[PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning

Slawomir Rosek posted 6 patches 2 weeks ago
There is a newer version of this series
[PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
Posted by Slawomir Rosek 2 weeks ago
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")
Signed-off-by: Slawomir Rosek <srosek@google.com>
---
 drivers/acpi/dptf/int340x_thermal.c | 7 +------
 drivers/thermal/intel/Kconfig       | 1 +
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/dptf/int340x_thermal.c b/drivers/acpi/dptf/int340x_thermal.c
index a222df059a16..947fe50c2ef6 100644
--- a/drivers/acpi/dptf/int340x_thermal.c
+++ b/drivers/acpi/dptf/int340x_thermal.c
@@ -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;
 }
 
diff --git a/drivers/thermal/intel/Kconfig b/drivers/thermal/intel/Kconfig
index e0268fac7093..47950859b790 100644
--- a/drivers/thermal/intel/Kconfig
+++ b/drivers/thermal/intel/Kconfig
@@ -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
-- 
2.51.0.384.g4c02a37b29-goog
Re: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
Posted by Sławomir Rosek 1 week, 1 day ago
Hi Rafael

On Wed, Sep 17, 2025 at 2:07 PM Slawomir Rosek <srosek@google.com> wrote:
>
> 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")
> Signed-off-by: Slawomir Rosek <srosek@google.com>
> ---
>  drivers/acpi/dptf/int340x_thermal.c | 7 +------
>  drivers/thermal/intel/Kconfig       | 1 +
>  2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/acpi/dptf/int340x_thermal.c b/drivers/acpi/dptf/int340x_thermal.c
> index a222df059a16..947fe50c2ef6 100644
> --- a/drivers/acpi/dptf/int340x_thermal.c
> +++ b/drivers/acpi/dptf/int340x_thermal.c
> @@ -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;
>  }
>
> diff --git a/drivers/thermal/intel/Kconfig b/drivers/thermal/intel/Kconfig
> index e0268fac7093..47950859b790 100644
> --- a/drivers/thermal/intel/Kconfig
> +++ b/drivers/thermal/intel/Kconfig
> @@ -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/202509181359.fLTuROj6-lkp@intel.com/
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

>         select INTEL_SOC_DTS_IOSF_CORE
>         help
>           Enable this to register Intel SoCs (e.g. Bay Trail) platform digital
> --
> 2.51.0.384.g4c02a37b29-goog
>
Re: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
Posted by Rafael J. Wysocki 16 hours ago
Hi,

Sorry for the delay.

On Tue, Sep 23, 2025 at 2:16 PM Sławomir Rosek <srosek@google.com> wrote:
>
> Hi Rafael
>
> On Wed, Sep 17, 2025 at 2:07 PM Slawomir Rosek <srosek@google.com> wrote:
> >
> > 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")
> > Signed-off-by: Slawomir Rosek <srosek@google.com>
> > ---
> >  drivers/acpi/dptf/int340x_thermal.c | 7 +------
> >  drivers/thermal/intel/Kconfig       | 1 +
> >  2 files changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/acpi/dptf/int340x_thermal.c b/drivers/acpi/dptf/int340x_thermal.c
> > index a222df059a16..947fe50c2ef6 100644
> > --- a/drivers/acpi/dptf/int340x_thermal.c
> > +++ b/drivers/acpi/dptf/int340x_thermal.c
> > @@ -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;
> >  }
> >
> > diff --git a/drivers/thermal/intel/Kconfig b/drivers/thermal/intel/Kconfig
> > index e0268fac7093..47950859b790 100644
> > --- a/drivers/thermal/intel/Kconfig
> > +++ b/drivers/thermal/intel/Kconfig
> > @@ -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/202509181359.fLTuROj6-lkp@intel.com/
> 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.

I wouldn't worry about this.  I'd just make SoC DTS thermal explicitly
depend on X86_64.

> 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

I'm not a big fan of using acpi_walk_namespace() for such things.

Those namespace walks usually end up being quite expensive.

> 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

Well, this doesn't sound really straightforward.

> Please let me know your comment so I can prepare the next version.

I'd go for option 1).

Thanks!
Re: [PATCH v2 1/6] ACPI: DPTF: Ignore SoC DTS thermal while scanning
Posted by kernel test robot 2 weeks ago
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/202509181359.fLTuROj6-lkp@intel.com/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/202509181359.fLTuROj6-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509181359.fLTuROj6-lkp@intel.com/

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);
         |         ^~~~~~
         |         writel

Kconfig 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  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki