From patchwork Mon Dec 11 08:52:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10104441 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7B5D605D2 for ; Mon, 11 Dec 2017 08:52:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0B029473 for ; Mon, 11 Dec 2017 08:52:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFD73294D1; Mon, 11 Dec 2017 08:52:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86092294D0 for ; Mon, 11 Dec 2017 08:52:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbdLKIw1 (ORCPT ); Mon, 11 Dec 2017 03:52:27 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40403 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751347AbdLKIw0 (ORCPT ); Mon, 11 Dec 2017 03:52:26 -0500 Received: by mail-wm0-f68.google.com with SMTP id f206so12523823wmf.5 for ; Mon, 11 Dec 2017 00:52:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=eLFivrSYYVhHtSHu4xh6cT0saPR30FDsFm3039vDWYU=; b=QnJQMOOy1UXxyyMduL4uxnQudj1vZ5yat7qjdKd7PDaJvtRz8e8vkpPQssBkGQF9c0 ANYZST1Y2GYgecKBv2Ppc7xsR0EFFikP3JjuJz4dLPw6EGScPQdspbWyORDu86bCvZtX zqgujJECLF//257dSNUeGLk4wV/tZ0oTR+9Eg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eLFivrSYYVhHtSHu4xh6cT0saPR30FDsFm3039vDWYU=; b=NKbMO0oOnoTfASun55latvfwxh2akXTjCu7eUrR4Y8jSJamKW1Zr3fE235eHf4h7YQ bFZH1tBLX1XeD3A8ql+zJYtaWDYB3TnXzLNztDwjxAwkiLP/FANTmO613X1FBeUw1RL8 rjtr4dG7/2lBSM1OxqqVAD8QvGzEdiQ8dGSifWDlFpyTeWs3uS+tu05MkSmcZTxkAhy6 L3ExhfEQ8fzhfTdyYN5e3hgYxH6gsPLtWj/FhgXiFOztjpcsVdNFiB45K9Hu7wRVI1pJ RgZDBd0tE0ymE2Be3HAPcAw0/KuJzhAhNshvkNv+eKdODb/+jAlBJ+/9ibOeW78XtBrj VNpw== X-Gm-Message-State: AKGB3mJMhgNqVtKd2bv5rldftGLhGBpowfvvZ8NJuNjHmJ/H7d/w4gSi 5qX6zrcE0NJlEAH5Ce98q8mRHg== X-Google-Smtp-Source: ACJfBotsKy26SA4F9HMK7oji/OS8BhadnbV/J8xDEzfsD+LQ4dMdFvITm6KL7BPP/oC6bQyfB/O5dA== X-Received: by 10.28.213.79 with SMTP id m76mr73269wmg.67.1512982344796; Mon, 11 Dec 2017 00:52:24 -0800 (PST) Received: from localhost.localdomain (LFbn-1-2062-11.w90-76.abo.wanadoo.fr. [90.76.129.11]) by smtp.gmail.com with ESMTPSA id o10sm15798723wrg.5.2017.12.11.00.52.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 00:52:24 -0800 (PST) From: Loic Poulain To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, linux-arm-msm@vger.kernel.org, k.eugene.e@gmail.com, bjorn.andersson@linaro.org, Loic Poulain Subject: [PATCH v2] wcn36xx: Fix dynamic power saving Date: Mon, 11 Dec 2017 09:52:22 +0100 Message-Id: <1512982342-10343-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since driver does not report hardware dynamic power saving cap, this is up to the mac80211 to manage power saving timeout and state machine, using the ieee80211 config callback to report PS changes. This patch enables/disables PS mode according to the new configuration. Remove old behaviour enabling PS mode in a static way, this make the device unusable when power save is enabled since device is forced to PS regardless RX/TX traffic. Acked-by: Bjorn Andersson Signed-off-by: Loic Poulain --- v2: remove error msg on unbalanced bmps exit return -EALREADY if not in bmps mode drivers/net/wireless/ath/wcn36xx/main.c | 23 ++++++++++++----------- drivers/net/wireless/ath/wcn36xx/pmc.c | 6 ++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index f0b4d43..436b8ea 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -384,6 +384,18 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed) } } + if (changed & IEEE80211_CONF_CHANGE_PS) { + list_for_each_entry(tmp, &wcn->vif_list, list) { + vif = wcn36xx_priv_to_vif(tmp); + if (hw->conf.flags & IEEE80211_CONF_PS) { + if (vif->bss_conf.ps) /* ps allowed ? */ + wcn36xx_pmc_enter_bmps_state(wcn, vif); + } else { + wcn36xx_pmc_exit_bmps_state(wcn, vif); + } + } + } + mutex_unlock(&wcn->conf_mutex); return 0; @@ -747,17 +759,6 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw, vif_priv->dtim_period = bss_conf->dtim_period; } - if (changed & BSS_CHANGED_PS) { - wcn36xx_dbg(WCN36XX_DBG_MAC, - "mac bss PS set %d\n", - bss_conf->ps); - if (bss_conf->ps) { - wcn36xx_pmc_enter_bmps_state(wcn, vif); - } else { - wcn36xx_pmc_exit_bmps_state(wcn, vif); - } - } - if (changed & BSS_CHANGED_BSSID) { wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss changed_bssid %pM\n", bss_conf->bssid); diff --git a/drivers/net/wireless/ath/wcn36xx/pmc.c b/drivers/net/wireless/ath/wcn36xx/pmc.c index 589fe5f..1976b80 100644 --- a/drivers/net/wireless/ath/wcn36xx/pmc.c +++ b/drivers/net/wireless/ath/wcn36xx/pmc.c @@ -45,8 +45,10 @@ int wcn36xx_pmc_exit_bmps_state(struct wcn36xx *wcn, struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); if (WCN36XX_BMPS != vif_priv->pw_state) { - wcn36xx_err("Not in BMPS mode, no need to exit from BMPS mode!\n"); - return -EINVAL; + /* Unbalanced call or last BMPS enter failed */ + wcn36xx_dbg(WCN36XX_DBG_PMC, + "Not in BMPS mode, no need to exit\n"); + return -EALREADY; } wcn36xx_smd_exit_bmps(wcn, vif); vif_priv->pw_state = WCN36XX_FULL_POWER;