Received: by 10.192.165.148 with SMTP id m20csp727883imm; Fri, 4 May 2018 19:34:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqOaG+3EsQphQzU/ZCyFt4Cb/LLjKMgejrJgKPW/uCIcP8/5bxL03XBcxjOSt9hMtn6DEXK X-Received: by 2002:a65:4244:: with SMTP id d4-v6mr23872614pgq.234.1525487686532; Fri, 04 May 2018 19:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525487686; cv=none; d=google.com; s=arc-20160816; b=eKKymVl9P0WzdwoNhXgOA+/YnAJ7rWtsC5NcORI8CJJxAmMvduoUcYpGGgcWdmM4X7 SL2xrzjFidlfKeZEJdeaM9rluiI2nNKRRvSY20t54XCGXpWOIiHWf0z9EsFL09kGMJ6c gZQ6o1sLZY+TZJ7fl/nAhBXe0nL0tsROao1itROSeZkLoPSpsv3VfU420cCYy0YLp91j grGkUfScbCjjaryHQ8a/Pa9pGRtZqC1au5nxLNaqQV4LgwjE2mQ1OW/jGuoy02oG14Hl Zu0hFujgGYSZx3lCg2FaFXiLi/T+D1UHPujy/uSS9TdYNqpMbzD0G/DfbjNicPZBVkDL yhfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=+Jj1E+hJqkrwmPXfC8WXdVyTLcirETIMjJXGXebv9Ts=; b=yAVhR0+b9VhXbSdnIkHzFusslRT1v5BCiyuroitI8WIV0MAgtVzxpj53oNUKCNzRlE bOIztSVtN5yN8e+Ktv23rtf4nixv/LaF/9RE3MazdrlBfelaS39mlFH8e9CqV1Ju5hN7 jrqW026spdKels4LDsQDF8Rl/CF0HdAmJWcKorHBMjAVflWlufKBmPgwiSeLLxXdpyqy jiqdvW5z/7n8cgIJ//WJ9KQ4U/9ij0pV4zyNJXuIPhcpsoL76A4CzxQweCtndq05aKn8 htPonZtU24Ag3kw17PIScpsVjFBrxlTu76zXUeEo7lWEZjDjyCqrQZOQ+qpwa72yRdsG aYhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pGDKvn7n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i14-v6si10060711pgp.558.2018.05.04.19.34.01; Fri, 04 May 2018 19:34:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pGDKvn7n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751924AbeEECdt (ORCPT + 99 others); Fri, 4 May 2018 22:33:49 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:40626 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbeEECdr (ORCPT ); Fri, 4 May 2018 22:33:47 -0400 Received: by mail-pg0-f65.google.com with SMTP id l2-v6so16586530pgc.7; Fri, 04 May 2018 19:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=+Jj1E+hJqkrwmPXfC8WXdVyTLcirETIMjJXGXebv9Ts=; b=pGDKvn7nX/ZTf2TzkhpiVmicCtDnevtdC4gTEQKCUQ1OtlIRjvjSooE8N4JBRI67Lt Up4ELtdr1hFHjQYSr8k3w8JP4DAqTSxkoPJpQ6j5WdYX1Rx9o33nrgeHUz0JXkJ5Yk1h mykvHhfbi/HRvuMfmlaPpBkF8+go+L6f/3edHvxn8FdGewmfrziYSrf5NMP/XP6KQTNU nxUSwGW01kQzK0eQUty3KWErbR5Wvg2rE/4GxsIw/TkEbISbJ7fkS7FKwwlBStxqqp96 t+hfQ5Ek/NHxW0JzanLvxxtjtHBYI5uMVjOzSCFnb+Mg6xVZhRO7S+xZ+JmA9ieZVpVY isnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=+Jj1E+hJqkrwmPXfC8WXdVyTLcirETIMjJXGXebv9Ts=; b=C/gcYy3S56ESBp3w/yl/sCT6KkbWPXchk6eQFIjp6luqFoVgrvjG5gYEpqsm0GpNy4 DLPUVHIIpYqJmljso7OBKej8kq/pduUJcZ26Cvwuy+J0dMWLftKp/CLb09f26rXKKaJh nMob+oSfKD5B2yvoB6DnGO5t9y1qmu4RJHvDzpUygU+8RLoBQSz40lvZRdIMwqCy1ItZ NIqbZjt+EXdfc1Q+N+nYDTDc8I05flKjSQlHZi4PMK9ikjHhYrV4EtfBEFqiVaNv4YtS D5mBK2d1hoWOZ1HY1Z4Wz6MzEh4WqeCC2Y2KVb496ZNtn3dt4BGiUce6tQ9H6qQNxnei 1dnw== X-Gm-Message-State: ALQs6tBwkNXhCOBl3sDiPtq7lK+8e9qSEk7kVdVLvNZwTSOCUAzr6wKP GH9tRXcjr2FeLOEapHLQtTGEq11U X-Received: by 10.98.216.199 with SMTP id e190mr28949996pfg.161.1525487626417; Fri, 04 May 2018 19:33:46 -0700 (PDT) Received: from localhost.localdomain ([106.120.101.38]) by smtp.googlemail.com with ESMTPSA id c3sm28759159pfn.62.2018.05.04.19.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 May 2018 19:33:45 -0700 (PDT) Subject: Re: [v2 PATCH 1/1] tg3: fix meaningless hw_stats reading after tg3_halt memset 0 hw_stats To: Michael Chan References: <20180502004234.230662-1-zumeng.chen@gmail.com> <5af186f8-9718-c295-4e34-e84dd78ea157@gmail.com> <8f73e98f-0c55-2d96-a1b7-0890bf90bf41@gmail.com> Cc: Netdev , open list , Siva Reddy Kallam , "prashant.sreedharan@broadcom.com" , David Miller From: Zumeng Chen Message-ID: <38cee318-ef18-18fb-80c2-780718ef12f9@gmail.com> Date: Sat, 5 May 2018 10:40:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/03/2018 01:04 PM, Michael Chan wrote: > On Wed, May 2, 2018 at 5:30 PM, Zumeng Chen wrote: >> On 2018年05月03日 01:32, Michael Chan wrote: >>> On Wed, May 2, 2018 at 3:27 AM, Zumeng Chen wrote: >>>> On 2018年05月02日 13:12, Michael Chan wrote: >>>>> On Tue, May 1, 2018 at 5:42 PM, Zumeng Chen >>>>> wrote: >>>>> >>>>>> diff --git a/drivers/net/ethernet/broadcom/tg3.h >>>>>> b/drivers/net/ethernet/broadcom/tg3.h >>>>>> index 3b5e98e..c61d83c 100644 >>>>>> --- a/drivers/net/ethernet/broadcom/tg3.h >>>>>> +++ b/drivers/net/ethernet/broadcom/tg3.h >>>>>> @@ -3102,6 +3102,7 @@ enum TG3_FLAGS { >>>>>> TG3_FLAG_ROBOSWITCH, >>>>>> TG3_FLAG_ONE_DMA_AT_ONCE, >>>>>> TG3_FLAG_RGMII_MODE, >>>>>> + TG3_FLAG_HALT, >>>>> I think you should be able to use the existing INIT_COMPLETE flag >>>> >>>> No, it will bring the uncertain factors into the existed complicate >>>> logic >>>> of INIT_COMPLETE. >>>> And I think it's very simple logic here to fix the meaningless hw_stats >>>> reading and the problem >>>> of commit f5992b72. I even suspect if you have read INIT_COMPLETE related >>>> codes carefully. >>>> >>> We should use an existing flag whenever appropriate >> >> I disagree. This is sort of blahblah... > I don't want to see another flag added that is practically the same as > !INIT_COMPLETE. The driver already has close to one hundred flags. > Adding a new flag that is similar to an existing flag will just make > the code more difficult to understand and maintain. > > If you don't want to fix it the cleaner way, Siva or I will fix it. Feel free to go, I just take a double look, INIT_COMPLETE can directly be used as follows: diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 08bbb63..0e04fd7 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -8733,14 +8733,11 @@ static void tg3_free_consistent(struct tg3 *tp) tg3_mem_rx_release(tp); tg3_mem_tx_release(tp); - /* Protect tg3_get_stats64() from reading freed tp->hw_stats. */ - tg3_full_lock(tp, 0); if (tp->hw_stats) { dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), tp->hw_stats, tp->stats_mapping); tp->hw_stats = NULL; } - tg3_full_unlock(tp); } /* @@ -14178,7 +14175,7 @@ static void tg3_get_stats64(struct net_device *dev, struct tg3 *tp = netdev_priv(dev); spin_lock_bh(&tp->lock); - if (!tp->hw_stats) { + if (!tp->hw_stats || tg3_flag(tp, INIT_COMPLETE)) { *stats = tp->net_stats_prev; spin_unlock_bh(&tp->lock); return; Cheers, Zumeng