From patchwork Wed Feb 7 12:07:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 197874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2180979dyb; Wed, 7 Feb 2024 04:11:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeaHVpHnT1RHGVxsm6DnS+mR1HqDm4pdG/yRhx5y5A/c9y2dJ2CyP7NblBdQxA9fns2HG9 X-Received: by 2002:a9d:7b47:0:b0:6dd:ed82:f46c with SMTP id f7-20020a9d7b47000000b006dded82f46cmr5807226oto.10.1707307912213; Wed, 07 Feb 2024 04:11:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707307912; cv=pass; d=google.com; s=arc-20160816; b=U9XHoZEJ/VHKX9QsRSjAOzqCZXPVrFTsOaa9sAfp6z8uGgfgLp7BFu3JpdloKgR/7W HcFGsw6D/MGtutCBVDRn5BCwvtNH90eWgRkHfO8A7NRKDG7GvuuqjuHslCmu9dxPoRPX +SQ41f14irhr6S4YKtGzrP61TFFbO1MCl1J7CUMHyTIcqXA2yzf8VrjnzQiBWoZ7u8o5 hwQUTsuVi4vVbUWIlhT3bSOtWehlwy3UNPrrYlaq/DF4qdixUURiMb5hTCsvNpB8rsM3 5wr2I1J65uDoD/4VmM7jS4KuOIm5FkT5cYDfclAGTI+JmDEBwkwOzgYoY/FO57vAT7X7 CCUA== 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=6kaiMDGRSMM1zSx7d5RwSXQOkmnjMZGD3UM1O1/WIzw=; fh=m0mty9KXRWPsieqq3L4SucP4OEp4m6tIQsvF13jXemg=; b=U3EhuXr8fkrQ46cy+CKLvx4td9Kn+MTShBhQxUyaKJQDWBmOlxj5IEFFlUiNHd2WY5 cQjPaJ3s4Cc6y0+15Vsv3dZDWxomMYNdJXPpdBlQSZIGe2HQEpVgoU3ctkusEGx2QGoA W/+46elMQSKIicGyzUMB5UAUu0tn3DWAuEx+9MxwSOjx6ZsujmR1wTM2t6lLQXwB57s9 KjH8UlsPxIjH7m0ShFoVJslQd+TdfD/U3zpx0CQjlqJFI7/d1I4uCifBseUeOqOZ9aRV H21ZcJ4Yy7Pi17fRP2uPp3bPt0M95z8W56hTALz7KfRiKoKQzB8xsMBrceYwMe4GUd0G Ankw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=DALnMaps; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56464-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56464-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCX0z0eSBH67q3ovD2OtBGygeGaHAgx40IvPOcpMj2hcK0fi3IOYGjJQNcLpteh/tiBCl78UF2NDrptaneI1F/uE9nPPhw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l5-20020a632505000000b005d8e221d9f7si1410088pgl.87.2024.02.07.04.11.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:11:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56464-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=DALnMaps; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56464-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56464-ouuuleilei=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 EC11E291551 for ; Wed, 7 Feb 2024 12:11:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 435605D731; Wed, 7 Feb 2024 12:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="DALnMaps" Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 A38E15B68C for ; Wed, 7 Feb 2024 12:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307676; cv=none; b=UAiqPNJjKwgYJ6NGutW2LJSKxR0KRbQMwEwAxuYFrVdIDHA2HNcotQxVxyzR3FmA11SHy8gdrsst5wqlHfW3TTrEtGrQ/r09B1aablsM/hc/cvkwN6uP2AazjVjRnE2o2eGS6M7tklYatxA1hqzPQwZiJZKNX91VnNHEciPLq1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307676; c=relaxed/simple; bh=HzMlCY/Qn/3NM/tReDw8aLGBXBUfCm+QYcZzIw0FINM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Cwdo8PIiNpjsx+LQt/dP/Oo+hobCNbK71Vjz+LcMLJWVKeFbc0FhNPPW0r9c/9bGbqc+f77m3gBoLw+BYJEeXANhf7Lnu+j55ftFrQBiIKv0zPtSAAfR7jGHOUstxh6gnymseNuL3hrJ4miwthqzVRELXICkWTIhqitdgpHt6yk= 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=DALnMaps; arc=none smtp.client-ip=209.85.221.41 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-f41.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so416266f8f.1 for ; Wed, 07 Feb 2024 04:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707307673; x=1707912473; 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=6kaiMDGRSMM1zSx7d5RwSXQOkmnjMZGD3UM1O1/WIzw=; b=DALnMapsKTD0udKd3+Q+4Xk+oWruDSSiDUwAYuObz7NcmpJ+kLXh9pQ1pkoYzfCdPK pJYwkSm6BSJNWHYPUNSjCg6+/DrLxR8UJDTP82UpXpTxG8KAlPnH4MpTq2Ri1tiGOIjG nSjuckaRyxx+58pszxV+/Ms6a1SE6k5JPFWVzLiZdVg7dBet7nnWef5ONIyuTW44vJso cgfjeoXNV4FBV4YvnOJEptusfIUuP5JzP8O9gYy8vTQAVFe9ByDw9t9iwj4aixdkZ4g8 OjJ80gJJ1eQ4m5kK3Qqk7hD7rC7OvXU8OWKLARQxa7GjFPZ/K2apRaVNWolOuCEoixO/ ZQ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707307673; x=1707912473; 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=6kaiMDGRSMM1zSx7d5RwSXQOkmnjMZGD3UM1O1/WIzw=; b=aLA6Q5nQaRYkh9n/sU/gQ5XfuHnVY1chSuyAz6MIzIgQsQbrh6ZThHKRxmblIdbSqL DhfQXABX81KxdmpjfKaIXYoBjS5XQCyldP1kMXjg/kwunrNirXVTQ/zvhgeLUnVFN5cq a30C8HZhI7JIfXOdAtGtovl/c6UmQhjqYAmP1xwbXlbNKWCAcd8PUR3+oQfXXzL9na+X iT1rhkzE/YFr/frhWR8z384W+82wgi3lor8l6jsE9i4rUAwFbuhFnBm96bLcecFSFL7b n3AMVVqz/MTUea3htisrA62/zBgLm8NMms1qWT/TDU5ssc//bAK2abl+enssrBuz7bLO JN2w== X-Gm-Message-State: AOJu0YzRXhL/K3ouejtA5e2j94X9Jiuf/fv7kDGB2TkyXnu1G/IG6R9H 6gQ3Rl69l7ffV/4E0KixNhsLTIedig9gEHjOsrH29P2xSWUwWwGhdWCwUkPNp+g= X-Received: by 2002:a5d:5f83:0:b0:33b:4b0f:b989 with SMTP id dr3-20020a5d5f83000000b0033b4b0fb989mr2495919wrb.0.1707307672200; Wed, 07 Feb 2024 04:07:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWtAmcMTuR90O6jEqWVyYaTB5twZsArS+hW6V0aatu+fU3AQDC4ELo2FdCW2ZsBYkVDizPBElBHV85Xoo0o/BWimP1pXMWsd+fsG5Vh4eMt2yu7Wch0uckFs7kfSdMwxykrWwdKO9KmON0w3lxYXNMe2aRsRc+6TGJvY5yWfHbOYvtvt1F3LBKSMCHiQHW2VOytpSBgVtCtMZVh8I9DgQN+FuN5rmsL9QRzCWysI0ZDfjc+RGHF22eVLDkG7KnFfu6gTRgQxiZxQl8eH+jIS/POVoMVaeMB9u5gN7l8dWx+ECxcH6INv32HkIyUYkXrnR8WiJfhEvSumn0= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.114]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0033b4db744e5sm1363957wrt.12.2024.02.07.04.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:07:51 -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 1/5] net: ravb: Get rid of the temporary variable irq Date: Wed, 7 Feb 2024 14:07:29 +0200 Message-Id: <20240207120733.1746920-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207120733.1746920-1-claudiu.beznea.uj@bp.renesas.com> References: <20240207120733.1746920-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790242100899568848 X-GMAIL-MSGID: 1790242100899568848 From: Claudiu Beznea The 4th argument of ravb_setup_irq() is used to save the IRQ number that will be further used by the driver code. Not all ravb_setup_irqs() calls need to save the IRQ number. The previous code used to pass a dummy variable as the 4th argument in case the IRQ is not needed for further usage. That is not necessary as the code from ravb_setup_irq() can detect by itself if the IRQ needs to be saved. Thus, get rid of the code that is not needed. Reported-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes since [2]: - this patch in new [2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 9521cd054274..e235342e0827 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2611,17 +2611,20 @@ static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, if (!dev_name) return -ENOMEM; - *irq = platform_get_irq_byname(pdev, irq_name); + error = platform_get_irq_byname(pdev, irq_name); flags = 0; } else { dev_name = ndev->name; - *irq = platform_get_irq(pdev, 0); + error = platform_get_irq(pdev, 0); flags = IRQF_SHARED; } - if (*irq < 0) - return *irq; + if (error < 0) + return error; - error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev); + if (irq) + *irq = error; + + error = devm_request_irq(dev, error, handler, flags, dev_name, ndev); if (error) netdev_err(ndev, "cannot request IRQ %s\n", dev_name); @@ -2633,7 +2636,7 @@ static int ravb_setup_irqs(struct ravb_private *priv) const struct ravb_hw_info *info = priv->info; struct net_device *ndev = priv->ndev; const char *irq_name, *emac_irq_name; - int error, irq; + int error; if (!info->multi_irqs) return ravb_setup_irq(priv, NULL, NULL, &ndev->irq, ravb_interrupt); @@ -2656,28 +2659,28 @@ static int ravb_setup_irqs(struct ravb_private *priv) return error; if (info->err_mgmt_irqs) { - error = ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interrupt); + error = ravb_setup_irq(priv, "err_a", "err_a", NULL, ravb_multi_interrupt); if (error) return error; - error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_interrupt); + error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", NULL, ravb_multi_interrupt); if (error) return error; } - error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrupt); + error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", NULL, ravb_be_interrupt); if (error) return error; - error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrupt); + error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", NULL, ravb_nc_interrupt); if (error) return error; - error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interrupt); + error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", NULL, ravb_be_interrupt); if (error) return error; - return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); + return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", NULL, ravb_nc_interrupt); } static int ravb_probe(struct platform_device *pdev) From patchwork Wed Feb 7 12:07:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 197878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2181620dyb; Wed, 7 Feb 2024 04:12:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYtDpzi2+CL4qZXmtlOnnLE9Rdcs9sqgFhpgqpHiReHau3GxYp88msah+2t9WHJtGyGapt X-Received: by 2002:a17:907:1112:b0:a38:1d44:dc54 with SMTP id qu18-20020a170907111200b00a381d44dc54mr3269905ejb.48.1707307977489; Wed, 07 Feb 2024 04:12:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707307977; cv=pass; d=google.com; s=arc-20160816; b=EVUSfsDd4eOtVjyRFEEOI10F93WSMcpTaMQmLf6UUIIW02nyYTMzNKRnfZjYjtkoo+ cLlg/BkikHl6G/wlvdmrNH7hz+PLWX7B9kyMFwEBWulCon6XSTEzYKKT9Dtv7BoG815c DCq2ah1bMd7uWTt2XgOYNFaNLFskGNkJ8HV+kHaHtp55Pza1IlyVv6Cd0NeEgpLRjkL5 oIBL2e3V5ZBf9IIEReF2orvhQLMStUYB7MWsN67MocHoXA4JGoEvVLlJbcrD/zj3KbZ1 9LfG3laB8NxJBr0Xcd5a2qVvgZQoI+t4QaEpsot6M7MAP/danjV3P0h7VUzqWgZvUTmB 23lg== 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=i8pXU065R8j0WF5WsKAZv+XgZqzc/5yTJ5Xq8oCQ9So=; fh=a4NUCU3XdL1UuoqADfaCQgkUXDbJDB7VX2Wugz5s9gM=; b=wext/s0Ylq1f8DePC954hgxL/zXqTUYudY8oRKwmKcL6IC70SHbFFmxurStLEzcjCt 6wJgGbQDFlLJB1y5ouKjCJVQ3uhPIwDtw8yoPTyh+61plql/otcv/q5sdnR+sNS+rEk5 cwxM5sojZLmvWnHb2hVj7pdVTx1Vglvm3z2gzvBt3LpXa4r/qH+LQVbdeZra6gfk2EiT AItQBzJgchF5Vl1kOrPNS65Tx2wZ8kDpJNZXd2DJ6l2GK0KCIc9lTY8a6Yh6rgkR8V2H feL6hIHmBwQvqxNKs4IBWo0IdVHN1knVI+QR3aBzY4pxF+wWwcZcrP0wxWeC/ZgaefL7 y5Pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=MPgOiRSk; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56465-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56465-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCV2+RMKcbKnTJoP/Gy96kZ+ZLhTjuZfRPd6Cm87JIgP3wgtYq0uqmccoMMjvr4RaibY3xuTujA80HkLZmuMEJoynTvdKw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mc18-20020a170906eb5200b00a389a9f49f1si37142ejb.660.2024.02.07.04.12.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:12:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56465-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=MPgOiRSk; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56465-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56465-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 94DC01F28991 for ; Wed, 7 Feb 2024 12:11:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69C4B5D73A; Wed, 7 Feb 2024 12:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="MPgOiRSk" Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 5E9E55BAC4 for ; Wed, 7 Feb 2024 12:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307677; cv=none; b=Hh6ZAy7MtIwTepOShPkBStBAIcidDLiPS4mj871fvz8Y03UZ8pb5qOP7RjM9wpGu8hDHhGQcJujUwM9cT8FE+dEAGXdiISKpBE8UxlP3Y5ODKNujGETwekLTa02OvUYbpgAi1NHcQJYWtm8OuxMyCvEwWOTQJLVZpx0SO29JgDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307677; c=relaxed/simple; bh=NYw9l+bXoPskg73dqQ5BlVMt8LzWUzBTvky6tqXSly0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BiFtDhI5mOoK7Z46h4CeHRG6K71g46BQMHqDmDru5KbCTr/yyrmnPOrW0tKyTzCo72Skh7r1OR5SSmt/F23hl/4fWYShRykmDh8puErKh+rvCbd8HZzZ8SScVxe3d1MTKBGyHIifE9dg39z1uqNKmgX3ZsKdD8alP6D7/1b4VBw= 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=MPgOiRSk; arc=none smtp.client-ip=209.85.221.44 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-f44.google.com with SMTP id ffacd0b85a97d-337d05b8942so486447f8f.3 for ; Wed, 07 Feb 2024 04:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707307673; x=1707912473; 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=i8pXU065R8j0WF5WsKAZv+XgZqzc/5yTJ5Xq8oCQ9So=; b=MPgOiRSkTxmMLIeoko5HPtqgXpR5EcuKIVNP4+5uTIioZRbFY06ZxbTL2FDv+XuKK/ 50HY8Gy7PIHLPAbJA277y1yOgczGQiM/bkVVu9sXkwUqHHATu/FYuXfxE3A2OlDxxDcJ +HuQemuEgfoKapU0eP7KXuIGrzUb6az75MOfkk1Fm8fVTPc/y+iUMTremd04WLE5gBO/ w3/y+wkKx1n8HNw91esOFVPGaVmMb/hLQU9Hy/W8JrQ+4995Y0+CYwwA0Dt8cFVE1uNi Sh9Ct5JPv6L+kQ2MrR0l7vxJFQsHC9bjuh4sXjv2URkviN1jQfps5u/zBoBeuShwoO95 t8bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707307673; x=1707912473; 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=i8pXU065R8j0WF5WsKAZv+XgZqzc/5yTJ5Xq8oCQ9So=; b=LEBazlPDvZTuZ4K6cFg3jfMS2L87/jZV+ISZIxc07egDAJjXnTPMv1ewVOONEXj6WH IGnxrwKTq+KFDRbEFrE/KsqXA2CSpx9ZwEhU8BaoVcNHmrK2Jht7LB+nfq1ikjPQlt+v TBdNlhpHOfrQUtrDgmWMF+wSN9bv10Ffob35VRpX2nDVv6MhI0xtGI+g8xdoJA4EeG2z tKwS5le6kAUkHQ7sjsoGlMnYV2ArW9kCrLpyUQ6MrNGQnXrTQuHHHoHzyAb3ilasagSU /hz6YMxWSxqxnFxfTc8fFuXW2i1JAbsINT5QQGI4rMnSr4l16Otd6Qb+8kn9i6QB2Xh0 xf1Q== X-Gm-Message-State: AOJu0Ywxo3iZz/iTSRSzP5VXNjh7bQzB3ABJDRHAXzaACm08GJFGbgOt YSoG1KLpfVH2O626AHqHYxY9KLEBFwLnkrp8pB5g5Bh/YtNRAvAuShbmT9zgQeg= X-Received: by 2002:adf:dd8b:0:b0:33b:305c:9de7 with SMTP id x11-20020adfdd8b000000b0033b305c9de7mr3456728wrl.50.1707307673633; Wed, 07 Feb 2024 04:07:53 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWTTQoQujoKD98K5RDcZ0QGCdCrcWsry8yyFZx96BpOOKCmgr5/QWLzRYTIE723RDA3tCxQaXoLt9BPkzheSBP7xK6rU5eUntOlOnuw+zm5cOsuL5pDJJqal4IooyFN/COmqcwuVOEwtk8a9vbqBuIIiUSa/KdURaKXvDGg8xLB7ABVyNXtADifd0qLXzrP00HdYyEwfIOFL6OX+Rw3JHzcLci1oOoDnxC1GzGO5Qc0TeuLH0aijoNFP3P5LoBdtMnBUhreNJqaafIuOUmR1acQmeD2uYNqZPLXD6y/7pfuiIKifjZtiIkuYBI+d72OYInUGNa95xb6V7U= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.114]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0033b4db744e5sm1363957wrt.12.2024.02.07.04.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:07:53 -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 2/5] net: ravb: Keep the reverse order of operations in ravb_close() Date: Wed, 7 Feb 2024 14:07:30 +0200 Message-Id: <20240207120733.1746920-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207120733.1746920-1-claudiu.beznea.uj@bp.renesas.com> References: <20240207120733.1746920-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790242169605077970 X-GMAIL-MSGID: 1790242169605077970 From: Claudiu Beznea Keep the reverse order of operations in ravb_close() when compared with ravb_open(). This is the recommended configuration sequence. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes since [2]: - none Changes in v3 of [2]: - fixed typos in patch description - collected tags 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index e235342e0827..0f38e127ad45 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2228,6 +2228,14 @@ static int ravb_close(struct net_device *ndev) ravb_write(ndev, 0, RIC2); ravb_write(ndev, 0, TIC); + /* PHY disconnect */ + if (ndev->phydev) { + phy_stop(ndev->phydev); + phy_disconnect(ndev->phydev); + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); + } + /* Stop PTP Clock driver */ if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); @@ -2246,14 +2254,6 @@ static int ravb_close(struct net_device *ndev) } } - /* PHY disconnect */ - if (ndev->phydev) { - phy_stop(ndev->phydev); - phy_disconnect(ndev->phydev); - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); - } - cancel_work_sync(&priv->work); if (info->nc_queues) From patchwork Wed Feb 7 12:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 197875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2181157dyb; Wed, 7 Feb 2024 04:12:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDRrY2pvkJ9dc2P7QKPRp1nyqD3OKnUvBkGLsSbzF349coNE0G4soHMckWNFFPw1go3Uvg X-Received: by 2002:a0c:aa9e:0:b0:68c:4ea9:5176 with SMTP id f30-20020a0caa9e000000b0068c4ea95176mr4135599qvb.49.1707307931831; Wed, 07 Feb 2024 04:12:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707307931; cv=pass; d=google.com; s=arc-20160816; b=a7ac4ckRrXrg8VM/Ei63JtSzFcepwq9mgftGAUGeuSBK5ZvM75NKyrK+qfAOyy6Wwv kKJ+I7fkDjyn3v/HlOcR/iJheC5kFz1zdR7nEk98w9zBO8MfILdUzaLMu5uXL9nOHebv bzXxtVVeGyah5mPQx/9riegu8/Mg78QFfufNkQ3XC05MkRKdpmEM6BV/CzPbxCAuZDER +2L9eQNIfmeyc8lPxberi74TLpjn+nL7+/nY91QsaNFEg1L5Ra/4q1jP5KtFGaXaoBsd f14mbhbbNMO3VO0+hQg7ncUwj5xliL1bSiHhYvvhZ6IC8al2dMT/0kytYZSicn3T/t2e JYBQ== 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=LLK6/a0FK8Ot1/f5skgmNRY6U/7ORDdebTOrPjkUupc=; fh=k6gcz5ngUdMFfwQ06vwATSx/h4FW+jl9htMvdkX5D2k=; b=pz89Cy4CPN35jTz/sgJwd35QxSwHtTsgwjFzYk9swhcf2UGJeA4yK6wTJ135704qiA 7Z+fo9TExYqHie7OX56FOyhxGUWSTkG5Mjr7QJKQdeEEFIg0ddeb4eP4uH7F8qll94Jk GsO1/Q1wmvQAo89PYjNKkHMK8oxSYWeX7qRl7LMV0ee1lycGVRiIgeMOt4Enyp8ku9hc vJopZJXseUQUaeiphRSWw7tKsQtb10cZtk7vExGawNEWMhQNciDENMIIxjDCYaEE/VoH vNIonpG/74d3hvWKJCPwV/2zayO+Avhn7ZQPg2Eg8cn9rElS8S8ydXVgZx29mJz3JQOf bQxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=PsQOPt2F; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56466-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56466-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCX6bCukrXqWlcB9K2rppy34rxKUKGXm6UDIl796tdzR8jPB38ke/tr86SjHsMX0Jmwib223NZl0KRONm0uUAiE37ZE/fw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j13-20020a056214032d00b0068caf39560dsi935849qvu.429.2024.02.07.04.12.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:12:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56466-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=PsQOPt2F; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56466-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56466-ouuuleilei=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 9E37E1C21AA4 for ; Wed, 7 Feb 2024 12:12:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4C295D479; Wed, 7 Feb 2024 12:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="PsQOPt2F" Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 C84415BACF for ; Wed, 7 Feb 2024 12:07:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307678; cv=none; b=Pb1gR7zI1fcMjA4PgquHO2MxV+jnVyp3BqakoepK8sx4HpSOKvK6ddLZ1Mp+zMIzQf5E6aNyLc0ym41CdYAs/nOC4/T/ghKJlQnLvIt/gtstUokWbZauwWIR9Ytsm0hbWm7Rs83+xVxFliR59M9Mk0yoe+YBKmq8u+Kab68PYQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307678; c=relaxed/simple; bh=Bnaw5Bul5W5Zl0rFQE8Xh95+4KfAdY3EvMYCv8nCePU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iehMwRXlt+cqT0f6VhAvOUouzKMgDtuHGVZJWcGn3HWrcW61qYe7ABkcD9cFnoUXQp1/Fnnnqrwx9ucIMWGQelRp8puAHfQ3DFYiyRoYzAANhoUy6OFj9q2HPctmRinXn5cIjYmOHSZ/MxWk1dnEvj7ZM//h1BooG/dUFzZRJSk= 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=PsQOPt2F; arc=none smtp.client-ip=209.85.128.41 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-wm1-f41.google.com with SMTP id 5b1f17b1804b1-40ef64d8955so4700985e9.3 for ; Wed, 07 Feb 2024 04:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707307675; x=1707912475; 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=LLK6/a0FK8Ot1/f5skgmNRY6U/7ORDdebTOrPjkUupc=; b=PsQOPt2FwsKCg0rQ5sY5IPRX1xYUWK4h8tDurcgejrTzOgMlF2pNZCEyXd9C87qruA 2eFGcI0xeas8N9c0ZG8h6DBKf5pT/w/omd0B+AkWZRURER0m6EUA3yzKSLBdte/Fv7h+ J9Ft14VKa9B7Wexn6tLnLxPTd3FaeM1moTNmBS5hJj4ugRL0ybThOy23w/2ptvf7M3D0 zltZ3aOERHHYmcj6etSH4NQsYJZypRHmgb+pfzgUd6n+jUNyw42UcYalZ/kkvHVZQZcT lEb/fZo74yI1fDE2+kT1c3nyCRRcCTN9wMDreaRwNLj9fJZrmfteKvA85NlqP7/KRg2e Gu+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707307675; x=1707912475; 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=LLK6/a0FK8Ot1/f5skgmNRY6U/7ORDdebTOrPjkUupc=; b=L55fJUqrNVkAcQWCq+UXwcJjeY0HxRhR7BatLbBSIPy8BMaVfGxwn2E2TXjoQ3PlFC MPLunVFPUYR/fCFnFNcJwO2XomIVvbbwQphpRythjsZD8YSbaKFIXITtf6WzuWX6a8Cv +gub9dEq8YdMEuLDeO1VU/NuxoIve2e30rkG71pq+8MU9m9XUY6jCs5fmGWdKVMTRp7m +rYJWRtwrveODH2OsxY2/Uy7jPJPmlNA+EI1h03VYzWC/V3uf/u3MpjMSOhwO74AOQbO diEXPOc6o+K91xIzYHGed5iZhzlf5Bb9n5hW8xU3fjZq0jc9a9tSKej+F0EpjNFYSN1u 6q+g== X-Gm-Message-State: AOJu0YxAz3EZCzF0l/PU3aO9YXBWq+fGnApUl5C7oelSAukhZ3+xOWP2 26JhxSlSqfwCTJ9oLe9LBcUFGLezwtiySDcEG2v5VERN8BTIbI5smrA24f5+ueA= X-Received: by 2002:a5d:42ce:0:b0:33b:159d:8222 with SMTP id t14-20020a5d42ce000000b0033b159d8222mr3115028wrr.23.1707307674942; Wed, 07 Feb 2024 04:07:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXb11E56lbQq1EfsOR7tjqVyUPeRtwU8Zow6DtY9W25t78y/rDocODfy5CjN9i/AMBHyRscCgMXwp4+8t0htzMjnLJWF01eg5RMG1zWxQv5lRKPJ0qpwVUcaSkeNqbN5ovi2T3KRBL06uRm89KRWW6lfYrd6AxMwLqjRDfJyXbYtLxb88M7VbU17d4L61YZO//ZtHR5wMSURVcvKX/qPZC2ugH63b6HI07fymnE+JtmFDXo6ZPloRCtPU78/n9rqB7mPJhNzJANy7KHL3XOKZeTBulvThSkp4NnEEosarHCxAx/sSBXQ0hILuuGkToqQz4dAN/gkJkL5uE= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.114]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0033b4db744e5sm1363957wrt.12.2024.02.07.04.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:07:54 -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 3/5] net: ravb: Return cached statistics if the interface is down Date: Wed, 7 Feb 2024 14:07:31 +0200 Message-Id: <20240207120733.1746920-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207120733.1746920-1-claudiu.beznea.uj@bp.renesas.com> References: <20240207120733.1746920-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790242122022834697 X-GMAIL-MSGID: 1790242122022834697 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 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 0f38e127ad45..4f8d5c9e9e03 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2155,8 +2155,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) { @@ -2198,6 +2205,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; } @@ -2265,6 +2274,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); } From patchwork Wed Feb 7 12:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 197876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2181298dyb; Wed, 7 Feb 2024 04:12:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX3GY5/aQb6QVhA2pJ3ayPw5SUNKy439KUtKn0ZGO7WzBkLEKvxFAnGF2VLIhMhiqZxiE5PhBBmv2HnviIx8jo84Hd/jA== X-Google-Smtp-Source: AGHT+IEQNa0ImFEg0fw8c2eUahlHCqDeZLvEzbZ7WmKzIuWgVqXppbqUwr1MbXMNRTxAX3y4tb/H X-Received: by 2002:a05:6830:22d5:b0:6e1:fa1:adfb with SMTP id q21-20020a05683022d500b006e10fa1adfbmr6336156otc.19.1707307945718; Wed, 07 Feb 2024 04:12:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707307945; cv=pass; d=google.com; s=arc-20160816; b=Gf0pvjojUmGHExpWsdPZF+UXLlHlgQOURgag+hwsrKfqESpUc6dgadF7f9INT5E5jx bK9rww1ynqSbuuHlObW5jnJIPr+0jP//Ba+T99Z56qD2Y9mgAarmodXZxb2Rbm330MT0 tt4jCinKBEa/sRUuWV/hoQ+qN8P8O5HpRqBnwdHYp6RftPnSClHriFEpHSL/EEE35Nl9 UEdJXpSgAqf4ARJovO/6avBFKbg/MVb96uDJ396envqg1deh0Hjdmv/XmReSVEHdWBPg HuDrcwKB6eaxROfh+1xgZxIDhxwf5LRtDFLtpZmq87zx3NhfqgKMZwxdc2M+FBD9rCnd dj+Q== 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=eXrz4m7f0rJ3JiKSvzdX6uwlbnfuFKCWsRP1dHUwshs=; fh=aKBBeZ6Y+GXbdn2UucBDxxl6o1syTdGyO6yhdhVLbsw=; b=VGy7wKP64MMwIfiSkX0O6EHsRnhjCcGw1HFpBFgbGTflA6lyl7D+DKOBnMbQ1xGOOc W9TuJvohZLCODLu3iVw91F14YP74CoKp78Pj79ivwMFrj18X+GLx8Up+3NXs8oPBZRS/ avl+Z7A+taUGmB4RfcbrunlfPhyRFwNkdNqGfChcTM1ZWIo5Q9Rn9J1VNvIwkBncU92M jQwXWgKXP5rTnTD8DCNxVlQrNxiLBVcofKXgDnKcUagtfXTAWoIS0eJ7+xkRPSeUnG9g wel0dljoMFQEmye/7+0MHB3oVcDiaXUWXGW6Y3kNRBZsqu/yEuVpyb82vz2P6e0MHN8R wjAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ov5mgB4g; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56467-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56467-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVyyy3kkwiHKAw/AZdIwVnng9+wQP2pmMVuuqa2sYoIikginqLCQdMj7C9o994SPSetC5Y4QZCWbz83DLvNIUClle8GkQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u17-20020a63b551000000b005d6860eb3aasi1406161pgo.689.2024.02.07.04.12.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:12:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56467-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ov5mgB4g; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56467-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56467-ouuuleilei=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 74B072914A2 for ; Wed, 7 Feb 2024 12:12:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04FA05DF31; Wed, 7 Feb 2024 12:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ov5mgB4g" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 DDE945B68A for ; Wed, 7 Feb 2024 12:07:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307679; cv=none; b=GDKqyLsNsa6oLlpvT4jjKPnMLDQ9RqqDD8HKM8g+/a6eUhJz78wZ+DDIc2WlcVoisxHfc5VOBxdAKwtzkcVIKqrCpcsd8OxXE8kEKSzNrU/guebCY0ky7FboN4fA89KKl1OFCIaEwkFZQUIlUfPx/u4PIj82/zI51R72bNO9NT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307679; c=relaxed/simple; bh=F9b6vWTtJjoroXcTR8WWfJ3XK0LPvKUUjYgH6P43a3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nf/afDxFkTEBJlu7rT0hOSn8ySoe3Jw1t2sM8PWh54hRKDWcDkk05mqUJqYcj1WLESsAfSUn06NhIUoMFQlhPaxddnT6F5hWCVuAoOjPmoDCoaLF8R8poZpPjiXIfqY4otFwAT0dDgQt1/LweJkIFZU7m1qYKPh/vBV9x4eV+yQ= 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=ov5mgB4g; arc=none smtp.client-ip=209.85.128.46 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-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40fb3b5893eso4205415e9.0 for ; Wed, 07 Feb 2024 04:07:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707307676; x=1707912476; 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=eXrz4m7f0rJ3JiKSvzdX6uwlbnfuFKCWsRP1dHUwshs=; b=ov5mgB4gwBWLiewhnc2EstSSHr3JGjJe0u66oBvYtPoOkSlgQIumAwvkBOsvRJWbyc 7LSYG8khWVtc09z6Nb9MzH/xNfhbbeOCYdYcsaDwbSH7Lpxdfs7X5GRMWiHC33hCxtxo mY9zNSsmRxCUJpjeQNzBVRTdeE20HUYPbu/LYWNcRWwG2kwC3nc2qS+rNgGy1znF/i4g t1kwvdyT2G6auEqp7JY0oaLiGEe9et19kWtoMedqKc1bMdIB6w/yWmh7Po1ZvjvVQcv3 vU1JdLRLpAGSMu0IZ3yAz5aGG9jzr1hnA8PktFJtDUvMWssIQ8S/jEllCqHTm3yU/LU/ ztMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707307676; x=1707912476; 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=eXrz4m7f0rJ3JiKSvzdX6uwlbnfuFKCWsRP1dHUwshs=; b=qN5WPXG3mGusSEiNpOGsulfRKqcFlM3ILXiCPVvPAtu6xtAqzshedU3ww6Ilzp4W0f /oijbC0zDtIkvK7eaZhC2Lz0nZrNqw5J6rqyHDDlyJjpPHZSCtM1vnJUYhpvC4B2IJeF gcPVHHkUAqcIJsV2b+1NPoBrD+MpCA1kvPXY1c2mlNWTJ1ehCMediRqUGhuWSJqm+WDg V+riRZn8fdt8NBw0EkUxSPDl/DRsEIMbKF0IsNtLVYn4TYbKIu8ww3IyryZ9UDz9a+eb 4KY/yc+ej0YOVbK+wTLczdqsy8rOfgy9vYMbHwXX/kRxk0YUAHVOYAbu++V+jJ4zGbRE k2XQ== X-Forwarded-Encrypted: i=1; AJvYcCUZPG3+RYYOHEYKXM0lsLhPvPEczCg9Pho7W1Is+tmcC5SdXES/Vt+dq//B+RWjVtcKsQj8wsMOlSm9CrU+TPAWwDBx477TNyEcRtoe X-Gm-Message-State: AOJu0Yy0Yy3J6JVcd1WI7bLCchYjAqD9x+VxQSqh4vouYx4P5IzrzJSf vwI5epF9agCCgtC/Q1FUfXA75b6zsnli+pKlaDL7TC3K1JGkhLSC54sgggfj190= X-Received: by 2002:a05:600c:a48:b0:40f:d3d8:c8d5 with SMTP id c8-20020a05600c0a4800b0040fd3d8c8d5mr4758685wmq.9.1707307676300; Wed, 07 Feb 2024 04:07:56 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXt+qPwWfutWoTuu5m18N3VTIW5s+99Y11Ssn0X6+okgZLtO6Bc/dIi+xYQSsj5hCMdDX43+1bjs8JiZUvV8BFePNa+pPx3w6EYREmI3XiKK38+EcDl3Vs8Cr2AcjCnY2cTTWvd9g3i2p0NZuCWflQYjf85e4tRdObt7NoaZD+wzF5G8kLtioazEegYeroQMZMS4btE3XZXsgJmTwwEBE7dEbioRnTG2eho41Q7S5NHvgN/KB8dHavGhSMlGCLAQ2OKDn2dNGeFbKSuviVR3dHf/mqcblmigSyCy+cXGeerMZhoj6uXJSkoElnpWnguWhReTzB/SptjRaU= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.114]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0033b4db744e5sm1363957wrt.12.2024.02.07.04.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:07:55 -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 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down Date: Wed, 7 Feb 2024 14:07:32 +0200 Message-Id: <20240207120733.1746920-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207120733.1746920-1-claudiu.beznea.uj@bp.renesas.com> References: <20240207120733.1746920-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790242136343392631 X-GMAIL-MSGID: 1790242136343392631 From: Claudiu Beznea Do not apply the RX checksum settings to hardware if the interface is down. In case runtime PM is enabled, and while the interface is down, the IP will be in reset mode (as for some platforms disabling the clocks will switch the IP to reset mode, which will lead to losing registers content) and applying settings in reset mode is not an option. Instead, cache the RX checksum settings and apply them in ravb_open() through ravb_emac_init(). This has been solved by introducing pm_runtime_active() check. The device runtime PM usage counter has been incremented to avoid disabling the device clocks while the check is in progress (if any). Commit prepares for the addition of runtime PM. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes since [2]: - use pm_runtime_get_noresume() and pm_runtime_active() and updated the commit message to describe that - fixed typos - s/CSUM/checksum in patch title and description Changes in v3 of [2]: - this was patch 20/21 in v2 - fixed typos in patch description - removed code from ravb_open() - use ndev->flags & IFF_UP checks instead of netif_running() 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 4f8d5c9e9e03..df47d3e057c5 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2385,8 +2385,14 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu) static void ravb_set_rx_csum(struct net_device *ndev, bool enable) { struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; unsigned long flags; + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_rpm_put; + spin_lock_irqsave(&priv->lock, flags); /* Disable TX and RX */ @@ -2399,6 +2405,9 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) ravb_rcv_snd_enable(ndev); spin_unlock_irqrestore(&priv->lock, flags); + +out_rpm_put: + pm_runtime_put_noidle(dev); } static int ravb_set_features_gbeth(struct net_device *ndev, From patchwork Wed Feb 7 12:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 197877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2181394dyb; Wed, 7 Feb 2024 04:12:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPlGSWvytyKbN/uo6x1urWDZOWVHw3sRQ2ZStwM5cGmWlSSqTmzr9nM06DdGErky4fFIkO X-Received: by 2002:a05:6102:3be1:b0:46d:276a:248d with SMTP id be1-20020a0561023be100b0046d276a248dmr2420510vsb.6.1707307955855; Wed, 07 Feb 2024 04:12:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707307955; cv=pass; d=google.com; s=arc-20160816; b=k0JD+9kM6ZkAi2Ag+OzATS2teeptVku0zJXgbresEZgaoXcfMTIoKuSxflY8a0r1ud tp1VGDtCCdUas/lICSqHipR4e3e4i+ouBd5x+hDOt1inmPLgvuRdMrjPFM0mOxNU5Z6L tcO8T3Kl2CRw+rIzwL/wmR/IXusXOf/mWGiZzmm40/O0XaYCleNZGMSythvHqIYQIOAD o6GOfr+tu34ObfcQBw/UISV89peWAF6Bj1z3usohnktZwNCdsqN34rsc+ZUWwB6a0FCZ HLtqH4c/MOceVJ/ZGgAqC7W5ize7x2sJR8NrzWrxuF5Zi18ubolsYRjjbpFOYe2zsBdf /kCA== 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=C9pUYyEyHMbAgMlD3we/lMOjIaBa3lJL0ER73fS7AMY=; fh=Nxjqr/0n7KhX5h7gMj+WiPbcH7dVWPiKvBwbb8NKnPk=; b=GwErkOGu+duegFGYYPqUxI0kRqkuBg//KQ3LYurFvOR+VDbqx44aAEofDtZnm3w7pZ NmNufFGMBJYdbaJggjQW6GQBzu8mZeavKMf/GhAPsq6yYMqPnfyU9eJZZ6tMPdrhmsbM /PCsSXBGWyfJHQYVGvLwsUArk+XdI4jIRCcS0JL3Yp4qug0GhBFr/24u4xrNjUPORiJh bexlUxS0pNpd8ICkQ9oiNMC1Rqatz5tLrN+Rq6aEzE0BlubzV+9Bgxm9PwU7OylEPnBV GYuFA4jpSD4skJ+zcEGvl3wyoQMjS76+hLfaNnIHdfsJo4f5CTvwk9a4xaANp+dGkPYW w+EQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=dQPdc6pF; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56468-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56468-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWo3ob3v6WVKX/0AJQJaTGea10+nUv3KC93UsSOC3NPl8BtFR34Dr8jTsxG7soAqXIXFaBbEiUQuk0ZAqFkAlRZXosU4Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ef9-20020a0562140a6900b0068caef783a3si915427qvb.491.2024.02.07.04.12.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:12:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56468-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=dQPdc6pF; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-56468-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56468-ouuuleilei=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 9431F1C220F3 for ; Wed, 7 Feb 2024 12:12:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DC196025E; Wed, 7 Feb 2024 12:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="dQPdc6pF" Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 C12BE5CDD2 for ; Wed, 7 Feb 2024 12:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307681; cv=none; b=lF6H7Vmt4c72dF2wmOke9UjR0hyQsFV+645YJgl2VtSA0ryZnxYkL6K+ZNV3+bH6IpASCMmvbxa8dy0KLr8OVZFhnAxgyC47bbd8iYcROZ2AthRRMHXmj6FjJ6p8nYfqkDQCjwCyVMUPQ0bo3175Ka+J3ufDlNOteyvrrH9pUlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707307681; c=relaxed/simple; bh=8myFEFdHxubvxUdidyiyBKUjeNFZRh73aQh+IGE32GI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NI3kDCpgIdVBxvkLNvMlfCDsFcNrlQI34Dg+6hEzIZBoOZIWLzDF6wJCQrGQotooacaRccyIUD3CaUKth8w8xBfKajrcLxi+4my/IhKmxN93oWnoe2CnyutfJ//oujnk0gA1vevWPDscSwXTybOtlDGOity8dSK7svbAp8n9YwI= 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=dQPdc6pF; arc=none smtp.client-ip=209.85.167.51 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-lf1-f51.google.com with SMTP id 2adb3069b0e04-511413e52d4so582688e87.1 for ; Wed, 07 Feb 2024 04:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707307677; x=1707912477; 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=C9pUYyEyHMbAgMlD3we/lMOjIaBa3lJL0ER73fS7AMY=; b=dQPdc6pFpR8mxpP6IFUQBHUlPt99Npd6N2zHf/xuufV6PFSkkyNFodfAJHlOfxw2uO qLkITM+80amcg7IWEB2pQ9jOb1KeGwyvVCXpXS9IWztpKVir2GW+NpCut7Sq6UOGzpcs G6IOzz+laYoH+GMIECBa52yGqn2cFr3C2PpG/3JHhRwA7a2wUvrZAcPsNCZDk5q4QbZJ 69BwEeI3f0KYMaSQSV/JXrHCdfx8AXbq1TsbHkjB6XETLoin8DSSuJFDBYpgHtG8sjb5 gsl6duvQMO9dYA8qLZAYrBBBLPo3PIuL7bdDEpAIpqec4uXUdbPMpRqt0dFYFLyDm9MB v+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707307677; x=1707912477; 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=C9pUYyEyHMbAgMlD3we/lMOjIaBa3lJL0ER73fS7AMY=; b=miWNzbI9yU9yOT4avq8wQX2mLOEuNgQ8if6oqjVa1CVFJm1U7RZm5ziRw+4Uw3vDT/ wwynYkWxeWINIeiNhEVWrjyLLfmBCrj5w4hTNqwDJYibN5E5DsJcHeJXjDOB3v5yWy1N M4XLwDblAnuPZ7PBJz21l7PYA7ZVT3EfkDflJn2zrWrD8RkVgrmhfVLjVZ0rwGTVq9N9 FsgyMZfamLM0eI7R5udAe753/Rd+1Fn1wHMRVpwM67i6naGvLXrA90oPpCy95Yd6JfBt p7f3hRwrvla/Iri59lnld5Gvn4MzT10SgbhTYWmTbcz53n9dK/wZbHbavnVCIzJFZ+CD CcJQ== X-Gm-Message-State: AOJu0Yz2+0t6OfgAB1sU4TLEFm3pD+0XK12zP+EmMiVayLqxBN3h8rIt bvAsD4VKUXFXLmZlLeNhXzjKmDA8wcbaxxO+hb96/N+1ZUYRaXQM5dJQv14m4IU= X-Received: by 2002:a05:6512:3255:b0:511:4d22:dcf9 with SMTP id c21-20020a056512325500b005114d22dcf9mr3539493lfr.23.1707307677694; Wed, 07 Feb 2024 04:07:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW2DpxgUHQ/7TWBk9ACo+3yDy3x5MTCFX4dP3IVsi4E+2wDKnwtKNe/BK4Ao10lcIJNf/skgBkhEO3614h900nokp7v4iJMpX7RMt4jzQ3+STOWF1eCkdjFxTNiK8Ji+VPRXcQIoTM9eTyf0nbRNuKveoSYZauTJmTjRWftBa56jSj+hC/xcTc0llqbpUWXCYIONWzTKuX7gtj8C6Q0sQ8PkHNmmyKrhxdVeZ3POGJVK9+CCy6pAfsltft3TVHOX9WeIzM92AKVjCpDOAgy/+pN3dkM4bUDDaSbFArvxW+VxG9KotQwCJNLgXQkqZE4zlLJ5Y5vYxYsCfQ= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.114]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b0033b4db744e5sm1363957wrt.12.2024.02.07.04.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:07:57 -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 5/5] net: ravb: Add runtime PM support Date: Wed, 7 Feb 2024 14:07:33 +0200 Message-Id: <20240207120733.1746920-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207120733.1746920-1-claudiu.beznea.uj@bp.renesas.com> References: <20240207120733.1746920-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790242147188451049 X-GMAIL-MSGID: 1790242147188451049 From: Claudiu Beznea Add runtime PM support for the ravb driver. As the driver is used by different IP variants, with different behaviors, to be able to have the runtime PM support available for all devices, the preparatory commits moved all the resources parsing and allocations in the driver's probe function and kept the settings for ravb_open(). This is due to the fact that on some IP variants-platforms tuples disabling/enabling the clocks will switch the IP to the reset operation mode where registers' content is lost and reconfiguration needs to be done. For this the rabv_open() function enables the clocks, switches the IP to configuration mode, applies all the registers settings and switches the IP to the operational mode. At the end of ravb_open() IP is ready to send/receive data. In ravb_close() necessary reverts are done (compared with ravb_open()), the IP is switched to reset mode and clocks are disabled. The ethtool APIs or IOCTLs that might execute while the interface is down are either cached (and applied in ravb_open()) or rejected (as at that time the IP is in reset mode). Keeping the IP in the reset mode also increases the power saved (according to the hardware manual). Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes since [2]: - none - didn't returned directly the ret code of pm_runtime_put_autosuspend() as, in theory, it might return 1 in case device is suspended through this calltrace: pm_runtime_put_autosuspend() -> __pm_runtime_suspend() -> rpm_suspend() -> rpm_check_suspend_allowed() Changes in v3 of [2]: - this was patch 21/21 in v2 - collected tags - fixed typos in patch description Changes in v2 of [2]: - keep RPM support for all platforms [2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 54 ++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index df47d3e057c5..a7381a90b739 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1879,16 +1879,21 @@ static int ravb_open(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + struct device *dev = &priv->pdev->dev; int error; napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + error = pm_runtime_resume_and_get(dev); + if (error < 0) + goto out_napi_off; + /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_napi_off; + goto out_rpm_put; ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); @@ -1922,6 +1927,9 @@ static int ravb_open(struct net_device *ndev) ravb_stop_dma(ndev); out_set_reset: ravb_set_opmode(ndev, CCC_OPC_RESET); +out_rpm_put: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2229,6 +2237,8 @@ static int ravb_close(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; struct ravb_tstamp_skb *ts_skb, *ts_skb2; + struct device *dev = &priv->pdev->dev; + int error; netif_tx_stop_all_queues(ndev); @@ -2278,7 +2288,14 @@ static int ravb_close(struct net_device *ndev) ravb_get_stats(ndev); /* Set reset mode. */ - return ravb_set_opmode(ndev, CCC_OPC_RESET); + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return 0; } static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) @@ -2779,6 +2796,8 @@ static int ravb_probe(struct platform_device *pdev) clk_prepare(priv->refclk); platform_set_drvdata(pdev, ndev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 100); + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); error = pm_runtime_resume_and_get(&pdev->dev); if (error < 0) @@ -2884,6 +2903,9 @@ static int ravb_probe(struct platform_device *pdev) netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + return 0; out_napi_del: @@ -2901,6 +2923,7 @@ static int ravb_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); out_rpm_disable: pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); clk_unprepare(priv->refclk); out_reset_assert: reset_control_assert(rstc); @@ -2914,6 +2937,12 @@ static void ravb_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + struct device *dev = &priv->pdev->dev; + int error; + + error = pm_runtime_resume_and_get(dev); + if (error < 0) + return; unregister_netdev(ndev); if (info->nc_queues) @@ -2925,8 +2954,9 @@ static void ravb_remove(struct platform_device *pdev) dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); - pm_runtime_put_sync(&pdev->dev); + pm_runtime_put_sync_suspend(&pdev->dev); pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(dev); clk_unprepare(priv->refclk); reset_control_assert(priv->rstc); free_netdev(ndev); @@ -3008,6 +3038,10 @@ static int ravb_suspend(struct device *dev) if (ret) return ret; + ret = pm_runtime_force_suspend(&priv->pdev->dev); + if (ret) + return ret; + reset_assert: return reset_control_assert(priv->rstc); } @@ -3030,16 +3064,28 @@ static int ravb_resume(struct device *dev) ret = ravb_wol_restore(ndev); if (ret) return ret; + } else { + ret = pm_runtime_force_resume(dev); + if (ret) + return ret; } /* Reopening the interface will restore the device to the working state. */ ret = ravb_open(ndev); if (ret < 0) - return ret; + goto out_rpm_put; ravb_set_rx_mode(ndev); netif_device_attach(ndev); + return 0; + +out_rpm_put: + if (!priv->wol_enabled) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } + return ret; }