mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices
@ 2025-11-14  3:23 Armin Wolf
  2025-11-14  3:23 ` [PATCH RFC 1/8] thermal: core: Allow setting the parent device of cooling devices Armin Wolf
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Armin Wolf @ 2025-11-14  3:23 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Lucas Stach, Russell King, Christian Gmeiner, David Airlie,
	Simona Vetter, Amit Daniel Kachhap, Viresh Kumar, Thierry Reding,
	Jonathan Hunter, Len Brown, Jonathan Corbet, Ido Schimmel,
	Petr Machata, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jeff Johnson, Miri Korenblit,
	Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Peter Kaestle, Hans de Goede, Ilpo Järvinen,
	Potnuri Bharat Teja, Sebastian Reichel, Miquel Raynal,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm
  Cc: linux-pm, linux-kernel, etnaviv, dri-devel, linux-tegra,
	linux-acpi, linux-doc, netdev, linux-wireless, ath10k, ath11k,
	linux-arm-kernel, linux-mediatek, platform-driver-x86, linux-pci,
	imx, linux-renesas-soc

Drivers registering thermal zone/cooling devices are currently unable
to tell the thermal core what parent device the new thermal zone/
cooling device should have, potentially causing issues with suspend
ordering and making it impossible for user space appications to
associate a given thermal zone device with its parent device.

This patch series aims to fix this issue by extending the functions
used to register thermal zone/cooling devices to also accept a parent
device pointer. The first six patches convert all functions used for
registering cooling devices, while the functions used for registering
thermal zone devices are converted by the remaining two patches.

I tested this series on various devices containing (among others):
- ACPI thermal zones
- ACPI processor devices
- PCIe cooling devices
- Intel Wifi card
- Intel powerclamp
- Intel TCC cooling

I also compile-tested the remaining affected drivers, however i would
still be happy if the relevant maintainers (especially those of the
mellanox ethernet switch driver) could take a quick glance at the
code and verify that i am using the correct device as the parent
device.

This work is also necessary for extending the ACPI thermal zone driver
to support the _TZD ACPI object in the future.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Armin Wolf (8):
      thermal: core: Allow setting the parent device of cooling devices
      thermal: core: Set parent device in thermal_of_cooling_device_register()
      ACPI: processor: Stop creating "device" sysfs link
      ACPI: fan: Stop creating "device" sysfs link
      ACPI: video: Stop creating "device" sysfs link
      thermal: core: Set parent device in thermal_cooling_device_register()
      ACPI: thermal: Stop creating "device" sysfs link
      thermal: core: Allow setting the parent device of thermal zone devices

 Documentation/driver-api/thermal/sysfs-api.rst     | 10 ++++-
 drivers/acpi/acpi_video.c                          |  9 +----
 drivers/acpi/fan_core.c                            | 16 ++------
 drivers/acpi/processor_thermal.c                   | 15 +------
 drivers/acpi/thermal.c                             | 33 ++++++---------
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c              |  4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c |  4 +-
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 47 +++++++++++-----------
 drivers/net/wireless/ath/ath10k/thermal.c          |  2 +-
 drivers/net/wireless/ath/ath11k/thermal.c          |  2 +-
 drivers/net/wireless/intel/iwlwifi/mld/thermal.c   |  6 +--
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c        | 12 +++---
 drivers/net/wireless/mediatek/mt76/mt7915/init.c   |  2 +-
 drivers/net/wireless/mediatek/mt76/mt7996/init.c   |  2 +-
 drivers/platform/x86/acerhdf.c                     |  4 +-
 drivers/power/supply/power_supply_core.c           |  4 +-
 drivers/thermal/armada_thermal.c                   |  2 +-
 drivers/thermal/cpufreq_cooling.c                  |  2 +-
 drivers/thermal/cpuidle_cooling.c                  |  2 +-
 drivers/thermal/da9062-thermal.c                   |  2 +-
 drivers/thermal/devfreq_cooling.c                  |  2 +-
 drivers/thermal/dove_thermal.c                     |  2 +-
 drivers/thermal/imx_thermal.c                      |  2 +-
 .../intel/int340x_thermal/int3400_thermal.c        |  2 +-
 .../intel/int340x_thermal/int3403_thermal.c        |  4 +-
 .../intel/int340x_thermal/int3406_thermal.c        |  2 +-
 .../intel/int340x_thermal/int340x_thermal_zone.c   | 13 +++---
 .../int340x_thermal/processor_thermal_device_pci.c |  7 ++--
 drivers/thermal/intel/intel_pch_thermal.c          |  2 +-
 drivers/thermal/intel/intel_powerclamp.c           |  2 +-
 drivers/thermal/intel/intel_quark_dts_thermal.c    |  2 +-
 drivers/thermal/intel/intel_soc_dts_iosf.c         |  2 +-
 drivers/thermal/intel/intel_tcc_cooling.c          |  2 +-
 drivers/thermal/intel/x86_pkg_temp_thermal.c       |  6 +--
 drivers/thermal/kirkwood_thermal.c                 |  2 +-
 drivers/thermal/pcie_cooling.c                     |  2 +-
 drivers/thermal/renesas/rcar_thermal.c             | 10 +++--
 drivers/thermal/spear_thermal.c                    |  2 +-
 drivers/thermal/tegra/soctherm.c                   |  5 +--
 drivers/thermal/testing/zone.c                     |  2 +-
 drivers/thermal/thermal_core.c                     | 23 +++++++----
 drivers/thermal/thermal_of.c                       |  9 +++--
 include/linux/thermal.h                            | 22 +++++-----
 43 files changed, 145 insertions(+), 162 deletions(-)
---
base-commit: 399fb812cd1532773e6aa985c0949859221341c4
change-id: 20251114-thermal-device-655d138824c6

Best regards,
-- 
Armin Wolf <W_Armin@gmx.de>


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

* [PATCH RFC 1/8] thermal: core: Allow setting the parent device of cooling devices
  2025-11-14  3:23 [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Armin Wolf
@ 2025-11-14  3:23 ` Armin Wolf
  2025-11-14  3:23 ` [PATCH RFC 2/8] thermal: core: Set parent device in thermal_of_cooling_device_register() Armin Wolf
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Armin Wolf @ 2025-11-14  3:23 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Lucas Stach, Russell King, Christian Gmeiner, David Airlie,
	Simona Vetter, Amit Daniel Kachhap, Viresh Kumar, Thierry Reding,
	Jonathan Hunter, Len Brown, Jonathan Corbet, Ido Schimmel,
	Petr Machata, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jeff Johnson, Miri Korenblit,
	Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Peter Kaestle, Hans de Goede, Ilpo Järvinen,
	Potnuri Bharat Teja, Sebastian Reichel, Miquel Raynal,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm
  Cc: linux-pm, linux-kernel, etnaviv, dri-devel, linux-tegra,
	linux-acpi, linux-doc, netdev, linux-wireless, ath10k, ath11k,
	linux-arm-kernel, linux-mediatek, platform-driver-x86, linux-pci,
	imx, linux-renesas-soc

Currently, cooling devices have no parent device, potentially causing
issues with suspend ordering and making it impossible for consumers
(thermal zones and userspace appications) to associate a given cooling
device with its parent device.

Extend __thermal_cooling_device_register() to also accept a parent
device pointer. For now only devm_thermal_of_cooling_device_register()
uses this, as the other wrapper functions need to be extended first.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/thermal/thermal_core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 17ca5c082643..c8b720194b44 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1040,6 +1040,7 @@ static void thermal_cooling_device_init_complete(struct thermal_cooling_device *
 
 /**
  * __thermal_cooling_device_register() - register a new thermal cooling device
+ * @parent:	parent device pointer.
  * @np:		a pointer to a device tree node.
  * @type:	the thermal cooling device type.
  * @devdata:	device private data.
@@ -1055,7 +1056,7 @@ static void thermal_cooling_device_init_complete(struct thermal_cooling_device *
  * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
  */
 static struct thermal_cooling_device *
-__thermal_cooling_device_register(struct device_node *np,
+__thermal_cooling_device_register(struct device *parent, struct device_node *np,
 				  const char *type, void *devdata,
 				  const struct thermal_cooling_device_ops *ops)
 {
@@ -1092,6 +1093,7 @@ __thermal_cooling_device_register(struct device_node *np,
 	cdev->ops = ops;
 	cdev->updated = false;
 	cdev->device.class = thermal_class;
+	cdev->device.parent = parent;
 	cdev->devdata = devdata;
 
 	ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
@@ -1158,7 +1160,7 @@ struct thermal_cooling_device *
 thermal_cooling_device_register(const char *type, void *devdata,
 				const struct thermal_cooling_device_ops *ops)
 {
-	return __thermal_cooling_device_register(NULL, type, devdata, ops);
+	return __thermal_cooling_device_register(NULL, NULL, type, devdata, ops);
 }
 EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
 
@@ -1182,7 +1184,7 @@ thermal_of_cooling_device_register(struct device_node *np,
 				   const char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *ops)
 {
-	return __thermal_cooling_device_register(np, type, devdata, ops);
+	return __thermal_cooling_device_register(NULL, np, type, devdata, ops);
 }
 EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
 
@@ -1222,7 +1224,7 @@ devm_thermal_of_cooling_device_register(struct device *dev,
 	if (!ptr)
 		return ERR_PTR(-ENOMEM);
 
-	tcd = __thermal_cooling_device_register(np, type, devdata, ops);
+	tcd = __thermal_cooling_device_register(dev, np, type, devdata, ops);
 	if (IS_ERR(tcd)) {
 		devres_free(ptr);
 		return tcd;

-- 
2.39.5


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

* [PATCH RFC 2/8] thermal: core: Set parent device in thermal_of_cooling_device_register()
  2025-11-14  3:23 [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Armin Wolf
  2025-11-14  3:23 ` [PATCH RFC 1/8] thermal: core: Allow setting the parent device of cooling devices Armin Wolf
@ 2025-11-14  3:23 ` Armin Wolf
  2025-11-14  3:23 ` [PATCH RFC 3/8] ACPI: processor: Stop creating "device" sysfs link Armin Wolf
  2025-11-14 12:13 ` [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Rafael J. Wysocki
  3 siblings, 0 replies; 7+ messages in thread
From: Armin Wolf @ 2025-11-14  3:23 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Lucas Stach, Russell King, Christian Gmeiner, David Airlie,
	Simona Vetter, Amit Daniel Kachhap, Viresh Kumar, Thierry Reding,
	Jonathan Hunter, Len Brown, Jonathan Corbet, Ido Schimmel,
	Petr Machata, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jeff Johnson, Miri Korenblit,
	Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Peter Kaestle, Hans de Goede, Ilpo Järvinen,
	Potnuri Bharat Teja, Sebastian Reichel, Miquel Raynal,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm
  Cc: linux-pm, linux-kernel, etnaviv, dri-devel, linux-tegra,
	linux-acpi, linux-doc, netdev, linux-wireless, ath10k, ath11k,
	linux-arm-kernel, linux-mediatek, platform-driver-x86, linux-pci,
	imx, linux-renesas-soc

Extend thermal_of_cooling_device_register() to allow users to specify
the parent device of the cooling device to be created.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 4 ++--
 drivers/thermal/cpufreq_cooling.c     | 2 +-
 drivers/thermal/cpuidle_cooling.c     | 2 +-
 drivers/thermal/devfreq_cooling.c     | 2 +-
 drivers/thermal/tegra/soctherm.c      | 5 ++---
 drivers/thermal/thermal_core.c        | 5 +++--
 include/linux/thermal.h               | 9 ++++-----
 7 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index cf0d9049bcf1..f2c98e46a1c6 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1778,8 +1778,8 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
 	int ret;
 
 	if (IS_ENABLED(CONFIG_DRM_ETNAVIV_THERMAL)) {
-		gpu->cooling = thermal_of_cooling_device_register(dev->of_node,
-				(char *)dev_name(dev), gpu, &cooling_ops);
+		gpu->cooling = thermal_of_cooling_device_register(dev, dev->of_node, dev_name(dev),
+								  gpu, &cooling_ops);
 		if (IS_ERR(gpu->cooling))
 			return PTR_ERR(gpu->cooling);
 	}
diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index 6b7ab1814c12..af9250c44da7 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c
@@ -593,7 +593,7 @@ __cpufreq_cooling_register(struct device_node *np,
 	if (!name)
 		goto remove_qos_req;
 
-	cdev = thermal_of_cooling_device_register(np, name, cpufreq_cdev,
+	cdev = thermal_of_cooling_device_register(dev, np, name, cpufreq_cdev,
 						  cooling_ops);
 	kfree(name);
 
diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index f678c1281862..520c89a36d90 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -207,7 +207,7 @@ static int __cpuidle_cooling_register(struct device_node *np,
 		goto out_unregister;
 	}
 
-	cdev = thermal_of_cooling_device_register(np, name, idle_cdev,
+	cdev = thermal_of_cooling_device_register(dev, np, name, idle_cdev,
 						  &cpuidle_cooling_ops);
 	if (IS_ERR(cdev)) {
 		ret = PTR_ERR(cdev);
diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 8fd7cf1932cd..d91695ed0f26 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -454,7 +454,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
 	if (!name)
 		goto remove_qos_req;
 
-	cdev = thermal_of_cooling_device_register(np, name, dfc, ops);
+	cdev = thermal_of_cooling_device_register(dev, np, name, dfc, ops);
 	kfree(name);
 
 	if (IS_ERR(cdev)) {
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 5d26b52beaba..4f43da123be4 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -1700,9 +1700,8 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
 			stc->init = true;
 		} else {
 
-			tcd = thermal_of_cooling_device_register(np_stcc,
-							 (char *)name, ts,
-							 &throt_cooling_ops);
+			tcd = thermal_of_cooling_device_register(dev, np_stcc, name, ts,
+								 &throt_cooling_ops);
 			if (IS_ERR_OR_NULL(tcd)) {
 				dev_err(dev,
 					"throttle-cfg: %s: failed to register cooling device\n",
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c8b720194b44..5d752e712cc0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1166,6 +1166,7 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
 
 /**
  * thermal_of_cooling_device_register() - register an OF thermal cooling device
+ * @parent:	parent device pointer.
  * @np:		a pointer to a device tree node.
  * @type:	the thermal cooling device type.
  * @devdata:	device private data.
@@ -1180,11 +1181,11 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
  * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
  */
 struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np,
+thermal_of_cooling_device_register(struct device *parent, struct device_node *np,
 				   const char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *ops)
 {
-	return __thermal_cooling_device_register(NULL, np, type, devdata, ops);
+	return __thermal_cooling_device_register(parent, np, type, devdata, ops);
 }
 EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
 
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 0b5ed6821080..fa53d12173ce 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -253,8 +253,8 @@ void thermal_zone_device_update(struct thermal_zone_device *,
 struct thermal_cooling_device *thermal_cooling_device_register(const char *,
 		void *, const struct thermal_cooling_device_ops *);
 struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
-				   const struct thermal_cooling_device_ops *);
+thermal_of_cooling_device_register(struct device *parent, struct device_node *np, const char *type,
+				   void *devdata, const struct thermal_cooling_device_ops *);
 struct thermal_cooling_device *
 devm_thermal_of_cooling_device_register(struct device *dev,
 				struct device_node *np,
@@ -302,9 +302,8 @@ thermal_cooling_device_register(const char *type, void *devdata,
 	const struct thermal_cooling_device_ops *ops)
 { return ERR_PTR(-ENODEV); }
 static inline struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np,
-	const char *type, void *devdata,
-	const struct thermal_cooling_device_ops *ops)
+thermal_of_cooling_device_register(struct device *parent, struct device_node *np, const char *type,
+				   void *devdata, const struct thermal_cooling_device_ops *ops)
 { return ERR_PTR(-ENODEV); }
 static inline struct thermal_cooling_device *
 devm_thermal_of_cooling_device_register(struct device *dev,

-- 
2.39.5


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

* [PATCH RFC 3/8] ACPI: processor: Stop creating "device" sysfs link
  2025-11-14  3:23 [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Armin Wolf
  2025-11-14  3:23 ` [PATCH RFC 1/8] thermal: core: Allow setting the parent device of cooling devices Armin Wolf
  2025-11-14  3:23 ` [PATCH RFC 2/8] thermal: core: Set parent device in thermal_of_cooling_device_register() Armin Wolf
@ 2025-11-14  3:23 ` Armin Wolf
  2025-11-14 12:13 ` [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Rafael J. Wysocki
  3 siblings, 0 replies; 7+ messages in thread
From: Armin Wolf @ 2025-11-14  3:23 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Lucas Stach, Russell King, Christian Gmeiner, David Airlie,
	Simona Vetter, Amit Daniel Kachhap, Viresh Kumar, Thierry Reding,
	Jonathan Hunter, Len Brown, Jonathan Corbet, Ido Schimmel,
	Petr Machata, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jeff Johnson, Miri Korenblit,
	Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Peter Kaestle, Hans de Goede, Ilpo Järvinen,
	Potnuri Bharat Teja, Sebastian Reichel, Miquel Raynal,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm
  Cc: linux-pm, linux-kernel, etnaviv, dri-devel, linux-tegra,
	linux-acpi, linux-doc, netdev, linux-wireless, ath10k, ath11k,
	linux-arm-kernel, linux-mediatek, platform-driver-x86, linux-pci,
	imx, linux-renesas-soc

The thermal core will soon automatically create sysfs links between
the cooling device and its parent device. Stop manually creating
the "device" sysfs link between the cooling device and the parent
device to avoid a name collision. The "thermal_cooling" sysfs link
however stays for backwards compatibility, as it does not suffer
from a name collision.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/acpi/processor_thermal.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index c7b1dc5687ec..1ff10321eac5 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -323,6 +323,7 @@ int acpi_processor_thermal_init(struct acpi_processor *pr,
 	dev_dbg(&device->dev, "registered as cooling_device%d\n",
 		pr->cdev->id);
 
+	/* For backwards compatibility */
 	result = sysfs_create_link(&device->dev.kobj,
 				   &pr->cdev->device.kobj,
 				   "thermal_cooling");
@@ -332,19 +333,8 @@ int acpi_processor_thermal_init(struct acpi_processor *pr,
 		goto err_thermal_unregister;
 	}
 
-	result = sysfs_create_link(&pr->cdev->device.kobj,
-				   &device->dev.kobj,
-				   "device");
-	if (result) {
-		dev_err(&pr->cdev->device,
-			"Failed to create sysfs link 'device'\n");
-		goto err_remove_sysfs_thermal;
-	}
-
 	return 0;
 
-err_remove_sysfs_thermal:
-	sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
 err_thermal_unregister:
 	thermal_cooling_device_unregister(pr->cdev);
 
@@ -356,7 +346,6 @@ void acpi_processor_thermal_exit(struct acpi_processor *pr,
 {
 	if (pr->cdev) {
 		sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
-		sysfs_remove_link(&pr->cdev->device.kobj, "device");
 		thermal_cooling_device_unregister(pr->cdev);
 		pr->cdev = NULL;
 	}

-- 
2.39.5


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

* Re: [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices
  2025-11-14  3:23 [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Armin Wolf
                   ` (2 preceding siblings ...)
  2025-11-14  3:23 ` [PATCH RFC 3/8] ACPI: processor: Stop creating "device" sysfs link Armin Wolf
@ 2025-11-14 12:13 ` Rafael J. Wysocki
  2025-11-14 20:10   ` Rafael J. Wysocki
  3 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-11-14 12:13 UTC (permalink / raw)
  To: Armin Wolf
  Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Lucas Stach, Russell King, Christian Gmeiner, David Airlie,
	Simona Vetter, Amit Daniel Kachhap, Viresh Kumar, Thierry Reding,
	Jonathan Hunter, Len Brown, Jonathan Corbet, Ido Schimmel,
	Petr Machata, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jeff Johnson, Miri Korenblit,
	Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Peter Kaestle, Hans de Goede, Ilpo Järvinen,
	Potnuri Bharat Teja, Sebastian Reichel, Miquel Raynal,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm, linux-pm, linux-kernel, etnaviv,
	dri-devel, linux-tegra, linux-acpi, linux-doc, netdev,
	linux-wireless, ath10k, ath11k, linux-arm-kernel, linux-mediatek,
	platform-driver-x86, linux-pci, imx, linux-renesas-soc

On Fri, Nov 14, 2025 at 4:24 AM Armin Wolf <W_Armin@gmx.de> wrote:
>
> Drivers registering thermal zone/cooling devices are currently unable
> to tell the thermal core what parent device the new thermal zone/
> cooling device should have, potentially causing issues with suspend
> ordering

Do you have any examples of this?

> and making it impossible for user space appications to
> associate a given thermal zone device with its parent device.
>
> This patch series aims to fix this issue by extending the functions
> used to register thermal zone/cooling devices to also accept a parent
> device pointer. The first six patches convert all functions used for
> registering cooling devices, while the functions used for registering
> thermal zone devices are converted by the remaining two patches.
>
> I tested this series on various devices containing (among others):
> - ACPI thermal zones
> - ACPI processor devices
> - PCIe cooling devices
> - Intel Wifi card
> - Intel powerclamp
> - Intel TCC cooling
>
> I also compile-tested the remaining affected drivers, however i would
> still be happy if the relevant maintainers (especially those of the
> mellanox ethernet switch driver) could take a quick glance at the
> code and verify that i am using the correct device as the parent
> device.
>
> This work is also necessary for extending the ACPI thermal zone driver
> to support the _TZD ACPI object in the future.

Can you please elaborate a bit here?

_TZD is a list of devices that belong to the given thermal zone, so
how is it connected to the thermal zone parent?

> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> Armin Wolf (8):
>       thermal: core: Allow setting the parent device of cooling devices
>       thermal: core: Set parent device in thermal_of_cooling_device_register()
>       ACPI: processor: Stop creating "device" sysfs link
>       ACPI: fan: Stop creating "device" sysfs link
>       ACPI: video: Stop creating "device" sysfs link
>       thermal: core: Set parent device in thermal_cooling_device_register()
>       ACPI: thermal: Stop creating "device" sysfs link
>       thermal: core: Allow setting the parent device of thermal zone devices

I can only see the first three patches in the series ATM as per

https://lore.kernel.org/linux-pm/20251114-thermal-device-v1-0-d8b442aae38b@gmx.de/T/#r605b23f2e27e751d8406e7949dad6f5b5b112067

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

* Re: [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices
  2025-11-14 12:13 ` [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Rafael J. Wysocki
@ 2025-11-14 20:10   ` Rafael J. Wysocki
  2025-11-15 20:07     ` Armin Wolf
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-11-14 20:10 UTC (permalink / raw)
  To: Armin Wolf
  Cc: Daniel Lezcano, Zhang Rui, Lukasz Luba, Hans de Goede,
	Ilpo Järvinen, linux-pm, linux-kernel, linux-acpi

CC list trimmed and I'd rather not use such an extensive one if I were you.

On Fri, Nov 14, 2025 at 1:13 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Fri, Nov 14, 2025 at 4:24 AM Armin Wolf <W_Armin@gmx.de> wrote:
> >
> > Drivers registering thermal zone/cooling devices are currently unable
> > to tell the thermal core what parent device the new thermal zone/
> > cooling device should have, potentially causing issues with suspend
> > ordering
>
> Do you have any examples of this?

Especially for thermal zones.

> > and making it impossible for user space appications to
> > associate a given thermal zone device with its parent device.
> >
> > This patch series aims to fix this issue by extending the functions
> > used to register thermal zone/cooling devices to also accept a parent
> > device pointer. The first six patches convert all functions used for
> > registering cooling devices, while the functions used for registering
> > thermal zone devices are converted by the remaining two patches.
> >
> > I tested this series on various devices containing (among others):
> > - ACPI thermal zones
> > - ACPI processor devices
> > - PCIe cooling devices
> > - Intel Wifi card
> > - Intel powerclamp
> > - Intel TCC cooling
> >
> > I also compile-tested the remaining affected drivers, however i would
> > still be happy if the relevant maintainers (especially those of the
> > mellanox ethernet switch driver) could take a quick glance at the
> > code and verify that i am using the correct device as the parent
> > device.
> >
> > This work is also necessary for extending the ACPI thermal zone driver
> > to support the _TZD ACPI object in the future.
>
> Can you please elaborate a bit here?
>
> _TZD is a list of devices that belong to the given thermal zone, so
> how is it connected to the thermal zone parent?
>
> > Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> > ---
> > Armin Wolf (8):
> >       thermal: core: Allow setting the parent device of cooling devices
> >       thermal: core: Set parent device in thermal_of_cooling_device_register()
> >       ACPI: processor: Stop creating "device" sysfs link
> >       ACPI: fan: Stop creating "device" sysfs link
> >       ACPI: video: Stop creating "device" sysfs link
> >       thermal: core: Set parent device in thermal_cooling_device_register()
> >       ACPI: thermal: Stop creating "device" sysfs link

This will kind of break things because user space may rely on those, may it not?

> >       thermal: core: Allow setting the parent device of thermal zone devices

For this last change, you need to define what it means for a thermal
zone to have a parent device.  In particular, in what way would a
thermal zone depend on its parent?

> I can only see the first three patches in the series ATM as per
>
> https://lore.kernel.org/linux-pm/20251114-thermal-device-v1-0-d8b442aae38b@gmx.de/T/#r605b23f2e27e751d8406e7949dad6f5b5b112067

That's probably because of the excessive CC list.

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

* Re: [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices
  2025-11-14 20:10   ` Rafael J. Wysocki
@ 2025-11-15 20:07     ` Armin Wolf
  0 siblings, 0 replies; 7+ messages in thread
From: Armin Wolf @ 2025-11-15 20:07 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Daniel Lezcano, Zhang Rui, Lukasz Luba, Hans de Goede,
	Ilpo Järvinen, linux-pm, linux-kernel, linux-acpi

Am 14.11.25 um 21:10 schrieb Rafael J. Wysocki:

> CC list trimmed and I'd rather not use such an extensive one if I were you.
>
> On Fri, Nov 14, 2025 at 1:13 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>> On Fri, Nov 14, 2025 at 4:24 AM Armin Wolf <W_Armin@gmx.de> wrote:
>>> Drivers registering thermal zone/cooling devices are currently unable
>>> to tell the thermal core what parent device the new thermal zone/
>>> cooling device should have, potentially causing issues with suspend
>>> ordering
>> Do you have any examples of this?
> Especially for thermal zones.

The device core suspends child devices before parent devices in order to avoid
child devices accessing an already suspended parent device. Since thermal zone
and cooling devices have no parent, they could potentially suspended after their
parent.

I said "potentially" because currently the thermal subsystem handles suspend/resume
using a PM notifier, something that prevents the above problem from occurring. We
should however eventually migrate to dev_pm_ops for that, so the device core needs
to know about parent-child dependencies between thermal zone/cooling devices and their
respective parent devices.

>>> and making it impossible for user space appications to
>>> associate a given thermal zone device with its parent device.
>>>
>>> This patch series aims to fix this issue by extending the functions
>>> used to register thermal zone/cooling devices to also accept a parent
>>> device pointer. The first six patches convert all functions used for
>>> registering cooling devices, while the functions used for registering
>>> thermal zone devices are converted by the remaining two patches.
>>>
>>> I tested this series on various devices containing (among others):
>>> - ACPI thermal zones
>>> - ACPI processor devices
>>> - PCIe cooling devices
>>> - Intel Wifi card
>>> - Intel powerclamp
>>> - Intel TCC cooling
>>>
>>> I also compile-tested the remaining affected drivers, however i would
>>> still be happy if the relevant maintainers (especially those of the
>>> mellanox ethernet switch driver) could take a quick glance at the
>>> code and verify that i am using the correct device as the parent
>>> device.
>>>
>>> This work is also necessary for extending the ACPI thermal zone driver
>>> to support the _TZD ACPI object in the future.
>> Can you please elaborate a bit here?
>>
>> _TZD is a list of devices that belong to the given thermal zone, so
>> how is it connected to the thermal zone parent?

The ACPI thermal zone driver currently matches cooling devices by accessing their
private drvdata and checking if it is a pointer to the correct ACPI device. This
work well enough for ACPI fans and processors, but will likely not work for other
cooling devices (like batteries). Such cooling devices are supposed to be listed
by the _TZD ACPI object, so we need a more generic matching algorithm before adding
support for said ACPI object.

I as thinking of modifying the ACPI thermal zone driver to instead use the ACPI handle
of the parent device for matching cooling devices. This would solve the problem described
above-

>>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
>>> ---
>>> Armin Wolf (8):
>>>        thermal: core: Allow setting the parent device of cooling devices
>>>        thermal: core: Set parent device in thermal_of_cooling_device_register()
>>>        ACPI: processor: Stop creating "device" sysfs link
>>>        ACPI: fan: Stop creating "device" sysfs link
>>>        ACPI: video: Stop creating "device" sysfs link
>>>        thermal: core: Set parent device in thermal_cooling_device_register()
>>>        ACPI: thermal: Stop creating "device" sysfs link
> This will kind of break things because user space may rely on those, may it not?

The driver core will create the "device" sysfs link for us as soon as we populate the
parent device pointer of the thermal zone/cooling device. So user space application
relying on those links should continue to work.

I even tested this on my devices.

>>>        thermal: core: Allow setting the parent device of thermal zone devices
> For this last change, you need to define what it means for a thermal
> zone to have a parent device.  In particular, in what way would a
> thermal zone depend on its parent?

1. A thermal zone should be suspended before the parent device is suspended. For this the
    device core needs to know the parent device of a given thermal zone device.
2. Users space applications can determine the physical device behind a given thermal zone device
    if we enable the device core to automatically create a "device" sysfs link.

Other than that all current thermal zone devices do not depend on the parent device pointer
(because currently it is always NULL).

>> I can only see the first three patches in the series ATM as per
>>
>> https://lore.kernel.org/linux-pm/20251114-thermal-device-v1-0-d8b442aae38b@gmx.de/T/#r605b23f2e27e751d8406e7949dad6f5b5b112067
> That's probably because of the excessive CC list.

Yes, that was my mistake. I will prune the CC list and resend the series. Do you think that i should include
all maintainers of the affected drivers or only the subsystem maintainers?

Thanks,
Armin Wolf


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

end of thread, other threads:[~2025-11-15 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-14  3:23 [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Armin Wolf
2025-11-14  3:23 ` [PATCH RFC 1/8] thermal: core: Allow setting the parent device of cooling devices Armin Wolf
2025-11-14  3:23 ` [PATCH RFC 2/8] thermal: core: Set parent device in thermal_of_cooling_device_register() Armin Wolf
2025-11-14  3:23 ` [PATCH RFC 3/8] ACPI: processor: Stop creating "device" sysfs link Armin Wolf
2025-11-14 12:13 ` [PATCH RFC 0/8] thermal: core: Allow setting the parent device of thermal zone/cooling devices Rafael J. Wysocki
2025-11-14 20:10   ` Rafael J. Wysocki
2025-11-15 20:07     ` Armin Wolf

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®