mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/3] thermal: core: Cleanups after bind/unbind changes
@ 2024-08-22 19:23 Rafael J. Wysocki
  2024-08-22 19:24 ` [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-08-22 19:23 UTC (permalink / raw)
  To: Linux PM; +Cc: LKML, Daniel Lezcano, Lukasz Luba, Zhang Rui, Huisong Li

Hi Everyone,

These are cleanups that can be done on top of

https://lore.kernel.org/linux-pm/2205737.irdbgypaU6@rjwysocki.net/

as suggested during patch review.

Please refer to the individual patch changelogs for more information.

Thanks!




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions
  2024-08-22 19:23 [PATCH v1 0/3] thermal: core: Cleanups after bind/unbind changes Rafael J. Wysocki
@ 2024-08-22 19:24 ` Rafael J. Wysocki
  2024-08-23  7:15   ` Daniel Lezcano
  2024-08-22 19:26 ` [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip() Rafael J. Wysocki
  2024-08-22 19:27 ` [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance Rafael J. Wysocki
  2 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-08-22 19:24 UTC (permalink / raw)
  To: Linux PM; +Cc: LKML, Daniel Lezcano, Lukasz Luba, Zhang Rui, Huisong Li

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Rename thermal_zone_cdev_binding() and thermal_zone_cdev_unbinding()
to thermal_zone_cdev_bind() and thermal_zone_cdev_unbind(), respectively,
to make the naming more consistent with the rest of the code.

No functional impact.

Link: https://lore.kernel.org/linux-pm/19beefd9-d3f9-4d43-a45d-d241996de2d0@linaro.org/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_core.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -937,8 +937,8 @@ void print_bind_err_msg(struct thermal_z
 		cdev->type, thermal_zone_trip_id(tz, trip), ret);
 }
 
-static void thermal_zone_cdev_binding(struct thermal_zone_device *tz,
-				      struct thermal_cooling_device *cdev)
+static void thermal_zone_cdev_bind(struct thermal_zone_device *tz,
+				   struct thermal_cooling_device *cdev)
 {
 	struct thermal_trip_desc *td;
 
@@ -1063,7 +1063,7 @@ __thermal_cooling_device_register(struct
 
 	/* Update binding information for 'this' new cdev */
 	list_for_each_entry(pos, &thermal_tz_list, node)
-		thermal_zone_cdev_binding(pos, cdev);
+		thermal_zone_cdev_bind(pos, cdev);
 
 	list_for_each_entry(pos, &thermal_tz_list, node)
 		if (atomic_cmpxchg(&pos->need_update, 1, 0))
@@ -1264,8 +1264,8 @@ unlock_list:
 }
 EXPORT_SYMBOL_GPL(thermal_cooling_device_update);
 
-static void thermal_zone_cdev_unbinding(struct thermal_zone_device *tz,
-					struct thermal_cooling_device *cdev)
+static void thermal_zone_cdev_unbind(struct thermal_zone_device *tz,
+				     struct thermal_cooling_device *cdev)
 {
 	struct thermal_trip_desc *td;
 
@@ -1304,7 +1304,7 @@ void thermal_cooling_device_unregister(s
 
 	/* Unbind all thermal zones associated with 'this' cdev */
 	list_for_each_entry(tz, &thermal_tz_list, node)
-		thermal_zone_cdev_unbinding(tz, cdev);
+		thermal_zone_cdev_unbind(tz, cdev);
 
 	mutex_unlock(&thermal_list_lock);
 
@@ -1517,7 +1517,7 @@ thermal_zone_device_register_with_trips(
 
 	/* Bind cooling devices for this zone */
 	list_for_each_entry(cdev, &thermal_cdev_list, node)
-		thermal_zone_cdev_binding(tz, cdev);
+		thermal_zone_cdev_bind(tz, cdev);
 
 	mutex_unlock(&thermal_list_lock);
 
@@ -1611,7 +1611,7 @@ void thermal_zone_device_unregister(stru
 
 	/* Unbind all cdevs associated with 'this' thermal zone */
 	list_for_each_entry(cdev, &thermal_cdev_list, node)
-		thermal_zone_cdev_unbinding(tz, cdev);
+		thermal_zone_cdev_unbind(tz, cdev);
 
 	mutex_unlock(&thermal_list_lock);
 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip()
  2024-08-22 19:23 [PATCH v1 0/3] thermal: core: Cleanups after bind/unbind changes Rafael J. Wysocki
  2024-08-22 19:24 ` [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions Rafael J. Wysocki
@ 2024-08-22 19:26 ` Rafael J. Wysocki
  2024-08-23  7:16   ` Daniel Lezcano
  2024-08-22 19:27 ` [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance Rafael J. Wysocki
  2 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-08-22 19:26 UTC (permalink / raw)
  To: Linux PM; +Cc: LKML, Daniel Lezcano, Lukasz Luba, Zhang Rui, Huisong Li

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Since thermal_bind_cdev_to_trip() is only called by
thermal_zone_cdev_binding() under the thermal zone lock and the latter
is only called by thermal_zone_device_register_with_trips() and
__thermal_cooling_device_register(), under thermal_list_lock in both
cases, both lockdep_assert_held() assertions can be dropped from it.

Moreover, in both cases thermal_zone_cdev_binding() is called after
both tz and cdev have been added to the global lists of thermal zones
and cooling device, respectively, so the check against their list nodes
in thermal_bind_cdev_to_trip() is redundant and can be dropped either.

Link: https://lore.kernel.org/linux-pm/CAJZ5v0jwkc2PB+osSkkYF9vJ1Vpp3MFE=cGQmQ2Xzjb3yjVfJg@mail.gmail.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_core.c |    6 ------
 1 file changed, 6 deletions(-)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -775,12 +775,6 @@ static int thermal_bind_cdev_to_trip(str
 	bool upper_no_limit;
 	int result;
 
-	lockdep_assert_held(&thermal_list_lock);
-	lockdep_assert_held(&tz->lock);
-
-	if (list_empty(&tz->node) || list_empty(&cdev->node))
-		return -EINVAL;
-
 	/* lower default 0, upper default max_state */
 	if (cool_spec->lower == THERMAL_NO_LIMIT)
 		cool_spec->lower = 0;




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance
  2024-08-22 19:23 [PATCH v1 0/3] thermal: core: Cleanups after bind/unbind changes Rafael J. Wysocki
  2024-08-22 19:24 ` [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions Rafael J. Wysocki
  2024-08-22 19:26 ` [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip() Rafael J. Wysocki
@ 2024-08-22 19:27 ` Rafael J. Wysocki
  2024-08-23  7:17   ` Daniel Lezcano
  2 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-08-22 19:27 UTC (permalink / raw)
  To: Linux PM; +Cc: LKML, Daniel Lezcano, Lukasz Luba, Zhang Rui, Huisong Li

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

After recent changes, it is only used for printing a debug message
in __thermal_cdev_update() which arguably is not worth preserving.

Drop it along with the dev_dbg() statement using it.

Link: https://lore.kernel.org/linux-pm/4a8d8f5a-122d-4c26-b8d6-76a65e42216b@linaro.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_core.c    |    2 +-
 drivers/thermal/thermal_core.h    |    1 -
 drivers/thermal/thermal_helpers.c |    2 --
 3 files changed, 1 insertion(+), 4 deletions(-)

Index: linux-pm/drivers/thermal/thermal_core.h
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.h
+++ linux-pm/drivers/thermal/thermal_core.h
@@ -213,7 +213,6 @@ int get_tz_trend(struct thermal_zone_dev
 struct thermal_instance {
 	int id;
 	char name[THERMAL_NAME_LENGTH];
-	struct thermal_zone_device *tz;
 	struct thermal_cooling_device *cdev;
 	const struct thermal_trip *trip;
 	bool initialized;
Index: linux-pm/drivers/thermal/thermal_helpers.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_helpers.c
+++ linux-pm/drivers/thermal/thermal_helpers.c
@@ -181,8 +181,6 @@ void __thermal_cdev_update(struct therma
 
 	/* Make sure cdev enters the deepest cooling state */
 	list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) {
-		dev_dbg(&cdev->device, "zone%d->target=%lu\n",
-			instance->tz->id, instance->target);
 		if (instance->target == THERMAL_NO_TARGET)
 			continue;
 		if (instance->target > target)
Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -792,7 +792,7 @@ static int thermal_bind_cdev_to_trip(str
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-	dev->tz = tz;
+
 	dev->cdev = cdev;
 	dev->trip = trip;
 	dev->upper = cool_spec->upper;




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions
  2024-08-22 19:24 ` [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions Rafael J. Wysocki
@ 2024-08-23  7:15   ` Daniel Lezcano
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2024-08-23  7:15 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux PM; +Cc: LKML, Lukasz Luba, Zhang Rui, Huisong Li

On 22/08/2024 21:24, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Rename thermal_zone_cdev_binding() and thermal_zone_cdev_unbinding()
> to thermal_zone_cdev_bind() and thermal_zone_cdev_unbind(), respectively,
> to make the naming more consistent with the rest of the code.
> 
> No functional impact.
> 
> Link: https://lore.kernel.org/linux-pm/19beefd9-d3f9-4d43-a45d-d241996de2d0@linaro.org/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip()
  2024-08-22 19:26 ` [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip() Rafael J. Wysocki
@ 2024-08-23  7:16   ` Daniel Lezcano
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2024-08-23  7:16 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux PM; +Cc: LKML, Lukasz Luba, Zhang Rui, Huisong Li

On 22/08/2024 21:26, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Since thermal_bind_cdev_to_trip() is only called by
> thermal_zone_cdev_binding() under the thermal zone lock and the latter
> is only called by thermal_zone_device_register_with_trips() and
> __thermal_cooling_device_register(), under thermal_list_lock in both
> cases, both lockdep_assert_held() assertions can be dropped from it.
> 
> Moreover, in both cases thermal_zone_cdev_binding() is called after
> both tz and cdev have been added to the global lists of thermal zones
> and cooling device, respectively, so the check against their list nodes
> in thermal_bind_cdev_to_trip() is redundant and can be dropped either.
> 
> Link: https://lore.kernel.org/linux-pm/CAJZ5v0jwkc2PB+osSkkYF9vJ1Vpp3MFE=cGQmQ2Xzjb3yjVfJg@mail.gmail.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>



-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance
  2024-08-22 19:27 ` [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance Rafael J. Wysocki
@ 2024-08-23  7:17   ` Daniel Lezcano
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2024-08-23  7:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux PM; +Cc: LKML, Lukasz Luba, Zhang Rui, Huisong Li

On 22/08/2024 21:27, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> After recent changes, it is only used for printing a debug message
> in __thermal_cdev_update() which arguably is not worth preserving.
> 
> Drop it along with the dev_dbg() statement using it.
> 
> Link: https://lore.kernel.org/linux-pm/4a8d8f5a-122d-4c26-b8d6-76a65e42216b@linaro.org
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-23  7:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22 19:23 [PATCH v1 0/3] thermal: core: Cleanups after bind/unbind changes Rafael J. Wysocki
2024-08-22 19:24 ` [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions Rafael J. Wysocki
2024-08-23  7:15   ` Daniel Lezcano
2024-08-22 19:26 ` [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip() Rafael J. Wysocki
2024-08-23  7:16   ` Daniel Lezcano
2024-08-22 19:27 ` [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance Rafael J. Wysocki
2024-08-23  7:17   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®