Skip to contentSkip to conversation

bnxt_en: eliminate the compile warning in bnxt_request_irq due to CONFIG_RFS_ACCEL

PATCH Superseded Jason Xing 4 participants 10 messages Jun 29, 2025 – Jul 2, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jason Xing

author
#0 lore raw

PATCH 1/1 bnxt_en: eliminate the compile warning in bnxt_request_irq due to CONFIG_RFS_ACCEL

From: Jason Xing <[email protected]>

I received a kernel-test-bot report[1] that shows the [-Wunused-but-set-variable] warning. Since the previous commit[2] I made gives users an option to turn on and off the CONFIG_RFS_ACCEL, the issue then can be discovered and reproduced. Move the @i into the protection of CONFIG_RFS_ACCEL.

[1]
All warnings (new ones prefixed by >>):

drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_request_irq':

Quoted 1 line
Quoted 1 line

drivers/net/ethernet/broadcom/bnxt/bnxt.c:10703:9: warning: variable 'j' set but not used [-Wunused-but-set-variable]

10703 | int i, j, rc = 0;
| ^

[2]
commit 9b6a30febddf ("net: allow rps/rfs related configs to be switched")

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -2
index 869580b6f70d..7369b39380d0 100644
@@ -11538,9 +11538,10 @@ static void bnxt_free_irq(struct bnxt *bp)
 
 static int bnxt_request_irq(struct bnxt *bp)
 {
-	int i, j, rc = 0;
+	int i, rc = 0;
 	unsigned long flags = 0;
 #ifdef CONFIG_RFS_ACCEL
+	int j = 0;
 	struct cpu_rmap *rmap;
 #endif
 
@@ -11559,7 +11560,7 @@ static int bnxt_request_irq(struct bnxt *bp)
 	if (!rc)
 		bp->tph_mode = PCI_TPH_ST_IV_MODE;
 
-	for (i = 0, j = 0; i < bp->cp_nr_rings; i++) {
+	for (i = 0; i < bp->cp_nr_rings; i++) {
 		int map_idx = bnxt_cp_num_to_irq_num(bp, i);
 		struct bnxt_irq *irq = &bp->irq_tbl[map_idx];
 
Signature · 1 line
2.41.3
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Jason Xing

From: Jason Xing <[email protected]>

I received a kernel-test-bot report[1] that shows the [-Wunused-but-set-variable] warning. Since the previous commit[2] I made gives users an option to turn on and off the CONFIG_RFS_ACCEL, the issue then can be discovered and reproduced. Move the @i into the protection of CONFIG_RFS_ACCEL.

[1]
All warnings (new ones prefixed by >>):

drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_request_irq':

Quoted 1 line
Quoted 1 line

drivers/net/ethernet/broadcom/bnxt/bnxt.c:10703:9: warning: variable 'j' set but not used [-Wunused-but-set-variable]

10703 | int i, j, rc = 0;
| ^

Quoted 6 lines

[2]
commit 9b6a30febddf ("net: allow rps/rfs related configs to be switched")

Not for net, but it would be nice to factor the #ifdefs out of this function entirely. E.g. by using a helper to perform that part of the initialisation.

...

author
#2 lore raw
Quoted 18 lines · Simon Horman
Quoted 16 lines · Jason Xing

From: Jason Xing <[email protected]>

I received a kernel-test-bot report[1] that shows the [-Wunused-but-set-variable] warning. Since the previous commit[2] I made gives users an option to turn on and off the CONFIG_RFS_ACCEL, the issue then can be discovered and reproduced. Move the @i into the protection of CONFIG_RFS_ACCEL.

[1]
All warnings (new ones prefixed by >>):

drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_request_irq':

Quoted 1 line
Quoted 1 line

drivers/net/ethernet/broadcom/bnxt/bnxt.c:10703:9: warning: variable 'j' set but not used [-Wunused-but-set-variable]

10703 | int i, j, rc = 0;
| ^

Quoted 8 lines
Quoted 6 lines

[2]
commit 9b6a30febddf ("net: allow rps/rfs related configs to be switched")

Thanks.

Quoted 4 lines

Not for net, but it would be nice to factor the #ifdefs out of this function entirely. E.g. by using a helper to perform that part of the initialisation.

Got it. I will cook a patch after this patch is landed on the net-next branch.

Thanks,
Jason

maintainer
#3 lore raw
Quoted 5 lines · On Mon, 30 Jun 2025 19:47:47 +0800 Jason Xing wrote:
Quoted 3 lines

Not for net, but it would be nice to factor the #ifdefs out of this function entirely. E.g. by using a helper to perform that part of the initialisation.

Got it. I will cook a patch after this patch is landed on the net-next branch.

Maybe we can fix it right already. The compiler should not complain if it sees the read:

drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -6
index f621a5bab1ea..6bbe875132b0 100644
@@ -11616,11 +11616,9 @@ static void bnxt_free_irq(struct bnxt *bp)
 
 static int bnxt_request_irq(struct bnxt *bp)
 {
+       struct cpu_rmap *rmap = NULL;
        int i, j, rc = 0;
        unsigned long flags = 0;
-#ifdef CONFIG_RFS_ACCEL
-       struct cpu_rmap *rmap;
-#endif
 
        rc = bnxt_setup_int_mode(bp);
        if (rc) {
@@ -11641,15 +11639,15 @@ static int bnxt_request_irq(struct bnxt *bp)
                int map_idx = bnxt_cp_num_to_irq_num(bp, i);
                struct bnxt_irq *irq = &bp->irq_tbl[map_idx];
 
-#ifdef CONFIG_RFS_ACCEL
-               if (rmap && bp->bnapi[i]->rx_ring) {
+               if (IS_ENABLED(CONFIG_RFS_ACCEL) &&
+                   rmap && bp->bnapi[i]->rx_ring) {
                        rc = irq_cpu_rmap_add(rmap, irq->vector);
                        if (rc)
                                netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n",
                                            j);
                        j++;
                }
-#endif
+
                rc = request_irq(irq->vector, irq->handler, flags, irq->name,
                                 bp->bnapi[i]);
                if (rc)
Signature · 1 line
pw-bot: cr
author
#4 lore raw
Quoted 16 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 30 Jun 2025 19:47:47 +0800 Jason Xing wrote:
Quoted 3 lines

Not for net, but it would be nice to factor the #ifdefs out of this function entirely. E.g. by using a helper to perform that part of the initialisation.

Got it. I will cook a patch after this patch is landed on the net-next branch.

Maybe we can fix it right already. The compiler should not complain if it sees the read:

drivers/net/ethernet/broadcom/bnxt/bnxt.c +0 -0
index f621a5bab1ea..6bbe875132b0 100644

drivers/net/ethernet/broadcom/bnxt/bnxt.c static void bnxt_free_irq(struct bnxt *bp) · line 11623

Quoted 9 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -3
@@ -11616,11 +11616,9 @@ static void bnxt_free_irq(struct bnxt *bp)
 
 static int bnxt_request_irq(struct bnxt *bp)
 {
+       struct cpu_rmap *rmap = NULL;
        int i, j, rc = 0;
        unsigned long flags = 0;
-#ifdef CONFIG_RFS_ACCEL
-       struct cpu_rmap *rmap;
-#endif

Sorry, Jakub. I failed to see the positive point of this kind of change comparatively.

drivers/net/ethernet/broadcom/bnxt/bnxt.c static void bnxt_free_irq(struct bnxt *bp) · line 11624

Quoted 3 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +0 -0
        rc = bnxt_setup_int_mode(bp);
        if (rc) {

Probably in this position, you expect 'rmap = bp->dev->rx_cpu_rmap;' to stay there even when CONFIG_RFS_ACCEL is off?

The report says it's 'j' that causes the complaint.

Thanks,
Jason

Quoted 21 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -4
@@ -11641,15 +11639,15 @@ static int bnxt_request_irq(struct bnxt *bp)
                int map_idx = bnxt_cp_num_to_irq_num(bp, i);
                struct bnxt_irq *irq = &bp->irq_tbl[map_idx];
 
-#ifdef CONFIG_RFS_ACCEL
-               if (rmap && bp->bnapi[i]->rx_ring) {
+               if (IS_ENABLED(CONFIG_RFS_ACCEL) &&
+                   rmap && bp->bnapi[i]->rx_ring) {
                        rc = irq_cpu_rmap_add(rmap, irq->vector);
                        if (rc)
                                netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n",
                                            j);
                        j++;
                }
-#endif
+
                rc = request_irq(irq->vector, irq->handler, flags, irq->name,
                                 bp->bnapi[i]);
                if (rc)
--

pw-bot: cr

maintainer
#5 lore raw
Quoted 11 lines · On Wed, 2 Jul 2025 08:47:08 +0800 Jason Xing wrote:

drivers/net/ethernet/broadcom/bnxt/bnxt.c static void bnxt_free_irq(struct bnxt *bp) · line 11623

Quoted 8 lines

static int bnxt_request_irq(struct bnxt *bp)
{

drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -3
+       struct cpu_rmap *rmap = NULL;
        int i, j, rc = 0;
        unsigned long flags = 0;
-#ifdef CONFIG_RFS_ACCEL
-       struct cpu_rmap *rmap;
-#endif  

Sorry, Jakub. I failed to see the positive point of this kind of change comparatively.

Like Simon said -- fewer #ifdefs leads to fewer bugs of this nature. Or do you mean that you don't understand how my fix works?

Quoted 5 lines
Quoted 2 lines
        rc = bnxt_setup_int_mode(bp);
        if (rc) {  

Probably in this position, you expect 'rmap = bp->dev->rx_cpu_rmap;' to stay there even when CONFIG_RFS_ACCEL is off?

no, dev->rx_cpu_rmap doesn't exist if RDS_ACCEL=n

Quoted 1 line

The report says it's 'j' that causes the complaint.

author
#6 lore raw
Quoted 14 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 2 Jul 2025 08:47:08 +0800 Jason Xing wrote:

drivers/net/ethernet/broadcom/bnxt/bnxt.c static void bnxt_free_irq(struct bnxt *bp) · line 11623

Quoted 8 lines

static int bnxt_request_irq(struct bnxt *bp)
{

drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -3
+       struct cpu_rmap *rmap = NULL;
        int i, j, rc = 0;
        unsigned long flags = 0;
-#ifdef CONFIG_RFS_ACCEL
-       struct cpu_rmap *rmap;
-#endif

Sorry, Jakub. I failed to see the positive point of this kind of change comparatively.

Quoted 1 line

Like Simon said -- fewer #ifdefs leads to fewer bugs of this nature.

Agree on this point.

Quoted 1 line

Or do you mean that you don't understand how my fix works?

I understand but my previous thought was not like this.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
        rc = bnxt_setup_int_mode(bp);
        if (rc) {

Probably in this position, you expect 'rmap = bp->dev->rx_cpu_rmap;' to stay there even when CONFIG_RFS_ACCEL is off?

no, dev->rx_cpu_rmap doesn't exist if RDS_ACCEL=n

I was trying to say 'readability' of rmap so I used 'stay' on purpose. As to the core of the patch you provided, it works for sure.

I will send a v2 as you advised :)

Thanks,
Jason

Quoted 2 lines
Quoted 2 lines

The report says it's 'j' that causes the complaint.

author
#7 lore raw
Quoted 16 lines · Jason Xing
Quoted 14 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 2 Jul 2025 08:47:08 +0800 Jason Xing wrote:

drivers/net/ethernet/broadcom/bnxt/bnxt.c static void bnxt_free_irq(struct bnxt *bp) · line 11623

Quoted 8 lines

static int bnxt_request_irq(struct bnxt *bp)
{

drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -3
+       struct cpu_rmap *rmap = NULL;
        int i, j, rc = 0;
        unsigned long flags = 0;
-#ifdef CONFIG_RFS_ACCEL
-       struct cpu_rmap *rmap;
-#endif

Sorry, Jakub. I failed to see the positive point of this kind of change comparatively.

Quoted 5 lines
Quoted 1 line

Like Simon said -- fewer #ifdefs leads to fewer bugs of this nature.

Agree on this point.

Quoted 1 line

Or do you mean that you don't understand how my fix works?

Oh, thanks to the word 'fix' you mentioned. It seems that I'm supposed to add Fixes: tag...

maintainer
#8 lore raw
Quoted 9 lines · On Wed, 2 Jul 2025 09:11:35 +0800 Jason Xing wrote:
Quoted 6 lines
Quoted 2 lines

Like Simon said -- fewer #ifdefs leads to fewer bugs of this nature.

Agree on this point.

Quoted 1 line

Or do you mean that you don't understand how my fix works?

Oh, thanks to the word 'fix' you mentioned. It seems that I'm supposed to add Fixes: tag...

Yes, change the commit reference to a full Fixes tag.
Also -- may be worth mentioning that it happens with GCC specifically. My first try to reproduce was with clang and it seems not to show this warning even with W=1

maintainer Reviewed-by on v1 1/1
#9 lore raw
In reply to Jason Xing
Quoted 17 lines · Jason Xing

From: Jason Xing <[email protected]>

I received a kernel-test-bot report[1] that shows the [-Wunused-but-set-variable] warning. Since the previous commit[2] I made gives users an option to turn on and off the CONFIG_RFS_ACCEL, the issue then can be discovered and reproduced. Move the @i into the protection of CONFIG_RFS_ACCEL.

[1]
All warnings (new ones prefixed by >>):

drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_request_irq':

Quoted 1 line
Quoted 1 line

drivers/net/ethernet/broadcom/bnxt/bnxt.c:10703:9: warning: variable 'j' set but not used [-Wunused-but-set-variable]

10703 | int i, j, rc = 0;
| ^

Quoted 6 lines

[2]
commit 9b6a30febddf ("net: allow rps/rfs related configs to be switched")

Thanks.