From patchwork Fri Feb 9 17:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 199255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1439538dyd; Sat, 10 Feb 2024 04:30:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUaFDrG8x/fV9eSN5vMV+ox38P/jfce7iPPs7sBav9QaCd9zryzOvOiZ9F7i6QQMwQS//WwzRW3/ZeFKSx4h6RhfANCLg== X-Google-Smtp-Source: AGHT+IEl+5231PY6biUzDXiZCjG3CWLQ8aDhKjgmo1EBqJv4VMuLf5mq/DkkhpYbHbSxLzCjU39l X-Received: by 2002:a05:6902:2612:b0:dc7:2e:7646 with SMTP id dw18-20020a056902261200b00dc7002e7646mr1718509ybb.25.1707568210276; Sat, 10 Feb 2024 04:30:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707568210; cv=pass; d=google.com; s=arc-20160816; b=aeoP19LlztjlFKuxdWE4hHVb3/s7fvwuctq6hTqWcyJj9KVvDrkmCJM6Di0IbXvCjb ISWxp4fRrF8sVjmXpWmd2KAEP92sE6mSDdGvU39M06xVFZOPxS2tv4g1w16VtJVP35h/ Qk6CK3MyQH6p2Ya3kVSeWzOhcMJwgPUOtg4urUUCol9XuzkI0MGvfbCpI9hm7K9mtZtw kssRJ4vbSViL0mm/LhBE33Lpqo9Z8e9INj6GtbQdoCTQVuB9x/0JODtJl+1cqdSq4fDo +q3oBi5R2b0NHKG3iL0GiKkYMdWiTkD9EvpXcFT4Tu5bGQIFQ3yJ3XCoFAaxxErNj5/N qtIg== 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=bMmTy0VJjCKazgGQSctD6Q6nmkdCJjbXHjwyCoGK8ZU=; fh=v9HQ1eZnOqnzeR2jEXRvOqGKSReL7RByDbkzyyzlH1E=; b=FZet8HBXk0MMdB/96lv/liya+zPllK4SY3Gp2o2XpPSIfpDdWbUz9qtTLVUpesMe/7 96swOdRAJ4QnB12gMhXKTcGLyCwOGlX2z1MKTVZ82XhA7FTi85oViWP2qnYmodPrQ2QX DBglUIEdR2E0bXF6Dd9sH6gRMaaHrYA4IyBitVdhhmMmbXcMJT7X+JqoWDVBFm8yMQ1X FGJHRg2LFbUXQN0C+uIz3ts50BjQpOlem1EqN4sPpTuNHaaqxRwT/Hghkcy7mgSaH82+ 08mDeajqIeZzoD+3ejcpNPsbInm8EXL2vd/djmfEBOeduOyjB2Ihsk9FwN6X8qeVqcJq ynOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=IveuWMye; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59694-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59694-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWrP58J8m+yTg3Jb3eioz+Za52H8gXBiyw/W6p2g5f01A41MH8u7eupToN0WJ/fpl7TjNnTR7KxeXPrgAFg8BFTTYZgTg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jx5-20020a0562142b0500b0068cc08516besi4137984qvb.567.2024.02.10.04.30.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:30:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59694-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=IveuWMye; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59694-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59694-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 D82401C232BB for ; Fri, 9 Feb 2024 17:06:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8062583CB8; 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="IveuWMye" Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 CDA227BB0F for ; Fri, 9 Feb 2024 17:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498311; cv=none; b=QcLI5nOD+bj22XDIfIjPZdKXBY1EklwD+Wz8ClN+CtTpmVXMUgnaU2MqgZMjaW6q/7HZ1wAfIcpdz6Qa+xS3Ic4ANR+6a2u8sID1ytO/TGvkAp+GowLZ+OrEoiFSSw9hVZrAzjcKFfGME48zDGxzjXGaLAGKi5flzj49FCE2Oko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498311; c=relaxed/simple; bh=uPRNapVGw8gXTZ9OJ20weiuo8n1QMpLfQmGGR/SfpJY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WeDQzhs2vSpxaaeW19DPBG54MRqqKcHqtO4sqroHYOBCYIaq12nc9VjOJZnuxobLHJM8nh256e4+PtPjg02aOe3VqDlzlWaGAkmA8geJSL6FtxVI6rS43GSeC2pQPmTypuqHkjrb5uZ2JMhn/6GS91PcdxHYwH30dBTG0UUSaEw= 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=IveuWMye; arc=none smtp.client-ip=209.85.221.54 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-f54.google.com with SMTP id ffacd0b85a97d-33b65b2e43eso527853f8f.1 for ; Fri, 09 Feb 2024 09:05:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707498308; x=1708103108; 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=bMmTy0VJjCKazgGQSctD6Q6nmkdCJjbXHjwyCoGK8ZU=; b=IveuWMye9Cd9q8ph/SP4YD04s8QI7MP+PbhGzJy7fi59ft97RWRRbZFiEfBSeYE64/ MJQe1wWn4v8rlT8UCL1F9LK6y6CTvb8F9wv4iHOSnJDLRSnwQpp+sS4+nmnV6bcUNt65 BcCmQEGzqt1hM8lTLuycP/D2rZNMPmOEN70E9SElkszcBaccv/3EFn4dXMscbtdwQz9i EUO09uczCb5HlwGlN490Z6k3Zup+fjHA1A7LfqLLCBLl/RwiJXZN6Rejz5X7RM2k/ywR Jhe+IKRXuSB2yi/8+Y2wuDOf0DwX3GNdcLcY9psTaPHVm1wtmMSafqghAiHDpm38saDe o1jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498308; x=1708103108; 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=bMmTy0VJjCKazgGQSctD6Q6nmkdCJjbXHjwyCoGK8ZU=; b=WNV9YJLeyWwMmlksGMgtKc8MauOeFOYWPqrgaEG/pUNwAjA9O0QKDGWzogz7CE0z4h Ho+JiveMlOb3Paip6KXWTlRq9r+w6XBlGUzjbr/GXSRo8nuoAelznmH39Oy2VIcp25PF noKrg5iMPI8fBR+l5P/IsZ8RTfZA32AOov/qGuwmLmj4Ax5RhRTJeFM7jnF2ZvoVSjd1 obRnrxAkbV8LekyAPoS5v8Ew5Zlnl5tB0WyyJrixTEttVkSvha4lSAgK3x21Qw9yu0RP yA+g9grvm8JsAEIjGzzbHj+I+LOfMcU5rVRETgwpObaOQ6jrmxBd50XqqP5nNFMPYKDp EOIA== X-Forwarded-Encrypted: i=1; AJvYcCWIadIo8CNyy5IoH+qemZtKw6M0sOY5sSn4c8IjgJ1yKxL8R7rYb3dEVk13U3qmWxiFmztcU8aB2hjaVR4Owteq9w3B7QvC4Jm71Kiu X-Gm-Message-State: AOJu0YzT4ZLhnqv6PPaxgx/5nNq6UXkKaIA0dwe7I74Z9nSKr+6DXqf+ aH1MhJ2aacK6zO3nzwzRIA6nrEZdDqs45N5UaBygMTEc/51QNEgHSZtnl0K7Y2w= X-Received: by 2002:a5d:5192:0:b0:33a:fe3b:b2ae with SMTP id k18-20020a5d5192000000b0033afe3bb2aemr1626156wrv.66.1707498307928; Fri, 09 Feb 2024 09:05:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVrLVQK/yh1IgtY5zXY/uBTVgbbVheQV+mlW1rD/wFw/A5oow2qDFCsFiFu9EZPhOIoPkmvtTQBE1s4Xl/QTeXHLFgkdfzSRe2qmagqQLxDCH9aghystw7iRORqPnmf5CXD+2qJ3uG3k1quoSjoEqjiNNqJyu53UF3nbhupyw4ayNagnLcnBKcOTE3ceKXo7U4SDWsUg4gX0bjUsQ5UKpwJHUyAh23F63h34yF4zVhSdunsd2CHThAXaaaGz8SZXrjNtYakqjl3yKa+fshWN1F5gNProC6DyS2t/HBmYyZYlfMxDpehA+wyI6658HOQjCtRQZceK+Ap00Y= 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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:05:07 -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 1/5] net: ravb: Get rid of the temporary variable irq Date: Fri, 9 Feb 2024 19:04:55 +0200 Message-Id: <20240209170459.4143861-2-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790453084001562264 X-GMAIL-MSGID: 1790515043308950921 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 in v2: - use a temporary variable in ravb_setup_irq() 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 | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f9a1e9038dbf..a1bf54de0e4c 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2747,24 +2747,27 @@ static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, struct device *dev = &pdev->dev; const char *dev_name; unsigned long flags; - int error; + int error, irq_num; if (irq_name) { dev_name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); if (!dev_name) return -ENOMEM; - *irq = platform_get_irq_byname(pdev, irq_name); + irq_num = platform_get_irq_byname(pdev, irq_name); flags = 0; } else { dev_name = ndev->name; - *irq = platform_get_irq(pdev, 0); + irq_num = platform_get_irq(pdev, 0); flags = IRQF_SHARED; } - if (*irq < 0) - return *irq; + if (irq_num < 0) + return irq_num; + + if (irq) + *irq = irq_num; - error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev); + error = devm_request_irq(dev, irq_num, handler, flags, dev_name, ndev); if (error) netdev_err(ndev, "cannot request IRQ %s\n", dev_name); @@ -2776,7 +2779,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); @@ -2799,28 +2802,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 Fri Feb 9 17:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 199263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1455145dyd; Sat, 10 Feb 2024 05:06:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQWDeaqGXIkPVsDoEKx3EwkYURpU3ukIFZU9saerlpHmGrsRcumUEjVJoGanCHJh73HllcfB+IhiEjPxYUCtojoPQj6A== X-Google-Smtp-Source: AGHT+IGr1rpgxq5OfSHBrnWnaic0KOWIn9EdNnbuuFOp9pzkhTU4xPruY+jEg0UWDpvdsAdmFnBg X-Received: by 2002:a17:906:f348:b0:a38:4cdf:adf6 with SMTP id hg8-20020a170906f34800b00a384cdfadf6mr1319072ejb.23.1707570376768; Sat, 10 Feb 2024 05:06:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707570376; cv=pass; d=google.com; s=arc-20160816; b=pzD19o0u2BbDfGuEKStBJA5i7alkcWVRwijFT/MtNtnUkJAH8Q09j+1rQ2ZSwg7oLw Fy9TYzfksz6hZ0gG5fZHcO0mCqOspKYEGxd3tjMxDci5HimXHjyzTjfpZorE1gel7EhM vb9pcvzrhSK2TdA5i/ncIreHGzixbJIg6lHQ+/xyXvh6fs/5NT/5UMlqyRmIZxkI5xhu sEANmoPjkqONUEK3wFmPvYS/m9snEIMUHN7vmiajsrr/i6sWj4m+1eRvMQRLVTvP/4QJ MHilF/mv1LJ76Am4LJq7YPHgySPvzH7oAzpb/vSxnCBMHGh/fOFZ07S5cNQyNUpSD0Ob jmOQ== 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=sJVjrzAqciRb2/LRj7N8tiqtGPPPqEc7yCwP1DwWHTU=; fh=KAY8c2exP/MMVeYyJg85skZrRB+Kx1p2V3tvyZ+TNGs=; b=gjnxUAMWAGGxDPBazR1ToE1krc1ZZolKEKng3HiCMWGN0r7m/8DF0RvUNZXpVxMSwR qTETZg483H8VAB1/Ojm3qAU9vpyC4muVKMzBw0EGB8yocJuOF6S1+fKGKUBcNHisoyJ0 6nsgU7D3GijgqNvLvaOxnvQAAnL6IVKvYhCVlpmNMjE/0gb7OofbzgqV5geOWV58cZfF W/ElnarvSnp8xqw61Po4IBB43oqddnECjwcSb+3NRzg6kXcISWoApLwEa/eqyiwUpxtg iFuhpknjrE2YuO1BU30BEWkmw/325Hr7fvwmsX43rkJY83sOuqqW7eqtMtdeByvF+cbe 0HKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=l7T8VIHe; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59696-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59696-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVLjjZ1hTupumgAODqFOiq1dgPNtmdMOVGm6sRGlQ3rHcVWQ+jMFcemaMABdXNDXPGpXb1xcJhDMGL8Sa9//bFiCMcm5A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 25-20020a170906311900b00a38303af19csi1955159ejx.481.2024.02.10.05.06.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 05:06:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59696-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=l7T8VIHe; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59696-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59696-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 D892A1F2677C for ; Fri, 9 Feb 2024 17:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A76784A33; Fri, 9 Feb 2024 17:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="l7T8VIHe" Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.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 1DB2E7CF37 for ; Fri, 9 Feb 2024 17:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498312; cv=none; b=RMKLTgNUcXRC5Vxs6/eVJHpCyJ8u2sAgxoycWCMnhPqpQl6bEIUuAcmdoDLbXAkiezh8DUVKOwE+MghtDhuetz8rgSG+gl6mNbC5hCzDs6QCjoLtsH2S/2DB6aIkZPTQ8dJpTuFntArblc9AjhQOlAWosJsgAcBVjgWfrsUlLt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498312; c=relaxed/simple; bh=E9qfFlPW1e6QyyiFWyQNW8LWGspZ155/NwV+vfM7aoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HXEW2FScKo1XqKyxJ0zdfBEOu7gFe82JET3NFPov0MTM2SChNApQYTqYOOD56Iz0BEc24B4IhwQxKkL28NovT+P1YSPlcRP6bbSoODyRH46fiI7kAU2n5dUUVPUoUusTUiijy2HWC5v59xD9FR602GaCAc15xauS4vIIlb5RmDI= 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=l7T8VIHe; arc=none smtp.client-ip=209.85.221.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-wr1-f46.google.com with SMTP id ffacd0b85a97d-33b0e5d1e89so727217f8f.0 for ; Fri, 09 Feb 2024 09:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707498309; x=1708103109; 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=sJVjrzAqciRb2/LRj7N8tiqtGPPPqEc7yCwP1DwWHTU=; b=l7T8VIHegpD1YRWTO6MaIW2hj6CeU+uTg5tmRZ3y2TRklBUpQTWPvdsoLPhKmVOqUv QgRzKMXBg0ut+7cipkcImfG6GD6hpaRcqtiPlauQAOX4xqqqKt5rQGJKAytvzIrlWTcT b6pkLV1KFEm5HKWkfBDmIc4VFq3kyKvd4nwjgTJWDsarNV7ziH3wQSSi6bA4DJ7iiJPp 19I731vgH5Sys0J51pDwf8WM1UaL9vzNeC2m/KUXED+yaiBleWTGuhGeBpf3pTfrmqdV jU2oMlTH/Y3xBdJ4yGrIcJKaS8eUcPLmt+/vG9l4GU+bq7jY74RyTRDAPBmLA6IF3lZO SeOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498309; x=1708103109; 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=sJVjrzAqciRb2/LRj7N8tiqtGPPPqEc7yCwP1DwWHTU=; b=KERJgesn/UksiohgAxBnttYf14ldnoCh5V/6CDKR/I6gWnIsIVqle24oeYoI/6rH9t bZONxtibKQVggXCw1yBfhbHd+Vf48CztnODFowR6xa5vBojyKXUAR7pCRUSRcUTvxzN+ ntbQJmysS3juzyIzD+ESzXHSIs0964RUJbnlFRT90vspJRnQMNLjDVK9bGiwMTjs/962 n+aonykvci24tGIAAgHcUXACD0x38vEaK/SkyuyW5MlBrt0h6l4VqMA6N7qOmihnp6pP zStt61t74eQJvk6vnADBv56xNEJnSKkKiCarvXhEheMszvi1IRicmt9Z2CY6ZIFYmAVc rdfw== X-Forwarded-Encrypted: i=1; AJvYcCXuXUEFButP+HeMc7Xs2byS8kb6ubhuwmCPJNC7ABdRLZaSSe3ZX3JC26ICSB64xKcO9Jm4wRdwkKuAYws0E13L9Nm7czf/KhGC3DeY X-Gm-Message-State: AOJu0YyNiKfEvJsj/XypcMkLSY4B0ETtdW81FKkwJ+C4bYJ60b/JAF+5 t6Vu8Me/bfe2QkPb3Igch2i0vVJ7vydNaaYQjrxqdPic14xhRmJB9y4YK5/Zwx0= X-Received: by 2002:adf:f987:0:b0:33a:e7de:aa8b with SMTP id f7-20020adff987000000b0033ae7deaa8bmr1508064wrr.26.1707498309451; Fri, 09 Feb 2024 09:05:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUL4NavJtL5JVa5Qyv6YHLP16s54U4xbfNKAHPk4QSUTjHRZVC7rScJU2FPwmIlt5b5HX+LCfOT34/72Q9ciLLpeaEVxL8z/63tDftL56fqTjsDzwzwsxM+iS1lUHZau+4yGYUkv+XDo762sSc/3MQxMQ5D0ilM5MW0hgWRBglOy31oJFFWTMnMF6SkJCf9copIVlu0I3rUm5CSFm/rzAEogw0wWxINU2/ly9Qpl0O3lkygYzXQpUGpEXQb8+MyVWTeI94r22kUn9+84bXezFq3HEc6y1fzHZxhoWLC27uKfqO6GOK/gDoRwy7Ue+KEw4ZmJ826uZE2e5Q= 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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:05:08 -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 2/5] net: ravb: Keep the reverse order of operations in ravb_close() Date: Fri, 9 Feb 2024 19:04:56 +0200 Message-Id: <20240209170459.4143861-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790517315554751875 X-GMAIL-MSGID: 1790517315554751875 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 in v2: - none 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 a1bf54de0e4c..c81cbd81826e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2321,6 +2321,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); @@ -2339,14 +2347,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 Fri Feb 9 17:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 199067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1064078dyd; Fri, 9 Feb 2024 11:01:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFwzg1SHI7kgs63qvncf2wGogKrUvZkpZrPhJCz+wmb8LKlJ7uM2Yr6xx6f2CKm31NPkRvfrq2uy0oaeCgWlWexPEbrA== X-Google-Smtp-Source: AGHT+IFIc+ImbjRnM+GfOq0+zw6kOYDcgq4NyBMk6B7NSjf96pGictWKvZ2nCfnb+BfozJ85Ze7h X-Received: by 2002:a67:eb4c:0:b0:46d:6e4a:2fe6 with SMTP id x12-20020a67eb4c000000b0046d6e4a2fe6mr270939vso.20.1707505273301; Fri, 09 Feb 2024 11:01:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707505273; cv=pass; d=google.com; s=arc-20160816; b=YJ3HkRkn+di+PmcQn8yNmZqCy4RtCjtGgSUNFBxqKnn+b6nOb4BVgPs1bu1f5S2y8G FjpTpimHALqGUJPlKUYMD8GCgzfmJ7sthy4SRnQdKAd4mOIdJg9Ox8air2E1j1WWQBwC u4c6MO/qouboDJG0mzvuTI5DGsAH2cTrSfvrtrrld9ql5PqgIOuOqX04gCRUX8PfN105 hp0co4+QqNqfR3qjTsamwdtVtVNzs05a3jFLyECZcZU+/icVadjLdIUICi2YCHPQUftL HHxjqmbf95zRYPIVyIm0BURNOPhL3AQShh7v6H0NL+zJqSjcCBrIzCVHaylUFTwa/uJU kt5g== 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=xhZy9E3GX4zkVptLlyXRNqzDt3Ynm9wObCoOnGgscOY=; b=KFMTpB0ZNM3eNvxrdO+0SsgLZyDKiX5b6VZi0JnZJOf1GTovsXRqDC+q1WrbtSQLP5 xi3GAHMIv1+KzKgHrX6Orb8xrXsrWNiZl0Z+zDG5sPyAfW3vDKYfz5PATanCBobyY9hj MnHDmuoiTtgfJWDu1xCqj/i6S4SU1UjvOVPbBOaSgsYMI3uolg1Kx3m5zsbJSYSHH3yJ ibp21ZEjlZ2PCMlIdR/WJJg06F87VF92GczXd4XUX4KaA8MXhRcZwEGoxf0NI+sHRzId gBN8YVy8cqn7k9OU7LyBIV1BwUYHxdnqDnHEs6p16HUt0pL4Vzfmq5xMJwIq2uZNTyAr yM7A==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59697-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVpISWRX/EYpeCmV4KD3TGHxYGgVcTUvYmllZHPX8rznHKrnIxtxHnwzVi6bTz0XFK/cDWO4N+lJBbSeDZd5phlT49QpQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t10-20020a67f5ca000000b0046b206ee0b6si3633vso.452.2024.02.09.11.01.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 11:01:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59697-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="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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59697-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 1BCB91C269A9 for ; Fri, 9 Feb 2024 17:06:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5343985C58; Fri, 9 Feb 2024 17:05:17 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790449048390009314 X-GMAIL-MSGID: 1790449048390009314 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); } From patchwork Fri Feb 9 17:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 199257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1441225dyd; Sat, 10 Feb 2024 04:33:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCu4sSr1Xqdqy9kaZBB4V9qrmV/5HaeTLO/WoE+Y8UQjiGCS0Lenn1cFbWU2GvqJUyVrT3YhfvUljC1I1nN3ebY1ySlw== X-Google-Smtp-Source: AGHT+IF4/AltQNTKT1Tf1oauv4xaww5JmkO4IReV9rjj76pwQ/O7ycvsQpkE+IquPtS0KTXU8RYJ X-Received: by 2002:a05:6a20:d819:b0:19c:7e49:495a with SMTP id iv25-20020a056a20d81900b0019c7e49495amr1503513pzb.57.1707568438210; Sat, 10 Feb 2024 04:33:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707568438; cv=pass; d=google.com; s=arc-20160816; b=fAGcqS63Fx1x3ZOEZO2E1+EajqCOlugxqQqjTHAVNgz+AcumkaMJQS7pqIrmaCmyWC JBgDfyYaR3IQKB+aIdtoZGzndAj64r9joehK/SPECaEky//IXUJQwI+58OQxwL6noUiN lP4/JFwSqbD9xvKnLK1TZOrmg7FXQB5QeRGxC6xmtHWIhCa4JPG/34sZiDu40qCLgjPQ 8yg8RUcgOIYC2qliq0lTYbKRcAx7RZpWtJDqVnd9A7T6aqreppAvckHtNwYZR8/lOkIZ fnXMqmW873DZ8XfJS//GLejPANijM3m7e2dSBuxPxj7de+6XjG623GSYZcNI3kCE7sjl Lfug== 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=geEctI3jAWOmh+DPS0zOGyuq69MDOHJs/LeL0ZEzs9E=; fh=EkXV6IEOJLwSg/5p3ORt0TCgR3DykqqpANvw5gjCGLw=; b=LAFwfRpHeOCMVeVq0eFQoxKYj78Cow96XAkU8OAaaG79rQ5GaA6iOzydsF3NtqXOxx TDtWXVSfgdeortO4i14aI0z0Yj13tQ6qOL/8z6IofSzag36Srj4mKXreLQ91K+U080tt +8lJgwv9/GOv4SM0jqgQrYFZ8B49aqcKPWDJPCCDj1jLOzwwp9jWN4JPycSVm75zHrRn FpLknHOFbeCPHOx+oIIGB2GBHEZZKar7cKqKkMeyjiXAJln7wMJ/TawrhIjAu6Vv3Bx6 Oe5IuT1p9CnRZEd+r+U3QtovvMyjYrOxP/Ybwcy8oQaHpCduRgb7qtrSyRJfrl9zm/FA 7hpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=I9VR92yd; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59698-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59698-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXLvgob9T+2l1o8QDebwpHwDL4aHjwAdpd5fD+ND9tcUQx/KxKD7JKjsTRDjKus4ouYgdDPNIqChm+x6L/3f2vtvZ1d9g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b185-20020a62cfc2000000b006e09edaf334si1746472pfg.375.2024.02.10.04.33.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59698-ouuuleilei=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=I9VR92yd; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59698-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59698-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 73B21284DA2 for ; Fri, 9 Feb 2024 17:07:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B62621272AA; Fri, 9 Feb 2024 17:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="I9VR92yd" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.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 8C7D380BF6 for ; Fri, 9 Feb 2024 17:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498315; cv=none; b=hipyd+ZfAWqaV6kenBJPkCBgn17Si/ohgV9NR2IYylTn1k2GqOt27/Fb+4ZOdZwcSGiD56kiQx3ax66GJ8NVIN2Du+za3sBQJdQC17ZAS79povO/u+F+cK1Iwv8VY/cnoUcMGqptYlKqRPMP91MvvmxiM71L/rOr9fDdkNWU9to= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498315; c=relaxed/simple; bh=Iko31EmtrFT0a0Vf7Lv+AOwIvZiu4+osFAFWG89yDtU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N2qA8yD4hjsCGW/1a2Cv+4bHIdSY16hLqGCw91RRUEtawvbaTc0/TqRqzseMVWrBWtoKdfw1vlzDgzl2PYTAkt2sImEtmKSivIkjMotRGq4EumgX8B8dRvmwQt5xyTXCHv5wnCg5vM42Tc7vXrerCJolnfTjYjYFkE0fS8w2jCU= 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=I9VR92yd; arc=none smtp.client-ip=209.85.128.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-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4103be6e938so10345655e9.0 for ; Fri, 09 Feb 2024 09:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707498312; x=1708103112; 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=geEctI3jAWOmh+DPS0zOGyuq69MDOHJs/LeL0ZEzs9E=; b=I9VR92ydaA20CdS51Qgnext83aZTOe3U2NoX0yS4OvQsyBSUbhcO4YvVDBm5HgtOdD XjPHT5HVsoJS5AKxawVlA1EvsZL3E2pp93y7tePxM9G4vNUwGARBbK/P4UkUJ0opX0ML Ciea5qDDT+DHGAvsEftOG4Ey4XaVmLGiAJODOMeHIY861AtTQNAIWOtzxxSHbu0yg/wG V6tQL65SxbJGlIVeHYFCvlK0Kd89fLyrhV48Li/10uANwXUfYInw0fermDHXdIxKmQ54 lnkd8z5VqqUKZT9x5ytU6+nwpnwDHKuj1A+RTGGpARY7ZAtm3bS4c/5W/j5YDWFjlECw QhTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498312; x=1708103112; 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=geEctI3jAWOmh+DPS0zOGyuq69MDOHJs/LeL0ZEzs9E=; b=lbz/LGKRSGB3IlD0YhMcgp0CoPnsFE3Tr8JdFMh0Ooyvi8Be/kovN2+tokw3pTLDgI qB1QJJ19PxASwg/9Aa18d3n5VfwBa7NkC2jGATCPAJ5yAJxcyJHRoTUN/uBgNQaDOcCW EZ8YTUJZR/bZXn8cWIx8DQsvrh4eIzgFZJxxSzw+9YzS2O8wlpYk8e6A7bf8itmjbWPZ HT2Gf/RO4BnH4YiUBUgTCyPVPMuGyiUKtlxDR3jYtemSt3RCy9HCKCmnk5n7KKGP9ix7 PWatrElsMprCyXZuZQkKkMe2sB1NizhiYSba2aS2wnkJQxF1iLfdZCnHaXBSsf/kpWHR 30zg== X-Forwarded-Encrypted: i=1; AJvYcCXxbGM+j1AnxJ9N2EmSC/8JUUDs7Ix+2GAjebhouj/FGZ2EpU5Bw00SAhpiMohO+r2pHs6OkuLd35M7TuEaYl5pi0z6jRJkCdOGwXZs X-Gm-Message-State: AOJu0YzMYC/v3hTrypYIyMgxhSvFQK3LHeId6CAdWD0t6cBpbJQEDoEj MR2gWQk/yuJsOxr1JOF6PrjOdymaozsBIanXk4qbDsVAoCbca0WErx57lfGXZNE= X-Received: by 2002:adf:e743:0:b0:33b:4967:4d2 with SMTP id c3-20020adfe743000000b0033b496704d2mr1660714wrn.41.1707498311891; Fri, 09 Feb 2024 09:05:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUd8zxXd0rM6pvBlpP/uV/+a8KGsTugrcQTnPU4iOwRPDgTMDAa9tUnAZGrems6xZZ1MgjrXeqNQh++MB+vh28kJkD4F03MObu2ymt5Rl1XXTk2Rf8h+3OiJEn7Y4rrw8hh6QoeUdn3K5LiEVzs+e7zlfCczdcTo+5FkiTsj/fZmCBiykEyMHl5R/8bAfL7ao1lkUVcItUaX15yB10h/Xllg2YuTBEAy5x+LSln8bpxbnj9adz9oBR2G1vyrZtDtfFdoY2X3fiadO3vxQ+cFfUZP/EiaQGIC/kPI88aeqvT0092AefdS8b514en7xkWQXhwxjAbKYKnb2U= 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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:05:11 -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 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down Date: Fri, 9 Feb 2024 19:04:58 +0200 Message-Id: <20240209170459.4143861-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790442263379035590 X-GMAIL-MSGID: 1790515282675721095 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 register contents) 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 --- Changes in v2: - fixed typo in patch description - adjusted ravb_set_features_gbeth(); didn't collect the Sergey's Rb tag due to this 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 | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7a7f743a1fef..f4be08f0198d 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2478,8 +2478,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 */ @@ -2492,6 +2498,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_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg, @@ -2515,10 +2524,16 @@ static int ravb_set_features_gbeth(struct net_device *ndev, { netdev_features_t changed = ndev->features ^ features; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; unsigned long flags; int ret = 0; u32 val; + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_rpm_put; + spin_lock_irqsave(&priv->lock, flags); if (changed & NETIF_F_RXCSUM) { if (features & NETIF_F_RXCSUM) @@ -2542,9 +2557,12 @@ static int ravb_set_features_gbeth(struct net_device *ndev, goto done; } - ndev->features = features; done: spin_unlock_irqrestore(&priv->lock, flags); +out_rpm_put: + pm_runtime_put_noidle(dev); + if (!ret) + ndev->features = features; return ret; } From patchwork Fri Feb 9 17:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 199256 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1439628dyd; Sat, 10 Feb 2024 04:30:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV58sx7XRDAlfZBN5q0U+jEcK4V8vVzJU8qCCfN/hiNl8T60UYo+CQDtyMX3NcMxoT3udYcFxRSlISXFaEUCyRA9Io6dg== X-Google-Smtp-Source: AGHT+IFSOkM/4a9WXnyA1A8NKq07ERpSVVhsBvD7Yklaf0kdU4zAvr1fEGiKk/JM5BIoUyGgxcrZ X-Received: by 2002:a05:6870:b24e:b0:21a:3115:3497 with SMTP id b14-20020a056870b24e00b0021a31153497mr1600751oam.7.1707568218535; Sat, 10 Feb 2024 04:30:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707568218; cv=pass; d=google.com; s=arc-20160816; b=CnY66Rroj8QbsoRT4td3F47OiKPj8drFh1vPCuI3Icie3pkOR7Htja7qoNopTwrSme qnXZAtb6Muq5yeoDoYNCqHYpY+7X+fK8XnYCa8Udcl1/gL1INwt+eZeKgKc/BScIWHqh m3reLqWKIzHSGJ7KJmST/GtQaaX1shhvI1i7NxYfgovlIczhZgrPb1Pk3tCASKjbiuNc Lw0cIx91g+UBiEPx6SICbHjiKP2OrMQvsDuBn+72UwbuJBDRJaPfBlro2uiCoAlLYkVv F9oBOqs7ev4ATXfCkW0JWRM3jQ49Z/eTIWnHaRWWd8rNC5TSs/LdbfzvhDqABHwCWp0Y Q1wQ== 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=MqzOcrxXkmN2Q8OVFhHyTRPrKazqUHrRQjUC+mJFZvQ=; fh=a50kTToiOF4uB3xjgUYd6jsK5aaGFBX4F3B4HhoNHYI=; b=Cpfj7rDdHPfCvcgh7ywoy6RnlfytGujp4V8UrV0Ct7NLVbIwYkme2t5+XHYOi6MzN0 wTRjoXhsei0sc2RWFiVMM5YMhZTlSg4SDzGiLP7HLzqIdUzk95J3pVNcnB+xMQ/pLpRw 2pCkEvy0lP7U7S3u2kk8zst8DuXuz3nkNHXvk6XgTCMfVk5eJ45MPa8sR3TabqOTVVkI 9lF9YOgPNWIsfBLaNHSCMYcDExY1iXTV/LRVP1NsWFd4fQJYxpOI0LmlD+klLf1bU30P 0qxOrOnYaVBzl7AjLuxLpjTh1iUs8o0JsTdEvL2D/393XuaOkuVBY0A6xNcGpW4KvMss R5Hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=RGEh8TJ9; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59699-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59699-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVNE27vk+JL7SEdouYMhji1M2wOU4HtwaeMC+EmsthRcRRruNV1f+XwqaLJiH5oaWVd9euyjZTrBP8Mv6wjoUatKCJftw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l10-20020a633e0a000000b005dc4819ce47si3377624pga.44.2024.02.10.04.30.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:30:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59699-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=RGEh8TJ9; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59699-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59699-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2E761B234EB for ; Fri, 9 Feb 2024 17:07:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F93780BF1; Fri, 9 Feb 2024 17:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="RGEh8TJ9" Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 A977282867 for ; Fri, 9 Feb 2024 17:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498316; cv=none; b=ckSmbTm9jg+3TKNmMy4+qIo19mAh3/kK7my7Y/CIQzAADyrgACjlBCI1ndByzOAXtOEOmce8N9VVecS1r0LzjTo4VnggdJ/fGNtp/26jUu8Ihc2x5ToYUxsG7dEsfohgwoPh2WvTNLD762xykIZof/+1hVFlwWdqU1vuxX6yahA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498316; c=relaxed/simple; bh=aJyW6klkiCEWCaN1kbMLvNn/LlK4LBkX7wlr068Ea4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Qk4NU8YcPDNUfPhuu90FVIcUsddmSHDwBIKZNdgd5ioSflbd+nwU6fDjjX5shaJCtC7dbLdv2+gwgGfbGsjnTKx8qiR3CNhhWZLASfJw7eqv2vdKGDe5fe9goVsHSivkHnmZNQavEdWITgHauFXOFga0Z1E+LQR9V4Z3Q6LYAi0= 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=RGEh8TJ9; arc=none smtp.client-ip=209.85.221.47 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-f47.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so800040f8f.1 for ; Fri, 09 Feb 2024 09:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707498313; x=1708103113; 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=MqzOcrxXkmN2Q8OVFhHyTRPrKazqUHrRQjUC+mJFZvQ=; b=RGEh8TJ9P41fDWbgg8mMzyM48VALVnzIwSvQ9jE3B+JHDfNuC8RMn4HoL1x4Xk/Vxz UK13PS0Cnet/r3bs+KaZIC4g+Cw9vJPkZ5ot3DjosbkbbEyYzSq76xdnUhQ4l4PooM7/ rWTbcCloSS33zP4teeEu2l5me+gJPVXFKDIqFAcNGh7BMvB87fT5Xe45hXU3DCf7Rwfy Pqrxs+oZZ7pluO33yyKJR/yHVmp+YsRvUBxSXla1xwFu6Lb1DZjijNmVa14sKGA9T0do PPeKiGb03Q3hlKYf7zjL4aCCqwwe939sEV75PSDnBGLf7Yv5m6p1yh6texPSTYJmPQXC GvRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498313; x=1708103113; 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=MqzOcrxXkmN2Q8OVFhHyTRPrKazqUHrRQjUC+mJFZvQ=; b=LRTaFg31QgFiCt+qXjn1IKlllIHOs6R2bfNlKapDpqwReL/v+nne7V3b8gIq4RGJdS 8yKwT2sjzLiHdoC2GO82H+WvXhme9Ljn84QgAJaeT6norR/EeKyCeEQmrDnRPCaW/Lr6 eHI1RS+reS7JuGWwawSh9ax005+S1bBZ7pLlC64OyY72tEBZm5StPyWDTYR99RQCTZzv Tieg15oQTxID/Zg8ocrerWjz2k98wErxpSVI1Cz9QgZZZnWQhscRbsNeIND/3XThKmMB 9pk0V2bnmHaBoBZtp28Z/DGWOKijvo8PkYCwCdid3dkE3I2Ls4WWIZHV/3qmnADP/Ofp yCOQ== X-Forwarded-Encrypted: i=1; AJvYcCVR6rTm2o/Kw6CGNDsQo5HT9A7dU8AcKrcN6CwLI38tpg+TLSk/RuFK3PV/p0K/6Xb2FfZfHkDYzBNDfW5pWr8QlS508SIMuR96JGvB X-Gm-Message-State: AOJu0YxAh9b1WKdLmjuoW6ZOl0xvwfxRAMJ2iCZQfwDG4sa/KvIJBVtO A/ks6UKu3qoMQs3GZRm/gaV8p/t23KhQk1NSoUTEJfOu7odhpqBZPTixuc1KZXA= X-Received: by 2002:adf:b192:0:b0:33b:4f08:ac9c with SMTP id q18-20020adfb192000000b0033b4f08ac9cmr1629190wra.33.1707498313034; Fri, 09 Feb 2024 09:05:13 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU8Rwost7tjJg6H1HzwrY78TwXxkunRNolTYR9oJ4fG7D3nXXseL7stbAf9T6SFH0QGRTfODwm+agRk/BYFce57fErHFoVBgoPkQ0jj0q6Kadw4aCCyu09k1CzpvrcZXo4AC9UldBwunIc6SrriDUoBeD5Zqf/q2LgKlmNczgl3bp0oirUtBRkOnat2ztVWG7deSi0mfMtqmthieTmNRCMoXGVnX2Ua5X889aRGMlf1mg9Vug7O46MJUiIrEtdckFytwSstSCPlZKUypyIcI24qU8364+pVtm5jgTbxJkCw/5RC0K5cn0+fI9s7wLG2Oiu9WNWJNVLWXq8= 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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:05:12 -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 5/5] net: ravb: Add runtime PM support Date: Fri, 9 Feb 2024 19:04:59 +0200 Message-Id: <20240209170459.4143861-6-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790456640389249075 X-GMAIL-MSGID: 1790515051969210125 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 in v2: - none 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 f4be08f0198d..5bbfdfeef8a9 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1939,16 +1939,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); @@ -1982,6 +1987,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]); @@ -2322,6 +2330,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); @@ -2371,7 +2381,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) @@ -2931,6 +2948,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) @@ -3036,6 +3055,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: @@ -3053,6 +3075,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); @@ -3066,6 +3089,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) @@ -3077,8 +3106,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); @@ -3160,6 +3190,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); } @@ -3182,16 +3216,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; }