From patchwork Wed Jun 3 10:16:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6533861 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 42FE69F1CC for ; Wed, 3 Jun 2015 10:17:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F514206B1 for ; Wed, 3 Jun 2015 10:17:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56E15206A9 for ; Wed, 3 Jun 2015 10:17:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z05jz-0004c4-55; Wed, 03 Jun 2015 10:17:43 +0000 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z05jv-0004UW-JX for ath10k@lists.infradead.org; Wed, 03 Jun 2015 10:17:41 +0000 Received: by wibut5 with SMTP id ut5so97175567wib.1 for ; Wed, 03 Jun 2015 03:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id; bh=bxEgkJWrsQ0jK5t3sl7qIG50MSu8bBpJAOnwWqcgsE8=; b=cmp7LVKiKDz3vgQpJmVRdvmqnZKTBACqtWmAAPWacmJc+eoSszdCfVuubnjS4iS7pX Lc/O5/F4ZQ3wTLk9rLPP7pbgv40Y4hYkCLfJFdJrYGjYmX79Rf4qPk00aLy2U7PWvZOW QetOqwSCozTd/U9HOnKqgBAZLQZBZUmfGioE8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bxEgkJWrsQ0jK5t3sl7qIG50MSu8bBpJAOnwWqcgsE8=; b=OE9Bw47qEkrQpmMhsAaSLTyzOKRS+Wmg0EbV9BN3HHZPWikxGmVVnl6TJBMBMnP1xC izznVJD1GPzy/gLBPE43NTgyk1suEe4cecVSnkTFWXM8YSD6LDfBQAbHCQ/VsfQMWfMI W0mw9XzCc3JWN+2y2s1JubkU4+nutXeqGgyo8i2kk770faPp0Z/RrpBRSwNdXC0iq2Uk h47QVfcDal7vxKUWxT9OMrU2/t+jeMES7G7VYFN4UWkH9IFhkKHDjFg9A2I+7hWAsRJ0 pCkf2BN66ck0AXnKmtvhUTuaY8llL/x8BmA9Zdp+7g/KOwskQ+bHKMfgZHbLvucLCQ8c BDrA== X-Gm-Message-State: ALoCoQn2fO+GBGW/HiL+nZ7xLvwwXjiqHxihePnxx0IcRH8ZafZSU6lbw4zKZw0AQRTO/roqlScp2fiMWpim0rHvX0bhheZmjbTJiyRNz1leEgTkT8QtqHPcx7YPRMzEQOyktXYUb0BUoNUu++THFsY6luQXm/N5ReHS/O30DryP5FZXsoYVuiT9frxetvGoHwG6nLoz8DVn X-Received: by 10.194.205.37 with SMTP id ld5mr61077614wjc.14.1433326635296; Wed, 03 Jun 2015 03:17:15 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id pd7sm348804wjb.27.2015.06.03.03.17.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jun 2015 03:17:14 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Subject: [PATCH 1/3] ath10k: fix ar->rx_channel updating logic Date: Wed, 3 Jun 2015 12:16:54 +0200 Message-Id: <1433326616-23279-1-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150603_031739_851534_239A7622 X-CRM114-Status: GOOD ( 12.18 ) X-Spam-Score: -0.8 (/) Cc: linux-wireless@vger.kernel.org, Michal Kazior X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Channel contexts aren't iterable until after they've been added to the driver. The code assumed otherwise. This problem could result in: * rx_channel being NULL and forcing Rx path to go the slow way to get channel on QCA988X, * report incorrect channel when running multi-channel on QCA61X4 hw2.1, * report incorrect channel after AP channel switch. Fixes: 500ff9f9389d ("ath10k: implement chanctx API") Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/mac.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index f4de71721f7d..fe53b1f5e6c9 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -6144,7 +6144,10 @@ static int ath10k_ampdu_action(struct ieee80211_hw *hw, } static void -ath10k_mac_update_rx_channel(struct ath10k *ar) +ath10k_mac_update_rx_channel(struct ath10k *ar, + struct ieee80211_chanctx_conf *ctx, + struct ieee80211_vif_chanctx_switch *vifs, + int n_vifs) { struct cfg80211_chan_def *def = NULL; @@ -6154,6 +6157,9 @@ ath10k_mac_update_rx_channel(struct ath10k *ar) lockdep_assert_held(&ar->conf_mutex); lockdep_assert_held(&ar->data_lock); + WARN_ON(ctx && vifs); + WARN_ON(vifs && n_vifs != 1); + /* FIXME: Sort of an optimization and a workaround. Peers and vifs are * on a linked list now. Doing a lookup peer -> vif -> chanctx for each * ppdu on Rx may reduce performance on low-end systems. It should be @@ -6165,11 +6171,17 @@ ath10k_mac_update_rx_channel(struct ath10k *ar) * affected much. */ rcu_read_lock(); - if (ath10k_mac_num_chanctxs(ar) == 1) { + if (!ctx && ath10k_mac_num_chanctxs(ar) == 1) { ieee80211_iter_chan_contexts_atomic(ar->hw, ath10k_mac_get_any_chandef_iter, &def); + + if (vifs) + def = &vifs[0].new_ctx->def; + ar->rx_channel = def->chan; + } else if (ctx && ath10k_mac_num_chanctxs(ar) == 0) { + ar->rx_channel = ctx->def.chan; } else { ar->rx_channel = NULL; } @@ -6204,7 +6216,7 @@ ath10k_mac_op_add_chanctx(struct ieee80211_hw *hw, spin_lock_bh(&ar->data_lock); ath10k_mac_chan_ctx_init(ar, arctx, ctx); - ath10k_mac_update_rx_channel(ar); + ath10k_mac_update_rx_channel(ar, ctx, NULL, 0); spin_unlock_bh(&ar->data_lock); ath10k_recalc_radar_detection(ar); @@ -6228,7 +6240,7 @@ ath10k_mac_op_remove_chanctx(struct ieee80211_hw *hw, mutex_lock(&ar->conf_mutex); spin_lock_bh(&ar->data_lock); - ath10k_mac_update_rx_channel(ar); + ath10k_mac_update_rx_channel(ar, NULL, NULL, 0); spin_unlock_bh(&ar->data_lock); ath10k_recalc_radar_detection(ar); @@ -6413,7 +6425,7 @@ ath10k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw, */ arctx_old->conf = *vifs[i].new_ctx; } - ath10k_mac_update_rx_channel(ar); + ath10k_mac_update_rx_channel(ar, NULL, vifs, n_vifs); spin_unlock_bh(&ar->data_lock); /* FIXME: Reconfigure only affected vifs */