From patchwork Fri Feb 2 08:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542425 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 2ADE15FBAA for ; Fri, 2 Feb 2024 08:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863315; cv=none; b=h6DgsZhWAnKOY7STxm+GXvpDQwO7PUZItQzoyB9ibW1GuVkjWsA+NIlN54prGrJRxx3iXPOs2m+vbyYtxZNNwX/NY4b0VY43wOuCSmNxSscxo/Umm1vPxB2rbUK3hsollkkUvp0HMEab1iodZmbp2A8ge7jXsrpfyB2T2EfFc2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863315; c=relaxed/simple; bh=wUt008c4L4wlWChR09y86kFZe0k8vYYcMrzbja33YqA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KFq6qEQHqdaup1vbtX8fSBF1c9a3RFjX1OsJm62BzBMSjNXseoHra6pxEKVr3skayJaUYKSk+y/XYEneNa2HTU41vAAUOAV01cJ+JcvgcVbE6vVHWBG1irnCkDKyuXOG+j7wYxe2SvLfYRT+YeCCB4Vb9izNmBP2cQfcGZleRrg= 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=T85UdcKD; arc=none smtp.client-ip=209.85.218.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="T85UdcKD" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a3651c87ebbso241540366b.1 for ; Fri, 02 Feb 2024 00:41:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863311; x=1707468111; 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=RE3Yoz85yiYAVvN91TcvWq86ovnNeno6HjqJQHeUHx8=; b=T85UdcKD+8vJ8yixlQP8Th3sYh7/jVZr5hLj/LkoAtEwgE8bgvNNL/vaatvbCbEGmQ BFJxT2Gu4t9nD56jnWHH/RaIHkVAAD9JU6B+2MQPCYPZo2sTXaZ8pBUGwaLXmExHYYCI JseBEL5hUab7c85530ethYFHH+spLePbz8rVm+XsaIQUcjnMPDXxa3FARPtjEBYR2fxK 6dGFA4daOVZhaI/OIfxMxYD7eajP/2/hTAuR3laMeUTInpd6QYvR76nzSLf8C17s12zL +7s1YhTJb2eR0LNG84GoXvvDzx6hOlHhnYHIYgorSD9v+sbp+RV5XgzxCOGbSOcWOH9E o7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863311; x=1707468111; 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=RE3Yoz85yiYAVvN91TcvWq86ovnNeno6HjqJQHeUHx8=; b=FL18WgsIwF9UXvj7otXohsq02QKUcNsnQ1BU9++nKo/c8+jkpi0GzWF66q2dI0ndv5 9S6rmfwAmOZoRcYkGT0OYWB3tXr040ERcKxYS6ria4twwlAN74DXDAwjfCNNJT3qC329 RfJyP/5VjJw8LI+x62R/YImWLm4jGHcpsYuWp3GSZgKTgde/3tIILm+rwrgI20yEeMGr lZ2GemOmPhgZbXycRZA8NY/UnXLOlz7GM8021rueyt5qVvnyHsTy7rmuEnM0u/GL3DMk JsRBx0jLdXfBs51Q6MWboyS9gkjDqLgXauggb5z68yZIFy2l3H7t/WRvEndD970SKntA pYbg== X-Gm-Message-State: AOJu0YxtbuZNsTWHqpeqopqzKzzkwXWhVUtg5gA4f6Xk776PnRWatAUG GkO6JFQFAimM/OGY2S/P0PmomqfYLiiYGT05a+8WRUSHtFW6wbcdmBnkHARnP8w= X-Google-Smtp-Source: AGHT+IF8povdNsKSI35kMnRnKqE2z3dt93rHDNgUs8u51yEI5gUvxpyTHQLAX54KHZPCyKsMbiR06g== X-Received: by 2002:a17:906:22d6:b0:a36:c845:86c2 with SMTP id q22-20020a17090622d600b00a36c84586c2mr2526641eja.51.1706863311112; Fri, 02 Feb 2024 00:41:51 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVeHQOh1G4LEVqjRkdvhRLVQzvENNq8LEhYiaIEyOycmk6CK1qYr9CNCrw6JOSTKXDnRw7lhb3ZTxKz8YA1cXWMnRvkNmkg10Bt5RyibQC1y2zJU11WEfStrcBcEEGL8UtSoKe685JjVbgobn5LanbWnA4cEeaLaL3Zb5HW+seY/3//isEubEGzfGZcCXX9bklqZQIHkBOOf7CgMNAdEqY13g5kyRYXgGTqnZV+RWN8xwNTCUwjVtjhpJOefzVO4bvFRWVT9DpvLJHhpZwa6uqruQEi78RWk2MHFRlCQ5xHmnh32qump0pIAvxyzkvwTWEMO52FWMIMKHc/eJfeLaY6P04ifPqXduXRv51ZiZhfDTT2rv6GGXBT5YCz7fW1TZ8Ehave8b7V2OOJHw== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:41:50 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 01/15] net: ravb: Let IP-specific receive function to interrogate descriptors Date: Fri, 2 Feb 2024 10:41:22 +0200 Message-Id: <20240202084136.3426492-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea ravb_poll() initial code used to interrogate the first descriptor of the RX queue in case gPTP is false to determine if ravb_rx() should be called. This is done for non-gPTP IPs. For gPTP IPs the driver PTP-specific information was used to determine if receive function should be called. As every IP has its own receive function that interrogates the RX descriptors list in the same way the ravb_poll() was doing there is no need to double check this in ravb_poll(). Removing the code from ravb_poll() leads to a cleaner code. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - collected Sergey's tag Changes in v2: - addressed review comments and keep stale code out of this patch drivers/net/ethernet/renesas/ravb_main.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0e3731f50fc2..d371c4bed634 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1288,25 +1288,16 @@ static int ravb_poll(struct napi_struct *napi, int budget) struct net_device *ndev = napi->dev; struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - bool gptp = info->gptp || info->ccc_gac; - struct ravb_rx_desc *desc; unsigned long flags; int q = napi - priv->napi; int mask = BIT(q); int quota = budget; - unsigned int entry; - if (!gptp) { - entry = priv->cur_rx[q] % priv->num_rx_ring[q]; - desc = &priv->gbeth_rx_ring[entry]; - } /* Processing RX Descriptor Ring */ /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); - if (gptp || desc->die_dt != DT_FEMPTY) { - if (ravb_rx(ndev, "a, q)) - goto out; - } + if (ravb_rx(ndev, "a, q)) + goto out; /* Processing TX Descriptor Ring */ spin_lock_irqsave(&priv->lock, flags); From patchwork Fri Feb 2 08:41:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542426 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 C83D95FDDC for ; Fri, 2 Feb 2024 08:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863316; cv=none; b=QT1NASUqtoJ5NvXtDUsI1CvYSLjUMR/rfpXzH4dqdH5qtyRCpPEd0wtvclpyVd9an5f1AmlM0JX8XdqOLyIFU24/D+rRjBSJI8ZP5W+Y2GNyepmFnOXuoffdq8XpWEczVHMuDfKmqnhq6tde1iJS4Uc1Aud78H81QUex2BJ42Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863316; c=relaxed/simple; bh=c8nXesotZMA9LnHdIJYZ8HFoGcP/JrAFcXSleBRLlFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KWatNw+bQmHdMXZQKaMPLD4pmqNq2Z8Z2aD80K2qlFl7e3W4SLEfvKCjkjXKyqupgg19+Ip7pRZBBwyZLn9Lh1x16hanR0aXwFufGbdjqeLqafzKsarc9VbffY+CfzcA3dOyE2clIoLQOrncplpApshzTzF0pdqIuXuFR91PnIo= 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=amGSXTrI; arc=none smtp.client-ip=209.85.218.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="amGSXTrI" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a318ccfe412so202558466b.1 for ; Fri, 02 Feb 2024 00:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863313; x=1707468113; 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=hdLMh/tNWDl5PwogMkAYZJ3cvD9jAZpIph9cVcEu3a0=; b=amGSXTrIaTqr2QhMIcjJwSOeeC2knmiWJ3HIyaiihB2lDPLODmcPJ+8DoGI1XSClpN C0TdwaPgEhhq6S40KZtM7XR42fbKUGZq2DoKUS+6u62V2kgtdjmyA32hjMvpNvHvjCuY tlJPaIKXWaz0t1+ln9n82DoabcSf0HXEFVF/XU56W42SkncoJJqmhdxby8a/eYo8+BJ7 dxjyl5DBnXJ6iUgje8wKwy6MS10PRj4Z/DmJcaot0e8s54yn/yptjVa2sb3A9EDgZquw Ck0oqCqUD7pJo5FMJe9CycW1MRBnY5NUp6vOUj4xQfoAZVqBb+RWAu9HBiUEkW/2SGwt mMeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863313; x=1707468113; 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=hdLMh/tNWDl5PwogMkAYZJ3cvD9jAZpIph9cVcEu3a0=; b=Gn9LkgvFCkTZdQSUiOdKWuZ2BKxP4rdM5SBTrwCtHHqiQVHX4AgUXgmdK+yh4VrMFp fdNCX7ijFNBVbmCpMKynbhiX+xs3XIX/OhwMttpcPrprIoVWUoWt1ZSVCfNSv/qLa/b8 lumZRrcfWeWSa+DLZ7fPAs98xqQxHVdKiyciVyPXjCsw7g+KdBIDuCheTcyUUAuzVhW8 K7v8yhItIsjZZKCUzODKV06ievtD5q7za/J7cMsVMVVyknaZiep4YN+SnBpJFTYlDNaD ABG4szsObfXeUzF6M270hbA2zaNKdyEtp9ejCWyVVtdGFnQNe78rSQFoMdKER5FUNLEh WNrA== X-Gm-Message-State: AOJu0Yy7k/yO0pEAQbrRSi/3/IJYqEqmTHTPtsSb+m8Z+lRCA/oZmsEl aXvOKoKK/7dLmWR9U8Mmk3z1ZxSPk+DnnmRpFakapvUMuhBdoXT2kW1iRyhUKRI= X-Google-Smtp-Source: AGHT+IEdxlZTup5lj+7djepr9X3NdWPssDNnsmV/JnqbxJuwWZ8VOhFN/E5iydxNwcEbW60qkwgG7A== X-Received: by 2002:a17:906:ca02:b0:a35:e9f1:9690 with SMTP id jt2-20020a170906ca0200b00a35e9f19690mr920331ejb.22.1706863313115; Fri, 02 Feb 2024 00:41:53 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVfy15tUjasHj3//aTI47mw3wKkfTJRaD/iGcE9BYbd9ZCTps8ujpQuUHjWiVec+S37MBzd6UIFP+2PFuVcl3b8fL0Xh/NY4qyUW06XAJbjLgUk59TIkVgMkSEfKTwTLVEEuXoRh93d+jOP929HLouK+U3rkOlKTeWXy9La71WB9cB2DfRHNnHiGFYJfHEIyuvOTtrNJcd/pC76K7ljp+SPac48n4Lh7W2fwGQ2VjkHP7OsqVtiLrF8e6wjslfwcL8++vTAbQ7Jj94FJSG24nUAL6Cgqo0TfbjzsYzXY1VsEckL5p+W/5monxmX6TWD8l/vL4nsdubaRNeNHqJZjaP4dWNfCJOHyCKAe1o24SInuZ35ovI4KKe34tEA8IC4cfi6lFwBaX4JrS0CSA== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:41:52 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 02/15] net: ravb: Rely on PM domain to enable gptp_clk Date: Fri, 2 Feb 2024 10:41:23 +0200 Message-Id: <20240202084136.3426492-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea ravb_rzv2m_hw_info::gptp_ref_clk is enabled only for RZ/V2M. RZ/V2M is an ARM64-based device which selects power domains by default and CONFIG_PM. The RZ/V2M Ethernet DT node has proper power-domain binding available in device tree from the commit that added the Ethernet node. (4872ca1f92b0 ("arm64: dts: renesas: r9a09g011: Add ethernet nodes")). Power domain support was available in the rzg2l-cpg.c driver when the Ethernet DT node has been enabled in RZ/V2M device tree. (ef3c613ccd68 ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC")). Thus, remove the explicit clock enable for gptp_clk (and treat it as the other clocks are treated) as it is not needed and removing it doesn't break the ABI according to the above explanations. By removing the enable/disable operation from the driver we can add runtime PM support (which operates on clocks) w/o the need to handle the gptp_clk in the Ethernet driver functions like ravb_runtime_nop(). PM domain does all that is needed. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index d371c4bed634..3181fa73aa32 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2780,7 +2780,6 @@ static int ravb_probe(struct platform_device *pdev) error = PTR_ERR(priv->gptp_clk); goto out_disable_refclk; } - clk_prepare_enable(priv->gptp_clk); } ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); @@ -2800,13 +2799,13 @@ static int ravb_probe(struct platform_device *pdev) /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; if (info->gptp || info->ccc_gac) { /* Set GTI value */ error = ravb_set_gti(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); @@ -2826,7 +2825,7 @@ static int ravb_probe(struct platform_device *pdev) "Cannot allocate desc base address table (size %d bytes)\n", priv->desc_bat_size); error = -ENOMEM; - goto out_disable_gptp_clk; + goto out_disable_refclk; } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; @@ -2889,8 +2888,6 @@ static int ravb_probe(struct platform_device *pdev) /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev); -out_disable_gptp_clk: - clk_disable_unprepare(priv->gptp_clk); out_disable_refclk: clk_disable_unprepare(priv->refclk); out_release: @@ -2925,7 +2922,6 @@ static void ravb_remove(struct platform_device *pdev) ravb_set_opmode(ndev, CCC_OPC_RESET); - clk_disable_unprepare(priv->gptp_clk); clk_disable_unprepare(priv->refclk); pm_runtime_put_sync(&pdev->dev); From patchwork Fri Feb 2 08:41:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542427 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 10A526025B for ; Fri, 2 Feb 2024 08:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863319; cv=none; b=tA+ftwlYHs9SIQCpGN9hGJCqcRNWHNcojAZQjyb4U9xnw+T6UpeypMws/wYNRumUs41h310YPC+HxumELDQl0g5JwCTe5H+MFdn5uvPu03osXTFRR+0rr25tGzJMnJGSpb6a1HKYXhyLnPsVBeY2lxMJhIev5WoKaU53YWMzrTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863319; c=relaxed/simple; bh=b56D2CY5bgg4QkrVUzroUfj/0+2LJ8RI6nI9KNFOMcs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g+r77DEu9aGlXtpD5yj1oMB2ZCglWYiOtrZ7arnVK5tKgyysnkEbI3Mv19XTn7ZcfOfdOhlhWPJSjtxyBvJNxBRVi2DSnPAvUwPTVpPmyQis3o+bS7ajl9P21bSV1XzHA0rD28AQTpc5gRFG/ShFjhqU3IW8SszJpc1JBSI65hs= 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=L6utNQ+u; arc=none smtp.client-ip=209.85.218.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="L6utNQ+u" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a318ccfe412so202562166b.1 for ; Fri, 02 Feb 2024 00:41:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863315; x=1707468115; 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=jzGt+E15n9CkIZ0b5NiVKi9D2q0/fFc8ybljSM9HrP0=; b=L6utNQ+utTtHZ1bk0qxAIouJtFmh7SFKayws8R2qWPQMEsljKB0NJ9I7IYU/kjG359 12TBxX7EVyJDH4WPBNYCfhKpsc5NVRONP4VezyE3+Q3ihol1Rt8Xlnd6gPx3OesoctEw 6ok7wAXO7KpFwuLkjEswenn5jz09+K1ddeeE+2lmH9KHG9vrkV9Rr8J67WBks+DEg9yM GUyLpnKqnND2IaUuR9Z1y1XNcrBpmKKUGtuP/kYbKR0FXXmHqnCYeVp8uVbTpCPwRmWi AJYfsKsOv5FQSVrNkG2c7dOccLlXzXjgWSkr+dgxSsZXTZD2BAbDZwTq86W+raOPz58Q 9Dbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863315; x=1707468115; 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=jzGt+E15n9CkIZ0b5NiVKi9D2q0/fFc8ybljSM9HrP0=; b=ly0uQGxLy9pkiSxm++qPADpdUvnqfrZt2nhlAGNltNsEYz2MpuiAIADUzOV3xempq8 4UNTqtKVB3ZkL2aT3vxqvOqQk4a4KDhfyZPizJKOJIDXiAiKcq9wIUqS2JTu6DsdGFZQ c5mJ10cGWt82e6r9sZeJ1DShXG3od7FaRvOQZI+hrWwUhHtSMWznqSw0S7aEAG9uNLeQ ooIQJ8tw1bgBnmxRmiwiIhLv/W2OiHuv8SyIydCAl2YRmZLOm2d5nIs+FZjg818VjzbW 5H0A03AGTrPOQy5xsTuuXFsr145rIin3+V6QnbRuCEALr8xR1vEOWzCq3yMzdIhgqFhg 8Wfg== X-Gm-Message-State: AOJu0YycZPwT3WjD2xeb6H/nM7cGABougQCp/dbT33GhwAmkTxJyxC0O 0VCNVfHJGtb3pey5xmAgXwkbRWBHfr5nFO6v2fgo/lG0EOHlGMlra3ML3S4O9mY= X-Google-Smtp-Source: AGHT+IE/pWJ574ClsrBeTk7aSvxb2/16S2ptiIy1yUNi6iNmqVmV3gn75wwbIVLVtrT+d481lsT/jw== X-Received: by 2002:a17:907:86a3:b0:a31:8b26:47ee with SMTP id qa35-20020a17090786a300b00a318b2647eemr1334170ejc.55.1706863315094; Fri, 02 Feb 2024 00:41:55 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWAqdCcHyQcWt8vvzEoffySZ6yJH3Lr1cgLPpEFkCZo7AA50MSHHvBLXjml76UBdsAwtcsz8MZ44TC3Z670P+HueNHtoFI4O5I8eRgQqFWAh53lHtohU1yz9uQmCdbbBqTY3HcQm6yJeCgrP1EI0S0LVc7u55iTIZONqU8Z8BwO5vcSF+GLI4Xs9WXsynqGq6BoOfMo2FaF48kNejkzz43DqSso7rUIVabixSi5nQK+YljHsTaEyrGLsSqoHeMBKtzVSnrpFlPj9spNeQ3kLA+SAWMCHZcnUqBeZlVVC0F8xXQ+Ez4YSKwIY5galpiKeJc1dMlPtiWJtYYea9Mxf0WOgwxn1d1eEl6VW9SkNkEtsWdMGjCjZhyl8b92rlKL+SMrYrijTj2yZMZM3Q== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:41:54 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 03/15] net: ravb: Make reset controller support mandatory Date: Fri, 2 Feb 2024 10:41:24 +0200 Message-Id: <20240202084136.3426492-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea On the RZ/G3S SoC the reset controller is mandatory for the IP to work. The device tree binding documentation for the ravb driver specifies that the resets are mandatory. Based on this, make the resets mandatory also in driver for all ravb devices. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Change in v5: - none Changes in v4: - select RESET_CONTROLLER - dropped Geert Rb as I changed the patch again according to his indication Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/Kconfig | 1 + drivers/net/ethernet/renesas/ravb_main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig index d6136fe5c206..b03fae7a0f72 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig @@ -34,6 +34,7 @@ config RAVB select MII select MDIO_BITBANG select PHYLIB + select RESET_CONTROLLER help Renesas Ethernet AVB device driver. diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 3181fa73aa32..fd431f1a0b98 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2645,7 +2645,7 @@ static int ravb_probe(struct platform_device *pdev) return -EINVAL; } - rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(rstc)) return dev_err_probe(&pdev->dev, PTR_ERR(rstc), "failed to get cpg reset\n"); From patchwork Fri Feb 2 08:41:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542428 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.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 316E76087A for ; Fri, 2 Feb 2024 08:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863321; cv=none; b=hHTWskkuU8+Y2PGQ390P/Cb6ecfOyMrHqLOxZwd7eajIWAMgPt6wAIptAXsWHUQK9JqTksvnuf08B0d0FOwAQiRlgq7tUVVzoIlMT8ql+3OEe6Qa13en3pLe5LEZUeymxlWgPgshMc032DlOuZMmjxQm2dWfD0er79b7+AD2SNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863321; c=relaxed/simple; bh=7knUzxJaOSATsmEqjBqD5f6xLSBKqcQD+sqyG+aVVfE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WBf8VIUoSpoFBwXDKjs8mwqS7/ll9sDojIZrANB47CUYDAXw54jlhYaGjQRppESgsazA7AMp9zEqh5Y2Gz15F8yDgTtJ/b9yxGBwhhEOVRTLNJ0kbNaix5Dl5Q5B8XLRRIrkszPCsy0T6lfOIbCiObjv1hL0DKJPXQm0LegJufM= 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=KeApL3q9; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="KeApL3q9" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-55fb4b22da8so1815304a12.2 for ; Fri, 02 Feb 2024 00:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863317; x=1707468117; 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=QcPvbSGq6xN49QvaaQuCyF55moPeocRQPNZDf403Hwc=; b=KeApL3q9VYwm1LbfD5KvpSf6/DSat/d8nFWKDdQE0QJldx+i7B5Gz5q4i1dTSJFcGo qWJQeYzfGdGbPcf/aDnl0YVJG/HMPiGVGKt4GLQzwl6f0IJA76TgePN8iIzOt/dzVDJK 36M4lY3mE5QIwHfTJm4KWaA2G4BjWGRkctmDP3kk9JZcolQuq/AH6GxxwCFD8v3igvnt I/IJjMLoBuZIOR0mvUYuRYxh/d+SCa5z4uLpG+fqsvnWAFZyMiYfhDPXUP5gwYqzfiWL ZdldmpJX6QUEXeyev/v3GfRD1wk5uw8a6KrcltmPKzvkelttjFTXlt+aXmcpqlMXKXit NT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863317; x=1707468117; 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=QcPvbSGq6xN49QvaaQuCyF55moPeocRQPNZDf403Hwc=; b=eeTCztsVg/EJOxbKjvmNKm4K9JG0J7UJhmf8CZAZK6ZvQ7UdYlPQbm3P7zlNBkLoAq sNDI06Vsey167BWRo9mlti+ma8vKVZykSZfH9DDcx7Lpmdnb7kfbJ9TaBPjt4JZ/MJ6K GcDiV9FjG1o+rx6JYvxDWiN2gZOvcjfiDPe6uRV/jOKGA0jFWQ9MQypj2vBz4rNVVaYG 4FxoKT95W5AMzU8PH8i+Z/g/e9oHXZ2zPi64SPnW/EeGtuPyA5a+7G3OK+iHmtZqsyKQ XQwnTNW5NpVw4IX+t7bZEaAI4QPa1ZdFTj6MP0Xuu+pyNEenoyIocxZ52xRPrJPn++at gkgA== X-Gm-Message-State: AOJu0Yw5iy6KpshdJaeQuNN/m80A74GCqR/y8bLca1qLbZTDL6HLjyco jAfPTpBGfreomL8XJdYBRyONgcLdrAev0XRqAPMsdvYmp3FucdY1YU2rMzmiL28= X-Google-Smtp-Source: AGHT+IHUg5QEIwAX1/FjeYfVhxorC/bkxITWEs1POR/iprN1aR+jqEPzp5x3sn7zuKVqxHeTAbGzGQ== X-Received: by 2002:a17:906:3612:b0:a36:8711:f7b6 with SMTP id q18-20020a170906361200b00a368711f7b6mr3487272ejb.34.1706863317150; Fri, 02 Feb 2024 00:41:57 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV3hy6AVSB5ks+zaQtr4DnV/Kixqk03qDqPraUFFQM/1B+JC0kfHttEMn8AbQJ5kvPdDJ97oThb3cJIJ/VVvpapYCn34so1BAuL57J9nGcO5LJAwOqh3u2nOlyD6uNKspJV2A9Sym6Q7Hv2oAhC763Aj8rEdWk3z+bwsFj5cyLUgeAp7ob17Wx3HTfOFp+2+aA0I9OlMGQUe+wCG1JD39yrcqR8ORml6IlCLOBdLhxi3179FdXTflWQdHLsjAqNwnUvGav9H1/Uitt9tsosglgtP3Ldq/dtv4mOju4JgA6B4jyz/4WlBFImRs58mxB+DyZVr0DnqLSMrqHD/OXxLJWEUHjWg2g0M9nr6dcs92tgf402JOdfk1Ka66LO8yi2Y/o5AM8uOBiqxalpZtAvDlEvt91EAzNJmLOk/Wr+GM8Soqgc7Qs= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:41:56 -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, richardcochran@gmail.com, p.zabel@pengutronix.de Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea , Geert Uytterhoeven Subject: [PATCH net-next v6 04/15] net: ravb: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr() Date: Fri, 2 Feb 2024 10:41:25 +0200 Message-Id: <20240202084136.3426492-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated now and require __maybe_unused protection against unused function warnings. The usage of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() allows the compiler to see the functions, thus suppressing the warning. Thus drop the __maybe_unused markings. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov Reviewed-by: Geert Uytterhoeven --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index fd431f1a0b98..7ced5db04f75 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2971,7 +2971,7 @@ static int ravb_wol_restore(struct net_device *ndev) return disable_irq_wake(priv->emac_irq); } -static int __maybe_unused ravb_suspend(struct device *dev) +static int ravb_suspend(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); @@ -2993,7 +2993,7 @@ static int __maybe_unused ravb_suspend(struct device *dev) return ret; } -static int __maybe_unused ravb_resume(struct device *dev) +static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); @@ -3052,7 +3052,7 @@ static int __maybe_unused ravb_resume(struct device *dev) return ret; } -static int __maybe_unused ravb_runtime_nop(struct device *dev) +static int ravb_runtime_nop(struct device *dev) { /* Runtime PM callback shared between ->runtime_suspend() * and ->runtime_resume(). Simply returns success. @@ -3065,8 +3065,8 @@ static int __maybe_unused ravb_runtime_nop(struct device *dev) } static const struct dev_pm_ops ravb_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) - SET_RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) + SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) + RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) }; static struct platform_driver ravb_driver = { @@ -3074,7 +3074,7 @@ static struct platform_driver ravb_driver = { .remove_new = ravb_remove, .driver = { .name = "ravb", - .pm = &ravb_dev_pm_ops, + .pm = pm_ptr(&ravb_dev_pm_ops), .of_match_table = ravb_match_table, }, }; From patchwork Fri Feb 2 08:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542429 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.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 EF4805FDB9 for ; Fri, 2 Feb 2024 08:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863322; cv=none; b=qXyS/YTmBSR1b4c8wO0Wh+Y2Qwmopt+Rabwc5iirHiRC4iWMuC4hvbuEcy1/NRVbvGFrd9lPXiWx6Na0f1LEjwmWED+MgRlJ3/CC0SqM9tMg75p4m6Fqf0pTfWdYEulo2Q8/Akws5ddaTdomK7Mv1iBPJOcxtnNzJMCrB2TKFaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863322; c=relaxed/simple; bh=ONbLpDUQ0pxclPSJgUwLbET51iczHAS/yqhLYj7/j1w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CYXQyxEByKQHzGV1YPdh6WNPFVjDYpv7fTOEHGxcO+FaJSWbvK81jzYRlwhVSbx4JYrsWGwibm5/FsFFP1eAYl7Dv66/uML4OiNRBkmxSIZ0+jaeZT2eDVt84S5m+kduTQUKw6aedc7LhSVUZQbhC1CmmQvg/KPYBqM6qwEF/r4= 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=LDAwv0yP; arc=none smtp.client-ip=209.85.218.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="LDAwv0yP" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a370e7e1e02so32289666b.0 for ; Fri, 02 Feb 2024 00:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863319; x=1707468119; 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=YI71IkOMT1SgNH06umqK9lD2YJ8x0EnJE4QH08tMLVg=; b=LDAwv0yPllK8bov9hAZ+TFwuH9APeDr0TnYLkT1pgRhcPQEilHS4KD3SgoVGNFQIsQ DkOmEe9ow8vi2+DH2v962Xock94UfXSypbDrM+QFdFUVC4QoIvr3dac698/wFmHifW10 jFK6SkUw15NCDGkJ5c1pF9Cb/CAMadkMNajel5PP4lAKVUb+saMZZm/WDyZYnczJAXFG Q00vO2qbDWFsDby9A0TG5m+Xn4c3gER/1mGkIjJjpRFU/bZ54nzcfaZQoz+JAMP+RgN9 kJCoVYh/qYcpDT9snQm0cDGFlDLvhFEUMOrYwBFdEuApTflz+bSUaUfiUzCC0EMfKP8z A6ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863319; x=1707468119; 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=YI71IkOMT1SgNH06umqK9lD2YJ8x0EnJE4QH08tMLVg=; b=wuarIDSH5yiMvq2gJCm753pfPchTgmbw9kDEvFh3PPlHcBYS0g1muHsnb6hEoJD4ir Ke6dKUIp7lTV7tALNAPHidJjePEEvofpZmI28uayIaelehXRkh4dGFZacVBnFg8FgcGZ m71Do4K22qkDVzSAYvpjCpj8udGV8SOhL/Rx2/sy6wZxqVb8S0HHMx+igpp4JjP2P1aM YSmM7II7+qnuUYn9WYXRPyKoiqRptR8NK3EoUJytvgcSvrhswNDl81bP1L85hnQfQWY9 3Px1K9l3LVZXCwr+P3MCWdm8kclbV1mIKO+UhCOcsS6WRCFexHz9jC8SpcknZoXLQJ9t +Acg== X-Gm-Message-State: AOJu0YyO1Pkd/YXnBxADXggTNqJ2dkXgg0i6/HrkEwrJKhpgLTeLGBlR KwL4uJtqVGMurCHOs2hg7vW3rGsjx/+ZVN9786z3S25DCNd76UuV6jmNqjxEu8c= X-Google-Smtp-Source: AGHT+IGwAEtd98gv9Uj3CwlkaCRSQFY2aondW9bQppJ81yZfClAIps1aFV/4117XUjsxgw6V+YnbgQ== X-Received: by 2002:a17:906:b803:b0:a31:8e54:14db with SMTP id dv3-20020a170906b80300b00a318e5414dbmr5796744ejb.55.1706863319184; Fri, 02 Feb 2024 00:41:59 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVycCJlmHxnoNErdRh/32hZodjiOrpxpOduG/5PQsHgwIF3io97/09VHxS0p38RtyN9ytVaKVPKLKhYWtB+BPmng5GPQoPG5I6GQcfbx1Y+rzz3MK1GqSN+LhmIjWmu4UbH1hjk5D5gjR/KlXHYcevuFzle8pgiTOaQMw0h5v6ICLIdZmRJl2HdQ7YGXMnGVWPWaPU3odIV4HY5t2GFJT5ezhCnpkw4STnO7C30QJOGz6EiJESR1e436seEfaOxe89+XI8CuJ+HErvhuZbg8R1qsa4Yzndc4PoW/243f3mcDCx8pCjkC3T6P8GarwvM75KzSEbvdgd4/64MtXfjmtZr3bSNDGw5IznO/q/YBm76LpTg8z3ddmwJtQEVKTtlRqzJt05EM/ASz0ZSvw== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:41:57 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 05/15] net: ravb: Use tabs instead of spaces Date: Fri, 2 Feb 2024 10:41:26 +0200 Message-Id: <20240202084136.3426492-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Use tabs instead of spaces in the ravb_set_rate_gbeth() function. This aligns with the coding style requirements. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7ced5db04f75..c05d4a2664eb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -96,13 +96,13 @@ static void ravb_set_rate_gbeth(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); switch (priv->speed) { - case 10: /* 10BASE */ + case 10: /* 10BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_10, GECMR); break; - case 100: /* 100BASE */ + case 100: /* 100BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_100, GECMR); break; - case 1000: /* 1000BASE */ + case 1000: /* 1000BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_1000, GECMR); break; } From patchwork Fri Feb 2 08:41:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542430 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.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 599476216B for ; Fri, 2 Feb 2024 08:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863326; cv=none; b=biGynfn5aK83d09l5LR77K52APmBrPw2lX30gJYEji3w+1eb79xvKamT2HfdFmtu6dXEBHRE9ZZBSc7SRdaWXxx1y/ABPqMeCRkDzoNsGQeX3NnzfCR5qaHieJjkU54H6zLOgUWsWBE1N1ZkGc1bInb7K3Cdk3wQ6x/RsUD5Oyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863326; c=relaxed/simple; bh=F0bxqF2Bs1iyl0FY+5Twbfa3UZ4Z4U0JEOAmmYMmU2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PKAGhL78S4vaCPixd647llFDmq7Am73AWsQ59GwGdXzVtkcSAhzDHV+4nw8nG/Mr/zBbsMI2IVLSffSo+6TPGwUZozQH1r08F8d66LZSoKZudIBIizhzbl3PL8F0B/V5zZIc9kCYyMsxzK3kMBpoEdOT0nLBlA/QQ57tsJFnrXY= 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=iTrYRCMS; arc=none smtp.client-ip=209.85.218.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="iTrYRCMS" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a3604697d63so280262366b.3 for ; Fri, 02 Feb 2024 00:42:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863322; x=1707468122; 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=WWxwGazwGxFm9RJ3W3AXRBZkyy08qk5mh8Ekn6FcMvw=; b=iTrYRCMSSkiXyJdzcEt3hWjfSwR4K1sVnyUGiif+4ReaDaxWlBm8HBC1EaLIp4X7ED NfNjUTNBViaIR2CfYyPFLPQ1Xr7ezt+YOwQaZAYZo/dccYskzQpGBBKH5ULtZwY3rNFm OLwvk8qP01pclstTdB/lEqR1es887YdounYZYrkjnua9JqRGDR0QDKrv1HTH0skSgJXi bLB/uJbTussSEqiiaocjcl33JdCl3jk1PbSQZQD/zigf+doMYp8hflUrpf/FKPcyYh2S VSN4/AQICK0T0v2MSdSpmHQDnHZR4qk9YG2x4bT5wmfm7qDolTaaPgi1WKVN6Pi1RiIt +dug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863322; x=1707468122; 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=WWxwGazwGxFm9RJ3W3AXRBZkyy08qk5mh8Ekn6FcMvw=; b=aopz+XcO1G4yxUQNOMi7XMTBZnI2qLTkhRCNbzjOWgw04c6uE2Nx5XVDQJoUx8WBbt 0SDdtFxABpozqtspnwHPpJOXbALk5H7lNN26g6e2xna8Vj7asStuqApQ2cfIzuyLZISh IinF9VX0fVGbgh0wTtPupBPmYsBGvrA2YsY+mUfd4X40c/hqXxyczgPYVgJqVqJaaVFj f7ZZ8hF0oJUsZtbJgY6liNCHnrxd+aXJlWoH206l77YJ28u0ircPiTAhnTFRZ+AWt3ki S/jOWwupP8FYzpsK9DDqa1BNzGLErcOAThs+/nxH7F/9Pw2kY785mvU/tJmpWXuczsAl Ii2w== X-Gm-Message-State: AOJu0YxWnKR/promEvdDvu/duNrP0g5ZMu23CvOjU4UxjOEtgWC+CB2s hUHXsKFVOzyLP1jT7ctVHkxYoVDQJ5txF7wpmXHW/qwtjEutnNNAMtGd9SndIHg= X-Google-Smtp-Source: AGHT+IEfVsf2BVBIztAwkZyOv2y5pbCiGTnjLxqvG+uO5Y9meerLsa0ZMPZjfKW20FVajQTgjWP2gA== X-Received: by 2002:a17:906:6d4c:b0:a35:6a40:b4cf with SMTP id a12-20020a1709066d4c00b00a356a40b4cfmr4641441ejt.19.1706863322413; Fri, 02 Feb 2024 00:42:02 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXwxLgk/J7vwLpbCP7gKuXZjoVSAZe65SJRtwC1O+341OqzcHNX4l3ZibHNNcJ4kz8EK8gIai+Yp5IFQocAWclZpoHZvagaDP9K11bH37oSTrJHzujj0z3mxShLgq1n36O9Xcmr7U/Jz2Dq5rG/WM8zA3ap7EvObKDt+YXP70HiRCTeQPavPnsHxzLPkuooGpi7YqqTiF27rWP9UmwbgO00k7WTZnw3TCjFERqEGd1mlaRVfbim8NHE/9+jnUY0TTOuMw1mmVpHafbKCeYu35vlf+JPmt6se7d74nu3pP7iaWvm383nS8b4MCks01liCufnbG9YcXFEuXRn0EM5QO0/xgiRPjvinkTTnhtQVtHiLoW/6MjwUsNFAt66VQXxVJhmkO903jblheQfkw== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:01 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 06/15] net: ravb: Assert/de-assert reset on suspend/resume Date: Fri, 2 Feb 2024 10:41:27 +0200 Message-Id: <20240202084136.3426492-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea RZ/G3S can go to deep sleep states where power to most of the SoC parts is off. When resuming from such a state, the Ethernet controller needs to be reinitialized. De-asserting the reset signal for it should also be done. Thus, add reset assert/de-assert on suspend/resume functions. On the resume function, the de-assert was not reverted in case of failures to give the user a chance to restore the interface (e.g., bringing down/up the interface) in case suspend/resume failed. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - collected tags Changes in v2: - fixed typos in patch description and subject - on ravb_suspend() assert the reset signal in case interface is down; due to this the Sergey's Rb tag was left aside in this version drivers/net/ethernet/renesas/ravb_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c05d4a2664eb..c2b65bdad13c 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2978,7 +2978,7 @@ static int ravb_suspend(struct device *dev) int ret; if (!netif_running(ndev)) - return 0; + goto reset_assert; netif_device_detach(ndev); @@ -2990,7 +2990,11 @@ static int ravb_suspend(struct device *dev) if (priv->info->ccc_gac) ravb_ptp_stop(ndev); - return ret; + if (priv->wol_enabled) + return ret; + +reset_assert: + return reset_control_assert(priv->rstc); } static int ravb_resume(struct device *dev) @@ -2998,7 +3002,11 @@ static int ravb_resume(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - int ret = 0; + int ret; + + ret = reset_control_deassert(priv->rstc); + if (ret) + return ret; /* If WoL is enabled set reset mode to rearm the WoL logic */ if (priv->wol_enabled) { From patchwork Fri Feb 2 08:41:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542431 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.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 509DC612D7 for ; Fri, 2 Feb 2024 08:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863328; cv=none; b=BMgnf2BpVHTlPkS7G0QED21oILxhhApfjJDZvxz2a4JqJKyMalQwALUchQXjyHaEA8znDVKoN/ynl9BloOMy27i32Cl21OLE9+AZxRawrazYGt8PHzOGtTAtqyFIRCluNFK+k4+Q02cKhpOzPU9wX1zB1Uy2QgTVQz+ovOa3YrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863328; c=relaxed/simple; bh=DK+aebRHFc2djoDWx6C3/OPosBYtMm2nVYmwfnXH2pA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WZBQydobxeOlF9+WB5AVb3ZQIAAgXShFEjLn7p+PSQRCRAeJgnuQQkiA7u/hW3zBWKFDlU25YvEPsPafu/gYaEPkjmO6yFj89KqTUy4EsnPrGsEB4g079+6QCWTUXY54ezNbpn1KIFU7EkxDkGUrbKCa4mZAHRjKcez2cVUCOVE= 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=kfelr1Xa; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="kfelr1Xa" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-55f19a3ca7aso5705809a12.1 for ; Fri, 02 Feb 2024 00:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863324; x=1707468124; 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=I2Tq0xany9i7GthfvOVG1vhvIi7DmAmdzJEMumk66i0=; b=kfelr1XaOM80lyQTyp/q69RW3i2k/Sz37AH7JsdtvGaUhy8jJWGr1ywhtxIuVmC4Li Vnd9iwaF6sSqqZaNMqkhp6ULD1MBnisSqx1eH/wXaMK56Za5NE4gGae0eZRxdE3L2FJI T0WmYCvzhlbrgrU/gdvfyiiHBZL3uJhJNkKKdd0tO7eW0GyMmffL7G/Rf2sATLSfld2P N5XoFe19ij1Esgknf95JJge8ZjOLyo/IYLzjkpnYH6ghI/NMdc847GtB8EEOsRGZbHY3 Ipkcqg+7dVgYxDG25O/AGK940qbspgzaL/wnSUxJiF9mbtAvc1BAihTvwKaf5mnY8fLI 8BZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863324; x=1707468124; 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=I2Tq0xany9i7GthfvOVG1vhvIi7DmAmdzJEMumk66i0=; b=GQlm9gJ2PwnnzcfSH2NPA9UVq1H3bJGN7IaSkt3pUwebS1A1tcI8Q0aBKIc1ZtVV4M WerHFGEeHQvUvfCcleQKYr/lHQEbxek3gkAhMSZN8ud2oJibBj3axTOV8B8H0PrSH1o5 q9/POgy1g44dmJ8SqsNseTt0D4oxcq4Uo9wemvXSjlZ3spXg+/TyILaCyQ+bxl6LM+Ko xSzCLanTT+QixYmPyJelRQmZoCUtSmd4Z5XVLvsIgWyns+05kex5jRebWpOGqCmguujc nEhVWwMHq2RD9WhsQMo+1yjeoNG+eeZn/c+Wm/7YK5zCqBK6MOuhRJNZ4zT3Mz2/FIJS 1Qew== X-Gm-Message-State: AOJu0YzNKUKG1SpNZ/+KjmR7UnlD85cngYpz9Mw3BKz6vP4siAE7PxQR toOqMWmqdtQDjmh+VxumT0cgJm5KBpXuHPgwSCYsOROj10CRcHDvYF5d+aRm9m4= X-Google-Smtp-Source: AGHT+IGgORQwf+B8SZkAnda4eDafc9eXIiDw5bDRirPguLcewqDWQaOb7E8l7gUAWE/kf//HZmNMGQ== X-Received: by 2002:a17:906:3c05:b0:a35:278:1c23 with SMTP id h5-20020a1709063c0500b00a3502781c23mr1053131ejg.35.1706863324517; Fri, 02 Feb 2024 00:42:04 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVk4gsRxArIg1NllHvFeuzJ5O9drz4PYfwdz5GkYCYSiX8HyRl1OHHo5LY1qzLK2G/bDGPHmNa+t44xzpyGl4UB4GZ2LASlODtV2K8rERDarEnKc7f8PXxsruDVta/6lUQluwb2CJYBlVassa9fndHNM7NcJVrs4rEwIGqLoDJYX2ztX7HIhC96Ir0tXxmNdubvGhFMRzZNuZsK0nXl48ZAxNeNM/mdq4X3fXzqtCq7xOjhALnCY9JwrqEBlWnDxWJEyXfkd9C5wr68sLI2LH/NQqENsW0/Nlw56hPQC1hXdgWzPZGiC/ZzpEAv3kHjQ7l+eB8WW12B/i35j1tQNQbDW1B0rLxkvtxgZjHON3ipUmYrZnurz+NGDpnDuQuMUSYlC64tjWl6nITkgg== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:03 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 07/15] net: ravb: Move reference clock enable/disable on runtime PM APIs Date: Fri, 2 Feb 2024 10:41:28 +0200 Message-Id: <20240202084136.3426492-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Reference clock could be or not be part of the power domain. If it is part of the power domain, the power domain takes care of properly setting it. In case it is not part of the power domain and full runtime PM support is available in driver the clock will not be propertly disabled/enabled at runtime. For this, keep the prepare/unprepare operations in the driver's probe()/remove() functions and move the enable/disable in runtime PM functions. By doing this, the previous ravb_runtime_nop() function was renamed ravb_runtime_suspend() and the comment was removed. A proper runtime PM resume function was added (ravb_runtime_resume()). The current driver still don't need to make any register settings on runtime suspend/resume (as expressed in the removed comment) because, currently, pm_runtime_put_sync() is called on the driver remove function. This will be changed in the next commits (that extends the runtime PM support) such that proper register settings (along with runtime resume/suspend) will be done on ravb_open()/ravb_close(). Along with it, the other clock request operations were moved close to reference clock request and prepare to have all the clock requests specific code grouped together. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - fixed typos in patch description - improved patch description Changes in v4: - dropped tag Changes in v3: - squashed with patch 17/21 ("net: ravb: Keep clock request operations grouped together") from v2 - collected tags Changes in v2: - this patch is new and follows the recommendations proposed in the discussion of patch 08/13 ("net: ravb: Rely on PM domain to enable refclk") from v2 drivers/net/ethernet/renesas/ravb_main.c | 110 ++++++++++++----------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c2b65bdad13c..e70c930840ce 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2664,11 +2664,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; - pm_runtime_enable(&pdev->dev); - error = pm_runtime_resume_and_get(&pdev->dev); - if (error < 0) - goto out_rpm_disable; - if (info->multi_irqs) { if (info->err_mgmt_irqs) irq = platform_get_irq_byname(pdev, "dia"); @@ -2679,7 +2674,7 @@ static int ravb_probe(struct platform_device *pdev) } if (irq < 0) { error = irq; - goto out_release; + goto out_reset_assert; } ndev->irq = irq; @@ -2697,10 +2692,37 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE; } + priv->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) { + error = PTR_ERR(priv->clk); + goto out_reset_assert; + } + + if (info->gptp_ref_clk) { + priv->gptp_clk = devm_clk_get(&pdev->dev, "gptp"); + if (IS_ERR(priv->gptp_clk)) { + error = PTR_ERR(priv->gptp_clk); + goto out_reset_assert; + } + } + + priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); + if (IS_ERR(priv->refclk)) { + error = PTR_ERR(priv->refclk); + goto out_reset_assert; + } + clk_prepare(priv->refclk); + + platform_set_drvdata(pdev, ndev); + pm_runtime_enable(&pdev->dev); + error = pm_runtime_resume_and_get(&pdev->dev); + if (error < 0) + goto out_rpm_disable; + priv->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(priv->addr)) { error = PTR_ERR(priv->addr); - goto out_release; + goto out_rpm_put; } /* The Ether-specific entries in the device structure. */ @@ -2711,7 +2733,7 @@ static int ravb_probe(struct platform_device *pdev) error = of_get_phy_mode(np, &priv->phy_interface); if (error && error != -ENODEV) - goto out_release; + goto out_rpm_put; priv->no_avb_link = of_property_read_bool(np, "renesas,no-ether-link"); priv->avb_link_active_low = @@ -2724,14 +2746,14 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "ch24"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->emac_irq = irq; for (i = 0; i < NUM_RX_QUEUE; i++) { irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->rx_irqs[i] = irq; } @@ -2739,7 +2761,7 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->tx_irqs[i] = irq; } @@ -2748,40 +2770,19 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "err_a"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->erra_irq = irq; irq = platform_get_irq_byname(pdev, "mgmt_a"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->mgmta_irq = irq; } } - priv->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - error = PTR_ERR(priv->clk); - goto out_release; - } - - priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); - if (IS_ERR(priv->refclk)) { - error = PTR_ERR(priv->refclk); - goto out_release; - } - clk_prepare_enable(priv->refclk); - - if (info->gptp_ref_clk) { - priv->gptp_clk = devm_clk_get(&pdev->dev, "gptp"); - if (IS_ERR(priv->gptp_clk)) { - error = PTR_ERR(priv->gptp_clk); - goto out_disable_refclk; - } - } - ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; @@ -2799,13 +2800,13 @@ static int ravb_probe(struct platform_device *pdev) /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; if (info->gptp || info->ccc_gac) { /* Set GTI value */ error = ravb_set_gti(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); @@ -2825,7 +2826,7 @@ static int ravb_probe(struct platform_device *pdev) "Cannot allocate desc base address table (size %d bytes)\n", priv->desc_bat_size); error = -ENOMEM; - goto out_disable_refclk; + goto out_rpm_put; } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; @@ -2871,8 +2872,6 @@ 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); - platform_set_drvdata(pdev, ndev); - return 0; out_napi_del: @@ -2888,12 +2887,12 @@ static int ravb_probe(struct platform_device *pdev) /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev); -out_disable_refclk: - clk_disable_unprepare(priv->refclk); -out_release: +out_rpm_put: pm_runtime_put(&pdev->dev); out_rpm_disable: pm_runtime_disable(&pdev->dev); + clk_unprepare(priv->refclk); +out_reset_assert: reset_control_assert(rstc); out_free_netdev: free_netdev(ndev); @@ -2922,10 +2921,9 @@ static void ravb_remove(struct platform_device *pdev) ravb_set_opmode(ndev, CCC_OPC_RESET); - clk_disable_unprepare(priv->refclk); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + clk_unprepare(priv->refclk); reset_control_assert(priv->rstc); free_netdev(ndev); platform_set_drvdata(pdev, NULL); @@ -3060,21 +3058,27 @@ static int ravb_resume(struct device *dev) return ret; } -static int ravb_runtime_nop(struct device *dev) +static int ravb_runtime_suspend(struct device *dev) { - /* Runtime PM callback shared between ->runtime_suspend() - * and ->runtime_resume(). Simply returns success. - * - * This driver re-initializes all registers after - * pm_runtime_get_sync() anyway so there is no need - * to save and restore registers here. - */ + struct net_device *ndev = dev_get_drvdata(dev); + struct ravb_private *priv = netdev_priv(ndev); + + clk_disable(priv->refclk); + return 0; } +static int ravb_runtime_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ravb_private *priv = netdev_priv(ndev); + + return clk_enable(priv->refclk); +} + static const struct dev_pm_ops ravb_dev_pm_ops = { SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) - RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) + RUNTIME_PM_OPS(ravb_runtime_suspend, ravb_runtime_resume, NULL) }; static struct platform_driver ravb_driver = { From patchwork Fri Feb 2 08:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542432 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.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 4BE41657CA for ; Fri, 2 Feb 2024 08:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863331; cv=none; b=JV/9cvbVA1ciPws9dLDulPg1f7Hapy3pZGcq5YdSDTONWaoxlpy+h2g5lvzjrC8lamhWw+PdAD2XAWEQMlKRjZt3R8v05sSv5Eg54tZUy791AhVJjf9fMTPNpUXGzYX1lojM6Xycd6HGdSprjv9BNG6YzpKGTb9efDqCV2ryQZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863331; c=relaxed/simple; bh=sjKZtlaEAVgFWl84cYhPxtJ7a9xxqnYxEBSVNtCDUTI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sHSnsoo/x2H1v4UOn7YtWquqUeT9+QwLpPOHYQyK1bfNSeOKyVaNLEbjODZ4iwhVjdIvwVt7Nd56kWeD4QnR2/N+tGvPei/iRdJ2ms5HK42lLBEDQ3o48MHT+OYA07slUgyjfyPPZfbx3ttoF5XVZiMHmzp9Dyd84AanAqow7uw= 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=VM0n2B4Q; arc=none smtp.client-ip=209.85.218.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="VM0n2B4Q" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a3604697d63so280275666b.3 for ; Fri, 02 Feb 2024 00:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863327; x=1707468127; 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=Ksq8mmW042xoc7lL/EYaD6FYn9rK5WCwbNEmW3ym7LI=; b=VM0n2B4Q0UwGHBkvtD/dlkz2/NXLkp70rkF2vAW3ob+5yFtw7warUqF8GX4A0+PxEi oym14WzlzIW4nqLm1B0cE1iC3fd4tGk7wsw7FVJ87Mlc2cGYzrnU3vAIgDlpYPK5gek4 rNf0oSyB0URC1f0zg2GQAQ601SP+ghrEnbq1DVe3KG8hcGJkWZTaFewgKbmmlJadhBZn cyFvvEAz2M0/SmTMYivI6QcqMCJuS0EZirVmQ5PpVdf9y2tviBb8FdbFZ+vJ2601AilJ IKFjN7U9S5VnhwjXnauAcEJyFBmMnnMGPB6Gsf849PzUL/39GoypAFViYWMoYO24YM7P M4ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863327; x=1707468127; 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=Ksq8mmW042xoc7lL/EYaD6FYn9rK5WCwbNEmW3ym7LI=; b=PtnOb/WmpG1Sxx0p17Su60GpbOSvIE5yukilMcJEbRY66emHhnPN9Hn9t6yVeiRjD8 E0Ko5BkBGm0ROuoD2pI8ua0XOlUPsN+9X4fvk6vddBu1gb40PkWtGObEPdeed/0svxmH OMdPk8wFNxy06Xt6oUaqb5HIH6XSRWWinkHUlzrIxFKFKvWx/l8e2/nVtNMrAeXoY7xE oxVepz6kf42xC7Yp/VB4h5RvEfOY0ucz8OwnnoQn3iUs0+AyztVf0TdEqOIRbe6FV6LT O71pzuMswzuyd9ecmJeODMPurwk0EbKcENf5UdWd/S74J8/FW8Q+8EGcdf5PrFQVs+NL Gh/Q== X-Gm-Message-State: AOJu0YztTgHY+oJjni75TT6w6z7RpzOnx7SiPPXatAFMVAxmI9ZbcN3M it7zcZSi973iKTL2Wt/ysk3oEUML3VsAGU4U5QnoRO0+3whstpcOnhPiW4le6yY= X-Google-Smtp-Source: AGHT+IFfQ3pnAtuEmmphHSFstQDj4/shOjzB+u4u88GPqebHTAWezlCE2rrRKbnq5l5BlY1/7pVcNw== X-Received: by 2002:a17:906:44d:b0:a35:356a:f601 with SMTP id e13-20020a170906044d00b00a35356af601mr5067863eja.34.1706863327426; Fri, 02 Feb 2024 00:42:07 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUS6/R64dd0PnlIl6CMmmQDnWiiH0O3REbzjhH5kzWKGyXETQUh2D9VgZpaflAKKJ5PDXycYydD0ZCmiKNTjlYGFV+DwiEfn0Ysd7a07hC8Zwh4XcVSNOmH0is4mk9FlYICKSAXXT0zUwMMoEr6Nt5BYQrZlzOuRTNJCITWTjq+eYw9yQBoJtQ7l6EPGRfdYSrgrHDqN004k86F9luIFtZUQP3pwtNH5B4ywvbkyUxd7zEHE72zl9OA+NltWUrKegYwTbIKvcE5mON7eYG+VkrSp2jb22OEemDlvBBhx0cygswlbYGmIT4kMPcEqzAkdnGPQ9WzRFZ0K0MAusvKKsoYPLiXEAEpjttkePXDPZaSgrZOJwfcz8BYIlpFEkDoGuoB5hH6CU7o4QypEA== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:05 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 08/15] net: ravb: Move getting/requesting IRQs in the probe() method Date: Fri, 2 Feb 2024 10:41:29 +0200 Message-Id: <20240202084136.3426492-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea The runtime PM implementation will disable clocks at the end of ravb_probe(). As some IP variants switch to reset mode as a result of setting module standby through clock disable APIs, to implement runtime PM the resource parsing and requesting are moved in the probe function and IP settings are moved in the open function. This is done because at the end of the probe some IP variants will switch anyway to reset mode and the registers content is lost. Also keeping only register settings operations in the ravb_open()/ravb_close() functions will make them faster. Commit moves IRQ requests to ravb_probe() to have all the IRQs ready when the interface is open. As now getting/requesting IRQs is done in a single place there is no need to keep intermediary data (like ravb_rx_irqs[] and ravb_tx_irqs[] arrays or IRQs in struct ravb_private). In order to avoid accessing the IP registers while the IP is runtime suspended (e.g. in the timeframe b/w the probe requests shared IRQs and IP clocks are enabled) in the interrupt handlers were introduced pm_runtime_active() checks. The device runtime PM usage counter has been incremented to avoid disabling the device's clocks while the check is in progress (if any). This is a preparatory change to add runtime PM support for all IP variants. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag - fixed typos in patch title and patch description Changes in v5: - fixed typos in patch description - collected tags Changes in v4: - use pm_runtime_active() in interrupt handlers - addressed review comments Changes in v3: - fixed typos in patch description - detailed patch description - reworked the code to have a single function doing IRQ get and request Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 4 - drivers/net/ethernet/renesas/ravb_main.c | 299 ++++++++++------------- 2 files changed, 130 insertions(+), 173 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e0f8276cffed..e3506888cca6 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1089,10 +1089,6 @@ struct ravb_private { int msg_enable; int speed; int emac_irq; - int erra_irq; - int mgmta_irq; - int rx_irqs[NUM_RX_QUEUE]; - int tx_irqs[NUM_TX_QUEUE]; unsigned no_avb_link:1; unsigned avb_link_active_low:1; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index e70c930840ce..f9297224e527 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -38,16 +38,6 @@ NETIF_MSG_RX_ERR | \ NETIF_MSG_TX_ERR) -static const char *ravb_rx_irqs[NUM_RX_QUEUE] = { - "ch0", /* RAVB_BE */ - "ch1", /* RAVB_NC */ -}; - -static const char *ravb_tx_irqs[NUM_TX_QUEUE] = { - "ch18", /* RAVB_BE */ - "ch19", /* RAVB_NC */ -}; - void ravb_modify(struct net_device *ndev, enum ravb_reg reg, u32 clear, u32 set) { @@ -1092,11 +1082,23 @@ static irqreturn_t ravb_emac_interrupt(int irq, void *dev_id) { struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; + irqreturn_t result = IRQ_HANDLED; + + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) { + result = IRQ_NONE; + goto out_rpm_put; + } spin_lock(&priv->lock); ravb_emac_interrupt_unlocked(ndev); spin_unlock(&priv->lock); - return IRQ_HANDLED; + +out_rpm_put: + pm_runtime_put_noidle(dev); + return result; } /* Error interrupt handler */ @@ -1176,9 +1178,15 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id) struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + struct device *dev = &priv->pdev->dev; irqreturn_t result = IRQ_NONE; u32 iss; + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Get interrupt status */ iss = ravb_read(ndev, ISS); @@ -1222,6 +1230,9 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id) } spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } @@ -1230,9 +1241,15 @@ static irqreturn_t ravb_multi_interrupt(int irq, void *dev_id) { struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; irqreturn_t result = IRQ_NONE; u32 iss; + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Get interrupt status */ iss = ravb_read(ndev, ISS); @@ -1254,6 +1271,9 @@ static irqreturn_t ravb_multi_interrupt(int irq, void *dev_id) } spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } @@ -1261,8 +1281,14 @@ static irqreturn_t ravb_dma_interrupt(int irq, void *dev_id, int q) { struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; irqreturn_t result = IRQ_NONE; + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Network control/Best effort queue RX/TX */ @@ -1270,6 +1296,9 @@ static irqreturn_t ravb_dma_interrupt(int irq, void *dev_id, int q) result = IRQ_HANDLED; spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } @@ -1727,85 +1756,21 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; -static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler, - struct net_device *ndev, struct device *dev, - const char *ch) -{ - char *name; - int error; - - name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); - if (!name) - return -ENOMEM; - error = request_irq(irq, handler, 0, name, ndev); - if (error) - netdev_err(ndev, "cannot request IRQ %s\n", name); - - return error; -} - /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - struct platform_device *pdev = priv->pdev; - struct device *dev = &pdev->dev; int error; napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); - if (!info->multi_irqs) { - error = request_irq(ndev->irq, ravb_interrupt, IRQF_SHARED, - ndev->name, ndev); - if (error) { - netdev_err(ndev, "cannot request IRQ\n"); - goto out_napi_off; - } - } else { - error = ravb_hook_irq(ndev->irq, ravb_multi_interrupt, ndev, - dev, "ch22:multi"); - if (error) - goto out_napi_off; - error = ravb_hook_irq(priv->emac_irq, ravb_emac_interrupt, ndev, - dev, "ch24:emac"); - if (error) - goto out_free_irq; - error = ravb_hook_irq(priv->rx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch0:rx_be"); - if (error) - goto out_free_irq_emac; - error = ravb_hook_irq(priv->tx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch18:tx_be"); - if (error) - goto out_free_irq_be_rx; - error = ravb_hook_irq(priv->rx_irqs[RAVB_NC], ravb_nc_interrupt, - ndev, dev, "ch1:rx_nc"); - if (error) - goto out_free_irq_be_tx; - error = ravb_hook_irq(priv->tx_irqs[RAVB_NC], ravb_nc_interrupt, - ndev, dev, "ch19:tx_nc"); - if (error) - goto out_free_irq_nc_rx; - - if (info->err_mgmt_irqs) { - error = ravb_hook_irq(priv->erra_irq, ravb_multi_interrupt, - ndev, dev, "err_a"); - if (error) - goto out_free_irq_nc_tx; - error = ravb_hook_irq(priv->mgmta_irq, ravb_multi_interrupt, - ndev, dev, "mgmt_a"); - if (error) - goto out_free_irq_erra; - } - } - /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_free_irq_mgmta; + goto out_napi_off; ravb_emac_init(ndev); /* Initialise PTP Clock driver */ @@ -1826,26 +1791,6 @@ static int ravb_open(struct net_device *ndev) if (info->gptp) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); -out_free_irq_mgmta: - if (!info->multi_irqs) - goto out_free_irq; - if (info->err_mgmt_irqs) - free_irq(priv->mgmta_irq, ndev); -out_free_irq_erra: - if (info->err_mgmt_irqs) - free_irq(priv->erra_irq, ndev); -out_free_irq_nc_tx: - free_irq(priv->tx_irqs[RAVB_NC], ndev); -out_free_irq_nc_rx: - free_irq(priv->rx_irqs[RAVB_NC], ndev); -out_free_irq_be_tx: - free_irq(priv->tx_irqs[RAVB_BE], ndev); -out_free_irq_be_rx: - free_irq(priv->rx_irqs[RAVB_BE], ndev); -out_free_irq_emac: - free_irq(priv->emac_irq, ndev); -out_free_irq: - free_irq(ndev->irq, ndev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2180,19 +2125,6 @@ static int ravb_close(struct net_device *ndev) cancel_work_sync(&priv->work); - if (info->multi_irqs) { - free_irq(priv->tx_irqs[RAVB_NC], ndev); - free_irq(priv->rx_irqs[RAVB_NC], ndev); - free_irq(priv->tx_irqs[RAVB_BE], ndev); - free_irq(priv->rx_irqs[RAVB_BE], ndev); - free_irq(priv->emac_irq, ndev); - if (info->err_mgmt_irqs) { - free_irq(priv->erra_irq, ndev); - free_irq(priv->mgmta_irq, ndev); - } - } - free_irq(ndev->irq, ndev); - if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); napi_disable(&priv->napi[RAVB_BE]); @@ -2616,6 +2548,90 @@ static void ravb_parse_delay_mode(struct device_node *np, struct net_device *nde } } +static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, + const char *ch, int *irq, irq_handler_t handler) +{ + struct platform_device *pdev = priv->pdev; + struct net_device *ndev = priv->ndev; + struct device *dev = &pdev->dev; + const char *dev_name; + unsigned long flags; + int error; + + 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); + flags = 0; + } else { + dev_name = ndev->name; + *irq = platform_get_irq(pdev, 0); + flags = IRQF_SHARED; + } + if (*irq < 0) + return *irq; + + error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev); + if (error) + netdev_err(ndev, "cannot request IRQ %s\n", dev_name); + + return error; +} + +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; + + if (!info->multi_irqs) + return ravb_setup_irq(priv, NULL, NULL, &ndev->irq, ravb_interrupt); + + if (info->err_mgmt_irqs) { + irq_name = "dia"; + emac_irq_name = "line3"; + } else { + irq_name = "ch22"; + emac_irq_name = "ch24"; + } + + error = ravb_setup_irq(priv, irq_name, "ch22:multi", &ndev->irq, ravb_multi_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, emac_irq_name, "ch24:emac", &priv->emac_irq, + ravb_emac_interrupt); + if (error) + return error; + + if (info->err_mgmt_irqs) { + error = ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_interrupt); + if (error) + return error; + } + + error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interrupt); + if (error) + return error; + + return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); +} + static void ravb_set_delay_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -2635,9 +2651,8 @@ static int ravb_probe(struct platform_device *pdev) struct reset_control *rstc; struct ravb_private *priv; struct net_device *ndev; - int error, irq, q; struct resource *res; - int i; + int error, q; if (!np) { dev_err(&pdev->dev, @@ -2664,20 +2679,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq = platform_get_irq_byname(pdev, "dia"); - else - irq = platform_get_irq_byname(pdev, "ch22"); - } else { - irq = platform_get_irq(pdev, 0); - } - if (irq < 0) { - error = irq; - goto out_reset_assert; - } - ndev->irq = irq; - SET_NETDEV_DEV(ndev, &pdev->dev); priv = netdev_priv(ndev); @@ -2692,6 +2693,10 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE; } + error = ravb_setup_irqs(priv); + if (error) + goto out_reset_assert; + priv->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { error = PTR_ERR(priv->clk); @@ -2739,50 +2744,6 @@ static int ravb_probe(struct platform_device *pdev) priv->avb_link_active_low = of_property_read_bool(np, "renesas,ether-link-active-low"); - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq = platform_get_irq_byname(pdev, "line3"); - else - irq = platform_get_irq_byname(pdev, "ch24"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->emac_irq = irq; - for (i = 0; i < NUM_RX_QUEUE; i++) { - irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->rx_irqs[i] = irq; - } - for (i = 0; i < NUM_TX_QUEUE; i++) { - irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->tx_irqs[i] = irq; - } - - if (info->err_mgmt_irqs) { - irq = platform_get_irq_byname(pdev, "err_a"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->erra_irq = irq; - - irq = platform_get_irq_byname(pdev, "mgmt_a"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->mgmta_irq = irq; - } - } - ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; From patchwork Fri Feb 2 08:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542433 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.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 8EFA75FDD9 for ; Fri, 2 Feb 2024 08:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863333; cv=none; b=h84hSlkdNttB2mCTSZEZKwhyYFT/W10iYvXko6Jqd7Jd9UIWrAFLViBKfFpRoSxteZ+zzFDvOc2+oum0GbkXEDtXgaZDAB8CYLicNhm2jrjuQMbLVpRd1b4sAi8OmIJZNcM3lOrV9f9e6xz9Mr1ilEuUeSEAY+0Gr8HHwEbuIV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863333; c=relaxed/simple; bh=dNRRDz4Bb1OuEmu+nW58AzscDhcZ6X/B2WLvdreri+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EpCd1q7nnjgeRYkUwXFG4DYH9pGQ+I00XSLhBSDo/pbY5FzX6nMv8uiULSrxlwfeaLTrjonP95lcFK1RVGH2fOs29POmFWjrsV7DlCoZQHyPl+5jGPltju398ajIaRSldRFdALOP+fj90mzocIWiwWwI98+OG+5xmxpK4Nu7xEs= 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=hXfRRiV1; arc=none smtp.client-ip=209.85.218.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="hXfRRiV1" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a26fa294e56so262968466b.0 for ; Fri, 02 Feb 2024 00:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863330; x=1707468130; 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=j9vMwV3T8fFvP4He6TN+KQoGt+DXHpVsSkF7+oq3d2E=; b=hXfRRiV1uPJZILQmyJZPJsPfhx3ceUzq8dojDPZ8se8I6nlNSRwceCxJ3xCDScA1da T8wyA6guspb0Vn3lC2xkzssz8sEX6UYdVKhrH3JsLJXDGkzovTfJWBND4sMWx2vRzc30 u8a6P74A2f4rlO6yfIFq+OPLt7wGPHah/7yNxZ6QuKNfn6zEdOaNxQZTBEh+seKCjm8y 4akoECkQByqZpMX9DoEsr8DPQImTsfApzaW8qXV0QGydASS3AfbSxg4bpQ9J+OStkqrB kvL6cwgdzy8/ZAWx3ZwtVpir3oGeF0MEOI4CgNISrXActHDC16syPdQbd2R6Td8GheVN ARDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863330; x=1707468130; 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=j9vMwV3T8fFvP4He6TN+KQoGt+DXHpVsSkF7+oq3d2E=; b=qpW5xG4nFF4Mg1d89i+uoHXnwKjryTgYOIvzbwVQw36s85cEkXHsqB0CaPg6VJwP17 1ahZoMrFFvfkqFmUBp032caR/SBSWg7LdWkn7wtyd0cqUFv+AwVBzUk0qMkXOVZdToKB UfRNHcY92F3RYev6YQesWsVGoOh7KvsyzUz9/qgVef1uz7oU93e7CnjzHvc6GFhzfeV/ cq7sJrcplHW7pVKz4stHWOjSFUe6nqusTtP8Jfote89QdBik6H4crHM1W6Jnz4WwEvRr lL2lQr/10f8wN4FGLgy705sHse8Ee9pgs5nib75J+z2j1MRtUzbHuik9XP9Ud/opEdgs 9JOQ== X-Gm-Message-State: AOJu0YwCdunqlJBxYSp68WESwaTKk9wcKWSBP7YkJmz+6JAWsZzTb5OW MBXfnuIq9VRA/ialYaCcSmKuzrJ6lnS1LAB2l7yqp8pvgyGDdOEKdvUxXiGR9P8= X-Google-Smtp-Source: AGHT+IGcZDQLgAPHlrsmpjdwNWSIXKaFglLjExIZhzctjGT2ucyxHzXDlA7vTs3IPQ3L3VDiGu16Ow== X-Received: by 2002:a17:906:1b1b:b0:a35:ffaa:b43 with SMTP id o27-20020a1709061b1b00b00a35ffaa0b43mr5930556ejg.50.1706863329810; Fri, 02 Feb 2024 00:42:09 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXKtPmK9JI1MfbzVeUDD6l0aAiiWl+UkcL4YTXG1dEy1rC8w8n19IPMPtZm8F5+viRxHIKFD53zgyVNHje6dUgFJPtt5x19GeIkNY/Rl1TEtTh434mzTOT7rE5Wo6oFin2CIXTz9WnENMqQh5uQeKSMb9IGSUnNTdfVzuc48Uuu8voqlWEiEQd94GoQsAR9LWAVOpwfpyufpjHP+N6mZe+tn47sZTTXxASyD+trZEhh2OuY5cSGaf9niC2HMGOanqXaEV+LL/VGOO8Z0Id53uTzyVNMfvtdtCwG5kLB6n6XNTpcNHbc3Gv88o5soSDDwtDw/qB7uFkK5FqXDY6rLcKR9unGAx5v/dB2ug/FtePddNTkh1B9sOlQw+h08mkz/nVIZRhnLAZytoCrWQ== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42: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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 09/15] net: ravb: Split GTI computation and set operations Date: Fri, 2 Feb 2024 10:41:30 +0200 Message-Id: <20240202084136.3426492-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea ravb_set_gti() was computing the value of GTI based on the reference clock rate and then applied it to register. This was done on the driver's probe function. In order to implement runtime PM for all IP variants (as some IP variants switches to reset mode (and thus the registers content is lost) when module standby is configured through clock APIs) the GTI setup was split in 2 parts: one computing the value of the GTI register (done in the driver's probe function) and one applying the computed value to register (done in the driver's ndo_open API). Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - collected tags Changes in v3: - fixed typos in patch description - use u64 instead of uint64_t - remove ravb_wait() for setting GCCR.LTI Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 2 + drivers/net/ethernet/renesas/ravb_main.c | 96 ++++++++++++------------ 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e3506888cca6..268ccfafe7aa 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1102,6 +1102,8 @@ struct ravb_private { const struct ravb_hw_info *info; struct reset_control *rstc; + + u32 gti_tiv; }; static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f9297224e527..0f7b1d503618 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1756,6 +1756,50 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; +static void ravb_set_gti(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + + if (!(info->gptp || info->ccc_gac)) + return; + + ravb_write(ndev, priv->gti_tiv, GTI); + + /* Request GTI loading */ + ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); +} + +static int ravb_compute_gti(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + struct device *dev = ndev->dev.parent; + unsigned long rate; + u64 inc; + + if (!(info->gptp || info->ccc_gac)) + return 0; + + if (info->gptp_ref_clk) + rate = clk_get_rate(priv->gptp_clk); + else + rate = clk_get_rate(priv->clk); + if (!rate) + return -EINVAL; + + inc = div64_ul(1000000000ULL << 20, rate); + + if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) { + dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n", + inc, GTI_TIV_MIN, GTI_TIV_MAX); + return -EINVAL; + } + priv->gti_tiv = inc; + + return 0; +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1773,6 +1817,8 @@ static int ravb_open(struct net_device *ndev) goto out_napi_off; ravb_emac_init(ndev); + ravb_set_gti(ndev); + /* Initialise PTP Clock driver */ if (info->gptp) ravb_ptp_init(ndev, priv->pdev); @@ -2464,34 +2510,6 @@ static const struct of_device_id ravb_match_table[] = { }; MODULE_DEVICE_TABLE(of, ravb_match_table); -static int ravb_set_gti(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - struct device *dev = ndev->dev.parent; - unsigned long rate; - uint64_t inc; - - if (info->gptp_ref_clk) - rate = clk_get_rate(priv->gptp_clk); - else - rate = clk_get_rate(priv->clk); - if (!rate) - return -EINVAL; - - inc = div64_ul(1000000000ULL << 20, rate); - - if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) { - dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n", - inc, GTI_TIV_MIN, GTI_TIV_MAX); - return -EINVAL; - } - - ravb_write(ndev, inc, GTI); - - return 0; -} - static int ravb_set_config_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -2763,15 +2781,9 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - error = ravb_set_gti(ndev); - if (error) - goto out_rpm_put; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + error = ravb_compute_gti(ndev); + if (error) + goto out_rpm_put; if (info->internal_delay) { ravb_parse_delay_mode(np, ndev); @@ -2984,15 +2996,7 @@ static int ravb_resume(struct device *dev) if (ret) return ret; - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - ret = ravb_set_gti(ndev); - if (ret) - return ret; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + ravb_set_gti(ndev); if (info->internal_delay) ravb_set_delay_mode(ndev); From patchwork Fri Feb 2 08:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542434 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 52747745F9 for ; Fri, 2 Feb 2024 08:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863336; cv=none; b=gb5GmUghWli1rXBhbcIitEcJE+LTsAR2VQo6OT6tOjbhKF9jb1JMCMdlDS92ZmSGVuR11LtAKZvLamnpgVdGewm35tY/Yni5JUjYnm5CEFAmG9ondjwSyCOatB/WZHhqTdyiBZP+IO8dRwj1an4BLrVXubX5sFFXruYq9K2DOkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863336; c=relaxed/simple; bh=jZ3wrAg3WdunwbfvNLxFkUjw65+VHGXuZ6j3a0GMwc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ojZP3WeW525asKAvZKFzM39vYESm5lrUKB5oqjsRC35qFrYCD/ZYxPcVMqUDinriZ/QFojyGZXXux199pLJAfzifqTJAv/9E7PF4LTm+SQpgY7+q+FQjhR/k+vT9jxOu2uX7fK9qmJQcFBh3rVtIfMDbecLq29oB2tpBGY5yFFc= 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=HEVcMwvW; arc=none smtp.client-ip=209.85.218.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="HEVcMwvW" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a3122b70439so253229966b.3 for ; Fri, 02 Feb 2024 00:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863332; x=1707468132; 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=xMe2EsCOFj/0fOiVmhxLtZq33Zm/0qJvFbnQUCQS9Lk=; b=HEVcMwvWMmTtIkvzKrAHbG9SzlEyAP7Mbzhye5B4HVKz0jziniBogmF5YVC/FVX4Li NHE2VZEFdKlzINPaZY34nePviuDdTNH6RQj54urlxnvyY8Ii6Pi+likZLH6AMjHzKVGr UOxfaXTU0hUIWFsDsWFmZN0VQAxH9B76g5ivqB3Qs/T7K0oWQ4bjp3taA0Q75pyW9EUp 2TnprOYd1y6NpItUZai8dkuSvjP+okRAKHjuJ/FmdQ+pXHsr7Rn3+ca/RKOT3lsC6WQn phink5Tn8jnLLUiaEKX4nTnVHzhHxKKWaU82/phN8y7zXhbfQOIcAL1MA10WJWgCFQwc iOlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863332; x=1707468132; 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=xMe2EsCOFj/0fOiVmhxLtZq33Zm/0qJvFbnQUCQS9Lk=; b=pf9KcJUum9Xy+3hUy40vI+xYwr/Qvb2j7CLVevma6U16AwMTKLlxd4P9SaZU9TcgLI qb7U/TAFMA9RcYp3YInsSDxbnLFeVB9N6HQIyNsj56FQRbYcPuntI0eT1Q46rbJWxoBL M/9kvjIgwRBk2gZGFn718Psn4eTbz76To9gGsXyNY7/CO6XlaDEM5H+YjfMDT2dyhnju uXWgNkg5+yaQi9X8zfQQXDn/bvYFCRSSB+6ewvvZTyckbyQFP9CTY4ag+a0j9nrn/bTB NtZ8MItaVCTr+iqfAKL4fRckWTsgvv4sF1bdAXQw71oB7w+wYJ6sZXJtllzCmaL+JvW3 HSHA== X-Gm-Message-State: AOJu0YyeAiP1a7WQ+ORtCYMv0RC0Hr2yrvnhapD9awG7NZKqKdP0NWH7 OHA4Fg/lgI7RtQhFOrTVursOZClQnhe9pu6LS8ejSfOA4zwhnySsf1wk3JLC28M= X-Google-Smtp-Source: AGHT+IFk+pB61DX9vBo1JzXqSqp2gldW864VkGgbSCw+b3cwztYr0l3+oPvx2AxFTjRvVGkEW68gtw== X-Received: by 2002:a17:906:2e87:b0:a35:6bc6:a300 with SMTP id o7-20020a1709062e8700b00a356bc6a300mr5118743eji.61.1706863332358; Fri, 02 Feb 2024 00:42:12 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWHFRTAM57GGRPyS7WH41ak8hlPCOds1zYhyTtogNMyE2KQqW+dO9dGg4X5cg4J0W3JWXdf77Ddgb/E6D+IOi8bV/Q/NAfFVHenctbfWN+qt5E723YIM5salXuNCfCUv64/tkm0eIVdZru2kO0lxxLTJZUEhVjJdcWHBr+JNZGpbr5D2uJM1dmTH2rdw8bYLxC95EEUBNhpvc3HVas/n0JxqoVkBL5kLkUvBvsEcrw91oERHS3z9/5R4u7/G9MeItKqLsgb5KegrPXIAlKd2KTAjSDv3wfjj4te+6djS1HFtWvyGPPVB3UQGXwODcqCik3/1Osc02zPviSlZ/PM/ol0nnpfJDaTQ7WhiYzTX0/tC0ucPnzazJ8vHPDu+XGATakpdfoxC8hzODgzRQ== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42: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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 10/15] net: ravb: Move delay mode set in the driver's ndo_open API Date: Fri, 2 Feb 2024 10:41:31 +0200 Message-Id: <20240202084136.3426492-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Delay parsing and setting were done in the driver's probe API. As some IP variants switch to reset mode (and thus the register contents is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM keep the delay parsing in the driver's probe function and move the delay applying function to the driver's ndo_open API. Along with it, ravb_parse_delay_mode() function was moved close to ravb_set_delay_mode() function to have the delay specific code in the same place. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - fixed typos in patch description - improved patch description Changes in v4: - collected tags Changes in v3: - fixed typos in patch description Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 107 ++++++++++++----------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0f7b1d503618..e5805e0d8e13 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1800,6 +1800,59 @@ static int ravb_compute_gti(struct net_device *ndev) return 0; } +/* Set tx and rx clock internal delay modes */ +static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + bool explicit_delay = false; + u32 delay; + + if (!priv->info->internal_delay) + return; + + if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 1800, according to DT bindings */ + priv->rxcidm = !!delay; + explicit_delay = true; + } + if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 2000, according to DT bindings */ + priv->txcidm = !!delay; + explicit_delay = true; + } + + if (explicit_delay) + return; + + /* Fall back to legacy rgmii-*id behavior */ + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { + priv->rxcidm = 1; + priv->rgmii_override = 1; + } + + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { + priv->txcidm = 1; + priv->rgmii_override = 1; + } +} + +static void ravb_set_delay_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + u32 set = 0; + + if (!priv->info->internal_delay) + return; + + if (priv->rxcidm) + set |= APSR_RDM; + if (priv->txcidm) + set |= APSR_TDM; + ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1811,6 +1864,8 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + ravb_set_delay_mode(ndev); + /* Device init */ error = ravb_dmac_init(ndev); if (error) @@ -2531,41 +2586,6 @@ static int ravb_set_config_mode(struct net_device *ndev) return error; } -/* Set tx and rx clock internal delay modes */ -static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - bool explicit_delay = false; - u32 delay; - - if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 1800, according to DT bindings */ - priv->rxcidm = !!delay; - explicit_delay = true; - } - if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 2000, according to DT bindings */ - priv->txcidm = !!delay; - explicit_delay = true; - } - - if (explicit_delay) - return; - - /* Fall back to legacy rgmii-*id behavior */ - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { - priv->rxcidm = 1; - priv->rgmii_override = 1; - } - - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { - priv->txcidm = 1; - priv->rgmii_override = 1; - } -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2650,18 +2670,6 @@ static int ravb_setup_irqs(struct ravb_private *priv) return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); } -static void ravb_set_delay_mode(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - u32 set = 0; - - if (priv->rxcidm) - set |= APSR_RDM; - if (priv->txcidm) - set |= APSR_TDM; - ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); -} - static int ravb_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -2785,10 +2793,7 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->internal_delay) { - ravb_parse_delay_mode(np, ndev); - ravb_set_delay_mode(ndev); - } + ravb_parse_delay_mode(np, ndev); /* Allocate descriptor base address table */ priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; From patchwork Fri Feb 2 08:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542435 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 311AF77622 for ; Fri, 2 Feb 2024 08:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863337; cv=none; b=nfNuGYNa5n0blpG4kGaEt4M+3yjDrpaoNUmt2OHr7xkDLEtal9mdL70o1D27FxVwaMavOsUqzbkutncYOElwUoPD+m7FHGBZLghwZ0OjAK1B7woxt94AP8SkqHu/VR12PKRYnUf6xWdfREmwRLQiAKEkpMBZo2yj4a9y4TlaQZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863337; c=relaxed/simple; bh=ga3nLsmlUPHxC6lprohW+AJrVuYSdcwOBoQLKkHF3cQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IjImd4cuZDt91Gs4YXRE2J/hDK3uDQ23fFCu7QkxjQkv26jWfGQCqyJbune3lXDmtBy0ougGRm07P6mvgfQkW33kkR5dkbXN46rWkxDWi3nuY/tCi0KtyVKI6sHvxLpkoQS46hvZUzhinsNPtgyNU7fc9iMoxXR7SRJHVO2vwgk= 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=DZJZjDUr; arc=none smtp.client-ip=209.85.218.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="DZJZjDUr" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a271a28aeb4so270276466b.2 for ; Fri, 02 Feb 2024 00:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863334; x=1707468134; 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=WdhJGQ6s9m0NV+6M+vVWcahgWKgGCVymWdzgAMvS+FE=; b=DZJZjDUrNOwJoLmuu1njocvKCskmiT+FgFJ4ytSOefX/kELwOhtaJXI0GOe4DqZTbb Pdf3qOn7xDZTX1b7zjPyfqI4SGD+txtX42BYSPMqntir4Wb5RbtheRfOzD4BTK7/hmQV rwA5iHi/zV63THi76zmwzYHMPqbngQet23RDTY1vwFxBkVE8T3Id982KC2smjlOOo4/I T56VCQ80R8ZQOSEcRefFjTuS63tCW/wYrk0eGSfdN3wFrwg7Dojj+68uUwm80cJU9S65 O3+02uP9qFSGAvo2SiXKJJC/5ZSrEGNzHQ8uAxTid0HXKiuhXe8xyLeNyboTwkD5/dyH Z3BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863334; x=1707468134; 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=WdhJGQ6s9m0NV+6M+vVWcahgWKgGCVymWdzgAMvS+FE=; b=V+vJx08v2ga3XV1GwS8tCuYxw93nY7nUlCbApG18RpEScZbRjYgSZHfkXkaWzITHRg uq51Q1DieTZJoAaoKhuCqYR/BMAcaA4BgLsRDdakHQrFRIlvqDyRJNhLbBA0hEUmMEI9 Z8L1zzZpu/lJkaJMgJj6TxV3rOiLoS7Mnuq+bkH1dCvl59EFwcb0VuOFISb79IfQvbyD yX4NK5rrG3SbhuWFPZUIsjNcThbPPXazmtD/H6zVLPWiSbY6dPlQYelzrM7+r45RZjJO b74o3IeB/7obRIZbF5Ctpm/eMlQtxiKyMe0bdr6NnsKPKnvPFiGcaGcaoEeaykLNuLZf AIOQ== X-Gm-Message-State: AOJu0YylwyhW0V1gEAa0FE7Rr0FxIXlDsm4B7o1+mgFRvoKxwquuLPDR FCPcIBFhAoDTShwJoXMt8IxKyURglF22dFq0zTT7TUuiHpti1LaK31blDPKOpbE= X-Google-Smtp-Source: AGHT+IHnXMNwzUo2Br1/N/+O9GPS3OoaSwlapRSfwmI6tY0ezHXdEiAppUdX9nbCdqrt8XHHoCgxZg== X-Received: by 2002:a17:906:53cd:b0:a35:ad04:af7f with SMTP id p13-20020a17090653cd00b00a35ad04af7fmr1090979ejo.0.1706863334441; Fri, 02 Feb 2024 00:42:14 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV7uSh6uPMkU6fkq4gPzd3tNLJFMVKQ77Z+E4z7R4rS2P0qx+LV0rAsfKqUEMPt9jGqAwQ9TAribpLMglVgFtOl+5ay6lL5S0pnvPNz4b2X1yzzMGbwtaVxPwtC7vIZJH8pDyj/Ug4buSyfR5qau+TOwH8nnnPXEi2QxntsWbgBCe3aN3fDcIRAFZ3tSwTu9/1VmVfU4DeBG0BRyv+lpxZBI3duNQvkQ54DiDTh+tkRUPFdLjNxiB99no50iZLQcQ/b5ukV1RrUns60JFxIQsQyVIQLcnzapwmZ+acqEZ9C3rDRxy2c8JlzGAgA7kBN65XwmWjecHfdMXljZTtra/fb3nuaVJlx1mDmJlLMmpdv6TtUKX2rsJdHoBYnT7Dewx+cXSHm5+WNFsSsHw== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:13 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 11/15] net: ravb: Move DBAT configuration to the driver's ndo_open API Date: Fri, 2 Feb 2024 10:41:32 +0200 Message-Id: <20240202084136.3426492-12-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea DBAT setup was done in the driver's probe API. As some IP variants switch to reset mode (and thus registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM move the DBAT configuration in the driver's ndo_open API. This commit prepares the code for the addition of runtime PM. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index e5805e0d8e13..318ab27635bb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1865,6 +1865,7 @@ static int ravb_open(struct net_device *ndev) napi_enable(&priv->napi[RAVB_NC]); ravb_set_delay_mode(ndev); + ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Device init */ error = ravb_dmac_init(ndev); @@ -2808,7 +2809,6 @@ static int ravb_probe(struct platform_device *pdev) } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; - ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); From patchwork Fri Feb 2 08:41:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542436 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 A3209779F8 for ; Fri, 2 Feb 2024 08:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863340; cv=none; b=EqgUCrefadP+O4pTQa/4s7W6KA/9AXPHC8EEDBeXhmG4H3V9oRkYhmKAE9Pgwvxn618O769wJGGNQlUnvVzN4YNWXsGvrw270VJ1761ZDXZkdVVmjNy3+ISMZo3DX8vSdetgi1TUcUlI082UIFaOx1iW2rHzoG8rnE/FRWe4iBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863340; c=relaxed/simple; bh=3HIkBLfmG0k2J7i2Q48TrkFvh+JqTUAQoMPHL5/cn7A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b5o9v/QV1FyQOYUkbzlFcP/mcdjDGJwBDLajrPjp9HUABHtBEpOiecKhiNHYUvXk/UhZtml46DwRAvZ0qfuIyXVXzguSReNYQcWSSmkwqbu4GUmRjELQ84sMGIUT4lNQ23o3jBznMdDwZ6wZ7cjL30OOPBsdDv92CIBFfjleeCE= 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=inpPjhzX; arc=none smtp.client-ip=209.85.218.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="inpPjhzX" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a3510d79ae9so239932766b.0 for ; Fri, 02 Feb 2024 00:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863337; x=1707468137; 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=kPdGoRi9Q/Z94tgZI+Yh2dsfYo8XG51UXhclzkjwaXI=; b=inpPjhzXyY+TgXD+R1nJ66G2gvqrc25riMI0NF2TvG1v97WBF2+Jni7kAL8ZaJupTb wq9rjnh6a5S76CaPxlO6xL5RQm1Gp/rzzUdhqohgqpvQo2fyJ7LUzIdOsZXqQXKZzGiN X3nFoxBfTNQZ8JGf2cdcf5oQ3Slfww7aRJ9QnJ9LabzoNAC4qISk0kDlUbgPScWbZi2t KGsnGLF+1YFadfn20KPV1pxuv/N/EX9LkprRWsgCeGIZUczwkYVvNr+xJj3RBuqdbuT2 srG3rrrilwj5/Ca6/8bc3VJ4/dXhp9Gdu4jHyImGxMxAuT8ajsKeGkTmEQz1asR23+PT F8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863337; x=1707468137; 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=kPdGoRi9Q/Z94tgZI+Yh2dsfYo8XG51UXhclzkjwaXI=; b=mWRksumSgWiO1E7su8qzzkBorpw8slzhfNVUXFvsfIUdccoJc8TIg0IjM7JYyhkeyz +hSnV9XUCNXq40kXC4igUkJ7wkxOSSSVvgMXUh1rkG8XUA8gEl/keQ+jbAb0Q5DLvmEB u2TQ1Ht9VngwIBv+DQIZgsPdKthrvB0M2IEMX2s/UPxAuPxlYORSGUDys+olgSeTFfY5 L69/x7tWe8h8mfqQJ2Abqa7cftegLKaHNyZcC9Ha3sDnh6zEnxjH5WyrU8ovn+lmf7lU 6lxcCwo5F60g5wmbeT7uPq1WvhZKNodbfN/gfem7BNOG1EVWGPgObQqmH7sIERa+IP0B F/3Q== X-Gm-Message-State: AOJu0YynG6Q1+DCNP7q5TV4LqBucernMAw7dgnsBk0QnYF0Dh9+aWtx2 8ndTtK+Rs+0LobFXftW7tSbQmeR6+z1SGFADCSXFsW9F/gIu+dgfAgT+7Gc3bFs= X-Google-Smtp-Source: AGHT+IEdkKMD2YyKIjcbZQJRMEInK5fZvN0HL2AEdTD3QAGNSDQhn3jqRZdGSvnkLfOOYK84zwmGJA== X-Received: by 2002:a17:906:7158:b0:a36:cd96:4b5d with SMTP id z24-20020a170906715800b00a36cd964b5dmr2660222ejj.45.1706863336919; Fri, 02 Feb 2024 00:42:16 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUkcQo0AGkIAWGrtXqaZ+TEINEoWJ0aPBkGGmtlxzgxbyWn8izca7eLmJs848nuNalvr7t0zZf5NzfJH674q8K+1iv37aWhIq0BrsaAUwWsHZ3CVQFHRzF0IPz0WNsPnWg3XctHTI9xeHRzWScO13EfrL5VJ15RQAdC+ms7nnBnFauz+kZkIC5lRr+ZF1HXgSiATTe7WyQYV605cDGFgXb+YP4YF1Q3/9V20fiOCkuDW0YENrVP/heiJxuke70zembo2EpDEykCLfbToAEDihxje1YyM8j4boUbvpB6sp1t1fkU+CGdT9UHZ/3J7EgJNW6sUr2C1he4kMlXNQWtWqH4sGPrJhH4rZAau+2heezIZ98lyofMLoCjCYH/mxHROf4hwc1assGuf32FBA== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:15 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 12/15] net: ravb: Move PTP initialization in the driver's ndo_open API for ccc_gac platorms Date: Fri, 2 Feb 2024 10:41:33 +0200 Message-Id: <20240202084136.3426492-13-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea The initialization sequence for PTP is the same for platforms with ccc_gac and gptp (according to "Figure 50.71 Flow of gPTP Initialization (Normal, Common to All Modes)" of the R-Car Series, 3rd generation hardware manual and "Figure 37A.53 Flow of gPTP Initialization (Normal, Common to All Modes)" of the RZ/G Series hardware manual). As some IP variants switch to reset mode (and thus the registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM, move the PTP initialization to the driver's ndo_open API. This commit prepares the code for the addition of runtime PM. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 318ab27635bb..54099fef946e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1876,7 +1876,7 @@ static int ravb_open(struct net_device *ndev) ravb_set_gti(ndev); /* Initialise PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); /* PHY control start */ @@ -1890,7 +1890,7 @@ static int ravb_open(struct net_device *ndev) out_ptp_stop: /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); out_napi_off: @@ -2200,7 +2200,7 @@ static int ravb_close(struct net_device *ndev) ravb_write(ndev, 0, TIC); /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); /* Set the config mode to stop the AVB-DMAC's processes */ @@ -2813,10 +2813,6 @@ static int ravb_probe(struct platform_device *pdev) /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); - /* Initialise PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_init(ndev, pdev); - /* Debug message level */ priv->msg_enable = RAVB_DEF_MSG_ENABLE; @@ -2861,10 +2857,6 @@ static int ravb_probe(struct platform_device *pdev) out_dma_free: dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); - - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); out_rpm_put: pm_runtime_put(&pdev->dev); out_rpm_disable: @@ -2890,10 +2882,6 @@ static void ravb_remove(struct platform_device *pdev) ravb_mdio_release(priv); - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); - dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); From patchwork Fri Feb 2 08:41:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542437 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 C70AD77F3E for ; Fri, 2 Feb 2024 08:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863343; cv=none; b=RqgnQi5a/OF2ye4gQZFMNdA32kNTIbVEzNbKY1s0uuhmrqUaMXwWO4QKpaVgcqf5pWgdh/1/2n6zcU0T/meNy8+ixMbMS2BmSNaL7apMhUNFhEt9iWO/O/S9RjKjeIm5jlEMg8SW/Ihdxl6TN1awOGdHl4n8jiY24ieZ3cLnNQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863343; c=relaxed/simple; bh=jZ/JtSBDk6b8fVvnMb9jcB+g4KQkYzKFaOwQs0N0jOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IKrXHriR+++stNWK7SyO3f/VFBp46u4s8LOFmmvK/HlkxEbDb4VwQnaDJdcjsbrOgnpaMjVKy7/VN+ut63m13suoMfspjzJJEOdgc5rhKVvf7yxhrdE9RtyX4CTG9f2TgmfcpcC5jgjmL9mAoNjOBTv0XLYDBg2R0UqCUDIvAQ4= 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=ERbCg8F9; arc=none smtp.client-ip=209.85.218.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ERbCg8F9" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a3510d79ae9so239939266b.0 for ; Fri, 02 Feb 2024 00:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863340; x=1707468140; 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=xdBRN43/f+IaSeAWmmcwymoLpbD8uhnfyRcjVPy2MFQ=; b=ERbCg8F9EXn7Cve1sUCsMG/fDAYF79O4Md8grwG6yTI5Y8Dpu1sJW5hUTXJbbgJO9t 9myZqaomA7ujmqeGb/6gFhEIZb5JkR8VAUSpuaC/jUt3pbmu9f5kjvJNKJyWNR3cJXFN tU+DapHqpiR2oxG2IPmVkW3Tb71l5Ocs9dFg9Nug+Z4r6IJVOrL7PM17efRDWfW9oCYW PDeXszDKKwyrQQSUyRsjJZw7EieLc9KAnRdSS12yJyr3PW+o5TnwE9UbmwkSvokCWU3t 8Idk56s+QBk4OGrEmOKZ4EjI2fqN36U56Dcjl7IrwXOjCPICfyj9edgJVH0bzAW9WbCI DGfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863340; x=1707468140; 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=xdBRN43/f+IaSeAWmmcwymoLpbD8uhnfyRcjVPy2MFQ=; b=hVI4iotSAjrD1ysYxG69QeZPG4EZGlBDcl1WR2IVliG6hHv9WCaKeVg3Lrg97tM+TO ZOBhSkosK69RecJfhwDPIhYdTcQYt3uLRrptTK5ufx8wHfERdgEnn67WI1VihPlFFgA8 alxtSDSu+1o7Ty0OyNbS2eamZjldljgUXx/NtdKkp4AnMSVQNXlpp0BW4vuKkFt4ToNl 1XvY9A0U8klQqa5Is+JZEwmrinXk7onnwfV7gVAAKd31P1/2G76v/2Txg1XDvZVS1PiJ b3L8qCRxqsKa2paiyFZMJoB6TF4EqczLQxW4/i5uCXfbDkB0zBwqPAJYsBMwSuPrta3J CbWQ== X-Gm-Message-State: AOJu0Yz5Vhk4BXdAxr+42VdgqUu1BvMQK9zzyRKv0pRoQ/PWonw6iUwu xDsI6AsLJ0Z2D1aMME/KmjveSFyQPGOb/QPeT9xSr3rrnMzu6ccoVsc5lmu+z/I= X-Google-Smtp-Source: AGHT+IHR2cDV4MQnJeg7q1Vq7RxAkmUq0ihbDA6MWkBVHgUbN+RHXN0c23xoH15dPCKl+J88sRxFOg== X-Received: by 2002:a17:906:48c7:b0:a35:62a9:a659 with SMTP id d7-20020a17090648c700b00a3562a9a659mr4595883ejt.72.1706863339945; Fri, 02 Feb 2024 00:42:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVk4KMSGP5eXxsUW72eskLr15QaB+6MF7/grCx5vZlhpLiedZvbOWbXrupftbIgQwJfTXd4YsHrmATa2dJyUNRFkLSaPARU4vxDROwIuo3yp6B5Ir8qLSG8XsCJf6b3bFQX9TDbVCpDn7jNakLepaAUSnL1ARP20uLuFJnwpUzrDjCO231fArdzLaf1HJsszHB8fJmz41tzXLKRQJG9+ioQN94KJfkFNUomwN9py2GLmoXaOfl40SR43jghyhKNBSNODbTxeY/aKmmIX+ANc0m0UfRo7KjIAwOoNXuR7zG2vWImu4WELECPfXEv0Lhm9k/O9AarJmDDRax/4r57BnXPkVbzxlX6DsUEZTWY2MATxzqGPuMI4LaV+rqDLDS3Ra0ibuCrlcm1SQqSuA== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:17 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 13/15] net: ravb: Set config mode in ndo_open and reset mode in ndo_close Date: Fri, 2 Feb 2024 10:41:34 +0200 Message-Id: <20240202084136.3426492-14-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea As some IP variants switch to reset mode (and thus the register contents is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM and save more power, set the IP's operating mode to reset at the end of the probe. Along with it, in the ndo_open API the IP will be switched to configuration, then operation mode. In the ndo_close API, the IP will be switched back to reset mode. This allows implementing runtime PM and, along with it, save more power when the IP is not used. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - fixed typos in patch description - collected tags Changes in v4: - set config mode before reading mac address Changes in v3: - fixed typos in patch description - in ravb_probe() switch the hardware to reset mode just after phy initialization Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 78 ++++++++++++++---------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 54099fef946e..0dab98ea615a 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1756,6 +1756,27 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; +static int ravb_set_config_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + int error; + + if (info->gptp) { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + if (error) + return error; + /* Set CSEL value */ + ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); + } else if (info->ccc_gac) { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); + } else { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + } + + return error; +} + static void ravb_set_gti(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -1864,13 +1885,19 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + /* Set AVB config mode */ + error = ravb_set_config_mode(ndev); + if (error) + goto out_napi_off; + ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_napi_off; + goto out_set_reset; + ravb_emac_init(ndev); ravb_set_gti(ndev); @@ -1893,6 +1920,8 @@ static int ravb_open(struct net_device *ndev) if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); +out_set_reset: + ravb_set_opmode(ndev, CCC_OPC_RESET); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2236,7 +2265,8 @@ static int ravb_close(struct net_device *ndev) if (info->nc_queues) ravb_ring_free(ndev, RAVB_NC); - return 0; + /* Set reset mode. */ + return ravb_set_opmode(ndev, CCC_OPC_RESET); } static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) @@ -2566,27 +2596,6 @@ static const struct of_device_id ravb_match_table[] = { }; MODULE_DEVICE_TABLE(of, ravb_match_table); -static int ravb_set_config_mode(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - int error; - - if (info->gptp) { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); - if (error) - return error; - /* Set CSEL value */ - ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); - } else if (info->ccc_gac) { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); - } else { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); - } - - return error; -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2785,11 +2794,6 @@ static int ravb_probe(struct platform_device *pdev) ndev->netdev_ops = &ravb_netdev_ops; ndev->ethtool_ops = &ravb_ethtool_ops; - /* Set AVB config mode */ - error = ravb_set_config_mode(ndev); - if (error) - goto out_rpm_put; - error = ravb_compute_gti(ndev); if (error) goto out_rpm_put; @@ -2816,6 +2820,11 @@ static int ravb_probe(struct platform_device *pdev) /* Debug message level */ priv->msg_enable = RAVB_DEF_MSG_ENABLE; + /* Set config mode as this is needed for PHY initialization. */ + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + if (error) + goto out_rpm_put; + /* Read and set MAC address */ ravb_read_mac_address(np, ndev); if (!is_valid_ether_addr(ndev->dev_addr)) { @@ -2828,9 +2837,14 @@ static int ravb_probe(struct platform_device *pdev) error = ravb_mdio_init(priv); if (error) { dev_err(&pdev->dev, "failed to initialize MDIO\n"); - goto out_dma_free; + goto out_reset_mode; } + /* Undo previous switch to config opmode. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + goto out_mdio_release; + netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll); if (info->nc_queues) netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll); @@ -2853,8 +2867,10 @@ static int ravb_probe(struct platform_device *pdev) netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); +out_mdio_release: ravb_mdio_release(priv); -out_dma_free: +out_reset_mode: + ravb_set_opmode(ndev, CCC_OPC_RESET); dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); out_rpm_put: @@ -2885,8 +2901,6 @@ 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); - ravb_set_opmode(ndev, CCC_OPC_RESET); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); clk_unprepare(priv->refclk); From patchwork Fri Feb 2 08:41:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542438 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 B02EA5FDC2 for ; Fri, 2 Feb 2024 08:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863345; cv=none; b=mstC4PpaIoUn27S0Yk+9p0cwzhoEZiPBckEn1Igb1oe7Ww8nqlgN607MWpAEvmacajNKeQQZtiggkFXiinqtufFO8D8fx4SHP2gAzvhPkep5gXMYjEEXkDHMTPaQLBqqOKeN/l3LHEVmrsQNfS3D/JbuC5bh6nHIItnpTQUqZf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863345; c=relaxed/simple; bh=WOBBQ89xE5VEPTNb63Hpn2LLLh1odlsZA/CvNjQEU8M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dkWtXbiVMHcsbWRXPIvS48CiQBe+BkJcKwjY22PITPJenEnWRhi/Oxz50+VMKuo5YQzmCUCFFWMojdAiu+dZyo0eVQBUoZBVuHMr3s6Qu2zx3G/OVUwaDk61vLDbVBDvCLMoKphXI0PAdIO2tYU+zMg4VRylivJcl7heuEE9xwE= 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=h54LWq1Y; arc=none smtp.client-ip=209.85.218.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="h54LWq1Y" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a36126e7459so220998166b.2 for ; Fri, 02 Feb 2024 00:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863342; x=1707468142; 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=zuBURh/xdc4/Pg+TNsZUpUsKplsL66NpMwBIUlAaHiE=; b=h54LWq1YArTK7kw5rKaoCF2jahx11xfO0UL6SbbUp05Xba+KoDsxoa7iVPCpBKxlqk 5tSxjH35vz6UMGojIg8wyWKL2xj+hRjUW4X4n+n3U65SNXECkIvIwSlEUfsaT9uUbHAw yOMs43hUtIW/O1YXzHJd/3ChHvG0Hld6RucM7fUqLooxYk4w2/qmaGQWSXQev2LtPVXh JceQ9PG9MUrmx3qYPZaOGjEtLvEZTiy/kM78PzirdjgUsGqj/TPO5USoijMh8PL/NfjW k4qmhYPUv3WYR0ISk5hhcpXtbkwlfRKFdYcNWTecjxIYuU0Ph5KfxrwWQRqow1jLzHpk UCVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863342; x=1707468142; 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=zuBURh/xdc4/Pg+TNsZUpUsKplsL66NpMwBIUlAaHiE=; b=HMP4VWp/VzILyY8VyBO4O6h8B2NWv95WpVWguNB9WI/SrNugi55oxA7SNMV7UXjq4R JnxLsrH31v0wR2QnhtmdR8oiR6qH0sSr4gE0WBJH8w5nVY4q6PsFcgc3r9kFI5qHiiQ6 sp/4XXUADm6kF0F817O+YhaJpoGVQlM0DI3+FUrOmt6L/mJof7HDwJUwCOIm/iajoApE kGRtc+mflBzp05CHp5aTTPIM5oWLsJ2nndPgMMIAetyLw+1ZLLlb+orLIqosGwnk8QLu m5expEmpuCFSyJUrTMI9EHFMLKoVktwYofgYvcdGPNjuc4S+7YoL8V2LucjWXFUGVro6 7XRg== X-Gm-Message-State: AOJu0YzWuFZtrcLOcMpJm1gLV//z2RbHjKAEjeUTkN90SnTkn5v3ivvH /oJrdFy8ca97IXE0h1R3wO0g+gvzUJst47S3ye/0J0YFFYVVqBP3h4isOlUkTrE= X-Google-Smtp-Source: AGHT+IHYVj5RKvUT2QGhcm3+Un4FLYJ34y6vVsJHsb2L8R+8m5OIyvAcHcCyDabaYHUq2sAG+7K9jA== X-Received: by 2002:a17:906:d14b:b0:a36:7189:af7f with SMTP id br11-20020a170906d14b00b00a367189af7fmr5658629ejb.50.1706863341961; Fri, 02 Feb 2024 00:42:21 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWxnLjE+Dj86SK0a5P/j1S1/oNiaOMssHUrYUW/HT81rC43H2dNa34RVu+9sUfkkoOLCaw/tuSDwIME4TnPypq5bmvyhrl7qour3gkZgf/96SNvxrZJdeThDFkcVJxk9WUDKg2fiaqiqtyjh8+uGmcoAvvCDIbQd3XeD2mP8Xah23kVtxnO2fNVGtj155AN0AZ2I7QHiUXyDYUlGZZ03ZRo9W7wuc4xAkcjbQnuni2JkU9+9S4JHePSaevj8/QmgQNjh0P3wPXq8D3jTqSXewHMTAWWhkh2TiOCBIP7xQGpkJi70QUnG2ssBYyCYd715W/2TZzmMNUTgPSEcQ+TZj7ewLv6AMwkvVGdHbQtKA6XV/5zySC22Q4Tn6rTOLiUAJJQpTz3jz1NyWyi3g== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:20 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 14/15] net: ravb: Simplify ravb_suspend() Date: Fri, 2 Feb 2024 10:41:35 +0200 Message-Id: <20240202084136.3426492-15-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea As ravb_close() contains now the call to ravb_ptp_stop() for both ccc_gac and gPTP aware platforms, there is no need to keep the separate call in ravb_suspend(). Instead, move it to ravb_wol_setup(). In this way the resulting code is cleaner. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0dab98ea615a..661236affa5b 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2929,6 +2929,9 @@ static int ravb_wol_setup(struct net_device *ndev) /* Enable MagicPacket */ ravb_modify(ndev, ECMR, ECMR_MPDE, ECMR_MPDE); + if (priv->info->ccc_gac) + ravb_ptp_stop(ndev); + return enable_irq_wake(priv->emac_irq); } @@ -2961,14 +2964,10 @@ static int ravb_suspend(struct device *dev) netif_device_detach(ndev); if (priv->wol_enabled) - ret = ravb_wol_setup(ndev); - else - ret = ravb_close(ndev); + return ravb_wol_setup(ndev); - if (priv->info->ccc_gac) - ravb_ptp_stop(ndev); - - if (priv->wol_enabled) + ret = ravb_close(ndev); + if (ret) return ret; reset_assert: From patchwork Fri Feb 2 08:41:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13542439 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 2284679DAF for ; Fri, 2 Feb 2024 08:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863346; cv=none; b=e9/Y46cXEEozxHbzobCxWNppkoNmgSqp2tIKZMBc4vx1FW3IBpw2VTTJ84//bS3jaRVy+5Hma2NuMhDAHDFWj3KSR+MWxnACZ5U/gCgTgjTe9GFClErZpIoFLqLSqtHcALPOc3qvxXroqOH/KLqSXV8C+06fKr3yPK5TehcqvNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863346; c=relaxed/simple; bh=JVshC7X6jp5iUKQ3s53GX1xxIrB2+jX9y0nLCqWFTPo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rNcq+8B/E0VdbHZ2D8ZOn2Rb3aew8pS/znoGaM58PotUuTTewri3SZYvcdU/FfQiH7WzPcwVYlbNFeoG4fnO2I2bs/fCy0y3MgpY+UBigEz04edsKJOm5dGORoeObLsmXyvyHe9+TMRS+9CSwqoabxWO+S6Z9IcVQsiMBSBO/jM= 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=okuZDAAz; arc=none smtp.client-ip=209.85.218.48 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="okuZDAAz" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a359446b57dso233632566b.3 for ; Fri, 02 Feb 2024 00:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706863343; x=1707468143; 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=zs60FNMiWlxCExO9vXRMyYdFHoUSgLYGgL3+MWbZfl0=; b=okuZDAAzUXE75QcoQMgYt8AbbK6Lm4tfad8raYYdggk8Yq9VjjePA7YmSR7H/3YAYa 68XgwWww7ODalzJxzYOwn0xS+v3/HKODS9APIAFutNLYT4hWY/jpc3QH/mw7mn11TUiI Yrv0rJ4//nVxOT6FKhs1lGH39T2t7OcWGlDWNryjPiX+Yv/H6Sizx8Mzq+rto7TLALcY SVfNE9AiGH0BvIktKfe60kIadRTXAZhQp/czjMF/qE31vvFHdQ8bk/Llb759CbFhd9uP B+NPfIY8CSqzUm+qokS26xW8OwKhpmLE4kR3yMAZQFVH6tAgyvtUij0FsQgykDg6AAnX EfCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863343; x=1707468143; 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=zs60FNMiWlxCExO9vXRMyYdFHoUSgLYGgL3+MWbZfl0=; b=dz8g2rlznO9go+zE44fLXmK8T6bQtAvsTAncUIZatB2AluMUy/J4tDZP3gjUl+ZYIs qfLj2sPMMr0YLXf4eJj3VrceqV/JbTIbByPYDuMmcuUclpKVpQzrtkIAylI/BJNnHgEl C4DvojR6Hu+jdXQlek0R9Gl/cYReNWq4OKPGzc6v5YEvfGMPz3gmqDUA95sYgdJMtTFq wdGYfkfkyfy4G/EkHkjX9nnT49I10BVA2UG6WDUuiB26RJXvhUO5xwdG5iWSi1sKsjUi Zbno2ht4ydFw5pbu3MKf+6Y84anxBp2afoneA5mKTVDl7izwXJu+G5kwzi35Q2KMu4TN XUHA== X-Gm-Message-State: AOJu0Yz9cDn09F9mILVoPYbvv/FCuvxmKvU8dhDpWGWvbFh2ay7JtAFe JX3cs0kkt03M+spTiYtM/aRNGL/CoY7PFVz2Tpjl6ocwiGlGwpDTguoumYxlWzg= X-Google-Smtp-Source: AGHT+IG/E0v+iAcGvMeGvRSwVa4WaMqCJFtf7Z6fBkY1Kjgb9SwRU/k9I63KBz/mL+Z54gJwA5dpzA== X-Received: by 2002:a17:906:4091:b0:a36:c2a5:d0f8 with SMTP id u17-20020a170906409100b00a36c2a5d0f8mr2636274ejj.34.1706863343447; Fri, 02 Feb 2024 00:42:23 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV6vjdQXUgGOWlqpX6qczcGspOtnavdUK6B7HzFv5OJ5Kx5Ig9kuPoufI1yMbwbPMEfjLk+ZmjiDcbiavmeQ3515+3J3r/LOIZxpksIW84pHGjJdsx9UxcQfoxPeVPeXgxtBzll0mDJy6ZXfeB3hX/UMkiZ9mTCT9mRBPmech8EAyykwCI9MOx1UQCf+NI6qLUa5T8iVy6SNr6twlzNwz07l+CzMwDYep5+Z8+AWosPrA4YkHPNBB//jVeUOeaR88axT1VOcVHxa/od5Igi5mB8pLCQdmwvZRv3SzVVr89S61EKkn4vIAVZypLuOQY72vz6tRXg8U7A1ROJlyw7fFWhqA3afFASBKz/4JBoq2rRJD3OxSEOti9Pq5gwTVZXmu3Oo7YIPHlKk5SuAg== Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id oz35-20020a1709077da300b00a361c1375absm631642ejc.133.2024.02.02.00.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:42:22 -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, richardcochran@gmail.com, p.zabel@pengutronix.de 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 v6 15/15] net: ravb: Simplify ravb_resume() Date: Fri, 2 Feb 2024 10:41:36 +0200 Message-Id: <20240202084136.3426492-16-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> References: <20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Remove explicit calls to functions that are called by ravb_open(). There is no need to have them doubled now that the ravb_open() already contains what is needed for the interface configuration. Along with it, configurations needed by PTP were moved to ravb_wol_restore(). With this, code in ravb_resume() becomes simpler. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v6: - re-arranged the tags as my b4 am/shazam placed the Rb tags before author's Sob tag Changes in v5: - none Changes in v4: - none Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 58 ++++++++++-------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 661236affa5b..9521cd054274 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2939,6 +2939,20 @@ static int ravb_wol_restore(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + int error; + + /* Set reset mode to rearm the WoL logic. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + /* Set AVB config mode. */ + error = ravb_set_config_mode(ndev); + if (error) + return error; + + if (priv->info->ccc_gac) + ravb_ptp_init(ndev, priv->pdev); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); @@ -2978,53 +2992,29 @@ static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; int ret; ret = reset_control_deassert(priv->rstc); if (ret) return ret; - /* If WoL is enabled set reset mode to rearm the WoL logic */ + if (!netif_running(ndev)) + return 0; + + /* If WoL is enabled restore the interface. */ if (priv->wol_enabled) { - ret = ravb_set_opmode(ndev, CCC_OPC_RESET); + ret = ravb_wol_restore(ndev); if (ret) return ret; } - /* All register have been reset to default values. - * Restore all registers which where setup at probe time and - * reopen device if it was running before system suspended. - */ - - /* Set AVB config mode */ - ret = ravb_set_config_mode(ndev); - if (ret) + /* Reopening the interface will restore the device to the working state. */ + ret = ravb_open(ndev); + if (ret < 0) return ret; - ravb_set_gti(ndev); - - if (info->internal_delay) - ravb_set_delay_mode(ndev); - - /* Restore descriptor base address table */ - ravb_write(ndev, priv->desc_bat_dma, DBAT); - - if (priv->info->ccc_gac) - ravb_ptp_init(ndev, priv->pdev); - - if (netif_running(ndev)) { - if (priv->wol_enabled) { - ret = ravb_wol_restore(ndev); - if (ret) - return ret; - } - ret = ravb_open(ndev); - if (ret < 0) - return ret; - ravb_set_rx_mode(ndev); - netif_device_attach(ndev); - } + ravb_set_rx_mode(ndev); + netif_device_attach(ndev); return ret; }