From patchwork Thu Oct 20 18:45:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 9387433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04B07607F0 for ; Thu, 20 Oct 2016 18:45:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED441287D6 for ; Thu, 20 Oct 2016 18:45:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD16629C19; Thu, 20 Oct 2016 18:45:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30929287D6 for ; Thu, 20 Oct 2016 18:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934225AbcJTSpj (ORCPT ); Thu, 20 Oct 2016 14:45:39 -0400 Received: from s3.sipsolutions.net ([5.9.151.49]:46887 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933869AbcJTSpi (ORCPT ); Thu, 20 Oct 2016 14:45:38 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1bxILN-0006QL-8A; Thu, 20 Oct 2016 20:45:33 +0200 Message-ID: <1476989132.14078.12.camel@sipsolutions.net> Subject: Re: cfg80211: race problem between suspend and disconnect event From: Johannes Berg To: Amitkumar Karwar Cc: Kalle Valo , Brian Norris , Nishant Sarmukadam , Cathy Luo , "linux-wireless@vger.kernel.org" , Ganapathi Bhat Date: Thu, 20 Oct 2016 20:45:32 +0200 In-Reply-To: <67400d1c5c2141b3af75bdce9ec43840@SC-EXCH04.marvell.com> References: <67400d1c5c2141b3af75bdce9ec43840@SC-EXCH04.marvell.com> X-Mailer: Evolution 3.20.5-1 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: 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 --- 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); } }