From patchwork Wed Sep 27 16:32:56 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: 727063 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 A4577E82CAE for ; Wed, 27 Sep 2023 16:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbjI0Qdo (ORCPT ); Wed, 27 Sep 2023 12:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbjI0Qdl (ORCPT ); Wed, 27 Sep 2023 12:33:41 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2077.outbound.protection.outlook.com [40.107.93.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4163AF4; Wed, 27 Sep 2023 09:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lpELk2KNHmZKh5JJMfKgPn8PmAfK5r7iJaNS2moStgzm9wF5/u3mbBbapkyluXAIFqHzVmZNcMFJ8vXFNm8QEF0tY4bivXTfub7/QGjnnVrfxlh6WP6SSBBDZA7kesJ9R2xSqEd9t3drYgJ7XhBjcgMeoh2Yr9x14YCFxFDF5RZnlVIrWIb3rsI0bIsrIDOp64SMSUjxZ8z5PJ/6CRcZn9fxqKcjvfF5xxUbZy19ZsKlj5eANsyzw0MloiKsAq67UPJ6ryPehDDMoqrcKFYa50zxlbUFAZ67J+JxRQRC0K5I2KxYzANa/QjLRpyb6RN5lITC+k2vU58pwMUt8t8vCA== 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=lWc8E8CMbVgT7TANNR/8TdPGoMSnLO96cJPktBpnkXU=; b=mQIJMyPAmjrs/MF1PdhMdEZ3wHnhCeMN0mrCvqmSoKU99hTaY7uKboVGX4tnGog1G+ClvnUyeIZxk2rDVJyxP4j+FWndHVhSm9iGYAUf7owvO2/+hXrSJ1l8q5UPUHnhTEQPXVbBsEcOycVU9MQVvxi7g7A0yQmR6y/yEbZYcLLYY797kFA+v2KKhTp0wqEymAONk3ekjcKA/WK/eMR4VMIVjo+AV6rjQXgZx4WzrsUIrqMl5ZyHcAc7NUHWTccbT0UKWA4im5sU1LNKzhQqqyMHHNJm2GA7yhtg5w+OKJfKEVfY+7TlXl0Z+NRASlszXoTOqUg1fM0vteMKlw3J9Q== 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=lWc8E8CMbVgT7TANNR/8TdPGoMSnLO96cJPktBpnkXU=; b=nlGA+udS0PDn21uITccIx8uV/TcmKiqkFDo/05wU77XWtAWMdlSLtR5KsChqrYORFwa/zYSf/1IgBRFZJxLrdY9x+lBlaOSnXLhG4FasDPwjL5qMsFQVe2j58He03hId+uoqYwcDN1U5gVlPT5mhS468HuIdZNI3FCBNrsb2/u8= 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 SA1PR11MB6781.namprd11.prod.outlook.com (2603:10b6:806:25d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Wed, 27 Sep 2023 16:33:28 +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.6813.027; Wed, 27 Sep 2023 16:33:28 +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 v2 8/9] wifi: wfx: scan_lock is global to the device Date: Wed, 27 Sep 2023 18:32:56 +0200 Message-Id: <20230927163257.568496-9-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927163257.568496-1-jerome.pouiller@silabs.com> References: <20230927163257.568496-1-jerome.pouiller@silabs.com> X-ClientProxiedBy: DS7PR06CA0052.namprd06.prod.outlook.com (2603:10b6:8:54::30) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|SA1PR11MB6781:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f0d3edb-924d-441d-5285-08dbbf777a4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RNHZwuDX1xdrqSk3M5kfh5GTvDMI05FM8f9Plok1OeCjhsIAWmPJzQwCfGGAFABAU1cd6g2NBOMqyRPSeiAsLa7lT/+fPneTw3SCVJ/WplHkN1d4hIRu5gEMvWr/XGmUdwVvyYB8d5uCp4w6Sexcgx8GaVnrLy287Sv6QUAdoUQ1syQaz76aW7EzikUxpdzsoZ8MJgoixDBfWuckrScf4+0aNYptJiGUCSwryfy4/F7DBFjBFB5PiMJez9yabXxwU+26I1n/mbCKaYn6rx1r0IfWsLX1uekjVO8FGCKg5zfoBcqCT9VLheDfViNTYOQfFRkjiBhw8+fjmUpyRWDx02i46SblSfQ0WGD4tePzF/UfaaZDHra+zrvcOYO3ErGmDWAAbb6yWTmkkTThzy3lAfJET9LUy8N/u/0O9sZ6jsJ4V0OhzUQtd9fXgrb2CvlvoFpzcE2M1FHUQxMfk46uku2ttfAEhzkDtvH3e42Uh/iVHpqZbfytE05AoQ8vVwGRmirWkzq4pkhgwDa723na+gvFepQC5jV2pXPhqonD/sv6htu6xFPtdghrs16BIxRP 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)(396003)(366004)(136003)(346002)(39850400004)(376002)(230922051799003)(451199024)(186009)(1800799009)(36756003)(86362001)(8936002)(107886003)(6486002)(8676002)(2906002)(38100700002)(4326008)(6512007)(41300700001)(83380400001)(66556008)(5660300002)(1076003)(66574015)(2616005)(52116002)(6506007)(6916009)(66476007)(66946007)(316002)(478600001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+2SVksEa4WY9Uw8EC+zpJiMXbB3o?= =?utf-8?q?1Cn/RRL9mfrSIsqIHAoQd3Bo4hUu3rYIZso9E42VW5MnexmCCu5m1BonjP+gxH3I3?= =?utf-8?q?Zcu8hUPG6BI9siVMweNTSzELm5VInpzGAYBeFbYbbIpjMQsBhPzxBxQb0k8Jv3JOI?= =?utf-8?q?+WE/wNnIZlTrcJPi4L0bQa6xRZ8JvryWfsI6TDGYECVuKH6oFsEHFdsKZhGlIb70w?= =?utf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-8?q?fQtBjFXL/5JnTLmGFvQwyKylYL0Ym1fDz7gblKUZbw6C8Srh/pb7g6v03EfMM3Sg8?= =?utf-8?q?92t65ln1JHVPi6LFlTlTFNanJGGoeDOx7CdgeTU1uWq2DB7B5x5Pxi5ainFQEtHJ3?= =?utf-8?q?yP6VhoVjLxumsaXqDUgoaS71sk5KKY6M57N1Fd9Qw3RbC/4uMIfPuUZDkgQvOtt0A?= =?utf-8?q?BLUzGYv+of3HHeBOVk7S3NTb53ueukUeL/KhF/e68jtJK8tGQkKshzqtEmq57axa5?= =?utf-8?q?++D9Wuv7DjARlxn4K5K/njTexFLIoEPLTsiDA4Ydykl1ELyMe1QB9au0y0k9Ue5sI?= =?utf-8?q?1RW9/ZEf9bESWzjD1uqiTDGCF5A89uOm12Q6eM7r7EmeExeWmiAxCIalj5bHA1Azh?= =?utf-8?q?gRB8+yP3fzD1t97LcK9RnjMfXGTNyNTAhHLc3OpT38+DQfZ60Y5Gm7eWIywDHDLAc?= =?utf-8?q?m7vzBA5ZgbeA6hjy+pToY4QUDmGtm/v2AiLMvXpNLTQo0GsJUjVXq9KMdGceVaahy?= =?utf-8?q?xJfMqmphDaz?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f0d3edb-924d-441d-5285-08dbbf777a4d X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 16:33:27.9536 (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: pPD1v/0t2Qy8oROJcBdsSmzRxTUA8waaQcYkDB8kyKsYt4PFmQi5CRrVKNieamdBcwM6ySqy+3U2sG1ay/fLvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6781 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 prohitibed 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. 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/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 31f6e0d3dc089..e7198520bdffc 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); } @@ -317,6 +318,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;