Message ID | 20230322071959.9101-2-wsa+renesas@sang-engineering.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2203856wrt; Wed, 22 Mar 2023 00:22:39 -0700 (PDT) X-Google-Smtp-Source: AK7set+6MQFQrljMy4TRHEOPsqmrYdlgdfkWxupSzAdR68Lz0fJ7reEWhAaK0FbLkCW8q407kKgT X-Received: by 2002:a17:906:b4d:b0:933:44ef:850d with SMTP id v13-20020a1709060b4d00b0093344ef850dmr1135844ejg.20.1679469759049; Wed, 22 Mar 2023 00:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679469759; cv=none; d=google.com; s=arc-20160816; b=SXYnCU2hLiQIH9sAuVs0vhD7MTNlJigS0M2PXueYkwVjtwfT6v8bo5Iy3oAui60/qq BDfoCjUsZxgCAuZG3r56qCIC48uvQn72/Y+UHv565pC1GA4qD3C5ohhpX8QosZPA9gBW 2BvU0imGnnbKsQKvMmPJGCJaipQmQywhQySJ4ZWEth0DFWCOVOCCq1xqxhLdqSJcV/SH bZ/vRlxAwon8SrEkx43LX2v3p+JJ1Or2cYYteW3a+wHVqLY7in+AzKJh7URb4QN33lV/ TOqp49L0tD7Qizlvm9ajvs6LdiL+ZxyU9UVGLgqzrPh5JB6Jwg2kqXOjeTn82BnjF/Aa G9UQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PIeVc1w0MuB4BmqqwHnTqwdrhJkztd69CuBlrirNQV8=; b=qUVuwDcor7YiBH5PxrcA27DM6SiR5D2LuZbcttjEfQGifazdHe6J7MkR2X9fKkaK/d UuWTMPuXR0QzW5dqVJ3hAdakSnHtvM1AHAVd5kX2+BCm4hW/hARKniLH1nZlv/LPGI8y BHJIEe9hZ3iAO10WIwlG8L3jB9UO7dKlUPuXfBxkqVCw79yDUMXy39AM+dHo2yF3kPKY 7dVhoNAXg6YmHSGJhdUmRT2s4/7AcVM5QHxZLOjKTfWhsteNZAscgOmEij44twUWNE1m gE00hNw/Vi2e2kTYwHbxsgpZpN5W4vRr9GfCCzKrj7jx30dI71ho4svyYGQlLJlL59bW O6XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=YWcPqWle; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a1709066b8800b00931b7294f0asi13489478ejr.410.2023.03.22.00.22.15; Wed, 22 Mar 2023 00:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=YWcPqWle; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbjCVHUS (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Wed, 22 Mar 2023 03:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjCVHUJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 22 Mar 2023 03:20:09 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C291A28E9E for <linux-kernel@vger.kernel.org>; Wed, 22 Mar 2023 00:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=f+cPQbgdhiXqSw UfD4emFcVbGADPFhBGTPDrLzdP0Mw=; b=YWcPqWledFXd0xvNYDMQseW7qNGgN4 B7b71mLodxT66Y2tsSNCl/HbEQOwVno9FKKd+hr4yQvg6wdEiUD/nP+sTAORwPMd vLjqKzhqfSOaLOEC3LE2zapLsmKT5oRKMJkqXMd4XZLxRnPukHl7j79MQcuT7v0U AZC5GdUnJdf08= Received: (qmail 1526190 invoked from network); 22 Mar 2023 08:20:01 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 22 Mar 2023 08:20:01 +0100 X-UD-Smtp-Session: l3s3148p1@j93//Hf3Gpsujnv6 From: Wolfram Sang <wsa+renesas@sang-engineering.com> To: netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Wolfram Sang <wsa+renesas@sang-engineering.com>, Simon Horman <simon.horman@corigine.com>, Florian Fainelli <f.fainelli@gmail.com>, Steve Glendinning <steve.glendinning@shawell.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Geert Uytterhoeven <geert+renesas@glider.be> Subject: [PATCH net v3 1/2] smsc911x: only update stats when interface is up Date: Wed, 22 Mar 2023 08:19:58 +0100 Message-Id: <20230322071959.9101-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230322071959.9101-1-wsa+renesas@sang-engineering.com> References: <20230322071959.9101-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761051682215380793?= X-GMAIL-MSGID: =?utf-8?q?1761051682215380793?= |
Series |
smsc911x: fix issues when interface is not up yet
|
|
Commit Message
Wolfram Sang
March 22, 2023, 7:19 a.m. UTC
Otherwise the clocks are not enabled and reading registers will BUG. Fixes: 1e30b8d755b8 ("net: smsc911x: Make Runtime PM handling more fine-grained") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes since v2: * added tags drivers/net/ethernet/smsc/smsc911x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Comments
On Wed, 22 Mar 2023 08:19:58 +0100 Wolfram Sang wrote: > - smsc911x_tx_update_txcounters(dev); > - dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP); > + > + if (netif_running(dev)) { > + smsc911x_tx_update_txcounters(dev); > + dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP); > + } Same problem as on the renesas patch, netif_running() can return true before ndo->open() is called. And stats can be read with just the RCU lock (via procfs). Maybe we should add a false-negative version of netif_running() ? __LINK_STATE_START*ED* ?
Hi Jakub, > Maybe we should add a false-negative version of netif_running() ? > __LINK_STATE_START*ED* ? Sounds very reasonable, yet I am missing subsystem details to really judge it. I just hacked a quick coccinelle script and 14 more drivers could be happy about such a change: drivers/net/ethernet/3com/3c515.c | 2 +- drivers/net/ethernet/8390/axnet_cs.c | 2 +- drivers/net/ethernet/8390/lib8390.c | 2 +- drivers/net/ethernet/dec/tulip/de2104x.c | 2 +- drivers/net/ethernet/dec/tulip/tulip_core.c | 2 +- drivers/net/ethernet/dec/tulip/winbond-840.c | 2 +- drivers/net/ethernet/fealnx.c | 2 +- drivers/net/ethernet/natsemi/natsemi.c | 2 +- drivers/net/ethernet/realtek/8139cp.c | 2 +- drivers/net/ethernet/silan/sc92031.c | 2 +- drivers/net/ethernet/smsc/epic100.c | 2 +- drivers/net/ethernet/sun/sungem.c | 2 +- drivers/net/ethernet/toshiba/tc35815.c | 2 +- drivers/net/ethernet/via/via-velocity.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) The script: @@ identifier name, args; @@ static struct net_device_stats *name(struct net_device *args) { ... - netif_running + netif_opened ... } Thanks and happy hacking, Wolfram
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index a2e511912e6a..67cb5eb9c716 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -1838,8 +1838,12 @@ smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) static struct net_device_stats *smsc911x_get_stats(struct net_device *dev) { struct smsc911x_data *pdata = netdev_priv(dev); - smsc911x_tx_update_txcounters(dev); - dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP); + + if (netif_running(dev)) { + smsc911x_tx_update_txcounters(dev); + dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP); + } + return &dev->stats; }