mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support
@ 2024-07-23 14:02 Srinivas Pandruvada
  2024-07-23 14:02 ` [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup Srinivas Pandruvada
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2024-07-23 14:02 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rui.zhang, lukasz.luba
  Cc: linux-pm, linux-kernel, Yijun.Shen, Srinivas Pandruvada

On some pre-production systems, there is a partial support for thermal
interrupts. This cause kernel warning and fail to register TCPU sensor.

This series address these issues.

Srinivas Pandruvada (3):
  thermal: intel: int340x: Fix kernel warning during MSI cleanup
  thermal: intel: int340x: Allow limited thermal MSI support
  thermal: intel: int340x: Free MSI IRQ vectors on module exit

 .../processor_thermal_device_pci.c            | 29 ++++++++++++++-----
 1 file changed, 22 insertions(+), 7 deletions(-)

-- 
2.45.0


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

* [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup
  2024-07-23 14:02 [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Srinivas Pandruvada
@ 2024-07-23 14:02 ` Srinivas Pandruvada
  2024-07-30 14:24   ` Zhang, Rui
  2024-07-23 14:02 ` [PATCH 2/3] thermal: intel: int340x: Allow limited thermal MSI support Srinivas Pandruvada
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Srinivas Pandruvada @ 2024-07-23 14:02 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rui.zhang, lukasz.luba
  Cc: linux-pm, linux-kernel, Yijun.Shen, Srinivas Pandruvada, Yijun Shen

On some pre-production Lunar Lake systems, there is a kernel
warning:

remove_proc_entry: removing non-empty directory 'irq/172'
WARNING: CPU: 0 PID: 501 at fs/proc/generic.c:717
	remove_proc_entry+0x1b4/0x1e0
...
...
remove_proc_entry+0x1b4/0x1e0
report_bug+0x182/0x1b0
handle_bug+0x51/0xa0
exc_invalid_op+0x18/0x80
asm_exc_invalid_op+0x1b/0x20
remove_proc_entry+0x1b4/0x1e0
remove_proc_entry+0x1b4/0x1e0
unregister_irq_proc+0xf2/0x120
free_desc+0x41/0xe0
irq_domain_free_irqs+0x138/0x1c0
irq_free_descs+0x52/0x80
irq_domain_free_irqs+0x151/0x1c0
msi_domain_free_locked.part.0+0x17e/0x1c0
msi_domain_free_irqs_all_locked+0x74/0xc0
pci_msi_teardown_msi_irqs+0x50/0x60
pci_free_msi_irqs+0x12/0x40
pci_free_irq_vectors+0x58/0x70

On these systems, not all the MSI thermal vectors are valid. This causes
devm_request_threaded_irq() to fail for some vectors. As part of the
clean up on this error, pci_free_irq_vectors() is called without calling
devm_free_irq(). This causes the above warning.

Add a function proc_thermal_free_msi() to call devm_free_irq() for all
successfully registered IRQ handlers, then call pci_free_irq_vectors().
Call this function for MSI cleanup.

Fixes: 7a9a8c5faf41 ("thermal: intel: int340x: Support MSI interrupt for Lunar Lake")
Reported-by: Yijun Shen <Yijun.shen@dell.com>
Tested-by: Yijun Shen <Yijun.shen@dell.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../processor_thermal_device_pci.c               | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index 114136893a59..2c9c45eb5b4a 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -278,6 +278,18 @@ static struct thermal_zone_params tzone_params = {
 
 static bool msi_irq;
 
+static void proc_thermal_free_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
+{
+	int i;
+
+	for (i = 0; i < MSI_THERMAL_MAX; i++) {
+		if (proc_thermal_msi_map[i])
+			devm_free_irq(&pdev->dev, proc_thermal_msi_map[i], pci_info);
+	}
+
+	pci_free_irq_vectors(pdev);
+}
+
 static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
 {
 	int ret, i, irq;
@@ -310,7 +322,7 @@ static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci
 	return 0;
 
 err_free_msi_vectors:
-	pci_free_irq_vectors(pdev);
+	proc_thermal_free_msi(pdev, pci_info);
 
 	return ret;
 }
@@ -397,7 +409,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
 
 err_free_vectors:
 	if (msi_irq)
-		pci_free_irq_vectors(pdev);
+		proc_thermal_free_msi(pdev, pci_info);
 err_ret_tzone:
 	thermal_zone_device_unregister(pci_info->tzone);
 err_del_legacy:
-- 
2.45.0


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

* [PATCH 2/3] thermal: intel: int340x: Allow limited thermal MSI support
  2024-07-23 14:02 [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Srinivas Pandruvada
  2024-07-23 14:02 ` [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup Srinivas Pandruvada
@ 2024-07-23 14:02 ` Srinivas Pandruvada
  2024-07-23 14:02 ` [PATCH 3/3] thermal: intel: int340x: Free MSI IRQ vectors on module exit Srinivas Pandruvada
  2024-07-30 13:52 ` [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Rafael J. Wysocki
  3 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2024-07-23 14:02 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rui.zhang, lukasz.luba
  Cc: linux-pm, linux-kernel, Yijun.Shen, Srinivas Pandruvada

On some Lunar Lake pre-production systems, not all the MSI thermal
vectors are valid. In that case instead of failing module load, continue
with partial thermal interrupt support.

pci_alloc_irq_vectors() can return less than expected maximum vectors.
In that case call devm_request_threaded_irq() only for current maximum
vectors.

Fixes: 7a9a8c5faf41 ("thermal: intel: int340x: Support MSI interrupt for Lunar Lake")
Reported-by: Yijun Shen <Yijun.Shen@dell.com>
Tested-by: Yijun Shen <Yijun.Shen@dell.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../int340x_thermal/processor_thermal_device_pci.c     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index 2c9c45eb5b4a..ff296626c498 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -292,18 +292,18 @@ static void proc_thermal_free_msi(struct pci_dev *pdev, struct proc_thermal_pci
 
 static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
 {
-	int ret, i, irq;
+	int ret, i, irq, count;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
-	if (ret < 0) {
+	count = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	if (count < 0) {
 		dev_err(&pdev->dev, "Failed to allocate vectors!\n");
-		return ret;
+		return count;
 	}
 
 	dev_info(&pdev->dev, "msi enabled:%d msix enabled:%d\n", pdev->msi_enabled,
 		 pdev->msix_enabled);
 
-	for (i = 0; i < MSI_THERMAL_MAX; i++) {
+	for (i = 0; i < count; i++) {
 		irq =  pci_irq_vector(pdev, i);
 
 		ret = devm_request_threaded_irq(&pdev->dev, irq, proc_thermal_irq_handler,
-- 
2.45.0


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

* [PATCH 3/3] thermal: intel: int340x: Free MSI IRQ vectors on module exit
  2024-07-23 14:02 [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Srinivas Pandruvada
  2024-07-23 14:02 ` [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup Srinivas Pandruvada
  2024-07-23 14:02 ` [PATCH 2/3] thermal: intel: int340x: Allow limited thermal MSI support Srinivas Pandruvada
@ 2024-07-23 14:02 ` Srinivas Pandruvada
  2024-07-30 13:52 ` [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Rafael J. Wysocki
  3 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2024-07-23 14:02 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rui.zhang, lukasz.luba
  Cc: linux-pm, linux-kernel, Yijun.Shen, Srinivas Pandruvada

On module exit call proc_thermal_free_msi() to free vectors allocated by
pci_alloc_irq_vectors().

Fixes: 7a9a8c5faf41 ("thermal: intel: int340x: Support MSI interrupt for Lunar Lake")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../intel/int340x_thermal/processor_thermal_device_pci.c       | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index ff296626c498..006614921870 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -431,6 +431,9 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev)
 	proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, 0);
 	proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
 
+	if (msi_irq)
+		proc_thermal_free_msi(pdev, pci_info);
+
 	thermal_zone_device_unregister(pci_info->tzone);
 	proc_thermal_mmio_remove(pdev, pci_info->proc_priv);
 	if (!pci_info->no_legacy)
-- 
2.45.0


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

* Re: [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support
  2024-07-23 14:02 [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Srinivas Pandruvada
                   ` (2 preceding siblings ...)
  2024-07-23 14:02 ` [PATCH 3/3] thermal: intel: int340x: Free MSI IRQ vectors on module exit Srinivas Pandruvada
@ 2024-07-30 13:52 ` Rafael J. Wysocki
  3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2024-07-30 13:52 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: rafael, daniel.lezcano, rui.zhang, lukasz.luba, linux-pm,
	linux-kernel, Yijun.Shen

On Tue, Jul 23, 2024 at 4:02 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> On some pre-production systems, there is a partial support for thermal
> interrupts. This cause kernel warning and fail to register TCPU sensor.
>
> This series address these issues.
>
> Srinivas Pandruvada (3):
>   thermal: intel: int340x: Fix kernel warning during MSI cleanup
>   thermal: intel: int340x: Allow limited thermal MSI support
>   thermal: intel: int340x: Free MSI IRQ vectors on module exit
>
>  .../processor_thermal_device_pci.c            | 29 ++++++++++++++-----
>  1 file changed, 22 insertions(+), 7 deletions(-)
>
> --

All patches applied as 6.11-rc material, thanks!

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

* Re: [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup
  2024-07-23 14:02 ` [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup Srinivas Pandruvada
@ 2024-07-30 14:24   ` Zhang, Rui
  0 siblings, 0 replies; 6+ messages in thread
From: Zhang, Rui @ 2024-07-30 14:24 UTC (permalink / raw)
  To: srinivas.pandruvada, lukasz.luba, rafael, daniel.lezcano
  Cc: linux-pm, linux-kernel, Shen, Yijun

On Tue, 2024-07-23 at 07:02 -0700, Srinivas Pandruvada wrote:
> On some pre-production Lunar Lake systems, there is a kernel
> warning:
> 
> remove_proc_entry: removing non-empty directory 'irq/172'
> WARNING: CPU: 0 PID: 501 at fs/proc/generic.c:717
>         remove_proc_entry+0x1b4/0x1e0
> ...
> ...
> remove_proc_entry+0x1b4/0x1e0
> report_bug+0x182/0x1b0
> handle_bug+0x51/0xa0
> exc_invalid_op+0x18/0x80
> asm_exc_invalid_op+0x1b/0x20
> remove_proc_entry+0x1b4/0x1e0
> remove_proc_entry+0x1b4/0x1e0
> unregister_irq_proc+0xf2/0x120
> free_desc+0x41/0xe0
> irq_domain_free_irqs+0x138/0x1c0
> irq_free_descs+0x52/0x80
> irq_domain_free_irqs+0x151/0x1c0
> msi_domain_free_locked.part.0+0x17e/0x1c0
> msi_domain_free_irqs_all_locked+0x74/0xc0
> pci_msi_teardown_msi_irqs+0x50/0x60
> pci_free_msi_irqs+0x12/0x40
> pci_free_irq_vectors+0x58/0x70
> 
> On these systems, not all the MSI thermal vectors are valid. This
> causes
> devm_request_threaded_irq() to fail for some vectors. As part of the
> clean up on this error, pci_free_irq_vectors() is called without
> calling
> devm_free_irq(). This causes the above warning.
> 
> Add a function proc_thermal_free_msi() to call devm_free_irq() for
> all
> successfully registered IRQ handlers, then call
> pci_free_irq_vectors().
> Call this function for MSI cleanup.
> 
> Fixes: 7a9a8c5faf41 ("thermal: intel: int340x: Support MSI interrupt
> for Lunar Lake")
> Reported-by: Yijun Shen <Yijun.shen@dell.com>
> Tested-by: Yijun Shen <Yijun.shen@dell.com>
> Signed-off-by: Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com>

The whole patch set looks good to me.

Reviewed-by: Zhang Rui <rui.zhang@intel.com>

thanks,
rui
> ---
>  .../processor_thermal_device_pci.c               | 16
> ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git
> a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.
> c
> b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.
> c
> index 114136893a59..2c9c45eb5b4a 100644
> ---
> a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.
> c
> +++
> b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.
> c
> @@ -278,6 +278,18 @@ static struct thermal_zone_params tzone_params =
> {
>  
>  static bool msi_irq;
>  
> +static void proc_thermal_free_msi(struct pci_dev *pdev, struct
> proc_thermal_pci *pci_info)
> +{
> +       int i;
> +
> +       for (i = 0; i < MSI_THERMAL_MAX; i++) {
> +               if (proc_thermal_msi_map[i])
> +                       devm_free_irq(&pdev->dev,
> proc_thermal_msi_map[i], pci_info);
> +       }
> +
> +       pci_free_irq_vectors(pdev);
> +}
> +
>  static int proc_thermal_setup_msi(struct pci_dev *pdev, struct
> proc_thermal_pci *pci_info)
>  {
>         int ret, i, irq;
> @@ -310,7 +322,7 @@ static int proc_thermal_setup_msi(struct pci_dev
> *pdev, struct proc_thermal_pci
>         return 0;
>  
>  err_free_msi_vectors:
> -       pci_free_irq_vectors(pdev);
> +       proc_thermal_free_msi(pdev, pci_info);
>  
>         return ret;
>  }
> @@ -397,7 +409,7 @@ static int proc_thermal_pci_probe(struct pci_dev
> *pdev, const struct pci_device_
>  
>  err_free_vectors:
>         if (msi_irq)
> -               pci_free_irq_vectors(pdev);
> +               proc_thermal_free_msi(pdev, pci_info);
>  err_ret_tzone:
>         thermal_zone_device_unregister(pci_info->tzone);
>  err_del_legacy:


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

end of thread, other threads:[~2024-07-30 14:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-23 14:02 [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Srinivas Pandruvada
2024-07-23 14:02 ` [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup Srinivas Pandruvada
2024-07-30 14:24   ` Zhang, Rui
2024-07-23 14:02 ` [PATCH 2/3] thermal: intel: int340x: Allow limited thermal MSI support Srinivas Pandruvada
2024-07-23 14:02 ` [PATCH 3/3] thermal: intel: int340x: Free MSI IRQ vectors on module exit Srinivas Pandruvada
2024-07-30 13:52 ` [PATCH 0/3] thermal: intel: int340x: Fix Lunar Lake MSI support Rafael J. Wysocki

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

all inboxes | Powered by JetHome®