Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp976196rdd; Wed, 10 Jan 2024 05:17:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4V0xC0KezCAyRybKiSOK4b3r7WLmnQx2wBSLX9CXn1OwJ/KzZk0/rach/OF9mjbVW1mTr X-Received: by 2002:a05:620a:563a:b0:783:2be7:9ed5 with SMTP id vv26-20020a05620a563a00b007832be79ed5mr1005331qkn.31.1704892674342; Wed, 10 Jan 2024 05:17:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704892674; cv=none; d=google.com; s=arc-20160816; b=Phr8xo9nDAInl/p+aahBBS9OdmQmTTGZRw495AXB4Y+oW/7PpYd2xzbX3DLNtiL5XP hhpZsAF6alPYn/Ln57A5wmIWcq60+YC7pClWH3Trf+jNnUuJVIVvYdL6jDYyK8QUjW4b U6UK0ka6XpUwxNjYIITlrCG02+IgYuTJrVDtiuGbMedSmuN2WOyJ+N36R/P3+pr/LvTe gnZ0gKyrpUzsmrUCKMTKptMRp1CkK3kK2j2mTdI5sQa0v7NPZA07PSKirxzQz8WoqD/B UxnMtGaKLRubZw60ib3sdfD7hozbwrb7fkV+yi/ilV8sp/cYwDZUW5W4/2Th7U8rltEJ Bx3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=vszx2G9uELuU9hK0zj2S4/o3kowknqBc1/GUoklXrQI=; fh=3FCQ1T5GHRWDbzSgn9nM4KThQ52A3uDxYT2ynpTsRU8=; b=hcmtkapkSIsgb+CJwKIM2s2sd+eBnZTD88/tjdpJKx0gvDYi9ZUVIWUFKVC2bUuhck avLVLQR+IC40IbzstBbAkufRCsuh3RO7nxVioM7WPFnZj4t6ujF7liNW9OucYCAxQWr/ 8h2JUUTOOba+bGoQ1Q0M2sRBudj3NPbhMcXMyTzE/cmk0ble5L4sClMV0CmYVCy1o0p/ sCI+8RZZ+o6yRBKnY2EF4cOMqmDyB7xQFO1S2Ak2+LUOkWiOrGbNe5f+LVAB1jU2baHn yxu9gn7J11cmk6psDjEDtuywoTAeYxq83c6QdZs5bfIOMBitbF+Xsq3Vdn88Xc7e0b3A hnlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mhD0fveQ; spf=pass (google.com: domain of linux-kernel+bounces-22220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22220-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d12-20020a05620a158c00b007814aa8eaedsi3980230qkk.108.2024.01.10.05.17.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 05:17:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mhD0fveQ; spf=pass (google.com: domain of linux-kernel+bounces-22220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22220-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DEE5D1C22219 for ; Wed, 10 Jan 2024 13:17:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D911487BD; Wed, 10 Jan 2024 13:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mhD0fveQ" Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEE9148CC1 for ; Wed, 10 Jan 2024 13:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-336c5b5c163so2509927f8f.1 for ; Wed, 10 Jan 2024 05:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704892659; x=1705497459; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vszx2G9uELuU9hK0zj2S4/o3kowknqBc1/GUoklXrQI=; b=mhD0fveQa7CF90Ky9sh1YCxbb3rlxicaqTGfktrGiPCkLetzcuZ2kkJjWINHjNedZi /eTXv5QcR1H47zBlFYItCeuJBTWHnORKSaiCCf+AWv6wTMj0KQpvF+q2aRElBf9TPIfa nPH6QwJfdC7hb9FmhtgG7aR891OF4R7zvwgTcBFewmaOnw9Mlu6ONQ9CSBrX9IRleyj7 cFeBBIPgAIVG9WOpPxmMKHmnHQx5y1cyFybyO/hRBXsoIOw5KWJIBrnuGT5xT6m7dCG4 dLgkYZjY3Rw4FJ67pQEcHK5Xxf2+eJgAYWVh/++CuzZ3yplVokvyfRuignYc2bLvh3ss xJgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704892659; x=1705497459; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vszx2G9uELuU9hK0zj2S4/o3kowknqBc1/GUoklXrQI=; b=Q0G4O/WGAuUtnzOQED8gGuusxW6eHLrC/K0qV1sTx2ZfOBUHYJni15tK3Km9GRusv8 Q79XY9hN3uqYEtw+QNZSz3IWtJOLmjcH+7Nwua7668hMyZgVNwOaTTOSoUddsEzuzemy kcPxyZLfxIK97K2T1znJ2n/HHuSls1iLRgxSbrrHE2VrHbt92fs75rJBSdUZg5cnOS2s UiJ1y/+L9NDT1PKg5ifBfzM0OQse/7LgyYIMzmcvVac60uNlippWK/EQY8Ny9inKYN8z itwyGe8HK8KLWoU/vCzl18eY9jkgXmMaSUMBDoBlbm89Dy+4j9zLUh2+gU3K1LYJPv+7 LKVA== X-Gm-Message-State: AOJu0YwBEe6PW9Cs1JwWqcdcmSBsAT+0rkm5JF2fRcAn0aDxLpFesCiB qX8HSPlP6Ju8KQuQ/MjMEYPtlZxR84Wj1g== X-Received: by 2002:adf:b182:0:b0:336:5b1e:ee66 with SMTP id q2-20020adfb182000000b003365b1eee66mr20524wra.31.1704892658708; Wed, 10 Jan 2024 05:17:38 -0800 (PST) Received: from [192.168.50.4] ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id z15-20020adff74f000000b0033740e109adsm4920854wrp.75.2024.01.10.05.17.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Jan 2024 05:17:38 -0800 (PST) Message-ID: Date: Wed, 10 Jan 2024 15:17:36 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v3 17/19] net: ravb: Return cached statistics if the interface is down Content-Language: en-US To: Sergey Shtylyov , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, geert+renesas@glider.be, Claudiu Beznea References: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> <20240105082339.1468817-18-claudiu.beznea.uj@bp.renesas.com> From: claudiu beznea In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 08.01.2024 22:22, Sergey Shtylyov wrote: > On 1/5/24 11:23 AM, Claudiu wrote: > >> From: Claudiu Beznea >> >> Return the cached statistics in case the interface is down. There should be >> no drawback to this, as cached statistics are updated in ravb_close(). >> >> The commit prepares the code for the addition of runtime PM support. >> >> Suggested-by: Sergey Shtylyov >> Signed-off-by: Claudiu Beznea > [...] > >> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c >> index 76035afd4054..168b6208db37 100644 >> --- a/drivers/net/ethernet/renesas/ravb_main.c >> +++ b/drivers/net/ethernet/renesas/ravb_main.c >> @@ -2117,6 +2117,9 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) >> const struct ravb_hw_info *info = priv->info; >> struct net_device_stats *nstats, *stats0, *stats1; >> >> + if (!(ndev->flags & IFF_UP)) > > Well, I guess it's OK to read the counters in the reset mode... BUT > won't this race with pm_runtime_put_autosuspend() when its call gets added > to ravb_close()? I re-checked it and, yes, this is true. A sync runtime suspend would be better here. But, as of my current investigation, even with this ravb_get_stats() can still race with ravb_open()/ravb_close() as they are called though different locking scheme (ravb_open()/ravb_close() is called with rtnl locked while ravb_get_stats() can be called only with dev_base_lock rwlock locked for reading). A mutex in the driver should to help with this. Thank you, Claudiu Beznea > >> + return &ndev->stats; >> + >> nstats = &ndev->stats; >> stats0 = &priv->stats[RAVB_BE]; >> > [...] > > MBR, Sergey >