All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com,
	 kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	 linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH net-next] rswitch: Add PM ops
Date: Thu, 12 Oct 2023 14:35:06 +0200	[thread overview]
Message-ID: <CAMuHMdWAk9kJBGGq9K-RnC0HFZk1XbaosTBO2OW1kpYFPh1Mqg@mail.gmail.com> (raw)
In-Reply-To: <20231012121618.267315-1-yoshihiro.shimoda.uh@renesas.com>

Hi Shimoda-san,

On Thu, Oct 12, 2023 at 2:16 PM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> Add PM ops for Suspend to Idle. When the system suspended,
> the Ethernet Serdes's clock will be stopped. So, this driver needs
> to re-initialize the Ethernet Serdes by phy_init() in
> renesas_eth_sw_resume(). Otherwise, timeout happened in phy_power_on().
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Thanks for your patch!

> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -17,6 +17,7 @@
>  #include <linux/of_net.h>
>  #include <linux/phy/phy.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/rtnetlink.h>
>  #include <linux/slab.h>
> @@ -1315,6 +1316,7 @@ static int rswitch_phy_device_init(struct rswitch_device *rdev)
>         if (!phydev)
>                 goto out;
>         __set_bit(rdev->etha->phy_interface, phydev->host_interfaces);
> +       phydev->mac_managed_pm = true;
>
>         phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0,
>                                 rdev->etha->phy_interface);
> @@ -1991,11 +1993,52 @@ static void renesas_eth_sw_remove(struct platform_device *pdev)
>         platform_set_drvdata(pdev, NULL);
>  }
>
> +static int __maybe_unused renesas_eth_sw_suspend(struct device *dev)
> +{
> +       struct rswitch_private *priv = dev_get_drvdata(dev);
> +       struct net_device *ndev;
> +       int i;

unsigned int (also below)

> +
> +       rswitch_for_each_enabled_port(priv, i) {
> +               ndev = priv->rdev[i]->ndev;
> +               if (netif_running(ndev)) {
> +                       netif_device_detach(ndev);
> +                       rswitch_stop(ndev);
> +               }
> +               if (priv->rdev[i]->serdes->init_count)
> +                       phy_exit(priv->rdev[i]->serdes);

If !init_count, the PHY was not initialized before suspending? ...

> +       }
> +
> +       return 0;
> +}
> +
> +static int __maybe_unused renesas_eth_sw_resume(struct device *dev)
> +{
> +       struct rswitch_private *priv = dev_get_drvdata(dev);
> +       struct net_device *ndev;
> +       int i;
> +
> +       rswitch_for_each_enabled_port(priv, i) {
> +               phy_init(priv->rdev[i]->serdes);

... while it is always initialized after resuming? Is that intentional,
or should the pre-suspend state be preserved?

> +               ndev = priv->rdev[i]->ndev;
> +               if (netif_running(ndev)) {
> +                       rswitch_open(ndev);
> +                       netif_device_attach(ndev);
> +               }
> +       }
> +
> +       return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(renesas_eth_sw_pm_ops, renesas_eth_sw_suspend,
> +                        renesas_eth_sw_resume);

Please use DEFINE_SIMPLE_DEV_PM_OPS() instead, so you can drop the
__maybe_unused tags from the callbacks.

> +
>  static struct platform_driver renesas_eth_sw_driver_platform = {
>         .probe = renesas_eth_sw_probe,
>         .remove_new = renesas_eth_sw_remove,
>         .driver = {
>                 .name = "renesas_eth_sw",
> +               .pm = &renesas_eth_sw_pm_ops,

pm_sleep_ptr(...)

>                 .of_match_table = renesas_eth_sw_of_table,
>         }
>  };

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2023-10-12 12:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 12:16 [PATCH net-next] rswitch: Add PM ops Yoshihiro Shimoda
2023-10-12 12:35 ` Geert Uytterhoeven [this message]
2023-10-13  2:10   ` Yoshihiro Shimoda
2023-10-13  7:28     ` Geert Uytterhoeven
2023-10-13  8:55       ` Yoshihiro Shimoda
2023-10-13  9:19         ` Geert Uytterhoeven
2023-10-13 10:02           ` Yoshihiro Shimoda

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=CAMuHMdWAk9kJBGGq9K-RnC0HFZk1XbaosTBO2OW1kpYFPh1Mqg@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=s.shtylyov@omp.ru \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.