From patchwork Fri Jun 9 07:28:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp773291vqr; Fri, 9 Jun 2023 00:36:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kMGtrJiLkhXlPqYouBGhIkU7lE06mORzpd7cgF8hjSs5SecZXAHcdSclq6+bcteikZrfV X-Received: by 2002:a05:6830:d3:b0:6b0:c62e:7941 with SMTP id x19-20020a05683000d300b006b0c62e7941mr747224oto.17.1686296181059; Fri, 09 Jun 2023 00:36:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686296181; cv=pass; d=google.com; s=arc-20160816; b=rp/Xqd6VOblGWAG4fHxIyFeH2LQArdgdY4DSdQCFjUeLWgh7csubQ7ERQaX9pr42/U rRDerO6XIYJ+ZPMfIRtae3EjlFPRI9H0KGFXxhUqLMF7k8M7IFIn18G7OdYL8icnFCXF pbyXqelu4DUz4W5SADcRqK/6nCXI+MYsE/lsaGtfh8UqKlvijVEGXux2aMES06dz/5y2 U+JP3ih5sQ57yaIfsSkO8QDu95f/J4sepYmfQ0SZLDPzWy4/nxMKjsOu8gMhk9PzO8TW 2blr4MQTg951Empda77Wg3jY8fdlPQz3ec9hP7ML85osFZSvIgXdtlvhMYskBdqfsecX Hhnw== 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=L+YPDkEOzweYgUb7zrJOGAgnGxzzpjMf6xgGT0U+Ndc=; b=gmyzakMjKBDBqBWihOaq564hD6QOyaP2Y3diECOFlefFX53NZ45SBj9wvcjOfPX5yd eTWIFZoGD+RUCxPo2cBHIpAkwbfdQefT7sW3spA0c2SIuGzC74E7gReGg9cRX5ZzHk01 gRivmzYrBVEzYqMzeiyxNk/sG2giAsOvLg+UGQ4F3lPMbZfdOu9opCd3KjpAk1PzDhQA 1Qr8BQCHOmB1Z+IQsKNQjfP1X74g3Fti1lSjtTlMpOOcov8D1SzrLeNRW62YSWRZ58Xj EcKQD/NAReQAiszLopnpFRvgsIIYi3SXo1V9xJZ+2KxUSSxtWjwpy9TE9OJUTd/M8XMt f3SQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=dbjTVHgR; 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 e26-20020aa7981a000000b00662c06a0a75si2087513pfl.15.2023.06.09.00.36.07; Fri, 09 Jun 2023 00:36: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=dbjTVHgR; 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 S238863AbjFIHa1 (ORCPT + 99 others); Fri, 9 Jun 2023 03:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238750AbjFIH3t (ORCPT ); Fri, 9 Jun 2023 03:29:49 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FF9830E4; Fri, 9 Jun 2023 00:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W103cstLFjFPEF0xbDaYZ4mM7FXziMSiiwKQav4jrifAcGRBrP93DL3NUSFtIA/+qTMv4ZnmWigSCDlkyKW17Dm6I96WBIVDAIyuKJa+u33njtDoynCYQWjgexaiQOMDXAnBRcsYaQzN85SkAQeJeSbm8EMnvreTlzld4MRPh/j1HMFSmWkmcL9ZeMPmf8woi+2o0ENGKh/JZDveJPsN6hKckZ7r+iMXHhf47M4wc5dH4FsQT65ap2u9VrIdL/e5wbpBYLHo3FIpwivBghDuWmUfVjPgn20uBTBEhDTXou1SGFlG/tbaMd73SXWBfEP41AgtXu3lj7CCfBcCqSS6eg== 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=L+YPDkEOzweYgUb7zrJOGAgnGxzzpjMf6xgGT0U+Ndc=; b=Ir3mb3DYKUAK6Cyi+qYp/inCCsdjmeWWOjkv0AGZIH7enbTZfxj3ECVMMK6X/CJeekdve1RAIPdtmYN6gnsi27zMCScz66gC5fJp7h4Qtv58Aq4hO1TTdFCigwa7zonntwyYvLbS5XtCbRpkoRmaNlrWFtPt08wLdmI7ROtkmjHPwpyGity6GVqOUy9qYHGR9OktimZ2YHIhB0cjgfWsasLufgntLri/3zAjJ+GyBibgXZUMVEVdEtwksRCYJmzFD0LujhHoh0sWUzqFrTNqRXVuboi7H5a/uWjXyIWxAFEzjKBvHKQk4VT6hZnR/Gw6VKR4dj/uaZlCEXpPBUdNYA== 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=L+YPDkEOzweYgUb7zrJOGAgnGxzzpjMf6xgGT0U+Ndc=; b=dbjTVHgRh8+GLlOXJ95jhMG5wPEPzv93KMIoxovEIB5u10JDCBsrI5tRuNUMINGscFi9nS707xVrrFfBzsIhC25B5EA7NathBnzBetAoIfuuNRsRYaiVKlF5Alp09UOCqSOrWn0l0rswsF2A1BxROTKiawQ8/Y2DnoQLxc9lMnk= Received: from SN7P222CA0018.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::27) by SJ0PR12MB6967.namprd12.prod.outlook.com (2603:10b6:a03:44b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Fri, 9 Jun 2023 07:29:19 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:124:cafe::d) by SN7P222CA0018.outlook.office365.com (2603:10b6:806:124::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.25 via Frontend Transport; Fri, 9 Jun 2023 07:29:19 +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 SN1PEPF0002636D.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.6477.19 via Frontend Transport; Fri, 9 Jun 2023 07:29:19 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:29:13 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Mario Limonciello , Evan Quan Subject: [PATCH V2 1/7] drivers/acpi: Add support for Wifi band RF mitigations Date: Fri, 9 Jun 2023 15:28:40 +0800 Message-ID: <20230609072846.1552238-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|SJ0PR12MB6967:EE_ X-MS-Office365-Filtering-Correlation-Id: f8a09b81-dd65-4775-4a75-08db68bb3d06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kp+ZEDQ7a93SVK9NidU7L7tTvWSZn/kAe5TLr28Ruu7APFjg33PjWJRCXzxqGdrR+UU1GzneyNTjHgv8N72d8YKCYkQHFgGE9R46CLGnE174KFb21nMA9WVhT4F6aknONA8beFa5LZL55GZvOu7QNnOa4rSTcgmXVQs3r02QvKdSiTrqAmu1Cyt8KH+1d5shqEU6dtCVnRONnQJFpaRqHWvaQFVM+nhKdxSompebMuzG01m332aX7lfzA/rvfA9jwuULMShDRW6BgULS9elGuF0qFpz0EWhSAKYh8nnnuIj/uIwGEHtK8JpgSLOySbLRv9yBR6WvgeCWXjaXSnOKEj8tFGvSZBJlLpJ8GVZqV9Bpj+xPVPQKFTSIO8xqDiOBrWSSJoMp21VKbIY2LxtPu4+XfmSzEWQmaPghCuMZODWtLie6QMRc9+Jccj2ddGAUEX0bZ+MnTPUylbU0Ys+SyHoKbFmlzl8Nd/AOz/YOPemwLVUnpqE+4tKZDnnCz50C4YM5idxQDirlm7PDOB3uidRDvRKpkPJdSH7b7qZdt0WgDIXFEjhUAxCFGOBLcenL4LOJxA86BdDmyOOaDRWSzbWQKxxf/rV/ZT+6plrNpOrWdCw7La0iA7h+ahFH+hkXRrWsuzG6EnpEJvFvyx9IrOAUgx2dP506J9G3KaoXbTmW3weHFxF0LmnrruIrD5fg51wFpVECNrTTrFQ+Jszb2cIshe8uizVknGDjzCDUAZkYLfQ7k2sdgeUQjYNq5ydUQaAKS95K1CWNqgHd/6UKgMHTSkbg/HbrHcVP0LjKfMs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(5660300002)(186003)(110136005)(26005)(1076003)(40460700003)(36756003)(2906002)(70206006)(316002)(44832011)(7416002)(8936002)(8676002)(40480700001)(54906003)(16526019)(41300700001)(921005)(70586007)(6636002)(356005)(82740400003)(478600001)(4326008)(426003)(82310400005)(2616005)(6666004)(7696005)(83380400001)(81166007)(336012)(36860700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:29:19.4427 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8a09b81-dd65-4775-4a75-08db68bb3d06 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: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6967 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,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?1768209704492949159?= X-GMAIL-MSGID: =?utf-8?q?1768209704492949159?= 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..9ee7c7dcc3e6 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -611,3 +611,10 @@ config X86_PM_TIMER You should nearly always say Y here because many modern systems require this timer. + +config ACPI_WBRF + bool "ACPI Wifi band RF mitigation mechanism" + help + Wifi band RF mitigation mechanism allows multiple drivers from + different domains to notify the frequencies in use so that hardware + can be reconfigured to avoid harmonic conflicts. \ No newline at end of file diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index feb36c0b9446..be173e76aa62 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -131,3 +131,5 @@ obj-y += dptf/ obj-$(CONFIG_ARM64) += arm64/ obj-$(CONFIG_ACPI_VIOT) += viot.o + +obj-$(CONFIG_ACPI_WBRF) += acpi_wbrf.o \ No newline at end of file diff --git a/drivers/acpi/acpi_wbrf.c b/drivers/acpi/acpi_wbrf.c new file mode 100644 index 000000000000..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 Fri Jun 9 07:28:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp773085vqr; Fri, 9 Jun 2023 00:35:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SmEALjR3YstdX4IRMgvHdUsJtlHK1soGtCFrt8PKJR3ww4fT0GpeXauJlbkGyaZw1xABq X-Received: by 2002:a17:902:e88c:b0:1b0:f8:9b2d with SMTP id w12-20020a170902e88c00b001b000f89b2dmr783100plg.29.1686296148827; Fri, 09 Jun 2023 00:35:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686296148; cv=pass; d=google.com; s=arc-20160816; b=xmy4MKMRqxOq3akx3HG3jpyB9jI3i9ZSiCvGt7Wuw11GKg5KlDpTbDxwLnSsvMhyO+ r2MYTqT3xpC2Z5Cn9wnbUmlBvb35hRw6p4hEI0+L9UdmLwwKBBAEQFtsZbpel550ZIC1 cc33HXcWB5k1wBzEVsieIB6lLc2lErMNCMZ52RruglfEOdWhT9YNcaExR9bhuBsg77rS DVjwA9cCxQrCdXeKX8v+Oc72SL7XL3p5a5VKbNkh2iirg7JQRHymGevGmZ0kD8U6yp32 Wy2BUYXKtgmDV5QYHJcHudo30AJAlLo/wJjmpZVWiS31VcDUYlZ9NEPCU4sE2iqlb/th CypQ== 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=5eIlIkPuJFg/F/2KgUp3XTFrZn/NNUZVcwFmqOo0O5o=; b=xrkUwDg81oJTpS/zoMlWpeGsZVWDTlixmZZM8+JmtcdXK6sLGI8ItaZ0IimUsywT09 MIYo7KSqy7IBl/wTNmEdODWyew42iofPVUvaHo4odvCojG+PZiumdpGWuEhJXTUqqnVO /5PyDbJp+Kcci5CPVrBPGSWZJc9zqkVMk57bWkQR3/TzHAnKWYHR9Z4EVk+qt86hsEhO e7eSlo7w9WMjV60hbXSc4529T057aXSH/SbAcYpkiblP9c8sOwAX3VZMHI51nz0F2QYq uS4Bze3NmW1XJFdYh+Jf6HbROIY9xqz9vglrqBUf/28dZSshW6kd3bT5CYM6et/hplR1 tBkw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=wGfzQPmJ; 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 ay6-20020a1709028b8600b001a97e24eb34si2253113plb.201.2023.06.09.00.35.35; Fri, 09 Jun 2023 00:35:48 -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=wGfzQPmJ; 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 S238908AbjFIHbG (ORCPT + 99 others); Fri, 9 Jun 2023 03:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238756AbjFIH3t (ORCPT ); Fri, 9 Jun 2023 03:29:49 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8786030F9; Fri, 9 Jun 2023 00:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BdOOd+z/QkdmNC/if2NLFBQrbYU1TUJbXaBaGDOYCSWFGKuZhgqwsLcwHTWxPn+YzO96QhcKpuviP8wqaSbBduKD9UA1dPOzZzBhzBG4rC7RWHugzrEjtPXjp7GDo2IDLDJ52vyPP7O1fJOp/DpkuGZn9ol9a5xtBzm8EsIwlI/AFet/DE+DKEg5C+J3dutjDvz0Rtfuy7UoQQSBpnvFnXiV2BaDPtQcwC10bLB6/K92FR7ICBL3tUSXM9+btRqtupUAEonaE0ewAoo6OARWe3qICg2SN2Ds2G00DiTIM2xFOhy3LjSPRgXX4QFNWalzxrtWaoLrgvlvkabfGEJI2g== 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=5eIlIkPuJFg/F/2KgUp3XTFrZn/NNUZVcwFmqOo0O5o=; b=ivAKvnWM6QuJmTGQ7gYjfKclbNUIaug6oZuFu+O4PCaOKR1rPsoXYbzdBjpCJXeMWWZv3j8VBL8+t6WVYIMoMIi3ZnXdpzERVwbdNVbe0TT85jVuZSTt7DFkog/0375MUQAv9VxxT+lRX3GPrXhREqF/DHS0JmFNp61ZsGBFuZyb7H9jKUduUzoHDgSEBRzVj4zys9P2oa9JgTcxVvCnxkREe7Jg2KawXQZGeWpKgFg0QAsIbnlq9+T7hzS4d3Zgp5/sehDeS11cP3bMg4kKiZF7kgbmMq02I3OZv3fAltwlcbFRiU6tDEVg7gJsXtGIuMbmqDTONbA6I4uCYbF+BQ== 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=5eIlIkPuJFg/F/2KgUp3XTFrZn/NNUZVcwFmqOo0O5o=; b=wGfzQPmJjDk3SPAIh0o20n4mwMRmXybHGgmoEQk+AxvAN7UJcoUx5PM6xmZN5TNzZohWj+J9r354MdgIVZh1HAVOSoWk9wB3cnPfJMVJ7VRtEfSeFvO+NBOaY7EgOlVnUCS21oqgiekC4xc6spKtVla5GlRsMlTuYdI7/yUziOQ= Received: from SN1PR12CA0043.namprd12.prod.outlook.com (2603:10b6:802:20::14) by PH0PR12MB7984.namprd12.prod.outlook.com (2603:10b6:510:26f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 07:29:27 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:802:20:cafe::16) by SN1PR12CA0043.outlook.office365.com (2603:10b6:802:20::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.27 via Frontend Transport; Fri, 9 Jun 2023 07:29:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00026368.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.6477.24 via Frontend Transport; Fri, 9 Jun 2023 07:29:27 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:29:21 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Mario Limonciello , Evan Quan Subject: [PATCH V2 2/7] wifi: mac80211: Add support for ACPI WBRF Date: Fri, 9 Jun 2023 15:28:41 +0800 Message-ID: <20230609072846.1552238-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|PH0PR12MB7984:EE_ X-MS-Office365-Filtering-Correlation-Id: 1be77f29-63f4-4a8b-9640-08db68bb41de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZMX3u2hYnQevk6GM/8bVn41z6zirJuN+t+mqvtg2eZMTIcQaIQUEcy5cGeKIJBL9aiJUU+WtzGu7WD8MyAXNhPvwdM/klSlXg47TtnAMfaBR8qpIESxPZ7yh6TXfytmVbAbaOELptKUCEVvufE0rRLH3HebPHeuGIQZXxn0GuMrLZWiYZD54/bnkWJeov+jT1XPM7+ZkMJ1tnk/GB2FI0mnNXJADMDKZKSaCi0mLL0+2KyRynolEcWWFbfgpLAdgoJgq2Xca/GesiUpaBLzFAtiNBQ45MsY6CuMyayMth3C0Ft35vcR35PHQvwhwX+FuBHGpOFVgDMPJbbHckbdM+7NyUMUGNZLa2C2eCF2UfP992alY603Wb1PlvUwSkQEL58FpfNoMTZLLWgJjGAkP7E5mtFOXY6QrEhQmYkcBBV7U/GI6sgE0FRpawfqbIcL2UF7/DAW5iB5NepH7K/m79xcnBwMUULc3mKqmwm/ugH1AU5s/IUluOw2lbI8iRb5+kd4miLtE1xLxMMe/4IdLHrFc4B0ogv+D4OXas1qJX8QKUWrb2IIz1FIiORLsxbcRsu7wAb2ZVXkCNMprp8NJBwiApKoOfGJgvAMpsj90m2sMGhPLJ5O7GfFyf1aXmpuEohv8eRT/PExJme8AVOgYINWIEUj+DENq8F1eb1VJNjYsR7EwyLQlCz1xOyn8Ix5gCivs42gGp2ArZ1QTck97OUs/AynRLSIi/ZzpM2sSP0by+egICMW0zcP3Vfc/lV6TBqtZPOA/7UUcD4dstnBkM93Aluf+lHjb7OPzDNlLjEo= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199021)(40470700004)(46966006)(36840700001)(41300700001)(478600001)(316002)(44832011)(7416002)(110136005)(54906003)(921005)(356005)(81166007)(82740400003)(5660300002)(6636002)(70586007)(4326008)(8936002)(70206006)(8676002)(6666004)(82310400005)(7696005)(40460700003)(2906002)(336012)(86362001)(2616005)(36756003)(186003)(16526019)(26005)(40480700001)(36860700001)(426003)(1076003)(83380400001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:29:27.5711 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1be77f29-63f4-4a8b-9640-08db68bb41de 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: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7984 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?1768209670287124613?= X-GMAIL-MSGID: =?utf-8?q?1768209670287124613?= From: Mario Limonciello 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 --- include/net/cfg80211.h | 18 ++++ net/mac80211/Makefile | 2 + net/mac80211/chan.c | 6 ++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 183 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 211 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9e04f69712b1..d995ba085692 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5551,6 +5551,10 @@ struct wiphy { u16 hw_timestamp_max_peers; +#ifdef CONFIG_ACPI_WBRF + bool wbrf_supported; +#endif + char priv[] __aligned(NETDEV_ALIGN); }; @@ -9067,4 +9071,18 @@ static inline int cfg80211_color_change_notify(struct net_device *dev) bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap, const struct cfg80211_chan_def *chandef); +#ifdef CONFIG_ACPI_WBRF +void ieee80211_check_wbrf_support(struct wiphy *wiphy); +int ieee80211_add_wbrf(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef); +#else +static inline void ieee80211_check_wbrf_support(struct wiphy *wiphy) { } +static inline int ieee80211_add_wbrf(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) { return 0; } +static inline void ieee80211_remove_wbrf(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) { } +#endif /* CONFIG_ACPI_WBRF */ + #endif /* __NET_CFG80211_H */ 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..d26a3f622e50 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -668,6 +668,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->hw.wiphy, &ctx->conf.def); + if (err) + return err; + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -748,6 +752,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, } ieee80211_recalc_idle(local); + + ieee80211_remove_wbrf(local->hw.wiphy, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local, diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 55cdfaef0f5d..539f9cbdda4f 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->hw.wiphy); + rtnl_lock(); wiphy_lock(hw->wiphy); diff --git a/net/mac80211/wbrf.c b/net/mac80211/wbrf.c new file mode 100644 index 000000000000..91712a927dd7 --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include + +#define KHZ_TO_HZ(freq) ((freq) * 1000ULL) + +void ieee80211_check_wbrf_support(struct wiphy *wiphy) +{ + struct device *dev = wiphy->dev.parent; + struct acpi_device *acpi_dev; + + acpi_dev = ACPI_COMPANION(dev); + if (!acpi_dev) { + dev_dbg(dev, "ACPI companion not found\n"); + return; + } + + wiphy->wbrf_supported = wbrf_supported_producer(acpi_dev); + dev_dbg(dev, "WBRF is %s supported\n", + wiphy->wbrf_supported ? "" : "not"); +} + +static int chan_width_to_mhz(enum nl80211_chan_width chan_width) +{ + int mhz; + + switch (chan_width) { + case NL80211_CHAN_WIDTH_1: + mhz = 1; + break; + case NL80211_CHAN_WIDTH_2: + mhz = 2; + break; + case NL80211_CHAN_WIDTH_4: + mhz = 4; + break; + case NL80211_CHAN_WIDTH_8: + mhz = 8; + break; + case NL80211_CHAN_WIDTH_16: + mhz = 16; + break; + case NL80211_CHAN_WIDTH_5: + mhz = 5; + break; + case NL80211_CHAN_WIDTH_10: + mhz = 10; + break; + case NL80211_CHAN_WIDTH_20: + case NL80211_CHAN_WIDTH_20_NOHT: + mhz = 20; + break; + case NL80211_CHAN_WIDTH_40: + mhz = 40; + break; + case NL80211_CHAN_WIDTH_80P80: + case NL80211_CHAN_WIDTH_80: + mhz = 80; + break; + case NL80211_CHAN_WIDTH_160: + mhz = 160; + break; + case NL80211_CHAN_WIDTH_320: + mhz = 320; + break; + default: + WARN_ON_ONCE(1); + return -1; + } + return mhz; +} + +static void get_chan_freq_boundary(u32 center_freq, + u32 bandwidth, + u64 *start, + u64 *end) +{ + bandwidth = MHZ_TO_KHZ(bandwidth); + center_freq = MHZ_TO_KHZ(center_freq); + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in HZ is expected */ + *start = KHZ_TO_HZ(*start); + *end = KHZ_TO_HZ(*end); +} + +static int wbrf_get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in *ranges_in) +{ + u64 start_freq1, end_freq1; + u64 start_freq2, end_freq2; + int bandwidth; + + bandwidth = chan_width_to_mhz(chandef->width); + if (bandwidth < 0) + return -EINVAL; + + get_chan_freq_boundary(chandef->center_freq1, + bandwidth, + &start_freq1, + &end_freq1); + + ranges_in->band_list[0].start = start_freq1; + ranges_in->band_list[0].end = end_freq1; + + if (chandef->width == NL80211_CHAN_WIDTH_80P80) { + get_chan_freq_boundary(chandef->center_freq2, + bandwidth, + &start_freq2, + &end_freq2); + + ranges_in->band_list[1].start = start_freq2; + ranges_in->band_list[1].end = end_freq2; + } + + return 0; +} + +static int wbrf_add_exclusion_wlan(struct acpi_device *adev, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + int ret; + + ret = wbrf_get_ranges_from_chandef(chandef, &ranges_in); + if (ret) + return ret; + + return wbrf_add_exclusion(adev, &ranges_in); +} + +static int wbrf_remove_exclusion_wlan(struct acpi_device *adev, + struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in ranges_in = {0}; + int ret; + + ret = wbrf_get_ranges_from_chandef(chandef, &ranges_in); + if (ret) + return ret; + + return wbrf_remove_exclusion(adev, &ranges_in); +} + +int ieee80211_add_wbrf(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) +{ + struct device *dev = wiphy->dev.parent; + struct acpi_device *acpi_dev; + + if (!wiphy->wbrf_supported) + return 0; + + acpi_dev = ACPI_COMPANION(dev); + if (!acpi_dev) + return -ENODEV; + + return wbrf_add_exclusion_wlan(acpi_dev, chandef); +} + +void ieee80211_remove_wbrf(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) +{ + struct device *dev = wiphy->dev.parent; + struct acpi_device *acpi_dev; + + if (!wiphy->wbrf_supported) + return; + + acpi_dev = ACPI_COMPANION(dev); + if (!acpi_dev) + return; + + wbrf_remove_exclusion_wlan(acpi_dev, chandef); +} From patchwork Fri Jun 9 07:28:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp771940vqr; Fri, 9 Jun 2023 00:32:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JhEar66xNR77oOPt1PsV6MyApeoEir9s6yUP4A2ydGkcnHhdrnpaWj5AmhIVzjbt58yL2 X-Received: by 2002:a05:6a21:380d:b0:10f:7abd:fe5e with SMTP id yi13-20020a056a21380d00b0010f7abdfe5emr200612pzb.40.1686295973396; Fri, 09 Jun 2023 00:32:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686295973; cv=pass; d=google.com; s=arc-20160816; b=oxvWJdij44Y31md8beH320gUfh5CeW3df5+tszRubuMvv+nOf7L8S4EmcDEdqAX6Aw ha0mMa0al9ll0E1SPTjq3bLaSS4QeYsPb13s8A5gtvhsBABN9eqz1UZCTUY8V9uqgMyT 0S4ruMEh4IOuZwDM7CcLNBEQTa6QMKGGnk5xVg4aOI+TS2uQdjpmSwiCBCiGIIzSqJlm yBaF6BEEREajDYabo1HLpIySmjAdos70y2Pm6JtqjMHArhFUwDss0ndvM2Omuvr4YYRi nqEYxyz7mx34GI8R0Tu6EQaYodhtCUkz9mnycIuICST8KoVc4Vghox0Ikg1DfBYA2i/B u6qA== 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=kS47+VWF7plcjJrQqiMe6eoziGUpBc8BpsIj7V5A+pk=; b=LZLmBoYx0RCk4QMcuDdXKqiIySsbvJWYe7+Y5cyeTn/oqyZL6KigSTWWQwHsfl7q6g GegScpuEiQJiuA8lrCbV9XDqxboAfyGAZtlkJ7nI4aI30JbknSl6ESiD67rV/7Q0NXGJ YouG6P2iljB9xbvWi1wQH6D80MO2KkoOMVHpR726zCqBXyMpaVQr2XWwHkfRtliKHbrK mGzz5Q+6JBnOE+FsdcsuAGiW05TEC3iUmTCr9ukP54OnTlucjjtcxUyy3knY6Vle8e5q j2BuYumP7FtW/jF4CCx6I9CXkiv8lIsdDcdt/Gef7jnkZ2++Cyc7MTlYXYsMTR4j3+SR moHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="ur4/Td+q"; 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 a188-20020a624dc5000000b00660d2553147si2128908pfb.212.2023.06.09.00.32.40; Fri, 09 Jun 2023 00:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="ur4/Td+q"; 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 S229890AbjFIHai (ORCPT + 99 others); Fri, 9 Jun 2023 03:30:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238808AbjFIH3z (ORCPT ); Fri, 9 Jun 2023 03:29:55 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84FCC2D7F; Fri, 9 Jun 2023 00:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLN7xKcE+hmgG5UwW7HXoONAvSQZ43bWKZ6Oe7lF9kR9U+j4/f0xwltVs4oECxrAhOlBTQVbrWBbi0ArszoGC64Mdbo5SRfGoLeR+KNPR428tu8mRXq/23kdLdTUTysvZVGUXbsTdK906+w/+inI4OctfhL2nVZjFL49FYRoYfbRF4iL2oZ3QDsVCbd8j0+nDWhkSvX+k4cmhVypy5AnCL6C48lZuRKhWmpuSceOecNoUbQfOkkUiXM0vckcflt+l2bMXfJX3WF9xBjJ+2+sLtqSPh9OOcbfC7ZWpMlbvhKAb8Xkj5majqyheDNIHRtVFHm3WRZfSfEXxSxqwsaKww== 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=kS47+VWF7plcjJrQqiMe6eoziGUpBc8BpsIj7V5A+pk=; b=AhZHW9V07VFgtjfhqD4yCvuFGIxCBylGfSI2gNk5M9Vcy7mIgjTmXl4mb08Q3qYWE20rX5tlTitBGCsV/f+8ykMwfZpO54jriLIt8iMu2HoCHW7Gy4My6PpAE74r48UcsBIuk0YKO/CQLccMs3FX7mxJXOmW4Szt5WKCcsz5BGKNhhgVSh+Ba7tnqwl3K2fhFJ1imkaZyQhNCXKgCOfymzz0AFhVddgt4pj9Trad/T+EoiHxoCwOuNXru3MLTmOpSng/KRzCf7Pw6+KvE+JB/45ks6eOaetDVP25/lD9Xk9/5MRRYeULDZCj1XjFEFvYxasgKmEXb1PaWq1vED5Qfg== 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=kS47+VWF7plcjJrQqiMe6eoziGUpBc8BpsIj7V5A+pk=; b=ur4/Td+qFYC3a6y1nNOUeEYmXFTNXS7cHvnejQ645SvyAP8GKsrbeIix3iHaOwse9QPbrLeH2Yac80qFODdC+WLmsmPH3vZhA5WEsHSvfp+NyFq82U2eXMMwNPzB0LJON8ZXpXvDE/f1Gth5l8CkuHpK0qHtaNgYmIXMeA35R00= Received: from DM6PR08CA0008.namprd08.prod.outlook.com (2603:10b6:5:80::21) by DS7PR12MB6215.namprd12.prod.outlook.com (2603:10b6:8:95::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Fri, 9 Jun 2023 07:29:37 +0000 Received: from DM6NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::35) by DM6PR08CA0008.outlook.office365.com (2603:10b6:5:80::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.26 via Frontend Transport; Fri, 9 Jun 2023 07:29:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT085.mail.protection.outlook.com (10.13.172.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.25 via Frontend Transport; Fri, 9 Jun 2023 07:29:37 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:29:29 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V2 3/7] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Fri, 9 Jun 2023 15:28:42 +0800 Message-ID: <20230609072846.1552238-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT085:EE_|DS7PR12MB6215:EE_ X-MS-Office365-Filtering-Correlation-Id: 41d12b73-ae6d-46fa-aa2c-08db68bb47ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xXjP9xKvs4hUSH4R9ADETvhlBnJAXYfovmizC1NFpFZZZtt5w9mp41l2uVQtk9w7dAegvXNbWzaO3nWOhG+IZ/D9T0j2St6vAESxg6jH5SVDYJ1XigYQPJuhx5ihxweeMy6uY1Agns/f9BMymtjinL/9dQpaDj+7ExZVYtvwdBuPXLvv1tRWTqbCUqnEpSW+iKk9/uOSu4siG66i09zGVP9loUCxnJH/i73tIP+E7iQzvP9ZnOgCnTg3vhABZNTe59cYLO1xP7wnGKmsg7uV/aB4QiofEzLtAyJnN/HDRSlsPd/j5x2m7jXSmMmAak88g5tAG+FNJhcRh+tEaHP1pzZOKDw3mwlcnj1/AMmNvb2Idy6kDMhJiYnTbkJ/wFt+8aOQlyx8geNx/B4wkF/HpIbxWJYhyNmkmV/S5Jn0686f1FiJTm5RT8yrVZeFjtQPURaMD23743WJKbZkJnKnpdVb7rs/LPR5NVe2Ee+XhQPsAR0cCdPToeuJdkWY68Z13gUK2CWZ85R806wfLTjFUBJ6O3d8HbKxPMAKYRTwgQz+/LTTeR9nly59tBnxjzvLaxqtZ0JUj4f2sYsdJRyTZSlvQHeIqlPJWhJFeOmtrpxtzXZp9eQYJXBfnkmZCJQDhJQPlTztI+O9SjMU/rFkJGNnjimqmy8SCfXlpDWzTiSqfcpd2Hfb6cBf2asx0wy+j3kaSiOi71lLT1TqvTckRGghmLSq4u++wZmBE/tVETXJ3huXUopNG5NX2OkkW2+YHm8ZitBhgOVP7eOPvQR0iAZoPCRzSj5Z+vPiDHi6J9Q= 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)(15650500001)(110136005)(54906003)(36756003)(2906002)(82310400005)(5660300002)(40460700003)(336012)(426003)(44832011)(7416002)(7696005)(2616005)(40480700001)(86362001)(6666004)(478600001)(41300700001)(47076005)(1076003)(356005)(921005)(26005)(82740400003)(36860700001)(316002)(81166007)(70586007)(70206006)(4326008)(6636002)(186003)(16526019)(8676002)(8936002)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:29:37.7338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41d12b73-ae6d-46fa-aa2c-08db68bb47ef 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: DM6NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6215 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?1768209486870409836?= X-GMAIL-MSGID: =?utf-8?q?1768209486870409836?= Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan --- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 14 +++++++++++++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 14 +++++++++++++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 3 ++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h index b686fb68a6e7..d64188fb5839 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h @@ -388,6 +388,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1592,7 +1603,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h index 4c46a0392451..77483e8485e7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h @@ -392,6 +392,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1624,7 +1635,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h index 10cff75b44d5..c98cc32d11bd 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h @@ -138,7 +138,8 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 //Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1 diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h index 6aaefca9b595..a6bf9cdd130e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h @@ -134,6 +134,7 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 #endif From patchwork Fri Jun 9 07:28:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp771962vqr; Fri, 9 Jun 2023 00:32:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UMCClGpSiPA8XCoDttYqSQiBqHaLEOOt1K+atvYwwORyJ/XGmWuAl/cuKuxjLFONJXdG9 X-Received: by 2002:a05:6808:bd1:b0:39c:6a30:cc88 with SMTP id o17-20020a0568080bd100b0039c6a30cc88mr1129755oik.23.1686295976468; Fri, 09 Jun 2023 00:32:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686295976; cv=pass; d=google.com; s=arc-20160816; b=apU2HGVHbXAaa/6BWOYDiycjUZXRfk9XtXmiQAJgT+Oqxp1gtbKWn+4HvwVx1Ptuyf Sme8k0JJdwe3Q45EHYKsWFyu0M3mICRyUJeVwNG/WRMmCYKebHtJ8+iDS/DuLe5l1Evd Qf3pvnSndBmenJjRM20SO4X9ormO46fCCaQeBUFG46PUgMEys5zKHtSV/jBZNQ6WUsW9 6r5A5wRFBlKzrCrM7lRXTt/zvbOSFDJRAMH9VfDuwFcfpceYo3k8Vwf81dTnSNJSooZE ZEAfXFusYblGbWbyg3ZBXok/aTjePN2sc0z8rskqWd5KrR5b1tq6rDsqrcpinzD4hJJ9 ZHZw== 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=5Cxmbpsm/4sUmxmXjFAyn1x8zoUJQHaEi9+50JKULWM=; b=MwJaXCDhdNPxS3Kdd3jsPG7MPXP6KncqQVLqqIrO+fZpgflMClhpq4qV5yG+9RwZ4x QfT1jo8YUfXnj5szPEP/307Ci9BzAK/byePSYQvEmi1Ao+wK9SuB3sRprTpIZKZb3JlI /EcaV9m6YBsbyV1zoIP68qW68Qd4NUfAvVIk8o0yOZoQ34pwA7nqAJHB8CGJT+peq+DL 3xDxp+n2EzOGk7bp1Hh0fZp0ES0BcX2Q2XhEEQVuD4YqfoD8tgQGp+WL2lh0adasyg5X AyiWjsQJluoj+zdqayWkfUVc8T499M8g2c+pgP3GZI65V6WtQ0SxaL22Rx3liPfgr4Ak gyUA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rnMyYQ1S; 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 q188-20020a632ac5000000b0053fc9f253basi2186592pgq.403.2023.06.09.00.32.43; Fri, 09 Jun 2023 00:32: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=rnMyYQ1S; 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 S238011AbjFIHao (ORCPT + 99 others); Fri, 9 Jun 2023 03:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238820AbjFIH34 (ORCPT ); Fri, 9 Jun 2023 03:29:56 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2084.outbound.protection.outlook.com [40.107.102.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6AC130CB; Fri, 9 Jun 2023 00:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LHFg8UYLaILZtkPi/+xWHWqrjW/j0vgJmt21dghpPiM41FzbberavDoDZk3flsDKqcm4LRSDmkU0knSrRRojg8+kZNnpzHwb2SeNBUwBTUu0Vs0Tjie2uguI2Yp35LpkQqlvxkY8H9KWuVmo7ryDfrTKPg09R6Lh5O0DotJtCrcsKhry8zIVrHskfW8au1RWfAOl+mS3J0MFc1OtntVZVQnukVuqpNdcR77nqnBHgPvKosLhdJvrN/q8kuTnZuXQuB0aw610M98IQjFvAbQQ/2SJaf1nSYOHswRITvASm4beuu0Ney9f/PNg7K33Dls26V0ZuKDkmUzs4exkOheW0A== 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=5Cxmbpsm/4sUmxmXjFAyn1x8zoUJQHaEi9+50JKULWM=; b=YYpHxAocHzzoQibwPoLv2Qg9UqmNaZrkZ6FjHDSSeEknOeVS7Jiz7dibLRO1+JRJhpTPvRMwgUGHPTWZ4xb779FT4Vh/Qm1zUpwrYukCrg9qACPwpaTcGIxE9ViH2FuOz686TyU4VAzEQkFpRuGbqD1AyKvxZ1MDkC8KGUaNJdyWOPbXfcBmYmGkZTxYUJGGdDv7qv/AkBSrekMiXOpm/Ka2MqGVJ9TzKUcuCx8cRgH0DRbpUH1/y2DaaYM6peY43QPFYIyA0p42Vku2uXeeUwd6AeSndyeP7EYLSNSXY191s49/zJ5o53m+RMnf9fOwBp522PEmG6ZPtV+/iu4yYw== 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=5Cxmbpsm/4sUmxmXjFAyn1x8zoUJQHaEi9+50JKULWM=; b=rnMyYQ1SaNvb5uTgd5VisqpzCFngD/flHDBqIeiWuqbXpdEu0gGmUF6SJzabJ8VgUdYWBtgTSNhp4QffCCKRqOQ7w7u3jaF0fdOt9yozHRXvqImPndoaS5komvdADX4P8a07PvKAs7JQyAgcW9Z56Zknxb3pw1THoYcyl5Ex05E= Received: from DM6PR05CA0050.namprd05.prod.outlook.com (2603:10b6:5:335::19) by SA1PR12MB5658.namprd12.prod.outlook.com (2603:10b6:806:235::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.38; Fri, 9 Jun 2023 07:29:43 +0000 Received: from DM6NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:5:335:cafe::a7) by DM6PR05CA0050.outlook.office365.com (2603:10b6:5:335::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.25 via Frontend Transport; Fri, 9 Jun 2023 07:29:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT081.mail.protection.outlook.com (10.13.172.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.23 via Frontend Transport; Fri, 9 Jun 2023 07:29:43 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:29:37 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V2 4/7] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Fri, 9 Jun 2023 15:28:43 +0800 Message-ID: <20230609072846.1552238-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT081:EE_|SA1PR12MB5658:EE_ X-MS-Office365-Filtering-Correlation-Id: 504fb5be-e2ba-45b0-ff98-08db68bb4b39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZNZJ7DLMLsYbBR/JmFypW+bBaB7RkwzkPE0fTFILnNtY/W37u7kVYwwceddCpEVqie3eZm6aoPwy7UH9qC5AriYUVqq8Nz0PAe4VTjrrqaTwwIcbTWI0I4BGAFb7+G3UqfmNApJ9lVCmwrYsPVX7v85y3o/9h/yJDsc8ajdOSpZk8UZEB0TYAxz7tBkRw7qBqRoOuevliZ9rZR+wLepGqrSOtvALs6/depp14wKACXR6fipmPxbB8x3MsurSHq9Pu+RazRzJzr/BKwLQzCOUbqCTvifda6Tfnlwmk+1kfOG1ON6DhRAd3wmCUipzjbdJOdt0d++neD5yf5xEdyp59pUzRb2aMh+fPOmkuS6W21Wz5WmGa1DC1ID768n05bZfRbZMARNxnz4WFb6aS8cttRF5ndo5vC+m2Gvq3XP/bQGE00foPvraytdSudFt+vjBRXMPQuD6drjuKn9EdcmDlNryffnGJwcFUHgYjEw0A0wdgpZaEvG8BnBAtYeZ/CpkNtv9ZKGYE72zt5lawGixoG1Q9k/pF9rmt7L3osBzkV42QBZHtXp34iIluq7MTE6QSJZ27sH7wlQ0zkFN2atC1yiUvOE/gfNaqcWALm+NJ8u8iGqqkzG7WwOlEozTXbnD8qwdO8xVMdzQXI0hGkRTIXaEEHhqxiIUfnXdJ2285DFXpKbe3iE55dh2K3J7YpUyJwDlANBbRoDOPxmEvp/Q0zbOjwQJSIlRB/cyg+yhCLAVmasTnNVAo8KSIJ6YfKvjSSRHmZ9XPWZ8u+EnPR0fYJj+pj9HuYT4tq9aQMRsO+007VIxH1WwkbP9CeB21Pzp 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)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(7696005)(316002)(40460700003)(41300700001)(336012)(426003)(2616005)(82310400005)(30864003)(86362001)(36860700001)(83380400001)(1076003)(186003)(7416002)(16526019)(47076005)(44832011)(26005)(2906002)(921005)(356005)(82740400003)(81166007)(40480700001)(5660300002)(36756003)(8936002)(8676002)(70586007)(70206006)(478600001)(110136005)(54906003)(6666004)(6636002)(4326008)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:29:43.2541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 504fb5be-e2ba-45b0-ff98-08db68bb4b39 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: DM6NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5658 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?1768209489420197926?= X-GMAIL-MSGID: =?utf-8?q?1768209489420197926?= 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 --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 26 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 63 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 19 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 184 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 20 ++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 6 files changed, 315 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 02b827785e39..2f2ec64ed1b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -241,6 +242,7 @@ extern int amdgpu_num_kcq; #define AMDGPU_VCNFW_LOG_SIZE (32 * 1024) extern int amdgpu_vcnfw_log; extern int amdgpu_sg_display; +extern int amdgpu_wbrf; #define AMDGPU_VM_MAX_NUM_CTX 4096 #define AMDGPU_SG_THRESHOLD (256*1024*1024) @@ -741,6 +743,9 @@ struct amdgpu_reset_domain; */ #define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size) +typedef +void (*wbrf_notify_handler) (struct amdgpu_device *adev); + struct amdgpu_device { struct device *dev; struct pci_dev *pdev; @@ -1050,6 +1055,8 @@ struct amdgpu_device { bool job_hang; bool dc_enabled; + + wbrf_notify_handler wbrf_event_handler; }; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) @@ -1381,6 +1388,25 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_state) { return 0; } #endif +#if defined(CONFIG_ACPI_WBRF) +bool amdgpu_acpi_is_wbrf_supported(struct amdgpu_device *adev); +int amdgpu_acpi_wbrf_retrieve_exclusions(struct amdgpu_device *adev, + struct wbrf_ranges_out *exclusions_out); +int amdgpu_acpi_register_wbrf_notify_handler(struct amdgpu_device *adev, + wbrf_notify_handler handler); +int amdgpu_acpi_unregister_wbrf_notify_handler(struct amdgpu_device *adev); +#else +static inline bool amdgpu_acpi_is_wbrf_supported(struct amdgpu_device *adev) { return false; } +static inline +int amdgpu_acpi_wbrf_retrieve_exclusions(struct amdgpu_device *adev, + struct wbrf_ranges_out *exclusions_out) { return 0; } +static inline +int amdgpu_acpi_register_wbrf_notify_handler(struct amdgpu_device *adev, + wbrf_notify_handler handler) { return 0; } +static inline +int amdgpu_acpi_unregister_wbrf_notify_handler(struct amdgpu_device *adev) { return 0; } +#endif + #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev); bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index aeeec211861c..efbe6dd91d1a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -1105,3 +1105,66 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) } #endif /* CONFIG_SUSPEND */ + +#ifdef CONFIG_ACPI_WBRF +bool amdgpu_acpi_is_wbrf_supported(struct amdgpu_device *adev) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(adev->dev); + + if (!acpi_dev) + return false; + + return wbrf_supported_consumer(acpi_dev); +} + +int amdgpu_acpi_wbrf_retrieve_exclusions(struct amdgpu_device *adev, + struct wbrf_ranges_out *exclusions_out) +{ + struct acpi_device *acpi_dev = ACPI_COMPANION(adev->dev); + + if (!acpi_dev) + return -ENODEV; + + return wbrf_retrieve_exclusions(acpi_dev, exclusions_out); +} + +#define CPM_GPU_NOTIFY_COMMAND 0x55 +static void amdgpu_acpi_wbrf_event(acpi_handle handle, u32 event, void *data) +{ + struct amdgpu_device *adev = (struct amdgpu_device *)data; + + if (event == CPM_GPU_NOTIFY_COMMAND && + adev->wbrf_event_handler) + adev->wbrf_event_handler(adev); +} + +int amdgpu_acpi_register_wbrf_notify_handler(struct amdgpu_device *adev, + wbrf_notify_handler handler) +{ + struct acpi_handle *acpi_hdler = ACPI_HANDLE(adev->dev); + + if (!acpi_hdler) + return -ENODEV; + + adev->wbrf_event_handler = handler; + + return acpi_install_notify_handler(acpi_hdler, + ACPI_ALL_NOTIFY, + amdgpu_acpi_wbrf_event, + adev); +} + +int amdgpu_acpi_unregister_wbrf_notify_handler(struct amdgpu_device *adev) +{ + struct acpi_handle *acpi_hdler = ACPI_HANDLE(adev->dev); + + if (!acpi_hdler) + return -ENODEV; + + adev->wbrf_event_handler = NULL; + + return acpi_remove_notify_handler(acpi_hdler, + ACPI_ALL_NOTIFY, + amdgpu_acpi_wbrf_event); +} +#endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index b1ca1ab6d6ad..bf82cc192153 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -191,6 +191,7 @@ int amdgpu_smartshift_bias; int amdgpu_use_xgmi_p2p = 1; int amdgpu_vcnfw_log; int amdgpu_sg_display = -1; /* auto */ +int amdgpu_wbrf = -1; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); @@ -948,6 +949,24 @@ MODULE_PARM_DESC(smu_pptable_id, "specify pptable id to be used (-1 = auto(default) value, 0 = use pptable from vbios, > 0 = soft pptable id)"); module_param_named(smu_pptable_id, amdgpu_smu_pptable_id, int, 0444); +#ifdef CONFIG_ACPI_WBRF +/** + * DOC: wbrf (int) + * Enable Wifi RFI interference mitigation feature. + * Due to electrical and mechanical constraints there may be likely interference of + * relatively high-powered harmonics of the (G-)DDR memory clocks with local radio + * module frequency bands used by Wifi 6/6e/7. To mitigate the possible RFI interference, + * with this feature enabled, PMFW will use either “shadowed P-State” or “P-State” based + * on active list of frequencies in-use (to be avoided) as part of initial setting or + * P-state transition. However, there may be potential performance impact with this + * feature enabled. + * (0 = disabled, 1 = enabled, -1 = auto (default setting, will be enabled if supported)) + */ +MODULE_PARM_DESC(wbrf, + "Enable Wifi RFI interference mitigation (0 = disabled, 1 = enabled, -1 = auto(default)"); +module_param_named(wbrf, amdgpu_wbrf, int, 0444); +#endif + /* These devices are not supported by amdgpu. * They are supported by the mach64, r128, radeon drivers */ diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 2ddf5198e5c4..89f876cc60e6 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1188,6 +1188,163 @@ static int smu_get_thermal_temperature_range(struct smu_context *smu) return ret; } +/** + * smu_wbrf_handle_exclusion_ranges - consume the wbrf exclusion ranges + * + * @smu: smu_context pointer + * + * Retrieve the wbrf exclusion ranges and send them to PMFW for proper handling. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_handle_exclusion_ranges(struct smu_context *smu) +{ + struct wbrf_ranges_out wbrf_exclusion = {0}; + struct exclusion_range *wifi_bands = wbrf_exclusion.band_list; + struct amdgpu_device *adev = smu->adev; + uint64_t start, end; + int ret, i, j; + + ret = amdgpu_acpi_wbrf_retrieve_exclusions(adev, &wbrf_exclusion); + if (ret) { + dev_err(adev->dev, "Failed to retrieve exclusion ranges!\n"); + return ret; + } + + /* + * The exclusion ranges array we got might be filled with holes and duplicate + * entries. For example: + * {(2400, 2500), (0, 0), (6882, 6962), (2400, 2500), (0, 0), (6117, 6189), (0, 0)...} + * We need to do some sortups to eliminate those holes and duplicate entries. + * Expected output: {(2400, 2500), (6117, 6189), (6882, 6962), (0, 0)...} + */ + for (i = 0; i < MAX_NUM_OF_WBRF_RANGES; i++) { + start = wifi_bands[i].start; + end = wifi_bands[i].end; + + /* get the last valid entry to fill the intermediate hole */ + if (!start && !end) { + for (j = MAX_NUM_OF_WBRF_RANGES - 1; j > i; j--) + if (wifi_bands[j].start && + wifi_bands[j].end) + break; + + if (j > i) { + wifi_bands[i].start = wifi_bands[j].start; + wifi_bands[i].end = wifi_bands[j].end; + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + } + + continue; + } + + /* eliminate duplicate entries */ + for (j = i + 1; j < MAX_NUM_OF_WBRF_RANGES; j++) { + if ((wifi_bands[j].start == start) && + (wifi_bands[j].end == end)) { + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + continue; + } + } + } + + /* Send the sorted wifi_bands to PMFW */ + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + /* Give it another chance */ + if (unlikely(ret == -EBUSY)) { + mdelay(5); + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + } + + return ret; +} + +/** + * smu_wbrf_event_handler - handle notify events + * + * @adev: struct amdgpu_device pointer + * + * Calls relevant amdgpu function in response to wbrf event + * notification from BIOS. + */ +static void smu_wbrf_event_handler(struct amdgpu_device *adev) +{ + struct smu_context *smu = adev->powerplay.pp_handle; + + smu_wbrf_handle_exclusion_ranges(smu); +} + +/** + * smu_wbrf_support_check - check wbrf support + * + * @smu: smu_context pointer + * + * Verifies the ACPI interface whether wbrf is supported. + */ +static void smu_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + smu->wbrf_supported = smu_is_asic_wbrf_supported(smu) && + !!amdgpu_wbrf && + amdgpu_acpi_is_wbrf_supported(adev); + + if (smu->wbrf_supported) + dev_info(adev->dev, "Enabled RF interference mitigations\n"); +} + +/** + * smu_wbrf_init - init driver wbrf support + * + * @smu: smu_context pointer + * + * Verifies the AMD ACPI interfaces and registers with the wbrf + * notifier chain if wbrf feature is supported. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_init(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + int ret; + + if (!smu->wbrf_supported) + return 0; + + ret = amdgpu_acpi_register_wbrf_notify_handler(adev, + smu_wbrf_event_handler); + if (ret) + return ret; + + /* + * Some wifiband exclusion ranges may be already there + * before our driver loaded. To make sure our driver + * is awared of those exclusion ranges. + */ + ret = smu_wbrf_handle_exclusion_ranges(smu); + if (ret) + dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + + return ret; +} + +/** + * smu_wbrf_fini - tear down driver wbrf support + * + * @smu: smu_context pointer + * + * Unregisters with the wbrf notifier chain. + */ +static void smu_wbrf_fini(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + if (!smu->wbrf_supported) + return; + + amdgpu_acpi_unregister_wbrf_notify_handler(adev); +} + static int smu_smc_hw_setup(struct smu_context *smu) { struct smu_feature *feature = &smu->smu_feature; @@ -1280,6 +1437,15 @@ static int smu_smc_hw_setup(struct smu_context *smu) if (ret) return ret; + /* Enable UclkShadow on wbrf supported */ + if (smu->wbrf_supported) { + ret = smu_enable_uclk_shadow(smu, true); + if (ret) { + dev_err(adev->dev, "Failed to enable UclkShadow feature to support wbrf!\n"); + return ret; + } + } + /* * With SCPM enabled, these actions(and relevant messages) are * not needed and permitted. @@ -1376,6 +1542,15 @@ static int smu_smc_hw_setup(struct smu_context *smu) */ ret = smu_set_min_dcef_deep_sleep(smu, smu->smu_table.boot_values.dcefclk / 100); + if (ret) { + dev_err(adev->dev, "Error setting min deepsleep dcefclk\n"); + return ret; + } + + /* Init wbrf support. Properly setup the notifier */ + ret = smu_wbrf_init(smu); + if (ret) + dev_err(adev->dev, "Error during wbrf init call\n"); return ret; } @@ -1431,6 +1606,13 @@ static int smu_hw_init(void *handle) return ret; } + /* + * Check whether wbrf is supported. This needs to be done + * before SMU setup starts since part of SMU configuration + * relies on this. + */ + smu_wbrf_support_check(smu); + if (smu->is_apu) { ret = smu_set_gfx_imu_enable(smu); if (ret) @@ -1583,6 +1765,8 @@ static int smu_smc_hw_cleanup(struct smu_context *smu) struct amdgpu_device *adev = smu->adev; int ret = 0; + smu_wbrf_fini(smu); + cancel_work_sync(&smu->throttling_logging_work); cancel_work_sync(&smu->interrupt_work); diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 09469c750a96..ff0af3da0be2 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -573,6 +573,9 @@ struct smu_context u32 debug_param_reg; u32 debug_msg_reg; u32 debug_resp_reg; + + /* data structures for wbrf feature support */ + bool wbrf_supported; }; struct i2c_adapter; @@ -1354,6 +1357,23 @@ struct pptable_funcs { * @init_pptable_microcode: Prepare the pptable microcode to upload via PSP */ int (*init_pptable_microcode)(struct smu_context *smu); + + /** + * @is_asic_wbrf_supported: check whether PMFW supports the wbrf feature + */ + bool (*is_asic_wbrf_supported)(struct smu_context *smu); + + /** + * @enable_uclk_shadow: Enable the uclk shadow feature on wbrf supported + */ + int (*enable_uclk_shadow)(struct smu_context *smu, + bool enablement); + + /** + * @set_wbrf_exclusion_ranges: notify SMU the wifi bands occupied + */ + int (*set_wbrf_exclusion_ranges)(struct smu_context *smu, + struct exclusion_range *exclusion_ranges); }; typedef enum { diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h index ceb13c838067..67d7495ab49e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h @@ -97,6 +97,9 @@ #define smu_get_default_config_table_settings(smu, config_table) smu_ppt_funcs(get_default_config_table_settings, -EOPNOTSUPP, smu, config_table) #define smu_set_config_table(smu, config_table) smu_ppt_funcs(set_config_table, -EOPNOTSUPP, smu, config_table) #define smu_init_pptable_microcode(smu) smu_ppt_funcs(init_pptable_microcode, 0, smu) +#define smu_is_asic_wbrf_supported(smu) smu_ppt_funcs(is_asic_wbrf_supported, false, smu) +#define smu_enable_uclk_shadow(smu, enablement) smu_ppt_funcs(enable_uclk_shadow, 0, smu, enablement) +#define smu_set_wbrf_exclusion_ranges(smu, exclusion_ranges) smu_ppt_funcs(set_wbrf_exclusion_ranges, -EOPNOTSUPP, smu, exclusion_ranges) #endif #endif From patchwork Fri Jun 9 07:28:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp772682vqr; Fri, 9 Jun 2023 00:34:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NAFP8RueBy1JPkJ+wCuw8iSnUPXYfImfmK2f+li7OYGf2Ucyx6fQty15ud3k/F3D+EIn1 X-Received: by 2002:a05:6808:128a:b0:398:2b10:d3cc with SMTP id a10-20020a056808128a00b003982b10d3ccmr1121833oiw.31.1686296087276; Fri, 09 Jun 2023 00:34:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686296087; cv=pass; d=google.com; s=arc-20160816; b=x1iXRT++8r+rYIuDvbIIdTeNzkAQwgA6V+FBatT3vQ5bF5AMDvzBo/nLIeOj5+u+ss 4vg4QxbT+puMorTisXeyqSWKSmYsw3k+22lxVxIq2Hh68KjjKJLwuw30viQFMxNZ1oj5 /5T6wsTjEoFDw/OEKYvUciNybpPaFPCB3kDp3Cc2hM8aIRfXILyphkp90uG86G50yWkW Wt5jG90qa1H4DTa6fGNb71qXv8OJnZOvx4NxbL2wrCyo4OfDg1kA3uX6nV8i+FuyuFQy E3snWnMhGKYhKk97eDiY1meB5mIgHabqBburSdQIuGPreYMDUAVt7y6jOYDa4zqNrA36 q7Vw== 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=w2vAmDKr5lEouUGHRYcDaTacr7hNBq+6N/BBGVsYBsE=; b=gcU4q8pc1Zd5tgD2H45E1xoLuWxDCM1mY1C4Ml9Ydhsq5Uilxvz+buQL3RI8x5xjCB /HvWq1fbSorZB9cCfLnvLwWgURPEUxYXkGSkAjN7HqX+AfcD52oHSSaIJ1JWYbpnrshB 9GSOM5rw0FOh5DMRQM8wrKI03PbNf196JsD5/SzKo/8u3+Uo0v9slc9q5wpavFwFiBz0 VjTigUYxcHzG37+bBjJzYcr8uvyFseti25XsOFCGrFJBvZPdXd4A2OHCG5bhvDScdSr/ o2IIMKWfe8SiAhIx1BQq4/CkwdgfsqW3fjzqAEuoBhDHd2tUxtn4yVIzyZ7ho3B4tkuM RPtw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=nelv98gH; 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 b3-20020a62cf03000000b0064354230c2asi2013801pfg.367.2023.06.09.00.34.33; Fri, 09 Jun 2023 00:34:47 -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=nelv98gH; 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 S238871AbjFIHav (ORCPT + 99 others); Fri, 9 Jun 2023 03:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238844AbjFIH36 (ORCPT ); Fri, 9 Jun 2023 03:29:58 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2087.outbound.protection.outlook.com [40.107.243.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6178B30E5; Fri, 9 Jun 2023 00:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QDF2P/3wRZ/a2eTt7g3KFdxx+NTUvCiUjc9vpBJ2g/N7/49mbXolBP1TPQJgBXkWm+jfe3fJBEeHDc/RuYF1orW/B1A9QuPfHii5O6qvo0hN0SF2poAv3QKJDJJtKNIhRDl3gOkFc58CVqhXqW09ScUNSwsYzHiyinSYe3VJedpF6/dheMsL3LvjrOG0v5KDpaWQjkxVa82zYnnlO4TjT3I1G+ekp0iqMqVTRtHtrm9aLAbTjnOU9FTXPiQGk8EIDdAPu4eH9ROHlfF1ID4ycQIy/9ay+CUyqS0tj68vxGbqQNrI33setV5Z5mJgB45LFO5rBo2vO4Wsi2gGDQcMOA== 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=w2vAmDKr5lEouUGHRYcDaTacr7hNBq+6N/BBGVsYBsE=; b=UYSJtrLgwTwYwP4MPe2Z90u2gRiJ4t5IQHWo5JnG76KtZ4C2gpx4X8B+CHDI7rJCzycCohtE01yMmigPx12hO5eKncPupt/UCbB/n9kluxxj3KxB/yuvpWv5AI1XtLrTLENUv1Y+WDMm8zZ9ISWr33K/natLHAnW0NxGrUf4AnleHI1+uDIs30nHluzswaHMAlHi+sQte2FTE9hO0ESk+kwBp/XE8ALKNN6b9vNEudA0P1DeAciNGBF65QL2ct6kVRYneKhVPokQXdpueeRIX/VEIdCYYi2q6clx3I56FfwBnpwbA0N+F+YvK2Y2Pd+qSdfIKjhMRxmSUHHRcuguXw== 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=w2vAmDKr5lEouUGHRYcDaTacr7hNBq+6N/BBGVsYBsE=; b=nelv98gHG7t1rK7adMgSIgnCER5IWjPo8wsS6hhgJQC0V3u99+tLzhIkGxRbj0fIkC/176y+2kocsrEORIVeFm9V4I8pgcIR4a8YEKXR2PHH1FF3xEzOFHU16DT2G0KPJ+Msm/lmdoaCi+MOQofyjFvMcvYuzLizn0wgufeSrkQ= Received: from DM6PR08CA0005.namprd08.prod.outlook.com (2603:10b6:5:80::18) by PH7PR12MB5950.namprd12.prod.outlook.com (2603:10b6:510:1d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19; Fri, 9 Jun 2023 07:29:51 +0000 Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::61) by DM6PR08CA0005.outlook.office365.com (2603:10b6:5:80::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.27 via Frontend Transport; Fri, 9 Jun 2023 07:29:50 +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 DM6NAM11FT039.mail.protection.outlook.com (10.13.172.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.27 via Frontend Transport; Fri, 9 Jun 2023 07:29:50 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:29:44 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V2 5/7] drm/amd/pm: add flood detection for wbrf events Date: Fri, 9 Jun 2023 15:28:44 +0800 Message-ID: <20230609072846.1552238-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT039:EE_|PH7PR12MB5950:EE_ X-MS-Office365-Filtering-Correlation-Id: 66a400b8-8dba-43a0-9679-08db68bb4fb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WDY133QC64MqTbuDNoF38fOdgeEipzRxW+rrvjU7cyjPk+EAR4XzyFTl3bRjnLAgXnmaOBYt9DmtSKdAG3mqPQ4HCUmH6sSVsr0br2Wb01KnfDBEjdNkD4tWdkuXsY7c97fMnegrUuYzTOhr0hWgCNIrlNn4ZV1zD+OzaxDtvyxueQSTfI+k3Fa8zsOwCWifsUL0vZqmBc9BCZgp3y6C7HYpujbnhVoV5GAcDv3pP3boikGEpTwaQk/3erreCwLcHV70P8skuOop4YH9ofCcjL6Jata65iDJ9UkmworO/JcQ43P2gi6/4zy/t/5+JkS1WFYQpCDfNbgWJ79mqC1xb9JrFCouGvRG9MTG5yN/Vn8xlMBi9nQgA5MF8HVD/T0c8wkLAOg1HtzOBM3MO8JQyUUxynNw/2K90dtsaJ+WMoWn5kgyqMb9OLrm/hlU5bKRy7JwmqVih5uKTu8SeSWnCJ78z4rMtZAyuXOSse2sW/fANoP+4cN6gQBK1hH9q0S4r2Vgg7JdP3QOa94Qx80Qyf9ggy3R1fBFBDfl2MwuLJiJPGFYLv7BLJ3ku2JnyoPTRWRvN88jyEwHvtUh+yJMLco3bI+21RDMIcZ7XAhWKiXKfawzlxPikXSBaioph7m5kchhqg2mtpVTjghdtWn/IZ3fsR4v7LbP4VsKEZbLzXRVP1Ca44pV8Gpgx3iGFYtf0cXaDhP8/jY1MeqC7rPyEzdq0xDYK2U46qhmcMSHnwkLnJo+4I6qd1bqERvV2v6FwHqlP2reSISKa97Wq02f+eJw6PMyuaNxnTC4snbkqys= 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)(346002)(396003)(136003)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(478600001)(186003)(1076003)(26005)(36860700001)(83380400001)(426003)(336012)(47076005)(2616005)(40460700003)(40480700001)(7696005)(8936002)(316002)(8676002)(86362001)(82310400005)(41300700001)(82740400003)(70206006)(81166007)(36756003)(921005)(6636002)(356005)(70586007)(44832011)(7416002)(4326008)(2906002)(5660300002)(110136005)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:29:50.7749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66a400b8-8dba-43a0-9679-08db68bb4fb5 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: DM6NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5950 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?1768209605816224699?= X-GMAIL-MSGID: =?utf-8?q?1768209605816224699?= To protect PMFW from being overloaded. Signed-off-by: Evan Quan --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 28 ++++++++++++++++--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 89f876cc60e6..2619e310ef54 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1272,6 +1272,22 @@ static void smu_wbrf_event_handler(struct amdgpu_device *adev) { struct smu_context *smu = adev->powerplay.pp_handle; + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); +} + +/** + * smu_wbrf_delayed_work_handler - callback on delayed work timer expired + * + * @work: struct work_struct pointer + * + * Flood is over and driver will consume the latest exclusion ranges. + */ +static void smu_wbrf_delayed_work_handler(struct work_struct *work) +{ + struct smu_context *smu = + container_of(work, struct smu_context, wbrf_delayed_work.work); + smu_wbrf_handle_exclusion_ranges(smu); } @@ -1311,6 +1327,9 @@ static int smu_wbrf_init(struct smu_context *smu) if (!smu->wbrf_supported) return 0; + INIT_DELAYED_WORK(&smu->wbrf_delayed_work, + smu_wbrf_delayed_work_handler); + ret = amdgpu_acpi_register_wbrf_notify_handler(adev, smu_wbrf_event_handler); if (ret) @@ -1321,11 +1340,10 @@ static int smu_wbrf_init(struct smu_context *smu) * before our driver loaded. To make sure our driver * is awared of those exclusion ranges. */ - ret = smu_wbrf_handle_exclusion_ranges(smu); - if (ret) - dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); - return ret; + return 0; } /** @@ -1343,6 +1361,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; amdgpu_acpi_unregister_wbrf_notify_handler(adev); + + cancel_delayed_work_sync(&smu->wbrf_delayed_work); } static int smu_smc_hw_setup(struct smu_context *smu) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index ff0af3da0be2..aa63cc43d41c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -478,6 +478,12 @@ struct stb_context { #define WORKLOAD_POLICY_MAX 7 +/* + * Configure wbrf event handling pace as there can be only one + * event processed every SMU_WBRF_EVENT_HANDLING_PACE ms. + */ +#define SMU_WBRF_EVENT_HANDLING_PACE 10 + struct smu_context { struct amdgpu_device *adev; @@ -576,6 +582,7 @@ struct smu_context /* data structures for wbrf feature support */ bool wbrf_supported; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter; From patchwork Fri Jun 9 07:28:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp773034vqr; Fri, 9 Jun 2023 00:35:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YGnsg6+mrdnPYkWZOuD/KglQObCyslKEOKLzKjZO4iSWiqoA8m41qQaFaTaJ+KTj7R99S X-Received: by 2002:a17:902:b702:b0:1b0:26f0:4c8e with SMTP id d2-20020a170902b70200b001b026f04c8emr313226pls.69.1686296142536; Fri, 09 Jun 2023 00:35:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686296142; cv=pass; d=google.com; s=arc-20160816; b=Ol1sL75XVfOIA6AJ4rPQin12kakYNkMlKSiyXDPWerE6L0LiN6FPptwhZ+BTUlSMam i3VPAOwbxhzI4bRDyg3LTRHVk+F+yRbS9G/Jq64h3RhYlZ+Bbz/OUPZg/r9E1859GYCF dRNVrwsVPu82A8huz6PnKF9d8vLv6WeJeUZ6QX/vYevu8NDbzb2T/P76+47hQuZo8fu2 O6h7NSq0gl7ofJfNadXAU6gZZjtL3j9/+ezBQyRphR0z7f7p2qGqGmMtnoHOwVLwTbJ7 tG3PjKRKrHqhiCRFbCIyUyhQG7h09+qrwJrd60oyH47kT+zQO8RQ9vbFbBLGGhAf4M2Q w4Zw== 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=3TpqsnmXQ/as7v7o5Su1sHZlEz2ArTZf4xL5W0EvPxE=; b=GTUTnt7KAF6zWtWNL4P0eYNUj9wxfn7vkYTJeyzAJjNwqnVIE3og3wwJwtCS5msku8 POHrsRW3nXpIFhp3NQGZpl9ksut4iSGFToMKOpPM3V8BTdZG+Ws8MHIFbrMb8LwRc9m7 Hg1ryGupjrIWnOJpUcGs3tgi3YUJYYc5kPyTEP41wtI4cHeTZOFLJXtc0xEM5Mdk77DG iMHyYZSaIqf/gm4TXNFASvzyexH/13dYSSEA0PGGP6j2QVomgL/w/QGHlHLakWvPINyD 4/E9U17u8LLD/tXYmkXjqQEx4j3pVKXbgZfUL8Gm6b1loJUbNroXgyJfEyiEQFg9N8Ab VO0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ce4gjlts; 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 l13-20020a170903120d00b001aaf1734d1dsi2298300plh.241.2023.06.09.00.35.29; Fri, 09 Jun 2023 00:35: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=ce4gjlts; 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 S238874AbjFIHa5 (ORCPT + 99 others); Fri, 9 Jun 2023 03:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238866AbjFIHaC (ORCPT ); Fri, 9 Jun 2023 03:30:02 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA48A2D7B; Fri, 9 Jun 2023 00:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HjfWEUWqqToXd5wLTQJqoc6f4EG6BzxxnFQDgBv56U1e1MuFWd7cBg1LddTGah7kjAq9xhSVepgxxixdgxI5KjnwKiq+voPY9i8KacuyxiCDSUYBSAdqxfU2d/tLmoJgxCWZW9Eva9iLhL8/oUmHGgchoCtPusEOZLIwJN1dvRYuuN2czzYguIgDMkAnaeVpD0G3VKtKPv0RWkUnHgnWU4QywoCMvAmD3E0KcpBjRMnViUzLF/Y7yA2zViFkiiTUnBYabaC4nnkToVgh5AGtj/MGsAKduZ8TAjim1TNVOBtYLn6QFsUrSgBGxGe+zHY9TaokhStS0xYRk1kDkZfEyw== 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=3TpqsnmXQ/as7v7o5Su1sHZlEz2ArTZf4xL5W0EvPxE=; b=I7x4v/W53RIpTjKLbmkzdLA61XWR+spsKwhgNMi0+k3frxwhdEP8v3VkqWBx0+cDHv7kZyL/bVR7/HiVYTrswLl6MggPB2ovBzeuLNrQp6YIdCJBiQTDrr3VZchrm7Uk0SNPyCsJ4xYEmCLkx9Yt6Nfsi+DrieTywrfSo7BjPjucV755Q3v1onNcEgD77U1/FWUIsEmH2fK7fsmlEcjT8Pq5WM9vKl3DJbulCrRrhfrecV1hW8mwUraBZJ8oWvw3lWIPlZXrIGgjxRw+MKOZWf04/UU8/DxYCFM2ooW/Yg4P8sMkJcYRvAXMI6Q3g8S2/cJnxPruMmIzLbzWnUlguw== 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=3TpqsnmXQ/as7v7o5Su1sHZlEz2ArTZf4xL5W0EvPxE=; b=ce4gjltsLssu/ua9E18JnTHKW+7Nm+/815mxBMR85bqCj/mF5TQ1Snd1PhBm/clDiDiZn/WTFH4X1Aw3ix70j42f2SnSlgHLgrgXWsQwH/b7QBc59S+Du3N9AeR604W3Qmo7ZlSQu+pN2USaVZQ2SHaoezj3xZ4n1ra5zSwrQnk= Received: from DS7PR03CA0262.namprd03.prod.outlook.com (2603:10b6:5:3b3::27) by PH7PR12MB8054.namprd12.prod.outlook.com (2603:10b6:510:27f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 07:29:58 +0000 Received: from DM6NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::e7) by DS7PR03CA0262.outlook.office365.com (2603:10b6:5:3b3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.25 via Frontend Transport; Fri, 9 Jun 2023 07:29:58 +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 DM6NAM11FT048.mail.protection.outlook.com (10.13.173.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.27 via Frontend Transport; Fri, 9 Jun 2023 07:29:58 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:29:52 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V2 6/7] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Fri, 9 Jun 2023 15:28:45 +0800 Message-ID: <20230609072846.1552238-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT048:EE_|PH7PR12MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: c3d03a05-e96e-490f-175d-08db68bb542a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TSE55qVMaoYWcumQ/Lgi0i6NiqNbwq2iiqS1VeUTmgIrR9NdTBkcam4wL211Y9GhSPBsZIRWScqJpdqXHUqh2Kc0w1eLR2tcglUYROXsRhlbvNuygxUi6daaDWxeyXNYGn8InGWVq+2a240K6zQCtDXdYtuebniH4dATileX+w4SM+eNsPghTsPw6v2JKq7x5UP2ATLpuPpvf8pqwAeJdh4s3dkZcAKhKuJ2KtaxQB6ROsZiOpJoQRpTG/ZYz4yuv1Hc6I4z6IxDyG9hwBhWnTzHbFvDbIwlXjiQCUy+tykTh2KCwYD0yZWTEGmkgIgPhjxirZBEHPM7ZxoRiNShQepIVECGAE9NpE3dwnZxU9GPsjbDaybFhNkEvJ+Bm//uLyUd0x44BJjuQ/xbp1WWu4kZs0Maq3JePbL1WxSxqXn3HT/nXXTspCTg7z7GGBM3VUXNuHf7LmV9FQnzTFu3o5j7g8QbWLWNnAlgikU1yiKE9XhG+tWgH/X6HiNAL1AabIJ1sp1EhnX5FNcRs3yd4Ln6+F34a1VOwAzon8gymPeRjgEA9YaYD3Ew0pr91dVxaWNLskJcRgoqR091HrHUMb0TCcMdPZaMLoYEFQ/Jk6SeWnKsgWjGpBajWAngrf0Fwiv731OzYjbS/ZO+slGMqdoRAush4Ych8WFjL1HDoGy/btlUeoITMd601coCPwFsJ2kv556yd6ZrfSmal2fF+nkqghs7ppREPspugAAthBYoUIiaySPm+WsXdYO/nuo5Hw2t3pjTQKzow0TCVtc8QBa8QVTnoKXJ9xj55BP8+VY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(39860400002)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(186003)(1076003)(26005)(16526019)(2616005)(82740400003)(426003)(336012)(83380400001)(47076005)(7416002)(6666004)(36756003)(7696005)(54906003)(44832011)(2906002)(82310400005)(36860700001)(8676002)(110136005)(40480700001)(478600001)(8936002)(6636002)(41300700001)(316002)(40460700003)(5660300002)(4326008)(86362001)(81166007)(356005)(921005)(70586007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:29:58.2649 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3d03a05-e96e-490f-175d-08db68bb542a 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: DM6NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8054 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?1768209664056419969?= X-GMAIL-MSGID: =?utf-8?q?1768209664056419969?= Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan --- 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..46000039e511 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]) { + /* PMFWs supporting WBRF feature are not yet available */ + case IP_VERSION(13, 0, 0): + case IP_VERSION(13, 0, 10): + return false; + default: + return false; + } +} + +static int smu_v13_0_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + 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 Fri Jun 9 07:28:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 105314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp773755vqr; Fri, 9 Jun 2023 00:37:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xLKRjqSeTY1vnHi4jnQvVeUy6pBatHJkHBITnKP9u7OYCl+94pcgMaHEF9uzc8/KoEFWX X-Received: by 2002:a05:6808:1586:b0:396:3969:a4a6 with SMTP id t6-20020a056808158600b003963969a4a6mr1028283oiw.18.1686296260481; Fri, 09 Jun 2023 00:37:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686296260; cv=pass; d=google.com; s=arc-20160816; b=bU5C8zvb2AyJEx0eApIvW5lRQc2q7Ontwwty57PX8jhTcqXMCPyvGKE/apGG0/pzq3 oYTTt7uV+4wXsWi7v28roiPiDnmYUTNsSc2r6SyQ9fyXnkS0UT7iGgGm2RWTt5l7UdR0 hlSe1l8Yh1mNo4hpAEQBory2V0F1Vojg2dfRq93PJchefKy2En882sLNuBZGOgQ9bJUO lszAR24tAWTfrobqrKORdSEvI82QgtNyByavPO7MdvCZeJHdwQhlHNRjtVsbJNOlQVfC OyEyc99IwERvPMvH9kYVChbap3T/TEGncgb60iQdgFU0JEpb6RZMejK6TLa8QLWXB07R UjUQ== 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=uE+bqOMK/vEPNCeadJJAJvY4Ncouei1S5fSDGvN5UTc=; b=k2N9kO+Nb5wqsselvm2TWztDPveOZgVyQFGiZZ9JqtRKyxUTg+s5yVi3ejzcqqucJ9 IVyvBDMm24MYpjyibKc2qKwppYr6MUirzGNsY3lvl7Mvp4leA/0vzCGO5Iwl4Rl1RoWQ u1VPFb/2ZdcPXygFze+UrGBX6UuYWvgkS1M6UoG7sTnCicDVKhWVQz1DUVr4ANtI32PB KpkCMrXXhlbglwnlwNw/qEXUIqmB5eEGZ7FK376OZr7/qPOIdGXbT5ytjvAHoZd71O7z xCd5Ou1dU8sPyzraoirmJeEg14DdCrLJ3YO7SZi1be9hcHjy1KOzT2o/a38BYkMEgUO9 X6iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0k5lNsoC; 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 p10-20020a17090a868a00b0025378fb1538si2233451pjn.41.2023.06.09.00.37.26; Fri, 09 Jun 2023 00:37:40 -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=0k5lNsoC; 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 S238882AbjFIHbA (ORCPT + 99 others); Fri, 9 Jun 2023 03:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbjFIHaP (ORCPT ); Fri, 9 Jun 2023 03:30:15 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2080.outbound.protection.outlook.com [40.107.92.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC2E72D7C; Fri, 9 Jun 2023 00:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eck/539/p9gwoyh67uhEHJS7jz7uQpxlwmt0sJiMiUmYzOjz4LV2LShsULAryAboJhgPgeEjUmr8GIC2XWU5HtHpaU/knOw4nsZad+CodMkohIdm4MNsnRYrpTWkF8nX8j74XUF6a+RMheJs6ChS8+gVEQUsazD8mb+pmu2gYTvETSeIe2MEnb/NeLtfnzruWr1uyNwd3bcGCqK8b8xRMpVykM6NpFu40SC5UBTpJ3DNMTJow3zyilPWdgLmCW1wEumJE34XqmvmNz13UJ5yKbeWU4ioitSYrW9ldCfU2Oa1cWDSd2jmGoUYX5E1BK9cCtQKTa4i8OD+cvU1k1yoaA== 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=uE+bqOMK/vEPNCeadJJAJvY4Ncouei1S5fSDGvN5UTc=; b=PEDIzQa4JElJZc9k/8f3NiXug5RHXJ/GuQ867rh8RTpqru8ym29aheu631xsZE8m4fU05jL4ktjx36TKboQlMs7H3BLjXHJDYkTQkjEv67e0Y0gGMmifBd28QWzxWpMIlKjQAOSTGI8+ctsEpdBgBZryi17dZRAzSAQT1UqaVvhwWQaHMLHBZZLbhE0JAYIj+Uo8SvpIGaJM4xY7aWyYXqkRSF6DDnqZX6Jc94kGNq9OVcKBWGZFZItnAAZDyoBNsvCB5S8lzdEpz0qdNwUySrt4RZptuNi353Cew1eYelO19BX1eVSO+I4IHSp78jSZ3IvNO+YYRUYmMXJQAD/kDg== 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=uE+bqOMK/vEPNCeadJJAJvY4Ncouei1S5fSDGvN5UTc=; b=0k5lNsoCul58dPrwU/0ieId2VCt2vGFfyD3a4PTckM4Bmnr81ps3WOuv+SgCw1CQKK66JOA5GI5Ge9l8NAdKlMm4df0QP/ecHCdiGi8NAmfFoRvOBNgjvWBcY7RthLhWFsgWcp1c7GnbIwJ2/ByGvrUOV/KuMjj1JSkeB+TpEZQ= Received: from SJ0PR13CA0107.namprd13.prod.outlook.com (2603:10b6:a03:2c5::22) by DM4PR12MB5118.namprd12.prod.outlook.com (2603:10b6:5:391::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 07:30:08 +0000 Received: from DM6NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:2c5:cafe::a0) by SJ0PR13CA0107.outlook.office365.com (2603:10b6:a03:2c5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.14 via Frontend Transport; Fri, 9 Jun 2023 07:30:08 +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 DM6NAM11FT026.mail.protection.outlook.com (10.13.172.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.27 via Frontend Transport; Fri, 9 Jun 2023 07:30:07 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Jun 2023 02:30:00 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V2 7/7] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Fri, 9 Jun 2023 15:28:46 +0800 Message-ID: <20230609072846.1552238-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609072846.1552238-1-evan.quan@amd.com> References: <20230609072846.1552238-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT026:EE_|DM4PR12MB5118:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e262760-0f3a-49d1-d095-08db68bb59cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qkZpucXjhVuvXAjZObZBWp6Ri5XIuwFQKgRzOmzxwThkoTbf302Hb7KHXlQwtUi5m2WSQiJLJRl42/9O0he54doW1UVWFcnqI+Y86ppEz8M4gmz4qZLgpxBrrEKzCsagsyzXBW5Pt0fyO8ZFGwAr61LczBQuY4twt9XCt4kk2v+P2eAYP5a8e/OCA93eu7M1CFsRTy6gTy2rj0FGdfNCVkKK5p2+mRDVv0EteBH6A+V71/5wYvbkqfP+S660//ARlc1apVRny9qGNvvl+LP4aLf9hqLjtwdSQl5gSHUKlzBTTP6H8WSFgIxaqpmEUyKFp7vAkthLfVpyrQrd/Jww9SdTnKRFfXLf+6Bwx9N3/CngeUzZoDUQDbo1443bOM4+e6Yo5UMQ5pDq1E9qqqoTuOKwJ8Lnb/DrOOFP9pzhr5tUmlaSxC8mAvBt28PIeesny/Jj+k0K6aCn8hXLLO8hKgdg1yWdEXmvDDkfGlGZbFCzhKXZ2ziPGYnbQz7CH6vrrFTiFAz6drh9uOe1fXOSdB2J45nMLugzTzPDr9SZFpONDHIDJ5lEg9Ol/tKEHeJHUCRRaXI9kJcPjq0xC/VRX3SvFoO8SiYOLJZxRpH26/Bgvn5BMY5vFPiHpg2f1txk2LVg3VjQL6rOhdY5Wbvi7lyFlrxe6dClnqlJJX5QazvFogXInLc+CXHgPb/S8evheKIbPCazVbkyfQ1h/eU0ytpQWeZm5WlzzBnwyVRAk0PtVX3RMa+tkIWK61pJ4QOA6r8KHJrDajynNST9lFPm9qbzhuFzsQZJ0zyqiZ9EJ9c= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(26005)(426003)(1076003)(40480700001)(5660300002)(41300700001)(16526019)(186003)(82310400005)(7696005)(36756003)(47076005)(7416002)(36860700001)(44832011)(4326008)(70206006)(6666004)(70586007)(83380400001)(336012)(8936002)(8676002)(2616005)(110136005)(478600001)(54906003)(316002)(2906002)(86362001)(921005)(356005)(6636002)(82740400003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 07:30:07.7043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e262760-0f3a-49d1-d095-08db68bb59cc 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: DM6NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5118 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?1768209787476209348?= X-GMAIL-MSGID: =?utf-8?q?1768209787476209348?= Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan --- .../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)