From patchwork Thu Aug 29 13:40:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: EnDe Tan X-Patchwork-Id: 13783283 X-Patchwork-Delegate: kuba@kernel.org Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 311391AC451; Thu, 29 Aug 2024 13:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724938871; cv=fail; b=fo+1HQ5J3wkJHIkG2cT7MJnCI2pS4+viKe4IMWGmrAZVgQ6560QWTB0zFzw1aVTgyYQZqmvsZ/Z3NMQTVa8oJkrOKUjjrq+COCxUq2Np/CgEwUdRzZ5qDsujPp5D9whqhRub72tlGwNzkF9GkQhFbcOSuvktzKhMvCxRtoSjnk0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724938871; c=relaxed/simple; bh=NyASlf1LMHnBfDXXip972vGq2WQEhQ9ssXj+eR2xgmI=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=QKD0mxUZsEfPqd561N67IVIlc6DAllUu/sZTXryvX5Cetgh8acPD0xZE4IOThJIaa3tZyOWViJ144hL7bTdx9XNfaLeTBcvQFYoK0WEFkhyAig22Y0Q0ddRR0Cir/FY95Oq0CEEnsrEysngHQTsC1YgHWXKmib2aj7QrVELMLuI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RhSuZH4s57Fu1l6XYoJb8XRtGULElyZspI6VO20VH2jfcaz4vCBGQ1UykmceOKNxw4EQQkDxJPhNj8Fh/NNDEWfETTfNxjCXv9ZQFO3ZuYapmGo06YJXJDG1J7NmgpGOaXPGfYyLRVL7Fv/YN7m7LdNxmJqAudG/3ljEhJ0onKBoeZOlJkloo14t4UF/1JhfRXpm3ZKSdkINtXNY20cQ2xqawNhsSYrg2hYOO1kgGhpPCnoc+OWJhXMACO+Pw9kIlIoFZn4HQevT5ov1Qqvj5feydGoksqx1EJ7pf1yT7XeqpG1zTdYY6Wh4W9BfmvmZcyIWwUc5lUzPd7mXyZV+ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CnYGrjHFd3PvE/A1cQgsfLrHi0OkCmeIGAE8NNvlSUA=; b=eaH/uNpg0p+8IN2TWV5KPZ1vFUfwRtTeycn1GGJvaNyi+EO+gzKJfeSzHztpoQJMM6bhuojVSf97AQVbNH/59PK2cKIpd2cNlJzvS1tMB50dGomkFRvyeVJ6lvmm8kBul30+AY0rYyYgWTcAj5vyWC7pbWYxkJfOwVxGzeOyBu1G7dmrj7ybk2gPOa3ktNy+muLGRR/rta/0bq80YbAxzPLhMRwrto29YovnD6Kn2c88E6YbcYfJiHZhBVyKQxuF3cpnczvRVQa7w0vppKbnjaGg8JV1cLGP4jiiHtzOpJmcJV9s9R5zIR0fLe7hrpBzurkGXvoSCa4U/v2xhEzhTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:b::7) by NTZPR01MB1002.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Thu, 29 Aug 2024 13:40:56 +0000 Received: from NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn ([fe80::e1c4:5bb3:adc:97f5]) by NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn ([fe80::e1c4:5bb3:adc:97f5%3]) with mapi id 15.20.7897.021; Thu, 29 Aug 2024 13:40:56 +0000 From: ende.tan@starfivetech.com To: netdev@vger.kernel.org Cc: andrew@lunn.ch, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, leyfoon.tan@starfivetech.com, minda.chen@starfivetech.com, endeneer@gmail.com, Tan En De Subject: [net-next,v3,1/1] net: stmmac: Batch set RX OWN flag and other flags Date: Thu, 29 Aug 2024 21:40:43 +0800 Message-Id: <20240829134043.323855-1-ende.tan@starfivetech.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BJXPR01CA0069.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:12::36) To NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:b::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: NTZPR01MB1018:EE_|NTZPR01MB1002:EE_ X-MS-Office365-Filtering-Correlation-Id: 71698778-d297-4cce-5db7-08dcc8303590 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|41320700013|1800799024|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 5jM23HdLLZ92EzBUocYc9vNQj+h1M9/AfovCUGqGyAEGPh4koNNjPduy4s2SbviRO9lgsp639cK4nY1sbIOCz1wRQwxrMQVpAMZubjBfXEApxWno4lMiekcD3PcPeNldEPBxcyGVFcFRxVD1jXAzFWP7B8+uvJjk4tlWrFxMDzqZIMeFd2MlvhIJ/P6nKIcBBToOhbTVLF5b7YxV9Zs8brf9X90ap2Ygsqjkv1n3gfedKgoOubThGjkgdmkwq/eXc8LMglAgvKrrDU9HO4t0DGmxe1Z8BQrHTHo1UbxrMnHut6mZFUUwFXyeMNMqqJQPwWqv/DKQvKxMkJ28pxyxT8gpT54nJnFE6dqlSNU3n44G67Gux+Llf4ypHCWJqirNg+IHhQ0PsofmpfsdMx047m1pzqMh2q/2bUscRflAX7NiDmIe2Ofx+SfxGcj1ksEdmL8Ux/K9naYFOIofSBiNW+7DePK0MMzUxM/PboS9bKI+d4Fjjqp78OUCnWmuda8DgjtBWVqskhW2xzFfBa3SxSEViErv6RWUxwDVwrJS85m3KmtwxD8DI5wk87DjfXquk49YHaQO8mgD3fOofhR1r1194mp8iomLJ1/BqQNFzY6bMQbkmCTyPyTT/LLx3X5G X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(366016)(41320700013)(1800799024)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kb8RZkyKCh8vr9pGSdPcGDGO/uKqO83vxeR8zLXcB5skwlaRlx9fk0Jwqgd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rZsOLnxa3awFkjSwQfmbn7iYs7lMF6sWzM5zC3z1+V+i9w6u3pBJVpcrPXtKhVIulVqHeFUzJtUDp6F5Pozs8YedcWsoaPbPurFgNhATqgiyHRyGM7MzKIyhFVb0Rab3rHK47Rqt/RcL9zG3TDLSXbwqBESXKtnlazPKepFNh5Zn1i5r0+I3XtLhT5SDvwsSfayStrAwyhXCNBcVDIiLx8PwSyeFU0WHqwoOixAKy4gJQAXxyuvGJFSLAaIkDGrK6t4r3WTa1C6VYaTB6co3s6TVlHtvhNuT/OK7YTpJFmub8vwCgkyRPyzSQlmqk5jvvoQlS0qz0utQuXZmlJyMiCZhZkhBneHBO3SR3T2P/GInKBytYfStZ8KqpQLAvQH2wnyjJR0U/JGeILiGyfmuFe15B8b7gmOfe2Bilwlhvf+rA8AblKKut5NHES8394DaNa2PIuuSrxyL9FcvOsgCOFV1Z0bU6MTocpH5Y9NQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71698778-d297-4cce-5db7-08dcc8303590 X-MS-Exchange-CrossTenant-AuthSource: NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 13:40:56.3563 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Cno8RSzYdfJgjjGwxyeyvitahmZVvy4ALSK7Sot2VQsWT7DkqcwIKG8dyESujY03EMfgmATo8OTmVPPV5u+Wya3jc3dbDnHOi9q3+DHivKA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: NTZPR01MB1002 X-Patchwork-Delegate: kuba@kernel.org From: Tan En De 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 --- 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; } 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; } static int dwxgmac2_get_tx_ls(struct dma_desc *p)