i2c: designware-pci: Fix BUG_ON during device removal
Subsystems (4)
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().
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-designware-pcidrv.c +1 -0
@@ -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
Quoted 8 lines · Jarkko Nikula
Function
i2c_dw_pci_remove()->pci_free_irq_vectors()->pci_disable_msi()->free_msi_irqs()will throw aBUG_ON()for MSI enabled device since the driver has not released the requested IRQ before calling thepci_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 callingpci_free_irq_vectors().
Does it make sense to keep devm for irq handling, then?
Quoted 9 lines · Jarkko Nikula
Function
i2c_dw_pci_remove()->pci_free_irq_vectors()->pci_disable_msi()->free_msi_irqs()will throw aBUG_ON()for MSI enabled device since the driver has not released the requested IRQ before calling thepci_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 callingpci_free_irq_vectors().
Quoted 22 lines
Fixes 21aa3983d619 ("i2c: designware-pci: Switch over to MSI interrupts")Cc [email protected] # v5.4+Signed-off-by Jarkko Nikula <[email protected]>--- drivers/i2c/busses/i2c-designware-pcidrv.c | 1 + 1 file changed, 1 insertion(+)drivers/i2c/busses/i2c-designware-pcidrv.c +1
-0@@ -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
Andy Shevchenko
reviewerQuoted 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 aBUG_ON()for MSI enabled device since the driver has not released the requested IRQ before calling thepci_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 callingpci_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
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 aBUG_ON()for MSI enabled device since the driver has not released the requested IRQ before calling thepci_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 callingpci_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
Wolfram Sang
AppliedQuoted 5 lines · Jarkko Nikula
Function
i2c_dw_pci_remove()->pci_free_irq_vectors()->pci_disable_msi()->free_msi_irqs()will throw aBUG_ON()for MSI enabled device since the driver has not released the requested IRQ before calling thepci_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 callingpci_free_irq_vectors().Fixes 21aa3983d619 ("i2c: designware-pci: Switch over to MSI interrupts")Cc [email protected] # v5.4+Signed-off-by Jarkko Nikula <[email protected]>
Applied to for-current, thanks!