netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Claudiu <claudiu.beznea@tuxon.dev>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<p.zabel@pengutronix.de>, <yoshihiro.shimoda.uh@renesas.com>,
	<geert+renesas@glider.be>, <wsa+renesas@sang-engineering.com>,
	<biju.das.jz@bp.renesas.com>,
	<prabhakar.mahadev-lad.rj@bp.renesas.com>,
	<sergei.shtylyov@cogentembedded.com>,
	<mitsuhiro.kimura.kc@renesas.com>, <masaru.nagai.vx@renesas.com>
Cc: <netdev@vger.kernel.org>, <linux-renesas-soc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH 13/13] net: ravb: Add runtime PM support
Date: Wed, 22 Nov 2023 19:25:48 +0300	[thread overview]
Message-ID: <04cb07fe-cccc-774a-f14d-763ce7ae7b07@omp.ru> (raw)
In-Reply-To: <20231120084606.4083194-14-claudiu.beznea.uj@bp.renesas.com>

On 11/20/23 11:46 AM, Claudiu wrote:

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

> RZ/G3S supports enabling/disabling clocks for its modules (including
> Ethernet module). For this commit adds runtime PM support which
> relies on PM domain to enable/disable Ethernet clocks.

   That's not exactly something new in RZ/G3S. The ravb driver has unconditional
RPM calls already in the probe() and remove() methods... And the sh_eth driver
has RPM support since 2009...

> At the end of probe ravb_pm_runtime_put() is called which will turn

   I'd suggest a shorter name, like ravb_rpm_put() but (looking at this function)
it doesn't seem hardly needed...

> off the Ethernet clocks (if no other request arrives at the driver).
> After that if the interface is brought up (though ravb_open()) then
> the clocks remain enabled until interface is brought down (operation
> done though ravb_close()).
> 
> If any request arrives to the driver while the interface is down the
> clocks are enabled to serve the request and then disabled.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb.h      |  1 +
>  drivers/net/ethernet/renesas/ravb_main.c | 99 ++++++++++++++++++++++--
>  2 files changed, 93 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
> index c2d8d890031f..50f358472aab 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> @@ -1044,6 +1044,7 @@ struct ravb_hw_info {
>  	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
>  	unsigned refclk_in_pd:1;	/* Reference clock is part of a power domain. */
> +	unsigned rpm:1;			/* Runtime PM available. */

   No, I don't think this flag makes any sense. We should support RPM
unconditionally...

[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index f4634ac0c972..d70ed7e5f7f6 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -145,12 +145,41 @@ static void ravb_read_mac_address(struct device_node *np,
[...]
> +static void ravb_pm_runtime_put(struct ravb_private *priv)
> +{
> +	const struct ravb_hw_info *info = priv->info;
> +	struct device *dev = &priv->pdev->dev;
> +
> +	if (!info->rpm)
> +		return;
> +
> +	pm_runtime_mark_last_busy(dev);

   Not very familiar with RPM... what's this for?

> +	pm_runtime_put_autosuspend(dev);

   Why not the usual pm_runtime_put()?

> +}
> +
>  static void ravb_mdio_ctrl(struct mdiobb_ctrl *ctrl, u32 mask, int set)
>  {
>  	struct ravb_private *priv = container_of(ctrl, struct ravb_private,
>  						 mdiobb);
> +	int ret;
> +
> +	ret = ravb_pm_runtime_get(priv);
> +	if (ret < 0)
> +		return;
>  
>  	ravb_modify(priv->ndev, PIR, mask, set ? mask : 0);
> +
> +	ravb_pm_runtime_put(priv);

   Hmm, does this even work? :-/ Do the MDIO bits retain the values while
the AVB core is not clocked or even powered down?
   Note that the sh_eth driver has RPM calls in the {read|write}_c{22?45}()
methods which do the full register read/write while the core is powere up
and clocked...

[...]
> @@ -2064,6 +2107,11 @@ 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;
> +	int ret;
> +
> +	ret = ravb_pm_runtime_get(priv);
> +	if (ret < 0)
> +		return NULL;

   Hm, sh_eth.c doesn't have any RPM calls in this method. Again, do
the hardware counters remain valid across powering the MAC core down?

[...]
> @@ -2115,11 +2165,18 @@ static void ravb_set_rx_mode(struct net_device *ndev)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
>  	unsigned long flags;
> +	int ret;
> +
> +	ret = ravb_pm_runtime_get(priv);
> +	if (ret < 0)
> +		return;

   Hm, sh_eth.c doesn't have any RPM calls in this method either.
Does changing the promiscous mode have sense for an offlined interface?

[...]
> @@ -2187,6 +2244,11 @@ static int ravb_close(struct net_device *ndev)
>  	if (info->nc_queues)
>  		ravb_ring_free(ndev, RAVB_NC);
>  
> +	/* Note that if RPM is enabled on plaforms with ccc_gac=1 this needs to be

   It's "platforms". :-)

> skipped and

   Overly long line?

> +	 * added to suspend function after PTP is stopped.

   I guess we'll have to do that because RPM is actually not RZ/G3
specific...

> +	 */
> +	ravb_pm_runtime_put(priv);
> +
>  	return 0;
>  }
>  
> @@ -2636,6 +2699,12 @@ static int ravb_probe(struct platform_device *pdev)
>  	if (error)
>  		return error;
>  
> +	info = of_device_get_match_data(&pdev->dev);
> +
> +	if (info->rpm) {
> +		pm_runtime_set_autosuspend_delay(&pdev->dev, 100);

   Why exactly 100 ms?

> +		pm_runtime_use_autosuspend(&pdev->dev);
> +	}

   Before calling pm_runtime_enable()?

>  	pm_runtime_enable(&pdev->dev);
[...]
> @@ -2880,6 +2950,8 @@ static int ravb_probe(struct platform_device *pdev)
>  	pm_runtime_put(&pdev->dev);
>  pm_runtime_disable:
>  	pm_runtime_disable(&pdev->dev);
> +	if (info->rpm)
> +		pm_runtime_dont_use_autosuspend(&pdev->dev);

   After calling pm_runtime_disable()?

[...]
> @@ -2908,6 +2985,8 @@ static void ravb_remove(struct platform_device *pdev)
>  			  priv->desc_bat_dma);
>  	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> +	if (info->rpm)
> +		pm_runtime_dont_use_autosuspend(&pdev->dev);

   After calling pm_runtime_disable()?

[...]

MBR, Sergey

  reply	other threads:[~2023-11-22 16:26 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  8:45 [PATCH 00/13] net: ravb: Add suspend to RAM and runtime PM support for RZ/G3S Claudiu
2023-11-20  8:45 ` [PATCH 01/13] net: ravb: Check return value of reset_control_deassert() Claudiu
2023-11-20 19:03   ` Sergey Shtylyov
2023-11-21  5:59     ` claudiu beznea
2023-11-24 19:04       ` Sergey Shtylyov
2023-11-20  8:45 ` [PATCH 02/13] net: ravb: Use pm_runtime_resume_and_get() Claudiu
2023-11-20 19:23   ` Sergey Shtylyov
2023-11-21  5:57     ` claudiu beznea
2023-11-24 19:02       ` Sergey Shtylyov
2023-11-20  8:45 ` [PATCH 03/13] net: ravb: Make write access to CXR35 first before accessing other EMAC registers Claudiu
2023-11-20 19:44   ` Sergey Shtylyov
2023-11-21  6:02     ` claudiu beznea
2023-11-23 19:30       ` Sergey Shtylyov
2023-11-20  8:45 ` [PATCH 04/13] net: ravb: Start TX queues after HW initialization succeeded Claudiu
2023-11-20 19:49   ` Sergey Shtylyov
2023-11-20  8:45 ` [PATCH 05/13] net: ravb: Stop DMA in case of failures on ravb_open() Claudiu
2023-11-20 20:01   ` Sergey Shtylyov
2023-11-20  8:45 ` [PATCH 06/13] net: ravb: Let IP specific receive function to interrogate descriptors Claudiu
2023-11-23 16:37   ` Sergey Shtylyov
2023-11-23 16:48     ` Biju Das
2023-11-23 16:54       ` Sergey Shtylyov
2023-11-23 17:02         ` Biju Das
2023-11-23 17:15     ` claudiu beznea
2023-11-24 17:27       ` Sergey Shtylyov
2023-11-20  8:46 ` [PATCH 07/13] net: ravb: Rely on PM domain to enable gptp_clk Claudiu
2023-11-22 16:59   ` Sergey Shtylyov
2023-11-20  8:46 ` [PATCH 08/13] net: ravb: Rely on PM domain to enable refclk Claudiu
2023-11-22 17:31   ` Sergey Shtylyov
2023-11-23  8:48   ` Geert Uytterhoeven
2023-11-23 17:10     ` claudiu beznea
2023-11-23 19:26       ` Sergey Shtylyov
2023-11-20  8:46 ` [PATCH 09/13] net: ravb: Make reset controller support mandatory Claudiu
2023-11-21 18:46   ` Sergey Shtylyov
2023-11-24  8:07   ` Geert Uytterhoeven
2023-11-20  8:46 ` [PATCH 10/13] net: ravb: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr() Claudiu
2023-11-21 20:29   ` Sergey Shtylyov
2023-12-06 11:36   ` Geert Uytterhoeven
2023-11-20  8:46 ` [PATCH 11/13] net: ravb: Use tabs instead of spaces Claudiu
2023-11-21 18:43   ` Sergey Shtylyov
2023-11-20  8:46 ` [PATCH 12/13] net: ravb: Assert/deassert reset on suspend/resume Claudiu
2023-11-21 19:13   ` Sergey Shtylyov
2023-11-22 16:41     ` Sergey Shtylyov
2023-11-20  8:46 ` [PATCH 13/13] net: ravb: Add runtime PM support Claudiu
2023-11-22 16:25   ` Sergey Shtylyov [this message]
2023-11-23 17:04     ` claudiu beznea
2023-11-23 19:19       ` Sergey Shtylyov
2023-11-24 18:03         ` claudiu beznea
2023-11-27 14:05           ` Geert Uytterhoeven
2023-11-27 14:46             ` claudiu beznea
2023-11-28  9:23               ` claudiu beznea
2023-11-27 19:01             ` Sergey Shtylyov
2023-11-30 17:35   ` Simon Horman
2023-11-20 20:48 ` [PATCH 00/13] net: ravb: Add suspend to RAM and runtime PM support for RZ/G3S Sergey Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04cb07fe-cccc-774a-f14d-763ce7ae7b07@omp.ru \
    --to=s.shtylyov@omp.ru \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=claudiu.beznea.uj@bp.renesas.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=masaru.nagai.vx@renesas.com \
    --cc=mitsuhiro.kimura.kc@renesas.com \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).