2020-06-23 18:14:00

by Luca Coelho

[permalink] [raw]
Subject: [PATCH] cfg80211: flush scan entries upon suspend

From: Emmanuel Grumbach <[email protected]>

When we suspend, we can't really remember our BSS table.
Purge all the data.
Export this function to allow driver to purge the BSS table
in case they feel the need to.
iwlwifi will need to do that.

Signed-off-by: Emmanuel Grumbach <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
---
include/net/cfg80211.h | 6 ++++++
net/wireless/scan.c | 10 ++++++++++
net/wireless/sysfs.c | 2 ++
3 files changed, 18 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fc7e8807838d..03a72b5b1986 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -7882,4 +7882,10 @@ void cfg80211_update_owe_info_event(struct net_device *netdev,
struct cfg80211_update_owe_info *owe_info,
gfp_t gfp);

+/**
+ * cfg80211_bss_flush - resets all the scan entries
+ * @wiphy: the wiphy
+ */
+void cfg80211_bss_flush(struct wiphy *wiphy);
+
#endif /* __NET_CFG80211_H */
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 74ea4cfb39fb..e67a74488bbe 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -712,6 +712,16 @@ void cfg80211_bss_expire(struct cfg80211_registered_device *rdev)
__cfg80211_bss_expire(rdev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE);
}

+void cfg80211_bss_flush(struct wiphy *wiphy)
+{
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+
+ spin_lock_bh(&rdev->bss_lock);
+ __cfg80211_bss_expire(rdev, jiffies);
+ spin_unlock_bh(&rdev->bss_lock);
+}
+EXPORT_SYMBOL(cfg80211_bss_flush);
+
const struct element *
cfg80211_find_elem_match(u8 eid, const u8 *ies, unsigned int len,
const u8 *match, unsigned int match_len,
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 3ac1f48195d2..b670f0d78621 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -5,6 +5,7 @@
*
* Copyright 2005-2006 Jiri Benc <[email protected]>
* Copyright 2006 Johannes Berg <[email protected]>
+ * Copyright (C) 2020 Intel Corporation
*/

#include <linux/device.h>
@@ -107,6 +108,7 @@ static int wiphy_suspend(struct device *dev)
if (rdev->wiphy.registered) {
if (!rdev->wiphy.wowlan_config) {
cfg80211_leave_all(rdev);
+ cfg80211_bss_flush(&rdev->wiphy);
cfg80211_process_rdev_events(rdev);
}
if (rdev->ops->suspend)
--
2.27.0


2020-06-25 09:46:00

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] cfg80211: flush scan entries upon suspend

On Tue, 2020-06-23 at 21:10 +0300, Luca Coelho wrote:
> From: Emmanuel Grumbach <[email protected]>
>
> When we suspend, we can't really remember our BSS table.

Sure we can. We do today :-)

Yes, I know why you want this for iwlwifi, but this commit message isn't
good. And if you had a good commit message, you'd know that it's
actually only needed for iwlwifi, not for basically anyone else.

And, in fact, it's not even needed for iwlwifi because if you had WoWLAN
then the firmware stays running and you don't need it.

> Purge all the data.

We age it already since commit cb3a8eec0e66. That should be sufficient
for most devices.

And in fact, if it weren't, then this should have removed the ageing
that's now completely pointless :)

> Export this function to allow driver to purge the BSS table
> in case they feel the need to.
> iwlwifi will need to do that.

I think we should just have a patch to purge it, without the call in
sysfs.c, and do then iwlwifi can call it in the right places (when it
resets the firmware.)

Note this won't even be _perfect_ because there are reasons (like being
connected) that mean the entry is not removed even when flushing, so
that should probably be documented.

johannes

2020-06-25 09:50:36

by Grumbach, Emmanuel

[permalink] [raw]
Subject: RE: [PATCH] cfg80211: flush scan entries upon suspend

> On Tue, 2020-06-23 at 21:10 +0300, Luca Coelho wrote:
> > From: Emmanuel Grumbach <[email protected]>
> >
> > When we suspend, we can't really remember our BSS table.
>
> Sure we can. We do today :-)
>
> Yes, I know why you want this for iwlwifi, but this commit message isn't
> good. And if you had a good commit message, you'd know that it's actually
> only needed for iwlwifi, not for basically anyone else.

I agree the commit message isn't sufficient and was written quickly to get the bugfix in, I should have rewritten it before getting it published.

>
> And, in fact, it's not even needed for iwlwifi because if you had WoWLAN
> then the firmware stays running and you don't need it.
>
> > Purge all the data.
>
> We age it already since commit cb3a8eec0e66. That should be sufficient for
> most devices.
>
> And in fact, if it weren't, then this should have removed the ageing that's
> now completely pointless :)
>
> > Export this function to allow driver to purge the BSS table in case
> > they feel the need to.
> > iwlwifi will need to do that.
>
> I think we should just have a patch to purge it, without the call in sysfs.c, and
> do then iwlwifi can call it in the right places (when it resets the firmware.)

I will rework this patch. I'll keep this function and call it from iwlwifi only.

>
> Note this won't even be _perfect_ because there are reasons (like being
> connected) that mean the entry is not removed even when flushing, so that
> should probably be documented.
>
> johannes