net: pcs: xpcs: mask readl() return value to 16 bits
Subsystems (3)
PATCH 1/1 net: pcs: xpcs: mask readl() return value to 16 bits
readl() returns 32-bit value but Clause 22/45 registers are 16-bit wide. Masking with 0xFFFF avoids using garbage upper bits.
--- drivers/net/pcs/pcs-xpcs-plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-xpcs-plat.c +2 -2
@@ -66,7 +66,7 @@ static int xpcs_mmio_read_reg_indirect(struct dw_xpcs_plat *pxpcs,switch (pxpcs->reg_width) {case 4 :writel (page, pxpcs->reg_base + (DW_VR_CSR_VIEWPORT <<2 )); - ret =readl (pxpcs->reg_base + (ofs <<2 )); + ret =readl (pxpcs->reg_base + (ofs <<2 )) &0xffff ;break ;default :writew (page, pxpcs->reg_base + (DW_VR_CSR_VIEWPORT <<1 ));
@@ -124,7 +124,7 @@ static int xpcs_mmio_read_reg_direct(struct dw_xpcs_plat *pxpcs,switch (pxpcs->reg_width) {case 4 : - ret =readl (pxpcs->reg_base + (csr <<2 )); + ret =readl (pxpcs->reg_base + (csr <<2 )) &0xffff ;break ;default : ret =readw (pxpcs->reg_base + (csr <<1 ));
Signature · 1 line
2.43.0
Hi Jack,
Quoted 4 lines · On Wed, 16 Jul 2025 11:03:49 +0800 Jack Ping CHNG <[email protected]> wrote:
readl()returns 32-bit value but Clause 22/45 registers are 16-bit wide. Masking with0xFFFFavoids using garbage upper bits.Signed-off-by Jack Ping CHNG <[email protected]>
I'm OK with the patch, but is it fixing an issue you've seen in real life ? If so, you should make this a fix, sent to -net with a Fixes tag. If not,
Maxime
Hi Maxime,
Quoted 7 lines · On Wed, 16 Jul 2025 3:26:00 +0800 Maxime Chevallier…
I'm OK with the patch, but is it fixing an issue you've seen in real life ? If so, you should make this a fix, sent to -net with a Fixes tag. If not,
Reviewed-by Maxime Chevallier <[email protected]>Maxime
Thanks for the review, this is not yet a real life issue.
Jack
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 7 lines · On Wed, 16 Jul 2025 11:03:49 +0800 you wrote:
readl()returns 32-bit value but Clause 22/45 registers are 16-bit wide. Masking with0xFFFFavoids using garbage upper bits.Signed-off-by Jack Ping CHNG <[email protected]>--- drivers/net/pcs/pcs-xpcs-plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Here is the summary with links:
- [net-next] net: pcs: xpcs: mask readl() return value to 16 bits
https://git.kernel.org/netdev/net-next/c/2b0ba7b5b010
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html