Subject: Re: [PATCH net] net: wan: fsl_uhdlc_hdlc: fix dma_rmb usage in hdlc_rx_done

From: "Christophe Leroy (CS GROUP)" <[email-masked]>
Date: Tue, 5 May 2026 07:29:29 +0200

Hi,

Le 04/05/2026 à 17:56, Holger Brunck a écrit :
> If dma_rmb is used it has to be done after reading bd_status and checking
> if R_E_S is zero. Therefore we need to move it into the while loop.

Can you give more details ? Why does dma_rmb() has to be done after 
reading bd_status and checking if R_E_S is zero ?

> 
> Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")
> Signed-off-by: Holger Brunck <[email-masked]>
> ---
>   drivers/net/wan/fsl_ucc_hdlc.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
> index 15bfb78381d4..09081f128a98 100644
> --- a/drivers/net/wan/fsl_ucc_hdlc.c
> +++ b/drivers/net/wan/fsl_ucc_hdlc.c
> @@ -523,12 +523,12 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
>   	u16 length, howmany = 0;
>   	u8 *bdbuffer;
>   
> -	dma_rmb();
>   	bd = priv->currx_bd;
>   	bd_status = be16_to_cpu(bd->status);
>   
>   	/* while there are received buffers and BD is full (~R_E) */
>   	while (!((bd_status & (R_E_S)) || (--rx_work_limit < 0))) {
> +		dma_rmb();
>   		if (bd_status & (RX_BD_ERRORS)) {
>   			dev->stats.rx_errors++;
>   
> @@ -610,7 +610,6 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
>   
>   		bd_status = be16_to_cpu(bd->status);
>   	}
> -	dma_rmb();
>   
>   	priv->currx_bd = bd;
>   	return howmany;