From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: geert@linux-m68k.org, woojung.huh@microchip.com,
UNGLinuxDriver@microchip.com, linux@roeck-us.net,
rjw@rjwysocki.net, netdev@vger.kernel.org,
linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lan78xx: Protect runtime_auto check by #ifdef CONFIG_PM
Date: Sun, 20 Mar 2016 16:52:51 -0400 (EDT) [thread overview]
Message-ID: <20160320.165251.836830192768797071.davem@davemloft.net> (raw)
In-Reply-To: <1458491752.10868.4.camel@edumazet-glaptop3.roam.corp.google.com>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 20 Mar 2016 09:35:52 -0700
> On Sun, 2016-03-20 at 11:43 +0100, Geert Uytterhoeven wrote:
>> If CONFIG_PM=n:
>>
>> drivers/net/usb/lan78xx.c: In function ‘lan78xx_get_stats64’:
>> drivers/net/usb/lan78xx.c:3274: error: ‘struct dev_pm_info’ has no member named ‘runtime_auto’
>>
>> If PM is disabled, the runtime_auto flag is not available, but auto
>> suspend is not enabled anyway. Hence protect the check for runtime_auto
>> by #ifdef CONFIG_PM to fix this.
>>
>> Fixes: a59f8c5b048dc938 ("lan78xx: add ndo_get_stats64")
>> Reported-by: Guenter Roeck <linux@roeck-us.net>
>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> ---
>> Alternatively, we can add a dev_pm_runtime_auto_is_enabled() wrapper to
>> include/linux/pm.h, which always return false if CONFIG_PM is disabled.
>>
>> The only other user in non-core code (drivers/usb/core/sysfs.c) has a
>> big #ifdef CONFIG_PM check around all PM-related code.
>>
>> Thoughts?
>> ---
>> drivers/net/usb/lan78xx.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
>> index d36d5ebf37f355f2..7b9ac47b2ecf9905 100644
>> --- a/drivers/net/usb/lan78xx.c
>> +++ b/drivers/net/usb/lan78xx.c
>> @@ -3271,7 +3271,9 @@ struct rtnl_link_stats64 *lan78xx_get_stats64(struct net_device *netdev,
>> * periodic reading from HW will prevent from entering USB auto suspend.
>> * if autosuspend is disabled, read from HW.
>> */
>> +#ifdef CONFIG_PM
>> if (!dev->udev->dev.power.runtime_auto)
>> +#endif
>> lan78xx_update_stats(dev);
>>
>> mutex_lock(&dev->stats.access_lock);
>
> Note that a ndo_get_stat64() handler is not allowed to sleep,
> so the mutex_lock() is not wise...
>
> Historically /proc/net/dev handler but also bonding ndo_get_stats() used
> RCU or a rwlock or a spinlock.
>
> So a complete fix would need to get rid of this mutex as well.
This function is also buggy for another reason. The driver needs to
capture the statistics when the runtime suspend happens.
Since it's much easier to find things wrong rather than right with
this new code, I've decided to completely revert the commit that added
lan78xx_get_stats64().
Once a correct version is implemented we can add it back.
Thanks.
next prev parent reply other threads:[~2016-03-20 20:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-20 10:43 [PATCH] lan78xx: Protect runtime_auto check by #ifdef CONFIG_PM Geert Uytterhoeven
2016-03-20 16:35 ` Eric Dumazet
2016-03-20 20:52 ` David Miller [this message]
2016-03-20 22:59 ` Guenter Roeck
2016-03-21 14:59 ` Woojung.Huh
2016-03-21 8:36 ` Oliver Neukum
[not found] ` <1458549361.2299.1.camel-IBi9RG/b67k@public.gmane.org>
2016-03-21 14:41 ` Woojung.Huh-UWL1GkI3JZL3oGB3hsPCZA
2016-03-21 14:57 ` Alan Stern
2016-03-21 17:34 ` Oliver Neukum
2016-03-21 18:24 ` Alan Stern
2016-03-21 18:42 ` Woojung.Huh
2016-03-21 19:27 ` Alan Stern
2016-03-21 20:09 ` Woojung.Huh
[not found] ` <9235D6609DB808459E95D78E17F2E43D404CC1EF-8fD0d2gESGrABDY0R+s2SH2Vsf1/G1/XQQ4Iyu8u01E@public.gmane.org>
2016-03-21 21:02 ` Alan Stern
2016-03-21 18:51 ` Oliver Neukum
2016-03-21 19:30 ` Alan Stern
2016-03-22 9:50 ` Oliver Neukum
[not found] ` <1458640209.1990.8.camel-IBi9RG/b67k@public.gmane.org>
2016-03-22 14:21 ` Alan Stern
2016-03-22 14:28 ` Oliver Neukum
2016-03-22 15:13 ` Alan Stern
2016-03-22 15:29 ` Oliver Neukum
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=20160320.165251.836830192768797071.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=UNGLinuxDriver@microchip.com \
--cc=eric.dumazet@gmail.com \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=woojung.huh@microchip.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).