From patchwork Mon Jul 10 08:36:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40A11EB64D9 for ; Mon, 10 Jul 2023 08:39:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233087AbjGJIj2 (ORCPT ); Mon, 10 Jul 2023 04:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231134AbjGJIjB (ORCPT ); Mon, 10 Jul 2023 04:39:01 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2046.outbound.protection.outlook.com [40.107.237.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73CD9E9; Mon, 10 Jul 2023 01:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ufuz5toGgnkBZck8Nv0xshqVd4+ZIrUb0v7y6l7ZragKp63e+/dhlTtjni6OLgqHEjbNnYE1CF/3U2iED+gEabZTMm00n3hKo5pUYjiwTJ+t3d3kcNRXj7GXjLWcFkEwE0TyqVZb6o7Oz5RfhUMliK6RVQU7dmOKE+m6Z0Khi+73EoG0PXBMuJMLLg4xjPEnCdq6kMRQQ1RDKvGSPtTcFdot4GOPXcoNbUgBPQSXvNfEzqSUnUMP/DnNEn8MdQd/KvESyLLNMWi+s/gAvwbZPdzw9k09O2OY2Ha4TyeGwnCiCyAaJd7529zlVoqKBP0WdDDqY2zw6p3EgXQ/eLBEWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Bpornu5Yj7Tw0flQlscdO20Wfpe40rXSOJGeHuvILis=; b=IlcKFOhb87VbozvnvtrYk/BGco6N6qy/cupxGL5qcu/RWLsJPs1JHGIXsczNkvZtfgdCBLsdmQbPGDvm/hfkMqq7R75yue+VFZhBIrke/nCrcj1Kwn+oKJwP4e9zrgZa7M/1mYvCkqIZIUh3wlcBIYZFezue8//F8PP4yAtfX2GUY9eHnmX8gCr+aJ2Gw8FJP+gMhDhhIkP1bDtW5ph/htyzlDhiKjTlnzsJrM4o+3zBoPpTFi8v1F1/sOMxhvBa/ZLK6rLcpUHHsATP8ZROieNN7BoahiZcB/6+L5/0YYtFKy8G2y9fJmLjC91VEmHOgAup4Xs3Va+5P2c4yrRE1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bpornu5Yj7Tw0flQlscdO20Wfpe40rXSOJGeHuvILis=; b=fZNq8D/egvceuM7ko+bfYCXVmtTA7cXX/ssCr3FKeXfUYa+m247xiEqqk3WVKhIdBGxI6TRabPBL6T/aiLwvn/6O6hSzDzHwMBDyy20UtT5fNkIPNd8cVAnzu/rdacVKZnACu/gGMd+mHPXSIXqBsJpWOT7CUDACyuS/YuE0xVE= Received: from MW4P221CA0018.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::23) by SA1PR12MB7174.namprd12.prod.outlook.com (2603:10b6:806:2b1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 08:38:34 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::a4) by MW4P221CA0018.outlook.office365.com (2603:10b6:303:8b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 08:38:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Mon, 10 Jul 2023 08:38:33 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:38:25 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 1/9] drivers core: Add support for Wifi band RF mitigations Date: Mon, 10 Jul 2023 16:36:33 +0800 Message-ID: <20230710083641.2132264-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT048:EE_|SA1PR12MB7174:EE_ X-MS-Office365-Filtering-Correlation-Id: 308b663a-03c5-4791-c7ae-08db81210c20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h7abzS2nI5W+7DS65Wip75VX6eP0cBVEZFZVkcMWi74h0p3fNQ9jjmWbN/YaSDnI3zq3gaNgnu0nwCCqzUfl7A7ejk01pLljopVkGCZ/7Vc9a0u2HIVSqsTYawyDU7uHe8FovOkrDifCDBwVKaJRNCxJuP8RMn2Ee5qRjORwE4uoS4Hc9ozfNnl+Veu9KBFP63x2ZngwNbdJyk6CbNzujq9AaNThLotdhlTaH6qcUn+IJzbpaix131A29aR73XBGUJOK/3TnYxBpOi6WyGhf4JnEa/f7Onpx7hTcYUFvk02Z687AEFSCDpvEktu8F+g3Q9S2uMqmuZH22ZC4hrM7UrbjXhk3Ev7Ay3ZL8K8i+zRffq5Lp8lc9wMqtyMBzK0wnsKKCaI/y5XeShlmjf3u1Eq47iY5QqpL+TNINwq+gEphs5y4oLdAbn5xbZsZ+zsS8YlexKUmrHCVJXxh21Y/V29Z/P+zazJ8TjgIuUH4OVJ9UBywEE/vQZw7SMsu7CeG7uNvngx7/uYMUHB441vhYudUcyV4gC0ON1/oTnQebDn+2LwGq9ZDp7DBmVngbWijAXAXXvPr0rWRHHW/od7W0x/VhkAlA891Z2aOlZMaVTrhDeoKxWu9WpMP9SmCEw+L1fIGQqMkFPmClkIsxjAur5/iEwzAMAzVwG9pUO74FOW+TBZl0/Ev/ulITNuRSXWoOsfflq2bQzG+m5yPrSMGCl9HhmrBKqSWxToyEeZrGV8vnoMfg5w0KQ5+yEWHELUp9axnyve6cBK7yCl4TNb9enmWaNKreXVObNBfsw1bOeIQAictHUj/EMYK9J6ortbH5Agz+psGFLsx4wqVDZdGCA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(186003)(16526019)(26005)(2616005)(1076003)(36860700001)(336012)(426003)(83380400001)(47076005)(41300700001)(30864003)(4326008)(2906002)(316002)(44832011)(7416002)(5660300002)(8676002)(8936002)(478600001)(7696005)(6666004)(70586007)(70206006)(110136005)(54906003)(40480700001)(36756003)(921005)(81166007)(356005)(82740400003)(86362001)(82310400005)(83996005)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:38:33.8873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 308b663a-03c5-4791-c7ae-08db81210c20 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7174 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7. To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance. In order for a device to support this, the expected flow for device driver or subsystems: Drivers/subsystems contributing frequencies: 1) During probe, check `wbrf_supported_producer` to see if WBRF supported for the device. 2) If adding frequencies, then call `wbrf_add_exclusion` with the start and end ranges of the frequencies. 3) If removing frequencies, then call `wbrf_remove_exclusion` with start and end ranges of the frequencies. Drivers/subsystems responding to frequencies: 1) During probe, check `wbrf_supported_consumer` to see if WBRF is supported for the device. 2) Call the `wbrf_retrieve_exclusions` to retrieve the current exclusions on receiving an ACPI notification for a new frequency change. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v4->v5: - promote this to be a more generic solution with input argument taking `struct device` and provide better scalability to support non-ACPI scenarios(Andrew) - update the APIs naming and some other minor fixes(Rafael) --- drivers/base/Kconfig | 8 ++ drivers/base/Makefile | 1 + drivers/base/wbrf.c | 227 ++++++++++++++++++++++++++++++++++++++++++ include/linux/wbrf.h | 70 +++++++++++++ 4 files changed, 306 insertions(+) create mode 100644 drivers/base/wbrf.c create mode 100644 include/linux/wbrf.h diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 2b8fd6bb7da0..5b441017b225 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -242,4 +242,12 @@ config FW_DEVLINK_SYNC_STATE_TIMEOUT command line option on every system/board your kernel is expected to work on. +config WBRF + bool "Wifi band RF mitigation mechanism" + default n + help + Wifi band RF mitigation mechanism allows multiple drivers from + different domains to notify the frequencies in use so that hardware + can be reconfigured to avoid harmonic conflicts. + endmenu diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 3079bfe53d04..c844f68a6830 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_GENERIC_MSI_IRQ) += platform-msi.o obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += arch_topology.o obj-$(CONFIG_GENERIC_ARCH_NUMA) += arch_numa.o obj-$(CONFIG_ACPI) += physical_location.o +obj-$(CONFIG_WBRF) += wbrf.o obj-y += test/ diff --git a/drivers/base/wbrf.c b/drivers/base/wbrf.c new file mode 100644 index 000000000000..2163a8ec8a9a --- /dev/null +++ b/drivers/base/wbrf.c @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include + +static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); +static DEFINE_MUTEX(wbrf_mutex); +static struct exclusion_range_pool wbrf_pool; + +static int _wbrf_add_exclusion_ranges(struct wbrf_ranges_in *in) +{ + int i, j; + + for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { + if (!in->band_list[i].start && + !in->band_list[i].end) + continue; + + for (j = 0; j < ARRAY_SIZE(wbrf_pool.band_list); j++) { + if (wbrf_pool.band_list[j].start == in->band_list[i].start && + wbrf_pool.band_list[j].end == in->band_list[i].end) { + wbrf_pool.ref_counter[j]++; + break; + } + } + if (j < ARRAY_SIZE(wbrf_pool.band_list)) + continue; + + for (j = 0; j < ARRAY_SIZE(wbrf_pool.band_list); j++) { + if (!wbrf_pool.band_list[j].start && + !wbrf_pool.band_list[j].end) { + wbrf_pool.band_list[j].start = in->band_list[i].start; + wbrf_pool.band_list[j].end = in->band_list[i].end; + wbrf_pool.ref_counter[j] = 1; + break; + } + } + if (j >= ARRAY_SIZE(wbrf_pool.band_list)) + return -ENOSPC; + } + + return 0; +} + +static int _wbrf_remove_exclusion_ranges(struct wbrf_ranges_in *in) +{ + int i, j; + + for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { + if (!in->band_list[i].start && + !in->band_list[i].end) + continue; + + for (j = 0; j < ARRAY_SIZE(wbrf_pool.band_list); j++) { + if (wbrf_pool.band_list[j].start == in->band_list[i].start && + wbrf_pool.band_list[j].end == in->band_list[i].end) { + wbrf_pool.ref_counter[j]--; + if (!wbrf_pool.ref_counter[j]) { + wbrf_pool.band_list[j].start = 0; + wbrf_pool.band_list[j].end = 0; + } + break; + } + } + } + + return 0; +} + +static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) +{ + int out_idx = 0; + int i; + + memset(out, 0, sizeof(*out)); + + for (i = 0; i < ARRAY_SIZE(wbrf_pool.band_list); i++) { + if (!wbrf_pool.band_list[i].start && + !wbrf_pool.band_list[i].end) + continue; + + out->band_list[out_idx].start = wbrf_pool.band_list[i].start; + out->band_list[out_idx++].end = wbrf_pool.band_list[i].end; + } + + return 0; +} + +/** + * wbrf_supported_producer - Determine if the device can report frequencies + * + * @dev: device pointer + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if this device needs to report such frequencies. + */ +bool wbrf_supported_producer(struct device *dev) +{ + return true; +} +EXPORT_SYMBOL_GPL(wbrf_supported_producer); + +/** + * wbrf_add_exclusion - Add frequency ranges to the exclusion list + * + * @dev: device pointer + * @in: input structure containing the frequency ranges to be added + * + * Add frequencies into the exclusion list for supported consumers + * to react to. + */ +int wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + int r; + + mutex_lock(&wbrf_mutex); + + r = _wbrf_add_exclusion_ranges(in); + + mutex_unlock(&wbrf_mutex); + if (r) + return r; + + blocking_notifier_call_chain(&wbrf_chain_head, WBRF_CHANGED, NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(wbrf_add_exclusion); + +/** + * wbrf_remove_exclusion - Remove frequency ranges from the exclusion list + * + * @dev: device pointer + * @in: input structure containing the frequency ranges to be removed + * + * Remove frequencies from the exclusion list for supported consumers + * to react to. + */ +int wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + int r; + + mutex_lock(&wbrf_mutex); + + r = _wbrf_remove_exclusion_ranges(in); + + mutex_unlock(&wbrf_mutex); + if (r) + return r; + + blocking_notifier_call_chain(&wbrf_chain_head, WBRF_CHANGED, NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(wbrf_remove_exclusion); + +/** + * wbrf_supported_consumer - Determine if the device can react to frequencies + * + * @dev: device pointer + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if this device needs to react to reports from + * other devices for such frequencies. + */ +bool wbrf_supported_consumer(struct device *dev) +{ + return true; +} +EXPORT_SYMBOL_GPL(wbrf_supported_consumer); + +/** + * wbrf_register_notifier - Register for notifications of frequency changes + * + * @nb: driver notifier block + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will allow consumers to register for frequency notifications. + */ +int wbrf_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(wbrf_register_notifier); + +/** + * wbrf_unregister_notifier - Unregister for notifications of frequency changes + * + * @nb: driver notifier block + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will allow consumers to unregister for frequency notifications. + */ +int wbrf_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(wbrf_unregister_notifier); + +/** + * wbrf_retrieve_exclusions - Retrieve the exclusion list + * + * @dev: device pointer + * @out: output structure containing the frequency ranges to be excluded + * + * Retrieve the current exclusion list + */ +int wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) +{ + int r; + + mutex_lock(&wbrf_mutex); + + r = _wbrf_retrieve_exclusion_ranges(out); + + mutex_unlock(&wbrf_mutex); + + return r; +} +EXPORT_SYMBOL_GPL(wbrf_retrieve_exclusions); diff --git a/include/linux/wbrf.h b/include/linux/wbrf.h new file mode 100644 index 000000000000..32c017232874 --- /dev/null +++ b/include/linux/wbrf.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + */ + +#ifndef _LINUX_WBRF_H +#define _LINUX_WBRF_H + +#include + +/* Maximum number of wbrf ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +struct exclusion_range { + /* start and end point of the frequency range in Hz */ + u64 start; + u64 end; +}; + +struct exclusion_range_pool { + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; + u64 ref_counter[MAX_NUM_OF_WBRF_RANGES]; +}; + +struct wbrf_ranges_in { + /* valid entry: `start` and `end` filled with non-zero values */ + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +}; + +struct wbrf_ranges_out { + u32 num_of_ranges; + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +} __packed; + +enum wbrf_notifier_actions { + WBRF_CHANGED, +}; + +#if IS_ENABLED(CONFIG_WBRF) +bool wbrf_supported_producer(struct device *dev); +int wbrf_add_exclusion(struct device *adev, + struct wbrf_ranges_in *in); +int wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in); +int wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out); +bool wbrf_supported_consumer(struct device *dev); + +int wbrf_register_notifier(struct notifier_block *nb); +int wbrf_unregister_notifier(struct notifier_block *nb); +#else +static inline bool wbrf_supported_producer(struct device *dev) { return false; } +static inline int wbrf_add_exclusion(struct device *adev, + struct wbrf_ranges_in *in) { return 0; } +static inline int wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) { return 0; } +static inline int wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) +{ + memset(out, 0, sizeof(*out)); + + return 0; +} +static inline bool wbrf_supported_consumer(struct device *dev) { return false; } +static inline int wbrf_register_notifier(struct notifier_block *nb) { return 0; } +static inline int wbrf_unregister_notifier(struct notifier_block *nb) { return 0; } +#endif + +#endif /* _LINUX_WBRF_H */ From patchwork Mon Jul 10 08:36:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEFB7EB64D9 for ; Mon, 10 Jul 2023 08:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233089AbjGJIjm (ORCPT ); Mon, 10 Jul 2023 04:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbjGJIjG (ORCPT ); Mon, 10 Jul 2023 04:39:06 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569EB12B; Mon, 10 Jul 2023 01:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S9zSBRFEfacsNf0LGRY0o3ArJrR+w4A/bV8SpNDQ3KWc7enCYYSaHs+e2zcaKXwLt1d5E6q74ugrONuPIRWL116CBTb1SPaSQcJzf1A2pKw3cRCwcfVra3gXJBk4SEuBB/OoD/hjCW9nDPWuxIP053JS/xlGzWin0zJgvSMQbq8bV2vJM7rqT8jq2MG3XfpLNoYqvvrWH5ZIiE6he8cCKzycjqpQ4olCPng+B3uGBdKjAWdRSk81NbOg+QGP+gaOhD6n/kst8KYOcgxDiH2JoVNW+TUDykcCXJIhe05mSy2xxjeQcMS7VhAhZ5B1vauMsToJ2cacz1xIUTXLsn8AIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5nDei7uuZqoTOslWgQibBud0GsaQVKnHNM+DYs7xJ9c=; b=dfjAMKebhQupO1wEjSI41YUg16/kcUzU+ERjr/O8vykIlIL7bozT8JAwvzibQQ7hjeulYlNzpOvwOoIN231sCfEOfAR4r32NqwVsxEoTS/zzwqdTaLmNNMEhOLYhfUuPtRB8bTriH2fkZyFNBe23mbUXY6fmh28jRXArxMrWYu9TJzYd3s4QyB99cQKqVrwgSc1xMknyEIFDfe4SQ6V69s5xv7eVkb4IERFOxZoeqr7W8krikM1DXy7RmnkQO1RRG53JAwXH8T45koOi6B751uXcshGZdctWKNNGNSNc6HwRVC/yUAoM2L8ixPmvw40sSH9/k9uVm/dPgBEsJqQe3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5nDei7uuZqoTOslWgQibBud0GsaQVKnHNM+DYs7xJ9c=; b=TbBxpCkUfhIzUoZwxu3DqVt2+VHncaZ3FZbxi78IxUa2dxrA2VjxBCyNv8efQrkiZCc+L4smpTvf191ynKKpZ5jF1GSspDuM7OlE9lbgMBlj3ZD0E6IbN/f8thzBT8VUQwzjkhSWwZ4xCoDEIgvo4ImfGnm43CRf1VEEOLm8lX0= Received: from MW3PR05CA0025.namprd05.prod.outlook.com (2603:10b6:303:2b::30) by PH8PR12MB6842.namprd12.prod.outlook.com (2603:10b6:510:1c9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Mon, 10 Jul 2023 08:38:43 +0000 Received: from CO1NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::c4) by MW3PR05CA0025.outlook.office365.com (2603:10b6:303:2b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:38:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT017.mail.protection.outlook.com (10.13.175.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:38:42 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:38:33 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 2/9] driver core: add ACPI based WBRF mechanism introduced by AMD Date: Mon, 10 Jul 2023 16:36:34 +0800 Message-ID: <20230710083641.2132264-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT017:EE_|PH8PR12MB6842:EE_ X-MS-Office365-Filtering-Correlation-Id: 62c99559-42ea-4064-2d90-08db81211167 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T4z2GTXLmUxfGx6i6PewZpUK8vEG+bvNZvoMZaFfNYVJ1RVEzE6th2DO7VqQTi5LgtrzVoWrsoC7cU3CyGVpXcAXvVThxPj3Qr9YIDQL/klxfw89K7tPO4oEdYv9QsH3VNSKrXwZWuZXx0grzzFpmmxvOuLZCzMDv/PyRq9lN08SL81xU4TawSyzYhD7RbwaqDTK4KWIGhbh/JQa+o9mvq7Vxu7h53CDt9F2OfCMdYZ1nj9NK5p+zCa0vDP+Fe4rRss7EuvprR+2DJC4wBPQFpclehDb+ut42lnHFZoxTEaCBMzclmmUSI6s/AzPzZbxu49EtB0Qwtpu3t0GK+tAa0DpdC09EV2FNDN1MKjKMm8prNrG+yZXsE3Sw4WsZJYUx6ucsJAPLc9arq77a+1xcs05OrVOSUqRhH15e0Reb48e9MVXRaksSIIXEcBqvNVIYkeq2zdtaj5uqiUNnsfELWotyJS/mnF9gBQbwpIu3tcHZ2mALjPx7G7STlSHXhXe75vY+NCopXswg8Rqcb983uRx7hUIemGHSN1n5CIMhQkmifVAIWc97X/JEYOi1F/IzVVTN/172XWvaA62X+nKaMhPKnbkoehOchgBaqi9CdVzDlM4+pkgdU1pgKzZbq6L4x6C7q0mevxvAKWMvoy3UEvkl7TP7and9GyLM7zqzQvz+00hR3R1Zs4HVXo7Li+2CoLk5JKvzHAZOHzD788BRrlLkWH2ccjQ2QEg/I7UUZ48nwOnsrKPAH8MaLYFwmSykz8n4JhSCTARrZq3SyEsmAL4eUIOd6H0DywQxYWdqXWxDX4y9jCKcFw2UkPFlIpsJZKU/JH6hkkcuBd2cCUJyQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199021)(36840700001)(46966006)(40470700004)(30864003)(1076003)(8676002)(41300700001)(8936002)(44832011)(2906002)(82740400003)(356005)(4326008)(81166007)(86362001)(7416002)(5660300002)(70586007)(70206006)(316002)(921005)(40460700003)(7696005)(186003)(54906003)(110136005)(16526019)(26005)(478600001)(36756003)(83380400001)(40480700001)(336012)(2616005)(426003)(36860700001)(47076005)(66899021)(82310400005)(83996005)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:38:42.7373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62c99559-42ea-4064-2d90-08db81211167 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6842 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org AMD has introduced an ACPI based mechanism to support WBRF for some platforms with AMD dGPU + WLAN. This needs support from BIOS equipped with necessary AML implementations and dGPU firmwares. For those systems without the ACPI mechanism and developing solutions, user can use the generic WBRF solution for diagnosing potential interference issues. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v4->v5: - promote this to be a more generic solution with input argument taking `struct device` and provide better scalability to support non-ACPI scenarios(Andrew) - update the APIs naming and some other minor fixes(Rafael) v5->v6: - make the code more readable and some other fixes(Andrew) --- drivers/acpi/Makefile | 2 + drivers/acpi/amd_wbrf.c | 269 ++++++++++++++++++++++++++++++++++ drivers/base/Kconfig | 29 ++++ drivers/base/wbrf.c | 35 ++++- include/linux/acpi_amd_wbrf.h | 24 +++ include/linux/wbrf.h | 2 + 6 files changed, 355 insertions(+), 6 deletions(-) create mode 100644 drivers/acpi/amd_wbrf.c create mode 100644 include/linux/acpi_amd_wbrf.h diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index feb36c0b9446..94b940ddbf88 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -131,3 +131,5 @@ obj-y += dptf/ obj-$(CONFIG_ARM64) += arm64/ obj-$(CONFIG_ACPI_VIOT) += viot.o + +obj-$(CONFIG_WBRF_AMD_ACPI) += amd_wbrf.o diff --git a/drivers/acpi/amd_wbrf.c b/drivers/acpi/amd_wbrf.c new file mode 100644 index 000000000000..481b1c180a09 --- /dev/null +++ b/drivers/acpi/amd_wbrf.c @@ -0,0 +1,269 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include + +/* + * Functions bit vector for WBRF method + * + * Bit 0: Supported for any functions other than function 0. + * Bit 1: Function 1 (Add / Remove frequency) is supported. + * Bit 2: Function 2 (Get frequency list) is supported. + */ +#define WBRF_SUPPORT_OTHER_FUNCTION 0x0 +#define WBRF_RECORD 0x1 +#define WBRF_RETRIEVE 0x2 + +/* record actions */ +#define WBRF_RECORD_ADD 0x0 +#define WBRF_RECORD_REMOVE 0x1 + +#define WBRF_REVISION 0x1 + +static const guid_t wifi_acpi_dsm_guid = + GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c, + 0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70); + +static int wbrf_dsm(struct acpi_device *adev, u8 fn, + union acpi_object *argv4, + union acpi_object **out) +{ + union acpi_object *obj; + int rc; + + obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, fn, argv4); + if (!obj) + return -ENXIO; + + switch (obj->type) { + case ACPI_TYPE_BUFFER: + *out = obj; + return 0; + + case ACPI_TYPE_INTEGER: + rc = obj->integer.value ? -EINVAL : 0; + break; + + default: + rc = -EOPNOTSUPP; + } + + ACPI_FREE(obj); + + return rc; +} + +static int wbrf_record(struct acpi_device *adev, uint8_t action, + struct wbrf_ranges_in *in) +{ + union acpi_object argv4; + union acpi_object *tmp; + u32 num_of_ranges = 0; + u32 num_of_elements; + u32 arg_idx = 0; + u32 loop_idx; + int ret; + + if (!in) + return -EINVAL; + + for (loop_idx = 0; loop_idx < ARRAY_SIZE(in->band_list); + loop_idx++) + if (in->band_list[loop_idx].start && + in->band_list[loop_idx].end) + num_of_ranges++; + + /* + * Every range comes with two end points(start and end) and + * each of them is accounted as an element. Meanwhile the range + * count and action type are accounted as an element each. + * So, the total element count = 2 * num_of_ranges + 1 + 1. + */ + num_of_elements = 2 * num_of_ranges + 1 + 1; + + tmp = kcalloc(num_of_elements, sizeof(*tmp), GFP_KERNEL); + if (!tmp) + return -ENOMEM; + + argv4.package.type = ACPI_TYPE_PACKAGE; + argv4.package.count = num_of_elements; + argv4.package.elements = tmp; + + tmp[arg_idx].integer.type = ACPI_TYPE_INTEGER; + tmp[arg_idx++].integer.value = num_of_ranges; + tmp[arg_idx].integer.type = ACPI_TYPE_INTEGER; + tmp[arg_idx++].integer.value = action; + + for (loop_idx = 0; loop_idx < ARRAY_SIZE(in->band_list); + loop_idx++) { + if (!in->band_list[loop_idx].start || + !in->band_list[loop_idx].end) + continue; + + tmp[arg_idx].integer.type = ACPI_TYPE_INTEGER; + tmp[arg_idx++].integer.value = in->band_list[loop_idx].start; + tmp[arg_idx].integer.type = ACPI_TYPE_INTEGER; + tmp[arg_idx++].integer.value = in->band_list[loop_idx].end; + } + + ret = wbrf_dsm(adev, WBRF_RECORD, &argv4, NULL); + + kfree(tmp); + + return ret; +} + +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return -ENODEV; + + return wbrf_record(adev, WBRF_RECORD_ADD, in); +} + +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return -ENODEV; + + return wbrf_record(adev, WBRF_RECORD_REMOVE, in); +} + +bool acpi_amd_wbrf_supported_producer(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return false; + + return acpi_check_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, + BIT(WBRF_RECORD)); +} + +static union acpi_object * +acpi_evaluate_wbrf(acpi_handle handle, u64 rev, u64 func) +{ + acpi_status ret; + struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; + union acpi_object params[4]; + struct acpi_object_list input = { + .count = 4, + .pointer = params, + }; + + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = rev; + params[1].type = ACPI_TYPE_INTEGER; + params[1].integer.value = func; + params[2].type = ACPI_TYPE_PACKAGE; + params[2].package.count = 0; + params[2].package.elements = NULL; + params[3].type = ACPI_TYPE_STRING; + params[3].string.length = 0; + params[3].string.pointer = NULL; + + ret = acpi_evaluate_object(handle, "WBRF", &input, &buf); + if (ACPI_SUCCESS(ret)) + return (union acpi_object *)buf.pointer; + + return NULL; +} + +static bool check_acpi_wbrf(acpi_handle handle, u64 rev, u64 funcs) +{ + int i; + u64 mask = 0; + union acpi_object *obj; + + if (funcs == 0) + return false; + + obj = acpi_evaluate_wbrf(handle, rev, 0); + if (!obj) + return false; + + if (obj->type != ACPI_TYPE_BUFFER) + return false; + + /* + * Bit vector providing supported functions information. + * Each bit marks support for one specific function of the WBRF method. + */ + for (i = 0; i < obj->buffer.length && i < 8; i++) + mask |= (((u64)obj->buffer.pointer[i]) << (i * 8)); + + ACPI_FREE(obj); + + if ((mask & BIT(WBRF_SUPPORT_OTHER_FUNCTION)) && + (mask & funcs) == funcs) + return true; + + return false; +} + +bool acpi_amd_wbrf_supported_consumer(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return false; + + return check_acpi_wbrf(adev->handle, + WBRF_REVISION, + BIT(WBRF_RETRIEVE)); +} + +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + union acpi_object *obj; + + if (!adev) + return -ENODEV; + + obj = acpi_evaluate_wbrf(adev->handle, + WBRF_REVISION, + WBRF_RETRIEVE); + if (!obj) + return -EINVAL; + + /* + * The return buffer is with variable length and the format below: + * number_of_entries(1 DWORD): Number of entries + * start_freq of 1st entry(1 QWORD): Start frequency of the 1st entry + * end_freq of 1st entry(1 QWORD): End frequency of the 1st entry + * ... + * ... + * start_freq of the last entry(1 QWORD) + * end_freq of the last entry(1 QWORD) + * + * Thus the buffer length is determined by the number of entries. + * - For zero entry scenario, the buffer length will be 4 bytes. + * - For one entry scenario, the buffer length will be 20 bytes. + */ + if (obj->buffer.length > sizeof(*out) || + obj->buffer.length < 4) { + dev_err(dev, "BIOS FUBAR, ignoring wrong sized WBRT information"); + ACPI_FREE(obj); + return -EINVAL; + } + memcpy(out, obj->buffer.pointer, obj->buffer.length); + + ACPI_FREE(obj); + + return 0; +} diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 5b441017b225..cbf0b2358c17 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -250,4 +250,33 @@ config WBRF different domains to notify the frequencies in use so that hardware can be reconfigured to avoid harmonic conflicts. +config WBRF_AMD_ACPI + bool "Use the ACPI mechanism introduced by AMD to support WBRF" + default n + depends on ACPI + select WBRF + help + AMD has introduced an ACPI based mechanism to support WBRF for some + platforms with AMD dGPU and WLAN. This needs support from BIOS equipped + with necessary AML implementations and dGPU firmwares. + + Say Y to enable this ACPI based mechanism. It is suggested to confirm + with the hardware designer/provider first whether your platform + equipped with necessary BIOS and firmwares. + +config WBRF_GENERIC + bool "Use the generic WBRF solution" + default n + depends on !WBRF_AMD_ACPI + select WBRF + help + Ideally it is the hardware designer/provider who should provide a + solution for the possible RF interference issue. Since they know + well whether there could be RF interference issue with their + platforms. + + Say Y to enable this generic WBRF solution for diagnosing potential + interference issues on systems without the ACPI mechanism and + developing solutions. + endmenu diff --git a/drivers/base/wbrf.c b/drivers/base/wbrf.c index 2163a8ec8a9a..401c6da86618 100644 --- a/drivers/base/wbrf.c +++ b/drivers/base/wbrf.c @@ -6,9 +6,12 @@ */ #include +#include static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); static DEFINE_MUTEX(wbrf_mutex); + +#if IS_ENABLED(CONFIG_WBRF_GENERIC) static struct exclusion_range_pool wbrf_pool; static int _wbrf_add_exclusion_ranges(struct wbrf_ranges_in *in) @@ -89,6 +92,7 @@ static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) return 0; } +#endif /** * wbrf_supported_producer - Determine if the device can report frequencies @@ -100,7 +104,12 @@ static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) */ bool wbrf_supported_producer(struct device *dev) { +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + return acpi_amd_wbrf_supported_producer(dev); +#elif IS_ENABLED(CONFIG_WBRF_GENERIC) return true; +#endif + return false; } EXPORT_SYMBOL_GPL(wbrf_supported_producer); @@ -116,12 +125,15 @@ EXPORT_SYMBOL_GPL(wbrf_supported_producer); int wbrf_add_exclusion(struct device *dev, struct wbrf_ranges_in *in) { - int r; + int r = -ENODEV; mutex_lock(&wbrf_mutex); +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + r = acpi_amd_wbrf_add_exclusion(dev, in); +#elif IS_ENABLED(CONFIG_WBRF_GENERIC) r = _wbrf_add_exclusion_ranges(in); - +#endif mutex_unlock(&wbrf_mutex); if (r) return r; @@ -144,12 +156,15 @@ EXPORT_SYMBOL_GPL(wbrf_add_exclusion); int wbrf_remove_exclusion(struct device *dev, struct wbrf_ranges_in *in) { - int r; + int r = -ENODEV; mutex_lock(&wbrf_mutex); +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + r = acpi_amd_wbrf_remove_exclusion(dev, in); +#elif IS_ENABLED(CONFIG_WBRF_GENERIC) r = _wbrf_remove_exclusion_ranges(in); - +#endif mutex_unlock(&wbrf_mutex); if (r) return r; @@ -171,7 +186,12 @@ EXPORT_SYMBOL_GPL(wbrf_remove_exclusion); */ bool wbrf_supported_consumer(struct device *dev) { +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + return acpi_amd_wbrf_supported_consumer(dev); +#elif IS_ENABLED(CONFIG_WBRF_GENERIC) return true; +#endif + return false; } EXPORT_SYMBOL_GPL(wbrf_supported_consumer); @@ -214,12 +234,15 @@ EXPORT_SYMBOL_GPL(wbrf_unregister_notifier); int wbrf_retrieve_exclusions(struct device *dev, struct wbrf_ranges_out *out) { - int r; + int r = -ENODEV; mutex_lock(&wbrf_mutex); +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + r = acpi_amd_wbrf_retrieve_exclusions(dev, out); +#elif IS_ENABLED(CONFIG_WBRF_GENERIC) r = _wbrf_retrieve_exclusion_ranges(out); - +#endif mutex_unlock(&wbrf_mutex); return r; diff --git a/include/linux/acpi_amd_wbrf.h b/include/linux/acpi_amd_wbrf.h new file mode 100644 index 000000000000..18b3d39b6abe --- /dev/null +++ b/include/linux/acpi_amd_wbrf.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#ifndef _ACPI_AMD_WBRF_H +#define _ACPI_AMD_WBRF_H + +#include + +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) +bool acpi_amd_wbrf_supported_consumer(struct device *dev); +bool acpi_amd_wbrf_supported_producer(struct device *dev); +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in); +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in); +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out); +#endif + +#endif /* _ACPI_AMD_WBRF_H */ diff --git a/include/linux/wbrf.h b/include/linux/wbrf.h index 32c017232874..7e627ef34c33 100644 --- a/include/linux/wbrf.h +++ b/include/linux/wbrf.h @@ -18,10 +18,12 @@ struct exclusion_range { u64 end; }; +#if IS_ENABLED(CONFIG_WBRF_GENERIC) struct exclusion_range_pool { struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; u64 ref_counter[MAX_NUM_OF_WBRF_RANGES]; }; +#endif struct wbrf_ranges_in { /* valid entry: `start` and `end` filled with non-zero values */ From patchwork Mon Jul 10 08:36:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CB84EB64D9 for ; Mon, 10 Jul 2023 08:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232830AbjGJIj6 (ORCPT ); Mon, 10 Jul 2023 04:39:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbjGJIjR (ORCPT ); Mon, 10 Jul 2023 04:39:17 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 481A210C2; Mon, 10 Jul 2023 01:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fA/b0xbuBiw0Fn3CZbPWz9GMgzR4y4jVqW4wysdzeZ/RpjTyYtZUIHdu2go09DgHAGkqKxBw6/418Fj/CJAdKZIAlwceMmhmXSU28AVZscuAFZ5P48oIa0q1VYxh/AppzB+O9Y52hvD6xvSs8S0ZS3Szo9Evl8dYBzv8BqSGTfEI2rGUnbZ4Hk/W6tGGgN+m+Ygn1DtZaSkO+xu4BIt2uVnJhF2axM7seXfCYX9apRr1gDg/wNgOj/MxcPg8yOiz7FeCmLUjZ2lipjSJqzQe3iKlIWowWJZu3PNHmm/SHonzjdxaqvsLAM3FHQCm6RMCyCMeNCcTTOKHVU423iiLOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=QcyuRM1scEM1Fni4a+P4z3b/Svu3cqw/Wgn5JNlfQRH+3VGa5Y0u8KvsUjqXep6e4doSqtz7FX9ehgXO7BD9Ih53HsR+Ijhjskb11m4F68QpotZD5giTMdK54O9YivaspDSo+bMiTIV5k2u8pnMj9+g+bhZ48ypPOZteuXqmwnh0H2Wb66qSnLU4qZN4aWVUNqtY+U7FoYqb5PiPjdIMTFwKiZZe+sN4d2iGtGPRxnpQiPA9h8df9vLaTJH94IC/pZuQkYl3sJLV03hi6D2YQA4rlv4kzMfpfz/0Cb8zn8mOs4Hn0s8o2wRJ9M6FeJIPlVi8WmDLED318CLYWAK3EQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=0OLXTQmXsdYdi4B7TFsrJWO6NCuuRt6kaCip5cXeEQtd5cLNn0xZvTBFl5ghx3aXieR+54n1f2v+Mhn5Wl4p2azedVzgDtUWa3qi5LgqKSiQatkhto6CPaSxDRPYRvGJ4ssBvjBp0i5ShtL5oLFgrRx3guCqfkMHktSjz3ppENM= Received: from MW4PR04CA0186.namprd04.prod.outlook.com (2603:10b6:303:86::11) by SJ0PR12MB6992.namprd12.prod.outlook.com (2603:10b6:a03:483::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 08:38:52 +0000 Received: from CO1NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::1c) by MW4PR04CA0186.outlook.office365.com (2603:10b6:303:86::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 08:38:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT079.mail.protection.outlook.com (10.13.175.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:38:52 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:38:42 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V6 3/9] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing Date: Mon, 10 Jul 2023 16:36:35 +0800 Message-ID: <20230710083641.2132264-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT079:EE_|SJ0PR12MB6992:EE_ X-MS-Office365-Filtering-Correlation-Id: 22a6e668-1e33-441a-84fe-08db812116f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7zIjSeS22b8aeBlhBP+2yKjV3pMs8RhwpJFO7tlMvHwFCY1r/SBd0aNV1U9QnRBl1I+OCsNQwJ6TP4eZhS5p7rA+fCKC7S0ZCaKKeQSQplGOAN5XP3bZcuARogIYnV8SpKwJXrm4LRi+7pteZCUNPKzekwTOLXSeztbL14YGlk4NGEqV2diFn/OqCTGM/bvbTDyUi097tH/QaAYzY+Zim1RHCf6A+0Ak+0rka60qc5HG9cO8nNWAFYA7EuwmLD4bn8vNpA3k65GiEVR6oKGAe/U0+ThZL/B7EuEHmzWRgqPUlloG/IxdXSQdJWAyxzld/uIa/TeGDPhx6RPRAcDmanVxnVwhriwfInziGccUj43cSmu/pwvnoHSTYdYQg8+aAQvCkTBkS/louKCIfzCJJLLgJKruHYzIWp3SP3Wui3migZGoosOddOltbL6jVmuCAn0JsEahspzrsEhqIWmLefIgtxwY9roMVoL/t53xUlSKG+IyGyvi/AkNgnWL1+ML6Gcyfe4F7++tM+mASUKzyQzUh7XW62+D0KEDb9afmR+mIdRMHvNo1rl1taBi9KV/PJJaZjsvNPFxgFkSR1pf01/bWLLH9oYDDUafzwLF4zH46neT+JQ7ileHcOufjPRTMLW6Q0l/SstFcgR669SE9f1ju+pppG0B5LeRZplapV9/oNUmWSRcUQCAfaIeMtoeZbN+V4gWKGhbGfVunMcsZclNMuyofIbRSyrRuFkh0kjHUKWELuNgoFZAYbglgElodA11jeEwOR1pDFj7IiAuDzxN4b3a5s0yXkSbyu1ZMK5FGuQ2CNv2UXh537nyTxi8EyiVBrYdjx13klGklS7QNQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(46966006)(40470700004)(36840700001)(6666004)(7696005)(478600001)(110136005)(54906003)(36860700001)(47076005)(426003)(83380400001)(36756003)(86362001)(40460700003)(40480700001)(2616005)(2906002)(70206006)(82310400005)(70586007)(16526019)(1076003)(26005)(186003)(336012)(81166007)(82740400003)(921005)(356005)(8676002)(4326008)(316002)(41300700001)(5660300002)(8936002)(44832011)(7416002)(83996005)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:38:52.0628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22a6e668-1e33-441a-84fe-08db812116f8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6992 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The newly added WBRF feature needs this interface for channel width calculation. Signed-off-by: Evan Quan --- include/net/cfg80211.h | 8 ++++++++ net/wireless/chan.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9e04f69712b1..c6dc337eafce 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -920,6 +920,14 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** + * nl80211_chan_width_to_mhz - get the channel width in Mhz + * @chan_width: the channel width from &enum nl80211_chan_width + * Return: channel width in Mhz if the chan_width from &enum nl80211_chan_width + * is valid. -1 otherwise. + */ +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width); + /** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 0b7e81db383d..227db04eac42 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef) return true; } -static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) { int mhz; @@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) } return mhz; } +EXPORT_SYMBOL(nl80211_chan_width_to_mhz); static int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c) { From patchwork Mon Jul 10 08:36:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0161EB64DA for ; Mon, 10 Jul 2023 08:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232932AbjGJIkH (ORCPT ); Mon, 10 Jul 2023 04:40:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233076AbjGJIjZ (ORCPT ); Mon, 10 Jul 2023 04:39:25 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2079.outbound.protection.outlook.com [40.107.102.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600D61BE; Mon, 10 Jul 2023 01:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cibNossU9NvmovVNz4n5LZY+oxPhK96qEmjTCq7H1AiZGiLJjouJdsXSNHIg9tnOMyKnhmsLZx2QyzlBVoddAh6wx3LMpNKH8iyKbjcw4kxmSx9vm9eYnTAaQARsk4DKnL8SQTCIKubIvzq+e+nDH/Dgh/2H3DwqBYkdgBmrxCGSPIC5Q9aPLD76gT48Q8qpgB22L9/UqA4t4cVA7he4jKQEuCgWjj6qmXp5UdtzcbzTAGnQEoRVdqkt0GDfpb4vToRYo403xa5yNxUok50X3fYHYRySJsXv1oyCVaArcsv0MzNPTuV6Rdlkt4g/T8EDGq3exdS68fmcdscJZlaxpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5J0Cz5Cadlw65Bzx+SEzLMeK7AP7NhydWrQ7o5Xd/xE=; b=jjroFjayqSqgK4ajLBkCuDTHP5M6uhVtxSitBaYjXstqIQsr5pBNaajdnONpBXmGy5dPkRkRjcaUz2bEkZhKJCsQZFrytkDyJ3o4/aMCxDLdxDiWXRois5FYYq3KfKDZ62F3Nu/q2J3b/XHFtxNnznOHL9X/daJ+UaAkIkLdbN/smY4H0rJiMy5nuCWZhHdcmop0TWXmkwObv7SMKm7x6IBkKpecgcmurl5QR0aW3jkd7cGS45rrYn3QZvRfGZwzxF0f4j1UzX+ifszqR+/wZvMuMb22kzE6NCZqg2oyaip/xszU3S0bIUbCbAY55RrnfzUcMpSKhnJwZUA/RQPJ2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5J0Cz5Cadlw65Bzx+SEzLMeK7AP7NhydWrQ7o5Xd/xE=; b=GxIDZG1AIsshSsi8CwJYZwNH2Un4Eh93pAI3D1xuyHZe1WrlNlUrdOJUFKlYET9U5Yxt62M0SYIRuCMcVXU+26GJaFuNalB63oVFtBjajqoVv4OhBnz1DgYTYdMjFMQxjGHEkgPWCedCKq8uVLQ5Gl6h/bExh4A+zIxd63PkcrE= Received: from MW4P223CA0009.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::14) by PH7PR12MB6610.namprd12.prod.outlook.com (2603:10b6:510:212::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Mon, 10 Jul 2023 08:39:02 +0000 Received: from CO1NAM11FT103.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::6f) by MW4P223CA0009.outlook.office365.com (2603:10b6:303:80::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 08:39:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT103.mail.protection.outlook.com (10.13.174.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:39:01 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:38:51 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 4/9] wifi: mac80211: Add support for ACPI WBRF Date: Mon, 10 Jul 2023 16:36:36 +0800 Message-ID: <20230710083641.2132264-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT103:EE_|PH7PR12MB6610:EE_ X-MS-Office365-Filtering-Correlation-Id: dfa167bc-dccf-4fcf-b5d2-08db81211cce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FdGQuib2vqbUR+jxDT4W4/NZd2vVp/wnYhsMgUkFQfyUtLxRjqWKUmEsUi8nlR5Fy49Vz6nGT8GwMT3ZZGtXUDbG0vG5IE0Bc8YgRJx9DRe0FZKSnaoFJlog5PyeDA8Q5dPTEA/b3ImPlsN6uSZYmN5KWqrW9wycsp+kGqESg2SsoqQhUxDScmpiHjU2VfWBrO0iNougc1P/CbGOiGMDDvhR/dY1ABcfLPpcgRr5lAMrIS++lGSZqw5Rg8Ch9v1FBLohKeTz5xpPhktLoWXfLl3OKDvvIgUAx4Typ7gR4pEdKgM68AnovNMYygvoQddm1saN/5TR3e13u72NxNTMiUQ9kGomYth+1eiGI+DNbijgKPsWPiv1xRXXX5rN05nnjYTH9FodDosmjmoj3StpHolrDjOywc+UJnSQLiN3UzitOoFKOCNSdyEF9OqCqY1qo0+S8l7ZwFe92ml0jotfWSaM3Ggkp1gwgUcG5OrCXa+btV/LPfhWDdRiN8HCGwb6L11Ft0CUOxBKc77DRII7CCQSGkVhbTSmAvuHp0q2sTYFAs4jGBwJR3fGEULz8kDSNIOSMIIdmORC6RS3W7e4YwXHHp9OKgp7hERB3uBx/mqrS7hZlSj0/m0rga5igbqjbOu3t/wcQfbBq5qi0snNK8eJsyw63A326ePtxcteWnUkqUnPcZBBkmjHq3VJEq+mDGqOoPi/GDIXI/xRhiOu5yLZCtuq8ABtNYaBcWNINWL8k8Qaxc/+Spp555sh661qH45tUH5L4W7lfRtYSt1CwmVSy42Xo48K10lTlw1Np0o3Im2RW/JiIhYt9poKi7EF6smii0SKct4lKo96mrxn+Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(136003)(396003)(346002)(451199021)(36840700001)(46966006)(40470700004)(336012)(426003)(2616005)(41300700001)(26005)(1076003)(83380400001)(16526019)(186003)(36860700001)(47076005)(478600001)(82740400003)(81166007)(921005)(356005)(110136005)(54906003)(6666004)(7696005)(40460700003)(4326008)(44832011)(40480700001)(70206006)(70586007)(316002)(7416002)(86362001)(82310400005)(8676002)(8936002)(5660300002)(2906002)(36756003)(2101003)(83996005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:39:01.8551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfa167bc-dccf-4fcf-b5d2-08db81211cce X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT103.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6610 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org To support AMD's WBRF interference mitigation mechanism, Wifi adapters utilized in the system must register the frequencies in use(or unregister those frequencies no longer used) via the dedicated APCI calls. So that, other drivers responding to the frequencies can take proper actions to mitigate possible interference. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v1->v2: - place the new added member(`wbrf_supported`) in ieee80211_local(Johannes) - handle chandefs change scenario properly(Johannes) - some minor fixes around code sharing and possible invalid input checks(Johannes) v2->v3: - drop unnecessary input checks and intermediate APIs(Mario) - Separate some mac80211 common code(Mario, Johannes) v3->v4: - some minor fixes around return values(Johannes) --- include/linux/ieee80211.h | 1 + net/mac80211/Makefile | 2 + net/mac80211/chan.c | 9 ++++ net/mac80211/ieee80211_i.h | 19 +++++++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 103 +++++++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index c4cf296e7eaf..0703921547f5 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -4319,6 +4319,7 @@ static inline int ieee80211_get_tdls_action(struct sk_buff *skb, u32 hdr_size) /* convert frequencies */ #define MHZ_TO_KHZ(freq) ((freq) * 1000) #define KHZ_TO_MHZ(freq) ((freq) / 1000) +#define KHZ_TO_HZ(freq) ((freq) * 1000) #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000 #define KHZ_F "%d.%03d" diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index b8de44da1fb8..8f8ac567e7c8 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -65,4 +65,6 @@ rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) +mac80211-$(CONFIG_WBRF) += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 77c90ed8f5d7..9887471028dc 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -506,11 +506,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local, WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef)); + ieee80211_remove_wbrf(local, &ctx->conf.def); + ctx->conf.def = *chandef; /* check if min chanctx also changed */ changed = IEEE80211_CHANCTX_CHANGE_WIDTH | _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); + + ieee80211_add_wbrf(local, &ctx->conf.def); + drv_change_chanctx(local, ctx, changed); if (!local->use_chanctx) { @@ -668,6 +673,8 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->chanctx_mtx); + ieee80211_add_wbrf(local, &ctx->conf.def); + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -748,6 +755,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, } ieee80211_recalc_idle(local); + + ieee80211_remove_wbrf(local, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4159fb65038b..fb984ce7038c 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1591,6 +1591,10 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + +#if IS_ENABLED(CONFIG_WBRF) + bool wbrf_supported; +#endif }; static inline struct ieee80211_sub_if_data * @@ -2615,4 +2619,19 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); + +#if IS_ENABLED(CONFIG_WBRF) +void ieee80211_check_wbrf_support(struct ieee80211_local *local); +void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +#else +static inline void ieee80211_check_wbrf_support(struct ieee80211_local *local) { } +static inline void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { } +static inline void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { } +#endif /* CONFIG_WBRF */ + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 55cdfaef0f5d..0a55626b1546 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1395,6 +1395,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) debugfs_hw_add(local); rate_control_add_debugfs(local); + ieee80211_check_wbrf_support(local); + rtnl_lock(); wiphy_lock(hw->wiphy); diff --git a/net/mac80211/wbrf.c b/net/mac80211/wbrf.c new file mode 100644 index 000000000000..7ddb29d128b1 --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface for WWAN + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include +#include "ieee80211_i.h" + +void ieee80211_check_wbrf_support(struct ieee80211_local *local) +{ + struct wiphy *wiphy = local->hw.wiphy; + struct device *dev; + + if (!wiphy) + return; + + dev = wiphy->dev.parent; + if (!dev) + return; + + local->wbrf_supported = wbrf_supported_producer(dev); + dev_dbg(dev, "WBRF is %s supported\n", + local->wbrf_supported ? "" : "not"); +} + +static void get_chan_freq_boundary(u32 center_freq, + u32 bandwidth, + u64 *start, + u64 *end) +{ + bandwidth = MHZ_TO_KHZ(bandwidth); + center_freq = MHZ_TO_KHZ(center_freq); + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in HZ is expected */ + *start = KHZ_TO_HZ(*start); + *end = KHZ_TO_HZ(*end); +} + +static void wbrf_get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in *ranges_in) +{ + u64 start_freq1, end_freq1; + u64 start_freq2, end_freq2; + int bandwidth; + + bandwidth = nl80211_chan_width_to_mhz(chandef->width); + + get_chan_freq_boundary(chandef->center_freq1, + bandwidth, + &start_freq1, + &end_freq1); + + ranges_in->band_list[0].start = start_freq1; + ranges_in->band_list[0].end = end_freq1; + + if (chandef->width == NL80211_CHAN_WIDTH_80P80) { + get_chan_freq_boundary(chandef->center_freq2, + bandwidth, + &start_freq2, + &end_freq2); + + ranges_in->band_list[1].start = start_freq2; + ranges_in->band_list[1].end = end_freq2; + } +} + +void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + wbrf_get_ranges_from_chandef(chandef, &ranges_in); + + wbrf_add_exclusion(dev, &ranges_in); +} + +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + wbrf_get_ranges_from_chandef(chandef, &ranges_in); + + wbrf_remove_exclusion(dev, &ranges_in); +} From patchwork Mon Jul 10 08:36:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 549F1EB64D9 for ; Mon, 10 Jul 2023 08:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233141AbjGJIkd (ORCPT ); Mon, 10 Jul 2023 04:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233061AbjGJIj7 (ORCPT ); Mon, 10 Jul 2023 04:39:59 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2063.outbound.protection.outlook.com [40.107.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08BF7E60; Mon, 10 Jul 2023 01:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jmB8nzdcmHCgHCybZo1dUPRDRE3w72Vldtd9XQl+R1UXHNowGyBaPbHPYWSVb4crOtikDPrM6bwd5B15mBcGpzvVbSHfeZ7pOT8l9g5KX+gQWIK4SgTYFbVMn3BAeUM0NJr1t4F9pYnRR2zd0BQFELoiwLQTQTx5/D1vpJYxGNiebs6vF+nuQO9AocJZ6RrYKb6S5uVKXdW/II6EUY7yzCOicYOSeTLDMZMG2Z+oaqvbM1Qzo7SjRiWW3A0WU6SFYPnaDQiI3IxFvMubTDvK0YC7ZKduJxRjGSF75CVnv5at/rAM9vPdTYspA5htYlZBQNhnH+yIvhB9YEdMouraRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=ieZVEhUpj0gnCs+VEMsLOnpP6Ib7Z6VmNYAjyXAN5Cpr+QAk1MOGm0jv4j/6WCWF5pXN8a6dFu4uNx5GDn7hbVDkEFNIujkbCFxwxcPub8NfiDRuyO6xWF1QID8IBu3sv/eFiTR0V7/26XSZ2aTwR5rAO2u7hEOV1a8wlD2RYagx4Mk1SX6HgwVii78r9J1HzZte6WC8qcvdIEL8aZAC5rjyk+INkNX06B9VpW+FH3RmfwNUXpDk13zIT1gjF2FVMnFML4w+pdWgB5WeeL0Xz6m0MPkbD1vA27TW7GkzCjy+CtK9j5j/q3Kc7i802gW+3HXFR6KPdyfL7mjyvMAIqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=THdDYaeDSkPyQkuBvKjrQAI2zGn+6c/vHjDrIzRKvPDOBCwegc1G7JClpDp/5JH4tugy9elWA24jIN92p3YDZ2kD9jR4BG+thEaCyMMD25ruikGH13s3Don6Q2xSZJvhOY4YzIJh2VvexGldUvb/H2NGkyapjNrfXKr5f/O9Fic= Received: from MW4PR03CA0023.namprd03.prod.outlook.com (2603:10b6:303:8f::28) by DM4PR12MB6279.namprd12.prod.outlook.com (2603:10b6:8:a3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 08:39:32 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::56) by MW4PR03CA0023.outlook.office365.com (2603:10b6:303:8f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Mon, 10 Jul 2023 08:39:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:39:32 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:39:00 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 5/9] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Mon, 10 Jul 2023 16:36:37 +0800 Message-ID: <20230710083641.2132264-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT080:EE_|DM4PR12MB6279:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f126d7a-3179-4c7f-a059-08db81212eee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gP0FgY97xnGoRINwPi8NP57NZqdXKLBdMHNLRgq8mA9JrtLXUdfdHnS/8zN3siUiRFTVRykkMFvSrQBI0RxjaICJe8GOYUgcBiAVdyAPAHeAOWYwHWJmLooKFUX7S0ZYoHYXBjnBojYW7WE3T9OdylhZOqrJLFuxMRDYSbD+J2yM83AmnUQ5CkPNNs+u5cZsDRQFaC478scOFIPaPST4TP1MUrQ5AgPOQw2qt0DgNLWNW/2KQKmIFww7FvzNDhGkadG6DSYeAH+ZS69fRUWcoaEWyf1xXIWyKpQPMlFdYuVwccl+q1ZJgCaxwNiRPzVsXKYLrJReHJFjQCDJkS/wp576GwuJautwo6rwXVcRhjxxApVVXY4YQRrK8hfEjYRlp/Jo0XuMdhe88HIuDXimNyJPZPFEE5Xzjq8u42P3S1c9KDnMcttKCM+hW1XsJsDKhH47F3D5UlOjeiuV3Ccta1qIIHo4oJU58LVye4dg3hT7LNNhRZ9p/voweDyVuR8D/3VbEkBONA/1FDk3fdFdwLSgnCKcLAwTE3XfujilwOLrN39HxC+rcZi/1+yJbxrOoVtmyh5AZJnqsvg/Y4KbJY9NQLxD3QMEB02O/qncMbI7eae/9+NmH8eN/zPq6zsg+YKXH3o3MebWnZ1Pm8ko/IFo8WCUQveagIs/rBq9c7bqkIutlDn6Ju5p0oNy7BNi115HRow2OFRX6+WWt7QdIu/XEOvEYpoczALTXUBvJzyndpuAklvSlqm7EWFEmY8whhZ9sjWlEHhWYpect/2A9BVE1KsWrUu+EdH+CZFvFxVDWzbjY1CiAExgfOT26IZo098cSgJsfZxoasD+b+DOlg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(86362001)(82310400005)(82740400003)(40460700003)(40480700001)(36756003)(6666004)(7696005)(110136005)(54906003)(70206006)(70586007)(81166007)(356005)(921005)(36860700001)(16526019)(26005)(186003)(1076003)(2616005)(44832011)(7416002)(5660300002)(316002)(2906002)(478600001)(15650500001)(8676002)(8936002)(47076005)(336012)(426003)(83380400001)(4326008)(41300700001)(36900700001)(83996005)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:39:32.2632 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f126d7a-3179-4c7f-a059-08db81212eee X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6279 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 14 +++++++++++++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 14 +++++++++++++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 3 ++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h index b686fb68a6e7..d64188fb5839 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h @@ -388,6 +388,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1592,7 +1603,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h index 4c46a0392451..77483e8485e7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h @@ -392,6 +392,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1624,7 +1635,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h index 10cff75b44d5..c98cc32d11bd 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h @@ -138,7 +138,8 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 //Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1 diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h index 6aaefca9b595..a6bf9cdd130e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h @@ -134,6 +134,7 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 #endif From patchwork Mon Jul 10 08:36:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D7A2EB64DA for ; Mon, 10 Jul 2023 08:40:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233147AbjGJIkt (ORCPT ); Mon, 10 Jul 2023 04:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233081AbjGJIkK (ORCPT ); Mon, 10 Jul 2023 04:40:10 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED8DD137; Mon, 10 Jul 2023 01:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PMlBFXMkjT1t/gUKX1Hnymtz1KRfH9WfwmMD/MVTVny4W0TEs9n/CdhE8XNUOLs4+j40/Whs6V6QvBCr63sisOtpRwDAGrahuHPruMHekJ1/AqEHos61psxi+Moi7G5bqttxz5AoazxD6E4oITR766gqXZsAC28m6Y0zbUq8Lr6IllJ/vV+fbJ4FFVtBKCEZRRt0TBbpwvJ970kpWLZWQG482X01dW/Zntw3F2mvmuOdX7hRhrw/RTgal8YFQ5NaQbpGevGIBrFgQha0qHFEaACY3v1O2oWeo7QY23T/XJzmt68X2aZzQPBiasPMZkGe1hHLUmhI8pgWkpjO7pWaFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9sPe2V6z4UQD/GNd2ywlKWmEsAmMimRgeNITaxFFJck=; b=e0TolsP3gbsmBoJAP+c2b7rOk3gjLNfj3iN1ogATMgt/+2VeFUIUQaMx764gXTU7NAhYg3LzJmNpyFMB72rv5N6qEymLQQQUNsuuVCfESkXaPp0iFL43LdpC/7Hpiji6uNJ7PC1X/hHAgljd8rKdHhGAiCvjG9RislKosUQUq2Bx4AzsbHMEGHtpEHaT8fjhHNSLSkH8up09F5Ih/nwdt8PX2fNSJlIZPzGSmXXneFBZTzFKPHkqyH0G31WdL6wDhT7ek1jUQ5vOi/iYH9gERiR3O1KVkKm0yIgrKuQeTKvMpscyLdRYzuMAGr8gqMPjzttZ5aOdNxvVtDZOINg0eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9sPe2V6z4UQD/GNd2ywlKWmEsAmMimRgeNITaxFFJck=; b=s2EqpvHeCEMaPdKDBWmFcR/5PMUtj4r4v4XoX9CDg9QmFTett4WJto/TnEs13qtOWoOHNlP7pDuSCuC0iF9QQYZewiL/LwC03kkyYJX50wNhF3/3qOr5zQz4m3W2r6gw5AF0ek0QwLyw+GPhph8bLp4XlLO5nVSZW09s2kEfCIE= Received: from MW4PR03CA0130.namprd03.prod.outlook.com (2603:10b6:303:8c::15) by BL0PR12MB4882.namprd12.prod.outlook.com (2603:10b6:208:1c3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Mon, 10 Jul 2023 08:39:41 +0000 Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::ba) by MW4PR03CA0130.outlook.office365.com (2603:10b6:303:8c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 08:39:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:39:40 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:39:31 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 6/9] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Mon, 10 Jul 2023 16:36:38 +0800 Message-ID: <20230710083641.2132264-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT060:EE_|BL0PR12MB4882:EE_ X-MS-Office365-Filtering-Correlation-Id: 2befd1fe-2676-41e6-41e3-08db812133fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G7EGCZ/imY53AwY2ywa/j0nerh2c85shY1+dW72h3lBekm8dybt391GJR7hNo29qOxwXH9dYLEKmvJlYHAFYF3UXYt6FcavdlMPC7DaI+6bZUPo4Z4AkQXXX6sIV+5Eg+zOPeD/mxiyikBhfbndPc51EKfoS6U1PdrWJjqibrOjMSurIx3XBZ16Mzbupzb/UqxeJoBoJVBpbfhaP9lqP45bT0qFs03SZ7utAtmkXWCe/R+IdQrqv4YLor5nLruNppr9ueCSC0PR+ynripPg9b4ETPpKs/pS6rsKgiShE4Xe3LsjOCPXxdNACZWVT2/Y/bLqAy03NIZzqXTryy3pmAesCD5rSjVW9aRDFlXk9mKfdZf890SdkjK0PHewbq7lUWLb4KA0vKff7kxr2/E91/4tYhFpKlwRahVGgJUZ+D+XpymZENC8Cvzqx6b98VPhF4RrXyoPLIqJXHqyYEietxgdzLYSXnQoHQfppy8zcmpoHj6LbCwgG60fFpTOchP5+LcjspRMVHiNsSABppP8Fwc7HM7dc2FFsafXOnEhak5Q6RqgDXGEd3Bw01ilT37pJFJ1crWjEsGBqtU/VUXKpWDVmurYfOUmNbLLr5D3LbSQbTKZXdnoii4tZNEeDH5fv8jq0tyydAxv29t46vFcyZo1prF4xRLqmnjRMBFwP18hWLt60GfaibibnOBCKEwl5sYcPSItQl45giCAkfvY9oE4ZkTDmNXfeUpwerS8XtAY25aoJFW3Gy3uhbkVzOCSAqLxQ7ia61PfaEK7XYNPqkdbDOd5/B6IXg48EqNmeTtPVjX9OMEbUYEbKH9SbFyDWPgAGLw3Us9BLufP2Sq2f+HsF6uP+r2aTwJPg8icMC9RPBjekNePb3LNQqjKY9Jga X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39850400004)(396003)(136003)(346002)(376002)(451199021)(40470700004)(46966006)(36840700001)(478600001)(7696005)(4326008)(54906003)(110136005)(26005)(1076003)(186003)(16526019)(30864003)(2906002)(82310400005)(41300700001)(8676002)(8936002)(44832011)(70586007)(70206006)(316002)(5660300002)(7416002)(356005)(81166007)(921005)(82740400003)(40460700003)(86362001)(47076005)(2616005)(426003)(83380400001)(336012)(40480700001)(36860700001)(36756003)(2101003)(83996005)(36900700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:39:40.7412 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2befd1fe-2676-41e6-41e3-08db812133fc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4882 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org With WBRF feature supported, as a driver responding to the frequencies, amdgpu driver is able to do shadow pstate switching to mitigate possible interference(between its (G-)DDR memory clocks and local radio module frequency bands used by Wifi 6/6e/7). Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- v1->v2: - update the prompt for feature support(Lijo) --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 19 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 194 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 23 +++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 5 files changed, 240 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 02b827785e39..785d9b43f0c4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -241,6 +241,7 @@ extern int amdgpu_num_kcq; #define AMDGPU_VCNFW_LOG_SIZE (32 * 1024) extern int amdgpu_vcnfw_log; extern int amdgpu_sg_display; +extern int amdgpu_wbrf; #define AMDGPU_VM_MAX_NUM_CTX 4096 #define AMDGPU_SG_THRESHOLD (256*1024*1024) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 393b6fb7a71d..d4f3921509a5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -191,6 +191,7 @@ int amdgpu_smartshift_bias; int amdgpu_use_xgmi_p2p = 1; int amdgpu_vcnfw_log; int amdgpu_sg_display = -1; /* auto */ +int amdgpu_wbrf = -1; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); @@ -948,6 +949,24 @@ MODULE_PARM_DESC(smu_pptable_id, "specify pptable id to be used (-1 = auto(default) value, 0 = use pptable from vbios, > 0 = soft pptable id)"); module_param_named(smu_pptable_id, amdgpu_smu_pptable_id, int, 0444); +#if IS_ENABLED(CONFIG_WBRF) +/** + * DOC: wbrf (int) + * Enable Wifi RFI interference mitigation feature. + * Due to electrical and mechanical constraints there may be likely interference of + * relatively high-powered harmonics of the (G-)DDR memory clocks with local radio + * module frequency bands used by Wifi 6/6e/7. To mitigate the possible RFI interference, + * with this feature enabled, PMFW will use either “shadowed P-State” or “P-State” based + * on active list of frequencies in-use (to be avoided) as part of initial setting or + * P-state transition. However, there may be potential performance impact with this + * feature enabled. + * (0 = disabled, 1 = enabled, -1 = auto (default setting, will be enabled if supported)) + */ +MODULE_PARM_DESC(wbrf, + "Enable Wifi RFI interference mitigation (0 = disabled, 1 = enabled, -1 = auto(default)"); +module_param_named(wbrf, amdgpu_wbrf, int, 0444); +#endif + /* These devices are not supported by amdgpu. * They are supported by the mach64, r128, radeon drivers */ diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 2ddf5198e5c4..83d428e890df 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1188,6 +1188,173 @@ static int smu_get_thermal_temperature_range(struct smu_context *smu) return ret; } +/** + * smu_wbrf_handle_exclusion_ranges - consume the wbrf exclusion ranges + * + * @smu: smu_context pointer + * + * Retrieve the wbrf exclusion ranges and send them to PMFW for proper handling. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_handle_exclusion_ranges(struct smu_context *smu) +{ + struct wbrf_ranges_out wbrf_exclusion = {0}; + struct exclusion_range *wifi_bands = wbrf_exclusion.band_list; + struct amdgpu_device *adev = smu->adev; + uint64_t start, end; + int ret, i, j; + + ret = wbrf_retrieve_exclusions(adev->dev, &wbrf_exclusion); + if (ret) { + dev_err(adev->dev, "Failed to retrieve exclusion ranges!\n"); + return ret; + } + + /* + * The exclusion ranges array we got might be filled with holes and duplicate + * entries. For example: + * {(2400, 2500), (0, 0), (6882, 6962), (2400, 2500), (0, 0), (6117, 6189), (0, 0)...} + * We need to do some sortups to eliminate those holes and duplicate entries. + * Expected output: {(2400, 2500), (6117, 6189), (6882, 6962), (0, 0)...} + */ + for (i = 0; i < MAX_NUM_OF_WBRF_RANGES; i++) { + start = wifi_bands[i].start; + end = wifi_bands[i].end; + + /* get the last valid entry to fill the intermediate hole */ + if (!start && !end) { + for (j = MAX_NUM_OF_WBRF_RANGES - 1; j > i; j--) + if (wifi_bands[j].start && + wifi_bands[j].end) + break; + + if (j > i) { + wifi_bands[i].start = wifi_bands[j].start; + wifi_bands[i].end = wifi_bands[j].end; + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + } + + continue; + } + + /* eliminate duplicate entries */ + for (j = i + 1; j < MAX_NUM_OF_WBRF_RANGES; j++) { + if ((wifi_bands[j].start == start) && + (wifi_bands[j].end == end)) { + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + continue; + } + } + } + + /* Send the sorted wifi_bands to PMFW */ + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + /* Give it another chance */ + if (unlikely(ret == -EBUSY)) { + mdelay(5); + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + } + + return ret; +} + +/** + * smu_wbrf_event_handler - handle notify events + * + * @nb: notifier block + * @action: event type + * @data: event data + * + * Calls relevant amdgpu function in response to wbrf event + * notification from kernel. + */ +static int smu_wbrf_event_handler(struct notifier_block *nb, + unsigned long action, void *_arg) +{ + struct smu_context *smu = container_of(nb, struct smu_context, + wbrf_notifier); + + switch (action) { + case WBRF_CHANGED: + smu_wbrf_handle_exclusion_ranges(smu); + break; + default: + return NOTIFY_DONE; + }; + + return NOTIFY_OK; +} + +/** + * smu_wbrf_support_check - check wbrf support + * + * @smu: smu_context pointer + * + * Verifies the ACPI interface whether wbrf is supported. + */ +static void smu_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + smu->wbrf_supported = smu_is_asic_wbrf_supported(smu) && + !!amdgpu_wbrf && + wbrf_supported_consumer(adev->dev); + + if (smu->wbrf_supported) + dev_info(adev->dev, "RF interference mitigation is supported\n"); +} + +/** + * smu_wbrf_init - init driver wbrf support + * + * @smu: smu_context pointer + * + * Verifies the AMD ACPI interfaces and registers with the wbrf + * notifier chain if wbrf feature is supported. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_init(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + int ret; + + if (!smu->wbrf_supported) + return 0; + + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; + ret = wbrf_register_notifier(&smu->wbrf_notifier); + if (ret) + return ret; + + /* + * Some wifiband exclusion ranges may be already there + * before our driver loaded. To make sure our driver + * is awared of those exclusion ranges. + */ + ret = smu_wbrf_handle_exclusion_ranges(smu); + if (ret) + dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + + return ret; +} + +/** + * smu_wbrf_fini - tear down driver wbrf support + * + * @smu: smu_context pointer + * + * Unregisters with the wbrf notifier chain. + */ +static void smu_wbrf_fini(struct smu_context *smu) +{ + if (!smu->wbrf_supported) + return; + + wbrf_unregister_notifier(&smu->wbrf_notifier); +} + static int smu_smc_hw_setup(struct smu_context *smu) { struct smu_feature *feature = &smu->smu_feature; @@ -1280,6 +1447,15 @@ static int smu_smc_hw_setup(struct smu_context *smu) if (ret) return ret; + /* Enable UclkShadow on wbrf supported */ + if (smu->wbrf_supported) { + ret = smu_enable_uclk_shadow(smu, true); + if (ret) { + dev_err(adev->dev, "Failed to enable UclkShadow feature to support wbrf!\n"); + return ret; + } + } + /* * With SCPM enabled, these actions(and relevant messages) are * not needed and permitted. @@ -1376,6 +1552,15 @@ static int smu_smc_hw_setup(struct smu_context *smu) */ ret = smu_set_min_dcef_deep_sleep(smu, smu->smu_table.boot_values.dcefclk / 100); + if (ret) { + dev_err(adev->dev, "Error setting min deepsleep dcefclk\n"); + return ret; + } + + /* Init wbrf support. Properly setup the notifier */ + ret = smu_wbrf_init(smu); + if (ret) + dev_err(adev->dev, "Error during wbrf init call\n"); return ret; } @@ -1431,6 +1616,13 @@ static int smu_hw_init(void *handle) return ret; } + /* + * Check whether wbrf is supported. This needs to be done + * before SMU setup starts since part of SMU configuration + * relies on this. + */ + smu_wbrf_support_check(smu); + if (smu->is_apu) { ret = smu_set_gfx_imu_enable(smu); if (ret) @@ -1583,6 +1775,8 @@ static int smu_smc_hw_cleanup(struct smu_context *smu) struct amdgpu_device *adev = smu->adev; int ret = 0; + smu_wbrf_fini(smu); + cancel_work_sync(&smu->throttling_logging_work); cancel_work_sync(&smu->interrupt_work); diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 09469c750a96..5b2343cfc69b 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -22,6 +22,8 @@ #ifndef __AMDGPU_SMU_H__ #define __AMDGPU_SMU_H__ +#include + #include "amdgpu.h" #include "kgd_pp_interface.h" #include "dm_pp_interface.h" @@ -573,6 +575,10 @@ struct smu_context u32 debug_param_reg; u32 debug_msg_reg; u32 debug_resp_reg; + + /* data structures for wbrf feature support */ + bool wbrf_supported; + struct notifier_block wbrf_notifier; }; struct i2c_adapter; @@ -1354,6 +1360,23 @@ struct pptable_funcs { * @init_pptable_microcode: Prepare the pptable microcode to upload via PSP */ int (*init_pptable_microcode)(struct smu_context *smu); + + /** + * @is_asic_wbrf_supported: check whether PMFW supports the wbrf feature + */ + bool (*is_asic_wbrf_supported)(struct smu_context *smu); + + /** + * @enable_uclk_shadow: Enable the uclk shadow feature on wbrf supported + */ + int (*enable_uclk_shadow)(struct smu_context *smu, + bool enablement); + + /** + * @set_wbrf_exclusion_ranges: notify SMU the wifi bands occupied + */ + int (*set_wbrf_exclusion_ranges)(struct smu_context *smu, + struct exclusion_range *exclusion_ranges); }; typedef enum { diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h index ceb13c838067..67d7495ab49e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h @@ -97,6 +97,9 @@ #define smu_get_default_config_table_settings(smu, config_table) smu_ppt_funcs(get_default_config_table_settings, -EOPNOTSUPP, smu, config_table) #define smu_set_config_table(smu, config_table) smu_ppt_funcs(set_config_table, -EOPNOTSUPP, smu, config_table) #define smu_init_pptable_microcode(smu) smu_ppt_funcs(init_pptable_microcode, 0, smu) +#define smu_is_asic_wbrf_supported(smu) smu_ppt_funcs(is_asic_wbrf_supported, false, smu) +#define smu_enable_uclk_shadow(smu, enablement) smu_ppt_funcs(enable_uclk_shadow, 0, smu, enablement) +#define smu_set_wbrf_exclusion_ranges(smu, exclusion_ranges) smu_ppt_funcs(set_wbrf_exclusion_ranges, -EOPNOTSUPP, smu, exclusion_ranges) #endif #endif From patchwork Mon Jul 10 08:36:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED98EB64D9 for ; Mon, 10 Jul 2023 08:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbjGJIlR (ORCPT ); Mon, 10 Jul 2023 04:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233042AbjGJIk3 (ORCPT ); Mon, 10 Jul 2023 04:40:29 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97FB219F; Mon, 10 Jul 2023 01:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDY11wFmYV2zCAb27pmkGgs7baTaJBrQbUDJNneS6xJLbMMBtH/znbbsrZW68ecE5SoQ+kUESbGp5ud2UB3E+4vG55iOsilYhHLXf5Dc+krndk0H3pTL8D7yz7gHZUnCJnzKBRV62ONXH66+IwnibGKGA7sMIFqaPuqBOqifENtjBt6lmnyDFHxZAGVlSf7O/VdV6rKp+5A/iERkXBP+PQ23XoX9OlSsdlBGdwjaXuDTB7rcq3jYaxrN7agrip+f1+qQYD/0drXbG6LcE1nTNA5gU4Ay1c3mYgF0FHtcn7NSaBe+5Nct3gwi9mzcmG3qeDdJTJSJ6nJ1aQ6LFFKOYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JOfMtK9uPCRjoqE44RI9oSOYI5o7ys3RsMEi8r5i9TA=; b=kk48iuUOKbgyeDpLFPHLpG9SP8NkjTbdR9rxHcmg5tAYOLiNW4LGaJJ/dFTr0ZEtUkHTkNpdMJ+AycDX/1AHDDHKHs95Rzxi15naHOWlGS/6cB4LMAeu+jiXrDTjxbiWQv5SGBNXFSa9a6JckIidD4O3VeKcxEHHuOmSldGWRfs0cRdbWMA54eM6iKnmbokZP9otv9bhvVe0cfjPmlxDSRzECNhOcheiAs86h8GgVpfmo+GYTs15MKmXuWDj+LZKYSCFRcgcn1UPNySQaDPGnwItNqP0SSKO9qclEi4a84wws/ZTMYyAsc6H2u7E8lsJXkueIrRnpFXbp3SLsPQTnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JOfMtK9uPCRjoqE44RI9oSOYI5o7ys3RsMEi8r5i9TA=; b=PjO1G/lhLvdwp7Uhz7/yn0KQQltr+jIarAcUFmu2eIWTA3WsP9bj+tSy5vjaNt+IgJ7ahQ7zDWN8SgVH336Izl7JkIzt9zQO5dL1f6c88gp1c91mpCyXnPOmt9OAZO5aVI/k8+RVAVq/I0YcKCkKjOyDzV3PyhpdGHxj5tO50AY= Received: from MW4PR03CA0279.namprd03.prod.outlook.com (2603:10b6:303:b5::14) by SA3PR12MB9089.namprd12.prod.outlook.com (2603:10b6:806:39f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 08:39:56 +0000 Received: from CO1NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::b6) by MW4PR03CA0279.outlook.office365.com (2603:10b6:303:b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Mon, 10 Jul 2023 08:39:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT030.mail.protection.outlook.com (10.13.174.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:39:56 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:39:40 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 7/9] drm/amd/pm: add flood detection for wbrf events Date: Mon, 10 Jul 2023 16:36:39 +0800 Message-ID: <20230710083641.2132264-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT030:EE_|SA3PR12MB9089:EE_ X-MS-Office365-Filtering-Correlation-Id: eb4a24ca-74b1-430c-fbe8-08db81213d20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aovI53qDsRjfPqIwVmaXjH7pFmB+DGqeXhcXfxjsnl2wCAwIcahw+/0cfPHTjHZTLYG/23JS+b552XnzbxzPUOwMDjnGl89nHRQ5UxHAPpRU0bmC0m+iTJvqPyM0zYoLwdaga3jlh+Tq+XrU5xZhMlCQ66NRJIF4Q6b6JoLrFavcfvjIhrmt1E8eT5I0eNrOirL4sUPMIwwLuxK+dWi8HvyM3yXIF5c52YTKpv+2BjZ16tgH3kcFoHUgsGGmkIHO3Mcwib5HOtnzNk12Tx1xmpjtvhpxkTXoNnrq19e5lpO6wU4lx1bvzXwNRWNfKfWBAN1ymn9tsu9dsBjDs2vUN8JSM9iPkONoK4KqN07MmsJyIkLvNyfUcyRKai6yg2nWQiQ3+HFVOzXDJz4wsY0hPZl2sYSu6ONgBh1vZpMoXJKlnlSjAmXQos11U1wDzWvOzU75EkLtyI8bu+kUDFFI9rCczOwULHELCI8s3Z/fVhm4qhh9C2RhIXzD6PBQZIyK3SiRSrnbsGaFKw5TalnavjVw/WBNHS1Gzp2W9Camu2de1fol05HxCgAvoCmXbHdoI04fwU6ahl5KCAS6IVfnzdfwLtUYVCEwyfeYtEMkfWq2wwiQDulHLFSVVkwLmagpceYUV4Nm9LimRguwcrYB9Mpb7QgeKbQnBh0ll1OtRkm7oXFKCSVA92DdiRv7C/lD/3excMFG+mSQMZI7vDAR0edL6/Hg+3zotZ31h9dqcAPGdIh3fq0l6yMFKdA8rvHsUFWl5dO/9BpuhflQu6OzzPoqz5Wyyli+XPvlEEihnMjJPmxWAtyEjzc0LnoF4/IwKsEAABVZJAMK09ZYf/irHg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(186003)(16526019)(26005)(2616005)(1076003)(36860700001)(336012)(426003)(83380400001)(47076005)(41300700001)(4326008)(2906002)(316002)(44832011)(7416002)(5660300002)(8676002)(8936002)(478600001)(7696005)(70586007)(70206006)(110136005)(54906003)(40480700001)(36756003)(921005)(81166007)(356005)(82740400003)(86362001)(82310400005)(83996005)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:39:56.1126 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb4a24ca-74b1-430c-fbe8-08db81213d20 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9089 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 31 +++++++++++++++---- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 83d428e890df..aa7faeafc86b 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1278,7 +1278,8 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, switch (action) { case WBRF_CHANGED: - smu_wbrf_handle_exclusion_ranges(smu); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); break; default: return NOTIFY_DONE; @@ -1287,6 +1288,21 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, return NOTIFY_OK; } +/** + * smu_wbrf_delayed_work_handler - callback on delayed work timer expired + * + * @work: struct work_struct pointer + * + * Flood is over and driver will consume the latest exclusion ranges. + */ +static void smu_wbrf_delayed_work_handler(struct work_struct *work) +{ + struct smu_context *smu = + container_of(work, struct smu_context, wbrf_delayed_work.work); + + smu_wbrf_handle_exclusion_ranges(smu); +} + /** * smu_wbrf_support_check - check wbrf support * @@ -1317,12 +1333,14 @@ static void smu_wbrf_support_check(struct smu_context *smu) */ static int smu_wbrf_init(struct smu_context *smu) { - struct amdgpu_device *adev = smu->adev; int ret; if (!smu->wbrf_supported) return 0; + INIT_DELAYED_WORK(&smu->wbrf_delayed_work, + smu_wbrf_delayed_work_handler); + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; ret = wbrf_register_notifier(&smu->wbrf_notifier); if (ret) @@ -1333,11 +1351,10 @@ static int smu_wbrf_init(struct smu_context *smu) * before our driver loaded. To make sure our driver * is awared of those exclusion ranges. */ - ret = smu_wbrf_handle_exclusion_ranges(smu); - if (ret) - dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); - return ret; + return 0; } /** @@ -1353,6 +1370,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; wbrf_unregister_notifier(&smu->wbrf_notifier); + + cancel_delayed_work_sync(&smu->wbrf_delayed_work); } static int smu_smc_hw_setup(struct smu_context *smu) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 5b2343cfc69b..5df28d4a8c30 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -480,6 +480,12 @@ struct stb_context { #define WORKLOAD_POLICY_MAX 7 +/* + * Configure wbrf event handling pace as there can be only one + * event processed every SMU_WBRF_EVENT_HANDLING_PACE ms. + */ +#define SMU_WBRF_EVENT_HANDLING_PACE 10 + struct smu_context { struct amdgpu_device *adev; @@ -579,6 +585,7 @@ struct smu_context /* data structures for wbrf feature support */ bool wbrf_supported; struct notifier_block wbrf_notifier; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter; From patchwork Mon Jul 10 08:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3063EEB64DC for ; Mon, 10 Jul 2023 08:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233151AbjGJIl1 (ORCPT ); Mon, 10 Jul 2023 04:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbjGJIke (ORCPT ); Mon, 10 Jul 2023 04:40:34 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2072.outbound.protection.outlook.com [40.107.100.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB8E6E40; Mon, 10 Jul 2023 01:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MBMvpLsUnoNqRT6hs+lcjLWzYW4BIUwiuZEV6hnJvLQefKaf9D9su3lt+J9O7ho6Zzt9mKeZbgjgsLh4IFMs7iFG73FFOd+rmJkYGjRD7od6h2QNJYk338vkwgUZZ8vd89yo9TD/8ouMbMq1E94UDKEnpnkmJsuX69kkU4hCZig0wbVYnn3PwSXeDyLr5KOGrTX85UlginEgG9zFtXaW0aSc7PrlmrsaAly2FlvLs96sxBgJGRF8lGOT6te79KTzJPrL2fWTGPpWhRj1jkbr6jn+qp+BYKBs26ffdi9IOzf81nLvJnYWX+hJp/7Dmt5OgilAjg2I35wg5+k7hfcFIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=77oJ1lJYQNNqqP80R3eGk4gvUAHbfABBOq8qNyuku1Q=; b=HrZEeCw+tmV7M1b2eZy7aefXbQGDyokTBvHzAkfg2lpF/vjQbO81drL8KSChWlZzlUjUleiMoMMO+UUDk8NbssSFyeh5F3iGtAosVHpWPYReQ3+WjkESpMf66p/snRe/qEoIrhZKpN6h6qtlchOwANTTnbaLJGxSl3IZ7HSicB2yM7/I7tTWSj/elCbcrLNyQbADyFW8hZJHsLvj8JjTgVX7vVolG4te7Srp1LeoqKrL6liggui6WXIcpjehCvrD5ZqxWm56Nsug6ifsC/9BUFKZYaY1Eq9VA8vB1MsfkMSxhXi6AVg8QlUKrnZgYIO9VG4Omyo9cQ+L+QuIeZaUvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=77oJ1lJYQNNqqP80R3eGk4gvUAHbfABBOq8qNyuku1Q=; b=XQCsfLR1Nu9Mw6MlWVeuEQen84/H5vh2TBjJEmWR3nHl8ZQKHlLfr5cMEf6z1nSWLi8GLEKUJikqAWBCL1zHPeXifHIkv45mr1OdeWp4BX+0uy8DLKq7LRa4+G15zE5dwW6R04JV44wR53Pia0OAYc/Sjkpiks3heZQ+4tmb7Vg= Received: from DS7PR03CA0356.namprd03.prod.outlook.com (2603:10b6:8:55::22) by SN7PR12MB8028.namprd12.prod.outlook.com (2603:10b6:806:341::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 08:40:04 +0000 Received: from DM6NAM11FT100.eop-nam11.prod.protection.outlook.com (2603:10b6:8:55:cafe::2d) by DS7PR03CA0356.outlook.office365.com (2603:10b6:8:55::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 08:40:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT100.mail.protection.outlook.com (10.13.172.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 08:40:03 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:39:55 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 8/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Mon, 10 Jul 2023 16:36:40 +0800 Message-ID: <20230710083641.2132264-9-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT100:EE_|SN7PR12MB8028:EE_ X-MS-Office365-Filtering-Correlation-Id: 0acf88a2-b45f-4aa8-992f-08db812141c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tSvV1OUZJpG/Gs41/u7HjbPsVkt5gw+tzjhpO3L3MHLCZ85zQUZlW0SioUraF6/SRmlYH+eiQ9T7DOTRKnG3/MtV5HYhMUqgkX/27ruw6a14zi5IuHdGk1JLA2o/iqwOKApJSe3H8i41uopXXNQmUkjusrtl3E/Fj9lkGk4XPKIJIvwoxZxnkCs6JkDUT8tncDcHT5z7vIix5SZpqOUjMq/I+FsLwpA9R1fXLaQU5N5Uh+qbwVt1geqnA4DQ48i/vdzTeAhJQ8UcV0fAsj0PcR9ZdaF5Zt2z2vcHUFsXv1/DMgdTiZX6PrlDiBAwHgJMsOWOJHbwGSxFqcxa4tYH6y2abz9BDegQwRwpug4Tea3fYjUouHAs2O9b/OV61sKhMkPTPLgjKm1MsW9MVWWze090n9PWt7Zon6V59e5Uz/ITyJGNy46MyLB0njbpQHYGqnLYd860/QPKNnRlh7Clm+LR9Tm+MxrXERb5mJg70I4iz5GVXows9Op8eMYpJ+d9NeMdtDFA0snYw04ufdI4Hu4LYM31hcfhj+0VBjP+XA5Z5R0T8TNv/41zsvJTdLMzd2yb0jh+3HdWnvupz9umkmaTw/khBN5qxbXozFI1S/s8DLblFzHGhQK2f4x2p1ZfHVGeeGkqgkofTvvoUpGm4zJeNdOclbx+4uMHba9uqjuA+EqTWddMoShW1Q1s/gGiS+4Nee+FGMV5AkbBIXj/MbLx72oa3IuA/Hy0YkL0RWq1yficJBe4ONgcWIbj3x5Opker1dDidzDvvAbuz59NRsn1UMammvByypb8nwMsQlVcK2+/fLoXeQ4vLdiwqEXz2vNMN/ni5QZoBxDxYIef2g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199021)(40470700004)(36840700001)(46966006)(86362001)(82310400005)(82740400003)(40460700003)(40480700001)(36756003)(6666004)(7696005)(110136005)(54906003)(70206006)(70586007)(921005)(81166007)(356005)(36860700001)(16526019)(1076003)(186003)(2616005)(26005)(44832011)(7416002)(5660300002)(316002)(2906002)(478600001)(8676002)(8936002)(47076005)(336012)(426003)(83380400001)(4326008)(41300700001)(83996005)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:40:03.9452 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0acf88a2-b45f-4aa8-992f-08db812141c2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT100.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8028 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 3 + .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 9 +++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 60 +++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 5df28d4a8c30..32764c509ba8 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -325,6 +325,7 @@ enum smu_table_id SMU_TABLE_PACE, SMU_TABLE_ECCINFO, SMU_TABLE_COMBO_PPTABLE, + SMU_TABLE_WIFIBAND, SMU_TABLE_COUNT, }; @@ -1499,6 +1500,8 @@ enum smu_baco_seq { __dst_size); \ }) +#define HZ_IN_MHZ 1000000U + #if !defined(SWSMU_CODE_LAYER_L2) && !defined(SWSMU_CODE_LAYER_L3) && !defined(SWSMU_CODE_LAYER_L4) int smu_get_power_limit(void *handle, uint32_t *limit, diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h index 297b70b9388f..5bbb60289a79 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h @@ -245,7 +245,8 @@ __SMU_DUMMY_MAP(AllowGpo), \ __SMU_DUMMY_MAP(Mode2Reset), \ __SMU_DUMMY_MAP(RequestI2cTransaction), \ - __SMU_DUMMY_MAP(GetMetricsTable), + __SMU_DUMMY_MAP(GetMetricsTable), \ + __SMU_DUMMY_MAP(EnableUCLKShadow), #undef __SMU_DUMMY_MAP #define __SMU_DUMMY_MAP(type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h index df3baaab0037..b6fae9b92303 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h @@ -303,5 +303,8 @@ int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, uint32_t *size, uint32_t pptable_id); +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement); + #endif #endif diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c index ca379181081c..7cb24c862720 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c @@ -2453,3 +2453,12 @@ int smu_v13_0_mode1_reset(struct smu_context *smu) return ret; } + +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement) +{ + return smu_cmn_send_smc_msg_with_param(smu, + SMU_MSG_EnableUCLKShadow, + enablement, + NULL); +} diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c index 08577d1b84ec..3e864bd2c5a4 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c @@ -155,6 +155,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(AllowIHHostInterrupt, PPSMC_MSG_AllowIHHostInterrupt, 0), MSG_MAP(ReenableAcDcInterrupt, PPSMC_MSG_ReenableAcDcInterrupt, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = { @@ -235,6 +236,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = { TAB_MAP(DRIVER_SMU_CONFIG), TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, + TAB_MAP(WIFIBAND), TAB_MAP(I2C_COMMANDS), TAB_MAP(ECCINFO), }; @@ -472,6 +474,9 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t), PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, + sizeof(WifiBandEntryTable_t), PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM); smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); if (!smu_table->metrics_table) @@ -2141,6 +2146,58 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu, return ret; } +static bool smu_v13_0_0_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + switch (adev->ip_versions[MP1_HWIP][0]) { + case IP_VERSION(13, 0, 0): + return smu->smc_fw_version >= 0x004e6300; + case IP_VERSION(13, 0, 10): + return smu->smc_fw_version >= 0x00503300; + default: + return false; + } +} + +static int smu_v13_0_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 + * is a valid setting. So, there should be no direct + * return on that. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table, @@ -2217,6 +2274,9 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .send_hbm_bad_channel_flag = smu_v13_0_0_send_bad_mem_channel_flag, .gpo_control = smu_v13_0_gpo_control, .get_ecc_info = smu_v13_0_0_get_ecc_info, + .is_asic_wbrf_supported = smu_v13_0_0_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_0_set_wbrf_exclusion_ranges, }; void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu) From patchwork Mon Jul 10 08:36:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 701546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BAACEB64D9 for ; Mon, 10 Jul 2023 08:41:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjGJIlp (ORCPT ); Mon, 10 Jul 2023 04:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233026AbjGJIlN (ORCPT ); Mon, 10 Jul 2023 04:41:13 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78081BE1; Mon, 10 Jul 2023 01:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CzS7gk/0eVRIcFMPLvglM9i1uyn0hCv8f0cSz9vAZ2XoUo379++Cj4zur4fG/CYPsu3FNVvtmU2RWf7LVx+WC33+mQD3t2R6M7DkiZ8VqlTchbCc5z3y5iMmagsMzaaYto3KQqrSoqU1G468oAJng+KQX9RWr4yJ4dWINBtqfMaIuJzEZytkqwYsEXs7OpuQvj99Kri3ZBAbTc+1n5ZZD94hJPartW9vqfwaP217oMwZzoBYeO2ZztatDljt/vyIMEc7O7EzQEv772oxHx7nAcXiC57g0EjpWFHRlM7+qut2PxeYg0106MmMRoizZu04ty9LEVTYwR1PEfkAXRi1XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cfth29BrWZrzk+qu1CaoTQ6BbwxlunM+2D18Jm9HX9w=; b=iuJ4uJrECU7A/Kc7ew0vpKxXeXApfjnIrCi6YjGEnwMs8yIlXeTQZYjZzJvU9G99fZu1sDOVnU4+Qscr8EasQ/wzPEdRX45bvKZ/vaSpXj2tejICytOaYCOiN16C1ak8EIi968sIVOo+BNzai7/06swI5oIHgZ6nJ7sMPf33b8ZLwBCyuEKi231CKh2znYIO016TBfAsWvMwYI/26ZH9l2SzxB/9+waC2lGuunWquoYPgzq5z30ceAhvMroVaBwQbPWZahaBt02HbVo/b5waP8QJGzxJexbjnRyuZHr5Ua7DwTEkWZSnn5vOv2VoQXmF/Hahv+OSuzH3WJBhtqoEeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cfth29BrWZrzk+qu1CaoTQ6BbwxlunM+2D18Jm9HX9w=; b=KIHj7z9bicSbfjZYksGMQuCyrOyj6BThcgZv42/0nfyAmJEsGS3InS2oeYI9o8NL06whXCEW+ySllN1b76EIkVwaI2+NMP9MTFSJylh0H/i4A3qiuyMayw43p984OgcSxNfcDO49JxiW7TmUTOEXiZxZySfcB6IyodsKkeuU5Rk= Received: from BY5PR16CA0028.namprd16.prod.outlook.com (2603:10b6:a03:1a0::41) by CH0PR12MB5172.namprd12.prod.outlook.com (2603:10b6:610:bb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 08:40:13 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:1a0:cafe::f5) by BY5PR16CA0028.outlook.office365.com (2603:10b6:a03:1a0::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 08:40:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Mon, 10 Jul 2023 08:40:12 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 03:40:03 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V6 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Mon, 10 Jul 2023 16:36:41 +0800 Message-ID: <20230710083641.2132264-10-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710083641.2132264-1-evan.quan@amd.com> References: <20230710083641.2132264-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT027:EE_|CH0PR12MB5172:EE_ X-MS-Office365-Filtering-Correlation-Id: 1403ae10-5218-4d31-6351-08db8121471d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gANj/KlIu4SSE8WWpwUeQC6tml3Dl+QzgL9ziHjR9TrU3OCRH5cmPS4alqG9AiqGyUITmZvDFNFOlJR6xZROgpyOSlcPZ/H46+EhP/IgULgC9d+V8hLByAASEfv64hLafic0aSUveilOAvnoLWWmQSYyGcLTofw7e8v2fDRX6DZgxmKyQI45HQynVD/7fyzNDQZbjboC9HaXH8WZVu4/vDjVnGOdZl+WSgk+TLTUrjMoO9gzF8+Kv2DrC8Yd2vJ9LDLBAlIiWKHJ/ev2/RIF3E0w4WLkXNYRueNgvy2yy5XfOD+OwA2M55N9Yks25XN2qOJ/f9SJghHWujjWIeDDuKD9SL6aOtbhHUe4P7xRDMTLVpPFJpAnkUYen9dHfNZCrm/lToebd1VLQftFFwwrRMyPTe4qPalR7ojpbZX8GwEHQ6KqzOkI+9NFdGffYLaEQniHlhnkZ3XpP4P8+FmjjUdtqdU8M5gQWxsJvixHz4FES3c56+lnslThV4uVR0sPddK9P8eVHE5tuC2/GvCLoGDwOWhh2kQknw9gFc3fC6URKClsgTgNBONiVg6nq5bvSEoeIzKb1g0PrQ35o7oxd847W1KFFVFfFVv7PHbjh3QpvdjwQJXn61I/3ORT8dV3jYjWHOeEl77zOfoGzM9kUB0smopsZByen8RlpBTeFiU1qUgxUisWIP2LyDzwrf9HWgm/WVLqOdCurjfKqHBnGoNQzHwj37h3Oy+xZgVHGLqb1v3Y6jUagmQKp9yosefWyMyuTTtrg2maNRiOeDp+DiTtqi/QW52viL7cPVwuRrL70ty18rQnWKNUXlQgcrZPHVmqMB0XoeOc8bAd/KR9Hg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(6666004)(70206006)(70586007)(40460700003)(2616005)(7696005)(82740400003)(26005)(478600001)(356005)(186003)(86362001)(1076003)(36756003)(921005)(40480700001)(16526019)(81166007)(110136005)(54906003)(47076005)(41300700001)(83380400001)(316002)(44832011)(36860700001)(5660300002)(7416002)(8676002)(8936002)(426003)(2906002)(4326008)(336012)(36900700001)(2101003)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:40:12.9288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1403ae10-5218-4d31-6351-08db8121471d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5172 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c index bba621615abf..4a680756208b 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c @@ -126,6 +126,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit, 0), MSG_MAP(NotifyPowerSource, PPSMC_MSG_NotifyPowerSource, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = { @@ -206,6 +207,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { TAB_MAP(DRIVER_SMU_CONFIG), TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -488,6 +490,9 @@ static int smu_v13_0_7_tables_init(struct smu_context *smu) AMDGPU_GEM_DOMAIN_VRAM); SMU_TABLE_INIT(tables, SMU_TABLE_COMBO_PPTABLE, MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, + sizeof(WifiBandEntryTable_t), PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM); smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); if (!smu_table->metrics_table) @@ -1722,6 +1727,57 @@ static int smu_v13_0_7_set_df_cstate(struct smu_context *smu, NULL); } +static bool smu_v13_0_7_wbrf_support_check(struct smu_context *smu) +{ + return smu->smc_fw_version > 0x00524600; +} + +static int smu_v13_0_7_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 is a valid setting. + * Considering the scenarios below: + * - At first the wifi device adds an exclusion range e.g. (2400,2500) to + * BIOS and our driver gets notified. We will set WifiBandEntryNum = 1 + * and pass the WifiBandEntry (2400, 2500) to PMFW. + * + * - Later the wifi device removes the wifiband list added above and + * our driver gets notified again. At this time, driver will set + * WifiBandEntryNum = 0 and pass an empty WifiBandEntry list to PMFW. + * - PMFW may still need to do some uclk shadow update(e.g. switching + * from shadow clock back to primary clock) on receiving this. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table, @@ -1787,6 +1843,9 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .set_mp1_state = smu_v13_0_7_set_mp1_state, .set_df_cstate = smu_v13_0_7_set_df_cstate, .gpo_control = smu_v13_0_gpo_control, + .is_asic_wbrf_supported = smu_v13_0_7_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_7_set_wbrf_exclusion_ranges, }; void smu_v13_0_7_set_ppt_funcs(struct smu_context *smu)