Subject: RE: Bug? xpcs-wx: read-modify-write to different registers?

From: Jiawen Wu <[email-masked]>
Date: Mon, 23 Sep 2024 18:12:44 +0800

> -----Original Message-----
> From: Russell King (Oracle) <[email-masked]>
> Sent: Monday, September 23, 2024 5:18 PM
> To: Jiawen Wu <[email-masked]>
> Cc: [email-masked]
> Subject: Bug? xpcs-wx: read-modify-write to different registers?
> 
> Hi,
> 
> While making some cleanups to the XPCS driver, I spotted the following
> in pcs-xpcs-wx.c:
> 
>         val = txgbe_read_pma(xpcs, TXGBE_RX_GEN_CTL3);
>         val = u16_replace_bits(val, 0x4, TXGBE_RX_GEN_CTL3_LOS_TRSHLD0);
>         txgbe_write_pma(xpcs, TXGBE_RX_EQ_ATTN_CTL, val);
> 
> This reads from the TXGBE_RX_GEN_CTL3 register, changes a value in a
> field, and then writes it back to a different register,
> TXGBE_RX_EQ_ATTN_CTL. This doesn't look correct.
> 
> Please check whether this code is correct, if not please submit a fix.
> 
> Thanks.

OMG, it's a real bug. Register TXGBE_RX_GEN_CTL3 should be written back.

Thanks Russell, I'll send a patch to fix it.