From patchwork Wed Oct 4 17:28: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: 13409100 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 E1EC1E7C4E6 for ; Wed, 4 Oct 2023 17:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243683AbjJDR3S (ORCPT ); Wed, 4 Oct 2023 13:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243659AbjJDR3O (ORCPT ); Wed, 4 Oct 2023 13:29:14 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2082.outbound.protection.outlook.com [40.107.94.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54FCED7; Wed, 4 Oct 2023 10:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OQ44YiThTT1WwfjpCgYQ2+2bNS8gbkQykFeQzGAd8q4ED2XJtEokrWEQFqQKiNxu9cVoJUUt8NQ9OGSlq07YrJRAieAYCT68R6C2PYo3F76lr/LNrkY/RcbivoZnHd5CkU9FCeWgzMpAMLSXzfBeajKpi1Wtzd7HEXp+DQ6ctWNFfVhczNoXCLvagrzmcfvvVZo9yFUELtpnaJXGRtBPW+s3EaDaTceadaNprUdjIMOJuzcXIpzIyI7HlZ67lAbQDI/kEu08gJ0Vpgn/L9VgvpKvALJeKyUTntSbCv91nQpYw+6kJjM9Mv38wf6Hwur4X13R3rc+irRe+XyMI3thUg== 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=jAXF46m/CPJayObdo/yO2Zf+QM4FW1e/fwL2cbCAoNA=; b=GZE+P1iJX3jwVpym3Uz8/4iYmueTjzH05jxGdbMhOzAcXpYEexyWc713vSje9C1Swu8r1TK129fZJQ2M7eTVEHh7g7g0hNfZYKtGdaDcTRh8d3aaHu8uTKHmVNFYyA97FoVbDgpnAU79JK6KvZgR5rM2rAJNa22+FQmPFG/llBu3xgj7gyJ11e7xfPA2rxyOG3h/k63e2mzIk7sRcZiG3Ijo/t1mnCBIcoqen8CPML/ttQttQmIyJbDCEm8SYpqQVw4daUDvQgh2RmjHHQm+Zj2SslsTvt9ggBkA3rFndoZZavvDyqnRL+zeU89ibuLk0o+eJxQiy7GlLE9nxIPk3Q== 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=jAXF46m/CPJayObdo/yO2Zf+QM4FW1e/fwL2cbCAoNA=; b=YKZyRrg3FcPlhUnKuLTkGktpzeAuSp1oW7SCSSDhnVf9Ai6s6vWPHk8d39kJtpYHuVrHheftecrMLIkmBaiXsr5B2B8+N3vcFvrIkN+yeNABIqV7sfnAkhoRnnzXvieg9ez4qXzfry7v/LM6AI85qI2yKPz9RB6h0yzknXL1GtQ= 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 PH7PR11MB5982.namprd11.prod.outlook.com (2603:10b6:510:1e1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.34; Wed, 4 Oct 2023 17:29:03 +0000 Received: from IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::d6c8:4cb6:2594:d8f3]) by IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::d6c8:4cb6:2594:d8f3%4]) with mapi id 15.20.6838.030; Wed, 4 Oct 2023 17:29:03 +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 v3 6/8] wifi: wfx: scan_lock is global to the device Date: Wed, 4 Oct 2023 19:28:41 +0200 Message-Id: <20231004172843.195332-7-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231004172843.195332-1-jerome.pouiller@silabs.com> References: <20231004172843.195332-1-jerome.pouiller@silabs.com> X-ClientProxiedBy: DS7PR03CA0305.namprd03.prod.outlook.com (2603:10b6:8:2b::25) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|PH7PR11MB5982:EE_ X-MS-Office365-Filtering-Correlation-Id: d599b826-ab11-4ed4-bf1e-08dbc4ff675d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NdQkG3GFtGVgeME77MkkfPA0KZlDX9i2iinEZfnNXbmMLZy7h/e2RCy3t3dTknSluHXSCuObLvok1SOlz+DISjwPFJT9vgEwm8THYJdv964CSW2u9mJcGjmYEf0Ft2eEY/6eKKxzRtfKJSEC123zQPvsG3FgRCoCy45+26wwIGge82QZ25QrWk05VQ+aAbCgCOnFJ3Q5obQSrk7cYXfO97zxB2xbyXOAnGoZ8wlCxgxC0pLH0RmJtqDfanV3pAjqRYfjoaIhHpm373Y+0SZhQiyI2Nka5qjOG7dqeadTo3xAwzBYizW/sjNg3MomnB51S04daBXBfyzXOFWJLWpn9JP+swuqUJ/zYd/s14Z44dSpwXepufhYbk2DHuTKoKKkP1e6oXk4TBzfltG9P2d5KLlwyH8oAIJ4kZ0g8hRXxN9ck2uijrLYikWzdXAgoQkNDXsEI7P5BupPz2rton+lxU5Uh+knQmNxcHIjBQoQljlc0yKWBEnzaFHXluRI2v0mEgeJdgJB/SsAvjZBjQOJ1tR6QcpvKVEfl4Sk7NSVWIotVHiMERqYch+72bfsyimd 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:(13230031)(376002)(136003)(366004)(346002)(39850400004)(396003)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(6486002)(36756003)(6512007)(38100700002)(6666004)(52116002)(86362001)(478600001)(6506007)(66556008)(66946007)(66476007)(316002)(6916009)(41300700001)(2616005)(107886003)(1076003)(8936002)(4326008)(8676002)(66574015)(5660300002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4k/HgQ+cWFZaCOvSDU3C+6XPzNR1?= =?utf-8?q?JsYO56uvGgE4YC+ghBnXtmjiihG6KFhh/gcgEb7H4gu8Me40E5VUXEeQg4p39U/e0?= =?utf-8?q?p2N+vfb7ICXnDrK6/hTxymBERmRVk3Airv3Twxuk4pCtvz3oQPMj8dxXgGrFY4fWX?= =?utf-8?q?JKW8U526mVtjd+R7Xj/NbYUe4225+eL37tS9cWfAVw7g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LjDS8hsgj00lE05hdrHVGlySY1QaLBJ+?= =?utf-8?q?UesXafJY8bYwYQb/1IjOwMoZxhojiOTLBUSTl38/d5V9mu9kiTU/vWBZNCopM5oHR?= =?utf-8?q?1PqKgaOwk4IBvlkjrdkrCVYxLajdZrP3cVQiLbzIpxAEaHwHok07/TTTDBMFBA7Do?= =?utf-8?q?DkbPLUajsTW8+JAzxEuF1/lchD0G526JcmCJgSsufCv7aLN9loNmIUvOPmHObY+Z9?= =?utf-8?q?BE2fSeXbfzxpCmtQwKo6jovxvpaRuULsPDwawpe8qXaex0JRkw1ZrYLBM3Wd6QOm4?= =?utf-8?q?pijrXuodLjNxUfoL4b31l0bxUwVdweBLRjW7IjIxGdYvQd8h//Tgdhc5SOD5vH8me?= =?utf-8?q?rZYLaL+39PBuGM0aQjTTam36WyMWjafj1ALkPdUfFd30A+98kHztWCITEQ7AJ/0As?= =?utf-8?q?L+coJOel7KCnaLQ23lV7LWmVTU3FTZudtO4IoUGbQabGOVXHMAXypt0WbQht/RHDU?= =?utf-8?q?ORUCBosBtd0vTZqTmU/LkBBD0f3i+SA9kHUtfh6sY31WThEwe2DZzviYWQBr54btw?= =?utf-8?q?OBBQdwa0k7U?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: d599b826-ab11-4ed4-bf1e-08dbc4ff675d X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 17:29:03.5136 (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: 6sawYa2969wMq0db4fkZUaWgadFlgdx9+gu50yiHV8RbkgjwxZOvTDFqw77B192wvyloPDh/Dph4UB8lU4DoFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB5982 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 a vif but it is always locked with conf_mutex (there is a case where conf_mutex is not associated to scan_lock but scan_lock is tested on all interfaces). So concurrent scan on vifs cannot happen. So, this patch relocate 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/scan.c | 4 ++-- drivers/net/wireless/silabs/wfx/sta.c | 11 +++-------- drivers/net/wireless/silabs/wfx/wfx.h | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c index ede822d771aaf..4bf16bceb0bbc 100644 --- a/drivers/net/wireless/silabs/wfx/main.c +++ b/drivers/net/wireless/silabs/wfx/main.c @@ -246,6 +246,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); } @@ -314,6 +315,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/scan.c b/drivers/net/wireless/silabs/wfx/scan.c index 16f619ed22e00..d6f98035f6844 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); } diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c index cb03a5cf7ffa4..8533bad6caeae 100644 --- a/drivers/net/wireless/silabs/wfx/sta.c +++ b/drivers/net/wireless/silabs/wfx/sta.c @@ -97,7 +97,7 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, FIF_PROBE_REQ | FIF_PSPOLL; /* Filters are ignored during the scan. No frames are filtered. */ - if (mutex_is_locked(&wvif->scan_lock)) + if (mutex_is_locked(&wdev->scan_lock)) return; mutex_lock(&wdev->conf_mutex); @@ -621,18 +621,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 +726,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); diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h index 13ba84b3b2c33..a41b2c35fa415 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; @@ -80,8 +81,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;