Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20860087ybl; Sun, 5 Jan 2020 13:18:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzAN0OAE/1vGO5Oa0OcdHxVgkKwelwDv+byJeBg/soo8uY44tUXqxDSE354DBUj7RO9kiG9 X-Received: by 2002:a9d:53c2:: with SMTP id i2mr105600978oth.43.1578259102844; Sun, 05 Jan 2020 13:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578259102; cv=none; d=google.com; s=arc-20160816; b=knxRlbIynbpSappwv4du5hR6WOYna7bMGtC8qUytR/c6EY19vGHTIBatepuId0vjnP BqRCglHe50G51AzasGg7qegRb2kaT/G3xpYu+Ntj20bpEdiz2Oa+iL55bqLD9huHHBVc DHBcvSJ7szrDztgvBFXETmCAzv4p299pDv3tCYf5ksTgE1uCeCWePpHe55Dsa4tyY5Jo WNCptvMAYRJlG39py+gY8civNEDUhnFEJ3RuBEEAIXjBdwRsuCRIV0RWFQU3xbfes1eI uPjDxVExAhpMqwhTix74B4Xa9MZPpZI+fngOxOGwD2pwEXsjUo7RL/NOaRbKvxuu1Yv3 PGFQ== 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=g0oTS9/d+QfSjAIzZSkepNseottcWt4PXpNx4iJXX0o=; b=XesekKfqHM37epC1OfseujpJcIeZHvknj9vPKnRC5iA8VmXgHoCJPSzjuAe75Psyxv reAFtCVVdD/g2YIyIqIv+sRJwrNT0BaAJYW1uNOeJWTMiAdaj1SLPJ+wpiBfgO+adzQc QQz1TZ4S1qvagaI7gH1MjLW8N/hsFPH2v7xygHzDag1zZsy6cVtw7fxDh+eD1cgk9ala HLiKMf22IaNtT0QG4dpyMWA82jJNSSZshpCwKLbj1hgnkssvYkKcmqiHdmoMQdMK8G2N ekUS9zpUz6u/wkXQtFRKELKaskWpJSqVSdwQ78l3gBhYlTLRK16bmLoicskcarrLjeA3 Iu6Q== 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 o4si34306295otp.200.2020.01.05.13.18.13; Sun, 05 Jan 2020 13:18:22 -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 S1727160AbgAEVRP (ORCPT + 99 others); Sun, 5 Jan 2020 16:17:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:50100 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727149AbgAEVRO (ORCPT ); Sun, 5 Jan 2020 16:17:14 -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 463D2B1AB; Sun, 5 Jan 2020 21:17:12 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id EE930E048B; Sun, 5 Jan 2020 22:17:11 +0100 (CET) Message-Id: <146ace9856b8576eea83a1a5dc6329315831c44e.1578257976.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next 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: Sun, 5 Jan 2020 22:17:11 +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 --- 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..b9915645412c 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