From owner-svn-src-all@FreeBSD.ORG Sat Dec 20 19:41:32 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6595DC95; Sat, 20 Dec 2014 19:41:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 466772C3A; Sat, 20 Dec 2014 19:41:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBKJfWgb012532; Sat, 20 Dec 2014 19:41:32 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBKJfWKp012531; Sat, 20 Dec 2014 19:41:32 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201412201941.sBKJfWKp012531@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 20 Dec 2014 19:41:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275964 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Dec 2014 19:41:32 -0000 Author: adrian Date: Sat Dec 20 19:41:31 2014 New Revision: 275964 URL: https://svnweb.freebsd.org/changeset/base/275964 Log: Document where in scan_task the scan state can change, and potentially deal/log a warning if the scan flags change during one of those race windows. It's highly likely that I need to actually sit down and replace this scan infrastructure at some point. It has some other side effects too - the scan task is a blocking task scheduled in the net80211 taskqueue; so drivers that use this taskqueue have other things not run. Eek. If you see this printf happen then please let me know! Modified: head/sys/net80211/ieee80211_scan.c Modified: head/sys/net80211/ieee80211_scan.c ============================================================================== --- head/sys/net80211/ieee80211_scan.c Sat Dec 20 19:15:10 2014 (r275963) +++ head/sys/net80211/ieee80211_scan.c Sat Dec 20 19:41:31 2014 (r275964) @@ -882,6 +882,9 @@ scan_task(void *arg, int pending) } scanend = ticks + SCAN_PRIVATE(ss)->ss_duration; + + /* XXX scan state can change! Re-validate scan state! */ + IEEE80211_UNLOCK(ic); ic->ic_scan_start(ic); /* notify driver */ IEEE80211_LOCK(ic); @@ -944,6 +947,8 @@ scan_task(void *arg, int pending) ic->ic_scan_curchan(ss, maxdwell); IEEE80211_LOCK(ic); + /* XXX scan state can change! Re-validate scan state! */ + SCAN_PRIVATE(ss)->ss_chanmindwell = ticks + ss->ss_mindwell; /* clear mindwell lock and initial channel change flush */ SCAN_PRIVATE(ss)->ss_iflags &= ~ISCAN_REP; @@ -960,6 +965,7 @@ scan_task(void *arg, int pending) IEEE80211_UNLOCK(ic); ic->ic_scan_end(ic); /* notify driver */ IEEE80211_LOCK(ic); + /* XXX scan state can change! Re-validate scan state! */ /* * Since a cancellation may have occured during one of the @@ -969,10 +975,10 @@ scan_task(void *arg, int pending) ((SCAN_PRIVATE(ss)->ss_iflags & ISCAN_CANCEL) != 0)) { /* XXX printf? */ if_printf(vap->iv_ifp, - "%s: OOPS! scan cancelled during driver call!\n", + "%s: OOPS! scan cancelled during driver call (1)!\n", __func__); + scandone = 1; } - scandone |= ((SCAN_PRIVATE(ss)->ss_iflags & ISCAN_CANCEL) != 0); /* * Record scan complete time. Note that we also do @@ -1032,6 +1038,19 @@ scan_task(void *arg, int pending) ticks, ss->ss_mindwell, scanend); /* + * Since a cancellation may have occured during one of the + * driver calls (whilst unlocked), update scandone. + */ + if (scandone == 0 && + ((SCAN_PRIVATE(ss)->ss_iflags & ISCAN_CANCEL) != 0)) { + /* XXX printf? */ + if_printf(vap->iv_ifp, + "%s: OOPS! scan cancelled during driver call (2)!\n", + __func__); + scandone = 1; + } + + /* * Clear the SCAN bit first in case frames are * pending on the station power save queue. If * we defer this then the dispatch of the frames