From patchwork Wed Nov 22 15:51:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 13465067 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="KUwobB1j" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2044.outbound.protection.outlook.com [40.107.20.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27B8F10DF for ; Wed, 22 Nov 2023 07:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xqj5TRsyDa4zDMDFtqePVBW+EQ2VC4Ayob0+8W0OI64sumd06Ax2VMaqCQflnVwJd6Aap11IRDFeowS60ab9TS3rjWqbTvqkrLUJ2tnvXFQWssdgD01hxWn0iPhdw4sHgXLIaiNFNPCuLX9QKjvd8Vf6E6yJE/GCA+CQzUoEa5PMJvEsQFNFbeDPIYOXHdinqBEMoybgzkUwpzyP/3SqlLylNUNkLqtwDxBgmAauR1n85iK6cg6XVnJ+I0YqpIAGEoxIQihZn4loA77KJltJdZDZ70QRzsbcXp+d7T3ZH7104tQjFe3NrXHmc5iMerViEKVBo8nkwBcZ4pofT+QzZw== 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=pRqPWcX9VHq06aidQ78wp1Ljb0zltvQw9sF+qvlIN4o=; b=LgOz6kPrU/UUwysolm9FnL0wiDBMBp6YF3QTRBEC5hhJzE8h1dh43NMEHXBCpMJRyPZaNpwWD9rTt3PwTUHthtPC79GFklij8LLsUyhTcNGqWrF12nsnY0CVLLQAr0IiahhHE8KEA3XNcQNUbrQmJyV0mKgS1IcRk/9QVWD9fITdqXQPoABFCtaJKNBfAnUjq9wuMl5cwbYq6nv1VFGYOV8VW9H/cqX/8ow8cKoEAuxaMiVI01nGl8UxnioVerb4yIz5w+QHTn9vLAsMn/RlMUO3AVrkblVe2yfq4+kdvvrHJ6tVjw5mDhDJ0xIOVtD6Qde/CiduTRW6MxTv8vlMMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pRqPWcX9VHq06aidQ78wp1Ljb0zltvQw9sF+qvlIN4o=; b=KUwobB1jPVdCPy9iYOwEQgqRgInvhTrTsPrvIqDuqC4CzsBc7OqND6dlCuLQqDAA5Umo3V7mOtJFWqZpFVjfJ+8Tygvy21REC98gr1Va2+mElowM8EWhZoyyfXtCiRd5eBA9OECarbfZWYbbrAlqZh75iuntncWcz9dKjH1LdjE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9070.eurprd04.prod.outlook.com (2603:10a6:150:21::14) by AS8PR04MB7878.eurprd04.prod.outlook.com (2603:10a6:20b:2af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.19; Wed, 22 Nov 2023 15:51:30 +0000 Received: from GV1PR04MB9070.eurprd04.prod.outlook.com ([fe80::1290:90d4:98c1:3d35]) by GV1PR04MB9070.eurprd04.prod.outlook.com ([fe80::1290:90d4:98c1:3d35%7]) with mapi id 15.20.7025.019; Wed, 22 Nov 2023 15:51:29 +0000 From: Ioana Ciornei To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: andrew@lunn.ch, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net 1/3] dpaa2-eth: increase the needed headroom to account for alignment Date: Wed, 22 Nov 2023 17:51:15 +0200 Message-Id: <20231122155117.2816724-2-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231122155117.2816724-1-ioana.ciornei@nxp.com> References: <20231122155117.2816724-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: VI1P195CA0037.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::26) To GV1PR04MB9070.eurprd04.prod.outlook.com (2603:10a6:150:21::14) 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: GV1PR04MB9070:EE_|AS8PR04MB7878:EE_ X-MS-Office365-Filtering-Correlation-Id: eff987da-e694-44e3-ee7c-08dbeb72e4a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sk5jM5rOs+LBJBI6aL6hjsAsQ9pcmkzYsXvixecVXGJmF7eDFH/TPRi+EqHtEbSYxDgEfWfMUoQU4+ysU58e0adgrKjeMi18e7RK92rK5cEaDIiNn7O4t/GMZZ3k6lb/4fNfQ4SMsu3olM7s7EhRvidhtybffWIweAUquoy6ZJi4O3HnsWDz+4ord7vHDs+xndTw6azEhA3LPs6TXvGswdpz04svyNLEoncUkPBgRXmxZNLG6veHl/1OThLMqAKIVdkvkbdzfEX2ycxnlUQOXWxMeTm+KTSsguCcgPnhzkvTn/TXykLwTyOMSeVhO1Ze6NWDsL6js8CKACOZF5g/O5F1Y0AQEP3Syj3sPxjsd+WxWlfy+m4cHzxX4kGjkbwtm5PQ3hYFdo4Q7BicQst2XIs8T/0gM3JB5SNw0XoAemJebARbUEiShwNin4kMy2qohcqrPVG2XeXDcRGEWHLl8E0HkVDaQDhAX8f7iYT0EK4CzvaK+zxHU5Hga4QhwhRkjbwwy/NdLPMXrLggotHcBTo48sfsedNz3By0cnAS7h4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9070.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(66556008)(66946007)(38100700002)(66476007)(36756003)(86362001)(6512007)(6506007)(83380400001)(26005)(6666004)(2616005)(15650500001)(6486002)(966005)(2906002)(316002)(478600001)(1076003)(8676002)(4326008)(5660300002)(41300700001)(8936002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Eo05MJVZaYnofwog4tsCcX3rXcox3hCsnMNxxdbhOXmdaD69nhiFutJf7JlVlyY4rG8aa+WAWnT8g1WBuiy0IRHgi+XuWQ/jtF2JYjFxv/Vjjje2WC6spY8UREm+TlMs/+C5FkaeqSrjKYn78ucVdQHnni4kwejBM+EIhSbcJp4v3J1FwVQOz9M1CfGFFdKzM4SY6Aoz8STbMAQM37LQGj36+JXuGam0L2e77RDjfvD0QJ4HqQu1VjKzzPxldQx8pab1rDgc/VXIs120E5mowgBXaSjnHSkttegZbn5SPYf/9hEe+Z4HXQHFzXlW0XIWUPwISQ2M2gylxao5zzGg2bvXFDxuY8r/Wwqb5f6prLDqgwUGYFFeezxb6gDaK7kDSJLGeNsMdS95IObGf7Bjb0STmaUnqJ+aKVyfEZOb7HkgJ1kfyXxOQhGiqtnBTP6qRyk+5gG4Yzds7aWzriLIxLC2XF148vcprmEri1rSYl0g0YI/XzX2dt8lOUi9BDIpv0pFvzvdi6oXGpCSnYHlB0yJOEtdwbjqe4bprkwa0ANsYcF1MYZdgLYgq/XkkxxFw0AdHOBefn7kEpkjwa3wlyr6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Exchange-CrossTenant-AuthSource: GV1PR04MB9070.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2023 15:51:29.8967 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SirC8wI2etzh+L1NeHSypmXFWxDEO8Od9zzISF9tJSYGKJP4hvRc+chSga/+IWDnXzwHYRZTJ4d8x0SbDKGClg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7878 X-Patchwork-Delegate: kuba@kernel.org Increase the needed headroom to account for a 64 byte alignment restriction which, with this patch, we make mandatory on the Tx path. The case in which the amount of headroom needed is not available is already handled by the driver which instead sends a S/G frame with the first buffer only holding the SW and HW annotation areas. Without this patch, we can empirically see data corruption happening between Tx and Tx confirmation which sometimes leads to the SW annotation area being overwritten. Since this is an old IP where the hardware team cannot help to understand the underlying behavior, we make the Tx alignment mandatory for all frames to avoid the crash on Tx conf. Also, remove the comment that suggested that this is just an optimization. Fixes: 6e2387e8f19e ("staging: fsl-dpaa2/eth: Add Freescale DPAA2 Ethernet driver") Closes: https://lore.kernel.org/netdev/aa784d0c-85eb-4e5d-968b-c8f74fa86be6@gin.de/ Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 6 ++---- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 15bab41cee48..f2676fd50e1f 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -1073,14 +1073,12 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv, dma_addr_t addr; buffer_start = skb->data - dpaa2_eth_needed_headroom(skb); - - /* If there's enough room to align the FD address, do it. - * It will help hardware optimize accesses. - */ aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN, DPAA2_ETH_TX_BUF_ALIGN); if (aligned_start >= skb->head) buffer_start = aligned_start; + else + return -ENOMEM; /* Store a backpointer to the skb at the beginning of the buffer * (in the private data area) such that we can release it diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index bfb6c96c3b2f..834cba8c3a41 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -740,7 +740,7 @@ static inline bool dpaa2_eth_rx_pause_enabled(u64 link_options) static inline unsigned int dpaa2_eth_needed_headroom(struct sk_buff *skb) { - unsigned int headroom = DPAA2_ETH_SWA_SIZE; + unsigned int headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN; /* If we don't have an skb (e.g. XDP buffer), we only need space for * the software annotation area From patchwork Wed Nov 22 15:51:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 13465068 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="OAUib04E" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2072.outbound.protection.outlook.com [40.107.20.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E231702 for ; Wed, 22 Nov 2023 07:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lLFlRRTYFQSxErxIwjE4H/UZOWLC0ZMIubTjpnSy1SQLHGurZktO4ybyo+e+zZaLIRJpzjj0shL/jfqGNihkmWsFfpTWsyeSzaCyyA8UNsWiedF8yOdYKhRXMGvalpzqfP/wgT1bQs3/N5oaozA3VpLFqLdTY5RkCqbGgQzUxmgPMUNbutVVW9nAvdPoRMXlw+g7nPjoH0/XJLy+CVzKApedJb8VppEBJctBpcLVyVMAIMvgQy/itd3U/f4K1OOMXk515WKz14vweYrtaEzUWYddMpqlrMQy/HZtAcyJkl6xcO8+l+MCIixegjxzXCp53kcZap9N3XSSI8+QyNzqiw== 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=5/MlaStpUgmu+fcWEIG8WokWEr6Kvy9orMpe0H0H30c=; b=TT2crHZBTC/6kZjQH/aavp3WUy7HtKPiHCZ0NCxy2nGyuaW+Dwd0LkNTL/xljpE0qKO3292ineAOGkT53edIY00wb1VhpHiG72cKART4X11pyHRMbsSmpgCkr5wTVxtqYWS8dgWtOO7lW23YHRP1lYlgDyEl3txocJeqL1a/pYI/geuJ3RnTFd1CI4cRFBs7hlCFCHGZR51tZa4N4dljpijNrMy8hH7Lxv6r88yYRUYk3yDngCI6hwxEXWFmXWsUpEYuJToz/77dPooHO7uLLiYOIICdfa2VRgjuZRDbqtV3H8oIVvpjUXnacKiF2HXMJaeuRjF75UcFQxU19ZDh1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5/MlaStpUgmu+fcWEIG8WokWEr6Kvy9orMpe0H0H30c=; b=OAUib04ErjqtM53VJSVfJjlpTqPGtLRsqR0MV6Ujg+OdbM8FHWeumxwIhWP5aSEYhncx54X6rePeTtXu8d9uwj4195CKs+HCPYAy/2O5FqF2xek/DauJVNvbMWkpT4NSFNR+LAojAq7XOOBJfKwq0imgNXMyavgfESuK/sfIbPk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9070.eurprd04.prod.outlook.com (2603:10a6:150:21::14) by AS8PR04MB7878.eurprd04.prod.outlook.com (2603:10a6:20b:2af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.19; Wed, 22 Nov 2023 15:51:31 +0000 Received: from GV1PR04MB9070.eurprd04.prod.outlook.com ([fe80::1290:90d4:98c1:3d35]) by GV1PR04MB9070.eurprd04.prod.outlook.com ([fe80::1290:90d4:98c1:3d35%7]) with mapi id 15.20.7025.019; Wed, 22 Nov 2023 15:51:31 +0000 From: Ioana Ciornei To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: andrew@lunn.ch, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net 2/3] dpaa2-eth: set needed_headroom for net_device Date: Wed, 22 Nov 2023 17:51:16 +0200 Message-Id: <20231122155117.2816724-3-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231122155117.2816724-1-ioana.ciornei@nxp.com> References: <20231122155117.2816724-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: VI1P195CA0033.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::22) To GV1PR04MB9070.eurprd04.prod.outlook.com (2603:10a6:150:21::14) 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: GV1PR04MB9070:EE_|AS8PR04MB7878:EE_ X-MS-Office365-Filtering-Correlation-Id: 3628f2e8-7d66-4aa4-1d61-08dbeb72e5b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jyrepGAa/4sH7pmsqG0JtmhiUORkI3a9UlhuDMJK+bPzz+J2Q9WAGY+d1BMQ2PQdStKpCoTfMJml954nQptCDu2jv0cbXwQktV873CFa2ZgW5E2TFfgtl0MHdmPVRtErTLLqcDree5Tg10U+PzqSzx0F6D+vaZOC1jQq3Erk3J8zACSGQbLKcRxKb8IVbrkP6Yztmx+2yT3dST4JUdzuDx0at6kByXyojYzM0ltCpy115mEdiv7nvpkjY96fX24z/KEl8y7+AIa14qdVEEnf/GPSRA1iDoWpR6HcDJ2crbbB3zt0hFVQo962SdXRuCzhW1kC+Gqrg0eqCWG8p5FzCTmPVdoHOUPJm30jbKA11MvOs/3p1J2jmulfGWxep2m3uRQgxX+SIRieu9xzWOPmYe5A3WStszkn1xphvu/Uy6n97nS7IeKm30fy5/6ijKSJI4+F5YjbJgeg80QGc5590c4F/x+bDpblgjy7atebLz2Z97OokHZmmVF7/BR9mrPHh5Mj//p81kFrGl2KMHTLWuHOEtjDiREZQy3Hz2mEsix9VCRORU8DnM1eUR6BF6HI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9070.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(66556008)(66946007)(38100700002)(66476007)(36756003)(86362001)(6512007)(6506007)(83380400001)(26005)(6666004)(2616005)(6486002)(2906002)(316002)(478600001)(1076003)(8676002)(4326008)(5660300002)(41300700001)(8936002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-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oQgbVtb7SBPoEa72NIGVWtaaqLl/WHRyAGMZK+F+mNdsgAUyOCSXqUC/TXWtUrb1yGNqnh7iOLD2EvEyqW67LDAxF+oq9tRGbdZkgA8evCjG4bwt/lvq1R/VWmayAUZ4m3Vm/uYAKoiLfwmRbe1l1EVn4NpJVrNxQzm+psL+4us0DyxnbJbKK1FU3Z+lwfEJzVWSE8SO9cJUfgzcd2Ci6jmA0ZThx6Ut+aF4o5oWUhUPcPumzYuJoHbQEUYafnOdJ3sMvMdAfJSPw/MvhcNX6Q+xjss1Q1M5A1iwJLfccG9vTG4uOpnOLsKSmA2IgdT0NaSrFzSXQFqvFLR6U0E+PZOkFlhcOKZO1DbtLku3PZD2944XMX5Lf8FdKTYheI1vRv3hv4va0G/J+HnoVYLA88vun2xb5ZmmgW0X10Ksoxi5XGaiRHaCmWmiCXCqYLQkEbxKctQqblVjhDNYYAOpsvjjye8rX7X6hQKAM21VAiqJzji2fSlHaVCOWaNmLYex0Y4aqSIbvUJIMP0yESmjwX075qaIro+wHusdxzxvP21S31Q/ys+L7SJ5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3628f2e8-7d66-4aa4-1d61-08dbeb72e5b8 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9070.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2023 15:51:31.6854 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5zAt2NtkQV0d7QInlGND5Mss88YLompfM5ToyWUiVFA1Bxhw5aY92zIrkIvr7MLF6Ynluhi5hSgvMfdL0iWQNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7878 X-Patchwork-Delegate: kuba@kernel.org Set the needed_headroom net device field to the usual value that the driver would need on the Tx path: - 64 bytes for the software annotation area - 64 bytes to account for a 64 byte aligned buffer address In the circumstances in which the needed Tx HW annotation would increase the needed headroom, for example timestamping, the driver is already capable to send a S/G frame with a single data buffer which circumvents the limited skb headroom. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index f2676fd50e1f..774377db0b4b 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -4965,6 +4965,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) if (err) goto err_dl_port_add; + net_dev->needed_headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN; + err = register_netdev(net_dev); if (err < 0) { dev_err(dev, "register_netdev() failed\n"); From patchwork Wed Nov 22 15:51:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 13465069 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="FycSbY4X" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2072.outbound.protection.outlook.com [40.107.20.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C4D1708 for ; Wed, 22 Nov 2023 07:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ipCCXBK+K6tHZYdnMjYWgfSPiVZO62OgydZPo5K4qc/T0xO0Y9d2q61ZiMT+hGgC9A/Kl4LRI7vZcx988HfoB7ND/GD1R9jfa5q5PlFoFceDIIWAjR+mTw6XOmsVAPB1llReoz5xMulJRRz8kkOQ1mDunLHN6uXoGEJbg8PR4V/0ceZw4EEHKR2VpVB2DxqiwkdzROJmXBnnVFBwz4UNasA2TOPczAM5bDlx/i1De9QpjmS0e0AJ7Dcek8pK4JwGg0vFxiEJ2yq0E1KiQchdz70npojR9B1lbzPVQrKfLFzMLFwHnixAaq1tT6Rj2OSUehZ6/c2rrHj3ZSIWEWw2lw== 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=28qgznvQq4u962BYYRC61aD08Cz/M2rP6UPjafOnX8s=; b=a0FJ3+flJkl9vCp7/oqzk705+WPdmdPnf3Bjf970P9ZHoQOI37rwC1W2lcjo/L5i282V/5GHZgC7QnaarodUokzS5YLyuc3QfdegIkC9m3J68AXZ/svEbrYui0POa1wkyokWC7OUdBYS3lvvCM6fSlrxgABwlCkNVM3dPtswlfijd+JCgaOkPpCWZvXqU0W8rS/g+NHaz4n2r+efVy/dTx63sX66ARN1UmeXZMo3nPhO1T2E46DAFC9rewCA+aliNNX/YjXz5K68MNPlGVdU83V4gUIk/TnjGTNrV8/gjTMncQm30j2AlzBp2qaEVbypeU88p1czVyXBbBox4+TCtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28qgznvQq4u962BYYRC61aD08Cz/M2rP6UPjafOnX8s=; b=FycSbY4XFSGt/9WxdlMPfsYiaSAjIAypbtm2agfLe5ZC+jRvc25DL+KLO4hRmWHQIdEfMdCoCqXej7dxlZYPfFs8F11tCbSWBte4ZkxRFHK951NI678jayO5YTVU5P1ADo/6q7goiAos2qVBQpra/xCzoJ31KvHmTnQuwPbtpXg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9070.eurprd04.prod.outlook.com (2603:10a6:150:21::14) by AS8PR04MB7878.eurprd04.prod.outlook.com (2603:10a6:20b:2af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.19; Wed, 22 Nov 2023 15:51:33 +0000 Received: from GV1PR04MB9070.eurprd04.prod.outlook.com ([fe80::1290:90d4:98c1:3d35]) by GV1PR04MB9070.eurprd04.prod.outlook.com ([fe80::1290:90d4:98c1:3d35%7]) with mapi id 15.20.7025.019; Wed, 22 Nov 2023 15:51:33 +0000 From: Ioana Ciornei To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: andrew@lunn.ch, netdev@vger.kernel.org, Ioana Ciornei Subject: [PATCH net 3/3] dpaa2-eth: recycle the RX buffer only after all processing done Date: Wed, 22 Nov 2023 17:51:17 +0200 Message-Id: <20231122155117.2816724-4-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231122155117.2816724-1-ioana.ciornei@nxp.com> References: <20231122155117.2816724-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: VI1P195CA0046.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::35) To GV1PR04MB9070.eurprd04.prod.outlook.com (2603:10a6:150:21::14) 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: GV1PR04MB9070:EE_|AS8PR04MB7878:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b8eaa75-a8c8-4d7d-4c50-08dbeb72e6ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D2a6S93ADGcel9DDBv9nIoq+V2JU0h7kMaW170DiN6YB1qi71LKtRD7y0yi3mj2588tbXVOD8SsAWxOiNGzP6oDaE2i1NV3glDAhUCot2BW+goV5YpHBS+vSaYlhipHDBycj/CHFcvFBqpwsAB5Q1CxriMNTQTa0mZcTYiRbjtFEWSAFwOPwCgjJ2ooUiNBYJNW9dhYegyZCrKOWopyHwBvhOv38rWi4ge+TJKzqzDJgBAUp8wCuN6F7UBgUtN9+2M4yInUzudv4l+bYjOyCxelP7kMwOu/YZfS1Si7AXpZ1+LTRbosZ2Da8k8VTe0GvNKlUo9wBh+xquPqpN8mIWx9R+g76njDB6FLYFMAckYhuOMNbNjpM7GteWRWk8rwb0YQBOx0AIROl9aGe/qMPc//2kamze+A40AzSnuOYBuxau/zRq2Q8/xtmc39kDOdTvmOdDp42+5JI+SeIf3FLj4UvQYsaWST8ZtqEbwDyclWi9RlZgbGyl7+gOK/q/MEXMLhVL6ZWqDKmhOGEfvUooZfmInWceq5auXoqXkeBPAfjA/NLhrZgMsrIvHcusXFa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9070.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(66556008)(66946007)(38100700002)(66476007)(36756003)(86362001)(6512007)(6506007)(83380400001)(26005)(6666004)(2616005)(6486002)(2906002)(316002)(478600001)(1076003)(8676002)(4326008)(5660300002)(41300700001)(8936002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YhPcwwRS0smwapVLAAxnjKzMh9/6j5JNKkNM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d98I0LYE148XoRdLv8oHE0p5nGIpH5WEdCPZF7dE7Lcjc/TRVSzaEISe/oEXfwtYDTkZOJ9jtfPLxx4gesMny/YzyUI5t0UG7ajdR0d3P5lAdn6c9IcTXtt0LzD6YtKpJMT3FtWrK/12nyMuBggKJcofofvtdoou8ApiSJJycXObgQ8ecJj6SJAE4a4yCd9TaKaczM1R/Z5PUMqZQhTFIJQcxL8IXAA5h0bTP0LiJkWWOyMIQnPYV+3hjxpJEiiWK9icOqG95DA5AblxRkd5PPzZDc9pK8fSBB9mMr7PEs37JOS2N05ADCm5uCIexif9a6hCeXOMTzQEoPK9yc3ZBu7wEux7g2QR4KuwgIfKUwZp6n6+UZADMZrDgzlPPcuBirqGCi4X/hQdf6IZjClu86HGfgqimJC2m4LECkesygMFmO6eYAkNUQPzXUDnSanfrWMqEc+KT+vVJPNdxPoPOfI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b8eaa75-a8c8-4d7d-4c50-08dbeb72e6ca X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9070.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2023 15:51:33.4822 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UyF0kHgs3IdNLMnAImSKH1LYWXvXsFIIGPOjx+gyrL9Rl9xBMT2NkU9z4+RMUR970vFTVhx0XUZVpJ3/+5U9jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7878 X-Patchwork-Delegate: kuba@kernel.org The blamed commit added support for Rx copybreak. This meant that for certain frame sizes, a new skb was allocated and the initial data buffer was recycled. Instead of waiting to recycle the Rx buffer only after all processing was done on it (like accessing the parse results or timestamp information), the code path just went ahead and re-used the buffer right away. This sometimes lead to corrupted HW and SW annotation areas. Fix this by delaying the moment when the buffer is recycled. Fixes: 50f826999a80 ("dpaa2-eth: add rx copybreak support") Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 774377db0b4b..888509cf1f21 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -516,8 +516,6 @@ struct sk_buff *dpaa2_eth_alloc_skb(struct dpaa2_eth_priv *priv, memcpy(skb->data, fd_vaddr + fd_offset, fd_length); - dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd)); - return skb; } @@ -589,6 +587,7 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, struct rtnl_link_stats64 *percpu_stats; struct dpaa2_eth_drv_stats *percpu_extras; struct device *dev = priv->net_dev->dev.parent; + bool recycle_rx_buf = false; void *buf_data; u32 xdp_act; @@ -618,6 +617,8 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, dma_unmap_page(dev, addr, priv->rx_buf_size, DMA_BIDIRECTIONAL); skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr); + } else { + recycle_rx_buf = true; } } else if (fd_format == dpaa2_fd_sg) { WARN_ON(priv->xdp_prog); @@ -637,6 +638,9 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, goto err_build_skb; dpaa2_eth_receive_skb(priv, ch, fd, vaddr, fq, percpu_stats, skb); + + if (recycle_rx_buf) + dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd)); return; err_build_skb: