From patchwork Wed Jan 20 07:41:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 8069571 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8088ABEEE5 for ; Wed, 20 Jan 2016 07:42:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A691F203A9 for ; Wed, 20 Jan 2016 07:42:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9940020320 for ; Wed, 20 Jan 2016 07:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933338AbcATHmx (ORCPT ); Wed, 20 Jan 2016 02:42:53 -0500 Received: from glaubenleben.de ([85.214.105.140]:44648 "EHLO glaubenleben.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbcATHmv (ORCPT ); Wed, 20 Jan 2016 02:42:51 -0500 Received: from [176.0.132.194] (helo=localhost) by glaubenleben.de with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1aLnPW-0007tk-U7; Wed, 20 Jan 2016 08:42:35 +0100 Received: from andi by localhost with local (Exim 4.84) (envelope-from ) id 1aLnP2-00071Z-Dt; Wed, 20 Jan 2016 08:42:04 +0100 From: Andreas Kemnade To: kvalo@codeaurora.org, libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, hns@goldelico.com Cc: Andreas Kemnade Subject: [PATCH RFC] wireless:libertas: enable auto deep sleep Date: Wed, 20 Jan 2016 08:41:49 +0100 Message-Id: <1453275709-25276-1-git-send-email-andreas@kemnade.info> X-Mailer: git-send-email 2.1.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enables auto deep sleep whenever the interface is up and power managament is enabled, so there is also power management when there is no connection That reduces power consumption between scanning intervals. Deep sleep mode is entered when there is no activity for 1s. The code looks a bit different to how things were done with the wext interface in earlier times. Signed-off-by: Andreas Kemnade --- drivers/net/wireless/libertas/cfg.c | 3 +++ drivers/net/wireless/libertas/main.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index fd18d03..bb6d8fd 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c @@ -2066,6 +2066,7 @@ int lbs_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, lbs_set_ps_mode(priv, PS_MODE_ACTION_EXIT_PS, true); + lbs_exit_auto_deep_sleep(priv); return 0; } if (priv->psmode != LBS802_11POWERMODECAM) @@ -2073,6 +2074,8 @@ int lbs_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, priv->psmode = LBS802_11POWERMODEMAX_PSP; if (priv->connect_status == LBS_CONNECTED) lbs_set_ps_mode(priv, PS_MODE_ACTION_ENTER_PS, true); + priv->auto_deep_sleep_timeout = 1000; /* 1000ms */ + lbs_enter_auto_deep_sleep(priv); return 0; } diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index b35b8bc..82e69ca 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c @@ -161,6 +161,11 @@ int lbs_start_iface(struct lbs_private *priv) lbs_update_channel(priv); priv->iface_running = true; + /* if deep sleep was enabled before + * the interface was brought down, reenable it + */ + if (priv->is_auto_deep_sleep_enabled) + lbs_enter_auto_deep_sleep(priv); return 0; err: @@ -227,6 +232,10 @@ int lbs_stop_iface(struct lbs_private *priv) cancel_work_sync(&priv->mcast_work); del_timer_sync(&priv->tx_lockup_timer); + /* autosleep should not mess with commands + * when the interface is powered down + */ + del_timer_sync(&priv->auto_deepsleep_timer); /* Disable command processing, and wait for all commands to complete */ lbs_deb_main("waiting for commands to complete\n"); @@ -824,7 +833,8 @@ static void auto_deepsleep_timer_fn(unsigned long data) } else { if (priv->is_auto_deep_sleep_enabled && (!priv->wakeup_dev_required) && - (priv->connect_status != LBS_CONNECTED)) { + (priv->connect_status != LBS_CONNECTED) && + priv->iface_running) { struct cmd_header cmd; lbs_deb_main("Entering auto deep sleep mode...\n");