Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp97788lqt; Thu, 18 Apr 2024 09:20:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVZxBq1691hwUSHTlsRJa5WVpZAvu1IS2v8UGWXAcjImWO5KXeUmqhVfCWydnNV76PFqVXLakM/Uvw9OwtPqPmFdA3rJ+x5ZGpmI7TARg== X-Google-Smtp-Source: AGHT+IHUmD2hT0/io5quGWJuTGpMYSh+TzgFrbyUvN8h80arozr8/FHaZYpwCt0OMmOq5WKWmHZq X-Received: by 2002:a05:620a:5222:b0:78f:677:63a3 with SMTP id dc34-20020a05620a522200b0078f067763a3mr3207105qkb.41.1713457237729; Thu, 18 Apr 2024 09:20:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713457237; cv=pass; d=google.com; s=arc-20160816; b=0H27XsDSYuhIRAquP7SA9mj/ZC7H5cqqztbCoiDA0C0GvMQdgSokJY61xu2qeloJgc G8qn4YmK8UTrkZhSRnmDummdwavOV/dSZ+H9Vz9IrBXSJbwben+6/N5S2HVxHIcRiuhk jMvotIyrS5GJAvA+QCgVhGn7thkDIJZlyHe+JZw3iJBmGDQbE3gQ1osfOuNZw+xGd/Vp DKaL8H8/cRBA2SU5znze0P8cdRP9ODgj5+DyPwsNeLKrDviWeE4tx0C5PyL3lcMJsr7u llvQHPZlWU5V0pWZHva4oEGFKTHAH43d3Z+AJlghZTop1Noo3v240Ezw7YEWFUuMKZOE kvIA== 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:dkim-signature; bh=yQ0ecB+l75cGxRwY7lVJkc0jzGVqtrTgSsEDd83ZqFU=; fh=unOd+iR/s4g3ccNRscfqoIvCvfbfQt24cpkffWnNbx8=; b=ynURxWhdQiKbsXOz64hI3jtKXJFsG1aAWjosOChbKQfnVVDGDHnx1EKtQHngMrl7Rv Bqp5DE3i2+rgkgRk4by0KbCeWm5Mtz+Ej1hbdxYD8asULEFnLNSlYbYSdK8yJCK0SrqB mpeB1TqKRTDbjTGdc4JM4cpTcKGXI+R1yybVxsRmf/b5tmrJP8vZsAME1J2HPZ0rFq5G wmuJ7Gf86IkY8kKDrwY+pLiZWcUoaUg3MLD5uYx3bomw3SnE3rpMFVgrSLPb4+upd2Ui M49wA90l+/C296rdvuq2OOi4x1smNWZYYvFKygQI8hw/XEDUJZO+EwNr+2thk1sAXqrd SEEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a6mcjY7H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-6535-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m3-20020a05620a24c300b0078a39dc8f3csi1957278qkn.86.2024.04.18.09.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 09:20:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6535-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a6mcjY7H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-6535-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 3BE511C216C8 for ; Thu, 18 Apr 2024 16:20:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2413116FF2A; Thu, 18 Apr 2024 16:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a6mcjY7H" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 009E616F918 for ; Thu, 18 Apr 2024 16:20:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457226; cv=none; b=fJuI7uNCBR7qS86EgeEv1GksloX511PY3jeot9ip5cpwQ3jWz5LoRPijz4KSPGMKSyGEM55Fa2Iqsgz2JCjc1FREzfxUvbReTnPRRycHZ/4GGMavExd56CheG2MZy+TJ2qWm5JT/f61fm2B07ttSsuWacJop7YW+GhDWU4glrGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457226; c=relaxed/simple; bh=dRUTCKzTiFbxyH8ftvDEo2GPr1jUEjLwlCbTFyrD7Gc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sGcwF2DKuky6TVGPY+fcg9oX34qvslPAVONR9BJBYqVGsEuLwIjabEDtbi/20uMzZndl1pYskLPwuMC2jGUHuCRivXryAntX0IG7nk3gmEShSJy7ILS18XJsqY68rcZ+U5Tm7R4ApJOA8PWoqpEIIVUGvlqV33XPyL5dnTJmGnc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a6mcjY7H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD2F1C113CC; Thu, 18 Apr 2024 16:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713457225; bh=dRUTCKzTiFbxyH8ftvDEo2GPr1jUEjLwlCbTFyrD7Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a6mcjY7HcAV+BC9qfjAhQUDAknbVj1ctnleB6Zs9+zHWpDHvmSTizc4BJJVwcH9Sx 3aIMYrhRTBTU0SNWunLE1sSoPjGcIpc3Zij0nri/7onFIswNGfckbwP/Ce38wH6Jfs /2qwAAG98ynAF2QKTLPRcMBIOgXvl4jsNTN59yfFpZRSPfdVBaDg21L5hlJHe9FU7d GXqiI1CLk/JtJ+JfJA3MQNlyaPGWeHoPT87DRlswsq1p1TnwGRoUtJeJRNKQLwnOBk W+dsMdbMXT1BBrpd5hWxJaDUBK8uQ3RmVP2MOXH5ELPZzqubuxAXpRNO8yVapmZ24q 92jBBbQ45tjew== From: Kalle Valo To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH v8 3/4] wifi: ath12k: ACPI CCA threshold support Date: Thu, 18 Apr 2024 19:20:18 +0300 Message-Id: <20240418162019.1246749-4-kvalo@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240418162019.1246749-1-kvalo@kernel.org> References: <20240418162019.1246749-1-kvalo@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Lingbo Kong Currently, ath12k does not have the ability to adjust Clear Channel Assessment (CCA) threshold values to meet the regulatory requirements. Get the values from ACPI and send them to the firmware using ath12k_wmi_set_bios_cmd() function. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 Signed-off-by: Lingbo Kong Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath12k/acpi.c | 37 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 8 ++++++ drivers/net/wireless/ath/ath12k/core.h | 1 + drivers/net/wireless/ath/ath12k/wmi.h | 1 + 4 files changed, 47 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/acpi.c b/drivers/net/wireless/ath/ath12k/acpi.c index b6d6187bc347..2fb8d53de68f 100644 --- a/drivers/net/wireless/ath/ath12k/acpi.c +++ b/drivers/net/wireless/ath/ath12k/acpi.c @@ -79,6 +79,18 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func) memcpy(&ab->acpi.geo_offset_data, obj->buffer.pointer, obj->buffer.length); + break; + case ATH12K_ACPI_DSM_FUNC_INDEX_CCA: + if (obj->buffer.length != ATH12K_ACPI_DSM_CCA_DATA_SIZE) { + ath12k_warn(ab, "invalid ACPI DSM CCA data size: %d\n", + obj->buffer.length); + ret = -EINVAL; + goto out; + } + + memcpy(&ab->acpi.cca_data, obj->buffer.pointer, + obj->buffer.length); + break; } } else { @@ -226,6 +238,7 @@ static int ath12k_acpi_set_tas_params(struct ath12k_base *ab) int ath12k_acpi_start(struct ath12k_base *ab) { acpi_status status; + u8 *buf; int ret; if (!ab->hw_params->acpi_guid) @@ -297,6 +310,30 @@ int ath12k_acpi_start(struct ath12k_base *ab) return ret; } + if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_CCA)) { + ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_INDEX_CCA); + if (ret) { + ath12k_warn(ab, "failed to get ACPI DSM CCA threshold configuration: %d\n", + ret); + return ret; + } + + if (ab->acpi.cca_data[0] == ATH12K_ACPI_CCA_THR_VERSION && + ab->acpi.cca_data[ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET] == + ATH12K_ACPI_CCA_THR_ENABLE_FLAG) { + buf = ab->acpi.cca_data + ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET; + ret = ath12k_wmi_set_bios_cmd(ab, + WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE, + buf, + ATH12K_ACPI_CCA_THR_OFFSET_LEN); + if (ret) { + ath12k_warn(ab, "failed to set ACPI DSM CCA threshold: %d\n", + ret); + return ret; + } + } + } + status = acpi_install_notify_handler(ACPI_HANDLE(ab->dev), ACPI_DEVICE_NOTIFY, ath12k_acpi_dsm_notify, ab); diff --git a/drivers/net/wireless/ath/ath12k/acpi.h b/drivers/net/wireless/ath/ath12k/acpi.h index 24a4c981e8de..9900fe3b1b1c 100644 --- a/drivers/net/wireless/ath/ath12k/acpi.h +++ b/drivers/net/wireless/ath/ath12k/acpi.h @@ -11,11 +11,13 @@ #define ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS 0 #define ATH12K_ACPI_DSM_FUNC_BIOS_SAR 4 #define ATH12K_ACPI_DSM_FUNC_GEO_OFFSET 5 +#define ATH12K_ACPI_DSM_FUNC_INDEX_CCA 6 #define ATH12K_ACPI_DSM_FUNC_TAS_CFG 8 #define ATH12K_ACPI_DSM_FUNC_TAS_DATA 9 #define ATH12K_ACPI_FUNC_BIT_BIOS_SAR BIT(3) #define ATH12K_ACPI_FUNC_BIT_GEO_OFFSET BIT(4) +#define ATH12K_ACPI_FUNC_BIT_CCA BIT(5) #define ATH12K_ACPI_FUNC_BIT_TAS_CFG BIT(7) #define ATH12K_ACPI_FUNC_BIT_TAS_DATA BIT(8) @@ -26,13 +28,17 @@ #define ATH12K_ACPI_TAS_DATA_ENABLE 0x1 #define ATH12K_ACPI_POWER_LIMIT_VERSION 0x1 #define ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG 0x1 +#define ATH12K_ACPI_CCA_THR_VERSION 0x1 +#define ATH12K_ACPI_CCA_THR_ENABLE_FLAG 0x1 #define ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET 1 #define ATH12K_ACPI_DBS_BACKOFF_DATA_OFFSET 2 +#define ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET 5 #define ATH12K_ACPI_BIOS_SAR_DBS_BACKOFF_LEN 10 #define ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET 12 #define ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN 18 #define ATH12K_ACPI_BIOS_SAR_TABLE_LEN 22 +#define ATH12K_ACPI_CCA_THR_OFFSET_LEN 36 #define ATH12K_ACPI_DSM_TAS_DATA_SIZE 69 #define ATH12K_ACPI_DSM_TAS_CFG_SIZE 108 @@ -41,6 +47,8 @@ ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN) #define ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE (ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET + \ ATH12K_ACPI_BIOS_SAR_TABLE_LEN) +#define ATH12K_ACPI_DSM_CCA_DATA_SIZE (ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET + \ + ATH12K_ACPI_CCA_THR_OFFSET_LEN) #ifdef CONFIG_ACPI diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index dac4a6cd60f1..0e33cf783f62 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -913,6 +913,7 @@ struct ath12k_base { u8 tas_sar_power_table[ATH12K_ACPI_DSM_TAS_DATA_SIZE]; u8 bios_sar_data[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE]; u8 geo_offset_data[ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE]; + u8 cca_data[ATH12K_ACPI_DSM_CCA_DATA_SIZE]; } acpi; #endif /* CONFIG_ACPI */ diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index 8ace566f7eb5..6db15a0a4735 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -4805,6 +4805,7 @@ struct wmi_pdev_set_bios_interface_cmd { } __packed; enum wmi_bios_param_type { + WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE = 0, WMI_BIOS_PARAM_TAS_CONFIG_TYPE = 1, WMI_BIOS_PARAM_TAS_DATA_TYPE = 2, WMI_BIOS_PARAM_TYPE_MAX, -- 2.39.2