[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <82473d11-ff14-494a-bac5-4a5b1fb8ce4d@gmail.com>
Date: Fri, 30 Aug 2024 16:59:09 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: ende.tan@...rfivetech.com, netdev@...r.kernel.org
Cc: andrew@...n.ch, alexandre.torgue@...s.st.com, joabreu@...opsys.com,
davem@...emloft.net, edumazet@...gle.com, 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,v3,1/1] net: stmmac: Batch set RX OWN flag and other
flags
On 8/29/24 06:40, ende.tan@...rfivetech.com wrote:
> From: Tan En De <ende.tan@...rfivetech.com>
>
> Minimize access to the RX descriptor by collecting all the flags in a
> local variable and then updating the descriptor at once.
>
> Signed-off-by: Tan En De <ende.tan@...rfivetech.com>
> ---
> v3:
> - Use local variable to batch set the descriptor flags.
> - This reduces the number of accesses to the descriptor.
> v2: https://patchwork.kernel.org/project/netdevbpf/patch/20240821060307.46350-1-ende.tan@starfivetech.com/
> - 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 | 6 ++++--
> drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 6 ++++--
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index 1c5802e0d7f4..dfcbe7036988 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -186,10 +186,12 @@ 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);
> + u32 flags = cpu_to_le32(RDES3_OWN | RDES3_BUFFER1_VALID_ADDR);
>
> if (!disable_rx_ic)
> - p->des3 |= cpu_to_le32(RDES3_INT_ON_COMPLETION_EN);
> + flags |= cpu_to_le32(RDES3_INT_ON_COMPLETION_EN);
> +
> + p->des3 |= flags;
You could just batch the endian conversion too:
u32 flags = DES3_OWN | RDES3_BUFFER1_VALID_ADDR;
if (!disable_rx_ic)
flags |= RDES3_INT_ON_COMPLETION_EN;
p->desc3 |= cpu_to_le32(flags);
> }
>
> 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..0c7ea939f787 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> @@ -56,10 +56,12 @@ 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);
> + u32 flags = cpu_to_le32(XGMAC_RDES3_OWN);
>
> if (!disable_rx_ic)
> - p->des3 |= cpu_to_le32(XGMAC_RDES3_IOC);
> + flags |= cpu_to_le32(XGMAC_RDES3_IOC);
> +
> + p->des3 |= flags;
And likewise here, and that would likely squash the sparse warning,
since you would not be assigning an 'u32' field to a __le32 field anymore.
--
Florian
Powered by blists - more mailing lists