lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 27 Apr 2021 14:18:45 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Joakim Zhang <qiangqing.zhang@....com>
Cc:     "Jisheng.Zhang@...aptics.com" <Jisheng.Zhang@...aptics.com>,
        "peppe.cavallaro@...com" <peppe.cavallaro@...com>,
        "alexandre.torgue@...com" <alexandre.torgue@...com>,
        "joabreu@...opsys.com" <joabreu@...opsys.com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "f.fainelli@...il.com" <f.fainelli@...il.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        dl-linux-imx <linux-imx@....com>
Subject: Re: [PATCH V2 net] net: stmmac: fix MAC WoL unwork if PHY doesn't
 support WoL

> According to your comments, I did a quick draft, and have not test
> yet, could you please review the logic to see if I understand you
> correctly?


> 
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> @@ -647,18 +647,7 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
>  static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
>  {
>         struct stmmac_priv *priv = netdev_priv(dev);
> -       u32 support = WAKE_MAGIC | WAKE_UCAST;
> -
> -       if (!device_can_wakeup(priv->device))
> -               return -EOPNOTSUPP;
> -
> -       if (!priv->plat->pmt) {
> -               int ret = phylink_ethtool_set_wol(priv->phylink, wol);
> -
> -               if (!ret)
> -                       device_set_wakeup_enable(priv->device, !!wol->wolopts);
> -               return ret;
> -       }
> +       u32 support = WAKE_MAGIC | WAKE_UCAST | WAKE_MAGICSECURE |  WAKE_BCAST;
> 
>         /* By default almost all GMAC devices support the WoL via
>          * magic frame but we can disable it if the HW capability
> @@ -669,13 +658,24 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
>         if (wol->wolopts & ~support)
>                 return -EINVAL;
> 
> -       if (wol->wolopts) {
> -               pr_info("stmmac: wakeup enable\n");
> -               device_set_wakeup_enable(priv->device, 1);
> -               enable_irq_wake(priv->wol_irq);
> -       } else {
> +       if (!wol->wolopts) {
> +               device_set_wakeup_capable(priv->device, 0);
>                 device_set_wakeup_enable(priv->device, 0);
>                 disable_irq_wake(priv->wol_irq);
> +       } else {
> +               if (priv->plat->pmt && ((wol->wolopts & WAKE_MAGIC) || (wol->wolopts & WAKE_UCAST))) {
> +                       pr_info("stmmac: mac wakeup enable\n");
> +                       enable_irq_wake(priv->wol_irq);
> +               } else {
> +                       int ret = phylink_ethtool_set_wol(priv->phylink, wol);

You can have multiple wake up sources enabled at the same time. So the
if/else is wrong here. It could be, some are provided by the MAC and
some by the PHY.

If you are trying to save power, it is better if the PHY provides the
WoL sources. If the PHY can provide all the required WoL sources, you
can turn the MAC off and save more power. So give priority to the PHY.

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ