Subject: Re: [PATCH net-next v2 1/6] net: dsa: add support for phylink mac_select_pcs()

From: "Russell King (Oracle)" <[email-masked]>
Date: Mon, 21 Feb 2022 16:38:35 +0000

On Mon, Feb 21, 2022 at 04:55:40PM +0200, Vladimir Oltean wrote:
> On Mon, Feb 21, 2022 at 02:44:34PM +0000, Russell King (Oracle) wrote:
> > > *and as I haven't considered, to be honest. When phylink_major_config()
> > > gets called after a SGMII to 10GBaseR switchover, and mac_select_pcs is
> > > called and returns NULL, the current behavior is to keep working with
> > > the PCS for SGMII. Is that intended?
> > 
> > It was not originally intended, but as a result of the discussion
> > around this patch which didn't go anywhere useful, I dropped it as
> > a means to a path of least resistance.
> > 
> > https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email-masked]/
> 
> Oh, but that patch didn't close exactly this condition that we're
> talking about here, did it? It allows phylink_set_pcs() to be called
> with NULL, but phylink_major_config() still has the non-NULL check,
> which prevents it from having any effect in this scenario:
> 
> 	/* If we have a new PCS, switch to the new PCS after preparing the MAC
> 	 * for the change.
> 	 */
> 	if (pcs)
> 		phylink_set_pcs(pl, pcs);
> 
> I re-read the conversation and I still don't see this argument being
> given, otherwise I wouldn't have opposed...

The reason for that condition above is to avoid disrupting the case
where drivers which do not (yet) provide a mac_select_pcs()
implementation (therefore  pcs will be NULL here) but instead register
their PCS by calling phylink_set_pcs() immediately after a call to
phylink_create(). If the above call to phylink_set_pcs() was
unconditional, then:

1) it would break these existing drivers,
2) we would definitely need to make phylink_set_pcs() safe to call
   with a NULL pcs argument to avoid crashing when in e.g. pcs-less
   modes.

If that usage was eliminated, then the problem goes away... but that
means changing drivers, and changing drivers is always a long hard
slog that takes months and several kernel cycles to do.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!