Skip to contentSkip to conversation

ACPI: DPTF: Move INT340X enumeration from DPTF core to thermal drivers

PATCH Superseded Slawomir Rosek 3 participants 18 messages Aug 30, 2025 – Sep 16, 2025

Subsystems (6)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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 (12):
ACPI: DPTF: Ignore SoC DTS thermal while scanning
ACPI: DPTF: Move INT3400 device IDs to header
ACPI: DPTF: Move INT3401 device IDs to header
ACPI: DPTF: Move INT3402 device IDs to header
ACPI: DPTF: Move INT3403 device IDs to header
ACPI: DPTF: Move INT3404 device IDs to header
ACPI: DPTF: Move INT3406 device IDs to header
ACPI: DPTF: Move INT3407 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              | 41 +---------
 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, 161 insertions(+), 188 deletions(-)
 create mode 100644 drivers/acpi/int340x_thermal.h
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#1 lore raw

PATCH 1/12 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.

Fixes 014d9d5d0cc1 ("ACPI/int340x_thermal: enumerate INT3401 for Intel SoC DTS thermal driver")
---
 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
index a222df059a16..947fe50c2ef6 100644
@@ -11,10 +11,9 @@
 
 #include "../internal.h"
 
-#define INT3401_DEVICE 0X01
 static 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
index e0268fac7093..47950859b790 100644
@@ -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.318.gd7df087d1a-goog
#2 lore raw

PATCH 2/12 ACPI: DPTF: Move INT3400 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3400 device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.

---
 drivers/acpi/dptf/int340x_thermal.c           | 10 ++-------
 drivers/acpi/int340x_thermal.h                | 21 +++++++++++++++++++
 .../intel/int340x_thermal/int3400_thermal.c   | 10 ++-------
 3 files changed, 25 insertions(+), 16 deletions(-)
 create mode 100644 drivers/acpi/int340x_thermal.h
drivers/acpi/dptf/int340x_thermal.c +2 -8
index 947fe50c2ef6..04df20ef1a2e 100644
@@ -9,10 +9,11 @@
 #include <linux/acpi.h>
 #include <linux/module.h>
 
+#include "../int340x_thermal.h"
 #include "../internal.h"
 
 static const struct acpi_device_id int340x_thermal_device_ids[] = {
-	{"INT3400"},
+	ACPI_INT3400_DEVICE_IDS,
 	{"INT3401"},
 	{"INT3402"},
 	{"INT3403"},
@@ -24,9 +25,6 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	{"INT340A"},
 	{"INT340B"},
 	{"INT3532"},
-	{"INTC1040"},
-	{"INTC1041"},
-	{"INTC1042"},
 	{"INTC1043"},
 	{"INTC1044"},
 	{"INTC1045"},
@@ -42,25 +40,21 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	{"INTC1064"},
 	{"INTC1065"},
 	{"INTC1066"},
-	{"INTC1068"},
 	{"INTC1069"},
 	{"INTC106A"},
 	{"INTC106B"},
 	{"INTC106C"},
 	{"INTC106D"},
-	{"INTC10A0"},
 	{"INTC10A1"},
 	{"INTC10A2"},
 	{"INTC10A3"},
 	{"INTC10A4"},
 	{"INTC10A5"},
-	{"INTC10D4"},
 	{"INTC10D5"},
 	{"INTC10D6"},
 	{"INTC10D7"},
 	{"INTC10D8"},
 	{"INTC10D9"},
-	{"INTC10FC"},
 	{"INTC10FD"},
 	{"INTC10FE"},
 	{"INTC10FF"},
drivers/acpi/int340x_thermal.h new file +21 -0
new file mode 100644
index 000000000000..a0d379492a79
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * The ACPI INT3400 device IDs are shared between the DPTF core
+ * and thermal drivers.
+ */
+
+#ifndef _ACPI_INT340X_H_
+#define _ACPI_INT340X_H_
+
+#define ACPI_INT3400_DEVICE_IDS	\
+	{"INT3400"},	\
+	{"INTC1040"},	\
+	{"INTC1041"},	\
+	{"INTC1042"},	\
+	{"INTC1068"},	\
+	{"INTC10A0"},	\
+	{"INTC10D4"},	\
+	{"INTC10FC"}
+
+#endif
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +2 -8
index 908cc1bf57f1..6311125c3ebd 100644
@@ -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,
 	{}
 };
 
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#3 lore raw

PATCH 3/12 ACPI: DPTF: Move INT3401 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3401 device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.

---
 drivers/acpi/dptf/int340x_thermal.c                     | 2 +-
 drivers/acpi/int340x_thermal.h                          | 3 +++
 drivers/thermal/intel/int340x_thermal/int3401_thermal.c | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +1 -1
index 04df20ef1a2e..8fa85c866675 100644
@@ -14,7 +14,7 @@
 
 static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	ACPI_INT3400_DEVICE_IDS,
-	{"INT3401"},
+	ACPI_INT3401_DEVICE_IDS,
 	{"INT3402"},
 	{"INT3403"},
 	{"INT3404"},
drivers/acpi/int340x_thermal.h +3 -0
index a0d379492a79..3ecd6c4bf2ca 100644
@@ -18,4 +18,7 @@
 	{"INTC10D4"},	\
 	{"INTC10FC"}
 
+#define ACPI_INT3401_DEVICE_IDS	\
+	{"INT3401"}
+
 #endif
drivers/thermal/intel/int340x_thermal/int3401_thermal.c +2 -1
index 96d6277a5a8c..e0603f218d2e 100644
@@ -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);
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#4 lore raw

PATCH 4/12 ACPI: DPTF: Move INT3402 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3402 device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.

---
 drivers/acpi/dptf/int340x_thermal.c                     | 2 +-
 drivers/acpi/int340x_thermal.h                          | 3 +++
 drivers/thermal/intel/int340x_thermal/int3402_thermal.c | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +1 -1
index 8fa85c866675..cf2e95a4f65a 100644
@@ -15,7 +15,7 @@
 static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	ACPI_INT3400_DEVICE_IDS,
 	ACPI_INT3401_DEVICE_IDS,
-	{"INT3402"},
+	ACPI_INT3402_DEVICE_IDS,
 	{"INT3403"},
 	{"INT3404"},
 	{"INT3406"},
drivers/acpi/int340x_thermal.h +3 -0
index 3ecd6c4bf2ca..cc1dfa56fc09 100644
@@ -21,4 +21,7 @@
 #define ACPI_INT3401_DEVICE_IDS	\
 	{"INT3401"}
 
+#define ACPI_INT3402_DEVICE_IDS	\
+	{"INT3402"}
+
 #endif
drivers/thermal/intel/int340x_thermal/int3402_thermal.c +2 -1
index 57b90005888a..213d4535f2c1 100644
@@ -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,
 	{}
 };
 
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#5 lore raw

PATCH 5/12 ACPI: DPTF: Move INT3403 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3403 device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.

---
 drivers/acpi/dptf/int340x_thermal.c                    |  9 +--------
 drivers/acpi/int340x_thermal.h                         | 10 ++++++++++
 .../thermal/intel/int340x_thermal/int3403_thermal.c    | 10 ++--------
 3 files changed, 13 insertions(+), 16 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +1 -8
index cf2e95a4f65a..f042bf22b664 100644
@@ -16,7 +16,7 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	ACPI_INT3400_DEVICE_IDS,
 	ACPI_INT3401_DEVICE_IDS,
 	ACPI_INT3402_DEVICE_IDS,
-	{"INT3403"},
+	ACPI_INT3403_DEVICE_IDS,
 	{"INT3404"},
 	{"INT3406"},
 	{"INT3407"},
@@ -25,37 +25,30 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	{"INT340A"},
 	{"INT340B"},
 	{"INT3532"},
-	{"INTC1043"},
 	{"INTC1044"},
 	{"INTC1045"},
-	{"INTC1046"},
 	{"INTC1047"},
 	{"INTC1048"},
 	{"INTC1049"},
 	{"INTC1050"},
 	{"INTC1060"},
 	{"INTC1061"},
-	{"INTC1062"},
 	{"INTC1063"},
 	{"INTC1064"},
 	{"INTC1065"},
 	{"INTC1066"},
-	{"INTC1069"},
 	{"INTC106A"},
 	{"INTC106B"},
 	{"INTC106C"},
 	{"INTC106D"},
-	{"INTC10A1"},
 	{"INTC10A2"},
 	{"INTC10A3"},
 	{"INTC10A4"},
 	{"INTC10A5"},
-	{"INTC10D5"},
 	{"INTC10D6"},
 	{"INTC10D7"},
 	{"INTC10D8"},
 	{"INTC10D9"},
-	{"INTC10FD"},
 	{"INTC10FE"},
 	{"INTC10FF"},
 	{"INTC1100"},
drivers/acpi/int340x_thermal.h +10 -0
index cc1dfa56fc09..3b34b5338618 100644
@@ -24,4 +24,14 @@
 #define ACPI_INT3402_DEVICE_IDS	\
 	{"INT3402"}
 
+#define ACPI_INT3403_DEVICE_IDS	\
+	{"INT3403"},	\
+	{"INTC1043"},	\
+	{"INTC1046"},	\
+	{"INTC1062"},	\
+	{"INTC1069"},	\
+	{"INTC10A1"},	\
+	{"INTC10D5"},	\
+	{"INTC10FD"}
+
 #endif
drivers/thermal/intel/int340x_thermal/int3403_thermal.c +2 -8
index ba63796761eb..d246c69d4872 100644
@@ -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);
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#6 lore raw

PATCH 6/12 ACPI: DPTF: Move INT3404 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3404 device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.

---
 drivers/acpi/dptf/int340x_thermal.c |  9 +--------
 drivers/acpi/fan.h                  | 10 ++--------
 drivers/acpi/int340x_thermal.h      | 10 ++++++++++
 3 files changed, 13 insertions(+), 16 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +1 -8
index f042bf22b664..be2299aadcff 100644
@@ -17,7 +17,7 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	ACPI_INT3401_DEVICE_IDS,
 	ACPI_INT3402_DEVICE_IDS,
 	ACPI_INT3403_DEVICE_IDS,
-	{"INT3404"},
+	ACPI_INT3404_DEVICE_IDS,
 	{"INT3406"},
 	{"INT3407"},
 	{"INT3408"},
@@ -25,31 +25,24 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	{"INT340A"},
 	{"INT340B"},
 	{"INT3532"},
-	{"INTC1044"},
 	{"INTC1045"},
 	{"INTC1047"},
-	{"INTC1048"},
 	{"INTC1049"},
 	{"INTC1050"},
 	{"INTC1060"},
 	{"INTC1061"},
-	{"INTC1063"},
 	{"INTC1064"},
 	{"INTC1065"},
 	{"INTC1066"},
-	{"INTC106A"},
 	{"INTC106B"},
 	{"INTC106C"},
 	{"INTC106D"},
-	{"INTC10A2"},
 	{"INTC10A3"},
 	{"INTC10A4"},
 	{"INTC10A5"},
-	{"INTC10D6"},
 	{"INTC10D7"},
 	{"INTC10D8"},
 	{"INTC10D9"},
-	{"INTC10FE"},
 	{"INTC10FF"},
 	{"INTC1100"},
 	{"INTC1101"},
drivers/acpi/fan.h +2 -8
index 8a28a72a7c6a..4015ac56c009 100644
@@ -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 +10 -0
index 3b34b5338618..d1ffa9c3cfb7 100644
@@ -34,4 +34,14 @@
 	{"INTC10D5"},	\
 	{"INTC10FD"}
 
+#define ACPI_INT3404_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 */
+
 #endif
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#7 lore raw

PATCH 7/12 ACPI: DPTF: Move INT3406 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3406 device IDs are shared between the DPTF core and thermal drivers, thus they are moved to the common header.

---
 drivers/acpi/dptf/int340x_thermal.c                     | 2 +-
 drivers/acpi/int340x_thermal.h                          | 3 +++
 drivers/thermal/intel/int340x_thermal/int3406_thermal.c | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +1 -1
index be2299aadcff..131648ddec87 100644
@@ -18,7 +18,7 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	ACPI_INT3402_DEVICE_IDS,
 	ACPI_INT3403_DEVICE_IDS,
 	ACPI_INT3404_DEVICE_IDS,
-	{"INT3406"},
+	ACPI_INT3406_DEVICE_IDS,
 	{"INT3407"},
 	{"INT3408"},
 	{"INT3409"},
drivers/acpi/int340x_thermal.h +3 -0
index d1ffa9c3cfb7..946f5bb23b44 100644
@@ -44,4 +44,7 @@
 	{"INTC10D6", }, /* Fan for Panther Lake generation */ \
 	{"INTC10FE", } /* Fan for Wildcat Lake generation */
 
+#define ACPI_INT3406_DEVICE_IDS	\
+	{"INT3406"}
+
 #endif
drivers/thermal/intel/int340x_thermal/int3406_thermal.c +2 -1
index e21fcbccf4ba..d05ca8bc4061 100644
@@ -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.318.gd7df087d1a-goog
#8 lore raw

PATCH 8/12 ACPI: DPTF: Move INT3407 device IDs to header

In reply to Slawomir Rosek

The ACPI INT3407 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 | 17 +----------------
 drivers/acpi/int340x_thermal.h      | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 32 deletions(-)
drivers/acpi/dptf/dptf_power.c +2 -16
index 776914f31b9e..d7c59f016083 100644
@@ -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 +1 -16
index 131648ddec87..43afb6141b98 100644
@@ -19,33 +19,18 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
 	ACPI_INT3403_DEVICE_IDS,
 	ACPI_INT3404_DEVICE_IDS,
 	ACPI_INT3406_DEVICE_IDS,
-	{"INT3407"},
+	ACPI_INT3407_DEVICE_IDS,
 	{"INT3408"},
 	{"INT3409"},
 	{"INT340A"},
 	{"INT340B"},
-	{"INT3532"},
 	{"INTC1045"},
-	{"INTC1047"},
 	{"INTC1049"},
-	{"INTC1050"},
-	{"INTC1060"},
-	{"INTC1061"},
 	{"INTC1064"},
-	{"INTC1065"},
-	{"INTC1066"},
 	{"INTC106B"},
-	{"INTC106C"},
-	{"INTC106D"},
 	{"INTC10A3"},
-	{"INTC10A4"},
-	{"INTC10A5"},
 	{"INTC10D7"},
-	{"INTC10D8"},
-	{"INTC10D9"},
 	{"INTC10FF"},
-	{"INTC1100"},
-	{"INTC1101"},
 	{"INTC1102"},
 	{""},
 };
drivers/acpi/int340x_thermal.h +18 -0
index 946f5bb23b44..8a3d2a9b218a 100644
@@ -47,4 +47,22 @@
 #define ACPI_INT3406_DEVICE_IDS	\
 	{"INT3406"}
 
+#define ACPI_INT3407_DEVICE_IDS	\
+	{"INT3407"},	\
+	{"INT3532"},	\
+	{"INTC1047"},	\
+	{"INTC1050"},	\
+	{"INTC1060"},	\
+	{"INTC1061"},	\
+	{"INTC1065"},	\
+	{"INTC1066"},	\
+	{"INTC106C"},	\
+	{"INTC106D"},	\
+	{"INTC10A4"},	\
+	{"INTC10A5"},	\
+	{"INTC10D8"},	\
+	{"INTC10D9"},	\
+	{"INTC1100"},	\
+	{"INTC1101"}
+
 #endif
Signature · 1 line
2.51.0.318.gd7df087d1a-goog
#9 lore raw

PATCH 9/12 ACPI: DPTF: Move PCH FIVR device IDs to header

In reply to Slawomir Rosek

The 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
index 952216c67d58..cb81636a5d63 100644
@@ -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
index 43afb6141b98..26522ddfcbaa 100644
@@ -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
index 8a3d2a9b218a..41e4ca2bc6e2 100644
@@ -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.318.gd7df087d1a-goog
#10 lore raw

PATCH 10/12 ACPI: DPTF: Remove not supported INT340X IDs

In reply to Slawomir Rosek

Remove not supported ACPI INT340X device IDs from scan handler.

Fixes 3230bbfce8a9 ("ACPI: introduce ACPI int340x thermal scan handler")
Fixes 9cf45756a4b9 ("ACPI: DPTF: Support for Wildcat Lake")
---
 drivers/acpi/dptf/int340x_thermal.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/acpi/dptf/int340x_thermal.c +0 -6
index 26522ddfcbaa..7d1308b1f513 100644
@@ -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.318.gd7df087d1a-goog
#11 lore raw

PATCH 11/12 ACPI: platform: Add macro for acpi platform driver

In reply to Slawomir Rosek

Introduce 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  | 41 +------------------------------
 drivers/platform/x86/intel/vbtn.c | 30 +---------------------
 include/linux/platform_device.h   | 17 +++++++++++++
 4 files changed, 46 insertions(+), 69 deletions(-)
drivers/acpi/acpi_platform.c +27 -0
index 48d15dd785f6..adf32ffa6be6 100644
@@ -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 +1 -40

44 lines not on this page · raw message

drivers/platform/x86/intel/vbtn.c +1 -29
index 232cd12e3c9f..42932479de35 100644
@@ -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
index 074754c23d33..3b70b054d8a5 100644
@@ -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.318.gd7df087d1a-goog
#14 lore raw

PATCH 12/12 ACPI: DPTF: Move INT340X enumeration to modules

In reply to Slawomir Rosek

Move 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
index cb81636a5d63..f3cd52c89e8d 100644
@@ -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
index d7c59f016083..b85e876b2e85 100644
@@ -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
index 7d1308b1f513..b2be3a8df9ac 100644
@@ -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
index 095502086b41..7df3caa59b73 100644
@@ -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
index 6311125c3ebd..0005961328fc 100644
@@ -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
index e0603f218d2e..d496f8b171e0 100644
@@ -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
index 213d4535f2c1..d06c06fadce5 100644
@@ -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
index d246c69d4872..33735515b47d 100644
@@ -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
index d05ca8bc4061..03cc026cdffb 100644
@@ -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.318.gd7df087d1a-goog
maintainer
#12 lore raw

Re: [PATCH v1 11/12] ACPI: platform: Add macro for acpi platform driver

In reply to Slawomir Rosek

Hi Slawomir,

Quoted 6 lines · Slawomir Rosek

Introduce 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.

Thank you for your interesting patch.

Quoted 54 lines
---
 drivers/acpi/acpi_platform.c      | 27 ++++++++++++++++++++
 drivers/platform/x86/intel/hid.c  | 41 +------------------------------
 drivers/platform/x86/intel/vbtn.c | 30 +---------------------
 include/linux/platform_device.h   | 17 +++++++++++++
 4 files changed, 46 insertions(+), 69 deletions(-)
drivers/acpi/acpi_platform.c +27 -0
index 48d15dd785f6..adf32ffa6be6 100644
@@ -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 +0 -1
index f25a427cccda..e2e0fc95e177 100644
@@ -766,43 +766,4 @@ static struct platform_driver intel_hid_pl_driver = {
 	.remove = intel_hid_remove,
 };
 
-/*

drivers/platform/x86/intel/hid.c static struct platform_driver intel_hid_pl_driver = { · line 779

Quoted 10 lines
drivers/platform/x86/intel/hid.c +0 -10
- * Unfortunately, some laptops provide a _HID="INT33D5" device with
- * _CID="PNP0C02".  This causes the pnpacpi scan driver to claim the
- * ACPI node, so no platform device will be created.  The pnpacpi
- * driver rejects this device in subsequent processing, so no physical
- * node is created at all.
- *
- * 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.
- */

This comment contains useful info, please preserve the comment changing the last paragraph to:

* 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 by using module_acpi_platform_driver()
* instead of the regular module_platform_driver().

Quoted 34 lines
drivers/platform/x86/intel/hid.c +1 -29
-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 +0 -0
index 232cd12e3c9f..42932479de35 100644

...

drivers/platform/x86/intel/vbtn.c static struct platform_driver intel_vbtn_pl_driver = { · line 411

Quoted 5 lines
drivers/platform/x86/intel/vbtn.c +0 -5
-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);

Too bad there is no comment here. I wonder if this is necessary at all, or if this was just copy & pasted from the intel/hid.c driver.

git blame is not really helpful here, the acpi_walk_namespace() was added in 332e081225fc2 ("intel-vbtn: new driver for Intel Virtual Button").

So it looks like this is just copy paste and maybe a regular module_platform_driver() will be sufficient here. But changing behavior like that is out of scope for this patch-set, so please keep using module_acpi_platform_driver()

Otherwise this looks good to me.

Regards,

Hans

#15 lore raw
In reply to Slawomir Rosek
Quoted 31 lines · Slawomir Rosek

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

Quoted 9 lines

Slawomir Rosek (12):
ACPI: DPTF: Ignore SoC DTS thermal while scanning
ACPI: DPTF: Move INT3400 device IDs to header
ACPI: DPTF: Move INT3401 device IDs to header
ACPI: DPTF: Move INT3402 device IDs to header
ACPI: DPTF: Move INT3403 device IDs to header
ACPI: DPTF: Move INT3404 device IDs to header
ACPI: DPTF: Move INT3406 device IDs to header
ACPI: DPTF: Move INT3407 device IDs to header

Please avoid sending multiple patches with the same subject, especially in one patch series.

Thanks!

Quoted 25 lines

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              | 41 +---------
 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, 161 insertions(+), 188 deletions(-)
 create mode 100644 drivers/acpi/int340x_thermal.h

--

#16 lore raw

Hi Rafael,

First of all I would like to apologize for the late reply and thank you for your comments.

Quoted 43 lines · Rafael J. Wysocki
Quoted 31 lines · Slawomir Rosek

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

Quoted 9 lines

Slawomir Rosek (12):
ACPI: DPTF: Ignore SoC DTS thermal while scanning
ACPI: DPTF: Move INT3400 device IDs to header
ACPI: DPTF: Move INT3401 device IDs to header
ACPI: DPTF: Move INT3402 device IDs to header
ACPI: DPTF: Move INT3403 device IDs to header
ACPI: DPTF: Move INT3404 device IDs to header
ACPI: DPTF: Move INT3406 device IDs to header
ACPI: DPTF: Move INT3407 device IDs to header

Quoted 5 lines

Please avoid sending multiple patches with the same subject, especially in one patch series.

Thanks!

The subjects are quite similar but they are not exactly the same.

Originally the ACPI bus scan handler was added in 3230bbfce8a9 ("ACPI: introduce ACPI int340x thermal scan handler") to prevent enumeration of ACPI device objects in range INT3401~INT340B and only the INT3400 master device had their platform driver added in 816cab931f28 ("Thermal: introduce int3400 thermal driver").

These days, however, each of INT3400~INT3407 device ID, representing a different kind of thermal device, has its own platform driver. Most of them, depending on X Lake generation, can also be enumerated on the ACPI bus using INTC1XXXX device ID. In addition INT3408~INT340B and some of The Wildcat Lake device IDs are not supported by any platform driver.

To make the review process easier and minimize the risk of mistakes I decided to create separe patch for each ID in range INT3400~INT3407. The INT3400, INT3404 and INT3407 device ID can probably be renamed to Thermal Core, Fan and Power device ID, respectively, but I am not sure about the others.

Alternatively they can be squashed into a single patch which moves all INT340X device IDs to the common header.

Please let me know which way is better.

Thanks, regards
Slawek

Quoted 25 lines
Quoted 25 lines

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              | 41 +---------
 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, 161 insertions(+), 188 deletions(-)
 create mode 100644 drivers/acpi/int340x_thermal.h

--

#13 lore raw

Re: [PATCH v1 11/12] ACPI: platform: Add macro for acpi platform driver

In reply to Hans de Goede

Hi Hans,

First of all I would like to apologize for the late reply and thank you for your comments.

Quoted 81 lines · Hans de Goede

Hi Slawomir,

Quoted 6 lines · Slawomir Rosek

Introduce 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.

Thank you for your interesting patch.

Quoted 54 lines
---
 drivers/acpi/acpi_platform.c      | 27 ++++++++++++++++++++
 drivers/platform/x86/intel/hid.c  | 41 +------------------------------
 drivers/platform/x86/intel/vbtn.c | 30 +---------------------
 include/linux/platform_device.h   | 17 +++++++++++++
 4 files changed, 46 insertions(+), 69 deletions(-)
drivers/acpi/acpi_platform.c +27 -0
index 48d15dd785f6..adf32ffa6be6 100644
@@ -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 +0 -1
index f25a427cccda..e2e0fc95e177 100644
@@ -766,43 +766,4 @@ static struct platform_driver intel_hid_pl_driver = {
      .remove = intel_hid_remove,
 };
 
-/*

drivers/platform/x86/intel/hid.c static struct platform_driver intel_hid_pl_driver = { · line 779

Quoted 10 lines
drivers/platform/x86/intel/hid.c +0 -10
- * Unfortunately, some laptops provide a _HID="INT33D5" device with
- * _CID="PNP0C02".  This causes the pnpacpi scan driver to claim the
- * ACPI node, so no platform device will be created.  The pnpacpi
- * driver rejects this device in subsequent processing, so no physical
- * node is created at all.
- *
- * 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.
- */

This comment contains useful info, please preserve the comment changing the last paragraph to:

Quoted 5 lines

* 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 by using module_acpi_platform_driver()
* instead of the regular module_platform_driver().

Good point. I shouldn't have deleted the original comment. I will restore and rephrase it according to your suggestions.

Quoted 47 lines
Quoted 34 lines
drivers/platform/x86/intel/hid.c +1 -29
-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 +0 -0
index 232cd12e3c9f..42932479de35 100644

...

drivers/platform/x86/intel/vbtn.c static struct platform_driver intel_vbtn_pl_driver = { · line 411

Quoted 5 lines
drivers/platform/x86/intel/vbtn.c +0 -5
-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);

Too bad there is no comment here. I wonder if this is necessary at all, or if this was just copy & pasted from the intel/hid.c driver.

Quoted 9 lines

git blame is not really helpful here, the acpi_walk_namespace() was added in 332e081225fc2 ("intel-vbtn: new driver for Intel Virtual Button").

So it looks like this is just copy paste and maybe a regular module_platform_driver() will be sufficient here. But changing behavior like that is out of scope for this patch-set, so please keep using module_acpi_platform_driver()

Changing vbtn driver behaviour is definitely out of the scope for this patch-set but you may be right about copy-paste. Should I update the commit message and mention about it?

Quoted 7 lines

Otherwise this looks good to me.

Regards,

Hans

Thanks, Regards,
Slawek

#17 lore raw
In reply to Sławomir Rosek

Hi,

Quoted 71 lines · Sławomir Rosek

Hi Rafael,

First of all I would like to apologize for the late reply and thank you for your comments.

Quoted 43 lines · Rafael J. Wysocki
Quoted 31 lines · Slawomir Rosek

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

Quoted 9 lines

Slawomir Rosek (12):
ACPI: DPTF: Ignore SoC DTS thermal while scanning
ACPI: DPTF: Move INT3400 device IDs to header
ACPI: DPTF: Move INT3401 device IDs to header
ACPI: DPTF: Move INT3402 device IDs to header
ACPI: DPTF: Move INT3403 device IDs to header
ACPI: DPTF: Move INT3404 device IDs to header
ACPI: DPTF: Move INT3406 device IDs to header
ACPI: DPTF: Move INT3407 device IDs to header

Quoted 5 lines

Please avoid sending multiple patches with the same subject, especially in one patch series.

Thanks!

The subjects are quite similar but they are not exactly the same.

Originally the ACPI bus scan handler was added in 3230bbfce8a9 ("ACPI: introduce ACPI int340x thermal scan handler") to prevent enumeration of ACPI device objects in range INT3401~INT340B and only the INT3400 master device had their platform driver added in 816cab931f28 ("Thermal: introduce int3400 thermal driver").

These days, however, each of INT3400~INT3407 device ID, representing a different kind of thermal device, has its own platform driver. Most of them, depending on X Lake generation, can also be enumerated on the ACPI bus using INTC1XXXX device ID. In addition INT3408~INT340B and some of The Wildcat Lake device IDs are not supported by any platform driver.

Quoted 8 lines

To make the review process easier and minimize the risk of mistakes I decided to create separe patch for each ID in range INT3400~INT3407. The INT3400, INT3404 and INT3407 device ID can probably be renamed to Thermal Core, Fan and Power device ID, respectively, but I am not sure about the others.

Alternatively they can be squashed into a single patch which moves all INT340X device IDs to the common header.

Yes, please.