Hi Johannes,
We came across one race issue while running suspend tests with Marvell device.
Mwifiex driver rejects del_key() requests from cfg80211 during suspend. They came very late when driver's cfg80211_suspend handler is already executed and driver is in the middle of SDIO's suspend handler.
In wowlan not configured case, below code ensures cfg80211 terminates connection before calling ops->suspend. However when driver reports disconnection through cfg80211_disconnected() API, cfg80211 handles EVENT_DISCONNECTED in separate work function where ops->del_key() is called in loop to flush keys.
------wiphy_suspend()-----------
if (rdev->wiphy.registered) {
if (!rdev->wiphy.wowlan_config)
cfg80211_leave_all(rdev);
if (rdev->ops->suspend)
ret = rdev_suspend(rdev, rdev->wiphy.wowlan_config);
--------------------------------
Please let us know if you have any suggestions to resolves this with cfg80211/driver change.
Regards,
Amitkumar
Hi,
> Mwifiex driver rejects del_key() requests from cfg80211 during
> suspend. They came very late when driver's cfg80211_suspend handler
> is already executed and driver is in the middle of SDIO's suspend
> handler.
Interesting. Rejecting those calls is probably perfectly reasonable,
and in fact it's not clear to me why we even try to delete the keys
after we've disconnected - any driver implementation should have
removed them already anyway? You probably don't actually care about the
key removal either?
That said though, there's also the critical protocol stop and the
set_qos_map(NULL) call, which removes the QoS mapping. It doesn't look
like you support this right now in your driver, but in any case it'd be
pretty strange to have that happen after or during suspend.
> Please let us know if you have any suggestions to resolves this with
> cfg80211/driver change.
For cfg80211 we could do something like this:
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -104,13 +104,16 @@ static int wiphy_suspend(struct device *dev)
rtnl_lock();
if (rdev->wiphy.registered) {
- if (!rdev->wiphy.wowlan_config)
+ if (!rdev->wiphy.wowlan_config) {
cfg80211_leave_all(rdev);
+ cfg80211_process_rdev_events(rdev);
+ }
if (rdev->ops->suspend)
ret = rdev_suspend(rdev, rdev->wiphy.wowlan_config);
if (ret == 1) {
/* Driver refuse to configure wowlan */
cfg80211_leave_all(rdev);
+ cfg80211_process_rdev_events(rdev);
ret = rdev_suspend(rdev, NULL);
}
}
However, that assumes that you actually cfg80211_disconnected()
synchronously while being asked to disconnect, which doesn't seem to be
true from looking at mwifiex, if HostCmd_CMD_802_11_DEAUTHENTICATE
command can be sent to the firmware then you wait for EVENT_LINK_LOST,
EVENT_DEAUTHENTICATED or EVENT_DISASSOCIATED to come back from the
firmware, so this cfg80211 change won't help.
So somehow you'd have to synchronize with the firmware as well, to
process all those things before suspend, I guess?
We could then export cfg80211_process_rdev_events() as
cfg80211_process_wiphy_events() or so, so that you can call that at an
appropriate place from your suspend handler, after having synchronized
with the firmware?
johannes
SGkgSm9oYW5uZXMsDQoNCj4gRnJvbTogSm9oYW5uZXMgQmVyZyBbbWFpbHRvOmpvaGFubmVzQHNp
cHNvbHV0aW9ucy5uZXRdDQo+IFNlbnQ6IFNhdHVyZGF5LCBPY3RvYmVyIDIyLCAyMDE2IDI6NTQg
QU0NCj4gVG86IEFtaXRrdW1hciBLYXJ3YXINCj4gQ2M6IEthbGxlIFZhbG87IEJyaWFuIE5vcnJp
czsgTmlzaGFudCBTYXJtdWthZGFtOyBDYXRoeSBMdW87IGxpbnV4LQ0KPiB3aXJlbGVzc0B2Z2Vy
Lmtlcm5lbC5vcmc7IEdhbmFwYXRoaSBCaGF0DQo+IFN1YmplY3Q6IFJlOiBjZmc4MDIxMTogcmFj
ZSBwcm9ibGVtIGJldHdlZW4gc3VzcGVuZCBhbmQgZGlzY29ubmVjdCBldmVudA0KPiANCj4gDQo+
ID4gWWVzLiBJbiBvdXIgY2FzZSwgKjgwMl8xMV9ERUFVVEhFTlRJQ0FURSBjb21tYW5kIGRvd25s
b2FkZWQgdG8NCj4gPiBmaXJtd2FyZSB0YWtlcyBjYXJlIG9mIGZsdXNoaW5nIHRoZSBrZXlzLg0K
PiA+DQo+ID4gSSBjYW4gc2VlIGJlbG93IGNvZGUgaW4gY2ZnODAyMTEncyBkaXNjb25uZWN0IGhh
bmRsaW5nLiBJdCBzZWVtcyB0byBiZQ0KPiA+IHRoZXJlIGZvciBsb25nIHRpbWUuDQo+IA0KPiBZ
ZWFoLCBJIHNhdy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N1c3BlbmQsIEkgZ3Vl
c3M/DQo+ID4gPg0KPiBbLi4uXQ0KPiA+IFRoaXMgd291bGQgbm90IGJlIG5lZWRlZC4NCj4gDQo+
IFJpZ2h0LiBDYXJlIHRvIHRlc3QgbXkgcGF0Y2ggYmVmb3JlIEkgcHJvcGVybHkgc3VibWl0IGl0
Pw0KDQpXZSByYW4gdGhlIHRlc3RzIGFuZCBjb25maXJtZWQgdGhhdCB5b3VyIHBhdGNoIGRvZXMg
c29sdmUgdGhlIHByb2JsZW0uIFlvdSBjYW4gc3VibWl0IGl0Lg0KDQpSZWdhcmRzLA0KQW1pdGt1
bWFyDQo=
> Yes. In our case, *802_11_DEAUTHENTICATE command downloaded to
> firmware takes care of flushing the keys.
>
> I can see below code in cfg80211's disconnect handling. It seems to
> be there for long time.
Yeah, I saw it, but it's not clear to me that there's much point in it.
In any case, that's an unrelated question in a way, because there
definitely are things happening here that should be "more synchronous",
regardless of whether or not the key deletion makes sense.
> I think, your cfg80211 change will help. We do ensure that
> cfg80211_disconnected() is called before exiting
> mwifiex_cfg80211_disconnect().
> Sending HostCmd_CMD_802_11_DEAUTHENTICATE command to firmware is a
> blocking call. cfg80211_disconnected() is called while handling that
> command's response.
Ah ok, I missed that - I thought it was asynchronous.
> > So somehow you'd have to synchronize with the firmware as well, to
> > process all those things before suspend, I guess?
> >
[...]
> This would not be needed.
Right. Care to test my patch before I properly submit it?
johannes
SGkgSm9oYW5uZXMsDQoNCj4gRnJvbTogSm9oYW5uZXMgQmVyZyBbbWFpbHRvOmpvaGFubmVzQHNp
cHNvbHV0aW9ucy5uZXRdDQo+IFNlbnQ6IEZyaWRheSwgT2N0b2JlciAyMSwgMjAxNiAxMjoxNiBB
TQ0KPiBUbzogQW1pdGt1bWFyIEthcndhcg0KPiBDYzogS2FsbGUgVmFsbzsgQnJpYW4gTm9ycmlz
OyBOaXNoYW50IFNhcm11a2FkYW07IENhdGh5IEx1bzsgbGludXgtDQo+IHdpcmVsZXNzQHZnZXIu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