ACPI: DPTF: Move INT340X enumeration from DPTF core to thermal drivers
Subsystems (6)
v2 cover ACPI: DPTF: Move INT340X enumeration from DPTF core to thermal drivers
The Intel Dynamic Platform and Thermal Framework (DPTF) relies on the INT340X ACPI device objects. The temperature information and cooling ability are exposed to the userspace via those objects.
Since kernel v3.17 the ACPI bus scan handler is introduced to prevent enumeration of INT340X ACPI device objects on the platform bus unless related thermal drivers are enabled. However, using the IS_ENABLED() macro in the ACPI scan handler forces the kernel to be recompiled when thermal drivers are enabled or disabled, which is a significant limitation of its modularity. The IS_ENABLED() macro is particularly problematic for the Android Generic Kernel Image (GKI) project which uses unified core kernel while SoC/board support is moved to loadable vendor modules.
This patch set moves enumeration of INT340X ACPI device objects on the platform bus from DPTF core to thermal drivers. It starts with some code cleanup and reorganization to eventually remove IS_ENABLED() macro from the ACPI bus scan handler. Brief list of changes is listed below:
1) Remove SOC DTS thermal driver case from the ACPI scan handler since its dependency on INT340X driver is unrelated to DPTF
2) Move all INT340X ACPI device ids to the common header and update the DPTF core and thermal drivers accordingly
3) Move dynamic enumeration of ACPI device objects on the platform bus from the intel-hid and intel-vbtn drivers to the ACPI platform core
4) Move enumeration of INT340X ACPI device objects on the platform bus from DPTF core to thermal drivers using ACPI platform core methods
Slawomir Rosek (6):
ACPI: DPTF: Ignore SoC DTS thermal while scanning
ACPI: DPTF: Move INT340X device IDs to header
ACPI: DPTF: Move PCH FIVR device IDs to header
ACPI: DPTF: Remove not supported INT340X IDs
ACPI: platform: Add macro for acpi platform driver
ACPI: DPTF: Move INT340X enumeration to modules
drivers/acpi/acpi_platform.c | 27 +++++++ drivers/acpi/dptf/dptf_pch_fivr.c | 10 +-- drivers/acpi/dptf/dptf_power.c | 20 +---- drivers/acpi/dptf/int340x_thermal.c | 76 ++++--------------- drivers/acpi/fan.h | 10 +-- drivers/acpi/fan_core.c | 2 +- drivers/acpi/int340x_thermal.h | 76 +++++++++++++++++++ drivers/platform/x86/intel/hid.c | 33 +------- drivers/platform/x86/intel/vbtn.c | 30 +------- drivers/thermal/intel/Kconfig | 1 + .../intel/int340x_thermal/int3400_thermal.c | 12 +-- .../intel/int340x_thermal/int3401_thermal.c | 5 +- .../intel/int340x_thermal/int3402_thermal.c | 5 +- .../intel/int340x_thermal/int3403_thermal.c | 12 +-- .../intel/int340x_thermal/int3406_thermal.c | 5 +- include/linux/platform_device.h | 17 +++++ 16 files changed, 163 insertions(+), 178 deletions(-) create mode 100644 drivers/acpi/int340x_thermal.h
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH v2 1/6 ACPI: DPTF: Ignore SoC DTS thermal while scanning
The Intel SoC DTS thermal driver on Baytrail platform uses IRQ 86 for critical overheating notification. The IRQ 86 is described in the _CRS control method of INT3401 device, thus Intel SoC DTS thermal driver requires INT3401 device to be enumerated.
Since dependency on INT3401 device is unrelated to DPTF the IS_ENABLE() macro is removed from ACPI DPTF INT340X scan handler, instead Kconfig is updated to ensure proper enumeration of INT3401 device.
--- drivers/acpi/dptf/int340x_thermal.c | 7 +------ drivers/thermal/intel/Kconfig | 1 + 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +1 -6
@@ -11,10 +11,9 @@#include "../internal.h" -#define INT3401_DEVICE 0X01static const struct acpi_device_id int340x_thermal_device_ids[] = { {"INT3400" }, - {"INT3401" ,INT3401_DEVICE }, + {"INT3401" }, {"INT3402" }, {"INT3403" }, {"INT3404" },
@@ -76,10 +75,6 @@ static int int340x_thermal_handler_attach(struct acpi_device *adev, {if (IS_ENABLED (CONFIG_INT340X_THERMAL ))acpi_create_platform_device (adev,NULL ); -/* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ -else if (IS_ENABLED (CONFIG_INTEL_SOC_DTS_THERMAL ) && - id->driver_data ==INT3401_DEVICE ) -acpi_create_platform_device (adev,NULL );return 1 ; }
drivers/thermal/intel/Kconfig +1 -0
@@ -45,6 +45,7 @@ config INTEL_SOC_DTS_IOSF_CORE config INTEL_SOC_DTS_THERMAL tristate "Intel SoCs DTS thermal driver" depends on X86 && PCI && ACPI + select INT340X_THERMAL select INTEL_SOC_DTS_IOSF_CORE help Enable this to register Intel SoCs (e.g. Bay Trail) platform digital
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
kernel test robot
build botRe: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
kernel test robot noticed the following build errors:
Hi Slawomir,
kernel test robot noticed the following build errors:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/bleeding-edge rafael-pm/thermal driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.17-rc6 next-20250917] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Slawomir-Rosek/ACPI-DPTF-Ignore-SoC-DTS-thermal-while-scanning/20250917-201033 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20250917120719.2390847-2-srosek%40google.com patch subject: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning config: i386-randconfig-003-20250918 (https://download.01.org/0day-ci/archive/20250918/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250918/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/thermal/intel/int340x_thermal/platform_temperature_control.c: In function 'ptc_mmio_show':
>> drivers/thermal/intel/int340x_thermal/platform_temperature_control.c:110:19: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Wimplicit-function-declaration]
110 | reg_val = readq((void __iomem *) (proc_priv->mmio_base + data->offset));
| ^~~~~
| readl
drivers/thermal/intel/int340x_thermal/platform_temperature_control.c: In function 'ptc_mmio_write':
>> drivers/thermal/intel/int340x_thermal/platform_temperature_control.c:142:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Wimplicit-function-declaration]
142 | writeq(reg_val, (void __iomem *) (proc_priv->mmio_base + offset));
| ^~~~~~
| writel
--
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c: In function 'int340x_thermal_read_trips':
>> drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:72:15: error: implicit declaration of function 'thermal_acpi_critical_trip_temp'; did you mean 'thermal_zone_set_trip_temp'? [-Wimplicit-function-declaration]
72 | ret = thermal_acpi_critical_trip_temp(zone_adev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| thermal_zone_set_trip_temp
>> drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:79:15: error: implicit declaration of function 'thermal_acpi_hot_trip_temp'; did you mean 'thermal_zone_set_trip_temp'? [-Wimplicit-function-declaration]
79 | ret = thermal_acpi_hot_trip_temp(zone_adev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| thermal_zone_set_trip_temp
>> drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:86:15: error: implicit declaration of function 'thermal_acpi_passive_trip_temp'; did you mean 'thermal_zone_set_trip_temp'? [-Wimplicit-function-declaration]
86 | ret = thermal_acpi_passive_trip_temp(zone_adev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| thermal_zone_set_trip_temp
>> drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c:94:23: error: implicit declaration of function 'thermal_acpi_active_trip_temp'; did you mean 'thermal_zone_set_trip_temp'? [-Wimplicit-function-declaration]
94 | ret = thermal_acpi_active_trip_temp(zone_adev, i,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| thermal_zone_set_trip_temp
--
drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c: In function 'proc_thermal_read_power_floor_status':
>> drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c:42:18: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Wimplicit-function-declaration]
42 | status = readq(proc_priv->mmio_base + SOC_WT_RES_INT_STATUS_OFFSET);
| ^~~~~
| readl
In file included from include/linux/bits.h:5,
from include/linux/ratelimit_types.h:5,
from include/linux/printk.h:9,
from include/asm-generic/bug.h:22,
from arch/x86/include/asm/bug.h:103,
from include/linux/bug.h:5,
from include/linux/fortify-string.h:6,
from include/linux/string.h:382,
from include/linux/uuid.h:11,
from include/linux/mod_devicetable.h:14,
from include/linux/pci.h:27,
from drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c:29:
include/vdso/bits.h:7:40: warning: left shift count >= width of type [-Wshift-count-overflow]
7 | #define BIT(nr) (UL(1) << (nr))
| ^~
drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c:32:41: note: in expansion of macro 'BIT'
32 | #define SOC_POWER_FLOOR_STATUS BIT(39)
| ^~~
drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c:43:26: note: in expansion of macro 'SOC_POWER_FLOOR_STATUS'
43 | return (status & SOC_POWER_FLOOR_STATUS) >> SOC_POWER_FLOOR_SHIFT;
| ^~~~~~~~~~~~~~~~~~~~~~
--
drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c: In function 'workload_type_index_show':
>> drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c:69:18: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Wimplicit-function-declaration]
69 | status = readq(proc_priv->mmio_base + SOC_WT_RES_INT_STATUS_OFFSET);
| ^~~~~
| readl
--
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c: In function 'proc_thermal_clear_soc_int_status':
>> drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c:145:18: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Wimplicit-function-declaration]
145 | status = readq(proc_priv->mmio_base + SOC_WT_RES_INT_STATUS_OFFSET);
| ^~~~~
| readl
>> drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c:146:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Wimplicit-function-declaration]
146 | writeq(status & ~SOC_WT_RES_INT_STATUS_MASK,
| ^~~~~~
| writel
--
drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c: In function 'read_soc_slider':
>> drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c:166:16: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Wimplicit-function-declaration]
166 | return readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
| ^~~~~
| readl
drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c: In function 'write_soc_slider':
>> drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c:171:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Wimplicit-function-declaration]
171 | writeq(val, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
| ^~~~~~
| writelKconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for INT340X_THERMAL
Depends on [n]: THERMAL [=y] && (X86 [=y] || X86_INTEL_QUARK [=n] || COMPILE_TEST [=n]) && X86_64 [=n] && ACPI [=y] && PCI [=y] && NET [=y] Selected by [y]:
- INTEL_SOC_DTS_THERMAL [=y] && THERMAL [=y] && (X86 [=y] || X86_INTEL_QUARK [=n] || COMPILE_TEST [=n]) && X86 [=y] && PCI [=y] && ACPI [=y]
vim +110 drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
9befea30133ca4 Srinivas Pandruvada 2025-04-28 90
9befea30133ca4 Srinivas Pandruvada 2025-04-28 91 static ssize_t ptc_mmio_show(struct ptc_data *data, struct device *dev,
9befea30133ca4 Srinivas Pandruvada 2025-04-28 92 struct device_attribute *attr, char *buf)
9befea30133ca4 Srinivas Pandruvada 2025-04-28 93 {
9befea30133ca4 Srinivas Pandruvada 2025-04-28 94 struct pci_dev *pdev = to_pci_dev(dev);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 95 struct proc_thermal_device *proc_priv;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 96 const struct mmio_reg *mmio_regs;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 97 int ret, units;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 98 u64 reg_val;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 99
9befea30133ca4 Srinivas Pandruvada 2025-04-28 100 proc_priv = pci_get_drvdata(pdev);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 101 mmio_regs = ptc_mmio_regs;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 102 ret = match_string(ptc_strings, -1, attr->attr.name);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 103 if (ret < 0)
9befea30133ca4 Srinivas Pandruvada 2025-04-28 104 return ret;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 105
9befea30133ca4 Srinivas Pandruvada 2025-04-28 106 units = mmio_regs[ret].units;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 107
9befea30133ca4 Srinivas Pandruvada 2025-04-28 108 guard(mutex)(&ptc_lock);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 109
9befea30133ca4 Srinivas Pandruvada 2025-04-28 @110 reg_val = readq((void __iomem *) (proc_priv->mmio_base + data->offset));
9befea30133ca4 Srinivas Pandruvada 2025-04-28 111 ret = (reg_val >> mmio_regs[ret].shift) & mmio_regs[ret].mask;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 112 if (units)
9befea30133ca4 Srinivas Pandruvada 2025-04-28 113 ret *= units;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 114
9befea30133ca4 Srinivas Pandruvada 2025-04-28 115 return sysfs_emit(buf, "%d\n", ret);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 116 }
9befea30133ca4 Srinivas Pandruvada 2025-04-28 117
9befea30133ca4 Srinivas Pandruvada 2025-04-28 118 #define PTC_SHOW(suffix)\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 119 static ssize_t suffix##_show(struct device *dev,\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 120 struct device_attribute *attr,\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 121 char *buf)\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 122 {\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 123 struct ptc_data *data = container_of(attr, struct ptc_data, suffix##_attr);\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 124 return ptc_mmio_show(data, dev, attr, buf);\
9befea30133ca4 Srinivas Pandruvada 2025-04-28 125 }
9befea30133ca4 Srinivas Pandruvada 2025-04-28 126
9befea30133ca4 Srinivas Pandruvada 2025-04-28 127 static void ptc_mmio_write(struct pci_dev *pdev, u32 offset, int index, u32 value)
9befea30133ca4 Srinivas Pandruvada 2025-04-28 128 {
9befea30133ca4 Srinivas Pandruvada 2025-04-28 129 struct proc_thermal_device *proc_priv;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 130 u64 mask, reg_val;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 131
9befea30133ca4 Srinivas Pandruvada 2025-04-28 132 proc_priv = pci_get_drvdata(pdev);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 133
9befea30133ca4 Srinivas Pandruvada 2025-04-28 134 mask = GENMASK_ULL(ptc_mmio_regs[index].shift + ptc_mmio_regs[index].bits - 1,
9befea30133ca4 Srinivas Pandruvada 2025-04-28 135 ptc_mmio_regs[index].shift);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 136
9befea30133ca4 Srinivas Pandruvada 2025-04-28 137 guard(mutex)(&ptc_lock);
9befea30133ca4 Srinivas Pandruvada 2025-04-28 138
9befea30133ca4 Srinivas Pandruvada 2025-04-28 139 reg_val = readq((void __iomem *) (proc_priv->mmio_base + offset));
9befea30133ca4 Srinivas Pandruvada 2025-04-28 140 reg_val &= ~mask;
9befea30133ca4 Srinivas Pandruvada 2025-04-28 141 reg_val |= (value << ptc_mmio_regs[index].shift);9befea30133ca4 Srinivas Pandruvada 2025-04-28 @142 writeq(reg_val, (void __iomem *) (proc_priv->mmio_base + offset));9befea30133ca4 Srinivas Pandruvada 2025-04-28 143 } 9befea30133ca4 Srinivas Pandruvada 2025-04-28 144
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
In reply to Slawomir RosekHi Rafael
Quoted 49 lines · Slawomir Rosek
The Intel SoC DTS thermal driver on Baytrail platform uses IRQ 86 for critical overheating notification. The IRQ 86 is described in the
_CRScontrol method of INT3401 device, thus Intel SoC DTS thermal driver requires INT3401 device to be enumerated.Since dependency on INT3401 device is unrelated to DPTF the
IS_ENABLE()macro is removed from ACPI DPTF INT340X scan handler, insteadKconfigis updated to ensure proper enumeration of INT3401 device.Fixes 014d9d5d0cc1 ("ACPI/int340x_thermal: enumerate INT3401 for Intel SoC DTS thermal driver")Signed-off-by Slawomir Rosek <[email protected]>--- drivers/acpi/dptf/int340x_thermal.c | 7 +------ drivers/thermal/intel/Kconfig | 1 + 2 files changed, 2 insertions(+), 6 deletions(-)drivers/acpi/dptf/int340x_thermal.c +1
-6@@ -11,10 +11,9 @@#include "../internal.h" -#define INT3401_DEVICE 0X01static const struct acpi_device_id int340x_thermal_device_ids[] = { {"INT3400" }, - {"INT3401" ,INT3401_DEVICE }, + {"INT3401" }, {"INT3402" }, {"INT3403" }, {"INT3404" },@@ -76,10 +75,6 @@ static int int340x_thermal_handler_attach(struct acpi_device *adev, {if (IS_ENABLED (CONFIG_INT340X_THERMAL ))acpi_create_platform_device (adev,NULL ); -/* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ -else if (IS_ENABLED (CONFIG_INTEL_SOC_DTS_THERMAL ) && - id->driver_data ==INT3401_DEVICE ) -acpi_create_platform_device (adev,NULL );return 1 ; }drivers/thermal/intel/Kconfig +0
-0
drivers/thermal/intel/Kconfig config INTEL_SOC_DTS_IOSF_CORE · line 48
Quoted 4 lines
drivers/thermal/intel/Kconfig +1
-0@@ -45,6 +45,7 @@ config INTEL_SOC_DTS_IOSF_CORE config INTEL_SOC_DTS_THERMAL tristate "Intel SoCs DTS thermal driver" depends on X86 && PCI && ACPI + select INT340X_THERMAL
This selection does not meet INT340X_THERMAL requirements so kernel tests are failing for randomly generated i386 config
https://lore.kernel.org/all/[email protected]/
I am considering two options:
1) Align SoC DTS thermal driver dependencies to match INT340X. Currently X86_64 and NET are missing. This is quite simple fix but after that enabling a SoC DTS thermal won't be possible for i386. From the other hand the driver requires ATOM Silvermont
https://elixir.bootlin.com/linux/v6.17-rc7/source/drivers/thermal/intel/intel_soc_dts_thermal.c#L39
which is a 64bit architecture, so I am not sure if support for i386 is really required.
2) Don't select INT340X driver (the original patch does not) and use acpi_walk_namespace to enumerate INT3401 on the platform bus just before intel_soc_dts_iosf_init is called
https://elixir.bootlin.com/linux/v6.17-rc7/source/drivers/thermal/intel/intel_soc_dts_thermal.c#L54
The code would be cleaned up later with next version of patch 5/6 and direct call to acpi_walk_namespace would be replaced with dedicated function exported by acpi platform core. Eventually, after the the last patch, there would be two drivers enumerating INT3401 which shouldn't be an issue since the acpi_walk_namespace uses global mutex while traversing the acpi device tree
Please let me know your comment so I can prepare the next version.
Thanks, Regards,
Slawek
Quoted 6 lines
drivers/thermal/intel/Kconfig +0
-1select INTEL_SOC_DTS_IOSF_CORE help Enable this to register Intel SoCs (e.g. Bay Trail) platform digital --2.51.0.384.g4c02a37b29-goog
Rafael J. Wysocki
maintainerRe: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
Hi,
Sorry for the delay.
Quoted 63 lines · Sławomir Rosek
Hi Rafael
Quoted 49 lines · Slawomir Rosek
The Intel SoC DTS thermal driver on Baytrail platform uses IRQ 86 for critical overheating notification. The IRQ 86 is described in the
_CRScontrol method of INT3401 device, thus Intel SoC DTS thermal driver requires INT3401 device to be enumerated.Since dependency on INT3401 device is unrelated to DPTF the
IS_ENABLE()macro is removed from ACPI DPTF INT340X scan handler, insteadKconfigis updated to ensure proper enumeration of INT3401 device.Fixes 014d9d5d0cc1 ("ACPI/int340x_thermal: enumerate INT3401 for Intel SoC DTS thermal driver")Signed-off-by Slawomir Rosek <[email protected]>--- drivers/acpi/dptf/int340x_thermal.c | 7 +------ drivers/thermal/intel/Kconfig | 1 + 2 files changed, 2 insertions(+), 6 deletions(-)drivers/acpi/dptf/int340x_thermal.c +1
-6@@ -11,10 +11,9 @@#include "../internal.h" -#define INT3401_DEVICE 0X01static const struct acpi_device_id int340x_thermal_device_ids[] = { {"INT3400" }, - {"INT3401" ,INT3401_DEVICE }, + {"INT3401" }, {"INT3402" }, {"INT3403" }, {"INT3404" },@@ -76,10 +75,6 @@ static int int340x_thermal_handler_attach(struct acpi_device *adev, {if (IS_ENABLED (CONFIG_INT340X_THERMAL ))acpi_create_platform_device (adev,NULL ); -/* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ -else if (IS_ENABLED (CONFIG_INTEL_SOC_DTS_THERMAL ) && - id->driver_data ==INT3401_DEVICE ) -acpi_create_platform_device (adev,NULL );return 1 ; }drivers/thermal/intel/Kconfig +0
-0drivers/thermal/intel/Kconfig config INTEL_SOC_DTS_IOSF_CORE · line 48
Quoted 4 lines
drivers/thermal/intel/Kconfig +1
-0@@ -45,6 +45,7 @@ config INTEL_SOC_DTS_IOSF_CORE config INTEL_SOC_DTS_THERMAL tristate "Intel SoCs DTS thermal driver" depends on X86 && PCI && ACPI + select INT340X_THERMALThis selection does not meet
INT340X_THERMALrequirements so kernel tests are failing for randomly generated i386 config
https://lore.kernel.org/all/[email protected]/
I am considering two options:
Quoted 7 lines
1) Align SoC DTS thermal driver dependencies to match INT340X. Currently
X86_64and NET are missing. This is quite simple fix but after that enabling a SoC DTS thermal won't be possible for i386. From the other hand the driver requires ATOM Silvermont
https://elixir.bootlin.com/linux/v6.17-rc7/source/drivers/thermal/intel/intel_soc_dts_thermal.c#L39
which is a 64bit architecture, so I am not sure if support for i386 is really required.
I wouldn't worry about this. I'd just make SoC DTS thermal explicitly depend on X86_64.
Quoted 4 lines
2) Don't select INT340X driver (the original patch does not) and use
acpi_walk_namespaceto enumerate INT3401 on the platform bus just beforeintel_soc_dts_iosf_initis called
https://elixir.bootlin.com/linux/v6.17-rc7/source/drivers/thermal/intel/intel_soc_dts_thermal.c#L54
I'm not a big fan of using acpi_walk_namespace() for such things.
Those namespace walks usually end up being quite expensive.
Quoted 6 lines
The code would be cleaned up later with next version of patch 5/6 and direct call to
acpi_walk_namespacewould be replaced with dedicated function exported by acpi platform core. Eventually, after the the last patch, there would be two drivers enumerating INT3401 which shouldn't be an issue since theacpi_walk_namespaceuses global mutex while traversing the acpi device tree
Well, this doesn't sound really straightforward.
Quoted 1 line
Please let me know your comment so I can prepare the next version.
I'd go for option 1).
Thanks!
PATCH v2 2/6 ACPI: DPTF: Move INT340X device IDs to header
In reply to Slawomir RosekThe ACPI INT340X device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.
--- drivers/acpi/dptf/dptf_power.c | 18 +---- drivers/acpi/dptf/int340x_thermal.c | 51 +++----------- drivers/acpi/fan.h | 10 +-- drivers/acpi/int340x_thermal.h | 68 +++++++++++++++++++ .../intel/int340x_thermal/int3400_thermal.c | 10 +-- .../intel/int340x_thermal/int3401_thermal.c | 3 +- .../intel/int340x_thermal/int3402_thermal.c | 3 +- .../intel/int340x_thermal/int3403_thermal.c | 10 +-- .../intel/int340x_thermal/int3406_thermal.c | 3 +- 9 files changed, 90 insertions(+), 86 deletions(-) create mode 100644 drivers/acpi/int340x_thermal.h
drivers/acpi/dptf/dptf_power.c +2 -16
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/acpi.h> #include <linux/platform_device.h> +#include "../int340x_thermal.h" /* * Presentation of attributes which are defined for INT3407 and INT3532.
@@ -224,22 +225,7 @@ static void dptf_power_remove(struct platform_device *pdev) }static const struct acpi_device_id int3407_device_ids[] = { - {"INT3407" ,0 }, - {"INT3532" ,0 }, - {"INTC1047" ,0 }, - {"INTC1050" ,0 }, - {"INTC1060" ,0 }, - {"INTC1061" ,0 }, - {"INTC1065" ,0 }, - {"INTC1066" ,0 }, - {"INTC106C" ,0 }, - {"INTC106D" ,0 }, - {"INTC10A4" ,0 }, - {"INTC10A5" ,0 }, - {"INTC10D8" ,0 }, - {"INTC10D9" ,0 }, - {"INTC1100" ,0 }, - {"INTC1101" ,0 }, +ACPI_INT3407_DEVICE_IDS , {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, int3407_device_ids);
drivers/acpi/dptf/int340x_thermal.c +8 -43
71 lines not on this page · raw message
drivers/acpi/fan.h +2 -8
@@ -11,16 +11,10 @@#define _ACPI_FAN_H_#include <linux/kconfig.h> +#include "int340x_thermal.h" #define ACPI_FAN_DEVICE_IDS \ - {"INT3404", },/* Fan */ \ - {"INTC1044", }, /* Fan for Tiger Lake generation */ \ - {"INTC1048", }, /* Fan for Alder Lake generation */ \ - {"INTC1063", }, /* Fan for Meteor Lake generation */ \ - {"INTC106A", }, /* Fan for Lunar Lake generation */ \ - {"INTC10A2", }, /* Fan for Raptor Lake generation */ \ - {"INTC10D6", }, /* Fan for Panther Lake generation */ \ - {"INTC10FE", }, /* Fan for Wildcat Lake generation */ \ + ACPI_INT3404_DEVICE_IDS, \ {"PNP0C0B", }/* Generic ACPI fan */ #define ACPI_FPS_NAME_LEN 20
drivers/acpi/int340x_thermal.h new file +68 -0
68 lines not on this page · raw message
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +2 -8
@@ -11,6 +11,7 @@#include <linux/acpi.h> #include <linux/thermal.h> #include "acpi_thermal_rel.h" +#include "../../../../drivers/acpi/int340x_thermal.h" #define INT3400_THERMAL_TABLE_CHANGED 0x83#define INT3400_ODVP_CHANGED 0x88
@@ -683,14 +684,7 @@ static void int3400_thermal_remove(struct platform_device *pdev) }static const struct acpi_device_id int3400_thermal_match[] = { - {"INT3400" ,0 }, - {"INTC1040" ,0 }, - {"INTC1041" ,0 }, - {"INTC1042" ,0 }, - {"INTC1068" ,0 }, - {"INTC10A0" ,0 }, - {"INTC10D4" ,0 }, - {"INTC10FC" ,0 }, +ACPI_INT3400_DEVICE_IDS , {} };
drivers/thermal/intel/int340x_thermal/int3401_thermal.c +2 -1
@@ -11,9 +11,10 @@#include "int340x_thermal_zone.h" #include "processor_thermal_device.h" +#include "../../../../drivers/acpi/int340x_thermal.h" static const struct acpi_device_id int3401_device_ids[] = { - {"INT3401" ,0 }, +ACPI_INT3401_DEVICE_IDS , {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, int3401_device_ids);
drivers/thermal/intel/int340x_thermal/int3402_thermal.c +2 -1
@@ -11,6 +11,7 @@#include <linux/acpi.h> #include <linux/thermal.h> #include "int340x_thermal_zone.h" +#include "../../../../drivers/acpi/int340x_thermal.h" #define INT3402_PERF_CHANGED_EVENT 0x80#define INT3402_THERMAL_EVENT 0x90
@@ -84,7 +85,7 @@ static void int3402_thermal_remove(struct platform_device *pdev) }static const struct acpi_device_id int3402_thermal_match[] = { - {"INT3402" ,0 }, +ACPI_INT3402_DEVICE_IDS , {} };
drivers/thermal/intel/int340x_thermal/int3403_thermal.c +2 -8
@@ -12,6 +12,7 @@#include <linux/thermal.h> #include <linux/platform_device.h> #include "int340x_thermal_zone.h" +#include "../../../../drivers/acpi/int340x_thermal.h" #define INT3403_TYPE_SENSOR 0x03#define INT3403_TYPE_CHARGER 0x0B
@@ -269,14 +270,7 @@ static void int3403_remove(struct platform_device *pdev) }static const struct acpi_device_id int3403_device_ids[] = { - {"INT3403" ,0 }, - {"INTC1043" ,0 }, - {"INTC1046" ,0 }, - {"INTC1062" ,0 }, - {"INTC1069" ,0 }, - {"INTC10A1" ,0 }, - {"INTC10D5" ,0 }, - {"INTC10FD" ,0 }, +ACPI_INT3403_DEVICE_IDS , {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, int3403_device_ids);
drivers/thermal/intel/int340x_thermal/int3406_thermal.c +2 -1
@@ -12,6 +12,7 @@#include <linux/backlight.h> #include <linux/thermal.h> #include <acpi/video.h> +#include "../../../../drivers/acpi/int340x_thermal.h" #define INT3406_BRIGHTNESS_LIMITS_CHANGED 0x80
@@ -187,7 +188,7 @@ static void int3406_thermal_remove(struct platform_device *pdev) }static const struct acpi_device_id int3406_thermal_match[] = { - {"INT3406" ,0 }, +ACPI_INT3406_DEVICE_IDS , {} };
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH v2 3/6 ACPI: DPTF: Move PCH FIVR device IDs to header
In reply to Slawomir RosekThe ACPI PCH FIVR device IDs are shared between the DPTF core and PCH FIVR driver, thus they are moved to the common header.
--- drivers/acpi/dptf/dptf_pch_fivr.c | 8 ++------ drivers/acpi/dptf/int340x_thermal.c | 7 +------ drivers/acpi/int340x_thermal.h | 8 ++++++++ 3 files changed, 11 insertions(+), 12 deletions(-)
drivers/acpi/dptf/dptf_pch_fivr.c +2 -6
@@ -8,6 +8,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> +#include "../int340x_thermal.h" struct pch_fivr_resp {u64 status;
@@ -147,12 +148,7 @@ static void pch_fivr_remove(struct platform_device *pdev) }static const struct acpi_device_id pch_fivr_device_ids[] = { - {"INTC1045" ,0 }, - {"INTC1049" ,0 }, - {"INTC1064" ,0 }, - {"INTC106B" ,0 }, - {"INTC10A3" ,0 }, - {"INTC10D7" ,0 }, +ACPI_PCH_FIVR_DEVICE_IDS , {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, pch_fivr_device_ids);
drivers/acpi/dptf/int340x_thermal.c +1 -6
@@ -20,16 +20,11 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {ACPI_INT3404_DEVICE_IDS ,ACPI_INT3406_DEVICE_IDS ,ACPI_INT3407_DEVICE_IDS , +ACPI_PCH_FIVR_DEVICE_IDS , {"INT3408"}, {"INT3409"}, {"INT340A"}, {"INT340B"}, - {"INTC1045"}, - {"INTC1049"}, - {"INTC1064"}, - {"INTC106B"}, - {"INTC10A3"}, - {"INTC10D7"}, {"INTC10FF"}, {"INTC1102"}, {""},
drivers/acpi/int340x_thermal.h +8 -0
@@ -65,4 +65,12 @@ {"INTC1100"}, \ {"INTC1101"} +#define ACPI_PCH_FIVR_DEVICE_IDS \ + {"INTC1045"}, \ + {"INTC1049"}, \ + {"INTC1064"}, \ + {"INTC106B"}, \ + {"INTC10A3"}, \ + {"INTC10D7"} +#endif
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH v2 4/6 ACPI: DPTF: Remove not supported INT340X IDs
In reply to Slawomir RosekRemove not supported INT340X and Wildcat Lake ACPI device IDs from scan handler.
--- drivers/acpi/dptf/int340x_thermal.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +0 -6
@@ -21,12 +21,6 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {ACPI_INT3406_DEVICE_IDS ,ACPI_INT3407_DEVICE_IDS ,ACPI_PCH_FIVR_DEVICE_IDS , - {"INT3408"}, - {"INT3409"}, - {"INT340A"}, - {"INT340B"}, - {"INTC10FF"}, - {"INTC1102"}, {""}, };
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH v2 5/6 ACPI: platform: Add macro for acpi platform driver
In reply to Slawomir RosekIntroduce module_acpi_platform_driver() macro to simplify dynamic enumeration of ACPI device objects on the platform bus by loadable modules. Move common code from the intel-hid and intel-vbtn drivers to the ACPI platform core.
--- drivers/acpi/acpi_platform.c | 27 +++++++++++++++++++++++++ drivers/platform/x86/intel/hid.c | 33 +++---------------------------- drivers/platform/x86/intel/vbtn.c | 30 +--------------------------- include/linux/platform_device.h | 17 ++++++++++++++++ 4 files changed, 48 insertions(+), 59 deletions(-)
drivers/acpi/acpi_platform.c +27 -0
@@ -190,6 +190,33 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev, }EXPORT_SYMBOL_GPL (acpi_create_platform_device); +static acpi_status +__acpi_platform_driver_register_cb (acpi_handle handle,u32 lvl, +void *context,void **rv) +{ +const struct acpi_device_id *ids = context; +struct acpi_device *dev =acpi_fetch_acpi_dev (handle); + +if (dev &&acpi_match_device_ids (dev, ids) ==0 ) +if (!IS_ERR_OR_NULL (acpi_create_platform_device (dev,NULL ))) { +dev_info (&dev->dev, +"created platform device\n" ); + } + +return AE_OK ; +} + +int __acpi_platform_driver_register (struct platform_driver *drv, +struct module *owner) +{ +acpi_walk_namespace (ACPI_TYPE_DEVICE ,ACPI_ROOT_OBJECT ,ACPI_UINT32_MAX , + __acpi_platform_driver_register_cb,NULL , + (void *)drv->driver.acpi_match_table,NULL ); + +return __platform_driver_register (drv, owner); +} +EXPORT_SYMBOL_GPL (__acpi_platform_driver_register); +void __init acpi_platform_init (void ) {acpi_reconfig_notifier_register (&acpi_platform_notifier);
drivers/platform/x86/intel/hid.c +3 -30
@@ -775,34 +775,7 @@ static struct platform_driver intel_hid_pl_driver = {* * As a workaround until the ACPI core figures out how to handle * this corner case, manually ask the ACPI platform device code to -* claim the ACPI node. +* claim the ACPI node by using module_acpi_platform_driver() +* instead of the regular module_platform_driver(). */ -static acpi_status __init -check_acpi_dev (acpi_handle handle,u32 lvl,void *context,void **rv) -{ -const struct acpi_device_id *ids = context; -struct acpi_device *dev =acpi_fetch_acpi_dev (handle); - -if (dev &&acpi_match_device_ids (dev, ids) ==0 ) -if (!IS_ERR_OR_NULL (acpi_create_platform_device (dev,NULL ))) -dev_info (&dev->dev, -"intel-hid: created platform device\n" ); - -return AE_OK ; -} - -static int __init intel_hid_init (void ) -{ -acpi_walk_namespace (ACPI_TYPE_DEVICE ,ACPI_ROOT_OBJECT , -ACPI_UINT32_MAX , check_acpi_dev,NULL , - (void *)intel_hid_ids,NULL ); - -return platform_driver_register (&intel_hid_pl_driver); -} -module_init (intel_hid_init); - -static void __exit intel_hid_exit(void) -{ -platform_driver_unregister (&intel_hid_pl_driver); -} -module_exit (intel_hid_exit); +module_acpi_platform_driver (intel_hid_pl_driver);
drivers/platform/x86/intel/vbtn.c +1 -29
@@ -390,32 +390,4 @@ static struct platform_driver intel_vbtn_pl_driver = { .remove = intel_vbtn_remove, }; -static acpi_status __init -check_acpi_dev (acpi_handle handle,u32 lvl,void *context,void **rv) -{ -const struct acpi_device_id *ids = context; -struct acpi_device *dev =acpi_fetch_acpi_dev (handle); - -if (dev &&acpi_match_device_ids (dev, ids) ==0 ) -if (!IS_ERR_OR_NULL (acpi_create_platform_device (dev,NULL ))) -dev_info (&dev->dev, -"intel-vbtn: created platform device\n" ); - -return AE_OK ; -} - -static int __init intel_vbtn_init (void ) -{ -acpi_walk_namespace (ACPI_TYPE_DEVICE ,ACPI_ROOT_OBJECT , -ACPI_UINT32_MAX , check_acpi_dev,NULL , - (void *)intel_vbtn_ids,NULL ); - -return platform_driver_register (&intel_vbtn_pl_driver); -} -module_init (intel_vbtn_init); - -static void __exit intel_vbtn_exit(void) -{ -platform_driver_unregister (&intel_vbtn_pl_driver); -} -module_exit (intel_vbtn_exit); +module_acpi_platform_driver (intel_vbtn_pl_driver);
include/linux/platform_device.h +17 -0
@@ -264,6 +264,14 @@ extern int __platform_driver_register(struct platform_driver *, struct module *);extern void platform_driver_unregister (struct platform_driver *); +/* +* use a macro to avoid include chaining to get THIS_MODULE +*/ +#define acpi_platform_driver_register (drv) \ + __acpi_platform_driver_register(drv, THIS_MODULE) +extern int __acpi_platform_driver_register (struct platform_driver *, +struct module *); +/* non-hotpluggable platform devices may use this so that probe() and * its support may live in __init sections, conserving runtime memory. */
@@ -292,6 +300,15 @@ static inline void platform_set_drvdata(struct platform_device *pdev,module_driver (__platform_driver, platform_driver_register, \ platform_driver_unregister) +/* module_acpi_platform_driver() - Helper macro for drivers that don't do +* anything special in module init/exit. This eliminates a lot of +* boilerplate. Each module may only use this macro once, and +* calling it replaces module_init() and module_exit() + */ +#define module_acpi_platform_driver (__platform_driver) \ + module_driver(__platform_driver, acpi_platform_driver_register, \ + platform_driver_unregister) +/* builtin_platform_driver() - Helper macro for builtin drivers that * don't do anything special in driver init. This eliminates some * boilerplate. Each driver may only use this macro once, and
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH v2 6/6 ACPI: DPTF: Move INT340X enumeration to modules
In reply to Slawomir RosekMove enumeration of INT340X ACPI device objects on the platform bus from DPTF core to thermal drivers using ACPI platform core methods
--- drivers/acpi/dptf/dptf_pch_fivr.c | 2 +- drivers/acpi/dptf/dptf_power.c | 2 +- drivers/acpi/dptf/int340x_thermal.c | 7 +++++-- drivers/acpi/fan_core.c | 2 +- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3401_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3402_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3403_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3406_thermal.c | 2 +- 9 files changed, 13 insertions(+), 10 deletions(-)
drivers/acpi/dptf/dptf_pch_fivr.c +1 -1
@@ -162,7 +162,7 @@ static struct platform_driver pch_fivr_driver = { }, }; -module_platform_driver (pch_fivr_driver); +module_acpi_platform_driver (pch_fivr_driver);MODULE_AUTHOR ("Srinivas Pandruvada <[email protected]>" );MODULE_LICENSE ("GPL v2" );
drivers/acpi/dptf/dptf_power.c +1 -1
@@ -239,7 +239,7 @@ static struct platform_driver dptf_power_driver = { }, }; -module_platform_driver (dptf_power_driver); +module_acpi_platform_driver (dptf_power_driver);MODULE_AUTHOR ("Srinivas Pandruvada <[email protected]>" );MODULE_LICENSE ("GPL v2" );
drivers/acpi/dptf/int340x_thermal.c +5 -2
@@ -27,8 +27,11 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {static int int340x_thermal_handler_attach (struct acpi_device *adev,const struct acpi_device_id *id) { -if (IS_ENABLED (CONFIG_INT340X_THERMAL )) -acpi_create_platform_device (adev,NULL ); +/* +* Do not attach INT340X devices until platform drivers are loaded. +* Enumeration of INT340X ACPI device objects on the platform bus +* should be done by thermal drivers. +*/ return 1 ; }
drivers/acpi/fan_core.c +1 -1
@@ -473,7 +473,7 @@ static struct platform_driver acpi_fan_driver = { }, }; -module_platform_driver (acpi_fan_driver); +module_acpi_platform_driver (acpi_fan_driver);MODULE_AUTHOR ("Paul Diefenbaugh" );MODULE_DESCRIPTION ("ACPI Fan Driver" );
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1 -1
@@ -699,7 +699,7 @@ static struct platform_driver int3400_thermal_driver = { }, }; -module_platform_driver (int3400_thermal_driver); +module_acpi_platform_driver (int3400_thermal_driver);MODULE_DESCRIPTION ("INT3400 Thermal driver" );MODULE_AUTHOR ("Zhang Rui <[email protected]>" );
drivers/thermal/intel/int340x_thermal/int3401_thermal.c +1 -1
@@ -69,7 +69,7 @@ static struct platform_driver int3401_driver = { }, }; -module_platform_driver (int3401_driver); +module_acpi_platform_driver (int3401_driver);MODULE_AUTHOR ("Srinivas Pandruvada <[email protected]>" );MODULE_DESCRIPTION ("Processor Thermal Reporting Device Driver" );
drivers/thermal/intel/int340x_thermal/int3402_thermal.c +1 -1
@@ -100,7 +100,7 @@ static struct platform_driver int3402_thermal_driver = { }, }; -module_platform_driver (int3402_thermal_driver); +module_acpi_platform_driver (int3402_thermal_driver);MODULE_DESCRIPTION ("INT3402 Thermal driver" );MODULE_LICENSE ("GPL" );
drivers/thermal/intel/int340x_thermal/int3403_thermal.c +1 -1
@@ -284,7 +284,7 @@ static struct platform_driver int3403_driver = { }, }; -module_platform_driver (int3403_driver); +module_acpi_platform_driver (int3403_driver);MODULE_AUTHOR ("Srinivas Pandruvada <[email protected]>" );MODULE_LICENSE ("GPL v2" );
drivers/thermal/intel/int340x_thermal/int3406_thermal.c +1 -1
@@ -203,7 +203,7 @@ static struct platform_driver int3406_thermal_driver = { }, }; -module_platform_driver (int3406_thermal_driver); +module_acpi_platform_driver (int3406_thermal_driver);MODULE_DESCRIPTION ("INT3406 Thermal driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.51.0.384.g4c02a37b29-goog