From: Jarkko Nikula <jhnikula@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: "John W. Linville" <linville@tuxdriver.com>,
Kalle Valo <kvalo@adurom.com>, Jarkko Nikula <jhnikula@gmail.com>
Subject: [PATCH 2/2] wl1251: Add support for idle mode
Date: Thu, 31 Mar 2011 16:04:03 +0300 [thread overview]
Message-ID: <1301576643-29224-2-git-send-email-jhnikula@gmail.com> (raw)
In-Reply-To: <1301576643-29224-1-git-send-email-jhnikula@gmail.com>
On Nokia N900 the wl1251 consumes the most power when the interface is up
but not associated to access point (that supports PSM). In terms of battery
current consumption, the consumption is ~180 mA higher when the interface is
up but not associated and only ~5 mA higher when associated compared to
interface down and driver not loaded cases.
This patch adds support for the mac80211 idle notifications. Chip is put into
idle very much the same way when entering into PSM by utilizing the Extreme
Low Power (ELP) mode. I.e. idle is entered by setting necessary conditions
in wl1251_ps_set_mode followed by a call to wl1251_ps_elp_sleep.
It seems it is just enough the authorize ELP mode followed by
CMD_DISCONNECT (thanks to Kalle Valo about the idea to use it).
Without disconnect command the chip remains somewhat active and stays
consuming ~20 mA. Idle mode is left by same way than PSM. The wl1251_join
call is used to revert the CMD_DISCONNECT. Without it association to AP
doesn't work when trying second time.
With this patch the interface up but not associated case the battery current
consumption is less than 1 mA higher compared to interface down case.
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
---
v2:
- cmd.h change not needed because of the patch 1/2
- developed on top vanilla commit 6aba74f2791287ec407e0f92487a725a25908067
v1:
- I don't have specs for the chip and this patch is developed heavily by
trial and error method. Anyway, I believe the chip enters into idle properly
as the consumption is very near to interface down case.
- I have verified the patch by making sure that the driver can scan the APs
and connect/disconnect multiple times after the idle mode was entered.
- There is still problem that the consumption jumps again ~+180 mA after
disconnection happens. Reason is the BSS_LOSE_EVENT which puts the chip
again into active mode and driver doesn't receive an idle mode request
after that. For me it looks the driver doesn't notify the mac80211
properly and thus no idle mode request is coming. As this patch doesn't
affect that I see that is better to handle separately.
---
drivers/net/wireless/wl1251/main.c | 16 ++++++++++++++++
drivers/net/wireless/wl1251/ps.c | 11 +++++++++++
drivers/net/wireless/wl1251/wl1251.h | 1 +
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/wl1251/main.c b/drivers/net/wireless/wl1251/main.c
index 04a0549..a14a48c 100644
--- a/drivers/net/wireless/wl1251/main.c
+++ b/drivers/net/wireless/wl1251/main.c
@@ -639,6 +639,22 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
}
}
+ if (changed & IEEE80211_CONF_CHANGE_IDLE) {
+ if (conf->flags & IEEE80211_CONF_IDLE) {
+ ret = wl1251_ps_set_mode(wl, STATION_IDLE);
+ if (ret < 0)
+ goto out_sleep;
+ } else {
+ ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
+ if (ret < 0)
+ goto out_sleep;
+ ret = wl1251_join(wl, wl->bss_type, wl->channel,
+ wl->beacon_int, wl->dtim_period);
+ if (ret < 0)
+ goto out_sleep;
+ }
+ }
+
if (conf->power_level != wl->power_level) {
ret = wl1251_acx_tx_power(wl, conf->power_level);
if (ret < 0)
diff --git a/drivers/net/wireless/wl1251/ps.c b/drivers/net/wireless/wl1251/ps.c
index 5485f03..50ed918 100644
--- a/drivers/net/wireless/wl1251/ps.c
+++ b/drivers/net/wireless/wl1251/ps.c
@@ -136,6 +136,17 @@ int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_station_mode mode)
if (ret < 0)
return ret;
break;
+ case STATION_IDLE:
+ wl1251_debug(DEBUG_PSM, "entering idle");
+
+ ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_ELP);
+ if (ret < 0)
+ return ret;
+
+ ret = wl1251_cmd_template_set(wl, CMD_DISCONNECT, NULL, 0);
+ if (ret < 0)
+ return ret;
+ break;
case STATION_ACTIVE_MODE:
default:
wl1251_debug(DEBUG_PSM, "leaving psm");
diff --git a/drivers/net/wireless/wl1251/wl1251.h b/drivers/net/wireless/wl1251/wl1251.h
index bf245a8..a77f1bb 100644
--- a/drivers/net/wireless/wl1251/wl1251.h
+++ b/drivers/net/wireless/wl1251/wl1251.h
@@ -132,6 +132,7 @@ enum wl1251_partition_type {
enum wl1251_station_mode {
STATION_ACTIVE_MODE,
STATION_POWER_SAVE_MODE,
+ STATION_IDLE,
};
struct wl1251_partition {
--
1.7.0.4
next prev parent reply other threads:[~2011-03-31 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 13:04 [PATCH 1/2] wl1251: Prepare for idle mode support Jarkko Nikula
2011-03-31 13:04 ` Jarkko Nikula [this message]
2011-04-01 19:30 ` [PATCH 2/2] wl1251: Add support for idle mode Kalle Valo
2011-04-01 19:22 ` [PATCH 1/2] wl1251: Prepare for idle mode support Kalle Valo
2011-04-04 6:49 ` Jarkko Nikula
-- strict thread matches above, loose matches on Subject: below --
2011-04-04 8:04 Jarkko Nikula
2011-04-04 8:04 ` [PATCH 2/2] wl1251: Add support for idle mode Jarkko Nikula
2011-04-04 18:18 ` Kalle Valo
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=1301576643-29224-2-git-send-email-jhnikula@gmail.com \
--to=jhnikula@gmail.com \
--cc=kvalo@adurom.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.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).