From patchwork Fri Jun 16 06:57:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1138292vqr; Fri, 16 Jun 2023 00:05:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5nr3PKg/8U+A5ygvO/2pNTDI/0gmtnZOVLwQf0kX+sh4geskhOy2SEpfLncNzzTgn0tms0 X-Received: by 2002:a17:902:d4ca:b0:1ab:29bc:bd87 with SMTP id o10-20020a170902d4ca00b001ab29bcbd87mr1073956plg.35.1686899143633; Fri, 16 Jun 2023 00:05:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686899143; cv=pass; d=google.com; s=arc-20160816; b=knFbTcdDlLBivJNIvc1A1xpWzio8a6M4NF1EU0YG6v/aThvc8xg9XC4773frd8+bPP M7qRR3a57RFPMq1L6w3MFRWhKjCfvPyTARUxQnPesR6teZiwrKd5wFhWxaC2hWPZ4H+b +vAzdY4padkiomBX/E0DOOWM0GOVbQfvSvleWOjGxsGInYusLsCCWd7b+srcFv5iuqS8 7CxNZfbHMAXsYcJx/OPv6orWbV1UXARVeBy+owEgXMpEEaY6IEWEbHZGM5cojZwrdos1 eiJLkD4lYe1hzEBajHwTcMd6TFGWUjPgg/ex906GB6SSB1KPxs8vozQAg/rISNvlr8/3 p2FQ== 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=MdcTlCAOjEchP32LOGHqFe4d5NRhSfnA8C6DaVNJEvN7ZREVv2p5p1dQGA35GxPzHf mZCCWieI3uK3vJbRbbNSa/9DEMP/t5TgI02x/Mf2ECw0Rso/D0aEjVOwzDPM6ItknFSF wKUhJ0CAxss8cU9PumlwQ+4WAELRDdpS7LxQnvdbneJ46LEVZX+EhmVS046TnE+TzmTG 1kbFP2RhPxdrKL1/nC2RHmM5tfJkRim/arOrYv6Y+RFb38z8CUYMrDz+3RNH0AwB9xgg Zy6Z1Q97mX/AMMWpvSsaksZ60MFisS0SlK+7A7JJXQ7eXayUYVeY+vIBmOEWmrnXckaW OXVg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=jgi19+2a; 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-20020a1709028b8600b001aafec82436si11129501plb.204.2023.06.16.00.05.27; Fri, 16 Jun 2023 00:05:43 -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=jgi19+2a; 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 S240822AbjFPG67 (ORCPT + 99 others); Fri, 16 Jun 2023 02:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241277AbjFPG6w (ORCPT ); Fri, 16 Jun 2023 02:58:52 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03DAA1FF9; Thu, 15 Jun 2023 23:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TpxU4zgazYgcuETsYgFCUxndAaY3pViizzeHuabLmPk96VeIi86MNs8o2AjR/1LNk/JQxhxTuaZpvDurpiXZzYp9n5tJv2+arxteFTcoQbbG18eGb3MuWO81gaF133H6BUSSguOjpLu4V0Y2ZwH/J8aE1EQtnHvQ66u+gHf8+RRXeQy5cfyHsVQ2g66nrF43mcv779uFAXd4UoRACXx5A+5AuJt8ZQiIkfqWKqwhyBp3+4K5Gz3wVDRyziIZpPbEAapiVdhrR5DWIpGLq7FNKgJz7hw91SlLe1/s6UXMPuzvAEmkayYA6E8xm2Rd0VA92brRgMTpsEfqfksFZvxWog== 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=YqwokyWv2KygSW8S6wa8GVbhOcfbXSDk3UqTicxq/jVFv7TSo/DDcDywyUyN5trRHf3iTakMm/0Hgg8bt6ZuVD9JCpKL2SNv5lnQ8PvWANb8x8Dw6JX3sRQLsjZ1xfbrNqYgfdNkpgOpPGohDWGVvFYevCLf39FcCsMsxm0sCVK/uktTptx+cW4gBBwIbXFl28hsap7Y0WH3yQ5R+/YMysI3Jn29MNejNPyWTD6XrLWJ1+IRZZOOqInBDNLSLk8cCpyZ7Z8/NiTfCtRyeDsS2RFFRVIJY9rRvPR3qQ/fV5dTjSgFXEspNkxy9TYFQKIdlfmRBzqHdVOUu6phtSR7iQ== 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=jgi19+2an94ghwMBvPw5NyTg1bykIlUKdOii9M7AGi74+tRA5mtWOKkmxIVaOI666bgajP5SY5Zv7RBmLV+NiMyuPbQ19hvfnHBp6rG1oXCTAkLIld0Gw+NWV5usLpwVHUFEg3SD0I6HWqKvmfYaU0PcOWedLZ+va6r10xs9o1s= Received: from BN9PR03CA0540.namprd03.prod.outlook.com (2603:10b6:408:131::35) by DM4PR12MB7526.namprd12.prod.outlook.com (2603:10b6:8:112::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25; Fri, 16 Jun 2023 06:58:48 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::7e) by BN9PR03CA0540.outlook.office365.com (2603:10b6:408:131::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:58:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 06:58:48 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:58:42 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Mario Limonciello , Evan Quan Subject: [PATCH V3 1/7] drivers/acpi: Add support for Wifi band RF mitigations Date: Fri, 16 Jun 2023 14:57:51 +0800 Message-ID: <20230616065757.1054422-2-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT056:EE_|DM4PR12MB7526:EE_ X-MS-Office365-Filtering-Correlation-Id: 0af414bb-2e43-4d6e-dda7-08db6e372289 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yESEjQO1l3tuVIUVJdWd8fCnyBPAi6aiWq9r44dhwC7QSkotJI/JQQkU2Xyav0DxKa4ZETSiRtzPsNJfYcCD7gzrDRvnz7N94/JuURrPliWS3sRHaTLPGs1YPsdO/MegBrgQzi5xFeHof6uQCUr1Xm+sMBVIUlP2dMC0wzPUqxCTcNBM7gNLxVLLO+frAT9xy+aT0ecLvd876UCAonFnMU75R/Y+E8bPYuV6KZg41eYnl1kZZGd7SVxoCDC7Q2JcAq3XusHyewdMYd+xD4URadEVwhk7aQr2aMt7k3J3Pusp4iIhQbsp71IISpNIivh0KTDw9LqPJnZ52aF6w1ILoLw/2uDfp/y9P4u70er2k4iw675MEw+xbyeRhMrbyBW1h7wv+Vv9xOvH/D58yhc97kf8GAf6a5x92RhPmGqjATE45MRtKtgjbXC6+CMj0AMIHr9VCsg532+RC0cJKSZhjozXYhlvL+wc0sGLLkbYWdfk+klt5NX4L/aLuJhLNDRsBXF7D2dAan21a8+IyB54ENDzF9+Vch8fU/eJiaIEFY1fPwfv3h3/L3ZAq4l2uGkk3klZOCyoQIOEJTM2pcxSqOwqTLlvB/V3zwhd3L6QmWx3kJ0urvGAfEUMF62Tk2/ZuZiTYlaSrwuX5clUxCi3aSWFGtmsBUSI7+i+UyIH3TEtAuk6jiibAzBiL8uDf0Je2vcFunyR57yihdWyPiSKljyvhrjYbshc64o5eV8ArPRh/4niW1FLA+EmFu9lnXWPgAVAYoooI5bOnI9RNPci+dxFzJ4iRhgLLmvWgljYEOg= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(82310400005)(478600001)(6666004)(6636002)(4326008)(36860700001)(8936002)(110136005)(5660300002)(8676002)(54906003)(41300700001)(26005)(7416002)(44832011)(86362001)(70206006)(70586007)(7696005)(316002)(16526019)(1076003)(186003)(83380400001)(426003)(2616005)(2906002)(40460700003)(336012)(47076005)(40480700001)(36756003)(82740400003)(81166007)(921005)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:58:48.4305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0af414bb-2e43-4d6e-dda7-08db6e372289 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: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7526 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?1768841956305607629?= X-GMAIL-MSGID: =?utf-8?q?1768841956305607629?= 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 16 06:57:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108889 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1141414vqr; Fri, 16 Jun 2023 00:12:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LXbPERDMUnhKE/tsSEE0zF+4spJIbWT/P2k/PS9DoChdZBWTMU+DP43BrWJl2gCoJiLQx X-Received: by 2002:a92:c60a:0:b0:33d:1735:fd79 with SMTP id p10-20020a92c60a000000b0033d1735fd79mr1692027ilm.20.1686899534566; Fri, 16 Jun 2023 00:12:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686899534; cv=pass; d=google.com; s=arc-20160816; b=Ki6amkFecFeGYbulDEpg5W1qDcVgUm5NgZL02j3P9e5E5ogr/nYeaGJSotAboe9y4G 1OOM2vlO6r6A42c8P+NBMQeQOHlcvYkydQFMhHqes/7IdiH90hzYht0yq19OzlwK19M5 oFvkdNzHrThw6XEkhiPGjAUu5izHAAbC4s7ktPkjJLqqD90GFSM6lczaHrhDkzE0CJSG 5ch+gjohR5mTNdIgjyXHj4SG4jSXcVLNwbHeGPpXMmGhBg0jSpIZ00lJpMabe5NdfwYQ Mj3Ly1HjxeX7DfwcwjFZ2Pne1NMoxkOcGTIQuNlZNg8dreAFVQJNCuWPmQLnGuQvQDhW Iz2g== 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=d+6jQuEYLGrZR/ujVS8LA8GFLexxjeUFqmVpzlOBpTI=; b=dK7JKiSvYb20C1WYzmC2urynLD1/aQkMR6znrnsjbyFLzR289T7N9F52WFCwfTIMgL RvPUUambvK60ziiyo7BxIlS3jCyv0mjh1BMYR1vrTqrwlf1OfSGQ+B+wdZDAVlIbF9KD ZDfSz+AsI5KqGhwbGBSl1piyB45Q+zSCCehG8j2GBW9qfV6x64LLckiM3tqU7P+xiQZi 21GeWles282q/5DY2QnWP+vBtud/1Xfz6FYwxvMHuv++tcX3EeKnyl6A/HegonlH8l6C n3/kdpI+LedpQinaOzmPhE0NA2ohhIfStOU+Fdk4E4YCzSTdqoxtF6WbZJwVSU6rlUkl sFEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=RBNE1bIn; 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 z22-20020a637e16000000b0054fd4d7d642si5215129pgc.4.2023.06.16.00.11.59; Fri, 16 Jun 2023 00:12:14 -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=RBNE1bIn; 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 S243117AbjFPG7X (ORCPT + 99 others); Fri, 16 Jun 2023 02:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242794AbjFPG7O (ORCPT ); Fri, 16 Jun 2023 02:59:14 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2066.outbound.protection.outlook.com [40.107.223.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6A4268A; Thu, 15 Jun 2023 23:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gLaxa5IQ6OyHMSPNSbD8ZwUa4w3mWxcjYeQ6UuSArACUSv4H4H/bitKLJuBRhMhWFNB9WD9JI4FS6oW5ypMIq3ez/zHnxmbI7k0HuDyuyW4GjkfyFNQbErOFYY71ZDXXLTCEGjpJzvdG7OF3vgdHhnSOH9GXccE9lmbgiVKaxxRT81YRLiAUQza1Wm7lG4oab2daIz5Bcu4X6HwJVCAs2FgaW3i1gM9JCxrZEG0y82a1lFBKNvIciKKpgxNGJkwFrJY/c+knw9AgrdYgT/6f/9a0oBZ1ZM33l5ls2uQxNqpLDQpps4Iqakaw8DqMGtDdcHFlQtpxmKWs2MFMaeA7gQ== 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=d+6jQuEYLGrZR/ujVS8LA8GFLexxjeUFqmVpzlOBpTI=; b=B7oVpGbXB1cCCc+ZPFXwh62ypQwqDeUN4MQ7/mDE5fOXbinL5w+6Kq5ekJ/VWczGLY7dCOE5B7qq3ywFBiQvb/9VrD7k9FPVKknLEfFHPGJGbBvzBCrTIUiiwIta8C11mIFmSlHTzI0yi2xvQMfxc2giCTuhBYQ7x9AP1NkbdBGniPxt0na6AouqQwZzFH5NxGEaVF+3R4e7BL2RNnMTAafOCahhkkF77kZOoQhIw/ilkHkoNHzfGyMzS1RFVVFfHvIa88p9ggTZWiuGvFI8jNxcbbEuW3+FkTseJ4VTYNVi6nBC0x0/Nkx5pEDX1V/pLDHqchLv3edhu1OuGNY4Nw== 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=d+6jQuEYLGrZR/ujVS8LA8GFLexxjeUFqmVpzlOBpTI=; b=RBNE1bInT9D3A36ONdYW4kSpLRb1p1zrGOMq3Nla3bOcyXRfbqRvXPE/cvFKGfXOTIxiUZOYrcKakQuS+9NMKO7Cre4V4iW+QRreQIppadb0LbkT2wCP25g3LELSHLiPkfIBFi6XtXrjeGIf7SzPg1jFdSxxGzETHFwBwQmzkYY= Received: from BN8PR16CA0022.namprd16.prod.outlook.com (2603:10b6:408:4c::35) by MN6PR12MB8490.namprd12.prod.outlook.com (2603:10b6:208:470::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 06:58:55 +0000 Received: from BN8NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::8b) by BN8PR16CA0022.outlook.office365.com (2603:10b6:408:4c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:58:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT106.mail.protection.outlook.com (10.13.177.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:58:55 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:58:48 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Mario Limonciello , Evan Quan Subject: [PATCH V3 2/7] wifi: mac80211: Add support for ACPI WBRF Date: Fri, 16 Jun 2023 14:57:52 +0800 Message-ID: <20230616065757.1054422-3-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT106:EE_|MN6PR12MB8490:EE_ X-MS-Office365-Filtering-Correlation-Id: 20c6e550-01ce-43b9-0d14-08db6e3726d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mEaMSC/8/I8uHcec0RT74Imr5oyU1MTEhWvpgtSMjBMF1vxnANQ3IE+fHH/U688mzf1/t7qQhrkobHaD0wYrd/5ixOfgroOeU3kIlwOHyPIwYMf+rQdD/DzazyRZq9mScIElUGijvXFItwXZ+XPhJnzdhFG+6pcWj6ZlqBrWuoj20NSLEdNewBxQw8pOM9BiY6TaEAXhWvPyrb2Dlc+bgu+E0Vuiy3d7PHrROuD9p7BOMByWJdmmfgWwUKBjuBZY3wKe6SUqhTcUfbItE1mtQsGr3o/54mmYkUGb7VTf0mPxxOM8f9wLjd8RjU1pPrRJq/goLmIxAiEqM5cTpEh4hELevZBesEhCpH/3ytxq6v/fikNDV7CRSo8Tzdu8dHHwKT549ckQT1/RgQh5iRf79us7+A120nalf+M5ooSoIJErAwJm/ni/eaGhOceG+pTgd6f2C9p6/yLXPcBBvrEHsY4qYX5v9Ly+LXjD6EKMsZmDS4e3H1vB/IS1iILpHl7Ns0jCZNKxvzfgMT+XeoJTfNTm/bSO1f9xPDmtkl3XoorIbOeAYAJ40mrrNm3a4CXqhSDsjdkT8t/7JVhEwkhhap//eng6eZy5QzSsAjrUWnw8QBsvkuO/xEiQSu09OzDzuoTyXYIC7gEnfzGIbEFa9gr1JOAguZKrqR2gGiJ39RnkswoGZk+a+Bcufuing0+EP1qxZUrD3W/f8NcT0qerGwMeFh/ho+dClF8cOkSWpS+zd/XXF+f/d/f7qdSe+NFS2AFmb75VtOb7cDtjHHYoax0vg09GDjDWP876u3ZdI+U= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(39860400002)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(26005)(1076003)(186003)(426003)(336012)(16526019)(2616005)(36860700001)(40480700001)(83380400001)(47076005)(40460700003)(110136005)(478600001)(82310400005)(54906003)(356005)(921005)(86362001)(82740400003)(36756003)(4326008)(41300700001)(70586007)(70206006)(6636002)(5660300002)(316002)(2906002)(6666004)(81166007)(7416002)(8676002)(44832011)(8936002)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:58:55.6563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20c6e550-01ce-43b9-0d14-08db6e3726d6 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: BN8NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8490 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?1768842366160629479?= X-GMAIL-MSGID: =?utf-8?q?1768842366160629479?= 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 --- v1->v2: - place the new added member(`wbrf_supported`) in ieee80211_local(Johannes) - handle chandefs change scenario properly(Johannes) - some minor fixes around code sharing and possible invalid input checks(Johannes) --- include/net/cfg80211.h | 8 +++ net/mac80211/Makefile | 2 + net/mac80211/chan.c | 11 +++ net/mac80211/ieee80211_i.h | 19 +++++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 137 +++++++++++++++++++++++++++++++++++++ net/wireless/chan.c | 3 +- 7 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 net/mac80211/wbrf.c diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9e04f69712b1..c6dc337eafce 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -920,6 +920,14 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** + * nl80211_chan_width_to_mhz - get the channel width in Mhz + * @chan_width: the channel width from &enum nl80211_chan_width + * Return: channel width in Mhz if the chan_width from &enum nl80211_chan_width + * is valid. -1 otherwise. + */ +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width); + /** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index b8de44da1fb8..709eb678f42a 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -65,4 +65,6 @@ rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) +mac80211-$(CONFIG_ACPI_WBRF) += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 77c90ed8f5d7..0c5289a9aa6c 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -506,11 +506,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local, WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef)); + ieee80211_remove_wbrf(local, &ctx->conf.def); + ctx->conf.def = *chandef; /* check if min chanctx also changed */ changed = IEEE80211_CHANCTX_CHANGE_WIDTH | _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); + + ieee80211_add_wbrf(local, &ctx->conf.def); + drv_change_chanctx(local, ctx, changed); if (!local->use_chanctx) { @@ -668,6 +673,10 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->chanctx_mtx); + err = ieee80211_add_wbrf(local, &ctx->conf.def); + if (err) + return err; + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -748,6 +757,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, } ieee80211_recalc_idle(local); + + ieee80211_remove_wbrf(local, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index b0372e76f373..f832de16073b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1591,6 +1591,10 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + +#ifdef CONFIG_ACPI_WBRF + bool wbrf_supported; +#endif }; static inline struct ieee80211_sub_if_data * @@ -2615,4 +2619,19 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); + +#ifdef CONFIG_ACPI_WBRF +void ieee80211_check_wbrf_support(struct ieee80211_local *local); +int ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef); +#else +static inline void ieee80211_check_wbrf_support(struct ieee80211_local *local) { } +static inline int ieee80211_add_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { return 0; } +static inline void ieee80211_remove_wbrf(struct ieee80211_local *local, + struct cfg80211_chan_def *chandef) { } +#endif /* CONFIG_ACPI_WBRF */ + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 55cdfaef0f5d..0a55626b1546 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1395,6 +1395,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) debugfs_hw_add(local); rate_control_add_debugfs(local); + ieee80211_check_wbrf_support(local); + rtnl_lock(); wiphy_lock(hw->wiphy); diff --git a/net/mac80211/wbrf.c b/net/mac80211/wbrf.c new file mode 100644 index 000000000000..2e1a58cf4dbf --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Wifi Band Exclusion Interface + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include +#include "ieee80211_i.h" + +#define KHZ_TO_HZ(freq) ((freq) * 1000ULL) + +void ieee80211_check_wbrf_support(struct ieee80211_local *local) +{ + struct device *dev = local->hw.wiphy->dev.parent; + struct acpi_device *acpi_dev; + + if (!dev) + return; + + acpi_dev = ACPI_COMPANION(dev); + if (!acpi_dev) { + dev_dbg(dev, "ACPI companion not found\n"); + return; + } + + local->wbrf_supported = wbrf_supported_producer(acpi_dev); + dev_dbg(dev, "WBRF is %s supported\n", + local->wbrf_supported ? "" : "not"); +} + +static void get_chan_freq_boundary(u32 center_freq, + u32 bandwidth, + u64 *start, + u64 *end) +{ + bandwidth = MHZ_TO_KHZ(bandwidth); + center_freq = MHZ_TO_KHZ(center_freq); + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in HZ is expected */ + *start = KHZ_TO_HZ(*start); + *end = KHZ_TO_HZ(*end); +} + +static int wbrf_get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in *ranges_in) +{ + u64 start_freq1, end_freq1; + u64 start_freq2, end_freq2; + int bandwidth; + + bandwidth = nl80211_chan_width_to_mhz(chandef->width); + if (bandwidth < 0) + return -EINVAL; + + get_chan_freq_boundary(chandef->center_freq1, + bandwidth, + &start_freq1, + &end_freq1); + + ranges_in->band_list[0].start = start_freq1; + ranges_in->band_list[0].end = end_freq1; + + if (chandef->width == NL80211_CHAN_WIDTH_80P80) { + get_chan_freq_boundary(chandef->center_freq2, + bandwidth, + &start_freq2, + &end_freq2); + + ranges_in->band_list[1].start = start_freq2; + ranges_in->band_list[1].end = end_freq2; + } + + return 0; +} + +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 ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct device *dev = local->hw.wiphy->dev.parent; + struct acpi_device *acpi_dev; + + if (!local->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 ieee80211_local *local, + struct cfg80211_chan_def *chandef) +{ + struct device *dev = local->hw.wiphy->dev.parent; + struct acpi_device *acpi_dev; + + if (!local->wbrf_supported) + return; + + acpi_dev = ACPI_COMPANION(dev); + if (!acpi_dev) + return; + + wbrf_remove_exclusion_wlan(acpi_dev, chandef); +} diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 0b7e81db383d..227db04eac42 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef) return true; } -static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) { int mhz; @@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) } return mhz; } +EXPORT_SYMBOL(nl80211_chan_width_to_mhz); static int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c) { From patchwork Fri Jun 16 06:57:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1139265vqr; Fri, 16 Jun 2023 00:07:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Xr5/ZHc/xVncaWIscFNuyz1LVN5IS58WEHUeS4Y3aWdSK2Ddg2M/sgBLrx7T37hknh6MA X-Received: by 2002:a17:90a:f30f:b0:25e:b5fa:9eea with SMTP id ca15-20020a17090af30f00b0025eb5fa9eeamr1151920pjb.17.1686899260508; Fri, 16 Jun 2023 00:07:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686899260; cv=pass; d=google.com; s=arc-20160816; b=tS6l0Ejsh5QVG5SoeLmx9vD2b466WTI8WzggPOwrEdK/kW1yyMMs+gdlPDnItnAtk5 rE3hO+avBdttY4ZV2bPRVQnXOqoVD6iqBSLB0RjuhckChK9m+ksKN8jcvt8BEzqsxTgs c9YMMRNQ00Y+t8EWdK2/14/HD90S6CX8vyzbfqYziB0ho5UD8qjMuUm7xaRy3/pbrOiE pgaeL98nv5KiYdoXtVftS1DsBRVUjZnYzLaVHneviU0v0iWD3PiFtxyq+ji+PJYSrBm6 m+AK1c3C6JkjRXHG7thBphThZ4B3xzOWHMXT8buoelgQoODx+Hm0xxjsxyPIeriqyZWW WUBQ== 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=UIRHFvX+6+pc+OKvSHjmSKJyidCku3NNwteaVTeKlejMS2X/fjzH184uIXYSPJcJq+ 6+Z/QIJzYU47RSmB4mCxpW924PZqrjjquIwjtWCRM7JelBFARbQh1HEemoWw8Vxcfiyk XRcAoNpBXlcSZfaG8yv6qlBD0+Nua+jaz6Qn96TBQts+gAsbi5dejbdkabfXmy6GsT/w guNmqUWhOW9+P5+eA9YnWXzlpbvmWRN9nN6acmiE4xsqJGicDdbst8twwnDzSNS7H73c Onlpf5c89hFvD5Vo2uZI8yMkfoivC23a45N83TkIdBr2HHt/zttB79tBxge73j7Q3r68 i91g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pYDFYaJ6; 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 d10-20020a17090a3b0a00b00253555e5f95si968447pjc.153.2023.06.16.00.07.28; Fri, 16 Jun 2023 00:07: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=pYDFYaJ6; 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 S243843AbjFPHAt (ORCPT + 99 others); Fri, 16 Jun 2023 03:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243634AbjFPG7q (ORCPT ); Fri, 16 Jun 2023 02:59:46 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BCCE2978; Thu, 15 Jun 2023 23:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVHJo6BtSOf+rpHF7tFA3kO8Hlj9WimIG9dP72GQWXFjebt5wHwBIyC5tYkEc7nS3futC/Igwc+yoDJk9V0rNIqCxZITNIpxAJ1pdS48gPruxhVbCbICUb/n50ZlL4en/EAFpXgLqlUBvraRW9FAl+9WX76cWWCIIudsei+Pr6+gSS+KG0+VX/EJFPId18j0vXEexsTgm8C0RHXH6aMCrQI5akLtlbYBi/PJ/E1gGUEJim3y7O+LPAag/83YXXqOmXl4VDnCOi+9L2EOmUV35ucplSooC2aMGum27YvQlolpmVTsnkK0Xv2tsfaWsQJ4b/MMLNVPmZWQxXE/04lbAw== 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=EvyPbDqqMwbR2J+bT53IUeXdjW2l5X+0yZK5obmVr1Pg7IhZMtuWj4Pr7E1MNADYgykX38mZQduRXGeTUNyqGQahIerMbMFcGW9sAs5OLkt1l5GTRoIwfMfJgjGCQ0CYPUrv65efd2qgH1xqCPCa4ydA1fZ+mJftdpbSgUzykwhGQSop7TxSBAhHm+ChO+DFgwRgmEzfNBLLE2LtcwtMZEUuxsDN/Ao6asZo4iIdDJTjsZqndCe6srK+WZlzwOHdOADyeCme3Vib3hfomDYNxaUwDYsPAiXD/4ab1sY8S/5H37lyqx5//+WJMve+mzHxAUf8HDcDeVHmDTp2G+JwBA== 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=pYDFYaJ6TdVANy6iFGLiRzm8JYqz+arM031kX3qmIGkE7kGRl9hdUS2GCldl+4gbYmYhAOvUSrAXG8q6vYwb3+Oo8CeZRGubdS49egNTeT3aoKY6iNa8wpXBqXmeAuckKTIJDv3AOwPODzsy+W/ira1w+eUTG5Murz9cQOiUY/Y= Received: from BN9PR03CA0928.namprd03.prod.outlook.com (2603:10b6:408:107::33) by MN6PR12MB8567.namprd12.prod.outlook.com (2603:10b6:208:478::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29; Fri, 16 Jun 2023 06:59:13 +0000 Received: from BN8NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::56) by BN9PR03CA0928.outlook.office365.com (2603:10b6:408:107::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:59:13 +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 BN8NAM11FT081.mail.protection.outlook.com (10.13.177.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:13 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:58:55 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V3 3/7] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Fri, 16 Jun 2023 14:57:53 +0800 Message-ID: <20230616065757.1054422-4-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT081:EE_|MN6PR12MB8567:EE_ X-MS-Office365-Filtering-Correlation-Id: 949f6eec-dd2e-4b48-d4ab-08db6e37314d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dCBgxXyH1a/wD/K6qmMTLUnqKElp0ykSm8ulSH6Bx4kHbcYXpqNyBQ8NPPFJl+VUWGywd/EJTFdqsExxUM8lGsPzftrtJTUsbiuGFeDGZV2vZA7VYYa5/X4rhiaIdOf9gDcN9SO1/94vlmKPABZkPfJ+CWrWB4WLgc0FXdiepXzCuLvPf78k3Gc3ssUXcq9MTo0HRMAhJjqAHRhpvSSWzfxL8royUe5MtHZpqRXBF+088dHaOxA80lhlA6R5I8e6nfmyj8nzW9i1LoHYkUf/u8xK+jTPSGRYKEe4YAD2qR0emgOF+9cgkUbOlxGlWocvDB+v+kPbBX6S/w3O558tNWHJp9iphVWNv+l3W9SlZE4SeYFXA4JWbYTqZQJsa9YVSbSo7CFaEPgYVkI0yKgYBzknk3TcMIhbPlwpsb9dXal+fee5KISD7EoQg09EEEdADkOLRIcE8IUHG60SbAkzo0Q+dqg6fiOat6OiDvXaP3kEJoy6ZZBF0ADMX3CF5YAiVRo8zWsohga5xlP41tFp0k0YUhhwLIO4RA2v1xW+GKxXtL8gseJMaVHd3tH2vNlCrXeKK9+qi8HPK+VnrEsiV263kdEBP3nRFx/hWpc96MrIkxalp51DNFsz85AoH9HJ87AsM0zXz5AxdiuAgqfhr3rjWV1Z3FUNgzeljDO2b4wRak7/YrIuS92pyH/2Oz5oRId8RqiBggWshkdmQNFUh3vrkncXaRV9r3ayNURp/1XDYEM/C3XFMzg5U9bRrnkE/dNR4zOzi5156CCsWybZRD7huN7GcTkNoGWHvAPRSvU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199021)(36840700001)(40470700004)(46966006)(478600001)(40480700001)(44832011)(86362001)(7696005)(40460700003)(316002)(82310400005)(41300700001)(47076005)(83380400001)(36860700001)(70206006)(70586007)(4326008)(6636002)(81166007)(82740400003)(5660300002)(8676002)(15650500001)(8936002)(356005)(921005)(2906002)(16526019)(186003)(110136005)(54906003)(1076003)(26005)(2616005)(36756003)(7416002)(426003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:59:13.2185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 949f6eec-dd2e-4b48-d4ab-08db6e37314d 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: BN8NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8567 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?1768842079178217901?= X-GMAIL-MSGID: =?utf-8?q?1768842079178217901?= Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 14 +++++++++++++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 14 +++++++++++++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 3 ++- .../amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h index b686fb68a6e7..d64188fb5839 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h @@ -388,6 +388,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1592,7 +1603,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h index 4c46a0392451..77483e8485e7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h @@ -392,6 +392,17 @@ typedef struct { EccInfo_t EccInfo[24]; } EccInfoTable_t; +typedef struct { + uint16_t LowFreq; + uint16_t HighFreq; +} WifiOneBand_t; + +typedef struct { + uint32_t WifiBandEntryNum; + WifiOneBand_t WifiBandEntry[11]; + uint32_t MmHubPadding[8]; +} WifiBandEntryTable_t; + //D3HOT sequences typedef enum { BACO_SEQUENCE, @@ -1624,7 +1635,8 @@ typedef struct { #define TABLE_I2C_COMMANDS 9 #define TABLE_DRIVER_INFO 10 #define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13 //IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h index 10cff75b44d5..c98cc32d11bd 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h @@ -138,7 +138,8 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 //Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1 diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h index 6aaefca9b595..a6bf9cdd130e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h @@ -134,6 +134,7 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 #endif From patchwork Fri Jun 16 06:57:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1139448vqr; Fri, 16 Jun 2023 00:08:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jLupTyNMS1tiW4Xek6vdIsjRFyZTMy6zyLs32duJtPaGZvfS8qayTKkqNQhylp2DH4b9+ X-Received: by 2002:a17:903:4293:b0:1a6:b971:faf6 with SMTP id ju19-20020a170903429300b001a6b971faf6mr900005plb.35.1686899282570; Fri, 16 Jun 2023 00:08:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686899282; cv=pass; d=google.com; s=arc-20160816; b=VIScCWxARicJW+1HufXc0mFbRu0UjRbDRgPv+Mb4PjtOcFalqhCt1JoJmVulS4qfow eQ6EDtupOZoN85/LYCG/yS0XLdFvSL6/SkdDAnNYYbaQMCAbShK6UCu38BCbs25Hw/6W H2u6iIuFeh534ufMVx0SUBxc5/1SNzq+D8Rv0DYb7YgHyTeOU0hTpVAaTeGBxvCzhjB/ jC0HrodaHizawN6NGtuGhcMvfvA2+HEG2m0fNnbnXM6li+dS99UPolCJ9sPcz735aniI RmaUV9ZChuozf/KcPbBmM2FxRFhen0G3OoNcFMstw1aRXD7nvLZpuANCIG6Bys+PdkAc mr2w== 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=tQEBCPjPeN+QiiyuJ5YygKo1mPKx2V8nuCUp7PfkvuHZCs1qx4NudS6WcIG4ja4Er8 wdPDBEzNUS9JXAY6xgXJq+zVRpumHhtsyugbCvC4m4cup4jSi8SbE6oFXqd7Peje8Tty 8fMDqQOMualRkzmS5IX4AvTyMlCcACd/cF9PQXTOefPvVXKRuAcNM/H6v6CSRyY5wkNE +U8bs9hxT+DVOzcjjcZCX/79trwo94vG9Vt6+tHopNjlH6sXX5gEizBBVJMJD7iXzA4x R4WpvEUq4WUpTkL9dET1unohLQawIFrBPDo+CJ+xEIZxkkM/Mwsm7lYPFapR8FtLj7Sr CUOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=UYxIyFZC; 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 u11-20020a170902e5cb00b001b382b2d2efsi13613772plf.28.2023.06.16.00.07.49; Fri, 16 Jun 2023 00:08:02 -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=UYxIyFZC; 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 S243699AbjFPHAl (ORCPT + 99 others); Fri, 16 Jun 2023 03:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244026AbjFPG7u (ORCPT ); Fri, 16 Jun 2023 02:59:50 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2045.outbound.protection.outlook.com [40.107.96.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7D130FD; Thu, 15 Jun 2023 23:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NXoCCNT8+c+wDK1TYuG5W+WGWVm9+J09Viiw+8wiJ9R62hLgcHOLgK/fw9C9023W3BK3UsWm6JkyviaKRWQBdQwQ0LWxXTWx2bDn5gCpLQuq1qFcF/gR6rX/DtMeibcezQ2o+j/mdaq4OWzZbTnknMcOzgtBqZ8kKtobzFHps2fft7Q6eFlYsyl7prR3zU1fC0ozS3B+tUz8ecpO9DndEIFLWMEiQYew8tiS7YjKgPbkXFZMPvpmuhyU379pFsrngkAcublJaceCYzU4gVX9NsTUmo5EBiiscKCnBmyYxwSfL6nM7we5QBMvdhj0ZPJmgSfqAixH5K2QMbJbXmqi8A== 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=YKWm/4hQi+/tMMNKQGET9Ku8+7IP/uuQxKrF/VkakXzwOSSoZOSgfEreBQTEEzHlpQdAFfISQNRbGwrHOVNLAaVW2LSWwwINeDypoV4w/eUFVEx+4aczKjOZlyGK8dlvvZwgxw83X1/iHcgrz9cOXK+j+VBtsbupSXzKjJu7v4sSGwzaSCBMVtK5Z0ZATzVmBHfdhmiuvyT2ElsQ3czmICNMr6f1fWcD9KYfdxbdMJWrcfh7tsVmWUtY9gG/qeZS/43R7TCxQ5+BdGj8yCNnIlFEl/tOn+WzP0sFbYMfFjZQCfyBNjo33vh10pjCR3MCkLx7BtCC7mEbqU8EdXQ7zQ== 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=UYxIyFZCeT+PdXl5VRHLyzjKW1rGNQNPf9YRMRnTmnnY/pwFg2yuJI8VkCfM7nJ1ntpF6bZldspU4GCXBBcueZd0NX02YNYfix4sn2XXqX4KhQ8JNvVj2YQV23kraFvmGpcRkmm74UEJa6fSQQeZ1Nb5hi4GfvSvZrnv7Oiq+qg= Received: from BN9PR03CA0914.namprd03.prod.outlook.com (2603:10b6:408:107::19) by MW4PR12MB7384.namprd12.prod.outlook.com (2603:10b6:303:22b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 16 Jun 2023 06:59:18 +0000 Received: from BN8NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::b8) by BN9PR03CA0914.outlook.office365.com (2603:10b6:408:107::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:59:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT081.mail.protection.outlook.com (10.13.177.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:17 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:59:10 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V3 4/7] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Fri, 16 Jun 2023 14:57:54 +0800 Message-ID: <20230616065757.1054422-5-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT081:EE_|MW4PR12MB7384:EE_ X-MS-Office365-Filtering-Correlation-Id: 568eda26-7cff-4a28-4574-08db6e3733f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ezpolntl9sQX9oIJKJx2LT0NFv2TmpDhbtOhyoMsFNcSWJQFZhunoWepNySsG+VGhnn3ncOBtyGk67uhjaYOb3Luuwz3JvsvAGkuqMFmdK5lb3mL5tYTXZlzGB+uKsyp+Ikoz8TY0emFXBHnMDS5ZmZwiIfSBZYQ1hqPz5InyDkS5EWZXiwxjCJeyRHf2AyvagaqVvmRnKxy9jXIHxImHd8oDvEiPfWpt68qWG5Sse/4LOcDP9Ima74ZjD+ZkvWoFZqvYnck0e8vgWpMUoxiIw9CWKKgemFgpGJ91rsVSskSNXLoqKWpMJZmvwiWn0M8K9rOr+1NUl7Ib79lvMUu6O+nFJscJR8aEw1T0pXEDZZWyIt6rvc5r3JPkUfUGtVE+T7dcciS8pzslzqvPpY01Au1iPv9bPufIgcTQWfp+iLgpTSUvquCHsckHBKS/BtIf2A5ZhCQm/vtgsw1PIE6WGFS2FclR5w6pz55pWaDiJMGIUnUfgo+s17AOmJA7WBeDVLKBCXEC/rcmkI/FSJ3jzZFYxGI/luHyPUao7uyrpicOkEzTIF0SIeKQGVo5O9tLL1EtSApy1LJBjrkyCFejgg/F2ihrmLKytmxRJYOvdMCO0XHriVL33ur/WA/cc36RKexmmh6E3m/JjxnaaT9E/VJSp5MkEKBNpg3Acak+2MsTciUV1rdPBdQBNFlPrHZD4OGao7b4ZipB4cpGinxeWfw/7gcQ83nGBFgdZ0JZgpKElloXxqKeBCvaw8ysW+KDSbVKpZTSfnxjYsZEZe8IG/wdgRSbYG0pQWmhrSljA5kaq4SQMy4LTVNCSW3B23L 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)(39860400002)(136003)(396003)(376002)(451199021)(40470700004)(46966006)(36840700001)(44832011)(40460700003)(36756003)(7416002)(81166007)(316002)(921005)(8936002)(5660300002)(8676002)(356005)(2906002)(86362001)(41300700001)(82310400005)(6636002)(30864003)(70206006)(40480700001)(70586007)(4326008)(2616005)(1076003)(16526019)(478600001)(426003)(26005)(6666004)(336012)(83380400001)(186003)(47076005)(82740400003)(110136005)(54906003)(36860700001)(7696005)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:59:17.6557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 568eda26-7cff-4a28-4574-08db6e3733f5 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: BN8NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7384 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?1768842102262765056?= X-GMAIL-MSGID: =?utf-8?q?1768842102262765056?= With WBRF feature supported, as a driver responding to the frequencies, amdgpu driver is able to do shadow pstate switching to mitigate possible interference(between its (G-)DDR memory clocks and local radio module frequency bands used by Wifi 6/6e/7). To make WBRF feature functional, the kernel needs to be configured with CONFIG_ACPI_WBRF and the platform is equipped with necessary ACPI based mechanism to get amdgpu driver notified. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- 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 16 06:57:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1145869vqr; Fri, 16 Jun 2023 00:23:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ627bt4oCYr0f6+kyGWbR/1czZ2NCkU40GHZ650nCxDIGLDbeWiXEfj88fS/vXZAYn6zqaf X-Received: by 2002:a05:620a:d8c:b0:75b:23a0:d9dc with SMTP id q12-20020a05620a0d8c00b0075b23a0d9dcmr1166296qkl.50.1686900217964; Fri, 16 Jun 2023 00:23:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686900217; cv=pass; d=google.com; s=arc-20160816; b=BVB1u2jULXlC8fa+2ytdrfnF+MyCU+WsRdxh/Vx5JuaIq6irq5EDOdCkMJEUMWqK2B rAV8BxDKnKLi0+rcp6qRKl71vYtLo9KmVjfI5r/zjb8xSNKJrLVguRe1AE/q2GeKO5L2 hGXksQ4JMd8k8Q+UfJqUKHC0281eOdz9gzHVZZkBNKs06lYo2e0+hsmLs5h//fSCNFVc ToqpdmneP671h7j8CmP0nyuKCpdDoCpdNA1d8+zqtppUVdDtjqXoP0ZqaU3wJV5SULsw fXQv14LfGwhRm0ghxLwb4VUcNMwkbaquWeVZb2mT4ViWPA5nrclGAnHAk2GtGa9qV3Hk uXYg== 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=biNt0VyvpDHv601CDxGnrcM+ymAsxPrwd1Y2UKA27lvu5Y3YA9RsJxY0enue0zip4O jRceztWf/PzCOEy6IxGoHz8qsJWYCGwR1GxSiHohcp5tzeVJHKLv0NJJjmMXAO4NKQr0 2P2ctWWHOD+KJ31oUDYuOmXldhiibFTR/Kv/poynK5pWv5/pNWygwmyF5GVPPSimcmLR gdn+pgGm7nZwJ+u05bNzGfNpefOoxdaUcT7AbhYAwEZ5ykPwKdlSKV0y7nObEozQYG4j FGiaqGFGOLVlUKErx/7jH/0Ns4Pt6tXkqC9lOXKf1z3iTLeFrY8OKYdHUkHVq2gxCMQ3 SAZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=NB0ExcST; 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 s6-20020a625e06000000b0063b7c4435c0si14586532pfb.54.2023.06.16.00.23.23; Fri, 16 Jun 2023 00:23:37 -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=NB0ExcST; 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 S244058AbjFPHBC (ORCPT + 99 others); Fri, 16 Jun 2023 03:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244119AbjFPG7w (ORCPT ); Fri, 16 Jun 2023 02:59:52 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2048.outbound.protection.outlook.com [40.107.95.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 533ED3589; Thu, 15 Jun 2023 23:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kM0ton+zF8dFNeDKRhZY6EU2ltMFCtYrpAN7/9K2fHgW7kbzhJ0Bi2HxvRQ7Lnyneoa3YWxJztoMwD0ZzOwaVl5qg7qtPv3SZiQFViHzHiv032bwmp25m1pRIhlf+z51mAaF+I6wdKQwi5yhIrHdMrxookinzFykK46GxARmqmEKTHFAPyoXDgARPjtjhD3L10DVo3npeOkJzup5sPhxTg6Ar2YTqdPsQB+IUkFPn2kJG0ZDbov6sFG5uPU1mue1D3NuMn+4c0cm+ssLMDGIWL4V2BxHDtyp58g2oN8pVKya8FNW4KTFK83gBNCydHwLBWA7vIPkEoJPPimrNCBahg== 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=Wa3YCEjeP0ag2CXeueV1N/zTVycSgHzotUPxbwW8dwTBwVg/Iu5VXYm8114zJoww8eXInFPwxMdUN74/o1HSEPhnlk7IoXi6yhDW33FnsPNtwCcpAMZdkTRAFKsI1vnlOeNYkTpNiSRGzeqYh1HogOQt2LmYlm+VcjEAx1LpsjD/KYhP/cXiQkXInb3ctS4SqhwmMA28y6fL+Zeb770qQ7slRMHJZGYFeKTSxwgG+QhhunUjJH9934M7g83CcgVwR33s6IzCuqoSOvKudcxnAHoNd9V9eFV5TfzKoZzCAbZNGw1ZKcYv3kFAfEYtbE/GOT9kCHQpJBqALMXDoNo7fA== 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=NB0ExcSTxAnPmCqhfJPBrzhz6ncpCcNoheRhcFKillw417ikbCRbuBvCYqubvRfksC+T6DKqih7XebMGvsLc7k3OFVMgW0l4+fM3X1b53KdmggyCJZ4NlVWklL9KeoY7VJIGXZm+O3TpXBjYHCoXqdk746ohG3Hfw8ebVyD+aLo= Received: from BN9P223CA0019.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::24) by CY8PR12MB8361.namprd12.prod.outlook.com (2603:10b6:930:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27; Fri, 16 Jun 2023 06:59:23 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10b:cafe::88) by BN9P223CA0019.outlook.office365.com (2603:10b6:408:10b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:59:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:22 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:59:16 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V3 5/7] drm/amd/pm: add flood detection for wbrf events Date: Fri, 16 Jun 2023 14:57:55 +0800 Message-ID: <20230616065757.1054422-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT003:EE_|CY8PR12MB8361:EE_ X-MS-Office365-Filtering-Correlation-Id: c4befece-993d-4af1-2633-08db6e3736ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ld13y2Xr9KvvTE0ZNHxyQtYyE1E6mEcd9zMXbNueFL5Iu3C+YUU/7EEZ4zPqp/LzCUvgnVzDfgruJ4z/ofZ/fqrGg3XDfjMo6sNnBljmsB02SMxQAiib/xeIBSGyqJrvpbFA21EkGJftyuPkYwsljEWRc8g3izerLRMXb2iwKwDFE65UIKDkPIofwJ/VHTnn1wKLy9/Skh1ffwLGzGms8EyoAhykHZihXfMHQse8aETIpK5Cl3GTBvhwE7JiNfOlQdBjFbEs4l8zO4fw70mnzAIATgqLPInpaDKyVRw6/rKyZM7IfO4CxIcal8GkW193x5f4DQ7TK+6SbCxSOkkQhnp6V/4yCjZABhsnzz5gm+wFzIJ9cZf5SSzxDzpnhRmIInTJtFbXy0VwS4WU8C9vNhSHMnb3eWKHOUpAvnqwO3SrdDR5TTFnCHNIDnMJtDd45kg5af0L100fwD/q1qkC6ui0tYsABDdKu7II0yl+vpbN/cyYTd89LdrjQVyNp5bHL9sngjFsfhBbCTHPKkZTWL1gl6eYFCDQUzRGWXNGTSTe1TZ6KzJy3kVh6snTm4rG+SVpYWpSca1sc+AROVgEDp7P1cRjUYiGNlNe6Rq0tuHNqGsAYAn8RfIF1x869niIq5WTTesSAzl8YwVdReBY0pvUG3mtwF88bxN5hkCWPzo4lRf4HNqoXCSNwB/4CxmXqS7rMXyRyNia6Nf7TbSeStAMSTu9KF9WamglKrd46UMtAGBABDE5lo5iI49dFwPxFLryF5at4268ThBy7KBYmy9qKm1p36UXCKbIZCq5E1A= 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)(136003)(396003)(39860400002)(376002)(451199021)(36840700001)(40470700004)(46966006)(5660300002)(478600001)(54906003)(8936002)(40480700001)(41300700001)(316002)(8676002)(7696005)(1076003)(110136005)(7416002)(16526019)(44832011)(186003)(4326008)(6636002)(70586007)(70206006)(6666004)(26005)(2616005)(47076005)(83380400001)(40460700003)(36860700001)(336012)(426003)(2906002)(81166007)(921005)(356005)(82740400003)(82310400005)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:59:22.6487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4befece-993d-4af1-2633-08db6e3736ef 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: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8361 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?1768843083013819211?= X-GMAIL-MSGID: =?utf-8?q?1768843083013819211?= To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 28 ++++++++++++++++--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 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 16 06:57:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1141117vqr; Fri, 16 Jun 2023 00:11:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kVWdOe7+cXUYwifHBVtX5hxDOkmpjrsax8PeeDZHpWq8hjXjBJe0KBnLKgIVA8sjABWxL X-Received: by 2002:a37:ac04:0:b0:75e:c960:9205 with SMTP id e4-20020a37ac04000000b0075ec9609205mr960060qkm.16.1686899492676; Fri, 16 Jun 2023 00:11:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686899492; cv=pass; d=google.com; s=arc-20160816; b=HaGu8Ii+gPVL0zcigKBsPC00bzNYQ9biTFPHy0KSq/z5oAr+6p/dOP1fM91qadOQxT BYTVR8fdtHmiviB/tBRT/rGUI3blY/r+HEA+mEKT8ckI2iOgrlVuuCM2l0PQLYzOC/Z5 /sNdoMkb7Ecc3te1Vsvsn5goQZyS4qT5zh/L0GxhTBcyolTLwu9cdIifnfupZ61+qXJL 5pa4ssQoKi3gAlNH3ZQ4HBxKBcJia4jjnvxgt0zWo8hp9amRP02IYWg0GSyGJvg0ckrS 15ZD0caTZxmBFDEjsNwvG0mlXVtBgFgWEKA/BcpqCSbWWUgOIDvctjzSLv8p4jjXZo8V bC1Q== 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=ofVDzS5UvGppbZBYrLufTyKyAE/j/gplX3IMu2voLtg=; b=ladq1NzxCeYwjUK0keeqps+mHwGUdzdqaCnmmLBLFrmPypJ/swYrhc07wRasL2jmeF HgV7UXahIYNHhtjgiHIXA8Qi2qtlNzPk/jxEDOyvtLCzCiJHIqQI93UQVrizlvWqx87K AuxzPTfl1h6HdI7F+tZHd2JxsFivYd/elsjOWvLHUqqxCkqEtnQH3LI1/NaI8eToUjy0 Q3erBPh02v12+N3DXrixQlZUrz+++fVe7Ds27TA10AmNOcyA8spK0TTh0HOwI+oGdQBW sLXG0xmr+murWfRkK6l5EnT7RyNhR70FPT98ZvlcHsSpr98dyUDGOkIeU7zzDckcXHIf jVYA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=YtlD7uGB; 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 u5-20020a634705000000b00542d2508ac7si10823560pga.200.2023.06.16.00.11.17; Fri, 16 Jun 2023 00:11:32 -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=YtlD7uGB; 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 S243969AbjFPHA5 (ORCPT + 99 others); Fri, 16 Jun 2023 03:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244419AbjFPHAA (ORCPT ); Fri, 16 Jun 2023 03:00:00 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2051.outbound.protection.outlook.com [40.107.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A323D3A88; Thu, 15 Jun 2023 23:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgwNQzYSiGBoQ/wyOJzRG7XDgSOQhxmhoKgvHbgix99FF38nrmHVVewUd9GpbL/D3qBmBaAv6vkEnM1LeOlX28uOWOPS0PtM3w3+M2ewRF2QKf4FBCCXp9TkReob9Ee1T8do7eOT7k8Is7KCrjwfezGhZp66G274E61GfhExmdPVrPS07/r1MxuYYKW2Ao13rAiUYZyxedioTAYfJEZ2E3p0q+L9PkvIovR1VD6EviYVe66z/sTLPZ3BJXqVYCxCZ/yJuv3UAF9OeKBwS3hRudpNltBVf57Ijufi70R+w4tuKLvOSw3+Hie2AdvjWJnCsRq9nexLASS7N9CMS4+LRw== 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=ofVDzS5UvGppbZBYrLufTyKyAE/j/gplX3IMu2voLtg=; b=oKd6MQ0rxLVsvIdTqtojJFYKxCM5JO4vmfV2HrJ4QsBfJS5DY5Lo+uWRdsEvBHQ8w1ZDK7H8oMgYP1yjhNiHdKDCahvxwPrCQvW7mRysIuyrpsHk0KeQ3dsLPkRwRVRNg+u9VDBsRgRWunNCjh7B2Rqgc7fQvkB1laNh3HTpfa9VL828RAqaH1ViWy7uW15gAexno5rZ4Lo17DM6kyRUdCV+Uiyg14ljMZkSlRgvy9pdI4sxXvwJJq39+vleN3erCN4d2xaDZjvi6XRP85gfjMou9KxoEBNsLH2vaW05QkruBnA6LI3IIvZpIshxVm6XCGA6h0d18luaZQHTKIbdug== 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=ofVDzS5UvGppbZBYrLufTyKyAE/j/gplX3IMu2voLtg=; b=YtlD7uGBKZdV+ocjJ8pxT0reCYI1GleMc45amWZqFnLQ35jkikvjSpZjc+WTUpOt01xnWXPjGJwt75CidQuJ/UOQ1FLULkRqpqZhQsDOi2pZ7l2Z5L4JDOiKw7mzK48JK5C26oL5Ib8NE2NUxzdlh9fn5z69qVC/PDg7KEOxlys= Received: from BN8PR04CA0058.namprd04.prod.outlook.com (2603:10b6:408:d4::32) by BY5PR12MB4902.namprd12.prod.outlook.com (2603:10b6:a03:1dd::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27; Fri, 16 Jun 2023 06:59:29 +0000 Received: from BN8NAM11FT109.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::2c) by BN8PR04CA0058.outlook.office365.com (2603:10b6:408:d4::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25 via Frontend Transport; Fri, 16 Jun 2023 06:59:28 +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 BN8NAM11FT109.mail.protection.outlook.com (10.13.176.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:28 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:59:22 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V3 6/7] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Fri, 16 Jun 2023 14:57:56 +0800 Message-ID: <20230616065757.1054422-7-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT109:EE_|BY5PR12MB4902:EE_ X-MS-Office365-Filtering-Correlation-Id: 87feddc5-f727-4c0d-2c2b-08db6e373a69 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: toW91PJf0wAHZ7Ah61743nTIcB2eO91y3uTjslkJrIjUEeWtwez4dMt4cVMrvKAdiNVS60iclHlTLVXr3BxLBbHIoowdxJFRI1/AJ5OZOhco2P9I9dfN0Isf62ECM3mGt26Ou2ZU2Ybz3hMqtineq2KA1shiN9TPu8iZmlnhGWcVUOwziysiplX2xTdPgBqkW3YDc1hYbAlMFoQcCT/oD/pbIJyWbClPJczLNZfT1MAmWTJggeN216f4v0tQtlxbl5bRdZ+S1c2xqXIGIWJE7BXYcn2JsORuhyg+TZyFDGKwO/dJLZQDdkYldfGI1GeoW7BPM4vajbT51Gtpyhj9uJvHXrDc0tyUqMqP5wCye7qwopIuPJQZoVrq/+pFfU2F1HgKI6+YhLy+ybMpfgU3zoB/DNQiyenKGRSGlKNi1M9E5PVoJ/nNb40LoEww2MzKE2shB8WFE+zFzl1cqp3HsTgwPjn2Hv/3DBeXqwHIgWE+SIbElio17Bx7hDfh/RDkKNF7NYKgomPE4qCe/MUBRT6zCFl62yKCJDSeMLpKAyKPbUV5Q6g0uldgJuhj0ChelHrQpY5uvAibu0c67TPFguYarOdh7SFQJq8o/ruL7IPfD5zeZ4xPrHKa29E6XcRAZU7InYzUgdqZES1WhxYC6FW4yy/1O3nvPR/rq+T8m5icC4hG0d4RD0okKVLFvkRYVkn+tAaPLUbhJxmL5WmyFMtz2LOttLOUCYbTLfcFRgGgmRCmVikzRzUWt4iuN/z94IlD//pdD+G5SbLN03KQDx9ozUx6REcY5CIvXkm50Rw= 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)(396003)(376002)(346002)(451199021)(36840700001)(46966006)(40470700004)(5660300002)(44832011)(7416002)(8936002)(41300700001)(8676002)(2906002)(70206006)(70586007)(4326008)(316002)(6636002)(54906003)(86362001)(110136005)(40480700001)(82310400005)(478600001)(356005)(81166007)(921005)(6666004)(82740400003)(7696005)(40460700003)(83380400001)(26005)(1076003)(47076005)(186003)(16526019)(36756003)(336012)(426003)(2616005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:59:28.4816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87feddc5-f727-4c0d-2c2b-08db6e373a69 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: BN8NAM11FT109.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4902 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?1768842322605865158?= X-GMAIL-MSGID: =?utf-8?q?1768842322605865158?= Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 3 + .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 9 +++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 60 +++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index aa63cc43d41c..a8a4be32cc59 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -323,6 +323,7 @@ enum smu_table_id SMU_TABLE_PACE, SMU_TABLE_ECCINFO, SMU_TABLE_COMBO_PPTABLE, + SMU_TABLE_WIFIBAND, SMU_TABLE_COUNT, }; @@ -1496,6 +1497,8 @@ enum smu_baco_seq { __dst_size); \ }) +#define HZ_IN_MHZ 1000000U + #if !defined(SWSMU_CODE_LAYER_L2) && !defined(SWSMU_CODE_LAYER_L3) && !defined(SWSMU_CODE_LAYER_L4) int smu_get_power_limit(void *handle, uint32_t *limit, diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h index 297b70b9388f..5bbb60289a79 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h @@ -245,7 +245,8 @@ __SMU_DUMMY_MAP(AllowGpo), \ __SMU_DUMMY_MAP(Mode2Reset), \ __SMU_DUMMY_MAP(RequestI2cTransaction), \ - __SMU_DUMMY_MAP(GetMetricsTable), + __SMU_DUMMY_MAP(GetMetricsTable), \ + __SMU_DUMMY_MAP(EnableUCLKShadow), #undef __SMU_DUMMY_MAP #define __SMU_DUMMY_MAP(type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h index df3baaab0037..b6fae9b92303 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h @@ -303,5 +303,8 @@ int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, uint32_t *size, uint32_t pptable_id); +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement); + #endif #endif diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c index 393c6a7b9609..8c2230d1d862 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c @@ -2453,3 +2453,12 @@ int smu_v13_0_mode1_reset(struct smu_context *smu) return ret; } + +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, + bool enablement) +{ + return smu_cmn_send_smc_msg_with_param(smu, + SMU_MSG_EnableUCLKShadow, + enablement, + NULL); +} diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c index 09405ef1e3c8..cf75feaee779 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c @@ -155,6 +155,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(AllowIHHostInterrupt, PPSMC_MSG_AllowIHHostInterrupt, 0), MSG_MAP(ReenableAcDcInterrupt, PPSMC_MSG_ReenableAcDcInterrupt, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = { @@ -235,6 +236,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = { TAB_MAP(DRIVER_SMU_CONFIG), TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, + TAB_MAP(WIFIBAND), TAB_MAP(I2C_COMMANDS), TAB_MAP(ECCINFO), }; @@ -472,6 +474,9 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t), PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, + sizeof(WifiBandEntryTable_t), PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM); smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); if (!smu_table->metrics_table) @@ -2112,6 +2117,58 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu, return ret; } +static bool smu_v13_0_0_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + switch (adev->ip_versions[MP1_HWIP][0]) { + case IP_VERSION(13, 0, 0): + return smu->smc_fw_version >= 0x004e5f00; + case IP_VERSION(13, 0, 10): + return smu->smc_fw_version >= 0x00503000; + default: + return false; + } +} + +static int smu_v13_0_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 + * is a valid setting. So, there should be no direct + * return on that. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table, @@ -2188,6 +2245,9 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .send_hbm_bad_channel_flag = smu_v13_0_0_send_bad_mem_channel_flag, .gpo_control = smu_v13_0_gpo_control, .get_ecc_info = smu_v13_0_0_get_ecc_info, + .is_asic_wbrf_supported = smu_v13_0_0_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_0_set_wbrf_exclusion_ranges, }; void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu) From patchwork Fri Jun 16 06:57:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1141079vqr; Fri, 16 Jun 2023 00:11:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6z5YBmYD8eiiFSvgemaoypQvcuxVdzOi3EjXg99mqn3ublV6Tu6THOBYRGZFei081C9M7W X-Received: by 2002:a17:90a:430a:b0:259:bff8:17a2 with SMTP id q10-20020a17090a430a00b00259bff817a2mr9286565pjg.0.1686899488409; Fri, 16 Jun 2023 00:11:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686899488; cv=pass; d=google.com; s=arc-20160816; b=csLzrlUDP+DHSbiK5GR8IaY3JMC7gv3zJaZ7Dah9YMPJv0OQ+iC2YD3X7ENsHECSN2 hw6vdaMj6/bKNENsXKtKWrb7MtHl8t19rpjBa4993RVv31l9C7M08Lfn8ukOt7KnHVvT Yhdr5G8j1VGjM7SKND5oeNH2bRN7b1clsXkJnWaCLB4eT0NKqPs8p2Q05oytygEWLMh6 DrHO/w0b2gntZ/zOke5TxPhoi59fWy27ldpx1rrO8Fzyqft5NVEg/zYCIeGRm8XqfpNR PIDW2LAmjGYBz3jUpCpQyht9+WDst6enYaM3AVs65i6CvESbnc1433vkOeUoXYLLXsak 5LNg== 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=I9SZVm+MFH5U7vsSAeuNozo8k4H1RT1Ba7AYPjwjhHS3ZzYhI1BRXxQT7ehEtYmaS8 zyD/jlMSV61BA+mhmP+A4UF+tesNxkIJoORfJMS+12VbOQJ++nvj6d9y95V6g+brPrXc 7u1sTwfI+AOgzjNklm+TO/bkZsTKyvDxuNfvDX5Im9M2GtYkUr51M9lCaEHaTWiuYDg0 ALJbYymvlwOnFjswfGyQAm3YMIgcs8NZPsikOD/xdp+v8kFos6unD8Qd6H6OC2CvA8PF b9TNCNEr6MciUQKJqekY3Zzw1bog0wCGXeh9lYL8gZzYskLIah2FhYLJWmHc56sEqCRs hu5Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=NVejxeaI; 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 a6-20020a17090abe0600b00259b538399csi991801pjs.46.2023.06.16.00.11.13; Fri, 16 Jun 2023 00:11:28 -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=NVejxeaI; 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 S243365AbjFPHAf (ORCPT + 99 others); Fri, 16 Jun 2023 03:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244285AbjFPG75 (ORCPT ); Fri, 16 Jun 2023 02:59:57 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F23435B8; Thu, 15 Jun 2023 23:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eM3ALuLW2bO38Yg5AmFc2WGSc04j0AtSRzZpExnBfIvfvC1NHPyQJ4XalH490mTkKtMEujYxkqcs7WPGAXOw6pl6n4zIaz+boWlsdFemkvOpQCfw7pdeszB0yr3RIYZoGMquKt3DAVrx0TP2P6E+e8h+98TG4c5UB6Hez8g6BZmaTmnvYoUcmeo+SqGtNHLvhIsWgsu0NxVXtYNojH6FhIBmISkDRYt6ukLl4Xg0MYMchn4HcrBZEbVwXps2QPdfpK0ITiKzIq3acKuZmyrm7VFizgAm75AeH4V0kWUpd15pfD5qAJgCCh1CLMQmbcr97MOLTZEqVLSmVYlC3mR6Fg== 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=DaVrbSVmz/65cXUrJRlwzWmrZRdQuDzcTjyzTF5KOAs4M3n13LaV1Ea0os+Sx2NdBKpkhUVF9aMnpJFXXOFTXerkUzp6ILDX07E3gQgdp9YH7q/ke1C2Ci9dZby76Ni/b254UkCdPjAooCN3pUh0xyKelZg8XxEvnSp3rNYxYx5o2ZaBiRr5pOj47LXnA4rYeRw+LckwUDLBu6sbseHt4zo+gvy2GEudzRAx8dvaricCh2nZXg4MmQzp0BwfRpYOgo9teT//kYZnOwRnNozTmNTyZbhbv5q8ZCgDLGhejQ5fAfeD2uJe2A94JnbEXodGSii5ykxvE9U+SGCPEJQ14A== 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=NVejxeaInamfF1ktLA8XLLOBDvq+Mg6Nu0MA7Nshnb8x4b7u/ifItgN9aeZCKT6aqJ6LxjqV0+dOI1zu4t5X8z7NYA35ukB1Kpbatup1goEKvwiZFCkuJ7LF6MczeK6ojQaY8DmWH2fXU/ZTwHggMr8fL+zkLwGCGOz4y6JMyWA= Received: from BN7PR02CA0009.namprd02.prod.outlook.com (2603:10b6:408:20::22) by IA0PR12MB8645.namprd12.prod.outlook.com (2603:10b6:208:48f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25; Fri, 16 Jun 2023 06:59:34 +0000 Received: from BN8NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::61) by BN7PR02CA0009.outlook.office365.com (2603:10b6:408:20::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT021.mail.protection.outlook.com (10.13.177.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:34 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 01:59:28 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V3 7/7] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Fri, 16 Jun 2023 14:57:57 +0800 Message-ID: <20230616065757.1054422-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT021:EE_|IA0PR12MB8645:EE_ X-MS-Office365-Filtering-Correlation-Id: 04d2a67b-b03e-485d-d802-08db6e373e02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MremAtLguZwFMuHBILadQECqMSpjCQHzqvGTwBLvJxdCYtH54pC9CyMmkctWC6hb6Quk7U8i/oCbhJskpyYdyvroyXzcY3xWreXsCInBg3j+uLIFcc5esyZT1mrXNlgvtWN4hzrtaocnr8VtH7NsUzBYK37YOOLYMGAsrhgpyEa+d5ysetaH3GwHfVbW2H0fpYQeVMe+ffxwCdBy/NOp2GqOzoz5FbeH2stxkF8M+691WtWCQNUvSOv6DMgMCyWvSaf/YDjo0HonDg6AKQ54VPGpZ7GHFPtWgn7tlCwCvthPSi+ZB+V/CrQpsgUTBPdK/qtwqUPi4j/QxnnT1LyVwyCK1YIwyKvayW8oNL4pDZFw1K77487ACLr4Yil/AGM7AbYSiOcWxN1XTcj8gbQ6LtMf+ZeRVHM+VuEl9T14ti6QFy345D7B8DWHJtNt0h2bAtBTSErz7xHvQXWGle2k356hpbZ3vjgJURFwTbHcJTy4nuv+/7rOMhUUMQIP64V094/i+2EHFT57kglgnMlcp9SL6RHREDU2yj9yxoTmw/SaHs/oRIKmd71hbWZMpfvnYRvk+/FrtWo/v/o4bPUuunDGDyZMK21rCoaLUJhr3/nJgeEEj0e25RYm9+o7VgIQU+ZegtteWFz2loRK076RR6Qx3QhILbl9KavB911LeRVQ6uXky5L4Ur2aqulHMcjGuOoP/vx9+HYkEPfRYcPGfWZgtb5kahbfkeLw16+NuGWFQEE0G+MU8j4JaXt1BN4t+rIg64KpJfZiERRsIb3LuQDVSA0bRQ2smdmYvz4rUCM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199021)(40470700004)(36840700001)(46966006)(44832011)(7416002)(70586007)(4326008)(86362001)(2906002)(316002)(6636002)(70206006)(41300700001)(110136005)(5660300002)(8676002)(8936002)(54906003)(356005)(40480700001)(82310400005)(478600001)(81166007)(921005)(7696005)(6666004)(82740400003)(40460700003)(47076005)(83380400001)(186003)(26005)(16526019)(1076003)(36756003)(2616005)(426003)(336012)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:59:34.5218 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04d2a67b-b03e-485d-d802-08db6e373e02 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: BN8NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8645 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?1768842317801064518?= X-GMAIL-MSGID: =?utf-8?q?1768842317801064518?= Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c index 98a33f8ee209..16c1c04e2034 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c @@ -125,6 +125,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(ArmD3, PPSMC_MSG_ArmD3, 0), MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = { @@ -205,6 +206,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { TAB_MAP(DRIVER_SMU_CONFIG), TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -487,6 +489,9 @@ static int smu_v13_0_7_tables_init(struct smu_context *smu) AMDGPU_GEM_DOMAIN_VRAM); SMU_TABLE_INIT(tables, SMU_TABLE_COMBO_PPTABLE, MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, + sizeof(WifiBandEntryTable_t), PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM); smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); if (!smu_table->metrics_table) @@ -1721,6 +1726,57 @@ static int smu_v13_0_7_set_df_cstate(struct smu_context *smu, NULL); } +static bool smu_v13_0_7_wbrf_support_check(struct smu_context *smu) +{ + return smu->smc_fw_version > 0x00524600; +} + +static int smu_v13_0_7_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct exclusion_range *exclusion_ranges) +{ + WifiBandEntryTable_t wifi_bands; + int valid_entries = 0; + int ret, i; + + memset(&wifi_bands, 0, sizeof(wifi_bands)); + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { + if (!exclusion_ranges[i].start && + !exclusion_ranges[i].end) + break; + + /* PMFW expects the inputs to be in Mhz unit */ + wifi_bands.WifiBandEntry[valid_entries].LowFreq = + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); + } + wifi_bands.WifiBandEntryNum = valid_entries; + + /* + * Per confirm with PMFW team, WifiBandEntryNum = 0 is a valid setting. + * Considering the scenarios below: + * - At first the wifi device adds an exclusion range e.g. (2400,2500) to + * BIOS and our driver gets notified. We will set WifiBandEntryNum = 1 + * and pass the WifiBandEntry (2400, 2500) to PMFW. + * + * - Later the wifi device removes the wifiband list added above and + * our driver gets notified again. At this time, driver will set + * WifiBandEntryNum = 0 and pass an empty WifiBandEntry list to PMFW. + * - PMFW may still need to do some uclk shadow update(e.g. switching + * from shadow clock back to primary clock) on receiving this. + */ + + ret = smu_cmn_update_table(smu, + SMU_TABLE_WIFIBAND, + 0, + (void *)(&wifi_bands), + true); + if (ret) + dev_err(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} + static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table, @@ -1786,6 +1842,9 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .set_mp1_state = smu_v13_0_7_set_mp1_state, .set_df_cstate = smu_v13_0_7_set_df_cstate, .gpo_control = smu_v13_0_gpo_control, + .is_asic_wbrf_supported = smu_v13_0_7_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_7_set_wbrf_exclusion_ranges, }; void smu_v13_0_7_set_ppt_funcs(struct smu_context *smu)