From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58F7FC4332F for ; Thu, 14 Dec 2023 11:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444101AbjLNLqU (ORCPT ); Thu, 14 Dec 2023 06:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444085AbjLNLqQ (ORCPT ); Thu, 14 Dec 2023 06:46:16 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A925D118 for ; Thu, 14 Dec 2023 03:46:21 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-54c70c70952so10877750a12.3 for ; Thu, 14 Dec 2023 03:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554380; x=1703159180; 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=sOZAMEvogW3XDicAaSrKeFR75wLTaTJmQUaxz//D884=; b=aBCyfvzffeuy42b2a47jBeJGrg53dY+MTmMzoc7yMX7VflA5yHr0WL7S68E4JNifGL KX6bZomu8uTJJaZZIS6nlHo9+XvgF9AaHiOmieyFEiuxYPQ86d9SqUkFEUB6edAoQo73 VESw2BtfPzNGCvPWudZMpFasmOmr3kME8U4VaXnzdjAThNxHcnku8ZAjVWxNM3PqcPIe 31fqqntHiX+5FVMekoykFVKbQehCe8JFIrbyAd4NBgCGclXP0C8EMMLy8ezhrpUSVnCG m/Dttb3Pt7yC9nt3olSIJikvLP+8oYIun8TH1ykpxSVkVul3drPvV5tnMheC5dW9W9x0 /SNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554380; x=1703159180; 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=sOZAMEvogW3XDicAaSrKeFR75wLTaTJmQUaxz//D884=; b=tbsVK1fsMmUVjS0go/5pO3vGjfdu0tzi8jHGJPFXrS2bhY93edwVeq8WaywNfUqu9y LaxUzKU/7T2f51BVvyMKsdmB8yiOpa9B6U25us+4rnrFXN1P07Bh5ZS8YBoR8GmtK9iE MlhNMEkixFWAHJc5+YxkjR7NBAZe4tXL52r3oTKOO6Yewj8XylsNWphC0QY+0N94L9h2 M5Xn6gc3QsJT+OdgMwBTs3gDHhupbMJiceTFLnVnBiKK4XY/G7rlT1OcPanuJ0RlfPVQ iWG7Kxx8nz3jwbRBq5T1m8UJG5JUNBdtIfbQL1EXhvUiXIj7gbKKKThXEgIg/hjIWcwF qMUQ== X-Gm-Message-State: AOJu0YxeBenFJzNu82S2Y0nXupwmZc+LEuvaFh0fe+5UQDft3JRlwuzP JcM+J+xt79iN58nV2Mf4d4LcBA== X-Google-Smtp-Source: AGHT+IEAFaM5Cm0jFSOiB0BP6s0buW/H66IBrBKllrAZ3Y8UZeWvQVog2DOBsNItlsCh8+yUrOEP2g== X-Received: by 2002:a17:906:14e:b0:a19:a19b:4231 with SMTP id 14-20020a170906014e00b00a19a19b4231mr2526628ejh.156.1702554380148; Thu, 14 Dec 2023 03:46:20 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:19 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 01/21] net: ravb: Let IP-specific receive function to interrogate descriptors Date: Thu, 14 Dec 2023 13:45:40 +0200 Message-Id: <20231214114600.2451162-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 1c253403a297..8e67a18b2924 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1282,25 +1282,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98ADDC4332F for ; Thu, 14 Dec 2023 11:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444115AbjLNLq1 (ORCPT ); Thu, 14 Dec 2023 06:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444102AbjLNLqR (ORCPT ); Thu, 14 Dec 2023 06:46:17 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD48123 for ; Thu, 14 Dec 2023 03:46:23 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-551ee7d5214so1029664a12.0 for ; Thu, 14 Dec 2023 03:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554381; x=1703159181; 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=xzZ0BgGaxayTSFzsb/BEZRjubDF9VvMmh4DxIfBVmak=; b=I69wKj6ciyjUxJ7QD/w621gbHVWbppXUhhnZ+Pw2vfjD8ysGHonveitzmjV0HB8mh2 IvfhpZ+S7Pm6BoW8V1eVcmePUjQI9SofLtPnOHA4dCR+fHx5rKqhNE7DQ36cWzmlEaYq 8iWDPRf2R0QDU4T3+u47GbIGofv5MGz4AOuTjxQkHUK9b+Hod/kH98vj2H3YtMetKvV8 a4bcab/zx04lAVQfa/bvp8ConLHmtSAOH6Dxq+9xnp+mKBIwaj1IJGrUBOQu2llmExbH Y26J2rISYlvGRem8LXGGok/FeVXkOcQxaR2QRvMY4ENlVPazClO/5UascgOx4uWxPBww T56g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554381; x=1703159181; 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=xzZ0BgGaxayTSFzsb/BEZRjubDF9VvMmh4DxIfBVmak=; b=XMbFviI722G8q8s6SKQRnwua4MdzBSIIJ9EBew/4P8FgCl2fQdjDeUUFOKqq08ZDrX 7wnJU/GdwxZMWUmX4lH0qOqtoM59VXdTtkpCeMF02HBuxmrWi4VLwWcuDhPVlujCqe5U T1v28OnM5d4iHy0dKeNcWAj968mKsDSPKy+9ygOyFyJQ8xutcxcMN6XJ6yBNJ9AR2LhB aqBvRY9U/CM3F7CPcY5yIW1DcVckVa5H3dp9OjGuIXyFv4idXoHJno9usk92L4QQkUi8 pZ58d30jpSjRfa35Tm3WaSAw5YM4Vag9VvUtxa5tPjqAwu7t50KaPAkFHo4RM2/lA7yp Ok9g== X-Gm-Message-State: AOJu0YwsTn9zU3H3mWqCTfujO9fRe3p4qXJTCLEtjNcclSYShclP56m8 xXXoEXDFAKF5ii8Y3cbdYUQ4pQ== X-Google-Smtp-Source: AGHT+IGrfsWF2TK37JNT1iRMcyS+d6NKRvQ7j5MzSSkR+QkO1AqE2szxYNqX3A233KgAaRlYFdYN5g== X-Received: by 2002:a17:907:5c7:b0:a23:f56:98e1 with SMTP id wg7-20020a17090705c700b00a230f5698e1mr903990ejb.18.1702554381683; Thu, 14 Dec 2023 03:46:21 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:21 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 02/21] net: ravb: Rely on PM domain to enable gptp_clk Date: Thu, 14 Dec 2023 13:45:41 +0200 Message-Id: <20231214114600.2451162-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 8e67a18b2924..aa5e9b27ed31 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); @@ -2806,7 +2805,7 @@ static int ravb_probe(struct platform_device *pdev) /* 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); @@ -2830,7 +2829,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; @@ -2893,8 +2892,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: @@ -2932,7 +2929,6 @@ static void ravb_remove(struct platform_device *pdev) if (error) netdev_err(ndev, "Failed to reset ndev\n"); =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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6201C4332F for ; Thu, 14 Dec 2023 11:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444109AbjLNLqc (ORCPT ); Thu, 14 Dec 2023 06:46:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444114AbjLNLqT (ORCPT ); Thu, 14 Dec 2023 06:46:19 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6D9312C for ; Thu, 14 Dec 2023 03:46:24 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-55193d5e8cdso3483636a12.1 for ; Thu, 14 Dec 2023 03:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554383; x=1703159183; 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=YimeFaEHAC3lIu4QGMGIH0XFkFOK3pB7g8Rtk8OXULw=; b=NVaV6MdFFn44vQOJ+T5Ea3KVQg2gyfSQXRtVBG80811Bw1y0QPFHPnbE4xxMd+RmZU ShxVe3PU8hmFyrjsBHGkZGl9MSKMm69RyYy0apLcy6a1d/bTymZGSqOPk3xjWv4vCduE 2NPAi35pRpgZu49R0TkEIcgE7u29CEj/sDijwTHMbMBU47gGANB4NDekfWi5fh2jGKPr EpamgjlewSiqBb/ttqQUdgoB8sX4bze6b7gj0qOWzI4wR7bAat6hkDyZQQm4OhNspXFz cRIF11Ide+Z/p0WaZ4taEohoG8LPWitYv3Xd9k/BJyE5RYsmKykNZkZJIKQPtTdJnM3I mu3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554383; x=1703159183; 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=YimeFaEHAC3lIu4QGMGIH0XFkFOK3pB7g8Rtk8OXULw=; b=VpCBNerHOqgXlpp+0PM4LmnKizI11RdCLVm00z6RZpGhF8b/0KYYs0ULLqB6IvMkZ8 IdbaH1OiJrt9kXeAUBMQ3Hy1EYXATBCMT2fQm4d1nGsCT81Q3eYJaqDnX+ALHdsgQDhb EQu0c+PfOWOnhIvh/h7LTkqurFUVfE3RVE4TlZoFqk2Si/Rebe7ZRR02sjSzDxAerQL1 REqE9EcnGul1Droi2lp+CV7kUC7wn/IuP4q9yC7IcD9e4NJqiMlcTl8pH/uRN5Vh1Pad sPbuXwL8vN+kovGzbDFTh5EEvXKfyAOa5/EDGreqdjBdn9OrRCSqMicETIeuk46IEbdg 5j3g== X-Gm-Message-State: AOJu0YzYdbASuD/2wSfCSIJk/8VXW44PyJoVSV3NVp7XpkAO+RuiEHMM HztpNsgpL6CFe7TDLgmemi6I3A== X-Google-Smtp-Source: AGHT+IGCn2/UbIdGnznzhJ0TGCQKSt7Gts2t4IoBzSpbr36Rkj3nYjorrXYeBtJoiUGaYtkZs1R4kQ== X-Received: by 2002:a17:907:2955:b0:a02:8b23:895d with SMTP id et21-20020a170907295500b00a028b23895dmr3746075ejc.35.1702554383237; Thu, 14 Dec 2023 03:46:23 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46: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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 03/21] net: ravb: Make reset controller support mandatory Date: Thu, 14 Dec 2023 13:45:42 +0200 Message-Id: <20231214114600.2451162-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Geert Uytterhoeven --- Changes in v2: - collected tags 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 aa5e9b27ed31..b4d5a14ac4e5 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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62FA8C4332F for ; Thu, 14 Dec 2023 11:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444188AbjLNLqf (ORCPT ); Thu, 14 Dec 2023 06:46:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444119AbjLNLqV (ORCPT ); Thu, 14 Dec 2023 06:46:21 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC9812A for ; Thu, 14 Dec 2023 03:46:26 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a1f0616a15bso916117466b.2 for ; Thu, 14 Dec 2023 03:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554385; x=1703159185; 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=PL5VROIQlUnuTnBZqVb2KKr5+vHUGpVIHNw8m0ZONHU=; b=Txa6w5xmmyEoli356lA+ucuv/peYFuyf6grVed9GrzHIrbYFN9wvFUpFBLvkgXD2VD S3GYhVrmlzbZ7PuHcjxFe/p+uSjt/R+JkAu4XzYjLQv3p6nMpoXMaNgbcWuVdLB7JF50 F9myfw4fw1ZnAaX1gVQOzMe+nsCjqxU8Z7c3/G2V24AJuqx4D+DXfCi/w/+KnBeHmt9K l3NwvkEIffbtRaI992uEXd9XwyJUPdbtWrddjQ3Pp0GbtqY1R6WbJPTUgAWKHM7kULrw 9uch6FJX8JNqjPIKKqE534aKOHHQLTxBAL/ghku6XV6unQdbng5vaTkO1w7/tC1xanGQ 6tRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554385; x=1703159185; 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=PL5VROIQlUnuTnBZqVb2KKr5+vHUGpVIHNw8m0ZONHU=; b=XEcEeAxF9Q1603+zbARYhx/+gXqDIQK6qVakifoqa+gv6/e58/UEmK6nLUvF6Infxk TZTyuGsUjNoYBFSuh0sLjeo7VZMBV+LD59bZwZZnzC6uCFTpXsvkqHvbsiM4YnayHNkL D2KXdloMpEUCOT5eQ7zaNG124RfG+sKQrJACeTdBDTkWVVm7RkrqtrYOM+S+jJ69CBfP H8Q2fU84hYk0AkSA5idgLNw6QGhuobju62AO24S8rYMBvxWH5OszZ4uvBEwTaQBTTHp9 5Dpc0giQcm5ESduPTxWC5suRyMFv4PwGToEAib/l2fOZEz8vJHUEWTZH3VUX23BEPyK0 mD6w== X-Gm-Message-State: AOJu0YwBqdAKBkyBpCazfwi6Po6eIoFuZG6DPJcoqLuADxVR9Nii3Wmq zMajrixmWfK38AGGPcwOyxpXNg== X-Google-Smtp-Source: AGHT+IFilY+iQeeK0x22eHDsUc6bGf7W5xarJ763eOpTEUGRRm8kqwNrurYkInmGp1MIRP3FbelzjA== X-Received: by 2002:a17:906:5350:b0:9b2:c583:cd71 with SMTP id j16-20020a170906535000b009b2c583cd71mr5817776ejo.50.1702554384854; Thu, 14 Dec 2023 03:46:24 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:24 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 04/21] net: ravb: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr() Date: Thu, 14 Dec 2023 13:45:43 +0200 Message-Id: <20231214114600.2451162-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 b4d5a14ac4e5..82085bb9b7a3 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2978,7 +2978,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); @@ -3000,7 +3000,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); @@ -3063,7 +3063,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. @@ -3076,8 +3076,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 { @@ -3085,7 +3085,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99562C4332F for ; Thu, 14 Dec 2023 11:46:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444133AbjLNLql (ORCPT ); Thu, 14 Dec 2023 06:46:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444146AbjLNLq1 (ORCPT ); Thu, 14 Dec 2023 06:46:27 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47A0A132 for ; Thu, 14 Dec 2023 03:46:27 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a1f6433bc1eso101502666b.1 for ; Thu, 14 Dec 2023 03:46:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554386; x=1703159186; 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=sboPzcqED4l7A2TcVT8TTFqV3DguoQYe1ei2qrslI+E=; b=ebcRxg6kZ6cjtU0xL4eBRKIbE+gPxPeJ3BYGM4TCCvSvMaRG5QIqhI63YeGOF41/CL 2rVetTJdjjOYkFASXmuTSmrvr+9RQlfZhmMfZVMlpF5BHLucnIzNfHwf2FHHk1FPpxrQ YGKjwGih8kuKQmzSE9CTUWxOosTTPi7H/phQGFw3MSZ6xP3POdxRkto3YoUZdpu9L6AV Sa1O47InUGCYa4vCBfmCYoRGpur9/0GoRQZWOfGZE+wHR2xm4SNnj76jp5UgyA/1kFvl ssuQtcoN5pgrz6tJQMnQDXd7UPyhBq9kMtv/4RPGFOQCTQ93AsUxa252ti0YmD3/ZGmC 3BCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554386; x=1703159186; 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=sboPzcqED4l7A2TcVT8TTFqV3DguoQYe1ei2qrslI+E=; b=o1rNz+ci2ye4Z8mjzlsaTt1GlWctfjxpErUyT9z/ZD+pFpz0or6IHvnUUXRuz0p0Ib MNMeDRGRIrPqTVV1Jvyw2cyw+mNzjk2lAFeBwjToZvXO7F52NYNYma7RnTu17sK9JEK3 cXju/+i1zO8b6IhhqawFkGKawNxObPaa9DaZX9kJrod4YgYjIWxotWSm+S1sq+1P25HK pQozNCCDk/ihn8xLSihWWCMkI5RfrTYFQs6bct6ex+ceE5qGLuJ7kWoZUKphK9OqMrwF KiFMi1QQcAgCHqRKmdTx/uLrmu+g2D6NuAUbLEGIb9FMfQmdHShIrGRGUfiOnxcFq0Qf wV/w== X-Gm-Message-State: AOJu0Yx8tU7HyAbLYYgvZL2UAq3wtbE1/O7jAC292/H0JrIuCdUJFp/I yE/Ztn8H0rJmUTusfCmQDog4Ug== X-Google-Smtp-Source: AGHT+IHl53VNtTjSgWUmsHo7m90haNzQ56Bx9egUjEPl/J+iHBivUUh8qpwlQivBaht+nSz2egnnTQ== X-Received: by 2002:a17:906:104d:b0:a19:c793:c85c with SMTP id j13-20020a170906104d00b00a19c793c85cmr8063016ejj.6.1702554386392; Thu, 14 Dec 2023 03:46:26 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:26 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 05/21] net: ravb: Use tabs instead of spaces Date: Thu, 14 Dec 2023 13:45:44 +0200 Message-Id: <20231214114600.2451162-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 82085bb9b7a3..5a57383762e7 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -85,13 +85,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8047C4332F for ; Thu, 14 Dec 2023 11:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444121AbjLNLqq (ORCPT ); Thu, 14 Dec 2023 06:46:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444145AbjLNLq1 (ORCPT ); Thu, 14 Dec 2023 06:46:27 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75300183 for ; Thu, 14 Dec 2023 03:46:29 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a1e83adfe72so736212166b.1 for ; Thu, 14 Dec 2023 03:46:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554388; x=1703159188; 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=zPmtetqkn+6AHMt4qrWAH+XK1NCRm1PmSoAA4AvSe08=; b=BtVfCesJcX7uXnFqQj+QHIRwpHKXSpwIdKN1kqLlTULuVmWU8Ph3KbRc5+UZdUky6y JSyPtSXAMVFh1eutGr2XZlEGAZ9tRvoGEnpYPbj2weZsmbS4y7qoBnDY+C3b2roG/VuT 2dX9vFNwiBmETk1l9rApf3j+zlHDUfesugHYmNvE+NPdtAWPHvcAtqh/VA3eW/+L1IlD dMM/9ggcQHJcshOv0WAXI6V+IeJRRbgZEYzMq8BKY+dl7iDVd8KEvPrkaI0Hbun8chOd tZDjFTy8/LJEOXasJwmALVe1Kk+fKStlYaKCR/pmH2m78TIuP+1NsCRdlQerBlg2bnS1 uvpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554388; x=1703159188; 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=zPmtetqkn+6AHMt4qrWAH+XK1NCRm1PmSoAA4AvSe08=; b=Xe3fxPbSBKGeWtCzNXYjVBOuFue9pZg3kl0LvR9/6uV5QKkw3GREF97pxp/UvWG4Nn hBpKaOmIcGvQ4OQfGbl/6W/GEM2INhxKcEA+oTjDYhfsgNdQOsvXELkc8j9LpgMJXAOv 1UUABhBQN8Netm1ePpu88DuD0CFAqUGG1HO9coShFHF+ZKeqUG7dNpQW+JMm3ZOO8kXs RU+Eu+Tqg6zlwFpMB2ZQ2Oau1UXfb1sG2+ziX+OtsUxKJIQBH1yHyHZN1XHxcXWRhHaD pLmyiHD5YY08ZnNM5EBpebHC99KIxBkxomwMEPtAWDDAgACjSpmp3BpU7cIlAWC/dWhQ Q2xg== X-Gm-Message-State: AOJu0YyuMpt0EDCvWD9IqZkuoCV0YSVt/qRFRhCnje9FoBx83fDkcVr7 C31aHjHS4/bDok8mUAZzs8X0Ng== X-Google-Smtp-Source: AGHT+IEV1vVXY4yCrxuSZjg06XM9leKb7L6pjYLxoh7jJlhdAxhghURah8mlsJHVPQriywu6r3+kgQ== X-Received: by 2002:a17:907:aa2:b0:a10:f9a8:bfe1 with SMTP id bz2-20020a1709070aa200b00a10f9a8bfe1mr4762907ejc.16.1702554387976; Thu, 14 Dec 2023 03:46:27 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:27 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 06/21] net: ravb: Assert/de-assert reset on suspend/resume Date: Thu, 14 Dec 2023 13:45:45 +0200 Message-Id: <20231214114600.2451162-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2: - fixed typos in patch description and subject - on ravb_suspend() assert the reset signal in case interface is down; due to this the Sergey's Rb tag was left aside in this version drivers/net/ethernet/renesas/ravb_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 5a57383762e7..9a618d8dbfcd 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2985,7 +2985,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 @@ -2997,7 +2997,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) @@ -3005,7 +3009,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFAAEC4332F for ; Thu, 14 Dec 2023 11:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444192AbjLNLq4 (ORCPT ); Thu, 14 Dec 2023 06:46:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444181AbjLNLqa (ORCPT ); Thu, 14 Dec 2023 06:46:30 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4508E197 for ; Thu, 14 Dec 2023 03:46:30 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-54c5ed26cf6so10160414a12.3 for ; Thu, 14 Dec 2023 03:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554389; x=1703159189; 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=urXQcBC1I2HSJadX/7B8vUlbLmboqpTqecwWwz/bPS4=; b=ZuGXB+eSIGZ4T0x03M35t+rn/f90z0mV8KJz/OtKj2skFSxpKG6woHKXRvYr257RXf O4D9wFhs9dTFtsakOMBIu4aYV3ZFq6BHhYzP/qRalWr7KeeI7tuHsJdFatmnrex6RWHw kq5rlD+8q8DdLJgx6fzPk0Sh9Xq3jCCxuSDqiBOJDhHalVt+tvZE/mp5DoUyYbrKYVMj KVw+FX2WMBxogAbAO5WRRTK+COsfQxYC0ab/fI65/Yz1IYsLsnjVkR3sox3PdS6Mmq6s Hcl9VHghyTr9PgAMEDfVZFYgedOHQz7db+B3xdeAozAXhl8bCeh/hkZoOpjzYmALnLRv kFCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554389; x=1703159189; 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=urXQcBC1I2HSJadX/7B8vUlbLmboqpTqecwWwz/bPS4=; b=Su1gEz+IQyuzX9WG+ZsyNoK0CgSY+7WKs+GdbKM0dUpgdF5gqINIsRPVe0ZCSnUIzt YbYqWmXaUCdToi4QGLetqoGNAE/Un+ZASHOX4W21mprFsDGu7ATIa6BLMyAyAdNxKbJJ SCtjyVGsjf5OvH4anmMeyXnKpwb8X/wVqmI2CDk0igEUGIBcRPKBGNp4qHQ/F04x4pvc GOlU3ZLzbuXDo1dNWGRq5JAPaicOyjxhJyl9G5R1I3AmuSAr3dRsv4CyqqO3mvj5ovGk FiS0Zgzl46F1+oI3Ck7xoekvavHiRjHICss+Cdb+GC4k18FAjYHcYf95/YIsqPefzDLS P94Q== X-Gm-Message-State: AOJu0Yzrr2039+70OhLZod4G3ULJU9OfcqipAcmm9gy0P6NwiHeOnOqJ JdMXP+S76RkE7CkA/8ytJcJhmg== X-Google-Smtp-Source: AGHT+IEqGQoFBiFfzfK3jqMrNe9KA/tUQ/OOWSMGUcII2taRF+pt0OygGdcB8qR+fZU+qYveelsr+w== X-Received: by 2002:a17:906:5a49:b0:a1e:86c2:dccd with SMTP id my9-20020a1709065a4900b00a1e86c2dccdmr4714486ejc.14.1702554389543; Thu, 14 Dec 2023 03:46:29 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:29 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 07/21] net: ravb: Move reference clock enable/disable on runtime PM APIs Date: Thu, 14 Dec 2023 13:45:46 +0200 Message-Id: <20231214114600.2451162-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Reference clock could be or not part of the power domain. If it is part of the power domain, the power domain takes care of propertly 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. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v2: - this patch is new and follows the recommendations proposed in the discussion of patch 08/13 ("net: ravb: Rely on PM domain to enable refclk= ") from v2 drivers/net/ethernet/renesas/ravb_main.c | 88 +++++++++++++----------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 9a618d8dbfcd..83691a0f0cc2 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,23 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] =3D NC_RX_RING_SIZE; } =20 + 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 +2719,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 +2732,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 +2747,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,14 +2756,14 @@ 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; } @@ -2764,21 +2772,14 @@ static int ravb_probe(struct platform_device *pdev) priv->clk =3D devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { error =3D PTR_ERR(priv->clk); - goto out_release; + goto out_rpm_put; } =20 - 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; + goto out_rpm_put; } } =20 @@ -2799,20 +2800,20 @@ 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); /* Check completion status. */ error =3D ravb_wait(ndev, GCCR, GCCR_LTI, 0); if (error) - goto out_disable_refclk; + goto out_rpm_put; } =20 if (info->internal_delay) { @@ -2829,7 +2830,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; @@ -2875,8 +2876,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: @@ -2892,12 +2891,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); @@ -2929,10 +2928,9 @@ static void ravb_remove(struct platform_device *pdev) if (error) netdev_err(ndev, "Failed to reset ndev\n"); =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); @@ -3071,21 +3069,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59C62C4332F for ; Thu, 14 Dec 2023 11:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444136AbjLNLrK (ORCPT ); Thu, 14 Dec 2023 06:47:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444219AbjLNLqo (ORCPT ); Thu, 14 Dec 2023 06:46:44 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A845133 for ; Thu, 14 Dec 2023 03:46:32 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9fa45e75ed9so926823766b.1 for ; Thu, 14 Dec 2023 03:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554391; x=1703159191; 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=UvqstCJTSxpQ0zTFtZeVFyf9XwS489IYbBY9tfQ8I8w=; b=YHA90Fx5I0cqQCkOrzTgfef48t0Rv4Tx/CMTl22g7xUdS5+QGJ2zs8USYnHzL5hMBM vu2g0DZN9ncR8e8S6jpA3qKCpioPYE12zLka/DrvUkXYbiMBvDaNiFCY0t7BHKb+Qt5O dfHm2txXvptwludAcCX57vjrnsXhILUfXg+JPHaIMdyfLGx547mFz9k8nE/S9dhUcQjN UjorlfyrVt2G4/ChIrWgQ8y0P9aOfX/i6Uz/SAT9KV/tz7uvHUJUhradi3Hq7HVy9arr /Y/NaV2+PmFDlDSNhTjqoRjyBfnHQ+NjJHk16J7hlsdu2U7F4WruPRrJnVuRpCCBRdto ZYvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554391; x=1703159191; 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=UvqstCJTSxpQ0zTFtZeVFyf9XwS489IYbBY9tfQ8I8w=; b=o7zYlTpV+lEnCad5BXHaiVdrfSEw9Aoua5lDO/WOhqBuuZKAXQVChyzgdoquZH8uVh BHVXFm8hTjyeZDGvgiiMl/iamGQ9aEIzJ6/gK2T8zTKL2ZcPr2OjLciWD8xpDjD6+J7r Ozdg14NCdbUjXv/1dsl/DKbE5O6VF28PjBHX0hkuu1pCqMT7Jsv7ju6xwtrKaXGZ1JGT RQ/EYZTmmnm4soJWNTiVXUdgft85Gxlz0wuV30rgjWLrtSJCMx7Xidjped3isKAHOOEw goZuRwCzAjeg1i+wrBfZVj+O06OJJr6/MN42DkuJNcVo2iGMBv41/6kOQyV9PbGB3zVR XVuw== X-Gm-Message-State: AOJu0Yy0+sLlLzgwJPQXJa+l/FgAjZtnXPaRlaS4epnSr0Kf5yIHluWc pJTXsALAiqSTKSPKCBd9UuLRHS13KjlphxoH964= X-Google-Smtp-Source: AGHT+IFgAP23xaHhWugO0C8DEtcDbctnuWlDzqn1ezvfAwo7Xo5UqKOcKz77/sBDQ6B+eyrxjZz8FQ== X-Received: by 2002:a17:906:3f5b:b0:a19:a19a:eab5 with SMTP id f27-20020a1709063f5b00b00a19a19aeab5mr4216369ejj.110.1702554391078; Thu, 14 Dec 2023 03:46:31 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:30 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 08/21] net: ravb: Move the IRQs get and request in the probe function Date: Thu, 14 Dec 2023 13:45:47 +0200 Message-Id: <20231214114600.2451162-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Move the IRQs get and request in the driver's probe function. As some IP variants switches to reset operation mode as a result of setting module standby through clock enable/disable APIs, to implement runtime PM the resource parsing and requests are moved in the probe function and IP settings are moved in the open functions. This is a preparatory change to add runtime PM support for all IP variants. Signed-off-by: Claudiu Beznea --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 274 +++++++++++------------ 1 file changed, 132 insertions(+), 142 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 83691a0f0cc2..d7f6e8ea8e79 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1731,7 +1731,7 @@ static inline int ravb_hook_irq(unsigned int irq, irq= _handler_t handler, 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); + error =3D devm_request_irq(dev, irq, handler, 0, name, ndev); if (error) netdev_err(ndev, "cannot request IRQ %s\n", name); =20 @@ -1755,63 +1755,16 @@ 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 */ @@ -1832,26 +1785,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]); @@ -2177,19 +2110,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 +2536,127 @@ static void ravb_parse_delay_mode(struct device_nod= e *np, struct net_device *nde } } =20 +static int ravb_get_irqs(struct ravb_private *priv) +{ + const char *err_a_irq_name =3D NULL, *mgmt_a_irq_name =3D NULL; + const struct ravb_hw_info *info =3D priv->info; + struct platform_device *pdev =3D priv->pdev; + struct net_device *ndev =3D priv->ndev; + const char *irq_name, *emac_irq_name; + int i, irq; + + if (!info->multi_irqs) { + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + ndev->irq =3D irq; + return 0; + } + + if (info->err_mgmt_irqs) { + irq_name =3D "dia"; + emac_irq_name =3D "line3"; + err_a_irq_name =3D "err_a"; + mgmt_a_irq_name =3D "mgmt_a"; + } else { + irq_name =3D "ch22"; + emac_irq_name =3D "ch24"; + } + + irq =3D platform_get_irq_byname(pdev, irq_name); + if (irq < 0) + return irq; + ndev->irq =3D irq; + + irq =3D platform_get_irq_byname(pdev, emac_irq_name); + if (irq < 0) + return irq; + priv->emac_irq =3D irq; + + if (err_a_irq_name) { + irq =3D platform_get_irq_byname(pdev, "err_a"); + if (irq < 0) + return irq; + priv->erra_irq =3D irq; + } + + if (mgmt_a_irq_name) { + irq =3D platform_get_irq_byname(pdev, "mgmt_a"); + if (irq < 0) + return irq; + priv->mgmta_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) + return irq; + 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) + return irq; + priv->tx_irqs[i] =3D irq; + } + + return 0; +} + +static int ravb_request_irqs(struct ravb_private *priv) +{ + const struct ravb_hw_info *info =3D priv->info; + struct net_device *ndev =3D priv->ndev; + struct device *dev =3D &priv->pdev->dev; + int error; + + if (!info->multi_irqs) { + error =3D devm_request_irq(dev, ndev->irq, ravb_interrupt, IRQF_SHARED, + ndev->name, ndev); + if (error) + netdev_err(ndev, "cannot request IRQ\n"); + + return error; + } + + error =3D ravb_hook_irq(ndev->irq, ravb_multi_interrupt, ndev, + dev, "ch22:multi"); + if (error) + return error; + error =3D ravb_hook_irq(priv->emac_irq, ravb_emac_interrupt, ndev, + dev, "ch24:emac"); + if (error) + return error; + error =3D ravb_hook_irq(priv->rx_irqs[RAVB_BE], ravb_be_interrupt, + ndev, dev, "ch0:rx_be"); + if (error) + return error; + error =3D ravb_hook_irq(priv->tx_irqs[RAVB_BE], ravb_be_interrupt, + ndev, dev, "ch18:tx_be"); + if (error) + return error; + error =3D ravb_hook_irq(priv->rx_irqs[RAVB_NC], ravb_nc_interrupt, + ndev, dev, "ch1:rx_nc"); + if (error) + return error; + error =3D ravb_hook_irq(priv->tx_irqs[RAVB_NC], ravb_nc_interrupt, + ndev, dev, "ch19:tx_nc"); + if (error) + return error; + + if (!info->err_mgmt_irqs) + return 0; + + error =3D ravb_hook_irq(priv->erra_irq, ravb_multi_interrupt, + ndev, dev, "err_a"); + if (error) + return error; + + return ravb_hook_irq(priv->mgmta_irq, ravb_multi_interrupt, + ndev, dev, "mgmt_a"); +} + static void ravb_set_delay_mode(struct net_device *ndev) { struct ravb_private *priv =3D netdev_priv(ndev); @@ -2635,9 +2676,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 +2704,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 +2718,14 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] =3D NC_RX_RING_SIZE; } =20 + error =3D ravb_get_irqs(priv); + if (error) + goto out_reset_assert; + + error =3D ravb_request_irqs(priv); + if (error) + 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); @@ -2725,50 +2759,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; - } - } - priv->clk =3D devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { error =3D PTR_ERR(priv->clk); --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12E40C4332F for ; Thu, 14 Dec 2023 11:47:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572877AbjLNLrC (ORCPT ); Thu, 14 Dec 2023 06:47:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444207AbjLNLqi (ORCPT ); Thu, 14 Dec 2023 06:46:38 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7571B11D for ; Thu, 14 Dec 2023 03:46:34 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a1ef2f5ed02so883803066b.1 for ; Thu, 14 Dec 2023 03:46:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554393; x=1703159193; 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=YyI1qtZFZcgDtG22qwfuXsbXZVe5eXhdPaWlE8gTXKo=; b=afNLmCDoJRxkUHNdlGGFw1CwSqctb3GiQWNg7AxoSZjnEUce426nKHYivo+n2l5jed Te/TW6i7VH34ZEOJ4lPq7JbRjsw+FbJ3eTdNEGsSbOK95fiLPef7oDmEnU8+10EMwpuW nC8qpsiIvCMokiQULb329ppIq35FgZkqufRQbrZbliYk6mNxqvLwmQjvWXQXSp7oE79z W4zHPz3QgHOvRoo4RiPBr/Z+C3UloXcWlLqEKGLQkvT/DMYpBphZFgUN9vpbNI2UPL9/ Vn0S8R5mLHISzbX2PB2U+IS2yAfg1WxQ/oQMFKSN95m3Qr0cNwLrIodCyJ/c6pM7Bpi2 O36w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554393; x=1703159193; 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=YyI1qtZFZcgDtG22qwfuXsbXZVe5eXhdPaWlE8gTXKo=; b=bh89mJO1RjtMqxzafMlJOG8MkPuyFTUIF93neMLB+FOQ5J/qm703J6RF21L6XzulvL +HY6gm3eqYxl+DQdqMXxfbrKOq1esam0+6wGo8s2kKQFgYX6RsnPFitdMcicQrzpLcOJ 8fWNJu8Ypq1iBk7tuj6tO5f9BHf4e1yFkwtwfNTbydyvO/vDtalHNoE4BzqVIPt9PZUK clluam2v1FCexUA2T2GB4m6j2M3i/WvgsGGWCpFWTYEB4HnZhed94fC1fXCqdxqcOB5n n+VuDmQUIG7gn51EXmowAKWI9y6VganiPdzMvSs2HuClFjWWpExBtdPeGfakxpy5M0UC uwEw== X-Gm-Message-State: AOJu0Yz1s8TlYtaGlxbMgle0vEHUgklhjdi3PqyLOQ7g8K19BwRetii5 9LbsIHZxgi67seVqA2/zOEdFjA== X-Google-Smtp-Source: AGHT+IH9hM6E8wlCul1HJ/7okzFNjCrfqFi/Oe3i2fnJoRVgpavpdhWPnxBeFos40NXvLSmFMhssBA== X-Received: by 2002:a17:906:20d6:b0:a22:fe3c:49c9 with SMTP id c22-20020a17090620d600b00a22fe3c49c9mr1251684ejc.27.1702554392844; Thu, 14 Dec 2023 03:46:32 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:32 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 09/21] net: ravb: Split GTI computation and set operations Date: Thu, 14 Dec 2023 13:45:48 +0200 Message-Id: <20231214114600.2451162-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 operation mode (and thus the register's content is lost) when module standby is configured through clock APIs) the GTI 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 --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 2 + drivers/net/ethernet/renesas/ravb_main.c | 110 ++++++++++++----------- 2 files changed, 58 insertions(+), 54 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index e0f8276cffed..76202395b68d 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1106,6 +1106,8 @@ struct ravb_private { =20 const struct ravb_hw_info *info; struct reset_control *rstc; + + uint64_t 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 d7f6e8ea8e79..5e01e03e1b43 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1750,6 +1750,51 @@ static int ravb_set_reset_mode(struct net_device *nd= ev) return error; } =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; + + if (!(info->gptp || info->ccc_gac)) + return 0; + + ravb_write(ndev, priv->gti_tiv, GTI); + + /* Request GTI loading */ + ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); + + /* Check completion status. */ + return ravb_wait(ndev, GCCR, GCCR_LTI, 0); +} + +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; + + 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; + + priv->gti_tiv =3D div64_ul(1000000000ULL << 20, rate); + + if (priv->gti_tiv < GTI_TIV_MIN || priv->gti_tiv > GTI_TIV_MAX) { + dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\= n", + priv->gti_tiv, GTI_TIV_MIN, GTI_TIV_MAX); + return -EINVAL; + } + + return 0; +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1767,6 +1812,10 @@ static int ravb_open(struct net_device *ndev) goto out_napi_off; ravb_emac_init(ndev); =20 + error =3D ravb_set_gti(ndev); + if (error) + goto out_dma_stop; + /* Initialise PTP Clock driver */ if (info->gptp) ravb_ptp_init(ndev, priv->pdev); @@ -1784,6 +1833,7 @@ static int ravb_open(struct net_device *ndev) /* Stop PTP Clock driver */ if (info->gptp) ravb_ptp_stop(ndev); +out_dma_stop: ravb_stop_dma(ndev); out_napi_off: if (info->nc_queues) @@ -2449,34 +2499,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); @@ -2792,19 +2814,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); - /* Check completion status. */ - error =3D ravb_wait(ndev, GCCR, GCCR_LTI, 0); - if (error) - goto out_rpm_put; - } + error =3D ravb_compute_gti(ndev); + if (error) + goto out_rpm_put; =20 if (info->internal_delay) { ravb_parse_delay_mode(np, ndev); @@ -3020,19 +3032,9 @@ 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); - /* Check completion status. */ - ret =3D ravb_wait(ndev, GCCR, GCCR_LTI, 0); - if (ret) - return ret; - } + ret =3D ravb_set_gti(ndev); + if (ret) + return ret; =20 if (info->internal_delay) ravb_set_delay_mode(ndev); --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5F04C4332F for ; Thu, 14 Dec 2023 11:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444248AbjLNLrN (ORCPT ); Thu, 14 Dec 2023 06:47:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444224AbjLNLqp (ORCPT ); Thu, 14 Dec 2023 06:46:45 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53DE11B5 for ; Thu, 14 Dec 2023 03:46:36 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a1f8a1e9637so102533966b.1 for ; Thu, 14 Dec 2023 03:46:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554394; x=1703159194; 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=e1OUji9wCp+dAckpdOqeAMpojOUtVbEPR5TgenY6gOI=; b=ooVfqKUklJlxQoHrqNicnWYxMgvGyQHIKGfKpVWUcejGNBMGhz0Xqk67jOZ8HMF+Em busJOk1edJAoH8ivjjr4DnpRY6LodWH+jyn8kwygrirP8JNOHIszNF61rtn0qEOmcTIW S2QwAQsh3m6rrxDfSKv8ffFm9kYHxSrrp3skRmd7wVJL4NFvjE1ZwSYm+cS6ted1C3KC BeY8hZoU05LeXGXSPZyAJVmbbvyXlXyR89er3uAlhXkcSOIW8DvZcWUkWVhIgywEykis IxJLHd4lSM9cTS1bdzwGY9In++0axBUwa5Tcbtafht4tfzrqjc+emo4Ci4CIVSgwrd65 CBHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554394; x=1703159194; 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=e1OUji9wCp+dAckpdOqeAMpojOUtVbEPR5TgenY6gOI=; b=Uj8USMTrliN7+9aNNtulEhggeYg8QIOdHQTUAqzrvxm8Jpg5pcb9E+AeVkzqGc5V69 Y7O9ymLewz8JrdkF1xN3cFQ87NY2NiXESfZkL0ToNkrTAVfiO2ETIht2rvBhhSzXdAVM 7xk0zQF/bmhuGYWJKUgcT46Iy8oF16s4icwV+QZ13BA17dCkyT+nIvQqCZjIV79heeM8 WcOOc3bF0/Cu7dVw+nEKH1buqRp54VkmxLIoY/SUhvNrkgZGHOlH9onTdJGikThdMSXI 51aLxY/SHCwq2/jTsuaW4qMS4N0i4tUMp1FpGmcOboe2nFsC9hmfztBpJfxp5t9JwHy1 /DJA== X-Gm-Message-State: AOJu0Yy41ayeZgvgRvWLUupb9j4MEpB7WkXsw++KFMUHJJ1EVlIYODYb 5pTas6Bu82are7xnC7ucCR7xIg== X-Google-Smtp-Source: AGHT+IG0O3EByFK5t8ueAC3nSEptoUgXCTlKhlPL3bo+hmkiivb3jH82qzlmXVkixY8Xyi001BW14w== X-Received: by 2002:a17:907:9729:b0:a1e:eebd:ecd with SMTP id jg41-20020a170907972900b00a1eeebd0ecdmr11378221ejc.32.1702554394749; Thu, 14 Dec 2023 03:46:34 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:34 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 10/21] net: ravb: Move delay mode set in the driver's ndo_open API Date: Thu, 14 Dec 2023 13:45:49 +0200 Message-Id: <20231214114600.2451162-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Delay parse and set were 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 keep the delay parsing in the driver's probe function and move the delay apply function to the driver's ndo_open API. Signed-off-by: Claudiu Beznea --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 37 ++++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 5e01e03e1b43..04eaa1967651 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1795,6 +1795,21 @@ static int ravb_compute_gti(struct net_device *ndev) return 0; } =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->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) { @@ -1806,6 +1821,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) @@ -2530,6 +2547,9 @@ static void ravb_parse_delay_mode(struct device_node = *np, struct net_device *nde bool explicit_delay =3D false; u32 delay; =20 + 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; @@ -2679,18 +2699,6 @@ static int ravb_request_irqs(struct ravb_private *pr= iv) ndev, dev, "mgmt_a"); } =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; @@ -2818,10 +2826,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9A55C4332F for ; Thu, 14 Dec 2023 11:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444313AbjLNLrQ (ORCPT ); Thu, 14 Dec 2023 06:47:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444234AbjLNLqp (ORCPT ); Thu, 14 Dec 2023 06:46:45 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F9A121 for ; Thu, 14 Dec 2023 03:46:37 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a1e2ded3d9fso967649866b.0 for ; Thu, 14 Dec 2023 03:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554396; x=1703159196; 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=lR5Cjb3g5JwSTu3j/K8ArNRp5NJou/sw/M1aYXvPkhE=; b=gryyX4Y6UY59iIdoIvoVNQbrEJ94YU9HfU3wjgLIP/OpjCse6cSY9v0Q1yvikxxU58 AtAFQJ78WRBndmjC0tLCBLt71fUZTVcODl9BRyM2CSNgYw6NkT1x7WhTssQMH9S0pvXw xXG4Z56d79I9g5kGyBJXgwN5T3LxmQUi2ROk8n4y3JgH0Xbl4kGIAdqMnP8QEhOSwbal xmiN77e4n1g19FI3SRkPV0ZNB9pAY6IlhTj2vxoOTb4RKeLOY1qccznWHhQ1IZ+h1dwZ 7GldsMsUw9wHI1lgQ9mpbgCO8LA1HiBnRr+8yclOH2tqNbUcq+haASEVPTu0OHeAZWZy f87A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554396; x=1703159196; 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=lR5Cjb3g5JwSTu3j/K8ArNRp5NJou/sw/M1aYXvPkhE=; b=lX9TFSorpA71C84pqRpKoqxASSHk9DblEL1sq/jrMfRyzgqUdp045soKksGSU5QDho F2dSjBJxj8SOm6Vyr528JJY3TOROktqcvuWlUe0VUxmf2+NdqQHWak08QNhj8ekTA3l5 lvzU4feJ6nEESEBbN2lnEov9Ndut/iaJX5MWuwcRGBRm3WPvciRhO3xMYDCXZlI+jDNJ FkF0q/kUpOxW0wWeMxwFwF5Vs1JEUFLseWRva4jOEsPTlqSc9stFP6kuWknEz63YoYgU RN1UfHs+O3e7RqU389bZNvuLtnw3gLmufCUDi1vlZa+YlaEqzPMoaOoXbWxW2qt0Ljus y+Rg== X-Gm-Message-State: AOJu0Yw7OmZ7e+b3nw7nEyYvuPMXQ5QXLD5iuhNak4ZnwfGgjafAZRZX MpYrUl1EIqgrBUrwc8nPtNXk0g== X-Google-Smtp-Source: AGHT+IGTEA8XdvK5DIgTXUJDZNcrpoxh+EdMHgeULkwRzquHNIZ6hTg2ARSBoQED7sSDbafP7bbF/g== X-Received: by 2002:a17:906:53:b0:a22:fc0f:9878 with SMTP id 19-20020a170906005300b00a22fc0f9878mr1424003ejg.16.1702554396449; Thu, 14 Dec 2023 03:46:36 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:36 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 11/21] net: ravb: Move DBAT configuration to the driver's ndo_open API Date: Thu, 14 Dec 2023 13:45:50 +0200 Message-Id: <20231214114600.2451162-12-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 04eaa1967651..6b8ca08be35e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1822,6 +1822,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); @@ -2841,7 +2842,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB2F9C4332F for ; Thu, 14 Dec 2023 11:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444317AbjLNLrT (ORCPT ); Thu, 14 Dec 2023 06:47:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444241AbjLNLqy (ORCPT ); Thu, 14 Dec 2023 06:46:54 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A811BD for ; Thu, 14 Dec 2023 03:46:39 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-50e0d1f9fe6so2852700e87.1 for ; Thu, 14 Dec 2023 03:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554398; x=1703159198; 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=YUpk9YEw4O5jZFB/MhCu88qNpJzCkLxLIB6VsR179rU=; b=kvJ9INdg0ZqMNqg8of9oBNzFNJJFxmQ70NToJ82NrikOjaxrizVuPoNIqcBLuY/+MD T1oo8gLFyEyXjhVMAZKvOHsYmBnVeP7XM+SGiO5pX0YTkfxHW5XfpBI15FVAAZymQ3Eu 5QsPdbE2qjJNp219I0CFCIexY4OwHZbGR/yom+uSMYbt/kqBMHX/GT5v8OdnPqPtrN2g hFv2SqqMJNQ0B9mTNAwRv3jMAjVQ3QW6HAAfb5czcaVASuAjHk6ZEbg8pwUd0Xv1flQA SFdGx6V7oDTlp/XyR79Odwvr1zHAn5L8im5BPr9eYcr2ivNfxjnFGNrfIfRWV6FayLun xMHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554398; x=1703159198; 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=YUpk9YEw4O5jZFB/MhCu88qNpJzCkLxLIB6VsR179rU=; b=WRW9cN1XjE3MpDYw49eMDmrkyIIwilwvAy1kzu0y/ICKu07BBZLFx2zfLtgWYyit/k X06IDe/C7PKWTLcsAIohFGG9vnnb0cgOuswt76Jb6c3jcmEH/HXOGJwlo3OTVgf8CI/e DiKkG0ijntmZZlvK+DNi/GGxwxYANiciQEyik+/0SDSWKCbw3Y2BnmSt8CwlDgvK0jiy 1D6wtgIkfAOiRq0VM4/fXZqBr7/OwUUTdiEYSawAkfsRL8maYS/mShHvY7U+Cza4PlpO 60Q20fmKfeQ9beWiSUZrTlrrDWnSCaXcKf86pTVeuo1RTxCb91ehp0Y1p+0zGN0Crr/v x0Fw== X-Gm-Message-State: AOJu0YxmdLtz/DDI9jTS7M+YoLy85wmWR/jDCpypI2AoD7KS0r15ryog jcjmS+Q3WH5h/5loGcfeLFz6yw== X-Google-Smtp-Source: AGHT+IE0y3Td04brKCB75tYN8zqof2o97uZkz4II4IxWKFLNIX1b77Ouhh0D+qPezdfOihQoAIzZ1g== X-Received: by 2002:ac2:4e8f:0:b0:50c:44:919e with SMTP id o15-20020ac24e8f000000b0050c0044919emr3721718lfr.108.1702554398125; Thu, 14 Dec 2023 03:46:38 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:37 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 12/21] net: ravb: Move ptp initialization in the driver's ndo_open API for ccc_gac platorms Date: Thu, 14 Dec 2023 13:45:51 +0200 Message-Id: <20231214114600.2451162-13-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 chapter "Figure 50.71 Flow of gPTP Initialization (Normal, Common to All Modes)" of the R-Car Series, 3rd generation hardware manual and chapter "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 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 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 6b8ca08be35e..db9222fc57c2 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1835,7 +1835,7 @@ static int ravb_open(struct net_device *ndev) goto out_dma_stop; =20 /* Initialise PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); =20 /* PHY control start */ @@ -1849,7 +1849,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); out_dma_stop: ravb_stop_dma(ndev); @@ -2151,7 +2151,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 */ @@ -2846,10 +2846,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 @@ -2894,10 +2890,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: @@ -2924,10 +2916,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD06CC4332F for ; Thu, 14 Dec 2023 11:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572885AbjLNLrV (ORCPT ); Thu, 14 Dec 2023 06:47:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444137AbjLNLqz (ORCPT ); Thu, 14 Dec 2023 06:46:55 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38E2DD46 for ; Thu, 14 Dec 2023 03:46:41 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a1e2f34467aso736082966b.2 for ; Thu, 14 Dec 2023 03:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554399; x=1703159199; 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=n7dNH0yi6XzttRpIS4P56ybelKHS8ihp5wjWT0GHLak=; b=Eeq6inLy5W2mrO354iuSXJVYQZU/JiVrKYFzyhVi0WPclNViMhg9B8TBysbWHKTEBM BO283Wx5dxCl5T99e6p6RjiULDAwOEmZV0ND3POX9y42nc76z5pqs330Fwna97we1+72 KadgywhLlXigJ7PTw3nsGHgUgCjXxa94c/864bIA70I4X8bkf9nBrBFt489t3vayRfXz 98YZWuw2e53qwqbZexp7HV9WLRgl6vKh0Pv83Gx2UhKn2t7wEL2dJXSCxwpUk7Y3UUqV x1dYzLSgFAuGseRQuZZggs5CTHO9TwzQ98P9PCUQm4w2CriGOE31U07WTToPKdSHKp8w 4CPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554399; x=1703159199; 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=n7dNH0yi6XzttRpIS4P56ybelKHS8ihp5wjWT0GHLak=; b=kfIwHxIuWsee3DR8RPvlGB02XyddFpz85raL3OuWKGkdcp9CBAj8iDf7DC2kEwvblN ZdGnvlUTUV2f6wgHEzwCW8MiNlYYIlUY0KNf+jtFliONz+Jmw5x4fGLWuqEBTloSP7XR 7oTWc+lMdLnJZZO7gjAJGORu8bWFlDS5T2AjwQ282dzAhReU2lG8u5kW56nI1JpkMzqZ 2NYwICSeWkTSg4nvYjF4J8Bjod8wtsXwiutotSbSCCuE5kd0pOI1uQAjaGKCss6GlPic avCFKXvAzPAAzOa7rmOxr8rQDffW2mxKDMS7LSuSZlOQlpWqVmVtS85lQIqiZJpte1oo iZ5Q== X-Gm-Message-State: AOJu0YxBUAVn0SEtTr8dednkEJ0aZbyL2Ud5NFuDIjgoRJOW66VeOu3b y8MoDB5sEUx7LKErRSopewOy7A== X-Google-Smtp-Source: AGHT+IEwULcW6kIbUcVj2dm26sY++GOUztxBHkNp2Xd5nW0QXKxtbqRqRpO6mxt8JWERKWyBfds/1w== X-Received: by 2002:a17:906:dfc7:b0:a1c:aebe:ff2 with SMTP id jt7-20020a170906dfc700b00a1caebe0ff2mr5282957ejc.37.1702554399757; Thu, 14 Dec 2023 03:46:39 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:39 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 13/21] net: ravb: Set config mode in ndo_open and reset mode in ndo_close Date: Thu, 14 Dec 2023 13:45:52 +0200 Message-Id: <20231214114600.2451162-14-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea 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 and save more power, set the IP's operation 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 operational 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 --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 91 ++++++++++++++---------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index db9222fc57c2..31a1f8a83652 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1738,6 +1738,30 @@ static inline int ravb_hook_irq(unsigned int irq, ir= q_handler_t handler, return error; } =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) { + ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); + /* Set CSEL value */ + ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); + } else if (info->ccc_gac) { + ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG | + CCC_GAC | CCC_CSEL_HPB); + } else { + ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); + } + + error =3D ravb_wait(ndev, CSR, CSR_OPS, CSR_OPS_CONFIG); + if (error) + netdev_err(ndev, "failed to switch device to config mode\n"); + + return error; +} + static int ravb_set_reset_mode(struct net_device *ndev) { int error; @@ -1821,13 +1845,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 error =3D ravb_set_gti(ndev); @@ -1853,6 +1883,8 @@ static int ravb_open(struct net_device *ndev) ravb_ptp_stop(ndev); out_dma_stop: ravb_stop_dma(ndev); +out_set_reset: + ravb_set_reset_mode(ndev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2187,6 +2219,9 @@ static int ravb_close(struct net_device *ndev) if (info->nc_queues) ravb_ring_free(ndev, RAVB_NC); =20 + /* Set reset mode. */ + ravb_set_reset_mode(ndev); + return 0; } =20 @@ -2517,30 +2552,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) { - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); - /* Set CSEL value */ - ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); - } else if (info->ccc_gac) { - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG | - CCC_GAC | CCC_CSEL_HPB); - } else { - ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG); - } - - error =3D ravb_wait(ndev, CSR, CSR_OPS, CSR_OPS_CONFIG); - if (error) - netdev_err(ndev, "failed to switch device to config mode\n"); - - return error; -} - /* Set tx and rx clock internal delay modes */ static void ravb_parse_delay_mode(struct device_node *np, struct net_devic= e *ndev) { @@ -2818,11 +2829,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; @@ -2857,11 +2863,16 @@ static int ravb_probe(struct platform_device *pdev) eth_hw_addr_random(ndev); } =20 + /* Set config mode as this is needed for PHY initialization. */ + error =3D ravb_config(ndev); + if (error) + goto out_rpm_put; + /* MDIO bus init */ 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 netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll); @@ -2875,19 +2886,30 @@ static int ravb_probe(struct platform_device *pdev) =20 device_set_wakeup_capable(&pdev->dev, 1); =20 + /* Reset MAC as the module will be runtime disabled at this moment. + * This saves power. MAC will be switched back to configuration mode + * in ravb_open(). + */ + error =3D ravb_set_reset_mode(ndev); + if (error) + goto out_netdev_unregister; + /* Print device information */ netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); =20 return 0; =20 +out_netdev_unregister: + unregister_netdev(ndev); out_napi_del: if (info->nc_queues) netif_napi_del(&priv->napi[RAVB_NC]); =20 netif_napi_del(&priv->napi[RAVB_BE]); ravb_mdio_release(priv); -out_dma_free: +out_reset_mode: + ravb_set_reset_mode(ndev); dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); out_rpm_put: @@ -2907,7 +2929,6 @@ static void ravb_remove(struct platform_device *pdev) struct net_device *ndev =3D platform_get_drvdata(pdev); struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; - int error; =20 unregister_netdev(ndev); if (info->nc_queues) @@ -2919,10 +2940,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 - error =3D ravb_set_reset_mode(ndev); - if (error) - netdev_err(ndev, "Failed to reset ndev\n"); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); clk_unprepare(priv->refclk); --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75375C4332F for ; Thu, 14 Dec 2023 11:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444151AbjLNLrb (ORCPT ); Thu, 14 Dec 2023 06:47:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444198AbjLNLq4 (ORCPT ); Thu, 14 Dec 2023 06:46:56 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FDD0D56 for ; Thu, 14 Dec 2023 03:46:43 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50bfd3a5b54so9071150e87.3 for ; Thu, 14 Dec 2023 03:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554401; x=1703159201; 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=9cT7sZVhk3SPH3qfWzj9p6vjX2dF9hm4OYxHa78CzWQ=; b=CDEYaeaE6qduuOmQss6XjTpBXM3l7gS2mus6VDSWgpvsyp5VVU14HtMHCVJG7z5rUX YkkdljRVLrtBpLWUoHHqmN73+boOi/tndrwdDrNwO03k5sScGTIoyMZv1EMB9KzhPAdV eXXr99nB4SQRzrDPDnMsfLd9I1uVo01hmH1PSXz6sI5ltOtO3eq6pA/gfxEnt6WqZuYj GskgPJd7cirHQ9sde+NaB75o769xgmBDu9vcb2MvmzihbVAzZ3NPbsrwmjHek5dOwurS Azdv0m4nc37IAPXIyl2lCCV0+9Fl9g/XAyvZ1Y7JV+lGnX9hALmkfZJVJSqAUdHGps5Q 2UYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554401; x=1703159201; 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=9cT7sZVhk3SPH3qfWzj9p6vjX2dF9hm4OYxHa78CzWQ=; b=UcaXT7xVLVWy+kV5XEIerXBhhORKTMqMaVWxe0om2XNDmwVUiScZqHgfxrR9dXJolj 1hZw498EYAI5BGam6OuiF3/akItw34C86bDI0W99z0yuPAeqW23dNRcFAt4FMYsAhwsO CJvKp8Lh9M2ecdfkKXTz312Nm5KAQEhpQbOxXgzYLMt2Mdfh7I50QcKWGUUtzkDoua0m G+hmwRtYsdPxNGoPC0nLYyBnEuv5VTz9FShhIU8axt/objnA26r4vvLWr8KHKvM4QQOU ryesMMI/2HJhmFy+3dEBTmk92qcyyVDw/8TsYa2er1T1b46GSxRu1k8IQebVTvv1YjMn KZbA== X-Gm-Message-State: AOJu0Ywh3OeHc7y2/WqceYUGqxwFPhzpJoBNfTbWmUGjRuvYWGB6JCal AUY5W9uNeuJlbY60KaPZIlWJvQ== X-Google-Smtp-Source: AGHT+IG971WfjyERHQhZ0TdR63Dq7y7Fb1xD2Xpc2eRNcB9COcCGSdCFifT0aHwVpfyDHrdNy75McA== X-Received: by 2002:a19:ad44:0:b0:50c:2fc:cac with SMTP id s4-20020a19ad44000000b0050c02fc0cacmr4070502lfd.126.1702554401526; Thu, 14 Dec 2023 03:46:41 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:40 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 14/21] net: ravb: Simplify ravb_suspend() Date: Thu, 14 Dec 2023 13:45:53 +0200 Message-Id: <20231214114600.2451162-15-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 separated 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 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 31a1f8a83652..16450bf241cd 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2968,6 +2968,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 @@ -3000,14 +3003,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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 063F5C4332F for ; Thu, 14 Dec 2023 11:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444196AbjLNLre (ORCPT ); Thu, 14 Dec 2023 06:47:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444270AbjLNLq4 (ORCPT ); Thu, 14 Dec 2023 06:46:56 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E650D5D for ; Thu, 14 Dec 2023 03:46:44 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-54bf9a54fe3so11086101a12.3 for ; Thu, 14 Dec 2023 03:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554403; x=1703159203; 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=33vAc5ck7zdvdX0qktOXfLvJPjpSeplyQvjMFmFH8tY=; b=LoFzQstsVKFmbpptn1HQVy1NiqC8PnygBJJAhNpM54Cr8k0uT/Vih+aw8BmqUvYG1s EmtYhdKoEu5Bx7nQjjjFz57MaOu3btxYEAL27cxVYnQs9nlShDo1qCPTa1rs9ItTDPd8 YhKcm9Y+N+6qhI/v6YrD5lcXVw6R0SQkt/0F3g0B2cHPmoSqa2mfIunH8xMLg4oScPg5 MhhTqOlDK1ZuzZaBz73QeBDTkHJ1BE/O/o651PQj3iZBnLpCKAXAuSjMTWHFWTnBC9jd 5SS/rqPuhQOjRyd5tPH7a8r8/1WsVVzxJtOocpoHunTqKJYMWoThAAniuWb2dVtrEAPt Ne7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554403; x=1703159203; 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=33vAc5ck7zdvdX0qktOXfLvJPjpSeplyQvjMFmFH8tY=; b=kKvep7p5g9kQEERFbPEKyNtw4UcW/qnZYlVB6gZeUyWXCpF4BH/Ci0x1V8KyMrK+Dd 6/HPl6S2JCj4RqHaIGObgoLlZOaN9MNYUcWgVLDAhyr2bArXXZHDCZNeUumzM3UF82D8 8HlVPw5kC8wFD7UMdPmrLePo+Ou04nxveVkZjPzVHzt0XCwnGlxMUVW4uQ55zX0abn+/ 4V9wqEGk58mga8eZFK9ewO7Cwhp4bxMHem5P6xwmdDxzAfF/b5U6Alpm4HKvXfxWOFmo xIFhma2wsiGNa8jHEL8TuUyjE/vNvxpj2cJSFT24TzabwNsUASYl3NLBhmZBI1rUkIoO g8Kg== X-Gm-Message-State: AOJu0Yy6jIWoPkimvt/lkCHX8w5q1+KAlHRLnK9DEN9LrEFR8ubX6q5r mp49t1dlgp0K0bAiwonI5lupaA== X-Google-Smtp-Source: AGHT+IFyLlweizU3HmYYgch4IUmSBXQSbhxj3U8dxHcyuNzp7kt/p9z7G0OxdVq+g4jtagb4Wh3qWg== X-Received: by 2002:a17:907:c715:b0:a1d:551f:a197 with SMTP id ty21-20020a170907c71500b00a1d551fa197mr5941372ejc.82.1702554403005; Thu, 14 Dec 2023 03:46:43 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:42 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 15/21] net: ravb: Simplify ravb_resume() Date: Thu, 14 Dec 2023 13:45:54 +0200 Message-Id: <20231214114600.2451162-16-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Remove explicit calls to functions that are called 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, PTP needed configurations were moved to ravb_wol_restore(). With this, code in ravb_resume() is simpler. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 60 ++++++++++-------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 16450bf241cd..b581666e341f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2978,6 +2978,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_reset_mode(ndev); + 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]); @@ -3017,55 +3031,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_reset_mode(ndev); + 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 - ret =3D ravb_set_gti(ndev); - if (ret) - return ret; - - 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 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 605D0C4332F for ; Thu, 14 Dec 2023 11:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572887AbjLNLrh (ORCPT ); Thu, 14 Dec 2023 06:47:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444206AbjLNLq5 (ORCPT ); Thu, 14 Dec 2023 06:46:57 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49951D6D for ; Thu, 14 Dec 2023 03:46:46 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5526c14b8f8so691150a12.3 for ; Thu, 14 Dec 2023 03:46:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554405; x=1703159205; 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=NoiORotVHtzab0Z6R5tqUvsar+MHiUXnH/O7lUfaa34=; b=VDRP0MYqeIxkNCwLg1+URch3+vUo8qgO7a1B9GIQ9sq8G2Jzn6TEJHo4n/kbNcT0TQ UzeoerzztzZ9yt9Jx4oulqrRdu74mLvZQbfL5eT2rsWr8HCLu5BzTj6rk8sHcnFAfTt5 CwiGIJlGtcWm4pz+N3VmlQ5HTAr9vERm11jB6w2taQDq2DtHbcdR8lIPym5PgMTbGuoe FaHH8gDnhn2CmZruZFXLO3lPx1+b3C+KXwogPyZ8IRsBfR2v6NJfy/Tt6j+eSymwZ6Mj fCFpOlymA63cxhPLuY1kd5+3o4wS5N9PWYLoXRETnDiSswU4koAfuYFBRutqcZIQRfSV +K2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554405; x=1703159205; 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=NoiORotVHtzab0Z6R5tqUvsar+MHiUXnH/O7lUfaa34=; b=SlWUhfQRiJC67INjAvcQ2yykewPj5Nd1ReIU/Oq7p7VfA/h6D+LNKnl14PWWsCsNMI tZ+++EOzis5WxK47LwsyAw+9Fky9RZ4EbBb6LgVr2QXZyhd9Lqgl0QbGmcxdlCBu9hPj Dh5jQriFhZPwTTl+dFBR6c0sEKq/5zeqPOoPKLiSHOdu1USEf69xJA0aKsRpnKWjEO4f WREHZV9LQ/SMR5Kts2vsiEKs5n4VnXhFRzDgaXejdUjleS28neE7sgDkb762Xyb7eRTr RLxwVYtBi6Z5kpqeCvUQUSvyD0/cgpiMxUbaGgcEI6oDsUhdt4EdQ6d/sdthokXMIYjC mqPA== X-Gm-Message-State: AOJu0Ywl2cfRuJvvMVNRUuVIt7g2LlVseB68ylTqA0/2uZeDaxaDrv5K ddVE9zDkXVK/tdp6fPi5RNZ/dQ== X-Google-Smtp-Source: AGHT+IEkHkIjbZxyWNnhWgVzwKp1oLjVB6rkXJC6EiXk5LsZBUGVINMSQUgKJqcBBpk9Att/KP854w== X-Received: by 2002:a17:906:de:b0:a19:a1ba:bada with SMTP id 30-20020a17090600de00b00a19a1babadamr2578053eji.128.1702554404767; Thu, 14 Dec 2023 03:46:44 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:44 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 16/21] net: ravb: Keep the reverse order of operations in ravb_close() Date: Thu, 14 Dec 2023 13:45:55 +0200 Message-Id: <20231214114600.2451162-17-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Keep the reverse order of operations in ravb_close() when comparing with ravb_open(). This is the recommended configuration sequence. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index b581666e341f..38999ef1ea85 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2182,6 +2182,14 @@ static int ravb_close(struct net_device *ndev) ravb_write(ndev, 0, RIC2); ravb_write(ndev, 0, TIC); =20 + /* PHY disconnect */ + if (ndev->phydev) { + phy_stop(ndev->phydev); + phy_disconnect(ndev->phydev); + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); + } + /* Stop PTP Clock driver */ if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); @@ -2200,14 +2208,6 @@ static int ravb_close(struct net_device *ndev) } } =20 - /* PHY disconnect */ - if (ndev->phydev) { - phy_stop(ndev->phydev); - phy_disconnect(ndev->phydev); - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); - } - cancel_work_sync(&priv->work); =20 if (info->nc_queues) --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F91C4332F for ; Thu, 14 Dec 2023 11:47:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572892AbjLNLrp (ORCPT ); Thu, 14 Dec 2023 06:47:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444225AbjLNLrJ (ORCPT ); Thu, 14 Dec 2023 06:47:09 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 361E7D7D for ; Thu, 14 Dec 2023 03:46:48 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a1ef2f5ed01so1006548166b.0 for ; Thu, 14 Dec 2023 03:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554406; x=1703159206; 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=tYBn9/laLzrg7Vdv2MX/5C0b5odhy/gUWFCra0JFpOw=; b=W7zLXBgU/MmJZmapmnyy1jmsQHZ7zVFjlgXXG1EsktOvneRpT/IuxMOOMw9WM8K56+ SWsoyZ7uC+zoDdYkq+Idik3vzN7uxAA/y3GlzqvxcJS8db8iCKB9Z72NfU0ksgPttFIL Cm0GvfuA7aEYcqrruZpkgwpb3guc/CFjPMCAh3uGWJ3TUOUtqBLlw0TMjvlbqPlvtSTc GteAnq8rhPPTKkTR0IADYOwsJsyrmkouIArwUtjlH4xvHmMM96aRCKb+038EFGSPjpGT iNytUewClQt6tYPHSsY1hhEJnRkFKdZ6BvdZcTLjK3FTah9rN8VmniVvN1ZqgP+E6VTr 2zAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554406; x=1703159206; 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=tYBn9/laLzrg7Vdv2MX/5C0b5odhy/gUWFCra0JFpOw=; b=gga2nukTSbekk9RqY8KvfxGIOsYtdbMB/jiX0OtUhtxYsxjOskdO3ENAx0Js+zOhkE zpU5mpbC9z9oaxve0arLHb12AmNEpzXcbqn75YlECI9miqkc5VGIFp0RGlBKVMdpJf6S H4mdUk3FqIFqdR0Q120W5vzEYzNqXzYw3xq98wayN3LfcFWho5xTFkNMmHhOGN3RVmxS IONKr2EykkDpVqXwD9tJoZ6aa8DSbjnAStlWDF/bUWmzmnUK5wwbNCgDhnLHmDOV6aGP 9RCTregQxJkyyZ/O2jwpp0eACsM2uAkfDoqUFyIerEAjkU1FksmKGXbx0jcqLfcIYOFW mV5Q== X-Gm-Message-State: AOJu0YwEiYE+FnXc454LRhwOyDhPA7VXhyY2MEjiPogmAAkb3wPmK3c5 nvgzUePFvxeP66bFT0fKrnY9VQ== X-Google-Smtp-Source: AGHT+IELfCBw9NbcKSq88512K3cgJnjQwOtGysv+vOQMfS/g+oF4gHBjkLsL02Q1+qt0DyW+mANwkw== X-Received: by 2002:a17:906:197:b0:a1b:d7a5:927a with SMTP id 23-20020a170906019700b00a1bd7a5927amr2171533ejb.183.1702554406583; Thu, 14 Dec 2023 03:46:46 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:45 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 17/21] net: ravb: Keep clock request operations grouped together Date: Thu, 14 Dec 2023 13:45:56 +0200 Message-Id: <20231214114600.2451162-18-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Keep clock request operations grouped togeter to have all clock-related code in a single place. This makes the code simpler to follow. Signed-off-by: Claudiu Beznea --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 38999ef1ea85..a2a64c22ec41 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2768,6 +2768,20 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_reset_assert; =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); @@ -2801,20 +2815,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 - priv->clk =3D devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - error =3D PTR_ERR(priv->clk); - goto out_rpm_put; - } - - 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_rpm_put; - } - } - 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 Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FA5C4332F for ; Thu, 14 Dec 2023 11:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444219AbjLNLru (ORCPT ); Thu, 14 Dec 2023 06:47:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444299AbjLNLrM (ORCPT ); Thu, 14 Dec 2023 06:47:12 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5EA210DF for ; Thu, 14 Dec 2023 03:46:49 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50bdec453c8so9441273e87.3 for ; Thu, 14 Dec 2023 03:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554408; x=1703159208; 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=hga+Euca2ffWU8RByuMIoZjdDg4sBJqJ6E8Xj3GqHcU=; b=l7aXLowxuHeivrKOLCrOxfXiS1Nkru3oah4VqGlbWzr/wvwFOVe4IafZKyJEBZsLE7 Q3Kri5ufiU8CX9ITsqdLvbIe3CNkWNKPN7oywmcvoD6u8ulM/EAcowXe7m/MQ1wWkqPT DUGDkvyLM2kFAC3xfLE9aSmrOvXmDV+doBJbK9ywwWDTBjp7JAaiUXwpaZWaLgRFbTIt i9oSBRGOalagrvRzGbHKOWP3IHnlz/VStR+oT0HpnFUIfc8dv74IbvmTZPgTjzEX1rO2 A3H5qLN0KnqwO4A1VU4k8Ur8vxNq9ITQv45AIgcPYmfxRMq5g37AzsTfAVm1/ly/9EYJ 3+Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554408; x=1703159208; 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=hga+Euca2ffWU8RByuMIoZjdDg4sBJqJ6E8Xj3GqHcU=; b=sSjJotwHTx+hCL6eCwD2Vw6fwczRETTConqNinBEb+B2tT/NcJ0U9bOBJFpcHLhlih Y9ri06IasWXmieNwct+gmWaIz9oAYOWn90LWU14oMZLUtlwXYl1iBMaHEBloQvR6pmMq 9LXySciDAafmbqAKsn/x4MpNFmjnGnojEeTcpv0YENV+VKKu2njVC+6OUVf6TkopMnyM dOmlzuTzv5BZrx6s5eVEHojeGkpFkDsv4VvdA+K1xP+2IzMc2U0G0pZjVn0H84E5tWSQ afrAzijxQgNZcqCNa2nNZvJWbtBUdl9zh0Wkndj6KeJ+DgueBl2hASj3Ubb8OTCoY1Ze 8F5g== X-Gm-Message-State: AOJu0Yyjf94ofNH/f9XsY77tS33QJBJwbq8n5Fw8PfoMpTntgiqWvnNu zqp2uUeJMl6h/GFfty/CLp2WPw== X-Google-Smtp-Source: AGHT+IFnDBljg1qdRWJ1vg6w1v/K2QMbcocaqB1sTTdcbBfsJx37oqwxmTaj3RmyvXHm2M4a86VXcw== X-Received: by 2002:ac2:554b:0:b0:50b:f09b:e5a6 with SMTP id l11-20020ac2554b000000b0050bf09be5a6mr4073265lfk.112.1702554408129; Thu, 14 Dec 2023 03:46:48 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:47 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 18/21] net: ravb: Return cached statistics if the interface is down Date: Thu, 14 Dec 2023 13:45:57 +0200 Message-Id: <20231214114600.2451162-19-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Return the cached statistics in case the interface is down. There should be no drawback to this, as most of the statistics are updated on the data path and if runtime PM is enabled and the interface is down, the registers that are explicitly read on ravb_get_stats() are zero anyway on most of the IP variants. The commit prepares the code for the addition of runtime PM support. Suggested-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index a2a64c22ec41..1995cf7ff084 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2110,6 +2110,9 @@ static struct net_device_stats *ravb_get_stats(struct= net_device *ndev) const struct ravb_hw_info *info =3D priv->info; struct net_device_stats *nstats, *stats0, *stats1; =20 + if (!netif_running(ndev)) + return &ndev->stats; + nstats =3D &ndev->stats; stats0 =3D &priv->stats[RAVB_BE]; =20 --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91A96C4332F for ; Thu, 14 Dec 2023 11:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444310AbjLNLsA (ORCPT ); Thu, 14 Dec 2023 06:48:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572882AbjLNLrS (ORCPT ); Thu, 14 Dec 2023 06:47:18 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B481702 for ; Thu, 14 Dec 2023 03:46:51 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a22ed5f0440so390724566b.1 for ; Thu, 14 Dec 2023 03:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554410; x=1703159210; 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=14qVcRtLUoxmGTGt0RCexgzno6C/e+ZUicAuIzWdGM8=; b=Y+m+p6IKW7np4yvKR3QIsaIFRHZ7BtcGXWxM4p8gan3plrP0UJWam9zMILEllQkOzp 9nZN8tWs/6VP5hNn3BckBwe7B/eqIQCO7fPH1Oi+aUwC+3Z5UpDue3sPEIHUIi4UfXIw opqQIr70z9f/1eoxLlCdkFD6MeuIcs01NdJ02GBfLxJVFCIa4TEQhspGGBKjZS6oQWA5 M6JYjyYoaPDkaubYLYJa22KQLuhKyqaFSabc7V0+ow5EIAOgEe/tmqj3cObCJPrbHmJc u5sf/tc9qqJS8vmUDg0InKcv4zyuaHnqYfJVCYlkQ5nd/cYang+ex3iHP6Igy2DlGDBn vMhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554410; x=1703159210; 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=14qVcRtLUoxmGTGt0RCexgzno6C/e+ZUicAuIzWdGM8=; b=bjSURP9Go5u/8fBPQorB+aLol9zYKaWITFKnS0Fz4IGQTUl8ajy8g9Jkiob8EokUQM 9MR9WUph2aCodL80si76ZrfRn4Dz10qO0vUnrbd2vIgbMkt3/1mYHCCXTD9KQUvuSRrT j/MBkxyA5ZgYsBuD7iuV4/Aa/jPipj6BepZOs4hiUD97On+be8niNGOoRLR4PyCr9kn9 CJoQ/qxlvZ0hraBk1YDvqE+x6W0iQrRijnxIP/2J6dND6B1GwJ0Ot/BM4F21NRcabhc/ h3s/MW6AWT+AFT7JaG8d10hpxM/tanbon9HkmFSFcQCsILVnVBk2Kao1JKmoR1fcy0qn 7ZIQ== X-Gm-Message-State: AOJu0Yw8eT1em801hvnoZgbgVpi2EqqCLnU2YN2F3d54p5IRDsoG3TrF bpCEN0VqD55P8U+LDBXH83YGDA== X-Google-Smtp-Source: AGHT+IHmclDok0JjLUg0rjrhrqia2ROzMPs6mwFhPJ8AeOdZc7oPAsNAsr5T6UPZrffIVAhz+HTrRA== X-Received: by 2002:a17:907:7d8b:b0:9e3:f24d:5496 with SMTP id oz11-20020a1709077d8b00b009e3f24d5496mr3578988ejc.28.1702554410066; Thu, 14 Dec 2023 03:46:50 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:49 -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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 19/21] net: ravb: Do not set promiscuous mode if the interface is down Date: Thu, 14 Dec 2023 13:45:58 +0200 Message-Id: <20231214114600.2451162-20-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Do not allow setting promiscuous mode if the interface is down. In case runtime PM is enabled, and while interface is down, the IP will be in reset mode (as for some platforms disabling/enabling the clocks will switch the IP to standby mode which will lead to losing registers' content). Commit prepares for the addition of runtime PM. Signed-off-by: Claudiu Beznea --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 1995cf7ff084..633346b6cd7c 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2164,6 +2164,9 @@ static void ravb_set_rx_mode(struct net_device *ndev) struct ravb_private *priv =3D netdev_priv(ndev); unsigned long flags; =20 + if (!netif_running(ndev)) + return; + spin_lock_irqsave(&priv->lock, flags); ravb_modify(ndev, ECMR, ECMR_PRM, ndev->flags & IFF_PROMISC ? ECMR_PRM : 0); --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D92F9C4332F for ; Thu, 14 Dec 2023 11:48:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444158AbjLNLsE (ORCPT ); Thu, 14 Dec 2023 06:48:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444262AbjLNLr3 (ORCPT ); Thu, 14 Dec 2023 06:47:29 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC771A8 for ; Thu, 14 Dec 2023 03:46:53 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5522ba3f94aso1861525a12.1 for ; Thu, 14 Dec 2023 03:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554411; x=1703159211; 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=f+ln7zR2keR4FaUbDItY5t4KbD1y5Hd3PKZ17DhMaKY=; b=TiaSZnUy1f20q3/f8xwGn1Qi6rnKrt86Ce8V9TTsaair15PPKDs6lkQpr+olTCGR+v LQ+MB5h0jQDfLtv7Ozkf3qASdTWyPguufcwZfMZNPjFJzSzLcvfjQvWCh+IWshEAO5PV pVLzxW2OZptgu37/ErZGC6PC6brc4P4htq9akCN6V+ll3ITOBFjjySfGsBXGQdfZKr30 hUEsAuZsPts/0Wg9GwpxaybMBosf2UC54nHa7mBNL7DwpuG4OPsMJU0HoqC8hGCFbiCl ldhk/XGBoBM46ucMMFznXSnU1wgBRyTceDSfpFzV3U0dZ4D/dBuHTabXyshUVElZd5j3 YzMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554411; x=1703159211; 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=f+ln7zR2keR4FaUbDItY5t4KbD1y5Hd3PKZ17DhMaKY=; b=N884Q/lfZryoG9gznps5MMPLAcpAX3Jrghd7VaFSVGl4OocJWOpEi6cWlfLa1Wgp8L M/Xhw563biLVmoyCGrWkKS4Vay1Uz+6jlTMUE7s9sih8QYiYeCjZVti9oCH/gvSbrVp8 kk9FKkrL/wIx06+PS/RscKn3cbRimsFHD8et3tWtdC+HHyYC2sy+XyMSwpC/icbwUFBc IUawS/0R4MlO01cIk5JpG+Q3HvB8WTqR1TUmd+kK0I8C4PjbSZkT3pWylys1+3r1yj/G zmJFgtnWixHOL/IQ9XLGjqOskCop+Fo9eN18Zc8lzY470JDihkZSHgB6He5w/xXt5a5H kfcg== X-Gm-Message-State: AOJu0Yw20s6jF9Bpof3d6+7GCk6kc2vhSa82HAQd5OlCVSfpsAy3zKAp 1lZ813GXJU+CBRhTmIu9omJTQg== X-Google-Smtp-Source: AGHT+IFgOBx15mU54bAyPdEXoWDrhA2ZoQXpznNb85CQGcD0zg2tnQGKXuJ2ho/Ah2o3YaitijDfqA== X-Received: by 2002:a17:906:748d:b0:a23:ff8:8528 with SMTP id e13-20020a170906748d00b00a230ff88528mr133043ejl.13.1702554411577; Thu, 14 Dec 2023 03:46:51 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46:51 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 20/21] net: ravb: Do not apply RX CSUM settings to hardware if the interface is down Date: Thu, 14 Dec 2023 13:45:59 +0200 Message-Id: <20231214114600.2451162-21-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Do not apply the RX CSUM settings to hardware if the interface is down. In case runtime PM is enabled, and while the interface is down, the IP will be in reset mode (as for some platforms disabling/enabling the clocks will switch the IP to standby mode, which will lead to losing registers' content) and applying settings in reset mode is not an option. Instead, cache the RX CSUM settings and apply them in ravb_open(). Commit prepares for the addition of runtime PM. Signed-off-by: Claudiu Beznea --- Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 633346b6cd7c..9ff943dff522 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1868,6 +1868,15 @@ static int ravb_open(struct net_device *ndev) if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); =20 + /* Apply features that might have been changed while the interface + * was down. + */ + if (ndev->hw_features & NETIF_F_RXCSUM) { + u32 val =3D (ndev->features & NETIF_F_RXCSUM) ? ECMR_RCSC : 0; + + ravb_modify(ndev, ECMR, ECMR_RCSC, val); + } + /* PHY control start */ error =3D ravb_phy_start(ndev); if (error) @@ -2337,6 +2346,9 @@ static void ravb_set_rx_csum(struct net_device *ndev,= bool enable) struct ravb_private *priv =3D netdev_priv(ndev); unsigned long flags; =20 + if (!netif_running(ndev)) + return; + spin_lock_irqsave(&priv->lock, flags); =20 /* Disable TX and RX */ --=20 2.39.2 From nobody Sat Dec 27 22:54:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FC8AC4332F for ; Thu, 14 Dec 2023 11:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572897AbjLNLsH (ORCPT ); Thu, 14 Dec 2023 06:48:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444214AbjLNLrc (ORCPT ); Thu, 14 Dec 2023 06:47:32 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1EB51718 for ; Thu, 14 Dec 2023 03:46:54 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a1e35c2807fso1058967166b.3 for ; Thu, 14 Dec 2023 03:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1702554413; x=1703159213; 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=AHdjbrsgC9c7zj7iW7XF4dehsvpJIxxX32noXPZIWvM=; b=VH2cq5w1BQ0Zbv/cNEd4CUZaRS8dyZjc4zE+W1wM4RqrCRVoR5xKR4uoz7hWqSGsHA DbhoR7p5hQ4v/uDaj0XiLwEjCI+im9ODDaJ9CSsxSGirOfFQ0IAYjV3OL3ZY1Xjv+W9V oM3GbU3NOcLAWVjdwTVD0bcLROXGqW4Ke5UpA5y5vTzeJR6EHc/tZ/kLz5yPMtPA+gP8 xmpv68vR2iJzUeXGGwRKynq1mn12XMVc3AAV2jA2BomxyfhUwe0LvvQYK+Ex311ELynx mErJJPbFEnscJrKgnWeDBblsz8C0BxMsYZj+M0bB8BsT4G8swO/IuypMyKS6H4pgQlD+ DtvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702554413; x=1703159213; 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=AHdjbrsgC9c7zj7iW7XF4dehsvpJIxxX32noXPZIWvM=; b=m92vDiKgIVBSynMCmOO2u0FtmGkF86MYYeInKBJHBvk+yQ0MSjheZm60OQDWtD2ccI DnJYVo7ZXZiQ9tuti2Q3msJvM8FLzsw5Qsmaox7sT6AS4lRS12NWR8m69NmcRBAeKgq7 0Fp28vidB7go8sLi9q3mWIP0PvFj4voCnTA/O3xpFzs8odkARDbwekVe96QQWXUYqPg6 J85VFNGbjcsYHHuIRrZf1IpR9uOI1NixBaKAnY/vuCx5ULbNVNZsRVg0n50g7vu7Of1t uSeoeDmWV3P7UjvUCt7XcFdf/GzOHv2CPacDzl6fWUfyMNzbDoEROVEeb4SuUa98PQQL hH6g== X-Gm-Message-State: AOJu0Yxcnov3hXFR3AgmRHNi8zFZ4dyHgaBWKjEebV+ydRofh9i/CTD8 OM7Aug6yeulWT45sT6fiObbgPg== X-Google-Smtp-Source: AGHT+IFrFS+Z+MB4DKzhISgHNRoGJDDklWTn4/FS7HR5/yJpAYoiauOPD4XcVQ8K730XQ5ToztxooQ== X-Received: by 2002:a17:906:284:b0:a19:940f:b9d3 with SMTP id 4-20020a170906028400b00a19940fb9d3mr4327540ejf.25.1702554413073; Thu, 14 Dec 2023 03:46:53 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.103]) by smtp.gmail.com with ESMTPSA id ll9-20020a170907190900b00a1da2f7c1d8sm9240877ejc.77.2023.12.14.03.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:46: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, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH net-next v2 21/21] net: ravb: Add runtime PM support Date: Thu, 14 Dec 2023 13:46:00 +0200 Message-Id: <20231214114600.2451162-22-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> References: <20231214114600.2451162-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Add runtime PM support for the ravb driver. As the driver is used by different IP variants, with different behaviors, to be able to have the runtime PM support available for all devices, the preparatory commits moved all the resources parsing and allocations in the driver's probe function and kept the settings for ravb_open(). This is due to the fact that on some IP variants-platforms tuples disabling/enabling the clocks will switch the IP to the reset operation mode where registers' content is lost and reconfiguration needs to be done. For this the rabv_open() function enables the clocks, switches the IP to configuration mode, applies all the registers settings and switches the IP to the operational mode. At the end of ravb_open() IP is ready to send/receive data. In ravb_close() necessary reverts are done (compared with ravb_open()), the IP is switched to reset mode and clocks are disabled. The ethtool APIs or IOCTLs that might execute while the interface is down are either cached (and applied in ravb_open()) or rejected (as at that time the IP is in reset mode). Keeping the IP in the reset mode also increases the power saved (according to the hardware manual). Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v2: - keep RPM support for all platforms drivers/net/ethernet/renesas/ravb_main.c | 47 ++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 9ff943dff522..0733b63ff910 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1839,16 +1839,21 @@ 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 device *dev =3D &priv->pdev->dev; int error; =20 napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); =20 + error =3D pm_runtime_resume_and_get(dev); + if (error < 0) + goto out_napi_off; + /* Set AVB config mode */ error =3D ravb_set_config_mode(ndev); if (error) - goto out_napi_off; + goto out_rpm_put; =20 ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); @@ -1894,6 +1899,9 @@ static int ravb_open(struct net_device *ndev) ravb_stop_dma(ndev); out_set_reset: ravb_set_reset_mode(ndev); +out_rpm_put: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2189,6 +2197,7 @@ static int ravb_close(struct net_device *ndev) struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; struct ravb_tstamp_skb *ts_skb, *ts_skb2; + struct device *dev =3D &priv->pdev->dev; =20 netif_tx_stop_all_queues(ndev); =20 @@ -2237,6 +2246,9 @@ static int ravb_close(struct net_device *ndev) /* Set reset mode. */ ravb_set_reset_mode(ndev); =20 + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; } =20 @@ -2808,6 +2820,8 @@ static int ravb_probe(struct platform_device *pdev) clk_prepare(priv->refclk); =20 platform_set_drvdata(pdev, ndev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 100); + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); error =3D pm_runtime_resume_and_get(&pdev->dev); if (error < 0) @@ -2916,6 +2930,9 @@ static int ravb_probe(struct platform_device *pdev) netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); =20 + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + return 0; =20 out_netdev_unregister: @@ -2934,6 +2951,7 @@ static int ravb_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); out_rpm_disable: pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); clk_unprepare(priv->refclk); out_reset_assert: reset_control_assert(rstc); @@ -2947,6 +2965,12 @@ static void ravb_remove(struct platform_device *pdev) struct net_device *ndev =3D platform_get_drvdata(pdev); struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; + struct device *dev =3D &priv->pdev->dev; + int error; + + error =3D pm_runtime_resume_and_get(dev); + if (error < 0) + return; =20 unregister_netdev(ndev); if (info->nc_queues) @@ -2958,8 +2982,9 @@ static void ravb_remove(struct platform_device *pdev) dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); =20 - pm_runtime_put_sync(&pdev->dev); + pm_runtime_put_sync_suspend(&pdev->dev); pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(dev); clk_unprepare(priv->refclk); reset_control_assert(priv->rstc); free_netdev(ndev); @@ -3041,6 +3066,10 @@ static int ravb_suspend(struct device *dev) if (ret) return ret; =20 + ret =3D pm_runtime_force_suspend(&priv->pdev->dev); + if (ret) + return ret; + reset_assert: return reset_control_assert(priv->rstc); } @@ -3063,16 +3092,28 @@ static int ravb_resume(struct device *dev) ret =3D ravb_wol_restore(ndev); if (ret) return ret; + } else { + ret =3D pm_runtime_force_resume(dev); + if (ret) + return ret; } =20 /* Reopening the interface will restore the device to the working state. = */ ret =3D ravb_open(ndev); if (ret < 0) - return ret; + goto out_rpm_put; =20 ravb_set_rx_mode(ndev); netif_device_attach(ndev); =20 + return 0; + +out_rpm_put: + if (!priv->wol_enabled) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } + return ret; } =20 --=20 2.39.2