From: "Luis R. Rodriguez" <lrodriguez@atheros.com>
To: Paul Stewart <pstew@google.com>
Cc: Johannes Berg <johannes@sipsolutions.net>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
Luis Rodriguez <Luis.Rodriguez@Atheros.com>
Subject: Re: [PATCH] mac80211: Push idle state to driver before stop
Date: Thu, 16 Dec 2010 09:44:10 -0800 [thread overview]
Message-ID: <20101216174410.GB5677@tux> (raw)
In-Reply-To: <AANLkTinWkYK2Zu1LsKw9YQ4dAXJ2b_quEvZLc59-c_5q@mail.gmail.com>
On Thu, Dec 16, 2010 at 08:02:27AM -0800, Paul Stewart wrote:
> On Thu, Dec 16, 2010 at 4:53 AM, Johannes Berg
> <johannes@sipsolutions.net> wrote:
> > On Thu, 2010-12-16 at 04:46 -0800, Paul Stewart wrote:
> > Not really -- the driver may throw away all internal state, mac80211
> > will (attempt to) restore it all through drv_config() with changed = ~0.
> > Evidently ath9k has some magic that makes this fail?
>
> The magic in question is as follows (ath9k_config()):
>
> if (changed & IEEE80211_CONF_CHANGE_IDLE) {
> bool enable_radio;
> bool all_wiphys_idle;
> bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
>
> spin_lock_bh(&sc->wiphy_lock);
> all_wiphys_idle = ath9k_all_wiphys_idle(sc);
> ath9k_set_wiphy_idle(aphy, idle);
>
> enable_radio = (!idle && all_wiphys_idle);
>
> /*
> * After we unlock here its possible another wiphy
> * can be re-renabled so to account for that we will
> * only disable the radio toward the end of this routine
> * if by then all wiphys are still idle.
> */
> spin_unlock_bh(&sc->wiphy_lock);
>
> if (enable_radio) {
> sc->ps_idle = false;
> ath_radio_enable(sc, hw);
> ath_dbg(common, ATH_DBG_CONFIG,
> "not-idle: enabling radio\n");
> }
> }
>
> So, ath9k enables and disables the radio based on ps_idle (the
> internal state), but that's not re-evaluated unless the wiphys
> actually change. In this case they do not change because ath9k was
> never informed that the wiphy went idle (all_wiphys_idle evaluates to
> false). One solution would be to do an ah9k_set_wiphy_idle(aphy,
> true) in ath9k_stop() instead of Luis' previous suggestion of setting
> sc->ps_idle directly. Perhaps in January when I return from vacation
> I'll test this to make sure that performs as intended in the
> suspend-resume-while-associated case. It's a little bit of a lie to
> do it in this case since in fact as far as mac80211 is concerned, the
> wiphy is not idle in this case.
Try this:
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index c68205d..3de3dbf 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1350,6 +1350,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
ath9k_ps_restore(sc);
sc->ps_idle = true;
+ ath9k_set_wiphy_idle(aphy, true);
ath_radio_disable(sc, hw);
sc->sc_flags |= SC_OP_INVALID;
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 7ca8499..4538283 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -310,6 +310,7 @@ static int ath_pci_resume(struct device *device)
ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
sc->ps_idle = true;
+ ath9k_set_wiphy_idle(aphy, true);
ath_radio_disable(sc, hw);
return 0;
next prev parent reply other threads:[~2010-12-16 17:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 18:54 [PATCH] mac80211: Push idle state to driver before stop Paul Stewart
2010-12-16 6:59 ` Johannes Berg
2010-12-16 11:17 ` Paul Stewart
2010-12-16 11:30 ` Johannes Berg
2010-12-16 11:51 ` Paul Stewart
2010-12-16 12:04 ` Johannes Berg
2010-12-16 12:27 ` Paul Stewart
2010-12-16 12:35 ` Johannes Berg
2010-12-16 12:46 ` Paul Stewart
2010-12-16 12:53 ` Johannes Berg
2010-12-16 16:02 ` Paul Stewart
2010-12-16 17:44 ` Luis R. Rodriguez [this message]
2010-12-16 17:49 ` Luis R. Rodriguez
2010-12-16 19:08 ` Paul Stewart
2010-12-16 19:12 ` Luis R. Rodriguez
2011-01-04 18:19 ` Paul Stewart
2011-01-04 22:29 ` Paul Stewart
2011-01-05 18:26 ` Luis R. Rodriguez
2011-01-05 22:57 ` Luis R. Rodriguez
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=20101216174410.GB5677@tux \
--to=lrodriguez@atheros.com \
--cc=Luis.Rodriguez@Atheros.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=pstew@google.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).