From patchwork Tue Nov 23 19:37:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Kossifidis X-Patchwork-Id: 350511 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oANJbduj025957 for ; Tue, 23 Nov 2010 19:37:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756522Ab0KWThi (ORCPT ); Tue, 23 Nov 2010 14:37:38 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:49942 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754593Ab0KWThh (ORCPT ); Tue, 23 Nov 2010 14:37:37 -0500 Received: by eye27 with SMTP id 27so4899367eye.19 for ; Tue, 23 Nov 2010 11:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mail-followup-to:mime-version:content-type :content-disposition:user-agent; bh=IOikuNW02TXAtZ+/Sp0cSHA6Q4kqlcxmml5fROHnUpc=; b=iXiau1jd2w62UfXj+GvKUW3Uw9nlLfDttwg6XzvALmylcx8UeF1kyaCj/qRFPE35wR 4H7diNpjWGGY2x6Vr9n40zmSH4tDh/TVgNPq/vtU3vOdmjSs6awPKj72KzOJyAt9eV96 QVJwUkin67nroc7HkaEjyxDb23huklkR0TJDA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:user-agent; b=TAE3s6iOu+AXovt8HVmDq2Xc0k5Cvo10DPdx0GTxqCpR9MGMFGzRZWzOkbqIrRu+wp FQWD07TOhyklcUmtXo4pjLAcMpoJxiW2j6/c7hHif/vi+lAfAAnKPbs5E30LIrioX4AH +3FZ/z/6MjhijfUIb7t+EY4GXMabKVeU07soM= Received: by 10.14.119.129 with SMTP id n1mr5497414eeh.13.1290541056211; Tue, 23 Nov 2010 11:37:36 -0800 (PST) Received: from localhost ([139.91.73.37]) by mx.google.com with ESMTPS id v56sm6124307eeh.14.2010.11.23.11.37.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 23 Nov 2010 11:37:33 -0800 (PST) Date: Tue, 23 Nov 2010 21:37:30 +0200 From: Nick Kossifidis To: ath5k-devel@venema.h4ckr.net, linux-wireless@vger.kernel.org Cc: linville@tuxdriver.com, me@bobcopeland.com, mcgrof@gmail.com, jirislaby@gmail.com, nbd@openwrt.org, br1@einfach.org Subject: [PATCH 22/30] ath5k: Skip powertable setting when we are on the same channel Message-ID: <20101123193730.GV4303@makis.mantri> Mail-Followup-To: ath5k-devel@lists.ath5k.org, linux-wireless@vger.kernel.org, linville@tuxdriver.com, me@bobcopeland.com, mcgrof@gmail.com, jirislaby@gmail.com, nbd@openwrt.org, br1@einfach.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 23 Nov 2010 19:37:39 +0000 (UTC) diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index b908915..9392320 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c @@ -3090,7 +3090,7 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr, */ static int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, - u8 ee_mode, u8 txpower) + u8 ee_mode, u8 txpower, bool fast) { struct ath5k_rate_pcal_info rate_info; u8 type; @@ -3126,10 +3126,15 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, return -EINVAL; } - /* FIXME: Only on channel/mode change */ - ret = ath5k_setup_channel_powertable(ah, channel, ee_mode, type); - if (ret) - return ret; + /* If fast is set it means we are on the same channel/mode + * so there is no need to recalculate the powertable, we 'll + * just use the cached one */ + if (!fast) { + ret = ath5k_setup_channel_powertable(ah, channel, + ee_mode, type); + if (ret) + return ret; + } /* Limit max power if we have a CTL available */ ath5k_get_max_ctl_power(ah, channel); @@ -3210,7 +3215,7 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER, "changing txpower to %d\n", txpower); - return ath5k_hw_txpower(ah, channel, ee_mode, txpower); + return ath5k_hw_txpower(ah, channel, ee_mode, txpower, true); } /*************\ @@ -3220,13 +3225,42 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 mode, u8 ee_mode, u8 freq) { + struct ieee80211_channel *curr_channel; int ret, i; u32 phy_tst1; - + bool fast_txp; ret = 0; /* - * 5211/5212 Specific + * If we don't change channel/mode skip + * tx powertable calculation and use the + * cached one. + */ + curr_channel = ah->ah_current_channel; + if ((channel->hw_value == curr_channel->hw_value) && + (channel->center_freq == curr_channel->center_freq)) + fast_txp = true; + else + fast_txp = false; + + /* + * Set TX power + * + * Note: We need to do that before we set + * RF buffer settings on 5211/5212+ so that we + * properly set curve indices. + */ + ret = ath5k_hw_txpower(ah, channel, ee_mode, + ah->ah_txpower.txp_max_pwr / 2, + fast_txp); + if (ret) + return ret; + + /* + * For 5210 we do all initialization using + * initvals, so we don't have to modify + * any settings (5210 also only supports + * a/aturbo modes) */ if (ah->ah_version != AR5K_AR5210) { @@ -3241,21 +3275,12 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, mdelay(1); /* - * Set TX power - */ - ret = ath5k_hw_txpower(ah, channel, ee_mode, - ah->ah_txpower.txp_max_pwr / 2); - if (ret) - return ret; - - /* * Write RF buffer */ ret = ath5k_hw_rfregs_init(ah, channel, mode); if (ret) return ret; - /* Write OFDM timings on 5212*/ if (ah->ah_version == AR5K_AR5212 && channel->hw_value & CHANNEL_OFDM) { @@ -3284,12 +3309,6 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, } } else { - /* - * For 5210 we do all initialization using - * initvals, so we don't have to modify - * any settings (5210 also only supports - * a/aturbo modes) - */ mdelay(1); /* Disable phy and wait */ ath5k_hw_reg_write(ah, AR5K_PHY_ACT_DISABLE, AR5K_PHY_ACT);