Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21182351ybl; Sun, 5 Jan 2020 22:41:14 -0800 (PST) X-Google-Smtp-Source: APXvYqy7rd1j/029mgzIYF4ICc09sPMPAO4BHbgSe/buLLp63HpIYPEujeiylgxnxCK5vluaGbjt X-Received: by 2002:a05:6830:13da:: with SMTP id e26mr41115774otq.302.1578292874149; Sun, 05 Jan 2020 22:41:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578292874; cv=none; d=google.com; s=arc-20160816; b=zjNLjM9vyDPdg5ariEGFvNovqVDUSRuqvYvY6iUH0V02mlV5+TdgeO0Yn1UWICiD6y t67xwkT7OHuCQVc1ubcDEWe9ErzPhhSQcIvinLuBzAO3qemo1c8OX/VVxY9WwKm1he/W pKQ3VVCbTZcWyrcJWk1zsNVgc7/4z2Y6NjdzVFSg2MTRwa/Gg6maxhR5sbNzpzbGtW2R lqVzrb1DoVdAyk7cEve+IsndLQzwaNLfV/iCupAbFT1qqIBNYFFljIDfVEAsM0lU5+cW e+EQbu4yWLcxh1M6rhE9OOLFPCuCLGbSHIitPt5ZqGFhTB/Um0vppS67cfM1XJ7mLe5w ecow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=msnzzv/Ps0zqYLE3POYRuB84lmkzs+r3klnWTQkPLZQ=; b=WYClhcTLxUGSjjCYwA9nqH0/e0MAtR36VaXcETtc03d5gV5dLLYapw19qYiOvT8ko8 WqgUuIeWLZcZRQTb536a5RZZZpZKqnXxl+c2bKctTOnRGl9/hvBsMOiEfOpVpWbBXGaC ScphHAIXmBEnzEthApEtJ1a7GbzV3AD+t8ynO3ds/I2ViBIhTmdHAWw+2L+Os+XNi643 ubPUKTPtVQGBdNW3mmnMe7/tsP+jcNLMu4uIAV/CN3h1pgmY++MiDsYkQsotR0BAGrPe uxmYJ38rxd+4T0F/95Ar2R1KqDYBCkKXj/8CHfBPz8+hadE5WDkvkAHPFBUYlMkdr5rF LeXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 w6si32345042oti.4.2020.01.05.22.41.04; Sun, 05 Jan 2020 22:41:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727528AbgAFGjo (ORCPT + 99 others); Mon, 6 Jan 2020 01:39:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:42620 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbgAFGjn (ORCPT ); Mon, 6 Jan 2020 01:39:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D0BECADBE; Mon, 6 Jan 2020 06:39:41 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 847C5E048A; Mon, 6 Jan 2020 07:39:41 +0100 (CET) Message-Id: <4d6d90454847364e49b104caf5736493170f2bea.1578292157.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next v2 3/3] epic100: allow nesting of ethtool_ops begin() and complete() To: "David S. Miller" , netdev@vger.kernel.org Cc: Maya Erez , Kalle Valo , linux-wireless@vger.kernel.org, wil6210@qti.qualcomm.com, Francois Romieu , linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli Date: Mon, 6 Jan 2020 07:39:41 +0100 (CET) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Unlike most networking drivers using begin() and complete() ethtool_ops callbacks to resume a device which is down and suspend it again when done, epic100 does not use standard refcounted infrastructure but sets device sleep state directly. With the introduction of netlink ethtool interface, we may have nested begin-complete blocks so that inner complete() would put the device back to sleep for the rest of the outer block. To avoid rewriting an old and not very actively developed driver, just add a nesting counter and only perform resume and suspend on the outermost level. Signed-off-by: Michal Kubecek --- v2: fix inverted condition in ethtool_begin() (thanks to Andrew Lunn) --- drivers/net/ethernet/smsc/epic100.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c index 912760e8514c..61ddee0c2a2e 100644 --- a/drivers/net/ethernet/smsc/epic100.c +++ b/drivers/net/ethernet/smsc/epic100.c @@ -280,6 +280,7 @@ struct epic_private { signed char phys[4]; /* MII device addresses. */ u16 advertising; /* NWay media advertisement */ int mii_phy_cnt; + u32 ethtool_ops_nesting; struct mii_if_info mii; unsigned int tx_full:1; /* The Tx queue is full. */ unsigned int default_port:4; /* Last dev->if_port value. */ @@ -1435,8 +1436,10 @@ static int ethtool_begin(struct net_device *dev) struct epic_private *ep = netdev_priv(dev); void __iomem *ioaddr = ep->ioaddr; + if (ep->ethtool_ops_nesting == U32_MAX) + return -EBUSY; /* power-up, if interface is down */ - if (!netif_running(dev)) { + if (!ep->ethtool_ops_nesting++ && !netif_running(dev)) { ew32(GENCTL, 0x0200); ew32(NVCTL, (er32(NVCTL) & ~0x003c) | 0x4800); } @@ -1449,7 +1452,7 @@ static void ethtool_complete(struct net_device *dev) void __iomem *ioaddr = ep->ioaddr; /* power-down, if interface is down */ - if (!netif_running(dev)) { + if (!--ep->ethtool_ops_nesting && !netif_running(dev)) { ew32(GENCTL, 0x0008); ew32(NVCTL, (er32(NVCTL) & ~0x483c) | 0x0000); } -- 2.24.1