USB and (upcoming) SDIO support may sleep in the read/write handlers.
Shrink the RCU critical section so it only cover the call to
ieee80211_find_sta() 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 "scheduling while atomic" or
"Voluntary context switch within RCU read-side critical section!"
warnings when accessing the registers using an SDIO card (which is
where this issue has been spotted in the real world - but it also
affects USB cards).
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
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 038a30b170ef..c827c4a2814b 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->deflink.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,
--
2.39.0
On Thu, 2022-12-29 at 13:48 +0100, Martin Blumenstingl wrote:
> USB and (upcoming) SDIO support may sleep in the read/write handlers.
> Shrink the RCU critical section so it only cover the call to
> ieee80211_find_sta() 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 "scheduling while atomic" or
> "Voluntary context switch within RCU read-side critical section!"
> warnings when accessing the registers using an SDIO card (which is
> where this issue has been spotted in the real world - but it also
> affects USB cards).
>
> Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
I think my reviewed-by should behind your signed-off-by.
> ---
> 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 038a30b170ef..c827c4a2814b 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->deflink.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,
Hi Ping-Ke, On Fri, Dec 30, 2022 at 12:48 AM Ping-Ke Shih <pkshih@realtek.com> wrote: [...] > > Reviewed-by: Ping-Ke Shih <pkshih@realtek.com> > > Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> > > I think my reviewed-by should behind your signed-off-by. My understanding is that I have to put your Reviewed-by above my Signed-off-by since I added the Reviewed-by to the description. If the maintainer adds your Reviewed-by while applying the patch to the tree they will put your Reviewed-by between my Signed-off-by and the maintainer's Signed-off-by. If this is incorrect then please let me know and I'll change it for v3. Best regards, Martin
> -----Original Message----- > From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> > Sent: Wednesday, January 4, 2023 11:44 PM > To: Ping-Ke Shih <pkshih@realtek.com> > Cc: linux-wireless@vger.kernel.org; kvalo@kernel.org; s.hauer@pengutronix.de; tony0620emma@gmail.com; > netdev@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 2/4] rtw88: Configure the registers from rtw_bf_assoc() outside the RCU lock > > Hi Ping-Ke, > > On Fri, Dec 30, 2022 at 12:48 AM Ping-Ke Shih <pkshih@realtek.com> wrote: > [...] > > > Reviewed-by: Ping-Ke Shih <pkshih@realtek.com> > > > Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> > > > > I think my reviewed-by should behind your signed-off-by. > My understanding is that I have to put your Reviewed-by above my > Signed-off-by since I added the Reviewed-by to the description. > If the maintainer adds your Reviewed-by while applying the patch to > the tree they will put your Reviewed-by between my Signed-off-by and > the maintainer's Signed-off-by. > > If this is incorrect then please let me know and I'll change it for v3. > My original thought is to add my reviewed-by in the order like maintainer applies the patch, but your understanding looks reasonable. Sorry for the noise. Ping-Ke
© 2016 - 2026 Red Hat, Inc.