Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2788057rdb; Mon, 5 Feb 2024 19:07:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyHJ7oQLB/PXNJ+S0BjKRyI2dzQov4lBxvPG9M9ox1ZmQSRf44kdVaSE/WdwIf3DmNBwQY X-Received: by 2002:a05:6102:3e13:b0:46d:283b:b5db with SMTP id j19-20020a0561023e1300b0046d283bb5dbmr738375vsv.23.1707188864706; Mon, 05 Feb 2024 19:07:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707188864; cv=pass; d=google.com; s=arc-20160816; b=f8gcca2AMzlqsIHAvbYWLtnUhJ8wE/O1GbP6vXQyBnQXBIm12srtS0l7wFZ/n0an5V Fz6Y2xA6bCbAR2H7AUsfkKPwaPWCvrY3TiOt7vzle/H3ADpGAr0CPCtF/jkKSrLLMEld 8Q70fvxSKy7I4iKPro319mh7rWMnhE9s4rXQbDV5IabjMCqKsRszj1hYa76rcg2Z1Kij QWViP13tP9gvw1TB5X2W7A5uFDqrkPjKQyMXi9uLWQOhjeU94+jF5G+KdVKJer/0tZ8J KlBaH/F9144MWrinDu5FXmqwPca90xiFVr/83O8+BnnLE6vtRpesQ68TC+eCwz+AZeIE t2sQ== 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=rHf9Epg8Ww+PMa6W9wHyIdPiU9lVEyIqtFx7s4f90/Y=; fh=Etfc/w2++sP9rA8JxksLUFLNoauudfiTrRqrWdK9Pzk=; b=sDG5DrrJrTWEVpjqJZQVrZNhd1nzKoshxa2lxsHK67otp+58HoPkBJ9iasOL6k82g+ JH86/M8KQZ96HNvsgIV8Q0e9OBeCQmsQ2gRyvzlq2wcVSYoIHbGJ61ml518mBvbWG2Ed i1AQPuGl3LgMxdLp0faVStXNsH1aGFNHD02tqeg/TOrkvWihS1YfPT3awis6rSEdsXjE eAGB7d0bGevLX6jFc/T4Oj5nLbOhYZNKAwbSlnBvtFdhM1PuXwLHzKwtMHXxbpGf7+Xw 5ivngVy0bNXZ5wTFgvxXz0Yliza24cJG7+WITx1pE7D3Ynqt5SuHdYDNrOe5d5LwMXLu Z5JQ==; 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-3193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3193-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWtBnOMEigTsMftR3f4bNOT7RTi03VmMNzuEfhgi+TZJc4kz+QgeERkP3A5ax5BAHR6hFaFT6BtHBDsQzhzyA13aQiIG0oeAaQj4pwung== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ff20-20020a0562140bd400b0068cb23914a0si593336qvb.476.2024.02.05.19.07.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-3193-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-3193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3193-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 6BF361C22A82 for ; Tue, 6 Feb 2024 03:07:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C1881AB7FC; Tue, 6 Feb 2024 03:07:41 +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 1EFB67316E for ; Tue, 6 Feb 2024 03:07:39 +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=1707188861; cv=none; b=WTC3L3RcwZ2wMkG/Moh5cJfd9rOlKMqHtd35bfXGF9prlj2fEbMEwHvC5rDpLSoDhp2LZM5lg8J214fHC0qMCZJ+mTnErGYb7fY+KPkXv3FwmAb9mClVfGWAUBcmqKByhZkpne74jvGVtEeVRvI37cVNNT4wgCpfp8qnnsNYhlI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707188861; c=relaxed/simple; bh=Q9A4y+oyqDEIxYRUWlO2vBlHjhAkNRQOX8QAFho/jfI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WhEnBey8YSGzmbL59oEvpL9SBp7E+VIDHF7/57FVUgblU3mvWwfghvIEvGiBHVGcBACywAZvOxgUcKsMzt2HnZXvEXl3ENuCZUUTbeqAWjyn6HC0Iw3X5oeqHg43MAfHV3LMDe4tAc8skj2yzBKDQPGIiiDJBUVd9gZe1tsMJT4= 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 41637YvD43532560, 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 41637YvD43532560 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Feb 2024 11:07:34 +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:35 +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:34 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH 6/6] wifi: rtw89: chan: MCC take reconfig into account Date: Tue, 6 Feb 2024 11:06:24 +0800 Message-ID: <20240206030624.23382-7-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 During mac80211 reconfig, chanctx ops of multiple channels might not be called in order as normal cases. However, we expect the first active chanctx always to be put at our sub entity index 0. So, if it does not, we do a swap there. Besides, reconfig won't allocate a new chanctx object. So, we should reset the reference count when ops add chanctx. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/chan.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c index 71fe0d3ab3b0..7b9baf4db70f 100644 --- a/drivers/net/wireless/realtek/rtw89/chan.c +++ b/drivers/net/wireless/realtek/rtw89/chan.c @@ -1980,6 +1980,7 @@ int rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev, rtw89_config_entity_chandef(rtwdev, idx, &ctx->def); cfg->idx = idx; + cfg->ref_count = 0; hal->sub[idx].cfg = cfg; return 0; } @@ -2011,11 +2012,23 @@ int rtw89_chanctx_ops_assign_vif(struct rtw89_dev *rtwdev, struct ieee80211_chanctx_conf *ctx) { struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv; + struct rtw89_entity_weight w = {}; rtwvif->sub_entity_idx = cfg->idx; rtwvif->chanctx_assigned = true; cfg->ref_count++; + if (cfg->idx == RTW89_SUB_ENTITY_0) + goto out; + + rtw89_entity_calculate_weight(rtwdev, &w); + if (w.active_chanctxs != 1) + goto out; + + /* put the first active chanctx at RTW89_SUB_ENTITY_0 */ + rtw89_swap_sub_entity(rtwdev, cfg->idx, RTW89_SUB_ENTITY_0); + +out: return rtw89_set_channel(rtwdev); } -- 2.25.1