From patchwork Tue Dec 28 21:14:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700616 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C30AEC433EF for ; Tue, 28 Dec 2021 21:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237398AbhL1VPZ (ORCPT ); Tue, 28 Dec 2021 16:15:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236376AbhL1VPV (ORCPT ); Tue, 28 Dec 2021 16:15:21 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF85C061574; Tue, 28 Dec 2021 13:15:21 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id b186-20020a1c1bc3000000b00345734afe78so10744336wmb.0; Tue, 28 Dec 2021 13:15:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SEMbs8uawFQ22g6pe5+yochD9fdd3KiYBmK2xcx9DT0=; b=OBJtompVYgj2tIy1ENvuYYRwZTT/I9of98emtNzcJE2Z0bc+u2dHTX7IwrD2Igxaq8 ZhQPLEE3gE+7RRzbncDF6LKeuJFs2ZslxzQw75HgFpOGpLBpeXNBkrmKbpU7MSVRFcoR I9cSjlgIh0s2FTMn8gahEGjbkM8a99wEUmkk16Ic2eAgpmB05aiC5SZl3H7XhnfYM4qQ Xy2XZtEAYp/ElqECmDdPhAvVb/HoQifpxG3qV2y7tTldRqoG5tiGhhAm1TmAPCr2RpBk Ztjfqq+2bnshnB4DmN4vgMvwvwqZruu46KGTytfuKXJwCbXc5ORUYCC4iSgAHq5do8yG g1jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SEMbs8uawFQ22g6pe5+yochD9fdd3KiYBmK2xcx9DT0=; b=xuhA6G64MvtiCgZKv15O0yccjBf7DK1rzyKTrUskxsUqByj7vsUsACRi50M84W7wRS nNA7bJaC+m/AO+zEz5YWZeasmaTDorphbJkgzMr5WQ7VIokfgN0wAr7ZA2ASzEMIItix OADfXmp1Lrt1LP8LKwrHwJTAw71NUNRhMJfRo3XdIQUkssqm4+wnqBNuRCYJBTUpZICM UedRWVfHh6zzN06/fHgLYRTVgNYRGXTWs0fx0iLEu04FRH9bf72HLyBc5jsb1gf7mC/0 Em+n7NkkJ/tA9bX2v0aFW5mKiEx4VzdHHjH/a97HiwVTWPFwDSLbq7Irz+24BiHq481A WRWA== X-Gm-Message-State: AOAM532q1aM7/OU8MIwGGxa5B/8bXvwpXdB1SQLNwCw3ovDE9XokiINI vGISlGamaJMqnH2Bq2Vn0kRg6ECd9pk= X-Google-Smtp-Source: ABdhPJwtZrewBBGpSnxq9D2Flyk9gtz7au9JRe7U0I1v7bEqPXPOk9C14Uftz8XD8+zDe3Z1fip7Aw== X-Received: by 2002:a7b:c00d:: with SMTP id c13mr6913816wmb.99.1640726119608; Tue, 28 Dec 2021 13:15:19 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:19 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 1/9] mac80211: Add stations iterator where the iterator function may sleep Date: Tue, 28 Dec 2021 22:14:53 +0100 Message-Id: <20211228211501.468981-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ieee80211_iterate_active_interfaces() and ieee80211_iterate_active_interfaces_atomic() already exist, where the former allows the iterator function to sleep. Add ieee80211_iterate_stations() which is similar to ieee80211_iterate_stations_atomic() but allows the iterator to sleep. This is needed for adding SDIO support to the rtw88 driver. Some interators there are reading or writing registers. With the SDIO ops (sdio_readb, sdio_writeb and friends) this means that the iterator function may sleep. Signed-off-by: Martin Blumenstingl --- v1 -> v2: - fixed kernel doc copy & paste (remove _atomic) as suggested by Ping-Ke and Johannes - added paragraph about driver authors having to be careful where they use this new function as suggested by Johannes include/net/mac80211.h | 21 +++++++++++++++++++++ net/mac80211/util.c | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 8907338d52b5..c50221d7e82c 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -5614,6 +5614,9 @@ void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, * This function iterates over the interfaces associated with a given * hardware that are currently active and calls the callback for them. * This version can only be used while holding the wiphy mutex. + * The driver must not call this with a lock held that it can also take in + * response to callbacks from mac80211, and it must not call this within + * callbacks made by mac80211 - both would result in deadlocks. * * @hw: the hardware struct of which the interfaces should be iterated over * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags @@ -5627,6 +5630,24 @@ void ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw, struct ieee80211_vif *vif), void *data); +/** + * ieee80211_iterate_stations - iterate stations + * + * This function iterates over all stations associated with a given + * hardware that are currently uploaded to the driver and calls the callback + * function for them. + * This function allows the iterator function to sleep, when the iterator + * function is atomic @ieee80211_iterate_stations_atomic can be used. + * + * @hw: the hardware struct of which the interfaces should be iterated over + * @iterator: the iterator function to call, cannot sleep + * @data: first argument of the iterator function + */ +void ieee80211_iterate_stations(struct ieee80211_hw *hw, + void (*iterator)(void *data, + struct ieee80211_sta *sta), + void *data); + /** * ieee80211_iterate_stations_atomic - iterate stations * diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 0e4e1956bcea..f71b042a5c8b 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -862,6 +862,19 @@ static void __iterate_stations(struct ieee80211_local *local, } } +void ieee80211_iterate_stations(struct ieee80211_hw *hw, + void (*iterator)(void *data, + struct ieee80211_sta *sta), + void *data) +{ + struct ieee80211_local *local = hw_to_local(hw); + + mutex_lock(&local->sta_mtx); + __iterate_stations(local, iterator, data); + mutex_unlock(&local->sta_mtx); +} +EXPORT_SYMBOL_GPL(ieee80211_iterate_stations); + void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, void (*iterator)(void *data, struct ieee80211_sta *sta), From patchwork Tue Dec 28 21:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700618 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F2FDC4167B for ; Tue, 28 Dec 2021 21:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237420AbhL1VP1 (ORCPT ); Tue, 28 Dec 2021 16:15:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236394AbhL1VPW (ORCPT ); Tue, 28 Dec 2021 16:15:22 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17ADDC06173E; Tue, 28 Dec 2021 13:15:22 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id a203-20020a1c7fd4000000b003457874263aso13402385wmd.2; Tue, 28 Dec 2021 13:15:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SM7IJAA3tcUmFTUnWjNYesUcXf6+3Mf9PHZAoA83J4U=; b=QZ+8HAuXGBgfsak4gck5ckM7OeD3E9/AGDswNzIk917HFY8+h3ct8wFVKyxvdSuNZd Ow7IkbGTpEEt4yOp15JDUKFUTHLNwpsPEmKW5T+ccYjwrQAywAitzp5pgmiZ2LEw6qLU cmXMawG20NILd1KwaCqmHpjQRxbnWMBdRyLHReDeXUyEVAL+sd5iY95e1w/d22zTfqkV EDg7IfiGBhosrRBXIpvRxQNfxi5EtBBRAftkaPasIuEN33LT9Aj43nRHBHZggrL+uyzV 3qtsYkKivC3s+V0/ml4llPkZMFR4qdQOrgLnJ0QWB4EbwFFsL8qrQpT7G+DGJIBgzhFb TFRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SM7IJAA3tcUmFTUnWjNYesUcXf6+3Mf9PHZAoA83J4U=; b=ESqvB03OSVk6/XhKEarfRU5Npm/dqgW+Lqb9HW2V0g4cj2HaUA8xtSb6gSAsibUePq gJng+YLFNXSgeYbYNqrsDlXMniOThc2bsEGpj926C6Jvg05XKd48vs4kBz1eIHJgYrYb xNzAHf9bt87Fid+NHrRvfXvFxQ3vkUndA00rgJsA3qpgPdutSnhMJ2cviUGykKwgGsL5 9fWOgBys4V49n3UOF0kHnwGmxoHNSM4PIBxwWh+0OIaIR3e+IKc4uZI6jOIDVOBui2G8 PuiYkbZZGbItuSzVLYQrUjhMFl2sMGx0KQAyej7DkH0ToETGEM9PkTP/rkAfNfFAyhy6 f1gA== X-Gm-Message-State: AOAM530q1WsOHWxwbVJ08H8evDKi76TPq1VJ20yHQ1msZtFi1BAA4f+k 6xA/+nUKz7wB+YyZrdT0uctZSUQvakQ= X-Google-Smtp-Source: ABdhPJxtQTWB/yWQnfM47HkjuOCWuTBJe2oNf7zVW6g32iRMzXm/TQ7OiZsPScm//M6kKOKFPzTJcQ== X-Received: by 2002:a05:600c:354c:: with SMTP id i12mr17535444wmq.139.1640726120430; Tue, 28 Dec 2021 13:15:20 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:20 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 2/9] rtw88: Move rtw_chip_cfg_csi_rate() out of rtw_vif_watch_dog_iter() Date: Tue, 28 Dec 2021 22:14:54 +0100 Message-Id: <20211228211501.468981-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org rtw_bf_cfg_csi_rate() internally access some registers while being called unter an atomic lock acquired by rtw_iterate_vifs_atomic(). Move the rtw_bf_cfg_csi_rate() call out of rtw_vif_watch_dog_iter() in preparation for SDIO support where register access may sleep. Signed-off-by: Martin Blumenstingl --- v1 -> v2: - this patch is new in v2 - keep rtw_iterate_vifs_atomic() to not undo the fix from commit 5b0efb4d670c8 ("rtw88: avoid circular locking between local->iflist_mtx and rtwdev->mutex") and instead call rtw_bf_cfg_csi_rate() from rtw_watch_dog_work() (outside the atomic section) as suggested by Ping-Ke. drivers/net/wireless/realtek/rtw88/main.c | 35 +++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 38252113c4a8..fd02c0b0025a 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -144,26 +144,9 @@ static struct ieee80211_supported_band rtw_band_5ghz = { struct rtw_watch_dog_iter_data { struct rtw_dev *rtwdev; struct rtw_vif *rtwvif; + bool cfg_csi_rate; }; -static void rtw_dynamic_csi_rate(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif) -{ - struct rtw_bf_info *bf_info = &rtwdev->bf_info; - u8 fix_rate_enable = 0; - u8 new_csi_rate_idx; - - if (rtwvif->bfee.role != RTW_BFEE_SU && - rtwvif->bfee.role != RTW_BFEE_MU) - return; - - rtw_chip_cfg_csi_rate(rtwdev, rtwdev->dm_info.min_rssi, - bf_info->cur_csi_rpt_rate, - fix_rate_enable, &new_csi_rate_idx); - - if (new_csi_rate_idx != bf_info->cur_csi_rpt_rate) - bf_info->cur_csi_rpt_rate = new_csi_rate_idx; -} - static void rtw_vif_watch_dog_iter(void *data, u8 *mac, struct ieee80211_vif *vif) { @@ -174,7 +157,8 @@ static void rtw_vif_watch_dog_iter(void *data, u8 *mac, if (vif->bss_conf.assoc) iter_data->rtwvif = rtwvif; - rtw_dynamic_csi_rate(iter_data->rtwdev, rtwvif); + iter_data->cfg_csi_rate = rtwvif->bfee.role == RTW_BFEE_SU || + rtwvif->bfee.role == RTW_BFEE_MU; rtwvif->stats.tx_unicast = 0; rtwvif->stats.rx_unicast = 0; @@ -241,6 +225,19 @@ static void rtw_watch_dog_work(struct work_struct *work) /* use atomic version to avoid taking local->iflist_mtx mutex */ rtw_iterate_vifs_atomic(rtwdev, rtw_vif_watch_dog_iter, &data); + if (data.cfg_csi_rate) { + struct rtw_bf_info *bf_info = &rtwdev->bf_info; + u8 fix_rate_enable = 0; + u8 new_csi_rate_idx; + + rtw_chip_cfg_csi_rate(rtwdev, rtwdev->dm_info.min_rssi, + bf_info->cur_csi_rpt_rate, + fix_rate_enable, &new_csi_rate_idx); + + if (new_csi_rate_idx != bf_info->cur_csi_rpt_rate) + bf_info->cur_csi_rpt_rate = new_csi_rate_idx; + } + /* fw supports only one station associated to enter lps, if there are * more than two stations associated to the AP, then we can not enter * lps, because fw does not handle the overlapped beacon interval From patchwork Tue Dec 28 21:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700624 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEF62C433FE for ; Tue, 28 Dec 2021 21:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237566AbhL1VPt (ORCPT ); Tue, 28 Dec 2021 16:15:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237367AbhL1VPY (ORCPT ); Tue, 28 Dec 2021 16:15:24 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6908C061574; Tue, 28 Dec 2021 13:15:22 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id e5so40527217wrc.5; Tue, 28 Dec 2021 13:15:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RPdDDH0ZoLrX7SD+q/Kr9dA7YENi3S2V9HGa57eaoKA=; b=oOeYCXFZ+tMu+tR5R9YITWCDA2+VplpTi1FrIiiW/SrAOF0vwc5d1tQXUyQbCN7fOs JovjLjk/qpve+wyOnq76dd+ZC5mzi0E55pOPqr7HjxXWhDtPG28Jx5K4qhB/JUz4bqvW bk03VR5CXDGKcaXUC4UahDGIU++qU7kMPL3kzt6ogTEGW33e9c7SeN/1BTqTgl1Qkri3 M9VvAlILnky72DHyKfpKm5AMJtu92KnGwRGC6nSzRfw03m9nYKiVYomSJGboc0InXUsE OElRebMDZv5xxQBhtppV3cQ4yYfLbuf87ygVdbZG2Fpxkh7cTea2EC0jKkdvxyP1UOX3 AO8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RPdDDH0ZoLrX7SD+q/Kr9dA7YENi3S2V9HGa57eaoKA=; b=1US1iXncGs6KCFIAZYwKHwAYFrgO/1hzb9Yrw5jNyjANl9CAw7C5FPZt+IkIuB2Qbg ARS7ENRgz8k6PUWxFn9sAhnqirYTW6FMKxDPKcRDmMJm9HEYt6Olnbnjj0ENknvpKMw1 fZ8R0OaIsUmI83sEGBJZDO10cEtzB/1FmbybjRYfnS2rBz3NygYEEO8hb/rcITAwr8qC OScYJsd5w8q8tUKVH2nDsitGdoJ+t8Oqx0FQInQ7LGipWy9r4Lcqh7A+S/DdFDXdBT2e 9IfrmMqU4GcshBcuL/SEtA7ZOX9aCWcpHakWhFq9+Dm/pTzbO7fDHg568wMaFUe0tdWm +U/g== X-Gm-Message-State: AOAM531zII8S//2X9Vyp3F3x9+5TJdYNv4vUmpuQtFpCRyyUl4KGe0s6 STfAVywoXTDMPFn1xTvWAuMfsW9Ljlw= X-Google-Smtp-Source: ABdhPJw/Ly05NqdAUfexDEE4cR9abOLrzErk0Ft1rbt3KdVYN5tuOe5paFTUXnAYzwuAOgoSlBMHDA== X-Received: by 2002:a5d:6d84:: with SMTP id l4mr18372539wrs.61.1640726121292; Tue, 28 Dec 2021 13:15:21 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:21 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 3/9] rtw88: Move rtw_update_sta_info() out of rtw_ra_mask_info_update_iter() Date: Tue, 28 Dec 2021 22:14:55 +0100 Message-Id: <20211228211501.468981-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org rtw_update_sta_info() internally access some registers while being called unter an atomic lock acquired by rtw_iterate_vifs_atomic(). Move rtw_update_sta_info() call out of (rtw_ra_mask_info_update_iter) in preparation for SDIO support where register access may sleep. Signed-off-by: Martin Blumenstingl --- v1 -> v2: - this patch is new in v2 - keep rtw_iterate_vifs_atomic() to prevent deadlocks as Johannes suggested. Keep track of all relevant stations inside rtw_ra_mask_info_update_iter() and the iter-data and then call rtw_update_sta_info() while held under rtwdev->mutex instead drivers/net/wireless/realtek/rtw88/mac80211.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c index ae7d97de5fdf..3bd12354a8a1 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -671,6 +671,8 @@ struct rtw_iter_bitrate_mask_data { struct rtw_dev *rtwdev; struct ieee80211_vif *vif; const struct cfg80211_bitrate_mask *mask; + unsigned int num_si; + struct rtw_sta_info *si[RTW_MAX_MAC_ID_NUM]; }; static void rtw_ra_mask_info_update_iter(void *data, struct ieee80211_sta *sta) @@ -691,7 +693,8 @@ static void rtw_ra_mask_info_update_iter(void *data, struct ieee80211_sta *sta) } si->use_cfg_mask = true; - rtw_update_sta_info(br_data->rtwdev, si); + + br_data->si[br_data->num_si++] = si; } static void rtw_ra_mask_info_update(struct rtw_dev *rtwdev, @@ -699,11 +702,20 @@ static void rtw_ra_mask_info_update(struct rtw_dev *rtwdev, const struct cfg80211_bitrate_mask *mask) { struct rtw_iter_bitrate_mask_data br_data; + unsigned int i; + + mutex_lock(&rtwdev->mutex); br_data.rtwdev = rtwdev; br_data.vif = vif; br_data.mask = mask; + br_data.num_si = 0; rtw_iterate_stas_atomic(rtwdev, rtw_ra_mask_info_update_iter, &br_data); + + for (i = 0; i < br_data.num_si; i++) + rtw_update_sta_info(rtwdev, br_data.si[i]); + + mutex_unlock(&rtwdev->mutex); } static int rtw_ops_set_bitrate_mask(struct ieee80211_hw *hw, From patchwork Tue Dec 28 21:14:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700623 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBF62C433EF for ; Tue, 28 Dec 2021 21:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237545AbhL1VPr (ORCPT ); Tue, 28 Dec 2021 16:15:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237383AbhL1VPY (ORCPT ); Tue, 28 Dec 2021 16:15:24 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B118CC06173E; Tue, 28 Dec 2021 13:15:23 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id a203-20020a1c7fd4000000b003457874263aso13402413wmd.2; Tue, 28 Dec 2021 13:15:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eir22dEvm+/a+IM/fF5TOGAC5dG+fiQ9p937xH/yeHg=; b=NS3iWLZMeaa2oNYWNDrgczQOtlVvMqfM6v8OWNpjesPd8FqZG4RTZfvXy6rMOmTtnw ugAMpE0AN/S6qkVoZ6QDCoPj4xyazYTgdhnNKgUSFYMsoVVJmit3wwACL7pcSKSU1C/p eSpi2dHfBXoAtdxBfeHK7rJN7SO27dBESXt6mv6BL01RfoJaw3uksgVPwd5E9loMsvt0 BPCgCI4f92TZjV9SgDiUx6QKHnrP3Lnfz1dCzEPZoo+1YhUSZ0b0cz2bTYGJ01FxlLBD ICEr570LhppZKiVQbYD9/FIOSkbxVOrJE35h4Ghlwb8eHPENir3XZzKkHIo88d6PTsKk iyzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eir22dEvm+/a+IM/fF5TOGAC5dG+fiQ9p937xH/yeHg=; b=Lxa6F3wG7wgNSI6quKzdJeM1PIc6GoRU8/uP9qtZfPIRnAZgMs4KZ1IF5kggNylJ/k eMj8HqtpSpLPX/HSMMSxp0TvMBQrVHnmR+qj7ZPjr1hoH7KgnIitp2Sv9+bSFUAy2pew vViXIfWh87Ln1hX94z4xOm0Z4W7UrzrBQQbTVYO3botKDwFb9cuBw6fkLglt5C17uPuY BgzttxZtoCY4p8OmPRLvXuf5cV4JtTYfTox88GL1cy+aFaYsWFasPv3ZkGtMD+9JgGJd 9o9EZAaRMW3cnpAmkrWnzqCUwCulCgOVivah3OGoVSdS/KBii/MoEgBV+JTbWn8pB9a2 Is2g== X-Gm-Message-State: AOAM530anOM2QV2zxbYRLnqIUyjMuu+qOFxai6M+HigVXStrSLA3+iTn K8nG7j6YxcO71eF9sSrY4vNvjCmvWvU= X-Google-Smtp-Source: ABdhPJyogg07htxPb2moDSF114S06c0OGcDfqC6ikew+3yPasNWSrZp6zp76Cd2nIvzsV9L6mWwcQQ== X-Received: by 2002:a05:600c:6018:: with SMTP id az24mr18648389wmb.103.1640726122019; Tue, 28 Dec 2021 13:15:22 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:21 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 4/9] rtw88: Use rtw_iterate_vifs where the iterator reads or writes registers Date: Tue, 28 Dec 2021 22:14:56 +0100 Message-Id: <20211228211501.468981-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Upcoming SDIO support may sleep in the read/write handlers. Switch all users of rtw_iterate_vifs_atomic() which are either reading or writing a register to rtw_iterate_vifs(). Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/main.c | 2 +- drivers/net/wireless/realtek/rtw88/ps.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index fd02c0b0025a..b0e2ca8ddbe9 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -585,7 +585,7 @@ static void __fw_recovery_work(struct rtw_dev *rtwdev) rtw_iterate_keys_rcu(rtwdev, NULL, rtw_reset_key_iter, rtwdev); rcu_read_unlock(); rtw_iterate_stas_atomic(rtwdev, rtw_reset_sta_iter, rtwdev); - rtw_iterate_vifs_atomic(rtwdev, rtw_reset_vif_iter, rtwdev); + rtw_iterate_vifs(rtwdev, rtw_reset_vif_iter, rtwdev); rtw_enter_ips(rtwdev); } diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c index bfa64c038f5f..a7213ff2c224 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.c +++ b/drivers/net/wireless/realtek/rtw88/ps.c @@ -58,7 +58,7 @@ int rtw_leave_ips(struct rtw_dev *rtwdev) return ret; } - rtw_iterate_vifs_atomic(rtwdev, rtw_restore_port_cfg_iter, rtwdev); + rtw_iterate_vifs(rtwdev, rtw_restore_port_cfg_iter, rtwdev); rtw_coex_ips_notify(rtwdev, COEX_IPS_LEAVE); From patchwork Tue Dec 28 21:14:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700622 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D06C2C43219 for ; Tue, 28 Dec 2021 21:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237455AbhL1VPc (ORCPT ); Tue, 28 Dec 2021 16:15:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237399AbhL1VPZ (ORCPT ); Tue, 28 Dec 2021 16:15:25 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A20E6C061401; Tue, 28 Dec 2021 13:15:24 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id v11so40542706wrw.10; Tue, 28 Dec 2021 13:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VjfR3K+5JgkYbWpldO+nZERSdwRbxL2f2Vl4DU5yMWU=; b=TRwvLLHPklunzn5JC6LZGhc+TFA19TdQQVKlUHf+XK6nAbNsVbP8QzjiFdNe+i7KEf bPjxow6OssknSfRlYEIjWZRFVACGbH2fS8i2ahK3OKp2qkcreZKTGHx1VStKBg7wY5So pF6Bkgu7H78giHQtXlohtr7L0+hNyOHdrLCjPbSDK6a1uBUh9PtNV/QcD/G6xrr0HMaw X2VyGgaeQUDOo7UpbYTImiUxXhzD5EotgTBl0e8T5YiQTkYbg1j0X3KyCJ0jKHOFJnQK WDP2fTgKv9Mu2SsVh40cnu20PrhBUYOMzsSLHXENTKeUb/l1niYQ+Kr/awTfFqw4oezu jeZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VjfR3K+5JgkYbWpldO+nZERSdwRbxL2f2Vl4DU5yMWU=; b=3PjzRK2tsh0YRK1+ejmYHZjYBF1mIUUxrTLThly+CLghNMunv2BGtzFGrnEhRq8o1R H8vpyuIN3fFNsnDtlwbFsLR+pDbOzlpRj3Ub0/I7P2m09mV0AE1bFdfE4vnwaaGoTmLR LuN98iSTJwtkWqaYP/ixMlcik8ZqR4IMmcFUQNvL0cGNRZg1nCtEDrtUS+5Wlbn0KGLd A/cAHVbcbH6UFKtLhyg/j8uSihQrS41FOSQ+f+wc7WFFQiZWOpNnCf4kTIuZNHPWbxwt GfjqYK2FWg/eizqmeQ96crPrv5efIeCcMZXIbnhpIk9rzecUIVCwWNDjp8nGQDU1SS3N zAhA== X-Gm-Message-State: AOAM531S6W4Pqh9lTSsj7m2det745ndHBpaGGG2OZUo9WE3pwu7E9lOw Zu9JckbV5esH+mukUCTdjlDAhWuEMSk= X-Google-Smtp-Source: ABdhPJxKs8RDjTJ1dXlLgjC33N03DhitK6NDEyt/SVW1wP2mUy375FlX1tq/CNs/exJQSyCxsDsHfQ== X-Received: by 2002:adf:80a1:: with SMTP id 30mr17486013wrl.557.1640726122908; Tue, 28 Dec 2021 13:15:22 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:22 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 5/9] rtw88: Use rtw_iterate_stas where the iterator reads or writes registers Date: Tue, 28 Dec 2021 22:14:57 +0100 Message-Id: <20211228211501.468981-6-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Upcoming SDIO support may sleep in the read/write handlers. Switch all users of rtw_iterate_stas_atomic() which are either reading or writing a register to rtw_iterate_stas(). Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/main.c | 2 +- drivers/net/wireless/realtek/rtw88/phy.c | 4 ++-- drivers/net/wireless/realtek/rtw88/util.h | 2 ++ drivers/net/wireless/realtek/rtw88/wow.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index b0e2ca8ddbe9..4b28c81b3ca0 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -584,7 +584,7 @@ static void __fw_recovery_work(struct rtw_dev *rtwdev) rcu_read_lock(); rtw_iterate_keys_rcu(rtwdev, NULL, rtw_reset_key_iter, rtwdev); rcu_read_unlock(); - rtw_iterate_stas_atomic(rtwdev, rtw_reset_sta_iter, rtwdev); + rtw_iterate_stas(rtwdev, rtw_reset_sta_iter, rtwdev); rtw_iterate_vifs(rtwdev, rtw_reset_vif_iter, rtwdev); rtw_enter_ips(rtwdev); } diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c index e505d17f107e..d8442adc11b1 100644 --- a/drivers/net/wireless/realtek/rtw88/phy.c +++ b/drivers/net/wireless/realtek/rtw88/phy.c @@ -300,7 +300,7 @@ static void rtw_phy_stat_rssi(struct rtw_dev *rtwdev) data.rtwdev = rtwdev; data.min_rssi = U8_MAX; - rtw_iterate_stas_atomic(rtwdev, rtw_phy_stat_rssi_iter, &data); + rtw_iterate_stas(rtwdev, rtw_phy_stat_rssi_iter, &data); dm_info->pre_min_rssi = dm_info->min_rssi; dm_info->min_rssi = data.min_rssi; @@ -544,7 +544,7 @@ static void rtw_phy_ra_info_update(struct rtw_dev *rtwdev) if (rtwdev->watch_dog_cnt & 0x3) return; - rtw_iterate_stas_atomic(rtwdev, rtw_phy_ra_info_update_iter, rtwdev); + rtw_iterate_stas(rtwdev, rtw_phy_ra_info_update_iter, rtwdev); } static u32 rtw_phy_get_rrsr_mask(struct rtw_dev *rtwdev, u8 rate_idx) diff --git a/drivers/net/wireless/realtek/rtw88/util.h b/drivers/net/wireless/realtek/rtw88/util.h index 0c23b5069be0..b0dfadf8b82a 100644 --- a/drivers/net/wireless/realtek/rtw88/util.h +++ b/drivers/net/wireless/realtek/rtw88/util.h @@ -13,6 +13,8 @@ struct rtw_dev; #define rtw_iterate_vifs_atomic(rtwdev, iterator, data) \ ieee80211_iterate_active_interfaces_atomic(rtwdev->hw, \ IEEE80211_IFACE_ITER_NORMAL, iterator, data) +#define rtw_iterate_stas(rtwdev, iterator, data) \ + ieee80211_iterate_stations(rtwdev->hw, iterator, data) #define rtw_iterate_stas_atomic(rtwdev, iterator, data) \ ieee80211_iterate_stations_atomic(rtwdev->hw, iterator, data) #define rtw_iterate_keys(rtwdev, vif, iterator, data) \ diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c index 89dc595094d5..7ec0731c0346 100644 --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c @@ -468,7 +468,7 @@ static void rtw_wow_fw_media_status(struct rtw_dev *rtwdev, bool connect) data.rtwdev = rtwdev; data.connect = connect; - rtw_iterate_stas_atomic(rtwdev, rtw_wow_fw_media_status_iter, &data); + rtw_iterate_stas(rtwdev, rtw_wow_fw_media_status_iter, &data); } static int rtw_wow_config_wow_fw_rsvd_page(struct rtw_dev *rtwdev) From patchwork Tue Dec 28 21:14:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700619 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2E18C28CF5 for ; Tue, 28 Dec 2021 21:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237475AbhL1VPc (ORCPT ); Tue, 28 Dec 2021 16:15:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237409AbhL1VP0 (ORCPT ); Tue, 28 Dec 2021 16:15:26 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 707D5C061747; Tue, 28 Dec 2021 13:15:25 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id s1so40554779wra.6; Tue, 28 Dec 2021 13:15:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qYRAJooeejsLElKVR8lduV1KN6qXlfQTHsLzXUd3d6g=; b=De5Lu8bqh0J4nFPh1J69zRiHeEeBM2ppK6xezxClAjS6uLL4Y60F3uW64i1SnSazIJ aRxe3+1yiVtrHxsP+NEDWJrFME3yxqrblgn7cfBWLlb7mTwElERwknrpIs3LWn0FRiqE kndJDA3VzRwYZxTZoKDeX7LpE3LwGnUV8VQfl2O/DPN6tqqvr1qPsN1qtsnSxedtfKyw 5kB1y3ZpXYm4l7wK5RSVQ9IOb+AzisBzsj57paOjSudnbCFH18T9WWBE3SSRHHzoiRE6 v5a8xnX6wkjQOUKtg/4e/JRnDfYpUTM+aJwJ4NqlomIJhv+K0AvjdsSxHTE55TclpU+F OFsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qYRAJooeejsLElKVR8lduV1KN6qXlfQTHsLzXUd3d6g=; b=CHRtvOUu3eEYY3rslp2Y1oacnudrsPWgEWddUMARQTpYmHhLVXNRC6tOKHVyiBDa0Q nKg/7wuKrqW6zDm4N6lrnn2hSmqvqcX59lH8F3rJZIe1ld4ETyNmkyPB9XAIuyUY00tz 8R9W8LADGUI8aEFkEH9Jbq2hQdPxUno5o1zaKaK+V9qlozrq8zRzuJMjGqV9DYocJj+v W2NitDB3Sc9hazDE3PQRLxN0x+E+g4rcNOotXfAlvj98BykpzL3IYqWEebTCadioYp6E XIjK79sphdqC3ejHwHXhN5wksQSG6CG6WocSoEovRACC2yAKr6I3DG3yxVqxWZ7cwwNR 7eHw== X-Gm-Message-State: AOAM533uZRZS2iv/J7S5UpPqDU1cttoyFpE0pOwsE9oErrhYa42uytj2 kS7skUngBwd8wMdF3d+1R5shWY900D0= X-Google-Smtp-Source: ABdhPJwoVqHyw+Vr0+/djiZypcuQw8B+dO5JU0Cud6lQWCXyu7oUiPSB1gjR2+g36JWYa/FefvvpBQ== X-Received: by 2002:a5d:59a6:: with SMTP id p6mr17447028wrr.559.1640726123719; Tue, 28 Dec 2021 13:15:23 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:23 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 6/9] rtw88: Replace usage of rtw_iterate_keys_rcu() with rtw_iterate_keys() Date: Tue, 28 Dec 2021 22:14:58 +0100 Message-Id: <20211228211501.468981-7-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Upcoming SDIO support may sleep in the read/write handlers. The only occurrence of rtw_iterate_keys_rcu() reads and writes registers from it's iterator function. Replace it with rtw_iterate_keys() (the non-RCU version). This will prevent an "scheduling while atomic" issue when using an SDIO device. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/main.c | 4 +--- drivers/net/wireless/realtek/rtw88/util.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 4b28c81b3ca0..3d4257e0367a 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -581,9 +581,7 @@ static void __fw_recovery_work(struct rtw_dev *rtwdev) WARN(1, "firmware crash, start reset and recover\n"); - rcu_read_lock(); - rtw_iterate_keys_rcu(rtwdev, NULL, rtw_reset_key_iter, rtwdev); - rcu_read_unlock(); + rtw_iterate_keys(rtwdev, NULL, rtw_reset_key_iter, rtwdev); rtw_iterate_stas(rtwdev, rtw_reset_sta_iter, rtwdev); rtw_iterate_vifs(rtwdev, rtw_reset_vif_iter, rtwdev); rtw_enter_ips(rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/util.h b/drivers/net/wireless/realtek/rtw88/util.h index b0dfadf8b82a..06a5b4c4111c 100644 --- a/drivers/net/wireless/realtek/rtw88/util.h +++ b/drivers/net/wireless/realtek/rtw88/util.h @@ -19,8 +19,6 @@ struct rtw_dev; ieee80211_iterate_stations_atomic(rtwdev->hw, iterator, data) #define rtw_iterate_keys(rtwdev, vif, iterator, data) \ ieee80211_iter_keys(rtwdev->hw, vif, iterator, data) -#define rtw_iterate_keys_rcu(rtwdev, vif, iterator, data) \ - ieee80211_iter_keys_rcu((rtwdev)->hw, vif, iterator, data) static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr) { From patchwork Tue Dec 28 21:14:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700617 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 643C9C4321E for ; Tue, 28 Dec 2021 21:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237430AbhL1VP3 (ORCPT ); Tue, 28 Dec 2021 16:15:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236376AbhL1VP1 (ORCPT ); Tue, 28 Dec 2021 16:15:27 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74116C061574; Tue, 28 Dec 2021 13:15:26 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id q16so40557879wrg.7; Tue, 28 Dec 2021 13:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uIrP2V3/ZBuZPe9ZMsaO5hiYD46qBHOPt+3lPFmmUuA=; b=pJCRkkW62ApgvhxiKl1PtR5fvAWmq2oDJ7s3aZ3BfcliOSzz1LpSSGGfXZayz+6Ba4 za8f1nba4kJ5Y4F2LJiCKgx08rQa7qbOtwXyw+nxbMdzEEFh653P4PeJp0wZlKIQV0Kh pbqtj6/OQbmhHo4V/sYjxBfzwl64oUv8EXENbMD+PNxTLqOzW8GWuPb3acp5Z8XId57f TcsOZONriTFN1to2puCt+CASj4ryGwsuMAZn3oZiyNiod5xtzWWj+Y1kHOn3Xkcz4LaZ OePdjIL1oqUUyazRBKBqZOZE1xFl+xh65NV1bW2SRkTnSLgW/jO62BR9k/z4Dc+R1XH0 rzpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uIrP2V3/ZBuZPe9ZMsaO5hiYD46qBHOPt+3lPFmmUuA=; b=p3KVn+knPBO2bJBwKGHSKIyY7IypJ4Bc1GXdUujOPt+GVrtpiNVGgtvJP1iowe0U2u WuQK//Gla/H1QXd5l2p4603w42WFDz8Nk7MccNIT7+d/zec9zAgQeV4KQqDW22Bn/kdA KeuMjHn3QBJ33neSK3j+FLnMobFThXNIfKYaQZL77x1pI0g+AyGzqYEdLwETkLooCdLS F6kqmJWl0bIvYjBDZee5eXwoln/i6DcdHreGPXTN/qcazShWt/q4dlVw4YeDi4/39pkT QNhIJ0nRV2jB+MIkGfuzDAUu0Lq5hC77TZRxHCKhG7E5txPzaWwk7h3qKW1sbMJHGFv5 9THQ== X-Gm-Message-State: AOAM531Y+T7NGGscOagQQOnHEUfpfVJvu9skmVjIEBsr5syUBy+mhzNB uJ6e8Ij0czKxJrKgOMsLyFFdt5vk7mk= X-Google-Smtp-Source: ABdhPJwf8efFb+QBvAFvwEHTTSB1/UF4Hqx2PmMBX4ydD9WYY5ERIchkafwpkrBENp5q89Okd0Zung== X-Received: by 2002:adf:ee0d:: with SMTP id y13mr18440905wrn.427.1640726124798; Tue, 28 Dec 2021 13:15:24 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:24 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 7/9] rtw88: Configure the registers from rtw_bf_assoc() outside the RCU lock Date: Tue, 28 Dec 2021 22:14:59 +0100 Message-Id: <20211228211501.468981-8-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Upcoming SDIO support may sleep in the read/write handlers. Shrink the RCU critical section so it only cover the ieee80211_find_sta() call and finding the ic_vht_cap/vht_cap based on the found station. This moves the chip's BFEE configuration outside the rcu_read_lock section and thus prevent a "scheduling while atomic" issue when accessing the registers using an SDIO card. Signed-off-by: Martin Blumenstingl --- v1 -> v2: - shrink the critical section as suggested by Ping-Ke drivers/net/wireless/realtek/rtw88/bf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/bf.c b/drivers/net/wireless/realtek/rtw88/bf.c index df750b3a35e9..792eb9930269 100644 --- a/drivers/net/wireless/realtek/rtw88/bf.c +++ b/drivers/net/wireless/realtek/rtw88/bf.c @@ -49,19 +49,23 @@ void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, sta = ieee80211_find_sta(vif, bssid); if (!sta) { + rcu_read_unlock(); + rtw_warn(rtwdev, "failed to find station entry for bss %pM\n", bssid); - goto out_unlock; + return; } ic_vht_cap = &hw->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap; vht_cap = &sta->vht_cap; + rcu_read_unlock(); + if ((ic_vht_cap->cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE) && (vht_cap->cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)) { if (bfinfo->bfer_mu_cnt >= chip->bfer_mu_max_num) { rtw_dbg(rtwdev, RTW_DBG_BF, "mu bfer number over limit\n"); - goto out_unlock; + return; } ether_addr_copy(bfee->mac_addr, bssid); @@ -75,7 +79,7 @@ void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, (vht_cap->cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)) { if (bfinfo->bfer_su_cnt >= chip->bfer_su_max_num) { rtw_dbg(rtwdev, RTW_DBG_BF, "su bfer number over limit\n"); - goto out_unlock; + return; } sound_dim = vht_cap->cap & @@ -98,9 +102,6 @@ void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, rtw_chip_config_bfee(rtwdev, rtwvif, bfee, true); } - -out_unlock: - rcu_read_unlock(); } void rtw_bf_init_bfer_entry_mu(struct rtw_dev *rtwdev, From patchwork Tue Dec 28 21:15:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700621 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59911C3525C for ; Tue, 28 Dec 2021 21:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237494AbhL1VPd (ORCPT ); Tue, 28 Dec 2021 16:15:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237422AbhL1VP2 (ORCPT ); Tue, 28 Dec 2021 16:15:28 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A941C061574; Tue, 28 Dec 2021 13:15:27 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id v11so40542842wrw.10; Tue, 28 Dec 2021 13:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oj4lreG5cZ3IFWojzIgNqoaNn8hukHMIHKIyr0AoqhQ=; b=e5QefRpQAY4BqOrnWdAEoUlf8ZKbEO/Bps3rEOzzlItT4AWG/Y/YvujfdLzhrH6Jev cuiolKaEQnX5LERTOaioIRhqJ6QSSypuPf+Vjy0lImBqmZAAdXQBN6buBOVRutDdYscc 6k1eFuECEqpaHLkEIslbOBA3BlAYuJ692G30E819btH+A5XZB8EQYrqnyi5ZFxnx5OYm lVs6fCRNB56uK17cIbQtKQJmS9eqz0PQJfw1kjXDtSrg+bElIwofRTIo8JkEt4rpIBC/ DOhsivNgmXGXgnta3rRMosIiyarNuFyE1pf/XKijuOkAqUvOu2lV8wNf0u4nTN7n69cL xA9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oj4lreG5cZ3IFWojzIgNqoaNn8hukHMIHKIyr0AoqhQ=; b=cv4j/Mhkhtv00GERfaU1uyjvy6+ie3HWirxeGdL9CRTwPju8MJrGacdA6rTp19SUww tRO5UQGCkYhgde83L2vILCuG84NyMPrd+APM2DdTwM7IKq5ubCUqQGQ0wsecpi2nRbY3 6JR2Swynlb9ZOMw+Y/vK4t8x2YPwGdZIxL4epZzOomOM2gAnu9UPH963eGG2vehGh6sZ BD934NkGo6yBOf7L31EsZDZuUayOq2nrRLz5hyBbavel0+8djWf7MY/bh0ZwGMb4e2SV Ey5ujyx3l48aGgzI/Sm/zHTKk8mh9+tC2WXrYwihiI4G4ce4Qiu82xJ20LZis8aObXRQ JZrQ== X-Gm-Message-State: AOAM533jB/syV2VKcfGjQaStHrCaarKdXbYqlHIU/FjB5qqM2UnzV/KX 673NqPWACooTeNsqI26LdTeSeVhDjr4= X-Google-Smtp-Source: ABdhPJzrMZ5qfvZCeoeuuBanLzhRdDynQhiefOc7Y5L4pz7fkUjQZJpWHkkW1hvVdUz55rQOgWnoTg== X-Received: by 2002:adf:f24e:: with SMTP id b14mr17711802wrp.612.1640726125677; Tue, 28 Dec 2021 13:15:25 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:25 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 8/9] rtw88: hci: Convert rf_lock from a spinlock to a mutex Date: Tue, 28 Dec 2021 22:15:00 +0100 Message-Id: <20211228211501.468981-9-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Upcoming SDIO support may sleep in the read/write handlers. Switch rf_lock from a spinlock to a mutex to allow for this behavior. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/hci.h | 11 ++++------- drivers/net/wireless/realtek/rtw88/main.c | 2 +- drivers/net/wireless/realtek/rtw88/main.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/hci.h b/drivers/net/wireless/realtek/rtw88/hci.h index 4c6fc6fb3f83..3c730b7a94f7 100644 --- a/drivers/net/wireless/realtek/rtw88/hci.h +++ b/drivers/net/wireless/realtek/rtw88/hci.h @@ -166,12 +166,11 @@ static inline u32 rtw_read_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path, u32 addr, u32 mask) { - unsigned long flags; u32 val; - spin_lock_irqsave(&rtwdev->rf_lock, flags); + mutex_lock(&rtwdev->rf_lock); val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask); - spin_unlock_irqrestore(&rtwdev->rf_lock, flags); + mutex_unlock(&rtwdev->rf_lock); return val; } @@ -180,11 +179,9 @@ static inline void rtw_write_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path, u32 addr, u32 mask, u32 data) { - unsigned long flags; - - spin_lock_irqsave(&rtwdev->rf_lock, flags); + mutex_lock(&rtwdev->rf_lock); rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data); - spin_unlock_irqrestore(&rtwdev->rf_lock, flags); + mutex_unlock(&rtwdev->rf_lock); } static inline u32 diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 3d4257e0367a..a94678effd77 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1920,12 +1920,12 @@ int rtw_core_init(struct rtw_dev *rtwdev) skb_queue_head_init(&rtwdev->coex.queue); skb_queue_head_init(&rtwdev->tx_report.queue); - spin_lock_init(&rtwdev->rf_lock); spin_lock_init(&rtwdev->h2c.lock); spin_lock_init(&rtwdev->txq_lock); spin_lock_init(&rtwdev->tx_report.q_lock); mutex_init(&rtwdev->mutex); + mutex_init(&rtwdev->rf_lock); mutex_init(&rtwdev->coex.mutex); mutex_init(&rtwdev->hal.tx_power_mutex); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index dc1cd9bd4b8a..e7a60e6f8596 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1949,7 +1949,7 @@ struct rtw_dev { struct mutex mutex; /* read/write rf register */ - spinlock_t rf_lock; + struct mutex rf_lock; /* watch dog every 2 sec */ struct delayed_work watch_dog_work; From patchwork Tue Dec 28 21:15:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12700620 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D931BC3525A for ; Tue, 28 Dec 2021 21:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237515AbhL1VPe (ORCPT ); Tue, 28 Dec 2021 16:15:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237423AbhL1VP2 (ORCPT ); Tue, 28 Dec 2021 16:15:28 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 334FAC06173E; Tue, 28 Dec 2021 13:15:28 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id v11so40542892wrw.10; Tue, 28 Dec 2021 13:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RaQ9bvcWekXUuYk7Fwo10dE04Y9Sl54Vm+TM6HP1ZNg=; b=CXQvj0OPLuHE68Xk9fZ9itvAzS4vubdYUgpYgfgBKUBy+mWlxfRZYLDd4I+EOtiGmC xmLWNWYrSAA0Y1p3iwCQRpsdW589SWf5LzO0XdoPMFH4LoanaOE9aemiLChMtkSHniCY SVSavDt3dHzc9iGNbazs+8JntsIt6QXCgJCBXR8SL8PUvMf64+mXfJCW4gNV8Iw7Y5Vk Bqrv8SHQgr9T3dIa3r+/j+Qt5C0Oh3JrrlQFezvv9DqrcYurilwxje1UgxDdQ+kIC/68 oxn3cc+NObS8P8pzY1WL4EkAqAiE19ggVs1GsOZe7bA0eDCrV2MSG0z/Nu3tMVOpcvdR O40g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RaQ9bvcWekXUuYk7Fwo10dE04Y9Sl54Vm+TM6HP1ZNg=; b=vE+isQ1Y5PvjtXn8cGHabJPURN/HjSD7MOAESB7f/mYSml0ZnKgWrhpkWBgSF0X7ax U/90BgYSiLqAHqvbtP4b5OSb7cIeCQrJaMWnmGFgF42OmggtNYaZl0YoaJT1MJzGy83O 73bLGtlFyrXP4Ob/AGLJ6dIvCPfTat66f1JlCRaBU5sfcjtnZF2bZMAN2l0vVbPGZQ9x JFfjZdZ6xeetqZqBtY5cqLEa2Yj6z2U6dGnA8WulgxESfE3yiiZgZTY7+c6PQmCRN4CM NxeYumpdoNrxh+uIIc10IA6LFCE6VlafBp0Zyxxf1FVC2GqbxgPDGEqC395sAhsm1ABD P1/A== X-Gm-Message-State: AOAM531lNv7X26SPuCnMQCGc2z/zWkcZOHGkhm/FVBOGvzq5AEq4+kFr bY33WJhRZsAEw9TBhiB+Kl2fyB45zfA= X-Google-Smtp-Source: ABdhPJxUkbn0/rXXvV4KL76p4YHj6BFPA6aTpn7t8ZKgSDewZ1C41tkCAOthuPTT+3H84FXszV6Ulg== X-Received: by 2002:adf:bb11:: with SMTP id r17mr18266752wrg.463.1640726126562; Tue, 28 Dec 2021 13:15:26 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-c1d2-d400-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:c1d2:d400:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id o11sm21939036wmq.15.2021.12.28.13.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 13:15:26 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@codeaurora.org, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , Pkshih , Martin Blumenstingl Subject: [PATCH 9/9] rtw88: fw: Convert h2c.lock from a spinlock to a mutex Date: Tue, 28 Dec 2021 22:15:01 +0100 Message-Id: <20211228211501.468981-10-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> References: <20211228211501.468981-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Upcoming SDIO support may sleep in the read/write handlers. Switch the h2c.lock from a spinlock to a mutex to allow for this behavior. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/fw.c | 14 +++++++------- drivers/net/wireless/realtek/rtw88/main.c | 2 +- drivers/net/wireless/realtek/rtw88/main.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index 2f7c036f9022..1bff43c14a05 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -317,7 +317,7 @@ static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, h2c[3], h2c[2], h2c[1], h2c[0], h2c[7], h2c[6], h2c[5], h2c[4]); - spin_lock(&rtwdev->h2c.lock); + mutex_lock(&rtwdev->h2c.lock); box = rtwdev->h2c.last_box_num; switch (box) { @@ -342,9 +342,9 @@ static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, goto out; } - ret = read_poll_timeout_atomic(rtw_read8, box_state, - !((box_state >> box) & 0x1), 100, 3000, - false, rtwdev, REG_HMETFR); + ret = read_poll_timeout(rtw_read8, box_state, + !((box_state >> box) & 0x1), 100, 3000, false, + rtwdev, REG_HMETFR); if (ret) { rtw_err(rtwdev, "failed to send h2c command\n"); @@ -360,7 +360,7 @@ static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, rtwdev->h2c.last_box_num = 0; out: - spin_unlock(&rtwdev->h2c.lock); + mutex_unlock(&rtwdev->h2c.lock); } void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c) @@ -372,7 +372,7 @@ static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt) { int ret; - spin_lock(&rtwdev->h2c.lock); + mutex_lock(&rtwdev->h2c.lock); FW_OFFLOAD_H2C_SET_SEQ_NUM(h2c_pkt, rtwdev->h2c.seq); ret = rtw_hci_write_data_h2c(rtwdev, h2c_pkt, H2C_PKT_SIZE); @@ -380,7 +380,7 @@ static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt) rtw_err(rtwdev, "failed to send h2c packet\n"); rtwdev->h2c.seq++; - spin_unlock(&rtwdev->h2c.lock); + mutex_unlock(&rtwdev->h2c.lock); } void diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index a94678effd77..e883f5ecf307 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1920,12 +1920,12 @@ int rtw_core_init(struct rtw_dev *rtwdev) skb_queue_head_init(&rtwdev->coex.queue); skb_queue_head_init(&rtwdev->tx_report.queue); - spin_lock_init(&rtwdev->h2c.lock); spin_lock_init(&rtwdev->txq_lock); spin_lock_init(&rtwdev->tx_report.q_lock); mutex_init(&rtwdev->mutex); mutex_init(&rtwdev->rf_lock); + mutex_init(&rtwdev->h2c.lock); mutex_init(&rtwdev->coex.mutex); mutex_init(&rtwdev->hal.tx_power_mutex); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index e7a60e6f8596..495a28028ac0 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1975,7 +1975,7 @@ struct rtw_dev { /* incicate the mail box to use with fw */ u8 last_box_num; /* protect to send h2c to fw */ - spinlock_t lock; + struct mutex lock; u32 seq; } h2c;