From patchwork Thu Feb 4 11:21:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 376766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41957C433E0 for ; Thu, 4 Feb 2021 11:22:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E18BE64F43 for ; Thu, 4 Feb 2021 11:22:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235727AbhBDLWm (ORCPT ); Thu, 4 Feb 2021 06:22:42 -0500 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74]:47262 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235653AbhBDLWe (ORCPT ); Thu, 4 Feb 2021 06:22:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gh3r1wL0PkPqBONnBxhon+U1VgNA5E5AhpMpEkssXo4NRuOcj0+F0QzeQK58GaabqqBGehRDQBf4xbg8cbxevZSlUN27v4QxZhz2MJ0V9fvvRs91lPYCy4lJo9kdAj17T4qk6JlH1f0X90yR1RavurJGvLvnpPKaEx7UJWvFZsVQI2h4ZhU5QjdQdAgdjieJ8nCfhOFk7cgAPE85cXbKiPLGk+X5ay11ws56iTl0ByUVh4vjFZVd7CRRriVzPj6i26ICJPzfh/vJywl1ItZQ47h/kqS26aLNZffjNC9J37W0VknhDrrAx61CgtXzvOLlb6C1F9V7/C5VDwHxkifRGg== 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-SenderADCheck; bh=uvY4SXst9mvSQ73QepaPMdp5mAe89Cw6XdSkVbFx0e4=; b=knHseEFQFpudiWkXgqY+tcyJ7GN/JSSWdFAcDFN39pgy9C2oa6LQmpbC1zTuz/v8Vcz8avoLeMHFEGPbE4jMU6hBbgu701/iMCHcWrR7per5kvhGy02sa+/mYXcFI70uBxb4/M9UfjBjN4X0N/HwCYo45IuF3i7xgc4tC5nxLbte9wuohLJ0QPtQpBKMmBYut0KIg6zaXEgjkgp54mZh1mzvyeCunoZZJnDZhZFw4Mn2DBktMeiRb9nNrqFPmjtdwdqb4UnfKmjqSPyJVYjfQigmGgZDPR0+JNB0Wknb8tm/FBoqVpjM6elP4uYRxnO0DXL13Rf4MKbrutLs3Za4Qw== 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=uvY4SXst9mvSQ73QepaPMdp5mAe89Cw6XdSkVbFx0e4=; b=fZTVb/nyjutmpR926/OukUoHfDwe2Udg1g6nOpia+Z/perDqXUhYrxQD5SO67y1fKPWj3eT84YzNGTy/wIOrnr+o0hqJtsM92Ant3xTzg4Hewj+DdZUOzGHOqSjjiiA34OC7olHCMz5TAntsDf6a1Vr7g+D85zVWy+Tfp2/rj/w= Authentication-Results: st.com; dkim=none (message not signed) header.d=none;st.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) by VI1PR04MB6157.eurprd04.prod.outlook.com (2603:10a6:803:f2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.24; Thu, 4 Feb 2021 11:21:45 +0000 Received: from VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::6958:79d5:16bf:5f14]) by VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::6958:79d5:16bf:5f14%9]) with mapi id 15.20.3825.019; Thu, 4 Feb 2021 11:21:45 +0000 From: Joakim Zhang To: peppe.cavallaro@st.com, alexandre.torgue@st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V4 net 2/5] net: stmmac: fix watchdog timeout during suspend/resume stress test Date: Thu, 4 Feb 2021 19:21:41 +0800 Message-Id: <20210204112144.24163-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204112144.24163-1-qiangqing.zhang@nxp.com> References: <20210204112144.24163-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) To VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.11 via Frontend Transport; Thu, 4 Feb 2021 11:21:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 69332026-f6a1-4718-0b04-08d8c8ff0e06 X-MS-TrafficTypeDiagnostic: VI1PR04MB6157: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hS4FMQdyURTKMsQBJzvtt/lxbWn+Y2IiblxY+LS9dnwGZSwtJq0RkNIWFWaTdcD4EXsSTFmx0/9AIsqkHiw1uukY42MXHZxcqwY6kEjXnpQegnkx5Cd/pkdmstReVJK+FF89icW6xMo5ez+OQ8JcAz8+N6vXQx9jg6o16dfxVrTdRtAGKm4QW/2vtR4M/XcY0KDwvHv8FbcyuZTakPpOxvG2UiiduB1WM85leLA10eRE3imjfQ+V/DiPfgSwQypRFcjdf86Gy5l4tP2ryZ5Cc+Oeutlg8iCXUmJHOVo7owFBbenfAwA1jCsbIJwDqF8uz8BtG4ltoPmUh605AjOvJfA3vhHZ2mmggXRFTlUPVNl2xpQOh6jeHP7sse0BTyMimsv/yqxvJYiy+ueY3pnJ5I/cqLSsEPgG0Gc9Rc/X8hWBRUKRfJIRAsRskKyImPF0KBErt9VEASTqflsH4Pu8CZ+ezjCsBbotDWsiBmk2vn9nOrATl1yDq8o4TMPsny7aeY//P+jMUD0qbjfE3XK38ZJITpSZg2hKiA1BsuYs4dPVhVzf8oYpFawHx9kFRD/BkD3Tqj2qAw0m7AN5Dvzijw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB6800.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(136003)(366004)(39860400002)(396003)(86362001)(69590400011)(8936002)(6486002)(1076003)(16526019)(956004)(2906002)(5660300002)(316002)(66556008)(26005)(186003)(2616005)(8676002)(4326008)(6512007)(15650500001)(66476007)(478600001)(83380400001)(52116002)(6506007)(36756003)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 968pumlPGFnHuhp3rjsK0Rd+xkiaY3HNiazbb+xV9iRKYdCp9HeweIYmSSLK00i2E9GTWnXTSl1HPZtFAv5cAMD2eJptE1absuJjzzCZAvQw8nX6kXH4vTMlWXUtOS3tHKHhfzky9kVP7nRObLETpyTj/lJxUB37upGTWSKDwsM5V92rPdxGk0dlc7ENxTUFxCk4wj9eTcuawemLl2I2prfxs2iwBUKRj7D+xjV4auETCVIWqMAHsxgyRB4dliVucnuc0nZ7gel+QXxcRq72iL5C7qO3ill+2qFjyOYcT6lCEboQoVITMtgbaKRvPE0UGGQy84l0axfPKuF9PUCBGr/EEUOI+rtxdPiIXYKta8DY+p0hL2avaX3FayOPFOlgFQGpcQJLFfYjN+m3l215gputiu1WuARQZyqj4F/zbXiDYsuZEUwre7KrEorEmKi6CIDd2JdcPa+UhkB/x4MdtOFzTvHKtN45GJsAAcIjMDvHQMd9W/PT8Lp4EXFXTZFo2eAbKYbRXpzHPUM4xaoPaXNSry4GjjvEcmZWzm4bH5GdIvS0bO2jMwDKLdEncJfeAhhb1JNyoaHyY+3YCim4IctPxd1zcNR+Rueh/YgWTKyBZsZm5Ifwj8quIwAOl+6qlF42zvE/slPfIKGIj2nHM0pdJLW51/SUWfnvY883ZcNspPJiGuUaKrwS/Eu0naOfdw/q+FUtZfS62lGCatw4PSrU8+P+yU5coxNLVepSf/6yOR7mXC0r77c3j44VSX23/I42rv/+cj2hLzszymqFBUXd3ODEkGufejfXrypevyyP40c4ZC8JPovD25GJqqQPxc1CPkAkvCPsesoyM3bkzoajhRxY6C+ADiWX9WNErnSX4FkvwdFBmvJIdzZ1UHC998fr7gLyVGcwdnXmOdHUc80YsuCX+vRCJ4+ghXqD0RWSANZx/HFbULUMkh8I6XI+1fjFspITEep7d1CrEffQqRoUtfoioywmoZusUpgV7tucJzzhyp4aP6I6KJzYNkSX6VxjQzEGVHQN+5MpBbgnzSxUtVK359LEW85y0tx5emlvDxUccPRxdra9MAMZgHiK X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69332026-f6a1-4718-0b04-08d8c8ff0e06 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6800.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:21:45.2757 (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: H5WZyz7BZ0GscfzbZXKHypXIyr0iqRtmjIN8h3grGYWaNWNLkl5B5ZkWicWJovpmvMvaDjNzmddByloWuQEepg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6157 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org stmmac_xmit() call stmmac_tx_timer_arm() at the end to modify tx timer to do the transmission cleanup work. Imagine such a situation, stmmac enters suspend immediately after tx timer modified, it's expire callback stmmac_tx_clean() would not be invoked. This could affect BQL, since netdev_tx_sent_queue() has been called, but netdev_tx_completed_queue() have not been involved, as a result, dql_avail(&dev_queue->dql) finally always return a negative value. __dev_queue_xmit->__dev_xmit_skb->qdisc_run->__qdisc_run->qdisc_restart->dequeue_skb: if ((q->flags & TCQ_F_ONETXQUEUE) && netif_xmit_frozen_or_stopped(txq)) // __QUEUE_STATE_STACK_XOFF is set Net core will stop transmitting any more. Finillay, net watchdong would timeout. To fix this issue, we should call netdev_tx_reset_queue() in stmmac_resume(). Fixes: 54139cf3bb33 ("net: stmmac: adding multiple buffers for rx") Signed-off-by: Joakim Zhang --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 26b971cd4da5..12ed337a239b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5257,6 +5257,8 @@ static void stmmac_reset_queues_param(struct stmmac_priv *priv) tx_q->cur_tx = 0; tx_q->dirty_tx = 0; tx_q->mss = 0; + + netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); } } From patchwork Thu Feb 4 11:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 376765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CECA0C433E0 for ; Thu, 4 Feb 2021 11:23:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7975664F46 for ; Thu, 4 Feb 2021 11:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235751AbhBDLXM (ORCPT ); Thu, 4 Feb 2021 06:23:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235653AbhBDLXH (ORCPT ); Thu, 4 Feb 2021 06:23:07 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF4FAC0613D6 for ; Thu, 4 Feb 2021 03:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aPOb5i1BSNxzko2/7RDt60kD9LuFCQk2LoDAopsQ7MqqIRhR2qVqNfLI8rvpw7CV1HeN7ZJ/x2X/nZ+IMQZyVP9nF6uDVzF5imKMpPZkyQMg9Cgg/qE1hb7YRYpobQwm0eJR2o1y0LcYvUjdnSF1NGXrWvc1cv4vhI7NgykA8vqZyhL+CM8Q5ThFuRYInuFClkWU3Q/mzgySb9Z/ZiDbXFzDAApHHt+HHEfTRQAIE/Bze4W0LZSapQD7itg9zGlNlMvghzn8WpoxldJvIXIpJZeAu8H5S4AIlxNSEj/3BJv8iZwUv2ltj2z6akBYyN70pBqflbud1j4EBqGJ74/hxg== 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-SenderADCheck; bh=XZVEYlSirYC/BxAuAH+v/SlAmkW390URv6Vj0seH1/c=; b=WaxYB9DoZJTXRLHadIsrBLrwegtcIKJZNdiWqgcOG2BYBlJOOmh5EEwBznlS/XCKGtc0EgR9yzlMt8nBO9hBKLlZPHcQZeOG4xqQ+q82YRpBJV4iw//veME/R+g1y4e/qHzXCERyUQeyI2D08lWzvPY29wES2suRYR7qv4A4VkyQuTHL0SSywO5mpxIHkbRMAUvEJFvHQVEi/WglVj2IRLFYik2UitNFrgMT2GYUvfwKTUrQQktrQZi8t9Qpqu8b1x8Gfogo/kEMgyvqLLPLvwLSLlRnfDvZhwr+JQW35RoVCLjkGXhBmaqmUkQdcy4NkMTN4LHbOhgf2S+btsjLPQ== 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=XZVEYlSirYC/BxAuAH+v/SlAmkW390URv6Vj0seH1/c=; b=a8h8c7qVSGEr6tDOtx2Fy0UFIDK0mmkG4c9uIF6qejLKPI6NgwR3xoLKUX+RKXXfRJc7+r5bVOv+b2jEob/4AXPrJ7HKo/k6QfLXAWlvDF5fJL+YzUg56YeVRmJYqp2TqyQIUNRhBdCYnEEJZYTaBe4TrpG0UN6m6EUATo3ljyM= Authentication-Results: st.com; dkim=none (message not signed) header.d=none;st.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) by VE1PR04MB6366.eurprd04.prod.outlook.com (2603:10a6:803:12a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Thu, 4 Feb 2021 11:21:48 +0000 Received: from VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::6958:79d5:16bf:5f14]) by VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::6958:79d5:16bf:5f14%9]) with mapi id 15.20.3825.019; Thu, 4 Feb 2021 11:21:48 +0000 From: Joakim Zhang To: peppe.cavallaro@st.com, alexandre.torgue@st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V4 net 3/5] net: stmmac: fix dma physical address of descriptor when display ring Date: Thu, 4 Feb 2021 19:21:42 +0800 Message-Id: <20210204112144.24163-4-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204112144.24163-1-qiangqing.zhang@nxp.com> References: <20210204112144.24163-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) To VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.11 via Frontend Transport; Thu, 4 Feb 2021 11:21:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1d5428b6-5fc3-46b9-277b-08d8c8ff0fa6 X-MS-TrafficTypeDiagnostic: VE1PR04MB6366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:151; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1sRgVDE7Gw0Sy/YfkhSJGoiCcAS8lzFmUDjdVcLIkjVpS5IA9BtSGUS57skiOlzxGqXo6UAdEgYxc9fdLGIb0b7niOsBdGV8iAFGL39hmIq8Zs2jkJApXOXOxFSVrEaFa0ziXyANktQY8sD33UgnJtsafPlESwIfgmqLeKxtzNWx1Ej7nDFSEwYS8ZRPD8dBWsH7mOWxXBcfzzPwIvlxJQpLJDN+UinJneTuU8aHwRBlRKsBb1VOKkBCP1naTEzrYGHhQJIeu2+Nzu9Bj6skJ7tTDJ3wwbKlGdmgUF+cLRwrV+TEUNUCTrxy7lZJtxLohsD/B8ETfv0otqDknNJWnKRqpMgfxky0YI7FQGf77Lq8mpYEqVTkytDVAJjY6uZPaCktu6NbPgoInWX11cGzqFfZT5YovLkZY/4cJwXftR8EptklyQMb771cqm/QxIUZwajKLIQDVyjP/HMQjU3idbVgwW5Dxo/2BNe9twC6qlQP9NRaelFjJ+UgWuRFXBZYmrKnDYcP6aECZ/QpJY5112yMAr/IYzWFYJvBB8RrrLXMDiyrxxIJVv4Kcki26mFzTjj7btrzpfGI1jmdau4hEA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB6800.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(376002)(346002)(136003)(396003)(316002)(83380400001)(66476007)(478600001)(4326008)(66556008)(66946007)(2906002)(26005)(36756003)(956004)(5660300002)(8676002)(1076003)(6486002)(86362001)(8936002)(69590400011)(186003)(16526019)(52116002)(2616005)(6506007)(6666004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 95/i68ddcWHwMltPJkDQjOLHPKbm0QDsT82xJQwweOGUYengeEHCc1eVK14NDoRmr/iAwl8YT2x4WM8BFmrAjzOJuhI6HxA7aqJ21Dg2gc7XoUijhhfkcb3NN9gPnXCETq+UHi+GjzEBDkjHYmlMlgR3ZFezOIHsjhRcYodaJTSjwfgdHdQHhKvmtxuqJiHCW5MlbJrffBLFsa+y8QUCUbio1GmAoXic9HwsApeL9lJez8QMjIIl3SGMaff8BFPaMOqs6LyhN+PDtxZEKmtLi6Fp9qH3DkNwow0qday8dpr2glg19nvRxUeN+Oay1BpVJ8nTonh4eq/6/21oXjIa3kxpAzOcDkyy9yZBhQ+3gaYd/EV6zugv35md7qoOlTADxo7Q+FQmgGZgHGaJICQ+OLcpRHbHZI/vPNjiVxADZwH9eUZaZx9FBtuKniklKADNA4sNjaYGvyqrVBeQkzzJ+QE6Ax7KOic9AQHBig5xhSOVCwm0I+krdUjDPDBsTRATGmKugDrBkLI5hx55LbCuLq4aCwxvYFGmEWMXoo0FZmrNpyV8bAc3kBEyGbUkDE14Io3bPAhkbmr+D0RY8toEpYbnhEVMQ98qzPJg5NjMfF6v1qjiRiEMJqBBZSx23xjCOx6hBz2bcuDfUxud+qzRQwJdy+I8OjsPqhE9yLREkFPwEBq8v7j2+JdtPeVkA6U7/l9j+qywIcSGQfDnpRO3PMkHIlQJudlVPVLXs8bDX0pXOLaj85bIhyYM6VYhqh7jwSR2U6ie0GtFuwsBAlbyY4VfsP8rUY6UBtnBhXnwZ5Q9IvR/jgEEBh1p69m+e5bcQJ6b6GiN6NCe7ZTHio5fafNNUrVHM+JpAJfE2szEGtv4FJ3Y5o3rUOxBDIYhbegSInrI4TfT0UvAHTwIXoJF/nIoDM+5zCzQ4JGMnwV6grjv7EoI6JoNUc1Htsdkb5p8Gmt+7cGFEvAwJ4qIZ+N/VpBIxTWYjM7xGgSbQ5t2bzhVLm1P2jmIAynW4xi3ygYSIV7J7FiHhBLAey/sv8ztyTBxVH4ams1j6Y8WTBJ9BQo+dMmiRdDGXsB6MddB9cGK X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d5428b6-5fc3-46b9-277b-08d8c8ff0fa6 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6800.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:21:48.1421 (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: N9dof9RAoFL40OUUYh00HaLwSIoNbqPgVBo6QQqlUW5OkjaIWolN/gQDwoKYxUrEff3W7wT0pZZgOW9pDTFnZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6366 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Driver uses dma_alloc_coherent to allocate dma memory for descriptors, dma_alloc_coherent will return both the virtual address and physical address. AFAIK, virt_to_phys could not convert virtual address to physical address, for which memory is allocated by dma_alloc_coherent. Signed-off-by: Joakim Zhang --- .../ethernet/stmicro/stmmac/dwmac4_descs.c | 7 +-- .../net/ethernet/stmicro/stmmac/enh_desc.c | 7 +-- drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 +- .../net/ethernet/stmicro/stmmac/norm_desc.c | 7 +-- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 54 ++++++++++++------- 5 files changed, 49 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index c6540b003b43..6f951adc5f90 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -402,7 +402,8 @@ static void dwmac4_rd_set_tx_ic(struct dma_desc *p) p->des2 |= cpu_to_le32(TDES2_INTERRUPT_ON_COMPLETION); } -static void dwmac4_display_ring(void *head, unsigned int size, bool rx) +static void dwmac4_display_ring(void *head, unsigned int size, bool rx, + dma_addr_t dma_rx_phy, unsigned int desc_size) { struct dma_desc *p = (struct dma_desc *)head; int i; @@ -410,8 +411,8 @@ static void dwmac4_display_ring(void *head, unsigned int size, bool rx) pr_info("%s descriptor ring:\n", rx ? "RX" : "TX"); for (i = 0; i < size; i++) { - pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", - i, (unsigned int)virt_to_phys(p), + pr_info("%03d [0x%llx]: 0x%x 0x%x 0x%x 0x%x\n", + i, (unsigned long long)(dma_rx_phy + i * desc_size), le32_to_cpu(p->des0), le32_to_cpu(p->des1), le32_to_cpu(p->des2), le32_to_cpu(p->des3)); p++; diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index d02cec296f51..eaea4cf02386 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -417,7 +417,8 @@ static int enh_desc_get_rx_timestamp_status(void *desc, void *next_desc, } } -static void enh_desc_display_ring(void *head, unsigned int size, bool rx) +static void enh_desc_display_ring(void *head, unsigned int size, bool rx, + dma_addr_t dma_rx_phy, unsigned int desc_size) { struct dma_extended_desc *ep = (struct dma_extended_desc *)head; int i; @@ -428,8 +429,8 @@ static void enh_desc_display_ring(void *head, unsigned int size, bool rx) u64 x; x = *(u64 *)ep; - pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", - i, (unsigned int)virt_to_phys(ep), + pr_info("%03d [0x%llx]: 0x%x 0x%x 0x%x 0x%x\n", + i, (unsigned long long)(dma_rx_phy + i * desc_size), (unsigned int)x, (unsigned int)(x >> 32), ep->basic.des2, ep->basic.des3); ep++; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index b40b2e0667bb..7417db31402f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -78,7 +78,8 @@ struct stmmac_desc_ops { /* get rx timestamp status */ int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats); /* Display ring */ - void (*display_ring)(void *head, unsigned int size, bool rx); + void (*display_ring)(void *head, unsigned int size, bool rx, + dma_addr_t dma_rx_phy, unsigned int desc_size); /* set MSS via context descriptor */ void (*set_mss)(struct dma_desc *p, unsigned int mss); /* get descriptor skbuff address */ diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c index f083360e4ba6..36e769d2e312 100644 --- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c @@ -269,7 +269,8 @@ static int ndesc_get_rx_timestamp_status(void *desc, void *next_desc, u32 ats) return 1; } -static void ndesc_display_ring(void *head, unsigned int size, bool rx) +static void ndesc_display_ring(void *head, unsigned int size, bool rx, + dma_addr_t dma_rx_phy, unsigned int desc_size) { struct dma_desc *p = (struct dma_desc *)head; int i; @@ -280,8 +281,8 @@ static void ndesc_display_ring(void *head, unsigned int size, bool rx) u64 x; x = *(u64 *)p; - pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x", - i, (unsigned int)virt_to_phys(p), + pr_info("%03d [0x%llx]: 0x%x 0x%x 0x%x 0x%x", + i, (unsigned long long)(dma_rx_phy + i * desc_size), (unsigned int)x, (unsigned int)(x >> 32), p->des2, p->des3); p++; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 12ed337a239b..b1950fd4eb80 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1133,6 +1133,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) static void stmmac_display_rx_rings(struct stmmac_priv *priv) { u32 rx_cnt = priv->plat->rx_queues_to_use; + unsigned int desc_size; void *head_rx; u32 queue; @@ -1142,19 +1143,24 @@ static void stmmac_display_rx_rings(struct stmmac_priv *priv) pr_info("\tRX Queue %u rings\n", queue); - if (priv->extend_desc) + if (priv->extend_desc) { head_rx = (void *)rx_q->dma_erx; - else + desc_size = sizeof(struct dma_extended_desc); + } else { head_rx = (void *)rx_q->dma_rx; + desc_size = sizeof(struct dma_desc); + } /* Display RX ring */ - stmmac_display_ring(priv, head_rx, priv->dma_rx_size, true); + stmmac_display_ring(priv, head_rx, priv->dma_rx_size, true, + rx_q->dma_rx_phy, desc_size); } } static void stmmac_display_tx_rings(struct stmmac_priv *priv) { u32 tx_cnt = priv->plat->tx_queues_to_use; + unsigned int desc_size; void *head_tx; u32 queue; @@ -1164,14 +1170,19 @@ static void stmmac_display_tx_rings(struct stmmac_priv *priv) pr_info("\tTX Queue %d rings\n", queue); - if (priv->extend_desc) + if (priv->extend_desc) { head_tx = (void *)tx_q->dma_etx; - else if (tx_q->tbs & STMMAC_TBS_AVAIL) + desc_size = sizeof(struct dma_extended_desc); + } else if (tx_q->tbs & STMMAC_TBS_AVAIL) { head_tx = (void *)tx_q->dma_entx; - else + desc_size = sizeof(struct dma_edesc); + } else { head_tx = (void *)tx_q->dma_tx; + desc_size = sizeof(struct dma_desc); + } - stmmac_display_ring(priv, head_tx, priv->dma_tx_size, false); + stmmac_display_ring(priv, head_tx, priv->dma_tx_size, false, + tx_q->dma_tx_phy, desc_size); } } @@ -3736,18 +3747,23 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) unsigned int count = 0, error = 0, len = 0; int status = 0, coe = priv->hw->rx_csum; unsigned int next_entry = rx_q->cur_rx; + unsigned int desc_size; struct sk_buff *skb = NULL; if (netif_msg_rx_status(priv)) { void *rx_head; netdev_dbg(priv->dev, "%s: descriptor ring:\n", __func__); - if (priv->extend_desc) + if (priv->extend_desc) { rx_head = (void *)rx_q->dma_erx; - else + desc_size = sizeof(struct dma_extended_desc); + } else { rx_head = (void *)rx_q->dma_rx; + desc_size = sizeof(struct dma_desc); + } - stmmac_display_ring(priv, rx_head, priv->dma_rx_size, true); + stmmac_display_ring(priv, rx_head, priv->dma_rx_size, true, + rx_q->dma_rx_phy, desc_size); } while (count < limit) { unsigned int buf1_len = 0, buf2_len = 0; @@ -4315,7 +4331,7 @@ static int stmmac_set_mac_address(struct net_device *ndev, void *addr) static struct dentry *stmmac_fs_dir; static void sysfs_display_ring(void *head, int size, int extend_desc, - struct seq_file *seq) + struct seq_file *seq, dma_addr_t dma_phy_addr) { int i; struct dma_extended_desc *ep = (struct dma_extended_desc *)head; @@ -4323,16 +4339,16 @@ static void sysfs_display_ring(void *head, int size, int extend_desc, for (i = 0; i < size; i++) { if (extend_desc) { - seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", - i, (unsigned int)virt_to_phys(ep), + seq_printf(seq, "%d [0x%llx]: 0x%x 0x%x 0x%x 0x%x\n", + i, (unsigned long long)(dma_phy_addr + i * sizeof(ep)), le32_to_cpu(ep->basic.des0), le32_to_cpu(ep->basic.des1), le32_to_cpu(ep->basic.des2), le32_to_cpu(ep->basic.des3)); ep++; } else { - seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n", - i, (unsigned int)virt_to_phys(p), + seq_printf(seq, "%d [0x%llx]: 0x%x 0x%x 0x%x 0x%x\n", + i, (unsigned long long)(dma_phy_addr + i * sizeof(p)), le32_to_cpu(p->des0), le32_to_cpu(p->des1), le32_to_cpu(p->des2), le32_to_cpu(p->des3)); p++; @@ -4360,11 +4376,11 @@ static int stmmac_rings_status_show(struct seq_file *seq, void *v) if (priv->extend_desc) { seq_printf(seq, "Extended descriptor ring:\n"); sysfs_display_ring((void *)rx_q->dma_erx, - priv->dma_rx_size, 1, seq); + priv->dma_rx_size, 1, seq, rx_q->dma_rx_phy); } else { seq_printf(seq, "Descriptor ring:\n"); sysfs_display_ring((void *)rx_q->dma_rx, - priv->dma_rx_size, 0, seq); + priv->dma_rx_size, 0, seq, rx_q->dma_rx_phy); } } @@ -4376,11 +4392,11 @@ static int stmmac_rings_status_show(struct seq_file *seq, void *v) if (priv->extend_desc) { seq_printf(seq, "Extended descriptor ring:\n"); sysfs_display_ring((void *)tx_q->dma_etx, - priv->dma_tx_size, 1, seq); + priv->dma_tx_size, 1, seq, tx_q->dma_tx_phy); } else if (!(tx_q->tbs & STMMAC_TBS_AVAIL)) { seq_printf(seq, "Descriptor ring:\n"); sysfs_display_ring((void *)tx_q->dma_tx, - priv->dma_tx_size, 0, seq); + priv->dma_tx_size, 0, seq, tx_q->dma_tx_phy); } } From patchwork Thu Feb 4 11:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 376764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF9C0C433E0 for ; Thu, 4 Feb 2021 11:23:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7694C64F43 for ; Thu, 4 Feb 2021 11:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235757AbhBDLX3 (ORCPT ); Thu, 4 Feb 2021 06:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235731AbhBDLXI (ORCPT ); Thu, 4 Feb 2021 06:23:08 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E41C061786 for ; Thu, 4 Feb 2021 03:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MkkTFejLQNf5c6KEqgU6HRwNvgu3ZwlqSvg1Br+bo1IfiAa/Mr7r2sKWOPdWOZrg/1kyYdGj/p3DpkpdoTWuZpqWB1KBzwvvkbaLmYltEx+PENzbUBJ0df7NGsq3sD2psDgvdSqEEZ7qpwMQ6L1CDJ4pNJxqE2xQRcOng6krV2kvP/oVAoVZWRrZmdlLwPPp204cK1Z5QYyXkyVj5jY0KBJ9JSlJFDgLmkcxisF0zfkJCBMmMcsUg3wRveYmQ2l9HKY54fuKKEfZ4ieWbj2DRUlRxsvSfP6lyA3G4vqdhRLOsFyV5MWwujyHQ9b2Db1z4Pv8+GfApXXIebDU7IsFpg== 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-SenderADCheck; bh=8pa0QoH5JhUGs0bwqoZBnXc9kei9tkMubKUdOHk+pPk=; b=gomKsevch//C8ET657Bahwsp1xKyHZ5Zq2a+PQFP8ttXtpwLS6J7XGFfOlSdMNVIwaH/8Cbh368ahRw9j5nDUxeqcSTcf6VgTWABvjKfu6mee9WvwQD20eOUvA93J+vvRvXQvmmJdZYpq1sn7da7b/vlltbX1aowTHwSFhtDwDTvHNWAQxOFItJhtBfdVsVnUbNKQ5W1kmaoz3aeS9iVeQcDXxCGHCJQoXC3NFrBPr30NNJeaSDIlP3AhvXwr1RvuHyyEUhTHyDV5WWFNLBzdPRx/n14jpvYXGCI8S9dN9p2hzgB2Oe9bEC/D2eYJ31p+eUL2mLa86H3NRQqkQxwTA== 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=8pa0QoH5JhUGs0bwqoZBnXc9kei9tkMubKUdOHk+pPk=; b=SqAaWb4r9ZfTSvwaSvftwyd7ATcz/kVlEwLzQFCW/AUjtKMJ99t6n5Um0ipZTufLRfPSvf3MCU3gLjarvgYcd7HaeU0rt3QeFP/ezfGrXGifwn8eoH33j8koYcH8XO70/jcyEMQ+LUu4BmSbld1HEMbdOLCCVRL+VD/8Z2TVM9E= Authentication-Results: st.com; dkim=none (message not signed) header.d=none;st.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) by VE1PR04MB6366.eurprd04.prod.outlook.com (2603:10a6:803:12a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Thu, 4 Feb 2021 11:21:55 +0000 Received: from VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::6958:79d5:16bf:5f14]) by VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::6958:79d5:16bf:5f14%9]) with mapi id 15.20.3825.019; Thu, 4 Feb 2021 11:21:54 +0000 From: Joakim Zhang To: peppe.cavallaro@st.com, alexandre.torgue@st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V4 net 5/5] net: stmmac: re-init rx buffers when mac resume back Date: Thu, 4 Feb 2021 19:21:44 +0800 Message-Id: <20210204112144.24163-6-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204112144.24163-1-qiangqing.zhang@nxp.com> References: <20210204112144.24163-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) To VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.11 via Frontend Transport; Thu, 4 Feb 2021 11:21:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 683dd735-8a6c-40b4-c181-08d8c8ff133b X-MS-TrafficTypeDiagnostic: VE1PR04MB6366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MErOUv/TfcQyAopRjFGlu4nI87eiArTEHLgeN7XT85516V3/Tlu89FxPPH5foAS2zxFNSo+xfnf9FLwwJVupg5gOVdDgMaZ+UV+W0fKwlGK63kQGwTe+PlH/SQERGfQ3HKG6KrbbIAIdVAxvC3hYV8XHr3ixk3/WHqr0CEK3h/3Aq6CqqXPxq6Bkqf5b0f/lA6wgUIWG9eSSU32aW4BWtwdVgy6ZKF+FnUWlUo0berxNceDZ5vP5aSH0Q0p/lOn+poHMUsgfSkZuIUk8MA4D/3wKKyOzNi39XCdVV9AKJcEPZsNpqqXwqlnUfV3asVH8LvPBoFDVuw+6kWqKUwaX0Hvv3tWjymi5QUSTaO7m3YTQUA17w5qxkKIX5hbT1PtS+kJx38hWNiXCKbbbxXdnmZCTyCWs6dDXenbUlkJxirG5b3gOgxCwSPJZFNblSAajd87qbtUqlbh6BZLxcxfX+XLFKO1Qj70P2QT2cOu9EkiuJULzX/WQpNoWLfJy1Qr+Xx4kudvqWGatY0NHZWUK3no/zAPuJkkjdXepq8IrEUz8Ff1ZZ8d4vdvm+/Frdvi++Jszm+IGv8zJ3tx6+P3suQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB6800.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(376002)(346002)(136003)(396003)(316002)(83380400001)(66476007)(478600001)(4326008)(66556008)(66946007)(2906002)(26005)(36756003)(956004)(5660300002)(8676002)(1076003)(6486002)(86362001)(8936002)(69590400011)(186003)(16526019)(52116002)(2616005)(6506007)(6666004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pV9Yye7EPDAgffr2Fj4oTPSNRLtZWKuoe2Iz4pQYjh77rF3jBWA2xNomvUMK55VPxOdNSvBtKRoSoU27ac+walwHWAUaNqkcC5CHshe5OKTXxPnst3AbbgR6v5RZlUI/yKtRmnFl6/Cdq6EX3V8FcpMTPgUr0trIhOvHvEVcy7HhWXt6G3azyZWoBNHMHDKu+c1Idpv55pqebFuh/C11pgCAdt4AJOeKP2b+M/L802zK+deauRMVLaRsCNEmyF+QB8+K5z3t1eFxbiUeUttRTqIleRsAjS3Xwv7GhnzcwKsYJq7dmTh7SiTktJOdodZ4qlYnL9PA5ohw8Zmc1XOsmhRIFi1ew9qvyty5tV29rSSpMO/p/3Jp736XfPtRnlW1OM+ggwXNtQBXuIidZL395G1pLRurbXe65ZSiPgNZkUKMWpYzJHcQ9byaFrJR9onULlkkP650FjTNYho3BTjQpAzyS1ypfgMk/oCPatMe6439vNctYj2B80TJe83rTaz1jgIxVJTawLDo+GOXXVA4B38PSzv3NxfSGHxRPe4fIHYdfftyzObZH97U3ZHCj4c7x7lKUXDHJKwe6GG9TTuGKnJ61RTxodIz3egR6cPHZrUF3FbWekcRzRzxveHPTaWGbkSKXU0dBM4OZo7fMUeHOyXGvmfp5RaP2zGfdRikwZzmlvwM5CIykwQCkk9E88T78tFwTBaoec6iqr4S24oF3d6maoreSh+JxZdFFdnQ7fyUO+PlZWHSu27o6dDwdWp3ndYIM317s3eKDijvAk1X/7WuoFVTI4nKoUiapcCY/5mpxscPMn9ZXW3rW92eXMqQ7Psx+jyUn48AQUqk61GC3jXqlOQHPBfcQAfMRAWXTgLu5kqCFO0951tyE2CR4WlcaBXyINqoS8kHQzvGg/ilVqpnMsSCLjEyoqtf+TWSYRx9jvcKMZzXk/J+JxZuE7OIzmyDBZpTnyS0anJApIt65eUJ4A4sxd8FS4RAPRFhz26HXTG45Nm+rf6bmYbvDRmb7klFPGQBIEI0L/jDO9AQ+EZtjpPtwe+wa4QyHeAslE9UrpjNpt/vSiDkhYA9091i X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 683dd735-8a6c-40b4-c181-08d8c8ff133b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6800.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:21:54.0582 (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: yilp+me/NC/aULwKxn79GB9xzhR4gmQgW07pW3SuCU9t+mM36kTWIyv5FSs9+Lpd1VbXmBcs9XU9yNY9OJ+FNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6366 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org During suspend/resume stress test, we found descriptor write back by DMA could exhibit unusual behavior, e.g.: 003 [0xc4310030]: 0x0 0x40 0x0 0xb5010040 We can see that desc3 write back is 0xb5010040, it is still ownd by DMA, so application would not recycle this buffer. It will trigger fatal bus error when DMA try to use this descriptor again. To fix this issue, we should re-init all rx buffers when mac resume back. Signed-off-by: Joakim Zhang --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 04ba77775e52..e8e9e5b8c62d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1379,6 +1379,91 @@ static void stmmac_free_tx_buffer(struct stmmac_priv *priv, u32 queue, int i) } } +/** + * stmmac_reinit_rx_buffers - reinit the RX descriptor buffer. + * @priv: driver private structure + * Description: this function is called to re-allocate a receive buffer, perform + * the DMA mapping and init the descriptor. + */ +static int stmmac_reinit_rx_buffers(struct stmmac_priv *priv) +{ + u32 rx_count = priv->plat->rx_queues_to_use; + u32 queue; + int i; + + for (queue = 0; queue < rx_count; queue++) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; + + if (buf->page) { + page_pool_recycle_direct(rx_q->page_pool, buf->page); + buf->page = NULL; + } + + if (priv->sph && buf->sec_page) { + page_pool_recycle_direct(rx_q->page_pool, buf->sec_page); + buf->sec_page = NULL; + } + } + } + + for (queue = 0; queue < rx_count; queue++) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; + struct dma_desc *p; + + if (priv->extend_desc) + p = &((rx_q->dma_erx + i)->basic); + else + p = rx_q->dma_rx + i; + + if (!buf->page) { + buf->page = page_pool_dev_alloc_pages(rx_q->page_pool); + if (!buf->page) + goto err_reinit_rx_buffers; + + buf->addr = page_pool_get_dma_addr(buf->page); + } + + if (priv->sph && !buf->sec_page) { + buf->sec_page = page_pool_dev_alloc_pages(rx_q->page_pool); + if (!buf->sec_page) + goto err_reinit_rx_buffers; + + buf->sec_addr = page_pool_get_dma_addr(buf->sec_page); + } + + stmmac_set_desc_addr(priv, p, buf->addr); + if (priv->sph) + stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); + else + stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); + if (priv->dma_buf_sz == BUF_SIZE_16KiB) + stmmac_init_desc3(priv, p); + } + } + + return 0; + +err_reinit_rx_buffers: + while (queue >= 0) { + while (--i >= 0) + stmmac_free_rx_buffer(priv, queue, i); + + if (queue == 0) + break; + + i = priv->dma_rx_size; + queue--; + } + + return -ENOMEM; +} + /** * init_dma_rx_desc_rings - init the RX descriptor rings * @dev: net device structure @@ -5340,7 +5425,7 @@ int stmmac_resume(struct device *dev) mutex_lock(&priv->lock); stmmac_reset_queues_param(priv); - + stmmac_reinit_rx_buffers(priv); stmmac_free_tx_skbufs(priv); stmmac_clear_descriptors(priv);