Re: [PATCH net-next v7 08/10] net: dsa: realtek: rtl8365mb: re-latch the family D SerDes

From: Alvin Šipraga

Date: Wed Nov 04 2026 - 08:03:10 EST


On Mon, Nov 02, 2026 at 03:43:45PM +0100, Mieczyslaw Nalewaj wrote:
> The family D receiver latches on the DISABLE -> HSGMII edge in SDS_MISC
> rather than on the value, and it will not latch until the MAC at the
> other end of the trunk has brought its own half of the link up. If it
> does not latch, the trunk reports 2.5Gbps/Full on both sides but moves
> no frames: the CPU MAC transmits, the switch CPU port counts no octets,
> and there are no CRC, alignment or FIFO errors.

[...]

>
> #define pcs_to_rtl8365mb(_pcs) container_of((_pcs), struct rtl8365mb, pcs)
> @@ -1357,43 +1404,53 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,
> static int rtl8365mb_sds_write(struct realtek_priv *priv, u8 index,
> u16 addr, u16 data)
> {
> + struct rtl8365mb *mb = priv->chip_data;
> int ret;
>
> + mutex_lock(&mb->sds_lock);

OK, I don't think I can give a particularly good review of this patch
since I didn't follow the previous work for SerDes support... But at
least, can you use guard(mutex)() here? ;-) And elsewhere it might
apply.

> +
> ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_DATA_REG, data);
> if (ret)
> - return ret;
> + goto out_unlock;
>
> ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_ADR_REG, addr);
> if (ret)
> - return ret;
> + goto out_unlock;
>
> /* The SerDes indirect access engine completes the command within the
> * register write transaction, so there is no need to wait or poll for
> * completion before the next access, matching the vendor driver.
> */
> - return regmap_write(priv->map, RTL8365MB_SDS_INDACS_CMD_REG,
> - RTL8365MB_SDS_INDACS_CMD_RUN_MASK |
> - RTL8365MB_SDS_INDACS_CMD_WR_MASK |
> - FIELD_PREP(RTL8365MB_SDS_INDACS_CMD_INDEX_MASK,
> - index));
> + ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_CMD_REG,
> + RTL8365MB_SDS_INDACS_CMD_RUN_MASK |
> + RTL8365MB_SDS_INDACS_CMD_WR_MASK |
> + FIELD_PREP(RTL8365MB_SDS_INDACS_CMD_INDEX_MASK,
> + index));
> +
> +out_unlock:
> + mutex_unlock(&mb->sds_lock);
> + return ret;
> }
>
> static int rtl8365mb_sds_read(struct realtek_priv *priv, u8 index,
> u16 addr, u16 *data)
> {
> + struct rtl8365mb *mb = priv->chip_data;
> u32 val;
> int ret;
>
> + mutex_lock(&mb->sds_lock);

Like here, etc.

Kind regards,
Alvin