From nobody Tue Dec 23 20:10:13 2025 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 207375FB8A for ; Fri, 2 Feb 2024 08:41:52 +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=1706863314; cv=none; b=kjPniaT2y08Jx6J4sN6cA9i6iX6lN5JIVGRrBHbiVs1vaXAQQbI9rbQ9XjmsKFpSsL203lCA+Atq57HhGOm0y6gBtJdYmnGKMjFPiXq5WPs7OXC50zyb+V2AuD/0grATG+IsrYiBw1qnHj4fPjon1C5DSPF2B1ri2vk/YSH8STs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863314; c=relaxed/simple; bh=wUt008c4L4wlWChR09y86kFZe0k8vYYcMrzbja33YqA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IIrPl/cnzZL+ko+auncCDqXi1YY3VyWLmmkvMiqI1zCBoA45AwKM++DC5QemVC3L/0hbKrBZMCHdOC09M/eg6/M7YIj4qsn5htwmJKIcI3xpTdY9pcDr5Uvh88NtXthqElCDHMwfc4H1sIarSW1Y8ZU2bOWQGvCxCzwnKrmrPD8= 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.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="T85UdcKD" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a370315191dso50604466b.2 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=Kmoj5H8blmafTj1qtmLldmJrZEOSafX6V507m0ECTXXeRQvzfdc0pJkN3/1LqdtFIJ 6IZALbl4IS68tQ1mUbN6UbeHZgc0IkCHo0yE67LJknStmi71fMeMUEbIMwGleVCEeI79 +KBxVOdMD5vjwfMDNDC60JCZYmdbAjMbLXCAgI/YtKS4MjnWyjJLzGITrpLBTIlkUWRb PSpbKbZwuI/34NIabkUQCrgX5l5dyU25KhGhB+Ai+nSEvu9H318nrJzx7U10mmk55tBW XkXG4SGO0xJBOKiSFK/0JgqtRZEUXRdN8WAyg7PXzAhuBFlMouEOXA0oPC5eSslGmzNv EyGw== X-Gm-Message-State: AOJu0Ywk5yUhaL6U9/Auc4KGn2hzPqhSI/CIAtfTA6Yx8yCYSbXxsOPR 9D4aWKiK9oCfH9YmsMmuJk+8TFubV0y6cR6k3PAsZV2o6zusPexszheEMDF1vxE= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 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/etherne= t/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 =3D napi->dev; struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; - bool gptp =3D info->gptp || info->ccc_gac; - struct ravb_rx_desc *desc; unsigned long flags; int q =3D napi - priv->napi; int mask =3D BIT(q); int quota =3D budget; - unsigned int entry; =20 - if (!gptp) { - entry =3D priv->cur_rx[q] % priv->num_rx_ring[q]; - desc =3D &priv->gbeth_rx_ring[entry]; - } /* Processing RX Descriptor Ring */ /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); - if (gptp || desc->die_dt !=3D DT_FEMPTY) { - if (ravb_rx(ndev, "a, q)) - goto out; - } + if (ravb_rx(ndev, "a, q)) + goto out; =20 /* Processing TX Descriptor Ring */ spin_lock_irqsave(&priv->lock, flags); --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 D73355FDC1 for ; Fri, 2 Feb 2024 08:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863316; cv=none; b=PjJDxYjw/3VBgWOjO2IMOcf7MkOPGRm1c9ftIeBtctzhBggYbtJnRYAe9dmG9LPT7oacjo1Lyl9IymRzTwXDtlliJEbOTJiznT5DKi7/7YDbAShLACl5PrtyasAA6ayJ56nevKO/6wmBY+EaRQ0NNEVeP3yJMkQx2IqJvP6tNQQ= 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.42 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-f42.google.com with SMTP id a640c23a62f3a-a370328e8b8so51711966b.3 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=rs8ACKAMMDRHN+uQTmBv6BtILjBR20lXK17Qrscimy9jAsRttR/DD92naJ8TWd0NGf ygqPX13cy/EZW1nTCXK9V92UY+KGzRfnsr2vWgJDyq5xN4hGhMspsvlXVxWi4kmscrXm U04uXKsih3kLUy7A1uBkiUOKeySBqbd1osbg4/Yn/aUgAcSpIkolc5pxXs0ufCgVMOhb 1UwjQXUlkilykkBD4qDC8h0f+W/BYV1J/NXBIozXyZBqysqji2vhG1a+6864S30SheRN 6wGXC9eH8X3QIT72BfLNvywnXf5f+Wpqx99lWJ93ziz6FPH+LTe9m+U+wBzSYW0MH9ol q/Ow== X-Gm-Message-State: AOJu0YzR/XSLBXE1ijEeXjdx1BVKYC4KXNAHQGv1jZsw7aNvIzu0YZQu mOVO/G5HmVvAFzRj+vFCcZNvJrpHmaOcdeNDG98iqgl5KQUgFEdlWDpiR7VY2nc= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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 =3D PTR_ERR(priv->gptp_clk); goto out_disable_refclk; } - clk_prepare_enable(priv->gptp_clk); } =20 ndev->max_mtu =3D 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 =3D ravb_set_config_mode(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; =20 if (info->gptp || info->ccc_gac) { /* Set GTI value */ error =3D ravb_set_gti(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; =20 /* 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 =3D -ENOMEM; - goto out_disable_gptp_clk; + goto out_disable_refclk; } for (q =3D RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt =3D 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) =20 ravb_set_opmode(ndev, CCC_OPC_RESET); =20 - clk_disable_unprepare(priv->gptp_clk); clk_disable_unprepare(priv->refclk); =20 pm_runtime_put_sync(&pdev->dev); --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 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 10A1D5FDDE 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-a35b32bd055so237183666b.2 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=XWNWTHADGI4sH1QgYZ302MkX//C4XainRnjlAqVC7c3GFtKgbnHj85Ii/yK7CorJKs GzvLVxZJVBeFnlwL6LNDsHBYm/S/IsSUUOfxbHpDC1YPoosAZp2BIvMNfqxXFTfoW/Rk c5ivDtkWFzITq2gJBT5yY8WWgIPAYcxFnS7qV8M5XNoUY+1XP7c2rvO3pq7kc41fTly/ ItWCNpB6F1tN8qTrPQ3T/hVXqheKdEpB1qpSGmeeTwVLQiSkMhzr9kbzy4H1gZ1qUB+m /Mxc8tGQ6DLMoEexJEyvjzgps1QN8V3Z8fwEQKmrRtakyMOyC/FUfuR6bmsfFFTE26DY XdyQ== X-Gm-Message-State: AOJu0YyPAyKekFT3mAqPWbRgA1ixfIn6Z2CElaxqXN0JmaiNo5kyv7Es pD6jb/UwJle6/X399ksOiBCANceO2ytjDuhjsAzW0tgk3cgsHSrMf57dtaxqCRs= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 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/re= nesas/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. =20 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/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; } =20 - rstc =3D devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + rstc =3D 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"); --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 33CE16087F for ; Fri, 2 Feb 2024 08:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863321; cv=none; b=ScTbvDTCucpzuZKR2/0sDUdYRlPVasLgmjPF+XuEFjgrrIa08smp1o+FjCiBegfAF81qqxE03zKPerHvByhz4FVZ/G5AykFMo13WqbZYiC1LD9nTJbldrqaAc97NtfHrR06XrNfCNEKLRvPPJuY59utow145OxLVNkej8Wbv8Js= 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.53 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-f53.google.com with SMTP id 4fb4d7f45d1cf-55ef0465507so2217287a12.3 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=qnPDntn0rkFa44y1PIDDd3WKZghvCfrxSo2EaDTGNnWCpDVJl02kaxe/wQ6O+1xr29 Df6rhQw14YDk/k+OcP3yvtRAjdZJSqDRXQTwM5BG2B5Ve138+xJr+D4/d6IhVeAdZ5EK pfVA77ZJGslUqNwFgSB77LA/5mGXJFfN/GEC/N4o3XNJuAe2eE+x/FkObBPrP9DeLi9s 1Cwbp8PN5Z7JkEBauw0p0jsiKLozFxS9Gnw/SD0NcxTMruHoL7I0pCgnr00U8rHT6snt fSaHbXyQIvBKK7qNjwSt19FZodtq3RygfEVL+efbpNxL36n+ga3hJ7+dPljsmcGBI/JI PLGw== X-Forwarded-Encrypted: i=0; AJvYcCV0rTXnW99WSqb5rP9TyVeKTbQyXIQoNMCahc06YRCsylJhf/FgbcDKGSiDrFEjh8uA/3GGfJH+NSb73sMCFHWSWwzE0HEL1zlC99iF X-Gm-Message-State: AOJu0YyiVNpYnS1qIAzxeygjleXdpktYULVDJpAv+IMZmsuxxnfm6Nb+ 8fit9HKIrsfHZtIWPDlgyIavWPyNGrcYmgoN4OdG1n/pg/cAYbBz/qofuWcU7Ms= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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); } =20 -static int __maybe_unused ravb_suspend(struct device *dev) +static int ravb_suspend(struct device *dev) { struct net_device *ndev =3D dev_get_drvdata(dev); struct ravb_private *priv =3D netdev_priv(ndev); @@ -2993,7 +2993,7 @@ static int __maybe_unused ravb_suspend(struct device = *dev) return ret; } =20 -static int __maybe_unused ravb_resume(struct device *dev) +static int ravb_resume(struct device *dev) { struct net_device *ndev =3D dev_get_drvdata(dev); struct ravb_private *priv =3D netdev_priv(ndev); @@ -3052,7 +3052,7 @@ static int __maybe_unused ravb_resume(struct device *= dev) return ret; } =20 -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 dev= ice *dev) } =20 static const struct dev_pm_ops ravb_dev_pm_ops =3D { - 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) }; =20 static struct platform_driver ravb_driver =3D { @@ -3074,7 +3074,7 @@ static struct platform_driver ravb_driver =3D { .remove_new =3D ravb_remove, .driver =3D { .name =3D "ravb", - .pm =3D &ravb_dev_pm_ops, + .pm =3D pm_ptr(&ravb_dev_pm_ops), .of_match_table =3D ravb_match_table, }, }; --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 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 F160060BAE for ; Fri, 2 Feb 2024 08:42:00 +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=1706863322; cv=none; b=DJ74zIIeKOa41DStOIGgtHW+Q7Ehx0w63s+Wr+nFu8+V69OLkYWSnc9uwQ1HngCtQrlHr5FH3Aa6Zx1LgfGLWkWV39padoxPeV2K/bJdPeLv71uJY1GUx1sSik1OLfkTW+5U7S+I9PPkDKD8DGoiHERzrHbHwWXH71jc1M6vWog= 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.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="LDAwv0yP" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a370e7e1e02so32289766b.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=V5cFeU4RDf8J1pFWZ8jTQgXgDLXhrSsKHr4fdB/mXX7R1cYLmYc7uJuIkiul/3Iru5 qHcCrdKGOyspI4jze0D+7IidBNZC/mRWc4F79yF/DAcahh6LRJI75WWvLy3ej5WLsIwM Bg77r5mRhl1yqsv102m7Es/mqrgrpWyrZmqrqPHrfUJL7dTfxM/oYNLJi1Ans9ldPtib eX2E7hIM0LBgXFYxC8FYzp8SMHU1HT7L0gcGkyH4/gJIuws1q4PQYjoJ0pyyRFdyj1e5 bJBwQY5IOXTFsuJqtG0/LQCXtjQnBz59ldjPrjxtI25HqCIBEP+jjnofnBfivgyWyjRR lwVw== X-Gm-Message-State: AOJu0Yy6ZeeLYPOvGju7JMrIeo6SCFitasgTRjyEw4fDc2sKw/8x6ckV 58vtMNFTRtqKJFBGszvoRGlxZ8iS4NIOvj3pcyQjy2SiRX20Erb/oskQeqvUoko= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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 =3D netdev_priv(ndev); =20 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; } --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 149E461682 for ; Fri, 2 Feb 2024 08:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863325; cv=none; b=uSv+R41hE+Olr6iV9KHHYyEWEqB8XHuGgbYVJnXHzJg1oAi+q6UamOoEwUYsOOmmoCnzNiHoAvBauLpYGHe0nQlnFRaTHs0SpjAjbFAHTPsEsvY/jiwViLqnKSk26J9Ccdvy/hak7c02tzWDSYKwihJcU1T8gYDA8tE0TKEnvGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863325; c=relaxed/simple; bh=F0bxqF2Bs1iyl0FY+5Twbfa3UZ4Z4U0JEOAmmYMmU2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AHU08NCZ/d3/ddW9Sq7EfsFLWYwZt32/A4x1NRW5aKRSIvfy/tfOx3tp+qcwhEJKKRbP5ESr12NpQVIFosOUTQgNqCnmfijwuz+xc0WweiniQraQw1iEhncXH7VTtJi/zlkUo6MClj5h4w9Zzugl9xy6TOfAn+XlUCcmNmKWKoc= 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.208.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="iTrYRCMS" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-55a179f5fa1so2515529a12.0 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=G6YOOJPNFDQITVNNdpgVGzN6dHK4UrbPz+TZtIoP0c69cejESe3TwgMEsrU5oasw0N buYpssgrWrUbi45OTOrG6d9sUC6swvSXzThmhyjFVJMDAWIiU/HFi8MaAYEjgegxfhEN WiPuZBEOp4x98CvfBtwtzIOJQ7ZOfpvnL9EaPUkC+x8I+cBAtwGTyToSwFiCSUZn8gpk XEa08E1R4BVtjfR9mPHl7/TcTUXElC52Nb120j1XROkGDiV3EtKK4/wZahcTkuTSgtWe Wu5WT5ACzUU5iQsznIu/+6LbCLvMYW7+JYsR1GWJA3L11yyMG+azDw1zzF0KOd0+ks/n jl6g== X-Gm-Message-State: AOJu0YxBES/jeE1dHk7GoV5sl7b8R6zcYTB2ZMqxQq3ZvW7R61VS/7VT xbh2DdaaN9xeKVSSwO4pTKwpXF6h68qNfcv+WNpDopwRE4MX1Lu9+lh/FN21Ozs= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 =20 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/etherne= t/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; =20 if (!netif_running(ndev)) - return 0; + goto reset_assert; =20 netif_device_detach(ndev); =20 @@ -2990,7 +2990,11 @@ static int ravb_suspend(struct device *dev) if (priv->info->ccc_gac) ravb_ptp_stop(ndev); =20 - return ret; + if (priv->wol_enabled) + return ret; + +reset_assert: + return reset_control_assert(priv->rstc); } =20 static int ravb_resume(struct device *dev) @@ -2998,7 +3002,11 @@ static int ravb_resume(struct device *dev) struct net_device *ndev =3D dev_get_drvdata(dev); struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; - int ret =3D 0; + int ret; + + ret =3D reset_control_deassert(priv->rstc); + if (ret) + return ret; =20 /* If WoL is enabled set reset mode to rearm the WoL logic */ if (priv->wol_enabled) { --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 5CC0E63113 for ; Fri, 2 Feb 2024 08:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863328; cv=none; b=VpD4n5T5TKIT+ZSsYkWWGWbVAvMyq6knPKvIhRH6BAw+7ivl9H2A1MK8jA+hWk6Dt/v5EeGuwKlMdxzFNZIqxGuqCYKvsRF0UFmxhc79y1BRrIh8gpFHG501hRlrVFsUil7Ou4ndLz4Enn5pjbV26gALHmN9PVrrbeCP/XuwqsE= 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.218.42 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-ej1-f42.google.com with SMTP id a640c23a62f3a-a354408e6bfso501196866b.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=YE3PpLdZuAnlfj9W5VTOLVeWNenHLA8VKPX9Z5Js3Rc3x4Xu7SHBNzEbPv5QUhA474 vrF0X1wjhTawHjti1E+EheDmISm1jhE5yb5nF1/hZHfkzsThstvAWMLcegxdjCaQbzoa kIq3yLoDgcGyDTqIFEap3tX18iUovg5ojJ8zs4iTGNk51AkARo+mS28iOgi+YAsWHrEn TouHjC0WepTa1FTNqe5HOhoVALEX3qhZv8fdA0RzPPjxDo8NVIoeZjUDOhjEmKLuqR9H qKG730cjIe83HFlfDNyVCSWfsasAjVEUondVuDASPHo6iY7faggEO0cSfWPg2gAQn9KP XF8Q== X-Gm-Message-State: AOJu0Yy+lt8LcU33rfgHhE7fsr+/00cf0rOpiCicdn0Qk3CZeeZHlnuD eFTOe3aWEEvGmUscre+RVrPwz0HULdQdEt5Q+GZU9aYB/chuu99yZEstwfiRd3c= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 grou= ped 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 =20 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/etherne= t/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; =20 - pm_runtime_enable(&pdev->dev); - error =3D pm_runtime_resume_and_get(&pdev->dev); - if (error < 0) - goto out_rpm_disable; - if (info->multi_irqs) { if (info->err_mgmt_irqs) irq =3D platform_get_irq_byname(pdev, "dia"); @@ -2679,7 +2674,7 @@ static int ravb_probe(struct platform_device *pdev) } if (irq < 0) { error =3D irq; - goto out_release; + goto out_reset_assert; } ndev->irq =3D irq; =20 @@ -2697,10 +2692,37 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] =3D NC_RX_RING_SIZE; } =20 + priv->clk =3D devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) { + error =3D PTR_ERR(priv->clk); + goto out_reset_assert; + } + + if (info->gptp_ref_clk) { + priv->gptp_clk =3D devm_clk_get(&pdev->dev, "gptp"); + if (IS_ERR(priv->gptp_clk)) { + error =3D PTR_ERR(priv->gptp_clk); + goto out_reset_assert; + } + } + + priv->refclk =3D devm_clk_get_optional(&pdev->dev, "refclk"); + if (IS_ERR(priv->refclk)) { + error =3D PTR_ERR(priv->refclk); + goto out_reset_assert; + } + clk_prepare(priv->refclk); + + platform_set_drvdata(pdev, ndev); + pm_runtime_enable(&pdev->dev); + error =3D pm_runtime_resume_and_get(&pdev->dev); + if (error < 0) + goto out_rpm_disable; + priv->addr =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(priv->addr)) { error =3D PTR_ERR(priv->addr); - goto out_release; + goto out_rpm_put; } =20 /* The Ether-specific entries in the device structure. */ @@ -2711,7 +2733,7 @@ static int ravb_probe(struct platform_device *pdev) =20 error =3D of_get_phy_mode(np, &priv->phy_interface); if (error && error !=3D -ENODEV) - goto out_release; + goto out_rpm_put; =20 priv->no_avb_link =3D of_property_read_bool(np, "renesas,no-ether-link"); priv->avb_link_active_low =3D @@ -2724,14 +2746,14 @@ static int ravb_probe(struct platform_device *pdev) irq =3D platform_get_irq_byname(pdev, "ch24"); if (irq < 0) { error =3D irq; - goto out_release; + goto out_rpm_put; } priv->emac_irq =3D irq; for (i =3D 0; i < NUM_RX_QUEUE; i++) { irq =3D platform_get_irq_byname(pdev, ravb_rx_irqs[i]); if (irq < 0) { error =3D irq; - goto out_release; + goto out_rpm_put; } priv->rx_irqs[i] =3D irq; } @@ -2739,7 +2761,7 @@ static int ravb_probe(struct platform_device *pdev) irq =3D platform_get_irq_byname(pdev, ravb_tx_irqs[i]); if (irq < 0) { error =3D irq; - goto out_release; + goto out_rpm_put; } priv->tx_irqs[i] =3D irq; } @@ -2748,40 +2770,19 @@ static int ravb_probe(struct platform_device *pdev) irq =3D platform_get_irq_byname(pdev, "err_a"); if (irq < 0) { error =3D irq; - goto out_release; + goto out_rpm_put; } priv->erra_irq =3D irq; =20 irq =3D platform_get_irq_byname(pdev, "mgmt_a"); if (irq < 0) { error =3D irq; - goto out_release; + goto out_rpm_put; } priv->mgmta_irq =3D irq; } } =20 - priv->clk =3D devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - error =3D PTR_ERR(priv->clk); - goto out_release; - } - - priv->refclk =3D devm_clk_get_optional(&pdev->dev, "refclk"); - if (IS_ERR(priv->refclk)) { - error =3D PTR_ERR(priv->refclk); - goto out_release; - } - clk_prepare_enable(priv->refclk); - - if (info->gptp_ref_clk) { - priv->gptp_clk =3D devm_clk_get(&pdev->dev, "gptp"); - if (IS_ERR(priv->gptp_clk)) { - error =3D PTR_ERR(priv->gptp_clk); - goto out_disable_refclk; - } - } - ndev->max_mtu =3D info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS= _LEN); ndev->min_mtu =3D ETH_MIN_MTU; =20 @@ -2799,13 +2800,13 @@ static int ravb_probe(struct platform_device *pdev) /* Set AVB config mode */ error =3D ravb_set_config_mode(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; =20 if (info->gptp || info->ccc_gac) { /* Set GTI value */ error =3D ravb_set_gti(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; =20 /* 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 =3D -ENOMEM; - goto out_disable_refclk; + goto out_rpm_put; } for (q =3D RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt =3D 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); =20 - platform_set_drvdata(pdev, ndev); - return 0; =20 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) =20 ravb_set_opmode(ndev, CCC_OPC_RESET); =20 - 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; } =20 -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 =3D dev_get_drvdata(dev); + struct ravb_private *priv =3D netdev_priv(ndev); + + clk_disable(priv->refclk); + return 0; } =20 +static int ravb_runtime_resume(struct device *dev) +{ + struct net_device *ndev =3D dev_get_drvdata(dev); + struct ravb_private *priv =3D netdev_priv(ndev); + + return clk_enable(priv->refclk); +} + static const struct dev_pm_ops ravb_dev_pm_ops =3D { 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) }; =20 static struct platform_driver ravb_driver =3D { --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ED4B657CF for ; Fri, 2 Feb 2024 08:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863332; cv=none; b=H6fJ/NgBI0QZzBJq5v73BoWGJnoT/QKVmWcmTHDUSY/q+zBJ6qPdRczkp9zVjfEmRb3VKfdx1HbsjJ0nefugRJ09z9krGcGWO9C9VsVYnZGs/CtdwIR+4zAX2kBEskVlgtXex6rL2tAG65dDAaVi+ffyqm1P8RgpUHGtbE91UBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863332; c=relaxed/simple; bh=sjKZtlaEAVgFWl84cYhPxtJ7a9xxqnYxEBSVNtCDUTI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Up2FX6auR3WBkmArzSKZvwB6dQ0ABz0RhiaSsWZbdO7M+kX8+9+YLsUsOd6XwzTqXc17pcVUIw2KUTqJ7n3f2OIzUg74WonTIwNiq6cQeKtrQ2SnSGt+FmAUVr8ykmtgEwEIpBDtiwdRL3HyjAaPLQP0mjcHfu57oXbyzn39Sdk= 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.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev 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-f54.google.com with SMTP id a640c23a62f3a-a36126ee41eso248854166b.2 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=CWeibii6OE49mcUNS8+6JshcXUh3JX6s+1zU0u7kwXblCL5AfY5sebMY9f4yHsWGtK Z9vY+9fvolt4G0mTr0vHdoCp/8iF7VW73lqRc61db40X6Tw+83/+EwWz9CiMr5jjfMud R6Oy3fuFYdU6YKvRDiMCzph4uTrBEaZCdctduE3rYJqp1prg5w+M/u46EuLLqIwWvjSi p57FoOLrD7nSgZJ6GCpDtPkZcMOLGj1BMjUkENrn4z6zVkFKZ5pAyEf5nAj8J5DzYX8S i/7cGNdWLrYCcObSrfWvbX1kJUMoUjm8y+EUjjZLYOQseB720AS6qGseQLeEYQklRqhk stFw== X-Gm-Message-State: AOJu0Yy3eFHRYMLm7L/9kSHx5ol4F5KUI7sqERfYJQYDeYw0NBi7dbFb NIQD5QsTq3yTDjWhAS76genpGGEC/1fcO2P4qr+XhNjFg5z+uLidQ7tdpQEHqgc= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ren= esas/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]; =20 unsigned no_avb_link:1; unsigned avb_link_active_low:1; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/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) =20 -static const char *ravb_rx_irqs[NUM_RX_QUEUE] =3D { - "ch0", /* RAVB_BE */ - "ch1", /* RAVB_NC */ -}; - -static const char *ravb_tx_irqs[NUM_TX_QUEUE] =3D { - "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, voi= d *dev_id) { struct net_device *ndev =3D dev_id; struct ravb_private *priv =3D netdev_priv(ndev); + struct device *dev =3D &priv->pdev->dev; + irqreturn_t result =3D IRQ_HANDLED; + + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) { + result =3D IRQ_NONE; + goto out_rpm_put; + } =20 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; } =20 /* Error interrupt handler */ @@ -1176,9 +1178,15 @@ static irqreturn_t ravb_interrupt(int irq, void *dev= _id) struct net_device *ndev =3D dev_id; struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; + struct device *dev =3D &priv->pdev->dev; irqreturn_t result =3D IRQ_NONE; u32 iss; =20 + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Get interrupt status */ iss =3D ravb_read(ndev, ISS); @@ -1222,6 +1230,9 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_= id) } =20 spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } =20 @@ -1230,9 +1241,15 @@ static irqreturn_t ravb_multi_interrupt(int irq, voi= d *dev_id) { struct net_device *ndev =3D dev_id; struct ravb_private *priv =3D netdev_priv(ndev); + struct device *dev =3D &priv->pdev->dev; irqreturn_t result =3D IRQ_NONE; u32 iss; =20 + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Get interrupt status */ iss =3D ravb_read(ndev, ISS); @@ -1254,6 +1271,9 @@ static irqreturn_t ravb_multi_interrupt(int irq, void= *dev_id) } =20 spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } =20 @@ -1261,8 +1281,14 @@ static irqreturn_t ravb_dma_interrupt(int irq, void = *dev_id, int q) { struct net_device *ndev =3D dev_id; struct ravb_private *priv =3D netdev_priv(ndev); + struct device *dev =3D &priv->pdev->dev; irqreturn_t result =3D IRQ_NONE; =20 + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); =20 /* 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 =3D IRQ_HANDLED; =20 spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } =20 @@ -1727,85 +1756,21 @@ static const struct ethtool_ops ravb_ethtool_ops = =3D { .set_wol =3D ravb_set_wol, }; =20 -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 =3D devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); - if (!name) - return -ENOMEM; - error =3D 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 =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; - struct platform_device *pdev =3D priv->pdev; - struct device *dev =3D &pdev->dev; int error; =20 napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); =20 - if (!info->multi_irqs) { - error =3D 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 =3D ravb_hook_irq(ndev->irq, ravb_multi_interrupt, ndev, - dev, "ch22:multi"); - if (error) - goto out_napi_off; - error =3D ravb_hook_irq(priv->emac_irq, ravb_emac_interrupt, ndev, - dev, "ch24:emac"); - if (error) - goto out_free_irq; - error =3D ravb_hook_irq(priv->rx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch0:rx_be"); - if (error) - goto out_free_irq_emac; - error =3D 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 =3D 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 =3D 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 =3D ravb_hook_irq(priv->erra_irq, ravb_multi_interrupt, - ndev, dev, "err_a"); - if (error) - goto out_free_irq_nc_tx; - error =3D ravb_hook_irq(priv->mgmta_irq, ravb_multi_interrupt, - ndev, dev, "mgmt_a"); - if (error) - goto out_free_irq_erra; - } - } - /* Device init */ error =3D ravb_dmac_init(ndev); if (error) - goto out_free_irq_mgmta; + goto out_napi_off; ravb_emac_init(ndev); =20 /* 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) =20 cancel_work_sync(&priv->work); =20 - 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 } } =20 +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 =3D priv->pdev; + struct net_device *ndev =3D priv->ndev; + struct device *dev =3D &pdev->dev; + const char *dev_name; + unsigned long flags; + int error; + + if (irq_name) { + dev_name =3D devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); + if (!dev_name) + return -ENOMEM; + + *irq =3D platform_get_irq_byname(pdev, irq_name); + flags =3D 0; + } else { + dev_name =3D ndev->name; + *irq =3D platform_get_irq(pdev, 0); + flags =3D IRQF_SHARED; + } + if (*irq < 0) + return *irq; + + error =3D 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 =3D priv->info; + struct net_device *ndev =3D 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 =3D "dia"; + emac_irq_name =3D "line3"; + } else { + irq_name =3D "ch22"; + emac_irq_name =3D "ch24"; + } + + error =3D ravb_setup_irq(priv, irq_name, "ch22:multi", &ndev->irq, ravb_m= ulti_interrupt); + if (error) + return error; + + error =3D ravb_setup_irq(priv, emac_irq_name, "ch24:emac", &priv->emac_ir= q, + ravb_emac_interrupt); + if (error) + return error; + + if (info->err_mgmt_irqs) { + error =3D ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interr= upt); + if (error) + return error; + + error =3D ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_inte= rrupt); + if (error) + return error; + } + + error =3D ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrup= t); + if (error) + return error; + + error =3D ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrup= t); + if (error) + return error; + + error =3D ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interr= upt); + 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 =3D 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; =20 if (!np) { dev_err(&pdev->dev, @@ -2664,20 +2679,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; =20 - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq =3D platform_get_irq_byname(pdev, "dia"); - else - irq =3D platform_get_irq_byname(pdev, "ch22"); - } else { - irq =3D platform_get_irq(pdev, 0); - } - if (irq < 0) { - error =3D irq; - goto out_reset_assert; - } - ndev->irq =3D irq; - SET_NETDEV_DEV(ndev, &pdev->dev); =20 priv =3D netdev_priv(ndev); @@ -2692,6 +2693,10 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] =3D NC_RX_RING_SIZE; } =20 + error =3D ravb_setup_irqs(priv); + if (error) + goto out_reset_assert; + priv->clk =3D devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { error =3D PTR_ERR(priv->clk); @@ -2739,50 +2744,6 @@ static int ravb_probe(struct platform_device *pdev) priv->avb_link_active_low =3D of_property_read_bool(np, "renesas,ether-link-active-low"); =20 - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq =3D platform_get_irq_byname(pdev, "line3"); - else - irq =3D platform_get_irq_byname(pdev, "ch24"); - if (irq < 0) { - error =3D irq; - goto out_rpm_put; - } - priv->emac_irq =3D irq; - for (i =3D 0; i < NUM_RX_QUEUE; i++) { - irq =3D platform_get_irq_byname(pdev, ravb_rx_irqs[i]); - if (irq < 0) { - error =3D irq; - goto out_rpm_put; - } - priv->rx_irqs[i] =3D irq; - } - for (i =3D 0; i < NUM_TX_QUEUE; i++) { - irq =3D platform_get_irq_byname(pdev, ravb_tx_irqs[i]); - if (irq < 0) { - error =3D irq; - goto out_rpm_put; - } - priv->tx_irqs[i] =3D irq; - } - - if (info->err_mgmt_irqs) { - irq =3D platform_get_irq_byname(pdev, "err_a"); - if (irq < 0) { - error =3D irq; - goto out_rpm_put; - } - priv->erra_irq =3D irq; - - irq =3D platform_get_irq_byname(pdev, "mgmt_a"); - if (irq < 0) { - error =3D irq; - goto out_rpm_put; - } - priv->mgmta_irq =3D irq; - } - } - ndev->max_mtu =3D info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS= _LEN); ndev->min_mtu =3D ETH_MIN_MTU; =20 --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 96AB0626D2 for ; Fri, 2 Feb 2024 08:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863333; cv=none; b=aorVMdNFYvmsWAgkmoGsrC0bs9dgPXQLJMZ8FIUubJf+n7nU8BQHOU50TGqnPr9WLSOnXDmOtQLFNic/3Fxpo+OiHYVk9rRpIVvndBG1yE2o4bT24ac8QKQtnd6OePY7iIkONloToCPNxZ47z9yXf5Qgfgsp+05bitPZX8XYI+w= 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.208.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="hXfRRiV1" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-55ff5f6a610so302597a12.3 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=kc+J+MoY4FCdC7lS1cNMEvKsnlSCS099pIsvz4/sAenI3lJ5uVUEAhx/vjfnScwB9J YCAf/hBPBsVMGTGj3O5SP6UYOJmIc50eaNRDsKWSJyuWB198ydRnmi7cNsQmfBA08ovT tJSSLQ+iOXJH/u1I0VmV5KlUe8ORUOJJEPL4VmPRJHoGvnlYYxl9MPSfSjItXtVNseVb W1/totgwxiZl7yxj1//iSFrw5XY1P+xCdBmnXzbwEC5oGJ6EehRv8CuaXpY08io9gb5B DV5/7VzhRljmWITHth3oucYwArQr10SKekJ3QRVuMovB7AHFCAeozF7pmk6tWand4d1V IUFQ== X-Gm-Message-State: AOJu0YzkDHyLJFyjUSLlw3CNqFaFJ0DZzo1R15sL8LTO1vdhBARzGz9e /HGL0MGg12x+Lt+sAgRpqYe7davph+ajOsJkLvSZhx+Rk7Kjmql4AbEyoLC8cVo= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ren= esas/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 { =20 const struct ravb_hw_info *info; struct reset_control *rstc; + + u32 gti_tiv; }; =20 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/etherne= t/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 =3D= { .set_wol =3D ravb_set_wol, }; =20 +static void ravb_set_gti(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + const struct ravb_hw_info *info =3D 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 =3D netdev_priv(ndev); + const struct ravb_hw_info *info =3D priv->info; + struct device *dev =3D ndev->dev.parent; + unsigned long rate; + u64 inc; + + if (!(info->gptp || info->ccc_gac)) + return 0; + + if (info->gptp_ref_clk) + rate =3D clk_get_rate(priv->gptp_clk); + else + rate =3D clk_get_rate(priv->clk); + if (!rate) + return -EINVAL; + + inc =3D 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 =3D 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); =20 + 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[] = =3D { }; MODULE_DEVICE_TABLE(of, ravb_match_table); =20 -static int ravb_set_gti(struct net_device *ndev) -{ - struct ravb_private *priv =3D netdev_priv(ndev); - const struct ravb_hw_info *info =3D priv->info; - struct device *dev =3D ndev->dev.parent; - unsigned long rate; - uint64_t inc; - - if (info->gptp_ref_clk) - rate =3D clk_get_rate(priv->gptp_clk); - else - rate =3D clk_get_rate(priv->clk); - if (!rate) - return -EINVAL; - - inc =3D 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 =3D netdev_priv(ndev); @@ -2763,15 +2781,9 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; =20 - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - error =3D ravb_set_gti(ndev); - if (error) - goto out_rpm_put; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + error =3D ravb_compute_gti(ndev); + if (error) + goto out_rpm_put; =20 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; =20 - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - ret =3D ravb_set_gti(ndev); - if (ret) - return ret; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + ravb_set_gti(ndev); =20 if (info->internal_delay) ravb_set_delay_mode(ndev); --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AA9F7429B for ; Fri, 2 Feb 2024 08:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863336; cv=none; b=bUFYkgNuLNadWMLXLVgpqtxyFk/qCbvgCrubFyMG8NlVYfDTBWQ60/WqYkK5I2EG56QD+cSlplFynH4h7bYPxgwa8BA4UMdGlNkMziaof5kUCCLlmVwpYcckjLvuyRuVdToPdqsAkfPhA9s2Bf1v5Lx6bQiNA30UhA/ffoEaIMw= 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.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev 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-f54.google.com with SMTP id a640c23a62f3a-a2a17f3217aso262203566b.2 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=SZG15QiLSe/IFo1ap2zZ5eegW6bpTQIfMn7Pwjz/wwU4p821uznetplFy94K/YLiEn MkvrBI/u8RqSECGDO+QcNp1uWdY+XSl7ahoChV8AOeg2+yIdLvrQ0ean6V1eDLAHYctG TfLv2tamCmswPvtHLID7nTOJlnWNobpJ2mIhCQn4l5xyNEqwt5hyfzuTvOpNYHuYQT82 /3CXQUpgMGJlVn8fwFzm/mffFXjPSdjzHWHXuSNhCmfjpr/fstyS8nzZZbXXvALT7juw swyzN5iVEyzJBaDoGWGKxgU+X1qpaVDl6edw6r1e//3cX+x0mMAZKP2A4pQX4Sp3PO41 H/YQ== X-Gm-Message-State: AOJu0YxzoUqEA5rkWDto82yLwlY4a4gi4gXJ04NlCC3suV4garBXmMiq vg9zG9DqQiPFo09xz3rpqJLcPtYAnaZ5BSTZZ3mUTaIb/gT0xgxmHdvI+DIWmjA= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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; } =20 +/* Set tx and rx clock internal delay modes */ +static void ravb_parse_delay_mode(struct device_node *np, struct net_devic= e *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + bool explicit_delay =3D 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 =3D !!delay; + explicit_delay =3D true; + } + if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 2000, according to DT bindings */ + priv->txcidm =3D !!delay; + explicit_delay =3D true; + } + + if (explicit_delay) + return; + + /* Fall back to legacy rgmii-*id behavior */ + if (priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_RXID) { + priv->rxcidm =3D 1; + priv->rgmii_override =3D 1; + } + + if (priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_TXID) { + priv->txcidm =3D 1; + priv->rgmii_override =3D 1; + } +} + +static void ravb_set_delay_mode(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + u32 set =3D 0; + + if (!priv->info->internal_delay) + return; + + if (priv->rxcidm) + set |=3D APSR_RDM; + if (priv->txcidm) + set |=3D 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]); =20 + ravb_set_delay_mode(ndev); + /* Device init */ error =3D ravb_dmac_init(ndev); if (error) @@ -2531,41 +2586,6 @@ static int ravb_set_config_mode(struct net_device *n= dev) return error; } =20 -/* Set tx and rx clock internal delay modes */ -static void ravb_parse_delay_mode(struct device_node *np, struct net_devic= e *ndev) -{ - struct ravb_private *priv =3D netdev_priv(ndev); - bool explicit_delay =3D 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 =3D !!delay; - explicit_delay =3D true; - } - if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 2000, according to DT bindings */ - priv->txcidm =3D !!delay; - explicit_delay =3D true; - } - - if (explicit_delay) - return; - - /* Fall back to legacy rgmii-*id behavior */ - if (priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_RXID) { - priv->rxcidm =3D 1; - priv->rgmii_override =3D 1; - } - - if (priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_TXID) { - priv->txcidm =3D 1; - priv->rgmii_override =3D 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= ); } =20 -static void ravb_set_delay_mode(struct net_device *ndev) -{ - struct ravb_private *priv =3D netdev_priv(ndev); - u32 set =3D 0; - - if (priv->rxcidm) - set |=3D APSR_RDM; - if (priv->txcidm) - set |=3D APSR_TDM; - ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); -} - static int ravb_probe(struct platform_device *pdev) { struct device_node *np =3D pdev->dev.of_node; @@ -2785,10 +2793,7 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; =20 - if (info->internal_delay) { - ravb_parse_delay_mode(np, ndev); - ravb_set_delay_mode(ndev); - } + ravb_parse_delay_mode(np, ndev); =20 /* Allocate descriptor base address table */ priv->desc_bat_size =3D sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 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 2EB386BB5C for ; Fri, 2 Feb 2024 08:42:15 +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=1706863338; cv=none; b=M5J4pFoCLX9vYBGiP6+KTesui33J7lLeIBl7tnQ2/ZN2Us6HmvHRS9tmR75Eh431PSOSymnVbHqex3vzCfks6yTFNFDgt+P2M2tbCrs1CpD7QPY306UWaGc6/y4H9xBSfns85KUk+v43K94xJ31Si9QF9e8LalJAG/eQZCUXfNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863338; c=relaxed/simple; bh=ga3nLsmlUPHxC6lprohW+AJrVuYSdcwOBoQLKkHF3cQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gc3hREqDPq5P1lyJB1kUhdLZVG30mpMCOykf7sJPqchb4+W96Z0vOVahXySizr7D4RcRqmEgRR9/PEGXu6/OLRC5RX8s8lfN4yrYn1BF0E6jwznJUT/A0VjMJD/YjBmTJmaUgcSZD1xqXH0T8Xv/7duu7FyYs3bCjtJT5j2Jj94= 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.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="DZJZjDUr" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a350bfcc621so221506166b.0 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=s8bo2OwX+DVDvcJy91xaJmrKtHMfff7nIipPZCvQLT166qhXD+QRcYWGemXRKGeI4n AYfOSRjnfvKYP8jehIH6autkVfvVy/7LH9ZJCqabywbte7cndGVjIiAruNM58a8LaZY8 1AuLp0RT6WVgR/tr8V7oEGeY1MCNq4H/+jMYvfDhfUjJhvDwu/fHlkyU9Ty8pcZCsKri YM3XWgQwE19Md7bR4AwfJRgiJvbkIqWvN66LR8luwXJ5TL83NOXNDjt4DHRfmF9H58G5 DCwK02FlkoAVQ6mv8fPntNZj+D6ZK76BJb/3AfytXJc6jiKR+REwajv5hhNElBu3Re7x IFQQ== X-Gm-Message-State: AOJu0YwAv/6NLzKP9O16L/QxYec4QccSsjHcV9ZVPD0WUDB0Fir5e4Cw uSzj2OQgLF0ADEXiQoOHDjmvXmzwSAVAGvPc4nz+zFFTqxy1OZ40mc/sVsh7zjg= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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]); =20 ravb_set_delay_mode(ndev); + ravb_write(ndev, priv->desc_bat_dma, DBAT); =20 /* Device init */ error =3D ravb_dmac_init(ndev); @@ -2808,7 +2809,6 @@ static int ravb_probe(struct platform_device *pdev) } for (q =3D RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt =3D DT_EOS; - ravb_write(ndev, priv->desc_bat_dma, DBAT); =20 /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 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 ABAB077F06 for ; Fri, 2 Feb 2024 08:42:18 +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=1706863341; cv=none; b=YjwrHIiJJuuvGFBmq/d0lPApRw61cVD/b9ZMmeUN4qdvy2kyV2lcqNxdZAwgmVMnVNBf4CDa5xyBkwXMa0udg1Pd9n+hACw8Gib3+RoEYwLn0EOwHJiBdizlPfnNhy48t/EcIpImxpE//Km8j2GtIwYFaRmJyo1okjmeM5edtBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863341; c=relaxed/simple; bh=3HIkBLfmG0k2J7i2Q48TrkFvh+JqTUAQoMPHL5/cn7A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RRI3RL5kYhpI24GrrBHxLgOJeTpQzjrhsAHUS+BvPr5aa7lLlC1Kk1LSkpcBGjvrelUVXhzoRU/CWqdygXX9OEfJffp3uOOQoXwHE2YWjgJLpvUhumsZBtDjUtwzCL2afaH+d/xk9C+xv5QsxGk91c/kjjABNzdZfxxWQuC4dFE= 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.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="inpPjhzX" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a29c4bbb2f4so226300966b.1 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=tryDv+KeAmCMFLE4H0jIJVXoqKg0f6m2HCS7J0DeXg8GWpUtsbAYDW+8DOadkwoNAQ nEw+5Td/mWkNcXE9cXGJbjzX7ejdmpOg83kRLerwDcceNnnVYXPwftBzAWYnSG4LBXDm rC8b3lbm0vlC9maNKQgzdNMwSk433jiYKxaxlc5Ksx/IAP/ftfTwLPFac76QbK4W+8PU U3FuSyc+toagrwTp6DotRB90PugE1JKP4E8cmACaVjxdgqzX6SYHU0cGh3yszXN9RpOg jOud7T9aBPvE5+KDxwwo34Dp0C10H3vd/vlLj6/GT/C1XRg0gzpkwH6XJVv/2vBMdroO MqzA== X-Gm-Message-State: AOJu0YwDpt4qVDAk8VprWq8NzGfeJGJdCPDRsjp7nTmWwCKx04Ay8RTd qGnXhisL5wzLfmZWnb/HQ8mQDDwmDh84Nb/3RtiWbRdd/mWkEa7SWnEKxBzdKo8= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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); =20 /* Initialise PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); =20 /* PHY control start */ @@ -1890,7 +1890,7 @@ static int ravb_open(struct net_device *ndev) =20 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); =20 /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); =20 /* 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); =20 - /* Initialise PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_init(ndev, pdev); - /* Debug message level */ priv->msg_enable =3D RAVB_DEF_MSG_ENABLE; =20 @@ -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) =20 ravb_mdio_release(priv); =20 - /* 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); =20 --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 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 C024577F3D for ; Fri, 2 Feb 2024 08:42:21 +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=1706863343; cv=none; b=JXhY87oUCkH/voHy9o4PlLiHsNE/CAe9nDgAXU49rmVKf43txhcPA98QbHxIJwtfrC/QbsyEI5XS79UDe2rNk1zu3F7WjKuV50qxDR4J1PTcQaYfeRbYgDn9mgDwipebLwL93mQL+6bkihF78NDsy+T/0u295gsZSQfElIZEoE8= 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.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="ERbCg8F9" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a29c4bbb2f4so226308166b.1 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=cZJqMhsVaUP/qleko6i1oe974nhdrkovvicRDrUTYk5iPB/bYB3onvnXlM+fGqHhsI uGN4tF8M/rrUFl3/97wYplbaXBxRkOEsUGbIVOVzIEEpcguuSBdAXYTBTcV+KgPOEcni N7PFscxyiEYMykA//JywV3gI5+q7JtDjW0IXOoqQSynVQEdj0HuOq+AQVXBUjzioRdJM oG2OXrKGD0rU8FDKl0Y6MkCEebelvLzKkOJbKjbKXGGTs7iGSUXzj2nFHf1pgCFU3sMQ EvSE19lNduupFt82fstipG2vCzRBVRfHoXq7i/LL3hFEwkYv8HLE63RxZVWq8GgGyHKj 126A== X-Gm-Message-State: AOJu0Yx6FRlVWhNZuoV4RGI+FiQTu8kqTlvuaQLagVy8BcR+wrBAImam yIA2Nulmu/X8PNXE7tAjmuY/Kgr1rGlxxrzQlZGDIvfCInAl6/44KKFE2bSCswA= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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 =3D= { .set_wol =3D ravb_set_wol, }; =20 +static int ravb_set_config_mode(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + const struct ravb_hw_info *info =3D priv->info; + int error; + + if (info->gptp) { + error =3D 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 =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); + } else { + error =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG); + } + + return error; +} + static void ravb_set_gti(struct net_device *ndev) { struct ravb_private *priv =3D 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]); =20 + /* Set AVB config mode */ + error =3D ravb_set_config_mode(ndev); + if (error) + goto out_napi_off; + ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); =20 /* Device init */ error =3D ravb_dmac_init(ndev); if (error) - goto out_napi_off; + goto out_set_reset; + ravb_emac_init(ndev); =20 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); =20 - return 0; + /* Set reset mode. */ + return ravb_set_opmode(ndev, CCC_OPC_RESET); } =20 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[] = =3D { }; MODULE_DEVICE_TABLE(of, ravb_match_table); =20 -static int ravb_set_config_mode(struct net_device *ndev) -{ - struct ravb_private *priv =3D netdev_priv(ndev); - const struct ravb_hw_info *info =3D priv->info; - int error; - - if (info->gptp) { - error =3D 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 =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); - } else { - error =3D 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 =3D &ravb_netdev_ops; ndev->ethtool_ops =3D &ravb_ethtool_ops; =20 - /* Set AVB config mode */ - error =3D ravb_set_config_mode(ndev); - if (error) - goto out_rpm_put; - error =3D 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 =3D RAVB_DEF_MSG_ENABLE; =20 + /* Set config mode as this is needed for PHY initialization. */ + error =3D 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 =3D ravb_mdio_init(priv); if (error) { dev_err(&pdev->dev, "failed to initialize MDIO\n"); - goto out_dma_free; + goto out_reset_mode; } =20 + /* Undo previous switch to config opmode. */ + error =3D 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]); =20 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); =20 - ravb_set_opmode(ndev, CCC_OPC_RESET); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); clk_unprepare(priv->refclk); --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 B2B4478B66 for ; Fri, 2 Feb 2024 08:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863345; cv=none; b=jOaQphMJ8L7BvYFA6JXyIwGcTw739yaFB9k0mdSJcF+TA6TWn1sxhN+DZOk7Z9OG69G8ySwDjrkHLZzQtI9AJmAOtscEOe/Toecu11zNAKNs391lPE9UT55NZeOxRx9Ent/+BVdYha9u8gCm5B/G+3nOflTKWzm3YwzZCJhp264= 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.53 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-f53.google.com with SMTP id a640c23a62f3a-a293f2280c7so250142366b.1 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=glS/Z5ujeVhqUfJAnL1uTMtJxmayvKGjTO3PSKftsJbeKvNk/p2jqa2BOxr1Pkx3MK 5lF+iHGqOTpZrC0kL7W5VsuuPYeDXG6hTp6sk1uEO7CeaTIxdPpMYLkeczeokC15749R eym56SsXPlCyhEMkzGvvf0BSYL9blsrFTjBYWohr5EgMwpSNB2vBlvntwtx8jSSc/dNd B5TrXEDW4n5tu6ALD997QGz0MOx/bjY6jS+t9G+cUCRL2vf0OF/kdoHpivwQzF4fMY9I JS2h1pcoDwe7X6AM2JVPLXdx7JJWv6guQaluOkl+E77cZjhBhhBYI/6GD/JHTx0I3VR/ TsfA== X-Gm-Message-State: AOJu0YzlqI3J0i+/MUhYCDLswR12Rr00/ZkJfbPRDvSHLyWmGCGcuf+u QZDzUIitEphzIYiv/BDOm5pwh/xeqvIOQMWZvuoxBn2UDlHeQ7t8AlN75sKpZeQ= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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); =20 + if (priv->info->ccc_gac) + ravb_ptp_stop(ndev); + return enable_irq_wake(priv->emac_irq); } =20 @@ -2961,14 +2964,10 @@ static int ravb_suspend(struct device *dev) netif_device_detach(ndev); =20 if (priv->wol_enabled) - ret =3D ravb_wol_setup(ndev); - else - ret =3D ravb_close(ndev); + return ravb_wol_setup(ndev); =20 - if (priv->info->ccc_gac) - ravb_ptp_stop(ndev); - - if (priv->wol_enabled) + ret =3D ravb_close(ndev); + if (ret) return ret; =20 reset_assert: --=20 2.39.2 From nobody Tue Dec 23 20:10:13 2025 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 35744748E for ; Fri, 2 Feb 2024 08:42:25 +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=1706863346; cv=none; b=biNbc/cKMU7d5GocoavAmEF0CdFoOgPSdEstOuXP59fZIDgU/EOjeFOyXUdlp+hrMROqfZsla8Wfldei5L0kP8k5wjmcTU5RN3iVA01xU/48Zbp+hsvFMGaAdXcSrdIpbAU7dp7Ob3eQ5h7Y+7QlgJPEFApOpjSnwzMagDjS9NM= 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.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="okuZDAAz" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a30f7c9574eso259956266b.0 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=ucftwQzxiYkIvJV2LBF0KXVa5Ld9wvgmEG8Y9NZ1uExHJn+pO73+jHK56hj6LBVs/p K/gjKtwmLkN8dh7fK3q9vaLY30HQ1o7mDRwoF4cpcxt/6U7+nwGP0gRKR3IC59uYva7I r5M36GfzDYYB4/CtR1CCAlvpkIfo7Av4kqhKY6l+CQ5I6yI9ASYDiHY/oqquPs+4BkFP btAiVNrbTjOVdaGG1krWBlO/xk3NuP9qTGgllMJ3FQAuJlQ4zqiNK+0PInHEMDED6jgR qJFzt7IIZTid89NHOL4i+EIZti0lUbKf7lENlLZgF4aezWXNFHcgkAxXLTcXXtVBBDt6 S1jA== X-Gm-Message-State: AOJu0YzDAZipjp2c+IIIQwrHJeUUV8qlTGT3CU4BzDBSUnKCJNrrFMw/ 7qzMHvvWsVl4F+drEImBj26Uo1hug9TpEVWC/aOZN4Nw+SXDohiVe4s63XzC67A= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/etherne= t/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 =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; + int error; + + /* Set reset mode to rearm the WoL logic. */ + error =3D ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + /* Set AVB config mode. */ + error =3D ravb_set_config_mode(ndev); + if (error) + return error; + + if (priv->info->ccc_gac) + ravb_ptp_init(ndev, priv->pdev); =20 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 =3D dev_get_drvdata(dev); struct ravb_private *priv =3D netdev_priv(ndev); - const struct ravb_hw_info *info =3D priv->info; int ret; =20 ret =3D reset_control_deassert(priv->rstc); if (ret) return ret; =20 - /* 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 =3D ravb_set_opmode(ndev, CCC_OPC_RESET); + ret =3D ravb_wol_restore(ndev); if (ret) return ret; } =20 - /* 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 =3D ravb_set_config_mode(ndev); - if (ret) + /* Reopening the interface will restore the device to the working state. = */ + ret =3D ravb_open(ndev); + if (ret < 0) return ret; =20 - 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 =3D ravb_wol_restore(ndev); - if (ret) - return ret; - } - ret =3D 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); =20 return ret; } --=20 2.39.2