* [PATCH net] qed: Fix missing bar_id comparison in qed_hw_bar_size()
@ 2026-11-19 17:04 Ian Rogers
2026-11-23 9:12 ` Daniel Machon
2026-11-25 15:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2026-11-19 17:04 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, llvm, Elkin Cruz, Ian Rogers
When PGLUE_B_REG_PF_BAR{0,1}_SIZE reads back as 0 on older management
firmware with multi-hwfn devices, qed_hw_bar_size() logs that it assumes
256 KiB for GRC (BAR_ID_0) and 512 KiB for DB (BAR_ID_1), but evaluates:
return BAR_ID_0 ? 256 * 1024 : 512 * 1024;
Because BAR_ID_0 is enum constant 0, the ternary condition is always
false and qed_hw_bar_size() unconditionally returns 512 KiB even for
BAR_ID_0, doubling the computed GRC BAR offset for the second hardware
function.
Compare bar_id == BAR_ID_0 as intended (matching the bar_reg selection
at the top of qed_hw_bar_size()).
Found by enabling Clang's -Wunreachable-code on an x86_64 allyesconfig
build, with AI coding assistant help to audit the warning and prepare
the fix. Build-tested with Clang; not runtime-tested on QLogic hardware.
Fixes: c2035eea3e9e ("qed: Correct BAR sizes for older MFW")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/net/ethernet/qlogic/qed/qed_dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index dd75c47758e1..3e84f53dfb50 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -1264,11 +1264,11 @@ static u32 qed_hw_bar_size(struct qed_hwfn *p_hwfn,
if (p_hwfn->cdev->num_hwfns > 1) {
DP_INFO(p_hwfn,
"BAR size not configured. Assuming BAR size of 256kB for GRC and 512kB for DB\n");
- return BAR_ID_0 ? 256 * 1024 : 512 * 1024;
+ return bar_id == BAR_ID_0 ? 256 * 1024 : 512 * 1024;
} else {
DP_INFO(p_hwfn,
"BAR size not configured. Assuming BAR size of 512kB for GRC and 512kB for DB\n");
- return 512 * 1024;
+ return 512 * 1024;
}
}
--
2.56.1.708.g77570a6a1d-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] qed: Fix missing bar_id comparison in qed_hw_bar_size()
2026-11-19 17:04 [PATCH net] qed: Fix missing bar_id comparison in qed_hw_bar_size() Ian Rogers
@ 2026-11-23 9:12 ` Daniel Machon
2026-11-25 15:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Machon @ 2026-11-23 9:12 UTC (permalink / raw)
To: Ian Rogers
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, linux-kernel, llvm, Elkin Cruz
> When PGLUE_B_REG_PF_BAR{0,1}_SIZE reads back as 0 on older management
> firmware with multi-hwfn devices, qed_hw_bar_size() logs that it assumes
> 256 KiB for GRC (BAR_ID_0) and 512 KiB for DB (BAR_ID_1), but evaluates:
>
> return BAR_ID_0 ? 256 * 1024 : 512 * 1024;
>
> Because BAR_ID_0 is enum constant 0, the ternary condition is always
> false and qed_hw_bar_size() unconditionally returns 512 KiB even for
> BAR_ID_0, doubling the computed GRC BAR offset for the second hardware
> function.
>
> Compare bar_id == BAR_ID_0 as intended (matching the bar_reg selection
> at the top of qed_hw_bar_size()).
>
> Found by enabling Clang's -Wunreachable-code on an x86_64 allyesconfig
> build, with AI coding assistant help to audit the warning and prepare
> the fix. Build-tested with Clang; not runtime-tested on QLogic hardware.
>
> Fixes: c2035eea3e9e ("qed: Correct BAR sizes for older MFW")
> Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] qed: Fix missing bar_id comparison in qed_hw_bar_size()
2026-11-19 17:04 [PATCH net] qed: Fix missing bar_id comparison in qed_hw_bar_size() Ian Rogers
2026-11-23 9:12 ` Daniel Machon
@ 2026-11-25 15:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-25 15:40 UTC (permalink / raw)
To: Ian Rogers
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-kernel, llvm, elkin
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Thu, 19 Nov 2026 09:04:12 -0800 you wrote:
> When PGLUE_B_REG_PF_BAR{0,1}_SIZE reads back as 0 on older management
> firmware with multi-hwfn devices, qed_hw_bar_size() logs that it assumes
> 256 KiB for GRC (BAR_ID_0) and 512 KiB for DB (BAR_ID_1), but evaluates:
>
> return BAR_ID_0 ? 256 * 1024 : 512 * 1024;
>
> Because BAR_ID_0 is enum constant 0, the ternary condition is always
> false and qed_hw_bar_size() unconditionally returns 512 KiB even for
> BAR_ID_0, doubling the computed GRC BAR offset for the second hardware
> function.
>
> [...]
Here is the summary with links:
- [net] qed: Fix missing bar_id comparison in qed_hw_bar_size()
https://git.kernel.org/netdev/net-next/c/8301cdd07d43
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-25 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:04 [PATCH net] qed: Fix missing bar_id comparison in qed_hw_bar_size() Ian Rogers
2026-11-23 9:12 ` Daniel Machon
2026-11-25 15:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®