Re: [PATCH net-next v19 10/15] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
From: Mieczyslaw Nalewaj
Date: Fri Dec 04 2026 - 01:21:37 EST
On 12/4/2026 3:18 AM, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] On family D, rtl8365mb_pcs_config() in
> drivers/net/dsa/realtek/rtl8365mb_main.c never programs the EXT0 mode…
>
> --
>
> net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
>
> This commit extends the rtl8365mb RTL8367S SGMII/HSGMII PCS code to
> family D switches. On family D the SerDes is reached through the indexed
> SDS13 window, and SDS_MISC has a different layout. Family D gets its own
> tuning tables, SDS_MISC programming and link state handling. The family C
> path is unchanged.
>
>> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
>> index 4fd79dbb2d691..4a8a04fc6d755 100644
>> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
>> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
>
> [ ... ]
>
>> @@ -1576,34 +1664,67 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
>
> [ ... ]
>
>> + misc_mask = RTL8365MB_D_SDS_MISC_CFG_MASK;
>> + misc_val = RTL8365MB_D_SDS_MISC_PA33PC_EN |
>> + RTL8365MB_D_SDS_MISC_PA12PC_EN |
>> + RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0 | sds_mode;
>> + } else {
>> + /* Mux the SerDes to MAC8 in the requested mode */
>> + misc_mask = RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK |
>> + RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK;
>> + misc_val = (sds_mode == RTL8365MB_EXT_PORT_MODE_SGMII) ?
>> + RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK :
>> + RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK;
>> + }
>> +
>> ret = regmap_update_bits(priv->map, RTL8365MB_SDS_MISC_REG,
>> - RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK |
>> - RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK,
>> - mode == RTL8365MB_EXT_PORT_MODE_SGMII ?
>> - RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK :
>> - RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK);
>> + misc_mask, misc_val);
>> if (ret)
>> return ret;
>>
>> - val = mode << RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(id);
>> - ret = regmap_update_bits(priv->map,
>> - RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(id),
>> - RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(id),
>> - val);
>> - if (ret)
>> - return ret;
>> + /* On family D, SDS_MISC selects the SerDes mode. id (1) refers to
>> + * RGMII port 7 on RTL8367S-VB and must not be overwritten. The EXT0
>> + * field of DIGITAL_INTERFACE_SELECT is not programmed here and keeps
>> + * its power-on or strap default; whether the vendor sequence sets it
>> + * for the SerDes was not verified, but the link came up on all tested
>> + * boards.
>> + */
>> + if (!is_d) {
>> + val = sds_mode << RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(id);
>> + ret = regmap_update_bits(priv->map,
>> + RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(id),
>> + RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(id),
>> + val);
>> + if (ret)
>> + return ret;
>> + }
>
> [Severity: Medium]
> On family D, does anything program the EXT0 mode nibble (bits 3:0) of
> DIGITAL_INTERFACE_SELECT_REG0 (0x1305) for the SerDes port 6 / MAC6?
>
> The whole DIGITAL_INTERFACE_SELECT write in rtl8365mb_pcs_config() is
> skipped when is_d is set. Family D has no init jam table, so it never gets
> the family C { 0x1305, 0xC000 } entry either.
>
> The only other family D write to this register is in
> rtl8365mb_ext_config_rgmii(). That write only updates the extint id 1
> nibble, which is used by the RGMII port 7:
>
> ret = regmap_update_bits(
> priv->map, RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(extint->id),
> RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(extint->id),
> RTL8365MB_EXT_PORT_MODE_RGMII
> << RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(
> extint->id));
>
> After rtl8365mb_reset_chip(), the EXT0 interface mode therefore keeps
> whatever value the strap or EEPROM set. SDS_MISC is still written with
> MAC6_SEL_SDS0 plus the SGMII/HSGMII mode, and the PCS is treated as
> configured.
>
> Suppose a board's straps leave EXT0 disabled or in a parallel-bus mode.
> Could MAC6 and the SDS_MISC mux then disagree, so that the port 6 SerDes
> link is dead or unreliable and the driver does not notice?
>
> The commit message says that whether the vendor RTL8367D sequence programs
> this field was not verified, and that "the link came up on all tested
> boards". This is still the case after the RTL8367S-VB chip entry is added
> later in the series.
>
> Would it be possible to program EXT0 explicitly for SGMII/HSGMII on
> family D? Or at least read it back and warn when it does not match the
> requested SerDes mode?
>
> [ ... ]
>
Thanks for the review.
I checked this against the vendor RTL8367D port API. In
dal_rtl8367d_port_extMode_set() the SerDes path for MAC6 (id == 1) does not
touch DIGITAL_INTERFACE_SELECT (0x1305) at all. It sets MAC6_SEL_SDS0, loads
the SGCfg/HSGCfg tuning table through the SDS indirect window, sets the
FIBER_CFG_2 RX disable field, and then programs PA12PC_EN, PA33PC_EN and the
mode field in SDS_MISC.
The EXT0 field (SELECT_GMII_0, bits 3:0) is defined in the vendor register
header but is not used anywhere in the vendor code. Every write to 0x1305 there
is to SELECT_GMII_1 (EXT1, RGMII on port 7). So on this family the SerDes mode
is selected by SDS_MISC alone, and the driver matches the vendor sequence by not
writing EXT0.
No code change is needed.