Skip to content

Commit d955d7c

Browse files
committed
Merge branch 'thermal-intel'
Merge fixes for the int340x thermal driver handling of MSI IRQs: - Fix MSI error path cleanup in int340x, allow it to work with a subset of thermal MSI IRQs if some of them are not working and make it free all MSI IRQs on module exit (Srinivas Pandruvada). * thermal-intel: thermal: intel: int340x: Free MSI IRQ vectors on module exit thermal: intel: int340x: Allow limited thermal MSI support thermal: intel: int340x: Fix kernel warning during MSI cleanup
2 parents f844793 + f8ce49b commit d955d7c

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,32 @@ static struct thermal_zone_params tzone_params = {
278278

279279
static bool msi_irq;
280280

281+
static void proc_thermal_free_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
282+
{
283+
int i;
284+
285+
for (i = 0; i < MSI_THERMAL_MAX; i++) {
286+
if (proc_thermal_msi_map[i])
287+
devm_free_irq(&pdev->dev, proc_thermal_msi_map[i], pci_info);
288+
}
289+
290+
pci_free_irq_vectors(pdev);
291+
}
292+
281293
static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
282294
{
283-
int ret, i, irq;
295+
int ret, i, irq, count;
284296

285-
ret = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
286-
if (ret < 0) {
297+
count = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
298+
if (count < 0) {
287299
dev_err(&pdev->dev, "Failed to allocate vectors!\n");
288-
return ret;
300+
return count;
289301
}
290302

291303
dev_info(&pdev->dev, "msi enabled:%d msix enabled:%d\n", pdev->msi_enabled,
292304
pdev->msix_enabled);
293305

294-
for (i = 0; i < MSI_THERMAL_MAX; i++) {
306+
for (i = 0; i < count; i++) {
295307
irq = pci_irq_vector(pdev, i);
296308

297309
ret = devm_request_threaded_irq(&pdev->dev, irq, proc_thermal_irq_handler,
@@ -310,7 +322,7 @@ static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci
310322
return 0;
311323

312324
err_free_msi_vectors:
313-
pci_free_irq_vectors(pdev);
325+
proc_thermal_free_msi(pdev, pci_info);
314326

315327
return ret;
316328
}
@@ -397,7 +409,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
397409

398410
err_free_vectors:
399411
if (msi_irq)
400-
pci_free_irq_vectors(pdev);
412+
proc_thermal_free_msi(pdev, pci_info);
401413
err_ret_tzone:
402414
thermal_zone_device_unregister(pci_info->tzone);
403415
err_del_legacy:
@@ -419,6 +431,9 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev)
419431
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, 0);
420432
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
421433

434+
if (msi_irq)
435+
proc_thermal_free_msi(pdev, pci_info);
436+
422437
thermal_zone_device_unregister(pci_info->tzone);
423438
proc_thermal_mmio_remove(pdev, pci_info->proc_priv);
424439
if (!pci_info->no_legacy)

0 commit comments

Comments
 (0)