Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1498004rdb; Sat, 10 Feb 2024 04:54:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWl5CF7zGENnDt5B/L/1wPDEuK+wzg5M681PNnwcDNbG28Ghdfdq/IHmUe4aUU84uiBvIQK401jKCrEP8Wjiz7g5G04osXniEF5dFy8ZA== X-Google-Smtp-Source: AGHT+IHbrM5VEpGJGE380DhTjeEJpIABUb0+qkDDggISLXkeNx22+MAEMw4bhxc7y8fQYaFP+Suz X-Received: by 2002:a05:6e02:16cb:b0:363:b5e3:1084 with SMTP id 11-20020a056e0216cb00b00363b5e31084mr3102919ilx.5.1707569642937; Sat, 10 Feb 2024 04:54:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707569642; cv=pass; d=google.com; s=arc-20160816; b=C9GXFiZ4c8Jj3fuLJo7jb7Uj72PeZxm/F9a2ZDb/K1F9I8SBgz93LOSpFydXoyNGGp zfVWSi7HA7VLEHO92UkbkBTKdaHdTV/Kn/xnmgrxRdUli1kc9yP7gDd2XJy0EH4JPDMR vxOUEVH27ONU62r7i1R39q1PMVbbjlbTT81VOgYdFEEiASQk7BcPH+Gll138/RbcqBWs RYC6nyeznb5QdcnvIi/y6I6fjgQXGVcCGb5jBkYmNNMPa9Y5jGUKLMKG2/eW12RmRvVE FeQfrLH2zRTg4j8aUK1k1wFVZ2JnM4bdBbbGUwziC9Q9K6KPJSFOLxPkmRb71pKfUwbM t5vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7KkuLN6apk9lso3kBDkDTwanpyfUBVaMZ5g7KLUGpOM=; fh=YvsGp4+ZkoQiFIN0EsykycNCHZzPdeNJZivPMJ2YdiY=; b=u3vi6YDmTWo8GqM1hQha4Bq4HCoD27H5J0BgiFblJK0lUoVzrNUNzEWLYP4DS4wt4s bt+8rfxdZ8Nbpw7i5OTFKdCQ9Rac7wpXPseFmVXVTWLjPyD2LY9IicjtJKgBnBr9rnKJ 6M7aYNPE+s8T8El7TELY/vXWWf9s8hxB+/dT1eeFRR8wiLjCpZjW9dm4GF0eDWFw0c/g wy4rddXdNuRXG9fNtjcaPeMxVqmou0o9wXmL8F0gAbfSG5/rfZH/GVK8mQB/qen0ls5y H9YhnwHFB/V9R/7Ngq0oRK6CzhilWufFtpASLcKTW0MqKo3FLUF3rhO6eAqLtzfDGUuY sq4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b="h/8yt6CT"; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59697-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59697-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXHXC+y3ZR50d3kKz2MUvAHZ3R5JkwEakw/DU9awwtj/ScLiU1NqUO/2RvKbdI7VKgyCYHu4uHu/CxHuZMYOg+hVZVyc2gMg9zSBkiQBQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t23-20020a639557000000b005d8b2b49e8bsi3418488pgn.662.2024.02.10.04.54.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:54:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59697-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b="h/8yt6CT"; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59697-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59697-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DE37628B711 for ; Fri, 9 Feb 2024 17:06:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0058D82882; Fri, 9 Feb 2024 17:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="h/8yt6CT" Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 4538B7EEEF for ; Fri, 9 Feb 2024 17:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498314; cv=none; b=amCZot7YwNdirVIRj79qQvKbgpsVWWRHYnmAbb3KmllxwCR2oVF2//ZLmY3zHA57xcm3578zWUNwt1s7Q38Iyyg1vVeuFhRK09LCxzDWzX4Zru72PA5GrWPlVexu0MFwBL564LZzPlZ6SdevTzgHUR/HKwI0OxZdz6H6/Kp2Ess= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498314; c=relaxed/simple; bh=0k9AgMjARUIYC1OSbrO7Ph+A4RU8GHcyx7gpzf3ruuo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=da11zmERAMHF4dTeCOJRidjXNbDg5hzk20fqckw5oGT983bnRwk+1vYi+8pWWsOGHbYQVAM26cdTZvbT6N2V/i7kvjldEOW8CzgwXAhmIqa93GsgnQr+BGezkGri5rEsZ/aPzCsLcVsc7v3KiIrJ19Cr5yCFOnka7oWk2Q+W/gM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=h/8yt6CT; arc=none smtp.client-ip=209.85.221.49 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-f49.google.com with SMTP id ffacd0b85a97d-33b670d8a74so466352f8f.1 for ; Fri, 09 Feb 2024 09:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707498310; x=1708103110; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7KkuLN6apk9lso3kBDkDTwanpyfUBVaMZ5g7KLUGpOM=; b=h/8yt6CTFuQecB37V333sxPPPQj5BEfX2FLSRW7N3LpmZxIkJBPC2nzZURRRGnwqO3 gZHYQ5awLJQ3/oMLVA262AeKPo5ZcrA5iJnGRI2D529wmXyRgPqRIZorWIDRlmWozWVk ASo7NYsETuJ5zciZbw+TqltkC0JtdpNMncs+V9VeGczQWmyrPu6To8lkCEvFBACaOre2 /YkW5Qd+1Qw+mZC4/z0OoIANAVW5L8ITfMzX7fvN4+FjlzpcAZZVBKBhd9/yGUgCMdLN qqBWu6+T465WzvhvpPyU2XXhsoy4+/OFLJHru04TQFcqpOtUdj4Z2Tj+OHMZvqt1aMBB dnJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498310; x=1708103110; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7KkuLN6apk9lso3kBDkDTwanpyfUBVaMZ5g7KLUGpOM=; b=HF6LbryZFSquY1fBOIVrfZL9A9/LX/mlHtGnIR7cKHb5SPnjfOke+zIZhqwuM8IW5c Gxj97R8Bs1FDHeqAAiLXjdjMmfXYxe6dh9U2vyzHa4dWbk0S7ojAJCRxdyDOcyZ2OgBK 37/O4GdOB7RfKWBXrbowtABz1Yinhg2G2Zkfl1rOzD8B3hcOmx5ESxMErtxLELD48MzJ vHEckQRh2Y2QqLuwWnatV07CPSrQsMGVTijQhnDkLPN86tEpMyc9qKM1zxPNJi44P90z WH9A4X/0ZMMD6byl3ynWJDXGE/Jxj70lcVEbr2jaFEq6fyoqCoPzoYGo6o5LVZWjexWH L3QQ== X-Forwarded-Encrypted: i=1; AJvYcCXddNTmB4+veyDZyAMeIX/mymFwn0N3Ky06iBKbcvYxg9fabs69HrJ20W5HQghzKxeE6gsEgYkc/Gc3w72vq+OjiSUd5lM39yI7nR61 X-Gm-Message-State: AOJu0YwIPDgJx9S4hD5jHykzm4FOfu/vZ/XehwvL+0wWtE+56Faxmwyt mwVMyU5NxMxEoMJLOvQC/JfJFH8TUzg4tSrfdFBa/RVPjWCACpTGi2AXUxt8qKs= X-Received: by 2002:a5d:58c2:0:b0:33b:46a3:74b4 with SMTP id o2-20020a5d58c2000000b0033b46a374b4mr1419938wrf.57.1707498310640; Fri, 09 Feb 2024 09:05:10 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUOAx1Il1mk4uhbcMD6WKURsESBtKR78AcuLJ573yPkN8Z6QuuLgxze4clamqcyRVfxMF+NVSDmisiuDcPSqZlgXMtsbx2BxanlHueBmaD2IEwM6ewQibEYjZydF8QbbKkAOWDD8vJfeVlKXyfG7Ma+nTushTzP/F5rCXfmXVt6GxR9/YJcaCft6Qgv0CT2jbj9CGTXMOlyeubeHUwCaDm2+1KAis1Xx7DPd4KEiF2naRE3h9Q0Wd5CiCOf4Aoh+nHwSRd81WF6G6VUrrkYLg9XhK73kDyhbprGSFtN5HCvhp1VMsFyq0+LTwnLjNusDoTQ/infYJsAJ04= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id j18-20020a056000125200b0033afe816977sm2254998wrx.66.2024.02.09.09.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:05:10 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v2 3/5] net: ravb: Return cached statistics if the interface is down Date: Fri, 9 Feb 2024 19:04:57 +0200 Message-Id: <20240209170459.4143861-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240209170459.4143861-1-claudiu.beznea.uj@bp.renesas.com> References: <20240209170459.4143861-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(). In order to avoid accessing the IP registers while the IP is runtime suspended pm_runtime_active() check was introduced. The device runtime PM usage counter has been incremented to avoid disabling the device clocks while the check is in progress (if any). The commit prepares the code for the addition of runtime PM support. Suggested-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v2: - collected tag Changes since [2]: - use pm_runtime_get_noresume() and pm_runtime_active() Changes in v3 of [2]: - this was patch 18/21 in v2 - use ndev->flags & IFF_UP instead of netif_running checks Changes in v2 of [2]: - none; this patch is new [2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c81cbd81826e..7a7f743a1fef 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2248,8 +2248,15 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; struct net_device_stats *nstats, *stats0, *stats1; + struct device *dev = &priv->pdev->dev; nstats = &ndev->stats; + + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_rpm_put; + stats0 = &priv->stats[RAVB_BE]; if (info->tx_counters) { @@ -2291,6 +2298,8 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) nstats->rx_over_errors += stats1->rx_over_errors; } +out_rpm_put: + pm_runtime_put_noidle(dev); return nstats; } @@ -2358,6 +2367,9 @@ static int ravb_close(struct net_device *ndev) if (info->nc_queues) ravb_ring_free(ndev, RAVB_NC); + /* Update statistics. */ + ravb_get_stats(ndev); + /* Set reset mode. */ return ravb_set_opmode(ndev, CCC_OPC_RESET); } -- 2.39.2