From patchwork Thu Aug 10 07:37:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712396 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 B833CC04A94 for ; Thu, 10 Aug 2023 07:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232907AbjHJHjj (ORCPT ); Thu, 10 Aug 2023 03:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbjHJHjh (ORCPT ); Thu, 10 Aug 2023 03:39:37 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EA701BCF; Thu, 10 Aug 2023 00:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mm+QbeKTglUm8QWVfGguZfWBthYsnJixI+pzn06RMXEDk0zjwkUM2jMmFC8fjd/G+15uItR8N4GC3Ck7sgVESk/SV+ECNhq5He5CbdH1ZHmtU9kH/rifDlsRZZ2uwl59MjByXr201ozDQ/n0bl1RHkzaGK3rR//CJs402tdIZNm/oC2oLq1Ryb/3EhzDVJLnEywf+vyRXPoqEvD7DIOy0XSv0YbVwGmQP/lQFF12Bol4aRg1BCOYUdyE/TnrRCewQBZXwsYyUe/Lbl93QY4PYcobB3jH23YBOfdZWaD/a+nEltjQxUM/dpQ69DGNx6fc3+NPfUkoU/QceBGZCv8jUA== 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=uDLR9nCc3WvnYEDHkNAPN4A94TUp8UHcvVIgzD15glI=; b=UP6JT+1TpcdsymniIE126lJaBsGWy31WFxCFOws709NlSUav+zf5CBCuL8MCPhWB7Od/YLSkj+7Pr1B9eDuCzo2yY9c9LJsKx87Bj0BDxDPVLVm8pt+WX6FxaRk76DUVP6oJKN3Al7rL4WAfptwWV7rDPHGkFLt955eo0daIncjFt84tMwolNgvshtjjbrzeHCONola/zysrCOxAG2GjlStLYv3OUQdqOWFNX9J5BLJn8jBKXeUSXBShxH1Us6hPAk/jOZo0MZDCRZ5sXsJGY9GPsdIqF8BaXYrgR3Lg+mtM7IUSuzsTb4ymXzwToAG7RezqHEeOknMR5d4FDMAzOg== 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=uDLR9nCc3WvnYEDHkNAPN4A94TUp8UHcvVIgzD15glI=; b=1xpYIaxLrWHoDO8A6mv3HcnA317Ve+IzrEtju7Txi2M6SZ7Hq88/4uEThv8IE1w6UhWw5eMPkfwOHQBBV26FJ/84dIVbt8yZ2BWvYT7MHatxYC9nkYKiOGgFfZTKhX58WtiQZCt3HsVi6k2mrkfNUuyXy9KL6gPETfoRvirW9vQ= Received: from MW4P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::15) by SJ2PR12MB9241.namprd12.prod.outlook.com (2603:10b6:a03:57b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:39:32 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::86) by MW4P220CA0010.outlook.office365.com (2603:10b6:303:115::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28 via Frontend Transport; Thu, 10 Aug 2023 07:39:31 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 07:39:31 +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.27; Thu, 10 Aug 2023 02:39:22 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 1/9] drivers core: Add support for Wifi band RF mitigations Date: Thu, 10 Aug 2023 15:37:55 +0800 Message-ID: <20230810073803.1643451-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E8:EE_|SJ2PR12MB9241:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d2f4a7d-e5f7-4dc4-f1c8-08db9974ef8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vo+xSbqieZs/Y3jBW/ItYN5jW7ntn+n5Z/aiAuTaem7P0RD5/4/OkMm6tki+czKoTgwCql4yreO+nuqdu8oevQkvmYHWVuc8FAtTZcoLjRU1mf7gABSk9PrqG5dDPxqgA0qlk7Gg2L7sq2K9Xnjs5X2+GtCFDyhet1+ZM/dNg2Vk8K/oFqjs/wHOSqGghRMig6ScTVFxItIrqdezR6EK91T+aYFTxmThDPw3eoeau7r3LiMqodmklRG9H5Po5FZ4M/MUAiGIwRa1m/oSxccKzMOkymy/hYHAW44e6Cx+DLoCAB3bvSR5CT9AXfRPVLR5kzCtb5YSiYnfdeij9jaDUdGq1MCqcvU7o0TFlEXfqgGHF+d0PP5pLoO9hXv2MbwuiV8eILZGc2WCFyR3rZOv3z5CwczEOjlA1izBbmj0DAJWORi/jYSWs27g8QUFXVz/hqL5sJ+MqOWq4D0gm0wBRiXjmEMFMq8Y1hjDRQ3OHIDkzKwWGdgxyBT18NpKf+fycqLc96sAthCkZeAzGb+5jmc918dIcy4f3/nNDG085tD0LoLkTRYHNj09S7DGkaHzCLOIO379AMRUOsc0/QusS1OujKVqxk45+A0KDyCwSwytVi9HOVjbmLzh8n+8e1R0OogSOXP2C2QIALFLYGXQt6bIUVYJkg9joerR4a47GcTM4weiPhD4t23dNzRMSyYZoeH9/aveIlv8IY3H2/C9Uj3Y0zTBfklQArFGYzCSSziiOWyI4uXbqCcNRFixKIBULZaVInv/Sp6XIyD9sE2h+0ZUR2qctzjv/oSHM7OWF7/ngZrClmdaaR4nycPDnltUmEjuCnL4k7kxYOwU+8F3FA== 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)(396003)(376002)(346002)(451199021)(82310400008)(1800799006)(186006)(36840700001)(40470700004)(46966006)(2906002)(336012)(478600001)(36756003)(16526019)(30864003)(26005)(1076003)(40480700001)(6666004)(7696005)(40460700003)(86362001)(316002)(8936002)(8676002)(7416002)(4326008)(70586007)(5660300002)(70206006)(41300700001)(81166007)(82740400003)(356005)(921005)(2616005)(426003)(36860700001)(44832011)(54906003)(47076005)(110136005)(83380400001)(83996005)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:39:31.6095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d2f4a7d-e5f7-4dc4-f1c8-08db9974ef8f 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9241 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_register_notifier` to register for notifications of frequency changes from other devices. 3) Call the `wbrf_retrieve_exclusions` to retrieve the current exclusions range on receiving a notification and response correspondingly. Meanwhile a kernel parameter `wbrf` with default setting as "auto" is introduced to specify what the policy is. - With `wbrf=on`, the WBRF features will be enabled forcely. - With `wbrf=off`, the WBRF features will be disabled forcely. - With `wbrf=auto`, it will be up to the system to do proper checks to determine the WBRF features should be enabled or not. 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) v6->v7: - revised the `struct wbrf_ranges_out` to be naturally aligned(Andrew) - revised some code comments(Andrew) --- .../admin-guide/kernel-parameters.txt | 9 + drivers/base/Makefile | 1 + drivers/base/wbrf.c | 280 ++++++++++++++++++ include/linux/wbrf.h | 47 +++ 4 files changed, 337 insertions(+) create mode 100644 drivers/base/wbrf.c create mode 100644 include/linux/wbrf.h diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index a1457995fd41..21f73a0bbd0b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7152,3 +7152,12 @@ xmon commands. off xmon is disabled. + wbrf= [KNL] + Format: { on | auto | off } + Controls if WBRF features should be enabled or disabled + forcely. Default is auto. + on Force enable the WBRF features. + auto Up to the system to do proper checks to + determine the WBRF features should be enabled + or not. + off Force disable the WBRF features. diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 3079bfe53d04..7b3cef898c19 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-y += wbrf.o obj-y += test/ diff --git a/drivers/base/wbrf.c b/drivers/base/wbrf.c new file mode 100644 index 000000000000..678f245c12c6 --- /dev/null +++ b/drivers/base/wbrf.c @@ -0,0 +1,280 @@ +// 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 enum WBRF_POLICY_MODE { + WBRF_POLICY_FORCE_DISABLE, + WBRF_POLICY_AUTO, + WBRF_POLICY_FORCE_ENABLE, +} wbrf_policy = WBRF_POLICY_AUTO; + +static int __init parse_wbrf_policy_mode(char *p) +{ + if (!strncmp(p, "auto", 4)) + wbrf_policy = WBRF_POLICY_AUTO; + else if (!strncmp(p, "on", 2)) + wbrf_policy = WBRF_POLICY_FORCE_ENABLE; + else if (!strncmp(p, "off", 3)) + wbrf_policy = WBRF_POLICY_FORCE_DISABLE; + else + return -EINVAL; + + return 0; +} +early_param("wbrf", parse_wbrf_policy_mode); + +static struct exclusion_range_pool { + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; + u64 ref_counter[MAX_NUM_OF_WBRF_RANGES]; +} 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; + } + + out->num_of_ranges = out_idx; + + return 0; +} + +/** + * wbrf_supported_system - Determine if the system supports WBRF features + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if the platform is able to support the + * WBRF features. + */ +static bool wbrf_supported_system(void) +{ + switch (wbrf_policy) { + case WBRF_POLICY_FORCE_ENABLE: + return true; + case WBRF_POLICY_FORCE_DISABLE: + return false; + case WBRF_POLICY_AUTO: + return false; + } + + return false; +} + +/** + * wbrf_supported_producer - Determine if the device should report frequencies + * + * @dev: device pointer + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if this device should report such frequencies. + */ +bool wbrf_supported_producer(struct device *dev) +{ + if (!wbrf_supported_system()) + return false; + + 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 should react to frequencies + * + * @dev: device pointer + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if this device should react to reports from + * other devices for such frequencies. + */ +bool wbrf_supported_consumer(struct device *dev) +{ + if (!wbrf_supported_system()) + return false; + + 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..476a28fec27a --- /dev/null +++ b/include/linux/wbrf.h @@ -0,0 +1,47 @@ +/* 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 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 { + u64 num_of_ranges; + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +}; + +enum wbrf_notifier_actions { + WBRF_CHANGED, +}; + +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); + +#endif /* _LINUX_WBRF_H */ From patchwork Thu Aug 10 07:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712705 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 938D2C001DE for ; Thu, 10 Aug 2023 07:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232046AbjHJHkC (ORCPT ); Thu, 10 Aug 2023 03:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbjHJHkB (ORCPT ); Thu, 10 Aug 2023 03:40:01 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567021702; Thu, 10 Aug 2023 00:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=np0fmzC8fN9H+kesc6UzS/8HFY8rYfypkctollNYX6jLNTCfKLcMpzxDS8xaWv27jSzVX+KYE9WRlHKtMTQCrsTijburb+W5gmsiPyJUvyOFMoOg07bC3dm9h8cz0cFUkhwPB/nbCeIY+y5MUDjsYV8pqSZ16aGK2EH39BjjCFgxoBTs9snV+KP0ydg6lBmEYc55yUZ6x3rFSNlt6vp0kcIBLrtbwpinVcZwcV+QTZCx7vwzoRK5bliScRV8F/kPb5uCeDC9NisVNml6zR/6Lexf0c48MrkV7oXt9d+zi3teoICW6TkuF6VAU/KLnTlZFATevmZzTucYDzYofEQeGQ== 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=yCaHqYP8QYyX8L941rjs+1lHEWpQH7UheKFD3geywvk=; b=O1QhCw1vUvkMBLrRjC9REF/z0rRtdTrReojVgx/dBqQMcdLtY0u5h4A81bq1/L6hV3Qvw2iI58dcaZ46Dx/fEnbZJIahXzfNPnXcQiBaVLvmbDLNrYqEsB7fzKkSPA+QWbFcGsXWhivQHMcS6gBtuRNTM+RdWOD/nQ7z8CsWcjAV//or7d97OxGZ2mSB8dBql+GTMQDo/ga118uvUDezlcYtzAlb+5KGUUQ8IGsV2XgfqjSGNbDF1kW28f4Tq67y/fR6qV/90DP64MU7COj10D9xK30r/+qXf+CcUK64kJ3BCPc9dVcgfLKpGHFZssthT0OqjwOisugbnq24RTwdDQ== 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=yCaHqYP8QYyX8L941rjs+1lHEWpQH7UheKFD3geywvk=; b=lQvCVvmGH5Ax8Hrn3o5UTdztzBV0gNvoea9oZFs1lVqsYuaui3crGY53HQLuj5nxbDeUMrMso53eaHs6/HiiFB3DBlJpD+saz9niXSSKh0bUd8xkK9f+S6PIoQqaWZVkxBKAajzVWCLGEkVOjIL4OdwklSJIAzWpPrlCsKKpe0c= Received: from MW4P220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::22) by DS0PR12MB7747.namprd12.prod.outlook.com (2603:10b6:8:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:39:54 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::34) by MW4P220CA0017.outlook.office365.com (2603:10b6:303:115::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 07:39:54 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 07:39:54 +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.27; Thu, 10 Aug 2023 02:39:30 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 2/9] drivers core: add ACPI based WBRF mechanism introduced by AMD Date: Thu, 10 Aug 2023 15:37:56 +0800 Message-ID: <20230810073803.1643451-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E8:EE_|DS0PR12MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a0ce06a-06d0-4efd-692a-08db9974fcf4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c/gGQCEEUNPw+iFHJf3czUYeey3BcnJos6RqVqQ+p2Lg8FFt7yAva48zyFMvSrVa/VwpHl4WhjHbiFnd8z67mTdU9NKfWKsU5H/bkJ2s8NRKax9PUVBCAIDiJG8pHgnqxZYxUykpHwmHoqEB8f5dpavKnnyoClQnIY0Hfl1Y5/Y3FMyAcdYEFRId01ukTjMwDvos7amDStvwUO/mQ60zmB7qvKx5vOhayMy39G8CIf5bQDdFnpm9hrcaqVCf+0JK9SYnNv9myFJdpkqJ7m0wQxCBa6TGBrvmlhhbdZ32BznDHBBtsZFocuwOm29v694/Gbto1uJc+o3DAeRsaXshleX2Ou3gd+L8BOuaiDvgSO7H2Wt2v71P1L8gMLYC80m8ctnGl4nix0AhjsmGRZiG/r8xxbUVlYMQOzzV7k47jPuTyGJMEty2Cv1tpmKwMznf2K2ALRT+3a/nCsTkb6MQyRZl5Vo10mIbI42Yx4oduiwZ+BSLQ9WAKRN6ywNYkSypd94P9w6CGOVZXaSyQ7wxGB0njCB6bfYn8DkRW+eR64Vt5UEzDQmBhFEoQ1tLUd77nMg8jov+NddAyobwWfktgpHBnhkQWnUa9H7N5ey5rdE2saXVFz9zdensAkqNCdVcmOGidXUUBjVNCz31k/0rC6SIBlJfZnm2fhhzfoBW2667dxpLfpDEUKizSzDAoCesujP/DB4dIu6g3IbIBMKTNN62u2eN/dKRL9UtoSj1VFB5DsBdQ69bakUlgdiDMMpko65dQOIaoO5HKe/wNTGsQhkI8qcgRw9UvsKI7G81dOv7x5mYdZ+gbG3iVv7wnvUiZqKgw5W5t/3Jju4KHOvvjw== 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)(39860400002)(376002)(346002)(396003)(451199021)(82310400008)(186006)(1800799006)(40470700004)(36840700001)(46966006)(36756003)(40460700003)(26005)(1076003)(8936002)(921005)(8676002)(356005)(82740400003)(40480700001)(316002)(86362001)(2616005)(478600001)(426003)(81166007)(41300700001)(336012)(16526019)(36860700001)(5660300002)(7696005)(44832011)(7416002)(30864003)(70586007)(70206006)(4326008)(2906002)(83380400001)(47076005)(6666004)(54906003)(110136005)(2101003)(83996005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:39:54.0783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a0ce06a-06d0-4efd-692a-08db9974fcf4 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7747 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/fall-back the generic WBRF solution for diagnosing potential interference issues. And for the platform which does not equip with the necessary AMD ACPI implementations but with CONFIG_WBRF_AMD_ACPI built as 'y', it will fall back to generic WBRF solution if the `wbrf` is set as "on". 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) v6->v8: - drop CONFIG_WBRF_GENERIC(Mario) - add `wbrf` kernel parameter for policy control(Mario) --- drivers/acpi/Makefile | 2 + drivers/acpi/amd_wbrf.c | 294 ++++++++++++++++++++++++++++++++++ drivers/base/Kconfig | 20 +++ drivers/base/wbrf.c | 135 +++++++++++++--- include/linux/acpi_amd_wbrf.h | 25 +++ 5 files changed, 452 insertions(+), 24 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 3fc5a0d54f6e..9185d16e4495 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -133,3 +133,5 @@ obj-$(CONFIG_ARM64) += arm64/ obj-$(CONFIG_ACPI_VIOT) += viot.o obj-$(CONFIG_RISCV) += riscv/ + +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..a3390d91cbea --- /dev/null +++ b/drivers/acpi/amd_wbrf.c @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include + +#define ACPI_AMD_WBRF_METHOD "\\WBRF" + +/* + * 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_ENABLED 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 + +/* + * The data structure used for WBRF_RETRIEVE is not natually aligned. + * And unfortunately the design has been settled down. + */ +struct amd_wbrf_ranges_out { + u32 num_of_ranges; + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +} __packed; + +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_system(void) +{ + acpi_status status; + acpi_handle handle; + + status = acpi_get_handle(NULL, ACPI_AMD_WBRF_METHOD, &handle); + + return ACPI_SUCCESS(status); +} + +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_ENABLED)) && + (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); + struct amd_wbrf_ranges_out acpi_out = {0}; + 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(acpi_out) || + obj->buffer.length < 4) { + dev_err(dev, "BIOS FUBAR, ignoring wrong sized WBRT information"); + ACPI_FREE(obj); + return -EINVAL; + } + memcpy(&acpi_out, obj->buffer.pointer, obj->buffer.length); + + out->num_of_ranges = acpi_out.num_of_ranges; + memcpy(out->band_list, acpi_out.band_list, sizeof(acpi_out.band_list)); + + ACPI_FREE(obj); + + return 0; +} diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 2b8fd6bb7da0..feb6f5625728 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -242,4 +242,24 @@ config FW_DEVLINK_SYNC_STATE_TIMEOUT command line option on every system/board your kernel is expected to work on. +menu "Wifi band RF mitigation mechanism" + +config WBRF_AMD_ACPI + bool "ACPI based mechanism introduced by AMD" + depends on ACPI + 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. + + 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. + + Before enabling this ACPI based mechanism, it is suggested to confirm + with the hardware designer/provider first whether your platform + equipped with necessary BIOS and firmwares. + +endmenu + endmenu diff --git a/drivers/base/wbrf.c b/drivers/base/wbrf.c index 678f245c12c6..751e252d0039 100644 --- a/drivers/base/wbrf.c +++ b/drivers/base/wbrf.c @@ -6,9 +6,25 @@ */ #include +#include static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); + static DEFINE_MUTEX(wbrf_mutex); + +static struct exclusion_range_pool { + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; + u64 ref_counter[MAX_NUM_OF_WBRF_RANGES]; +} wbrf_pool; + +enum WBRF_SUPPORT_CHECK { + WBRF_SUPPORT_UNCHECKED, + WBRF_SUPPORT_NONE, + WBRF_SUPPORT_GENERIC, + WBRF_SUPPORT_OTHERS, +}; +static atomic_t wbrf_support_check = ATOMIC_INIT(WBRF_SUPPORT_UNCHECKED); + static enum WBRF_POLICY_MODE { WBRF_POLICY_FORCE_DISABLE, WBRF_POLICY_AUTO, @@ -30,11 +46,6 @@ static int __init parse_wbrf_policy_mode(char *p) } early_param("wbrf", parse_wbrf_policy_mode); -static struct exclusion_range_pool { - struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; - u64 ref_counter[MAX_NUM_OF_WBRF_RANGES]; -} wbrf_pool; - static int _wbrf_add_exclusion_ranges(struct wbrf_ranges_in *in) { int i, j; @@ -121,20 +132,45 @@ static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) * * WBRF is used to mitigate devices that cause harmonic interference. * This function will determine if the platform is able to support the - * WBRF features. + * WBRF features. For example, for AMD ACPI implementation it should say + * true only when the necessary AML code/logic supporting wbrf feature + * available. */ -static bool wbrf_supported_system(void) +static enum WBRF_SUPPORT_CHECK wbrf_supported_system(void) { + enum WBRF_SUPPORT_CHECK support_check; + + support_check = atomic_read(&wbrf_support_check); + if (support_check != WBRF_SUPPORT_UNCHECKED) + return support_check; + + support_check = WBRF_SUPPORT_NONE; + switch (wbrf_policy) { case WBRF_POLICY_FORCE_ENABLE: - return true; +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + if (acpi_amd_wbrf_supported_system()) { + support_check = WBRF_SUPPORT_OTHERS; + break; + } + pr_warn_once("Force WBRF w/o acpi_amd_wbrf support\n"); + pr_warn_once("Fall back to generic version\n"); +#endif + support_check = WBRF_SUPPORT_GENERIC; + break; case WBRF_POLICY_FORCE_DISABLE: - return false; + break; case WBRF_POLICY_AUTO: - return false; +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + if (acpi_amd_wbrf_supported_system()) + support_check = WBRF_SUPPORT_OTHERS; +#endif + break; } - return false; + atomic_set(&wbrf_support_check, support_check); + + return support_check; } /** @@ -144,13 +180,22 @@ static bool wbrf_supported_system(void) * * WBRF is used to mitigate devices that cause harmonic interference. * This function will determine if this device should report such frequencies. + * For example, for AMD ACPI implementation it should say true only when the + * necessary AML code/logic supporting wbrf feature available for this device. */ bool wbrf_supported_producer(struct device *dev) { - if (!wbrf_supported_system()) + switch (wbrf_supported_system()) { + case WBRF_SUPPORT_GENERIC: + return true; + case WBRF_SUPPORT_OTHERS: +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + return acpi_amd_wbrf_supported_producer(dev); +#endif + fallthrough; + default: return false; - - return true; + } } EXPORT_SYMBOL_GPL(wbrf_supported_producer); @@ -166,11 +211,22 @@ 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); - r = _wbrf_add_exclusion_ranges(in); + switch (wbrf_supported_system()) { + case WBRF_SUPPORT_OTHERS: +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + r = acpi_amd_wbrf_add_exclusion(dev, in); +#endif + break; + case WBRF_SUPPORT_GENERIC: + r = _wbrf_add_exclusion_ranges(in); + break; + default: + break; + } mutex_unlock(&wbrf_mutex); if (r) @@ -194,11 +250,22 @@ 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); - r = _wbrf_remove_exclusion_ranges(in); + switch (wbrf_supported_system()) { + case WBRF_SUPPORT_OTHERS: +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + r = acpi_amd_wbrf_remove_exclusion(dev, in); +#endif + break; + case WBRF_SUPPORT_GENERIC: + r = _wbrf_remove_exclusion_ranges(in); + break; + default: + break; + } mutex_unlock(&wbrf_mutex); if (r) @@ -217,14 +284,23 @@ EXPORT_SYMBOL_GPL(wbrf_remove_exclusion); * * WBRF is used to mitigate devices that cause harmonic interference. * This function will determine if this device should react to reports from - * other devices for such frequencies. + * other devices for such frequencies. For example, for AMD ACPI implementation + * it should say true only when the necessary AML code/logic supporting wbrf + * feature available for this device. */ bool wbrf_supported_consumer(struct device *dev) { - if (!wbrf_supported_system()) + switch (wbrf_supported_system()) { + case WBRF_SUPPORT_GENERIC: + return true; + case WBRF_SUPPORT_OTHERS: +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + return acpi_amd_wbrf_supported_consumer(dev); +#endif + fallthrough; + default: return false; - - return true; + } } EXPORT_SYMBOL_GPL(wbrf_supported_consumer); @@ -267,11 +343,22 @@ 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); - r = _wbrf_retrieve_exclusion_ranges(out); + switch (wbrf_supported_system()) { + case WBRF_SUPPORT_OTHERS: +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) + r = acpi_amd_wbrf_retrieve_exclusions(dev, out); +#endif + break; + case WBRF_SUPPORT_GENERIC: + r = _wbrf_retrieve_exclusion_ranges(out); + break; + default: + break; + } mutex_unlock(&wbrf_mutex); diff --git a/include/linux/acpi_amd_wbrf.h b/include/linux/acpi_amd_wbrf.h new file mode 100644 index 000000000000..40c59e9f626d --- /dev/null +++ b/include/linux/acpi_amd_wbrf.h @@ -0,0 +1,25 @@ +// 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_system(void); +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 */ From patchwork Thu Aug 10 07:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712395 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 51EA4C001DB for ; Thu, 10 Aug 2023 07:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232257AbjHJHkP (ORCPT ); Thu, 10 Aug 2023 03:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbjHJHkM (ORCPT ); Thu, 10 Aug 2023 03:40:12 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413B42136; Thu, 10 Aug 2023 00:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I8OGs+qUznR9gpn1CsH1fYq9Rf8aP1qiAhR3OWd27zOAwr9guVqm0Nzb4ete/MqijayTyD5hCYfkHpGG2XyfbFCjCy01ed/AmpFRIHgg8pVyByCAL8rdTXudZd+K3j5mjByjd6SD4zwVtI5BdMnfU2b5bjraCNw7uwGGRlAumjVFrqSxspQ6/60lsVHIG//4bGcOKQM6/KY1y+am6Luh/OQDPiuvdDX9HcQQWhPdEHJb3H9ws/NtYtZprbvG5q+4lVLHl13C4nYDe0VYVlQBhNOkP29NynnLoFY55RD+KHg6SASk9/fuoGB1oP1NZOUL5X6GVGyUyxzWy6VcVKGMjw== 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=iiMLnjCApacLG4wsAzcrg+11GjFpwA3RTl1Uo2H/Zug=; b=ZQVp9VR16RKYSNMzSuttEgb6KrOA9yc7fN6ZS15DLbWeThDuRFljp5WEpFO94b1hz9SHoxh0pc2qKMUQkK1TID9DR25uEQVyGXJ7vHHMD6V2BzPiv0h1PFjgUhVCpoXbgHLW6cC5eK6iG3fcFymLLnZAEYIWnDUql3T5zekXheQLiRICQdTDhF9DsmLFt/UGr8r8LwKnZUM5D4F8G+cJkX+ilcaElzbryrZBQZUyvP7ZTq4iUf1QILuMhbOrshYn8QTLfjTbDWxqpPhPPrtkIbS9nDLJZhLARm84NUkO4fFidrfTqrcoqQqD+435EL4p3OCxMXMtSyqV0c1kf1hVVQ== 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=iiMLnjCApacLG4wsAzcrg+11GjFpwA3RTl1Uo2H/Zug=; b=iSTY9X6UnOn1+NhLMG4IYw1H0b0uVZy3YmcmC3zy4LJUgJC0p9qCKIdxYCkzD0Bof1ODQRxp09p8JDRYEru268gNzSQ8rdj6cRIWcqPpUJ5uxIabb1AeANIxsGCLIB/rxJ7Y6Awioix7jwaSmnOyLmrlcbiA+0v7tnq/2k6TvUo= Received: from CH0PR03CA0032.namprd03.prod.outlook.com (2603:10b6:610:b3::7) by CH0PR12MB5060.namprd12.prod.outlook.com (2603:10b6:610:e3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:40:07 +0000 Received: from MWH0EPF000971E2.namprd02.prod.outlook.com (2603:10b6:610:b3:cafe::21) by CH0PR03CA0032.outlook.office365.com (2603:10b6:610:b3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 07:40:07 +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 MWH0EPF000971E2.mail.protection.outlook.com (10.167.243.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 07:40:07 +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.27; Thu, 10 Aug 2023 02:39:52 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V8 3/9] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing Date: Thu, 10 Aug 2023 15:37:57 +0800 Message-ID: <20230810073803.1643451-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E2:EE_|CH0PR12MB5060:EE_ X-MS-Office365-Filtering-Correlation-Id: 32f28ec9-575f-49c8-53c9-08db997504f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KUVDtO+5RDVSo/qMJM343/EkMPx5Nu9WHLgH26saAnbjQ6PEpW6R/BwhnrFU+3vyOuvJDnVB48Kr/iJp3bgfAAwFVoICLkdkmT5maih3D0IjYDW39x4PPXI4CVhC0KkeyIAyQCxf6ZRyLCYz2MqPP1nXDs04NdWEB25qBYSeWUNVSGA6hYvuMOV4D9DCaTuweFEqCvsN1ZTb3tnLFYZ/zp85402Las8nRh6G4mgZ1arMH0Bj7223/zLF2Uou9IQsL3sZdfRhTVPblAXtmirMwn9orY5lLcO8/yXRwf/ETTC4Z/9jKPYoIVhLpTiXUmTYAdgd6ZCtM0HgX91UOosbi0OUmVctQcM6DZGWSj3WD8YIaXotBD/fmRzREGy1PmRGbSDAOtTLJpGrJjMwpQztQ4YLGFC+6CK09vOGLg2f05NBVEojdzHRTXTckN/5y3iwjpLWntP7VP3VtMbiEZY9VCy4LXs83hV1AxnxSs6TjhJy1mzkqFq9c8fZb8AMIdiOHanLqcKluS0pN1bvRzWh4mKiLoyrFrmkIXTFUXKXrJCXoS6enlc/0UfiABVcDFPVjAhV9xkPAchsX9EpjFOhz+xvVxNevq7wezM9CMOGd234L3ggpfBtFrIVIE8eXUKn+IpTDLHTESST1S4K7R2Vz8fSaofsoi+5ly+LAxBXS83klc201HoAEB4GHNSKcW21Cw/xEMLZ3LGoQgces0nXa0Z8d1S5I0LuMK8ReMovYSphFhhZbYKkHwPS0/fTQb9RyOmlUVvyhWz4aNhWCZc+kLdmK6rDKkPbEslH/EKTLWYsbU+4oUEYPfht3R5/a+Gpgg404o9TI2Kkbbcg4Ppwsw== 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)(346002)(136003)(396003)(376002)(186006)(451199021)(1800799006)(82310400008)(36840700001)(40470700004)(46966006)(44832011)(2906002)(426003)(2616005)(110136005)(54906003)(7696005)(83380400001)(5660300002)(16526019)(7416002)(47076005)(36860700001)(86362001)(40460700003)(8936002)(8676002)(336012)(26005)(1076003)(41300700001)(316002)(478600001)(36756003)(4326008)(70206006)(70586007)(40480700001)(82740400003)(921005)(356005)(81166007)(36900700001)(2101003)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:40:07.5060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32f28ec9-575f-49c8-53c9-08db997504f5 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: MWH0EPF000971E2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5060 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 7c7d03aa9d06..f50508e295db 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 Thu Aug 10 07:37:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712704 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 D1307C41513 for ; Thu, 10 Aug 2023 07:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjHJHkQ (ORCPT ); Thu, 10 Aug 2023 03:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233904AbjHJHkP (ORCPT ); Thu, 10 Aug 2023 03:40:15 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53BF71BCF; Thu, 10 Aug 2023 00:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lLZSPCqxDjEk+QD4lXDOdMiXCLMhUX2FFgJfmfCpGYfeZxV6fgBKtuU7GsRp/i/oTRDhldtAo5RAyvnSxdIhJahNzskYsna0AxBquoKZlLSWFAwrJiaXxa3im8Vp5yDoOA5X6K1ED1BbG6VW2+HDXkrnwiY/04WlKiW8M1jhdVhA9lnotWApVzn4r0SfV+9wHsYMKfMANXvSjb8Bg2s9fWbkAmv1Z+sDINZZBAv3Lp8khTcLIrniP3BA4+AFF1Xlc9j3832wEfGcn4h1p2c+7hNiT9tj4vUZq4llUwetoGA1VjLd59pZIXuYy4OM28JEFtvpQIuKpEx90yu6kkswqA== 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=Q5LG80jWP0p8zL8areOorSlwoEVqVFSCwvMCtSNmvkE=; b=XwcgDUJum015kwt7JAYxAW2LnuBCQ3UFxOisUjCqt4FdVpb4tG3Fl7mrZ9i1zla8OU4GVpHz3QlHNSP3zUTv81XgO3Tpi7FjgkCkxUvarGaz+rrWJqv/xDXUXYQ29jjI+hn1+DGvOjhWXRBVcSzOIlcX/2B5vdMyin6296pw88/bFE7zAPXJ04uTJPjnH+rWpbXhpoG9bhWihP5kJd4gXKfJsznX+FPV8fvyP9zedLhi00JNHcOo4vwjmx84udQYYsn6yTuMdxITgklC37anNw7k9l1jXadEM9EbY7Tah3wUYI5iaotphnCy+Q2QxeziPZoQRed4Wj0F2Y0Q4yMtVQ== 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=Q5LG80jWP0p8zL8areOorSlwoEVqVFSCwvMCtSNmvkE=; b=V4qLd1PbBfvP4HXBWJ63o6p+fBHMwJ9xsu2sMA6GyWi5bHWWePbU6/uGOLKTax5IBIv2jbXt9g9SxVOPIUIpwoCqjo2M3giyOEjRJlbXMD5xPDNv/J3EAYnisA/gxz0EXLAhBbcJE/sD9VHpRjsiVOuupWdv0lmlPumvhoenrHY= Received: from MW4P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::15) by SJ1PR12MB6315.namprd12.prod.outlook.com (2603:10b6:a03:456::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:40:11 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::a4) by MW4P220CA0010.outlook.office365.com (2603:10b6:303:115::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28 via Frontend Transport; Thu, 10 Aug 2023 07:40:11 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 07:40:11 +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.27; Thu, 10 Aug 2023 02:40:02 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 4/9] wifi: mac80211: Add support for WBRF features Date: Thu, 10 Aug 2023 15:37:58 +0800 Message-ID: <20230810073803.1643451-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E8:EE_|SJ1PR12MB6315:EE_ X-MS-Office365-Filtering-Correlation-Id: 735a28d7-2d3e-4aae-f13c-08db9975073e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bwksnDjOAwaHxInq96oTlBdL+c/uznvBrCkiznZJ2hNI+pR0rKVbFf+jPdnW5/+N80t62wAB/LHsRZAkQSt4lLws/L/WekLS3RmRs1Qlb9i4HaUIilX5D2D3L2YsWJeE1pwMGKHRB1HTNodt+H10STWRwyO0s5sPAl6pk3r8cpBbEFrX9+GEjA6WJQGzbZGJVLq1jwIb2OWKnCNtosFXYr7OTXmJKczSj3JvotnfWxv7k8p3Rvjn441MZDQD1D9v5DIL2paP2C6SHRHQJH7EcAhJHdclZwcFmcKgAsFMzv62l3GoNsNo2cXFEe378tcezL8YhOc4vrIEtYs6xhSjbnDI0/qQv4w5lRihFY0NXnVH0F1KATgWrXQo2xi+yGkRCp1X/5N3qGBKmCjt0jHJAS52uUmXw7zmKJTxqKWRDCUseZem9ayE+lwYNRLqYcIZ7TDxseRvXsetgSPlf70FDatdSzN1pmfPJtXWv0xbycOX8IupquhQcF78miI1lxpLpLhwRmQjWGivRL0dUrdy1LSJbLHuVIX42zGTYV9z9zmOCC8BcsK6BL4j1kln4VcLuITaujyMxCxaY5ys9NCfAd1jO/WixZ47Z/ASDOtl/3jaZ8bHtdBsEMuodDiIbQvkSM3N7eOJzwxjBf8rBG1foUl7Z8mTFel/lThPHtu+mMMg9Xl9cjZbK6LihlRduTGH1zkKQ3M4aUXCyoaXMkAicOMmRLIQR9zSSxZpnp5IPh0oKHZ9vfqoQ2MZ9toSGfgYCXMQqDXghs2YrdOQ8VAzrUrPaksHvnDl0JvPSWOyJ43Zx5+bxnpRVNhqx86v34SdLxXcLg75CiNyVOdNYwfRhA== 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)(376002)(346002)(136003)(39860400002)(186006)(82310400008)(1800799006)(451199021)(40470700004)(46966006)(36840700001)(426003)(40460700003)(1076003)(26005)(82740400003)(83380400001)(2906002)(36756003)(336012)(356005)(921005)(81166007)(16526019)(110136005)(40480700001)(54906003)(2616005)(36860700001)(7416002)(44832011)(6666004)(7696005)(5660300002)(316002)(478600001)(41300700001)(8676002)(8936002)(86362001)(4326008)(70586007)(70206006)(47076005)(36900700001)(83996005)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:40:11.3283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 735a28d7-2d3e-4aae-f13c-08db9975073e 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6315 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org To support the WBRF mechanism, Wifi adapters utilized in the system must register the frequencies in use(or unregister those frequencies no longer used) via the dedicated 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 | 9 ++++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 103 +++++++++++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 4b998090898e..f995d06da87f 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -4335,6 +4335,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..d46c36f55fd3 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-y += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 68952752b599..458469c224ae 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 91633a0b723e..719f2c892132 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1600,6 +1600,8 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + + bool wbrf_supported; }; static inline struct ieee80211_sub_if_data * @@ -2638,4 +2640,11 @@ 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); + +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); + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 24315d7b3126..b20bdaac84db 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1396,6 +1396,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 Thu Aug 10 07:37:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712394 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 9E802C001DE for ; Thu, 10 Aug 2023 07:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjHJHkf (ORCPT ); Thu, 10 Aug 2023 03:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233959AbjHJHka (ORCPT ); Thu, 10 Aug 2023 03:40:30 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2078.outbound.protection.outlook.com [40.107.220.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6966A26BC; Thu, 10 Aug 2023 00:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4vnb0fdXjpxS7Qf/amz0SxZk4srAErUFvCEECzNeftAnNMBtRnVofW2tD4/2+6DjjIGK98/vIr3Z1VXPL7EcYVIQcvZpkTx0CLCoZpln8HrZmXPYJs2Tfw+7vkE9SbA+Re35psZIj35OUkD7KQTPCe63ut4w0H6mOL2QbUNId4IkzBWdq4gysYkqFuIKpz013YX5EnoyM61AWSmLmddr+k/G3vPoj/9mNmffaOUiVhUkSP+/s2d957I+v4finTUH+NYnjcqlmNPeSZNs92IrGfIh+dZs9T1oP53Fv/XdOBYdebCbqO8HUsF2O4jCt1ZD9r6FptgWUAKTRe1b0ydVg== 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=8KVZcsU5wLNmNsZV2fXC998Zi1YeRhJaLYvlo00xQX4=; b=gayIus3aHUEOxh9cWZT85mfun0fMP/unDrpc8FeV8Y6mBlblA/EoRwraiPauUbx/8MoI/+o9YdZxVVdzyl3OdIq8k/REfKDCP5AwMdxltBoQaxE79e9MS2jfvEvVy4lnUjjxVlvuxu9fLSkYCrn9FukF2lrX4XIthxZ5W6bRN6A7DICSHXq2SJP/v270N9fPCoYMu7Kn78ZdG2Wxac7RYZ3USMPvZZqJKKuAjopnoCABHWD6+rNzPpFfZb26EWyM67S1BwO8f0oiOOPYc4MAR9ZBh2UwG4+Pn05RsQEUSEQiA3VOL11VER6BcoGsMzYVonWXJZYXsEx0CLz0NhAWJQ== 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=8KVZcsU5wLNmNsZV2fXC998Zi1YeRhJaLYvlo00xQX4=; b=zvri3StkT/sJOZsgFlTjoBL67EqMlMLwP1LO+I4sq30ZPO2wiHIG0ZwyWPTnGLPmvboFY1RRcB9XiN3TdFm1yxOPmh6IbEJYUta09Z/J7hYQzddX8ilWafOPtqio+briwJhzVoVuRrvVxIOhLGpbSUUj30bl1AaEgAC4acwXDeY= Received: from MW4P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::16) by PH8PR12MB6673.namprd12.prod.outlook.com (2603:10b6:510:1c0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28; Thu, 10 Aug 2023 07:40:21 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::9a) by MW4P220CA0011.outlook.office365.com (2603:10b6:303:115::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28 via Frontend Transport; Thu, 10 Aug 2023 07:40:21 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 07:40:21 +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.27; Thu, 10 Aug 2023 02:40:11 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 5/9] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Thu, 10 Aug 2023 15:37:59 +0800 Message-ID: <20230810073803.1643451-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E8:EE_|PH8PR12MB6673:EE_ X-MS-Office365-Filtering-Correlation-Id: b5feb5f2-f65c-4ffc-d489-08db99750d15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PBCpXufreKHvnw3zfSJjxCA+OkQnz0OqWhmpr0+u1NsdDOlp1o2vGiqrmakjBkn27upAgM78GM4soXkSM9HG+1jALdZgX06Yav6OsqFQA9XD56A68sKrHPvE2158p+lhHyDMqoPbRaGUofU+9tKdhL1UZ3JnT10affX99ow32rBF1vahTjwouyqULGPtNXeHQNfKPXmP/eA5pFcYfxl8FozBD12n5i6AS/joN2MuzGJcHu72u0EQFGMgQ1RCOjt0e3K1GsJYpwPk7swCDAfnXHNyNXOuyxGHITGmIXPRFW5Tw1d2ksfymHBidKOO+OddSjr2F7aEpPjbiT3UpyHAiNWTxko1LSY743ML8auzkTaBYjl52UmgpCQVHqMh71WSaERX/i9pNDzjxCn6ssq33Z+bCMoBGtrVOPBvm8dfaU554z26t7zKL9owLG+Q0RKnN3zdT5jGT2+MYDOyzW1xUY4BwIpO3deKCmeffdZMKg7NwekrXFIBP79Z3ZUY/5+EGrm5MXQgBwxe/ftfJcx5WX7KcpH/LF0HGPcanzmwhQOb7XNTiCEGQielUIotvCEa/Me2m3WC49MC/vMNjhzXX8D7pZQwM6TRDb2AXEsVfF/gET3WDAc+CvWdFkMdRXxymLaIuOLW4c3VlzK8YAnV70K8zz/GoX6xULQvetZoaVMU5usMWf32vkpiurSjBDuhd5Lntfs/S4RF+DPKUgD5GS2U8fTshQaqnFeFfRHR8eHDLDdiTdYcJkZJbuSHUzG6F10ZFI9hyUftd3qBGFPtBa5KYlNYcn/ZfEk7dF/MjDT/uy7zWL7NJHiyMVHYueg4swKXu0U+egwyzyU79kw5kA== 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)(39860400002)(346002)(136003)(376002)(1800799006)(82310400008)(186006)(451199021)(40470700004)(36840700001)(46966006)(4326008)(8676002)(8936002)(70586007)(15650500001)(6666004)(316002)(70206006)(5660300002)(2906002)(41300700001)(44832011)(7416002)(110136005)(40460700003)(82740400003)(478600001)(54906003)(40480700001)(1076003)(36756003)(7696005)(336012)(426003)(2616005)(36860700001)(83380400001)(47076005)(26005)(86362001)(921005)(81166007)(356005)(16526019)(36900700001)(83996005)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:40:21.1252 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5feb5f2-f65c-4ffc-d489-08db99750d15 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6673 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 9dd1ed5b8940..e481407b6584 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 @@ -391,6 +391,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, @@ -1615,7 +1626,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 62b7c0daff68..1530ca002c6c 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, @@ -1605,7 +1616,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 Thu Aug 10 07:38:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712703 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 EA59FC001DB for ; Thu, 10 Aug 2023 07:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbjHJHlw (ORCPT ); Thu, 10 Aug 2023 03:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbjHJHls (ORCPT ); Thu, 10 Aug 2023 03:41:48 -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 9510810FF; Thu, 10 Aug 2023 00:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XY0ZRJkwGPUz8gnWLkpoHmYzep7Rzj2nHD+ijKE0FuffQ3jUbUX35l2UuwBwBGHruGYw32NzREhWgKfPAImRPfEdnGvYpNUMv186a8nqMg/Ub5u0mNCotp7yysk5xyqS6bxHTTjCeaAZoZDf4MteFL+odLDRq/TUey3L2Yz33ctd/AoaY1Yk31YxHjevgTbXBgIQWAXwrGL3P8byOy6UtpLM6K9+IbkM+G+qYtZDXxRefcKbrYqgB/mmAkjSvW5UXUmc4jrnU2V5G9LcuEUw5A0Zy8YkJDj9rIHZXipb61Kt5OyCGIxbe+NxLyer0Wmmnndd9ulTf3Pf/w+VEkINlA== 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=ICfFFCripL2P4ocC0bWkvw3oRf/7mOzyprGso847CcI=; b=C81a/DM26WMN+wz9lik08J9gK1NuXWAU2avpBVVTF+cgYdsSVgqugLyTA1smKxQK07v9lPqFDu7UdTmlBl/v6MQuqMeWFS37Z3An1PmJbUMcv9JklfsrlgwgzDXrKQB8dqHL2rM7NUMip8CXNfcc937+G1HwggufKVB0yyYNGtgLTu9RkG4oxluUepSJ+i5n8FxMgaYGZ84QlyRi4yUvjmjdKhAT7k83JFndP42Ea551K++ffKQsZGLR0bWpLyVeNM30SyOzAgi/WLqxwF4fvBSs9N6/9q62jmlpbWnzTMpuH9G5YxN/bWvvHolyH6RyiAVFZjsra2WMhtOMQYaXDg== 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=ICfFFCripL2P4ocC0bWkvw3oRf/7mOzyprGso847CcI=; b=QMs6GZW9mIsmNh4tAwYm0npMWnMwY7Xe5z+O0iGH9xPBwmwhQmwV9L2mqaqeAbYPcNptlo/UF1KnFVdd8Ph9+7N01qu+bDNejLCsnLlffbZ8OeoYTmWQL9q1qNON8lCGTEVQnJ/K05GRz8WjJ4cs5oi/13lSIp026o04li0fsUQ= Received: from CY5PR13CA0034.namprd13.prod.outlook.com (2603:10b6:930:11::19) by LV2PR12MB5967.namprd12.prod.outlook.com (2603:10b6:408:170::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:41:37 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:930:11:cafe::97) by CY5PR13CA0034.outlook.office365.com (2603:10b6:930:11::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.18 via Frontend Transport; Thu, 10 Aug 2023 07:41:37 +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 CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Thu, 10 Aug 2023 07:41:36 +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.27; Thu, 10 Aug 2023 02:40:20 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 6/9] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Thu, 10 Aug 2023 15:38:00 +0800 Message-ID: <20230810073803.1643451-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D0:EE_|LV2PR12MB5967:EE_ X-MS-Office365-Filtering-Correlation-Id: c95fb823-bc77-4b40-501e-08db99753a41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bLHUSTo0KOuv7BpLGGBmvjxuSNiNtREtFmRMVJASuHRofiYkORD61UrgydP0Ikl0Im9iOKHpzJW9Wq4S37SP2o3+6h1S7MD4sHTgFFTpiKjyMNaMJavYEhTvKzY3GLJAdNEOTdbe1oC6Vp5917tz46+BDTw4bSnGgxaSeUCnJwMCgdo2kYybXGk8xoTRm29hU/it0A81HaIC9eXL6sTYJ78VGFeFhUmJKqGLWAJlIYTIPkh3NQPk/ofM45tAT/mMPeMU+iG6yj48EvyLLiXSHU2b0GO+i6fFi+OMdPr6t+U5G0XauvkFGyurpsNJcFoCXafokllWi6fSHThloqWbp1CFRWuIh+tnwKMidbLvri1sTwHFLWOT6oJ3Ul3otvxwPmjGywjEcCE34uldftvfF8FI0wNRJJR3abPtqQfC7SrddgoR+Hw2FnCza9OukCu/UCOpOvC7nXIgm6hTi4JjZ5xXS806gw6ZFFXlvVQR5tK728k2BH7D/kNf+BpeTcdhEbh6HoLFCrSukETDoWAZOobqCrO/BM0UsFWpBLpnqkPZzwOx9Kd5qI5sJhwRrBOIVwyxvfqUsqaAtNuD+XlFcO13zvGaf5PMXuj9n5pwUMT/KKgfy5KK517yFCAeDPRL/M3NwLM+emT0TBMiL524VM1w0gTprSg2BlUcPvKhUECoE7SZh/tkF1cVZnG2y5K2bJ57OoNTYRoEeb/LBr3yeIQunBYmHbyLMPlXKvgC5d/M+eObeEBhKxV8sqaar7eJfVguvUSqU1hiZAGiVzwjsx1WdE85d3mZ+qSHF5QPiVrckhwrzW5DbQncaB3Q4b8GTSVYdszKrrn0tPK6EkQaNkjLZMwthR2m/GW8sMzBLVorAlkEF+XTPdGG3O4xxyoD 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)(396003)(376002)(136003)(39860400002)(82310400008)(451199021)(1800799006)(186006)(40470700004)(46966006)(36840700001)(36756003)(36860700001)(6666004)(478600001)(110136005)(70586007)(70206006)(16526019)(26005)(1076003)(336012)(54906003)(7696005)(4326008)(316002)(2906002)(7416002)(41300700001)(44832011)(8676002)(921005)(5660300002)(82740400003)(356005)(81166007)(30864003)(86362001)(8936002)(83380400001)(2616005)(426003)(47076005)(40480700001)(40460700003)(36900700001)(2101003)(83996005)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:41:36.9389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c95fb823-bc77-4b40-501e-08db99753a41 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: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5967 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 | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 17 ++ 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, 239 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index a3b86b86dc47..2bfc9111ab00 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -247,6 +247,8 @@ extern int amdgpu_sg_display; extern int amdgpu_user_partt_mode; +extern int amdgpu_wbrf; + #define AMDGPU_VM_MAX_NUM_CTX 4096 #define AMDGPU_SG_THRESHOLD (256*1024*1024) #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 0593ef8fe0a6..1c574bd3b60d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -195,6 +195,7 @@ int amdgpu_use_xgmi_p2p = 1; int amdgpu_vcnfw_log; int amdgpu_sg_display = -1; /* auto */ int amdgpu_user_partt_mode = AMDGPU_AUTO_COMPUTE_PARTITION_MODE; +int amdgpu_wbrf = -1; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); @@ -981,6 +982,22 @@ module_param_named(user_partt_mode, amdgpu_user_partt_mode, uint, 0444); module_param(enforce_isolation, bool, 0444); MODULE_PARM_DESC(enforce_isolation, "enforce process isolation between graphics and compute . enforce_isolation = on"); +/** + * 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); + /* 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 ce41a8309582..163037bd6d16 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1228,6 +1228,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; @@ -1320,6 +1487,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. @@ -1416,6 +1592,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; } @@ -1471,6 +1656,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) @@ -1623,6 +1815,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 6e2069dcb6b9..244297979f92 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" @@ -575,6 +577,10 @@ struct smu_context u32 debug_resp_reg; struct delayed_work swctf_delayed_work; + + /* data structures for wbrf feature support */ + bool wbrf_supported; + struct notifier_block wbrf_notifier; }; struct i2c_adapter; @@ -1356,6 +1362,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 Thu Aug 10 07:38:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712393 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 318FDC41513 for ; Thu, 10 Aug 2023 07:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbjHJHmA (ORCPT ); Thu, 10 Aug 2023 03:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbjHJHlw (ORCPT ); Thu, 10 Aug 2023 03:41:52 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8240269D; Thu, 10 Aug 2023 00:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FwRBai9A/XZwSRmHBqCfMW2bHShikRgs0/aMcRwPQ5AFBHzxknh/6D6HQ50Zey9gmaCZ9+D09EHTeoAna9iFIg6TZjb6extzxKGWr8vncQ1IAT9zqTBczXv4Lq4yMKvfAQ7ANf5b7YYdj9sgOvVMGX0sn0ps2WPZQJblkKzdG9OwB3RuYmU5GBzzfIiDRoyAyFgm4jaiR8DtbivbJxQiD3zv77lrdJJRn92EA3C58cmHAZSLIM6QS+uAi9/Juir1hV/69pMNWG3xDLjKBfisCbpPlK7nze/+qbXmsv7vnAJlxLPkM5PHYPu1GTw7Ycp5p1wZ8l2bIp36SHKawTB2+w== 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=XSR6QCoMxbBXa8p/1+youpYsXRQcxwhwWUT8fxMX9yU=; b=IDY25WF/Z1j3AfplSTioXe/AkW7FbHkIt4egpBOpPurSyGpi02kHVatetr+2IJnO5QKIOKlUvH9GyXprwjSy1sEeZFFbChQNrCEAeDZzHsk0tUCzEKR1mr0KCMHgrzr+OOi5oibAGBmEMKC+l68tndKiNi7Z4b7RkMvw0sCPfKahms1H2617FTfdWJrxoOThOMZzPKjzTsGKEhC/GBi6yLJMhmV5uGc6aWj/FvGNketDF+zOnxo64feskQj/1mZWJ0cthud46iWMDx42BkCwRf30sjixNjelFnlozWBAkhV7AuNOS7CxXRVv7KLPogJzVC6wBk/790rm3oQLnLZtxQ== 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=XSR6QCoMxbBXa8p/1+youpYsXRQcxwhwWUT8fxMX9yU=; b=xu8akgUysbGFd+H5V3Z/SPINgLXt1WZURETe63ZEDAbkJ5cBvfIZELiR9FAxYdEvJvebAuMsGM/BkckvdpY4VnpBGE7cnLClZ1p18s7QBzrOXw5Y4Z75wfm5Hx147RG+qUwc6jXjtD3CRvpB5KjCjbuNNj3ffaz6OADtUxOTuVM= Received: from CY5PR15CA0217.namprd15.prod.outlook.com (2603:10b6:930:88::6) by MW3PR12MB4444.namprd12.prod.outlook.com (2603:10b6:303:5c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:41:43 +0000 Received: from CY4PEPF0000E9D3.namprd03.prod.outlook.com (2603:10b6:930:88:cafe::a1) by CY5PR15CA0217.outlook.office365.com (2603:10b6:930:88::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 07:41:43 +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 CY4PEPF0000E9D3.mail.protection.outlook.com (10.167.241.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Thu, 10 Aug 2023 07:41: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.27; Thu, 10 Aug 2023 02:41:17 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 7/9] drm/amd/pm: add flood detection for wbrf events Date: Thu, 10 Aug 2023 15:38:01 +0800 Message-ID: <20230810073803.1643451-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D3:EE_|MW3PR12MB4444:EE_ X-MS-Office365-Filtering-Correlation-Id: c79b746d-3434-4faa-b682-08db99753dd0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Zh5QNK2bGGP23L9wenkueGOJDPQBUQ0Qmkbv6ouTKUKQsxqSSa95q7SOViGO8yOEb6VZWJV3Z/F5Ay1/KfhOeHczewvcrEPmXMSvA39vQ8J1w+sdJElN3aJ8qn0GSigqHZPdoQ81haPP1iZmYt/HCzmy4Z5jx0wCH24F2bWwqKv+PrG3p2tufJv2OxPn95nXXKuyh5JWwy4uQzjdBKxj+2pImbT3shUTSuNWrq/pcbSiD0HmJamAOL40oOrSFoQ7Odq8Bt9l+8RYmGolGydyU77u3ffv1wlbx3M51IA0ycUoKLGKkq3Dtlo/Kl9drViox+cjNK6ed6qpR7koAaE779SAHLhBNGJyeyVZ8Fsv6vxMIsN3/7fFhf1WAqEMarbipmY3POxgEGY+t5NJQ+q7qccyiC2s984EyeSflFnon4oHaPIYubsjvFsCOpEHEpZVe/jFAzavjw2xaow8ljLU1VLPyCVevPtp8JSmXW+nNxpess5uu64Gem2XgTP0JNz2r/ttNZQVEbGGORhni4BqAWV1QwNe+WTDKynrzyMwxUGev8shlh7fGlUDy5wiYVP+RLtWnho+tzWP6F5D1u4KxZIvXYkhA0gdPhmJsQSpgUXVpRMgjtwL0fycAW/Cor+HhpuZh9B8Xx7ORFPgzPy4pWzs1DW8tchIFridKzTyK993p+p59khIh2VN7fJcktxutOZXWxcEN+n3GgrpdvrngNXaWaws8Swjw0zF7x18RwDlQJ1IWVZdLM30IFUxYR5kH1kA08PVb4xY/Sy+Vd3wembZ0pJy7oBp4+I8TXvjA2VfbCfkSf1uHSU3TLii4gQR81mcwv/LROwX+916RneRg== 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)(136003)(376002)(39860400002)(346002)(186006)(82310400008)(451199021)(1800799006)(46966006)(40470700004)(36840700001)(6666004)(83380400001)(356005)(2616005)(40480700001)(81166007)(47076005)(40460700003)(2906002)(82740400003)(426003)(921005)(478600001)(41300700001)(26005)(1076003)(316002)(16526019)(336012)(36756003)(70206006)(70586007)(36860700001)(4326008)(110136005)(54906003)(44832011)(7416002)(7696005)(86362001)(8936002)(5660300002)(8676002)(36900700001)(2101003)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:41:42.9275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c79b746d-3434-4faa-b682-08db99753dd0 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: CY4PEPF0000E9D3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4444 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 163037bd6d16..aa5e1123ac0a 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1318,7 +1318,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; @@ -1327,6 +1328,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 * @@ -1357,12 +1373,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) @@ -1373,11 +1391,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; } /** @@ -1393,6 +1410,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 244297979f92..4d5cb1b511e5 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; @@ -581,6 +587,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 Thu Aug 10 07:38:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712702 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 4FB20C001DE for ; Thu, 10 Aug 2023 07:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233175AbjHJHmB (ORCPT ); Thu, 10 Aug 2023 03:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbjHJHlz (ORCPT ); Thu, 10 Aug 2023 03:41:55 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2086.outbound.protection.outlook.com [40.107.94.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1806211E; Thu, 10 Aug 2023 00:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wx+lLO2vbXSuwP4IvAINuB1R0hcUM/qbiwKsrMG1Ijp3ffopJaeCCl9OSm62/BrONAzFDOKH9dO+LH1PM5WHtiUShVs1tAmMfqd7q0ZGxzXLEaV77MiJmyiT17goeT1OpLoKk0eXhTpZc4qpYnuurQH3txoyl1kf25VmoDt3NiD4TAsF6QFQ+4KC55trWt2tO7I2ZxbHETK256+FcdKy/gukLUF+EuKqF28e8eW1V4uycO4uFIqB4U3UJMHta4cKsJt8qIuXY5sjFaeyEheVoDxBecTeVYKfkPj3QYTQAHLUHR1TiVYaqPBUxO9M5YmqSkcqVXglH9HMVg4Aukxeaw== 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=DHKsK4YsLasPeX8ksJhIhjxXAD5r4x8f4RHwbLwU9BI=; b=l57k8/9UzWOyXl//h/ILr5TwRlO0dCFJ0uh4VQd++7TLCPhPMt9p2cIl30VGiLrItl37gqjB6kgzRyxk6g2BU0l4RiUyl+AvdrLWzAyIKPzwlgaYkRkh5CwyUW/+jMtLadd7QF5DUFfYiAeS6IA6qULod2ka/+2OScvcqe4D9fvM5Y8AwR1WBA0ZD9eRzvBIwu5v8wyCoL2Arl05xdeWw3/StJFr2ZltDfuGwLMc5FHOnaLrmkzGzd7Z8G5ncBNqTHkIhvu+/s0feZqSaAh3duOt2BAkeMuMPC41OZ0wf1grBV3YfJFMtAtsc4Y356cbmV0sA5EBvN+rCzh+39BorQ== 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=DHKsK4YsLasPeX8ksJhIhjxXAD5r4x8f4RHwbLwU9BI=; b=NYHv8NJwL12W76I+xZ32CQcUQOrTcI8tr7HQTXGVR4q29cgeSNU+NjdOSCNRKl+HUE/PB4Zz3WQ4xRrV4hXyMfBZsicsTX9OlCPgfP48TJ1qFGcf2Ih26SS47nkSCdvEKWQo7lJ3yCmwiZpdU4BC2i8t4ylN84Q2vsxSM4hnUMk= Received: from CY5PR13CA0039.namprd13.prod.outlook.com (2603:10b6:930:11::25) by DS0PR12MB8219.namprd12.prod.outlook.com (2603:10b6:8:de::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:41:51 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:930:11:cafe::21) by CY5PR13CA0039.outlook.office365.com (2603:10b6:930:11::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.7 via Frontend Transport; Thu, 10 Aug 2023 07:41:51 +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 CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Thu, 10 Aug 2023 07:41:51 +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.27; Thu, 10 Aug 2023 02:41:42 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 8/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Thu, 10 Aug 2023 15:38:02 +0800 Message-ID: <20230810073803.1643451-9-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D0:EE_|DS0PR12MB8219:EE_ X-MS-Office365-Filtering-Correlation-Id: 2171d866-ef8a-4bc0-281e-08db997542d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: db3BCAexxqHe/hwrsX7IhIl1K5Dgjv51No32EUevrlojPGqDlecMOTLPVJcu21qhNYoVF3XyrUPmOnuDktaW2R+nZRHcUXovFZqEbFvlFZmQDFWgY5xCl8l6Gh0zC+bqhnUkV8CjjpggG+e3rd4Y961UaktRN5XnyJl4S4X35C5qXT/Bkl/MuIOGxq46YLvrF/gYi/fKFCcyXnopOL+/IdsiE/4akzsy6zg79VIfuBfS1cJa3jd8BFE7OI4ZT7BnRiWaDwOhla4bxW7BDVelSuuXzIQfnwNf8cUfKSUL8qeyWLmeJxKm8WcnIjsVg3XJ2UsuSce1CRrh3PttM3Q04+2x2HfguZ6l2Xs7xweq+SNrI2/8dZNFbbXcABYmKakOImNq3kylkgBZ3RcjT3FYDwzt1/u3GCXwaQPHHMAGDd3o4yr8TwAxXLYOWEyT9/sWWAmm9eJonJ4ulfJVYLP2G0fSVLJ3qm1Mk9K1nOS/T56T8ELQx3kVkqpH4Kcu3CAC6VyGwn7RuBeAjSKzVuxP1KkrNj4tRZHDpix/iww2h7xagyx46tqWu9tR98j0AP+kS/IKW1CxtQxLEGX49Jw8H79GBdlrhwCh7pfcvpvQbIHsHPFy5i5DupiB02wpuEwZIFVMjsofYrG9YUp0iIfn5Trt0vdZxH5YPyWPIe27wEpvjFf3KGBVWXT8XbOEWOsnzPy1b3UZb0NPsgv4CAwnnhZgSnMI2XKC7i78GNDO85rNbKXVDK+0mBZIvVV4EBQfGH9kSnEfmGJK6mk6umAgaMzIbnDVIU3zKFixQUvZ8lTJgHgB7gEmHEcjofxkn85C3ReBFQ6elLSvsLD5+W4T5A== 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)(376002)(396003)(136003)(451199021)(1800799006)(82310400008)(186006)(46966006)(36840700001)(40470700004)(5660300002)(47076005)(70206006)(36860700001)(7416002)(70586007)(44832011)(110136005)(54906003)(4326008)(83380400001)(478600001)(86362001)(41300700001)(8676002)(8936002)(316002)(2906002)(40460700003)(81166007)(82740400003)(426003)(2616005)(921005)(356005)(7696005)(6666004)(16526019)(40480700001)(36756003)(26005)(1076003)(336012)(2101003)(36900700001)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:41:51.3296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2171d866-ef8a-4bc0-281e-08db997542d5 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: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8219 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 4d5cb1b511e5..54e76d6e66ce 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, }; @@ -1501,6 +1502,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 355c156d871a..dd70b56aa71e 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 @@ -299,5 +299,8 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu, uint32_t pcie_gen_cap, uint32_t pcie_width_cap); +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 9b62b45ebb7f..6a5cb582aa92 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 @@ -2472,3 +2472,12 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu, return 0; } + +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 3d188616ba24..fd3ac18653ed 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 @@ -154,6 +154,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] = { @@ -237,6 +238,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = { TAB_MAP(I2C_COMMANDS), TAB_MAP(ECCINFO), TAB_MAP(OVERDRIVE), + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_0_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -481,6 +483,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) @@ -2593,6 +2598,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, @@ -2672,6 +2729,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 Thu Aug 10 07:38:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 712392 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 8C556C001DE for ; Thu, 10 Aug 2023 07:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233956AbjHJHmW (ORCPT ); Thu, 10 Aug 2023 03:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233950AbjHJHmE (ORCPT ); Thu, 10 Aug 2023 03:42:04 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67C32133; Thu, 10 Aug 2023 00:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CWnUsdMYlzT+BLhd9hshsKxjS6QZ7L1cSrFd5kwD28LvXMcTLNuTJ1i8VL8vRkjkQZZQphtS+W+AgyVwS/hj1BeU9CkZ0onETDTwhL9wtGalAWg12xz60DjfZhfUlffYnJO3KAGADgajtztts9jlf9oqh7Ok4MyawgvtxgkQZLKtyjT9GX78ekHo/8/9ZSqcSX6oP+s3X+8Us3Sy96pAp7ct59iWibW61KdkLshdhhAfz4oDsly9h8BMmuRksLoP9qoW4zJEAfRseZ6QrRM/QSrsqYzE6zryL0mWZxGqbK+VnVii4npsmrmrKkPM5v+JPS1w7nVOYog6fr/JsDMwZg== 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=oBMyP5sjBldwqJ3K6uKO9aVAXKYlirNWck9M6BuMFVM=; b=NIdPwMPCnTULVR3KLOkeafZ7axdU8t9i6YArgVguBYEaH6TmMz9kS9RkyHAYh+p7+JC8ZJzBsbJxBkWIAbiiNqsr+W4BbfPwyQoSQ6GUxRE1vsWWJxCM7bRAkSOkQ6+DeUHXmyAkH4Grg/YxZDVk7STclejMiR86wfL3AzG68VXX9zKC2MqEcd7W0mHMyfsTDmj16zt0aTgkO6Z4nqpdq5OqMtwXieiXLg+Zvnz3jLabGIEvpXCyVfyVYj/Olvi9WwJUKVb/SX+IVgH6ZAYdVYzfOQ3YMlKTn2tZ9PPkWgxe7dHgyC2qU9urLl9To/iWuZtVNr8kcbeUKNYcPgg+yA== 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=oBMyP5sjBldwqJ3K6uKO9aVAXKYlirNWck9M6BuMFVM=; b=zAqJKDQ9IiHRkEX+Cs6pNW/svGZTMpIR76Y1TLbGPzkkogd0JJkoT5PWs+ENbJ3qCFoj8D5abrws9GtO8Y3x6YOBhR3N2qHyK+fmZwq6+DVcREYGjLGStZbCXgNOWm2WFoDeILOMzYBkZbvNEmiPw3ZjZ0K/VcV/hYE/aMhlSfQ= Received: from CY5PR15CA0233.namprd15.prod.outlook.com (2603:10b6:930:88::29) by SN7PR12MB7882.namprd12.prod.outlook.com (2603:10b6:806:348::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28; Thu, 10 Aug 2023 07:42:00 +0000 Received: from CY4PEPF0000E9D3.namprd03.prod.outlook.com (2603:10b6:930:88:cafe::84) by CY5PR15CA0233.outlook.office365.com (2603:10b6:930:88::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 07:41:59 +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 CY4PEPF0000E9D3.mail.protection.outlook.com (10.167.241.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Thu, 10 Aug 2023 07:41:59 +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.27; Thu, 10 Aug 2023 02:41:51 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V8 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Thu, 10 Aug 2023 15:38:03 +0800 Message-ID: <20230810073803.1643451-10-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230810073803.1643451-1-evan.quan@amd.com> References: <20230810073803.1643451-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D3:EE_|SN7PR12MB7882:EE_ X-MS-Office365-Filtering-Correlation-Id: 2645e1bb-d213-46b1-e026-08db997547da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LeRKh9mRJ6CAvSBAx6lPLSKFZDcYzELuoznfWpSoDoQj1MjItEEgn0q9v8ePZPECaigv+QTq+5Xk8720gKXnmIjL5cEL7daeYz5nM/5b+DT/LxwtrTp9YTWQ0vopw8BYXzPfgC8/Qgkuz2MII3N0IFTFksjuE13GxhHsgo4BDad/Va/6mlaHNCyU9SHvRmsTFoOPSRukQOXPqxYi2GZcna882NxY+myac/4bOLazL53UVp7j4v1tFj5LGH1szg3OB+JSN/YPAM2GQhfGhMBIAL6g7iMLcRdlamNKGEdVE7/NFOWSW9D/ympgZjU9+k805wKRVBGeaepRI3PViaQ+eMLjkiFR35sJL5fX/VpJ3etWF5gynSpxhuchXq2SQMtXxoiTI1LCpSvDVaTsUsBzYsE3WPB58isPOhs3aTmPM9FNP6Z41mq2IBTCo1ZAABFcI8k6y/NZ1h+GihpvvPgvIuAHKlJm3m0qtMIugI+eh7pOrlzEdcdEXkENBAmKGRKeSiz2ciwbCueXayMFmIhkJQX1z0NFhEP1XwRQFDOmOd2+P6XvOotoL8KZxwQx/2JLdA7WzPMKhtCI046Jl1siJgEO7cicMsgra/pWUOLf6MBL/3FUKXdLF/lCPiwKEsCA1Pjst998BU38UbxUL6hAr4upgXdCylD9h4XxXPqH4NQe3Dd743kI1DxzzktdFafYJERcVQgLNXlU6mkV/sN6tEm7wbMwTeVTqkBFnnnCHykBCWXVBBsl4sdC6id1HF5pogq2/wW2oIE2iUhrrsbWZGP8IqgHsrm8sd1LZ1nbPan7UUZpTRVmdmqb0RG2WfUS74QM/EYDEEFEYSxemlzGMQ== 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)(346002)(396003)(376002)(136003)(186006)(1800799006)(82310400008)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(40480700001)(1076003)(70206006)(54906003)(16526019)(26005)(336012)(478600001)(6666004)(110136005)(36756003)(70586007)(83380400001)(47076005)(426003)(2616005)(36860700001)(41300700001)(316002)(44832011)(7416002)(7696005)(4326008)(2906002)(86362001)(921005)(81166007)(5660300002)(8936002)(356005)(82740400003)(8676002)(2101003)(36900700001)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:41:59.7557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2645e1bb-d213-46b1-e026-08db997547da 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: CY4PEPF0000E9D3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7882 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 b1f0937ccade..d02fe284b05d 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] = { @@ -207,6 +208,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, TAB_MAP(OVERDRIVE), + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -497,6 +499,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) @@ -2173,6 +2178,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, @@ -2241,6 +2297,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)