Subject: Re: [PATCH RFC net-next 9/9] net: pcs: xpcs: avoid reading STAT1 more than once

From: Simon Horman <[email-masked]>
Date: Fri, 12 May 2023 21:36:12 +0200

On Fri, May 12, 2023 at 06:27:45PM +0100, Russell King (Oracle) wrote:
> Avoid reading the STAT1 registers more than once while getting the PCS
> state, as this register contains latching-low bits that are lost after
> the first read.
> 
> Signed-off-by: Russell King (Oracle) <[email-masked]>

...

> @@ -880,13 +854,25 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
>  			      const struct xpcs_compat *compat)
>  {
>  	bool an_enabled;
> +	int pcs_stat1;
> +	int an_stat1;
>  	int ret;
>  
> +	/* The link status bit is latching-low, so it is important to
> +	 * avoid unnecessary re-reads of this register to avoid missing
> +	 * a link-down event.
> +	 */
> +	pcs_stat1 = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT1);
> +	if (pcs_stat1 < 0) {
> +		state->link = false;
> +		return stat1;

Hi Russell,

stat1 doesn't seem to exist in this scope.

> +	}