bnxt_en: eliminate the compile warning in bnxt_request_irq due to CONFIG_RFS_ACCEL
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
@@ -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
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 ofCONFIG_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]
commit9b6a30febddf("net: allow rps/rfs related configs to be switched")Reported-by kernel test robot <[email protected]>Signed-off-by Jason Xing <[email protected]>
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.
...
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 ofCONFIG_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]
commit9b6a30febddf("net: allow rps/rfs related configs to be switched")Reported-by kernel test robot <[email protected]>Signed-off-by Jason Xing <[email protected]>Reviewed-by Simon Horman <[email protected]>
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
Jakub Kicinski
maintainerQuoted 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
@@ -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
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
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
-0rc =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
Jakub Kicinski
maintainerQuoted 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 whenCONFIG_RFS_ACCELis 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.
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 whenCONFIG_RFS_ACCELis off?no,
dev->rx_cpu_rmapdoesn'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.
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...
Jakub Kicinski
maintainerQuoted 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
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 ofCONFIG_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]
commit9b6a30febddf("net: allow rps/rfs related configs to be switched")Reported-by kernel test robot <[email protected]>Signed-off-by Jason Xing <[email protected]>
Thanks.