Skip to contentSkip to conversation

Added support for host sleep feature

PATCH In review Amitkumar Karwar 3 participants 4 messages Jul 8, 2010 – Jul 13, 2010 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added support for host sleep feature

From: Amitkumar Karwar <[email protected]>

Existing "ethtool -s ethX wol X" command configures hostsleep parameters, but those are activated only during suspend/resume, there is no way to configure host sleep without actual suspend.

This patch adds debugfs command to enable/disable host sleep based on already configured host sleep parameters using wol command.

---
 drivers/net/wireless/libertas/README    |   12 ++++++
 drivers/net/wireless/libertas/cmd.c     |   61 ++++++++++++++++++++++++++++-
 drivers/net/wireless/libertas/cmd.h     |    2 +
 drivers/net/wireless/libertas/debugfs.c |   66 +++++++++++++++++++++++++++++++
 drivers/net/wireless/libertas/main.c    |   34 +---------------
 5 files changed, 142 insertions(+), 33 deletions(-)
drivers/net/wireless/libertas/README +12 -0
index 2726c04..60fd1af 100644
@@ -226,6 +226,18 @@ setuserscan
     All entries in the scan table (not just the new scan data when keep=1)
     will be displayed upon completion by use of the getscantable ioctl.
 
+hostsleep
+	This command is used to enable/disable host sleep.
+	Note: Host sleep parameters should be configured using
+	"ethtool -s ethX wol X" command before enabling host sleep.
+
+	Path: /sys/kernel/debug/libertas_wireless/ethX/
+
+	Usage:
+		cat hostsleep: reads the current hostsleep state
+		echo "1" > hostsleep : enable host sleep.
+		echo "0" > hostsleep : disable host sleep
+
 ========================
 IWCONFIG COMMANDS
 ========================
drivers/net/wireless/libertas/cmd.c +60 -1

73 lines not on this page · raw message

drivers/net/wireless/libertas/cmd.h +2 -0
index cb4138a..386e565 100644
@@ -127,4 +127,6 @@ int lbs_set_tx_power(struct lbs_private *priv, s16 dbm);
 
 int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep);
 
+int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep);
+
 #endif /* _LBS_CMD_H */
drivers/net/wireless/libertas/debugfs.c +66 -0

78 lines not on this page · raw message

drivers/net/wireless/libertas/main.c +2 -32
index b519fc7..2a0b590 100644
@@ -544,20 +544,8 @@ static int lbs_thread(void *data)
 	return 0;
 }
 
-static int lbs_ret_host_sleep_activate(struct lbs_private *priv,
-		unsigned long dummy,
-		struct cmd_header *cmd)
-{
-	lbs_deb_enter(LBS_DEB_FW);
-	priv->is_host_sleep_activated = 1;
-	wake_up_interruptible(&priv->host_sleep_q);
-	lbs_deb_leave(LBS_DEB_FW);
-	return 0;
-}
-
 int lbs_suspend(struct lbs_private *priv)
 {
-	struct cmd_header cmd;
 	int ret;
 
 	lbs_deb_enter(LBS_DEB_FW);
@@ -571,25 +559,8 @@ int lbs_suspend(struct lbs_private *priv)
 		priv->deep_sleep_required = 1;
 	}
 
-	memset(&cmd, 0, sizeof(cmd));
-	ret = lbs_host_sleep_cfg(priv, priv->wol_criteria,
-						(struct wol_config *)NULL);
-	if (ret) {
-		lbs_pr_info("Host sleep configuration failed: %d\n", ret);
-		return ret;
-	}
-	if (priv->psstate == PS_STATE_FULL_POWER) {
-		ret = __lbs_cmd(priv, CMD_802_11_HOST_SLEEP_ACTIVATE, &cmd,
-				sizeof(cmd), lbs_ret_host_sleep_activate, 0);
-		if (ret)
-			lbs_pr_info("HOST_SLEEP_ACTIVATE failed: %d\n", ret);
-	}
+	ret = lbs_set_host_sleep(priv, 1);
 
-	if (!wait_event_interruptible_timeout(priv->host_sleep_q,
-				priv->is_host_sleep_activated, (10 * HZ))) {
-		lbs_pr_err("host_sleep_q: timer expired\n");
-		ret = -1;
-	}
 	netif_device_detach(priv->dev);
 	if (priv->mesh_dev)
 		netif_device_detach(priv->mesh_dev);
@@ -602,11 +573,10 @@ EXPORT_SYMBOL_GPL(lbs_suspend);
 int lbs_resume(struct lbs_private *priv)
 {
 	int ret;
-	uint32_t criteria = EHS_REMOVE_WAKEUP;
 
 	lbs_deb_enter(LBS_DEB_FW);
 
-	ret = lbs_host_sleep_cfg(priv, criteria, (struct wol_config *)NULL);
+	ret = lbs_set_host_sleep(priv, 0);
 
 	netif_device_attach(priv->dev);
 	if (priv->mesh_dev)
Signature · 1 line
1.5.3.4
#1 lore raw
Quoted 5 lines · amitkumar

From: Amitkumar Karwar <[email protected]>

Existing "ethtool -s ethX wol X" command configures hostsleep parameters, but those are activated only during suspend/resume, there is no way to configure host sleep without actual suspend.

as background, can you expand on how this is useful? i just spent a bunch of time debugging issues with HOST_SLEEP_CFG and HOST_SLEEP_ACTIVATE (which doesn't work on an 8388) on the XO-1 OLPC laptop, and i'm wondering whether or how this would have helped.

as an aside, since i know you've helped OLPC with some of these issues in the past, the pertinent results of my debugging are:
http://dev.laptop.org/git/olpc-2.6/commit/?h=olpc-2.6.31&id=515dc7313c37218fa02888eb19fba065ca0ab63c
and
http://dev.laptop.org/git/olpc-2.6/commit/?h=olpc-2.6.31&id=8db05fd8301980cf48ff10f61c977256e1f136b5

other nearby commits, all dated 6/22/2010, are related, but were less central to the problems we were having.)

paul

Quoted 6 lines

This patch adds debugfs command to enable/disable host sleep based on already configured host sleep parameters using wol command.

Quoted 8 lines
---
 drivers/net/wireless/libertas/README    |   12 ++++++
 drivers/net/wireless/libertas/cmd.c     |   61 ++++++++++++++++++++++++++++-
 drivers/net/wireless/libertas/cmd.h     |    2 +
 drivers/net/wireless/libertas/debugfs.c |   66 +++++++++++++++++++++++++++++++
 drivers/net/wireless/libertas/main.c    |   34 +---------------
 5 files changed, 142 insertions(+), 33 deletions(-)

....

=---------------------
paul fox, [email protected]

#2 lore raw
Quoted 9 lines
Quoted 5 lines · amitkumar

From: Amitkumar Karwar <[email protected]>

Existing "ethtool -s ethX wol X" command configures hostsleep parameters, but those are activated only during suspend/resume, there is no way to configure host sleep without actual suspend.

Quoted 5 lines

as background, can you expand on how this is useful? i just spent a bunch of time debugging issues with HOST_SLEEP_CFG and HOST_SLEEP_ACTIVATE (which doesn't work on an 8388) on the XO-1 OLPC laptop, and i'm wondering whether or how this would have helped.

This patch is useful if someone wants to enable host sleep feature without the device entering suspend state.

The host sleep using device suspend feature is also intact.

Thanks,
Amitkumar Karwar

#3 lore raw
Quoted 14 lines · Amitkumar Karwar
Quoted 8 lines
Quoted 5 lines · amitkumar

From: Amitkumar Karwar <[email protected]>

Existing "ethtool -s ethX wol X" command configures hostsleep parameters, but those are activated only during suspend/resume, there is no way to configure host sleep without actual suspend.

Quoted 5 lines

as background, can you expand on how this is useful? i just spent a bunch of time debugging issues with HOST_SLEEP_CFG and HOST_SLEEP_ACTIVATE (which doesn't work on an 8388) on the XO-1 OLPC laptop, and i'm wondering whether or how this would have helped.

Quoted 6 lines

This patch is useful if someone wants to enable host sleep feature without the device entering suspend state.

The host sleep using device suspend feature is also intact.

Thanks,
Amitkumar Karwar

Regards current consumption, maintaining a wireless connection active, the device consumes circa 30 mA instead of 180 mA of full power idle mode.
So for embedded devices powered from battery, enabling the Power Save mode is a huge battery save task.

Best Regards,

Signature · 4 lines
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)