Skip to contentSkip to conversation

thermal: intel: int340x: Fix Lunar Lake MSI support

PATCH In review Srinivas Pandruvada 3 participants 6 messages Jul 23, 2024 – Jul 30, 2024 Thermal

lore
Share & tools
lore
#0 lore raw

cover thermal: intel: int340x: Fix Lunar Lake MSI support

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(-)
Signature · 1 line
2.45.0
#1 lore raw

PATCH 1/3 thermal: intel: int340x: Fix kernel warning during MSI cleanup

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")
---
 .../processor_thermal_device_pci.c               | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +14 -2
index 114136893a59..2c9c45eb5b4a 100644
@@ -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:
Signature · 1 line
2.45.0
reviewer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] thermal: intel: int340x: Fix kernel warning during MSI cleanup

Quoted 39 lines · Srinivas Pandruvada

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.

Quoted 6 lines
Fixes 7a9a8c5faf41 ("thermal: intel: int340x: Support MSI interrupt

for Lunar Lake")

Signed-off-by Srinivas Pandruvada

<[email protected]>

The whole patch set looks good to me.

thanks,
rui

Quoted 60 lines

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

(quoted diff) +0 -0
@@ -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)

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +6 -0
+{
+       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);
+       }

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +4 -0
+
+       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;

(quoted diff) +0 -0
@@ -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;
 }

(quoted diff) +0 -0
@@ -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:

#3 lore raw

PATCH 2/3 thermal: intel: int340x: Allow limited thermal MSI support

In reply to 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")
---
 .../int340x_thermal/processor_thermal_device_pci.c     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +5 -5
index 2c9c45eb5b4a..ff296626c498 100644
@@ -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,
Signature · 1 line
2.45.0
#4 lore raw

PATCH 3/3 thermal: intel: int340x: Free MSI IRQ vectors on module exit

In reply to 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")
---
 .../intel/int340x_thermal/processor_thermal_device_pci.c       | 3 +++
 1 file changed, 3 insertions(+)
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +3 -0
index ff296626c498..006614921870 100644
@@ -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)
Signature · 1 line
2.45.0
#5 lore raw
In reply to Srinivas Pandruvada
Quoted 11 lines · 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

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

--

All patches applied as 6.11-rc material, thanks!