Skip to contentSkip to conversation

i2c: designware-pci: Fix BUG_ON during device removal

PATCH Applied Jarkko Nikula 3 participants 6 messages Feb 13, 2020 – Mar 10, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: designware-pci: Fix BUG_ON during device removal

Function i2c_dw_pci_remove() -> pci_free_irq_vectors() -> pci_disable_msi() -> free_msi_irqs() will throw a BUG_ON() for MSI enabled device since the driver has not released the requested IRQ before calling the pci_free_irq_vectors().

Here driver requests an IRQ using devm_request_irq() but automatic release happens only after remove callback. Fix this by explicitly freeing the IRQ before calling pci_free_irq_vectors().

Fixes 21aa3983d619 ("i2c: designware-pci: Switch over to MSI interrupts")
---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-designware-pcidrv.c +1 -0
index 050adda7c1bd..05b35ac33ce3 100644
@@ -313,6 +313,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
 	pm_runtime_get_noresume(&pdev->dev);
 
 	i2c_del_adapter(&dev->adapter);
+	devm_free_irq(&pdev->dev, dev->irq, dev);
 	pci_free_irq_vectors(pdev);
 }
 
Signature · 1 line
2.25.0
#1 lore raw
Quoted 8 lines · Jarkko Nikula

Function i2c_dw_pci_remove() -> pci_free_irq_vectors() -> pci_disable_msi() -> free_msi_irqs() will throw a BUG_ON() for MSI enabled device since the driver has not released the requested IRQ before calling the pci_free_irq_vectors().

Here driver requests an IRQ using devm_request_irq() but automatic release happens only after remove callback. Fix this by explicitly freeing the IRQ before calling pci_free_irq_vectors().

Does it make sense to keep devm for irq handling, then?

reviewer Reviewed-by on v1 1/1
#4 lore raw
In reply to Jarkko Nikula
Quoted 9 lines · Jarkko Nikula

Function i2c_dw_pci_remove() -> pci_free_irq_vectors() -> pci_disable_msi() -> free_msi_irqs() will throw a BUG_ON() for MSI enabled device since the driver has not released the requested IRQ before calling the pci_free_irq_vectors().

Here driver requests an IRQ using devm_request_irq() but automatic release happens only after remove callback. Fix this by explicitly freeing the IRQ before calling pci_free_irq_vectors().

Quoted 22 lines
Fixes 21aa3983d619 ("i2c: designware-pci: Switch over to MSI interrupts")
---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-designware-pcidrv.c +1 -0
index 050adda7c1bd..05b35ac33ce3 100644
@@ -313,6 +313,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
 	pm_runtime_get_noresume(&pdev->dev);
 
 	i2c_del_adapter(&dev->adapter);
+	devm_free_irq(&pdev->dev, dev->irq, dev);
 	pci_free_irq_vectors(pdev);
 }
 
Signature · 1 line
2.25.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to Wolfram Sang
Quoted 11 lines · Wolfram Sang
Quoted 8 lines · Jarkko Nikula

Function i2c_dw_pci_remove() -> pci_free_irq_vectors() -> pci_disable_msi() -> free_msi_irqs() will throw a BUG_ON() for MSI enabled device since the driver has not released the requested IRQ before calling the pci_free_irq_vectors().

Here driver requests an IRQ using devm_request_irq() but automatic release happens only after remove callback. Fix this by explicitly freeing the IRQ before calling pci_free_irq_vectors().

Does it make sense to keep devm for irq handling, then?

Only for sake of better error handling in error path in the ->probe().

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Wolfram Sang
Quoted 5 lines · Jarkko Nikula

Function i2c_dw_pci_remove() -> pci_free_irq_vectors() -> pci_disable_msi() -> free_msi_irqs() will throw a BUG_ON() for MSI enabled device since the driver has not released the requested IRQ before calling the pci_free_irq_vectors().

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

Here driver requests an IRQ using devm_request_irq() but automatic release happens only after remove callback. Fix this by explicitly freeing the IRQ before calling pci_free_irq_vectors().

Does it make sense to keep devm for irq handling, then?

I thought about it and decided devm still saves one line of code in drivers/i2c/busses/i2c-designware-platdrv.c: dw_i2c_plat_remove().

Quoted 2 lines

Only for sake of better error handling in error path in the ->probe().

Yeah, that too.

Signature · 1 line
Jarkko
Applied
#5 lore raw
In reply to Jarkko Nikula
Quoted 5 lines · Jarkko Nikula

Function i2c_dw_pci_remove() -> pci_free_irq_vectors() -> pci_disable_msi() -> free_msi_irqs() will throw a BUG_ON() for MSI enabled device since the driver has not released the requested IRQ before calling the pci_free_irq_vectors().

Quoted 7 lines

Here driver requests an IRQ using devm_request_irq() but automatic release happens only after remove callback. Fix this by explicitly freeing the IRQ before calling pci_free_irq_vectors().

Fixes 21aa3983d619 ("i2c: designware-pci: Switch over to MSI interrupts")

Applied to for-current, thanks!