From patchwork Sat Jul 17 20:40:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 479766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD96AC636C9 for ; Sat, 17 Jul 2021 20:41:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA00061103 for ; Sat, 17 Jul 2021 20:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235499AbhGQUoK (ORCPT ); Sat, 17 Jul 2021 16:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235304AbhGQUoK (ORCPT ); Sat, 17 Jul 2021 16:44:10 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2803C061764; Sat, 17 Jul 2021 13:41:12 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id m11-20020a05600c3b0bb0290228f19cb433so10284515wms.0; Sat, 17 Jul 2021 13:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ub1HsGiuNnybNJs5WdbxXtwzsH2TKD1etrBmG16trf8=; b=CiZLuaEdJVvFa3WM66L6CR/35+LZUZSrfCevHyRoEkFnH4KdzSFrXdeZME8n1yc+hV RWZOVc4gC05SyYNN2QbkyjWayfDHAs5wSEeoiq+GFrXEz/RvNyTqtSoLC92y5m77nmcA 7nxU2jrSov5688YJpZN82LlneC+NJZT59kD5dQs5mHMeV2abb2WGsPEm1cCAdhUzKqKA Tee1TBflos3ZLu5nZ4NBrYLHkxyAWtVUfJgqTSNmD3/EeDB3o6pCQoPaYs21udFGpqYF vshwB300xpelsyW+Cd3Ovusvt7YsE51YJd3HC71a8L1IaqncV/X0PUNr/nH3rxYBaiY/ U43w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ub1HsGiuNnybNJs5WdbxXtwzsH2TKD1etrBmG16trf8=; b=cSlShcee4xS7M/O7m/thg9WyfjOPsuogCfaMxxGpuRKhssBibNBBojoIQN7tUGoz0D s05POUaBmmYWqJzLiw3AMIn1P5Aq/FP6kpdmRfKQkZ9K2aFn3G7G+rlhM+A3lBgplTNt QCubH8HfOFWLFQu9GO0t9wgfmWWc3OUfGDhEtG3OWrKXaHGxZi1lbdWtByVCnGyptF4H QyZ3vRACAO9L6LRxV4nO8s12EKaxR7Ru2jJOZdvu9DrIRM1a5lOKNsUxHMqbzsrK6SrH vs36gQG7N+5XZSK7fztLtK4MCtgmrlq7RWjQvFYZCDcBq9iv5tGN+7jxFwZIZsqMNFV3 tDCA== X-Gm-Message-State: AOAM532Y33T4Ly657F2/hxSC5Emm1WxjbB//HbN+CKdz9n7d9r7J3lY2 kZTFKRAZcUrPmX4MuGNPhon/LheKydw= X-Google-Smtp-Source: ABdhPJwuLk7/VOAal/tp1Jo2xRjrL13P75si/BZkcu4Ws2qee0BmuGxZO349GBQxWxVvwWo1HMC66A== X-Received: by 2002:a05:600c:246:: with SMTP id 6mr21335374wmj.143.1626554471334; Sat, 17 Jul 2021 13:41:11 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:10 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 1/7] mac80211: Add stations iterator where the iterator function may sleep Date: Sat, 17 Jul 2021 22:40:51 +0200 Message-Id: <20210717204057.67495-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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 --- include/net/mac80211.h | 18 ++++++++++++++++++ net/mac80211/util.c | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index d8a1d09a2141..77de89690008 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -5575,6 +5575,24 @@ void ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw, struct ieee80211_vif *vif), void *data); +/** + * ieee80211_iterate_stations_atomic - 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 05e96212b104..c6984d0464f2 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 Sat Jul 17 20:40:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 479765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB992C636C9 for ; Sat, 17 Jul 2021 20:41:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9B1D60E0B for ; Sat, 17 Jul 2021 20:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235678AbhGQUo3 (ORCPT ); Sat, 17 Jul 2021 16:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235603AbhGQUoM (ORCPT ); Sat, 17 Jul 2021 16:44:12 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28AF2C061764; Sat, 17 Jul 2021 13:41:14 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id u1so16232326wrs.1; Sat, 17 Jul 2021 13:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tPr7LAmpU6jyv73PvT3aqNoJ9gxeSNay3lgZkX9Owew=; b=oqR3B2p7Dz3pZE49V3HySWH7R69B2m6be3Y7fHHrUoKKK1ns82+VxxGcuyzN3eFi6Z tZ+ZJED62OWpAo/Tc3p6XtOMFc7Yf25JtDE4E7kqBLu4/HZDCJD3dwtUkRwaG4odV3pu 53o3Gfc7kUeXov30zckdSSpWAdJ8meNFjKVH1sDaPg988qtQc9X41w427u6fNp/RDQZE 9w3h2Pyv2huCn6kkkTREpygwfN3lrMsFEiyzeX1eRydSWqZa//njqdZlXThLl7u2Zq+A GJumDOyDl240Ps8J23hFyi3qN58mMLVYAN7ipOaUX5siIJ/lMDeY6xclqPm/ocl+WcwD rfgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tPr7LAmpU6jyv73PvT3aqNoJ9gxeSNay3lgZkX9Owew=; b=JCvifR9yMc6r7uSP2cIQAPeSHpcDJg5Mf/wzPyB/Syh/De12k+cIHma07No4T2Wrqj +x0uyWHnl7FvvR5XbbkDC5HdKYis8Vbt3ycM8dBNgQXOkdJ5EhkzEOKhc5/KseInYo8p /F73povOq62YYZb/Dy44HgqXqyIO9NmSoA43IIKEVX0zVl1yH4Aeiz8As45RbTPbk4Us bpsrh44x1lDuElvMJYXvP+9VYkKDjFR+DUaN2KSJ/vxEPJkS4lioRejuEnOg4peISkw7 4KJAuFewlFINFrbSMs+K+dyz+fcemjmB7G5iQEIFXaW/LRYWgRTMMRl17qlt+swBVWt/ qaOg== X-Gm-Message-State: AOAM5308D7wk323lOHCRY+1B6UWv3PDufYFIaoK7b8OFKgyT+XOQTtFA 5uuUw0gcLavvlXX9foaGY9aunhLwIBs= X-Google-Smtp-Source: ABdhPJxUfvevUhOuI0hyiP84rLEwP67gmLb8dOHuZtzP8MUM/lM252U2vJjrz+G8/mWB6mDjlWdFbw== X-Received: by 2002:a5d:5987:: with SMTP id n7mr20756010wri.263.1626554472448; Sat, 17 Jul 2021 13:41:12 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:11 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 2/7] rtw88: Use rtw_iterate_vifs where the iterator reads or writes registers Date: Sat, 17 Jul 2021 22:40:52 +0200 Message-Id: <20210717204057.67495-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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 | 6 +++--- drivers/net/wireless/realtek/rtw88/ps.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index c6364837e83b..207161a8f5bd 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -229,8 +229,8 @@ 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(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 @@ -578,7 +578,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 3f0ac33156d6..95f9060b083f 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 Sat Jul 17 20:40: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: 479533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 929C2C636CA for ; Sat, 17 Jul 2021 20:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A86361151 for ; Sat, 17 Jul 2021 20:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235779AbhGQUob (ORCPT ); Sat, 17 Jul 2021 16:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235609AbhGQUoN (ORCPT ); Sat, 17 Jul 2021 16:44:13 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AEEFC061762; Sat, 17 Jul 2021 13:41:15 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v5so16221236wrt.3; Sat, 17 Jul 2021 13:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uk0gQtyHe+7seTs9c47Ts/miKfxRiB6TKSQHr8dMLFs=; b=PaSgDAONVjZRZ8egE8bl4q9kszRYtLcpEPCaq4ebtf++SsgdHXQjZ0TdwifKjku80s NUeqYMPyG9bFm/2mE4NFZdM/BGqN7MrTGUe5C2HVHg4hmfscZkMcCxjv/O/9bteWaSQG 2CmJ4qyKJJm9x0L5/xlZIrL1vKMzxLQO0AIadd5NSScqybX/0G6W0tD1rorJlw5Dm43f NVrFaZS8uCqXd+8UG0v82CwtuTaUbQxXg0jiTqQr+1XB1iDAV/bEvbcI4u+5Be8trKLK GD1umNt81Cr1q3WdVnlcnyv40eL8PW9x/WkBe0jTvZjQv6YBmXAXbXpMa2Pu1Vj72Vma 5+OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uk0gQtyHe+7seTs9c47Ts/miKfxRiB6TKSQHr8dMLFs=; b=mSt5meGbfaopN+wr9frGsxJ5zVaVTJLpqdd23040rOXRzNrIQ73a3wtfJBVUahlIrN s6k4Obl6U2ORAtQ78OR7VCKiKK1D1CvEsojGSu4OqK15+irGyWSsf6cvH1oBkYNqEyyu 8ojxCk7OWElKs64cwbwgMi3b3c8JN7XtNgINz462XP42j9VVYm68MhXVGx8cAdutNGag wtqXIKpbwYII9jlcfr4agE+c9EiAZOVyt/3F33oY398A1rlcTc0ZfSFPFyl7XwEs/+o9 F6+rwT8eQ1wswo0iMm0XPClHtYAu0um+95LRBleDb9Rt3ruo2v+3gfSFj0p37pk5Sr+e 3oCA== X-Gm-Message-State: AOAM5337gsWNws9ltObdicxNjvOURDj++wWWw1GQrIsvhucUZ743rHur 7q1b20q5HooU6jhzGpDTuVPUdl+yHYY= X-Google-Smtp-Source: ABdhPJzuO8mojLgo0pHNtVhw4KS7FjmYW13zBLHNuoWZiI56hqh709Rw4RKei+w3Qr8wmUc0WdbHhQ== X-Received: by 2002:a05:6000:231:: with SMTP id l17mr21054508wrz.40.1626554473554; Sat, 17 Jul 2021 13:41:13 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:12 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 3/7] rtw88: Use rtw_iterate_stas where the iterator reads or writes registers Date: Sat, 17 Jul 2021 22:40:53 +0200 Message-Id: <20210717204057.67495-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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/mac80211.c | 2 +- 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 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c index 6f5629852416..7650a1ca0e9e 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -721,7 +721,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, diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 207161a8f5bd..6e0d25f0afe3 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -577,7 +577,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 569dd3cfde35..8f2827ecb514 100644 --- a/drivers/net/wireless/realtek/rtw88/phy.c +++ b/drivers/net/wireless/realtek/rtw88/phy.c @@ -240,7 +240,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; @@ -484,7 +484,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 fc9544f4e5e4..9c4050d4c6e2 100644 --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c @@ -429,7 +429,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 void rtw_wow_config_pno_rsvd_page(struct rtw_dev *rtwdev, From patchwork Sat Jul 17 20:40: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: 479535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC11AC636C9 for ; Sat, 17 Jul 2021 20:41:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9840161151 for ; Sat, 17 Jul 2021 20:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235865AbhGQUod (ORCPT ); Sat, 17 Jul 2021 16:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbhGQUoO (ORCPT ); Sat, 17 Jul 2021 16:44:14 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A1E1C061764; Sat, 17 Jul 2021 13:41:16 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id b14-20020a1c1b0e0000b02901fc3a62af78so10258895wmb.3; Sat, 17 Jul 2021 13:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dhCvrW6VDzVeJLnbwvW9u01I7iypqs1UknLeEWPJNXk=; b=l3WLbYi8AwPUrAcxJ2L8LNl5UV1hhGlfUCqZVZk5ip+NgRprX8CPtkvcgifEQrnTnW eHpfnEa2cDBuU3zb912a40lJtK+sHb4ARAsAZnao+f74m+zXgob5DG3ZHyAoqt9UJglW c5FfsdcHtk80AI/oY0+nKZXEYDlFSnJ/AXnyDi/nmYelRNP1/ta7n3D7ra8oZAwmCtJ2 ZozAS1OGoYkKLSkM5sXgSXY6GsjCfbqxyaxd+CGSIIk5ZdckUy3JMk1gZQx/wPPSnsfM npZc0Ocv728nkuLlwpeT4C1f873Op6mCswBC8CADkp2FvEwALJTj7OcWl5II2q8ztCTb 3HOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dhCvrW6VDzVeJLnbwvW9u01I7iypqs1UknLeEWPJNXk=; b=elnY5SrvWbP6hMlczo6mgt0UxZE02k7kxY6U7fwXI1WA9VSO8eapuyh5A93KfngyvF lm+8Ms81mK2QdTjTrMNTwqr7tfcjeHfQOxCL8TyLAaa6UnrzWkkrS2KDKTm7vbt96Hwz r3YEb8biSVwRIRnhJqzDnvzWVZxa+lP4oUwKcNbH1xGpRpv20tfxB0Z248zJiTHEMren Iu/SVBzgLB3bOGiPp+pPkMjUqN+++cFNFYNHntvqtRlPjEZY6AZb78uWNGJboiHDKvqY SZnKWNOr9aUI8G83z7B+xO8pKIzTihwUBEofiHYDQVYiJmplbdRjroTHlV90BY7eYJrF oNKQ== X-Gm-Message-State: AOAM533N2QcYpu28ZUhEkrhdxW2FuEMsVmVwQuw1QkVt5LyEjcFYHMGU mScPpydp7Wnab/eNll0x41Ezd1QIW7g= X-Google-Smtp-Source: ABdhPJy/zCdnIuXOe4369cvTIvSEMaWbZhSmnQh2PShVOcxnWt6mIedkTVfQOwrhYwZF7fYulRCTww== X-Received: by 2002:a1c:a9c6:: with SMTP id s189mr13090699wme.143.1626554474426; Sat, 17 Jul 2021 13:41:14 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:13 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 4/7] rtw88: Replace usage of rtw_iterate_keys_rcu() with rtw_iterate_keys() Date: Sat, 17 Jul 2021 22:40:54 +0200 Message-Id: <20210717204057.67495-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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 6e0d25f0afe3..e40432b1dcee 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -574,9 +574,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 Sat Jul 17 20:40: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: 479534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7C67C636C9 for ; Sat, 17 Jul 2021 20:41:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5A7161103 for ; Sat, 17 Jul 2021 20:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236053AbhGQUoj (ORCPT ); Sat, 17 Jul 2021 16:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235625AbhGQUoS (ORCPT ); Sat, 17 Jul 2021 16:44:18 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF85C061765; Sat, 17 Jul 2021 13:41:17 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id l6so7879182wmq.0; Sat, 17 Jul 2021 13:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x+Od9A6k+Mx3oOsy+sHLyJqYPR0woYwsH4hDTgPiCu4=; b=ixN4prt3eNJpDmPoxtWXzP5O/6zEOsVyObd2lNpRe21XGp2P2g9HFHzGghz2jAzQrD zAHG/n0DHWHi4u2hUTQorjYgtSCG8H8E0JMpt14c6NC6wt1gQLzwSp/nb/OqlTsycxlw ZOFOVH/zsuzdmu/M0U/EHzbi6eQJ/Yz4MR1XaW8qv9j2F8jjt3FlOqYHGSvpnReJwt8p BlfRGk+8fhjwmoVqfVpYhXWElJSkAaQdJLw/Y2SXiIiptUprqXLWK08tigzIokT3VUDU PJACRweHK4Q1KXbTW44ZLzKMgDX2l9QLRqw2e8hxUitft9lkRgEhNqjn4MoYhm3mSxQ2 DHKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x+Od9A6k+Mx3oOsy+sHLyJqYPR0woYwsH4hDTgPiCu4=; b=gJp/zpdDxF9gR8zg4qfQtzYxbYUq7K1W8hrZ6XhzkCXNGsjr5b0xkTNbaM3TCAUxkm l/34m932nKVEK1CAiIXu59MciEgq2BMu0OdhUAWM+Y9Q4K8NWUQj2sf2UiuGNbZ5YMpd UoDUm1Z0SOsS45y0jEecPHcUTKxZm7y2sIKMKo2Dd4P6MwpMI+Wv74WGi3OjauvO5GqD 7GqTGLCkLHpNZWTZEFzvOzLUcp4KkrBxrj1cBpayHNmt0aPlfgGBKoboWqPBnVGBX7vc NkoRLQCNGecUSjfq//MuPv8a/kmBCkOAMKl9v8AJDwgK1F4D4ULfv93dI39Jmucfhalq 4w7A== X-Gm-Message-State: AOAM530fUDNfsnPA2rERlxPxAdX5tgM9/P1NmpE5rc+lv25Ylgmi+a9Q WCw+75jide1CtgP5l6Vh/xdjUXEDalc= X-Google-Smtp-Source: ABdhPJzueVEA9BIVnzs7TNWEnkDDpPoK5NYiOKp4BBh+CURWQw6f+dQ2x8Lp+wiXIMfRN4/1y6vjeQ== X-Received: by 2002:a05:600c:214a:: with SMTP id v10mr22951878wml.17.1626554475512; Sat, 17 Jul 2021 13:41:15 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:15 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 5/7] rtw88: Configure the registers from rtw_bf_assoc() outside the RCU lock Date: Sat, 17 Jul 2021 22:40:55 +0200 Message-Id: <20210717204057.67495-6-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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. Configure the chip's BFEE configuration set from rtw_bf_assoc() outside the rcu_read_lock section to prevent a "scheduling while atomic" issue. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/realtek/rtw88/bf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/bf.c b/drivers/net/wireless/realtek/rtw88/bf.c index aff70e4ae028..06034d5d6f6c 100644 --- a/drivers/net/wireless/realtek/rtw88/bf.c +++ b/drivers/net/wireless/realtek/rtw88/bf.c @@ -39,6 +39,7 @@ void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, struct ieee80211_sta_vht_cap *vht_cap; struct ieee80211_sta_vht_cap *ic_vht_cap; const u8 *bssid = bss_conf->bssid; + bool config_bfee = false; u32 sound_dim; u8 i; @@ -70,7 +71,7 @@ void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, bfee->aid = bss_conf->aid; bfinfo->bfer_mu_cnt++; - rtw_chip_config_bfee(rtwdev, rtwvif, bfee, true); + config_bfee = true; } else if ((ic_vht_cap->cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE) && (vht_cap->cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)) { if (bfinfo->bfer_su_cnt >= chip->bfer_su_max_num) { @@ -96,11 +97,14 @@ void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, } } - rtw_chip_config_bfee(rtwdev, rtwvif, bfee, true); + config_bfee = true; } out_unlock: rcu_read_unlock(); + + if (config_bfee) + rtw_chip_config_bfee(rtwdev, rtwvif, bfee, true); } void rtw_bf_init_bfer_entry_mu(struct rtw_dev *rtwdev, From patchwork Sat Jul 17 20:40: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: 479763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02D30C636CB for ; Sat, 17 Jul 2021 20:41:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E09D661158 for ; Sat, 17 Jul 2021 20:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236132AbhGQUol (ORCPT ); Sat, 17 Jul 2021 16:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235643AbhGQUoS (ORCPT ); Sat, 17 Jul 2021 16:44:18 -0400 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 D5E7CC061766; Sat, 17 Jul 2021 13:41:17 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id f17so16189527wrt.6; Sat, 17 Jul 2021 13:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZvC5Ygzd6gbVP8NtAh30qzHzpl/bhx2z4pCtMRNmGCA=; b=CMNps2dWETudqhXFL3YQvTQxtOvEK1YLiyZvUF+210/zOMc9vee/5Ev4z1Whf3v/0P QKZ4pnTBoIpOaZ9rvsc2Ot4Nb+rBJ/egOvVEuW/13+73zIWyI6SSFNn3UfBYyIfrCuJw Yzmz/5dzfg8G16RdnQUi4U2bWhQN32Drp4gSsk1CX+1535n1Yvi8xpMeALeg3nPZhJEL r4rxjz3ZojkSJylPkdst5zHcQa8/bGCy8lR/+aeFCqzanntann3zpxuWC4PJugsdxYSf VyORN16rEWEFp39FjElWZPgTh5q8D08aSCyFsZgtaTk+M1hipN+E7nWl76IhxxdaHk/P K+rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZvC5Ygzd6gbVP8NtAh30qzHzpl/bhx2z4pCtMRNmGCA=; b=mqBOTiebTSDE352AJXNrPTKpGumJoOTiptso5MASFSZQsAEFirKeCEzH8ihqE9MxRg lu08R2Is3NcyZrLJhiZJ5HXHQPkq4UAHPee3sCVKxzoQiO2txjFIxsF6Vr79jiSju5Ay jbRGWrNxhEcDslUcaOULODGOtQx1DL6AcuT6oRbsD64MEaXWM1QEFb4oIF4WBAgXC5YB w+SkqnXbfckzx/xK/E5WbGlvqfgpt1fR820vhhvw708JmaAnqAd8CGvgJopOosavOLR9 hkBTjBntpXMxH1lIV2YXXqGfwdXqkp/z7+YJx1WxqwMBQ3qxZwOtrrm9ZJuM19EbRcfQ 1fzA== X-Gm-Message-State: AOAM530NLul5oaWYUJ/gykD4Zgu0H8nG17KJTe5RNRO6J/4CnOfMwgNu 9ppAr9RnOnDoEI4xQRctiwZA4r9K4Ls= X-Google-Smtp-Source: ABdhPJzkXbYkUOoXNPBxmgOc/tU5EZp/j/GUswIG+cPU+/iXe2bnZnWqX+NlnyCUEgzsuTN29A+lTg== X-Received: by 2002:adf:ef03:: with SMTP id e3mr20546311wro.316.1626554476324; Sat, 17 Jul 2021 13:41:16 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:16 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 6/7] rtw88: hci: Convert rf_lock from a spinlock to a mutex Date: Sat, 17 Jul 2021 22:40:56 +0200 Message-Id: <20210717204057.67495-7-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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 e40432b1dcee..5ebc4c0b4ccc 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1834,12 +1834,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 e5af375b3dd0..fd213252fbe2 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1842,7 +1842,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 Sat Jul 17 20:40: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: 479764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAB5FC636CD for ; Sat, 17 Jul 2021 20:41:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D680B61103 for ; Sat, 17 Jul 2021 20:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235953AbhGQUof (ORCPT ); Sat, 17 Jul 2021 16:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235646AbhGQUoS (ORCPT ); Sat, 17 Jul 2021 16:44:18 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F49C061767; Sat, 17 Jul 2021 13:41:18 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id d12so16136396wre.13; Sat, 17 Jul 2021 13:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mj2H3msC6oyhKz7UwATyKp0y5VOYMGrKZ8Me0MwbHlo=; b=RRfAQgvDxFkq9BTwC4WA0SaA78PX1voZJS9zeepKtWYEbDR7nr9+rou4xCBIF8M6GZ 8YT9n90qbhBNfZtQOLcri2UJPCLvJClXTYirrgpEldvIw8WpJT9lTZRWZuokpQ/P3JAG 6gttyHWXP+AQD86M64TZnJhuDXcihS4GrpvpJ/su4a8Ylq9ZGbt6orqtgwu1DFEYcQSc qlPjPxa4JPihb4jfmEOHhXgFJDVT1yfX8OITd++TIw6lhN5yOpjHywNnjeLr95p47kfY zRVl8w9eCaxZFOm//QViM7+Mro0o0vA5KPLiKhWu0xv81AWzjZkSCNbDwHf7C7pxCgwQ +RrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mj2H3msC6oyhKz7UwATyKp0y5VOYMGrKZ8Me0MwbHlo=; b=biTY/PeHTrM9uodFMeDeSyn0B10qFYcyGNlnmifvD5IDgMiyZuubW39YgdDrFTGlol ovKwai0Be0cg19FCkcNori2eIOtypxfKqMjCw25WabRk+MR/65gaGZ+UQiZ5xMMVBywG gCVL77n6zBAyb9u6tTNnN1X32NG02bHbQX9mC0yIAHSo03f26epbMblSYkRhw0U2zvVT uTZz8Im5TJy9gQNta3HWNT79ayIXw/WSHYjz4qb4Bxh3TypwGDXImclVqC5AXN5kK4uC y2D70yJNhPm/iXuJw9LwdYWH/OFioc1zng3U/Ylzm5CeaGh3w2FOUryl+58S9Cd9ZCd6 gVyA== X-Gm-Message-State: AOAM531BHylmLXq+WR0724K5+KaEb695Ty30iKEGbkczy5dnsS0s4Muc AMDEU+3P7JobUXqXMvqDUY40KPUWwoc= X-Google-Smtp-Source: ABdhPJx0xizcRHPfUYgxXxQWN7LnGYOrn+BzTXtExqnxUqjICf37qSmxBsOHt8Cihcae+Jh+qsuysA== X-Received: by 2002:adf:edd1:: with SMTP id v17mr19892978wro.276.1626554477229; Sat, 17 Jul 2021 13:41:17 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c22-7602-4e00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7602:4e00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id n7sm14078357wmq.37.2021.07.17.13.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 13:41:16 -0700 (PDT) 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 , Martin Blumenstingl Subject: [PATCH RFC v1 7/7] rtw88: fw: Convert h2c.lock from a spinlock to a mutex Date: Sat, 17 Jul 2021 22:40:57 +0200 Message-Id: <20210717204057.67495-8-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717204057.67495-1-martin.blumenstingl@googlemail.com> References: <20210717204057.67495-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 3bfa5ecc0053..5acc798299e5 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -285,7 +285,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) { @@ -310,9 +310,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"); @@ -328,7 +328,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) @@ -340,7 +340,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); @@ -348,7 +348,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 5ebc4c0b4ccc..34e5bc97d9f4 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1834,12 +1834,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 fd213252fbe2..1788fc339afb 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1868,7 +1868,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;