diff mbox series

net: bcmgenet: Don't claim WOL when its not available

Message ID 20220310045535.224450-1-jeremy.linton@arm.com (mailing list archive)
State Accepted
Commit 00b022f8f876a3a036b0df7f971001bef6398605
Delegated to: Netdev Maintainers
Headers show
Series net: bcmgenet: Don't claim WOL when its not available | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Jeremy Linton March 10, 2022, 4:55 a.m. UTC
Some of the bcmgenet platforms don't correctly support WOL, yet
ethtool returns:

"Supports Wake-on: gsf"

which is false.

Ideally if there isn't a wol_irq, or there is something else that
keeps the device from being able to wakeup it should display:

"Supports Wake-on: d"

This patch checks whether the device can wakup, before using the
hard-coded supported flags. This corrects the ethtool reporting, as
well as the WOL configuration because ethtool verifies that the mode
is supported before attempting it.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Peter Robinson March 10, 2022, 5:30 p.m. UTC | #1
On Thu, Mar 10, 2022 at 4:55 AM Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> Some of the bcmgenet platforms don't correctly support WOL, yet
> ethtool returns:
>
> "Supports Wake-on: gsf"
>
> which is false.
>
> Ideally if there isn't a wol_irq, or there is something else that
> keeps the device from being able to wakeup it should display:
>
> "Supports Wake-on: d"
>
> This patch checks whether the device can wakup, before using the
> hard-coded supported flags. This corrects the ethtool reporting, as
> well as the WOL configuration because ethtool verifies that the mode
> is supported before attempting it.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>

This fixes the reporting of the WOL capabilities on the Raspberry Pi 4.

> ---
>  drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
> index e31a5a397f11..f55d9d9c01a8 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
> @@ -40,6 +40,13 @@
>  void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
>  {
>         struct bcmgenet_priv *priv = netdev_priv(dev);
> +       struct device *kdev = &priv->pdev->dev;
> +
> +       if (!device_can_wakeup(kdev)) {
> +               wol->supported = 0;
> +               wol->wolopts = 0;
> +               return;
> +       }
>
>         wol->supported = WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER;
>         wol->wolopts = priv->wolopts;
> --
> 2.35.1
>
Florian Fainelli March 10, 2022, 6:52 p.m. UTC | #2
On 3/9/22 8:55 PM, Jeremy Linton wrote:
> Some of the bcmgenet platforms don't correctly support WOL, yet
> ethtool returns:
> 
> "Supports Wake-on: gsf"
> 
> which is false.
> 
> Ideally if there isn't a wol_irq, or there is something else that
> keeps the device from being able to wakeup it should display:
> 
> "Supports Wake-on: d"
> 
> This patch checks whether the device can wakup, before using the
> hard-coded supported flags. This corrects the ethtool reporting, as
> well as the WOL configuration because ethtool verifies that the mode
> is supported before attempting it.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Fixes: c51de7f3976b ("net: bcmgenet: add Wake-on-LAN support code")

Thanks Jeremy!
patchwork-bot+netdevbpf@kernel.org March 10, 2022, 11 p.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  9 Mar 2022 22:55:35 -0600 you wrote:
> Some of the bcmgenet platforms don't correctly support WOL, yet
> ethtool returns:
> 
> "Supports Wake-on: gsf"
> 
> which is false.
> 
> [...]

Here is the summary with links:
  - net: bcmgenet: Don't claim WOL when its not available
    https://git.kernel.org/netdev/net/c/00b022f8f876

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
index e31a5a397f11..f55d9d9c01a8 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
@@ -40,6 +40,13 @@ 
 void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct bcmgenet_priv *priv = netdev_priv(dev);
+	struct device *kdev = &priv->pdev->dev;
+
+	if (!device_can_wakeup(kdev)) {
+		wol->supported = 0;
+		wol->wolopts = 0;
+		return;
+	}
 
 	wol->supported = WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER;
 	wol->wolopts = priv->wolopts;