netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits
@ 2025-07-16  3:03 Jack Ping CHNG
  2025-07-16  7:25 ` Maxime Chevallier
  2025-07-18  2:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Jack Ping CHNG @ 2025-07-16  3:03 UTC (permalink / raw)
  To: netdev; +Cc: davem, fancer.lancer, yzhu, sureshnagaraj, Jack Ping CHNG

readl() returns 32-bit value but Clause 22/45 registers are 16-bit wide.
Masking with 0xFFFF avoids using garbage upper bits.

Signed-off-by: Jack Ping CHNG <jchng@maxlinear.com>
---
 drivers/net/pcs/pcs-xpcs-plat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/pcs/pcs-xpcs-plat.c b/drivers/net/pcs/pcs-xpcs-plat.c
index 629315f1e57c..9dcaf7a66113 100644
--- a/drivers/net/pcs/pcs-xpcs-plat.c
+++ b/drivers/net/pcs/pcs-xpcs-plat.c
@@ -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));
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits
  2025-07-16  3:03 [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits Jack Ping CHNG
@ 2025-07-16  7:25 ` Maxime Chevallier
  2025-07-16  8:00   ` Jack Ping Chng
  2025-07-18  2:00 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Maxime Chevallier @ 2025-07-16  7:25 UTC (permalink / raw)
  To: Jack Ping CHNG; +Cc: netdev, davem, fancer.lancer, yzhu, sureshnagaraj

Hi Jack,

On Wed, 16 Jul 2025 11:03:49 +0800
Jack Ping CHNG <jchng@maxlinear.com> wrote:

> readl() returns 32-bit value but Clause 22/45 registers are 16-bit wide.
> Masking with 0xFFFF avoids using garbage upper bits.
> 
> Signed-off-by: Jack Ping CHNG <jchng@maxlinear.com>

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 <maxime.chevallier@bootlin.com>

Maxime


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits
  2025-07-16  7:25 ` Maxime Chevallier
@ 2025-07-16  8:00   ` Jack Ping Chng
  0 siblings, 0 replies; 4+ messages in thread
From: Jack Ping Chng @ 2025-07-16  8:00 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: netdev@vger.kernel.org, davem@davemloft.net,
	fancer.lancer@gmail.com, Yi xin Zhu, Suresh Nagaraj

Hi Maxime,

On Wed, 16 Jul 2025 3:26:00 +0800
Maxime Chevallier <maxime.chevallier@bootlin.com> wrote:
 
> 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 <maxime.chevallier@bootlin.com>
> 
> Maxime

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

Jack


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits
  2025-07-16  3:03 [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits Jack Ping CHNG
  2025-07-16  7:25 ` Maxime Chevallier
@ 2025-07-18  2:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-18  2:00 UTC (permalink / raw)
  To: Jack Ping Chng; +Cc: netdev, davem, fancer.lancer, yzhu, sureshnagaraj

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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.
> 
> Signed-off-by: Jack Ping CHNG <jchng@maxlinear.com>
> ---
>  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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-18  2:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  3:03 [PATCH net-next] net: pcs: xpcs: mask readl() return value to 16 bits Jack Ping CHNG
2025-07-16  7:25 ` Maxime Chevallier
2025-07-16  8:00   ` Jack Ping Chng
2025-07-18  2:00 ` 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;
as well as URLs for NNTP newsgroup(s).