From patchwork Thu Mar 29 10:15:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10314855 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 3F1C660383 for ; Thu, 29 Mar 2018 10:16:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35D442A2EB for ; Thu, 29 Mar 2018 10:16:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A4CD2A2EC; Thu, 29 Mar 2018 10:16:25 +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 DA63C2A2F6 for ; Thu, 29 Mar 2018 10:16:22 +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=oIJEJCzZ+jqRay0VOgYXx8RXPo1Z0BgojhN4G9CnxFg=; b=OvjqBiIqpUMZS7 6PbB+YChzq52aWMjlsYJfxWzPyBblsngWfk4mB6FVrJ167aWuxKKef67oC+O7Df+V4e5GDvhC2/pN aA4dSwWtPwO0IhsCuWytJv0s9pcVPH3/zPXJnC8fRw4Sks4c3ytaiQ39CaZ/auK8LqI0Cw+m6pK2i 9404VNrxRGEmC5hJ80BwVrtDx48Cpvw0C50wfnsgWNqbVAPlbOJDCC4s8UY6DvvqYSLBJwHnPLniW ckyHHTLVahLA7B/VSuiRuBr+wEyKERnZu16juBZhuQttrW6ilzIxrH7MYZRRmnZZt5PQLgu/iejg8 x0ar6Lzt9gOu3cNLomxA==; 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 1f1UbN-0001UM-Cf; Thu, 29 Mar 2018 10:16:13 +0000 Received: from mail-co1nam03on0072.outbound.protection.outlook.com ([104.47.40.72] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1UbF-0001RO-8m for linux-arm-kernel@lists.infradead.org; Thu, 29 Mar 2018 10:16:11 +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=2QoD0lBdjSsm0sQG6mjUwqgyyY2zWAaZsvgpo4uvM7Q=; b=QtwTn5rRcWbmcHOB6UZLec5ZUuoLwAxoVgROzh0NjpdhayWOGfng4uaxRF1JkxowsrGKWBcbYiznFgmrmr6Ki8Yr9y+Upv5+BjIEGsKY98zYNWmmJMpb25OCIqz6O47Wz5VN0WYCztWrB9vdPVziyc2VbMYpWMBvrEUa/Z+Oato= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by CY4PR03MB2630.namprd03.prod.outlook.com (2603:10b6:903:75::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Thu, 29 Mar 2018 10:15:51 +0000 Date: Thu, 29 Mar 2018 18:15:36 +0800 From: Jisheng Zhang To: David Miller , Thomas Petazzoni Subject: [PATCH 2/2] net: mvneta: improve suspend/resume Message-ID: <20180329181536.46e065d2@xhacker.debian> In-Reply-To: <20180329181220.61d63c92@xhacker.debian> References: <20180329181220.61d63c92@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: TY1PR01CA0193.jpnprd01.prod.outlook.com (2603:1096:403::23) To CY4PR03MB2630.namprd03.prod.outlook.com (2603:10b6:903:75::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7359915d-8cc9-4302-72c9-08d5955e0d79 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR03MB2630; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2630; 3:YX1n4j95tSl6aIiebBVf5t8qLxrQ46b/SWu2JukzrE7QZn7W99vodPNK0Nx0UPb6Wgqa6c5uyCwoCJFs1WckrcLE/0JrAUSyoVXk/R9FqzNu/vCXCE1uf3agKh8ACmYK07CqmmCCKm3vzOZHC5VFFyH75kDFi40TfTJjwoufZSWeBj1YBNMhNL73P3XKJIDfQJ+DqDxZHUK8AwElZnsHu1UB/xkg4Tk55P3RlrIopwpmOoZp82wzNjbb5lFf1QaL; 25:UKco2QealuoAFqn0lPylEtq1lHUqgBFUjiJcwtzmCJPsmhR+7jBk+TYZmzj3+ufvP4BL0C+h/D76koXKnIrUvpRGCVy6h9WnbTYK2nfxlM4g9mMiaFMj+Vm89Okt7rHjhrEwOT1hcoXraA801A+VGuFpll/lkvMw2Jj+T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ed/uFSGe7+UYjoRDkxuUHax3EMBzJ51+wKMG+AO4ph1kX6rXam/UzhJ2LzOXYA+kxis7RihVUy/aj0PK5PCS47dzgGNPUZgPvIvamov1VvHvadYJDL6fKMNK35wIUnzw5AIuY6mOn2I0mo6WByJmIjNd2AwjptyHjDwpILXzDxWd9T9u3066J+8nFJMXcqwxIvA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR03MB2630; BCL:0; PCL:0; RULEID:; SRVR:CY4PR03MB2630; X-Forefront-PRVS: 0626C21B10 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(346002)(366004)(376002)(199004)(189003)(68736007)(105586002)(81166006)(52116002)(97736004)(5890100001)(6116002)(110136005)(7696005)(230700001)(3846002)(23726003)(476003)(6506007)(7736002)(81156014)(386003)(305945005)(50466002)(6666003)(956004)(11346002)(446003)(53936002)(1076002)(33896004)(16526019)(2906002)(9686003)(76176011)(59450400001)(4326008)(5660300001)(86362001)(106356001)(26005)(8676002)(8936002)(486005)(478600001)(486005)(47776003)(316002)(15650500001)(25786009)(50226002)(72206003)(66066001)(186003)(55016002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2630; H:xhacker.debian; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB2630; 23:6zbpkW1XWsb1dN16e5zr9q3stTW8dWLMztlA1NK4/?= =?us-ascii?Q?asEpqiVkyKwtJX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kea4SM/e/bCy?= =?us-ascii?Q?eoC+uoKt2rJXnzFm38wbqfuWBOIAw0YIx55ifr4IRXoLcDx88nhKUDC2Qcod?= =?us-ascii?Q?avFgE+Mw2Qf9ad+qX0kwiRmbjYd2Xzynx7mUROYnLqAtclEab5GatntoGf6O?= =?us-ascii?Q?y1nPRaSw1Q2yPS4VVZeP5e7DwHc/y9rshgcKMwQcnSgqYLVf8RvYgNXwakfP?= =?us-ascii?Q?ERXaTgDCw3Blg4tIldy2WyQPuVAK1tLv2GKBZ2M61HIoHBjIWNfgNEHlrVB/?= =?us-ascii?Q?y+taYJrrZnrfCVd4evyTVNitCdggk7O91BBsq3fqk7HjZXlNJh6c1iRHwB/X?= =?us-ascii?Q?V355PAUwqc7Dpj+jz6sAhilErFcazNvf369HMBLGYevmtxynGY4oXowLfcwx?= =?us-ascii?Q?PJDzT+pDWcRzsF1nPsL/PmpFdokQMzB6wgnDNNKONts?= X-Microsoft-Antispam-Message-Info: KS6oDTaCtM6+ApcsV+FNuq7F8FL2ssbjWARUY5ZzT7gm4dizfrM6xFu3mCvtWkvrzUfNuZ0eYY3MrU/Jk72QLxQk9/smqhKj5HAmdCxQddd2WX+JXM4P543mmgc8esa3D+fbfv4vKIXU3hyz6f28X3NwUZ0jqgrKakU5+2QWCjGfRvEm7EkJzgVHEgZAiTnA X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2630; 6:cAC7IpQ9CwT33an8gGrGMKKPB/zBEmg6MqYGDRZG56/3gmGBvtyK0XRfX5MgN2C4nfG0e4uN9u1RhfCOteqBg9om1AqbTJmlE8BjDP5i3CF7CemfwYTA7w8VqdVGGvSKpgaqiZfy8cA94hV6gtqmghqDjuJjL2hT7EF7FNJroB5gDsgzVM97AoOwRkYVOGhx2v4VQju7qG60CAWmQHP580YtWR1OUMGxa9gVaH436qxUkwiKHyV66Yo404XfsGSEkfSL57uZzfRzs91nB9u9o38i55iseYlyDXSFa3b8ARr5B8tmIXyOakH9w/z9ApfpS3zYTfbr1kJ2B3wZ2VJsZpDktjIL4fNmoCIBVaAjBlFgMWZJ/XdgOO33vqXUScKUxCxQfETW115HhdfbpsK+LQwBX+uUWBRVxsWVXA/uYp6+mp4SnktAeVBYC6xJWMoz8xDr0j3+0Y9p9RbYpbsNXw==; 5:LYQ1mtK1blCURKNnCKVzmqOFxeoNGKrmhdfPKBD4m/mx488Tc2dN/bGX92owjN3aVS+KM2jpo0z8bZZeR/rumUwxxUJVdlf4V+Umbt8cebN/ZHLpOxktKmwT3hPWx37ItNBq7qLykJo5zTK7UdXiOb7wxqIyKfIpbNvsB9WIZuE=; 24:Xxp3+DSVOSNRqPrJtRFO15NXTOy/q8ZPr54T+cTwrj5qWmHY3peQoecKBKhnxxm28mo0TUlfWRtk6a6zVFjB8OCbod9aRu2OU5Tr1hLu5FM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2630; 7:/9vHh3rel8X0eeE9FuTat4QXblirWc+s7nMHCaFNRYw3rnR9JABsKQNA01Pweas/gULF56AJ12tEdRrlvopVvIpAC6udsLeiUVTuLik3RVyWRW/wVMPR2OprLR48tY6VXjwbFXoiY2l08LkTICVYV1f17bAjcyJOe4+nLkLjs9EIgKOl8XC1koNeJTH5JgmGTVWLUjd9NZcYji3ZYpt7eSOL8iNw4pUss27rW0DJWjDSAB/zdKxJfOLJ8Lg5K62m X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2018 10:15:51.1601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7359915d-8cc9-4302-72c9-08d5955e0d79 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2630 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180329_031605_328811_8B6977A8 X-CRM114-Status: GOOD ( 11.56 ) 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 | 76 ++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 4ec69bbd1eb4..1870f1dd7093 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -4575,14 +4575,46 @@ 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); - rtnl_lock(); - if (netif_running(dev)) - mvneta_stop(dev); - rtnl_unlock(); + if (!netif_running(dev)) + return 0; + netif_device_detach(dev); + + mvneta_stop_dev(pp); + + 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); + } + + 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]; + + /* Set minimum bandwidth for disabled TXQs */ + mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0); + mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0); + + /* Set Tx descriptors queue starting address and size */ + mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), 0); + mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), 0); + } + clk_disable_unprepare(pp->clk_bus); clk_disable_unprepare(pp->clk); return 0; @@ -4593,7 +4625,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)) @@ -4614,13 +4646,37 @@ static int mvneta_resume(struct device *device) return err; } + if (!netif_running(dev)) + return 0; + netif_device_attach(dev); - rtnl_lock(); - if (netif_running(dev)) { - mvneta_open(dev); - mvneta_set_rx_mode(dev); + + 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); } - rtnl_unlock(); + + 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); + } + + mvneta_set_rx_mode(dev); + mvneta_start_dev(pp); return 0; }