From patchwork Mon Apr 2 03:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10319439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7121460388 for ; Mon, 2 Apr 2018 03:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61C8328D3A for ; Mon, 2 Apr 2018 03:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5590C28D62; Mon, 2 Apr 2018 03:25:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BBB2528D3A for ; Mon, 2 Apr 2018 03:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9fC9cxKY2a+j4aO+y3tHJ3iDKiH7jS68xXTLltGiDhk=; b=WvEmULUJNSHGnM r6LdhtHP5WVhsCMypDEArvHbcgkI0wNg+U4ohxXzdT8Dk8ym4/o/k7xQzcwxQrqoPoks0po0GnPtC QrIVnN2bWk/3Mqiw2DYC7vNkH9yvYXLYCcMMIVgF5PO1i5fBg0jLDZVmg6Atvjn1iq4uPNHdS8npn z0aaY0ZvhWfIItPHLNguWSbPz0yegfPjkYq6LUwEDlrmJqlWVbNCO+USAaDaF5+MNW2sm9h+vHDdo BzjTK5fW/cQoAfH+VaPFvgIx4QK/BVObWEgm5HihRjWq1YSt8nkUXPiyob8vaG1CV2BhpQmXv7l+8 WiN/fouaP2aP8fPAHWwg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2q6A-0002bZ-EE; Mon, 02 Apr 2018 03:25:34 +0000 Received: from mail-by2nam03on0051.outbound.protection.outlook.com ([104.47.42.51] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2q67-0002am-1a for linux-arm-kernel@lists.infradead.org; Mon, 02 Apr 2018 03:25:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=UiqwCzDZna69EEKUinP2eOhl9buoL5ubKTxB6A/z6j4=; b=dgCFYwO0zeM4ZlOcA6m+LsFSEBCzKuuuCS5oo/0iUnbNygs/oJE5Wicjf9/OFhCYM+UjRkiwStxm1k5Vk+VEJ63HfvSxgMfIU4dwTxKHBuepg9KkQd/0FlxIVkQlSWwIQNG2dMiulGUi/CXUDNkrUOVJOeMk+WQnnWHGquNhZWQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by DM5PR03MB2635.namprd03.prod.outlook.com (2603:10b6:3:43::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Mon, 2 Apr 2018 03:25:17 +0000 Date: Mon, 2 Apr 2018 11:24:59 +0800 From: Jisheng Zhang To: David Miller , Thomas Petazzoni , Russell King - ARM Linux Subject: [PATCH v3 2/2] net: mvneta: improve suspend/resume Message-ID: <20180402112500.4b58058d@xhacker.debian> In-Reply-To: <20180402112229.508e1feb@xhacker.debian> References: <20180402112229.508e1feb@xhacker.debian> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: KU1PR03CA0034.apcprd03.prod.outlook.com (2603:1096:802:19::22) To DM5PR03MB2635.namprd03.prod.outlook.com (2603:10b6:3:43::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52227f1e-9353-4ba2-7d62-08d598495c5d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM5PR03MB2635; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2635; 3:8S4P/DD12cRmDFmzX9PalOLwvRbL/5GuSLTnCVKUIoMWOOFP0eFCfcibZorZxhE4RewLuSHgI5ix4JEg0GNSoPIQzANz/y9SRtSOvA3drtjC7RilbQbZ3vggxblc5DUl005nz4+PBlrS9NtIRZGO0TRYATJ3MtNUFP6jKc/GP+9PrVCyJwYUtQEen5EG0uMwLKX2lMwYNPoCMdHIeOermLd562IzWVgl0Szl4scfTYy5d4s9jjNdiXFJ+dbDhK4j; 25:tXiB1MvD0A3pFTQcDY3fvqq69Hm+mxoshi2jzLjyfEwYIdJ4VG0gd0n7vQGjmBr5KmZICEK5pre45Pd4GzehNU2Bs7lDVAJbfASUxmZ+vdBxmdhkZ/YRM92m+LSARCLP1dddcfNeuVQf2SheZmgPjubeOMyhTHl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AI9jGzQtPox1zv8rLeBH+ZWnAYKCyAQVjjr08eIt04XhtWmtuRpileyDpMpu945jV2TVk6xxJAmdWGm42vFknht/MNcYRmTXKYqzBLpMw7z7Q1diuT0kOAacFeNQnJ/N1LxpfWhObjLThtvUsubxHYMbi9VnR7gs97TnNCm+Z5JnifYfSCgdT8dP7tuRrRTbOeGtunUb2m1Ufg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(3002001)(10201501046)(93006095)(93001095)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR03MB2635; BCL:0; PCL:0; RULEID:; SRVR:DM5PR03MB2635; X-Forefront-PRVS: 0630013541 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(346002)(39850400004)(396003)(376002)(199004)(189003)(7696005)(52116002)(386003)(76176011)(86362001)(33896004)(15650500001)(110136005)(53936002)(316002)(106356001)(72206003)(6666003)(59450400001)(81156014)(1076002)(8676002)(478600001)(47776003)(66066001)(25786009)(6506007)(81166006)(8936002)(50226002)(230700001)(4326008)(16526019)(186003)(26005)(7736002)(105586002)(5890100001)(2906002)(68736007)(50466002)(5660300001)(305945005)(97736004)(9686003)(23726003)(55016002)(3846002)(6116002)(956004)(486005)(446003)(486005)(476003)(11346002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2635; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2635; 23:mU4v1VgYG8WuVbdi5C17mkljXHQyoIc4tI7F38wGw?= =?us-ascii?Q?neWw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QSC+1Mmxq915+bRYas1UA3J0gnZAfUVKjSArJOdTKz9XOs8rsuwQR4HgKTOVFy2DHWnKfyVi64BLvcNQ7Tw7X7dmH0dB9Ksm5u7v3Lno5yzaFjulmrJ6sRHm7wr0EB1tOu+373+fAyKjWmPWYjMj3PstuqOBrtngcmfomRiAlg==; 5:Jnfhni6SJv2nggWYJx0VAtqcR7n7IdwXhVhJ9Z/e9adT/OS1ykUZh/wgnH11KZ1o5NS3G1Hnbz7BJTS5dMFNoShXRZlDHrl51F3TiU6mKIlfddnSIzBPsW4YwsH2Qmlg8pQSh0hlBFcekK4TPAhsaMTEu2wIwx5DY5dNftkw6kI=; 24:1Yia81hBnoeH+nGc04OcdpV6miOtDQe7/kZ/Qsk2N3YuN/i0s2k/8cLJdIb36v2GxW2SNgK3NRJsyA1Lkfx4B5pP5684GemVavaUqBqj1Vc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2635; 7:NM+lqzz2734L5OuPWnhUt0SgeaomfYW6oALhEXYAw+WMkAyR6oqGyVoSum1DA1Yd+UWdVyGRJRBpUaqVlNArCfi/70SL9Zv+nzIgWM1Ggd8txZy0tkRoxUHMscZSlocMj9iv17krMDe2gUqJvA1Itk6W5rkDS2UiTXgowMIKNvePMZ+2+/dZylAZBFFsbXUk5WK0Yn7vRH9mx1bcMOH9vOfwb72UQpBUo3sMGW9Xz2hVYGUQRK7Tf/tZv0UWOu3y X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2018 03:25:17.0583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52227f1e-9353-4ba2-7d62-08d598495c5d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2635 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180401_202531_098377_AC30E773 X-CRM114-Status: GOOD ( 12.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Current suspend/resume implementation reuses the mvneta_open() and mvneta_close(), but it could be optimized to take only necessary actions during suspend/resume. One obvious problem of current implementation is: after hundreds of system suspend/resume cycles, the resume of mvneta could fail due to fragmented dma coherent memory. After this patch, the non-necessary memory alloc/free is optimized out. Signed-off-by: Jisheng Zhang --- drivers/net/ethernet/marvell/mvneta.c | 69 +++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index f96815853108..8999a9a52ca2 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -4586,16 +4586,45 @@ static int mvneta_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int mvneta_suspend(struct device *device) { + int queue; struct net_device *dev = dev_get_drvdata(device); struct mvneta_port *pp = netdev_priv(dev); + if (!netif_running(dev)) + goto clean_exit; + + if (!pp->neta_armada3700) { + spin_lock(&pp->lock); + pp->is_stopped = true; + spin_unlock(&pp->lock); + + cpuhp_state_remove_instance_nocalls(online_hpstate, + &pp->node_online); + cpuhp_state_remove_instance_nocalls(CPUHP_NET_MVNETA_DEAD, + &pp->node_dead); + } + rtnl_lock(); - if (netif_running(dev)) - mvneta_stop(dev); + mvneta_stop_dev(pp); rtnl_unlock(); + + for (queue = 0; queue < rxq_number; queue++) { + struct mvneta_rx_queue *rxq = &pp->rxqs[queue]; + + mvneta_rxq_drop_pkts(pp, rxq); + } + + for (queue = 0; queue < txq_number; queue++) { + struct mvneta_tx_queue *txq = &pp->txqs[queue]; + + mvneta_txq_hw_deinit(pp, txq); + } + +clean_exit: netif_device_detach(dev); clk_disable_unprepare(pp->clk_bus); clk_disable_unprepare(pp->clk); + return 0; } @@ -4604,7 +4633,7 @@ static int mvneta_resume(struct device *device) struct platform_device *pdev = to_platform_device(device); struct net_device *dev = dev_get_drvdata(device); struct mvneta_port *pp = netdev_priv(dev); - int err; + int err, queue; clk_prepare_enable(pp->clk); if (!IS_ERR(pp->clk_bus)) @@ -4626,12 +4655,38 @@ static int mvneta_resume(struct device *device) } netif_device_attach(dev); - rtnl_lock(); - if (netif_running(dev)) { - mvneta_open(dev); - mvneta_set_rx_mode(dev); + + if (!netif_running(dev)) + return 0; + + for (queue = 0; queue < rxq_number; queue++) { + struct mvneta_rx_queue *rxq = &pp->rxqs[queue]; + + rxq->next_desc_to_proc = 0; + mvneta_rxq_hw_init(pp, rxq); + } + + for (queue = 0; queue < txq_number; queue++) { + struct mvneta_tx_queue *txq = &pp->txqs[queue]; + + txq->next_desc_to_proc = 0; + mvneta_txq_hw_init(pp, txq); } + + if (!pp->neta_armada3700) { + spin_lock(&pp->lock); + pp->is_stopped = false; + spin_unlock(&pp->lock); + cpuhp_state_add_instance_nocalls(online_hpstate, + &pp->node_online); + cpuhp_state_add_instance_nocalls(CPUHP_NET_MVNETA_DEAD, + &pp->node_dead); + } + + rtnl_lock(); + mvneta_start_dev(pp); rtnl_unlock(); + mvneta_set_rx_mode(dev); return 0; }