From patchwork Wed Jun 21 05:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4144726vqr; Tue, 20 Jun 2023 22:55:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Z64LlkEKx3vxUhseSrMmWReWF0AXa6cfIvz+ZdxGz1r5uTyH7wHO2RHHHlRx9JXzGzhES X-Received: by 2002:aa7:88c1:0:b0:668:83b6:bfe8 with SMTP id k1-20020aa788c1000000b0066883b6bfe8mr7815171pff.9.1687326921265; Tue, 20 Jun 2023 22:55:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687326921; cv=pass; d=google.com; s=arc-20160816; b=dJ1hmphHGrJYT72uX92L1yXFaNAc5QCNbe9vWEomk18djRaJHcZRBWrtIQIziCx/yt VJ4M1MoaDrBPA5YGexz2qfmmYyvQGgQ9RLqrunkqwyOfgfak0eo9XQrnzGQclFDWkHmJ 08upLNqZkptHVzweOmeRj+Pxc02SURgDeBGn4T/PUwXeJ4iDFhcj7aieBCu1WUOCoIpw NKuzlhRIgu5ilDSvJfW5mQInT6sw0zemAhSf+5LbjQ5SysHMkzbV+IgzZtXTIH9A+mWl W0cXnaFGNGTFW9RXRonRGIGMRcsr63ct7lB99TzO77qBtA9wcLyQHLUFyHdG5YLki/gn gXQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cow0QdZCPEsGDMYAI+jklwqjwTBkNc7U47PLXhHPBDg=; b=uLk/xwC/Cl+1r7Fbi0UfdrpeKy3ZI+biszvURtHQfGVOF1SzG7kSNhGHcNFXHmSdde 5Vt3A5H8andI92B981Y44qV8dx2/IHyEPErnqkd4vUrafMfnAj77WZ9YCMvJjyZc8kBz Hkr1/XBE9zdm7ZjoZpkuoZ4jxx9oQUW1qY8snJ2lgnqhhzyIZhc7KmFIJz/jwKYadMOo rsGZyCBWr4UtYYUst3/swMtNJiUct7jwRUUmj8LCIvTjwa8jnk9jbQEJ+OpoUU50oHZw DCnGyWmRpMP9ieFhAOI9fy6GpBxdTgvRq4ru6/dGXSHZU2tXMUVw/e2zhkb4TszSTlV4 NYqQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pwRgDg1Z; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i19-20020aa796f3000000b0064d3e86948esi3429805pfq.115.2023.06.20.22.55.08; Tue, 20 Jun 2023 22:55:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pwRgDg1Z; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbjFUFrr (ORCPT + 99 others); Wed, 21 Jun 2023 01:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbjFUFrm (ORCPT ); Wed, 21 Jun 2023 01:47:42 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2051.outbound.protection.outlook.com [40.107.94.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F28B8198B; Tue, 20 Jun 2023 22:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=heg8oRZfKNGziSA+hlJHwIFMdeG1ejOFpv8J8HtenAPmHCcvWExl/CK5OjMXjhYf32f2Mju7QNATdLf11of/ngKG+yA88NUyoQ1GlRhmWmc2AJ3aRTfZHM6v5qAz4Ms1tFLlD56EV7ghgf8+avClTVvKNPeIOsMCvBq0TNfd/3tvn521ely+umA5rKUuLBA06HAFw2Z+1Yk+dMPRdM6Mbv23z86il5qciC8ceC0gmEOUJotZdeztavFz7tu1JB0nygs76GY7UxS0+cvMMn4cqFNjW8wdZj5gHb5VPNIZp2pAI/XjseQ6KKPPFG2ki5HPAb2eocnENRolv5Fejjqc+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=cow0QdZCPEsGDMYAI+jklwqjwTBkNc7U47PLXhHPBDg=; b=neSYzsJC94uw9LzMNji2QIycM4Pi3uh5JBuoLzChMzPn2XDp9mJs1xwXoj6vuK1Dt0H98wIgYW77w2WkH9b79rpUEm4l+l7BicEotYyD8mMHOuJYcTSb/RKSXWIaM8zi1eXLML2HSpbh7OihQAHNvovBORVhdeagmr48A/rh6+J8788/pTwz5LVcotd2TqXuY1YgrlwEHX3zWNyqHbx1M0HZWDjrtb0oATJZCIxZum4D86w/uo35OIMzTC0HR4Iidg9pgaRzlsLPTTcHSuyTcubGIYb/H+Y09MVOUZ6LXHyCwTWc4IVMtsi862cLxmA1JQEwYQ4BuPbYfZnYpOToCg== 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=cow0QdZCPEsGDMYAI+jklwqjwTBkNc7U47PLXhHPBDg=; b=pwRgDg1Z7mKgRU+b8+GJPbbddkH2LRo6lqSKKiS3u+FZGBGkCWCo09oV6YZGKzdYjo/mR7PolIsrR0BjQR7AyIhRB+2IMZ5haAOSnVkowY6bfiwPbVAuTk/O4ms9wXY2sTl1UHIPxAznTdeMaw4ZW+orSUGuoPG8dEC5uw1f3uU= Received: from BY5PR17CA0028.namprd17.prod.outlook.com (2603:10b6:a03:1b8::41) by PH8PR12MB7445.namprd12.prod.outlook.com (2603:10b6:510:217::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Wed, 21 Jun 2023 05:47:36 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:a03:1b8:cafe::e4) by BY5PR17CA0028.outlook.office365.com (2603:10b6:a03:1b8::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Wed, 21 Jun 2023 05:47: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 MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 05:47: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.2507.23; Wed, 21 Jun 2023 00:47:26 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 1/8] drivers/acpi: Add support for Wifi band RF mitigations Date: Wed, 21 Jun 2023 13:45:56 +0800 Message-ID: <20230621054603.1262299-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|PH8PR12MB7445:EE_ X-MS-Office365-Filtering-Correlation-Id: b0262719-631d-4de2-4c55-08db721b03f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ppq2gD0loBfOLW6QGV2qN6DQ2dT9NegEUoe+UcrMBFevZXqIXVaZXlYvFJs7b1gCAlkuxIsPHbGzg88EUegycs67uX1e3yZO/5PJ0E/xusRLmf6cCc6bjSI8eePI9XFhIhV6gnAPbEhUFe4B1koU9XmdUXvRj8lx5sXYa8E9A2xzwfIJeQe0BTtsGIZ8Kql/gS+3x66TCCMGfj5bwLVK8w0W29WErcgSPfyWaK/sslfQ/v3TySqH6yAy+S0cUw7REUpTlCjYmkFpPGLaESac7tT7HveTrC+vvPaYqmMCGNhuNPLnpkMM11V2D/2ic607QgjgR9Xj8d/dac4c+xznqH2OOwLmigHvvsN51xH3WIKY9pRIsgnI4LcpvrGRYQCHVn8yAQZUPIYrialCTPFh9yuGbxRtyQMaPQdvI6FQEteGFwSPTmGnKQc5lSWuyz0T8srxnN7dsM0ZaPdyk8Dy/fNuJ9I9Xa/bj2LHNA2VJL+gniMsvulq/rvfg88KwCZ2wa7XveBqXnMSR5aAxptgIzsHLfRSGzGw0e3dwFYkusaoMibQLcYjBUf+tAqQ0PX0yWWsSkoVxhEmlNp4hMrt5f0jLpP0EB3FFU6nsVYW0CkYBxUtB2oh0DciI/6AeZuQHeK9kzu6wCSY4wohn0uAXupSO9AyDArci1hXAwcoi2hoWmeIbaM8MNj6XbvBwFULkPDxeRQhtl/hWlY7Su1JQajJd8WgRVQWYH0k9eHX2XBOTbvvi99oUcqAUSgt0c2855AE5B7xjPI+l542Yn2akWhAThzN5pmk6mkA4EYetut4NTOE24TsmMrvg4zSeaHrsTQWCi5Rjrb1L+ChxQ98Uw== 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)(82310400005)(36860700001)(36756003)(40460700003)(81166007)(70206006)(356005)(921005)(5660300002)(44832011)(7416002)(86362001)(8936002)(8676002)(41300700001)(4326008)(316002)(40480700001)(70586007)(82740400003)(1076003)(2906002)(47076005)(186003)(26005)(426003)(16526019)(7696005)(2616005)(83380400001)(478600001)(110136005)(54906003)(6666004)(336012)(83996005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:47:35.8013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0262719-631d-4de2-4c55-08db721b03f2 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: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7445 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769290514198858796?= X-GMAIL-MSGID: =?utf-8?q?1769290514198858796?= 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. 3) If removing frequencies, then call `wbrf_remove_exclusion` with start and end ranges of the frequencies. Drivers/subsystems responding to frequencies: 1) During probe, check `wbrf_supported_consumer` to see if WBRF is supported for the device. 2) Call the `wbrf_retrieve_exclusions` to retrieve the current exclusions on receiving an ACPI notification for a new frequency change. Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v1->v2: - move those wlan specific implementations to net/mac80211(Mario) --- drivers/acpi/Kconfig | 7 ++ drivers/acpi/Makefile | 2 + drivers/acpi/acpi_wbrf.c | 215 +++++++++++++++++++++++++++++++++++++++ include/linux/wbrf.h | 55 ++++++++++ 4 files changed, 279 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..0276c1487fa2 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. diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index feb36c0b9446..14863b0c619f 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 diff --git a/drivers/acpi/acpi_wbrf.c b/drivers/acpi/acpi_wbrf.c new file mode 100644 index 000000000000..8c275998ac29 --- /dev/null +++ b/drivers/acpi/acpi_wbrf.c @@ -0,0 +1,215 @@ +// 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 + +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); + +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..e4c99b69f1d2 --- /dev/null +++ b/include/linux/wbrf.h @@ -0,0 +1,55 @@ +/* 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 + +/* Maximum number of wbrf ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +struct exclusion_range { + /* start and end point of the frequency range in Hz */ + uint64_t start; + uint64_t end; +}; + +struct 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); + +/** + * 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 Wed Jun 21 05:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4144749vqr; Tue, 20 Jun 2023 22:55:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ648pVaHZCDwNQS7TBYKvJobl63XJeZtwuKso5S5BNOzkpdglMT5wdJ/bQKDrdvFJ8r/0lR X-Received: by 2002:a05:6a20:9389:b0:121:637e:f0e5 with SMTP id x9-20020a056a20938900b00121637ef0e5mr11561297pzh.5.1687326924251; Tue, 20 Jun 2023 22:55:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687326924; cv=pass; d=google.com; s=arc-20160816; b=g6rFmIfQrRN42WiGAF6/SAPeU/APL8Zxel+QGN1qDcp2ZvzroIXc6+HtbUVwcRI8Wh wdb6dWbCIYwmjFyAW2M8UwCCkk7XyevSPWgtRBNOWeNalyE8FZkMc86cvHiwK1y/4ymI p1LBtelrGDDmWGh3uN1QglgrbU11/96vREDDp9Pn4fpIhOaTL0+F8dSQOq4KIr6wlieN Bte2ZzN6HGLgE/kmgv1Qsy7nCnSALPalOAB19xleKIP4EC1Na9sErXMm+YXlvdeL2IYD QZLtJMPBKapC4ME2AuSmx0TSfT7wFMBWjUGmbjS61Y0pGEdMu1kaYXEq6SuZXgHR371U t7vA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=TO75fdsuAe1xTwPngQYOvdJw2ZaJ2FCpW4CZ9W0J45RiwmBFu0v9L+X2RxYYBWiY2U LaIGMCHmGcgu1tp+jLvbQWzGdMutDQGU4ekPBJ2Q23EF2nseubCMwUKLBaC3lluH1keA vyEyjdyKAB9VMAyPLY1sBA7BhSsYouqy+DeLkkEli/RZ67Ltk9mSuqEZ1AQs1R1p2YGW xdqHrBj7Pug0FuGAwb7GXTV/PuiBKLGK2QdDuGtIgSQkVlZvw9+bUTDmllZrsY9eKq1G 8oPBtKIMrG35fmfMPLKhCwEy4iRO29nHv8pFQ9KizSY50f553xEUuCdy+pm28xoNNqQp +4Ug== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HLOWVUKE; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a63e310000000b0054febeddbd8si3242477pgh.356.2023.06.20.22.55.11; Tue, 20 Jun 2023 22:55:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HLOWVUKE; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbjFUFsH (ORCPT + 99 others); Wed, 21 Jun 2023 01:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbjFUFrw (ORCPT ); Wed, 21 Jun 2023 01:47:52 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9458B1989; Tue, 20 Jun 2023 22:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Refr58cvqrJFU6+4aA6hNN16815N84AxWM1kIfUylIvfgyNXK6bh3yeIBoUrAHUdaoHGMuNWXR3tLRJ7saaLsN76JpIBnoV4fTWeD40ocTQIKMGNvl88xVMZonKvmfuEs1GIkPlscTLQoFdaZrBkdQim4xDSITY3lF/cRnmtnH5cMw1Pg6J5ZQj+YXc90i3OFn8HMso7/YmWiM28ZohPY18BBVx/c/JEZkqJkyqijW4No0V9wmCiTds/vq0WGwBsSLYYE4u0WKS10Ix3NZCf/xD/lqYzQYcs3wzdJiTbLrZopX/h88jUV6Wk+OdL8iZ8eaSS9c1HOy4vff0jew0QAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=aT2nTD/1vqR7FmZYDsAd//KmVNa2NhSPFOHCjcFJKZlMFZlJyJJA9db9tJMrJrYeVpS1Qp7t0+QMH4dPSaRWotVJdpZeFquc9Ubzmu0qMv7CongixFml9wx+envEnE0MEh/QZD7/u7uFQgSLviG8S3q0jdrqr4Q601zzPRI2GKJUanJbZCR/HRnHpa6i3UID/q8NMZ04RMYG6UqGmAOo07+9MRw16AWfN93ugD4Rbsfsvx+JqTh7dtMEmV0v8hhlzOrs4oCLhyxDEIaS/LGsNgWmruQI6/raCREVkBcJQGuBE95JOzsYRTfci8E/+IVYkrHpRiaNE/jWHqj1iU2N6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V2W7MeeYoJAjHpnZBPrbz+KWPIKBQOAP/ttwqdtMG0c=; b=HLOWVUKEdQ/s+VVBNZ6cIuj3QDdqj7dFaydXbVB7eDhaPqZMd7CP2XOH0hCDY2t1NwEabwrwmgnMX/mtSYwmqK/q/1RV2ch1+P5XlPQAKQ6e32nOUPnx+hl3TFEyatEuve7MFi9Rw6GJOXCRWatmgHdmcxHCz1Fcd0sWxzB0Qd0= Received: from BY5PR17CA0035.namprd17.prod.outlook.com (2603:10b6:a03:1b8::48) by SJ2PR12MB7848.namprd12.prod.outlook.com (2603:10b6:a03:4ca::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 05:47:44 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:a03:1b8:cafe::57) by BY5PR17CA0035.outlook.office365.com (2603:10b6:a03:1b8::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Wed, 21 Jun 2023 05:47:44 +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 MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 05:47:44 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:47:35 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 2/8] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing Date: Wed, 21 Jun 2023 13:45:57 +0800 Message-ID: <20230621054603.1262299-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|SJ2PR12MB7848:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c50bf97-b33a-451c-ea4e-08db721b0900 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6D1F66XADojQEHzi1ZXWJdKTHLhBoVRdWgIj8ntD2cEcEO3yzuSMOyU0zik5S5hDbGs+HQXuutBgx2wnYWbHBlY94ZtpoBPO4LmmcZ6DnbvcezgxUuiTOfl2IR/C5E3HF+IHO+BkuW0JWfblDLwF4NTljWWSAbIfbwxP5T0B2cj5mJo3V5x8HO10d+aprsi1YO8yJICqWXGOCvZVrdCIaPrEA95wABBPAgVT9qhqjxyp1qEBAGfTNhXijdNb1eodwrelTWCjpNqzZLoNEDlYDrD9YIi6Mxz1/aht0oxbQxY01bDU5lxZ/Kf0G9kt+jy79Ia0lXM9HHPyj80lrVyxOx5Aq+BwZ4ARUQ2ehWQlqTV8F20q4Reh1+m8Slx4z1P3Xz2KhQ/AsSGAdFM33zPEdh6gt3M6V5aoy1CIPONbLLVyvaltgaCBF98+dWZaeaEd2+jAM9enIBliF29eu4mWf5rSQno4WQhZ3ZfuKbm95/T2IwQRx1fKLq/MWvZ4HrjhV0P5B/kr6vp99pxYgg+ZT/5xu/60aNC9wphhWIfIFhdmo2GfK6EI067oD1J0h1kqXFyK1RKJjqqRPNRxa90lu8trDIB66K2RDFlJMXy/uEvzWwWAduA3IhJwq8/HWVECkIii5jfldGZUZzyWnNrHn65QKVrIw+Hd6xn4DwN5k7bkZ7RC2ozpmQGD7nwTTw7NJj5HsO6UaEeWiO8wwe9KWprjzItVUVZLyg70caB0tz6X12EctpbpmnaJLHqB2SGkJS+z/4me4VsZ5B659xGGfFAc2slGQMk0F4msZlsE8nYfKLG9qmZm75pddxEQl0hIEBXllUx4vVWkS4ecxzII2g== 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)(40470700004)(36840700001)(110136005)(54906003)(6666004)(478600001)(82310400005)(70206006)(70586007)(16526019)(26005)(186003)(1076003)(2616005)(336012)(40460700003)(7696005)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002)(44832011)(7416002)(2906002)(40480700001)(81166007)(356005)(921005)(82740400003)(36756003)(86362001)(426003)(36860700001)(47076005)(83380400001)(2101003)(36900700001)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:47:44.2858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c50bf97-b33a-451c-ea4e-08db721b0900 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: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7848 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769290516939929612?= X-GMAIL-MSGID: =?utf-8?q?1769290516939929612?= The newly added WBRF feature needs this interface for channel width calculation. Signed-off-by: Evan Quan --- include/net/cfg80211.h | 8 ++++++++ net/wireless/chan.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9e04f69712b1..c6dc337eafce 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -920,6 +920,14 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** + * nl80211_chan_width_to_mhz - get the channel width in Mhz + * @chan_width: the channel width from &enum nl80211_chan_width + * Return: channel width in Mhz if the chan_width from &enum nl80211_chan_width + * is valid. -1 otherwise. + */ +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width); + /** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 0b7e81db383d..227db04eac42 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef) return true; } -static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) { int mhz; @@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) } return mhz; } +EXPORT_SYMBOL(nl80211_chan_width_to_mhz); static int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c) { From patchwork Wed Jun 21 05:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4149336vqr; Tue, 20 Jun 2023 23:06:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qtBdcm49jHyIx3eSR9L7bmAiMuzVWDOG91viYvSFG0IhUYkRHVPbPPYVfxKIR4p7Hevt8 X-Received: by 2002:a05:6214:501b:b0:62f:f071:623a with SMTP id jo27-20020a056214501b00b0062ff071623amr16063780qvb.55.1687327591338; Tue, 20 Jun 2023 23:06:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687327591; cv=pass; d=google.com; s=arc-20160816; b=bmt/cL++8CjM5TnB2m5AblLMPqIyYtVJzIhgozGQbKzCMH+KJJS0Rt/vaiCuQv5F4W KSDAkzj+42mktP9OTYg9+o/q8tcLs3X3v5iRmDnxEAYJrpbCa8IKdRLR5bTeGEL8U8TD GYvjPiem/pINkBjTWvAzvDwj6HYAYu9l40SNmbL4gkCOkNUiR7ulmj9Fb8uGJximEq89 r+Fkjy7jqhy+c291O0nZbw6DklBYsze9nnDbys4vWcchorBUmmi+TMWYNBIXtHNTOMtr cCos1YZvXc0bCs/xzdx4Y5M3wp+cLLsFgH8SfJDckxzzsJ37ZUppROj64FKu2t5XI/qQ ArWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CjjAbG827nEyTsn7Jg9GyQhKlreYyYVCmvy4usNxypk=; b=H0/XwP+s39BSuLrXM/mgLZB/Sa05LwnyFKhTLk0ixT33sTYtlxiGiH6bXxxtZnx4ah 7AoK9ZrAVmSR8pEk0kqQm4Rk3WzDp4fbnsjDqRpsE3oJZVRfKJzkKngDH63ofPar+fFD 0X5u6Qaafi8O2f4Gmw2wJWRRpQ4Etv98sxabUswYFM3+Wp+sGOqe+IqVcC+faLTIDHaK zWd2BY8RmYBqmCY5CkpjfCDgV8vJ09pATsfPi+QZ4cWjNxhAd22sRT45JaoxIsua1fRq yOPAiK9ZqVlnEZq3uCxxMAiaeijPLVCLpLK/ClGSBGxJDPWZzewMWxgLVNATHTspWa4p nOSA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=T23uxqHc; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k129-20020a633d87000000b00551bb2b99besi3492405pga.85.2023.06.20.23.06.16; Tue, 20 Jun 2023 23:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=T23uxqHc; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbjFUFtN (ORCPT + 99 others); Wed, 21 Jun 2023 01:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbjFUFsw (ORCPT ); Wed, 21 Jun 2023 01:48:52 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637651737; Tue, 20 Jun 2023 22:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijm83pBzdTlZrFlDvtYC/FYVMXNx1L0g1s3icMveV0qmL965kK5CPcR+60g2Qsb5LbjSh/gXX3MwqHpQpeSlHk0FgzIhrARXs/l7kmeZpv4LzGJjDrII5r30GFPOAmHFnq92XIKs0JvwoHMiFqcg0/ZfZEZy+orHsl3lM2ZwV53M3weDS09Pnuiur50EgS922RGlzkwrrEh4KSFfVT9t29co8JCKt/T0VUhaYRTLz9oL21EL1rfzOrdI9ajgIa+/2+wQ1JZQCitvlLmFxaN2irZg4cbxzDPaZGnSD433TxSeGNXzLoQWvBD2UkQBQ/ouW3FNHZPZKrJGY7DqjC4MEg== 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=CjjAbG827nEyTsn7Jg9GyQhKlreYyYVCmvy4usNxypk=; b=GQCUwhktK/VM2Ktd7SpOH56azVpktCFZFFKvPDrp90pxbutSFJDH62OaMFFTqXDH/+TM+XYgMclzLAqgrUe0B8CKtntxZFbtFKDFbZ6F6L10KhXi0k474YDkQsmtiek7PuRf/BmTv0eMbKWBINQTH6bEOUMjAenyYtpNhYkZw225O+xpfWPSdf9ew9eyLobqsFHBTDx8ynZcWQMDW/kdIO2Mlb+qji2fc/TYYwNJu/2pCxOy1uoL6PA6x+mjiKqDbAedZKY2lbWlpuVl+wYWf0Y4OrOowKxQNUnwM1ubxQXS2r1fQulipV5Hva9XS/Ga5Znv4F3O1OcJoZITIX6EnQ== 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=CjjAbG827nEyTsn7Jg9GyQhKlreYyYVCmvy4usNxypk=; b=T23uxqHcWuGozI+E6tmRTjjxheTmbzn93GkBIUXM7+ethyGcoKAyEsf+GQ8dAFfrVuXxOCLrMpD9TFXLl5Vyq8ysJQ5oJ4JTeFACG//Pxh3fdmxd2YW8N3bnYw1MBoHroCgyAGGhNsSw4B2ZQlAKF1nQIZh2nTKWLxwuuUfsCXQ= Received: from MW4PR04CA0210.namprd04.prod.outlook.com (2603:10b6:303:86::35) by DS0PR12MB8527.namprd12.prod.outlook.com (2603:10b6:8:161::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 05:48:31 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:303:86:cafe::82) by MW4PR04CA0210.outlook.office365.com (2603:10b6:303:86::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Wed, 21 Jun 2023 05:48:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 05:48:31 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:47:43 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 3/8] wifi: mac80211: Add support for ACPI WBRF Date: Wed, 21 Jun 2023 13:45:58 +0800 Message-ID: <20230621054603.1262299-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|DS0PR12MB8527:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b2be76c-66d7-4b43-0c7c-08db721b2521 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cAnsYneNy/GP23mET1hy15hNHnoqbWOtunQp8JZp62URbXI1ppfnagEqfQzvwOQ1XYIMk/1JOMmtfNicCeqYIwVBHa8Jl+rSH3Bq5SkOJrYFgEw+OvyOH0uC2tP+BNLnGYo1WGphrwrG/qVDSsYpXfNK+y7ydqO9VMBVOxbie1+wSWEk+/itEWaI7/dENipkyKbIOJh/E5rGNhb2PfWhuxgAOChHQUuCl+jLKzGq+W9gwSpDyUHX18wviLRtfNahFVzsGckKQ223ItR15vwwd2vq8YRYxTdxEX8lzG4eXW1OBMlbny3R4ftpgmhT3k+8S996gXPGJtdefFkk15lfdLuJPY7AHkGA6ih26ZV4v8WcCqnXu5/0ybCPIe+2rH/tcEEfUvAyg/+l0X+qTPo775YRh0LSSyYbu+KoopusGqvp39PaoAQ0QoCMkN8mBKmZZ7+7TPk6hVEK6+KB8nXxSSfyEy/UQFdCB5Ir59gwyn2kR8YVl/Ilh+VZ/H9yWTntxkCGpUhj9fvIz2YmpkUjq15q5IHy0c2oQUvaD9JA5TZwr6FMqEb3SwktSONmwxzp7yJZSM0cCYG4ypOUIeYvsJRWo70Fq7NFB6vVfYtCMXbyp3xQ6tPpQxhj100qZEEBrUa40L7Lgycwo7M1jIKw7NCrQoaLTGn0/gE4ePREcPxNFUpzPAj6T8KXiR9dq/AzEsdIjWFwvZ3N0tMwW/zUBLcASeuifphcr7BJZbwkbE+IEfR4DsYt69TyyM7q46cbjVZqno6bFtHJzNAcz5SEbIRDn5gNZIuwPHKzFo06R2I6LqXv+vIrJQElYZT+V/Q/32pW0jzPQacQBY7M95xsWA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(82740400003)(36756003)(921005)(81166007)(356005)(82310400005)(86362001)(40460700003)(41300700001)(8676002)(40480700001)(7416002)(5660300002)(44832011)(26005)(1076003)(8936002)(478600001)(2616005)(186003)(16526019)(83380400001)(426003)(336012)(2906002)(316002)(54906003)(70586007)(6666004)(7696005)(4326008)(70206006)(110136005)(47076005)(36860700001)(36900700001)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:48:31.4726 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b2be76c-66d7-4b43-0c7c-08db721b2521 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: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8527 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769291215999922665?= X-GMAIL-MSGID: =?utf-8?q?1769291215999922665?= To support AMD's WBRF interference mitigation mechanism, Wifi adapters utilized in the system must register the frequencies in use(or unregister those frequencies no longer used) via the dedicated APCI calls. So that, other drivers responding to the frequencies can take proper actions to mitigate possible interference. To make WBRF feature functional, the kernel needs to be configured with CONFIG_ACPI_WBRF and the platform is equipped with WBRF support(from BIOS and drivers). Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan --- v1->v2: - place the new added member(`wbrf_supported`) in ieee80211_local(Johannes) - handle chandefs change scenario properly(Johannes) - some minor fixes around code sharing and possible invalid input checks(Johannes) v2->v3: - drop unnecessary input checks and intermediate APIs(Mario) - Separate some mac80211 common code(Mario, Johannes) --- include/linux/ieee80211.h | 1 + net/mac80211/Makefile | 2 + net/mac80211/chan.c | 11 ++++ net/mac80211/ieee80211_i.h | 19 +++++++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 111 +++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index c4cf296e7eaf..0703921547f5 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -4319,6 +4319,7 @@ static inline int ieee80211_get_tdls_action(struct sk_buff *skb, u32 hdr_size) /* convert frequencies */ #define MHZ_TO_KHZ(freq) ((freq) * 1000) #define KHZ_TO_MHZ(freq) ((freq) / 1000) +#define KHZ_TO_HZ(freq) ((freq) * 1000) #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000 #define KHZ_F "%d.%03d" diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index b8de44da1fb8..709eb678f42a 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -65,4 +65,6 @@ rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) +mac80211-$(CONFIG_ACPI_WBRF) += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 77c90ed8f5d7..0c5289a9aa6c 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -506,11 +506,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local, WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef)); + ieee80211_remove_wbrf(local, &ctx->conf.def); + ctx->conf.def = *chandef; /* check if min chanctx also changed */ changed = IEEE80211_CHANCTX_CHANGE_WIDTH | _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); + + ieee80211_add_wbrf(local, &ctx->conf.def); + drv_change_chanctx(local, ctx, changed); if (!local->use_chanctx) { @@ -668,6 +673,10 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->chanctx_mtx); + err = ieee80211_add_wbrf(local, &ctx->conf.def); + if (err) + return err; + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -748,6 +757,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, } ieee80211_recalc_idle(local); + + ieee80211_remove_wbrf(local, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index b0372e76f373..f832de16073b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1591,6 +1591,10 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + +#ifdef CONFIG_ACPI_WBRF + bool wbrf_supported; +#endif }; static inline struct ieee80211_sub_if_data * @@ -2615,4 +2619,19 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); + +#ifdef CONFIG_ACPI_WBRF +void ieee80211_check_wbrf_support(struct ieee80211_local *local); +int ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +#else +static inline void ieee80211_check_wbrf_support(struct ieee80211_local *local) { } +static inline int ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { return 0; } +static inline void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { } +#endif /* CONFIG_ACPI_WBRF */ + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 55cdfaef0f5d..0a55626b1546 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1395,6 +1395,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) debugfs_hw_add(local); rate_control_add_debugfs(local); + ieee80211_check_wbrf_support(local); + rtnl_lock(); wiphy_lock(hw->wiphy); diff --git a/net/mac80211/wbrf.c b/net/mac80211/wbrf.c new file mode 100644 index 000000000000..a96f74ef6584 --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include +#include "ieee80211_i.h" + +void ieee80211_check_wbrf_support(struct ieee80211_local *local) +{ + struct device *dev = local->hw.wiphy->dev.parent; + struct acpi_device *acpi_dev; + + if (!dev) + return; + + acpi_dev = ACPI_COMPANION(dev); + if (!acpi_dev) { + dev_dbg(dev, "ACPI companion not found\n"); + return; + } + + local->wbrf_supported = wbrf_supported_producer(acpi_dev); + dev_dbg(dev, "WBRF is %s supported\n", + local->wbrf_supported ? "" : "not"); +} + +static void get_chan_freq_boundary(u32 center_freq, + u32 bandwidth, + u64 *start, + u64 *end) +{ + bandwidth = MHZ_TO_KHZ(bandwidth); + center_freq = MHZ_TO_KHZ(center_freq); + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in HZ is expected */ + *start = KHZ_TO_HZ(*start); + *end = KHZ_TO_HZ(*end); +} + +static 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 = nl80211_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 ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct device *dev = local->hw.wiphy->dev.parent; + struct wbrf_ranges_in ranges_in = {0}; + int ret; + + if (!local->wbrf_supported) + return 0; + + ret = wbrf_get_ranges_from_chandef(chandef, &ranges_in); + if (ret) + return ret; + + return wbrf_add_exclusion(ACPI_COMPANION(dev), &ranges_in); +} + +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct device *dev = local->hw.wiphy->dev.parent; + struct wbrf_ranges_in ranges_in = {0}; + int ret; + + if (!local->wbrf_supported) + return; + + ret = wbrf_get_ranges_from_chandef(chandef, &ranges_in); + if (ret) + return; + + wbrf_remove_exclusion(ACPI_COMPANION(dev), &ranges_in); +} From patchwork Wed Jun 21 05:45:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4153266vqr; Tue, 20 Jun 2023 23:16:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Qs9ao8bk4kQJf1VWdTPhEItYMCJU2pWjBBKimJwAjocCQHorZy6sPw2nhJB43vHWqW5ul X-Received: by 2002:a05:6a20:1609:b0:10d:5430:c8d6 with SMTP id l9-20020a056a20160900b0010d5430c8d6mr16015670pzj.0.1687328216800; Tue, 20 Jun 2023 23:16:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687328216; cv=pass; d=google.com; s=arc-20160816; b=jZB/drmPBGARI/tNoiaqZd9+XV39C89FDNbGvfDegZjo8QzUhNMurezUNxWRItcQns Jel+KkbAehejbiXmGBdQf7iAg0YMOilRuhS6Esaxv44+iTUSxYidwxCbkYwG7LqxGo0Z Nj/ex/nLbaRSKH8PXae+XU+DhHNJwWZ3epg0DOhbyxdzXiTtIPkWOxI4qr1iU1tKJXW4 22BKMnYh6DOD7fO2/KipVw6j7pMBf0suxiZKgDWiNQ6t8qxMFPqSAg5sxd2swOLbKMT7 cAtKQX7n3BsWUlr87wKriR1msvnhDPj2YJObKpMVfkzewYvK039D7QB1762NP7M9hAG7 +0Ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=YCYJ74/vC/SLKoVuATJai109OerA476OFFb1qqaTSk/qyXqLoyHFkWfRsHIHhE3gBz hAPbgwDUbdKb7+QE8GAESuf46X7RzIezftTuOjWnvq+op2uHX/CC+jltmCbmcXQ9ow+J Wy6z9KVB4cdHSgz8wsOvcnkNmxRpbcPfqHClYV+GrrolnLsN+WDbxEI0H5Wyhs8umSSa jY3lDr8xwiVTCkz1K0vTPtWUErvfCprN0uco2FNa0y3CkFXNe5SdDnLt1gRMX6W3n4hm MIMQWUks/qe65FORdy4npUZfUJl6YRMuHGTl9TcX+WJSyuUzPwCdfq/pDJvv9xIjEq7g 7dkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z4FoYngg; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u132-20020a63798a000000b0053ef0ac79c8si3451659pgc.263.2023.06.20.23.16.43; Tue, 20 Jun 2023 23:16:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z4FoYngg; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjFUFtS (ORCPT + 99 others); Wed, 21 Jun 2023 01:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjFUFsy (ORCPT ); Wed, 21 Jun 2023 01:48:54 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5ADA1739; Tue, 20 Jun 2023 22:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GScW/SWuCrndy+JspCS1AwucyzLXnbyp7J9WqYKh1erDOqrb83Spmo7Ot1JgxxwUd0RpUlDFZ4txJ3vbqisHu8EVOmXPxkCGOGpQiRETKRTXNy/KxuCJJOI28HiXfqtjDcmjwRvCIO0W4S9yXo7DM8W7U4y3KEbmRCmrf1mJ4QNC548c+AXL+dp1xqOY7dx5H33pld7iWUFKjIm2ZDXo2E76n2ehuhdKc/nMtUPNi6CN7seCyrkhhhkLZMRbMyfoFI7aiu4pC+nByZMa7E7JanOw6Xnmh/M0yvPxjrjjLZTP5HibYWZyREvRY3YsTelDGrIUlPpsuRhHob5ebvkJGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=JergrLKi79FxBreLlc1O/t2/GBGt2WnhfPk5pxNjJb6iIsPkN+RndtocCoYa13SKXuXwbTC20ZdFwVPnGDnqu3YBvLk7v7UKClFIrXm305ZdQsWJ+o16uPX0l1RxfhiRDskkKWWOg4KW6wzF+lqOOqCcLsfnpRfEwzXZ0bhcZ0lV9ni8Gy65Eg9+pUowY034jDYAmTZ3evEYQmmMwYxuCf/5ycbj9NXRUkr8nlHfcpLqquqlSZ5J9TB1Fqbt+TNAKQQHzSu/O7C5okS8GvXojZz9Ra/cUu2yzBQek2ULxGhXCRj6sRCd7FlQGaD60wlT+qRkK7h66T6ZGjPljnXZNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jiyRm8230ePWHdpc1Lroiu7N3Eh7mvvWEAN2GjgUtx0=; b=Z4FoYnggvok0zGJQfvqXDhmt5uevbY1ps2Bl60sfUso3d65HX1Nh7rw8wivNf8e+6BBPBJ21AIwT4ZUmQNDgZUdg7F8uJqFNua8oi8W5RWc/235/ENOclML7zRlVPwYyCpYkEGYvJLswnJdqXJDy05VXAKjavvuXWyMYT2VFnhY= Received: from DM6PR12CA0015.namprd12.prod.outlook.com (2603:10b6:5:1c0::28) by MN0PR12MB6270.namprd12.prod.outlook.com (2603:10b6:208:3c2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 05:48:33 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:5:1c0:cafe::63) by DM6PR12CA0015.outlook.office365.com (2603:10b6:5:1c0::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Wed, 21 Jun 2023 05:48:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 05:48:32 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:48:25 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 4/8] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Wed, 21 Jun 2023 13:45:59 +0800 Message-ID: <20230621054603.1262299-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E5:EE_|MN0PR12MB6270:EE_ X-MS-Office365-Filtering-Correlation-Id: 7efebd76-eca6-48c7-0b54-08db721b25e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8WJWMMLKqwrPV3Ty5GzTu1YxDxTMeoLUlAGnhOPDBeVbAG5ylPH3ZLMlF8iGGjU4+XCuc6NNyEXKBnRWAw+9mG2PkhvQG+8N7FoyPLIXG1EUrCllX6gkFBMISTOyelBlUqUdk9dV+AcARiTveAVFlbMqq9scF5jULvKV/0xaC1a1fNIGgKMTYZWMU8fEoXtrJOwRZFZGz+y9uKStMHzLm542o6aNxZ3wY8U8fk9GVEATIxAsOcjsapMqE1BqQuAtwvnCpjKl+IEmOLC5GAT/5iZfFSKjRlqFdTL/Cyy/bKX9HPEefRH4Y/MVlK9kqBcVJKUYVXiKvciqpRE9ZBDkaceKc7o/JGntiGsq9UVnFgY3dn6vyzpmYe7Fbo+p8rFX2u/PTOILL4XV/b/qJq3RHifz7WjQCs88hJNmNpHpIOgvcRWqCulzUnLg3GEBmzJO3LDCWhJuOXu31x2z2222jAB4ZDGOx9/i3Sj2VwEO5HTNqiR1HqHkdD0rAiAgTxDNzxLa/spo1Wc7XDXpS7auvrPyQCvvUSyvB6hPVxm4MfautbV2B9lUn3QCOPYmDL3V2khaGpUpmyTX4fcdrm1B6NWWSMGseAEk3D4fC2YAeqppBPF1W2qs2e1JGth7LMlzut/uFMI0Su549H/C+sgGyCw5nmL3ewtC1Wg4xUJuPcyX2Grno0MXpVvoXtN/DZVj+8EDiFx9L47adWEv+q8AAYb22sjsbJnaXCbckG++BWX7W6zZm4Y6lWKsyPhqubZHSBwWP6ivxprczydlrPGSiYYc73JSxerVuzjXtb190PTNwa7DIWyVsb1CNdCfqihQtz+u44XLknUxF+Q6BHSpEA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(41300700001)(5660300002)(8676002)(8936002)(40480700001)(6666004)(44832011)(316002)(15650500001)(2906002)(7416002)(4326008)(70206006)(70586007)(40460700003)(336012)(426003)(110136005)(54906003)(7696005)(478600001)(36756003)(82740400003)(86362001)(82310400005)(186003)(2616005)(356005)(921005)(81166007)(16526019)(83380400001)(47076005)(1076003)(26005)(36860700001)(83996005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:48:32.7701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7efebd76-eca6-48c7-0b54-08db721b25e7 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6270 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769291872401739602?= X-GMAIL-MSGID: =?utf-8?q?1769291872401739602?= Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 14 +++++++++++++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 14 +++++++++++++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 3 ++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h index b686fb68a6e7..d64188fb5839 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h @@ -388,6 +388,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1592,7 +1603,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h index 4c46a0392451..77483e8485e7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h @@ -392,6 +392,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1624,7 +1635,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h index 10cff75b44d5..c98cc32d11bd 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h @@ -138,7 +138,8 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 //Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1 diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h index 6aaefca9b595..a6bf9cdd130e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h @@ -134,6 +134,7 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 #endif From patchwork Wed Jun 21 05:46:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4146595vqr; Tue, 20 Jun 2023 23:00:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PVlQMyMBUs4fr15+RdXFrQza19kFJSnXufrg+7GWfBjYA+VimBmIK0znz/l36dBLFVmsR X-Received: by 2002:ad4:5be4:0:b0:5ef:6eb6:e26e with SMTP id k4-20020ad45be4000000b005ef6eb6e26emr17758941qvc.6.1687327242802; Tue, 20 Jun 2023 23:00:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687327242; cv=pass; d=google.com; s=arc-20160816; b=Drx5B2oA3ZSyJOnHmV+WKeUNRkxZCHDN54cpfllDNAgNZnivsCDimxN5fdqqmJS4iO 6UMJMGZ1hDRZyX+IQbfrnpAAwYNJ3+TUCTXNvLKYyuIDtegK8XfpV6RErtue2be1ajfd FMb9KMRp7O7MS3uxme8U6/5nyzotRMTry55v5PEqzekll5UazFUot6dcDPZzCsfo6ubT FccPxDzFS6jAaiOvUi0+YdVZ7TgnYCGw3ZR2BlbOkmRywGTgLFaK2AwIXe+XKSIl1BOv w7rLOnYnu+C9TJMU/hYFDAqFI8XughzNE8HaAFFFkpLPE7JNhqnfNe2N2ppBUlIr8aj2 yymg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nm1/EACQ0Cz0UaQDUiGBDbeq90RNCji/7UFQqCNggbw=; b=Tgf51bMfgEs6ImeYKbxb99i3Bt+Zc+1uOSLvivMRXClddlCUEvhHwHq2llbmnhFAmv K+9Ibrigv0ZreB/VKoyl0blqkPvkd0nzE6G9Ojqt8Ev7bCkicmapuDLtU78gK6aF+3To OxqwlOwJRRtlHv6dHw0NYGVB5jjAABxibpvGONwW7468cIpgfkxi8Fa4MADOCwtr0gO7 yFPxBZ+xe3NYncbBPPQd92AkYMSHOfhxu+7+8eX1UOOlfAlSpZu4yGbL1xiJ+cSYQjBp Eq4lmjdtEWXiBcIxr8IgEEox6YQGBHhJOp6gwNXw06uVZevMKNk4Q9VEFOLHtvNqOKTU kmgw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=DPijEggO; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a632c12000000b0054fe20c31e6si3390169pgs.649.2023.06.20.23.00.28; Tue, 20 Jun 2023 23:00:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=DPijEggO; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbjFUFtf (ORCPT + 99 others); Wed, 21 Jun 2023 01:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbjFUFs4 (ORCPT ); Wed, 21 Jun 2023 01:48:56 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE06D199C; Tue, 20 Jun 2023 22:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y49PodKg7nLQvN8dcqf2cIxaew9fa+xCc7r8lnRahWOWyPj6SPgcnCvio2GyYxZp2fJV/4gzyZHZXZkqwT25ENNLj3K+D5bKbj2uxMuQBWQMa+X0qrXP84B4Woig1Afs5Gbf37LksSXA4pa+ILFfSv2Iysde5VXuJvUwDMnQatx0Fw4HgNtUlAhiYFARcvjpx9xIlNwXOXGnkiZrFRhS02rRTfHY2Ov5VIGBQx88gyk5hmZojDKmcTk3QeDc06jfq3GnxP82AGjxCUknz2lLNgNyLc6mrpQCQKeGdY4ZODNj7OJLdIEh+c6YsLuyFIXuFBSF4i/gHW0jpsj9x2l9hQ== 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=nm1/EACQ0Cz0UaQDUiGBDbeq90RNCji/7UFQqCNggbw=; b=RCWSLqJpUyhftXInDTgR4uyq/l5pPYR3qCnaosCMF0oKL2x+006KoaMKz0GjsoWk1LQzI7+zNQ72Zs6wn7/ZExZi/0aKdd6UwCtnRZ7olmv1R4yypQKDgGsu/o/2rDyGxNuZBbeESPG9okiSfilMYtbHBbOG3GL6MH2WsKOpn38ujJ17zTp+I/SaYTp0vgE+FpB2sFXo/FgnyTvln+SadaCikxI4eOTw9JHce3gDqBtZngaBXd1cP0HJjPREh7BdjEsbeh5yGAaKf9wKom0tpYr/Ypwy0kY+sWsyhycJtFQCqRhe/9xu7oBHcmKtyM4nI9F58ncO1F5iIEvvdn5xkQ== 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=nm1/EACQ0Cz0UaQDUiGBDbeq90RNCji/7UFQqCNggbw=; b=DPijEggO4UA12oBz+TkzQSjgkVxbYSBWFKYGiiHcWR9Cm94mP413YkzpMoFRu2T7+Qxuf7aiGS9lpFI78vqO0iZAWX/JQ2/zrChJrC8Uk3X5prnVJs8bxinc0D/OFZuWiIYtMav5mPM9tdT9MP3EVgy9npvCAR09EpcOp7AV2Ms= Received: from SJ0PR13CA0118.namprd13.prod.outlook.com (2603:10b6:a03:2c5::33) by MN0PR12MB6077.namprd12.prod.outlook.com (2603:10b6:208:3cb::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 05:48:42 +0000 Received: from MWH0EPF000989E6.namprd02.prod.outlook.com (2603:10b6:a03:2c5:cafe::95) by SJ0PR13CA0118.outlook.office365.com (2603:10b6:a03:2c5::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Wed, 21 Jun 2023 05:48:41 +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 MWH0EPF000989E6.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.19 via Frontend Transport; Wed, 21 Jun 2023 05:48:41 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:48:32 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 5/8] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Wed, 21 Jun 2023 13:46:00 +0800 Message-ID: <20230621054603.1262299-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E6:EE_|MN0PR12MB6077:EE_ X-MS-Office365-Filtering-Correlation-Id: 11440857-9ad1-4db4-ea8d-08db721b2b31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v+CoBxKauZKkbcwx4sPhq/XIc/KCL6mIayJpxym6PPlD/9rHak6cN4AijG0Gn4uFiA+g74kAZhw2gEz1fIqzmhDECl/YkXZq6Nz7JiiocAOCnJL2wrr8GFcM/XrHso8G1EgWQ5WgcDdCXFmrm463fBc6g/Fcnq1lkqGBvIBvpHlu3N8ReXBZnL4h6jfpYPgKZsBVSIshgjxIBpNy56VGWnemzecu4Kfn4AbcbfJm73b4mGWdNiQoOH/TxuZMW5bdmaIcWWyzVnlR+k33YQhVucz6FColCirkxFv4g4RItTK1ExQbZccDVCSq5e6vO3Vz84yAyrcmD71NbAkpCsxbYxdTgiGCVRC/7DI4q/84xWrcMn4FfR0UvFeIGL6rjAj9KIaj0B21zhbQyYkYg6wuJsKeGDjsxvFATd2jNjLI2w+XiPr9ZDNn0bPNn7YbEml8QAhocWBtCjMnKmerromrtQkvmFouXHJ0C0349Wj1dhL+eRjKTvydVxDCNVJsXNLhtyE8D/tkANGnoY6Fo8rgYSp9aABtPt3svd5B9ycZk9gHgG4AxD/0HdwDYex0JOUUsGBHYN4+sb/RjSwkGkp+Y9IY7CW8Y1giM0/a0EoliQ1mzJl8bMJicr08f+maVT853VNc1qk2pHIjAnkPLz6A73t2haF/rmvau5y5u7DqtcWFHAYV86+rOBDBKSfjVcWVVjoqzmpJxnZJ2BC89xgeFgpfmqBZoHkicZX/ZoWS+wQ4Dwu1riEXmY2XmDkjCpD4cb2qAKiHLvKGnVpsyc5QBK9VOI14cZiCScsuYJXP/SbW9c8N0GRDPa/MzbFaoXqpoTYI78PEI8RkQrbvTJaxsCPEj4B7Z6mWSWvyplZ/K7zgZBzN562V1+DN7FppSsjY 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)(396003)(39860400002)(376002)(346002)(451199021)(46966006)(40470700004)(36840700001)(6666004)(7696005)(82310400005)(83380400001)(356005)(921005)(81166007)(40480700001)(26005)(186003)(1076003)(16526019)(426003)(2616005)(47076005)(336012)(36860700001)(40460700003)(36756003)(30864003)(70586007)(70206006)(316002)(4326008)(2906002)(8936002)(8676002)(7416002)(44832011)(86362001)(5660300002)(41300700001)(54906003)(110136005)(82740400003)(478600001)(36900700001)(2101003)(83996005)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:48:41.6494 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11440857-9ad1-4db4-ea8d-08db721b2b31 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: MWH0EPF000989E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6077 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769290850738921179?= X-GMAIL-MSGID: =?utf-8?q?1769290850738921179?= 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 Reviewed-by: Mario Limonciello --- v1->v2: - update the prompt for feature support(Lijo) --- 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..a8efdce4607c 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, "RF interference mitigation is supported\n"); +} + +/** + * smu_wbrf_init - init driver wbrf support + * + * @smu: smu_context pointer + * + * Verifies the AMD ACPI interfaces and registers with the wbrf + * notifier chain if wbrf feature is supported. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_init(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + int ret; + + if (!smu->wbrf_supported) + return 0; + + 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 Wed Jun 21 05:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4144090vqr; Tue, 20 Jun 2023 22:53:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nhCt04oD4xzI892pY8YU5skeF0BFNcFrlquQx6U8vuWKi7j9d0VG9DaE+qBaVM1PXopv5 X-Received: by 2002:a05:622a:40b:b0:3f6:4892:c773 with SMTP id n11-20020a05622a040b00b003f64892c773mr20136862qtx.30.1687326791821; Tue, 20 Jun 2023 22:53:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687326791; cv=pass; d=google.com; s=arc-20160816; b=llPFQzUI2navIJ6XJIE8W50uiJaB+1bVoIvkigW8A7MWgqmBjP2DZGDIEmvhE662dQ 6URjDYmhK9V5qvxs6oXaKLnKiv4eokU4ZTV7qsRtdNJ+VnZR751dRAxfsAs3m+/91nmU TexaBek5dqKwb88yEYwKWgKPK0Cnr7hGMVr/sdwehe1gzqyR3l/GYsMKfsGZYZeR0F1f aoADuf3jvZEioEgearAGr8cKxkQFCdCpDKsw7PDuOJH7RnXtHfFnoGr8ZdfbCrm0ViG8 Rro2ul01PZtxzXrzNJBXKJ81fmRR+HCvCJpTYGbSU3uwhejgjIo2gUynv2Ed8bbSBk9S RGhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SsI6VaYpP62y6kkaUAPmJ7wVYQgNVT499l60/J6MfyA=; b=QsS9zmaUdNIT7+FmdUqo+VlWnH+hcnFP4OLRUoy0+iFFrgSJvl2lwRhv2bJrYE6TgD 7op5V+xxqmXXZ/LQkkSj8lHKVxJ70Bz8jJXL+y+2+cTaMs6dPsuDEhWz7U1oRc9uZRQ5 NE6oDJxrhQpLyHHG5BCqru6wdmzcHB654n8oOnlLtK7w7qc7bDn/sNoJDTsQRqJL5GDT vv4+lMl4byMcIkbpxzYTqSBhFzR6TQ1YrA2nDobYSjXYmgsINgrT5j6SWHoO++tvSXMI /nYuvA96RLvz7NUTKsSjd/Tmd1O7yfz33xQXsQp2CFmlVRcj54X/cYGaM/whT0siy9zI FjIg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tjAzY8hd; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a17090a64c800b0024e43558fbdsi10914085pjm.129.2023.06.20.22.52.56; Tue, 20 Jun 2023 22:53:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tjAzY8hd; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbjFUFuh (ORCPT + 99 others); Wed, 21 Jun 2023 01:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbjFUFuC (ORCPT ); Wed, 21 Jun 2023 01:50:02 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2076.outbound.protection.outlook.com [40.107.100.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 323AB1FCE; Tue, 20 Jun 2023 22:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bvte7awAs9FxKmbYE+g+Pb+fygdbW03OVsQLvdJNAOARyzYgMGjcO00BNIRMpkn0IDgxJztmbKLzpw2acqS4rhAJ1vcSJeL1/rkOyoQkwcWkxv6rVFshb3PjV1x6ygtIT/cyS8kKtvJRK3497EFReKdYuFRD/OxYRcUTs5tEFqxNEM3yDWz8N8FN4AsoMgXsjvyol+EWwcyvGoghUbBw3930SbRtZVAz/0cYR5RJSxKQbnEiStK3cG+qH6i1nRw+WoNz7KihKe7IjsnIZ+saE74TvUDtZ8GpqOkX2ksQqUR0vCnuvcukj1AQdWn60RAQCwxFDbC3fq30jFHpZFq/WA== 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=SsI6VaYpP62y6kkaUAPmJ7wVYQgNVT499l60/J6MfyA=; b=UcZOn6pNBwQyci+tUhYwzMXCSVlpGi6BXiQoVGwVdJKOz9k/GQmD/qxi1mTxYDGJJfelPvUQ3Xxk/y8Rn53xFAdfGfnqiuqySAUGIBqJAoOtyzZBZA+I5NuYg92CAKsC6YyvReKbiN6RYN4YtoAqWmC2hqNvN6Y09dTEWbLIdWrzzziCOxiEGHBh1KU0uqSTByRroO07uVoMFzPcegDSXr2Mw7NE3d5UmBB3Maf7i9ceJI6fPJbj7+/c5fZsB0/lRUV6MtkRbFNc3wb+EANw9ptpod19sXt29/dN+jUbxJAtsnNU/GTNqqqQbaOfEJ70o3fPTyrlXldDwi+7EuNIxQ== 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=SsI6VaYpP62y6kkaUAPmJ7wVYQgNVT499l60/J6MfyA=; b=tjAzY8hdDC+yxG5Qsiu2Z901+vDl0V0Kk3TOy6Ny6wk9Xn378zUxsuDelCyhmkzbkYs0+4sXIFoH5yqIl9h5w7D1xJgk8rmbYBCwhqrGiBI8+4W+0dJx59Ls1KWy85F8z1eUKT8DFGFT81yp8PBWQ6t57SxXj05nkTM2Mz3rOJo= Received: from BY5PR17CA0035.namprd17.prod.outlook.com (2603:10b6:a03:1b8::48) by IA1PR12MB6436.namprd12.prod.outlook.com (2603:10b6:208:3ac::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Wed, 21 Jun 2023 05:49:35 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:a03:1b8:cafe::2e) by BY5PR17CA0035.outlook.office365.com (2603:10b6:a03:1b8::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Wed, 21 Jun 2023 05:49: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 MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 05:49:34 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:48:41 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 6/8] drm/amd/pm: add flood detection for wbrf events Date: Wed, 21 Jun 2023 13:46:01 +0800 Message-ID: <20230621054603.1262299-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|IA1PR12MB6436:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c3789f2-9ff4-4124-0e7c-08db721b4af1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zUzpRWQEWYmWrPk9zlElZDn7RQpXsmYO97SCxgsFJEkW7vj4/18JGdWGvVKP32qmY4ZSHIrJ4BhsPLTD5M8UbHkiuH577YzqsM0xTvO0TcfDA9fQr82FO5hJ9CR3/nGFuLwW0SZCYRmraNQhw7zjhfJXj1HLk8LGBbkUoi6dH6skVJaSOt2ogVDufAjHlkePb002RpZ8YNZ4AFdlGjh7XsdAw4Zj3lTaKEeu7wGdJ0GwYigJhGa8g6AZSoojBtlQo7QQhNoqOnej1SnnINKfGw+EnWVl8cBTlIFmRM7cRJ9sHzYbPT6GqngnDY+Nt+Ni1IL/kl2o8T7PW6TmZFL6tio0dUwN7aVl6gIAl6m0zINaQRbpx63v24TC+N3UYkT4wMX2faGGciFRQ52YN9sqIfAdaxaQdgd+Iz2Xg8qeJ5vGQhxQNrGdscG2wwryvH8sxqycJX86NNq8J1zruXTmv8uu/nnyBKy3zcI8V61/M531WQYOQnCkUOZ0XBNubLBO9rsT3m1bEWpanfgHBvrmoS08rLDW9YAAMZ8vegz+GAJ+kX6y1o7RnEFthhUmi7lUY7tKKXjrQy4MUgRja0v+QTjdkPkrRoQTmz33fXcE9koi84xRsccSmSLLzmg03Nu7UoBw7gGyYQvDRi1OWi4kKXhdlBr6kAiKbcRBpHA9F2eO2/wRfoLMZYIIYPp/C0Oc8V6aWGPA2HVZHT/EtT3vsGYSPtJkV5yoNfT+gntXJIMpel4NZ72uS1ozwFHJ/q18y02dgVRLZxzquAbWq96eUEw+hXrLo+Hb0O/Gyx9lKtTNLSXXWYHeeB2Etno4ftkEAeqzVcb3LbxbmDyY+Ho5LQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199021)(36840700001)(46966006)(40470700004)(82740400003)(40480700001)(8936002)(40460700003)(41300700001)(8676002)(82310400005)(921005)(2616005)(6666004)(356005)(426003)(336012)(83380400001)(81166007)(186003)(16526019)(26005)(478600001)(7696005)(47076005)(54906003)(86362001)(110136005)(316002)(36756003)(4326008)(70206006)(1076003)(44832011)(70586007)(36860700001)(5660300002)(7416002)(2906002)(36900700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:49:34.6614 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c3789f2-9ff4-4124-0e7c-08db721b4af1 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: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6436 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769290378311130385?= X-GMAIL-MSGID: =?utf-8?q?1769290378311130385?= To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- 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 a8efdce4607c..75d6e654b2a6 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 Wed Jun 21 05:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4148659vqr; Tue, 20 Jun 2023 23:04:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7d5K+4ouwYO1NKZt/WgmHzzAgxMY0fNZTJhiLyVpUSep6zOBs8rvvd/3IhiT6Y9S1RYplh X-Received: by 2002:a17:902:b28c:b0:1ad:dac0:5125 with SMTP id u12-20020a170902b28c00b001addac05125mr8813758plr.11.1687327489605; Tue, 20 Jun 2023 23:04:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687327489; cv=pass; d=google.com; s=arc-20160816; b=qZER/aDWpbbLNmTcAMDuX9XcZ3mQNUfDks1Svt8xi7lwKRptAiciExNE2+uCeGi5mb lnYnCBxPTTRqNjE62MJIwrDZoHPk2Qo57T0T9lH3PtAoUoQnZe4+OShxdFQpf977pws6 1GqH9e6/vIPLEHHa5/QZdm08xFCJFWruMJWVmtHH3JwqRttbVAtosE6XP67Zk+iWjeWa 8DzgV2II89dgrfvAm4aZz7/nyBPAvQNBUJHrMAlBDBGRRHPKazx68JgPRR4ArNLcPKSI kP/PbsADNg0OveFA0B2spJTj3i3foAhEpCfCI5GbCedJVYG5XbZFP24LazaDToNWAH9u QKmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0z6ibdcFT/8MmVrVyhFkBUyZoPiugSXma1cMC0A9HYI=; b=harlq4x3kLcSflsKjQqd/xsJA96nJAeoayfLOwyoTBb2CS6bBaq3smdrlsgAdWHLDm 9mRUjdqUpYSF0Hlepe9ivru371JwE2zExkW9iIqjgVq11iXnNfpQr41klPLOfxpx9rWy xzJSiSMZmCxIG6FMwdTVf6QFeOMKsNblHxRree2WWYU1YHdPe6GrrLX1HS0p35lNJHR3 XVKNfBC8q0nc4ZlC440kU3l4xuKXH2BWW+jTcQT34gb3vv66Pv/laOeqHWaZe1tqEyv4 nrXH4r6tpObZNVrL+aWnqo1eNlIQV1UyhEVtYBa0jc3MpoQevCKO+rv0N3vAMBoA56yF CX7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tewzGVxg; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a170902f68c00b001b511022d76si3697362plg.360.2023.06.20.23.04.37; Tue, 20 Jun 2023 23:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tewzGVxg; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbjFUFvK (ORCPT + 99 others); Wed, 21 Jun 2023 01:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjFUFuU (ORCPT ); Wed, 21 Jun 2023 01:50:20 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2078.outbound.protection.outlook.com [40.107.101.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 794942106; Tue, 20 Jun 2023 22:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D833BY1lnxUM4z8xn39HoYOhQJxLEQBnUPwQyef5csQjPRQgYL6KqPfTmrQRo8uDxINZkfT2eOuTh9DCkLNtq0PQhF+kxjn3WNEQ8R5smP3SgEqC9GwlKkID+zhuF37mjqQlLdhmwE+iM6q91pLXJA6WjrA66xUt4fOWWGPzrKu1iHXnmIzlfTplleWWDjT4VaqChsgea6MTcpiZp+P+QmK+B3E3bdLdGJLceis3eYW1m7Sp0CRVh5c1lzeQhv6zULhTKyJTXpUBe2QXF5jzm3nRbT2rKS+oVV5GHNn8zcBdmIK18gBnBcDr/Uatvd2Qre+Z18z7ptWfhnIE2mi5MA== 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=0z6ibdcFT/8MmVrVyhFkBUyZoPiugSXma1cMC0A9HYI=; b=OOi8HBdomodeF8c5tShl/8EQWAFnywouDUg1jFyOAwypOslN4ciRfGmabwGCsBus5h04HHh/bxhljHhy0V/IRtlY8stRcTZpLaSvMMSB99kb7dFJgQk4ToeGk9C4MWXfErfOnR0MOX9Q4pwIUJxh39Uo0SE2teGkB06VQJQ9AebstQT/tEanugWoeyveWW8CjW9F3hliTLboKlwVKEghevBOYg0OkZW2O96KDBASExf4X+kNgy4BmKkBzzBBF6x0LlQdmNAZufzdgEnog/SA3xgzcANW5YYJkNKHJGy2IxIdm+c/RsNpHPaIlueRE9a+zp77/tIfg3e3ZvPE7eJ89A== 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=0z6ibdcFT/8MmVrVyhFkBUyZoPiugSXma1cMC0A9HYI=; b=tewzGVxgrW7/OwsdTnRaSDm+Y97nNicPRpSBjbj+6o47QVkbx3/1KMgquOutlAEHc3H+VNdjV8k7pC/4ql0hResFT6iEfXXPDKJmqEXCP1XrlneLi8teHk6MVHBSLrXv7Hk3siPIpbUVrmu7cSTofIx8ymmGZ9QO9Qbs3K0U4wk= Received: from DM6PR12CA0010.namprd12.prod.outlook.com (2603:10b6:5:1c0::23) by SA1PR12MB8119.namprd12.prod.outlook.com (2603:10b6:806:337::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Wed, 21 Jun 2023 05:49:44 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:5:1c0:cafe::da) by DM6PR12CA0010.outlook.office365.com (2603:10b6:5:1c0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Wed, 21 Jun 2023 05:49:44 +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 MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 05:49:44 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:49:34 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 7/8] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Wed, 21 Jun 2023 13:46:02 +0800 Message-ID: <20230621054603.1262299-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E5:EE_|SA1PR12MB8119:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b29972b-593b-42ad-2a74-08db721b5079 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 60TKyO6o4VtdTvHM3KMDh2BirClAhy4Lwh/0SLdgOmwIQefOGFx5XdspzfkqhIL6pKQCGh7a9HryIENcADk9W784csuKfugpDhHmIrM9Pe9hwsFE1VgC+23Ts0ZqqLE6FxF+5UZQ214uEfjg/Yna9nr3WtOg97/IY9hPcigDadekY6BZQGEQMJlgPUcKI2yIMpZHkKGLzYd5bSGLsDI+0pM6fyFPL4XTHrzX9D0sTjMKZ6HZHFE5CBSaNjZ8G+3wv9Bcqd1i9ewAuL9vw7csi4LdsBiOYtYSxt8CGLsguugp2JNrAbXWpXUH6aXC0y2gEdE1tiVASGu5Z+SmH5Qq1NvHEDPrlIVtTN/3DCyyp9nvvLOeC4brrU6wtlHczNJJZ82uVPIOhbOs+Sm0AxVpAye9UuysLrtKUvBvkJTdlY6badVSiMzHhvnnAv2+cxxFjLDxCh8UzBiguVkEi3Vvex4zz4NGcConJ594bQdCqb21JGBpak6E7ARwsq+o6MuvXdKivUfXBi/EqCfG3eKJ7QNpZCLtLQOKNsRZvX94FH4p4zXNBGL9JFiFwixsMfeTMQOm6JeAVKh5OLsCQrr/TE27Uh5XtgnaNlanhvAIKwHWLiDvQubLXN5TxXJaSDaHbqv2ZteT0FAKL5P6JhEtp05G3/nwJ5YNgZBVX0JKE0dqhzeBg0yGlVF3Y2yjGQ0kjz2g409HdeCPurPz5C+oi6ElPda4K2Vr7lueH31d2aoi0PeimivZaxOJtXWJ9Q3Q1n7OcfmQXK6A/AZpC76FbL/mAlNs5nBq+n9aV3wxJ+D5tfFgYVUV1eIkx5q9uvIqSTl8UEb/sf70PxwZCOs2+Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(46966006)(36840700001)(40470700004)(81166007)(921005)(40480700001)(82740400003)(36756003)(356005)(82310400005)(86362001)(7416002)(40460700003)(70206006)(4326008)(44832011)(316002)(26005)(186003)(110136005)(54906003)(5660300002)(70586007)(6666004)(7696005)(16526019)(8936002)(1076003)(426003)(2616005)(2906002)(36860700001)(8676002)(478600001)(47076005)(336012)(41300700001)(83380400001)(2101003)(83996005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:49:44.1921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b29972b-593b-42ad-2a74-08db721b5079 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8119 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769291110058680170?= X-GMAIL-MSGID: =?utf-8?q?1769291110058680170?= Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 3 + .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 9 +++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 60 +++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index aa63cc43d41c..a8a4be32cc59 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,8 @@ enum smu_baco_seq { __dst_size); \ }) +#define HZ_IN_MHZ 1000000U + #if !defined(SWSMU_CODE_LAYER_L2) && !defined(SWSMU_CODE_LAYER_L3) && !defined(SWSMU_CODE_LAYER_L4) int smu_get_power_limit(void *handle, uint32_t *limit, diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h index 297b70b9388f..5bbb60289a79 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h @@ -245,7 +245,8 @@ __SMU_DUMMY_MAP(AllowGpo), \ __SMU_DUMMY_MAP(Mode2Reset), \ __SMU_DUMMY_MAP(RequestI2cTransaction), \ - __SMU_DUMMY_MAP(GetMetricsTable), + __SMU_DUMMY_MAP(GetMetricsTable), \ + __SMU_DUMMY_MAP(EnableUCLKShadow), #undef __SMU_DUMMY_MAP #define __SMU_DUMMY_MAP(type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h index df3baaab0037..b6fae9b92303 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h @@ -303,5 +303,8 @@ int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, uint32_t *size, uint32_t pptable_id); +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement); + #endif #endif diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c index 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..cf75feaee779 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,58 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu, return ret; } +static bool smu_v13_0_0_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + switch (adev->ip_versions[MP1_HWIP][0]) { + case IP_VERSION(13, 0, 0): + return smu->smc_fw_version >= 0x004e5f00; + case IP_VERSION(13, 0, 10): + return smu->smc_fw_version >= 0x00503000; + default: + return false; + } +} + +static int smu_v13_0_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 + * is a valid setting. So, there should be no direct + * return on that. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table, @@ -2188,6 +2245,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 Wed Jun 21 05:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 110787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4153201vqr; Tue, 20 Jun 2023 23:16:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7S3T6Fiw6cg74J/1bi9uI44MKjdfsg2IDQtP/r1yTR+bf0BsgfmD5/o/2/FmP9e9jV9O43 X-Received: by 2002:a05:6a21:585:b0:10e:f369:2809 with SMTP id lw5-20020a056a21058500b0010ef3692809mr7727435pzb.21.1687328204439; Tue, 20 Jun 2023 23:16:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687328204; cv=pass; d=google.com; s=arc-20160816; b=p01PuIOmcnCW80JpKh+dwCmLnlELiorn5ZO/ntxV3W5gpZ6KCXL6uObgWclZE7Gy6F A2u+rVL+ipjoBzeSgLn44SnsYx0PbUM0p8zBkDSCqtHzaJa1ulKZz3p9XBTb5xNqpUO2 HKmhqW2IZ02uU7RrMrmu8tdgHTsEtEBqV1zDbqO5uvR6uw3MiAktoXLszHJoDiEx0fyE eSP+ceC4FVyP9dtu+uJ7e68Lrf9pwu8yvToyWW6bp5R6YjUZx+ZeuSakp1yafaKlksbC PKisb5e2LVuJOZoGVk3qUcIsBPqNEQx6Nfnc7ukjU5WVG2oevTQttkZVKHNu0X7nWVQL iuZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lUPArdpXEEigCis4DV1aAiRsjHVy/YsYGKX7wtaEc18=; b=lzgFa/be9d1vjv3c7K+3DV4U3XeRnUoJjV9+f+CxzfhANcj2+qkKoC+q55WO4CwRfG i0nlO6aOc5kb8wJpwNKaf7SEvmrkNarNvF3HfDwlbsqICfoO/rsbC9igThDa+Dquowx2 /5uohpCJ+af8A35tSnb32sLpPftnLqxdOX+wGjjhxcNhmXPmR2xL+p+wnQQRvCC9Wlst rLMkJzxuqWzschHLKHuF16sMsV2gR2MScFgfM/o5rqEl9VjPMqKCWQfVKp/uHd/wiz0R VW6V3sZY52ZWluamzstdOgD3G/pGVjqWXEI+EyvwcQVvBJvvXfVQWMgiXABaf22jXpkE aQxw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tZiRj3UB; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u132-20020a63798a000000b0053ef0ac79c8si3451023pgc.263.2023.06.20.23.16.31; Tue, 20 Jun 2023 23:16:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tZiRj3UB; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbjFUFwE (ORCPT + 99 others); Wed, 21 Jun 2023 01:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjFUFv3 (ORCPT ); Wed, 21 Jun 2023 01:51:29 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 490AB1BD9; Tue, 20 Jun 2023 22:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DLwyG8a3BivnzvmZrPBXWtfabfPhnxN7DnUdpTHhPesNOWESNuTugtLhReX+toh2pEc5D4jtHdHr7X1oFLEnfJVbhIGvkRXnI+kKzPELH5Dtk9EkajeS8HdyLzgopYt9PKzy+VhzzZK/CY46kJkFPdQbUZ+akuFxIPiNtMEk2fQvSW+5zfFyFOISjMXdBbc0CTLHvybz0GSqjZ4jm1iqEP+OBKBxbtobNLDg80z2DXvCSIf9GwSePw6eFvq+Pa1vrjpiY8JelO9S61G9QRuL/c5yycD6DUJqsXCt7J8bCm33gzfegI6dVNli86vsYH0VCTvoySzk0pThdLsO7NtPbg== 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=lUPArdpXEEigCis4DV1aAiRsjHVy/YsYGKX7wtaEc18=; b=S+vfZuJAmHwEozzpJJ62ClzsWNdXKNhNTo4Ii7ocWp17xwXVPNWF+u2O9lc06aClS7ppQw0Qfm3wWZYB0W0xzKpyXixo8307YSHx07cIHl/KUjXqQBD77p8zMdGn78ikO4pOvEpNq+Xzp/7aSwjtTReNfQ8/Dj/ZLx3GpCnmOVEAtui6de+/KH76y+1SuACyxoe2HWK7HSVEiZFrwnKuaVkl1s5lO6gY6V8J+9VsYNb1M9uDEkk4o0SMuvepKu5suUZwdklIBOdtViIC1vM/fDluhG5K3qKuWGQWwK8IxnqhBgnq9Ick9e3peJrf9peMhVWJXam6GfOojRumJzVWNA== 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=lUPArdpXEEigCis4DV1aAiRsjHVy/YsYGKX7wtaEc18=; b=tZiRj3UBR1JlPBcIiq/6VTz7IidX8Rif5amTBFI1ZZDA580+at6HObN7xMRxHYeUvZVLhnAEenZbMQQg0xc1ed9cYWVZAYHHjx6q/bjAYeSLR44WYLsmMAnCGN1FkZGpzLQdkBAF744QaN2ad7bvjZ2sXmoV2lWebNkiwwKekgg= Received: from SA1P222CA0014.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:22c::23) by PH0PR12MB5468.namprd12.prod.outlook.com (2603:10b6:510:ea::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 05:50:32 +0000 Received: from SN1PEPF000252A0.namprd05.prod.outlook.com (2603:10b6:806:22c:cafe::27) by SA1P222CA0014.outlook.office365.com (2603:10b6:806:22c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 05:50:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000252A0.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 05:50:32 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 00:49:42 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan Subject: [PATCH V4 8/8] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Wed, 21 Jun 2023 13:46:03 +0800 Message-ID: <20230621054603.1262299-9-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621054603.1262299-1-evan.quan@amd.com> References: <20230621054603.1262299-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A0:EE_|PH0PR12MB5468:EE_ X-MS-Office365-Filtering-Correlation-Id: 68f3f6f1-88e5-4e19-c5b6-08db721b6d33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FOHwDvswiXY+YNoM7ysUqleQpS37ZcreZeY/mfrohqek4cUP3pzSWyd4LfYiJ9HBM4uJ8xgsx0u17+JsPHI9hEgS628jSTG0kMBZstbJEByXXlcxzqvMJal7QnrGZ/IdP3gtNxu2YPiqMbsghVXG00vuLMckySv7V8ZBPhMSRC7q1jyKhMw59gHh7wiQSZmcMKs+Fqw95QX/tmrWSWAH9nxYo1rFXYq3T5YUxtZj/CtsHmkO7757xvG6DdzWDkX6bJFSKvriy0GRPsJt7+T4jexC9Hf0XHtwiP2gPZdkUL97iS5Qg+s+xSgTZoD3K5PHmJ4od9+Jh77dk8M44wyEq6pdFLNkVhZA5yzJAFo4gKUnzgj70JTqdTsKfaA8zEILNHc5teivS1ENLI8D8UhPQD8DPdBdyR/3JZ+RZ32gQ+d2R9EiAbs7ZqHGAsOSlkoDHx9pNmTcEmMyBMLhC69LSiwdaizAmSc5Mj3e0o5YaYbpCFsYY01IapwMDUcDLaJbY8BQcDi6hSnFwJVnhibzaQc022PHoAyl/EHk+nF3yGU1+KRDShAQrq6Vx0GCZWQBr9zr8nGutnozbPg+bS8xMnCDCjVlRXZfe1PNaLRQhxeoMgkCLBGJ98BiwZUgfnLFYqQHXquZDdteIo/sqbMg8B7UTbZnFDzJlEptZdakFkHN2BW2pkmV2nOBL0XZbO5ktWMu/SsN+Nd5su+ndrb/LUiAMwxxmXPeVFqIGdBsbvMSQIWGvGmNOj7+xt95Qkei525zRmqnJU0vI5Z8ESqPlbn6C7UhRc9AAvUF2ND2nkfeZzxJIKZN2DXAYg8FzfE/8WNgRtg4MVa46B6ZF9QNJg== 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)(136003)(346002)(451199021)(40470700004)(36840700001)(46966006)(356005)(81166007)(921005)(82740400003)(336012)(1076003)(426003)(83380400001)(26005)(186003)(2616005)(16526019)(36860700001)(40480700001)(47076005)(44832011)(7416002)(5660300002)(8936002)(8676002)(41300700001)(2906002)(36756003)(6666004)(478600001)(7696005)(70206006)(70586007)(4326008)(40460700003)(316002)(110136005)(54906003)(86362001)(82310400005)(36900700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 05:50:32.4381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68f3f6f1-88e5-4e19-c5b6-08db721b6d33 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: SN1PEPF000252A0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5468 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769291859301175891?= X-GMAIL-MSGID: =?utf-8?q?1769291859301175891?= Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c index 98a33f8ee209..16c1c04e2034 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,57 @@ static int smu_v13_0_7_set_df_cstate(struct smu_context *smu, NULL); } +static bool smu_v13_0_7_wbrf_support_check(struct smu_context *smu) +{ + return smu->smc_fw_version > 0x00524600; +} + +static int smu_v13_0_7_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 is a valid setting. + * Considering the scenarios below: + * - At first the wifi device adds an exclusion range e.g. (2400,2500) to + * BIOS and our driver gets notified. We will set WifiBandEntryNum = 1 + * and pass the WifiBandEntry (2400, 2500) to PMFW. + * + * - Later the wifi device removes the wifiband list added above and + * our driver gets notified again. At this time, driver will set + * WifiBandEntryNum = 0 and pass an empty WifiBandEntry list to PMFW. + * - PMFW may still need to do some uclk shadow update(e.g. switching + * from shadow clock back to primary clock) on receiving this. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table, @@ -1786,6 +1842,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)