Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3041107rwl; Mon, 27 Mar 2023 08:29:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Y+aBO7O10LokBR/scflElUyAq1BvzV9PpDmHueD2gSIohba/5NU9qdCqT8yvQLv3ExqMBV X-Received: by 2002:a17:902:fb88:b0:1a1:aea7:6d4e with SMTP id lg8-20020a170902fb8800b001a1aea76d4emr10359796plb.34.1679930950966; Mon, 27 Mar 2023 08:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679930950; cv=none; d=google.com; s=arc-20160816; b=iR+5U8Al8sEk5s8drvaTYDr/pGZDykoVE7p88Yq3CLbsJYCVIkvX3nO1jXBsnS9zM+ +WOpdmBwS7mIM6WlFhPy8vLRQY+KnJhL7O4NOQ9T16FaUTBHb/3xOptmF6PbO8cp+er6 JtBO4sCYDYk2n1NQZspKUwVWbUlz0LVdYAFY7EoCqm6nPXqSL9LhKcc1Vbk2Z8lEVNTG 8AiKHvBgIEPr7k6NgpFPEHuGHxuUWom1DbMX1OyrTMOg31pAiGXJJ+NXwoD/5SfbfFBM fQgKtqS4i5QRreRAmdFCq4P5zQNb3AR6PU/PIHc5247M6i+SykdOY9LQGRdeLezh7xmq N1iQ== 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:dkim-signature; bh=kfNitNUuPnVl4Mmb1zaP5VAjOaQChIM5/8ilZjPh3Pc=; b=N2RDboD1TP5iOcggRRruA9FFyKoU5Hh1NRp6f3Qbgp+uUjR30fq2ahhb8s/Gt4Cnd7 /Cga6Xoh7SvOoDoJWpZaXzy0daH6r8xAjmvVCusVHVx+q/my9vzYas9cJTwDmvz30joE XghzsiDf1B93lE1aI4JHKY5RPaEbf6Y1iRRVFMlvAU4fiPYlZzKqCUNTEkKW5Xfmvqt5 4HsO8v57zRKU93+kJmqRb6oSSKdaBKjAkLzV5VWTv+27zUQKHQAEcdx5idNOh43zy5jW kAn6Xvqk2ZOsfUNEQB3un7iqPgxI3VNItikUXhT1qvprFfiLnA0BmLtSvg6Su8Ny1yZM t0sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=f1lNr5Oa; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a63e805000000b00502effd3bb9si27795206pgh.521.2023.03.27.08.28.58; Mon, 27 Mar 2023 08:29:10 -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=f1lNr5Oa; 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 S232502AbjC0PV2 (ORCPT + 99 others); Mon, 27 Mar 2023 11:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232141AbjC0PV1 (ORCPT ); Mon, 27 Mar 2023 11:21:27 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7979D2705 for ; Mon, 27 Mar 2023 08:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=/hEkQuC5dIyQge5O1M/0+jkjKhV RP21yuq+uBggGlXE=; b=f1lNr5OaBMalEC9f23kB9Pwe8lViA8QXaMkzBslZN/z wbQhsY511cIvbzK26c9VNIm34r03u9KBZcCMIofTWb3K8JeBervbm1sxlAhOKU8v Y8TAx0QO5IQQ3YL4pWzDGxh9b4jqbq/yCrt0FHaQOWRW3fK4V84Viw0SVuXz7Ark = Received: (qmail 3175861 invoked from network); 27 Mar 2023 17:21:22 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 27 Mar 2023 17:21:22 +0200 X-UD-Smtp-Session: l3s3148p1@p6ejS+P3ApAujnv6 From: Wolfram Sang To: netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Wolfram Sang , Sergey Shtylyov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2] Revert "sh_eth: remove open coded netif_running()" Date: Mon, 27 Mar 2023 17:21:12 +0200 Message-Id: <20230327152112.15635-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 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 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: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit ce1fdb065695f49ef6f126d35c1abbfe645d62d5. It turned out this actually introduces a race condition. netif_running() is not a suitable check for get_stats. Reported-by: Sergey Shtylyov Signed-off-by: Wolfram Sang --- Change since v1: * added 'net-next' to $subject drivers/net/ethernet/renesas/sh_eth.c | 6 +++++- drivers/net/ethernet/renesas/sh_eth.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 2d9787231099..d8ec729825be 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -2441,6 +2441,8 @@ static int sh_eth_open(struct net_device *ndev) netif_start_queue(ndev); + mdp->is_opened = 1; + return ret; out_free_irq: @@ -2563,7 +2565,7 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) if (mdp->cd->no_tx_cntrs) return &ndev->stats; - if (!netif_running(ndev)) + if (!mdp->is_opened) return &ndev->stats; sh_eth_update_stat(ndev, &ndev->stats.tx_dropped, TROCR); @@ -2612,6 +2614,8 @@ static int sh_eth_close(struct net_device *ndev) /* Free all the skbuffs in the Rx queue and the DMA buffer. */ sh_eth_ring_free(ndev); + mdp->is_opened = 0; + pm_runtime_put(&mdp->pdev->dev); return 0; diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index f56dbc8a064a..a5c07c6ff44a 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h @@ -560,6 +560,7 @@ struct sh_eth_private { unsigned no_ether_link:1; unsigned ether_link_active_low:1; + unsigned is_opened:1; unsigned wol_enabled:1; }; -- 2.30.2