Skip to contentSkip to conversation

sfc: fix calling of free_irq with already free vector

PATCH Superseded Nikolay Aleksandrov 2 participants 2 messages May 8, 2014 – May 9, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sfc: fix calling of free_irq with already free vector

If the sfc driver is in legacy interrupt mode (either explicitly by using interrupt_mode module param or by falling back to it) it will hit a warning at kernel/irq/manage.c because it will try to free an irq which wasn't allocated by it in the first place because the MSI(X) irqs are zero and it'll try to free them unconditionally. So fix it by checking if we're in legacy mode and freeing the appropriate irqs.

CC Zenghui Shi <[email protected]>
CC Ben Hutchings <[email protected]>
CC Shradha Shah <[email protected]>
CC David S. Miller <[email protected]>
Fixes 1899c111a535 ("sfc: Fix IRQ cleanup in case of a probe failure")

---
v2: Change the fix to check for the interrupt mode and adjust the commit message.

 drivers/net/ethernet/sfc/nic.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/sfc/nic.c +8 -6
index 32d969e857f7..43761d3b8651 100644
@@ -156,13 +156,15 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
 	efx->net_dev->rx_cpu_rmap = NULL;
 #endif
 
-	/* Disable MSI/MSI-X interrupts */
-	efx_for_each_channel(channel, efx)
-		free_irq(channel->irq, &efx->msi_context[channel->channel]);
-
-	/* Disable legacy interrupt */
-	if (efx->legacy_irq)
+	if (efx->interrupt_mode != EFX_INT_MODE_LEGACY) {
+		/* Disable MSI/MSI-X interrupts */
+		efx_for_each_channel(channel, efx)
+			free_irq(channel->irq,
+				 &efx->msi_context[channel->channel]);
+	} else {
+		/* Disable legacy interrupt */
 		free_irq(efx->legacy_irq, efx);
+	}
 }
 
 /* Register dump */
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 6 lines · Nikolay Aleksandrov

If the sfc driver is in legacy interrupt mode (either explicitly by using interrupt_mode module param or by falling back to it) it will hit a warning at kernel/irq/manage.c because it will try to free an irq which wasn't allocated by it in the first place because the MSI(X) irqs are zero and it'll try to free them unconditionally. So fix it by checking if we're in legacy mode and freeing the appropriate irqs.

Oops, I think we had given up regular testing legacy interrupts by this point as there seemed to be no real need for them.

Quoted 21 lines
CC Zenghui Shi <[email protected]>
CC Ben Hutchings <[email protected]>
CC Shradha Shah <[email protected]>
CC David S. Miller <[email protected]>
Fixes 1899c111a535 ("sfc: Fix IRQ cleanup in case of a probe failure")

---
v2: Change the fix to check for the interrupt mode and adjust the commit message.

 drivers/net/ethernet/sfc/nic.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/sfc/nic.c +0 -0
index 32d969e857f7..43761d3b8651 100644

drivers/net/ethernet/sfc/nic.c void efx_nic_fini_interrupt(struct efx_nic *efx) · line 159

Quoted 10 lines
drivers/net/ethernet/sfc/nic.c +1 -6
@@ -156,13 +156,15 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
 	efx->net_dev->rx_cpu_rmap = NULL;
 #endif
 
-	/* Disable MSI/MSI-X interrupts */
-	efx_for_each_channel(channel, efx)
-		free_irq(channel->irq, &efx->msi_context[channel->channel]);
-
-	/* Disable legacy interrupt */
-	if (efx->legacy_irq)
+	if (efx->interrupt_mode != EFX_INT_MODE_LEGACY) {

Minor nit: this could use EFX_INT_MODE_USE_MSI(efx), same as in efx_nic_init_interrupt().

drivers/net/ethernet/sfc/nic.c void efx_nic_fini_interrupt(struct efx_nic *efx) · line 170

Quoted 11 lines
drivers/net/ethernet/sfc/nic.c +7 -0
+		/* Disable MSI/MSI-X interrupts */
+		efx_for_each_channel(channel, efx)
+			free_irq(channel->irq,
+				 &efx->msi_context[channel->channel]);
+	} else {
+		/* Disable legacy interrupt */
 		free_irq(efx->legacy_irq, efx);
+	}
 }
 
 /* Register dump */

Ben.

Signature · 2 lines
Ben Hutchings
Beware of programmers who carry screwdrivers. - Leonard Brandwein