From patchwork Wed Mar 22 19:42:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 9639921 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 5EC8E6020B for ; Wed, 22 Mar 2017 19:44:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53EA328420 for ; Wed, 22 Mar 2017 19:44:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4867B28471; Wed, 22 Mar 2017 19:44:26 +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=ham 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 43B6828420 for ; Wed, 22 Mar 2017 19:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759800AbdCVToX (ORCPT ); Wed, 22 Mar 2017 15:44:23 -0400 Received: from nbd.name ([46.4.11.11]:42744 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965959AbdCVTmo (ORCPT ); Wed, 22 Mar 2017 15:42:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Message-Id:Date:Subject:Cc:To:From; bh=Bl2GtZUFzYC+wWl0iXPhrn64HNxj446ndmgDNDoNVQ0=; b=SGz3h2ukbODtQH/eYAWwDqAuEY5zGUeq92h73rFNYcdUeuJljiVQv/QIa6RDRJM1gp2P9YhdppI/pmTEbRgGGuKfxmCLJGMbGBEmxiyCyCnX9ocl4y/mDGN8Tr6KDCvSFVob51dPKej/w8sZSa2/Pq3uAGG25aBSe5Nz3TA0FnI=; Received: by nf-4.local (Postfix, from userid 501) id 26DB719B58A66; Wed, 22 Mar 2017 20:42:41 +0100 (CET) From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: kvalo@codeaurora.org, stable@vger.kernel.org Subject: [PATCH] ath9k_hw: fix channel maximum power level test Date: Wed, 22 Mar 2017 20:42:40 +0100 Message-Id: <20170322194240.1488-1-nbd@nbd.name> X-Mailer: git-send-email 2.11.0 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 The tx power applied by set_txpower is limited by the CTL (conformance test limit) entries in the EEPROM. These can change based on the user configured regulatory domain. Depending on the EEPROM data this can cause the tx power to become too limited, if the original regdomain CTLs impose lowr limits than the CTLs of the user configured regdomain. To fix this issue, set the initial channel limits without any CTL restrictions and only apply the CTL at run time when setting the channel and the real tx power. Cc: stable@vger.kernel.org Signed-off-by: Felix Fietkau --- drivers/net/wireless/ath/ath9k/hw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 17ca60482b5f..3346cbf63b9c 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2937,10 +2937,14 @@ void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan, struct ieee80211_channel *channel; int chan_pwr, new_pwr, max_gain; int ant_gain, ant_reduction = 0; + u16 ctl = NO_CTL; if (!chan) return; + if (!test) + ctl = ath9k_regd_get_ctl(reg, chan); + channel = chan->chan; chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER); new_pwr = min_t(int, chan_pwr, reg->power_limit); @@ -2950,9 +2954,7 @@ void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan, if (ant_gain > max_gain) ant_reduction = ant_gain - max_gain; - ah->eep_ops->set_txpower(ah, chan, - ath9k_regd_get_ctl(reg, chan), - ant_reduction, new_pwr, test); + ah->eep_ops->set_txpower(ah, chan, ctl, ant_reduction, new_pwr, test); } void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)