Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2787961rdb; Mon, 5 Feb 2024 19:07:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IG92MTSOxkHtT3vDt3hGTfGwhWMCwvMxtrMKwM7vXrz64ZzsmUB5nGgFKkLToN4bEBguCyu X-Received: by 2002:a05:622a:ec3:b0:42b:f094:25c5 with SMTP id df3-20020a05622a0ec300b0042bf09425c5mr1202696qtb.38.1707188846360; Mon, 05 Feb 2024 19:07:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707188846; cv=pass; d=google.com; s=arc-20160816; b=qW88pemLEwWBB84/N0HBxbp70fJSO0deFOUsYSIzdXHh89xIrFxLfulidKksH19h77 +Wu7DQ3VQcXjjmXMsmaMKFnQPLuN9uTSyXcV3JBoRprZV8PpA7N5TWkUsZVDzMAe67de hY9ZOZSugIsjEyXsp89XOaDXACt8NgQdNFd6bgYJfaPx6T733U9J8rDN34gVqBxgJmXs x8r4G5aMGNHrIjBZV8IU7LxlxgvCbPJDWAMVn392lf5cBeZ7w/KlfojsaqAqNWwiz3US Q4QA8S25vSaMi5Uj9wUqT7PyOZLHo+ihlf7Tx2F5vna+DMufzux5RPDK6AM5TqjZIwCX BoUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=nzghqH2gWcVwFikHqKmQtfgIACA9A3KDruXrnOevofk=; fh=5NcVciLF5A9717ev4SNjYZZQOD9dy3wFQU/bbN99Qr0=; b=bS7IFcBXkPhyFlkO69p0PFuAjAdXt0pPm7QhOVp0up3PD9XuhQiyDgw1MJ98ISs7Nj NPsBK3tvhCLzvbGA9rY7F+op2Kejc/isE5T5xIbf+5L3i5ZJUFX+GjMkrRihGZtLO8Cg TFz5m9clNxUaqFrTql087whIsj0XWlXgEdlQcAqlcxWQddLVYfYJhpHmMR+uQU57N1Qb Tvx10dHkG6SHmSNDqmNx5ZJmBMGCKp1nQYJ5H8hoo4kJauvqPlNEh0DROdeBxvq4p/53 c1rUkW5Zat+Pg/vHq0Jl2xy3Yp9fli8shmLSWHktFaujRhtL5KwV8w3mp6AbqoTpkzv1 BUHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-3189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3189-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCX6D7eyV35X0EvjzRro1TFaHwzLx9X29bg/vnuL3XUrKnJ5s96o6jh866UN6UvI5CkSFE5TAt2kiPYjtnR/cOvCSB9Ei4Ry+Lrzx65y0g== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r12-20020a05622a034c00b0042be3944ca4si1426834qtw.80.2024.02.05.19.07.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:07:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-3189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-3189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3189-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0F15A1C22A95 for ; Tue, 6 Feb 2024 03:07:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36EF84BAAA; Tue, 6 Feb 2024 03:07:19 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40313482FC for ; Tue, 6 Feb 2024 03:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707188839; cv=none; b=SD1iN4e9fx7LMi5revpnEP3XzGFomXHznE2xggO+42u3brbP3IoNVxT6bwgptS+aQ36souyXiDQltQokD0Ny/wZtxoT+QhLdgDfbbDJV+hN0i1QtVBfjSSDlJeJwmicPJKSM2NOx7yAvhW5WmjfhHAMp+2VVHuzNCx9hg74QMhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707188839; c=relaxed/simple; bh=SavqJWX4luqdL/iz3Izmb1PIyZjBKQxGY4rvRIVhlQY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U++F/kW7wB75SqgjAO1KfEv1uijoq9Qs1mm5O2jvXJCqGQDPhnmNIQrCr+mdq/vwbr+rLx/ovptJBsdnWV75NH1Nmuqoc89CP8pqlMMZsQZV5iuSdTqVsf6zrRLVq4AX+dGCH3mqHo9dEQlU4/EHDymYm422j5siLzKsqPqrBzY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 41637ANH03532480, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 41637ANH03532480 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Feb 2024 11:07:10 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.32; Tue, 6 Feb 2024 11:07:11 +0800 Received: from [127.0.1.1] (172.21.69.94) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 6 Feb 2024 11:07:10 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH 2/6] wifi: rtw89: chan: add sub-entity swap function to cover replacing Date: Tue, 6 Feb 2024 11:06:20 +0800 Message-ID: <20240206030624.23382-3-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240206030624.23382-1-pkshih@realtek.com> References: <20240206030624.23382-1-pkshih@realtek.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback From: Zong-Zhe Yang Originally, we replaced sub-entity of index 0 with another one in some cases. However, we will need a swap here in following implementations. So, we introduce it ahead and change code from replacing to swapping. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/chan.c | 47 +++++++++++++++++------ 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c index 2a95f9db83f9..11d46878f51e 100644 --- a/drivers/net/wireless/realtek/rtw89/chan.c +++ b/drivers/net/wireless/realtek/rtw89/chan.c @@ -1893,6 +1893,41 @@ void rtw89_chanctx_proceed(struct rtw89_dev *rtwdev) rtw89_queue_chanctx_work(rtwdev); } +static void rtw89_swap_sub_entity(struct rtw89_dev *rtwdev, + enum rtw89_sub_entity_idx idx1, + enum rtw89_sub_entity_idx idx2) +{ + struct rtw89_hal *hal = &rtwdev->hal; + struct rtw89_sub_entity tmp; + struct rtw89_vif *rtwvif; + u8 cur; + + if (idx1 == idx2) + return; + + hal->sub[idx1].cfg->idx = idx2; + hal->sub[idx2].cfg->idx = idx1; + + tmp = hal->sub[idx1]; + hal->sub[idx1] = hal->sub[idx2]; + hal->sub[idx2] = tmp; + + rtw89_for_each_rtwvif(rtwdev, rtwvif) { + if (!rtwvif->chanctx_assigned) + continue; + if (rtwvif->sub_entity_idx == idx1) + rtwvif->sub_entity_idx = idx2; + else if (rtwvif->sub_entity_idx == idx2) + rtwvif->sub_entity_idx = idx1; + } + + cur = atomic_read(&hal->roc_entity_idx); + if (cur == idx1) + atomic_set(&hal->roc_entity_idx, idx2); + else if (cur == idx2) + atomic_set(&hal->roc_entity_idx, idx1); +} + int rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev, struct ieee80211_chanctx_conf *ctx) { @@ -1918,7 +1953,6 @@ void rtw89_chanctx_ops_remove(struct rtw89_dev *rtwdev, struct rtw89_hal *hal = &rtwdev->hal; struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv; enum rtw89_entity_mode mode; - struct rtw89_vif *rtwvif; u8 drop, roll; drop = cfg->idx; @@ -1934,16 +1968,7 @@ void rtw89_chanctx_ops_remove(struct rtw89_dev *rtwdev, /* RTW89_SUB_ENTITY_0 is going to release, and another exists. * Make another roll down to RTW89_SUB_ENTITY_0 to replace. */ - hal->sub[roll].cfg->idx = RTW89_SUB_ENTITY_0; - hal->sub[RTW89_SUB_ENTITY_0] = hal->sub[roll]; - - rtw89_for_each_rtwvif(rtwdev, rtwvif) { - if (rtwvif->sub_entity_idx == roll) - rtwvif->sub_entity_idx = RTW89_SUB_ENTITY_0; - } - - atomic_cmpxchg(&hal->roc_entity_idx, roll, RTW89_SUB_ENTITY_0); - + rtw89_swap_sub_entity(rtwdev, RTW89_SUB_ENTITY_0, roll); drop = roll; out: -- 2.25.1