netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex
@ 2025-08-27 19:26 Alok Tiwari
  2025-08-28 17:21 ` Simon Horman
  2025-08-30  2:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Alok Tiwari @ 2025-08-27 19:26 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, horms, netdev; +Cc: alok.a.tiwari

The current code incorrectly passes (XIRCREG1_ECR | FullDuplex) as
the register address to GetByte(), instead of fetching the register
value and OR-ing it with FullDuplex. This results in an invalid
register access.

Fix it by reading XIRCREG1_ECR first, then or-ing with FullDuplex
before writing it back.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
This patch is untested due to hardware limitations.
If the Fixes tag is not required, it can be removed.
---
 drivers/net/ethernet/xircom/xirc2ps_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c
index a31d5d5e6593..97e88886253f 100644
--- a/drivers/net/ethernet/xircom/xirc2ps_cs.c
+++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c
@@ -1576,7 +1576,7 @@ do_reset(struct net_device *dev, int full)
 	    msleep(40);			/* wait 40 msec to let it complete */
 	}
 	if (full_duplex)
-	    PutByte(XIRCREG1_ECR, GetByte(XIRCREG1_ECR | FullDuplex));
+	    PutByte(XIRCREG1_ECR, GetByte(XIRCREG1_ECR) | FullDuplex);
     } else {  /* No MII */
 	SelectPage(0);
 	value = GetByte(XIRCREG_ESR);	 /* read the ESR */
-- 
2.50.1


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

* Re: [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex
  2025-08-27 19:26 [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex Alok Tiwari
@ 2025-08-28 17:21 ` Simon Horman
  2025-08-28 18:49   ` [External] : " ALOK TIWARI
  2025-08-30  2:20 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2025-08-28 17:21 UTC (permalink / raw)
  To: Alok Tiwari; +Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev

On Wed, Aug 27, 2025 at 12:26:43PM -0700, Alok Tiwari wrote:
> The current code incorrectly passes (XIRCREG1_ECR | FullDuplex) as
> the register address to GetByte(), instead of fetching the register
> value and OR-ing it with FullDuplex. This results in an invalid
> register access.
> 
> Fix it by reading XIRCREG1_ECR first, then or-ing with FullDuplex
> before writing it back.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
> This patch is untested due to hardware limitations.
> If the Fixes tag is not required, it can be removed.

Interesting.

It seems that XIRCREG1_ECR is 14, and FullDuplex is 0x4.
And 14 | 0x4 = 14. So the right register is read. But
clearly the bit isn't set as intended when the register is written
(unless, somehow it's already set in the value read from the register).

So I guess this never worked as intended.
But I guess so long as the code exists it should
do what it intended to do.

Reviewed-by: Simon Horman <horms@kernel.org>

...

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

* Re: [External] : Re: [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex
  2025-08-28 17:21 ` Simon Horman
@ 2025-08-28 18:49   ` ALOK TIWARI
  2025-08-28 21:36     ` Jacob Keller
  0 siblings, 1 reply; 5+ messages in thread
From: ALOK TIWARI @ 2025-08-28 18:49 UTC (permalink / raw)
  To: Simon Horman; +Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev



On 8/28/2025 10:51 PM, Simon Horman wrote:
> Interesting.
> 
> It seems that XIRCREG1_ECR is 14, and FullDuplex is 0x4.
> And 14 | 0x4 = 14. So the right register is read. But
> clearly the bit isn't set as intended when the register is written
> (unless, somehow it's already set in the value read from the register).
> 
> So I guess this never worked as intended.
> But I guess so long as the code exists it should
> do what it intended to do.
> 
> Reviewed-by: Simon Horman<horms@kernel.org>

Thanks, Simon. your analysis is spot on.
It seems this never worked as intended.

Thanks for the review.

Thanks
Alok

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

* Re: [External] : Re: [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex
  2025-08-28 18:49   ` [External] : " ALOK TIWARI
@ 2025-08-28 21:36     ` Jacob Keller
  0 siblings, 0 replies; 5+ messages in thread
From: Jacob Keller @ 2025-08-28 21:36 UTC (permalink / raw)
  To: ALOK TIWARI, Simon Horman
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev


[-- Attachment #1.1: Type: text/plain, Size: 935 bytes --]



On 8/28/2025 11:49 AM, ALOK TIWARI wrote:
> 
> 
> On 8/28/2025 10:51 PM, Simon Horman wrote:
>> Interesting.
>>
>> It seems that XIRCREG1_ECR is 14, and FullDuplex is 0x4.
>> And 14 | 0x4 = 14. So the right register is read. But
>> clearly the bit isn't set as intended when the register is written
>> (unless, somehow it's already set in the value read from the register).
>>
>> So I guess this never worked as intended.
>> But I guess so long as the code exists it should
>> do what it intended to do.
>>
>> Reviewed-by: Simon Horman<horms@kernel.org>
> 
> Thanks, Simon. your analysis is spot on.
> It seems this never worked as intended.
> 
> Thanks for the review.
> 
> Thanks
> Alok
> 

That analysis also explains why there haven't been complaints about any
issues with invalid access to HW registers, since the address read is
"correct".

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex
  2025-08-27 19:26 [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex Alok Tiwari
  2025-08-28 17:21 ` Simon Horman
@ 2025-08-30  2:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-30  2:20 UTC (permalink / raw)
  To: ALOK TIWARI; +Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, netdev

Hello:

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

On Wed, 27 Aug 2025 12:26:43 -0700 you wrote:
> The current code incorrectly passes (XIRCREG1_ECR | FullDuplex) as
> the register address to GetByte(), instead of fetching the register
> value and OR-ing it with FullDuplex. This results in an invalid
> register access.
> 
> Fix it by reading XIRCREG1_ECR first, then or-ing with FullDuplex
> before writing it back.
> 
> [...]

Here is the summary with links:
  - [net] xirc2ps_cs: fix register access when enabling FullDuplex
    https://git.kernel.org/netdev/net/c/b79e498080b1

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] 5+ messages in thread

end of thread, other threads:[~2025-08-30  2:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 19:26 [PATCH net] xirc2ps_cs: fix register access when enabling FullDuplex Alok Tiwari
2025-08-28 17:21 ` Simon Horman
2025-08-28 18:49   ` [External] : " ALOK TIWARI
2025-08-28 21:36     ` Jacob Keller
2025-08-30  2:20 ` 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).