From patchwork Thu Dec 29 12:48:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13083487 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 B5588C53210 for ; Thu, 29 Dec 2022 12:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233122AbiL2MtR (ORCPT ); Thu, 29 Dec 2022 07:49:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbiL2MtP (ORCPT ); Thu, 29 Dec 2022 07:49:15 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC7313D50; Thu, 29 Dec 2022 04:49:14 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id s5so26545496edc.12; Thu, 29 Dec 2022 04:49:14 -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=oiGoLUnjOTf7e6Jl/lm1CqIHOz+PnhchazFWlsj2FA0=; b=qLQpmWfq4dgok0NDj5piPhut7qxDewoNVuh6k5Gy5XVvBR6aUIMPKcZvMot4wlnqJA cVkiGVJaMuGxjP00yujDRhuI4BhIc3Q+9VYsNNeEnsEnaeN8MpBe9JF2f092rJsCNzQz yavUZMnOk+XIn0vopyTt6VjcWVQBhIlNkRZL7KyBFu3YAszjRHXrIs+aYb2jRETA6iBS cRbH3Xdld+lcwzknB0TxM2YrMC55mIZsP0CmKTv0krOcksuPmrEa5QhncZmFnDGMrUnf xhtqf0E9I/vMSEUAbJ8H6oApAwjQdcLt7VB6U2rsx81ieqFn5vjFlon1oqdVHvWugmLa XU7w== 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=oiGoLUnjOTf7e6Jl/lm1CqIHOz+PnhchazFWlsj2FA0=; b=Y+4vjQ+fObTsVRS5kDkmKYFEyfzyIpJDktGQHjLOw4lIhfxPYCHLLMEgaeoJBnLieH xRFtX4UFFMfaNw4htSziz6gcu1PHp4GieQNep0yK8nS3ZVNe2kWJQ7T20w6yp/+zYyNe GTGDJLJAFkbkNDRZsJHdAGA4ABl2X+jJdow5E7kiiHw6QGBUl+nBc2TDwamlPR70tbKU 6FCnt80lUHhCnXyoK6ERzmDA63QSTSv/Ah4vB/rR7YkDLiTPqGQu/WHe4hxi4dbKcgsz OOKJEI+yhDE8Yiko8y71n33a6zmj08xmzxwKfXxSm5YGLuDcoQjZyXlpf1wyYZ01QJ2L bgoQ== X-Gm-Message-State: AFqh2koRoW7MpUlC0CHDd1JwHTdhO86SkfKiOb8S3Lu28JXtmodzf4c3 IacqR0dfLOQftKmJj0RY59eJw8mjDto= X-Google-Smtp-Source: AMrXdXvik6JDzwc7E2FlR4SlqauXFvJtS1c4X0ETKjtsBYqhpkqjrGAkjeUpVXnylA7tSAfJdF7d9A== X-Received: by 2002:aa7:d448:0:b0:467:b851:6066 with SMTP id q8-20020aa7d448000000b00467b8516066mr31660784edr.6.1672318152146; Thu, 29 Dec 2022 04:49:12 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7789-6e00-0000-0000-0000-0e63.c22.pool.telefonica.de. [2a01:c22:7789:6e00::e63]) by smtp.googlemail.com with ESMTPSA id b12-20020aa7dc0c000000b0046892e493dcsm8166299edu.26.2022.12.29.04.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 04:49:11 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@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: Thu, 29 Dec 2022 13:48:42 +0100 Message-Id: <20221229124845.1155429-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221229124845.1155429-1-martin.blumenstingl@googlemail.com> References: <20221229124845.1155429-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 split the res2 eFuse field (which for some reason has parts of it's data in two separate u8 fields) 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 Reviewed-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw88/main.h | 6 +++--- drivers/net/wireless/realtek/rtw88/rtw8723d.h | 6 +++--- drivers/net/wireless/realtek/rtw88/rtw8821c.h | 9 +++++---- drivers/net/wireless/realtek/rtw88/rtw8822b.h | 9 +++++---- drivers/net/wireless/realtek/rtw88/rtw8822c.h | 9 +++++---- 5 files changed, 21 insertions(+), 18 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..6ab16f56b5cd 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 */ @@ -47,7 +47,8 @@ struct rtw8821ce_efuse { u8 ltr_en:1; u8 res1:2; u8 obff:2; - u8 res2:3; + u8 res2_1:1; + u8 res2_2:2; u8 obff_cap:2; u8 res3:4; u8 res4[3]; @@ -63,7 +64,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 +96,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..35a937fc5162 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 */ @@ -47,7 +47,8 @@ struct rtw8822be_efuse { u8 ltr_en:1; u8 res1:2; u8 obff:2; - u8 res2:3; + u8 res2_1:1; + u8 res2_2:2; u8 obff_cap:2; u8 res3:4; u8 res4[3]; @@ -63,7 +64,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 +96,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..868c0e6825e5 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 */ @@ -34,7 +34,8 @@ struct rtw8822ce_efuse { u8 ltr_en:1; u8 res1:2; u8 obff:2; - u8 res2:3; + u8 res2_1:1; + u8 res2_2:2; u8 obff_cap:2; u8 res3:4; u8 class_code[3]; @@ -50,7 +51,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 +95,7 @@ struct rtw8822c_efuse { struct rtw8822cu_efuse u; struct rtw8822ce_efuse e; }; -}; +} __packed; enum rtw8822c_dpk_agc_phase { RTW_DPK_GAIN_CHECK, From patchwork Thu Dec 29 12:48:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13083488 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 3D563C4332F for ; Thu, 29 Dec 2022 12:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233216AbiL2MtV (ORCPT ); Thu, 29 Dec 2022 07:49:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbiL2MtQ (ORCPT ); Thu, 29 Dec 2022 07:49:16 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCCE63E9; Thu, 29 Dec 2022 04:49:15 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id g1so12353739edj.8; Thu, 29 Dec 2022 04:49:15 -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=jS0BiJw2eP0LQeJB4SgDtJllStgyNgULQaap6Y5302g=; b=qUxgdoWcXPNKGV3jwKEZYVeP+ev4EebR7XyHf8T2jnR2VWM35VS03JfARWCYMCKuVH Azz47TJAb6TGskMibN9h9OukfXB0Jcrm+9TkiH5JfUebfu3trOqIMk3TBn6EKzIHu/s8 EFCk81y85REqM5c2+o8fShnAamaGg3vp65NLULXplDl5/zebxLRoN7dv8GLVGU8qPOho h3RwZIM2VCw77M+6YAu6sQw+zTIX6GxXmwkhXntVWmLIPct70U3O+aiK30oYceodzsgh bYTIC/CNBPaWk06st51LO9tlrDgCIYkn1L99JPcDfHN8TGR7RqLyJcSuL/62eUR8+hWw UX1w== 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=jS0BiJw2eP0LQeJB4SgDtJllStgyNgULQaap6Y5302g=; b=EEIh645jqMn2X5j6OPJOa+YFOHGyJS7qhppZNH0oWN8VKP3yPkfutDxh+Mo9hzevBp ZbTFLg4cD2pkr61rRAwdtMIxxM4C4Z28NdO46a66ixfWC+5kN/Cdtmv8Dv94ut7y405K 7yZ7KChWoH9uanyoT1f0s36iyWVCIrm2Ko0Eyzc0RaZV8Qx6CpTjLvpOUAzEaws64p1b RxoWCxsQ/213AcDaynzdq1pQlh5RGagIh5yh8thw3cB/pHbPBdj240eJmBtC/w4SMIYA Evzt6s2NVAp8qYXnpku5RqTgUDHFmS0w8s9ZdXPUJfNg7gK7HniAnbmmOaf1UC7HPdM8 9zrw== X-Gm-Message-State: AFqh2kraudP7vuaDmVX9szE5keQsH2UdDFnIn/OqPk85mNx05QyVYtbN w1Q+mhhDr9tgRdh23HmaPOSbIEQQZic= X-Google-Smtp-Source: AMrXdXsunfKh92D2/cZnTt4ol0i/ilao2jAh47Nmz9xmsczrGF7l7VU4C3EPAjodMDSnisYURfmS+Q== X-Received: by 2002:a50:ff0f:0:b0:47f:5c62:310f with SMTP id a15-20020a50ff0f000000b0047f5c62310fmr19001519edu.35.1672318153389; Thu, 29 Dec 2022 04:49:13 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7789-6e00-0000-0000-0000-0e63.c22.pool.telefonica.de. [2a01:c22:7789:6e00::e63]) by smtp.googlemail.com with ESMTPSA id b12-20020aa7dc0c000000b0046892e493dcsm8166299edu.26.2022.12.29.04.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 04:49:12 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@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: Thu, 29 Dec 2022 13:48:43 +0100 Message-Id: <20221229124845.1155429-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221229124845.1155429-1-martin.blumenstingl@googlemail.com> References: <20221229124845.1155429-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). Reviewed-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl --- 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 Thu Dec 29 12:48: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: 13083489 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 30539C3DA7D for ; Thu, 29 Dec 2022 12:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233404AbiL2Muv (ORCPT ); Thu, 29 Dec 2022 07:50:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233090AbiL2MtR (ORCPT ); Thu, 29 Dec 2022 07:49:17 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18AF81277B; Thu, 29 Dec 2022 04:49:16 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id i15so26623811edf.2; Thu, 29 Dec 2022 04:49:16 -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=fg+vEqAErRjfJQS0/hInbwE16nRV7CNR4R99NQ21R+I=; b=LBTmQnMTbFUzmaX6mkw/x7IQVw3oGfTZGmV0KiQBv+9K0pNEwGXourydtFnItjyO9j o2USVnnOnMCN9JoM2ToKWa3BJrgDEbK/UzbBpsTWiYOK3efI05X5hAWOjgaijd4qEK0T M8Jsp1+6G3FwqXKFBSjJnN5M3KGT8MLq40/UKWTT2qoTKqXhfJBwxfgftZLfs8jv0orT Gec1nnqXfDKCF+RropCNwT7tTuzGkiEURVlbG1xdqRKw4+kbc0EBufjQ9YHWK3Svzv+A Mw0sHLmX/41ubzwZB17jrtlSX8dZ155SS/0TGdixS+6p8yN2TTx13m2Wb5CZCCzx+B6d TxSw== 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=fg+vEqAErRjfJQS0/hInbwE16nRV7CNR4R99NQ21R+I=; b=vIMfFYYI1kndJ1qQaEKBysNyNSl5DJ0foQkv4mD9rGjeS9q6IulcKO0LaTKzIoqWLt 3AUT4pKr1WaTDLvdM9y6LLwqCR5tX4gKL44aiq9T48Na5YXI8JZIgVqAy0F+bWCkm01n Rno3YcV40YIb4TJd6FWxm1oAjpVYdjl4yOOLu9qP1/7ISZR0pr5nVl9TEHtjuOCzEk9g bEOklNK4fapGSrYe7lFSIUIUt5ajoKQVM8mdUWgPS/6G5eDQuSouSDnfB2j6/nSAjBtB /PTPid1I5jXwwybxnoyw1urD5MCi7bSpNWzrp2HILXhEyh8CR3TV1hVNd+J+nCt2DWOa tnwQ== X-Gm-Message-State: AFqh2koM7ij6gyExYkb9r8NsKK+C2SSRWqkV2RTbYUFI9muMJr0LNd0r OCMRGZefFiSlnNnjcTtbDvPGTpo/qPU= X-Google-Smtp-Source: AMrXdXtIhIFj/fgwd5upKntEX0RHdhfJsgS2SRg/x+Ome4DVhMn3tycHMd0Ti92sQJks3pKNFZ4XZw== X-Received: by 2002:a05:6402:3807:b0:47e:eb84:c598 with SMTP id es7-20020a056402380700b0047eeb84c598mr22161141edb.30.1672318154404; Thu, 29 Dec 2022 04:49:14 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7789-6e00-0000-0000-0000-0e63.c22.pool.telefonica.de. [2a01:c22:7789:6e00::e63]) by smtp.googlemail.com with ESMTPSA id b12-20020aa7dc0c000000b0046892e493dcsm8166299edu.26.2022.12.29.04.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 04:49:14 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@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: Thu, 29 Dec 2022 13:48:44 +0100 Message-Id: <20221229124845.1155429-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221229124845.1155429-1-martin.blumenstingl@googlemail.com> References: <20221229124845.1155429-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 Reviewed-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl --- 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 Thu Dec 29 12:48: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: 13083490 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 08123C4708D for ; Thu, 29 Dec 2022 12:50:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233412AbiL2Muw (ORCPT ); Thu, 29 Dec 2022 07:50:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233184AbiL2MtS (ORCPT ); Thu, 29 Dec 2022 07:49:18 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F06691057B; Thu, 29 Dec 2022 04:49:16 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id c17so26517719edj.13; Thu, 29 Dec 2022 04:49:16 -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=FdmvaeMNmNESXg2Bm+GivnT9MUmG0nTE7m4Nif5YY+w=; b=XyKTz13T3nT39wJI2E8a+WhRDTPnxNtpjRpmPXYcFPRxb4Y1UemPmrXlUMMoegYBu1 PKMgpVzl+JvZ+pU3Ig5WSPs2QGh+GblNk9uYtdnnpPjIUMpSO+etz6bRV9yPMVOjJ2ip aICV9p53iaE1JBPF/3JBxlhk9grBpDEu2Mj6vxNkNWngL11EOLYDWjqN1YGefHCXBd3T TowLRu4ByOzsYDhfm2LBUnJXlRt+XQSszHIFT5qn4NWcA7zKAHTcjVTDhxkNnFvokdr5 xV2vtwBUt1IwwC6Q+TSDGyvkdg/fDqxi8FWzTfGwuccGrch4R5gF/u9D9dTK+4Kzof/B bO+A== 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=FdmvaeMNmNESXg2Bm+GivnT9MUmG0nTE7m4Nif5YY+w=; b=Qm6QSxCEr4mOsyns9TLeEnMqlgkKuA7ia3KYiNh/UUql1lLfI/3ENfpjmMsQi7G8vg ikFg/JwhhLHH4Eglgd5Hnm90abkXE4OlIagwbGvsoKrcczGwpBTaMV+RFR14bveVVRCc 93wbtdkEwrzoWIJPtuz0cviiv+qMyUaVjLh5KbEJk1r258fRdqNRdmgIkHBpWg2a4zHe viUPNJEQs9QiYBuRJt8zYbt++5MJfIY2c9TEmEEbBl47hWKu40rLBMb4Mn1/nWxZNUsN yEUO4DZyQcCB1vHpLPv31HovclAjZpH/5osU1GpDu5NgBWbjPPHL29CyMfZQSFwkcwsv pwgg== X-Gm-Message-State: AFqh2kq0hkOaLHqpukvVSxWsDEcTRelgibUgUK4rZRBPW2+eFXN+aS0t AuKFHjffxOT9RjhgjbeTXm7D2YbD+Ss= X-Google-Smtp-Source: AMrXdXt7M9fcIhyspkEURxl3uMIC5sS+7gdrmQhg/daPLFCN35b5gLQAWLyPPvoWOQreq9zyn3KXQA== X-Received: by 2002:a05:6402:1609:b0:46a:f004:5e38 with SMTP id f9-20020a056402160900b0046af0045e38mr23718823edv.37.1672318155241; Thu, 29 Dec 2022 04:49:15 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7789-6e00-0000-0000-0000-0e63.c22.pool.telefonica.de. [2a01:c22:7789:6e00::e63]) by smtp.googlemail.com with ESMTPSA id b12-20020aa7dc0c000000b0046892e493dcsm8166299edu.26.2022.12.29.04.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 04:49:14 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, pkshih@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: Thu, 29 Dec 2022 13:48:45 +0100 Message-Id: <20221229124845.1155429-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221229124845.1155429-1-martin.blumenstingl@googlemail.com> References: <20221229124845.1155429-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 Reviewed-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl --- 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; }