From patchwork Fri Jun 30 10:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10254957vqr; Fri, 30 Jun 2023 03:36:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4k1ff6VEK7GTLB+AcFkZ9mqfVxKMi2s0KOCzznRVBdtPmWTDoBghRGUau7jgYzRPWLrs/A X-Received: by 2002:a05:6a20:1443:b0:12b:e9a0:f04a with SMTP id a3-20020a056a20144300b0012be9a0f04amr2103445pzi.22.1688121378728; Fri, 30 Jun 2023 03:36:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121378; cv=pass; d=google.com; s=arc-20160816; b=id/JevQXq8UPiNMcwhmviGmH6nq4+XETzLb9gxB2Kb+qhSkLUommy8ywvmSy5g5jnF SCpP55UiJrhMNmPeypAYsXdJjyD8pcrlGt+cMs3SMau6tim8hPEiVgChUwpGC6RaKRz+ 1SBg65XoAUynGj1a1r8LbDjq6qFH/jeAPwtMdTJgkjVdUonKVu6vT9Wa6Y+xF/JIY7b7 tuJcpOEi2Ap+wHZDGznHtuim5DmNZNZjbRK2A/J1sM0dhE0/owAMYoQd/Ud7CQMcTx23 pZbxQLApzQ+IRwIOwGKwRJlL2RZU8goG+HTHXrPQOPdPVO0bHtcczTScSjZ8mfkCuiA7 d41A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WsjmQaF5H416mbQpzvFbajOo0W4E/KVXPyHmLYnnRxU=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=te9TZvUrGQdQ/oixqj6bGaovlLhORbE9r5gn1vzH3rboK1NV8OWw987liJOIfdKvat 8y9nLPfkVAsPJKxEHmojuLqB61JF4DcD14NpeEbL1D5Rf7VCFM49lVKlILgnnaAt3i9V HWaogPt1/YmE45mpl+UZpaehdSn1j7EUvHsQZS28R10i5zoKXN/vum273epjn9w5Js8q Uf8m1P9gj1vGe7z6Dz8oon6xyIL6anZbvUfoXjqDkwgccWVhYdUzFcuVg4JjgV05rwKT yLpEtGnFd9dlrD9+ep5CwSZ6WxBnGmthp/c4HUhCyGkV4FBgskvoKXeMyaM6TH8y60st j4hw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=c2jLp+pC; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a170902bf4200b001b68a92c33asi11837619pls.47.2023.06.30.03.36.04; Fri, 30 Jun 2023 03:36:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=c2jLp+pC; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbjF3KeT (ORCPT + 99 others); Fri, 30 Jun 2023 06:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbjF3KeJ (ORCPT ); Fri, 30 Jun 2023 06:34:09 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F1D30C5; Fri, 30 Jun 2023 03:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SEbhnW/jg8BDgex0wS9mf9FSkCFWkha8w2HYYCdSFd4Ixwv0fcfPWYmHuruUdPMF4c6Qb8oYpD7JXUG4ykj0n04zbsU2pudep+w3tNq8/ahVPiArhxKCJ+HROBq9Fig31mMGu7ig7U3019u8qM7Qyv1Ol7YfxZw28w5acE0oeDAyDm5kVNBvtgRKK1CCTZrA+W5R3H+9+Dhze0Ab7rx/aKrD5weg6Pal1/Fj1MmznYVDAF3qj81nyVyDjWvAieq9ypW4Qx6ONYMaHwY298NEhGX8ULzsM2ha+gcEW3wr41h1mhxAU9U0yAzPQhL71sEtjbKuhUBKrMD5Ri378lzxEA== 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=WsjmQaF5H416mbQpzvFbajOo0W4E/KVXPyHmLYnnRxU=; b=nzZxzyJo1VvWMxjtZb5bWNZMIaV3URGpnxeKewNZXWIQ0oGWQGLxhC3XTVD+VgHjkdvBcLdWip+YYoEPavrQNI080oHVaSNs6zsqUqsjUVQsIh+J6c3MP6MUduMMIMCpGMPxEvRyGM87AN5OpV5Jlk6d5TcaiubJaZvTYmzpoEo3uG45TZRp1+AhY374K/1+T9Ot2rwCGfJxmnDPS/tBwrgEYH/r8nicB+ftCNeWGn2OZ8m++eV8hzQ3+wSKLLwcjzWaFQ6EqvOwn5rpjGSs7Yk5TEFw2SEIy5hi9ZUEMA/k30GimD4jzPzhfgC7p+8eg3C2ICIWXISo538GsNnlqA== 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=WsjmQaF5H416mbQpzvFbajOo0W4E/KVXPyHmLYnnRxU=; b=c2jLp+pCNPECeVItVmQ3e9wiXkK+/KFuuI+fqr8iyTBwYusCRPwrHQZp5WKj06TFfcNDCe/KGsS4LWFAHy0/tRh8cJYTleI/wdisVNe4ac8zoWYPuriOx6/2XF1ZGA6y3E5dxTDzvKMf0GjUrWkn5IshlgSav18YgEXVvAirZiE= Received: from DM6PR06CA0032.namprd06.prod.outlook.com (2603:10b6:5:120::45) by IA1PR12MB7565.namprd12.prod.outlook.com (2603:10b6:208:42f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 10:34:02 +0000 Received: from DM6NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::56) by DM6PR06CA0032.outlook.office365.com (2603:10b6:5:120::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:34:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT095.mail.protection.outlook.com (10.13.172.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.49 via Frontend Transport; Fri, 30 Jun 2023 10:34:02 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:33:54 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 1/9] drivers core: Add support for Wifi band RF mitigations Date: Fri, 30 Jun 2023 18:32:32 +0800 Message-ID: <20230630103240.1557100-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT095:EE_|IA1PR12MB7565:EE_ X-MS-Office365-Filtering-Correlation-Id: fc9be6fc-717d-4607-46b1-08db79558590 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xiztqM3CvJZIdcGtstsk5U+5+/vHiEx0hHa9hXI1qQ+m1WZDmJXm1f5UQoyhRFpSe0D/vY46MIaq0M+pdU+uJHfWLxawPtLsiiHBBomicdW8m/3ZjcMEZfNyWG/L3rt1kkQxlYbpzDNSfQMCB/SXIwKbuHU9XaDaYSzTT/bK5t2YUbE5ryKv3FirWa6By3KBea3uqz2iqbrUilQGsdt//Cgqgqk1u4ACp1iMt/BVzqc94sc8xqWEditGPd7nJsd+eUcX+26iZuUBhhVWYVB/QCjQdryJlUAce+LKBjaCPnsWhtWfzlHOPUAKhkjq5zuSbzGSh3pHBAnwZWo8kT5GTrXwVvQLmAunk3TzRtKTM/u1Ellh4uJJMTrLJN357DS/ti9kClY3uLSpfaqqCbGinFnUvTHYBKSqVBjrQHo18keCTHaQb779IqZ5bbYcb8Z4pk705SseEKpkAEL2fKF1YqHhALfoU6g3D9rLvW509dcv996ZuAFVxnx8Mz0zaeXyXt8Gm23lVZ8twPxJlJaNd91w2+7Etn3o3beMmMuWPIxT0p9zDgVTOTPtcWiemB5oiWM2M+QMcaOnxtagB+3+8sWvuGDrZkY/tXPgH0FVmOgD0Fn8bl3yB30zCC7zbCUfIwzgTpHFeBNvQaqfQQOHr2Vuhfy/AJXxSHa9B5sM0WxwQQK7MTIZdeSwbjsa/rJP/aciEGo0aSaZGOpNdcCopJfiiQFMMVjylofmYtcWveQqO1ehhn33OnYGxgHScEepbedm8lZy5tFLU+x5yXwEWnCxDdcfLlRBj32f6RDQcNtHUINLON2fie9kYOdhc5plpNd07B9S681MmyeQnrkDtA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(40470700004)(36840700001)(46966006)(82310400005)(70206006)(70586007)(54906003)(110136005)(7416002)(2906002)(30864003)(44832011)(36756003)(8936002)(316002)(41300700001)(4326008)(478600001)(426003)(336012)(83380400001)(47076005)(921005)(7696005)(356005)(82740400003)(81166007)(6666004)(5660300002)(86362001)(36860700001)(16526019)(8676002)(40460700003)(26005)(1076003)(2616005)(186003)(40480700001)(36900700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:34:02.2282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc9be6fc-717d-4607-46b1-08db79558590 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: DM6NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7565 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770123562533971194?= X-GMAIL-MSGID: =?utf-8?q?1770123562533971194?= Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7. To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance. In order for a device to support this, the expected flow for device driver or subsystems: Drivers/subsystems contributing frequencies: 1) During probe, check `wbrf_supported_producer` to see if WBRF supported for the device. 2) If adding frequencies, then call `wbrf_add_exclusion` with the start and end ranges of the frequencies. 3) If removing frequencies, then call `wbrf_remove_exclusion` with start and end ranges of the frequencies. Drivers/subsystems responding to frequencies: 1) During probe, check `wbrf_supported_consumer` to see if WBRF is supported for the device. 2) Call the `wbrf_retrieve_exclusions` to retrieve the current exclusions on receiving an ACPI notification for a new frequency change. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v4->v5: - promote this to be a more generic solution with input argument taking `struct device` and provide better scalability to support non-ACPI scenarios(Andrew) - update the APIs naming and some other minor fixes(Rafael) --- drivers/base/Kconfig | 8 ++ drivers/base/Makefile | 1 + drivers/base/wbrf.c | 227 ++++++++++++++++++++++++++++++++++++++++++ include/linux/wbrf.h | 65 ++++++++++++ 4 files changed, 301 insertions(+) create mode 100644 drivers/base/wbrf.c create mode 100644 include/linux/wbrf.h diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 2b8fd6bb7da0..5b441017b225 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -242,4 +242,12 @@ config FW_DEVLINK_SYNC_STATE_TIMEOUT command line option on every system/board your kernel is expected to work on. +config WBRF + bool "Wifi band RF mitigation mechanism" + default n + help + Wifi band RF mitigation mechanism allows multiple drivers from + different domains to notify the frequencies in use so that hardware + can be reconfigured to avoid harmonic conflicts. + endmenu diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 3079bfe53d04..c844f68a6830 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_GENERIC_MSI_IRQ) += platform-msi.o obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += arch_topology.o obj-$(CONFIG_GENERIC_ARCH_NUMA) += arch_numa.o obj-$(CONFIG_ACPI) += physical_location.o +obj-$(CONFIG_WBRF) += wbrf.o obj-y += test/ diff --git a/drivers/base/wbrf.c b/drivers/base/wbrf.c new file mode 100644 index 000000000000..2163a8ec8a9a --- /dev/null +++ b/drivers/base/wbrf.c @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include + +static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); +static DEFINE_MUTEX(wbrf_mutex); +static struct exclusion_range_pool wbrf_pool; + +static int _wbrf_add_exclusion_ranges(struct wbrf_ranges_in *in) +{ + int i, j; + + for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { + if (!in->band_list[i].start && + !in->band_list[i].end) + continue; + + for (j = 0; j < ARRAY_SIZE(wbrf_pool.band_list); j++) { + if (wbrf_pool.band_list[j].start == in->band_list[i].start && + wbrf_pool.band_list[j].end == in->band_list[i].end) { + wbrf_pool.ref_counter[j]++; + break; + } + } + if (j < ARRAY_SIZE(wbrf_pool.band_list)) + continue; + + for (j = 0; j < ARRAY_SIZE(wbrf_pool.band_list); j++) { + if (!wbrf_pool.band_list[j].start && + !wbrf_pool.band_list[j].end) { + wbrf_pool.band_list[j].start = in->band_list[i].start; + wbrf_pool.band_list[j].end = in->band_list[i].end; + wbrf_pool.ref_counter[j] = 1; + break; + } + } + if (j >= ARRAY_SIZE(wbrf_pool.band_list)) + return -ENOSPC; + } + + return 0; +} + +static int _wbrf_remove_exclusion_ranges(struct wbrf_ranges_in *in) +{ + int i, j; + + for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { + if (!in->band_list[i].start && + !in->band_list[i].end) + continue; + + for (j = 0; j < ARRAY_SIZE(wbrf_pool.band_list); j++) { + if (wbrf_pool.band_list[j].start == in->band_list[i].start && + wbrf_pool.band_list[j].end == in->band_list[i].end) { + wbrf_pool.ref_counter[j]--; + if (!wbrf_pool.ref_counter[j]) { + wbrf_pool.band_list[j].start = 0; + wbrf_pool.band_list[j].end = 0; + } + break; + } + } + } + + return 0; +} + +static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) +{ + int out_idx = 0; + int i; + + memset(out, 0, sizeof(*out)); + + for (i = 0; i < ARRAY_SIZE(wbrf_pool.band_list); i++) { + if (!wbrf_pool.band_list[i].start && + !wbrf_pool.band_list[i].end) + continue; + + out->band_list[out_idx].start = wbrf_pool.band_list[i].start; + out->band_list[out_idx++].end = wbrf_pool.band_list[i].end; + } + + return 0; +} + +/** + * wbrf_supported_producer - Determine if the device can report frequencies + * + * @dev: device pointer + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if this device needs to report such frequencies. + */ +bool wbrf_supported_producer(struct device *dev) +{ + return true; +} +EXPORT_SYMBOL_GPL(wbrf_supported_producer); + +/** + * wbrf_add_exclusion - Add frequency ranges to the exclusion list + * + * @dev: device pointer + * @in: input structure containing the frequency ranges to be added + * + * Add frequencies into the exclusion list for supported consumers + * to react to. + */ +int wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + int r; + + mutex_lock(&wbrf_mutex); + + r = _wbrf_add_exclusion_ranges(in); + + mutex_unlock(&wbrf_mutex); + if (r) + return r; + + blocking_notifier_call_chain(&wbrf_chain_head, WBRF_CHANGED, NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(wbrf_add_exclusion); + +/** + * wbrf_remove_exclusion - Remove frequency ranges from the exclusion list + * + * @dev: device pointer + * @in: input structure containing the frequency ranges to be removed + * + * Remove frequencies from the exclusion list for supported consumers + * to react to. + */ +int wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + int r; + + mutex_lock(&wbrf_mutex); + + r = _wbrf_remove_exclusion_ranges(in); + + mutex_unlock(&wbrf_mutex); + if (r) + return r; + + blocking_notifier_call_chain(&wbrf_chain_head, WBRF_CHANGED, NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(wbrf_remove_exclusion); + +/** + * wbrf_supported_consumer - Determine if the device can react to frequencies + * + * @dev: device pointer + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will determine if this device needs to react to reports from + * other devices for such frequencies. + */ +bool wbrf_supported_consumer(struct device *dev) +{ + return true; +} +EXPORT_SYMBOL_GPL(wbrf_supported_consumer); + +/** + * wbrf_register_notifier - Register for notifications of frequency changes + * + * @nb: driver notifier block + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will allow consumers to register for frequency notifications. + */ +int wbrf_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(wbrf_register_notifier); + +/** + * wbrf_unregister_notifier - Unregister for notifications of frequency changes + * + * @nb: driver notifier block + * + * WBRF is used to mitigate devices that cause harmonic interference. + * This function will allow consumers to unregister for frequency notifications. + */ +int wbrf_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(wbrf_unregister_notifier); + +/** + * wbrf_retrieve_exclusions - Retrieve the exclusion list + * + * @dev: device pointer + * @out: output structure containing the frequency ranges to be excluded + * + * Retrieve the current exclusion list + */ +int wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) +{ + int r; + + mutex_lock(&wbrf_mutex); + + r = _wbrf_retrieve_exclusion_ranges(out); + + mutex_unlock(&wbrf_mutex); + + return r; +} +EXPORT_SYMBOL_GPL(wbrf_retrieve_exclusions); diff --git a/include/linux/wbrf.h b/include/linux/wbrf.h new file mode 100644 index 000000000000..3ca95786cef5 --- /dev/null +++ b/include/linux/wbrf.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + */ + +#ifndef _LINUX_WBRF_H +#define _LINUX_WBRF_H + +#include + +/* Maximum number of wbrf ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +struct exclusion_range { + /* start and end point of the frequency range in Hz */ + uint64_t start; + uint64_t end; +}; + +struct exclusion_range_pool { + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; + uint64_t ref_counter[MAX_NUM_OF_WBRF_RANGES]; +}; + +struct wbrf_ranges_in { + /* valid entry: `start` and `end` filled with non-zero values */ + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +}; + +struct wbrf_ranges_out { + uint32_t num_of_ranges; + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +} __packed; + +enum wbrf_notifier_actions { + WBRF_CHANGED, +}; + +#ifdef CONFIG_WBRF +bool wbrf_supported_producer(struct device *dev); +int wbrf_add_exclusion(struct device *adev, + struct wbrf_ranges_in *in); +int wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in); +int wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out); +bool wbrf_supported_consumer(struct device *dev); + +int wbrf_register_notifier(struct notifier_block *nb); +int wbrf_unregister_notifier(struct notifier_block *nb); +#else +static inline bool wbrf_supported_producer(struct device *dev) { return false; } +static inline int wbrf_add_exclusion(struct device *adev, + struct wbrf_ranges_in *in) { return -ENODEV; } +static inline int wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) { return -ENODEV; } +static inline int wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) { return -ENODEV; } +static inline bool wbrf_supported_consumer(struct device *dev) { return false; } +static inline int wbrf_register_notifier(struct notifier_block *nb) { return -ENODEV; } +static inline int wbrf_unregister_notifier(struct notifier_block *nb) { return -ENODEV; } +#endif + +#endif /* _LINUX_WBRF_H */ From patchwork Fri Jun 30 10:32:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10257330vqr; Fri, 30 Jun 2023 03:41:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hJTTymBetvbQ+bR1E3b3cuXxZXODez6sgIWgJbg5kvlIDJ2NgqfRm/wI/6AirvgaK8tYz X-Received: by 2002:a05:6a20:938a:b0:126:3eba:748e with SMTP id x10-20020a056a20938a00b001263eba748emr1987810pzh.21.1688121691538; Fri, 30 Jun 2023 03:41:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121691; cv=pass; d=google.com; s=arc-20160816; b=UEmXrb1QKY/+dCQ5hlZZ/ZaT5OrAvrrRAgS3qLIx0Dz1OALsZGwXAynFKXI7HLpw2k f2DeK6c59YB/wi2zJA/qeL3XfG2EZ02JlM0cxzyFAp2VZvY7UD7kSzyorwoA4lntZDuo GBI1WhpgBKhwpsJEPvWvZfkkaQ6a5K2sobOzdOan/1t0W1vT0i+Q139LPcLIOJp7m+nH xvilfnInCQQH4EKgmWOn9FElmGVXJtxrKI0rszV1h9mIqj4G2Up1Q+VfK+YQEZlFEY1R 03oIuF8KzHI6QtbeGBkVDUmHzTCc0a7VjDpZW8hQRW8T7t3kNNvIizwXC3XYGX53dRip 7w1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bhYfZLG0qKeanOUYjubLfrEZXNQFsM0seDnuO72sm2s=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=Q3tXQh334eF2P4mmN8GbLOvIBDtTR8JuU8ErmDFceIpURaM/nCQ9PfqKbR2fi9yAyU cDJwXUPjLgDWB4pwjDT7tieGPQwX46eQ3JjWtZCUUkupk2TUBTJP+kdJAgxTLzUEztic nrhaMUnMcYeMuYhxSWI/0rY8l7GBNgoE5tywNyCTwRYkoVmqm02dWsseoIGeuaTAF2QR MsC1EIH31rjxtMBCy0Pi3o4+7ZJm+H3Olr0QwO545DiD0PTocm/0cHCnCaQfSm0pWgSN Y55qjcSos9xSSOhoWTUlq3BkfUpBsSPOJ2sluQpm8Sk9rLSjJJYaQAxMJmfSnnP6XNIH 7p+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Ri4+xrCu; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a170902b18700b001b69bc74fd7si11450365plr.157.2023.06.30.03.41.17; Fri, 30 Jun 2023 03:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Ri4+xrCu; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232590AbjF3Ked (ORCPT + 99 others); Fri, 30 Jun 2023 06:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbjF3KeR (ORCPT ); Fri, 30 Jun 2023 06:34:17 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 127CC3A94; Fri, 30 Jun 2023 03:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jQQy+Y73KRIZOBHcb69Eroq1ynRsmiVCdztaCeVRyXZT0SHz3tOaqLkYGFLmyjcynBAPnmxK0M6ZJ8sf4qskYU6A3TkTOyWpEN+D/E2ARW6mB8hRl+m4XyRFXEpXOjZEBvmosDAU4rVkzgvUwHum+I1o8lIDcRoZgBKbq3VxZafjG7/PdIwDFDH42dMsbVn5HB1+36dvYVObCYtZc2Kn+s98Fduxd17MJ6UzdK5dHVzYuAA4FJL081v3+bw6ubrDQDG/UvUGcR95oGi5oEahPvm52d6p3iFvga6lK7FSkj/kl7lyADQh+IIzOfsyenhNdeZs+0Eam52BvFyFQxDZ7w== 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=bhYfZLG0qKeanOUYjubLfrEZXNQFsM0seDnuO72sm2s=; b=iG5ksWvak3XjGIPZJF+E0u10Qk4VYBmIMmM3e/wGH64VXkHQpUABs+ZGtK9qcDACCKlXoHL8xORIifYgVCtlJ/CWnnR0LVOXz0Y+QxMfXL9ytdsX27jm5Ngd8UTeIpWdmzaM9NXVQfTw/NqzDwzpsvgfpORyGVkUAp+5F9oQrcu6KrFVEngt4mwwF0VsBSLkFuu8kNPvZAAY+BSE9wYoo220yEJR2vmUgOWJZgGycIfSK9k/oVN5jbjXH1XqOdhn5RD/98tTauKghl6jgg/t6ixprDONM367lt1b2wxWucX84ntVTN9R5Ojnr2+4rpSJyBx95oj2F4Yzeix/97FVGw== 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=bhYfZLG0qKeanOUYjubLfrEZXNQFsM0seDnuO72sm2s=; b=Ri4+xrCuI9Sd66sTPnVp/I3/TevySYYV/xqBsl50VJJp69DUTa3l+HI/H9ShhFRpEdGqDEgjQZNWUwkTMBI7DQ5pqkIkfEZTfOyRhZ9Z4FnUmPnm/hnXDp4ZcYJdX3Ud906Y/Wbrnmq9IyyKluXtC4+Uw+N27TXgt7MKEb9KOeA= Received: from DM6PR18CA0004.namprd18.prod.outlook.com (2603:10b6:5:15b::17) by MW6PR12MB7086.namprd12.prod.outlook.com (2603:10b6:303:238::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 10:34:11 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::95) by DM6PR18CA0004.outlook.office365.com (2603:10b6:5:15b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:34:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.49 via Frontend Transport; Fri, 30 Jun 2023 10:34:10 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:34:02 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 2/9] driver core: add ACPI based WBRF mechanism introduced by AMD Date: Fri, 30 Jun 2023 18:32:33 +0800 Message-ID: <20230630103240.1557100-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT010:EE_|MW6PR12MB7086:EE_ X-MS-Office365-Filtering-Correlation-Id: 95a2c99d-3c5c-4729-40c4-08db79558ac9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jmE2Zvdiy5ZZBhHV4KOVMI81ACGR95wqDQ/bpfPobVNvm/YefXw0/69Tbp8pOcu8bZkWOkIXXd/SWQKgiBvCy/sf8QKU/rbGG9mrwseBBSCkkMXPgeB7WmL8soNxwcT9zK7PFz7gCyDfmUv3dQe2sX9WWRHcQvYgjcqEAPgp70AY5c79QwXQdc8ESCsCW1XdJI58AZdcpNQ42ngSmoPal5sy/yNxcRW3cRNT8m6sftv+2YyWm/IlyMTtRU8OBiV/WKC0vCCFg+zCVrcOejhnigTjXC9tsr4VZtUr6XYbi5xOqUxunONQdvhdSn1wc00h1O0e1LwvQWT5T0VpQYbSxMIzMTHedodSau96LXZQBPdVG47WTNvvc/f/8lGSSaj6uZMHmb+1n4dqjErFMh8eNxevFGdvYUp5wlR5GiH/Il5lyZ+gxdpNuqQibpqnRhTA9d0L12ZB/SoSYMUMGd92Fh9jNziHW5MyK7e3zYyAqD3a4UKj2Mfw3S0eci7gVYtZVngxanjGZcGcrXxXhAf7hOXDGE41WxYXn8INxGMjna4dwgdWvb4mX/+CwTT2h90kJG9FiuMPMIS5O3CKxvpRGkl9hL2tWxDgT7ave59it7rCkUM7tN2cPeAVmMpBHI4eIsEg6ricFNBWLQAJ4t6fX8BJOJEXygOISfvFhIwPe3Dwg6bKRh3b9p38SVLX7T1mBOT176610m2Q0DVCQDCwtHGS+aC8Vk1/0iywuEfDnGdwER8I7VfbFrgSmv4gsGmrumWLSaygrG+wiR2G3CLLlCE00SLFruiFxJOFnUmno5A78m4iRPiECScmPpNyPosQjxYVpXbyQC5I2EeATSls3w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199021)(46966006)(40470700004)(36840700001)(66899021)(41300700001)(36860700001)(16526019)(82310400005)(36756003)(40460700003)(316002)(70206006)(81166007)(7416002)(30864003)(5660300002)(44832011)(921005)(356005)(8936002)(86362001)(8676002)(70586007)(40480700001)(4326008)(82740400003)(47076005)(1076003)(2906002)(478600001)(83380400001)(2616005)(26005)(186003)(426003)(6666004)(7696005)(110136005)(336012)(54906003)(36900700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:34:10.9902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 95a2c99d-3c5c-4729-40c4-08db79558ac9 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: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB7086 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770123890867882978?= X-GMAIL-MSGID: =?utf-8?q?1770123890867882978?= AMD has introduced an ACPI based mechanism to support WBRF for some platforms with AMD dGPU + WLAN. This needs support from BIOS equipped with necessary AML implementations and dGPU firmwares. For those systems without the ACPI mechanism and developing solutions, user can use the generic WBRF solution for diagnosing potential interference issues. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v4->v5: - promote this to be a more generic solution with input argument taking `struct device` and provide better scalability to support non-ACPI scenarios(Andrew) - update the APIs naming and some other minor fixes(Rafael) --- drivers/acpi/Makefile | 2 + drivers/acpi/amd_wbrf.c | 236 ++++++++++++++++++++++++++++++++++ drivers/base/Kconfig | 29 +++++ drivers/base/wbrf.c | 35 ++++- include/linux/acpi_amd_wbrf.h | 38 ++++++ include/linux/wbrf.h | 2 + 6 files changed, 336 insertions(+), 6 deletions(-) create mode 100644 drivers/acpi/amd_wbrf.c create mode 100644 include/linux/acpi_amd_wbrf.h diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index feb36c0b9446..94b940ddbf88 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -131,3 +131,5 @@ obj-y += dptf/ obj-$(CONFIG_ARM64) += arm64/ obj-$(CONFIG_ACPI_VIOT) += viot.o + +obj-$(CONFIG_WBRF_AMD_ACPI) += amd_wbrf.o diff --git a/drivers/acpi/amd_wbrf.c b/drivers/acpi/amd_wbrf.c new file mode 100644 index 000000000000..44e38c97acf0 --- /dev/null +++ b/drivers/acpi/amd_wbrf.c @@ -0,0 +1,236 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include + +/* functions */ +#define WBRF_RECORD 0x1 +#define WBRF_RETRIEVE 0x2 + +/* record actions */ +#define WBRF_RECORD_ADD 0x0 +#define WBRF_RECORD_REMOVE 0x1 + +#define WBRF_REVISION 0x1 + +static const guid_t wifi_acpi_dsm_guid = + GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c, + 0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70); + +static int wbrf_dsm(struct acpi_device *adev, u8 fn, + union acpi_object *argv4, + union acpi_object **out) +{ + union acpi_object *obj; + int rc; + + obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, fn, argv4); + if (!obj) + return -ENXIO; + + switch (obj->type) { + case ACPI_TYPE_BUFFER: + *out = obj; + return 0; + + case ACPI_TYPE_INTEGER: + rc = obj->integer.value ? -EINVAL : 0; + break; + + default: + rc = -EOPNOTSUPP; + } + + ACPI_FREE(obj); + + return rc; +} + +static int wbrf_record(struct acpi_device *adev, uint8_t action, + struct wbrf_ranges_in *in) +{ + union acpi_object *argv4; + uint32_t num_of_ranges = 0; + uint32_t arg_idx = 0; + uint32_t 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++; + + argv4 = kzalloc(sizeof(*argv4) * (2 * num_of_ranges + 2 + 1), GFP_KERNEL); + if (!argv4) + return -ENOMEM; + + argv4[arg_idx].package.type = ACPI_TYPE_PACKAGE; + argv4[arg_idx].package.count = 2 + 2 * num_of_ranges; + argv4[arg_idx++].package.elements = &argv4[1]; + argv4[arg_idx].integer.type = ACPI_TYPE_INTEGER; + argv4[arg_idx++].integer.value = num_of_ranges; + argv4[arg_idx].integer.type = ACPI_TYPE_INTEGER; + argv4[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; + + argv4[arg_idx].integer.type = ACPI_TYPE_INTEGER; + argv4[arg_idx++].integer.value = in->band_list[loop_idx].start; + argv4[arg_idx].integer.type = ACPI_TYPE_INTEGER; + argv4[arg_idx++].integer.value = in->band_list[loop_idx].end; + } + + ret = wbrf_dsm(adev, WBRF_RECORD, argv4, NULL); + + kfree(argv4); + + return ret; +} + +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return -ENODEV; + + return wbrf_record(adev, WBRF_RECORD_ADD, in); +} + +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return -ENODEV; + + return wbrf_record(adev, WBRF_RECORD_REMOVE, in); +} + +bool acpi_amd_wbrf_supported_producer(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return false; + + return acpi_check_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, + BIT(WBRF_RECORD)); +} + +static union acpi_object * +acpi_evaluate_wbrf(acpi_handle handle, u64 rev, u64 func) +{ + acpi_status ret; + struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; + union acpi_object params[4]; + struct acpi_object_list input = { + .count = 4, + .pointer = params, + }; + + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = rev; + params[1].type = ACPI_TYPE_INTEGER; + params[1].integer.value = func; + params[2].type = ACPI_TYPE_PACKAGE; + params[2].package.count = 0; + params[2].package.elements = NULL; + params[3].type = ACPI_TYPE_STRING; + params[3].string.length = 0; + params[3].string.pointer = NULL; + + ret = acpi_evaluate_object(handle, "WBRF", &input, &buf); + if (ACPI_SUCCESS(ret)) + return (union acpi_object *)buf.pointer; + + return NULL; +} + +static bool check_acpi_wbrf(acpi_handle handle, u64 rev, u64 funcs) +{ + int i; + u64 mask = 0; + union acpi_object *obj; + + if (funcs == 0) + return false; + + obj = acpi_evaluate_wbrf(handle, rev, 0); + if (!obj) + return false; + + if (obj->type != ACPI_TYPE_BUFFER) + return false; + + /* + * Bit vector providing supported functions information. + * Each bit marks support for one specific function of the WBRF method. + */ + for (i = 0; i < obj->buffer.length && i < 8; i++) + mask |= (((u64)obj->buffer.pointer[i]) << (i * 8)); + + ACPI_FREE(obj); + + /* + * Bit 0 indicates whether there's support for any functions other than + * function 0. + */ + if ((mask & 0x1) && (mask & funcs) == funcs) + return true; + + return false; +} + +bool acpi_amd_wbrf_supported_consumer(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return false; + + return check_acpi_wbrf(adev->handle, + WBRF_REVISION, + BIT(WBRF_RETRIEVE)); +} + +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + union acpi_object *obj; + + if (!adev) + return -ENODEV; + + obj = acpi_evaluate_wbrf(adev->handle, + WBRF_REVISION, + WBRF_RETRIEVE); + if (!obj) + return -EINVAL; + + WARN(obj->buffer.length != sizeof(*out), + "Unexpected buffer length"); + memcpy(out, obj->buffer.pointer, obj->buffer.length); + + ACPI_FREE(obj); + + return 0; +} diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 5b441017b225..cbf0b2358c17 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -250,4 +250,33 @@ config WBRF different domains to notify the frequencies in use so that hardware can be reconfigured to avoid harmonic conflicts. +config WBRF_AMD_ACPI + bool "Use the ACPI mechanism introduced by AMD to support WBRF" + default n + depends on ACPI + select WBRF + help + AMD has introduced an ACPI based mechanism to support WBRF for some + platforms with AMD dGPU and WLAN. This needs support from BIOS equipped + with necessary AML implementations and dGPU firmwares. + + Say Y to enable this ACPI based mechanism. It is suggested to confirm + with the hardware designer/provider first whether your platform + equipped with necessary BIOS and firmwares. + +config WBRF_GENERIC + bool "Use the generic WBRF solution" + default n + depends on !WBRF_AMD_ACPI + select WBRF + help + Ideally it is the hardware designer/provider who should provide a + solution for the possible RF interference issue. Since they know + well whether there could be RF interference issue with their + platforms. + + Say Y to enable this generic WBRF solution for diagnosing potential + interference issues on systems without the ACPI mechanism and + developing solutions. + endmenu diff --git a/drivers/base/wbrf.c b/drivers/base/wbrf.c index 2163a8ec8a9a..d9fab9f3045e 100644 --- a/drivers/base/wbrf.c +++ b/drivers/base/wbrf.c @@ -6,9 +6,12 @@ */ #include +#include static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); static DEFINE_MUTEX(wbrf_mutex); + +#if defined(CONFIG_WBRF_GENERIC) static struct exclusion_range_pool wbrf_pool; static int _wbrf_add_exclusion_ranges(struct wbrf_ranges_in *in) @@ -89,6 +92,7 @@ static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) return 0; } +#endif /** * wbrf_supported_producer - Determine if the device can report frequencies @@ -100,7 +104,12 @@ static int _wbrf_retrieve_exclusion_ranges(struct wbrf_ranges_out *out) */ bool wbrf_supported_producer(struct device *dev) { +#ifdef CONFIG_WBRF_AMD_ACPI + return acpi_amd_wbrf_supported_producer(dev); +#elif defined(CONFIG_WBRF_GENERIC) return true; +#endif + return false; } EXPORT_SYMBOL_GPL(wbrf_supported_producer); @@ -116,12 +125,15 @@ EXPORT_SYMBOL_GPL(wbrf_supported_producer); int wbrf_add_exclusion(struct device *dev, struct wbrf_ranges_in *in) { - int r; + int r = -ENODEV; mutex_lock(&wbrf_mutex); +#ifdef CONFIG_WBRF_AMD_ACPI + r = acpi_amd_wbrf_add_exclusion(dev, in); +#elif defined(CONFIG_WBRF_GENERIC) r = _wbrf_add_exclusion_ranges(in); - +#endif mutex_unlock(&wbrf_mutex); if (r) return r; @@ -144,12 +156,15 @@ EXPORT_SYMBOL_GPL(wbrf_add_exclusion); int wbrf_remove_exclusion(struct device *dev, struct wbrf_ranges_in *in) { - int r; + int r = -ENODEV; mutex_lock(&wbrf_mutex); +#ifdef CONFIG_WBRF_AMD_ACPI + r = acpi_amd_wbrf_remove_exclusion(dev, in); +#elif defined(CONFIG_WBRF_GENERIC) r = _wbrf_remove_exclusion_ranges(in); - +#endif mutex_unlock(&wbrf_mutex); if (r) return r; @@ -171,7 +186,12 @@ EXPORT_SYMBOL_GPL(wbrf_remove_exclusion); */ bool wbrf_supported_consumer(struct device *dev) { +#ifdef CONFIG_WBRF_AMD_ACPI + return acpi_amd_wbrf_supported_consumer(dev); +#elif defined(CONFIG_WBRF_GENERIC) return true; +#endif + return false; } EXPORT_SYMBOL_GPL(wbrf_supported_consumer); @@ -214,12 +234,15 @@ EXPORT_SYMBOL_GPL(wbrf_unregister_notifier); int wbrf_retrieve_exclusions(struct device *dev, struct wbrf_ranges_out *out) { - int r; + int r = -ENODEV; mutex_lock(&wbrf_mutex); +#ifdef CONFIG_WBRF_AMD_ACPI + r = acpi_amd_wbrf_retrieve_exclusions(dev, out); +#elif defined(CONFIG_WBRF_GENERIC) r = _wbrf_retrieve_exclusion_ranges(out); - +#endif mutex_unlock(&wbrf_mutex); return r; diff --git a/include/linux/acpi_amd_wbrf.h b/include/linux/acpi_amd_wbrf.h new file mode 100644 index 000000000000..c274093972e3 --- /dev/null +++ b/include/linux/acpi_amd_wbrf.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#ifndef _ACPI_AMD_WBRF_H +#define _ACPI_AMD_WBRF_H + +#include + +#ifdef CONFIG_WBRF_AMD_ACPI +bool acpi_amd_wbrf_supported_consumer(struct device *dev); +bool acpi_amd_wbrf_supported_producer(struct device *dev); +int acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in); +int acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in); +int acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out); +#else +static inline bool +acpi_amd_wbrf_supported_consumer(struct device *dev) { return false; } +static inline bool +acpi_amd_wbrf_supported_producer(struct device *dev) {return false; } +static inline int +acpi_amd_wbrf_remove_exclusion(struct device *dev, + struct wbrf_ranges_in *in) { return -ENODEV; } +static inline int +acpi_amd_wbrf_add_exclusion(struct device *dev, + struct wbrf_ranges_in *in) { return -ENODEV; } +static inline int +acpi_amd_wbrf_retrieve_exclusions(struct device *dev, + struct wbrf_ranges_out *out) { return -ENODEV; } +#endif + +#endif /* _ACPI_AMD_WBRF_H */ diff --git a/include/linux/wbrf.h b/include/linux/wbrf.h index 3ca95786cef5..f71ac2343b29 100644 --- a/include/linux/wbrf.h +++ b/include/linux/wbrf.h @@ -18,10 +18,12 @@ struct exclusion_range { uint64_t end; }; +#if defined(CONFIG_WBRF_GENERIC) struct exclusion_range_pool { struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; uint64_t ref_counter[MAX_NUM_OF_WBRF_RANGES]; }; +#endif struct wbrf_ranges_in { /* valid entry: `start` and `end` filled with non-zero values */ From patchwork Fri Jun 30 10:32:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10255150vqr; Fri, 30 Jun 2023 03:36:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4kvbUoG+kifYFJdeQ88jOR88pZ45+G4ZXJds2d/Tw4T8UfouhoJSinsQI0sAslm1ooRllX X-Received: by 2002:a9d:77cf:0:b0:6b7:6e07:4951 with SMTP id w15-20020a9d77cf000000b006b76e074951mr2694330otl.25.1688121402415; Fri, 30 Jun 2023 03:36:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121402; cv=pass; d=google.com; s=arc-20160816; b=R3801ARuYcP9dLzq93etJ0CIEB4WFKMmB5uTch2wurs5yHoHEbo5zhxXrSNuzBS4aQ VkAg6oOUCnfHD576/CVm9KrRdu3SuUNP6lBpFMyl91YKERhjrfquZmoL0PLMArlJUWRw Pl5hCN9KzyXWwtFOhLwOv7CbQ0969hsQrfssZjnche1mPg3ZG7Py1tOGw2nVUen1vhrF OtenL1Q+yh2OSnMZ/Y8ErPIVh5oPp+wPF8a5hQ9TQHNe0VPAqo2dmEVCMBy9Wq6hzBwg vV8XgBBgFQosZOmwTIoFceicjSiPldRUExJv6U9f3UlW3xO5FCDt81SkD3Z1UMcXcYGN faeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; fh=tZamKbvZatpQvAZ+RR1feUGppizA8+3zYl3Ia8p51XE=; b=B6ecWuAIfevrDsQ8yKgik34B8biHf+LuI9NBWYdeiz7g8fdB9+EtpOU+3tYfcxy3YI FXcOTSGsUyxULwvFAQkznC7S8Tq4jH8DBVZO3V1oLLHFBA+31rrbd63OlsjEwih2I4Wt STEUs+DmwOz57LVskLzsYVzcq3SeVOHTHTdf5Y+HfgfQNnPx7kDDIiXsnCWrV0+79A84 2Q+1pYtJUO4VAw1VUowDdjJRRC8Mo9MQLlhXBdALPKXmDOrIlljOiV5NRHZRHwSVED2h /mhxJAKJIxAOSLfb2euXYGTeiCsGjVqEWbtGJbjDgrPfSPAihAJz1QTWVHcflMNrgJM1 IfLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rTCowzhn; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a630c04000000b00528d0d8b7bbsi12016605pgl.595.2023.06.30.03.36.29; Fri, 30 Jun 2023 03:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rTCowzhn; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232536AbjF3Keq (ORCPT + 99 others); Fri, 30 Jun 2023 06:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232563AbjF3Keh (ORCPT ); Fri, 30 Jun 2023 06:34:37 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2057.outbound.protection.outlook.com [40.107.220.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D53E30DD; Fri, 30 Jun 2023 03:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NWtMc0Zaw6/Pth9VSmhIJF3J0wD802OpLVQrVAfJZ6j1NLPm5k2Qo8EtlVXQHC2m3U0c081fIy2viLe+I9cu6yec10hT/aeXa9myLPRyszN3Td2Cxa6LQjd6E4N+DHsFr10S9rMFToEHqu9OT3E915a8QNRpIjvL3/uuEKxVb2vdk90CslTjsxtvjwCRg5zfNMe3NYoZ1icqdIH8dj4KGBv8pd4LPzD9cQrYNfd2Mpsru1P4LE7cMu88X1j3L2ANVOxM5CHYuEv4YZ8KVjISAZYKOHFcYzkMrDTPaMs4RCGA3DvMZA3SsUQv84BOywsvt/yoJJb0PUjZGX6+gXq6lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=cAycHEny0G5gxvP2lDPK7jeIKjQha6nSEg2dlVZiamO2sQTQ70Lj/IwSfvjp7mAddTqZCpT6dhXma3CLMu7y+sXuDMN5CdLnMz294H16AXmkL4FtspHTZ/ndOXWo8gwtAAFWDKpJLPJodNoIJ/nzFX8hsCrMvg366PfYB3Ms9Jk1xPdV9lBUhhvn4stKUDYoGDiVI3WE3j81x+CX5/B63TOXUoojQfoPj4gimddn87XjV8pT1KnH2xdllHIzg3e4utR8EaRb9ZfejdmcaT46ScjC4zfZSik7bZqyjj1nFSLllK7g/7gieYBgoUnVMWa/OfGu12C4OT0NJrknJR6Qpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=rTCowzhnDQoiPYBFFq5s9WBfTp3gJWfxLdkdKy/hZnnUAbGCBGamVYnCktst80NRDCyTy3QNbyPDbJbX9NRhOmp8XFnEUUE1/RTqyjEmotJ5FDraMZ7zJNGw5E8gFQLYrs2k9gYlPZohvLcfnv2c4B98ybaAOE3BHEHBbwREMZw= Received: from BYAPR05CA0085.namprd05.prod.outlook.com (2603:10b6:a03:e0::26) by IA1PR12MB6140.namprd12.prod.outlook.com (2603:10b6:208:3e8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 10:34:33 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:e0:cafe::ab) by BYAPR05CA0085.outlook.office365.com (2603:10b6:a03:e0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.10 via Frontend Transport; Fri, 30 Jun 2023 10:34: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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.50 via Frontend Transport; Fri, 30 Jun 2023 10:34:32 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:34:09 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V5 3/9] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing Date: Fri, 30 Jun 2023 18:32:34 +0800 Message-ID: <20230630103240.1557100-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT050:EE_|IA1PR12MB6140:EE_ X-MS-Office365-Filtering-Correlation-Id: f455329f-e084-4063-cc58-08db79559797 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kIJxXKLc0HPVNAoT+yvortIcRzQkHoI047h52HmQX4N1GcrapD60p6ejfoy57QEBBXVaPZ424bsYWpgDZvUl0LrzSnELnUPQfR/GXm52nxQ9OHHeH0cGUqB3dgVFZ/jCzBjxxrbxOcX3ABq91/lRetW5zrOLGa72R+yV8YLW6k6q5Uf1i/W7Xjr9MSXDiscrZjZB+Z+U5E6FvFMHRl9r4dM4gNVPogOiP9gQHUejg+UK7lW9eLg0+kiEbv+I8s6I67DDGwLBdbQForl94G/fyFM9cigqKmrIDPMFGdEYpYi/iBqnRpvMQXCtb5bLLhho9VhFLALWhKPeKwylGGw97W/emW0UdEFXWpJ53mrVMwi+7D+HMrL8GrNt68WDzW8WXzZeKbwABQjOFlEA3jK3yo31pZXUDJEwlmCBvwckub8dsoxpXBF+bZp1VCPtXiauqgn7fmq709NEzqmcKF2mdclBuJNjO8pz6UpfIpe/PvzIwfcbH93VjTK5ODi6GdYwDj6M4Lv4sNUpkXuOgO62P0S/96mAYw7XEW1icwecqkTS7peRgrtbFer8sRx9bABPOnpIoYAgO7rLYom6DYb8ELvVINNA0xt/9y3xTNfnpIUO78g557OF0slvI76Yb3GxUnb34RkpX/RpB05oI3IklEY1jK0jepZGKaMQN2+91O2Cp0tfNTDNeq7AdwKrdrpGHxmL9S3wqvaXXSbMzDlAZU/Ld4IbTxRb8EB5lUu4A85VFeU/8QEGLOfpIdKgoFdcAPmtFoVYYFVRvnpAEgBXGRxhc4o/0Iym1LtWwiwo5xP8BsA3I78zysEQkPIIUljo/P50AVRmi7CzPFq9h/x/Wg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199021)(36840700001)(46966006)(40470700004)(5660300002)(1076003)(7416002)(44832011)(70586007)(316002)(36756003)(4326008)(478600001)(70206006)(8936002)(8676002)(86362001)(2906002)(26005)(110136005)(54906003)(40460700003)(41300700001)(36860700001)(40480700001)(7696005)(6666004)(82310400005)(356005)(186003)(336012)(426003)(47076005)(16526019)(82740400003)(83380400001)(921005)(81166007)(2616005)(36900700001)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:34:32.4764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f455329f-e084-4063-cc58-08db79559797 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6140 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770123588069256150?= X-GMAIL-MSGID: =?utf-8?q?1770123588069256150?= The newly added WBRF feature needs this interface for channel width calculation. Signed-off-by: Evan Quan --- include/net/cfg80211.h | 8 ++++++++ net/wireless/chan.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9e04f69712b1..c6dc337eafce 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -920,6 +920,14 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** + * nl80211_chan_width_to_mhz - get the channel width in Mhz + * @chan_width: the channel width from &enum nl80211_chan_width + * Return: channel width in Mhz if the chan_width from &enum nl80211_chan_width + * is valid. -1 otherwise. + */ +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width); + /** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 0b7e81db383d..227db04eac42 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef) return true; } -static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) { int mhz; @@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) } return mhz; } +EXPORT_SYMBOL(nl80211_chan_width_to_mhz); static int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c) { From patchwork Fri Jun 30 10:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10255269vqr; Fri, 30 Jun 2023 03:36:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlER7YSXCT5ASHy3Iy8HSsWHsyyJ1lI6IxLlvivJU5z3Yv4PKeyjkC9zwnIbzbTFYgtAguHS X-Received: by 2002:a17:902:b711:b0:1ae:50cc:455 with SMTP id d17-20020a170902b71100b001ae50cc0455mr1209992pls.39.1688121416756; Fri, 30 Jun 2023 03:36:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121416; cv=pass; d=google.com; s=arc-20160816; b=cdTECKXmnw9tsO3sQ35znRgeKRsk1loQSc8nzYc4npUX8YF6H6hjZJZyK6QOWur2Dt hG9IXlDI/t9t29tpI9o+lyleY8ciB30BN4TqXgsjmgnhjC+65ggSVK3bCA5mppVswvv/ KGw/t1cE6hQb7rGWgD5VWmhL/bsaxCSHDhnB2Kndu+M+WYm1GedUsJuKvdC82THdYuwH 2UOLrjn9MAdZXcfKHb0LCTsaGGiUKy3aMBJaRYGoXHSJa0GT+gXfpbvQPJNHWN30OT96 pHYStonriP5kQlvu0T37pxsDFAcRHzawDZiIVm8Utx0xnIv5CrdfVf+cjj9pv9UuM83K IkkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/ucv2D8bHZwMRnkFoviWKHtr5t08ZHdG8lQ3sb1FmBI=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=hA2KbsytUR8sceyXOsjtb0oY/gT+Wv1gGAeJtAqA5eP9v7WPqir9A4cWnKkYaF+lIK Wtyitg+dPMj11CrbFhf3BTmnLhRrAsjznpK8KnaXjBCAtR1w3qEVaW4HxT76I/mQ6oLp fmpC9sNd+l6Xl5U6C9hOxkQdd1P8YDEmWz3mHIzGnXqsYgs+hdokyNA3JaWHXnWkUKXt zVQlycY+tgDkdzoUVZRGAFEPvOIY0mZnnzzc3RhjSzMLCKovHmiu4e1btdDi9UmVBHYI mYBiiTLEEKyy6aNq5xR9Rd0s9bQiKyp+ZeqlJkBV4O0gLvotkRidARlRAQtjd0Csu3Dq TqSA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=CC56dxcR; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020a170902c40300b001b665d8d63asi13434490plk.356.2023.06.30.03.36.44; Fri, 30 Jun 2023 03:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=CC56dxcR; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbjF3KfE (ORCPT + 99 others); Fri, 30 Jun 2023 06:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbjF3Keo (ORCPT ); Fri, 30 Jun 2023 06:34:44 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDBA2359E; Fri, 30 Jun 2023 03:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FtPMvlnu0h2B2fUiZjCmC9xwqk8wOFRmkpKU0k3lvEWuRx4rxHMSLg8r4o72wp4I2An6yeti8UwHsPWdRy58WheHLZGeSqvzmxQw1YvbMP8caLl6vtOc9m8PUO7vvYAnYMxeNB6p3zYPzQ5hxA+Wx4I89Yw10DzYDnKYLfOT0QApxQuNnD7Yx2KbwZttCJugj5F7yk8TfvtJjp7+X1XFvvAXYsHG2J/fxhDaRIIpb6Klr/HiOQW5o4GhUQ2c56CfhODaB4LOqe9+PTFE0R0vRgbAv26oC+z9GJZifd2qNBdpXQ3XQheHF4irgwb5XAGXX3n8lqqHnC0yapv5zTlA9w== 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=/ucv2D8bHZwMRnkFoviWKHtr5t08ZHdG8lQ3sb1FmBI=; b=ilIf0V6owmMSIoxA2dJnuZYUKHLQ4mEUDL5/Jo7GwKcP1ZHO3u9HTxCfQ1Ziq7su4893BmxgJgeVtTjy80aZb85czOWvRh1pRYr/5dPD8J116QEV1LTnJrkvpgoAlVP07FUJzzWvld7vOGlsUmYJah7J3sESP/pBdD6gHBLpNvxrSS1U1zpxfsmgbDabDsGEa+sB4QoP9nqBpC23vEjnHuDkfxLhTSkzlVnzUFfbJ78m1mRz48XqMomaRJNK7mBZp25gAYF9uCoatHzaXJv6/nuqdS4eL2Y+lGIspjfLJc1GMixbOxhlO5czE2Tg3P23dGEUwNrBVOAxtqNWD01NEA== 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=/ucv2D8bHZwMRnkFoviWKHtr5t08ZHdG8lQ3sb1FmBI=; b=CC56dxcR8NsOpeQYIf5YDFekWRgbQJSelLaTgjum/wMKH9651caiTkqXEjIOuxcDj0ECfY/PQTv0bXaB7+Fk29Lp2PHISJTp2V8bkIivrSAcvKV8ZQGtAYzniRySa3zyyRLHFBwVZDpMK9XleOg2ZG0TEW2AkHjyfKr7kzCF69o= Received: from DS7PR03CA0006.namprd03.prod.outlook.com (2603:10b6:5:3b8::11) by DM4PR12MB6039.namprd12.prod.outlook.com (2603:10b6:8:aa::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 10:34:40 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b8:cafe::2c) by DS7PR03CA0006.outlook.office365.com (2603:10b6:5:3b8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:34:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.49 via Frontend Transport; Fri, 30 Jun 2023 10:34:39 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:34:32 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 4/9] wifi: mac80211: Add support for ACPI WBRF Date: Fri, 30 Jun 2023 18:32:35 +0800 Message-ID: <20230630103240.1557100-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT025:EE_|DM4PR12MB6039:EE_ X-MS-Office365-Filtering-Correlation-Id: b6499c45-de03-4627-2136-08db79559c0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O5wrxH+SJ8IL68G6g26asHmsDACSsJ4fg4BSc2JS9/g1X//OKh48q3TIHaERW4DKRKTk0KlzOrtNqmNw1Hx8zdpp3Ge613AQcBbP0HTT+0wh6vcTxZ/7OeDPGJ/moQ6J+Lhb1v/bMdC1kfooJ8mDQ5mPWHK0bnAkcmm4lCC5aHHc/i8HGdXEr4OTeEl10QqC5AA0xk1yxttXh5vuUj1dCVDC9qq1cI/rBHm3RKpsJ5DFY1FpQfdM/6upTHTry1Eohx20DsvkhQOXFJ6p9YVcSR5o7Envc8j+gjSbsoXus4GDgX960jXhVzFKw9LygDzUMvN9dqZz8VXkj904DvZW6d2in9Ptq1ZDnMWzME3AayCxxevYY13Ulee7lmzouTngsmvQ+t3Tw/6QCScmlb8bCQMIqxBmKbyaBfyO4nL1mgYrYKZe/9a6OqGMON/j9apiSpGz25tub4NtYL1IO8frX8ip+3ekQE6a4mH2LnoMVNsmkZHXLYZ4z17RTT4NW+kbedoV+p2K7pw0E5M1ZXXfwl+XHzEWNGwHP85ToMszgj1UH79btiF/bWgMdBEtjc6DQL1Epl0CRb3l3TmXRHofnIp6hx2rcAjg7NU30kejYByWy8v/jcZ2uRWPoucb5pqDUCA+JX7JRjGGQOeFy23Izav1Hd8s8M3xHBTCDKB0/EABhgBTf4okjgbIz0XtqvzSkTeDLiWoCFfGy1aBi47hoA+3RkAyiQDv70X1mLwniLzqRvZIYg34YDXqa4PCLnVfshvmcHYuXrV+CnOnIUrwZnLyoK9rc5RJ+gCDAqc4LCn6RgTsGC92m0qRw3zYRv+E8kkTO+MYIClA18JOjWjSIQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199021)(46966006)(36840700001)(40470700004)(5660300002)(7416002)(316002)(70206006)(70586007)(8676002)(44832011)(8936002)(2906002)(41300700001)(40480700001)(40460700003)(82310400005)(356005)(81166007)(82740400003)(921005)(86362001)(36756003)(36860700001)(186003)(26005)(7696005)(478600001)(1076003)(16526019)(4326008)(110136005)(54906003)(47076005)(2616005)(83380400001)(336012)(426003)(2101003)(36900700001)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:34:39.9563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6499c45-de03-4627-2136-08db79559c0d 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: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6039 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770123602801745617?= X-GMAIL-MSGID: =?utf-8?q?1770123602801745617?= To support AMD's WBRF interference mitigation mechanism, Wifi adapters utilized in the system must register the frequencies in use(or unregister those frequencies no longer used) via the dedicated APCI calls. So that, other drivers responding to the frequencies can take proper actions to mitigate possible interference. Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v1->v2: - place the new added member(`wbrf_supported`) in ieee80211_local(Johannes) - handle chandefs change scenario properly(Johannes) - some minor fixes around code sharing and possible invalid input checks(Johannes) v2->v3: - drop unnecessary input checks and intermediate APIs(Mario) - Separate some mac80211 common code(Mario, Johannes) v3->v4: - some minor fixes around return values(Johannes) --- include/linux/ieee80211.h | 1 + net/mac80211/Makefile | 2 + net/mac80211/chan.c | 9 ++++ net/mac80211/ieee80211_i.h | 19 +++++++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 103 +++++++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index c4cf296e7eaf..0703921547f5 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -4319,6 +4319,7 @@ static inline int ieee80211_get_tdls_action(struct sk_buff *skb, u32 hdr_size) /* convert frequencies */ #define MHZ_TO_KHZ(freq) ((freq) * 1000) #define KHZ_TO_MHZ(freq) ((freq) / 1000) +#define KHZ_TO_HZ(freq) ((freq) * 1000) #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000 #define KHZ_F "%d.%03d" diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index b8de44da1fb8..8f8ac567e7c8 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -65,4 +65,6 @@ rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) +mac80211-$(CONFIG_WBRF) += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 77c90ed8f5d7..9887471028dc 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -506,11 +506,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local, WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef)); + ieee80211_remove_wbrf(local, &ctx->conf.def); + ctx->conf.def = *chandef; /* check if min chanctx also changed */ changed = IEEE80211_CHANCTX_CHANGE_WIDTH | _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); + + ieee80211_add_wbrf(local, &ctx->conf.def); + drv_change_chanctx(local, ctx, changed); if (!local->use_chanctx) { @@ -668,6 +673,8 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->chanctx_mtx); + ieee80211_add_wbrf(local, &ctx->conf.def); + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -748,6 +755,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, } ieee80211_recalc_idle(local); + + ieee80211_remove_wbrf(local, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4159fb65038b..ffe00c55304e 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1591,6 +1591,10 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + +#ifdef CONFIG_WBRF + bool wbrf_supported; +#endif }; static inline struct ieee80211_sub_if_data * @@ -2615,4 +2619,19 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); + +#ifdef CONFIG_WBRF +void ieee80211_check_wbrf_support(struct ieee80211_local *local); +void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +#else +static inline void ieee80211_check_wbrf_support(struct ieee80211_local *local) { } +static inline void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { return 0; } +static inline void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { } +#endif /* CONFIG_WBRF */ + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 55cdfaef0f5d..0a55626b1546 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1395,6 +1395,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) debugfs_hw_add(local); rate_control_add_debugfs(local); + ieee80211_check_wbrf_support(local); + rtnl_lock(); wiphy_lock(hw->wiphy); diff --git a/net/mac80211/wbrf.c b/net/mac80211/wbrf.c new file mode 100644 index 000000000000..7ddb29d128b1 --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface for WWAN + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include +#include "ieee80211_i.h" + +void ieee80211_check_wbrf_support(struct ieee80211_local *local) +{ + struct wiphy *wiphy = local->hw.wiphy; + struct device *dev; + + if (!wiphy) + return; + + dev = wiphy->dev.parent; + if (!dev) + return; + + local->wbrf_supported = wbrf_supported_producer(dev); + dev_dbg(dev, "WBRF is %s supported\n", + local->wbrf_supported ? "" : "not"); +} + +static void get_chan_freq_boundary(u32 center_freq, + u32 bandwidth, + u64 *start, + u64 *end) +{ + bandwidth = MHZ_TO_KHZ(bandwidth); + center_freq = MHZ_TO_KHZ(center_freq); + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in HZ is expected */ + *start = KHZ_TO_HZ(*start); + *end = KHZ_TO_HZ(*end); +} + +static void wbrf_get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in *ranges_in) +{ + u64 start_freq1, end_freq1; + u64 start_freq2, end_freq2; + int bandwidth; + + bandwidth = nl80211_chan_width_to_mhz(chandef->width); + + get_chan_freq_boundary(chandef->center_freq1, + bandwidth, + &start_freq1, + &end_freq1); + + ranges_in->band_list[0].start = start_freq1; + ranges_in->band_list[0].end = end_freq1; + + if (chandef->width == NL80211_CHAN_WIDTH_80P80) { + get_chan_freq_boundary(chandef->center_freq2, + bandwidth, + &start_freq2, + &end_freq2); + + ranges_in->band_list[1].start = start_freq2; + ranges_in->band_list[1].end = end_freq2; + } +} + +void ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + wbrf_get_ranges_from_chandef(chandef, &ranges_in); + + wbrf_add_exclusion(dev, &ranges_in); +} + +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + wbrf_get_ranges_from_chandef(chandef, &ranges_in); + + wbrf_remove_exclusion(dev, &ranges_in); +} From patchwork Fri Jun 30 10:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10259695vqr; Fri, 30 Jun 2023 03:46:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlGgz3MGRvMDsa9dObPRAnpcezPbRKgEl/748rwQnaHBOLZ2J0wiT1b0ppVUWQxqxxn5qxsv X-Received: by 2002:a05:6a20:914d:b0:12d:d6e:c945 with SMTP id x13-20020a056a20914d00b0012d0d6ec945mr2030001pzc.49.1688122002630; Fri, 30 Jun 2023 03:46:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688122002; cv=pass; d=google.com; s=arc-20160816; b=Opd9x/FHr8GGrnYHn9v/K1ogxua1iav2F5y0loSwtUPQErbRbDi6ROTLuXfO8BxW4l t/Z1QUPnA3VK3ho7MWcGbTREYsFMAy9WJmYy8c6iLpJDrb9mUQslJY7PiJb6IZSzMV0w 5aOtxrh6+Mq3bYbHgAQk0HynREZp4NDsKm+UAZgVnmsJUFCpZOkt1uQwwrYc2v3nXB3Z mOu0HDf8tCUrDMwzuW644WfR7sqUp+FI9NhZacO3iPorHkOYBwyBtQEv0yMe120TZ2QG yqRsWJfSqwuTCM6M5dmQxvR8A44sXeGuYj2LF9buEQtFaI3swPJ3GGtQQRtR0rU47WhA PKqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=U/Lj4hQO1EOUAJpcqQoRNdsODzQ9FaRqKWIJkhADYRQMablpUQ1h35YLrlTvIQq0VG CT0XMG2sOaWS5onSd2v9Rfk9UOYNJ39rdHFXH/ajKoJadIk534f5+5/d0M23BfykMFSk JRqr4YYPP8OZpepN3Ejee8FkPEUnFhjclYllyY2xa0H0njE5DBitnCjACbp5y6Wp6Vmv Q53+INRSNO4uAI5Mh/ruZkYlpUAvLOlXC6K4Dd+rjW3q68O/nUqQLnBSrhRuIQ8nz7MB yz7Rp0pmTpJRqbw5XwhF9GsvkoNOIH2hA2UDTg7of7n5kd4S2m9KLUrUZ3YXE/cfJPHj ALXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=mCyMzTPx; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a17090311c900b001b3dacdf717si13173852plh.608.2023.06.30.03.46.30; Fri, 30 Jun 2023 03:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=mCyMzTPx; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbjF3KfJ (ORCPT + 99 others); Fri, 30 Jun 2023 06:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232694AbjF3Kex (ORCPT ); Fri, 30 Jun 2023 06:34:53 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC20B30C5; Fri, 30 Jun 2023 03:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iO3/JBZ9EZOboZpvMCgoWEu3n9+OSqD6fdKwOarXZa8SHgOqdDgU+86Xbpjfg352jMEm9rzW4cPGqAAJZPFh6+BJTUxVcslPuchw9e2N3+HFMFL4SGBwHbxd97MLThvARQuXDDnuPaogL0Zhfg4qq1+2mKnMKbrwROMHt4g2R1PgHWW9rbLBWeLylLciJ5VwFIwlGSEsfqyj2G14G/YBjMXxKAUQnKNPoBj4jmbVci+RFRcwJqeQba6Ej4pTt9zBjO3dZRATWcVi5GL3n5IGAgjndcv/H5DV8o9i2StjSzWBNthSCr2GMoZI03qjYqEY83hMl4QRcPaJMIgMfg5uiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=TM/MptCyctFgPXga451t1KjBTaeuIO+UWO6Pnt0a/WdcvXzIHsnF9e6CHco+jcXcufkAgIisWKewE7iU6RWtDcYRkxBdvqtP1o5mZvA/FBtfhmIapHdXbrYdz40xXqSu4giOoxnzu4igIz83L7GZMx/KcyTzIQzdSScJ3XPgM2BVne0s/TcCrQFrdcb5S8e65LE9w0GClRt9VuoBhZ2xZkMas5oSbJr46g59KtRWtnY1UGOL2HEPpaVQ2EwYQfKyvjFyjzd9Q0XtYGu6CsU+rpLAnqVzirIBA1jGwbKP78aMROtHK3cH9Iipvy3seX6O219r5+TusnsrExctv2EvAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=mCyMzTPxdfcc1HJZnZRIh1cMQP3adD0kXRbpOe1d5N3TF1zMktEgJKyQ45KXhmchZxHCCcslCuQ+FwEHU4CPXvPkYl8xpoRLgbS/ZFCjRQCFw89tGq+u+UXNb39PKe5mAigsVcmSuF+/YDJ4Ct6xB+cNoehtPac3JFftejoSrw8= Received: from DM5PR07CA0108.namprd07.prod.outlook.com (2603:10b6:4:ae::37) by MN0PR12MB5907.namprd12.prod.outlook.com (2603:10b6:208:37b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Fri, 30 Jun 2023 10:34:47 +0000 Received: from DM6NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::70) by DM5PR07CA0108.outlook.office365.com (2603:10b6:4:ae::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:34:47 +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 DM6NAM11FT006.mail.protection.outlook.com (10.13.173.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.48 via Frontend Transport; Fri, 30 Jun 2023 10:34:47 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:34:39 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 5/9] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Fri, 30 Jun 2023 18:32:36 +0800 Message-ID: <20230630103240.1557100-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT006:EE_|MN0PR12MB5907:EE_ X-MS-Office365-Filtering-Correlation-Id: b62a1fb7-aead-4119-6cb8-08db7955a099 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 90zQGhhiQI+KfnGhmFPPgCpbvjLEJVYR+cL1/vf/jjefkjpVhUthnv6s9F7aVGTUPNFOW8Xb/OZnqWXl+J8bEQTfvlNejMeZgLyknP1DdIe9oiTStWbSUJHjqtP+MO/EnsU1lKgXlCbL8KLtwUwnqXX2qD42543nw09THZnzX7L0aQFuazjYregtX3rr9ochF4Jy9e3+h8S3dFo72gQZwyS8YF0EEhUEEwT6a9AEp18G5HRB1J/14+V8BTVHt7Fmon9lTakJtZvvzNayoSwDYiQwBWRQOxBJ3wdgePof2lhn9jYpqfTmcOmPBB+Ub6gWsaY+jTDZxtH2T7ZSXRGaZzzQUylESEWSXjrcOhXiI6EKTPnTH8UPJSjyAYETgvYScw2Ok85lgkrbYaT+uEe+wKw8HPH91QGPBm/esIhchYBAhMMRb00HA0+8PFCieEjIJr16kzZIwW+yb/w/LE5RQ2hYKfwCHCouD6rotHSaX+y06q1nBvzEFBbafrutSwNfBiQOiuHYu7QCliefY9ynss+NxMchxRC6V1AzbStmXm+O33p+GriNlHILcEzMVCCjj5D1xB//V0BcRJ8+B22QvncRaehXcsNeKBAKnYvRIWpCJev18Yrj2kOu0AsA8ojxgzLlqpYwK2djLq+eQUACJgWcTc6wxbIKWYorRC4+VEnSDpi2pCoktA5e/2lhSi6L3UStSEZsI8NwceuubhDc11/KskMw5+alaeuHYwMKwRQSAq5kgcjjzyDyqEwyj5BNNnOkJIiB4DN/DGc8dPhupKuTkjczZdZTpylHUHYLFr2sGFAK+MdhHujzAEd0tRSSrTaolubWaLGaiZPw0c0g1A== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(15650500001)(186003)(16526019)(36860700001)(426003)(40480700001)(83380400001)(336012)(2616005)(47076005)(40460700003)(6666004)(2906002)(316002)(70206006)(70586007)(8676002)(8936002)(110136005)(41300700001)(54906003)(81166007)(356005)(921005)(478600001)(4326008)(82740400003)(86362001)(1076003)(44832011)(26005)(82310400005)(7696005)(36756003)(5660300002)(7416002)(2101003)(83996005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:34:47.5866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b62a1fb7-aead-4119-6cb8-08db7955a099 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: DM6NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5907 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770124217276626611?= X-GMAIL-MSGID: =?utf-8?q?1770124217276626611?= Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 14 +++++++++++++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 14 +++++++++++++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 3 ++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h index b686fb68a6e7..d64188fb5839 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h @@ -388,6 +388,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1592,7 +1603,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h index 4c46a0392451..77483e8485e7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h @@ -392,6 +392,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1624,7 +1635,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h index 10cff75b44d5..c98cc32d11bd 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h @@ -138,7 +138,8 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 //Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1 diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h index 6aaefca9b595..a6bf9cdd130e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h @@ -134,6 +134,7 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 #endif From patchwork Fri Jun 30 10:32:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10255363vqr; Fri, 30 Jun 2023 03:37:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFa54I4GAD9bSXVogBzc4GzdvkOIP6Bp5MG6DVS1FxWcCIDQDTMDr4I1U31aNp7MY4fNvxa X-Received: by 2002:a25:ac07:0:b0:bb1:568c:437d with SMTP id w7-20020a25ac07000000b00bb1568c437dmr2199486ybi.3.1688121429327; Fri, 30 Jun 2023 03:37:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121429; cv=pass; d=google.com; s=arc-20160816; b=dQ1Z6eraKZJsGo0hl08eLFkM9/bfCrGhZp3R8+Ltueycy6MSCtOXeYpwKOl78gJifU Cc1C0R466p2dG/FhJVXcPIQzpb6ifIzPBCwzk7QJRKZ1+oVCvKwtYJeFhgHKqTeRPjzZ D6M26CGSe7MS8MlyLDj57x2G36CgggyqyXNrEsZl6ZCoxCGrWkvGIrjejdYq4jMpX5Rk 6UGuwGMdDKDZNWnQfTtF59+E1X7+sPnazkAeKAscdmiObQiQVkMlskTJ8pPGZE/ImyH2 kIZ8MA66HfbwyzaNDX2MCGzIdyBii7ZjRG2UY3xu2d2Aw0G83aXmwFR2jtbSMVryZa6L 6Ndg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ftbgJPZVzskMrSl36Z6EJf2i1m7DILJM43QSSyOU4Ro=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=JADGF1XBg9BLIPF4zKQZzGU/Z29lcFRm4PDzTDWf1flRVo3cuFuXby/pvkOfC5ofXE 3759UM5p/+YJBE4rZTrZPUw1dNAHBKp/ZEoNLXnN1KCIjcJ4BUKe2csk+TAhKGMS1/gB Tui45BOw4OwHo8gEhIHXyTbTVbxafZxKEImbOfhH7ti7uaCMPwd9SK904WTqh6TpgTzf bhcDUythU9VP64X4sHERoCh9K1ap8BEub+/Yq6ssqDbavMsdkEmfYnfIBbOlK1vm8yoZ RlH42VFVVaSlNu0kOHyt1vXjQj8k+JzKNbwLeS6fCFf7qtrCYSrStYXwQGx+9OyLE4/p VkDw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z1EJ1I2T; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s186-20020a632cc3000000b0055ad2d6c8aesi7351869pgs.772.2023.06.30.03.36.57; Fri, 30 Jun 2023 03:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z1EJ1I2T; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbjF3KfO (ORCPT + 99 others); Fri, 30 Jun 2023 06:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232770AbjF3KfA (ORCPT ); Fri, 30 Jun 2023 06:35:00 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2085.outbound.protection.outlook.com [40.107.96.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 929F430C5; Fri, 30 Jun 2023 03:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D1aOcYU61IMRnLhjYnoKjvBAVlsyu8Gdwp8ZF+Kz4pqyjd5wJ8iDQ1kg3Z9/BtqSAVF6BtJeIIoRp+qHSI82ozR/XCbJ18pDk63ZhExxaGMlFrzpi9GWBa67QcDIIJC97xqy364SG+tjOzwQtragm7s0c1rPatFSmyPuvhz9JYCMO1FzxAAM3QmQpDoQSyVI3r9Yi/je/KoCDudwZKP6OhJINNWUxn6NPHNHEjx623wrl+bdAjBHpnvaVyeujfE5feCcCpzqzj3O47jUMNNe95tMUnZDr9voJ8Wn1HDZDTEaZ5eH+D7KUYBJv4/XLFbO0T+1JzTvSpCGJCqeVZPd/Q== 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=ftbgJPZVzskMrSl36Z6EJf2i1m7DILJM43QSSyOU4Ro=; b=GK/o7xNgZWohYw7LkhbAcxgaR6U2sy3BDpVY5gY3d+9pSzA0rgUGidUchckRdHU1cZn1GObuxT5hxbIIVHFOJNJCVa+uGlsUhrSrx2v8HoBuLoGGldUqHFCiKl2kXF8UoAOcTz1cY1wVEI2obFfVTxj8pTxROneU4NtjMrV22A3SpJynSM1sMdB905s0Sdr5YpnpZ/m/YrdzJ08L2eD4GiX0pDsdfSl23OpqS0EckqqKiFkeQs4JBZPHKHM/R6v9tfPFOyvDA08l6WW2ZmzBKRw2xLuyR9Lnlcog8XTv/B/IFbX1N8IJVDYdQcGqxHpmVYO1MWqE4R4baWU+2GpS8A== 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=ftbgJPZVzskMrSl36Z6EJf2i1m7DILJM43QSSyOU4Ro=; b=Z1EJ1I2TwsT2UO/ZDV+lLELLY9c3FT563LB6yeUXvLRu8aSI0FO0YJUJx0O/iHv+S1zLRMHd6ryqijyQr8/2LBgMJkc3kPjZ6qBei9vcWmfay8gW01w26bdHKaJ9iOJL8F6hjH1u88a7u6EGoeUt7tmX2Mc+592pECBMBvr7IrM= Received: from BYAPR05CA0057.namprd05.prod.outlook.com (2603:10b6:a03:74::34) by CY8PR12MB7754.namprd12.prod.outlook.com (2603:10b6:930:86::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 10:34:56 +0000 Received: from DM6NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:74:cafe::fb) by BYAPR05CA0057.outlook.office365.com (2603:10b6:a03:74::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.10 via Frontend Transport; Fri, 30 Jun 2023 10:34:55 +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 DM6NAM11FT014.mail.protection.outlook.com (10.13.173.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.33 via Frontend Transport; Fri, 30 Jun 2023 10:34:55 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:34:47 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 6/9] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Fri, 30 Jun 2023 18:32:37 +0800 Message-ID: <20230630103240.1557100-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT014:EE_|CY8PR12MB7754:EE_ X-MS-Office365-Filtering-Correlation-Id: a2991753-dc1f-42dc-a317-08db7955a54d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wNDrj+MTOb1VeD6rRUuUDrafsbeKjRE1wUKimacXHmOfVszJy/XnujGI7RivRqgxQTlXZtVd/g395Fxdwg+HnysW6/sgGLVA1IQE/fdXomOwmmJa+0CyTLQN8RKKDvFco6+7Wa1/Odx1k6HqDLYR7EK/F1PtctbA+DRAP7gbH/2FjfcaPYrvHjtWLYrsmtIEkI5WWPU1obvRG9YNUTqwCqKSgyuijD5kmIhAEknrzEVZPxMbj5Gy+8+a/8xT/T02yf/NCjuwVrTCx6Lg0dbvNfFJFjG99H+rXYwpC5hcZMcVL+aN0fbtp3AGvvm034LaV2vzct3X7l8DKROLuykuBuvPXCUu3lr0kQoreDKRcyD8r2MpDp6AmVJQus9kwHDb2CL/0te/MC8mS7Lz8zOnP5/fpqayZ3QiKckfGKx3ryTvbg94uectD3dnCfO8Ay0qAieGyBObjuHRBxdC4DO5KGQwrWtlcwkIoEJL5QdCIaN0Qh/Fl4tLf7EKKg9qeXMRAmGyEGg9/pywWNgTyXPN0rEI0dv+WsHadl7iuINcMh25L6vfmfPi1GpIwcV8ucFaFg6VM+AbMns/5J/K7qDDwR4eXrF2A/1u/3r75PWrorceBzPG86WFC4UHsgeRiTlETF+0jBlYbzCy5etWIBLekJkjS5C0JBx7jgqYM9bqjkGWiqrmzcE0b70u+Yrw0aHANJMbmIPEq4QxwcwG/o36H3oxW1cjQ3BrMSYR41wQbw4h3TEkEkvga6qlxled5rKiXnQIpbFAr5B/o9wIpZq0QwrtQuEi/Wl7D+6pPJCWPNgMky/313shEsUK4sRIPIp365ws2Vy6eJVI3b8J0BVNqv3VLSq2dQ9iziQ/16gQ+kqWYbu1YI5MdhCaJhD063am X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(8676002)(8936002)(70586007)(336012)(316002)(83380400001)(70206006)(7696005)(186003)(41300700001)(26005)(16526019)(1076003)(4326008)(2616005)(110136005)(54906003)(6666004)(40460700003)(82310400005)(2906002)(30864003)(5660300002)(7416002)(40480700001)(44832011)(478600001)(921005)(356005)(81166007)(82740400003)(86362001)(36756003)(47076005)(36860700001)(426003)(83996005)(36900700001)(2101003)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:34:55.4785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2991753-dc1f-42dc-a317-08db7955a54d 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: DM6NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7754 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770123616057819029?= X-GMAIL-MSGID: =?utf-8?q?1770123616057819029?= With WBRF feature supported, as a driver responding to the frequencies, amdgpu driver is able to do shadow pstate switching to mitigate possible interference(between its (G-)DDR memory clocks and local radio module frequency bands used by Wifi 6/6e/7). Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- v1->v2: - update the prompt for feature support(Lijo) --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 19 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 194 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 23 +++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 5 files changed, 240 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 02b827785e39..785d9b43f0c4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -241,6 +241,7 @@ extern int amdgpu_num_kcq; #define AMDGPU_VCNFW_LOG_SIZE (32 * 1024) extern int amdgpu_vcnfw_log; extern int amdgpu_sg_display; +extern int amdgpu_wbrf; #define AMDGPU_VM_MAX_NUM_CTX 4096 #define AMDGPU_SG_THRESHOLD (256*1024*1024) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 393b6fb7a71d..6c08a0cf8381 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -191,6 +191,7 @@ int amdgpu_smartshift_bias; int amdgpu_use_xgmi_p2p = 1; int amdgpu_vcnfw_log; int amdgpu_sg_display = -1; /* auto */ +int amdgpu_wbrf = -1; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); @@ -948,6 +949,24 @@ MODULE_PARM_DESC(smu_pptable_id, "specify pptable id to be used (-1 = auto(default) value, 0 = use pptable from vbios, > 0 = soft pptable id)"); module_param_named(smu_pptable_id, amdgpu_smu_pptable_id, int, 0444); +#ifdef CONFIG_WBRF +/** + * DOC: wbrf (int) + * Enable Wifi RFI interference mitigation feature. + * Due to electrical and mechanical constraints there may be likely interference of + * relatively high-powered harmonics of the (G-)DDR memory clocks with local radio + * module frequency bands used by Wifi 6/6e/7. To mitigate the possible RFI interference, + * with this feature enabled, PMFW will use either “shadowed P-State” or “P-State” based + * on active list of frequencies in-use (to be avoided) as part of initial setting or + * P-state transition. However, there may be potential performance impact with this + * feature enabled. + * (0 = disabled, 1 = enabled, -1 = auto (default setting, will be enabled if supported)) + */ +MODULE_PARM_DESC(wbrf, + "Enable Wifi RFI interference mitigation (0 = disabled, 1 = enabled, -1 = auto(default)"); +module_param_named(wbrf, amdgpu_wbrf, int, 0444); +#endif + /* These devices are not supported by amdgpu. * They are supported by the mach64, r128, radeon drivers */ diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 2ddf5198e5c4..83d428e890df 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1188,6 +1188,173 @@ static int smu_get_thermal_temperature_range(struct smu_context *smu) return ret; } +/** + * smu_wbrf_handle_exclusion_ranges - consume the wbrf exclusion ranges + * + * @smu: smu_context pointer + * + * Retrieve the wbrf exclusion ranges and send them to PMFW for proper handling. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_handle_exclusion_ranges(struct smu_context *smu) +{ + struct wbrf_ranges_out wbrf_exclusion = {0}; + struct exclusion_range *wifi_bands = wbrf_exclusion.band_list; + struct amdgpu_device *adev = smu->adev; + uint64_t start, end; + int ret, i, j; + + ret = wbrf_retrieve_exclusions(adev->dev, &wbrf_exclusion); + if (ret) { + dev_err(adev->dev, "Failed to retrieve exclusion ranges!\n"); + return ret; + } + + /* + * The exclusion ranges array we got might be filled with holes and duplicate + * entries. For example: + * {(2400, 2500), (0, 0), (6882, 6962), (2400, 2500), (0, 0), (6117, 6189), (0, 0)...} + * We need to do some sortups to eliminate those holes and duplicate entries. + * Expected output: {(2400, 2500), (6117, 6189), (6882, 6962), (0, 0)...} + */ + for (i = 0; i < MAX_NUM_OF_WBRF_RANGES; i++) { + start = wifi_bands[i].start; + end = wifi_bands[i].end; + + /* get the last valid entry to fill the intermediate hole */ + if (!start && !end) { + for (j = MAX_NUM_OF_WBRF_RANGES - 1; j > i; j--) + if (wifi_bands[j].start && + wifi_bands[j].end) + break; + + if (j > i) { + wifi_bands[i].start = wifi_bands[j].start; + wifi_bands[i].end = wifi_bands[j].end; + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + } + + continue; + } + + /* eliminate duplicate entries */ + for (j = i + 1; j < MAX_NUM_OF_WBRF_RANGES; j++) { + if ((wifi_bands[j].start == start) && + (wifi_bands[j].end == end)) { + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + continue; + } + } + } + + /* Send the sorted wifi_bands to PMFW */ + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + /* Give it another chance */ + if (unlikely(ret == -EBUSY)) { + mdelay(5); + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + } + + return ret; +} + +/** + * smu_wbrf_event_handler - handle notify events + * + * @nb: notifier block + * @action: event type + * @data: event data + * + * Calls relevant amdgpu function in response to wbrf event + * notification from kernel. + */ +static int smu_wbrf_event_handler(struct notifier_block *nb, + unsigned long action, void *_arg) +{ + struct smu_context *smu = container_of(nb, struct smu_context, + wbrf_notifier); + + switch (action) { + case WBRF_CHANGED: + smu_wbrf_handle_exclusion_ranges(smu); + break; + default: + return NOTIFY_DONE; + }; + + return NOTIFY_OK; +} + +/** + * smu_wbrf_support_check - check wbrf support + * + * @smu: smu_context pointer + * + * Verifies the ACPI interface whether wbrf is supported. + */ +static void smu_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + smu->wbrf_supported = smu_is_asic_wbrf_supported(smu) && + !!amdgpu_wbrf && + wbrf_supported_consumer(adev->dev); + + if (smu->wbrf_supported) + dev_info(adev->dev, "RF interference mitigation is supported\n"); +} + +/** + * smu_wbrf_init - init driver wbrf support + * + * @smu: smu_context pointer + * + * Verifies the AMD ACPI interfaces and registers with the wbrf + * notifier chain if wbrf feature is supported. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_init(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + int ret; + + if (!smu->wbrf_supported) + return 0; + + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; + ret = wbrf_register_notifier(&smu->wbrf_notifier); + if (ret) + return ret; + + /* + * Some wifiband exclusion ranges may be already there + * before our driver loaded. To make sure our driver + * is awared of those exclusion ranges. + */ + ret = smu_wbrf_handle_exclusion_ranges(smu); + if (ret) + dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + + return ret; +} + +/** + * smu_wbrf_fini - tear down driver wbrf support + * + * @smu: smu_context pointer + * + * Unregisters with the wbrf notifier chain. + */ +static void smu_wbrf_fini(struct smu_context *smu) +{ + if (!smu->wbrf_supported) + return; + + wbrf_unregister_notifier(&smu->wbrf_notifier); +} + static int smu_smc_hw_setup(struct smu_context *smu) { struct smu_feature *feature = &smu->smu_feature; @@ -1280,6 +1447,15 @@ static int smu_smc_hw_setup(struct smu_context *smu) if (ret) return ret; + /* Enable UclkShadow on wbrf supported */ + if (smu->wbrf_supported) { + ret = smu_enable_uclk_shadow(smu, true); + if (ret) { + dev_err(adev->dev, "Failed to enable UclkShadow feature to support wbrf!\n"); + return ret; + } + } + /* * With SCPM enabled, these actions(and relevant messages) are * not needed and permitted. @@ -1376,6 +1552,15 @@ static int smu_smc_hw_setup(struct smu_context *smu) */ ret = smu_set_min_dcef_deep_sleep(smu, smu->smu_table.boot_values.dcefclk / 100); + if (ret) { + dev_err(adev->dev, "Error setting min deepsleep dcefclk\n"); + return ret; + } + + /* Init wbrf support. Properly setup the notifier */ + ret = smu_wbrf_init(smu); + if (ret) + dev_err(adev->dev, "Error during wbrf init call\n"); return ret; } @@ -1431,6 +1616,13 @@ static int smu_hw_init(void *handle) return ret; } + /* + * Check whether wbrf is supported. This needs to be done + * before SMU setup starts since part of SMU configuration + * relies on this. + */ + smu_wbrf_support_check(smu); + if (smu->is_apu) { ret = smu_set_gfx_imu_enable(smu); if (ret) @@ -1583,6 +1775,8 @@ static int smu_smc_hw_cleanup(struct smu_context *smu) struct amdgpu_device *adev = smu->adev; int ret = 0; + smu_wbrf_fini(smu); + cancel_work_sync(&smu->throttling_logging_work); cancel_work_sync(&smu->interrupt_work); diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 09469c750a96..5b2343cfc69b 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -22,6 +22,8 @@ #ifndef __AMDGPU_SMU_H__ #define __AMDGPU_SMU_H__ +#include + #include "amdgpu.h" #include "kgd_pp_interface.h" #include "dm_pp_interface.h" @@ -573,6 +575,10 @@ struct smu_context u32 debug_param_reg; u32 debug_msg_reg; u32 debug_resp_reg; + + /* data structures for wbrf feature support */ + bool wbrf_supported; + struct notifier_block wbrf_notifier; }; struct i2c_adapter; @@ -1354,6 +1360,23 @@ struct pptable_funcs { * @init_pptable_microcode: Prepare the pptable microcode to upload via PSP */ int (*init_pptable_microcode)(struct smu_context *smu); + + /** + * @is_asic_wbrf_supported: check whether PMFW supports the wbrf feature + */ + bool (*is_asic_wbrf_supported)(struct smu_context *smu); + + /** + * @enable_uclk_shadow: Enable the uclk shadow feature on wbrf supported + */ + int (*enable_uclk_shadow)(struct smu_context *smu, + bool enablement); + + /** + * @set_wbrf_exclusion_ranges: notify SMU the wifi bands occupied + */ + int (*set_wbrf_exclusion_ranges)(struct smu_context *smu, + struct exclusion_range *exclusion_ranges); }; typedef enum { diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h index ceb13c838067..67d7495ab49e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h @@ -97,6 +97,9 @@ #define smu_get_default_config_table_settings(smu, config_table) smu_ppt_funcs(get_default_config_table_settings, -EOPNOTSUPP, smu, config_table) #define smu_set_config_table(smu, config_table) smu_ppt_funcs(set_config_table, -EOPNOTSUPP, smu, config_table) #define smu_init_pptable_microcode(smu) smu_ppt_funcs(init_pptable_microcode, 0, smu) +#define smu_is_asic_wbrf_supported(smu) smu_ppt_funcs(is_asic_wbrf_supported, false, smu) +#define smu_enable_uclk_shadow(smu, enablement) smu_ppt_funcs(enable_uclk_shadow, 0, smu, enablement) +#define smu_set_wbrf_exclusion_ranges(smu, exclusion_ranges) smu_ppt_funcs(set_wbrf_exclusion_ranges, -EOPNOTSUPP, smu, exclusion_ranges) #endif #endif From patchwork Fri Jun 30 10:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10262439vqr; Fri, 30 Jun 2023 03:53:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzsxZSjDux1Q0rJYq6+3GxT2JuN4Ou4uAtxyRDt1I/dDXxiU5arb15C2SHcIatE1594G0W X-Received: by 2002:a05:6a00:b8c:b0:675:667c:f261 with SMTP id g12-20020a056a000b8c00b00675667cf261mr3254473pfj.2.1688122380576; Fri, 30 Jun 2023 03:53:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688122380; cv=pass; d=google.com; s=arc-20160816; b=ikqwmMUs8sh02rehwZCjupOi5MDWuCDMUSkM2IBRF0+Eh7FDrkOqJ23j3cUhytfLXg yRS32ucnLLPsFaLf7DIuswf0EDSD3c6hHmNEE4OAobn9b3MQeLBImUR90Ud5WKOFedyA 60p8HAICXkdi5TYWBGvqzjS1gJOfRWNDfJ/uBzayE0FA4FDT6a9XjizNWo3JHWYjbFUj QTn8ff9t+ofI88Bmsa4+h+zs44TorQokQ1D5iJqQOXxo2oZ9Q7LRw9yFDErl9ZDSSQ5U wCxC6gTHgvmDyO3hnH107clNgQF1Vfkrc8lIqWxo86jgCGnmAZB7O42rAvMpsP0NjJhJ Jz3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wYAs4talKNZ8KMt4uQMnwm8y018gFWvj/kcPWZLZv28=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=o1vuy7CaTuecQuNRekaI7rmwVA0mjMtZmRsBrcNzvnL6P9X+rvOzjF918cwyaukANn BgawIf7HJiqBobuZR8bWt1KBgq8lpzt4KMkDXnIb1XwNdWAwJyZaa0LJVWrmNcYVsFuZ oJ68FBKkXsTcVpRMvPg6/DkgwQvILickvknaAqXBNaDtR/f6AaqWbqtjvCuFzgrPpfSI 6PHdNSEEebsdMNggR1AlVObIG/zCnUiey+PLJOK72ov7F1/zgUeqaVjTWIRbWeOA/ATV 9JK/QvbpVewmHOU9dU0JwYFJqWNga1BZAQqs8r7Vkzy3cUX7EM8rc6bXvVfsU+XpvFQi JpqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="nWTVicR/"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p23-20020a056a000a1700b0067b77e7f473si7681470pfh.232.2023.06.30.03.52.46; Fri, 30 Jun 2023 03:53:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="nWTVicR/"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232888AbjF3Kgr (ORCPT + 99 others); Fri, 30 Jun 2023 06:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232792AbjF3KgH (ORCPT ); Fri, 30 Jun 2023 06:36:07 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045223C32; Fri, 30 Jun 2023 03:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbgOrIXI8ce34sGQP38ucKRBeIDL8HzSdPIKyMjX06YisUYwabxSNUMjxcbhe5R/AzucXon28ybkUmsHltynVXuRAMYhL03iSVQ/Ol2zOQAOXXb4UxtDZiOxov4/VZtaGbGbEIiZfCH0rm4roWBKh+wuNbE2nZmGWOZrL3ehGPnt0yJgPkjboi9lQejrmXxt3Hdf9qhKNdLQnfes6pyhXIuEgc+Jw0K9bezDD8YRAdizOQjmoxgKXOe2r6aEY6KMujc7mNCwuPZ3JkWcWVj24pNkJRf6z7CS7zmBv7BrolC8iKfTMhggTAHXX2qaHehu/z8wa5BZtF0VigEoV94ILg== 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=wYAs4talKNZ8KMt4uQMnwm8y018gFWvj/kcPWZLZv28=; b=N9VjYEaF5mCe98oTL6HPj6Q05gBh8fyaH6Pet8ivvgWR5YrdyPRqY+KBZnBsqnDAxAjLYqW4eVzkQni1STJR73bX/21cinxPDGgpppQ3osa7elev53HX1onlIsm2bZoBm/CBEoKFBNZeuL5mdIc3XChg5dqBG0KZXB1wi1j9YgXyMHeN2Ds5Pm07GS4fxLtkHMyK7pQU7QsK3WLNCNI5CbMRz2sbMhBy2klS7oremEcHpvHrqBh16Rhrr7YgbrUZUmxV7g8mFB4sPRTMQeqPeTt0C452bkFaiSeQ8De/Yiawasu9qq35ddqMCMXrm2JhwwWGjf5t4WTjyrNZxeGt6g== 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=wYAs4talKNZ8KMt4uQMnwm8y018gFWvj/kcPWZLZv28=; b=nWTVicR/8ak7/QzJEVScFFpHrwEjT773w/5OgTESQkhk7BoxUWkel17LDsz5sEEF2IZPrsUrS2Bbp08d9wZ/S4WGAOGWrZEnwpAAjNscRWEqU6dK+7E+Uw3Bm9Uf70qZ0QKEjRG5aFSOwrQd7qa+PYB1UW7Q1VdrAJ6fglD9BCU= Received: from DS7PR03CA0023.namprd03.prod.outlook.com (2603:10b6:5:3b8::28) by BL1PR12MB5029.namprd12.prod.outlook.com (2603:10b6:208:31d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 10:35:18 +0000 Received: from DM6NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b8:cafe::bd) by DS7PR03CA0023.outlook.office365.com (2603:10b6:5:3b8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:35:18 +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 DM6NAM11FT114.mail.protection.outlook.com (10.13.172.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.43 via Frontend Transport; Fri, 30 Jun 2023 10:35:18 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:34:55 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 7/9] drm/amd/pm: add flood detection for wbrf events Date: Fri, 30 Jun 2023 18:32:38 +0800 Message-ID: <20230630103240.1557100-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT114:EE_|BL1PR12MB5029:EE_ X-MS-Office365-Filtering-Correlation-Id: 7833bc9d-7ec2-4e39-b6eb-08db7955b2eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jmqtBbdDxgjAY8+0rUz9iR0FpuCUlXPND42+8BKBc/67V7c96nvySjn9xFmgW2TWea1/srCOXyI2670QVcV2jk2Aihu7/xx1zLC2/CWvPnz6mxRGfcv+mnQcBGhbmyfoWAFumtSsPNBy5sEcW1f1+IZbi5IsKYUqhum5NnCyIv2aChLX9hD/7PHZ8in/Cu9CJ03NMTcoT2riBRLrZ0E4ABmmpqqf3SANfjV5wfrTK31kJq0P+8HYAv8qYx6TQfDtdOcFlN23Y8lZUXuK04/8OJhpnUnjnKEmzrUBklCsAt8il0f3jhHii9lcpUUvhmL2Bj+COmHHN/9x0j/Zfa6Tzj2TUNH7zjlIfrRHaB/k/BdDmFfLJLRtUAf4p06RAn0vglVp1aB7V51T674xKFeGrWp7H1QKy8sBXDHO7fNDrKjIRmR2wXXOYAUFgfiaiuBQirQcefrg7uvNAvIMY9OCWB5qXgyOhMqoQxKfyz6cpGGIxw3TQuvbgsvC0faraV80XcnS/SRooFOTiiua97TX4TQVqZZ/8JUUfRJVNjy2meueI8T7hLTIn1zXClXW+rBqn92jCQz/TBH1FbWpVjGpfhPfn08JbnQrzUw18/fJIC+ncNBfT1p6/DrcPE/t2Wv8TSkf6eH/XmqXk+TsqCyycgpTe4Dko1MOCCdSiiyKifvKvJVmRZSIZ+d6B4PxyKBNeZdRiNaUxBC75i0FmhuESSP+q2gq/JqbdQN/yigQj9yuJflVDjSzSHPCTt7HFAwbATqkaNEp0MghGHW7VjwL7cVwYVq7r4WRKI+xAW36vrqarnWNDtapi466Vyps7c8L9obRIyVDw1/ZyAbwQGOREg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(86362001)(54906003)(8936002)(8676002)(5660300002)(82310400005)(110136005)(7416002)(26005)(1076003)(44832011)(7696005)(478600001)(4326008)(70206006)(70586007)(41300700001)(316002)(6666004)(16526019)(186003)(2616005)(2906002)(47076005)(40460700003)(83380400001)(336012)(426003)(36860700001)(40480700001)(36756003)(82740400003)(921005)(356005)(81166007)(83996005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:35:18.3249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7833bc9d-7ec2-4e39-b6eb-08db7955b2eb 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: DM6NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5029 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770124613191814976?= X-GMAIL-MSGID: =?utf-8?q?1770124613191814976?= To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 30 +++++++++++++++---- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 83d428e890df..a4cfaf8a6f59 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1278,7 +1278,8 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, switch (action) { case WBRF_CHANGED: - smu_wbrf_handle_exclusion_ranges(smu); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); break; default: return NOTIFY_DONE; @@ -1287,6 +1288,21 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, return NOTIFY_OK; } +/** + * smu_wbrf_delayed_work_handler - callback on delayed work timer expired + * + * @work: struct work_struct pointer + * + * Flood is over and driver will consume the latest exclusion ranges. + */ +static void smu_wbrf_delayed_work_handler(struct work_struct *work) +{ + struct smu_context *smu = + container_of(work, struct smu_context, wbrf_delayed_work.work); + + smu_wbrf_handle_exclusion_ranges(smu); +} + /** * smu_wbrf_support_check - check wbrf support * @@ -1323,6 +1339,9 @@ static int smu_wbrf_init(struct smu_context *smu) if (!smu->wbrf_supported) return 0; + INIT_DELAYED_WORK(&smu->wbrf_delayed_work, + smu_wbrf_delayed_work_handler); + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; ret = wbrf_register_notifier(&smu->wbrf_notifier); if (ret) @@ -1333,11 +1352,10 @@ static int smu_wbrf_init(struct smu_context *smu) * before our driver loaded. To make sure our driver * is awared of those exclusion ranges. */ - ret = smu_wbrf_handle_exclusion_ranges(smu); - if (ret) - dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); - return ret; + return 0; } /** @@ -1353,6 +1371,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; wbrf_unregister_notifier(&smu->wbrf_notifier); + + cancel_delayed_work_sync(&smu->wbrf_delayed_work); } static int smu_smc_hw_setup(struct smu_context *smu) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 5b2343cfc69b..5df28d4a8c30 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -480,6 +480,12 @@ struct stb_context { #define WORKLOAD_POLICY_MAX 7 +/* + * Configure wbrf event handling pace as there can be only one + * event processed every SMU_WBRF_EVENT_HANDLING_PACE ms. + */ +#define SMU_WBRF_EVENT_HANDLING_PACE 10 + struct smu_context { struct amdgpu_device *adev; @@ -579,6 +585,7 @@ struct smu_context /* data structures for wbrf feature support */ bool wbrf_supported; struct notifier_block wbrf_notifier; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter; From patchwork Fri Jun 30 10:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10258376vqr; Fri, 30 Jun 2023 03:43:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56jeammJjL4FDj2Wm0eTGsOQITqGc85sqtP6HWEZdZ8Du7yTs5UYEW/z0xqOzFze9xkWv+ X-Received: by 2002:a17:90a:c78a:b0:262:ecdd:2799 with SMTP id gn10-20020a17090ac78a00b00262ecdd2799mr8667374pjb.8.1688121833067; Fri, 30 Jun 2023 03:43:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121833; cv=pass; d=google.com; s=arc-20160816; b=FHPHD/W8imuCziq/gF/xDvqiGx6VCMYpgWx+iqEKBBUO+iwS2yZP340TSb4JoDkIVd 0BsofrrNKPDa7TA3+lDztbpG52Fm9QLGCnzFu/O1EgzYzUdIRuSda5YhJ0tVy0i2SJja YMI2PmyVgW/ZrcCXP/qWRz66OQLIvEnWP/EvxgmM/3riFglEpz0DiqtpRle8gPtB43P1 szd2EqXi/HY5QhL+yYTw5UXWqAd4emI/MfftiE2OQhiS/2/HPNeb7cb6ZEO2ocD/DW4K +599PAQCrPOwsMLMROgBThpinFF/hm6Fe/YpV7Fdgh1ZvJ4AgbfkI4OFbotpivWbIvlZ V84w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=77oJ1lJYQNNqqP80R3eGk4gvUAHbfABBOq8qNyuku1Q=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=Ff8pwd63pLlNSuykLxVWFPhXDNjIHQ6sUSNOv31JnPxT0IzCFp4SaoMJCkfbBUaqu2 jovkw0WKtwcqepY1mBKAkSX1AgoJLqeK9Xpfml7GuYrmOv7MphlKLTm/0xcep+CoYYCX vBls/9BhNMZ5rx6zcg4o+PKPLFWeGK5Zns/2vr7qTMru2A9+rVuV8OI6Z8xbR86S8OXK RTTo4mw82W5AfdgxFeglvGlHbiEPNRpIGzm2HPunhGdmW9fh2ZcfttnCrUWlV+4n97FR F9lVsVWNFxiyt7fBpSD8CPTti70ROaPbJmLQV+0PvE1ejIsAypxXPIIN5YavFu1+S8lW MKyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=h6hMA38+; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a631f06000000b0054fcdcbf4a3si12591189pgf.142.2023.06.30.03.43.40; Fri, 30 Jun 2023 03:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=h6hMA38+; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232435AbjF3KhV (ORCPT + 99 others); Fri, 30 Jun 2023 06:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbjF3Kgo (ORCPT ); Fri, 30 Jun 2023 06:36:44 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBAAB4495; Fri, 30 Jun 2023 03:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sl3qM1l+uQMyEgcnc8FgSRJk/GVJAyYipZIx+V1C7P32FI4kHAAMbb+DKAspdcJwUwS+3mmn4zbpmeJ3/BgSYAHknMyYpO3nusiVknUrrVoKvhGcNarEM/kiKXOK1MSBZUPbrtANTzE+SnE++eyuUBUSSMgWDmnb4PI4pHc8X0IF1tzRgcopbe+FaWXj1dWtuUsm60WGYqNU8h5QdDVFmlIGntkov8YpA104te0uG2j9YzzNwPrMFffy6VD5RdxcFQEk5fgwrhNoy/aal2FrXnokKrSiSa9iIUHa1WXtmsJ4f/Bcef1Q4sElnZ31BAW/levgwNuklVkRsDKsfjQOWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=77oJ1lJYQNNqqP80R3eGk4gvUAHbfABBOq8qNyuku1Q=; b=g++xU2hKxQrEAkhwj7T2OufCfxIQJpeeGR83q90JrsSq+21mBBHxaC2Enn92KeXq4Ol8/lUUBqWXJUA0dIMgxkcP3/ZPcBl8mt70e5mfS999BWelDhPgURwsUjJPfii0ngbEs8X+JM5qUKdSflIF5DYLz6wmz+HA3CkLsZlxo9bQcLk4U5nR1X7o+zw6GJNO+HaiWqemOGzqVbZ4vpqdCf7j/Ro//z79vmTVfOeFJskG0vYZme4dW+CBWO61hM6WE/wjVKUvsPstg8cGrmjvXrsjWIn6Qj7HuVKdRq/kzIA8xaUseH/YHiPSJUAvoDVdjB+bYYb0lD/+fawAinnAOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=77oJ1lJYQNNqqP80R3eGk4gvUAHbfABBOq8qNyuku1Q=; b=h6hMA38+tIKujNJGmhLGkmbc155Uk7bnNnUpiIWuh61I4Rit29RvB2jAtVEbdN5H8KFMRvWm8L7C98h+BkWxxcMjHt8nMxEtmfNFHq/qnTHkK0hMvigDxoD/GMnO0R5TYmK0LZVH3WYhDTLaz7CZZeIKdErw5Cmxnv/1zMNSLqw= Received: from BYAPR08CA0067.namprd08.prod.outlook.com (2603:10b6:a03:117::44) by PH7PR12MB6419.namprd12.prod.outlook.com (2603:10b6:510:1fd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 10:35:26 +0000 Received: from DM6NAM11FT090.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:117:cafe::36) by BYAPR08CA0067.outlook.office365.com (2603:10b6:a03:117::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:35:26 +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 DM6NAM11FT090.mail.protection.outlook.com (10.13.172.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.43 via Frontend Transport; Fri, 30 Jun 2023 10:35:26 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:35:18 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 8/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Fri, 30 Jun 2023 18:32:39 +0800 Message-ID: <20230630103240.1557100-9-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT090:EE_|PH7PR12MB6419:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d1ad201-81b3-49e2-13e5-08db7955b781 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OvApaI5drF6SWj2X79ppNkta+fMr+MeOJ65IfZGruHVCnaboz20npANTVbyWiRzFstWIVuUA/CCLTAhwFJjPKw4myclOrCxFGW9rEROnqW98IFDamMBQ+PkqKCWtZEq73Qs+z+rSkh6bdypLMv3LU6ZwyznxNpQYyvu3H/E8F+2dVwO2DnU+aSsdDEqu0bT8LnckQ+CcznYrFEisNeS227vORs1PYyT+sOJsSqfSGPaN6eCkUdLLPabTho0k9xaZ3rf1QsJSHUaRrdsdTz/6Sel0hZjXss+bcyg1kl43P+v37VzA5hr8MbyC+kSWq3zaV+3xfG08xUQpqIeeuqp4tWekPEkkO2RTRFJqJTG8vTO75/L/9ktWZJ/HkP7uYsGP1qBEEybz54sDYYJpxvgxLI6EOOxbNGruGsZnUYC0D0CksTLRVHgG87peOqd3EwnRvz7uFuQkxAUEP7saqRqBcnzufbfdOe3E50vykVxLrNC5f3ZFzSzB7eyyzBW25DsxFHVj/t+tDKs4KRT+ZJtcXGhAska9qGFwGgoaAYVQMqD4wZFzfB3KRDddBR2HlzZoAVQK05orHU9V7neJZsDnzq3ALfm/P+kjAZUVWkxn7NQCDG3ZnvbKMOVGaiefU+BAFhEBmCK0VfIKXBCSubcYbh3y0m6qDdUMKuYlgrm9T6fG6h4RKlWri9z6XqDOSU+wVxHySd1gkSUH7EeYG2lERh0sxxEeI80H6z+2OjWCs0UgY3cPHPCT9WVyGNZY/l1PSmP52EZqFC8q2z9LGq7Y5RxKkKOp9W1BI2tTlQshCIi9icrgAw6rAVdHTKDCUkpBGd4nAg75zkXxbBvEh2EHdg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(86362001)(54906003)(8936002)(8676002)(5660300002)(82310400005)(110136005)(7416002)(26005)(1076003)(44832011)(7696005)(478600001)(4326008)(70206006)(70586007)(41300700001)(316002)(6666004)(16526019)(186003)(2616005)(2906002)(47076005)(40460700003)(83380400001)(336012)(426003)(36860700001)(40480700001)(36756003)(82740400003)(921005)(356005)(81166007)(83996005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:35:26.0146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d1ad201-81b3-49e2-13e5-08db7955b781 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: DM6NAM11FT090.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6419 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770124039420245104?= X-GMAIL-MSGID: =?utf-8?q?1770124039420245104?= Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 3 + .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 9 +++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 60 +++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 5df28d4a8c30..32764c509ba8 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -325,6 +325,7 @@ enum smu_table_id SMU_TABLE_PACE, SMU_TABLE_ECCINFO, SMU_TABLE_COMBO_PPTABLE, + SMU_TABLE_WIFIBAND, SMU_TABLE_COUNT, }; @@ -1499,6 +1500,8 @@ enum smu_baco_seq { __dst_size); \ }) +#define HZ_IN_MHZ 1000000U + #if !defined(SWSMU_CODE_LAYER_L2) && !defined(SWSMU_CODE_LAYER_L3) && !defined(SWSMU_CODE_LAYER_L4) int smu_get_power_limit(void *handle, uint32_t *limit, diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h index 297b70b9388f..5bbb60289a79 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h @@ -245,7 +245,8 @@ __SMU_DUMMY_MAP(AllowGpo), \ __SMU_DUMMY_MAP(Mode2Reset), \ __SMU_DUMMY_MAP(RequestI2cTransaction), \ - __SMU_DUMMY_MAP(GetMetricsTable), + __SMU_DUMMY_MAP(GetMetricsTable), \ + __SMU_DUMMY_MAP(EnableUCLKShadow), #undef __SMU_DUMMY_MAP #define __SMU_DUMMY_MAP(type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h index df3baaab0037..b6fae9b92303 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h @@ -303,5 +303,8 @@ int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, uint32_t *size, uint32_t pptable_id); +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement); + #endif #endif diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c index ca379181081c..7cb24c862720 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c @@ -2453,3 +2453,12 @@ int smu_v13_0_mode1_reset(struct smu_context *smu) return ret; } + +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement) +{ + return smu_cmn_send_smc_msg_with_param(smu, + SMU_MSG_EnableUCLKShadow, + enablement, + NULL); +} diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c index 08577d1b84ec..3e864bd2c5a4 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c @@ -155,6 +155,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(AllowIHHostInterrupt, PPSMC_MSG_AllowIHHostInterrupt, 0), MSG_MAP(ReenableAcDcInterrupt, PPSMC_MSG_ReenableAcDcInterrupt, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = { @@ -235,6 +236,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = { TAB_MAP(DRIVER_SMU_CONFIG), TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, + TAB_MAP(WIFIBAND), TAB_MAP(I2C_COMMANDS), TAB_MAP(ECCINFO), }; @@ -472,6 +474,9 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t), PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, + sizeof(WifiBandEntryTable_t), PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM); smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); if (!smu_table->metrics_table) @@ -2141,6 +2146,58 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu, return ret; } +static bool smu_v13_0_0_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + switch (adev->ip_versions[MP1_HWIP][0]) { + case IP_VERSION(13, 0, 0): + return smu->smc_fw_version >= 0x004e6300; + case IP_VERSION(13, 0, 10): + return smu->smc_fw_version >= 0x00503300; + default: + return false; + } +} + +static int smu_v13_0_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 + * is a valid setting. So, there should be no direct + * return on that. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table, @@ -2217,6 +2274,9 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .send_hbm_bad_channel_flag = smu_v13_0_0_send_bad_mem_channel_flag, .gpo_control = smu_v13_0_gpo_control, .get_ecc_info = smu_v13_0_0_get_ecc_info, + .is_asic_wbrf_supported = smu_v13_0_0_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_0_set_wbrf_exclusion_ranges, }; void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu) From patchwork Fri Jun 30 10:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 114666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10258405vqr; Fri, 30 Jun 2023 03:43:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlZSzxIrCeqrva9rAoQHPdQOHl34OjMwcU8wHwIB2EO+pweZQ11lUPJX2J3Wim88/sJi/K X-Received: by 2002:a05:6870:80c9:b0:1b0:1087:4475 with SMTP id r9-20020a05687080c900b001b010874475mr3048751oab.26.1688121836917; Fri, 30 Jun 2023 03:43:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688121836; cv=pass; d=google.com; s=arc-20160816; b=bpRvgH2P+wibdcsb2eXepu5wQGR0hOcJ5vJxOiTDaK7nBP9aa/J5WMJjGfDLJ+hZQd 5aC43PAkjzGOUEylBxURolPcMDyQWVaTvRs7QqW/d7kCoo9GU0NmUV/ojtLvfnl9IYJh UfnDqBSa/vLU+38XizBHr3wa04gG5Ps/AwIIDJ7CZJDq6AtGIKDeKpiikdrlq4PHAgOt rACNrTuweNVfdXEm8t+l1uQmrdIgHj7wbYN2+7paQWdp3v8m9Ym9SXBRI0VGMpIy52ND CUj3TNHDXqezInGKZRUjdM3bnb/4fAHefY4/3Obzz17HlsQp4cmA6IepYMLnKMkmTIrO 8snQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cfth29BrWZrzk+qu1CaoTQ6BbwxlunM+2D18Jm9HX9w=; fh=7yAUDM/fW7MjH1A34f3XGs5dG3yJvcsrWz5pWYGU/Dc=; b=0/6KXt/DDMr/Dqcy0rs3V0Z+rDqcUFzOO0cOdpf9sOVnMknACSxpnIlvpjsqW5+J77 L8vfHLG1W9OGsmFA7OYl1tClKp2NJfOhRO4g4rc4JtR/Ine/fS3VDB13RuuyJ0EysjtA RluuLe2aB4hLKPOierx0ay0zkDUTQBi4ae5JiHSWZwIXyBLh4e+Xr9h0fD5p7vY2Q3ha JC9hi8dxjqija06AC0SHxmWZ0g7eRURJHUWImNTK5uW7zb89mJaYImcxEbqydVTy0G69 A2g01xT4WdxhOBv8Wg4/OBbliRpkC6BV+/t396g4Ygbesbai/GSeqziSihuHVt1PjFm7 fY0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fdj7mstP; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a170902ea0a00b001b8698d619asi1602845plg.602.2023.06.30.03.43.44; Fri, 30 Jun 2023 03:43:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fdj7mstP; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232835AbjF3KiN (ORCPT + 99 others); Fri, 30 Jun 2023 06:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbjF3KhF (ORCPT ); Fri, 30 Jun 2023 06:37:05 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B954681; Fri, 30 Jun 2023 03:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=an9t2hp4OGSK7KXcymIj9sZ+OTaVXcigFQrMAbCM4j5i+ojBaFwa5dUaC5U+7nIbWnDAgCmmMBg4sIi0PR92EuzqwF9BalYvK/RndsueVJIrzWwyFfjpgacZloVXT0ZUQss1RN1CBxCGKnfegyh6MqEHXUxdAsIOAYCJI0CzeRJY2Um7F90hEGgydpeerNCY1SYp+amgJBo0VGy2ZkiJrsq2e4j0ohmCdTmujxInztfsoBobQPCnvhsQDMdVDaxDUlUfrqU1PP8TpFdP+aQGxpr5D287mYdVwv9793ORNuqO3ZcA6TnF1Rj6TFkFdbSg7fA3Dhe2ZDaqXVjrj2cvHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cfth29BrWZrzk+qu1CaoTQ6BbwxlunM+2D18Jm9HX9w=; b=hSj67nbxuuLhLIPfDzXeffrQCMVv5jOBhY1cS4tZOhs1DawN1uB0pWUarap8wqYN1GUFTMARSHWxoCPfXFHJsjhI2M1ekpT0bAQmO9fWWMWMxH6gl/phD5UFnp1S5C+TmgXSf+jfYcfbbmc4sFJTv43GgCvlMCVTHlms43ZBoPYia5WFz0uzonopp+S9XQLPvUfHHpTdJJ6fxg2n/qpHAkGvgmWH3+FvGB5XYNWsSGwvRJuQpiqSC2ApgobWP7hnwagbsmlCITc9Po0PPQh1oifEZADqsIOLuTa1Lz/iMBEQYcFasPDQ6kcpelvFdcGgpcmkwrH5DfNPB5ZfclE3yQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cfth29BrWZrzk+qu1CaoTQ6BbwxlunM+2D18Jm9HX9w=; b=fdj7mstPKgfFd6nme2B0SKu4II8yZUXtIPwkn7cJVZHFA9zLxctlcDmHnXoQWexrrP+qpwEiNrztr8kl8N8ny8n/wyeIGeR3EskHWmDmVE0k2Ft5PLDdIJWIMdhdiX9OWlSztEfpS5F9rUy9dBCOJCoLchvzbLqtFvnhrS39XuA= Received: from DS7PR03CA0238.namprd03.prod.outlook.com (2603:10b6:5:3ba::33) by IA1PR12MB8357.namprd12.prod.outlook.com (2603:10b6:208:3ff::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 10:35:34 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::a3) by DS7PR03CA0238.outlook.office365.com (2603:10b6:5:3ba::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 10:35:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.49 via Frontend Transport; Fri, 30 Jun 2023 10:35:33 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 30 Jun 2023 05:35:26 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V5 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Fri, 30 Jun 2023 18:32:40 +0800 Message-ID: <20230630103240.1557100-10-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630103240.1557100-1-evan.quan@amd.com> References: <20230630103240.1557100-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT066:EE_|IA1PR12MB8357:EE_ X-MS-Office365-Filtering-Correlation-Id: ec17b99f-5e18-4126-1f48-08db7955bc37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gc9QSWXbnkwvEF9SJSkxyi880uE5eYjV8yoxgAYdLgwTMNrCCZ+gPx8N4GQOpcc53RubPd2v35iOyQPyoLbVDRhpETZV3rq8SF7m5H1ZNKUMxM2r6R6INe3JMjeIOSGOH/+uqPalyyBZiUBYqhKpIGz1qOKvfKUZqsruv1VAuUO1WYdmDkyfjD3ysWTVoDZYV9oCOyg5SUd5KUkm2z8m8zEsarP5yj83J7jH9rA3Yawv/woBIG4EZX/0029wkM4IoCWLhAaW36KZhMZUSNFyCZtb4ZtO6y9bTEh3TWTUvVNjBI62rq2SZ6VQMdpnktJGI8Cvvq5xmVHrtzdbUJ6X6kP0UNZYV9UKk/V0WJhH05RXoQmhBc9FF3CNtBc33tSod/OGZFn/5Xs8x7qk/j1QRTEPmNnF341EAgpDicStTm+E2Q3op6rpLCftM/iXCXSFlSfl8yFDg1yzVcKTLZM9XXXZU13pbKvW8ZGve2RVJcd2lGvbtQQmxZrSXCc292i/eXMBDcvbFcy/h/2+hcRoXBxLCuPPQYc2DcIoazgpGLZdRevIt6jroJeSIN8x/Q2Sj0SOWmRkmwfPL9mL3+O5W3kTGRaq1TgDHJJE8Rz26bT/cLGu6rM+aAcru2GyNl1OLfXyDBXQqha/47N3RgLlaGeSzNVodJL9DRWKLGD2aveZD6IpvdOd1QoWCSYnDrlIXg+/aMjZ3TcUJT5H49By/uG6U1wUL3CNP3znSjnAUdRHYQsUww9Rd6Tj3qZe2bdmW6So3ww+agFgARimksPMt0bqxHiExhM6GKvqnBChvJfpNib9WMVkx9JYNQumirnQSa+byb0kdWWnXNLlp2hCZw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199021)(46966006)(36840700001)(40470700004)(426003)(83380400001)(336012)(47076005)(316002)(6666004)(110136005)(8676002)(7696005)(4326008)(8936002)(41300700001)(40460700003)(36860700001)(36756003)(54906003)(40480700001)(82310400005)(82740400003)(86362001)(81166007)(356005)(921005)(2616005)(70586007)(44832011)(7416002)(5660300002)(478600001)(70206006)(2906002)(186003)(16526019)(26005)(1076003)(2101003)(83996005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 10:35:33.9186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec17b99f-5e18-4126-1f48-08db7955bc37 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: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8357 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770124043215367258?= X-GMAIL-MSGID: =?utf-8?q?1770124043215367258?= Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c index bba621615abf..4a680756208b 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c @@ -126,6 +126,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit, 0), MSG_MAP(NotifyPowerSource, PPSMC_MSG_NotifyPowerSource, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = { @@ -206,6 +207,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { TAB_MAP(DRIVER_SMU_CONFIG), TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -488,6 +490,9 @@ static int smu_v13_0_7_tables_init(struct smu_context *smu) AMDGPU_GEM_DOMAIN_VRAM); SMU_TABLE_INIT(tables, SMU_TABLE_COMBO_PPTABLE, MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, + sizeof(WifiBandEntryTable_t), PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM); smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); if (!smu_table->metrics_table) @@ -1722,6 +1727,57 @@ static int smu_v13_0_7_set_df_cstate(struct smu_context *smu, NULL); } +static bool smu_v13_0_7_wbrf_support_check(struct smu_context *smu) +{ + return smu->smc_fw_version > 0x00524600; +} + +static int smu_v13_0_7_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 is a valid setting. + * Considering the scenarios below: + * - At first the wifi device adds an exclusion range e.g. (2400,2500) to + * BIOS and our driver gets notified. We will set WifiBandEntryNum = 1 + * and pass the WifiBandEntry (2400, 2500) to PMFW. + * + * - Later the wifi device removes the wifiband list added above and + * our driver gets notified again. At this time, driver will set + * WifiBandEntryNum = 0 and pass an empty WifiBandEntry list to PMFW. + * - PMFW may still need to do some uclk shadow update(e.g. switching + * from shadow clock back to primary clock) on receiving this. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table, @@ -1787,6 +1843,9 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .set_mp1_state = smu_v13_0_7_set_mp1_state, .set_df_cstate = smu_v13_0_7_set_df_cstate, .gpo_control = smu_v13_0_gpo_control, + .is_asic_wbrf_supported = smu_v13_0_7_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_7_set_wbrf_exclusion_ranges, }; void smu_v13_0_7_set_ppt_funcs(struct smu_context *smu)