Stable Archive on lore.kernel.org
 help / color / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: netdev@vger.kernel.org,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Auke Kok <auke-jan.h.kok@intel.com>,
	Jeff Garzik <jeff@garzik.org>,
	intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org,
	Len Brown <len.brown@intel.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"Shevchenko, Andriy" <andriy.shevchenko@intel.com>,
	"Neftin, Sasha" <sasha.neftin@intel.com>,
	"Lifshits, Vitaly" <vitaly.lifshits@intel.com>,
	Stable@vger.kernel.org
Subject: Re: [PATCH 2/2] e1000e: Make WOL info in ethtool consistent with device wake up ability
Date: Sat, 23 May 2020 17:09:50 +0800
Message-ID: <20200523090950.GA20370@chenyu-office.sh.intel.com> (raw)
In-Reply-To: <20200521192342.GE8771@lion.mk-sys.cz>

Hi Michal,
Thanks for reviewing,
and sorry for late reply.
On Thu, May 21, 2020 at 09:23:42PM +0200, Michal Kubecek wrote:
> On Fri, May 22, 2020 at 01:59:13AM +0800, Chen Yu wrote:
> > Currently the ethtool shows that WOL(Wake On Lan) is enabled
> > even if the device wakeup ability has been disabled via sysfs:
> >   cat /sys/devices/pci0000:00/0000:00:1f.6/power/wakeup
> >    disabled
> > 
> >   ethtool eno1
> >   ...
> >   Wake-on: g
> > 
> > Fix this in ethtool to check if the user has explicitly disabled the
> > wake up ability for this device.
> 
> Wouldn't this lead to rather unexpected and inconsistent behaviour when
> the wakeup is disabled? As you don't touch the set_wol handler, I assume
> it will still allow setting enabled modes as usual so that you get e.g.
> 
>   ethtool -s eth0 wol g   # no error or warning, returns 0
>   ethtool eth0            # reports no modes enabled
> 
> The first command would set the enabled wol modes but that would be
> hidden from user and even the netlink notification would claim something
> different. Another exampe (with kernel and ethtool >= 5.6):
> 
>   ethtool -s eth0 wol g
>   ethtool -s eth0 wol +m
> 
> resulting in "mg" if device wakeup is enabled but "m" when it's disabled
> (but the latter would be hidden from user and only revealed when you
> enable the device wakeup).
> 
I've tested ethtool v5.6 on top of kernel v5.7-rc6, it looks like
the scenario you described will not happen as it will not allow
the user to enable the wol options with device wakeup disabled,
not sure if I missed something:

/sys/devices/pci0000:00/0000:00:1f.6/power# echo disabled > wakeup

ethtool -s eno1 wol g
netlink error: cannot enable unsupported WoL mode (offset 36)
netlink error: Invalid argument

I've not digged into the code too much, but according to
ethhl_set_wol(), it will first get the current wol options
via dev->ethtool_ops->get_wol(), and both the wolopts and
wol.supported are 0 when device wake up are disabled. Then
ethnl_update_bitset32 might manipulate on wolopts and
make it non-zero each is controdict with the precondition that
no opts should be enabled due to 0 wol.supported.
> This is a general problem discussed recently for EEE and pause
> autonegotiation: if setting A can be effectively used only when B is
> enabled, should we hide actual setting of A from userspace when B is
> disabled or even reset the value of A whenever B gets toggled or rather
> allow setting A and B independently? AFAICS the consensus seemed to be
> that A should be allowed to be set and queried independently of the
> value of B.

But then there would be an inconsistence between A and B. I was thinking
if there's a way to align them in kernel space and  maintain the difference in user space?

Thanks,
Chenyu
> 
> Michal
> 
> > Fixes: 6ff68026f475 ("e1000e: Use device_set_wakeup_enable")
> > Reported-by: Len Brown <len.brown@intel.com>
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: <Stable@vger.kernel.org>
> > Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> > ---
> >  drivers/net/ethernet/intel/e1000e/ethtool.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
> > index 1d47e2503072..0cccd823ff24 100644
> > --- a/drivers/net/ethernet/intel/e1000e/ethtool.c
> > +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
> > @@ -1891,7 +1891,7 @@ static void e1000_get_wol(struct net_device *netdev,
> >  	wol->wolopts = 0;
> >  
> >  	if (!(adapter->flags & FLAG_HAS_WOL) ||
> > -	    !device_can_wakeup(&adapter->pdev->dev))
> > +	    !device_may_wakeup(&adapter->pdev->dev))
> >  		return;
> >  
> >  	wol->supported = WAKE_UCAST | WAKE_MCAST |
> > -- 
> > 2.17.1
> > 

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1590081982.git.yu.c.chen@intel.com>
2020-05-21 17:59 ` [PATCH 1/2] e1000e: Do not wake up the system via WOL if device wakeup is disabled Chen Yu
2020-05-26  0:23   ` Sasha Levin
2020-05-26  3:34     ` Chen Yu
2020-05-21 17:59 ` [PATCH 2/2] e1000e: Make WOL info in ethtool consistent with device wake up ability Chen Yu
2020-05-21 19:23   ` Michal Kubecek
2020-05-23  9:09     ` Chen Yu [this message]
2020-05-24 21:06       ` Michal Kubecek
2020-05-25 16:12         ` Chen Yu

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=20200523090950.GA20370@chenyu-office.sh.intel.com \
    --to=yu.c.chen@intel.com \
    --cc=Stable@vger.kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=auke-jan.h.kok@intel.com \
    --cc=davem@davemloft.net \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeff@garzik.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=kuba@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sasha.neftin@intel.com \
    --cc=vitaly.lifshits@intel.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

Stable Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://lore.kernel.org/stable \
		stable@vger.kernel.org
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git