linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2)
@ 2024-02-09 17:04 Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq Claudiu
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Claudiu @ 2024-02-09 17:04 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Hi,

Series adds runtime PM support for the ravb driver. This is a continuation
of [1].

There are 4 more preparation patches (patches 1-4) and patch 5
adds runtime PM support.

Patches in this series were part of [2].

Change in v2:
- address review comments
- in patch 4/5 take into account the latest changes introduced
  in ravb_set_features_gbeth()

Changes since [2]:
- patch 1/5 is new
- use pm_runtime_get_noresume() and pm_runtime_active() in patches
  3/5, 4/5
- fixed higlighted typos in patch 4/5

[1] https://lore.kernel.org/all/20240202084136.3426492-1-claudiu.beznea.uj@bp.renesas.com/
[2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/

Claudiu Beznea (5):
  net: ravb: Get rid of the temporary variable irq
  net: ravb: Keep the reverse order of operations in ravb_close()
  net: ravb: Return cached statistics if the interface is down
  net: ravb: Do not apply RX checksum settings to hardware if the
    interface is down
  net: ravb: Add runtime PM support

 drivers/net/ethernet/renesas/ravb_main.c | 131 ++++++++++++++++++-----
 1 file changed, 105 insertions(+), 26 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq
  2024-02-09 17:04 [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2) Claudiu
@ 2024-02-09 17:04 ` Claudiu
  2024-02-09 20:04   ` Sergey Shtylyov
  2024-02-09 17:04 ` [PATCH net-next v2 2/5] net: ravb: Keep the reverse order of operations in ravb_close() Claudiu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Claudiu @ 2024-02-09 17:04 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

The 4th argument of ravb_setup_irq() is used to save the IRQ number that
will be further used by the driver code. Not all ravb_setup_irqs() calls
need to save the IRQ number. The previous code used to pass a dummy
variable as the 4th argument in case the IRQ is not needed for further
usage. That is not necessary as the code from ravb_setup_irq() can detect
by itself if the IRQ needs to be saved. Thus, get rid of the code that is
not needed.

Reported-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v2:
- use a temporary variable in ravb_setup_irq()

Changes since [2]:
- this patch in new

[2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/

 drivers/net/ethernet/renesas/ravb_main.c | 29 +++++++++++++-----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index f9a1e9038dbf..a1bf54de0e4c 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2747,24 +2747,27 @@ static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name,
 	struct device *dev = &pdev->dev;
 	const char *dev_name;
 	unsigned long flags;
-	int error;
+	int error, irq_num;
 
 	if (irq_name) {
 		dev_name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch);
 		if (!dev_name)
 			return -ENOMEM;
 
-		*irq = platform_get_irq_byname(pdev, irq_name);
+		irq_num = platform_get_irq_byname(pdev, irq_name);
 		flags = 0;
 	} else {
 		dev_name = ndev->name;
-		*irq = platform_get_irq(pdev, 0);
+		irq_num = platform_get_irq(pdev, 0);
 		flags = IRQF_SHARED;
 	}
-	if (*irq < 0)
-		return *irq;
+	if (irq_num < 0)
+		return irq_num;
+
+	if (irq)
+		*irq = irq_num;
 
-	error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev);
+	error = devm_request_irq(dev, irq_num, handler, flags, dev_name, ndev);
 	if (error)
 		netdev_err(ndev, "cannot request IRQ %s\n", dev_name);
 
@@ -2776,7 +2779,7 @@ static int ravb_setup_irqs(struct ravb_private *priv)
 	const struct ravb_hw_info *info = priv->info;
 	struct net_device *ndev = priv->ndev;
 	const char *irq_name, *emac_irq_name;
-	int error, irq;
+	int error;
 
 	if (!info->multi_irqs)
 		return ravb_setup_irq(priv, NULL, NULL, &ndev->irq, ravb_interrupt);
@@ -2799,28 +2802,28 @@ static int ravb_setup_irqs(struct ravb_private *priv)
 		return error;
 
 	if (info->err_mgmt_irqs) {
-		error = ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interrupt);
+		error = ravb_setup_irq(priv, "err_a", "err_a", NULL, ravb_multi_interrupt);
 		if (error)
 			return error;
 
-		error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_interrupt);
+		error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", NULL, ravb_multi_interrupt);
 		if (error)
 			return error;
 	}
 
-	error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrupt);
+	error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", NULL, ravb_be_interrupt);
 	if (error)
 		return error;
 
-	error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrupt);
+	error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", NULL, ravb_nc_interrupt);
 	if (error)
 		return error;
 
-	error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interrupt);
+	error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", NULL, ravb_be_interrupt);
 	if (error)
 		return error;
 
-	return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt);
+	return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", NULL, ravb_nc_interrupt);
 }
 
 static int ravb_probe(struct platform_device *pdev)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 2/5] net: ravb: Keep the reverse order of operations in ravb_close()
  2024-02-09 17:04 [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2) Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq Claudiu
@ 2024-02-09 17:04 ` Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 3/5] net: ravb: Return cached statistics if the interface is down Claudiu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Claudiu @ 2024-02-09 17:04 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Keep the reverse order of operations in ravb_close() when compared with
ravb_open(). This is the recommended configuration sequence.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---

Changes in v2:
- none

Changes since [2]:
- none

Changes in v3 of [2]:
- fixed typos in patch description
- collected tags

Changes in v2 of [2]:
- none; this patch is new

[2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/

 drivers/net/ethernet/renesas/ravb_main.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index a1bf54de0e4c..c81cbd81826e 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2321,6 +2321,14 @@ static int ravb_close(struct net_device *ndev)
 	ravb_write(ndev, 0, RIC2);
 	ravb_write(ndev, 0, TIC);
 
+	/* PHY disconnect */
+	if (ndev->phydev) {
+		phy_stop(ndev->phydev);
+		phy_disconnect(ndev->phydev);
+		if (of_phy_is_fixed_link(np))
+			of_phy_deregister_fixed_link(np);
+	}
+
 	/* Stop PTP Clock driver */
 	if (info->gptp || info->ccc_gac)
 		ravb_ptp_stop(ndev);
@@ -2339,14 +2347,6 @@ static int ravb_close(struct net_device *ndev)
 		}
 	}
 
-	/* PHY disconnect */
-	if (ndev->phydev) {
-		phy_stop(ndev->phydev);
-		phy_disconnect(ndev->phydev);
-		if (of_phy_is_fixed_link(np))
-			of_phy_deregister_fixed_link(np);
-	}
-
 	cancel_work_sync(&priv->work);
 
 	if (info->nc_queues)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 3/5] net: ravb: Return cached statistics if the interface is down
  2024-02-09 17:04 [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2) Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 2/5] net: ravb: Keep the reverse order of operations in ravb_close() Claudiu
@ 2024-02-09 17:04 ` Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware " Claudiu
  2024-02-09 17:04 ` [PATCH net-next v2 5/5] net: ravb: Add runtime PM support Claudiu
  4 siblings, 0 replies; 15+ messages in thread
From: Claudiu @ 2024-02-09 17:04 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Return the cached statistics in case the interface is down. There should be
no drawback to this, as cached statistics are updated in ravb_close().

In order to avoid accessing the IP registers while the IP is runtime
suspended pm_runtime_active() check was introduced. The device runtime
PM usage counter has been incremented to avoid disabling the device clocks
while the check is in progress (if any).

The commit prepares the code for the addition of runtime PM support.

Suggested-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---

Changes in v2:
- collected tag

Changes since [2]:
- use pm_runtime_get_noresume() and pm_runtime_active()

Changes in v3 of [2]:
- this was patch 18/21 in v2
- use ndev->flags & IFF_UP instead of netif_running checks

Changes in v2 of [2]:
- none; this patch is new

[2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/

 drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index c81cbd81826e..7a7f743a1fef 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2248,8 +2248,15 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
 	struct net_device_stats *nstats, *stats0, *stats1;
+	struct device *dev = &priv->pdev->dev;
 
 	nstats = &ndev->stats;
+
+	pm_runtime_get_noresume(dev);
+
+	if (!pm_runtime_active(dev))
+		goto out_rpm_put;
+
 	stats0 = &priv->stats[RAVB_BE];
 
 	if (info->tx_counters) {
@@ -2291,6 +2298,8 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
 		nstats->rx_over_errors += stats1->rx_over_errors;
 	}
 
+out_rpm_put:
+	pm_runtime_put_noidle(dev);
 	return nstats;
 }
 
@@ -2358,6 +2367,9 @@ static int ravb_close(struct net_device *ndev)
 	if (info->nc_queues)
 		ravb_ring_free(ndev, RAVB_NC);
 
+	/* Update statistics. */
+	ravb_get_stats(ndev);
+
 	/* Set reset mode. */
 	return ravb_set_opmode(ndev, CCC_OPC_RESET);
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down
  2024-02-09 17:04 [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2) Claudiu
                   ` (2 preceding siblings ...)
  2024-02-09 17:04 ` [PATCH net-next v2 3/5] net: ravb: Return cached statistics if the interface is down Claudiu
@ 2024-02-09 17:04 ` Claudiu
  2024-02-09 17:11   ` Biju Das
  2024-02-09 20:27   ` Sergey Shtylyov
  2024-02-09 17:04 ` [PATCH net-next v2 5/5] net: ravb: Add runtime PM support Claudiu
  4 siblings, 2 replies; 15+ messages in thread
From: Claudiu @ 2024-02-09 17:04 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Do not apply the RX checksum settings to hardware if the interface is down.
In case runtime PM is enabled, and while the interface is down, the IP will
be in reset mode (as for some platforms disabling the clocks will switch
the IP to reset mode, which will lead to losing register contents) and
applying settings in reset mode is not an option. Instead, cache the RX
checksum settings and apply them in ravb_open() through ravb_emac_init().
This has been solved by introducing pm_runtime_active() check. The device
runtime PM usage counter has been incremented to avoid disabling the device
clocks while the check is in progress (if any).

Commit prepares for the addition of runtime PM.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v2:
- fixed typo in patch description
- adjusted ravb_set_features_gbeth(); didn't collect the Sergey's Rb
  tag due to this 

Changes since [2]:
- use pm_runtime_get_noresume() and pm_runtime_active() and updated the
  commit message to describe that
- fixed typos
- s/CSUM/checksum in patch title and description

Changes in v3 of [2]:
- this was patch 20/21 in v2
- fixed typos in patch description
- removed code from ravb_open()
- use ndev->flags & IFF_UP checks instead of netif_running()

Changes in v2 of [2]:
- none; this patch is new

[2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/

 drivers/net/ethernet/renesas/ravb_main.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 7a7f743a1fef..f4be08f0198d 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2478,8 +2478,14 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu)
 static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	struct device *dev = &priv->pdev->dev;
 	unsigned long flags;
 
+	pm_runtime_get_noresume(dev);
+
+	if (!pm_runtime_active(dev))
+		goto out_rpm_put;
+
 	spin_lock_irqsave(&priv->lock, flags);
 
 	/* Disable TX and RX */
@@ -2492,6 +2498,9 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 	ravb_rcv_snd_enable(ndev);
 
 	spin_unlock_irqrestore(&priv->lock, flags);
+
+out_rpm_put:
+	pm_runtime_put_noidle(dev);
 }
 
 static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg,
@@ -2515,10 +2524,16 @@ static int ravb_set_features_gbeth(struct net_device *ndev,
 {
 	netdev_features_t changed = ndev->features ^ features;
 	struct ravb_private *priv = netdev_priv(ndev);
+	struct device *dev = &priv->pdev->dev;
 	unsigned long flags;
 	int ret = 0;
 	u32 val;
 
+	pm_runtime_get_noresume(dev);
+
+	if (!pm_runtime_active(dev))
+		goto out_rpm_put;
+
 	spin_lock_irqsave(&priv->lock, flags);
 	if (changed & NETIF_F_RXCSUM) {
 		if (features & NETIF_F_RXCSUM)
@@ -2542,9 +2557,12 @@ static int ravb_set_features_gbeth(struct net_device *ndev,
 			goto done;
 	}
 
-	ndev->features = features;
 done:
 	spin_unlock_irqrestore(&priv->lock, flags);
+out_rpm_put:
+	pm_runtime_put_noidle(dev);
+	if (!ret)
+		ndev->features = features;
 
 	return ret;
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 5/5] net: ravb: Add runtime PM support
  2024-02-09 17:04 [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2) Claudiu
                   ` (3 preceding siblings ...)
  2024-02-09 17:04 ` [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware " Claudiu
@ 2024-02-09 17:04 ` Claudiu
  2024-02-09 21:00   ` Sergey Shtylyov
  4 siblings, 1 reply; 15+ messages in thread
From: Claudiu @ 2024-02-09 17:04 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, claudiu.beznea, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

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 <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---

Changes in v2:
- none

Changes since [2]:
- none
- didn't returned directly the ret code of pm_runtime_put_autosuspend()
  as, in theory, it might return 1 in case device is suspended through
  this calltrace:
  pm_runtime_put_autosuspend() ->
    __pm_runtime_suspend() ->
      rpm_suspend() ->
        rpm_check_suspend_allowed()

Changes in v3 of [2]:
- this was patch 21/21 in v2
- collected tags
- fixed typos in patch description

Changes in v2 of [2]:
- keep RPM support for all platforms

[2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/

 drivers/net/ethernet/renesas/ravb_main.c | 54 ++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index f4be08f0198d..5bbfdfeef8a9 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1939,16 +1939,21 @@ static int ravb_open(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
+	struct device *dev = &priv->pdev->dev;
 	int error;
 
 	napi_enable(&priv->napi[RAVB_BE]);
 	if (info->nc_queues)
 		napi_enable(&priv->napi[RAVB_NC]);
 
+	error = pm_runtime_resume_and_get(dev);
+	if (error < 0)
+		goto out_napi_off;
+
 	/* Set AVB config mode */
 	error = ravb_set_config_mode(ndev);
 	if (error)
-		goto out_napi_off;
+		goto out_rpm_put;
 
 	ravb_set_delay_mode(ndev);
 	ravb_write(ndev, priv->desc_bat_dma, DBAT);
@@ -1982,6 +1987,9 @@ static int ravb_open(struct net_device *ndev)
 	ravb_stop_dma(ndev);
 out_set_reset:
 	ravb_set_opmode(ndev, CCC_OPC_RESET);
+out_rpm_put:
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
 out_napi_off:
 	if (info->nc_queues)
 		napi_disable(&priv->napi[RAVB_NC]);
@@ -2322,6 +2330,8 @@ static int ravb_close(struct net_device *ndev)
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
 	struct ravb_tstamp_skb *ts_skb, *ts_skb2;
+	struct device *dev = &priv->pdev->dev;
+	int error;
 
 	netif_tx_stop_all_queues(ndev);
 
@@ -2371,7 +2381,14 @@ static int ravb_close(struct net_device *ndev)
 	ravb_get_stats(ndev);
 
 	/* Set reset mode. */
-	return ravb_set_opmode(ndev, CCC_OPC_RESET);
+	error = ravb_set_opmode(ndev, CCC_OPC_RESET);
+	if (error)
+		return error;
+
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
+
+	return 0;
 }
 
 static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req)
@@ -2931,6 +2948,8 @@ static int ravb_probe(struct platform_device *pdev)
 	clk_prepare(priv->refclk);
 
 	platform_set_drvdata(pdev, ndev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 100);
+	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 	error = pm_runtime_resume_and_get(&pdev->dev);
 	if (error < 0)
@@ -3036,6 +3055,9 @@ static int ravb_probe(struct platform_device *pdev)
 	netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n",
 		    (u32)ndev->base_addr, ndev->dev_addr, ndev->irq);
 
+	pm_runtime_mark_last_busy(&pdev->dev);
+	pm_runtime_put_autosuspend(&pdev->dev);
+
 	return 0;
 
 out_napi_del:
@@ -3053,6 +3075,7 @@ static int ravb_probe(struct platform_device *pdev)
 	pm_runtime_put(&pdev->dev);
 out_rpm_disable:
 	pm_runtime_disable(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	clk_unprepare(priv->refclk);
 out_reset_assert:
 	reset_control_assert(rstc);
@@ -3066,6 +3089,12 @@ static void ravb_remove(struct platform_device *pdev)
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
+	struct device *dev = &priv->pdev->dev;
+	int error;
+
+	error = pm_runtime_resume_and_get(dev);
+	if (error < 0)
+		return;
 
 	unregister_netdev(ndev);
 	if (info->nc_queues)
@@ -3077,8 +3106,9 @@ static void ravb_remove(struct platform_device *pdev)
 	dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
 			  priv->desc_bat_dma);
 
-	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_put_sync_suspend(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(dev);
 	clk_unprepare(priv->refclk);
 	reset_control_assert(priv->rstc);
 	free_netdev(ndev);
@@ -3160,6 +3190,10 @@ static int ravb_suspend(struct device *dev)
 	if (ret)
 		return ret;
 
+	ret = pm_runtime_force_suspend(&priv->pdev->dev);
+	if (ret)
+		return ret;
+
 reset_assert:
 	return reset_control_assert(priv->rstc);
 }
@@ -3182,16 +3216,28 @@ static int ravb_resume(struct device *dev)
 		ret = ravb_wol_restore(ndev);
 		if (ret)
 			return ret;
+	} else {
+		ret = pm_runtime_force_resume(dev);
+		if (ret)
+			return ret;
 	}
 
 	/* Reopening the interface will restore the device to the working state. */
 	ret = ravb_open(ndev);
 	if (ret < 0)
-		return ret;
+		goto out_rpm_put;
 
 	ravb_set_rx_mode(ndev);
 	netif_device_attach(ndev);
 
+	return 0;
+
+out_rpm_put:
+	if (!priv->wol_enabled) {
+		pm_runtime_mark_last_busy(dev);
+		pm_runtime_put_autosuspend(dev);
+	}
+
 	return ret;
 }
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* RE: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down
  2024-02-09 17:04 ` [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware " Claudiu
@ 2024-02-09 17:11   ` Biju Das
  2024-02-09 20:27   ` Sergey Shtylyov
  1 sibling, 0 replies; 15+ messages in thread
From: Biju Das @ 2024-02-09 17:11 UTC (permalink / raw)
  To: Claudiu.Beznea, s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu.Beznea, Claudiu Beznea

Hi Claudiu Beznea,

> -----Original Message-----
> From: Claudiu <claudiu.beznea@tuxon.dev>
> Sent: Friday, February 9, 2024 5:05 PM
> Subject: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum
> settings to hardware if the interface is down
> 
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Do not apply the RX checksum settings to hardware if the interface is
> down.
> In case runtime PM is enabled, and while the interface is down, the IP
> will be in reset mode (as for some platforms disabling the clocks will
> switch the IP to reset mode, which will lead to losing register contents)
> and applying settings in reset mode is not an option. Instead, cache the
> RX checksum settings and apply them in ravb_open() through
> ravb_emac_init().
> This has been solved by introducing pm_runtime_active() check. The device
> runtime PM usage counter has been incremented to avoid disabling the
> device clocks while the check is in progress (if any).
> 
> Commit prepares for the addition of runtime PM.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
> 
> Changes in v2:
> - fixed typo in patch description
> - adjusted ravb_set_features_gbeth(); didn't collect the Sergey's Rb
>   tag due to this
> 
> Changes since [2]:
> - use pm_runtime_get_noresume() and pm_runtime_active() and updated the
>   commit message to describe that
> - fixed typos
> - s/CSUM/checksum in patch title and description
> 
> Changes in v3 of [2]:
> - this was patch 20/21 in v2
> - fixed typos in patch description
> - removed code from ravb_open()
> - use ndev->flags & IFF_UP checks instead of netif_running()
> 
> Changes in v2 of [2]:
> - none; this patch is new
> 
> [2]
> 
>  drivers/net/ethernet/renesas/ravb_main.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> b/drivers/net/ethernet/renesas/ravb_main.c
> index 7a7f743a1fef..f4be08f0198d 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2478,8 +2478,14 @@ static int ravb_change_mtu(struct net_device *ndev,
> int new_mtu)  static void ravb_set_rx_csum(struct net_device *ndev, bool
> enable)  {
>  	struct ravb_private *priv = netdev_priv(ndev);
> +	struct device *dev = &priv->pdev->dev;
>  	unsigned long flags;
> 
> +	pm_runtime_get_noresume(dev);
> +
> +	if (!pm_runtime_active(dev))
> +		goto out_rpm_put;


Thanks for the patch,

Why can't this be handled in ravb_set_features() to avoid code
duplication??

Cheers,
Biju

> +
>  	spin_lock_irqsave(&priv->lock, flags);
> 
>  	/* Disable TX and RX */
> @@ -2492,6 +2498,9 @@ static void ravb_set_rx_csum(struct net_device
> *ndev, bool enable)
>  	ravb_rcv_snd_enable(ndev);
> 
>  	spin_unlock_irqrestore(&priv->lock, flags);
> +
> +out_rpm_put:
> +	pm_runtime_put_noidle(dev);
>  }
> 
>  static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum
> ravb_reg reg, @@ -2515,10 +2524,16 @@ static int
> ravb_set_features_gbeth(struct net_device *ndev,  {
>  	netdev_features_t changed = ndev->features ^ features;
>  	struct ravb_private *priv = netdev_priv(ndev);
> +	struct device *dev = &priv->pdev->dev;
>  	unsigned long flags;
>  	int ret = 0;
>  	u32 val;
> 
> +	pm_runtime_get_noresume(dev);
> +
> +	if (!pm_runtime_active(dev))
> +		goto out_rpm_put;
> +
>  	spin_lock_irqsave(&priv->lock, flags);
>  	if (changed & NETIF_F_RXCSUM) {
>  		if (features & NETIF_F_RXCSUM)
> @@ -2542,9 +2557,12 @@ static int ravb_set_features_gbeth(struct
> net_device *ndev,
>  			goto done;
>  	}
> 
> -	ndev->features = features;
>  done:
>  	spin_unlock_irqrestore(&priv->lock, flags);
> +out_rpm_put:
> +	pm_runtime_put_noidle(dev);
> +	if (!ret)
> +		ndev->features = features;
> 
>  	return ret;
>  }
> --
> 2.39.2
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq
  2024-02-09 17:04 ` [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq Claudiu
@ 2024-02-09 20:04   ` Sergey Shtylyov
  0 siblings, 0 replies; 15+ messages in thread
From: Sergey Shtylyov @ 2024-02-09 20:04 UTC (permalink / raw)
  To: Claudiu, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea

On 2/9/24 8:04 PM, Claudiu wrote:

> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> The 4th argument of ravb_setup_irq() is used to save the IRQ number that
> will be further used by the driver code. Not all ravb_setup_irqs() calls
> need to save the IRQ number. The previous code used to pass a dummy
> variable as the 4th argument in case the IRQ is not needed for further
> usage. That is not necessary as the code from ravb_setup_irq() can detect
> by itself if the IRQ needs to be saved. Thus, get rid of the code that is
> not needed.
> 
> Reported-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down
  2024-02-09 17:04 ` [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware " Claudiu
  2024-02-09 17:11   ` Biju Das
@ 2024-02-09 20:27   ` Sergey Shtylyov
  2024-02-09 20:41     ` Biju Das
  1 sibling, 1 reply; 15+ messages in thread
From: Sergey Shtylyov @ 2024-02-09 20:27 UTC (permalink / raw)
  To: Claudiu, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea

On 2/9/24 8:04 PM, Claudiu wrote:

> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Do not apply the RX checksum settings to hardware if the interface is down.
> In case runtime PM is enabled, and while the interface is down, the IP will
> be in reset mode (as for some platforms disabling the clocks will switch
> the IP to reset mode, which will lead to losing register contents) and
> applying settings in reset mode is not an option. Instead, cache the RX
> checksum settings and apply them in ravb_open() through ravb_emac_init().
> This has been solved by introducing pm_runtime_active() check. The device
> runtime PM usage counter has been incremented to avoid disabling the device
> clocks while the check is in progress (if any).
> 
> Commit prepares for the addition of runtime PM.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down
  2024-02-09 20:27   ` Sergey Shtylyov
@ 2024-02-09 20:41     ` Biju Das
  2024-02-10 20:37       ` Sergey Shtylyov
  0 siblings, 1 reply; 15+ messages in thread
From: Biju Das @ 2024-02-09 20:41 UTC (permalink / raw)
  To: Sergey Shtylyov, Claudiu.Beznea, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea

Hi Sergey,

> -----Original Message-----
> From: Sergey Shtylyov <s.shtylyov@omp.ru>
> Sent: Friday, February 9, 2024 8:27 PM
> Subject: Re: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum
> settings to hardware if the interface is down
> 
> On 2/9/24 8:04 PM, Claudiu wrote:
> 
> > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> >
> > Do not apply the RX checksum settings to hardware if the interface is
> down.
> > In case runtime PM is enabled, and while the interface is down, the IP
> > will be in reset mode (as for some platforms disabling the clocks will
> > switch the IP to reset mode, which will lead to losing register
> > contents) and applying settings in reset mode is not an option.
> > Instead, cache the RX checksum settings and apply them in ravb_open()
> through ravb_emac_init().
> > This has been solved by introducing pm_runtime_active() check. The
> > device runtime PM usage counter has been incremented to avoid
> > disabling the device clocks while the check is in progress (if any).
> >
> > Commit prepares for the addition of runtime PM.
> >
> > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

This will do the same job, without code duplication right?

static int ravb_set_features(struct net_device *ndev,
			     netdev_features_t features)
{
	struct ravb_private *priv = netdev_priv(ndev);
	struct device *dev = &priv->pdev->dev;
	const struct ravb_hw_info *info = priv->info;

	pm_runtime_get_noresume(dev);
	if (!pm_runtime_active(dev)) {
		pm_runtime_put_noidle(dev);
		ndev->features = features;
		return 0;
	}
		
	return info->set_feature(ndev, features);
}

Cheers,
Biju

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 5/5] net: ravb: Add runtime PM support
  2024-02-09 17:04 ` [PATCH net-next v2 5/5] net: ravb: Add runtime PM support Claudiu
@ 2024-02-09 21:00   ` Sergey Shtylyov
  2024-02-12  7:56     ` claudiu beznea
  0 siblings, 1 reply; 15+ messages in thread
From: Sergey Shtylyov @ 2024-02-09 21:00 UTC (permalink / raw)
  To: Claudiu, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea

On 2/9/24 8:04 PM, Claudiu wrote:

> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> 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

   This pesky "registers' content" somehow evaded me -- should be "register
contents" as well...

> 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 <claudiu.beznea.uj@bp.renesas.com>
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
[...]

> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index f4be08f0198d..5bbfdfeef8a9 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -1939,16 +1939,21 @@ static int ravb_open(struct net_device *ndev)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
>  	const struct ravb_hw_info *info = priv->info;
> +	struct device *dev = &priv->pdev->dev;
>  	int error;
>  
>  	napi_enable(&priv->napi[RAVB_BE]);
>  	if (info->nc_queues)
>  		napi_enable(&priv->napi[RAVB_NC]);
>  
> +	error = pm_runtime_resume_and_get(dev);
> +	if (error < 0)
> +		goto out_napi_off;

   Well, s/error/ret/ -- it would fit better here...

[...]
> @@ -3066,6 +3089,12 @@ static void ravb_remove(struct platform_device *pdev)
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct ravb_private *priv = netdev_priv(ndev);
>  	const struct ravb_hw_info *info = priv->info;
> +	struct device *dev = &priv->pdev->dev;
> +	int error;
> +
> +	error = pm_runtime_resume_and_get(dev);
> +	if (error < 0)
> +		return;

   Again, s/erorr/ret/ in this case.

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down
  2024-02-09 20:41     ` Biju Das
@ 2024-02-10 20:37       ` Sergey Shtylyov
  0 siblings, 0 replies; 15+ messages in thread
From: Sergey Shtylyov @ 2024-02-10 20:37 UTC (permalink / raw)
  To: Biju Das, Claudiu.Beznea, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea

On 2/9/24 11:41 PM, Biju Das wrote:
[...]

>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>
>>> Do not apply the RX checksum settings to hardware if the interface is
>>> down.
>>> In case runtime PM is enabled, and while the interface is down, the IP
>>> will be in reset mode (as for some platforms disabling the clocks will
>>> switch the IP to reset mode, which will lead to losing register
>>> contents) and applying settings in reset mode is not an option.
>>> Instead, cache the RX checksum settings and apply them in ravb_open()
>>> through ravb_emac_init().
>>> This has been solved by introducing pm_runtime_active() check. The
>>> device runtime PM usage counter has been incremented to avoid
>>> disabling the device clocks while the check is in progress (if any).
>>>
>>> Commit prepares for the addition of runtime PM.
>>>
>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> This will do the same job, without code duplication right?
> 
> static int ravb_set_features(struct net_device *ndev,
> 			     netdev_features_t features)
> {
> 	struct ravb_private *priv = netdev_priv(ndev);
> 	struct device *dev = &priv->pdev->dev;
> 	const struct ravb_hw_info *info = priv->info;
> 
> 	pm_runtime_get_noresume(dev);
> 	if (!pm_runtime_active(dev)) {
> 		pm_runtime_put_noidle(dev);
> 		ndev->features = features;
> 		return 0;
> 	}
> 		
> 	return info->set_feature(ndev, features);

   We now leak the device reference by not calling pm_runtime_put_noidle()
after this statement...
   The approach seems sane though -- Claudiu, please consider following it.

[...]

> Cheers,
> Biju

MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 5/5] net: ravb: Add runtime PM support
  2024-02-09 21:00   ` Sergey Shtylyov
@ 2024-02-12  7:56     ` claudiu beznea
  2024-02-12 20:19       ` Sergey Shtylyov
  0 siblings, 1 reply; 15+ messages in thread
From: claudiu beznea @ 2024-02-12  7:56 UTC (permalink / raw)
  To: Sergey Shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea



On 09.02.2024 23:00, Sergey Shtylyov wrote:
> On 2/9/24 8:04 PM, Claudiu wrote:
> 
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> 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
> 
>    This pesky "registers' content" somehow evaded me -- should be "register
> contents" as well...
> 
>> 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 <claudiu.beznea.uj@bp.renesas.com>
>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> [...]
> 
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
>> index f4be08f0198d..5bbfdfeef8a9 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>> @@ -1939,16 +1939,21 @@ static int ravb_open(struct net_device *ndev)
>>  {
>>  	struct ravb_private *priv = netdev_priv(ndev);
>>  	const struct ravb_hw_info *info = priv->info;
>> +	struct device *dev = &priv->pdev->dev;
>>  	int error;
>>  
>>  	napi_enable(&priv->napi[RAVB_BE]);
>>  	if (info->nc_queues)
>>  		napi_enable(&priv->napi[RAVB_NC]);
>>  
>> +	error = pm_runtime_resume_and_get(dev);
>> +	if (error < 0)
>> +		goto out_napi_off;
> 
>    Well, s/error/ret/ -- it would fit better here...

Using error is the "trademark" of this driver, it is used all around the
driver. I haven't introduced it here, I don't like it. The variable error
in this particular function is here from the beginning of the driver.

So, I don't consider changing error to ret is the scope of this series.

> 
> [...]
>> @@ -3066,6 +3089,12 @@ static void ravb_remove(struct platform_device *pdev)
>>  	struct net_device *ndev = platform_get_drvdata(pdev);
>>  	struct ravb_private *priv = netdev_priv(ndev);
>>  	const struct ravb_hw_info *info = priv->info;
>> +	struct device *dev = &priv->pdev->dev;
>> +	int error;
>> +
>> +	error = pm_runtime_resume_and_get(dev);
>> +	if (error < 0)
>> +		return;
> 
>    Again, s/erorr/ret/ in this case.

error was used here to comply with the rest of the driver. So, if you still
want me to change it here and in ravb_remove() please confirm.

Thank you,
Claudiu Beznea

> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 5/5] net: ravb: Add runtime PM support
  2024-02-12  7:56     ` claudiu beznea
@ 2024-02-12 20:19       ` Sergey Shtylyov
  2024-02-13  6:59         ` claudiu beznea
  0 siblings, 1 reply; 15+ messages in thread
From: Sergey Shtylyov @ 2024-02-12 20:19 UTC (permalink / raw)
  To: claudiu beznea, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea

On 2/12/24 10:56 AM, claudiu beznea wrote:

[...]

>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>
>>> 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
>>
>>    This pesky "registers' content" somehow evaded me -- should be "register
>> contents" as well...
>>
>>> 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 <claudiu.beznea.uj@bp.renesas.com>
>>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>> [...]
>>
>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
>>> index f4be08f0198d..5bbfdfeef8a9 100644
>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>>> @@ -1939,16 +1939,21 @@ static int ravb_open(struct net_device *ndev)
>>>  {
>>>  	struct ravb_private *priv = netdev_priv(ndev);
>>>  	const struct ravb_hw_info *info = priv->info;
>>> +	struct device *dev = &priv->pdev->dev;
>>>  	int error;
>>>  
>>>  	napi_enable(&priv->napi[RAVB_BE]);
>>>  	if (info->nc_queues)
>>>  		napi_enable(&priv->napi[RAVB_NC]);
>>>  
>>> +	error = pm_runtime_resume_and_get(dev);
>>> +	if (error < 0)
>>> +		goto out_napi_off;
>>
>>    Well, s/error/ret/ -- it would fit better here...
> 
> Using error is the "trademark" of this driver, it is used all around the
> driver. I haven't introduced it here, I don't like it. The variable error

   Heh, because it's my usual style. Too bad you don't like it... :-)

> in this particular function is here from the beginning of the driver.

   I think it's well suited for the functions returning either 0 or a
(negative) error code. It's *if* (error < 0) that confuses me (as this
API can return positive numbers in case of success...

> So, I don't consider changing error to ret is the scope of this series.

   OK, you're probably right... are you going to respin the series because
of Biju's comments?

[...]
>>> @@ -3066,6 +3089,12 @@ static void ravb_remove(struct platform_device *pdev)
>>>  	struct net_device *ndev = platform_get_drvdata(pdev);
>>>  	struct ravb_private *priv = netdev_priv(ndev);
>>>  	const struct ravb_hw_info *info = priv->info;
>>> +	struct device *dev = &priv->pdev->dev;
>>> +	int error;
>>> +
>>> +	error = pm_runtime_resume_and_get(dev);
>>> +	if (error < 0)
>>> +		return;
>>
>>    Again, s/erorr/ret/ in this case.
> 
> error was used here to comply with the rest of the driver. So, if you still
> want me to change it here and in ravb_remove() please confirm.

   No, we are good enough without that; I'll consider doing a cleanup
when/if I have time. :-)

> Thank you,
> Claudiu Beznea

MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 5/5] net: ravb: Add runtime PM support
  2024-02-12 20:19       ` Sergey Shtylyov
@ 2024-02-13  6:59         ` claudiu beznea
  0 siblings, 0 replies; 15+ messages in thread
From: claudiu beznea @ 2024-02-13  6:59 UTC (permalink / raw)
  To: Sergey Shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, linux-kernel, Claudiu Beznea



On 12.02.2024 22:19, Sergey Shtylyov wrote:
> On 2/12/24 10:56 AM, claudiu beznea wrote:
> 
> [...]
> 
>>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>>
>>>> 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
>>>
>>>    This pesky "registers' content" somehow evaded me -- should be "register
>>> contents" as well...
>>>
>>>> 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 <claudiu.beznea.uj@bp.renesas.com>
>>>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>> [...]
>>>
>>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
>>>> index f4be08f0198d..5bbfdfeef8a9 100644
>>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>>>> @@ -1939,16 +1939,21 @@ static int ravb_open(struct net_device *ndev)
>>>>  {
>>>>  	struct ravb_private *priv = netdev_priv(ndev);
>>>>  	const struct ravb_hw_info *info = priv->info;
>>>> +	struct device *dev = &priv->pdev->dev;
>>>>  	int error;
>>>>  
>>>>  	napi_enable(&priv->napi[RAVB_BE]);
>>>>  	if (info->nc_queues)
>>>>  		napi_enable(&priv->napi[RAVB_NC]);
>>>>  
>>>> +	error = pm_runtime_resume_and_get(dev);
>>>> +	if (error < 0)
>>>> +		goto out_napi_off;
>>>
>>>    Well, s/error/ret/ -- it would fit better here...
>>
>> Using error is the "trademark" of this driver, it is used all around the
>> driver. I haven't introduced it here, I don't like it. The variable error
> 
>    Heh, because it's my usual style. Too bad you don't like it... :-)
> 
>> in this particular function is here from the beginning of the driver.
> 
>    I think it's well suited for the functions returning either 0 or a
> (negative) error code. It's *if* (error < 0) that confuses me (as this
> API can return positive numbers in case of success...
> 
>> So, I don't consider changing error to ret is the scope of this series.
> 
>    OK, you're probably right... are you going to respin the series because
> of Biju's comments?

Yes!

Thank you,
Claudiu Beznea

> 
> [...]
>>>> @@ -3066,6 +3089,12 @@ static void ravb_remove(struct platform_device *pdev)
>>>>  	struct net_device *ndev = platform_get_drvdata(pdev);
>>>>  	struct ravb_private *priv = netdev_priv(ndev);
>>>>  	const struct ravb_hw_info *info = priv->info;
>>>> +	struct device *dev = &priv->pdev->dev;
>>>> +	int error;
>>>> +
>>>> +	error = pm_runtime_resume_and_get(dev);
>>>> +	if (error < 0)
>>>> +		return;
>>>
>>>    Again, s/erorr/ret/ in this case.
>>
>> error was used here to comply with the rest of the driver. So, if you still
>> want me to change it here and in ravb_remove() please confirm.
> 
>    No, we are good enough without that; I'll consider doing a cleanup
> when/if I have time. :-)
> 
>> Thank you,
>> Claudiu Beznea
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-02-13  6:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-09 17:04 [PATCH net-next v2 0/5] net: ravb: Add runtime PM support (part 2) Claudiu
2024-02-09 17:04 ` [PATCH net-next v2 1/5] net: ravb: Get rid of the temporary variable irq Claudiu
2024-02-09 20:04   ` Sergey Shtylyov
2024-02-09 17:04 ` [PATCH net-next v2 2/5] net: ravb: Keep the reverse order of operations in ravb_close() Claudiu
2024-02-09 17:04 ` [PATCH net-next v2 3/5] net: ravb: Return cached statistics if the interface is down Claudiu
2024-02-09 17:04 ` [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware " Claudiu
2024-02-09 17:11   ` Biju Das
2024-02-09 20:27   ` Sergey Shtylyov
2024-02-09 20:41     ` Biju Das
2024-02-10 20:37       ` Sergey Shtylyov
2024-02-09 17:04 ` [PATCH net-next v2 5/5] net: ravb: Add runtime PM support Claudiu
2024-02-09 21:00   ` Sergey Shtylyov
2024-02-12  7:56     ` claudiu beznea
2024-02-12 20:19       ` Sergey Shtylyov
2024-02-13  6:59         ` claudiu beznea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).