From patchwork Wed Jun 26 09:02:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan periyasamy X-Patchwork-Id: 11017269 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-2.web.codeaurora.org (Postfix) with ESMTP id 42C881398 for ; Wed, 26 Jun 2019 09:02:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EBF428684 for ; Wed, 26 Jun 2019 09:02:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22CBB286F6; Wed, 26 Jun 2019 09:02:40 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A807828684 for ; Wed, 26 Jun 2019 09:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=NxpRqLKMKTgq5mMFXCqFjNciyWiasyv04FMZ1JwOxA8=; b=qn7 ohoe0PDoSs5x05z86C/aPThQE0/cd4MKzT1z+dOEkw9ULP7nuzIttcmCV3tf160PDleh40pWyROmM fmGoGpAM+ddoZnqPvy10vusrnmiDU0YFiEQueMp6mIWaxlO2IGTVib/sfH2C/EFhCB0q7gHRAe7hg LyOlLwyRgM6LWRKF/T4bVzilwwVOJKfo+GnEu4QhtqAxRdpoQl1Fz+s/mVdb7xAa5WyOmGQSGo06y jBLKL/0jgY6TsOQSdKQiQkGyvxxgjIxnI+TD7ik9ng+dPvjFjfmOgy9d/mhEYf2Gn84ho+mgJSCY/ Vsw0IVpBHy4vYejyXlFMMOJFzKC/B3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hg3p7-0000XW-6O; Wed, 26 Jun 2019 09:02:37 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hg3oz-0000WA-Jh for ath11k@lists.infradead.org; Wed, 26 Jun 2019 09:02:35 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9B8EC60A33; Wed, 26 Jun 2019 09:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561539748; bh=+AENVN4s1HA1lx4tyOCrG7lLLGGu7SdsxlXe0KHLiiE=; h=From:To:Cc:Subject:Date:From; b=b25RcbqmcUv0mGyzFmZPzx5KXU1rItu0Oe+XXaSxcGGzJbqQoS6FYwhqET/2+i2Bl mfHhLWjEvxHzHivkc15eOkbg+wv1wbo+B1z7jOQSyWB6i012NRGbfb5kMsw5NAS6nK OghsxPuVHirrtSyLP9YfggePVwQPCOmOYwZSvw4A= Received: from CHECSTP284781-LIN.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: periyasa@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3696C601E7; Wed, 26 Jun 2019 09:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561539748; bh=+AENVN4s1HA1lx4tyOCrG7lLLGGu7SdsxlXe0KHLiiE=; h=From:To:Cc:Subject:Date:From; b=b25RcbqmcUv0mGyzFmZPzx5KXU1rItu0Oe+XXaSxcGGzJbqQoS6FYwhqET/2+i2Bl mfHhLWjEvxHzHivkc15eOkbg+wv1wbo+B1z7jOQSyWB6i012NRGbfb5kMsw5NAS6nK OghsxPuVHirrtSyLP9YfggePVwQPCOmOYwZSvw4A= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3696C601E7 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=periyasa@codeaurora.org From: Karthikeyan Periyasamy To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: avoid inappropriate data lock Date: Wed, 26 Jun 2019 14:32:05 +0530 Message-Id: <1561539725-24438-1-git-send-email-periyasa@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190626_020234_371319_25FDAC3F X-CRM114-Status: GOOD ( 11.03 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Karthikeyan Periyasamy MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP peer data should protected by the ath11k_base data_lock not by the ath11k data_lock. so lock the ath11k_base data_lock before accessing ath11k_peer_find(). Signed-off-by: Karthikeyan Periyasamy --- drivers/net/wireless/ath/ath11k/mac.c | 40 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 1a4a333..f30b2df 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -2095,6 +2095,7 @@ static int ath11k_clear_peer_keys(struct ath11k_vif *arvif, const u8 *addr) { struct ath11k *ar = arvif->ar; + struct ath11k_base *ab = ar->ab; struct ath11k_peer *peer; int first_errno = 0; int ret; @@ -2103,9 +2104,9 @@ static int ath11k_clear_peer_keys(struct ath11k_vif *arvif, lockdep_assert_held(&ar->conf_mutex); - spin_lock_bh(&ar->data_lock); - peer = ath11k_peer_find(ar->ab, arvif->vdev_id, addr); - spin_unlock_bh(&ar->data_lock); + spin_lock_bh(&ab->data_lock); + peer = ath11k_peer_find(ab, arvif->vdev_id, addr); + spin_unlock_bh(&ab->data_lock); if (!peer) return -ENOENT; @@ -2121,12 +2122,12 @@ static int ath11k_clear_peer_keys(struct ath11k_vif *arvif, first_errno = ret; if (ret < 0) - ath11k_warn(ar->ab, "failed to remove peer key %d: %d\n", + ath11k_warn(ab, "failed to remove peer key %d: %d\n", i, ret); - spin_lock_bh(&ar->data_lock); + spin_lock_bh(&ab->data_lock); peer->keys[i] = NULL; - spin_unlock_bh(&ar->data_lock); + spin_unlock_bh(&ab->data_lock); } return first_errno; @@ -2137,6 +2138,7 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_key_conf *key) { struct ath11k *ar = hw->priv; + struct ath11k_base *ab = ar->ab; struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); struct ath11k_peer *peer; const u8 *peer_addr; @@ -2167,13 +2169,13 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, /* the peer should not disappear in mid-way (unless FW goes awry) since * we already hold conf_mutex. we just make sure its there now. */ - spin_lock_bh(&ar->data_lock); - peer = ath11k_peer_find(ar->ab, arvif->vdev_id, peer_addr); - spin_unlock_bh(&ar->data_lock); + spin_lock_bh(&ab->data_lock); + peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr); + spin_unlock_bh(&ab->data_lock); if (!peer) { if (cmd == SET_KEY) { - ath11k_warn(ar->ab, "cannot install key for non-existent peer %pM\n", + ath11k_warn(ab, "cannot install key for non-existent peer %pM\n", peer_addr); ret = -EOPNOTSUPP; goto exit; @@ -2192,20 +2194,20 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = ath11k_install_key(arvif, key, cmd, peer_addr, flags); if (ret) { - ath11k_warn(ar->ab, "ath11k_install_key failed (%d)\n", ret); + ath11k_warn(ab, "ath11k_install_key failed (%d)\n", ret); goto exit; } - spin_lock_bh(&ar->data_lock); - peer = ath11k_peer_find(ar->ab, arvif->vdev_id, peer_addr); + spin_lock_bh(&ab->data_lock); + peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr); if (peer && cmd == SET_KEY) peer->keys[key->keyidx] = key; else if (peer && cmd == DISABLE_KEY) peer->keys[key->keyidx] = NULL; else if (!peer) /* impossible unless FW goes crazy */ - ath11k_warn(ar->ab, "peer %pM disappeared!\n", peer_addr); - spin_unlock_bh(&ar->data_lock); + ath11k_warn(ab, "peer %pM disappeared!\n", peer_addr); + spin_unlock_bh(&ab->data_lock); exit: mutex_unlock(&ar->conf_mutex); @@ -2669,21 +2671,25 @@ static void ath11k_mac_op_sta_rc_update(struct ieee80211_hw *hw, struct ath11k_peer *peer; u32 bw, smps; - spin_lock_bh(&ar->data_lock); + spin_lock_bh(&ar->ab->data_lock); peer = ath11k_peer_find(ar->ab, arvif->vdev_id, sta->addr); if (!peer) { - spin_unlock_bh(&ar->data_lock); + spin_unlock_bh(&ar->ab->data_lock); ath11k_warn(ar->ab, "mac sta rc update failed to find peer %pM on vdev %i\n", sta->addr, arvif->vdev_id); return; } + spin_unlock_bh(&ar->ab->data_lock); + ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac sta rc update for %pM changed %08x bw %d nss %d smps %d\n", sta->addr, changed, sta->bandwidth, sta->rx_nss, sta->smps_mode); + spin_lock_bh(&ar->data_lock); + if (changed & IEEE80211_RC_BW_CHANGED) { bw = WMI_PEER_CHWIDTH_20MHZ;