From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3608CC4338F for ; Sat, 31 Jul 2021 03:04:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E93DC60F48 for ; Sat, 31 Jul 2021 03:04:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231511AbhGaDEx (ORCPT ); Fri, 30 Jul 2021 23:04:53 -0400 Received: from smtpbg704.qq.com ([203.205.195.105]:37614 "EHLO smtpproxy21.qq.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231285AbhGaDEw (ORCPT ); Fri, 30 Jul 2021 23:04:52 -0400 X-QQ-mid: bizesmtp34t1627700679tx3105p6 Received: from localhost.localdomain (unknown [117.152.154.62]) by esmtp6.qq.com (ESMTP) with id ; Sat, 31 Jul 2021 11:04:37 +0800 (CST) X-QQ-SSF: 0140000000200050B000B00A0000000 X-QQ-FEAT: mrYqqQu6MtHX06+OAGTAWFBFQ7MmCD7WcfnU/eu4WLDlXI1MVsqi06CaJt8SB zUBGGK3yL/+5Wb9gyf4ITJ67gVybg809QdB6/hNs6b9iXbhmwKSSCFAAc9TGAymqhNIyezR NCAACa/c4ntdVChdwzQn48QudwrB0mp+ZvRR9hOVh5D4097e7ZirZNfkNbBdfzVV4m3hIcb FufSraCMkUkP83kqrqEDjZBofkJNwzWoLt0B+/l+fZUKJWH7ot10DxKqRP77VgCFJoTpfZy 006ZP5hWIWhvGO6v48zXSIxZNDTx1U5fCpnyRvqhoBO4Hx9LGdFHNzWToKor6W2MqEyyLFJ /LPPENJ1K7sevqcm1unEy3nzTFMdQ== X-QQ-GoodBg: 2 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-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hao Chen Subject: [net,v7] net: stmmac: fix 'ethtool -P' return -EBUSY Date: Sat, 31 Jul 2021 11:04:36 +0800 Message-Id: <20210731030436.24666-1-chenhaoa@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I want to get permanent MAC address when the card is down. And I think it is more convenient to get statistics in the down state by 'ethtool -S'. But current all of the ethool command return -EBUSY. I don't think we should detect that the network card is up in '. Begin', which will cause that all the ethtool commands can't be used when the network card is down. If some ethtool commands can only be used in the up state, check it in the corresponding ethool OPS function is better. This is too rude and unreasonable. I have checked the '.begin' implementation of other drivers, most of which support the submission of NIC driver for the first time. They are too old to know why '.begin' is implemented. I suspect that they have not noticed the usage of '.begin'. Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.") Compile-tested on arm64. Tested on an arm64 system with an on-board STMMAC chip. Changes v6 ... v7: - fix arg type error of 'dev' to 'priv->device'. Changes v5 ... v6: - The 4.19.90 kernel not support pm_runtime, so implemente '.begin' and '.complete' again. Add return value check of pm_runtime function. Changes v4 ... v5: - test the '.begin' will return -13 error on my machine based on 4.19.90 kernel. The platform driver does not supported pm_runtime. So remove the implementation of '.begin' and '.complete'. Changes v3 ... v4: - implement '.complete' ethtool OPS. Changes v2 ... v3: - add linux/pm_runtime.h head file. Changes v1 ... v2: - fix spell error of dev. Signed-off-by: Hao Chen --- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index d0ce608b81c3..fd5b68f6bf53 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -12,8 +12,9 @@ #include #include #include -#include #include +#include +#include #include #include "stmmac.h" @@ -410,11 +411,18 @@ 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; - return 0; + struct stmmac_priv *priv = netdev_priv(dev); + + return pm_runtime_resume_and_get(priv->device); +} + +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) @@ -1073,7 +1081,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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F7C0C4338F for ; Sat, 31 Jul 2021 03:07:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47FC160EB7 for ; Sat, 31 Jul 2021 03:07:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 47FC160EB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=uniontech.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0yXTYbAFUMNxWSLb7SgLVRptYy4NT6TWT3QWSnXe9gA=; b=2CABG+5INA1RF/ LeB+pzICiAjgt03183lCBjO+ET/WCLcgg/lRGXiFZ+RsnJZx7sFonknTw6iS2BoTO8hKBndkthNdB Rrva4n1DucB3ybRPhitUx9CON5C+VDkZFxlWF26g8eIAAwIbk4bKIp1PIgPi8QJbbNjs5NIrRYb8k uvIaL2lzMy2b8PyfhNTtJUjLukmF1mV2d9m3mR/9/tr74P4UBGHZOHmCTSmK12FBUhVUFynVKbIxl 9pyP7BZ5LfPz73Nw0wlFKrS9PPmLU/r2DCjg5bE9lhj2vvYR+CRLvs+dgbg0dmeBg5RAoPmjR8ZWX y1NKYcPiIvDcr2QSuf2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9fK0-00AqSv-9V; Sat, 31 Jul 2021 03:05:56 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9fJx-00AqSn-UJ for linux-arm-kernel@bombadil.infradead.org; Sat, 31 Jul 2021 03:05:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=RKUx0DZDHl+QT82AKdB1bKLQQIc7JYc9HA0PFdH3osQ=; b=AiAN68uPxu9tSSfDh+/NDxmyFi RDhlaqQ5quNJmto3cRlq0oIDKio2TqgM4dpaWUdApoUA9rMVhaatqmq7duhXGAAzDxd2kuwpgl9me kGIQUS64mMvPWDxj+HuuL290+gg70jRsOsi3cKfI6E4OOByv4pswbnoyoCu8wiXj5LCyAgEMCOIid MLS553UKPoUhN/xgt+CHOlFTrmuYWzyy1P80WEbDSVMzMJc3XacvZ/BA5NL4GTM1D9v08anDk2VbU IrBhjev2FFWdbKPEDtiS4pJt8sy9hU1Ia6iXkCSMJnKB4OKQ0sZfciPOmdMmLaR+HDp9GMrxQy5Ig w3TFTKkw==; Received: from smtpbg702.qq.com ([203.205.195.102] helo=smtpproxy21.qq.com) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9fJU-001MQp-47 for linux-arm-kernel@lists.infradead.org; Sat, 31 Jul 2021 03:05:37 +0000 X-QQ-mid: bizesmtp34t1627700679tx3105p6 Received: from localhost.localdomain (unknown [117.152.154.62]) by esmtp6.qq.com (ESMTP) with id ; Sat, 31 Jul 2021 11:04:37 +0800 (CST) X-QQ-SSF: 0140000000200050B000B00A0000000 X-QQ-FEAT: mrYqqQu6MtHX06+OAGTAWFBFQ7MmCD7WcfnU/eu4WLDlXI1MVsqi06CaJt8SB zUBGGK3yL/+5Wb9gyf4ITJ67gVybg809QdB6/hNs6b9iXbhmwKSSCFAAc9TGAymqhNIyezR NCAACa/c4ntdVChdwzQn48QudwrB0mp+ZvRR9hOVh5D4097e7ZirZNfkNbBdfzVV4m3hIcb FufSraCMkUkP83kqrqEDjZBofkJNwzWoLt0B+/l+fZUKJWH7ot10DxKqRP77VgCFJoTpfZy 006ZP5hWIWhvGO6v48zXSIxZNDTx1U5fCpnyRvqhoBO4Hx9LGdFHNzWToKor6W2MqEyyLFJ /LPPENJ1K7sevqcm1unEy3nzTFMdQ== X-QQ-GoodBg: 2 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-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hao Chen Subject: [net,v7] net: stmmac: fix 'ethtool -P' return -EBUSY Date: Sat, 31 Jul 2021 11:04:36 +0800 Message-Id: <20210731030436.24666-1-chenhaoa@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210731_040534_127647_690DE92D X-CRM114-Status: GOOD ( 16.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org I want to get permanent MAC address when the card is down. And I think it is more convenient to get statistics in the down state by 'ethtool -S'. But current all of the ethool command return -EBUSY. I don't think we should detect that the network card is up in '. Begin', which will cause that all the ethtool commands can't be used when the network card is down. If some ethtool commands can only be used in the up state, check it in the corresponding ethool OPS function is better. This is too rude and unreasonable. I have checked the '.begin' implementation of other drivers, most of which support the submission of NIC driver for the first time. They are too old to know why '.begin' is implemented. I suspect that they have not noticed the usage of '.begin'. Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.") Compile-tested on arm64. Tested on an arm64 system with an on-board STMMAC chip. Changes v6 ... v7: - fix arg type error of 'dev' to 'priv->device'. Changes v5 ... v6: - The 4.19.90 kernel not support pm_runtime, so implemente '.begin' and '.complete' again. Add return value check of pm_runtime function. Changes v4 ... v5: - test the '.begin' will return -13 error on my machine based on 4.19.90 kernel. The platform driver does not supported pm_runtime. So remove the implementation of '.begin' and '.complete'. Changes v3 ... v4: - implement '.complete' ethtool OPS. Changes v2 ... v3: - add linux/pm_runtime.h head file. Changes v1 ... v2: - fix spell error of dev. Signed-off-by: Hao Chen --- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index d0ce608b81c3..fd5b68f6bf53 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -12,8 +12,9 @@ #include #include #include -#include #include +#include +#include #include #include "stmmac.h" @@ -410,11 +411,18 @@ 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; - return 0; + struct stmmac_priv *priv = netdev_priv(dev); + + return pm_runtime_resume_and_get(priv->device); +} + +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) @@ -1073,7 +1081,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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel