From patchwork Mon Aug 7 15:05:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 711527 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 DF950C00528 for ; Mon, 7 Aug 2023 15:06:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjHGPGW (ORCPT ); Mon, 7 Aug 2023 11:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbjHGPGP (ORCPT ); Mon, 7 Aug 2023 11:06:15 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2041.outbound.protection.outlook.com [40.107.223.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B37A510FC; Mon, 7 Aug 2023 08:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eKBNjga4HVA4tynnwwL9JnOpAZEvz/dzHZ+DeN0GcUZhuyr5fklGVJAyL1oG0Jw1MNW6sGlEd0L6b4pMRxKUjKLzM7A1PRRU3VIEq2QEmJcdavfRdpW64dLyv40gCD2Z3C0OIGMBoXaOWogseug+MXJgW9SoN0KkImaJtXDViDuu6Ot/jyFWl7OFsIr3/5+cQmqHk077W71m0fn7NOoHPNYjMyFsbd2MLokcukwuDrxXlYAz0plDQYlmhKUajhf9w6cpMGcNoltBK3YhlAdCkDyqbsPo+2QF2imvaFBwg4n6SypKs3oZM+5RSRX1tSaBoB+9F/Fa7c1yn4BBX+XkWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MDrcTDCa+jCrYxb+wZAdupVXskszFZLV1jIGUVLLGJ0=; b=jSWM5HDrhUTVulRmFkuWFj+zQ1rC5RzuFXTZbV51CbmvTnahd/Gk9HIZ837U+iG1Gq7YLufDksqdPPA5GBmCK+R+bjJfSwX/glD6TMYgMolRukab3OwzBLrxmDTVvBKxEfDs5ZDQjDYzkBUU0N8IcuY6yKFav0dmUOisadPBYrUIdn1OyktbuvCLODmlJgQ9gjHKp2LUA4ehMQS+9oG5lSUYtVqGbMfXZGUl564R7NjQDMd8/WskCbhu0ArB/cHSHrUL7wSzY9abIDFnCSVrJGGjo8DUKcEwy8IRFZ/W0S6Yo0p0KMqpZGeUwmpDlTW/pqjcgk+aLGWTEpk0CpuRdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MDrcTDCa+jCrYxb+wZAdupVXskszFZLV1jIGUVLLGJ0=; b=Ph0maI/en1X6MB1k4nX0Ba0PqhdmEIeTNPoA5VmjB7qzo6MGVvUxhfn8KIFtVLJgFD4NcwedcaX5T8r9pBkb0zEx+mFMTlXy66ggB8hVlIkpqUgKiLqTz+8FcCzVYp84lyRMwS+T0nwbjlnkqsQs2RhgC5Qf2yRWJENy28ge/Lg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silabs.com; Received: from IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) by SN7PR11MB7590.namprd11.prod.outlook.com (2603:10b6:806:348::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Mon, 7 Aug 2023 15:06:10 +0000 Received: from IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::14b1:be6e:19a3:2eca]) by IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::14b1:be6e:19a3:2eca%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 15:06:10 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= To: Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 8/9] wifi: wfx: scan_lock is global to the device Date: Mon, 7 Aug 2023 17:05:41 +0200 Message-Id: <20230807150542.247801-9-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230807150542.247801-1-jerome.pouiller@silabs.com> References: <20230807150542.247801-1-jerome.pouiller@silabs.com> X-ClientProxiedBy: PR0P264CA0252.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100::24) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|SN7PR11MB7590:EE_ X-MS-Office365-Filtering-Correlation-Id: 02b9e598-f85f-4b36-9cf4-08db9757d5af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PpLRvLpvUTQyX9kyV1yT0jtOAeIgXZXTkOvLVNbx4/xw++OpS4GbyAvEOCJ3nOKjF8eKD5RoRdx+jJvMCBYd+UUSF5iVfvxCyqcp0bSp/tepQ27sjZ+P3jQDqdw7/BtxQKHMrfJFc0oDdISlcevcHWTbQPivXp60/IIgVsaPg/GQ0MSmAYP5Il+x5mPPL7RtJ5vJVF9R3qPKGEzfAKe+OdS1fH7peW9QUTEfdztRaapJk0TB7eWbbl9360KVs+LhjMJIzNTK8nE2e7Ch2LERteE3q1Um1IePNWs1uDB9A5sn7asYV+DWGmX4zw30iidePPzowud6goHAlPI5Y1Letk4Il4Rla1CxRu4GAdbY4nbdJYnsthBR0o0RYrMZeitH/CforgrAaawyNH2jCacOrjgiNklAyaIgMMawrs1x5oWD71mlUd026h8lO8DwQljpjPJ68KkyIkwIjF1CKx5CZVuQkl1zOHUKPUua4O2zMZmZFqqtpBsjDBJW7D/f+v/MHNb/8y8cDdWB+ZqNWEb6BV4dsvdW0UmBeCdCTIkjbgFC7+pky2P6QkZntWeFq881vprvJRdgadVO0EA484FuNo1nCfl3sg99j4V+El/gEeTtHyUrmjZqmJipIb9U4nIf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:IA1PR11MB7773.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(39850400004)(376002)(346002)(396003)(366004)(451199021)(1800799003)(186006)(2906002)(4326008)(6916009)(66556008)(66476007)(66946007)(6486002)(52116002)(6666004)(66574015)(83380400001)(5660300002)(41300700001)(8936002)(316002)(8676002)(38350700002)(38100700002)(2616005)(478600001)(36756003)(107886003)(26005)(6506007)(1076003)(86362001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GWwgdLi1KknGw+4LYcIt/e8cBVEA?= =?utf-8?q?jVUGXLFjo7o9ZdyE3d3NNE5yhDUSdOEyPQL0P9mTgUZsV9cVxtqkmR3RmYctCpPLm?= =?utf-8?q?EinXK5Z3YGXuJjDbRblehf2HQaLmNbYwGG6+TFp7D9A7+Wc4HtsM50a3axIuyEE+o?= =?utf-8?q?Es4VX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21wtWCYzagJI0N5lW0wy79CFeYl2BzBSUle8Ezl6sTumQl1y0rWU?= =?utf-8?q?EQdNT2TdzcTRR39qmJmkGxK+YscJX+1xFPyjiemrK/gFF9aCbHZL4JOf7qAjO+aRy?= =?utf-8?q?F31ieirffMIYaKIRLPkyFILUGfrhtzWK06iqThIVdZAvnMN03301xT090CYGxr7GI?= =?utf-8?q?VvisE2pNtoWYFyDJok0MxqfMhGnKZgNht2JBLppnfYJTQ5Hsr4UF2VAuXfEf4t2lc?= =?utf-8?q?56cw0eUiRMb0uhoEPR+7zn47clKlyZZioERWhB/kFwDkfYmfemr11uoRHC+BjHtso?= =?utf-8?q?PfBpZEs+RVxMNcmKBwDXQEYWY8lRu+0es0UJBB6s9eVbMpBI8JkNctgDcsl+ku+YU?= =?utf-8?q?au2gIBibBiVdYQ5ucV2fDdsiuD5OhDUd5aXu6V/rM3R7wLzxP9FIIAZc6Grdeizrt?= =?utf-8?q?8PgdyJAiua/pSHwTUiosY6LGyL025jTlcry4SluSARbJVsEbfMwEBKMyA69/sGelp?= =?utf-8?q?M+tbVEIUYpNc?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02b9e598-f85f-4b36-9cf4-08db9757d5af X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 15:06:10.7015 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8TwZ7M5F94by+UT3w0bAJ799s0+I+trPM8AZLkYJDaVLGk3NgPDH8npv7+W4Rg5BzNqACKxN3QFu3A5IQZZKcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB7590 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Currently, one scan_lock is associated to each vif. However, concurrent scan on vifs is explicitly prohibited by the device. Currently, scan_lock is associated with conf_mutex that ensure that concurrent scan on vifs cannot happen. In the only case where conf_mutex is not associated to scan_lock, the scan_lock is tested on all interfaces. Short, this patch relocates scan_lock to the device and simplify the code. Signed-off-by: Jérôme Pouiller --- drivers/net/wireless/silabs/wfx/main.c | 2 ++ drivers/net/wireless/silabs/wfx/queue.c | 6 ++---- drivers/net/wireless/silabs/wfx/scan.c | 8 ++++---- drivers/net/wireless/silabs/wfx/sta.c | 15 ++++----------- drivers/net/wireless/silabs/wfx/wfx.h | 3 +-- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c index a0906d7d026e0..32564f5c98e5c 100644 --- a/drivers/net/wireless/silabs/wfx/main.c +++ b/drivers/net/wireless/silabs/wfx/main.c @@ -248,6 +248,7 @@ static void wfx_free_common(void *data) mutex_destroy(&wdev->tx_power_loop_info_lock); mutex_destroy(&wdev->rx_stats_lock); + mutex_destroy(&wdev->scan_lock); mutex_destroy(&wdev->conf_mutex); ieee80211_free_hw(wdev->hw); } @@ -318,6 +319,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, const struct wfx_platform_da gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup"); mutex_init(&wdev->conf_mutex); + mutex_init(&wdev->scan_lock); mutex_init(&wdev->rx_stats_lock); mutex_init(&wdev->tx_power_loop_info_lock); init_completion(&wdev->firmware_ready); diff --git a/drivers/net/wireless/silabs/wfx/queue.c b/drivers/net/wireless/silabs/wfx/queue.c index b5975d18f09b4..e61b86f211e53 100644 --- a/drivers/net/wireless/silabs/wfx/queue.c +++ b/drivers/net/wireless/silabs/wfx/queue.c @@ -267,10 +267,8 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) } } - wvif = NULL; - while ((wvif = wvif_iterate(wdev, wvif)) != NULL) - if (mutex_is_locked(&wvif->scan_lock)) - return NULL; + if (mutex_is_locked(&wdev->scan_lock)) + return NULL; wvif = NULL; while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { diff --git a/drivers/net/wireless/silabs/wfx/scan.c b/drivers/net/wireless/silabs/wfx/scan.c index 817eeb3aa8bff..c3c103ff88cce 100644 --- a/drivers/net/wireless/silabs/wfx/scan.c +++ b/drivers/net/wireless/silabs/wfx/scan.c @@ -95,7 +95,7 @@ void wfx_hw_scan_work(struct work_struct *work) int chan_cur, ret, err; mutex_lock(&wvif->wdev->conf_mutex); - mutex_lock(&wvif->scan_lock); + mutex_lock(&wvif->wdev->scan_lock); if (wvif->join_in_progress) { dev_info(wvif->wdev->dev, "abort in-progress REQ_JOIN"); wfx_reset(wvif); @@ -116,7 +116,7 @@ void wfx_hw_scan_work(struct work_struct *work) ret = -ETIMEDOUT; } } while (ret >= 0 && chan_cur < hw_req->req.n_channels); - mutex_unlock(&wvif->scan_lock); + mutex_unlock(&wvif->wdev->scan_lock); mutex_unlock(&wvif->wdev->conf_mutex); wfx_ieee80211_scan_completed_compat(wvif->wdev->hw, ret < 0); } @@ -155,7 +155,7 @@ void wfx_remain_on_channel_work(struct work_struct *work) /* Hijack scan request to implement Remain-On-Channel */ mutex_lock(&wvif->wdev->conf_mutex); - mutex_lock(&wvif->scan_lock); + mutex_lock(&wvif->wdev->scan_lock); if (wvif->join_in_progress) { dev_info(wvif->wdev->dev, "abort in-progress REQ_JOIN"); wfx_reset(wvif); @@ -178,7 +178,7 @@ void wfx_remain_on_channel_work(struct work_struct *work) dev_err(wvif->wdev->dev, "roc didn't stop\n"); ieee80211_remain_on_channel_expired(wvif->wdev->hw); end: - mutex_unlock(&wvif->scan_lock); + mutex_unlock(&wvif->wdev->scan_lock); mutex_unlock(&wvif->wdev->conf_mutex); wfx_bh_request_tx(wvif->wdev); } diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c index f42341c2baffb..496b93de3ee58 100644 --- a/drivers/net/wireless/silabs/wfx/sta.c +++ b/drivers/net/wireless/silabs/wfx/sta.c @@ -97,9 +97,8 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, FIF_PROBE_REQ | FIF_PSPOLL; mutex_lock(&wdev->conf_mutex); + mutex_lock(&wdev->scan_lock); while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { - mutex_lock(&wvif->scan_lock); - /* Note: FIF_BCN_PRBRESP_PROMISC covers probe response and * beacons from other BSS */ @@ -126,9 +125,8 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, else filter_prbreq = true; wfx_hif_set_rx_filter(wvif, filter_bssid, filter_prbreq); - - mutex_unlock(&wvif->scan_lock); } + mutex_unlock(&wdev->scan_lock); mutex_unlock(&wdev->conf_mutex); } @@ -621,18 +619,14 @@ int wfx_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd notify_cmd) { - struct wfx_vif *wvif_it; - if (notify_cmd != STA_NOTIFY_AWAKE) return; /* Device won't be able to honor CAB if a scan is in progress on any interface. Prefer to * skip this DTIM and wait for the next one. */ - wvif_it = NULL; - while ((wvif_it = wvif_iterate(wvif->wdev, wvif_it)) != NULL) - if (mutex_is_locked(&wvif_it->scan_lock)) - return; + if (mutex_is_locked(&wvif->wdev->scan_lock)) + return; if (!wfx_tx_queues_has_cab(wvif) || wvif->after_dtim_tx_allowed) dev_warn(wvif->wdev->dev, "incorrect sequence (%d CAB in queue)", @@ -730,7 +724,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) complete(&wvif->set_pm_mode_complete); INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work); - mutex_init(&wvif->scan_lock); init_completion(&wvif->scan_complete); INIT_WORK(&wvif->scan_work, wfx_hw_scan_work); INIT_WORK(&wvif->remain_on_channel_work, wfx_remain_on_channel_work); diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h index 5fd80c423d6f6..bd0df2e1ea990 100644 --- a/drivers/net/wireless/silabs/wfx/wfx.h +++ b/drivers/net/wireless/silabs/wfx/wfx.h @@ -43,6 +43,7 @@ struct wfx_dev { struct delayed_work cooling_timeout_work; bool poll_irq; bool chip_frozen; + struct mutex scan_lock; struct mutex conf_mutex; struct wfx_hif_cmd hif_cmd; @@ -81,8 +82,6 @@ struct wfx_vif { unsigned long uapsd_mask; - /* avoid some operations in parallel with scan */ - struct mutex scan_lock; struct work_struct scan_work; struct completion scan_complete; int scan_nb_chan_done;