Skip to contentSkip to conversation

fbnic: Set napi irq value after calling netif_napi_add

PATCH Applied Brett Creeley 4 participants 4 messages Sep 12, 2024 – Sep 14, 2024

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

PATCH 1/1 fbnic: Set napi irq value after calling netif_napi_add

The driver calls netif_napi_set_irq() and then calls netif_napi_add(), which calls netif_napi_add_weight(). At the end of netif_napi_add_weight() is a call to netif_napi_set_irq(napi, -1), which clears the previously set napi->irq value. Fix this by calling netif_napi_set_irq() after calling netif_napi_add().

This was found when reviewing another patch and I have no way to test this, but the fix seemed relatively straight forward.

Fixes bc6107771bb4 ("eth: fbnic: Allocate a netdevice and napi vectors with queues")
---
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +4 -4
index 0ed4c9fff5d8..72f88ae7815f 100644
@@ -1012,14 +1012,14 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
 	nv->fbd = fbd;
 	nv->v_idx = v_idx;
 
-	/* Record IRQ to NAPI struct */
-	netif_napi_set_irq(&nv->napi,
-			   pci_irq_vector(to_pci_dev(fbd->dev), nv->v_idx));
-
 	/* Tie napi to netdev */
 	list_add(&nv->napis, &fbn->napis);
 	netif_napi_add(fbn->netdev, &nv->napi, fbnic_poll);
 
+	/* Record IRQ to NAPI struct */
+	netif_napi_set_irq(&nv->napi,
+			   pci_irq_vector(to_pci_dev(fbd->dev), nv->v_idx));
+
 	/* Tie nv back to PCIe dev */
 	nv->dev = fbd->dev;
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Brett Creeley

The driver calls netif_napi_set_irq() and then calls netif_napi_add(), which calls netif_napi_add_weight(). At the end of netif_napi_add_weight() is a call to netif_napi_set_irq(napi, -1), which clears the previously set napi->irq value. Fix this by calling netif_napi_set_irq() after calling netif_napi_add().

Quoted 6 lines

This was found when reviewing another patch and I have no way to test this, but the fix seemed relatively straight forward.

Fixes bc6107771bb4 ("eth: fbnic: Allocate a netdevice and napi vectors with queues")

I agree with your analysis, but I'm not sure if this needs to be backported to other kernels because:
- It is not a device that is easily available (currently),
- The bug is relatively minor

I'm not a maintainer so I'll let those folks decide if this should be a net-next thing to reduce load on the stable folks.

In any case:

Reviewed-by on v1 1/1
#2 lore raw
In reply to Brett Creeley
Quoted 11 lines · Brett Creeley

The driver calls netif_napi_set_irq() and then calls netif_napi_add(), which calls netif_napi_add_weight(). At the end of netif_napi_add_weight() is a call to netif_napi_set_irq(napi, -1), which clears the previously set napi->irq value. Fix this by calling netif_napi_set_irq() after calling netif_napi_add().

This was found when reviewing another patch and I have no way to test this, but the fix seemed relatively straight forward.

Fixes bc6107771bb4 ("eth: fbnic: Allocate a netdevice and napi vectors with queues")

I agree that irq vector is lost without this patch.

#3 lore raw
In reply to Brett Creeley
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 12 Sep 2024 10:49:22 -0700 you wrote:

The driver calls netif_napi_set_irq() and then calls netif_napi_add(), which calls netif_napi_add_weight(). At the end of netif_napi_add_weight() is a call to netif_napi_set_irq(napi, -1), which clears the previously set napi->irq value. Fix this by calling netif_napi_set_irq() after calling netif_napi_add().

This was found when reviewing another patch and I have no way to test this, but the fix seemed relatively straight forward.

[...]

Here is the summary with links:
- [net] fbnic: Set napi irq value after calling netif_napi_add

    https://git.kernel.org/netdev/net/c/9f3e7f11f21a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html