Skip to contentSkip to conversation

net: pcs: xpcs: mask readl() return value to 16 bits

PATCH Applied Jack Ping CHNG 3 participants 4 messages Jul 16, 2025 – Jul 18, 2025

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

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
index 629315f1e57c..9dcaf7a66113 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw

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 with 0xFFFF avoids using garbage upper bits.

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

#2 lore raw

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,

Maxime

Thanks for the review, this is not yet a real life issue.

Jack

#3 lore raw
In reply to Jack Ping CHNG
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 with 0xFFFF avoids using garbage upper bits.

---
 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