From patchwork Tue May 30 02:42:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 686979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DB6AC7EE23 for ; Tue, 30 May 2023 02:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230198AbjE3CnZ (ORCPT ); Mon, 29 May 2023 22:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbjE3CnV (ORCPT ); Mon, 29 May 2023 22:43:21 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8344FB0; Mon, 29 May 2023 19:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ch/YHgStkzgw7h0veYdYlbvd76a6uTElVDDyzBzLqZM8aPWpVtrOWMHixcznlydUbWkd4LbOqLg7tbNSJpdgMDmU7vGBT8FSowR7pfuMmJYU+jbUkujusqmZzEhU4SP0CEplKJ4IZbikejT3wxaA1zc2tWqVHYx4A9Js4MvLeeWCZCRHTdczsHLBEnbzUEpDXfES+GtKU9PaOqa7hgjwwhuO701PpS6ptBZo2lKqeoZluz9VZTXLCGzj7eA1bdPVEq/27wJ8ZDhhA/dXYZQwmVnqDfbkK2LUIuYJkiKusX6o7zlhxzrVOYYQ8vPVWVsoP3X7NLbVBFwvFmonQnu6dQ== 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=XAbVT9ROTPdXrJWm3kGd6olP9jTlaT+vKHK5FWRChK0=; b=jswqVUKprvtaCus+k/U2hefWi8NbgkOJW5oo7baUHC/jReiscREC8bCYwhZQmBP4UUpNCpH5+2B1bf7IxRA0CK+sa5z/8m5+/8/QBRwWBq1YtUGqhKjQ5891GRsqGAoB/gKalkmBOlgrzkLIKc9vCQrdKmLY89AbZ2GUpP+Mm8L3Z3atuxQIpZehvz5JqU7AbqOB/MG2f9Q4M5k91tNQ6u4QgII3HXDGogMFC2ZuhpPDIYwFrgqvzM5U2HUM/3Hfl5j7lradEBC6Ey4QKTnNhpG2bSJItSIvZbFKrzzOp/JYi3gWA67UH0CP7kkreuoQTsJ1XrY+KVrIWdN8GYHfig== 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=XAbVT9ROTPdXrJWm3kGd6olP9jTlaT+vKHK5FWRChK0=; b=Nlo3CJdzP/R1XOsWb8Xbp20sNjIAeh4J8UtvgwNlo47bqZvXfYDRcVPhmhMe7jsuSRmSlWc7FnJgnxnZao/ufZJzKSEJ+88cS68hKYCx8dL/rmpRP8FDTcnfdlji//UlLz80/8D/wFItfEQ4pIZuY2N9s8aEM3zKM8tsP3nt6eY= Received: from BN8PR16CA0032.namprd16.prod.outlook.com (2603:10b6:408:4c::45) by CY5PR12MB6156.namprd12.prod.outlook.com (2603:10b6:930:24::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 02:43:16 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::16) by BN8PR16CA0032.outlook.office365.com (2603:10b6:408:4c::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:43:16 +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 BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:43:16 +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.2375.34; Mon, 29 May 2023 21:43:09 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , , Mario Limonciello Subject: [PATCH 1/9] drivers/acpi: Add support for Wifi band RF mitigations Date: Tue, 30 May 2023 10:42:19 +0800 Message-ID: <20230530024227.2139632-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT040:EE_|CY5PR12MB6156:EE_ X-MS-Office365-Filtering-Correlation-Id: 285892d8-f087-49dd-692c-08db60b79ee1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hcBYBF06ClfGuiUq2S7NSmdM6jz3bPGIw8QpgPfvGuDzKHOzmBY4WD4/3TtOoC1vmCqjhRqicQIVutvugJjmjUKGdIJzCzhlZiGtkEA95Mc62zpdRm0fia5MpOVFryK6dy/f5VRFgzwL7ci2oH7OlXjSY/sdtSOc6dud7NuSQ/PSP9C4ZIFYLSPsLu4UqqzQiP3KllIkSm6DCYAUc+Q4ZQ2Y7RX+/wQwyP0gAczJ7eE0l9JJZ7Qnm0I1EG4Ff2pAcbnzaWP8LnbTHCNWDkL/IMHdXAfWbpcnGr88qwj/2DJSAeH3mk6qDr+neO60zHw6jeqQVvZTKwzNKXVDhGsMlfFZ45d0FWfGfqnOqYuvSF0wpVE4bYHrS7qxsofr0BiJ/juqybGwHFPnW6lRFx+D8sQkP6b7rNqZ9GWLHDPLhMyy0m5KzMvObQ24S/rafGBSZpJrCMJvDsaftdfUZikmuC7R8zQM0nUzFzjbhf71VPZ1eLV+DYx0V4CHgVTp8KHIT/W2B4Iry+eM1yBFg+xovEQqYVuOLaxpOsiDX1U1OwdKscPx9n/sf4GiNYxg+W2psfEpKEP6O1lBNDey+BgZdSlNBDWN9C2oAj4L4JK9Yr/biy2Z+j/Km0d0ap1S8tuiFyQoVnfIEIiceZcft9X8aP1NzNVONxLoRGDf61QKMxD/f8Hw1dRxtF9vH4HS69Pbiuh/0ZJXyI/Hikmg7NDfLCo1KlFGqe2NZSf6gA5FQMpet0i1HJ2i+HoA9f7xyEVuCOwE36KLXEQlkYou4ZWsZas4o3Uq6zjKeD+a0KLlV8M= 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)(346002)(376002)(451199021)(46966006)(36840700001)(40470700004)(54906003)(478600001)(110136005)(40460700003)(8676002)(44832011)(6636002)(8936002)(7416002)(5660300002)(30864003)(36756003)(2906002)(86362001)(82310400005)(82740400003)(4326008)(70206006)(70586007)(81166007)(316002)(921005)(356005)(40480700001)(41300700001)(186003)(36860700001)(16526019)(26005)(336012)(1076003)(47076005)(7696005)(6666004)(426003)(83380400001)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:43:16.3442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 285892d8-f087-49dd-692c-08db60b79ee1 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: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6156 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Mario Limonciello Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7. To mitigate this, AMD has introduced an ACPI based mechanism that devices can use to notify active use of particular frequencies so that 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. For net/wireless subsystem specifically, `wbrf_add_exclusion_wlan` can be used instead. 3) If removing frequencies, then call `wbrf_remove_exclusion` with start and end ranges of the frequencies. For net/wireless subsystem specifically, `wbrf_remove_exclusion_wlan` can be used instead. 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. Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v1->v2: - update wifi_acpi_dsm_guid and wbrf_record to fit latest designs - the frequency range fed to BIOS is expected to be in HZ unit v2->v3: - correct the algorithm for frequency range start and end point calculation - drop unneeded notifier register/unregister APIs v3->v4: - concentrate all wbrf ACPI related code in acpi_wbrf.c v4->v5: - typo and some other minor fixes(Mario) v5->v6: - correct the calculations around start/end frequency points v6->v7: - correct the data type for arg3 to fit ACPI spce --- drivers/acpi/Kconfig | 7 + drivers/acpi/Makefile | 2 + drivers/acpi/acpi_wbrf.c | 343 +++++++++++++++++++++++++++++++++++++++ include/linux/wbrf.h | 70 ++++++++ 4 files changed, 422 insertions(+) create mode 100644 drivers/acpi/acpi_wbrf.c create mode 100644 include/linux/wbrf.h diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccbeab9500ec..9ee7c7dcc3e6 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -611,3 +611,10 @@ config X86_PM_TIMER You should nearly always say Y here because many modern systems require this timer. + +config ACPI_WBRF + bool "ACPI Wifi band RF mitigation mechanism" + 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. \ No newline at end of file diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index feb36c0b9446..be173e76aa62 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_ACPI_WBRF) += acpi_wbrf.o \ No newline at end of file diff --git a/drivers/acpi/acpi_wbrf.c b/drivers/acpi/acpi_wbrf.c new file mode 100644 index 000000000000..bf8e0ed73072 --- /dev/null +++ b/drivers/acpi/acpi_wbrf.c @@ -0,0 +1,343 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#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 + +#define KHZ_TO_HZ(freq) ((freq) * 1000ULL) + +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: + if (!*out) { + rc = -EINVAL; + break; + } + *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 wbrf_add_exclusion(struct acpi_device *adev, + struct wbrf_ranges_in *in) +{ + return wbrf_record(adev, WBRF_RECORD_ADD, in); +} +EXPORT_SYMBOL_GPL(wbrf_add_exclusion); + +int wbrf_remove_exclusion(struct acpi_device *adev, + struct wbrf_ranges_in *in) +{ + return wbrf_record(adev, WBRF_RECORD_REMOVE, in); +} +EXPORT_SYMBOL_GPL(wbrf_remove_exclusion); + +static int chan_width_to_mhz(enum nl80211_chan_width chan_width) +{ + int mhz; + + switch (chan_width) { + case NL80211_CHAN_WIDTH_1: + mhz = 1; + break; + case NL80211_CHAN_WIDTH_2: + mhz = 2; + break; + case NL80211_CHAN_WIDTH_4: + mhz = 4; + break; + case NL80211_CHAN_WIDTH_8: + mhz = 8; + break; + case NL80211_CHAN_WIDTH_16: + mhz = 16; + break; + case NL80211_CHAN_WIDTH_5: + mhz = 5; + break; + case NL80211_CHAN_WIDTH_10: + mhz = 10; + break; + case NL80211_CHAN_WIDTH_20: + case NL80211_CHAN_WIDTH_20_NOHT: + mhz = 20; + break; + case NL80211_CHAN_WIDTH_40: + mhz = 40; + break; + case NL80211_CHAN_WIDTH_80P80: + case NL80211_CHAN_WIDTH_80: + mhz = 80; + break; + case NL80211_CHAN_WIDTH_160: + mhz = 160; + break; + case NL80211_CHAN_WIDTH_320: + mhz = 320; + break; + default: + WARN_ON_ONCE(1); + return -1; + } + return mhz; +} + +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 in BIOS */ + *start = KHZ_TO_HZ(*start); + *end = KHZ_TO_HZ(*end); +} + +static int 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 = chan_width_to_mhz(chandef->width); + if (bandwidth < 0) + return -EINVAL; + + 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; + } + + return 0; +} + +int wbrf_add_exclusion_wlan(struct acpi_device *adev, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + int ret; + + ret = wbrf_get_ranges_from_chandef(chandef, &ranges_in); + if (ret) + return ret; + + return wbrf_add_exclusion(adev, &ranges_in); +} +EXPORT_SYMBOL_GPL(wbrf_add_exclusion_wlan); + +int wbrf_remove_exclusion_wlan(struct acpi_device *adev, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + int ret; + + ret = wbrf_get_ranges_from_chandef(chandef, &ranges_in); + if (ret) + return ret; + + return wbrf_remove_exclusion(adev, &ranges_in); +} +EXPORT_SYMBOL_GPL(wbrf_remove_exclusion_wlan); + +bool wbrf_supported_producer(struct acpi_device *adev) +{ + return acpi_check_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, + (1ULL << WBRF_RECORD) | (1ULL << WBRF_RETRIEVE)); +} +EXPORT_SYMBOL_GPL(wbrf_supported_producer); + +static union acpi_object * +acpi_evaluate_wbrf(acpi_handle handle, u64 rev, u64 func) +{ + acpi_status ret; + struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; + union acpi_object params[4]; + struct acpi_object_list input = { + .count = 4, + .pointer = params, + }; + + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = rev; + params[1].type = ACPI_TYPE_INTEGER; + params[1].integer.value = func; + params[2].type = ACPI_TYPE_PACKAGE; + params[2].package.count = 0; + params[2].package.elements = NULL; + params[3].type = ACPI_TYPE_STRING; + params[3].string.length = 0; + params[3].string.pointer= NULL; + + ret = acpi_evaluate_object(handle, "WBRF", &input, &buf); + if (ACPI_SUCCESS(ret)) + return (union acpi_object *)buf.pointer; + + if (ret != AE_NOT_FOUND) + acpi_handle_warn(handle, + "failed to evaluate WBRF(0x%x)\n", ret); + + 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; + + 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 wbrf_supported_consumer(struct acpi_device *adev) +{ + return check_acpi_wbrf(adev->handle, + WBRF_REVISION, + 1ULL << WBRF_RETRIEVE); +} +EXPORT_SYMBOL_GPL(wbrf_supported_consumer); + +int wbrf_retrieve_exclusions(struct acpi_device *adev, + struct wbrf_ranges_out *exclusions_out) +{ + union acpi_object *obj; + + obj = acpi_evaluate_wbrf(adev->handle, + WBRF_REVISION, + WBRF_RETRIEVE); + if (!obj) + return -EINVAL; + + memcpy(exclusions_out, obj->buffer.pointer, obj->buffer.length); + + ACPI_FREE(obj); + + return 0; +} +EXPORT_SYMBOL_GPL(wbrf_retrieve_exclusions); diff --git a/include/linux/wbrf.h b/include/linux/wbrf.h new file mode 100644 index 000000000000..c77766069d73 --- /dev/null +++ b/include/linux/wbrf.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + */ + +#ifndef _LINUX_WBRF_H +#define _LINUX_WBRF_H + +#include +#include + +/* Maximum number of wbrf ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +struct exclusion_range { + uint64_t start; + uint64_t end; +}; + +struct wbrf_ranges_in { + /* valid entry: `start` and `end` filled with non-zero values */ + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +}; + +struct wbrf_ranges_out { + uint32_t num_of_ranges; + struct exclusion_range band_list[MAX_NUM_OF_WBRF_RANGES]; +} __attribute__((packed)); + +/** + * APIs needed by drivers/subsystems for contributing frequencies: + * During probe, check `wbrf_supported_producer` to see if WBRF is supported. + * If adding frequencies, then call `wbrf_add_exclusion` with the + * start and end points specified for the frequency ranges added. + * If removing frequencies, then call `wbrf_remove_exclusion` with + * start and end points specified for the frequency ranges added. + */ +bool wbrf_supported_producer(struct acpi_device *adev); +int wbrf_add_exclusion(struct acpi_device *adev, + struct wbrf_ranges_in *in); +int wbrf_remove_exclusion(struct acpi_device *adev, + struct wbrf_ranges_in *in); +/** + * The following two APIs are created specially for net/wireless subsystem( + * a main player for contributing frequencies) for adding and removing + * frequencies: + * If adding frequencies, then call `wbrf_add_exclusion_wlan` with + * `struct cfg80211_chan_def` which defines the center frequency points + * and bandwidth. + * If removing frequencies, then call `wbrf_remove_exclusion_wlan` with + * `struct cfg80211_chan_def` which defines the center frequency points + * and bandwidth. + */ +int wbrf_add_exclusion_wlan(struct acpi_device *adev, + struct cfg80211_chan_def *chandef); +int wbrf_remove_exclusion_wlan(struct acpi_device *adev, + struct cfg80211_chan_def *chandef); + +/** + * APIs needed by drivers/subsystems responding to frequencies: + * During probe, check `wbrf_supported_consumer` to see if WBRF is supported. + * When receiving an ACPI notification for some frequencies change, run + * `wbrf_retrieve_exclusions` to retrieve the latest frequencies ranges. + */ +int wbrf_retrieve_exclusions(struct acpi_device *adev, + struct wbrf_ranges_out *out); +bool wbrf_supported_consumer(struct acpi_device *adev); + +#endif /* _LINUX_WBRF_H */ From patchwork Tue May 30 02:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 688344 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A4A4C7EE23 for ; Tue, 30 May 2023 02:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbjE3Cni (ORCPT ); Mon, 29 May 2023 22:43:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjE3Cn2 (ORCPT ); Mon, 29 May 2023 22:43:28 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70056E8; Mon, 29 May 2023 19:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B5JV+zHIRVA97ySwN9qWCFelbrhvEIHXP4AIuHYRnT7uTee9C3ohRuEhV7PTQHWrVuJ5TnvBLugj7EH/AgZQZ8whSi7zkfvivlc0EstjGQjOVcVCtA9RazGIjQzhW1CjfTHinCuxryDo3p0DBqLLQ4gfCkjFtlCByYT4z/D9HdMBJkfU99dDcmUAo/uGmSrZbsabRbA5NEpxaf27aEIJvOawLkUQq1W+EqNCzG2mhNii45Qz0dOpEeF0H84ppHhOtYhzsTUIJOQ+s8yDJAynGD+jQqtk7tgyOsm7tZISO3HuBejMNoQrqH2M4V36WDUMjU0PIZDgVS/nfcNbwLQhUg== 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=BxSJbwsexBc+KyHw60xot62C2fTQOYaZTLymbSgTBGY=; b=e1KtJZ1FgGGkj63o8P3BV2ryoasBOvd8moKZjkpX93Hmj+dG6Tpuv3mLzWrlyLnhPL/9crzyUBUrpBfNFUDI9xESAck+ellwMd4SvZzdm0p6CPME+LawLprcddj6FtZo/iCCWWTORT/rIvcDeney0UWfsR8MkKStIuUdK0TfaGhQVTdS4z+Tt4LINcn92HfMhed/ZaaKlXKQNunBf74y4ZAlzc+9vjoDC0/ZlXg+myRrxjXLdIGUc8F396yt6N7aU7lKWk02c02YOj9Gb0Z2iDCbeTg/KuaLnzLhkuW4nvz9m29JRdG1PiwVb1EAg/7zPI0dhg7auzQbcgCscUnfOg== 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=BxSJbwsexBc+KyHw60xot62C2fTQOYaZTLymbSgTBGY=; b=lsGhQ3+EP88srSDFtEKYj+84yGhgWVmHNawM+8BBhGjFNmZACroRc8DtqwuuKare2qXUHQMKhpUJlKKgaMbRdeWh/yRqdX9j6Hd9TKAV2lcq3j3H+FvJWUI2fEg5SWGCeZjS1aS3zMGVsTbuQwTjaVynhumdeuwtVelmfxW+c6k= Received: from BN0PR02CA0023.namprd02.prod.outlook.com (2603:10b6:408:e4::28) by SN7PR12MB6931.namprd12.prod.outlook.com (2603:10b6:806:261::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 02:43:22 +0000 Received: from BN8NAM11FT072.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e4:cafe::b4) by BN0PR02CA0023.outlook.office365.com (2603:10b6:408:e4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:43:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT072.mail.protection.outlook.com (10.13.176.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:43:22 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 29 May 2023 21:43:16 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , , Mario Limonciello , Anson Taso Subject: [PATCH 2/9] mt76: Add support to the Mediatek MT7921 for ACPI WBRF Date: Tue, 30 May 2023 10:42:20 +0800 Message-ID: <20230530024227.2139632-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT072:EE_|SN7PR12MB6931:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a9494a4-52b5-46a3-0a5b-08db60b7a29a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 309PcQx+nfcsSTS/Alen5rZtJmqhuMyroDWYCdaHycvclIS8ZrAEkHi6lDBKo/zDEzvXx5mQfwEL39aoNURPeK6cKbgY1HL0aZnp0Pdna6yQer+ortyCJxkuLW0niSci4oeZC4eEttKK/LeW8z/aFTlitf0KYxEih2OzuQHwlGN+TxJbEhpwynIAWxQLuj/6CAWWC+157pA5/eIDfS13XURG6j6Y95ud+gfbKneRD+xA2Qv4klGEbo7jm9EzFx8JGVOTV9Ytcn9q4DsOlxWiBayt2H1WLpVPh2pIjD30UomqWqpJO08HbzX35ega75ZJjUw92rxVvRn8pbNtO4MtzCXBLdOa4P/g6TmpkqngVhB6d5timyiyh/8jG/6rTR02MsZDww35CxYfLD/GjrzWcD0bMdMoSppL8vhRizD/ab6ZnGfxcXEhGEw/i5ont0yy5uMJeQZCWmkE7Cnu32CqhwvJGmE0nqFvxgpWAFmuw1J1g2i+qyqqXElsQVcG463uqRFUxEBksXCXyyIWWGZSueNa9odpiLZuW7lhQxeEaJOwLe8212tvNUqpbFDuW+VnNnO455nu+3BSko87zfETsTZ6OnS9tH2ZzHct/ZKzc6o761iDAtzZB8tQGlT66bPJGznjw/fp55H/FHR+hYpNeX7wmm6UUXesMUH2nYLUlETwsMNSuSzJOTAVqasWyZaO3yQMvCikutcYJsPazrqJ8B7/dBpsNdMUhEBBLoomWlxTo2UAtuKkOJWw6ylC8vk0I35B85Wx+5Yb4Ice+BlJ4lPgCBrxExayKk3ukbLgsVo= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(376002)(136003)(451199021)(36840700001)(40470700004)(46966006)(186003)(2906002)(2616005)(110136005)(54906003)(16526019)(336012)(426003)(478600001)(1076003)(26005)(44832011)(47076005)(86362001)(40460700003)(36860700001)(7696005)(356005)(81166007)(8676002)(41300700001)(82740400003)(8936002)(921005)(40480700001)(316002)(5660300002)(6666004)(70586007)(70206006)(82310400005)(36756003)(7416002)(6636002)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:43:22.6030 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a9494a4-52b5-46a3-0a5b-08db60b7a29a 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: BN8NAM11FT072.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6931 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Mario Limonciello Mediatek wifi adapters are utilized in systems that support AMD's WBRF interference mitigation mechanism. For this mechanism to work frequencies utilized use must be notified to an ACPI device. If the kernel is configured with CONFIG_ACPI_WBRF then notify this ACPI device accordingly. Signed-off-by: Mario Limonciello Signed-off-by: Anson Taso Co-developed-by: Anson Taso --- v1->v2: - Fix build errors below for mt76 w/ WBRF enabled ERROR: modpost: "mt76_add_wbrf" [drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2e.ko] undefined! ERROR: modpost: "mt76_remove_wbrf" [drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2e.ko] undefined! ERROR: modpost: "mt76_init_acpi_wbrf" [drivers/net/wireless/mediatek/mt76/mt7921/mt7921-common.ko] undefined! v2->v3: - add support to the real driver(mt7921/main.c) which supports Mediatek MT7921 --- drivers/net/wireless/mediatek/mt76/Makefile | 1 + .../net/wireless/mediatek/mt76/acpi_wbrf.c | 36 +++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 19 ++++++++++ .../net/wireless/mediatek/mt76/mt7921/init.c | 2 ++ .../net/wireless/mediatek/mt76/mt7921/main.c | 3 ++ 5 files changed, 61 insertions(+) create mode 100644 drivers/net/wireless/mediatek/mt76/acpi_wbrf.c diff --git a/drivers/net/wireless/mediatek/mt76/Makefile b/drivers/net/wireless/mediatek/mt76/Makefile index 84c99b7e57f9..c016c71f23bd 100644 --- a/drivers/net/wireless/mediatek/mt76/Makefile +++ b/drivers/net/wireless/mediatek/mt76/Makefile @@ -12,6 +12,7 @@ mt76-y := \ mt76-$(CONFIG_PCI) += pci.o mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o +mt76-$(CONFIG_ACPI_WBRF) += acpi_wbrf.o mt76-usb-y := usb.o usb_trace.o mt76-sdio-y := sdio.o sdio_txrx.o diff --git a/drivers/net/wireless/mediatek/mt76/acpi_wbrf.c b/drivers/net/wireless/mediatek/mt76/acpi_wbrf.c new file mode 100644 index 000000000000..ceef57bddc6f --- /dev/null +++ b/drivers/net/wireless/mediatek/mt76/acpi_wbrf.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: ISC +/* Copyright (C) 2023 Advanced Micro Devices */ + +#include +#include "mt76.h" + +#if defined(CONFIG_ACPI_WBRF) +void mt76_init_acpi_wbrf(struct mt76_dev *dev) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(dev->dev); + + if (!acpi_dev) { + dev_dbg(dev->dev, "ACPI companion not found\n"); + return; + } + + dev->phy.wbrf = wbrf_supported_producer(acpi_dev); + dev_dbg(dev->dev, "WBRF is %s supported\n", + dev->phy.wbrf ? "" : "not"); +} +EXPORT_SYMBOL_GPL(mt76_init_acpi_wbrf); +int mt76_add_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef) +{ + if (!dev->phy.wbrf) + return 0; + return wbrf_add_exclusion_wlan(ACPI_COMPANION(dev->dev), chandef); +} +EXPORT_SYMBOL_GPL(mt76_add_wbrf); +int mt76_remove_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef) +{ + if (!dev->phy.wbrf) + return 0; + return wbrf_remove_exclusion_wlan(ACPI_COMPANION(dev->dev), chandef); +} +EXPORT_SYMBOL_GPL(mt76_remove_wbrf); +#endif diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 6b07b8fafec2..fd33a553ba2e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -733,6 +733,7 @@ struct mt76_phy { int txpower_cur; u8 antenna_mask; u16 chainmask; + bool wbrf; #ifdef CONFIG_NL80211_TESTMODE struct mt76_testmode_data test; @@ -1511,4 +1512,22 @@ mt76_packet_id_flush(struct mt76_dev *dev, struct mt76_wcid *wcid) idr_destroy(&wcid->pktid); } +#ifdef CONFIG_ACPI_WBRF +void mt76_init_acpi_wbrf(struct mt76_dev *dev); +int mt76_add_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef); +int mt76_remove_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef); +#else +static inline void mt76_init_acpi_wbrf(struct mt76_dev *dev) { }; +static inline int +mt76_add_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef) +{ + return 0; +} +static inline int +mt76_remove_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef) +{ + return 0; +} +#endif /* CONFIG_ACPI_WBRF */ + #endif diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index bf1da9fddfab..91396139a177 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -420,6 +420,8 @@ int mt7921_register_device(struct mt7921_dev *dev) mt7921_init_acpi_sar(dev); + mt76_init_acpi_wbrf(&dev->mt76); + ret = mt7921_init_wcid(dev); if (ret) return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 3b6adb29cbef..241d5b1729dd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -480,6 +480,8 @@ static int mt7921_set_channel(struct mt7921_phy *phy) mt7921_mutex_acquire(dev); set_bit(MT76_RESET, &phy->mt76->state); + mt76_remove_wbrf(phy->mt76->dev, &phy->mt76->chandef); + mt76_set_channel(phy->mt76); ret = mt7921_mcu_set_chan_info(phy, MCU_EXT_CMD(CHANNEL_SWITCH)); @@ -493,6 +495,7 @@ static int mt7921_set_channel(struct mt7921_phy *phy) out: clear_bit(MT76_RESET, &phy->mt76->state); + mt76_add_wbrf(phy->mt76->dev, &phy->mt76->chandef); mt7921_mutex_release(dev); mt76_worker_schedule(&dev->mt76.tx_worker); From patchwork Tue May 30 02:42:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 686978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F93C77B7E for ; Tue, 30 May 2023 02:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbjE3Cnx (ORCPT ); Mon, 29 May 2023 22:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbjE3Cnl (ORCPT ); Mon, 29 May 2023 22:43:41 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6026812A; Mon, 29 May 2023 19:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S4TVo8gkNebwDvw3ZJR7fBe+aK65Hebt9WgacdU+GwR4dU77We3PcaUHriiu4F6Pr6TklWzC0HfLvxF/jX/qtMybFTwQC1QhZ++iCLKY7WWp4MQ9Uf4fUcIurXMRy569OuIslDX9UraUaypRE26ErWKi1N+LnrV7+MYaGr/GJzFFbxWGnVzFLAa/TUzkNJOdpsv0AddZQKq7sAuhQDD6EHoKlu+def/HRcUvPwXam2ITiRvSZvQPNjOb2i74jlQutyLSQqE1YpY70Pc/oJvgOSwYNg5/+t11c081fYnT/o9/XRpFWfgyrQd8C5QbuVqyFN96z0GkN4bnmnLLQ1e5tw== 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=zP2Mj09EECWAAQZ5Co1FJARpQzmGjUwt6MWpCVUUISk=; b=KKv4BAR8DmJhkHuPtcT5Cgq7QjbTgm8gQ5BHKevHXe8bEkDP+ZJJSwOoIPWl6yBL+LIOwQAsS3c/h3Lh1l78JJ2hU5zHW773AIzERsODFEzFAicHyFhz+/LVvUAs3vQ6yfChb5MfJiweCqR47fGZwHjt4HPN8UHw13kqMHcLVcggB08WtrfGbaP/ubOoz0Ko6E2vDjJa2Sj1oNOwFh+CN8cFrMC9ICcRQicqGjpzXZO3G+SHAiG0eH5+XvsRRVoWFf99e3rKdVqkx1Veqr7HA31h9xH4JNnoU2E4faNQy09YTZ43un7+hGwP6xBQxok+rN8cfrmqAxeYjyImoed4rw== 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=zP2Mj09EECWAAQZ5Co1FJARpQzmGjUwt6MWpCVUUISk=; b=HXpgRyGc9afmhE8nK1Y030vurKE3vpQP/TjmotDewmfO5I62BiTFsDvfJ3EW0k8exYPjIfhdyGSmast1wjxuCRlxW+rM+K7ui9rJ4jpM2vkkgIoO97lFEktJhLFj/Y1wfDQIqZRZgeAElr6l2yk53JA+PhhGlC/HidWqlbOYqj4= Received: from BN0PR04CA0064.namprd04.prod.outlook.com (2603:10b6:408:ea::9) by DM4PR12MB5817.namprd12.prod.outlook.com (2603:10b6:8:60::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 02:43:30 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::d8) by BN0PR04CA0064.outlook.office365.com (2603:10b6:408:ea::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:43:29 +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 BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:43:29 +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.2375.34; Mon, 29 May 2023 21:43:22 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , , Anson Tsao Subject: [PATCH 3/9] wifi: ath11k: Add support to the Qualcomm ath11k for ACPI WBRF Date: Tue, 30 May 2023 10:42:21 +0800 Message-ID: <20230530024227.2139632-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT009:EE_|DM4PR12MB5817:EE_ X-MS-Office365-Filtering-Correlation-Id: 94453707-cbff-4f29-45e4-08db60b7a6f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +GiiDLZlBp9AlsJidV/FCrH0I0U/fdHi5446wYzU6n1c9XiAFznERRGOzTh1Y+vK3WmfZlzmtxtVwwQA6m8SbM3OEfRWZOgygt1wDGcKxB7AYIhpE1Jx2udwpogy3VlXE1XtTokeVgH+FxpsndNGzD5eMRlZF1Sr1nz9JBFmkKTGcw3NqC634CE5UZpfeD19YFL9+7gVoILmJEAA5KBRYm0USBCdNlgNpBhtKs+9C/N57r26zQ6lIpXjlvHMnnTTsym4jIAmNBnoiiFROY3aR0ihSQG3TE96jRgIcBQqy1ukgGrqdOBIkAI61xKlNSvv/zoCI/MQveWuwjPkieRyQFlDmTEFTwtOA82wmigsVFYsjFEtHlW49BVe329VBRqXdwtUyKjLYUuzdpyI9fgnhyRjJGr8NcYEyEYsJyaMIuL8i85re0jas8hyHrPRW3NNcynGWKT4hhWMeUSnpQrMdLpNAZ9uz0n8qsIJEnLlIVP4wHwB5cP8fhRcS5N1en85KkjNSJP/Ec+tjY4E5q5en0Ix/yD+fcCK3+wx57fKH0sbsO7SRBgqVjjqmLsSpfSXYzrmPqDA7dJZ4p7UxdAhds/rIRkdIMR4rCvFMneRW9mY3DUSZ0pveGElQaZuq6/xCReBodJrvXP/WcUu5AhcrWqO1vOzWiv4KTfIltRmo9rrTNMly/u/MxFDDm0UAGoRszqpbliz9El0nPz5oELGIZVU7BJRGHbfIdnaaox8XKmL7TKmjOko0NrMu8nwuvFKaRqqFPy/34GZZfilaaG2slYkRwXPHuTW44x63PdIM78= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199021)(46966006)(36840700001)(40470700004)(54906003)(478600001)(110136005)(40460700003)(8936002)(44832011)(7416002)(5660300002)(8676002)(2906002)(86362001)(36756003)(82310400005)(70206006)(70586007)(4326008)(6636002)(82740400003)(81166007)(356005)(921005)(316002)(40480700001)(41300700001)(2616005)(16526019)(336012)(426003)(186003)(1076003)(26005)(47076005)(7696005)(36860700001)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:43:29.8790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 94453707-cbff-4f29-45e4-08db60b7a6f0 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: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5817 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Anson Tsao Qualcomm wifi adapters are utilized in systems that support AMD's WBRF interference mitigation mechanism. For this mechanism to work frequencies utilized use must be notified to an ACPI device. If the kernel is configured with CONFIG_ACPI_WBRF then notify this ACPI device accordingly. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 Signed-off-by: Anson Tsao Signed-off-by: Evan Quan Co-developed-by: Evan Quan --- v1->v2: - Fix possible NULL pointer dereference caused by ar->hw->conf.chandef.chan v2->v3: - correct the timing for `ath11k_add_wbrf` and `ath11k_remove_wbrf` calling --- drivers/net/wireless/ath/Makefile | 1 + drivers/net/wireless/ath/acpi_wbrf.c | 45 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath.h | 15 +++++++++ drivers/net/wireless/ath/ath11k/core.c | 23 +++++++++++++ drivers/net/wireless/ath/ath11k/core.h | 14 ++++++++ drivers/net/wireless/ath/ath11k/mac.c | 4 +++ drivers/net/wireless/ath/ath11k/pci.c | 3 ++ 7 files changed, 105 insertions(+) create mode 100644 drivers/net/wireless/ath/acpi_wbrf.c diff --git a/drivers/net/wireless/ath/Makefile b/drivers/net/wireless/ath/Makefile index 8d6e6e218d24..234e904bdfa9 100644 --- a/drivers/net/wireless/ath/Makefile +++ b/drivers/net/wireless/ath/Makefile @@ -21,5 +21,6 @@ ath-objs := main.o \ ath-$(CONFIG_ATH_DEBUG) += debug.o ath-$(CONFIG_ATH_TRACEPOINTS) += trace.o +ath-$(CONFIG_ACPI_WBRF) += acpi_wbrf.o CFLAGS_trace.o := -I$(src) diff --git a/drivers/net/wireless/ath/acpi_wbrf.c b/drivers/net/wireless/ath/acpi_wbrf.c new file mode 100644 index 000000000000..98b3416eca4d --- /dev/null +++ b/drivers/net/wireless/ath/acpi_wbrf.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: ISC +/* Copyright (C) 2023 Advanced Micro Devices */ + +#include +#include "ath.h" + +bool ath_check_wbrf_support(struct device *dev) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(dev); + bool wbrf_supported; + + if (!acpi_dev) { + dev_dbg(dev, "ACPI companion not found\n"); + return false; + } + + wbrf_supported = wbrf_supported_producer(acpi_dev); + dev_dbg(dev, "WBRF is %s supported\n", + wbrf_supported ? "" : "not"); + + return wbrf_supported; +} +EXPORT_SYMBOL_GPL(ath_check_wbrf_support); + +int ath_add_wbrf(struct device *dev, struct cfg80211_chan_def *chandef) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(dev); + + if (!acpi_dev) + return -ENODEV; + + return wbrf_add_exclusion_wlan(acpi_dev, chandef); +} +EXPORT_SYMBOL_GPL(ath_add_wbrf); + +int ath_remove_wbrf(struct device *dev, struct cfg80211_chan_def *chandef) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(dev); + + if (!acpi_dev) + return -ENODEV; + + return wbrf_remove_exclusion_wlan(acpi_dev, chandef); +} +EXPORT_SYMBOL_GPL(ath_remove_wbrf); diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index f02a308a9ffc..c9f5c9a67c0a 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -334,4 +334,19 @@ static inline const char *ath_bus_type_to_string(enum ath_bus_type bustype) return ath_bus_type_strings[bustype]; } +#ifdef CONFIG_ACPI_WBRF +bool ath_check_wbrf_support(struct device *dev); +int ath_add_wbrf(struct device *dev, struct cfg80211_chan_def *chandef); +int ath_remove_wbrf(struct device *dev, struct cfg80211_chan_def *chandef); +#else +static inline +bool ath_check_wbrf_support(struct device *dev) { return false; } +static inline +int ath_add_wbrf(struct device *dev, + struct cfg80211_chan_def *chandef) { return 0; } +static inline +int ath_remove_wbrf(struct device *dev, + struct cfg80211_chan_def *chandef) { return 0; } +#endif + #endif /* ATH_H */ diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index b1b90bd34d67..1f1eed9c8ae7 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -16,6 +16,7 @@ #include "debug.h" #include "hif.h" #include "wow.h" +#include "../ath.h" unsigned int ath11k_debug_mask; EXPORT_SYMBOL(ath11k_debug_mask); @@ -2035,5 +2036,27 @@ struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size, } EXPORT_SYMBOL(ath11k_core_alloc); +#if defined(CONFIG_ACPI_WBRF) +int ath11k_add_wbrf(struct ath11k_base *ab, + struct cfg80211_chan_def *chandef) +{ + if (!ab->wbrf) + return 0; + + return ath_add_wbrf(ab->dev, chandef); +} +EXPORT_SYMBOL_GPL(ath11k_add_wbrf); + +int ath11k_remove_wbrf(struct ath11k_base *ab, + struct cfg80211_chan_def *chandef) +{ + if (!ab->wbrf) + return 0; + + return ath_remove_wbrf(ab->dev, chandef); +} +EXPORT_SYMBOL_GPL(ath11k_remove_wbrf); +#endif + MODULE_DESCRIPTION("Core module for Qualcomm Atheros 802.11ax wireless LAN cards."); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 0830276e5028..02975d012875 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -978,6 +978,8 @@ struct ath11k_base { const struct ath11k_pci_ops *ops; } pci; + bool wbrf; + /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; @@ -1236,4 +1238,16 @@ static inline const char *ath11k_bus_str(enum ath11k_bus bus) return "unknown"; } +#ifdef CONFIG_ACPI_WBRF +int ath11k_add_wbrf(struct ath11k_base *ab, struct cfg80211_chan_def *chandef); +int ath11k_remove_wbrf(struct ath11k_base *ab, struct cfg80211_chan_def *chandef); +#else +static inline +int ath11k_add_wbrf(struct ath11k_base *ab, + struct cfg80211_chan_def *chandef) { return 0; } +static inline +int ath11k_remove_wbrf(struct ath11k_base *ab0, + struct cfg80211_chan_def *chandef) { return 0; } +#endif /* CONFIG_ACPI_WBRF */ + #endif /* _CORE_H_ */ diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 1c93f1afccc5..b96e13ae816b 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -6838,6 +6838,8 @@ static int ath11k_mac_op_add_chanctx(struct ieee80211_hw *hw, mutex_lock(&ar->conf_mutex); + ath11k_add_wbrf(ar->ab, &ctx->def); + spin_lock_bh(&ar->data_lock); /* TODO: In case of multiple channel context, populate rx_channel from * Rx PPDU desc information. @@ -6862,6 +6864,8 @@ static void ath11k_mac_op_remove_chanctx(struct ieee80211_hw *hw, mutex_lock(&ar->conf_mutex); + ath11k_remove_wbrf(ar->ab, &ctx->def); + spin_lock_bh(&ar->data_lock); /* TODO: In case of there is one more channel context left, populate * rx_channel with the channel of that remaining channel context. diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c index 7b33731a50ee..f648f92c7564 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -15,6 +15,7 @@ #include "mhi.h" #include "debug.h" #include "pcic.h" +#include "../ath.h" #define ATH11K_PCI_BAR_NUM 0 #define ATH11K_PCI_DMA_MASK 32 @@ -891,6 +892,8 @@ static int ath11k_pci_probe(struct pci_dev *pdev, goto err_irq_affinity_cleanup; } + ab->wbrf = ath_check_wbrf_support(ab->dev); + ret = ath11k_core_init(ab); if (ret) { ath11k_err(ab, "failed to init core: %d\n", ret); From patchwork Tue May 30 02:42:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 688343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B59CC77B7E for ; Tue, 30 May 2023 02:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjE3CoH (ORCPT ); Mon, 29 May 2023 22:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbjE3CoC (ORCPT ); Mon, 29 May 2023 22:44:02 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8F6C187; Mon, 29 May 2023 19:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BoBOvNWq507la18Wz7sNZnhPxmWYzIslk9j2F5B28SrZH2R0jFJ7na+2fB6qIWsP6DjRgsjv5encvN58K8K9Y3ae2bhlWJPw1CIMdFuJqFNgiQW3MBpfaXdhrD1u6uk6vum/wd0qZ+PDn5hR8zXsQblgez5YMAol+EcQlB3pN1PGlmmahuNEPr6bcWynqr3dybJ0zJLuvQxSmXmf7Rye5cczcaf6JO8SgYqP0w/0hC9spnJx1dopqHZi9n0F6Xr2Y5EdRyZl0Auta2P+J4fBSpafPqswMChkt7pACLx+j/2aBIGfSVGefzfXZ7nKZu7ZAagLGx0BfJpg0qPXvRvUBw== 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=pqoYW+ZppvfRNPNCv8U//lStS+ck/No3nz1J9q9VpPg=; b=QMbguje0+6dZALfEWqVtAjg/V4LHftcvTJdDouQ98B17Ihy4tbd/lFYYYZ5/H2Fg1z/ul/tOYLJWts8uuvAP4RaNmV8yUqGQQn0MdcfoWv3UO1gDcp/jjqYS6LON7oXr1r/cSSaOJDFUeug4bUe5Zs/pIbnVh+ub/DW3w29iIMbsBk3iyB1xJh24xF8B8thQuZRvewrBm4OHz/gF6nC53Q8vAZURk+NypGxO3wWLBu8BpzSI5JCDRwNcBi/gJb9GasqiLp9zdEo5uMSAWFS/QGkVf/yIygj1k+qAdMN3OX2O7/BngpkzYs81ryWZkHqmNCuNW+TkQ2p7K91oRip9NQ== 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=pqoYW+ZppvfRNPNCv8U//lStS+ck/No3nz1J9q9VpPg=; b=WbqEcb0V2G4C+Usl+8lO/AY+lYT/Tu7u6/MmS6lamY9PcorPaGp/XjTyhE1E0A7wGJa0EiJ8vpPPGuQthythGqamAFhOia76Wd/1VP1EBhqPKd64GwTaKhS4q9wskk2Jkj19OMFABlV/pw0Q88oSOgOZsbfS0b4hZixkDqnd/bA= Received: from BN9PR03CA0965.namprd03.prod.outlook.com (2603:10b6:408:109::10) by DS0PR12MB6461.namprd12.prod.outlook.com (2603:10b6:8:c7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 02:43:35 +0000 Received: from BN8NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::6) by BN9PR03CA0965.outlook.office365.com (2603:10b6:408:109::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:43:35 +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 BN8NAM11FT084.mail.protection.outlook.com (10.13.176.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:43:35 +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.2375.34; Mon, 29 May 2023 21:43:29 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH 4/9] wifi: ath12k: Add support to the Qualcomm ath12k for ACPI WBRF Date: Tue, 30 May 2023 10:42:22 +0800 Message-ID: <20230530024227.2139632-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT084:EE_|DS0PR12MB6461:EE_ X-MS-Office365-Filtering-Correlation-Id: f3a26c40-d72b-4517-7d32-08db60b7aa4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /oeBcEucD4u7h/xDusOvOhXB2S3/Jd8IYlluECkrzDK23wbsRGumfH1HlwZtnKCWQduQ7bNXvDBrUQ03lRih9SSr37baGtA4XFFP8y0+t5FuW1BUjhOvs/NfjWNuEJEIxhFCIGvmME1SHuobat+jIftkrSVcYbYWOVXtYnUT6/oLGUHQdKThZy4a9ClHQ4qP2TjyTx80iCqZHzJItz1rrgVbA1UK0+YfK3/G/iHcd0fcGwKNc+T9/HSZCL0I4Ko4vbk/LHsE7yGLRVN9iCBfw+VIhLEyiXJTIqgsaOq6Y6iTWAbyDVdaPO2iGPj9GSPOe0Ebj98Cltv3jm9K3oVv3NgLdqEUre+cgBFxN931jjwj4g4HMK4aIgXvcLXmgclU0yCdiqhH5autkiMYb7MzyN0pn83hCDRLTTPKssQ6hswHV1sah/eAQAden03TEUjKATaePDm3Ek35xtkJS3WAMY/PeW4dIydLRdmnqENIGquyO/7NcmTJBdw4C2atrqFTSAEr6t4sbY907WJLhAbKICz+ucx66DttIWYhgpLhrB02CneoWR3Yum5bNw7XumLzR0myYloogSdT9sY+qF+6A58b4/+85jg/nv8UgOaXNB/QCc5BhICk+J3RpPNWuvKvGYedMBmug0UrQC0fcHMmKcYeuMB50CdDHjCEqm4x0EwrcFfApxuNis9ugKLQoAmuYtbw1lD7In8MEaVhYMFMrP8oKhnHhKPJ2W3AYxk5BUU3d10xFTkI64XApWD5GxZS4CVZ0N3bJEARFwuqaDaGvYxxyhFosJ9EzBIrdt+aBKQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(47076005)(36860700001)(16526019)(186003)(26005)(1076003)(41300700001)(2616005)(83380400001)(6666004)(426003)(336012)(7696005)(478600001)(110136005)(40460700003)(54906003)(70586007)(82740400003)(6636002)(356005)(921005)(82310400005)(40480700001)(316002)(81166007)(4326008)(7416002)(8676002)(70206006)(5660300002)(44832011)(86362001)(36756003)(2906002)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:43:35.5296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3a26c40-d72b-4517-7d32-08db60b7aa4e 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: BN8NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6461 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Qualcomm wifi adapters are utilized in systems that support AMD's WBRF interference mitigation mechanism. For this mechanism to work frequencies utilized use must be notified to an ACPI device. If the kernel is configured with CONFIG_ACPI_WBRF then notify this ACPI device accordingly. Change based on code review, not tested due to lack of hardware. Signed-off-by: Evan Quan --- v1->v2: - drop unnecessary EXPORT_SYMBOL_GPL(Mario) --- drivers/net/wireless/ath/ath12k/core.c | 21 +++++++++++++++++++++ drivers/net/wireless/ath/ath12k/core.h | 14 ++++++++++++++ drivers/net/wireless/ath/ath12k/mac.c | 4 ++++ drivers/net/wireless/ath/ath12k/pci.c | 3 +++ 4 files changed, 42 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index a89e66653f04..fde811524756 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -14,6 +14,7 @@ #include "dp_rx.h" #include "debug.h" #include "hif.h" +#include "../ath.h" unsigned int ath12k_debug_mask; module_param_named(debug_mask, ath12k_debug_mask, uint, 0644); @@ -935,5 +936,25 @@ struct ath12k_base *ath12k_core_alloc(struct device *dev, size_t priv_size, return NULL; } +#if defined(CONFIG_ACPI_WBRF) +int ath12k_add_wbrf(struct ath12k_base *ab, + struct cfg80211_chan_def *chandef) +{ + if (!ab->wbrf) + return 0; + + return ath_add_wbrf(ab->dev, chandef); +} + +int ath12k_remove_wbrf(struct ath12k_base *ab, + struct cfg80211_chan_def *chandef) +{ + if (!ab->wbrf) + return 0; + + return ath_remove_wbrf(ab->dev, chandef); +} +#endif + MODULE_DESCRIPTION("Core module for Qualcomm Atheros 802.11be wireless LAN cards."); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 9439052a652e..53ffb679b5c1 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -736,6 +736,8 @@ struct ath12k_base { u64 fw_soc_drop_count; bool static_window_map; + bool wbrf; + /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; @@ -820,4 +822,16 @@ static inline const char *ath12k_bus_str(enum ath12k_bus bus) return "unknown"; } +#ifdef CONFIG_ACPI_WBRF +int ath12k_add_wbrf(struct ath12k_base *ab, struct cfg80211_chan_def *chandef); +int ath12k_remove_wbrf(struct ath12k_base *ab, struct cfg80211_chan_def *chandef); +#else +static inline +int ath12k_add_wbrf(struct ath12k_base *ab, + struct cfg80211_chan_def *chandef) { return 0; } +static inline +int ath12k_remove_wbrf(struct ath12k_base *ab0, + struct cfg80211_chan_def *chandef) { return 0; } +#endif /* CONFIG_ACPI_WBRF */ + #endif /* _CORE_H_ */ diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index ee792822b411..999354d60228 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -5396,6 +5396,8 @@ static int ath12k_mac_op_add_chanctx(struct ieee80211_hw *hw, mutex_lock(&ar->conf_mutex); + ath12k_add_wbrf(ab, &ctx->def); + spin_lock_bh(&ar->data_lock); /* TODO: In case of multiple channel context, populate rx_channel from * Rx PPDU desc information. @@ -5420,6 +5422,8 @@ static void ath12k_mac_op_remove_chanctx(struct ieee80211_hw *hw, mutex_lock(&ar->conf_mutex); + ath12k_remove_wbrf(ab, &ctx->def); + spin_lock_bh(&ar->data_lock); /* TODO: In case of there is one more channel context left, populate * rx_channel with the channel of that remaining channel context. diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c index 9f174daf324c..544d93d66d69 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -13,6 +13,7 @@ #include "hif.h" #include "mhi.h" #include "debug.h" +#include "../ath.h" #define ATH12K_PCI_BAR_NUM 0 #define ATH12K_PCI_DMA_MASK 32 @@ -1272,6 +1273,8 @@ static int ath12k_pci_probe(struct pci_dev *pdev, goto err_ce_free; } + ab->wbrf = ath_check_wbrf_support(ab->dev); + ret = ath12k_core_init(ab); if (ret) { ath12k_err(ab, "failed to init core: %d\n", ret); From patchwork Tue May 30 02:42:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 686977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBE10C77B7E for ; Tue, 30 May 2023 02:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbjE3Co2 (ORCPT ); Mon, 29 May 2023 22:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbjE3CoT (ORCPT ); Mon, 29 May 2023 22:44:19 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E309100; Mon, 29 May 2023 19:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/A7fhD6UWNvgh0wyepohp6RF2oQGFe1vw0J4vla2zY/ykAl7bX7EVmU7CgT92MA4p7VXVcwR3cBCFo2zEFDD+c9zHM4uOggcEtKCo2/ZQ++WHTu3Nk2N4Vo1J7RobX4i8H/15omy2FPDx5+6nHfpGcH0RThnrvoxuzLxz/0uEFjTtLet1/CRIHoOfcw1eNaCglsXczMu5BJEGbh+V9QzFW7DMRnmEdpeuqTL3SJK+WM/v10qnA4DqP8dX85bZpmzSSFm/KbC6OW/+ZxZsLSOAT4fYoKEMIJ74KvOXl2+SlkQEPo31WCDwnGOLS0PhemoELyh+ZhBp1d3PSQDk8gtg== 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=x6yf5Wa0WlXsKSGJNNgGxWou9LG68YEysF5avKreUgM=; b=mwsHHBevXAcoErbmzkCBTWkfEdRwoVjMH12DNpSx7fIh1d9d1+4MG8/YBp2TEhWUQMAfdqK6OqNYVhsdJ8+MRr4Y7Qs+JTK5RyQxt1Ps2oajGDgZezvEwMJydS47qD20Oxef+rY19+j+7Th4XB/6DtbENWOsQ5yNKG1hZUbl6iu4YkVvLmd43tTTyqXJnxRBknH6uoHrHHh8ZmPZrlC90HAfwvN3W9RKHjLrBTuCB9Pi7pfzHE5upQSIVLvNdVzPHykfqqgaxchvFsGSoAVuU2aOMknLdYxaYgx89JwCfsGym9PFS6zWujXJnhq52cjImAv8BELOhfIpodTlRqD5aw== 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=x6yf5Wa0WlXsKSGJNNgGxWou9LG68YEysF5avKreUgM=; b=gNGvZx0l7x3zCTJyygZ2TpGC7RHerHGtYaZ8RlYqtDQS82P3pTxndRVfGIcazUUF+n8U9TF2roUVHAlWO6bi9TKqUbY7TKtiAKIwEXllQRYN8ETmwiZq/4iwzg5pr7de8BMBx8IWavPntdO9jKZnLW15RB5b7/Qj6vfYUlIU684= Received: from BN1PR14CA0023.namprd14.prod.outlook.com (2603:10b6:408:e3::28) by DS7PR12MB5768.namprd12.prod.outlook.com (2603:10b6:8:77::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.17; Tue, 30 May 2023 02:43:48 +0000 Received: from BN8NAM11FT075.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e3:cafe::9f) by BN1PR14CA0023.outlook.office365.com (2603:10b6:408:e3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:43:48 +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 BN8NAM11FT075.mail.protection.outlook.com (10.13.176.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:43: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.2375.34; Mon, 29 May 2023 21:43:35 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH 5/9] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Tue, 30 May 2023 10:42:23 +0800 Message-ID: <20230530024227.2139632-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT075:EE_|DS7PR12MB5768:EE_ X-MS-Office365-Filtering-Correlation-Id: 4482cd13-91e2-43ce-8f99-08db60b7b1b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6giuCOW/d0FOVgnLNcq7To0n6USSPtqzL5yjQNm7D2NYoMzWlklQBYLLoEMIxPybQjMUqGmTSv8gifGuSpGjKxoZj7lsovS15sGpq2O/bFFQ4RV5+UHxE3t71AO7F+dhHtmGOfgB8FRd7hfCKO7wJfgEGWA0VSRJfSYv94u32SsB6YQNH4YVIiNREN3mOxSPL+3MuWDjbxdgUbNTY6wKtgZlOV9oli9o/yBkaa2yykkuH0nIov4UCR/9eEZlKfhg2di0mW3LmhwmLKyuTpTLXhboSxzQ0JONrGOdNLGWKCRc2s0R/7hO2Dn6+ySXun5BPB2P91JXR5RLLs/+JdCaR1eb8JfQw6w99ov8CaXc1nW8h3m0cL+wTn1aQOopcrwHZC4Mkm32Xbzh/HfwpeD0r/9VOOoFCh4lanqhOJ0rsjPTrEIwqcX/hI4lXJUsLbBsFAXhdoF+bY313eTGWJLS2sNNK+3lRiHzAM5xYAM04LM8hWDirkpm6vyEeDcgFgfRRo7CJqW8GSu9iZbSvVVnjkuFyKgZAmvGSjnRPDrMc/r823M38D/vcRK8+rSHPOwlX+WgmpN2dHTNUX+8c0EQdibVJybGd0+KcmKZjoWllH6tmx7r7EMwphqmE8jzmAI7HC0vbNRzlGTBofXwwml9E6FJzY0w4Lz9wxnZnybS4szIwgLm+dtr5sPgmrPvvxVdEvJBjdr5GbwLB3VlsEjb6xApRB0XZkdq7cSLRjvSiC+GhYeMLaRCWUYpMVcFNMVCOjhr/rtLYcurHFA2Jc18egmdVIiXr926Wm4RljBmXyk= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(346002)(376002)(136003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(316002)(36860700001)(40460700003)(336012)(5660300002)(1076003)(356005)(82740400003)(8676002)(921005)(26005)(8936002)(426003)(83380400001)(15650500001)(186003)(2616005)(2906002)(81166007)(16526019)(47076005)(7416002)(44832011)(40480700001)(4326008)(6666004)(6636002)(7696005)(41300700001)(36756003)(86362001)(70206006)(82310400005)(70586007)(110136005)(54906003)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:43:47.9310 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4482cd13-91e2-43ce-8f99-08db60b7b1b7 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: BN8NAM11FT075.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5768 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan --- v1->v2: - update smu_v13_0_7_ppsmc.h to fit latest messages definitions --- .../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 Tue May 30 02:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 688342 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 760F3C77B7E for ; Tue, 30 May 2023 02:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjE3Coj (ORCPT ); Mon, 29 May 2023 22:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbjE3Cof (ORCPT ); Mon, 29 May 2023 22:44:35 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062.outbound.protection.outlook.com [40.107.94.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6416EE41; Mon, 29 May 2023 19:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iCkXu0SUEDIUZfwvzAerV68vIz8MrlfGO9/keGAp5dDSM5S+WVruMN9C+C48uQ/v2haAcJRddKWsqdVRFcpGniD1rWOcU2GO7zNHxZsf+gQXxK0sr1hMgCW2TB4wUSjaunYeuDWhBbAsvmeN1G4Vnf2sRqX3we4oW1Pfl+Cv5RU3K+/kBbZZoOyR4MJto29cNu8yuMt9LERpzKyWHMRWbEeanTsNECGfmSyt7vXKCZHYqhr4mn0hOLo8JuaQkkedVk6vI268CC9SVGaugLjRQnYH8dyG5gu96tPLOp4skGDRpwADIri20ksxaNk8+JqhhggxUqQLG345XE+tEE1H+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zM4E1IBXv1Nhe41O+8IWq5Pkm6YST1ULZ0qkXRlZv1M=; b=h8EsgCoTGQNHMryjZYbAD/wzxhIWX5BYVAAqSlURiQtr43qyD1E94QN2mpkasQvv4aVV+y4y0r9JRll15uhLNQ76WFu2vNXw5NhzUsB7yeNia0pY9ug5hct/5APm/a+BLlkMnL2E07ci5mSkFOZB2TQsEpRTPrN978RcxBmTjGR5a995gmlYqm5EaUXsy9xVCInsWv++jBklGUwCKlqyTiern8GP+OlriyPIWo+4ddGNDS65BPyU1iyxorFSkBn0e5zCYdSUQ0qU0LBoLBlQkGS8crPsBl5tmU6qmEodn9CofHKCOAEPKkXIRCOw6mU0Neq0IDxRsxfo906rHvaCeA== 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=zM4E1IBXv1Nhe41O+8IWq5Pkm6YST1ULZ0qkXRlZv1M=; b=XPR/BpHI66kXGK/Sk9abh/j8wqYEdlU50tdhVrv+Wu1zZEY42H/59M0a9fuHOM9Zy9AkxlkUSAFpIFctNSVQm5HVnPRKw5/neizqPY1GP8DPSU4h8Da6UwKdBMAvH/uGACPH5ArPQuheqYbxNfkgV7ny5BP06waizIFJ5uLbHyA= Received: from BN8PR16CA0006.namprd16.prod.outlook.com (2603:10b6:408:4c::19) by SA1PR12MB7295.namprd12.prod.outlook.com (2603:10b6:806:2b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 02:43:54 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::4f) by BN8PR16CA0006.outlook.office365.com (2603:10b6:408:4c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:43:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:43:54 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 29 May 2023 21:43:48 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH 6/9] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Tue, 30 May 2023 10:42:24 +0800 Message-ID: <20230530024227.2139632-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT058:EE_|SA1PR12MB7295:EE_ X-MS-Office365-Filtering-Correlation-Id: de233692-a4b1-49c6-550b-08db60b7b59e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gB4eWDHn9f2JnPCaC1rwvXSxUYtrx3Nd8sakpK44fAQ/PStLArUQDj4dCvD0rZ8rmcUvyW5JEt7SnSkNDhu3hirwxOnCwfynnG/koTvKhhUcBimTKLrdUUqYS9WQKEcaQ7iF00tBSZ3tth97UB0qWHoymWQyqdUjIGmNuE7s0hgg/NMOx98PhmBttWVKr9iT/OHjrz0lv/3QnHgCfz0PNvKnMjaOPr5qPzAgYiOEUtnUZjVu05uSjF2ZM3AzkS5/A5/Fx/Qaj0sUHjYWqgubJCA3LTHalwi1bZESaNSH5CtgcIGYXWxiB56BaJaUJzbjcFJPopng+iwGXlWQRGDgez67IcAjBbymG3L0GyVWUK8OWSZM/jVvwonukj9n+8amGyWu1ARnwvxJilmKIxOmy6Yltet94dSDTWSrkI/qOz2kSaoIp165IFWT6ouWgr2mYZXhiqcGHuH/EdaBOxr+W+6RwJc1P6+dFmWbxJvAzhQg+IjduTh9kcFfGiY5YqU4JtpuBg+YQNN/+Bgxw8QDunfIeAjI0BbUxhxuuNHZ4WXAs+kQiGKwabWryYEpeFyotj/1VvdfXoDLwY8V1WwsfiSGuJu61Tk8VKemIzfB6iuZPdnYcL/EMcGNzxDWmIl0Cwb1FXGZJJXKnZxuDFxtUp8ffx1FTzmdLf2sVcZlsV5KSe283BMD54/2QuMJrFJgAHQVNEq7jPBpJvo/f4E6IbqdaF8V+lPV/7fve9p/Oi8IgfxweNZt4OEoYIj8kPvFKBc1M7MB+V6n3sTlQxCOGWahohDakaX+JqEjZiDKjXoDv1R899SpkTNxWyKOisRpNXsxA57KHxVpgK8kBYpeT/vkV44fO669tAEpEKzC/y0= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(46966006)(40470700004)(36840700001)(426003)(336012)(478600001)(83380400001)(36860700001)(40460700003)(40480700001)(47076005)(5660300002)(186003)(16526019)(6636002)(4326008)(30864003)(86362001)(7696005)(8676002)(8936002)(2906002)(82310400005)(41300700001)(316002)(82740400003)(81166007)(921005)(356005)(6666004)(44832011)(1076003)(26005)(70586007)(70206006)(7416002)(2616005)(54906003)(110136005)(36756003)(36900700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:43:54.4922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de233692-a4b1-49c6-550b-08db60b7b59e 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: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7295 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org With WBRF feature supported, as a driver responding to the frequencies, amdgpu driver is able to do shadow pstate switching to mitigate possible interference(between its (G-)DDR memory clocks and local radio module frequency bands used by Wifi 6/6e/7). To make WBRF feature functional, the kernel needs to be configured with CONFIG_ACPI_WBRF and the platform is equipped with necessary ACPI based mechanism to get amdgpu driver notified. Signed-off-by: Evan Quan --- v1->v2: - move the implementations to swsmu(Lijo) - support runpm suspend/resume scenario(Lijo) - add missing mutex_destory(Mario) v2->v3: - Per the latest designs, get those ACPI interfaces needed by consumer(VGA) implemented in amdgpu_smu.c v3->v4: - update the descriptions for parameter 'wbrf'(Alex) v4->v5: - support CONFIG_ACPI_WBRF disabled scenario - correct the default setting for parameter `wbrf` as -1 (auto)(Alex) v5->v6: - separate those ACPI related code into amdgpu_acpi.c and acpi_wbrf.c v6->v7: - wrap the document and modinfo for `wbrf` under CONFIG_ACPI_WBRF(Mario) v7->v8: - some minor fixes around error/information prompts(Mario) --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 26 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 63 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 19 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 184 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 20 ++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 6 files changed, 315 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 02b827785e39..2f2ec64ed1b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -241,6 +242,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) @@ -741,6 +743,9 @@ struct amdgpu_reset_domain; */ #define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size) +typedef +void (*wbrf_notify_handler) (struct amdgpu_device *adev); + struct amdgpu_device { struct device *dev; struct pci_dev *pdev; @@ -1050,6 +1055,8 @@ struct amdgpu_device { bool job_hang; bool dc_enabled; + + wbrf_notify_handler wbrf_event_handler; }; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) @@ -1381,6 +1388,25 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_state) { return 0; } #endif +#if defined(CONFIG_ACPI_WBRF) +bool amdgpu_acpi_is_wbrf_supported(struct amdgpu_device *adev); +int amdgpu_acpi_wbrf_retrieve_exclusions(struct amdgpu_device *adev, + struct wbrf_ranges_out *exclusions_out); +int amdgpu_acpi_register_wbrf_notify_handler(struct amdgpu_device *adev, + wbrf_notify_handler handler); +int amdgpu_acpi_unregister_wbrf_notify_handler(struct amdgpu_device *adev); +#else +static inline bool amdgpu_acpi_is_wbrf_supported(struct amdgpu_device *adev) { return false; } +static inline +int amdgpu_acpi_wbrf_retrieve_exclusions(struct amdgpu_device *adev, + struct wbrf_ranges_out *exclusions_out) { return 0; } +static inline +int amdgpu_acpi_register_wbrf_notify_handler(struct amdgpu_device *adev, + wbrf_notify_handler handler) { return 0; } +static inline +int amdgpu_acpi_unregister_wbrf_notify_handler(struct amdgpu_device *adev) { return 0; } +#endif + #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev); bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index aeeec211861c..efbe6dd91d1a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -1105,3 +1105,66 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) } #endif /* CONFIG_SUSPEND */ + +#ifdef CONFIG_ACPI_WBRF +bool amdgpu_acpi_is_wbrf_supported(struct amdgpu_device *adev) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(adev->dev); + + if (!acpi_dev) + return false; + + return wbrf_supported_consumer(acpi_dev); +} + +int amdgpu_acpi_wbrf_retrieve_exclusions(struct amdgpu_device *adev, + struct wbrf_ranges_out *exclusions_out) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(adev->dev); + + if (!acpi_dev) + return -ENODEV; + + return wbrf_retrieve_exclusions(acpi_dev, exclusions_out); +} + +#define CPM_GPU_NOTIFY_COMMAND 0x55 +static void amdgpu_acpi_wbrf_event(acpi_handle handle, u32 event, void *data) +{ + struct amdgpu_device *adev = (struct amdgpu_device *)data; + + if (event == CPM_GPU_NOTIFY_COMMAND && + adev->wbrf_event_handler) + adev->wbrf_event_handler(adev); +} + +int amdgpu_acpi_register_wbrf_notify_handler(struct amdgpu_device *adev, + wbrf_notify_handler handler) +{ + struct acpi_handle *acpi_hdler = ACPI_HANDLE(adev->dev); + + if (!acpi_hdler) + return -ENODEV; + + adev->wbrf_event_handler = handler; + + return acpi_install_notify_handler(acpi_hdler, + ACPI_ALL_NOTIFY, + amdgpu_acpi_wbrf_event, + adev); +} + +int amdgpu_acpi_unregister_wbrf_notify_handler(struct amdgpu_device *adev) +{ + struct acpi_handle *acpi_hdler = ACPI_HANDLE(adev->dev); + + if (!acpi_hdler) + return -ENODEV; + + adev->wbrf_event_handler = NULL; + + return acpi_remove_notify_handler(acpi_hdler, + ACPI_ALL_NOTIFY, + amdgpu_acpi_wbrf_event); +} +#endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index b1ca1ab6d6ad..bf82cc192153 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_ACPI_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..89f876cc60e6 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1188,6 +1188,163 @@ 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 = amdgpu_acpi_wbrf_retrieve_exclusions(adev, &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 + * + * @adev: struct amdgpu_device pointer + * + * Calls relevant amdgpu function in response to wbrf event + * notification from BIOS. + */ +static void smu_wbrf_event_handler(struct amdgpu_device *adev) +{ + struct smu_context *smu = adev->powerplay.pp_handle; + + smu_wbrf_handle_exclusion_ranges(smu); +} + +/** + * 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 && + amdgpu_acpi_is_wbrf_supported(adev); + + if (smu->wbrf_supported) + dev_info(adev->dev, "Enabled RF interference mitigations\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; + + ret = amdgpu_acpi_register_wbrf_notify_handler(adev, + smu_wbrf_event_handler); + 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) +{ + struct amdgpu_device *adev = smu->adev; + + if (!smu->wbrf_supported) + return; + + amdgpu_acpi_unregister_wbrf_notify_handler(adev); +} + static int smu_smc_hw_setup(struct smu_context *smu) { struct smu_feature *feature = &smu->smu_feature; @@ -1280,6 +1437,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 +1542,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 +1606,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 +1765,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..ff0af3da0be2 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -573,6 +573,9 @@ 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 i2c_adapter; @@ -1354,6 +1357,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 Tue May 30 02:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 686976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03438C7EE29 for ; Tue, 30 May 2023 02:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbjE3Cou (ORCPT ); Mon, 29 May 2023 22:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbjE3Cok (ORCPT ); Mon, 29 May 2023 22:44:40 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4189E4; Mon, 29 May 2023 19:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fTmwR1mzNCXnzeLfORj3QIctkO74sHVHmP+2tiYwiFBnUCiNXJ8z/jSLvNpURTsx4HMG3GnW/0y7YswX7kggBSdnXXt3/UywwfbQ7HXFa3oDkUpeciqjWyw9OVzlIOJmT6GI3l2Qpx8sdS2aBHQWEOwZ7IxIB9kooX3lqboucu4RoBtH8SU4ZbLPz2beEhIodJR1c1EJGVBT6QZwLXMqen9oWjxg9E1omSZKaUGwUi0BTUNQ26bjwI3KqTAoedPkcfi/IVVRu3fwA8niF92t3F4N/T56AsUCla0BpiVztQmCAawLbtuXDEPPbwI34jDACdjXORSIZupK04yUt63//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=D5BWoNQzZsM1yKgT8FJmEZMD/hQq9cCO7SKM+IQtK/0=; b=Mx+lo9OqXoFO/5Nzl7GqtBVxRCoA2qR0j6OViMv2Hj3V7pUyGsaDX6wNW3BbbfQSsrU06r4x1spRcmiUhnexNummcMwk7PRKLZ4pkaiIV/Skx4cnZfRGDZ4hWa79/EWv35HO1BT17jUgXvJ9GuBpDL8ldbHJyoRIdF0LVUojEVp34uwa/dJ6uTcmanW7XBW4LKLpsBSWs8RxBW5J01zVMokTQjg0NCSdWoVzW392yTKzjcToemCLfQhxapl1vYlHipK9pVrN4u+EgAHCKKjJzUqCDvVjZdvXMUgpcxCjavK4y7ubU2QNsug1WBkoNmMq16MbaVjrNxudW/OgU5/QXA== 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=D5BWoNQzZsM1yKgT8FJmEZMD/hQq9cCO7SKM+IQtK/0=; b=TVuHs5bfQcP9Fe3g5il25LnjLnlamxqG0WPhFnIA7GRsRndBZjPjoMqCRiX+FyE2xK1pwu6JOF28SUDRpSgOxXf+cPcegJWSvYwIkScp1+FSwL3vwr+vzNrac0wAIxIt99MamP67Q6N6zIKYodh6RoJ1FE6C+FmKbOuN4OcGxzc= Received: from BN9PR03CA0513.namprd03.prod.outlook.com (2603:10b6:408:131::8) by CY8PR12MB7708.namprd12.prod.outlook.com (2603:10b6:930:87::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 02:44:00 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::85) by BN9PR03CA0513.outlook.office365.com (2603:10b6:408:131::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:44:00 +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 BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:44:00 +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.2375.34; Mon, 29 May 2023 21:43:54 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH 7/9] drm/amd/pm: add flood detection for wbrf events Date: Tue, 30 May 2023 10:42:25 +0800 Message-ID: <20230530024227.2139632-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT049:EE_|CY8PR12MB7708:EE_ X-MS-Office365-Filtering-Correlation-Id: ecda4d38-3830-4d04-87ac-08db60b7b92d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VpYjlDWmymBGMIhBzbbbaJ4EQbI2A5J3XeuwAdY1hRnRvA5DqCwP9CUFhzXR+OL+lrktw1JHz3ezyGHxhPX+vUI4ncLfTISxIvtVIutqmw+NKtRe2mk0z9hzbvQSwwjIX4zp6j6s5sDHrVDxpYJi+3sXYfRcKAZQE36ruy2dratNa+aB6iTOn+TT7lzzCcVf7Ux6cA+N0zFlkfadP4enwG4OPBNfHgGi4GG2K5i65U8Znu9lZCwFyw3oXX7kdgmYI0tosN1K7oCx8X2tBdLrvBiqjUeAf0mfRCJmsRE/uLo7IZnqfX9URXeg/HTCw7LufH+fIZZOQb6DWdnWwaDjT00/cAqcGafyTFOFZY4EhjWkwDlKzGdO2VdYMgYPonPPuaD76ipl5GvTPVtimp3I6/0aF0Lqn/WUCNRvgdzAUGQYubAXicfmDw4z/EjBV4M6g4SUUarFKzHTeH/njDfFWxCWGMiUbwUfTb/rUblvRzou0ImVG1+niq+3w0swMZqFsqq6Ad2bFLWcXXN7/I3NJJy+h4UdgTt6ihbP4BEnJ5hWyJ6mox1tnk5ajCLVj90eGtJzLhEP9LesTxusNI+3vNqSkS0/C9ncG5t7D0NWmPe5uSuQNuDue4kzHK2xKli+PSQxFnIaVI8lokua79qBab0wIud/tYZ4SMG00ioj22lAALjRnHgofU/hm+HXXtDLoEOGKkYzgYPUD/oyLx5zl0JRreyqkYV2xSElQ1vOxsn99KC+CKl5wzvic/d7Uk9Qtbmaz1+qk4ILRPOBuh6QZgiOFntVnAELyS0ydbjFuUw= 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)(40470700004)(36840700001)(46966006)(336012)(426003)(16526019)(2616005)(41300700001)(83380400001)(26005)(1076003)(186003)(6666004)(7696005)(36860700001)(47076005)(478600001)(110136005)(40460700003)(54906003)(70206006)(82740400003)(6636002)(4326008)(82310400005)(40480700001)(356005)(921005)(316002)(81166007)(7416002)(8676002)(70586007)(44832011)(86362001)(36756003)(2906002)(8936002)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:44:00.4170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecda4d38-3830-4d04-87ac-08db60b7b92d 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: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7708 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org To protect PMFW from being overloaded. Signed-off-by: Evan Quan --- v1->v2: - utilize the delayed work(Lijo, Christian) - split the new module parameter changes out(Christian, Alex) v2->v3: - simplify the flood detection further per latest design v3->v4: - drop unneeded wbrf_mutex(Lijo, Christian) - use schedule_delayed_work() to avoid possible concurrent access(Chrisitan) --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 28 ++++++++++++++++--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 89f876cc60e6..2619e310ef54 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1272,6 +1272,22 @@ static void smu_wbrf_event_handler(struct amdgpu_device *adev) { struct smu_context *smu = adev->powerplay.pp_handle; + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); +} + +/** + * 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); } @@ -1311,6 +1327,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); + ret = amdgpu_acpi_register_wbrf_notify_handler(adev, smu_wbrf_event_handler); if (ret) @@ -1321,11 +1340,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; } /** @@ -1343,6 +1361,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; amdgpu_acpi_unregister_wbrf_notify_handler(adev); + + 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 ff0af3da0be2..aa63cc43d41c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -478,6 +478,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; @@ -576,6 +582,7 @@ struct smu_context /* data structures for wbrf feature support */ bool wbrf_supported; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter; From patchwork Tue May 30 02:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 688341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ED12C77B7E for ; Tue, 30 May 2023 02:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbjE3Co6 (ORCPT ); Mon, 29 May 2023 22:44:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjE3Co5 (ORCPT ); Mon, 29 May 2023 22:44:57 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2041.outbound.protection.outlook.com [40.107.212.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 851D718D; Mon, 29 May 2023 19:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DiJrOaxCSbECyxC6Hb5KZf9cnY54RFYnXkM6dSZon5ZosU2cjWz2YwjmxHsOyU8jgwwV6V6wvdK0NxfX2K3Sf5TqP681ol18580XX9UjnXE4c87edVPR5x2Q23KDzFWLIG399pKaZZc3S9C583x1RnvzuAVjMiZO+8CS/3HY+mVVPIvHATFdLnvl9zDNANv6t1p+QA67ZwXfr7OBAOEtiFNHoNm0Yu0MzTmsYJzm7DNLBVG/6K2uv+qXNsLRZX76IG9J4ZSMwgycyD82/vomjPgyx6+/ERYwUV/MxQvNu0+udyal9KlRiWvGoTT8jA99WKUEPsRu+zFf82wwJJZByw== 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=+DPiMETxb14ONOEhEw63QFZbtn7slHl/H0PGwnx9R4M=; b=aAki85GbaYaaBwwqfXvYj4PhicDpmH+4Ux8uRD5I1AN+qPYOoNSDKgcyDfMl2fRI9NYPgHtfKTWUHkJMvETgzCCdEKe0vT8+S73vzDsofJ6zpBHNedYg/oj7r4ymFW0xsIFqasTGK2jlBJTCNCMi87gDxuOMzueozukm6++Pzxbeo3rXhcjbDNAtV0o6bEnxujRGCmyLYc8pLzf/HSpYHyhhKA2G73JMTU+/BFfZ+uX5JWhEuBkC1rKU+yF8Hlph8k33zp3yYfFuCl5VrgnS2S8Mp+tKoLX38YwFPP6/CfyXUL/QLzM1iSACVxxvkfT7y37tqJoZ5DQyosFed4NDuQ== 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=+DPiMETxb14ONOEhEw63QFZbtn7slHl/H0PGwnx9R4M=; b=cZUSERpK6zQIOQYilZx7EOtZOG3fa5jqQU7Y5cRZhHucCqwCToPxVdki+QPxvYRumZakzMf7+9A4FKSyjX0oVbRx2O2zBPKg/66+XK8wgLdmwyxxawbp347RziHBENZqTMSnY2hqQK4CscmHivHPASr18dhRRKSlmjd6XwFgb6U= Received: from BN9PR03CA0987.namprd03.prod.outlook.com (2603:10b6:408:109::32) by MN0PR12MB6224.namprd12.prod.outlook.com (2603:10b6:208:3c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 02:44:07 +0000 Received: from BN8NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::92) by BN9PR03CA0987.outlook.office365.com (2603:10b6:408:109::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:44:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT084.mail.protection.outlook.com (10.13.176.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:44:07 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 29 May 2023 21:44:00 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH 8/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Tue, 30 May 2023 10:42:26 +0800 Message-ID: <20230530024227.2139632-9-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT084:EE_|MN0PR12MB6224:EE_ X-MS-Office365-Filtering-Correlation-Id: bcccd112-40f5-4b19-f7c8-08db60b7bd2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K0QZKt1Vs8kWkMNf/DkV4e2rSYTOnNKcsanWZhkLVATuebrrGfag5Z9hg8Lt6WAVyLyfT/uLMb8vIh1g4Z3VMYKtp4GkaIepPMhhkg/O64KuxKg8VpP4bLIizt9GZcOlXs/UgQNAKX0p7av6sga53SUflMQbvLBSSC3WKW4RTn5E89eBmtQ++Lx+rrJ7r6Xm9T84D3LgGWJT+xQpu+xivH8jOuUl0Rmqq7510Qypy1tFoXrufjO0Wg+0E7nz6qNa3mlGTfIOxuN3Ykfk7JKDE0PBch1mJuJ5Ga6TVwA6fRhdLgiikgeTYJq+4sLDd0GNJZRi5TlNf6yQOAU22H1ja9KREZW7Prfci/Z2OUHprqTUc+uHkos1w1cIZPTJJwmA9qyVSC4/0F/+Y+mfCuKX+OQIN4e7flTOZXMNPpU/IEWEF8lLwnXxoDmJooXgxI/XZgVARXWV+GMAUxYF8ED+dI5TrVDVC087W4oNdQw4WEx6BoLxH86s8+oHrMxpqQ4DY9ij+xwJpkJ3UGY8mvtQ2YjD+YdCSO+t9p4mOI7hEQPZbKyhPMMcr+7YDuS/4peWSo4STO309QcFQF1wnZDtd55P596DbspjibeepaahqbgJLNv3CcTpqqXzn6gg9cWJNbwv5nOqcsmAH+NvLe8BnV1U4aiHa2cx581fDHwVNXFY0gThB4hBKbouWKcBr/DIFmX1oTwynuFN2O3TtMZpElUfp7gWiGcB4+66YXw+/coOkpsuvK4Wpr+px5GZP1mEJ/CHrndpWHUTjZm6kwMyf053SHUQjLKzTMGuRW2jNtM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(136003)(346002)(376002)(451199021)(36840700001)(46966006)(40470700004)(316002)(6666004)(40460700003)(82740400003)(40480700001)(7696005)(41300700001)(81166007)(356005)(921005)(36756003)(36860700001)(478600001)(7416002)(44832011)(86362001)(186003)(82310400005)(2616005)(83380400001)(26005)(1076003)(110136005)(54906003)(336012)(426003)(47076005)(2906002)(5660300002)(4326008)(16526019)(6636002)(70586007)(70206006)(8676002)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:44:07.1841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcccd112-40f5-4b19-f7c8-08db60b7bd2e 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: BN8NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6224 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan --- v1->v2: - check the wbrf support using pmfw version(Lijo) v2->v3: - some minor fixes(Mario) --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 4 ++ 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 | 62 +++++++++++++++++++ 5 files changed, 80 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 aa63cc43d41c..b71df196d047 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -323,6 +323,7 @@ enum smu_table_id SMU_TABLE_PACE, SMU_TABLE_ECCINFO, SMU_TABLE_COMBO_PPTABLE, + SMU_TABLE_WIFIBAND, SMU_TABLE_COUNT, }; @@ -1496,6 +1497,9 @@ enum smu_baco_seq { __dst_size); \ }) +#define HZ_IN_MHZ 1000000UL +#define HZ_TO_MHZ(freq) ((freq) / HZ_IN_MHZ) + #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 393c6a7b9609..8c2230d1d862 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 09405ef1e3c8..c617046cb893 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) @@ -2112,6 +2117,60 @@ 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]) { + /* PMFWs supporting WBRF feature are not yet available */ + case IP_VERSION(13, 0, 0): + case IP_VERSION(13, 0, 10): + return false; + 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; + uint64_t start_rounddown; + uint64_t end_roundup; + 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; + + start_rounddown = rounddown(exclusion_ranges[i].start, HZ_IN_MHZ); + end_roundup = roundup(exclusion_ranges[i].end, HZ_IN_MHZ); + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = HZ_TO_MHZ(start_rounddown); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = HZ_TO_MHZ(end_roundup); + } + 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, @@ -2188,6 +2247,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 Tue May 30 02:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 686975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4443AC7EE23 for ; Tue, 30 May 2023 02:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjE3CpT (ORCPT ); Mon, 29 May 2023 22:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbjE3CpP (ORCPT ); Mon, 29 May 2023 22:45:15 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43E931AD; Mon, 29 May 2023 19:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lVobFsa8NpPMgGaV0rbMSeC5+vgz/WO6ndBoqBDEdMCCHBS3JdDmm2RE/ZVcbpNRQUwHsFreroY30pz/qbCvMMfqVf1WPGu6ak/EuTGIjnQQO5B3152OqETvd2I4YkAEcaTKPu/wvKN+s+MDRCzgjPEcVZ5uwsGN2c7INMlq+KG6gl0JH5lj57H4n15Ku54hISI15olkA9061ze9IDo3AX8BA49vDauLKYp1lVS/HUPFd+fjrIMxcvafNOAvbKRHMrUxG2R76XKPqtBKATlxBjKZftW/R+GRmxCZE3Q9GjvlSdOoj6LJmEWJij8Tpawx9IYIdEJi1X4+asMkMUhNZA== 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=DvOPH4a1HF+Wn1Cr30JJC456qjKMVEuOZFPrL3Y9Ajw=; b=J+GQRTuFj7dmV1ZKa/d67WW7Wt9Vn/WVo/o+4sy6XVBVQK2+TZXJaYd9tJyneECXyvn/y/PLXzCJ2WYtM4r3fkltODAGQc+Xj4Z63B1ACZhDqATCFEmYprHbeEjyl8NEcywURDnGe1aRaF2+yzDjQgQ0ZfQfmsKurP+9OSDtqhEQyuT2wekM7gl1APxnkjBd6dmXj3mnaapVLp8l9pvmzRFA3Ra0vEyH5EYajbUx7CNIj3VGscF05HEN0BglAVgTR6DrA6uYbBE/cG20YdtSvkQOCBjrONUgvdppqIk+SbE2q1SpNpGgZdVqzt5v7R9Z96fR89iUcwRzCGSabr0jHQ== 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=DvOPH4a1HF+Wn1Cr30JJC456qjKMVEuOZFPrL3Y9Ajw=; b=M8gKFGwOLkJ/FegitRQtGSLrjHMlo6jve08sqY9RirdSUire+SVF0Iq399oz/lRuQ3J98xA8GuniRiqJeWsj0mbR/WI3oqekklVwGx30GLFw09ZYXV/dktKdjz8gufgPRr1BuSCFw9ZYfZP43Bul/AulVsINWkJ6ZhFUVad5O+4= Received: from BN0PR04CA0142.namprd04.prod.outlook.com (2603:10b6:408:ed::27) by CY8PR12MB7492.namprd12.prod.outlook.com (2603:10b6:930:93::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 02:44:12 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ed:cafe::1c) by BN0PR04CA0142.outlook.office365.com (2603:10b6:408:ed::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 02:44:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.21 via Frontend Transport; Tue, 30 May 2023 02:44:12 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 29 May 2023 21:44:06 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Tue, 30 May 2023 10:42:27 +0800 Message-ID: <20230530024227.2139632-10-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com> References: <20230530024227.2139632-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT029:EE_|CY8PR12MB7492:EE_ X-MS-Office365-Filtering-Correlation-Id: cd9173ad-4b57-4c6f-6f8b-08db60b7c071 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a6RhYQkiKZPMJAVr/JkuK27HisTs8JHQFCnZZ2UUkqiPAclRuBaTvo2cm7+oUVWjr3HXEtBXheG6y+WRIeQozsKpekQ7hppGWeULG7nD+nxPRNIogaWOPB5khRkgj652lWopCgBBknfUhhuyiElov4R9k2JCV5VmK2CPTTaUs5JsynKUGHaZ9wBJtM+n18F3cn5M5Tzh07ioMRsj3wSaHcc1PWvP6j1WThQBRpa9k44zFArfwi3B8NPJleERROSfiHxKcXan+F6tYjTdsrLk5vGK3Tb+rdtoV+omWkQxYYVYQALPIXJ3qo+Lri86dMFeoeCEItWd1efobI2fhzwXr5w0Xk3v26cTQFwFDZ3yQqZsBzYJWm38M951w45zmA9FN7WHp+YxlL34OAMG1m4WgMm8Dpz7j9QR90QyRwQQ+0bfvUi+4xfYz8yDAaif9K+LvGNr96WAOREwH77mhPO6mMnhIWQel3t2ytGH23bJmj80Strwd2ovX6JOXAjEqSPmITyVYX6Fo29W8vx9BGcy5ymO0Q6vKVwMMcNz6KsJGL8ncLpRDnCnkt4z7oOFB9/ykWz+BlTX09ONFS7/EibY0aau/KBUA0CkelcNr15M1Xk/5Nbz3YTnN/6PXPtzIe04AubOrSUhpcpXAaFKHMX5IgC0/hoQyzu2bYaYsSp6pxM7yB2a0S5hpDiprKdfxY0WaEGmCFjK2MoJGD+YgXP1kQfhKqkOoRkEDQ+VzcoxE6gajxyBmtfKuMhJGslfqh3KeKKOoyVaberNz7AK3SA5uP36Vqr3EdBiKosRianD1vQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(136003)(346002)(376002)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(47076005)(83380400001)(2616005)(426003)(336012)(2906002)(16526019)(186003)(40480700001)(36756003)(82740400003)(356005)(81166007)(921005)(36860700001)(8936002)(8676002)(7416002)(5660300002)(86362001)(478600001)(6636002)(4326008)(70586007)(70206006)(41300700001)(7696005)(316002)(6666004)(26005)(1076003)(110136005)(82310400005)(44832011)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 02:44:12.6529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd9173ad-4b57-4c6f-6f8b-08db60b7c071 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: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7492 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan --- v1->v2: - check wbrf support using pmfw version(Lijo) v2->v3: - some minor fixes(Mario) --- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 61 +++++++++++++++++++ 1 file changed, 61 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 98a33f8ee209..d885f20e33d7 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 @@ -125,6 +125,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(ArmD3, PPSMC_MSG_ArmD3, 0), MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = { @@ -205,6 +206,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] = { @@ -487,6 +489,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) @@ -1721,6 +1726,59 @@ 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; + uint64_t start_rounddown; + uint64_t end_roundup; + 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; + + start_rounddown = rounddown(exclusion_ranges[i].start, HZ_IN_MHZ); + end_roundup = roundup(exclusion_ranges[i].end, HZ_IN_MHZ); + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = HZ_TO_MHZ(start_rounddown); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = HZ_TO_MHZ(end_roundup); + } + 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, @@ -1786,6 +1844,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)