Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp876610rdh; Thu, 23 Nov 2023 23:18:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHExgL/8m2wSQ0X2n7iPpMTbTHRba4WClmfqutDCdX7Sh9qEY/DTGheBH3u3JDOChZf5XnB X-Received: by 2002:a05:622a:4a0d:b0:423:9642:7824 with SMTP id fv13-20020a05622a4a0d00b0042396427824mr2349732qtb.49.1700810309150; Thu, 23 Nov 2023 23:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700810309; cv=none; d=google.com; s=arc-20160816; b=aRLoIpHU8xMAlhPmfHqw76tRpbAclLGqeVrK5TW08o9jUkyIYLCOxV5d+Eq0eDMbf7 JXvvI2bqzpCZd88L4MsOnVgjifZrF8VGESnuw55HWRxk0yYT6ctkYODmH4swOzg03NBh bc7Oflr4Oxsn3zEhiDYAF97Dtqpn199HGqwasbj0KKkev34DKZCaRs/P0sREO0idNppq HYnXtpZ/zSORFIUWwzKPiK2GfKgF+h0gZJb/aVPtsavZoN7ATzpzBOfm7Kunxqj5WApC UI4dSdmPk7ukqfBvxSbBVHFGpULQGDWrp0DdJc17a4JWX9af8QJuUOvT9PHP+qs65Rif LZvQ== ARC-Message-Signature: i=1; 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=mNt5WdJickzDLAGtaLw10kGLVCcmQgapwcApY+W5/J0=; fh=TSuyMlfOTyCx0zt3ucDyTttlN37QPvmvgk5pf20rBgY=; b=oRJ69pfxokjX+Xwh2x2dMLE08atGdxQhgaFTaCSJHiM6MhIQn8i8vmNeWf0LVd1E1s i5ovekP5i8AoTnlieDO3YY+joKgTWMMxo+zyjme3qtIAtdC0SVdmwv2GURPz4dtM7J8+ m/2pSI1oLP4vKpdpJqM6XI21QABD5RZ5rxaMsy5xi1aHFPJemX0RSAEhTVCfKEirInT5 P0oQ6H5Xe9sLGzl58kXl2LqOg3ybYbzqumEL3LfILWByuBagJrrNtvWQAKWe1YqMUluB TX+3KjLUJmOW/l3NLrE7cBXPf3uktq//7YlUp9pc4QXKfp89X/tF+mAuQ9dvI7TSgcXi K7+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-28-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-28-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id cb9-20020a05622a1f8900b004238bffaf90si2819535qtb.804.2023.11.23.23.18.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 23:18:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-28-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-28-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-28-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 E0D2C1C20A0E for ; Fri, 24 Nov 2023 07:18:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA33C8F63; Fri, 24 Nov 2023 07:18:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F06D5E for ; Thu, 23 Nov 2023 23:18:14 -0800 (PST) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 3AO7I73M03551149, 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 3AO7I73M03551149 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Nov 2023 15:18:07 +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_128_GCM_SHA256) id 15.1.2507.17; Fri, 24 Nov 2023 15:18:08 +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_128_GCM_SHA256) id 15.1.2375.7; Fri, 24 Nov 2023 15:18:07 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH 3/8] wifi: rtw89: add reserved size as factor of DLE used size Date: Fri, 24 Nov 2023 15:16:58 +0800 Message-ID: <20231124071703.132549-4-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231124071703.132549-1-pkshih@realtek.com> References: <20231124071703.132549-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: RTEXMBS04.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback DLE stands for Double Link Engine that is used to maintain buffer page. To avoid linking to wrong pages, we check the used page size during initialization and stop driver probe if the used size is unexpected. Currently, we check the page size used by PLE (payload engine) and WDE (WiFi descriptor engine). For coming WiFi 7 chips, additional reserved size is added for BB as buffer to run LA mode, so add and check the reserved size as well. Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/mac.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c index ac14865a114a..bdd9c152951f 100644 --- a/drivers/net/wireless/realtek/rtw89/mac.c +++ b/drivers/net/wireless/realtek/rtw89/mac.c @@ -1672,11 +1672,21 @@ static bool mac_is_txq_empty(struct rtw89_dev *rtwdev) return (val32 & msk32) == msk32; } -static inline u32 dle_used_size(const struct rtw89_dle_size *wde, - const struct rtw89_dle_size *ple) +static inline u32 dle_used_size(const struct rtw89_dle_mem *cfg) { - return wde->pge_size * (wde->lnk_pge_num + wde->unlnk_pge_num) + + const struct rtw89_dle_size *wde = cfg->wde_size; + const struct rtw89_dle_size *ple = cfg->ple_size; + u32 used; + + used = wde->pge_size * (wde->lnk_pge_num + wde->unlnk_pge_num) + ple->pge_size * (ple->lnk_pge_num + ple->unlnk_pge_num); + + if (cfg->rsvd0_size && cfg->rsvd1_size) { + used += cfg->rsvd0_size->size; + used += cfg->rsvd1_size->size; + } + + return used; } static u32 dle_expected_used_size(struct rtw89_dev *rtwdev, @@ -1898,8 +1908,7 @@ static int dle_init(struct rtw89_dev *rtwdev, enum rtw89_qta_mode mode, ext_wde_min_qt_wcpu = ext_cfg->wde_min_qt->wcpu; } - if (dle_used_size(cfg->wde_size, cfg->ple_size) != - dle_expected_used_size(rtwdev, mode)) { + if (dle_used_size(cfg) != dle_expected_used_size(rtwdev, mode)) { rtw89_err(rtwdev, "[ERR]wd/dle mem cfg\n"); ret = -EINVAL; goto error; @@ -3037,8 +3046,7 @@ static int dle_quota_change(struct rtw89_dev *rtwdev, enum rtw89_qta_mode mode) return -EINVAL; } - if (dle_used_size(cfg->wde_size, cfg->ple_size) != - dle_expected_used_size(rtwdev, mode)) { + if (dle_used_size(cfg) != dle_expected_used_size(rtwdev, mode)) { rtw89_err(rtwdev, "[ERR]wd/dle mem cfg\n"); return -EINVAL; } -- 2.25.1