Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3533076pxv; Mon, 19 Jul 2021 02:33:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqeW2oHU6VxcVdc72KMtoG5HUWn001vJM2B8ZdvY0K+rYD7IaWk2g0CGxDMqsh/Juq1k9X X-Received: by 2002:a05:6e02:f93:: with SMTP id v19mr16163601ilo.170.1626687218436; Mon, 19 Jul 2021 02:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626687218; cv=none; d=google.com; s=arc-20160816; b=zM1WJqAjaCSMzDJpMLSDFbKSqU34sEGn/jGvZ7z1PP5Vd9phDoM40gHTjqzrtHKNvi oFg0f0U0mpPfasR+5JrQYAcsx8Ryfo0nmFwEK/VcBj9f55QdzXGh1sTnTNs7pZ2EFZtT zBnmNOT38l40YuhidlRp9YsADdpT+TJW/+BPj1c60xCWfUinzZ/4/Ip0EokXVqa5pJaL QI/oSJQ9TXKyCYpjjDSWf8iax9QgAaseC64VvFjxJYz6RI+k/ZErqkwopVqplnVXOIw+ 1GH87b7gD5yPAyEIh04z0d0hsoV7Sn8LL01mF/+sEwjuldcTIsrsM9rZKTB6tuYDLZsH sPSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=d2M56jMnl+E32YLwGlCeEETfIpGRpH0VsBI7bmt85vg=; b=zhmgljGvTaLOvOebrigZqJfKF7a/PFUTIJOCITF2uhbNZiTriF79L2Ry6NSC2g+59E njni9eSgx7L/6RHNN+gxzCB2K+0TdeMq9fVJVFOD1Gwgaih5+81GuBkHgDNU/46Lsv7Y 5/C/hx69a7jA+BV0qUjYGIXKDbRCEL3Jto+IOe2wbuh4btsKnoy5cw4oR5I1TEnLoCgt H5oCuiCgmD53W4jPuVOf0/fPUhQZ4P8IMe6k+3XxYvxWwg6bWsXvgj++sQdacqmnJQMx MoxMXE46sQjgLyYz0JQwzPWoT38LLAuuYQeIHBX/MSv7F2cEon65GZ0D+MnokfKmhr77 KsCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si11456335jaj.40.2021.07.19.02.33.26; Mon, 19 Jul 2021 02:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235998AbhGSIwQ (ORCPT + 99 others); Mon, 19 Jul 2021 04:52:16 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:49124 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235976AbhGSIwP (ORCPT ); Mon, 19 Jul 2021 04:52:15 -0400 Received: from localhost (unknown [192.168.167.13]) by lucky1.263xmail.com (Postfix) with ESMTP id 79C2BD5AE3; Mon, 19 Jul 2021 17:32:48 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 Received: from localhost.localdomain (unknown [113.57.152.160]) by smtp.263.net (postfix) whith ESMTP id P30158T139874211661568S1626687167926777_; Mon, 19 Jul 2021 17:32:48 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: chenhaoa@uniontech.com X-SENDER: chenhaoa@uniontech.com X-LOGIN-NAME: chenhaoa@uniontech.com X-FST-TO: peppe.cavallaro@st.com X-RCPT-COUNT: 11 X-SENDER-IP: 113.57.152.160 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Hao Chen To: peppe.cavallaro@st.com Cc: alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, mcoquelin.stm32@gmail.com, linux@armlinux.org.uk, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org, Hao Chen Subject: [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY Date: Mon, 19 Jul 2021 17:32:07 +0800 Message-Id: <20210719093207.17343-1-chenhaoa@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The permanent mac address should be available for query when the device is not up. NetworkManager, the system network daemon, uses 'ethtool -P' to obtain the permanent address after the kernel start. When the network device is not up, it will return the device busy error with 'ethtool -P'. At that time, it is unable to access the Internet through the permanent address by NetworkManager. I think that the '.begin' is not used to check if the device is up. Signed-off-by: Hao Chen --- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index d0ce608b81c3..25c44c1ecbd6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "stmmac.h" #include "dwmac_dma.h" @@ -410,13 +411,22 @@ static void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level) } -static int stmmac_check_if_running(struct net_device *dev) +static int stmmac_ethtool_begin(struct net_device *dev) { - if (!netif_running(dev)) - return -EBUSY; + struct stmmac_priv *priv = netdev_priv(dev); + + pm_runtime_get_sync(priv->device); + return 0; } +static void stmmac_ethtool_complete(struct net_device *dev) +{ + struct stmmac_priv *priv = netdev_priv(dev); + + pm_runtime_put(priv->device); +} + static int stmmac_ethtool_get_regs_len(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); @@ -1073,7 +1083,8 @@ static int stmmac_set_tunable(struct net_device *dev, static const struct ethtool_ops stmmac_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES, - .begin = stmmac_check_if_running, + .begin = stmmac_ethtool_begin, + .complete = stmmac_ethtool_complete, .get_drvinfo = stmmac_ethtool_getdrvinfo, .get_msglevel = stmmac_ethtool_getmsglevel, .set_msglevel = stmmac_ethtool_setmsglevel, -- 2.20.1