From patchwork Tue Feb 13 09:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp429944dyb; Tue, 13 Feb 2024 01:52:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3vhZKVb+DNcsLIAI+5RIkOTpkP3sHYaq0ce8HxQdYi7+IYiA2I+ce4zwEcJsoqWUoRElofKu8bPMXRzzuvKq3DDFdiQ== X-Google-Smtp-Source: AGHT+IGt8kwDFEMWKgW4jrP0qBtC6f59aDtVSDYG8MiJhpaqHx5mHCVBTXGDWNU+YTBTbkbsdkEl X-Received: by 2002:a05:6a20:9f8a:b0:19e:9a75:7834 with SMTP id mm10-20020a056a209f8a00b0019e9a757834mr13422138pzb.33.1707817925231; Tue, 13 Feb 2024 01:52:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817925; cv=pass; d=google.com; s=arc-20160816; b=t7nNMdlSZ2llsKSBbjjjXd0woe0Fa7stRvr4MEUaTpmA7P83WyEEpvKLZZNbiJk4BV K08AdNvYF9x4nu6zqA3eXf37gXSlkGpi/3DqLXApQyClVWDuzAnmfH0VusgYj5SOTBd6 Tj3Qq33lGn/d3GDtHhdrPWHH97rHMzZFlB0nEySN2nNEl5D5+YpO69iob6VmFwk2VYED LLOm9bINzdA/eEJieoaVPrr9vlqiEVpf/Op59xNbnSbZcoC5WoKHnPI8YJpZ20Rv3H7o PYxPWgZyoqjxQaPh1//fQJcfozaj0RjuEZTi1wrIFcNgM1spBxUOv0B+XA7ObQDlB9W3 sm6Q== 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=TTm27U9imY+diMQ+Cfy3KOx1XX4gyrrNl9Sty+DsGIw=; fh=5PJ6sKylaS+IlSZe2PHlELjxZll7xbAb7hTCjHHs8SA=; b=iVwpA4VF8DsgQN16fa+5qoNvH2XiVOypeqolrL6thtaEMQ+5dy4ZXvjlh0foSEsMbc LQvXJWzVec06tcLmpAHbR396gHVYpMkB83ddoBVRE0vrLY5LYD1CyDNewFMyc6yG1yMC 1WzoFeBneWy+BuLa8ouUDdK5eD6+VCBIsnbjPjEBO4PDtEFSzukyHde7zIjJ+AR/421I RSBEWl1/pdkohM9kMhqiolcOxuRtjpHrjno//YCSm6jxoBejQoDflz3qh2Dqh2UIJEj6 4oFtCo8M0RdXFkG2Jcs7qQP9W2PSbM1zaOXlpFOrYouq8v3rpPOuwjjp2WhjXkWW12gD qXTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mrKxNdLb; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63247-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63247-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCX2paLmqmX4PZIiSftofSqo7g2eytdrr3LisWi3Rxqyk7v642UYfUqSjfXIYLpwfxvGPszupxHTOtz+5wALdr+9Hjc38g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q8-20020a17090311c800b001d88b4759c5si1792773plh.19.2024.02.13.01.52.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:52:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63247-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=mrKxNdLb; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63247-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63247-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 8B51228C7A9 for ; Tue, 13 Feb 2024 09:47:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 154AF53E38; Tue, 13 Feb 2024 09:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mrKxNdLb" Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.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 59AD838DF9 for ; Tue, 13 Feb 2024 09:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817306; cv=none; b=I6C2OmWBXol3eoECjzxj9JIWAowf3IslNBdfy6PliW9OC+waEUDn5PTsxAWTTVvk2jNqISNXQjKz4/Q3p4kS6ItxrLBrxZfDo92NSlC+nInrRFox/V7XFki6AgMXofQektzwxfUTnewkNl08yjJE1wSvbF0L7FJtOeMvcphA9TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817306; c=relaxed/simple; bh=L6m3PaHcpH7fTAmCpzJxhaBYogFtv5x2tXcok6WfMQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=frpMIdOkrIJSWV2qmKXrlMduxn9HUiiSIDiJunnl83RCr/MRRe+fj+oK/VI/RKt/o6jov//69chEc4b6/DzlSldLZuqLdh02+MWnkrvp3CxUVOV7aP0hyHw9Ra8+m8W2zaDAkaWO5q5T43vna+GGevJVgZrvv+0dmSZFwVj7Qs8= 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=mrKxNdLb; arc=none smtp.client-ip=209.85.167.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-lf1-f41.google.com with SMTP id 2adb3069b0e04-51167e470f7so5004278e87.2 for ; Tue, 13 Feb 2024 01:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817302; x=1708422102; 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=TTm27U9imY+diMQ+Cfy3KOx1XX4gyrrNl9Sty+DsGIw=; b=mrKxNdLb7i/l8a7tAAHtIRj/hsQhCoC15dts+sckLCqVwww+GCWFFwJWi+5xc7pKQn dp5SVHdRVA5WthHAuGx+CAHS34vOSFJjmVCBP6w98spy0duaDIawq3RWeZztc8oDU/5P T0uOUdgzwkG3+XX09OFswYBbgwoIzRH6eb+CtlBYDA7N7pluOG2thJWZwHhZL8QQpKjz LJs6tXeyo7+4F24n3fshfGl8AJNTWb5wgd8+Lr0hxVvmXuO0uNI5S9DLAKEF008eIZ0l qRSIVT3hHpOBbsdcFlYJl3UE6wCmljeok1XZXGGY3kQvX8Yef3O1sUi1RD284Gv8sKNb pjCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817302; x=1708422102; 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=TTm27U9imY+diMQ+Cfy3KOx1XX4gyrrNl9Sty+DsGIw=; b=wG/NN5NNYHjvQZMoorWfCKVHexSp2LDE8AfMsTprtHdnoBpFfabEYAxUcUTzOUcCXs 8MjpqqZeHGocu8i4xwkdWaeKVny8VI3PpnZDzXmbbEW7B5wl2iWAUEmVq86CSVY5vaFC fRt5Nob/BlfAMZaiFtVqgdjiCEV/PqMTTZ+x08jxlzmmKUueoZVOv1Sq4YY/JDxUCUqB dw1NYdSFu4FKXMsPOW5/ShOvtImD0094oRco7iZsxJIDoa1WHEB06RmCxQkJT2YFkitX 9GWRlvkVKCd+XXUzmiWc5KqxGWOWHV5pqSP+GhY/AOkgTcw4RlwyiaYQ3oIgAWtS8vbg pRsg== X-Forwarded-Encrypted: i=1; AJvYcCV9Oj5a5QA9FEopopzLH40OvmGmPcvz4lqmAsxP9ssywrGAIlLfDZ4doMZRuYv1Q7qPyryn+StCdM1a1/g15r0Phxn5dLxhCC/3ujfs X-Gm-Message-State: AOJu0YxbgHRwKlQ3zCnjnzF0LOoyg5TJr865t3zBTZwWZL9Z1l8y9G8O KqMir05Ab0U0NIlU1H/S0Rth78MjqAjz2AjqDwEJfdztaMlvINnDCfCm9eFvu0k= X-Received: by 2002:a05:6512:33cc:b0:511:75e2:6b5e with SMTP id d12-20020a05651233cc00b0051175e26b5emr7171150lfg.36.1707817302073; Tue, 13 Feb 2024 01:41:42 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXjyHUR8jchFQdRr8F1L8nPt1dQno6MxmexiRb08RAy4xTMgBKVPT3usunHLtuz/wIcTmSdf3AAEbXhvyljapHU2VeLsXWN4mwuF8zL32zg7nsgUu0oAGPS1iHB964cw74Q4aj4xX0cEkjQlHTvMr6QQobIrIDRU2gwhyJRY1S4naFO40Rk/uaqEwagRzYbXR91NI3NTUtu5g4E5jNL2VcbPMRopQFamz1Ybeqh/pCZPgkPFjvor3cadv9sbJqNUaCuk3G0AzIVyDdJSeFHQB12+AIbPFrWUROzC2ZiowVgjllxtJ2rGMlncepbeZHw6XswzBg4qUfvwLZ/3WDzSXqT/mdUzWzTvCcHDCzeeOxNiMkNesQi Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:41 -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, biju.das.jz@bp.renesas.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 v3 1/6] net: ravb: Get rid of the temporary variable irq Date: Tue, 13 Feb 2024 11:41:05 +0200 Message-Id: <20240213094110.853155-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-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: 1790776888801223429 X-GMAIL-MSGID: 1790776888801223429 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 Reviewed-by: Sergey Shtylyov --- Changes in v3: - collected tag 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 Tue Feb 13 09:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp428595dyb; Tue, 13 Feb 2024 01:48:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFWNJs/QhhhSxmQzD8baD4UD1ekrRgTGEdT+sSDwsz13Mu/AiukQzeSF3w3jwQu2TMuWeEZYrp+OGdII3q1VQAKMoyOg== X-Google-Smtp-Source: AGHT+IFfxfZoGhAay8fj81wSd2DVAXb3v2zuk5K/bgC9XiY6GjAVBVvnu7wM6UuvMQYPkdab5Cfl X-Received: by 2002:a17:906:af87:b0:a3c:21ec:5baa with SMTP id mj7-20020a170906af8700b00a3c21ec5baamr6359477ejb.20.1707817683983; Tue, 13 Feb 2024 01:48:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817683; cv=pass; d=google.com; s=arc-20160816; b=CIiTJ1k5WGybrfz4Gl2V46H2mzzTaZWHI66j1v/C2FjYc3MqQTGvWQRk0Z7CF+60wt z5sG9n+M+9AOONPoD1Ep5UX4HfpAFLboaST8avbPBfU5L246IYre6civgRPan44Kj5Vl /Y5aZkgfqV9cQ8J78xJf5K1cWEjLrwIya85hSmywpmwQFadU1Zdx7+cCQIrjKpVSg1Z0 BrpQOOtHkR1Pf90U/Ol7PkeZ1fRVq4+RgFVOMqtK/XAarkXC0Ok1+2Jk3OadQRvR2ucB NigiyQ6uZ15dcLwLj1bqgc0tFvdbU4aPCyxDbmBLCpwBSlo6cBzlWAIq/awL6GLyYgg/ BypQ== 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=aAa50mXZbPqqgphxhzpCHoCd19uwy4xnnSSFW1+XwKE=; fh=EX7fbQntBd97SuV8TrJ9z76KENP+u/7AFuxejPl+qIw=; b=GMRkARxr7e84cQ7fW0PbYIdkYTefXX9GF5mDONcIdpch5OvNj63S/NZqZ2rR/oDSJT 6S0AbjRnqBpHXA1/g3fNKOp4IoEtj1llsRbOwa2dXbBXa3CR87Nddb4WErooLQgpO6eE f2v3SP18O3LJy04uP0K0EJgLGduBSfxMXDv3juIi7Ur25GvNJ7cexyahTz4r0M2mlzWj gTnfdGx9XQNfNqEJ6u39dUGpc2ScsBvWfQYYQPOo+c91oWuJWOPER+9a9Q3rRpTAQJpg gkocGaecBGBUz9b2e6/c/XzU+ANEHuyRNzX9cv3Cr3WcZTJmtODB8o+bS7D3QgtPOvMM 7wuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=KJfPgRHL; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63248-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63248-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXgXc8PIl09EzRQiBSD0Fle/P06PQ59csAkSZATIOznGU4UdInD0pvISQU22iM5tFTY9by3pSHsbmNc3TSzfO9GvrvJkA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g13-20020a170906594d00b00a3ba2c57c60si1022981ejr.309.2024.02.13.01.48.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:48:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63248-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=KJfPgRHL; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63248-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63248-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 8DA831F21B6E for ; Tue, 13 Feb 2024 09:47:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A72754BD7; Tue, 13 Feb 2024 09:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="KJfPgRHL" Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.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 51DB239AF0 for ; Tue, 13 Feb 2024 09:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817307; cv=none; b=i0obhsMOtJY5lR3JE/gKrPAP0J0s/ABIrL/GZ35CP5pOydvFU9bLFyNre43eOi9d4RgBbMLIXl8O/AbQJ8gLImTlpry4H/tzm9XbRUjNTbJr/y7wSC05l7hF7ZUbrdtxFZcoafPXZ50HLANXsCpoM0vp/E0SSMlISdFoQ8Yrso4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817307; c=relaxed/simple; bh=enmy+LoY5r8g/P1HcJj+4PzEb3nLIvXmdJEA1A5e1ZY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pzMidNP4T3wQ60YAIVSHU/YdslatKZaDoA0CSlD86xHBynCwemjedeLW+pffVkx6r4SP660CDP1b/cwH3ajYmuzlg30KsVxnpkhzna9+BVxY/2pIzfAV0pQhiKljYRBmTZ6qapMIt0Wo1L7+Wr/UUwaiA0nUnUxP9XNfDOl0uLI= 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=KJfPgRHL; arc=none smtp.client-ip=209.85.167.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-lf1-f54.google.com with SMTP id 2adb3069b0e04-51165a488baso5433204e87.2 for ; Tue, 13 Feb 2024 01:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817303; x=1708422103; 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=aAa50mXZbPqqgphxhzpCHoCd19uwy4xnnSSFW1+XwKE=; b=KJfPgRHLm9Eq94KaPzNNmX+TEPHUXD96exrxaHIMiQrUYOXbxmZa2eY58kj0aQ35EU X+uKVtSHqqW0St7ruKV8XAL5bR+lY4EBPNM8rh0J7R9fUM53YwoKDnk5Jr5zm6UFyedY VYY43gxGBsCQ10CC1njy2L6xRdR4gaQzrVEu4ssnSzhw3GLF3xYOZnUXnMywj7HjfkKG QCbPjakxCPXdDJzwTEqkyM40+5kKyCajfn2Agrcm+3JCTt50xSlzsRc3eNVLG23XM8iu nRKCaVJQghoEcUFLDDobCzPAg0lYUt5n7g3mh0nPrIE81eLVhUKVSnHfId41pKC+0fEM 1LmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817303; x=1708422103; 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=aAa50mXZbPqqgphxhzpCHoCd19uwy4xnnSSFW1+XwKE=; b=gq49cQe4Fwq55x4yCVmBoeJ0HOUEAaXShcSPgcMOzFcIzjEnuifgJ8503WJTfvdbQL nyxh0tXZi58jNw247AZm8jbjMQMTMmjMAZULtunicDhBi0BIjg0n0g1fQ4XLHhDEl3UH rGOGdoUvK3HABcHvUQMX7ryHx1Ki1Q/5tYcrT/x38Wd77YmWeKJp2Lh6c2YHUAVWMPI6 PbZvLs2VYxX32yWP6JQImolA1lj1g837bZ1vVX46IXgtnPs07W7eKjPyJjpBfy3GwSgz NJ3UO5lO1ilb7k5sdMAxN/Ve6rUm2NrrEsINOap2qaJlS0yPw9RBsgXqzpFbLn8lrQIK UEJQ== X-Forwarded-Encrypted: i=1; AJvYcCUrNsdWjHwL7aosqZAeYboQNgvDOYGR/5LDomNPptfqjH2IbQ6vIUBGLyCj/uFajerBK99heOBVFp2JNAvDDDbWLthpRDKXdIssZtwL X-Gm-Message-State: AOJu0YxC227iOMJ3ZPNQl2GBC36cV5X7pPIc/xJdCBOisbgpNnoqfVGy dLesUILfpmB7M3Hcghl1FFoP7bYcctjAzZyKW3A90l6d5QE0aQ8bg8A7Iy7VvyM= X-Received: by 2002:a05:6512:49e:b0:511:4ee3:dc0f with SMTP id v30-20020a056512049e00b005114ee3dc0fmr5561325lfq.19.1707817303330; Tue, 13 Feb 2024 01:41:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW69Al/3XiflcXDZn21jWBYjJTg/9YKAkSVPu7lcjXWsEFj22RQh8x78vO7ZDXQ2jbkrOg2+H2Jh5cJoPHYHc1gWmn2Fmy3w0baKaxs1oaLpab7PQLXyv8vthemHmcCWqIGDr6FF6lBFIb7DvWYESwnS1UNT00GA0k9KBsTi6QWmNOH9CFVFt8X8RT/jDoJ6Q8jfZ36yOJ5r+EJ47XzX4aW/ykfx3Y3TirLNuMe7uraNmJIN25disnVBZUpPUtbIqOlHes6vKvSHqoTIfkRlMq9GqFaPyD/D2+69D7wmqp1/2Oc9SG4LcLI5lpESA+o9VHA7gYHgo12c+jW3DzcQNrbPsomBPmgT3cZHDH32ar0o5soRVXm Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:42 -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, biju.das.jz@bp.renesas.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 v3 2/6] net: ravb: Keep the reverse order of operations in ravb_close() Date: Tue, 13 Feb 2024 11:41:06 +0200 Message-Id: <20240213094110.853155-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-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: 1790776635939178792 X-GMAIL-MSGID: 1790776635939178792 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 v3: - none 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 Tue Feb 13 09:41:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp437090dyb; Tue, 13 Feb 2024 02:07:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWMNANoxRkX3+g0btoWWoM+K00nFhalGy2UrT1YGPk2pD/yx/IGjJY4kQk0I915TCXCA9fcgr+DEIBQjre7lCg6wGrBVg== X-Google-Smtp-Source: AGHT+IHhUHFIXe7WvIR+Xtud2i0kv3pM288nitC6iz5hf/9g5Ydu2cDtxQ7tKA8yYcgpisKyUhj4 X-Received: by 2002:a05:6e02:1d89:b0:363:c796:7736 with SMTP id h9-20020a056e021d8900b00363c7967736mr12670810ila.28.1707818844783; Tue, 13 Feb 2024 02:07:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707818844; cv=pass; d=google.com; s=arc-20160816; b=gYSyYGjD+UMJ9HBACDeJQxy1NvXjOpN+OlBJx2phOSjJfrbNPeOrsyMy1e+MZmZNM4 dBTZnzcdJD8Z0wEmrhOaEEiYfCwggXBBAi2ZkW52sCY755nNvPblryc89tFadr0pbC3/ v5mbqlkvQvAc69iN2CBAk/5KR1x0fMlTfp+uYTUBG3Et/VL4mN/y2pbCxWumeEd2QTC2 mdO3ng9aFJ8NYxaSlC87E6Vm/T9ZQoY85h7lR7hjfmM7uvyDeC/GQBsQeQgVuun+72c6 RlRUx8oZsTCW5j1ujIXqMxCDCAm78Hbvq7SCTQzN/dMbJ7pEz9smv3VjFc5BXBdoMEyT EdPw== 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=1DX0f87HSAsoENN6G92H3MYTw5gEFb3bGk/lETsw33o=; fh=tT0Pe08VwJD3H9eUGO9lPTbxsHzim0N6e9iayL2T4xA=; b=D0diLZnSTcEvQ5fRpfoL2DZ18Zqr3/ZbeFHhW6mLOXBhupSxQ45tSqqm8NO4MxhHTB jGI8n6o+2OOLkYv4vrjTdJ1wCblLT4IFKjQF35n0hXJQXUiF1BRsUYYOfCqHZkKGRlAM WMsllF9sV8Q5eQTdoUKbXjOH93VggCxWVUcIBlIfbk6et/Z4Fp/KUVDSbhBCJIro34jc HVpQZcWz5pSzq+WX+RU8tFKFLiMiA7CLMG9HE8SuVCb3+myjsoreAdAVpjBT5Da2vEOH b4N52Qp8VsRgrhuvKDItmD+hmCDHtMnZJMkEUoSqScKsGSTDwjbTjHM/B43/YOh+F3zJ OUZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mxbfYbLX; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63249-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63249-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVw+RVTvAr7vqzTpbW8yQEbeC4WpStImUwT0TvTDo6tnkHBH7zz8L8SwmVb9x1MwjKObq4UrM1WShM4Btr398NDNY27ng== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c22-20020a6566d6000000b005cf0e5119fesi1232319pgw.304.2024.02.13.02.07.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 02:07:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63249-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mxbfYbLX; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63249-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63249-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 A592FB25D38 for ; Tue, 13 Feb 2024 09:48:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF93654F9A; Tue, 13 Feb 2024 09:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mxbfYbLX" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 744B93D0D4 for ; Tue, 13 Feb 2024 09:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817308; cv=none; b=uno5tXV5J/tJcYGgj6xf2KvPValb8XuRpwqdIA6QSksFYHAp5Fw4p/MSA/V+jM/mzAoLiQdXPHkJWzBrvYk0/W4+P439yj5/g7OFBP9g9qcg/UGx0VK7MUIP/YWcfT87UWZYM5sH76DX4b+KgpNC1cWl6/Y37o+yjgoCCTmo2X0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817308; c=relaxed/simple; bh=+cx7uCdIjjcdxImi5aLciGuFRrSNN2LcXONA1R9FXrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XcYz1ZVs8vsL4nduNj35A7pAfvgpWuulXCkU+snf8hxkZnOUXhET3DboSlQ5s5h5Fzp/lYrbP43GM7C9lp9+fputpKhfvzqlcdT09FIN8yxlc/20pStgwzJKC8/Px+3plbIKYEfHQ67DUgiYndR6XENUH9sfMlGtlNRGN+GG6Us= 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=mxbfYbLX; arc=none smtp.client-ip=209.85.208.173 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-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d109e82bd0so4773171fa.3 for ; Tue, 13 Feb 2024 01:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817304; x=1708422104; 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=1DX0f87HSAsoENN6G92H3MYTw5gEFb3bGk/lETsw33o=; b=mxbfYbLXXtNT9LjfEXoo/+BtQu2YTI7bS0BQ3UW207yfiZ0Ts+t8Vg+byrqg6mPtwq wden/ywycgIJAAcppIH1G2UC1qTAx19GIdXEBKsVnL88co2oZXjGHh3j6QQ7W1EN1nlp cOKqt072aoX82qS8mMTuNoOtQlIySo4fCvbgFSEcAezXXqiyAUmgo4L57Jm2144PKFkF fMPBNWmjRuZ8rCZrUrzOKOqxFwK19vFf1nD1OyJV/P7Vfg7YYIlpqhsy20sV9MHCVlj5 SFujz8+sM/SqRf4c9VsYnekUFuoCa4sitD22/s4rWR3UXvW/75PujdYueAfWa1qucHKx Ty9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817304; x=1708422104; 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=1DX0f87HSAsoENN6G92H3MYTw5gEFb3bGk/lETsw33o=; b=Ej0LfNb6VprnwwqeLxVV0xgcIVv4fFWzd9CqyLLJoZQswswcvADIbm3C+EjzCM8mE8 a6LoPIvMCEZcApgX+K29PU4HNQmbQhT76+4AdNqzZsY8PBjFcEZZNk+5RvjMDlJ/zLN6 8JffFGuKGzghKBLcUdRaDPsKQVkP/7p1gEIJJDgE+4JZyk2sAuWAPYyLd6xTwENO6NHX CHadXe/iLLSKfZepeNrAKcBI/mAQ+W90YBQyRjSS6aI1pR3LFf1s35boDYpX5zqI+xBE U6hLIYZrq2Lq4vgAPr5f+HtU/HjwBx3hPePMgJNv9JDXmlaTzJ9CGz6pzy6HFxDNzcZI I5Sg== X-Forwarded-Encrypted: i=1; AJvYcCVEtNINQc/pRv1+1YUtzXdGE5sdU8whQ2gKRot7EDhglZLs5mhSJuDcSAQLVvyI5pnGqa96nvUujATaArMceaASkJ0LDh8lHBh9rYct X-Gm-Message-State: AOJu0Yx7D40BAvUE3R3VwD51yPa7FoSZUWUTaSeavp6rQcrnoP3BZjRd Q7qWbvbsNNLdD7EOuDXbSs2UN5NXeDfB9GskmgALPNAG0o9FagOMuWVlc8258Qc= X-Received: by 2002:a2e:a0c4:0:b0:2d0:9fac:bdf3 with SMTP id f4-20020a2ea0c4000000b002d09facbdf3mr5748134ljm.33.1707817304664; Tue, 13 Feb 2024 01:41:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUzOvwLfxb6mc5IygbTF21uL/zVxJgyubcSOCZJpBmUb8xYYcieW6D96ISYX1OAhKHVVTGBmLdwDaIz5XEFSvoDrIRkmbiW7tpYV7K9/IHNl2mFR1vfPTnGR5gtwTeTadUy6OycuwwU25zU2v2Q1aVkyBzSAvm54MslEMCbEhFe+46b1WKbejYVyfstHY1+C3L+8QyLBa1G+z77KDCEQruUlTJuU1clswyeHaPx6giwB3ae9RUkU5c0zqDnA/QYL8uLymKjR10eUO0beDY/X2LLtpObTvuqYtiPym4WsevD/U1idNsbhkLWONpI5i+tPBqah8TG8FdzbeyVkevUQCr8CDcXrH7oX8MYp1SGj14XH3Pa+INv Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:44 -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, biju.das.jz@bp.renesas.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 v3 3/6] net: ravb: Return cached statistics if the interface is down Date: Tue, 13 Feb 2024 11:41:07 +0200 Message-Id: <20240213094110.853155-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-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: 1790777853032256034 X-GMAIL-MSGID: 1790777853032256034 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 v3: - none 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 Tue Feb 13 09:41:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp430249dyb; Tue, 13 Feb 2024 01:52:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUK28J8l/2z1axhw6icKWE/iUrnnsgEOvwB0i3iMqql0QqG0crsVidTsVwO1YQFjOczd1q X-Received: by 2002:a17:903:428d:b0:1da:2128:eb16 with SMTP id ju13-20020a170903428d00b001da2128eb16mr6014463plb.3.1707817959188; Tue, 13 Feb 2024 01:52:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817959; cv=pass; d=google.com; s=arc-20160816; b=R1PPpP4oIcOFjizckc0Y+ZJuchTmLpOlSDKyDy4VQvYTjk27gLaSwRdgOeibaMfh5g de4brkLgbI+Yu5QiCpQG5cD9nHfyb5/9IDc2auZLHOT1POwY6EF8rQqOgcRRmogv05G/ mTGByF6zFZ6DHylv7pMxDJGGCToTSIm1UqgiS9ZTN1xXWNorwHB//+x8DgU8VBUfWFrf lQ4v+wwYK1F3U+tCkYm23dVqGPYPlBpybrwozQTex6rZVymnQ0DbWPojA9HQYU9bE0tB juqSomJUFg8tMH3gcnzSKhI5bcz1zHTymm9eNAMD6QKIGubFX8FjoVPOknRjh8qrPXiU IgDw== 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=G3JEuLP9KTchU1G8nG9TZkkS8ubWydU8LFmKq7GO1a4=; fh=4YAf/tm+VkKmsuRdnS6DtZls7Epl8Tt4zA/EVx5vM2Q=; b=EOjXB4Z2CrLJ4kEjhpC/a02U4CuG8qiqjgIiObYuAJ+zswVD3XWB3CxjsAimXPi1eJ 2sRoxdcGsbe9HFvtY8Pa9P8b00Tbl7qeLPEzR434EdDEna0iJWgVp3TeBts6ENVLBvhH 84L+Q5A6zFB6AyKHcZ9AhOHlw4L++aBDMOTeOGapw8Yinfb6AHQCA2A/65hj/OYlgc1h bgfX1jDtjK7F6EN4lWsAqp5oRrwoWPR6UOZoVLOC5fwXvOW3HVvgjJ4xpkqgSJJkBqvc jiMDZRM/Wls7jHvFz9A2Q5FTz44kl628POiMFnBjghfZ2tqAj4zNDoInsTD3OfLwIgoP D83g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=omRoEFN+; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVtROiFnhuoQgZ2T29ztuOVfQ7ErppzK1JqKHYyHovX3IMhwr3/ZESqvOPvgIeOCOX/Is9PSvTidLgCLm93bT9fYgkcXQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j9-20020a170902da8900b001d3c375bff6si1834249plx.534.2024.02.13.01.52.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:52:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63250-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=omRoEFN+; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63250-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 0352B28D3B7 for ; Tue, 13 Feb 2024 09:48:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C611555C03; Tue, 13 Feb 2024 09:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="omRoEFN+" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 BE693405D8 for ; Tue, 13 Feb 2024 09:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817310; cv=none; b=k6p00F7E815FjCqGovTmYDGutBxv5v51iqZ7O+zTPGmSKcLdAH4U22IO7HqHXxMuLyduFMXsMBBUe7BlzuCzyM4B5zCid8jDclndWovb/mSsneXnxRf/CMmHv2b4nHH6PpWJjJHRBd9pZe69qhth3ylijlrFzLfonsseiUYxvMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817310; c=relaxed/simple; bh=EnYdAd19jAwWHKc4rTgfMXY+rwG0QS5c2MPhvFCHKqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uKtcn/lFju2LbWH4gC9ojrZpldUj6D4CKLhfQrl+Lyav8DVaoBf7kSAq3P7ICCsXkI3+KWQojp+lrxOZcyiALHTWOcNwCbIFwKjN1gMdCG4g4qrbdBSXWWeZKTl3uMVRzwjxeIRc5O5OK+koyUmth428n97mCV7olhdSqwqF9qc= 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=omRoEFN+; arc=none smtp.client-ip=209.85.167.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-lf1-f44.google.com with SMTP id 2adb3069b0e04-51183b02564so831250e87.0 for ; Tue, 13 Feb 2024 01:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817306; x=1708422106; 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=G3JEuLP9KTchU1G8nG9TZkkS8ubWydU8LFmKq7GO1a4=; b=omRoEFN+2yqeQi1bA+sjv6MlujBNCx1y1w0PZDpnguGfER1alEh5294XPfH94A9xgb Tm+dXO5nSjSoXmj+wek7QCLAf7BC94xOHsKegmk5Po6mbTJBP1pMcna8upPoOEDkPnXb h7qJwKtSF2e1jjwkqUH4M3eW+vBPJ2TWKGwM58cWe80oMO6nmF+5nScQo822q9mFdfDo kYQ4h+N3MVRWgnsrOg+v78qG+MmQxWktqg++9xHqV/IZXVz+X0UpYYrUsMOkeL3eJUlv yvNvvAZojz8RKC+I/C1okZilO7qIe7bJsUqO9vdPIlQ+tHiLpS7Jtj+Yej/4g8/VQfD6 /ugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817306; x=1708422106; 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=G3JEuLP9KTchU1G8nG9TZkkS8ubWydU8LFmKq7GO1a4=; b=O/mThp1r4BIf6psblgHalInErdKh2mgyW7/VsjAVY73922AWyj1exewPmUg0VwGdGz oIH7U+/Q59a635m2PDxug3BATfB5CZhbjSvXDLlgYW8ciexJ2O+ZNOMFPZdN6zRnUdFK /AA20Yp11k0QbX1ykjinF1OvvtZIbzejrVOELaNYo91JU9w0H9j8pJ7z3Z8Me6RTZpP0 O4dkdHwmBDH8niTcT8wSi23e5YHTS3NkPrUpiCNe40LKgeVkQC5e/totza9wsHnM38KK RHgi/6qYeyv3mqunHtDuUuz1tWMjVS8Z1vF6wXTiH/+uXBB3//Ov0H6DUo26Gz3+WCgP IaCg== X-Gm-Message-State: AOJu0YwBOGIoE+QCiYcH0833+OnvQtXl6ULvn+HYBAqHZIBudKV9nKHq +N+Nsn3lBaj07NXqul07hDbaQMzOfKFSfmZfGNVBCSftyZCswqBfINVC0DqXesM/IbZIreUPze+ G X-Received: by 2002:a05:6512:220a:b0:511:4860:425f with SMTP id h10-20020a056512220a00b005114860425fmr7089788lfu.17.1707817305969; Tue, 13 Feb 2024 01:41:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWpx/iWNTvhbGArJHuVS+xJtVDBJufLVxr9+Tyt6q2KGYNfq+yhlLx4uiyXm+TkwpNS3CUysf3vSYXi38naHoKvPpAbowAO+P5fGxT9bSLYvJyc2DD3TiEhttCmbE8KBc7wJKnO572OFuzeYUOjhlimSuFf0GqrXJEgiArhc9yLuDp+0JdHPWq4NWaSsOYvmWsbffxfYVbeXufF1FWC853KEJtWtOe8Ds79pIp5EmPlXapnRvpvqq9lPsu/8lVDUQjTfuAkzyRj/tasWdJSoGdVUxSSl88iNy/Z+gmgQgowR565dCVCM5Pso6uekM0nVfJEgTlRIoO3l2h62QWRWL4DU6NnahABqHrID55EWnPAkXzgNfQy Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:45 -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, biju.das.jz@bp.renesas.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 v3 4/6] net: ravb: Move the update of ndev->features to ravb_set_features() Date: Tue, 13 Feb 2024 11:41:08 +0200 Message-Id: <20240213094110.853155-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-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: 1790776924367446433 X-GMAIL-MSGID: 1790776924367446433 From: Claudiu Beznea Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth") introduced support for setting GbEth features. With this the IP-specific features update functions update the ndev->features individually. Next commits add runtime PM support for the ravb driver. The runtime PM implementation will enable/disable the IP clocks on the ravb_open()/ravb_close() functions. Accessing the IP registers with clocks disabled blocks the system. The ravb_set_features() function could be executed when the Ethernet interface is closed so we need to ensure we don't access IP registers while the interface is down when runtime PM support will be in place. For these, move the update of ndev->features to ravb_set_features() and make the IP-specific features set function return int. In this way we update the ndev->features only when the IP-specific features set function returns success and we can avoid code duplication when introducing runtime PM registers protection. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7a7f743a1fef..b3b91783bb7a 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2475,7 +2475,7 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu) return 0; } -static void ravb_set_rx_csum(struct net_device *ndev, bool enable) +static int ravb_set_rx_csum(struct net_device *ndev, bool enable) { struct ravb_private *priv = netdev_priv(ndev); unsigned long flags; @@ -2492,6 +2492,8 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) ravb_rcv_snd_enable(ndev); spin_unlock_irqrestore(&priv->lock, flags); + + return 0; } static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg, @@ -2542,7 +2544,6 @@ static int ravb_set_features_gbeth(struct net_device *ndev, goto done; } - ndev->features = features; done: spin_unlock_irqrestore(&priv->lock, flags); @@ -2557,8 +2558,6 @@ static int ravb_set_features_rcar(struct net_device *ndev, if (changed & NETIF_F_RXCSUM) ravb_set_rx_csum(ndev, features & NETIF_F_RXCSUM); - ndev->features = features; - return 0; } @@ -2567,8 +2566,15 @@ static int ravb_set_features(struct net_device *ndev, { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + int ret; - return info->set_feature(ndev, features); + ret = info->set_feature(ndev, features); + if (ret) + return ret; + + ndev->features = features; + + return 0; } static const struct net_device_ops ravb_netdev_ops = { From patchwork Tue Feb 13 09:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200305 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp428846dyb; Tue, 13 Feb 2024 01:48:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFN/mYoWZz7ZbIGgRBqfcaJCWdPKufntC5VqBaOmQcy5uy0HUgu/oQ7wAuSO8YKxxeVSDsG X-Received: by 2002:a05:622a:350:b0:42b:ff40:a6b0 with SMTP id r16-20020a05622a035000b0042bff40a6b0mr12266261qtw.40.1707817731462; Tue, 13 Feb 2024 01:48:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817731; cv=pass; d=google.com; s=arc-20160816; b=j2QyOixM9MF2wB5NuIU8DjCD9Fx9lBsWDcLdzUwjN9FP3mg38r0u/jJeIrl0A3LD6C +V6JuTo00GxgJQCWPAm2+febBsOZwgopbWRV3wyIoQqn9IF0r8oXh0NdADBwWaHSAHDZ wDynfF1BMzb2Jb3D/b/7lBt/2AXMYqMWo7MHuy4MTQluRT6a5NYEu/R3g4n2E2Vj+uEx mL2YMR7LqJ5IXHMr0aCeU6HOMWtrgPZdLAkc9GbgAP28z1b4ObHhwWqHep3/FcQOlkgn o1LGFKUtqOWzCPwQVgY6iMOTJ9QTa+/4pAlLWhQf/mT8Wzt+VyF9D8H/2y8HwZtUBeJl LeaQ== 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=jjpBbInCxVXMckDKlb1X2pBcFBDdY3zPqFanpTI/+i4=; fh=j2JAcjmH9dLoLZCZlV6mfCD0bH+0biNjs0NGsgKTjcY=; b=CYYUoKFQv1FUhq13uR30i4IYJemaqFwnHjh5lVj13soiMyM6lLR2U5xZgopYrbTWy2 eR+K/iZ43twN6CAgoV7iltd9LU4SsOt6lQktPV5fazVed0co4xGfvKayJX3W60NlFJCy Qgq2csVjLon4cXgzK5+aimx19USlvfrN/gtMHIzPAR2rYsjPzUz7JcoqIrmG9TuqdeQ5 C5nd8HIPC+3ujIe7cgueekaCODczuQevjQYMabHfxoNGVgM4usmeZAW6UgpR1fJMvtZ6 snc0wr/SHLIHvYtTNKeHjZ2SLIl15CD5ckUXnJ2IkqCy4hNHAhbxSVWC2sjhpFnobs5s W/sA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=avw8iUbx; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63251-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63251-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUpbvi6LUoaLRPuZLeyhugai6U0QdIe63ETyWiDDqVTrOvGRE2poihsBKS7GIZJyHm7HnTVPUDELG4ZcnJdnbgyD8ao3g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z9-20020ac87f89000000b0042db2599568si251189qtj.764.2024.02.13.01.48.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:48:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63251-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=avw8iUbx; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63251-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63251-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 3516D1C20159 for ; Tue, 13 Feb 2024 09:48:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B3B155C0F; Tue, 13 Feb 2024 09:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="avw8iUbx" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.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 07E30524C2 for ; Tue, 13 Feb 2024 09:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817310; cv=none; b=gi281XROXuNG2+sTWqfmmAyUIfSw4T+C9zBGjDnXC241ZZJIQrLG2GU67BU5+9ojQfdJnBieWZX9VhlIdOBShjPRFlzxKlfjYJ5GFGeGMC5VcjHM3Xxuk8aX8yDzQH2GAGOWyLUKqRNHmh+uwN1tyDRPOF1rdWxeUS5bJ66HFG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817310; c=relaxed/simple; bh=WV8FSkl5YwYxmgU6Z/VKljzD29i9dc9v4Oo9UOpnmTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WwJO137uVXu1ORZDdwdDPJ7rg1sVeGZ0AGG0FdgeEDQ2tRNbxffKDjW5kYkkUTKp5iIis0BBSyK8vzr/tX7hcZoIAexS5wTLC4dahHSa92mCroBVEANOVLKYDRbdU4JWdrH8XL5XYdGfevnv0Twt7lEp9xVSBazZYdGVv541dpU= 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=avw8iUbx; arc=none smtp.client-ip=209.85.128.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-wm1-f47.google.com with SMTP id 5b1f17b1804b1-411a5b8765bso6520835e9.1 for ; Tue, 13 Feb 2024 01:41:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817307; x=1708422107; 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=jjpBbInCxVXMckDKlb1X2pBcFBDdY3zPqFanpTI/+i4=; b=avw8iUbxPkxL4+oaJHW0LrSkUDZ30IXRe5YUHL7EbRmsEHqaDbNVT3RD13sj1hsv1N Q05QMNcdwJx5Xk7UAFHWUyG5Dp7WRKVgQ+dAS0Ow/w+qUejBphbdU8PQiVwRLnllEe5g 22iG/sJzjke2wttb5DDAcEB+oaufabkIc111LhWn+oYpvudbNpVZQc2OBlWdSV/6/9nY o2EZYDFi4WMOwAbLM6XWWGgCbnYc2CgLg8j61a1t8rNm87Y5ZaUBjxUJxV6bhz/fOSWv y78Xwlk3a8kz1iE4P0+1OwoNA4leI2vqk16Mr8H+ltCdh9lElh93xNHfIgfMp7uTOiW/ LGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817307; x=1708422107; 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=jjpBbInCxVXMckDKlb1X2pBcFBDdY3zPqFanpTI/+i4=; b=laQuTlx9TB4L77hNhiuUoK7tVXTuG6nNWapMq8NOIcP4Lz9klwaxkAy6Xa+2rxxEZK 7KuwyUA/fuP7dYlgBW1CaMVPr+E9isaXojbsRv1/mXH65KZbH8+WtRf9oisVW7Zahr1U P1JqaSItLiT7M6q5Nr54tPuPF4QTdfiytN2EKl/ZYA8CWzX6uNogfSjSysjxzMm4elEf zgs/p7LcFQP4UASsF8cUjINjFQ1EFfgFyQ7S06TBN+aJ8ydADxC0ouldxuO+C/kbeeWX vYM7MWy1U/Mw3dAZsZenHwrGhZbBds2ewwpEAA0lwHmLAMq89XHV8b9m4EsEP7OYC85f uhyA== X-Gm-Message-State: AOJu0YzGlQWOZs8WUk54bMGWz38J94RPDqb+dYOee1GTrAhZY+1+FTA6 N7+W7sIXXflr6Smlv1AZP2AHPjOx3yoTpdjgFMGvdzy/8x3NqhiQ8tUkIVI6SvI= X-Received: by 2002:a05:600c:1d1c:b0:411:50aa:110c with SMTP id l28-20020a05600c1d1c00b0041150aa110cmr1737496wms.12.1707817307225; Tue, 13 Feb 2024 01:41:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVu4bAcAhu3dzF1s6vl2Da30WVZxWiUvmrTiLoQvpFkuWYVuwImENr83RFlEORbdTcYMKPR/wq+OmyR70o1CKQH7BGQRdQo+qx0+f1Lhx4fdl9ghJBog4sE3Tfr82cigYgVQPNhj4NsRr9+0fGaj//HuhzWqfZmIXIXLaZPSfpctCZpB378rFBD12xDr1lBENW0kqn6FhfxzyhQ9W1m1qnR4b/w+8INO1hENq5NH0IF2n+w8FPocz32Jc1M54QOXK7aZIsoEk/6nQlbWr9hkC+9dyzM72t4qxABfnxE7hIPzxJ3UQ4TP8vUg4tD0w7+zQSPsBzfGIR2+KfmqQAxzkuKfLhnwCTeEhB5OiopPhdd8StyTb+g Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:46 -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, biju.das.jz@bp.renesas.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 v3 5/6] net: ravb: Do not apply features to hardware if the interface is down Date: Tue, 13 Feb 2024 11:41:09 +0200 Message-Id: <20240213094110.853155-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-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: 1790776685415540070 X-GMAIL-MSGID: 1790776685415540070 From: Claudiu Beznea Do not apply features 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 features and apply them in ravb_open() through ravb_emac_init(). To avoid accessing the hardware while the interface is down pm_runtime_active() check was introduced. Along with it 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 in v3: - updated patch title and description - updated patch content due to patch 4/6 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 drivers/net/ethernet/renesas/ravb_main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index b3b91783bb7a..4dd0520dea90 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2566,15 +2566,23 @@ static int ravb_set_features(struct net_device *ndev, { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - int ret; + struct device *dev = &priv->pdev->dev; + int ret = 0; + + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_set_features; ret = info->set_feature(ndev, features); if (ret) - return ret; + goto out_rpm_put; +out_set_features: ndev->features = features; - - return 0; +out_rpm_put: + pm_runtime_put_noidle(dev); + return ret; } static const struct net_device_ops ravb_netdev_ops = { From patchwork Tue Feb 13 09:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp430442dyb; Tue, 13 Feb 2024 01:52:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOAjic1pGHROikWKus8oSi83hT39qmtN35SM0s2rSYmpOaqF8NzLvzuaW4rHyoR48O3C+LnAaw1Gm15C9GjCEElGg67g== X-Google-Smtp-Source: AGHT+IFzrJd0swE/p6+7CdcFdzHW+h/Pa76IjYwJ60KRH+Jk0SyPkNtKQTOalxBsAOI1xd9NpWD5 X-Received: by 2002:a05:6a00:3243:b0:6df:eb95:2c78 with SMTP id bn3-20020a056a00324300b006dfeb952c78mr8342339pfb.10.1707817977087; Tue, 13 Feb 2024 01:52:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817977; cv=pass; d=google.com; s=arc-20160816; b=j/AtjidDXqE2JPG30AYzGRkKaa4s2A03U4ZAHN15YdqQwY7SGtcBufbxdaWVJjNUg7 CsC1C2RAWd5BV9OAqRAve3L0vZfO8uOWeAy9dkIN1SfH1GoVzRCZoFeBmItKD2M1hwkb 0X7hehKdxO9ASYWUKx2VSOxVU/bsoyYR3LG8RlR5ibdU+vpLxPgaeHxTRnH8OMPaxuiH qCbd+dgEYlCPMoYvNxmjLtcFa8N+XaffVfNUHjBDF3UzX24Hh2omTMfZHmdk43TS0qpI 5bWmBLNybglpnVo3Ri94xJ4eXTzWST2xOXGoG1ZM4TSZqLCqNTisMzbbk6lAhGF8he5C XF7g== 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=J4yzSzCHL5tZEjla4g9SMO0ApNhYh0fsLQEGXJT8U68=; fh=7VEzVhqEqvE1RznQy6Dyu0Bbr2wwuyGo0j0ZR9QDOGA=; b=yxdsOLMw8vYYnuTHDVLwUK3lB/jT7EGIhEN7OR7Ghwq5hV1SB7FE1RaJbicWFBSikS Yz2qK3AT07AMzzwcqvahp5QsbPy2CnsZNgd8qWWo4DI3PQNIxJWHxnM5F6+spBj8CAK5 vpH4MCPq6pHclXuM/wBu318lVnF6FzPNkzoyFtB2IV6S1tyIRNZ9rphWufi1CK5Dkm3n MiMt6H5jK4b6gRcJsWX8dLzr9Y1KzLvQw+AySgUbQ53v9O9zykeQ4Xs35qIMZ/T2Irb+ NM2cHjiTxElV92EH50OZWF1lkwJ8K6qZSpCFSM6p71ZuSEdfps8w3VaRfGUMGEKj4wCh DQ/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=jbKsIs1S; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63252-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63252-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWvQ7WhEwbG/Ih7Yt2HRWRiZG5SGj25ISRV9jmvsi33cjb67WBZeQuDbPLs8HT0QYvCT8pvjBjTFE1fwS1s333l2SoOcA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y18-20020a637d12000000b005dc7e96d5e7si1545839pgc.532.2024.02.13.01.52.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:52:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63252-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=jbKsIs1S; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63252-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63252-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 658812893A8 for ; Tue, 13 Feb 2024 09:49:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5627C55E62; Tue, 13 Feb 2024 09:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="jbKsIs1S" 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 53BBA54BCB for ; Tue, 13 Feb 2024 09:41:50 +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=1707817312; cv=none; b=Qqg4oSHTWbV4jzMDBXh1xR19ryzrbfi9Mz9tJ7MzR2JNdeQ7awyK2a08RNhBCS2wZ63Aoe6aQOXi0p3obwxb7vruJiR8oKS8zMRjVEuLMQ+VH0CRJbDr6MPTwuFGmOQEK9tUmFIsksdmMQTYlCHVHmIz2RA69MS/MjGooFsl60k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817312; c=relaxed/simple; bh=fmzS2Yan2keHs53R4x+qMd55iIATYx4wBLC/B6HhXB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Smx+M6sVWBVJdAuDqLMVo9zvSgUIWGJvw6f3Jyw1pUeVrQWNWG1BSe3VyqecGXGtBBPG7ZN4fBO17IzRxV/JIxtFvlmgzEfcMEgLErvdgU9Ij9nEWPyyhTBZ9mDyAansDtpu8AjqRWQ4b8Y1WZ8az3aee4LerGRDj54VApOt/oY= 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=jbKsIs1S; 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-51176eb6a4bso4134279e87.3 for ; Tue, 13 Feb 2024 01:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817308; x=1708422108; 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=J4yzSzCHL5tZEjla4g9SMO0ApNhYh0fsLQEGXJT8U68=; b=jbKsIs1SclKnjQ5ATPFcUEyiVmAx1FZPlVLf2181zVTwPJpFSHQNcNIRMNY4Vu04b5 xmW3s1Lam6j2AfH1kmsxH5NXcjxZZIGoW8+VzwySDqHhrtlx6VXjLy4npok3kfDjQc1K zuipQK9sYk2fx8gGie8vsJO0QRju6wygmGsxj0NIE9ey8xRhJWOoxrPVfvajHC6R+zTJ 84ypKKKvBCkq9fg1e8K6uXuhEZ2Zt2CiKq15wPkimPsixDzE0HGQIW0ILecw8aTyAsyb m9p6nok9uE1iUEz5yvo7ZGCRCH+Qp7PXPGk1G4R55vGDp8kwu17hSRoVaLmdcmwWdMSe zKNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817308; x=1708422108; 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=J4yzSzCHL5tZEjla4g9SMO0ApNhYh0fsLQEGXJT8U68=; b=dl8q4aBErCUA/Lf/UYjDYZQJ4AAMzRit/MafVKmmVmF5TwQtSrzmdwBkG28opU/U4F gI8gXC1En2RdqhB6+0sFPRCWFUJP5m0I58khstNI8n0Upb6oOcpYYUzL6R6yOEugnBp2 w4IJe+sKQTbUa3zrTczz7E3vS0/u1wPoj2qzgLtNwz0H/o3p4SXZuWSL/9p4gbwmtap6 Cr0OzQvCK1I6qx9D5gPHMu/wSk+P0TZe3r5dWINqW5mn7innsHMrW5AUOHLgUrBt2FsI NqiZf5++x2h1/AIV8qfnXxz+mtU48ZDRgaiLdWJENNeKqYtZLbV6BzD/zOT0xS4MBDlP Lg8w== X-Forwarded-Encrypted: i=1; AJvYcCXNicN0yj571/sdJruz/d1xhR1mn4nccrnooFk+pPkTrF61tPsdFJO1bMrejq5ra1FZ33t52+FQBhqPlVOZZeXzy2aDySBIvL6vtMaC X-Gm-Message-State: AOJu0YxJeimIpTawKT+rReYKn0mH34axC939X3DlPGbSBn21dowBvVI+ aa6nK7ayKeGOG4bs/358FN7XQ+One0BWTYA0CmnUSJXBGMO66wfzDYIvpofxEBY= X-Received: by 2002:a05:6512:eaa:b0:511:87b4:d01 with SMTP id bi42-20020a0565120eaa00b0051187b40d01mr5770164lfb.27.1707817308520; Tue, 13 Feb 2024 01:41:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUL7UtBYOYE16wvxX8CYyA+8ywuXQvbt/fW3DEuuyGoO7IhMSzDZacgkkn+aMm0J28D3Vq0lJU2IVf+dCi/Q+SDQP3yGeqXBijeWPFMNrjplKQU6PIGO2zNHaf6maqZ3NTGOX5BS8x0HUpuVT27f7uxK5TH+vb6BDo8lquohy0GlrVtP/R4I32TGqCPpcLVy4Tc8UWzuzx9ztMgYGPfJORaLUKmQwgfF4J35ev3hCS7hNUuMPP5s8k2F/67ZrR9gYQp2OFg523ehSWDtOBEo4mHyIk9xYq+Nn1+0Y+ZLhHwmy8L/qq57GY8v1njFDzphUF3T5H9BeTiVt5DSO2914NCNBM1De6A0ea35WH7TLXLAXdDtiv4 Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:48 -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, biju.das.jz@bp.renesas.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 v3 6/6] net: ravb: Add runtime PM support Date: Tue, 13 Feb 2024 11:41:10 +0200 Message-Id: <20240213094110.853155-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-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: 1790776943130713990 X-GMAIL-MSGID: 1790776943130713990 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 register contents 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 register 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 v3: - fixed typo in patch description 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 4dd0520dea90..1d3de2e3f917 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) @@ -2927,6 +2944,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) @@ -3032,6 +3051,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: @@ -3049,6 +3071,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); @@ -3062,6 +3085,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) @@ -3073,8 +3102,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); @@ -3156,6 +3186,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); } @@ -3178,16 +3212,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; }