From patchwork Thu Aug 31 06:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370972 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1C43C83F10 for ; Thu, 31 Aug 2023 06:21:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0981110E584; Thu, 31 Aug 2023 06:21:17 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2083.outbound.protection.outlook.com [40.107.102.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 596A110E577; Thu, 31 Aug 2023 06:21:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Roip0wpheboTNk7TnNBqOrhbNOlso5SD2LxICT1Iq/S4nCBUMwemZE+npALiwBhLI/R86MHkWDiYvfo2iB8TnP04m9PJaivZuL77WUEOW1JBJ6PT2VfNRQ8uN0fNltDjwTWGN5Sey9166bQrFnye7wZ4B25hZ+FaEaiMWwmtvb+yhoNj42OrtV6g5niCAvy1IMUCfM8ujUTQVsr13+Q8iIcysdd1UAfHXGl534GHNSbe22CY7rYHXZb7HFAVi65h7xyDB/zEzPnKxGPszu/r09J9ZJOb+Bep4h4c8bJO3Pq7EHpfayM3zsPLXgqb9wsPJQgWBTs3PHu8wcln9NP58A== 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=NJ75n/beCEyoC+OCidKcqlhvMPEqIdYYZy8ugTYX8bE=; b=iWdDECGpf0FzVllcyrjtUVLiDtSb5XmHf3HkierhzVINfiKEbLzKNF5WTJ2cY6+cgL4dzGmUojX6gzZlFHPEvbr28Q/LWSd0XY25c1gpecsfHPLcwrQTbt/WPbZ5JkFknOBPm93jBQv7I0YOuZUMCjDB0Tc0s88jZk/tRcpVFGrcG/YBaVCNZyaONUIwV2BtLPR48gqKJXGJPqZQrysCA3u9mpNzEF/88t4P1T9d08PM8gzWZlh+vRipFPibnPer40QQ8ui+xbsWbvIuY3WYCm0gGbuXSdPKyYJfMN4L4IgY59qt1zSacBOPKIaN4edTXfEjbHq/H7TvA6jkM4ohZw== 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=NJ75n/beCEyoC+OCidKcqlhvMPEqIdYYZy8ugTYX8bE=; b=4rUfoMBg/0ne4bdF08Ci5XeenTQVDYnLbhyXun1kpjTBoWPprnlMTrUnBzlmlT4fh4MI0bS4nBWnHFbsfjZ/oq5dtCCxKZZB9w48gF1dk9BmLBeKQ7VcVBd68hXrfbKmMbJ8dfz/EDgQzTkvcMAg0l1KWzVPs3Zf5gr0rapG7RA= Received: from MW2PR2101CA0028.namprd21.prod.outlook.com (2603:10b6:302:1::41) by PH7PR12MB6737.namprd12.prod.outlook.com (2603:10b6:510:1a8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36; Thu, 31 Aug 2023 06:21:09 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:302:1:cafe::a0) by MW2PR2101CA0028.outlook.office365.com (2603:10b6:302:1::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.9 via Frontend Transport; Thu, 31 Aug 2023 06:21:09 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:09 +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, 31 Aug 2023 01:21:01 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 1/8] ACPI: Add support for AMD ACPI based Wifi band RFI mitigation feature Date: Thu, 31 Aug 2023 14:20:24 +0800 Message-ID: <20230831062031.1014799-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044F9:EE_|PH7PR12MB6737:EE_ X-MS-Office365-Filtering-Correlation-Id: bbd772a3-af4a-4e5c-b422-08dba9ea7756 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KFgEbZOJVP62vbuV4/JsNE10KJaQ1G6aAlwY3nEajYSkds0AnqDwp3qavGMuDjVQDiaZacACyUNo+loD1O8Dhue/N+oMIVymA4KzsglanA4tMFK0enawdrQYxQPjzbWDvhw7vwwosDDajAJofZk8SiCob7alhxDmaCsha0q10I2lZ4OkdygzRkbBCvlTL0Ben1JTSiyl+wWISrOceQS1WZoXWNIF1wKtF/GaZmae9xwv0qVKA0i/ffqR8kpdR+DRqJpLMHZU8W15n255Q54M9ZqOKKMqtsCZPTf3l055473xSszTSvBTadP7GQVXqUuQs/FymGdhJfqc9qUfUYfIiApfs1Ak/WKkqVfNu3I3T684zkCjeMMCk9Dz3bxtQGbxFgHWJKbWALX9jyrML7l48YyEfs7khWxooG38vMQbbCmSKkZPLTQ0HSBuooBFFq/xJ1raBpNmd42/CTzmJye4gWcnhysKcin0WBEvYtwZu9AFufOPugqlHCUd1eivJo1tTw6/ohr5173XP605y886R9RFtaD5NcUA9Cx6wLVKZDzZiXyN56Ah2GoErNoWhzS2/u5iG0BeMBJhcpD8JYTYyMpo24t90v8gME0XrCuRi7CMUKkxk6pXE10xl1yjuHcLk/tl2QlhUSkACr8/7bz/qRtI0pDvBnko4x6D9aPASTA0Wtj9y9yO3NZkn8UOFUvDSXitfudUL0VwvzO6RyB3XhGSlQBFLwoIItBLwEhZDTt5e0iV4rvNsBMxlkT/qxZ9A3xQWv6tOfd4gsCgeKQojretEtfzAZM+HIcTXWzsitU= 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:(13230031)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199024)(82310400011)(1800799009)(186009)(46966006)(40470700004)(36840700001)(40460700003)(41300700001)(316002)(6636002)(8676002)(4326008)(7416002)(426003)(336012)(2616005)(2906002)(47076005)(30864003)(86362001)(44832011)(16526019)(5660300002)(83380400001)(36756003)(1076003)(26005)(36860700001)(40480700001)(8936002)(6666004)(82740400003)(921005)(81166007)(356005)(7696005)(54906003)(478600001)(110136005)(70586007)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:09.0950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbd772a3-af4a-4e5c-b422-08dba9ea7756 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6737 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Signed-off-by: Evan Quan --- v10->v11: - fix typo(Simon) --- drivers/acpi/Kconfig | 17 ++ drivers/acpi/Makefile | 2 + drivers/acpi/amd_wbrf.c | 414 ++++++++++++++++++++++++++++++++++ include/linux/acpi_amd_wbrf.h | 140 ++++++++++++ 4 files changed, 573 insertions(+) create mode 100644 drivers/acpi/amd_wbrf.c create mode 100644 include/linux/acpi_amd_wbrf.h diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 00dd309b6682..a092ea72d152 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -594,6 +594,23 @@ config ACPI_PRMT substantially increase computational overhead related to the initialization of some server systems. +config WBRF_AMD_ACPI + bool "ACPI based WBRF mechanism introduced by AMD" + depends on ACPI + default n + help + Wifi band RFI 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. + endif # ACPI config X86_PM_TIMER diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index eaa09bf52f17..a3d2f259d0a5 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -132,3 +132,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..8ee0e2977a30 --- /dev/null +++ b/drivers/acpi/amd_wbrf.c @@ -0,0 +1,414 @@ +// 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 naturally 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 BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); + +static int wbrf_dsm(struct acpi_device *adev, + u8 fn, + union acpi_object *argv4) +{ + 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_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_out *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++; + + /* + * The valid entry counter does not match with this told. + * Something must went wrong. + */ + if (num_of_ranges != in->num_of_ranges) + return -EINVAL; + + /* + * Every input frequency band comes with two end points(start/end) + * and each 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); + + kfree(tmp); + + return ret; +} + +/** + * acpi_amd_wbrf_add_exclusion - broadcast the frequency band the device + * is using + * + * @dev: device pointer + * @in: input structure containing the frequency band the device is using + * + * Broadcast to other consumers the frequency band the device starts + * to use. Underneath the surface the information is cached into an + * internal buffer first. Then a notification is sent to all those + * registered consumers. So then they can retrieve that buffer to + * know the latest active frequency bands. The benefit with such design + * is for those consumers which have not been registered yet, they can + * still have a chance to retrieve such information later. + */ +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in_out *in) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret; + + if (!adev) + return -ENODEV; + + ret = wbrf_record(adev, WBRF_RECORD_ADD, in); + if (ret) + return ret; + + blocking_notifier_call_chain(&wbrf_chain_head, + WBRF_CHANGED, + NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_add_exclusion); + +/** + * acpi_amd_wbrf_remove_exclusion - broadcast the frequency band the device + * is no longer using + * + * @dev: device pointer + * @in: input structure containing the frequency band which is not used + * by the device any more + * + * Broadcast to other consumers the frequency band the device stops + * to use. The stored information paired with this will be dropped + * from the internal buffer. And then a notification is sent to + * all registered consumers. + */ +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in_out *in) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret; + + if (!adev) + return -ENODEV; + + ret = wbrf_record(adev, WBRF_RECORD_REMOVE, in); + if (ret) + return ret; + + blocking_notifier_call_chain(&wbrf_chain_head, + WBRF_CHANGED, + NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_remove_exclusion); + +static 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); +} + +/** + * acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled + * for the device as a producer + * + * @dev: device pointer + * + * Determine if the platform equipped with necessary implementations to + * support WBRF for the device as a producer. + */ +bool acpi_amd_wbrf_supported_producer(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!acpi_amd_wbrf_supported_system()) + return false; + + if (!adev) + return false; + + return acpi_check_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, + BIT(WBRF_RECORD)); +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_supported_producer); + +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_FAILURE(ret)) + return NULL; + + return buf.pointer; +} + +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); + + return mask & BIT(WBRF_ENABLED) && (mask & funcs) == funcs; +} + +/** + * acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled + * for the device as a consumer + * + * @dev: device pointer + * + * Determine if the platform equipped with necessary implementations to + * support WBRF for the device as a consumer. + */ +bool acpi_amd_wbrf_supported_consumer(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!acpi_amd_wbrf_supported_system()) + return false; + + if (!adev) + return false; + + return check_acpi_wbrf(adev->handle, + WBRF_REVISION, + BIT(WBRF_RETRIEVE)); +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_supported_consumer); + +/** + * acpi_amd_wbrf_retrieve_exclusions - retrieve current active frequency + * bands + * + * @dev: device pointer + * @out: output structure containing all the active frequency bands + * + * Retrieve the current active frequency bands which were broadcasted + * by other producers. The consumer who calls this API should take + * proper actions if any of the frequency band may cause RFI with its + * own frequency band used. + */ +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_in_out *out) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + struct amd_wbrf_ranges_out acpi_out = {0}; + union acpi_object *obj; + int ret = 0; + + 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, "Wrong sized WBRT information"); + ret = -EINVAL; + goto out; + } + 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)); + +out: + ACPI_FREE(obj); + + return ret; +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_retrieve_exclusions); + +/** + * acpi_amd_wbrf_register_notifier - register for notifications of frequency + * band update + * + * @nb: driver notifier block + * + * The consumer should register itself via this API. So that it can get + * notified timely on the frequency band updates from other producers. + */ +int acpi_amd_wbrf_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_register_notifier); + +/** + * acpi_amd_wbrf_unregister_notifier - unregister for notifications of + * frequency band update + * + * @nb: driver notifier block + * + * The consumer should call this API when it is longer interested with + * the frequency band updates from other producers. Usually, this should + * be performed during driver cleanup. + */ +int acpi_amd_wbrf_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_unregister_notifier); diff --git a/include/linux/acpi_amd_wbrf.h b/include/linux/acpi_amd_wbrf.h new file mode 100644 index 000000000000..c2363d664641 --- /dev/null +++ b/include/linux/acpi_amd_wbrf.h @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + * + * 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 an ACPI based mechanism to support + * WBRF(Wifi Band RFI mitigation Feature) for platforms with AMD dGPU + WLAN. + * This needs support from BIOS equipped with necessary AML implementations + * and dGPU firmwares. + * + * Some general terms: + * Producer: such component who can produce high-powered radio frequency + * Consumer: such component who can adjust its in-use frequency in + * response to the radio frequencies of other components to + * mitigate the possible RFI. + * + * To make the mechanism function, those producers should notify active use + * of their particular frequencies so that other consumers can make relative + * internal adjustments as necessary to avoid this resonance. + */ + +#ifndef _ACPI_AMD_WBRF_H +#define _ACPI_AMD_WBRF_H + +#include +#include + +/* + * A wbrf range is defined as a frequency band with start and end + * frequency point specified(in Hz). And a vaild range should have + * its start and end frequency point filled with non-zero values. + * Meanwhile, the maximum number of wbrf ranges is limited as + * `MAX_NUM_OF_WBRF_RANGES`. + */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +struct exclusion_range { + u64 start; + u64 end; +}; + +struct wbrf_ranges_in_out { + u64 num_of_ranges; + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +}; + +/* + * The notification types for the consumers are defined as below. + * The consumers may need to take different actions in response to + * different notifications. + * WBRF_CHANGED: there was some frequency band updates. The consumers + * should retrieve the latest active frequency bands. + */ +enum wbrf_notifier_actions { + WBRF_CHANGED, +}; + +#if IS_ENABLED(CONFIG_WBRF_AMD_ACPI) +/* + * The expected flow for the producers: + * 1) During probe, call `acpi_amd_wbrf_supported_producer` to check + * if WBRF can be enabled for the device. + * 2) On using some frequency band, call `acpi_amd_wbrf_add_exclusion` + * to get other consumers properly notified. + * 3) Or on stopping using some frequency band, call + * `acpi_amd_wbrf_remove_exclusion` to get other consumers notified. + */ +bool acpi_amd_wbrf_supported_producer(struct device *dev); +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in_out *in); +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in_out *in); + +/* + * The expected flow for the consumers: + * 1) During probe, call `acpi_amd_wbrf_supported_consumer` to check if WBRF + * can be enabled for the device. + * 2) Call `acpi_amd_wbrf_register_notifier` to register for notification + * of frequency band change(add or remove) from other producers. + * 3) Call the `acpi_amd_wbrf_retrieve_exclusions` intentionally to retrieve + * current active frequency bands considering some producers may broadcast + * such information before the consumer is up. + * 4) On receiving a notification for frequency band change, run + * `acpi_amd_wbrf_retrieve_exclusions` again to retrieve the latest + * active frequency bands. + * 5) During driver cleanup, call `acpi_amd_wbrf_unregister_notifier` to + * unregister the notifier. + */ +bool acpi_amd_wbrf_supported_consumer(struct device *dev); +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_in_out *out); +int acpi_amd_wbrf_register_notifier(struct notifier_block *nb); +int acpi_amd_wbrf_unregister_notifier(struct notifier_block *nb); +#else +static inline +bool acpi_amd_wbrf_supported_consumer(struct device *dev) +{ + return false; +} +static inline +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in_out *in) +{ + return -ENODEV; +} +static inline +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in_out *in) +{ + return -ENODEV; +} +static inline +bool acpi_amd_wbrf_supported_producer(struct device *dev) +{ + return false; +} +static inline +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_in_out *out) +{ + return -ENODEV; +} +static inline +int acpi_amd_wbrf_register_notifier(struct notifier_block *nb) +{ + return -ENODEV; +} +static inline +int acpi_amd_wbrf_unregister_notifier(struct notifier_block *nb) +{ + return -ENODEV; +} +#endif + +#endif /* _ACPI_AMD_WBRF_H */ From patchwork Thu Aug 31 06:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370973 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1F23C83F29 for ; Thu, 31 Aug 2023 06:21:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD98B10E589; Thu, 31 Aug 2023 06:21:18 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2065.outbound.protection.outlook.com [40.107.237.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7516D10E584; Thu, 31 Aug 2023 06:21:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZzv+Q8zgTMWy2NI4jQvnprIrecJoH2vQ0PywNqsfB0yphG0Pt5JdXSpRGidAC6bdppavNDASZZ5DxXn3fgBtUbuhStFOJldJb9IfuDE3+du+Bmg+JojVZj2P7+WWzFeLv3Z29WsDF8ycn2Y4fx6F1Cdu7GDt6lycQiJKKmuRX1ZXRbY0nTBGRcsrqRm0j3ajGsmAV/MDXwxqGDq68/jeHNZeke4TPoAqlRD8M5dCUiDbV0BxEpm1MlvxC7wHDxDhp/5mAZnNDmdbI5CKkTEXka2tfNY6JV32JTynC+tFNqojLS82m2DdAVxV6aQ9GMqQNZQd63N5pOb1H7fhN2PSw== 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=Qu7ufWBfNSNsnpJhj/ftM09iZry5yoIJIMA8q53g9Nk=; b=a5C5skcgzUsYUxIK3FDLFOgQMmM+UPy0cd8H+L9awPbr0wM379Q59WWSjuFvwabCJ7nJo69yTZgAQ/0PIYG7NfgA5eoxnXewgr8sOflPYSeuIItBvw+JgNaH9HwPfz7/SUWCTlZ9+5F+Vcd12MOC5GabWmYYZygUgW6rHCrR3AENlgRkb5rWC5zd3f6whSS6zGeasdJatXvX3LmNXsHLcOxFVifE7Xy/cATOD6G3hWKEkgsWQHWtRymlWNy9lR6LWQEevFBRoNL4/G9lQ50zeTIpuMu5cXShXaKa+iWPfwqwufMwU/NWmXOeL+iTF1j0MzXthUAtnSl9WhY2Jjda3Q== 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=Qu7ufWBfNSNsnpJhj/ftM09iZry5yoIJIMA8q53g9Nk=; b=3NCNaBn3S05eMtVKqlEFvATZ4mBuDcLuTSFowD0nQzLbcK/WyAc6zFh6HU+WBFzMXQoBNi0WVQNHZqrxMLxCY1Cci9buOIVSRf93uVzZL+pT4s3+Ur3CzL6HVlVeVzzQxOFS9Z/UxIa8rCZLYafMaHzxGDuh3YuB6+X6NSQh6tk= Received: from MW2PR2101CA0017.namprd21.prod.outlook.com (2603:10b6:302:1::30) by CY5PR12MB6408.namprd12.prod.outlook.com (2603:10b6:930:3b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36; Thu, 31 Aug 2023 06:21:12 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:302:1:cafe::e) by MW2PR2101CA0017.outlook.office365.com (2603:10b6:302:1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.12 via Frontend Transport; Thu, 31 Aug 2023 06:21:12 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:12 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 01:21:07 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 2/8] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing Date: Thu, 31 Aug 2023 14:20:25 +0800 Message-ID: <20230831062031.1014799-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044F9:EE_|CY5PR12MB6408:EE_ X-MS-Office365-Filtering-Correlation-Id: d27f5a3e-762a-4099-7553-08dba9ea795e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u/vRdcxyTZGQwZ//vhg5CVR/gRb6meTpToNNuGtHFliDxmsCvubEOFwpACm/kZqRpebHNRHWDVeKBYUUB2PqmAEvLbkZnYKoxpe6X8ThiqX2QWSQUsqPNiSic/U5IH0PrA/kNoFQ11yC60GtWsprLOKm3+MZhQ2y1AiFxntq6CUAh7Sfu7LbGHQYzafVrvHOEEPt13pYPzsn5Y3zMNQ+rbs9fBLlVNLdL+ec6xYmPgljvMQPJ0Jza2r6FzaHPhTPZdKaZlcn3Y7D9T0uFQdNdByXjqUiE4KWT+2HilRoryAe2iUzkY3BFXZqFpln1EXBLfUzPh50GE4hff96lB8m/Mdy1kIP5W6yi5e06bgwqvTEkFG/dBUJeNxKjT5etd7eWh1SQN6iWaeh3BO54ftifAKGxk47wj/7km2PsPLdQ8OAmpllKivb91lQ4uhnjyj0guv0yvnQbBV/7q5nYEERrXDhC5HT43XZlhj39JucHRRdHQpjvDM2zzKXf0YSPAF8uky1izypGs43k/tTQaEcGNQ/mhJKgiKs36QSIWaElJ8fWvNdSgi3y+UL5+qsNNUjIqrXjX+zcxQQsmZ/O6n2McHk78u3dq50Vw49blg90p2+cMKBwWauBYbNTBTu++MuWEdT73Mbv4rUevGDP9sdHpC4IkgJyZuy75yLtLr5lqK51DXbMKNGBeNXy+EfHdIh7tRnWgI1p1seOoaxbDflu5qQJa2wB+aWcIM8fjO9BdN10f18x/penZ0AzlPpQyk4JSitkOHfY5XjrY5719px/2262XIrBgL3C94uzKX0sWw= 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:(13230031)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199024)(82310400011)(1800799009)(186009)(46966006)(40470700004)(36840700001)(40460700003)(41300700001)(316002)(6636002)(8676002)(4326008)(7416002)(426003)(336012)(2616005)(2906002)(47076005)(86362001)(44832011)(16526019)(5660300002)(83380400001)(36756003)(1076003)(26005)(36860700001)(40480700001)(8936002)(6666004)(82740400003)(921005)(81166007)(356005)(7696005)(54906003)(478600001)(110136005)(70586007)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:12.5169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d27f5a3e-762a-4099-7553-08dba9ea795e 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6408 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The newly added WBRF feature needs this interface for channel width calculation. Signed-off-by: Evan Quan --- v8->v9: - correct typo(Mhz -> MHz) (Johnson) --- 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..8c2a9b748621 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 31 06:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370974 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED823C83F10 for ; Thu, 31 Aug 2023 06:21:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BC1610E58F; Thu, 31 Aug 2023 06:21:25 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id C97A710E58B; Thu, 31 Aug 2023 06:21:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ibYUEShpAA9SU50H3RoAGZbSnB8XXZLCVQb3OPDsR+i+DcLfKdkC3zFiUIqI3UlvJ4smH9PQr8GNdW409GLbWfUgfgISQgiWujDBQUD9/mgaODxGvU8cDBVBDLxBHZgcauuzp06MwF/foi9RFFhX0uTu/ainTCSwdZdGTVlzmykQl5SGRU7nGYiDi0wV2C6+IsSRIHs4kHwtCSRYXxSoYJY2FR1MNzDqDGex0s1DGubRek8fyYFRqAwHddjQiokx/MGMymmBzvhWHH1ApbopfOx+mTGZlzNn/I2oH2oUu5xK1++3IVvjMyRgRFIJHfkKaSPqn9BiNadRwFh3Z8XUDQ== 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=IdVgZLvvokRkEpz6Vd9hjJbKFXH8b+svFNiq5wM+suc=; b=oN2afk8RJEjimDZir5mP+PGTZ0yJEHrLUB2hx7L8Eir5uF1N3sxdbuf+6DAFQ6p/NSD88QnwnIYUc9RIIkHi4CEwOqxqW2+RwNZKTk9jVen3Spg2PqVHvj2AH1GQnRzZFMzNJntsvykZ95hwft84kLXtgWGH8BfP6+HpwM1xPh/I9t3wciFEOOcIWJ4IeyRYYdU8ztBcEwUN1NmNcwwmkWgZjV8xBrkR6n9+yzmbIlkGUDToGK/UymmkSEMpR66jtSKxGfcL47+jvf0vEGDxFVQK9z+Qc3neOh/i1ae0rPK0xWJyVrciYYqowIMMhcZUWdfBfGcDcm4OED6nM59png== 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=IdVgZLvvokRkEpz6Vd9hjJbKFXH8b+svFNiq5wM+suc=; b=Jnyw3OIMAEl+tLRDwZTKlyZ4dJOrBzjRhmlwT1LkMTnfl7IXBfHclCUIaLaGm9b0la/CCcrNtLeBYvrXwNKUGyEOiRgRtJV/cD+BJQl9Ys6eAiikaFrJLQAJrIDMvXabQtzFi+KX+gCXbK0St2IEd1trsFOutpKJlhHEB2BQR58= Received: from MW2PR2101CA0010.namprd21.prod.outlook.com (2603:10b6:302:1::23) by DS0PR12MB8767.namprd12.prod.outlook.com (2603:10b6:8:14f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Thu, 31 Aug 2023 06:21:17 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:302:1:cafe::34) by MW2PR2101CA0010.outlook.office365.com (2603:10b6:302:1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.9 via Frontend Transport; Thu, 31 Aug 2023 06:21:17 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:17 +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, 31 Aug 2023 01:21:12 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 3/8] wifi: mac80211: Add support for WBRF features Date: Thu, 31 Aug 2023 14:20:26 +0800 Message-ID: <20230831062031.1014799-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044F9:EE_|DS0PR12MB8767:EE_ X-MS-Office365-Filtering-Correlation-Id: 48917443-7e4a-46b9-7a89-08dba9ea7c4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YknQZyBn/116k4pQNUIx+sUzVdNMqvufkbo65h8SJpPtXSJdC6kX4goZSeU4RBcQkKjJDQqf/+SZXgvAFuy8HIFgiQg8JyiQRlZJYn3e6kL2ZlEttfbLLpsiMeaCoNnQoJH8+31C5jfsqNoSYnNNuleuYm/zVEg+4Sxl2fY3/QvqPn8AWpPfoBSFXpKH1PQMgn3xbEyVDObACuREyhb8SJRoJxKSXf8umBFZ8mRRAkwVmYwGrqlhSsmC8Qq2gRf82qQ6zyt8Z91HB0MPNWijCCzEXT0mOMN2cIWBNp5fMt6quD0r23DtYa8ann7x5CuGI0DWPXKp0zpGbLixKKvuU5O2EAoXuCtdAoKisQTz0Cq6/llavSowxwxgPMRBPQbWBqoEJKNM/DgKYmzCQtO1365DPUW4p+TiI0XueR3sfRqxylCDXwqaht9BmKsqgOjzyzEM6mLpkPsF5JJspxuosbSVhj6ILDSaVc+ToOAjrT8suPZW35upc3H+rux0H9scxh1GmITxe1H3HYR6EQSgZK6CsnY9ruFSXtZmGAjlUUxKxHpJlEB40oNn1Ag611Y6c+hcM0wrWhMlwCmlfD/12CPTR3PEgiTh+6a0EHJEAjjqsL2RAE/oPCTSSaeUjSh0J2ayklh7PjI0BdgL1SGih6dgXGp1xtTPJqmzxTvnlZH/DCXD+a3Q41twZrTMj2SWzWPky699ymO4jHSkmZdSzOzmJegiK+8aVRhfst8EKzNwlJecIYH12VwreFS9uhTZhXqySJD4Vhua0PuW7ALht6R25GkeVZ+BJyzITl6/YYg= 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:(13230031)(4636009)(39860400002)(376002)(346002)(136003)(396003)(82310400011)(451199024)(1800799009)(186009)(40470700004)(46966006)(36840700001)(7696005)(6666004)(478600001)(83380400001)(1076003)(2616005)(336012)(426003)(26005)(16526019)(2906002)(7416002)(44832011)(6636002)(316002)(54906003)(41300700001)(70206006)(70586007)(110136005)(5660300002)(4326008)(8676002)(8936002)(40460700003)(36756003)(40480700001)(47076005)(36860700001)(86362001)(81166007)(921005)(356005)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:17.4388 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48917443-7e4a-46b9-7a89-08dba9ea7c4d 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8767 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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) v9->v10: - get ranges_in->num_of_ranges set and passed in(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 | 105 +++++++++++++++++++++++++++++++++++++ 6 files changed, 128 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..63978c7d2bcb --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,105 @@ +// 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 = acpi_amd_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 get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in_out *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; + ranges_in->num_of_ranges = 1; + + 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; + ranges_in->num_of_ranges++; + } +} + +void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in_out ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + get_ranges_from_chandef(chandef, &ranges_in); + + acpi_amd_wbrf_add_exclusion(dev, &ranges_in); +} + +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in_out ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + get_ranges_from_chandef(chandef, &ranges_in); + + acpi_amd_wbrf_remove_exclusion(dev, &ranges_in); +} From patchwork Thu Aug 31 06:20:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370975 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9C44C83F29 for ; Thu, 31 Aug 2023 06:21:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFE4D10E594; Thu, 31 Aug 2023 06:21:30 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2045.outbound.protection.outlook.com [40.107.244.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB00710E58B; Thu, 31 Aug 2023 06:21:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTEomrNVrFEqWksJVby1ROmX4Pv1oaUx3GcS24WCccj46XhmJ4+jtlwriqLh0F+UXoxshNE9qTzmxsSIKNLIoa7Zc9hEoD1VEB39ctgI6INB9w4ihf/762disSZLh3SqwtAskpIM+HzLZo/qorRjc9rqL2yZG28xMC7bZJem+YuWvWSb5wE5AJhNWpJUrH0f00+iKmvJ3tW5k+nt1zpiHf4xFzu8wCv4FQ+eSwWlUARHjEMIZ22/hjzv2Nb6h/JxmOLCyIchm8pEoUIKHNtrJeMrsqYbh/852onJTW/Chbk95U2DpcVaIERVOOZUOUIo/nDnqZ1PtFVxXckdF6pkdA== 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=XatdWpQPtlSMnhSmshlzx5/2BvTp4WOFta4PJsRDI6cV9kHUK/LIlpdCnX9j8t0TCoxASdfo//lbucNmj+yEv9CdHKn8EWVZrotsC+wnmTtVnf76GSEL/NZHCmQy3JxYaQ5fQ8OsC+wf/v7qa4HLkhqUDHq4UbErQp+ccww1HmJL2OfZSNYWXohB2Gq207bYdGX1a1VknewzdpiyBLGxwYOnBfAYtw5g/5J6rw3XS40iBJGb7b1ENjUFbrTrnopAJZtz6Sb5Jpia3581Ja0YfejnPV3UTFjOAACwUqNmQt4OymF+9G/dLUNqCbydvAHA4d00Zj/wKQ3H3mYyEdJMJQ== 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=gZqNtRCdlV/eFlnvVRssTL6Gp2jJ8OCjxa2mGvZLOVeTLwNI5PyQXomaClGIhsScNPdFKMZJmz37WdyfYiwPoMXvYjA+EPavYNfwAiP/jCpDhIcllVtbmy6yRYUQHaQZV4UwzOrkTbNENB1z4zlRQ6cCXxudW1At4qrmpkts/A4= Received: from MW4P223CA0006.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::11) by DM4PR12MB7551.namprd12.prod.outlook.com (2603:10b6:8:10d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 06:21:22 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:303:80:cafe::9c) by MW4P223CA0006.outlook.office365.com (2603:10b6:303:80::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21 via Frontend Transport; Thu, 31 Aug 2023 06:21:22 +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 CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:22 +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, 31 Aug 2023 01:21:17 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 4/8] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Thu, 31 Aug 2023 14:20:27 +0800 Message-ID: <20230831062031.1014799-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044F8:EE_|DM4PR12MB7551:EE_ X-MS-Office365-Filtering-Correlation-Id: df2bc0fb-e1ff-4c5e-e190-08dba9ea7f1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AkqLwUlVIFsIgwE1cCrRysNfIJkukIF3x9GLV/8/ASS8GWVPBPqlqOoO6cOPAPLp9HFTJZUmAyXrNn9+VmK80GElK43MQOV7PEz3y/6jv2+bnQsa+nAsPrulMb4akac3dP/dW0WkUWIiqEQwAcg35ZGIjVSsi0zm7puiyWbh3f476OW3G0h4QmZToygWWRiNtnt0yyz7tgfi3VH5+QdKsSw2RntlucozvNf7a9wz1Xqg4SQWlKGElz8u8nu0d+JJFB1BadfEAsZbtGxA7N8JSITdnYKZPFc0JvOvaqQz/bppbVoZhXOMOPWyFPeZnyuGodZlPNqC0HxhV+jSCiNN0W54WkIX+78x4I2RRO2SQjJs5FptNO/JdehagDaLwB8rWHJqDrdtHJBpOjXT2EGRcPZm3jbaMw7+4L25rpU8YMmVcEjIk2HXCka/eUUCsZHhVHGePRKqBsHfu5zD+vp/ihJorwWyPJBbISIOBhRC5+8SjPsdMg/4/VeDrgbWQrAvpyhVVaFdKjYxzl/TTMOhUNMFCR1o3ECQkYksJRiqIVd4QjGN6xytmdg7G5xgWtMDAVnDrqkeeMaPTfKLRdNKQYZe2R5AXSp82oHsUdHmf6kCivCwpm/VoIb90WDIWtDYnrp8YYZORhj0QWLJvPBv5eoYMxm1KGQDrALjK5PNLX6CpBUL5nMShxzP3D+IVztFToepGHQZ0zQbQr8v/aKktrZNLje3J+ghuFUhovQ/mfE8dG0jOFkVMUjtJizPQimypLQv0QwqBkreASqkmC/BcE0CfmKtGbGPMg5bmPVPI24= 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:(13230031)(4636009)(39860400002)(396003)(376002)(136003)(346002)(186009)(1800799009)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(83380400001)(54906003)(70206006)(316002)(6636002)(70586007)(110136005)(15650500001)(921005)(356005)(478600001)(2906002)(81166007)(82740400003)(41300700001)(86362001)(8936002)(8676002)(4326008)(5660300002)(44832011)(26005)(7696005)(47076005)(336012)(1076003)(6666004)(426003)(36860700001)(7416002)(16526019)(2616005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:22.1888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df2bc0fb-e1ff-4c5e-e190-08dba9ea7f1f 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: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7551 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 31 06:20:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370977 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42620C83F29 for ; Thu, 31 Aug 2023 06:21:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3DFA610E5AE; Thu, 31 Aug 2023 06:21:38 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EAA110E594; Thu, 31 Aug 2023 06:21:30 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IU2w+qE194con9dOK8D0ttev5BpQP49rocTKHqI5f4ngsWhP8s9R4pqC9BVAE57+5n47OqIAb4PDk6beat/jM9VXhfCqqA5DrFTWTlp5DzK3d2gpimYBvsINjeWQf90ZkL71q87erFwQH2B5+/kV+eQCoYSikfDHIsb9zqxJ/Mu56ffpng8aj+DtKs73U57XaQgf3ODYOs7NXH30jrlgKtekukFes1Nq6QM+OBu88lqwXRcDIbjBGSL//8AGpY0TlGV+2ntdRt5AiOLkfPcmwfHYQvA45z4MotMWdcMLLRdP1GS6U7vv94NqZgGRoALmrF31MbVudmDQv5AbzWRaAA== 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=Htd1mFxSVlkhYdvRivRi0EXb5chfu+1IcqJXQMj8ays=; b=j3DPkNKDWWBqM7kC67L59wVf5lqCFCvjn96UvwPAGwcUamGWkw5QeY2Pi045f/uVwIZc2Jf77KYiPq5VyooH7Az5rkXgUrUo6rO6EuywI7B52AWPxN5QEM4vgyG53/yMcC1T7tfRemN0zUQsRngwFFMqk46gUqY0TOYKWAJW6cc2nI44mYQzxQwCtypRT2JmHjIZB2j5UsX4xm5G4cgowO4g2BSO7HeICXZuFMat/gh4vHU8I0ARAuvFGkLJ5d2IMax4gnzhLgr5L21alRyGh7AQzGYATjcfBNEs4SXp/+oDPgToDfeZKYrOYm+FK/+s2bP93VYTDnBdfW9/QchK3w== 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=Htd1mFxSVlkhYdvRivRi0EXb5chfu+1IcqJXQMj8ays=; b=L5hbIG5emU8HhpS1qWu5GpwYQWq+RJqvSjPJsbwjynk4ggJb1/QzvBkErJx8InwAtJuSkuOA5SQQ6eBQWgkv8Bm5BxLyBnBwp+8hmPHh/q+hSvXuHOZ20CObUHW93eGpDbc5xAtcM7f4aERG32dNi/vgnFs7q1XFD8ot84OkOlQ= Received: from MW2PR2101CA0017.namprd21.prod.outlook.com (2603:10b6:302:1::30) by PH0PR12MB7813.namprd12.prod.outlook.com (2603:10b6:510:286::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Thu, 31 Aug 2023 06:21:28 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:302:1:cafe::77) by MW2PR2101CA0017.outlook.office365.com (2603:10b6:302:1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.12 via Frontend Transport; Thu, 31 Aug 2023 06:21:27 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:27 +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, 31 Aug 2023 01:21:22 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 5/8] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Thu, 31 Aug 2023 14:20:28 +0800 Message-ID: <20230831062031.1014799-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044F9:EE_|PH0PR12MB7813:EE_ X-MS-Office365-Filtering-Correlation-Id: c832d08e-2f68-4561-958e-08dba9ea827c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fuWmiCg1Nyk+ioy/iIJmeA2dNHTJtWBjRZZfhT1WNF7wkYd0vWqPIURWh7JglWu6nhXg7Df8W24mx4cgWXODmpOcj1ld0WCFkykXUukSXyjUz5fWmglUoDbUblneyDxGaAi+RcDO5Z9GUkWHgdLsuJfWPp+KSN88G8S36/oDBaKJ02yov4N3bPjI2V/u+SwZFhSbSUqJNleZdlmP6QeVNf/8bLMeRw7cx/gGRvwU7Mj9+ZvzpB3wWS8CYmdhGhW2wzi3+WCnCBVqsK9EXpGGxKGJJiN78sMEIyvWArfHMlqgDI1UDp+g0f2pfM7t5AcspggzcAN7BPDOXktgx6nVu64iGZ0js3ckD5n89KISLuCMl5A40UIm56FAf1wFbzt4TRLew/u3FR2Vh3o5F3pF1lg62CETrK4tNMV0ca4eoOL1i47+BMYmUCWU1Rc7b3Mq5NIuSZSMegAOCZ+k7oscu/OpcfIg/kZHOawwfOi4skd1WzaZA8eGH05SwzGljskIIanWMucmIZLlkl09+OWbIpRVQdmlmhhoCydBwpYFgKLGT9GgOV0SNBrUv/W2qWrZ3/RuNhyDdBNNaROzwPL1H2ZzMP1xZCmsrSUl70ljKG2MauxAWbuwkRumdRdC07HfuW08KCOJgWuM/2EKNvqLQCxl89e0PHN3qj6aMhnQbVLGEPWg051HURhAZ0EnDfk9CRO6qTNCrx27Kcat9bhfOk7+NNDwgxeJmUiRdoBTumvFv/GjnjDJw7RD+SF8vTg+T7LwrqS+xuh0vjQNRMU9NUunUWnZ7fGmY9Jea4at4vvF6i+U6SmgcdbmoAnfdljz 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:(13230031)(4636009)(136003)(346002)(376002)(39860400002)(396003)(1800799009)(451199024)(186009)(82310400011)(40470700004)(46966006)(36840700001)(82740400003)(7696005)(110136005)(70206006)(86362001)(40480700001)(356005)(81166007)(36756003)(47076005)(921005)(36860700001)(2616005)(426003)(26005)(16526019)(336012)(83380400001)(1076003)(40460700003)(54906003)(8936002)(478600001)(44832011)(5660300002)(7416002)(2906002)(30864003)(8676002)(70586007)(41300700001)(6636002)(316002)(4326008)(36900700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:27.8138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c832d08e-2f68-4561-958e-08dba9ea827c 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7813 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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) v8->v9: - update parameter document for smu_wbrf_event_handler(Simon) v9->v10: v10->v11: - correct the logics for wbrf range sorting(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 | 195 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 23 +++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 5 files changed, 240 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 97cb56c791f3..47595b892c1f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -246,6 +246,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 7691177d87aa..c7231ad89aa0 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); @@ -978,6 +979,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 222af2fae745..bac2a362a2fc 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1228,6 +1228,174 @@ 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_in_out wbrf_exclusion = {0}; + struct exclusion_range *wifi_bands = wbrf_exclusion.band_list; + struct amdgpu_device *adev = smu->adev; + uint32_t num_of_wbrf_ranges = MAX_NUM_OF_WBRF_RANGES; + uint64_t start, end; + int ret, i, j; + + ret = acpi_amd_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 < 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 = num_of_wbrf_ranges - 1; j > i; j--) + if (wifi_bands[j].start && + wifi_bands[j].end) + break; + + /* no valid entry left */ + if (j <= i) + break; + + start = wifi_bands[i].start = wifi_bands[j].start; + end = wifi_bands[i].end = wifi_bands[j].end; + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + num_of_wbrf_ranges = j; + } + + /* eliminate duplicate entries */ + for (j = i + 1; j < 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; + } + } + } + + /* 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 + * @_arg: 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 && + acpi_amd_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 = acpi_amd_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; + + acpi_amd_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 +1488,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 +1593,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 +1657,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 +1816,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..3eb1c72a76f1 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 31 06:20:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370976 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83017C83F31 for ; Thu, 31 Aug 2023 06:21:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A56B210E5A7; Thu, 31 Aug 2023 06:21:36 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::61c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 16CFF10E598; Thu, 31 Aug 2023 06:21:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eyy/wykofk77iC0lRTZSVcgt8YWq1Te4+oj0P/sZyUwiG1bNYfn+WiZ9gk7pSXNlMzlExoFXEZ9+LbVq952mYlE5DHEZ3OfN3Vat11woQvKKMRdnBZOvBY1Gz1O/K3YOAibJ3Vq41jJWc0Rf1F52uTiIx4tPzW0dmBB+byld4TdLUVbZnz9b684n8gLf7krgFGEvqxJLTqIPeDQDUNKNKmttXGD/z6X+2iN6W2n8PhCuusFUw3DLDw3Yd892HnMi7K2ApcJ/3AFZ3dHGj1iNEfKwoKI25T480klRomi5HFfyRrO9pBj8gsmyjxw7PbN9EjqjO4RCOrw/6SzixRAVIg== 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=WBRHfsfZe939lO6ulz/XCDvUc7IzpeK7VI4Vp/iPpAc=; b=cRIYzTJri50YSGDUb7d+ancS8C6VBaLFfaUwToEOGjD0nfB9q+cM2fHxWBAlujDzk1Z82bqHVcaosdV1YLg304RNPEMVqJsMLQiffzmpCg0drtEp41RVMLb8YEo8vtINkXNpvk4UtKRO2h2KAeH/TYut5ENYU0ZVLu3jcaOQxpcQplV3GsXTk4wumyB6rS0nWDLAjHP3KXc3bGbktmro0xa+tCPnc8/uiaok9vmY2Tdmqj1wxskUljtW4nZ2OA8ODPGEozrDlXmPl7ZdfGWtMsOTNGAjlsFEbxXiDEAvNvtYGVz2bdpNY1gRwQ722cIZZCG7tbPlSQIFAm3th784tw== 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=WBRHfsfZe939lO6ulz/XCDvUc7IzpeK7VI4Vp/iPpAc=; b=Xy8hCZXyJpZ7kF4+Nqk63SrNupJ/72nN/qFRJ2gzZptJNTYPJnKo/jvuJHBZHQrOyJIgPypeon3NmPIqw5qIgAuDmbTHnWFNk04PP0bs00G5IPPoOu5NOTuk3L1CiCJEsTNOw6/8pmLtxY6ELdgGw6S7OysBpljgpsaJLWKEvPA= Received: from MW4PR04CA0336.namprd04.prod.outlook.com (2603:10b6:303:8a::11) by SN7PR12MB7346.namprd12.prod.outlook.com (2603:10b6:806:299::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 06:21:32 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:8a:cafe::82) by MW4PR04CA0336.outlook.office365.com (2603:10b6:303:8a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Thu, 31 Aug 2023 06:21:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:32 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 01:21:27 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 6/8] drm/amd/pm: add flood detection for wbrf events Date: Thu, 31 Aug 2023 14:20:29 +0800 Message-ID: <20230831062031.1014799-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044FD:EE_|SN7PR12MB7346:EE_ X-MS-Office365-Filtering-Correlation-Id: a9feca61-0733-46dd-e414-08dba9ea8513 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nUD/RyEWuhJujzdDkZnjPf1JDIv9vBOXHP+MldX2YJQdy+hQqhTBFs4GyOCjkiH+TjGt2y0NB52ZzH81Z9/3hW+Or/a2gt/Fl8mixu5/sFp7tGcoccN7q8Evo9Sozg1OH8EoHExVyEk6QZU7z4NYUN5Pp2jHSz+VlOndZMZ3YiUnf0kV6aRuVxwryTVxwT9XEzpVy0q6Egu1CGpDMvIyKjCZ5RK8GlCJFzyEVq54mqcOWmIynySF5H86bjhYE6QjXLI1U9hAhiKpRv3zcU3n9ATy382JgM26mGbn3ksdlssMqM3mm3iOzVBNzEnxo69kC7P8Zt/XFnb5voZ0aX15lcxh8EojgCHhmt4OjEZDNyZAPqJXaAru/fyKy7+Rm/0rUzIbOSlIlDgZm3R9SY5oxEwY07az/SebOc9HOi4fBjyJX4DKk3AZo4MfCec/9PxLry4VkzmPFitVaDofpc4tBJbVcjCjijQeA7GhRlNcR/+c26sXhoB+W+rGmotMTYvnNN1gGiZYxDA6ASAhcFdURLpGHqU5aESF8wlTr4UfabUS6mC1RDHsm5hyP4QEvyd5864GU4LfGk5OOwlqjql9+60TdzO1Ve3KOlXZJrZVxJg0k18Db/SF9wkEJrr7SEhnsT8hiSZo9NG3RE/v+Bb3s1trn1We1g2bsvrh7X/MgOOVWeM80gkK1S/G7ZA/b7XcARqunujGXDUwhw+imX/B7bEHIJ3UbFNv6XmlciVSmIZDYxBXgxjP7RsEPYYSd5kCvutGX0Usv95imyNYFCwnnnifSV2LC485shsp+f5kKac= 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:(13230031)(4636009)(346002)(376002)(396003)(136003)(39860400002)(186009)(82310400011)(451199024)(1800799009)(40470700004)(46966006)(36840700001)(36756003)(40460700003)(40480700001)(83380400001)(4326008)(44832011)(41300700001)(86362001)(8936002)(5660300002)(7416002)(8676002)(1076003)(26005)(336012)(7696005)(16526019)(426003)(2616005)(36860700001)(47076005)(82740400003)(356005)(110136005)(921005)(478600001)(81166007)(6636002)(2906002)(70206006)(70586007)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:32.1609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9feca61-0733-46dd-e414-08dba9ea8513 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: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7346 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 bac2a362a2fc..2dbdb4149428 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1319,7 +1319,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; @@ -1328,6 +1329,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 * @@ -1358,12 +1374,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 = acpi_amd_wbrf_register_notifier(&smu->wbrf_notifier); if (ret) @@ -1374,11 +1392,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; } /** @@ -1394,6 +1411,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; acpi_amd_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 3eb1c72a76f1..60d595344c45 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 31 06:20:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370978 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02675C83F2E for ; Thu, 31 Aug 2023 06:21:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3900B10E5B5; Thu, 31 Aug 2023 06:21:47 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20622.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::622]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DEC010E5B7; Thu, 31 Aug 2023 06:21:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DUt1UQjOZDd9xviQE2iW6NdW/dNJoGDWVQL7telfMHusPqneim8y0rXkbuW9C8rGqASfotklmczcQkNWfmcrUPdMsNWtk39XoEA80hbewcW/gcQLs/+q0m4WNJ47W1fn/OoLfKuwMGn6YXSrTIxXAHdA3DewW++7+UOICvfj5p3DMID/uG6wu6vFxiXCogI5WEcVExcPDdTS0MiOAQKXcKQBZgr566BuzMKAtLfrIv/9XWksmXqaykLcahs9QSanSbx8CXJE2Q5pmtmgykhki8B+NzhTqH0YCe/F9m6e/tVFrZziBNsgI2577lzB+POKmu7PbXeaeiLYbgAjwhjSVw== 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=WFFnW0xRkztAb7gMdcjvh1Wj5dspp6P6q9v2lV3MAV0=; b=PHVvX7tU8r/wlUmk3kmTObijrxRTw8Zyx0NO2Oi60K1SL8Mj9E0Qb3U4fB7+6wlZKd7jYsvl01iHp8zXbxdU19o5G4SUlgfBCv1/NCZRieUffrCYADrM9KJJBklWssEc472ZyqmUh6BjWwKPDMWCDMtY5xWmukmsiNi/sAFXogNEINyMilnQsmukkcXmKZalrQLu2icdHoa8/6rWM84Me0Phkb1VojemfuUO+u7hSM1Q20juSFY9xtShuBeL4YoCo8NRJjHs3zLq9NU792SVqWD1rtiRbmf2XrbkvpXwvmuK83dEOczNUbDleaS6s730CyU8GshM87qfsE2NTIOqkQ== 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=WFFnW0xRkztAb7gMdcjvh1Wj5dspp6P6q9v2lV3MAV0=; b=MwmLwBo1gXgZUkoFOjVIgOUQ8OH0UXAGspEJNkZ5KCNJd9ceItRq5h6Ehpd1nCf9pMbEc67n64b3NYZACBI4hD1ggDaRRVyJibIfOaPb+3vpKFFgvyt5/wcXkGq0tdB/f3+9kWrHKJsC35Cvl1MoOmrV61Rt5KScvsa67dffPOM= Received: from MW4PR04CA0347.namprd04.prod.outlook.com (2603:10b6:303:8a::22) by IA0PR12MB7553.namprd12.prod.outlook.com (2603:10b6:208:43f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Thu, 31 Aug 2023 06:21:38 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:8a:cafe::8a) by MW4PR04CA0347.outlook.office365.com (2603:10b6:303:8a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21 via Frontend Transport; Thu, 31 Aug 2023 06:21:38 +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 CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21:37 +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, 31 Aug 2023 01:21:32 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 7/8] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Thu, 31 Aug 2023 14:20:30 +0800 Message-ID: <20230831062031.1014799-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044FB:EE_|IA0PR12MB7553:EE_ X-MS-Office365-Filtering-Correlation-Id: d9483b13-9996-4907-5f9c-08dba9ea887f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tCiT9dpbLdLdLH00mkhEknQ8KLDaA55RIILYKXP/9DwdLiPpJ34cmG87BGKrXfEzNADcy2vDzOymmtr82UOGfL/tbD1WKeXFpIFWUHYZ6NhBrE8sEOcXTTD0Wb/jl9oHTPSGjmV1gpcTVPnheEu0/cj/j8adipw8d06/e8mcdpMizntEVHujKKZYwOzeFqEAt8zlntsicS+IMbxv8X/8wMKZC9BcqxvxWpYgPuvqS1EsGT33M/sab7YvPh6klM016sH+xpKITvvOskQU9j2VLZZcDIqG5oTI+RiRQgzuqZnhhgnBhniEnmJWNYw090ts/Sd2vYTrNUuAhZqEgSFtx+mX3p72/cSHTCR58/rEbwgw5xB0xHZiQNQC+UCJAgQqYCo2pLV8UoaX60g3mi8SBLg1nRxmuq/elY/SHlfWt4zr7lsDxUFcx8JjyIJCiLfSRlpJ9ObU2NHB84gq5hzyEawbLHzvsQwhxC9bZnNMuFL6H2N6JX34exbGP1hFKhXVJtjQp1VOopsaqGJsypVnCVkH+SCZeTF6Iv8/Qobq2VplBOXATqrEuzcb6hWUb3EAAgU8MzU3/zsfHGw30eA3BwnjnTYf9ck224UlSkNC/1DjDjQ9tQZHdeSbrXE756q2yWJvKZ0eptFus/2tQYZ5v3FP4g/AJL6TAFE3tmS8i+c7hQ3kWVNLtFSdWK7eKDBysPzHKK1oQkbY4yGAM5VOW8n/GVhTBPc65HLzGMGeKuJZ2E78FcMSGYrnKEHriColjG5OsdxCcLy4XwhWrxPsDX+Ah/E22c/3gehpn/W1aRc= 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:(13230031)(4636009)(39860400002)(376002)(346002)(136003)(396003)(82310400011)(451199024)(1800799009)(186009)(40470700004)(46966006)(36840700001)(7696005)(478600001)(83380400001)(1076003)(2616005)(336012)(426003)(26005)(16526019)(2906002)(7416002)(44832011)(6636002)(316002)(54906003)(41300700001)(70206006)(70586007)(110136005)(5660300002)(4326008)(8676002)(8936002)(40460700003)(36756003)(40480700001)(47076005)(36860700001)(86362001)(81166007)(921005)(356005)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:37.9141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9483b13-9996-4907-5f9c-08dba9ea887f 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: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7553 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- v10->v11: - downgrade the prompt level on message failure(Lijo) --- 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 60d595344c45..a081e6bb27c4 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 fddcd834bcec..5a7a5804794a 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] = { @@ -492,6 +494,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) @@ -2603,6 +2608,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_warn(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, @@ -2682,6 +2739,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 31 06:20:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 13370979 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 174D5C83F29 for ; Thu, 31 Aug 2023 06:21:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F63510E5B7; Thu, 31 Aug 2023 06:21:48 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id D127D10E5B5; Thu, 31 Aug 2023 06:21:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FIne4OL0tkfpAllqFVXkJpjJAa28NIRoltjnsZWNXi2KNBTS37Lg2bdO/9Nli9qcphRYZbyP9h0hq86Veh4fBee+P3RVLDaB9h1OPL/O9METqIp3vgnbZCdPjU85JAGyk/209RbBb+B0l7XC1sjlBdehHabLW7hIYIcw13v9QlcE6ZfyVcqKy0MVDjcjQsPWwsbWyz4lYniYfWlTnPP6y02DhAvWbgBRqCW+Zeha0HSgjWg/HThIcCxUk35rQj06SDMdZSd7Vpwfeuf2wNN7BVKnTVOuiOoKlDy/TK86CXK3TCmhrI33zF4RxekTXrC2boYmJfghrVpBTA/95GRwyw== 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=kP1PP8xDbIv+QLYz6JOcXtBMe2vQ8EeAQ3SohEzRbeU=; b=kcbuno/ivuQ4RXLE72F6cnyhll229syoXqnBaCb9TCdmtKbYpxLZRYcFHpuTzEsqtwznnL24NPvQNcETdGUOur1lP0gcMVLUb43J9+mMBaLO12/eODfpfuHVFHiuz9iuf96nWIYOLapRWpXhe+KgUaqrE6oYm+ZRbJsKwth1JUMsMkyCeImpAdBevXcCm7WGndjarTcY7cJWVDRSpUwqU+o2PJb/N5kT9VsaOqpSrNULPM9uCCOt3KjxuqobL15cVSaK6JXnqgt0qcg6y1A3lowy1qqCAH5Vqzfjg9OVN9WwRO0D7GMCAookM+jyWpNNH+DKE0YwLRid6KKT6SBuUw== 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=kP1PP8xDbIv+QLYz6JOcXtBMe2vQ8EeAQ3SohEzRbeU=; b=h8kkS2UmgcXXq36kR+kcL6GAIZmZGnqkxPpGV+qffrslZbDDrDRqT5LWMt9sSEBwkqL8oskVsGtKNDKwPxTi5pn4mGAXhgb5bdXTuHYY7RftNzmQzYlR62lGCsT8GxbXY704KbsEHfmc6np0W0ZrnMEsx2/wvg9SjvOdgd5HJ7Q= Received: from MW4PR04CA0047.namprd04.prod.outlook.com (2603:10b6:303:6a::22) by MW6PR12MB8914.namprd12.prod.outlook.com (2603:10b6:303:244::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 06:21:42 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:6a:cafe::7) by MW4PR04CA0047.outlook.office365.com (2603:10b6:303:6a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Thu, 31 Aug 2023 06:21:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 06:21: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, 31 Aug 2023 01:21:36 -0500 From: Evan Quan To: , , , , , , , , , Subject: [V11 8/8] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Thu, 31 Aug 2023 14:20:31 +0800 Message-ID: <20230831062031.1014799-9-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831062031.1014799-1-evan.quan@amd.com> References: <20230831062031.1014799-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: CO1PEPF000044FA:EE_|MW6PR12MB8914:EE_ X-MS-Office365-Filtering-Correlation-Id: 96116d53-db0c-4db8-5202-08dba9ea8afc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eoFEqvH0CeVSXi16peAssQ/ZDR9Nk5TcWizTe1g6FuBMtJcf9U2PL5bVXUEN0sX/W+c5IIHSRreZPYMySRt8QBZpM05DpTjNgecmO1t24TVD5ydUhzRP/utzV3YYkzTzG64Op1DM0I9r1aY4iV4rBQkcSi3aSrmcUx7ll00NRAd/wwDSxsShyzohFugPaKvRVInhmS7zKA8XK/WOVmplsbSu6nt6YSxM0kTY+nzQai23LgKK6HnLL59Zyt8Suuy1DnAFMEIzlt1KY/Pg6fFfKWPMXvH/tw06JAr2FLAxpbNjhPZo/kwo5DZ1EfKWU8A7CwSwflL1s2Funmg18tV2xGCY1zmka7UbLQ+1AlULCfHWvJXc/4ioMCGNyUz7tIsazX25PF0z4DtrFODP6Ie/COc9OWFporV+EXny+I13TftZ6zRZWUEQA/gR9xdYOqC7qA+4kjvN9YOLwe+TliSIhZVTv9gro7OrCUj2E05CLP44XryUjGHXjPU3QvOJEmHG3db6h+4fW9HAqH0f8rRv2KH4/x4/pi/decldAdYnFsJH8h0VWXSKuggw0BdvstBxTUUU5uAVO/iwRvdn449clToHM2YH/qe3SOe6UVszap61P2OBz9LAgabkgvPWIqZ+mI6NEVHyNjBr+CLEUUZsS5Soc4Q5u5XsykOEDU0/AQtIM/tMFde8Pn/jLJoHHlIGbBQO7Ht7M6g69i7sReI6VxKU9CW00JDpx1g/qmXf2mIk/+SrXxHO2SL+nBIvLaP9M15/VKFFf7/IT7e/BdzD2Uq5nm9X6UH4Cf3zG4RVAIQ= 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:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(1800799009)(186009)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(70206006)(41300700001)(8936002)(83380400001)(40480700001)(47076005)(36860700001)(336012)(8676002)(4326008)(478600001)(6666004)(6636002)(110136005)(70586007)(26005)(316002)(2616005)(16526019)(426003)(1076003)(54906003)(7696005)(2906002)(356005)(82740400003)(81166007)(921005)(40460700003)(5660300002)(7416002)(36756003)(44832011)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 06:21:42.0884 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96116d53-db0c-4db8-5202-08dba9ea8afc 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8914 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, amd-gfx@lists.freedesktop.org, Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- v10->v11: - downgrade the prompt level on message failure(Lijo) --- .../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 62f2886ab4df..d1a93f961e9e 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] = { @@ -503,6 +505,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) @@ -2179,6 +2184,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_warn(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, @@ -2247,6 +2303,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)