Received: by 10.213.65.68 with SMTP id h4csp185019imn; Fri, 30 Mar 2018 03:38:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49woVkpZUEI8Ws7NcOgkTg10g+7n3VyG9mJRUkX70H8dF7Cqs+uE5ehrJNEE02CklqJQFCt X-Received: by 10.98.133.28 with SMTP id u28mr9452820pfd.190.1522406300210; Fri, 30 Mar 2018 03:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522406300; cv=none; d=google.com; s=arc-20160816; b=AoJKiPgQa83O/aK28JQfTKfc8r7wRpjPez21yNT4Yx2LBUE0SkLsB/N6q7IR5ykaZ6 7ah7bHercqiaXgkgjz54egViJ/dSL0g9LLjC5cFSWwGHVK+wcOCaXeqJLKd5yRGM6n6c HewwB26fbLd8BybdOheDpc3dgfDz9GWCEkXFj8OlQrJYnmbd8/PEnjfX0YYGW07BeuFE d0BImTpcdaet4M0WxX9EzGwxbBIWYuyutStD2BmSUgaamZyFlhYVcAZ6gf2wGKD4choS 6lI0clM4QN0AVuu4XXlEgmrNkYarJ2bc6rImsYbiSIoo6Sk7AM0LRxvg4kGEmVLxc4Za Mbfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=hbUAO21iP37CA27bpNftEAuN/BAWvVlY48ayXYjTOLQ=; b=aUVFYRqsccFGQeJabG7LGaD2P5aJ+GnRyZknYDYld62LWRR8eJr0BQTun+TkJwx/uA NSXpk2UO/ZVDQCn1qOupfWRNpBtJ2SFFQ0+Q57uOIlGmmkdCw2mem+hzZ9QbSJCK7KLs FpWfbksYsn+avxVkeAgjWXUSj0uYwwLGtdEWfLoaFeUnUeM/1OeyXvTHJ85SveIkr/21 Z7BkhN9bAbQmiTNrXRvsUAOb8NMfY2fU4AC6E7i7s9QGee4HiFi4Ym6Dnrmh0BL4L4ac X36kukSKBk6B54c25zwq4HESjlB71RWFLhyRiGMm5R6+Pm9VneSeP9NgdNhC9bqMctvn DSeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=ki6o32k0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si6117509pfa.103.2018.03.30.03.37.56; Fri, 30 Mar 2018 03:38:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=ki6o32k0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751268AbeC3Kge (ORCPT + 99 others); Fri, 30 Mar 2018 06:36:34 -0400 Received: from mail-sn1nam02on0074.outbound.protection.outlook.com ([104.47.36.74]:11200 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750971AbeC3Kga (ORCPT ); Fri, 30 Mar 2018 06:36:30 -0400 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=hbUAO21iP37CA27bpNftEAuN/BAWvVlY48ayXYjTOLQ=; b=ki6o32k0CWtvE7tA5DL+8ciFq5E95q7cOkb2R0tQ+k5V/MFe3uBm5yev5gc1wmdC+xU6Z1gK+gLBOhM6AFN3TfjIwrJPt2yetPiwrOvao9KRX1XID77dIlxpfbNsxhuqybWpeP3PD76Pxyu/fxDB5DFnB9PZmpLzmQ3TSQH38BU= 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; Fri, 30 Mar 2018 10:36:27 +0000 Date: Fri, 30 Mar 2018 18:36:15 +0800 From: Jisheng Zhang To: David Miller , Thomas Petazzoni Cc: , , Subject: [PATCH v2 2/2] net: mvneta: improve suspend/resume Message-ID: <20180330183615.6b34d153@xhacker.debian> In-Reply-To: <20180330183332.3e180a1a@xhacker.debian> References: <20180330183332.3e180a1a@xhacker.debian> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: OSBPR01CA0039.jpnprd01.prod.outlook.com (2603:1096:603:1e::27) To DM5PR03MB2635.namprd03.prod.outlook.com (2603:10b6:3:43::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d971722c-22d8-494a-4f1c-08d5962a1889 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:AkZ/aDevHwZjEQyxsobs4DbwQltKlaPA/0P32QJyKid9FtLOMQJUE5pei9pc+wR8/Fvcp0wtmlsZv7A52DUAAmf6iBPMUq5mVW0BcHYS9oXi5XFXy5uLH4JHVVJYjzBaM00yPJY18LnBHFGj4M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Pd5+/CGZUVQnA8Qd+UdDperqqtnw/lkAruQDmQEIfFKDRxWUwumQt+UwDzuQZLv8CrhNI9DD7+LPNyJFIMbI9v41iOa64xngkaEuc4v4W4tCLSdCkftxXwf9mclf64vzAKzJKzAzfGx3sXS0DUBAQtIC9pEp7X1IFNHllVluRksKz/rZMi48NpZ6vLZf20MLHwCtekZ;4:4mBRZg5ZhRbvi+htJLNF0BvgwDwWrLTVp7gN2BBT4d4Siya/YP57y6iNbKhpwonl8BZUPXnRCwItpU4P1f98Zypz1qjcNBBWG/P/fQ43nTgkyFvnAwmVqAEF7B95ohEiw52sTcF5sFWkGwQez0vVWMdMFm86e3cqLyBVAl2sDdS+LFW8p1zcI3VgSf+E7Qp6RmaJJLqgKBRqDMT1J22q8gJ2J88qo0YFueD+gCIa+VUrTsGKphuuVKw7Xe0cti0KdDzGv3IXnQd9vy8pf4JYCQ== 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)(3002001)(10201501046)(93006095)(93001095)(3231221)(944501327)(52105095)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011);SRVR:DM5PR03MB2635;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2635; X-Forefront-PRVS: 06274D1C43 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39380400002)(376002)(366004)(39860400002)(346002)(396003)(189003)(199004)(53936002)(15650500001)(26005)(4326008)(50226002)(86362001)(81156014)(8936002)(8676002)(25786009)(316002)(81166006)(16526019)(2906002)(230700001)(1076002)(106356001)(446003)(956004)(5890100001)(486005)(486005)(476003)(11346002)(186003)(47776003)(9686003)(55016002)(105586002)(6116002)(3846002)(66066001)(7696005)(52116002)(54906003)(59450400001)(386003)(6506007)(50466002)(33896004)(76176011)(97736004)(23726003)(305945005)(6666003)(7736002)(5660300001)(478600001)(110136005)(68736007)(72206003)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB2635;H:xhacker.debian;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A: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:vJDPwb6B5uYX2Yjy4455dXU47P8VL4E+jC0ss8Mn8?= =?us-ascii?Q?oIJ0wt8f7jhCDxuCp2TNJKN76qdDuWJiiucxdvBlZFhWxH+AxpzYv/vUUmlV?= =?us-ascii?Q?Hr+qubQPL6RZ04f9sbK5zKJIIyl13t1kxk1o6b3AnMr4HM2ikBC+Trm6aiQG?= =?us-ascii?Q?0TZMDCItTP2EQYDJd3YJo4MhcOP73EV0yunp3X2S2n09iCaI6YFG1DjapOUc?= =?us-ascii?Q?RBkIkMY6slubHtZO0j6nLvwr4th3yOiaQni7LWIf0rrQ+usWIHEFM+LvnxNl?= =?us-ascii?Q?ZcGsRcWVLuG7lB/0EpZtGEIGkLhTgVWYE+bUvhnIWH38UvFy78wKfFVtub1o?= =?us-ascii?Q?f9WAInk9NLrqjHTsJzrraIYWh9xdIZDF88n58QRc01I18IFN0I/Ccxnc0gCy?= =?us-ascii?Q?p3jHDxe1R+Mv6YBc3kCNMTMm8QUUuKuAQjrxfD6fdm4rmN5tu4dRz8NzEnTL?= =?us-ascii?Q?UFrrx+/k7Om33W5oBg27iWCtQsWWy6/Ik3dxrjE36dH/bmegp/v5g2IFTTAF?= =?us-ascii?Q?X5vIIutRXFDjPubEmOLoxwtBbCrLJKHX1SSbMCD0+NxMkaQvQr7+x+BDBxR+?= =?us-ascii?Q?1gG494/7zZa+t8X/l/4b4N8Zba5vFEAc6SYVnI/VnzUbMmKR1KGd3V4ZudTa?= =?us-ascii?Q?c6rZlx7dZJ+lK/mhbFY7kIu6y0sv8sEpz6H9H4/FnXZwennkr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6sa/h7IWm0H7vaxhbDmxrfvEgvNjjDuCIiufXfQRs X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2018 10:36:27.1925 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d971722c-22d8-494a-4f1c-08d5962a1889 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2635 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 71 ++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index f96815853108..cb7fce99ed6d 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -4586,16 +4586,43 @@ 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)) + 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); + } + + mvneta_stop_dev(pp); + + 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 +4631,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 +4653,36 @@ 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); } - 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_start_dev(pp); + mvneta_set_rx_mode(dev); return 0; } -- 2.16.3