Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2788354rdb; Mon, 5 Feb 2024 19:08:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0gmB9XVURYFIOPup5J+9XFysoA593z+OpyFgy20wj5NRSimRzqjZ24rbz8pKAxLNPvfoA X-Received: by 2002:a05:6358:5907:b0:176:5bef:d33e with SMTP id g7-20020a056358590700b001765befd33emr876022rwf.14.1707188923626; Mon, 05 Feb 2024 19:08:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707188923; cv=pass; d=google.com; s=arc-20160816; b=TR/wGgqofwexw68Y9iVUwUuRI5iBPADINrsep3YBW1BXOKFzdDKeHzQQuqhmaUFgZw d5T4fP6643tENhazst2IWW9OwJbwI8wJWZ1ZDOXRxkY67w70tclKkqh/BkLaZ8VtFZLC AuNm7aWa+nhd7mJu8rgHuLrNxtMWXchCqrVTQm1WyJbtR5VUSHLyRzGAeMCmZWCipVBv MHA8z275Amp60SoyhRCj6U0EdkIHu7G7pnEbPc6yQXOIqert0C1O/6LdOxcpkgsUgIJD 09NTORGG6Hdng9HJBmoIjZQs1jxBrWMuoXrRUIyrjnUGqNhyEKTyQehVU7Bzqhx0xMNf 5Mvg== 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=JWyxyNtgRApAmn2Syv+BJLzGQRP/b18C9gWgV2PNTJs=; fh=P22SIOT2Nh6epU7xk44H4tsbEAEAbhs9RZVY4FtyeJk=; b=V7Vr4y2bxn8HJwLS3l24iBiXHqd5CyfreiWEwJ8Yag0jEwuTQqxYsSPD2ZqgNGgs4m Xegci3N93Js1sBjITVvRxtxpwi1EmOvHzb0cpNutMmli9zPoMxUOiLICpLz3WF/GZ0n4 ywFyWKW4v2mR3K2EeqGkzMOYEg9SvdR2kFi0sBWL+K1VNTlJP7p9kpg4ZG/sZ+5/WSFM cZwomCCNyNiK9A+rXn92ffh+heKeYNzaIo2loG0B3q3dfDxPm6lXLWf1BUntyVtI7CoP RHYRKg6e+EAXYBU1wKFqPbMb80aME7FUNrk91wexsy/hsCQZcta9fz0Lpv42Zig9741j QTxg==; 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-3190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3190-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWKmwCR36AYilPnyRbM/YonIC7KXevRC8TyvJ+yZ3m8xoIw24vo42ZMoXSBvBiHTu8x6WHxUIcjKZ6zEWqn99huZy3+RNvjoumliK1EKw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j8-20020a170903024800b001d8b5747fd3si870596plh.228.2024.02.05.19.08.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:08:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-3190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-3190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3190-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 76B7AB22667 for ; Tue, 6 Feb 2024 03:07:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F161E73175; Tue, 6 Feb 2024 03:07:22 +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 3215D73163 for ; Tue, 6 Feb 2024 03:07:20 +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=1707188842; cv=none; b=KRuU7N3+5gl9yh6iGUE1iwaA1Sk7Z4lsOyLA3lJCNhnzQ2XoowNWnAl9RlcnV+bdzrFu0pqUFUSGs4qMyzFWT/i0ubaHvDNnwFgeG5tvAZ8dgUyw9LX5Gg8Nj55NrM6lHveXMLPcZrnXgLuwC6iAfSOcitGdO534laZV1K6VHRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707188842; c=relaxed/simple; bh=0foG6KG6cjlpU6jK2o4X6AgQ3eRIS/2fecopVP7Ts3U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nmKSEeFS/ugzfZ/V/+mK1jMXxxX/m4CWEaiYiD8dG94CIh30pnFgqyEA8MFNvLMNm/+AY3qgJq1tvM2ajrGvq99xZeRczbUOZxxqgWzBFtKHG6YPZFgbQ02OfNDwhaZW0YIC7AkDfUNpdyizb2MQPowoWX78TBZtfu+1ixp9efI= 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 41637FzZ43532488, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 41637FzZ43532488 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Feb 2024 11:07:15 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.17; Tue, 6 Feb 2024 11:07:16 +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:15 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH 3/6] wifi: rtw89: chan: tweak bitmap recalc ahead before MLO Date: Tue, 6 Feb 2024 11:06:21 +0800 Message-ID: <20240206030624.23382-4-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) From: Zong-Zhe Yang Originally, we just declared two sub-entity, and according to rolling down mechanism, we ensured that index 0 contained sub-entity as long as there are sub-entity. So, we could use for-loop after deciding the last index. But, we are preparing to expand num of sub-entity for MLO. Then, there won't be just two sub-entity. And, there might be holes between two bits in the bitmap. So, we cannot simply do for-loop as before. Instead, we need to follow the set bits. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/chan.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c index 11d46878f51e..6a666a92b59b 100644 --- a/drivers/net/wireless/realtek/rtw89/chan.c +++ b/drivers/net/wireless/realtek/rtw89/chan.c @@ -214,31 +214,32 @@ void rtw89_entity_init(struct rtw89_dev *rtwdev) enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev) { + DECLARE_BITMAP(recalc_map, NUM_OF_RTW89_SUB_ENTITY) = {}; struct rtw89_hal *hal = &rtwdev->hal; const struct cfg80211_chan_def *chandef; enum rtw89_entity_mode mode; struct rtw89_chan chan; u8 weight; - u8 last; u8 idx; lockdep_assert_held(&rtwdev->mutex); + bitmap_copy(recalc_map, hal->entity_map, NUM_OF_RTW89_SUB_ENTITY); + weight = bitmap_weight(hal->entity_map, NUM_OF_RTW89_SUB_ENTITY); switch (weight) { default: rtw89_warn(rtwdev, "unknown ent chan weight: %d\n", weight); - bitmap_zero(hal->entity_map, NUM_OF_RTW89_SUB_ENTITY); + bitmap_zero(recalc_map, NUM_OF_RTW89_SUB_ENTITY); fallthrough; case 0: rtw89_config_default_chandef(rtwdev); + set_bit(RTW89_SUB_ENTITY_0, recalc_map); fallthrough; case 1: - last = RTW89_SUB_ENTITY_0; mode = RTW89_ENTITY_MODE_SCC; break; case 2: - last = RTW89_SUB_ENTITY_1; mode = rtw89_get_entity_mode(rtwdev); if (mode == RTW89_ENTITY_MODE_MCC) break; @@ -247,7 +248,7 @@ enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev) break; } - for (idx = 0; idx <= last; idx++) { + for_each_set_bit(idx, recalc_map, NUM_OF_RTW89_SUB_ENTITY) { chandef = rtw89_chandef_get(rtwdev, idx); rtw89_get_channel_params(chandef, &chan); if (chan.channel == 0) { -- 2.25.1