lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89i+C_BoyG7hu4jH2PcWwKGdDQZ155s3A1B-xQ4fDmnubxw@mail.gmail.com>
Date: Wed, 21 Aug 2024 09:57:23 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: ende.tan@...rfivetech.com
Cc: netdev@...r.kernel.org, andrew@...n.ch, alexandre.torgue@...s.st.com, 
	joabreu@...opsys.com, davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com, 
	mcoquelin.stm32@...il.com, linux-kernel@...r.kernel.org, 
	linux-stm32@...md-mailman.stormreply.com, 
	linux-arm-kernel@...ts.infradead.org, leyfoon.tan@...rfivetech.com, 
	minda.chen@...rfivetech.com, endeneer@...il.com
Subject: Re: [net-next,v2,1/1] net: stmmac: Add dma_wmb() barrier before
 setting OWN bit in set_rx_owner()

On Wed, Aug 21, 2024 at 8:03 AM <ende.tan@...rfivetech.com> wrote:
>
> From: Tan En De <ende.tan@...rfivetech.com>
>
> Currently, some set_rx_owner() callbacks set interrupt-on-completion bit
> in addition to OWN bit, without inserting a dma_wmb() barrier in
> between. This might cause missed interrupt if the DMA sees the OWN bit
> before the interrupt-on-completion bit is set.
>
> Thus, this patch adds dma_wmb() barrier right before setting OWN bit in
> each of the callbacks. Now that the responsibility of calling dma_wmb()
> is delegated to the callbacks, let's simplify main driver code by
> removing dma_wmb() before stmmac_set_rx_owner().
>
> Signed-off-by: Tan En De <ende.tan@...rfivetech.com>
> ---
> v2:
> - Avoid introducing a new function just to set the interrupt-on-completion
>   bit, as it is wasteful to do so.
> - Delegate the responsibility of calling dma_wmb() from main driver code
>   to set_rx_owner() callbacks (i.e. let callbacks to manage the low-level
>   ordering/barrier rather than cluttering up the main driver code).
> v1:
> - https://patchwork.kernel.org/project/netdevbpf/patch/20240814092438.3129-1-ende.tan@starfivetech.com/
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c   | 5 ++++-
>  drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 5 +++--
>  drivers/net/ethernet/stmicro/stmmac/enh_desc.c       | 1 +
>  drivers/net/ethernet/stmicro/stmmac/norm_desc.c      | 1 +
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 2 --
>  5 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index 1c5802e0d7f4..95aea6ad485b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -186,10 +186,13 @@ static void dwmac4_set_tx_owner(struct dma_desc *p)
>
>  static void dwmac4_set_rx_owner(struct dma_desc *p, int disable_rx_ic)
>  {
> -       p->des3 |= cpu_to_le32(RDES3_OWN | RDES3_BUFFER1_VALID_ADDR);
> +       p->des3 |= cpu_to_le32(RDES3_BUFFER1_VALID_ADDR);
>
>         if (!disable_rx_ic)
>                 p->des3 |= cpu_to_le32(RDES3_INT_ON_COMPLETION_EN);

RDES3_INT_ON_COMPLETION_EN was possibly written after RDES3_OWN

This looks like a bug fix to me, this should target the net tree.

> +
> +       dma_wmb();
> +       p->des3 |= cpu_to_le32(RDES3_OWN);
>  }
>
>  static int dwmac4_get_tx_ls(struct dma_desc *p)
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> index fc82862a612c..d76ae833c840 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> @@ -56,10 +56,11 @@ static void dwxgmac2_set_tx_owner(struct dma_desc *p)
>
>  static void dwxgmac2_set_rx_owner(struct dma_desc *p, int disable_rx_ic)
>  {
> -       p->des3 |= cpu_to_le32(XGMAC_RDES3_OWN);
> -
>         if (!disable_rx_ic)
>                 p->des3 |= cpu_to_le32(XGMAC_RDES3_IOC);

Same kind of bug here.

> +
> +       dma_wmb();
> +       p->des3 |= cpu_to_le32(XGMAC_RDES3_OWN);
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ