Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp166104pxv; Wed, 21 Jul 2021 18:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz84mk4bt6V+F3uvIEW3lNvLER/imJPxj5dELxNPdctwcC046D/Sg2h7IOr5lgrgYtIUXp7 X-Received: by 2002:a05:6638:2656:: with SMTP id n22mr33039184jat.64.1626918989636; Wed, 21 Jul 2021 18:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626918989; cv=none; d=google.com; s=arc-20160816; b=Um2v7KB1NHIqRecluO5FhyXwggDgX4e5YKO+W5QMn4Z1rZRlHCpQ67RczqQcR9g6tg TsmNolj4+Ea2wBdtnOLkbVw3p1Lf61AQ3YVxPeGU2eTO5/AX2xwdMBDQSwbo8PidwWqx zF30/gJVl2B/ClLvUfkKj/DoVphLPXb71sOAc9DYp4CCJPBTVhX9lo1I5GY7iHssphke Qaqq9OMMZPQJUzb9v2xCTZnmqp4wMtY8sMuWN0RwrqhPxnXUJBU2BAN1R7thtXB/LH2C 9WGLNs0ley6qEy2eoEeHsAu5Hl5yuuniNFlU75vPsa7Dq84I4qcYr88+r58SQ5B5MkSm e6qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=9iDuV0BkfeogjvPGYqnuGT8TKykX5Z7MErvKqpc9MmA=; b=1CKTfqveEAI1j39hUU7fQX8W9tRFh2X+S48w85KHu1PiVog7j3gGILqqqcQ8+OEYdX bp6gXysXUaoN3EKDYsaWCIw1LUJfz5PYaBZEWt+nh8WZovbHcgXZYsD2sVLEDtx7XQnx +EKNoIS49RoISk3VRqzuo5tgZ/uAcPDKGuArPc+DMwcJAk37/dxmqmaUS3BM/Dp3PgwF /SVuxLeMGJZCeTjSLfKmuppG1ek7axTOx49xcz97jN/ncoshEAKyg6K0qIhRJRhBJKoi p8BF/OkD10J9CU8pnkJfZRhjBYwhtHbsGrsynrvy9oq4Njg+YJe0wD860cKnIvimA971 rlcw== 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 r19si28201579jad.79.2021.07.21.18.56.16; Wed, 21 Jul 2021 18:56:29 -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 S230045AbhGVBOu (ORCPT + 99 others); Wed, 21 Jul 2021 21:14:50 -0400 Received: from smtpbgeu1.qq.com ([52.59.177.22]:54989 "EHLO smtpbgeu1.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbhGVBOt (ORCPT ); Wed, 21 Jul 2021 21:14:49 -0400 X-QQ-mid: bizesmtp31t1626918915t01g3xrb Received: from localhost.localdomain (unknown [113.57.152.160]) by esmtp6.qq.com (ESMTP) with id ; Thu, 22 Jul 2021 09:55:14 +0800 (CST) X-QQ-SSF: 0140000000800020B000B00A0000000 X-QQ-FEAT: wgl5Lpe0bqFJIbxZFiCG+P+3qbONXpGJAjR+gShnpifsoAS6TUtryBpiUQUoA kwOpvr5orYHzO88VvE+oEcO4cxGxtqA9XkIPH97l+WzybzYZWRkNeBPJH4Jbvpj63AiQWij wNnV+EUvhQrgiOF0Xv8WjdTAoxnEhO8iA+YqUdHbOQdngazB3GLXgYteor9e/U1e9pIs7Si iAaV8olZIeUoBq9HCNzZi/arI7pGPYu5L1pCEO734I2KyDZF861xmZN0PvtORNwokkTQ9eu k/zXGyLJqzWEmdEOrFZJd2tyJMFTUGgTXmGaKABzUBjtZ3w99AqsNBznHLC7/o3zXDdGzrE tW3zbo4KlUdPuGeraKMlR92B2tucg== 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-kernel@vger.kernel.org, qiangqing.zhang@nxp.com, Hao Chen Subject: [net,v7] net: stmmac: fix 'ethtool -P' return -EBUSY Date: Thu, 22 Jul 2021 09:54:33 +0800 Message-Id: <20210722015433.8563-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