From patchwork Wed Dec 28 13:35:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13082985 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 16F94C54EBC for ; Wed, 28 Dec 2022 13:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232997AbiL1NhK (ORCPT ); Wed, 28 Dec 2022 08:37:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232892AbiL1Ngn (ORCPT ); Wed, 28 Dec 2022 08:36:43 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B08B25D6; Wed, 28 Dec 2022 05:36:41 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id qk9so38432654ejc.3; Wed, 28 Dec 2022 05:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lYZhKnZhGNvp8Xep7RsrgSJ8LUS+CmNkQDKEvWswvc8=; b=CQA6avDsiZEmJEhbFddEiEJMN4q2sWO1s5G3xMVHZsRmMokA8ru0VG3gtTEobjSRlO SbLC4pPXOWYmEHgu3ijRE+eR7odRbsmxk8na30IN1pkzGH0ylXeAnPlAYBNVgB5vVSfB t2gh06TKv9f1gtqLw5OFGz62GO/Qa5d/fDixsHFkeywRFaOfSTM64ycpDRuhrHpYC6Rg HnE3ZB/TeNByjKm1/HEFYl0fgzJqvsS/ZmUcOfzKTUFW3DHr38qwI9Jm4THQwxBLFBQ2 9O75HTGEJrtW7baPvMSnG/r27TbP3m8xCamvP/vWC0MgEfhpM1FDOiOCCpjKmJzikIlh 4W9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lYZhKnZhGNvp8Xep7RsrgSJ8LUS+CmNkQDKEvWswvc8=; b=AtNDFs6z+C8rjWy2DJCOk0syaYYHR02kB1IOOtDfyIzJoxHuUGatE9w+kV6iJzDVWh nNyDA4NoM1igO2Se9krmE+I7UO0f14D49uXG0uRx40OhUbqVLbmA3zTtnbsgCrmtuP2I rm8WlCcol8vFHA4T5W4GcyVn7ld9+uC1mywYIWJt1jpDmyYGSHeNiOFQAmqHsaWtt0/5 O3+CIUK1TmmPldZx2jtMptDJip5cA54iChhiz7Gn2akPfvXAqwPP15ZmQZkP+hdB2mqu 3HgqJxAJDNCVUr1ErycZH249PRfZOSUn/cZ+zL+5rgj01p3oD2Q6gn4XDzyJjWU+AEo8 napQ== X-Gm-Message-State: AFqh2kqpfJ8lsheVMRnw138zldI3foIslYVhBliMl+jSirCb3fuHKLKJ +kZ61juO4fJN9H9RMpl8DExRlKLl5xA= X-Google-Smtp-Source: AMrXdXtbhpc7LmU4h0/mF5HOGMsX6Lvo91Ar908rhw1PEdNupB67Ewn0dciOsKdmQNY8eeeqo0PgtQ== X-Received: by 2002:a17:906:94f:b0:7c1:4f7c:947f with SMTP id j15-20020a170906094f00b007c14f7c947fmr22135258ejd.72.1672234599669; Wed, 28 Dec 2022 05:36:39 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-b830-5100-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:b830:5100:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id g3-20020a170906538300b0082535e2da13sm7450475ejo.6.2022.12.28.05.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 05:36:39 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@realtek.com, tehuang@realtek.com, s.hauer@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH 1/4] rtw88: Add packed attribute to the eFuse structs Date: Wed, 28 Dec 2022 14:35:44 +0100 Message-Id: <20221228133547.633797-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> References: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The eFuse definitions in the rtw88 are using structs to describe the eFuse contents. Add the packed attribute to all structs used for the eFuse description so the compiler doesn't add gaps or re-order attributes. Also change the type of the res2..res3 eFuse fields to u16 to avoid the following warning, now that their surrounding struct has the packed attribute: note: offset of packed bit-field 'res2' has changed in GCC 4.4 Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver") Fixes: ab0a031ecf29 ("rtw88: 8723d: Add read_efuse to recognize efuse info from map") Fixes: 769a29ce2af4 ("rtw88: 8821c: add basic functions") Fixes: 87caeef032fc ("wifi: rtw88: Add rtw8723du chipset support") Fixes: aff5ffd718de ("wifi: rtw88: Add rtw8821cu chipset support") Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/main.h | 6 +++--- drivers/net/wireless/realtek/rtw88/rtw8723d.h | 6 +++--- drivers/net/wireless/realtek/rtw88/rtw8821c.h | 20 +++++++++---------- drivers/net/wireless/realtek/rtw88/rtw8822b.h | 20 +++++++++---------- drivers/net/wireless/realtek/rtw88/rtw8822c.h | 20 +++++++++---------- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 165f299e8e1f..8441c26680ad 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -438,7 +438,7 @@ struct rtw_2g_txpwr_idx { struct rtw_2g_ns_pwr_idx_diff ht_2s_diff; struct rtw_2g_ns_pwr_idx_diff ht_3s_diff; struct rtw_2g_ns_pwr_idx_diff ht_4s_diff; -}; +} __packed; struct rtw_5g_ht_1s_pwr_idx_diff { #ifdef __LITTLE_ENDIAN @@ -495,12 +495,12 @@ struct rtw_5g_txpwr_idx { struct rtw_5g_vht_ns_pwr_idx_diff vht_2s_diff; struct rtw_5g_vht_ns_pwr_idx_diff vht_3s_diff; struct rtw_5g_vht_ns_pwr_idx_diff vht_4s_diff; -}; +} __packed; struct rtw_txpwr_idx { struct rtw_2g_txpwr_idx pwr_idx_2g; struct rtw_5g_txpwr_idx pwr_idx_5g; -}; +} __packed; struct rtw_timer_list { struct timer_list timer; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h index a356318a5c15..8160c4782457 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h @@ -39,7 +39,7 @@ struct rtw8723de_efuse { u8 device_id[2]; u8 sub_vender_id[2]; u8 sub_device_id[2]; -}; +} __packed; struct rtw8723du_efuse { u8 res4[48]; /* 0xd0 */ @@ -47,7 +47,7 @@ struct rtw8723du_efuse { u8 product_id[2]; /* 0x102 */ u8 usb_option; /* 0x104 */ u8 mac_addr[ETH_ALEN]; /* 0x107 */ -}; +} __packed; struct rtw8723d_efuse { __le16 rtl_id; @@ -81,7 +81,7 @@ struct rtw8723d_efuse { struct rtw8723de_efuse e; struct rtw8723du_efuse u; }; -}; +} __packed; extern const struct rtw_chip_info rtw8723d_hw_spec; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.h b/drivers/net/wireless/realtek/rtw88/rtw8821c.h index 1c81260f3a54..6ba0d4ee92bd 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.h @@ -27,7 +27,7 @@ struct rtw8821cu_efuse { u8 res11[0xcf]; u8 package_type; /* 0x1fb */ u8 res12[0x4]; -}; +} __packed; struct rtw8821ce_efuse { u8 mac_addr[ETH_ALEN]; /* 0xd0 */ @@ -43,13 +43,13 @@ struct rtw8821ce_efuse { u8 link_cap[4]; u8 link_control[2]; u8 serial_number[8]; - u8 res0:2; /* 0xf4 */ - u8 ltr_en:1; - u8 res1:2; - u8 obff:2; - u8 res2:3; - u8 obff_cap:2; - u8 res3:4; + u16 res0:2; /* 0xf4 */ + u16 ltr_en:1; + u16 res1:2; + u16 obff:2; + u16 res2:3; + u16 obff_cap:2; + u16 res3:4; u8 res4[3]; u8 class_code[3]; u8 pci_pm_L1_2_supp:1; @@ -63,7 +63,7 @@ struct rtw8821ce_efuse { u8 res6:1; u8 port_t_power_on_value:5; u8 res7; -}; +} __packed; struct rtw8821c_efuse { __le16 rtl_id; @@ -95,7 +95,7 @@ struct rtw8821c_efuse { struct rtw8821ce_efuse e; struct rtw8821cu_efuse u; }; -}; +} __packed; static inline void _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.h b/drivers/net/wireless/realtek/rtw88/rtw8822b.h index 01d3644e0c94..12a123436741 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.h @@ -27,7 +27,7 @@ struct rtw8822bu_efuse { u8 res11[0xcf]; u8 package_type; /* 0x1fb */ u8 res12[0x4]; -}; +} __packed; struct rtw8822be_efuse { u8 mac_addr[ETH_ALEN]; /* 0xd0 */ @@ -43,13 +43,13 @@ struct rtw8822be_efuse { u8 link_cap[4]; u8 link_control[2]; u8 serial_number[8]; - u8 res0:2; /* 0xf4 */ - u8 ltr_en:1; - u8 res1:2; - u8 obff:2; - u8 res2:3; - u8 obff_cap:2; - u8 res3:4; + u16 res0:2; /* 0xf4 */ + u16 ltr_en:1; + u16 res1:2; + u16 obff:2; + u16 res2:3; + u16 obff_cap:2; + u16 res3:4; u8 res4[3]; u8 class_code[3]; u8 pci_pm_L1_2_supp:1; @@ -63,7 +63,7 @@ struct rtw8822be_efuse { u8 res6:1; u8 port_t_power_on_value:5; u8 res7; -}; +} __packed; struct rtw8822b_efuse { __le16 rtl_id; @@ -95,7 +95,7 @@ struct rtw8822b_efuse { struct rtw8822bu_efuse u; struct rtw8822be_efuse e; }; -}; +} __packed; static inline void _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.h b/drivers/net/wireless/realtek/rtw88/rtw8822c.h index 479d5d769c52..4ca7874fdc35 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.h @@ -14,7 +14,7 @@ struct rtw8822cu_efuse { u8 res1[3]; u8 mac_addr[ETH_ALEN]; /* 0x157 */ u8 res2[0x3d]; -}; +} __packed; struct rtw8822ce_efuse { u8 mac_addr[ETH_ALEN]; /* 0x120 */ @@ -30,13 +30,13 @@ struct rtw8822ce_efuse { u8 link_cap[4]; u8 link_control[2]; u8 serial_number[8]; - u8 res0:2; /* 0x144 */ - u8 ltr_en:1; - u8 res1:2; - u8 obff:2; - u8 res2:3; - u8 obff_cap:2; - u8 res3:4; + u16 res0:2; /* 0x144 */ + u16 ltr_en:1; + u16 res1:2; + u16 obff:2; + u16 res2:3; + u16 obff_cap:2; + u16 res3:4; u8 class_code[3]; u8 res4; u8 pci_pm_L1_2_supp:1; @@ -50,7 +50,7 @@ struct rtw8822ce_efuse { u8 res6:1; u8 port_t_power_on_value:5; u8 res7; -}; +} __packed; struct rtw8822c_efuse { __le16 rtl_id; @@ -94,7 +94,7 @@ struct rtw8822c_efuse { struct rtw8822cu_efuse u; struct rtw8822ce_efuse e; }; -}; +} __packed; enum rtw8822c_dpk_agc_phase { RTW_DPK_GAIN_CHECK, From patchwork Wed Dec 28 13:35:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13082982 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 525F1C4167B for ; Wed, 28 Dec 2022 13:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232926AbiL1NhH (ORCPT ); Wed, 28 Dec 2022 08:37:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbiL1Ngn (ORCPT ); Wed, 28 Dec 2022 08:36:43 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 828AB101E2; Wed, 28 Dec 2022 05:36:42 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id qk9so38432746ejc.3; Wed, 28 Dec 2022 05:36:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3q41smj/ytzNCubyI8baX/IOyt0BWi1B4JVJle7DtVs=; b=LpnNr+Q1krL40BPmaKAm9yeFtu0YJAiPWjQ2SxbadRPOOH4m4tJngQSUGeiQcwmi97 7EfUlYS0ZBi+WXFg549D4fN0UaJqgV36IZJ/mVgA73U6v/qbh+a7dsEl+c5CuB/YOE1g j8oGIYu2CWWRE/zOlhh8v/Gb/XwDkQHeRpLrAcHhxf17SbZye2x91/d2YV5IeX7dZL3a sKI3uS+mZLQrgtgwRfoQ5fl2PY+BNBNH7cCeY0n0Eilerme06UDVN2xbD2O4m3D8lCLQ b8rHT3SMVxv2zRYwmPNFq8hxKwM+9c0RLce8dvW+Ywl0YRciyfZBTFuBfVXKulI5G1ra L2YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3q41smj/ytzNCubyI8baX/IOyt0BWi1B4JVJle7DtVs=; b=ZU/lXFqhxJd7Med0UzI+g5H9FUVfWvKq9m213bz8srIPuunmhpQ41+Zd4WPI1M2NuD OPX0w59OzhSSf1pht8wmk3tPieb0awXVWLcT8wdsCPHqiUCTM+cv+d42mmYf1I2ZgQET K1lkmK42TjSMuGz6Z6IYi4WeuDZGhnG6FcQUn/MaV+BqzJHLNaClPbQmzdmqfT24DDlK BlLCXJ/ajfpJ4p5KNLZxUeMiW8739WL2JCZbJ/7puSu1QDyoCMpHpFOMt+qjdF7UPrjn 4kcSo4ufYF3WB32gF+ge1XWl+8Qy3RRAAzWbRTmGxvZzdUXOoIUzNjd/vVoFarg5p3Kx bemQ== X-Gm-Message-State: AFqh2kr61PYV9iIUCL5WteaN6MwVY+s/GqpDrJHN2t116LPhTJQKr1IM vaOz6qGccLC4mtisefYNqvwBPCX+QS0= X-Google-Smtp-Source: AMrXdXtMZ2irLyN6LgT+kvA24YzaE6vNH6PWdYx+kb/ya0zicrtv7m0ajHJPqS88u5Ouww9e1dCiAg== X-Received: by 2002:a17:907:7d8f:b0:7b5:911c:9b12 with SMTP id oz15-20020a1709077d8f00b007b5911c9b12mr25792298ejc.1.1672234600767; Wed, 28 Dec 2022 05:36:40 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-b830-5100-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:b830:5100:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id g3-20020a170906538300b0082535e2da13sm7450475ejo.6.2022.12.28.05.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 05:36:40 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@realtek.com, tehuang@realtek.com, s.hauer@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH 2/4] rtw88: Configure the registers from rtw_bf_assoc() outside the RCU lock Date: Wed, 28 Dec 2022 14:35:45 +0100 Message-Id: <20221228133547.633797-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> References: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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). Signed-off-by: Martin Blumenstingl Reviewed-by: Ping-Ke Shih --- 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, From patchwork Wed Dec 28 13:35:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13082984 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 234E1C5479D for ; Wed, 28 Dec 2022 13:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbiL1NhI (ORCPT ); Wed, 28 Dec 2022 08:37:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232923AbiL1Ngo (ORCPT ); Wed, 28 Dec 2022 08:36:44 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B24DF5BE; Wed, 28 Dec 2022 05:36:43 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id jo4so38419452ejb.7; Wed, 28 Dec 2022 05:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y+w5TwnAIJB6W6RWk0dufhbGDA9p9yyE6P/ljgdLyic=; b=bF8RnDFPQVshmuFhqMhkAfBhRcl50G89tS2g1VRrHnk9cCuh4C3GM/DWXDr+KRFOPP znqswxkZ6CPT2fxdj1jAXmJ9AwT7orPvGcqFgl8qKWbcKwhq2N0USl1iInZSb/3IXS/C vlu9RJdTvH3Bu8JVt2j0jtOXmRR4h6S20hVY61AspZ2aH/rZKaLgsAJa5Vpy6W9u9z7q pNt/a59rv3foMZM3XxQ6A/SOh8pPV5o5jQCqLLaNlQTfvYCiZ3TcNJUptLoS2BxBRyey PBxqbV+lgTzo3zV8qTQzCwVpA2aSXzrYBg6bkoZjsagQT1jSODjH4X15bulsVxflb6Uu KQfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y+w5TwnAIJB6W6RWk0dufhbGDA9p9yyE6P/ljgdLyic=; b=Dcn/ZlScDuLs725MkHCcfXXy1+u37zYjdMSTuOqzsC1PwVXEmINeAZzrRYZ+h0tWpn y2RcfPrP01+zyxrE9teYbvWz4jojA3WKniJQUjuKVtYbocOTqwm39jlQKlRj1I6e3/Ih Q36oSrmTj0wmVtOAy6CcLZUhm039MVgS4CS6CxniNXoiRG6bF7MHwl/n1tvYkPIAY/Ba vyMk2YryUUYDFnIo+0K1QPEJ9wsq/PXGtl3a2fgOnEkByyRI10Wo3tpZRsLkzV8tVbOE y74afSfVgfS5V6Vr69R/aFl7Voq63yDzVPTOmUQX8lYWIdJH7tftS7bVBE7zF/zZTttL A55Q== X-Gm-Message-State: AFqh2krhisBquHHMDKxuaIACR8SlTr3X02wmXZodTvb92wS3IRO08NnA JVCQIhSgri6M++9K1p53zqDHSGQF2ck= X-Google-Smtp-Source: AMrXdXuwHz14OTEMBZHkRZBLykO9NhRXqbTRM9y5xCwgQjo5mXQva77u1S5UlDGNX+3FRgTW9hRNMQ== X-Received: by 2002:a17:906:c0ce:b0:7ad:d7a4:4346 with SMTP id bn14-20020a170906c0ce00b007add7a44346mr27381367ejb.66.1672234601607; Wed, 28 Dec 2022 05:36:41 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-b830-5100-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:b830:5100:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id g3-20020a170906538300b0082535e2da13sm7450475ejo.6.2022.12.28.05.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 05:36:41 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@realtek.com, tehuang@realtek.com, s.hauer@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH 3/4] rtw88: Use rtw_iterate_vifs() for rtw_vif_watch_dog_iter() Date: Wed, 28 Dec 2022 14:35:46 +0100 Message-Id: <20221228133547.633797-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> References: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org USB and (upcoming) SDIO support may sleep in the read/write handlers. Make rtw_watch_dog_work() use rtw_iterate_vifs() to 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). Fixes: 78d5bf925f30 ("wifi: rtw88: iterate over vif/sta list non-atomically") Suggested-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl Reviewed-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw88/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 888427cf3bdf..b2e78737bd5d 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -241,8 +241,10 @@ static void rtw_watch_dog_work(struct work_struct *work) rtw_phy_dynamic_mechanism(rtwdev); data.rtwdev = rtwdev; - /* use atomic version to avoid taking local->iflist_mtx mutex */ - rtw_iterate_vifs_atomic(rtwdev, rtw_vif_watch_dog_iter, &data); + /* rtw_iterate_vifs internally uses an atomic iterator which is needed + * to avoid taking local->iflist_mtx mutex + */ + rtw_iterate_vifs(rtwdev, rtw_vif_watch_dog_iter, &data); /* 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 From patchwork Wed Dec 28 13:35:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13082983 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 ECE4FC4167B for ; Wed, 28 Dec 2022 13:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233013AbiL1NhL (ORCPT ); Wed, 28 Dec 2022 08:37:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbiL1Ngp (ORCPT ); Wed, 28 Dec 2022 08:36:45 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157CF1A5; Wed, 28 Dec 2022 05:36:44 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id u9so38550432ejo.0; Wed, 28 Dec 2022 05:36:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7cV9Fdo1DL6GcPAsaixy13a9upftzi/bKQrV6XnSaJE=; b=USJJdxr3Yz8nPXAAgyGOZVykqPmSUXeK/1ry0KFjCY4hRH9aQWpkx9ZKCwUvS584LV 3HhqWFaVguLKjkYq8mRugAQ9zk9YkAxiUc9efCumVsgRzEfzQ6EN1065HgROUie4jPPG vAj84V1WGloWB6MzSoW1mJxCuhYjFrup/jdHI+DJ6Us+WV6Qq9i0GBRY+1UtrBvBTCAl +mqO8WOHkzeQz1df6+SckyhA397MA5O99MwtWmyBkXFl7FJQ+1ZuS5s9/C9+WRKagckQ tyIgytef+lt5OPs15rEhdyo7K4egpTm5rnoY6NeVyQVm1XqIF7DVDSOq94jrVjFNMCiz 9Xng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7cV9Fdo1DL6GcPAsaixy13a9upftzi/bKQrV6XnSaJE=; b=GaKXG8tpKAsQ8igP5/xpKrq/kAuTTSSmVAg4Chh52TQXqjeI71Z65Z3k2iPzw9Lig4 rR4xMgY23WeOt8QVQY7G509sO+W7TuV81N6sc3UCzdZ3yFq79R2oCjGvVUMtZ6OiSnRi WyzNYOxSl4uB4wB7DleuB+u06Acr46IM1v9iBvlrUTTvA0tWVIwFBanS1lCWCGY4159A bncOMSICqiOObL1teCd73v/PE6kGYc/EpiAuJknOF+afnQcFVO3zlDqaqSg3teFqDEHP 4zkv+xti5laCJS1gzrHKcSjw+y+5UGRtlIvf9mogmFiMkFMKKEdpULswzf1FO8GR/AEq aaCA== X-Gm-Message-State: AFqh2kpuYMMwOAGI0Z4/oB1zsfly6RjWpoEoWgNhLUq27ieHBkmnJuVU 3Q/wWI205KfqbCSv5zGSg3hGFUnPJiY= X-Google-Smtp-Source: AMrXdXsjhQ2pro9S2msXgEkEhAegxknZw8ooT5nRpSojikoYXWDpEfjoMoGN6JfJAJAae6odJFUHLw== X-Received: by 2002:a17:906:6d2:b0:7e7:4dd7:bb88 with SMTP id v18-20020a17090606d200b007e74dd7bb88mr18612063ejb.57.1672234602426; Wed, 28 Dec 2022 05:36:42 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c23-b830-5100-f22f-74ff-fe21-0725.c23.pool.telefonica.de. [2a01:c23:b830:5100:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id g3-20020a170906538300b0082535e2da13sm7450475ejo.6.2022.12.28.05.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 05:36:42 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@realtek.com, tehuang@realtek.com, s.hauer@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH 4/4] rtw88: Use non-atomic rtw_iterate_stas() in rtw_ra_mask_info_update() Date: Wed, 28 Dec 2022 14:35:47 +0100 Message-Id: <20221228133547.633797-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> References: <20221228133547.633797-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org USB and (upcoming) SDIO support may sleep in the read/write handlers. Use non-atomic rtw_iterate_stas() in rtw_ra_mask_info_update() because the iterator function rtw_ra_mask_info_update_iter() needs to read and write registers from within rtw_update_sta_info(). Using the non-atomic iterator ensures that we can sleep during USB and SDIO register reads and writes. This fixes "scheduling while atomic" or "Voluntary context switch within RCU read-side critical section!" warnings as seen by SDIO card users (but it also affects USB cards). Fixes: 78d5bf925f30 ("wifi: rtw88: iterate over vif/sta list non-atomically") Suggested-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl Reviewed-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw88/mac80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c index 776a9a9884b5..3b92ac611d3f 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -737,7 +737,7 @@ static void rtw_ra_mask_info_update(struct rtw_dev *rtwdev, br_data.rtwdev = rtwdev; br_data.vif = vif; br_data.mask = mask; - rtw_iterate_stas_atomic(rtwdev, rtw_ra_mask_info_update_iter, &br_data); + rtw_iterate_stas(rtwdev, rtw_ra_mask_info_update_iter, &br_data); } static int rtw_ops_set_bitrate_mask(struct ieee80211_hw *hw, @@ -746,7 +746,9 @@ static int rtw_ops_set_bitrate_mask(struct ieee80211_hw *hw, { struct rtw_dev *rtwdev = hw->priv; + mutex_lock(&rtwdev->mutex); rtw_ra_mask_info_update(rtwdev, vif, mask); + mutex_unlock(&rtwdev->mutex); return 0; }