From patchwork Wed Nov 29 09:13:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472477 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gK6kY7MN" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FCF11BDC; Wed, 29 Nov 2023 01:14:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C2jls8+xceaUq+zmXVR1ym8Qu2vq/2UP6erDdfDqSP9D9G85qRGARU60eFVcGfnEdS9m8Rgj+NTVetDCWeGTIEYQClmWrQXGukTisVAxNjo7k/Pur8iAPER8/XFMHPCQyp+6h7UW8jGv1Oa2x/NYfQ+GjUuH7Zzh2EqdvWyoTsJAWZCHoNtwfCgHwunSDUBfR+MONvofvEiB8PAs0C2akosTYzgmdnBhEHyk9FAJWIj92cJciBC1SpSz9EzTdOCsCkLPhPeNKnlBpUZndBbaIGhC0uA0ZzIu9XFO5QhnB9YPiQ9tQZMOttWrkTxKAOGcPW5uDC6tHiEmIyiAghdqpQ== 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=hbYANmssnII81GCFDHN4Q7992LrDQ1SmxcSBrprIeZg=; b=THOjTKepXjPXsKyYsh+CKM+SEnClWsHJeABOHeAvKTFuGs1q0Igp7LMwZweRcCa7A+9KY+wQvnESflv/xxXEScLbX/BXHDitBtaGdSEc1+bmAtPjt4J0cM+kLRU4rpN2xCWDEFip6NH/Gics1y3hx+UIbsPbTxIUccuFIhQgPpykSHGcQJWD5NYn2jxIno2YAbQieGAtgQjMhTYVuXfiXq+OtUXRpSjg7/SBTfjKXUJI+Sd7aDPNS1TsncWuc17rjUrFpzJ34NlrmtHMrwgM9U1JEqYppRGv5yDZzDUEo16XhGicQKODP8CadqAYVuXV8+9+i6VwhvhH9MRDVD5h7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=hbYANmssnII81GCFDHN4Q7992LrDQ1SmxcSBrprIeZg=; b=gK6kY7MN86z+FLRCUWLNF4CDr+mjAzjflveMTcWXQRlxq4lRNiGQ0H0Dkuac5h7n5lIiWoTpSnf0rh7fHQYoKIteswagqiilcmf2VD9D+DLpkGX6MPjo02RU4LuhyMceh0Q6QpAHi+sTeiG8Lfx1a96O2UD7RLHgSThrT4oRCSA= Received: from BL1PR13CA0085.namprd13.prod.outlook.com (2603:10b6:208:2b8::30) by CYYPR12MB8962.namprd12.prod.outlook.com (2603:10b6:930:c4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Wed, 29 Nov 2023 09:14:28 +0000 Received: from MN1PEPF0000ECD5.namprd02.prod.outlook.com (2603:10b6:208:2b8:cafe::1) by BL1PR13CA0085.outlook.office365.com (2603:10b6:208:2b8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22 via Frontend Transport; Wed, 29 Nov 2023 09:14:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD5.mail.protection.outlook.com (10.167.242.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:27 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:21 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Ma Jun Subject: [PATCH v14 1/9] Documentation/driver-api: Add document about WBRF mechanism Date: Wed, 29 Nov 2023 17:13:40 +0800 Message-ID: <20231129091348.3972539-2-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD5:EE_|CYYPR12MB8962:EE_ X-MS-Office365-Filtering-Correlation-Id: cc9fa9b0-4104-4a5f-812e-08dbf0bb9675 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ziJvnGfaqJiO7SIEXO16CnItJNpFLOPLEVCJf7XN3Q45h8xBuSit8a29O7cGqpp8HsW68I23v1PodKiaFGO3hg3ahmrh7wUrs/mCNhwwq0eJaF6fmIpL5oboVF/Jwq4OcySveE3kotIbyM9cRMeFOmic4Oyj1id8Op3frojuWSOY+i58BIOeJvyt+nYHefv6rwY8olcSC52FMHkWSQRoza3mjm6MOzvVfCIJTohlwpWZuT/xMSqE7oHScn7bi7Sz/7TahGZlCvRiq2eETM0P1J/cQJYh+nug4LRfXPC2Sla/To7u4NyEHoDSDYvidg+nbRscRbFatSHtGkwC1c5yCVIU4XnEnD0NhmNSHzH60ncNAAsxnow1wADrEgC6s19ON7yz6lrS6GNNQdSs//fq96GHgOxhcZnrLof6njRNM14L+n0V1hZrNFoUv+d1F1tieHitoFMvyufr2p6Ol1W8uSOEL5t65QNmU6yDMuyLUZgz9cV7FIIXPFu9OCBDbn1Vio+GyA8NrNCmdX6I7Jh2dTSHvmm+3bKjvn+Daf4wy+G+1JZLfGYs5fJ3FuhlcRoNjWss6xQ8VTq4Nz92mCqDFzSsT/INmhz3xxrHaXffcpyHJ+2iYDEtNoFnJofpsSTKP6LcfCq3bWer3GJYCkaYOevDUkEGvgSLaa/vFoTYN8zvTdZxGlUHTz7NvmpG62IGaThu0zqSK1EFAgE+4QF0XtUIA5i6azIa5cF4j25E7ky/630obeCoFaP4FZQvDgLH3kAQAHe78n9im0pABoit01AN4Y+YgCY8/KT9oIwMX4= 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:(13230031)(4636009)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(186009)(1800799012)(82310400011)(64100799003)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(41300700001)(36756003)(1076003)(921008)(81166007)(47076005)(356005)(83380400001)(426003)(7416002)(5660300002)(82740400003)(70206006)(336012)(16526019)(36860700001)(26005)(86362001)(2616005)(70586007)(2906002)(7696005)(6666004)(8676002)(4326008)(8936002)(478600001)(40460700003)(316002)(110136005)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:27.6422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc9fa9b0-4104-4a5f-812e-08dbf0bb9675 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: MN1PEPF0000ECD5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8962 Add documentation about AMD's Wifi band RFI mitigation (WBRF) mechanism explaining the theory and how it is used. Signed-off-by: Ma Jun Reviewed-by: Hans de Goede Reviewed-by: Mario Limonciello --- v14: - Fix the format issue (IIpo Jarvinen) --- Documentation/driver-api/wbrf.rst | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/driver-api/wbrf.rst diff --git a/Documentation/driver-api/wbrf.rst b/Documentation/driver-api/wbrf.rst new file mode 100644 index 000000000000..12793bb1abce --- /dev/null +++ b/Documentation/driver-api/wbrf.rst @@ -0,0 +1,78 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +================================= +WBRF - Wifi Band RFI Mitigations +================================= + +Due to electrical and mechanical constraints in certain platform designs +there may be likely interference of relatively high-powered harmonics of +the GPU memory clocks with local radio module frequency bands used by +certain Wifi bands. + +To mitigate possible RFI interference producers can advertise the +frequencies in use and consumers can use this information to avoid using +these frequencies for sensitive features. + +When a platform is known to have this issue with any contained devices, +the platform designer will advertise the availability of this feature via +ACPI devices with a device specific method (_DSM). +* Producers with this _DSM will be able to advertise the frequencies in use. +* Consumers with this _DSM will be able to register for notifications of +frequencies in use. + +Some general terms +================== + +Producer: such component who can produce high-powered radio frequency +Consumer: such component who can adjust its in-use frequency in + response to the radio frequencies of other components to + mitigate the possible RFI. + +To make the mechanism function, those producers should notify active use +of their particular frequencies so that other consumers can make relative +internal adjustments as necessary to avoid this resonance. + +ACPI interface +============== + +Although initially used by for wifi + dGPU use cases, the ACPI interface +can be scaled to any type of device that a platform designer discovers +can cause interference. + +The GUID used for the _DSM is 7B7656CF-DC3D-4C1C-83E9-66E721DE3070. + +3 functions are available in this _DSM: + +* 0: discover # of functions available +* 1: record RF bands in use +* 2: retrieve RF bands in use + +Driver programming interface +============================ + +.. kernel-doc:: drivers/platform/x86/amd/wbrf.c + +Sample Usage +============= + +The expected flow for the producers: +1. During probe, call `acpi_amd_wbrf_supported_producer` to check if WBRF + can be enabled for the device. +2. On using some frequency band, call `acpi_amd_wbrf_add_remove` with 'add' + param to get other consumers properly notified. +3. Or on stopping using some frequency band, call + `acpi_amd_wbrf_add_remove` with 'remove' param to get other consumers notified. + +The expected flow for the consumers: +1. During probe, call `acpi_amd_wbrf_supported_consumer` to check if WBRF + can be enabled for the device. +2. Call `amd_wbrf_register_notifier` to register for notification + of frequency band change(add or remove) from other producers. +3. Call the `amd_wbrf_retrieve_freq_band` initally to retrieve + current active frequency bands considering some producers may broadcast + such information before the consumer is up. +4. On receiving a notification for frequency band change, run + `amd_wbrf_retrieve_freq_band` again to retrieve the latest + active frequency bands. +5. During driver cleanup, call `amd_wbrf_unregister_notifier` to + unregister the notifier. From patchwork Wed Nov 29 09:13:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472478 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="l4jwISMy" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF5C1BFD; Wed, 29 Nov 2023 01:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JTUuFIbr6kkbOBZefuvDJUEAMzJ0SSfnErfi2jK3wERgc/lGgFMNhLJvf/5ZgDBEZjb1SnSc4xkSH73g5DVlZEdJptwqBcFmG37imCxi3ITedGWjzAj7sFZ1YD/iOJ7uAfO9mEMGW67SNyXA5BHpjPEbag4X5Ch4bXetoeN9SCK7vldPiRz3oerDLfKXqcn7/zRe6uLVM8E7sAs28q/tULNKfpUeQcW/uyWvY6QDrcQtqMRN/ftvnj6wWK/AK4KLAaTIPQbLMcZxSQf3SqZTtpeNHNvsvA1cfGlYODWUU9u0lwtI4fvh/KrLzP/I56yNsCGwoUpZPYVCuLgXjVmcSQ== 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=SKFSQJSAGZOxQax56bNPWfTbmfVQiNdrX37BllB2UVM=; b=Klc/ca9UR6fzEgoyGTrgI9FpJOhMEo225Of5EGTeNohasynd2FACDVBwDkWc+pYP3U6Idx39EhWGklGiyWOo9NKoQrhkNXRSnOpwkL275e4UtvPST2JkJVsU6C/taTYcqqh2tb9/aB19IFM5nQoh97SygdkGf8sUcPchE572/ZBiHBFFuxiw+l7me4sq181/+A3rscc0H2eixUsG7CFbi3S1JEGGOr/9YOp/hCzGM1VGu5DE0hsbEd4lMLj78/S1eRajJ6+v/TmbUwtAHT04cKg6duylIaUSN0BLPV8CE32qAOQMJUrQRARPWdBO2KjzDvdwIFF4wRaJIf/upUF2FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=SKFSQJSAGZOxQax56bNPWfTbmfVQiNdrX37BllB2UVM=; b=l4jwISMyOFa0aqCq3iP4MW3m8C8BkoIaGW2vrfaNygp5EAwJSdMsFt+O0+gUAb5VyNebhvXpih1Sq/6X8Dq+QJwTMWJCCqFyDPbUzH9kjzgw9c1XzADP9ktgI4IdEXD9Anu2f/OSH/+k8OI58KkfFNr5UCkhCDKtzadLnnMj+Js= Received: from BL0PR02CA0083.namprd02.prod.outlook.com (2603:10b6:208:51::24) by IA0PR12MB8422.namprd12.prod.outlook.com (2603:10b6:208:3de::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22; Wed, 29 Nov 2023 09:14:33 +0000 Received: from MN1PEPF0000ECD9.namprd02.prod.outlook.com (2603:10b6:208:51:cafe::61) by BL0PR02CA0083.outlook.office365.com (2603:10b6:208:51::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22 via Frontend Transport; Wed, 29 Nov 2023 09:14:33 +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 MN1PEPF0000ECD9.mail.protection.outlook.com (10.167.242.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:33 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:26 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Ma Jun , Evan Quan Subject: [PATCH v14 2/9] platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature Date: Wed, 29 Nov 2023 17:13:41 +0800 Message-ID: <20231129091348.3972539-3-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD9:EE_|IA0PR12MB8422:EE_ X-MS-Office365-Filtering-Correlation-Id: 2dade31c-c8d1-4cac-17e9-08dbf0bb99cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nmuKq6RQ4pPbfNjFHhLmhmkGpGVtqGv0Ij9pajZFnGfX64yPB2HsXqD3CTTbMPseQ7PWLvBmiO4os/U8wyvpIGcD6t0t5Dh0H2idSd4IzKAmCXs4LFnrZzw9ge3ZWUp3a7X5bWxDNtvlAHcV85AA4FJSll+YQJnUFskSzyKr53OQNAq4ItkqVJnatSZiK2i51lox4p8xDg2ZmIqJY/Fr3E03OzNXATCOIBH3ZQFx/QGh4gW7TIzeLtC0fZqSTbG4S+E1EXSiBrTmItfgpPn+YoRKdBBwvx++mcsK9UE8iLO7cDHj9iVHJO7fYaYMb2gj5G8/k+Q+aOlWFSJSl/67Yfnk5yMrYcGXJAgIDc2XoS4hLuk0e91zkOyN8HO2o5lUjBIUgiiT4tRZhcPuaJKaM4c4GvHvNVL+JNZjllU/4WoJdx44iY1SGRenmEjnJqr5ASWxJL4JAoghcXSKqXlsJyEAd4ZX91K0BBSE4rEeILtFbmUL9FuzuI2bsBs+r0aPTE9mJ5SzZEANuqKXIl2ZcthSY+f7KeHzsG4YmpYpFFtWQKNxI4dSVfHqsm1i1ACW4OCmf87AGJj3KHAgEMo5PCGV0QVseEoiHi1iKiFnJU3a6YcvM5gLmrzXkKdXTye/oqLt36NnJFMJtciaJU3WNafJa7aLN6XydgepIBKf3r3+EjAKJ6xE0UrDBkzlWWctBh+iIVtFKH9eSehxzii6Vd7I8IKKbFxlDWxpYHXM4lEqZiLGJNqjrH+1tAlhgpLrYXyXrcRvx81+xDm431ENG2oRhGefaAdyWIaCHo0aWFQ= 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:(13230031)(4636009)(346002)(136003)(376002)(39860400002)(396003)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(82310400011)(36840700001)(40470700004)(70206006)(70586007)(40480700001)(54906003)(41300700001)(83380400001)(4326008)(8676002)(36860700001)(478600001)(7416002)(2906002)(5660300002)(30864003)(110136005)(316002)(86362001)(8936002)(45080400002)(6666004)(32650700002)(7696005)(40460700003)(36756003)(356005)(2616005)(81166007)(1076003)(16526019)(26005)(921008)(82740400003)(426003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:33.2362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2dade31c-c8d1-4cac-17e9-08dbf0bb99cb 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: MN1PEPF0000ECD9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8422 Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7. To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance. Co-developed-by: Evan Quan Signed-off-by: Evan Quan Signed-off-by: Ma Jun Reviewed-by: Mario Limonciello --- v11: - fix typo(Simon) v12: - Fix the code logic (Rafael) - Move amd_wbrf.c to drivers/platform/x86/amd/wbrf.c - Updated Evan's email because he's no longer at AMD.Thanks for his work in earlier versions. v13: - Fix the format issue (IIpo Jarvinen) - Add comment for some functions v14: - Use the apci_check_dsm and acpi_evaluate_dsm (Hans de Goede) --- drivers/platform/x86/amd/Kconfig | 15 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/wbrf.c | 337 ++++++++++++++++++++++++++++++ include/linux/acpi_amd_wbrf.h | 94 +++++++++ 4 files changed, 447 insertions(+) create mode 100644 drivers/platform/x86/amd/wbrf.c create mode 100644 include/linux/acpi_amd_wbrf.h diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig index 55f3a2fc6aec..ac2b7758a04f 100644 --- a/drivers/platform/x86/amd/Kconfig +++ b/drivers/platform/x86/amd/Kconfig @@ -18,3 +18,18 @@ config AMD_HSMP If you choose to compile this driver as a module the module will be called amd_hsmp. + +config AMD_WBRF + bool "AMD Wifi RF Band mitigations (WBRF)" + depends on ACPI + default n + help + WBRF(Wifi Band RFI mitigation) mechanism allows Wifi drivers + to notify the frequencies they are using so that other hardware + can be reconfigured to avoid harmonic conflicts. + + AMD provides an ACPI based mechanism to support WBRF on platform with + appropriate underlying support. + + This mechanism will only be activated on platforms that advertise a + need for it. diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile index f04932b7a7d1..dcec0a46f8af 100644 --- a/drivers/platform/x86/amd/Makefile +++ b/drivers/platform/x86/amd/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/ amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o obj-$(CONFIG_AMD_PMF) += pmf/ +obj-$(CONFIG_AMD_WBRF) += wbrf.o diff --git a/drivers/platform/x86/amd/wbrf.c b/drivers/platform/x86/amd/wbrf.c new file mode 100644 index 000000000000..36e90a1159be --- /dev/null +++ b/drivers/platform/x86/amd/wbrf.c @@ -0,0 +1,337 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Frequency Band Manage Interface + * Copyright (C) 2023 Advanced Micro Devices + */ + +#include +#include + +#define ACPI_AMD_WBRF_METHOD "\\WBRF" + +/* + * Functions bit vector for WBRF method + * + * Bit 0: WBRF supported. + * Bit 1: Function 1 (Add / Remove frequency) is supported. + * Bit 2: Function 2 (Get frequency list) is supported. + */ +#define WBRF_ENABLED 0x0 +#define WBRF_RECORD 0x1 +#define WBRF_RETRIEVE 0x2 + +#define WBRF_REVISION 0x1 + +/* + * The data structure used for WBRF_RETRIEVE is not naturally aligned. + * And unfortunately the design has been settled down. + */ +struct amd_wbrf_ranges_out { + u32 num_of_ranges; + struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES]; +} __packed; + +static const guid_t wifi_acpi_dsm_guid = + GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c, + 0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70); + +/* + * Used to notify consumer (amdgpu driver currently) about + * the wifi frequency is change. + */ +static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head); + +static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ranges_in_out *in) +{ + union acpi_object argv4; + union acpi_object *tmp; + union acpi_object *obj; + u32 num_of_ranges = 0; + u32 num_of_elements; + u32 arg_idx = 0; + int ret; + u32 i; + + if (!in) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { + if (in->band_list[i].start && in->band_list[i].end) + num_of_ranges++; + } + + /* + * The num_of_ranges value in the "in" object supplied by + * the caller is required to be equal to the number of + * entries in the band_list array in there. + */ + if (num_of_ranges != in->num_of_ranges) + return -EINVAL; + + /* + * Every input frequency band comes with two end points(start/end) + * and each is accounted as an element. Meanwhile the range count + * and action type are accounted as an element each. + * So, the total element count = 2 * num_of_ranges + 1 + 1. + */ + num_of_elements = 2 * num_of_ranges + 2; + + tmp = kcalloc(num_of_elements, sizeof(*tmp), GFP_KERNEL); + if (!tmp) + return -ENOMEM; + + argv4.package.type = ACPI_TYPE_PACKAGE; + argv4.package.count = num_of_elements; + argv4.package.elements = tmp; + + /* save the number of ranges*/ + tmp[0].integer.type = ACPI_TYPE_INTEGER; + tmp[0].integer.value = num_of_ranges; + + /* save the action(WBRF_RECORD_ADD/REMOVE/RETRIEVE) */ + tmp[1].integer.type = ACPI_TYPE_INTEGER; + tmp[1].integer.value = action; + + arg_idx = 2; + for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { + if (!in->band_list[i].start || !in->band_list[i].end) + continue; + + tmp[arg_idx].integer.type = ACPI_TYPE_INTEGER; + tmp[arg_idx++].integer.value = in->band_list[i].start; + tmp[arg_idx].integer.type = ACPI_TYPE_INTEGER; + tmp[arg_idx++].integer.value = in->band_list[i].end; + } + + obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, WBRF_RECORD, &argv4); + + if (!obj) + return -EINVAL; + + if (obj->type != ACPI_TYPE_INTEGER) { + ret = -EINVAL; + goto out; + } + + ret = obj->integer.value; + if (ret) + ret = -EINVAL; + +out: + ACPI_FREE(obj); + kfree(tmp); + + return ret; +} + +/** + * acpi_amd_wbrf_add_remove - add or remove the frequency band the device is using + * + * @dev: device pointer + * @action: remove or add the frequency band into bios + * @in: input structure containing the frequency band the device is using + * + * Broadcast to other consumers the frequency band the device starts + * to use. Underneath the surface the information is cached into an + * internal buffer first. Then a notification is sent to all those + * registered consumers. So then they can retrieve that buffer to + * know the latest active frequency bands. Consumers that haven't + * yet been registered can retrieve the information from the cache + * when they register. + * + * Return: + * 0 for success add/remove wifi frequency band. + * Returns a negative error code for failure. + */ +int acpi_amd_wbrf_add_remove(struct device *dev, uint8_t action, struct wbrf_ranges_in_out *in) +{ + struct acpi_device *adev; + int ret; + + adev = ACPI_COMPANION(dev); + if (!adev) + return -ENODEV; + + ret = wbrf_record(adev, action, in); + if (ret) + return ret; + + blocking_notifier_call_chain(&wbrf_chain_head, WBRF_CHANGED, NULL); + + return 0; +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_add_remove); + +static bool acpi_amd_wbrf_supported_system(void) +{ + acpi_status status; + acpi_handle handle; + + status = acpi_get_handle(NULL, ACPI_AMD_WBRF_METHOD, &handle); + + return ACPI_SUCCESS(status); +} + +/** + * acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled + * for the device as a producer + * + * @dev: device pointer + * + * Check if the platform equipped with necessary implementations to + * support WBRF for the device as a producer. + * + * Return: + * true if WBRF is supported, otherwise returns false + */ +bool acpi_amd_wbrf_supported_producer(struct device *dev) +{ + struct acpi_device *adev; + + adev = ACPI_COMPANION(dev); + if (!adev) + return false; + + if (!acpi_amd_wbrf_supported_system()) + return false; + + + return acpi_check_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, BIT(WBRF_RECORD)); +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_supported_producer); + +/** + * acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled + * for the device as a consumer + * + * @dev: device pointer + * + * Determine if the platform equipped with necessary implementations to + * support WBRF for the device as a consumer. + * + * Return: + * true if WBRF is supported, otherwise returns false. + */ +bool acpi_amd_wbrf_supported_consumer(struct device *dev) +{ + struct acpi_device *adev; + + adev = ACPI_COMPANION(dev); + if (!adev) + return false; + + if (!acpi_amd_wbrf_supported_system()) + return false; + + return acpi_check_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, BIT(WBRF_RETRIEVE)); +} +EXPORT_SYMBOL_GPL(acpi_amd_wbrf_supported_consumer); + +/** + * amd_wbrf_retrieve_freq_band - retrieve current active frequency + * bands + * + * @dev: device pointer + * @out: output structure containing all the active frequency bands + * + * Retrieve the current active frequency bands which were broadcasted + * by other producers. The consumer who calls this API should take + * proper actions if any of the frequency band may cause RFI with its + * own frequency band used. + * + * Return: + * 0 for getting wifi freq band successfully. + * Returns a negative error code for failure. + */ +int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *out) +{ + struct amd_wbrf_ranges_out acpi_out = {0}; + struct acpi_device *adev; + union acpi_object *obj; + union acpi_object param; + int ret = 0; + + adev = ACPI_COMPANION(dev); + if (!adev) + return -ENODEV; + + param.type = ACPI_TYPE_STRING; + param.string.length = 0; + param.string.pointer = NULL; + + obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid, + WBRF_REVISION, WBRF_RETRIEVE, ¶m); + if (!obj) + return -EINVAL; + + /* + * The return buffer is with variable length and the format below: + * number_of_entries(1 DWORD): Number of entries + * start_freq of 1st entry(1 QWORD): Start frequency of the 1st entry + * end_freq of 1st entry(1 QWORD): End frequency of the 1st entry + * ... + * ... + * start_freq of the last entry(1 QWORD) + * end_freq of the last entry(1 QWORD) + * + * Thus the buffer length is determined by the number of entries. + * - For zero entry scenario, the buffer length will be 4 bytes. + * - For one entry scenario, the buffer length will be 20 bytes. + */ + if (obj->buffer.length > sizeof(acpi_out) || obj->buffer.length < 4) { + dev_err(dev, "Wrong sized WBRT information"); + ret = -EINVAL; + goto out; + } + memcpy(&acpi_out, obj->buffer.pointer, obj->buffer.length); + + out->num_of_ranges = acpi_out.num_of_ranges; + memcpy(out->band_list, acpi_out.band_list, sizeof(acpi_out.band_list)); + +out: + ACPI_FREE(obj); + return ret; +} +EXPORT_SYMBOL_GPL(amd_wbrf_retrieve_freq_band); + +/** + * amd_wbrf_register_notifier - register for notifications of frequency + * band update + * + * @nb: driver notifier block + * + * The consumer should register itself via this API so that it can get + * notified on the frequency band updates from other producers. + * + * Return: + * 0 for registering a consumer driver successfully. + * Returns a negative error code for failure. + */ +int amd_wbrf_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(amd_wbrf_register_notifier); + +/** + * amd_wbrf_unregister_notifier - unregister for notifications of + * frequency band update + * + * @nb: driver notifier block + * + * The consumer should call this API when it is longer interested with + * the frequency band updates from other producers. Usually, this should + * be performed during driver cleanup. + * + * Return: + * 0 for unregistering a consumer driver. + * Returns a negative error code for failure. + */ +int amd_wbrf_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL(amd_wbrf_unregister_notifier); diff --git a/include/linux/acpi_amd_wbrf.h b/include/linux/acpi_amd_wbrf.h new file mode 100644 index 000000000000..15b54734a080 --- /dev/null +++ b/include/linux/acpi_amd_wbrf.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Wifi Band Exclusion Interface (AMD ACPI Implementation) + * Copyright (C) 2023 Advanced Micro Devices + */ + +#ifndef _ACPI_AMD_WBRF_H +#define _ACPI_AMD_WBRF_H + +#include +#include + +/* The maximum number of frequency band ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +/* Record actions */ +#define WBRF_RECORD_ADD 0x0 +#define WBRF_RECORD_REMOVE 0x1 + +/** + * struct freq_band_range - Wifi frequency band range definition + * @start: start frequency point (in Hz) + * @end: end frequency point (in Hz) + */ +struct freq_band_range { + u64 start; + u64 end; +}; + +/** + * struct wbrf_ranges_in_out - wbrf ranges info + * @num_of_ranges: total number of band ranges in this struct + * @band_list: array of Wifi band ranges + */ +struct wbrf_ranges_in_out { + u64 num_of_ranges; + struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES]; +}; + +/** + * enum wbrf_notifier_actions - wbrf notifier actions index + * @WBRF_CHANGED: there was some frequency band updates. The consumers + * should retrieve the latest active frequency bands. + */ +enum wbrf_notifier_actions { + WBRF_CHANGED, +}; + +#if IS_ENABLED(CONFIG_AMD_WBRF) +bool acpi_amd_wbrf_supported_producer(struct device *dev); +int acpi_amd_wbrf_add_remove(struct device *dev, uint8_t action, struct wbrf_ranges_in_out *in); +bool acpi_amd_wbrf_supported_consumer(struct device *dev); +int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *out); +int amd_wbrf_register_notifier(struct notifier_block *nb); +int amd_wbrf_unregister_notifier(struct notifier_block *nb); +#else +static inline +bool acpi_amd_wbrf_supported_consumer(struct device *dev) +{ + return false; +} +static inline +int acpi_amd_wbrf_remove_exclusion(struct device *dev, struct wbrf_ranges_in_out *in) +{ + return -ENODEV; +} +static inline +int acpi_amd_wbrf_add_exclusion(struct device *dev, struct wbrf_ranges_in_out *in) +{ + return -ENODEV; +} +static inline +bool acpi_amd_wbrf_supported_producer(struct device *dev) +{ + return false; +} +static inline +int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *out) +{ + return -ENODEV; +} +static inline +int amd_wbrf_register_notifier(struct notifier_block *nb) +{ + return -ENODEV; +} +static inline +int amd_wbrf_unregister_notifier(struct notifier_block *nb) +{ + return -ENODEV; +} +#endif /* CONFIG_AMD_WBRF */ + +#endif /* _ACPI_AMD_WBRF_H */ From patchwork Wed Nov 29 09:13:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472479 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Xv9UV82R" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2042.outbound.protection.outlook.com [40.107.237.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52E3510E4; Wed, 29 Nov 2023 01:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bzlyTDY5xSR/g2IpngCwxosfuGK17lIjoSAZTz5Mi+trEI6/qUxce5/C7RgK4WqhVj98jnweE/ZgT9m05ISKD9GOwXeoTFpZGgVOkoeyUW+rGce97h4yeSBuVjm6vII8bmnR+wqrdmxqm9o7+aOW3yLl9rGJbhUB7qRR9fICvzqvzOlODskJ4VuqM5wFC56Lbg1PuEkpm9fjNILytPqJs73i4D2DN0frS4aWA1N4BFgXhp1lUiTRe/+0+J0ck+H0c8fjjwS4173HiTKbzH0Cl+JsB/9vTMjqX//ximqfG9jFDCuf3mTEXTv3aAFqPGZLsMxpK6fD+bEDJlBc2VyY9w== 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=bttUKqwJUPN6jJABYzXAVbvz0oMxc1gHVVluGh6R+j0=; b=GvB0WChiLmB4/OLmahkxMpkTNYzN3+uC3oWxnUPHpJ+Xnv2Vtyr3GYdXwTL69DiI9cp3C+ky4ENEN+nVbCX4ZPbflIuvsrbux6uKCkp+HMB7Vm5J32+6uZ3riRUXYCkl1IZfite9poz7I8fgXN/eZij7/WDPUCrwlCilWmWGbeoqEWXOZCleJX/lv1EKnmK4Psl6hOYfyL5rc8VXTIlt6UPUpibcqkSrSKjbJVINzkrBv/r1tkkj6BXj3dGToUhVXsIOyfEs3S/BVIiBChfpkvikAoac7tDn67ap6BufsMHh/TpebLgMvE0U1O/ZEJtMhiulHwmZSntRGY/p7Rje0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=bttUKqwJUPN6jJABYzXAVbvz0oMxc1gHVVluGh6R+j0=; b=Xv9UV82R2mpHglioXAEn0Cw8Vv7d7TaFpjaR25+KzZOFLtHhWEQ2uK/Qa/4ZvzwnAXzU4DL/Ty0Dz22pptyOwfZCh4mibuCa9uajrFqGaeuKrBO85cGhkj4KJDxKRnYj3rRvTy2Hzq1+E7N7Qjq8gDV07bh0Rfv9bx1LQlF65gw= Received: from BL1P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::35) by DS0PR12MB7996.namprd12.prod.outlook.com (2603:10b6:8:14f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.28; Wed, 29 Nov 2023 09:14:38 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:2c4:cafe::78) by BL1P223CA0030.outlook.office365.com (2603:10b6:208:2c4::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27 via Frontend Transport; Wed, 29 Nov 2023 09:14:38 +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 MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:38 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:32 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v14 3/9] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing Date: Wed, 29 Nov 2023 17:13:42 +0800 Message-ID: <20231129091348.3972539-4-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDA:EE_|DS0PR12MB7996:EE_ X-MS-Office365-Filtering-Correlation-Id: f2845fb7-8307-48cf-1d45-08dbf0bb9cf3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dsnStSmM/6vAIye++eR5XIS96HmSWlJ7KHwkC0FFRBOvgpDVALJd9MKAb5vTn323PnWRHo00xSEZIWxXjx4nNLq6J2lHHwuftCwMy/7vo0PC96hDqbZ5RKRu2mugcoVAk+a79usi/HQZx5hFeQMgm6WS76sQv+LkeV+q5WX1iYJnB2PfMnRh6szka1Jec5FLzQFST/Tb0uDT+fDgiFuSPy8FbAgvEDTwnJ9HlekjC7PuKxsXY6i8ao5MQu1AZdwNh0qhUtjVLLI0fomi8a4J6nRaPbqHkmXLCJ3yQGIpIyCsUac0JYoZOVsDm46knrvqEY+Lgoh61jWxWb7WVlQXDIcewhqQ+f9kqlyu9gD2YRSH+CxdYRM3xLdASlT5aCyvVoGP/wM9pspI4Le4IdGWO/xgv7I5omC0ujGOtX+9UzYMjd2W2cFxp2hP5jLtjgDnaKaTvqXWHYhuiLWG0oObiSI/5t+Rgs2G8bqaPluJpaVczD3mhySSa/GL/iuHVf3VN66BtU8sWvNl9iNmCUjjtRh2npeV/wIrDQBO1XOMsShTJNm7Mii+9CW/6GG+ADjgQ6bv6+erUPiS8xTc8kjzbIJCSyEgCKUAkCK00O+elp+EZNM/qGWOn9nZaIHdUOA++gIdDuSJO9ttLabsa9eU/7kgU9zEx6vVlEgG2/0Xx7AMs/0mrA32F/qHLEa/tQno6ArzCfCsZsSTREUhFty89RNTRRp2x1fw0DaCkLZCMVvXGKRKlX6u8x9YjC+OoqSxjg+OwZ79W/uNR6ruQexK14Akc3swLRo9qxtlMBp3qdg= 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:(13230031)(4636009)(396003)(376002)(346002)(39860400002)(136003)(230922051799003)(82310400011)(1800799012)(64100799003)(186009)(451199024)(36840700001)(40470700004)(4326008)(41300700001)(8936002)(2906002)(40480700001)(8676002)(336012)(2616005)(7696005)(426003)(86362001)(316002)(921008)(54906003)(5660300002)(7416002)(1076003)(478600001)(36860700001)(32650700002)(82740400003)(16526019)(36756003)(26005)(6666004)(70206006)(110136005)(45080400002)(70586007)(81166007)(40460700003)(356005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:38.5317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2845fb7-8307-48cf-1d45-08dbf0bb9cf3 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7996 From: Evan Quan The newly added WBRF feature needs this interface for channel width calculation. Signed-off-by: Ma Jun Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- v8->v9: - correct typo(Mhz -> MHz) (Johnson) v13: - Fix the format issue (IIpo Jarvinen) --- include/net/cfg80211.h | 9 +++++++++ net/wireless/chan.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b137a33a1b68..08f0d7184167 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -976,6 +976,15 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** + * nl80211_chan_width_to_mhz - get the channel width in MHz + * @chan_width: the channel width from &enum nl80211_chan_width + * + * Return: channel width in MHz if the chan_width from &enum nl80211_chan_width + * is valid. -1 otherwise. + */ +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width); + /** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 2d21e423abdb..dfb4893421d7 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef) return true; } -static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) { int mhz; @@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) } return mhz; } +EXPORT_SYMBOL(nl80211_chan_width_to_mhz); static int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c) { From patchwork Wed Nov 29 09:13:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472481 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vhNqAtQ7" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545B81FEC; Wed, 29 Nov 2023 01:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hc/h3qc/PCA16PIDQ84blK0svASIL2XGkBmSEdWubcq2hxjDRuynzrXfQYyJpUZziLx/7X/+AadIClPcn4m0Mckonf14MfdQcNB9FAq7bXGcYZPnjiZvnjpqTzG0MBHeP51m1P+c2Ai5/aWOdMSBb/rkmSs0qpsPbW1KnOl4Nwh2mi1ysKQzGj1yWsqXDzXkJGwMh0Jtn6dYMJHSIc3vi//s54fVqllpz6ZrM/CwKvXAZ1FSrpavydCo30Bg+ttSlpOn66LXjwnZgK8bCsYXsrsop30pf9CDS/VdBy9CqpGExF6MzJtkK7D02zFJ3WTB07J/0xJXN+o7ei4mLAJNeQ== 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=tYuDtvnVZanXhljP9hxBdIyFe/iV530N5ek5C/lOkMg=; b=abznsKiPKjT59EQ7XJZ7Em4pI30mwzi40yOs8n3XWCJ4U6CBu/W4POojzh6WBcaBMJnoJqkpRip6ndPaWFM6GTdodMaB2oqGr3H3gGrV2srzXEsPwbHFwD6n7VjmPFVifD5CaPpdtrEEPvgxmT3yYFhjM6VdX/cgrGj79V9BiwOcgstPjecYm1PhDrgUFDzaiCOpyFJijDiVo6l5BKcVXzcSoVeAi/es5pt5ciUTjLpRIojQgq+g2bvinrBFgv/oml628xe5tKjXsNrXsWhRlC5ahvU/0I96hkXmUbZssKctViK266vftPPlAmZZK2RlByIqbpgWhpyrGuGlod8rgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=tYuDtvnVZanXhljP9hxBdIyFe/iV530N5ek5C/lOkMg=; b=vhNqAtQ76BtKG+WmakRk5QOcpNlTcfwY5RDNsGFDdjaE58lPaU/X9bspJcEUeHBIJe8uXaGF+ClbbuM7d6ohIV8n0Q/WZQu1Tdz0TgPSPbyacrG5wqgkyIcRLOWCBwr2YuH62wyXmcX+pXW8NCjL8puil8/jJCE3T98iyiNnb3Q= Received: from BLAPR03CA0063.namprd03.prod.outlook.com (2603:10b6:208:329::8) by IA0PR12MB8696.namprd12.prod.outlook.com (2603:10b6:208:48f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22; Wed, 29 Nov 2023 09:14:43 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::50) by BLAPR03CA0063.outlook.office365.com (2603:10b6:208:329::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.23 via Frontend Transport; Wed, 29 Nov 2023 09:14:43 +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 MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:43 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:38 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v14 4/9] wifi: mac80211: Add support for WBRF features Date: Wed, 29 Nov 2023 17:13:43 +0800 Message-ID: <20231129091348.3972539-5-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDB:EE_|IA0PR12MB8696:EE_ X-MS-Office365-Filtering-Correlation-Id: 8907733a-1d35-4ecd-9042-08dbf0bb9ffe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lGeGsOuoFbnNpWlk8rdJpCg6K1IQibkXkBILU/906tXBkOzrNZ56jjNB9PXwA+ri57rVtU1EwaEktWoX9Qel8TETs6htp6r4kgohRrphJjOj9UN4GYPISLWq2LLtCLiz7rXvTPtOpk3XZ68FvJF/46EJcKHLZ+Dl/mKVhp2bOPD+OE7zBKHj0NhxrisbeOsNpWU+5QhuhzL8oz+HZnUks3gCCD3CGH+q9XkN5jeLCUCdCYBtOlmybq2/bRIBkxktRD+BOXn4G3cMKnYf+SYEeT9hUeQkR7hpgIFUF79Vr0Tfx5MY95Ak65wdpTJOA8okKg/kEokRV1EWhKxxcgn+I4r5k0oXv3ZbgmwC6MhYRbmGQObIaVZQquNm5+/jAgpfEKfHM62f85sPJ5oLimQH1QoQ9nAvsygLjIGWJ2mwd57vtdSDcQ1z909HcG+mJ/sUgRhLneFFZuN1a3Mu9O9oHOIaiLKUsVoBQLxkgoyiJNSiVjv1M7PfiQ1EDg9MzJu8XyisKIReX2uN7dZnjCzZ0MKmU8esPcJt1ViM1wfHrBLdntEu01sRKPhub2A+labuoFFZqBYX67BGXChxKAPzFlic5xLEy+2bKAUytSsi2Vy1KuqlyqjCB+34/FGqR1eJHqMjktftjv10vZgex6xWYMgiufmQneexJBpf8S/OIVhgxKjQgbxcLNMxnZsUGunGYbtHWKBHsL7lT4SXAFINFuee78RFQw0rUJjRjx00uxeb9nbsLq8vA8/tDXeTI9pS4kRymNPN6gClk87NjM6Lb+VBu2PBL7CRQFeny2AsWrM= 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:(13230031)(4636009)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(186009)(451199024)(82310400011)(1800799012)(64100799003)(40470700004)(36840700001)(40480700001)(40460700003)(36860700001)(32650700002)(81166007)(356005)(921008)(7416002)(86362001)(2906002)(5660300002)(26005)(1076003)(7696005)(82740400003)(336012)(426003)(83380400001)(16526019)(2616005)(6666004)(110136005)(478600001)(45080400002)(36756003)(41300700001)(54906003)(316002)(4326008)(8936002)(70586007)(70206006)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:43.6399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8907733a-1d35-4ecd-9042-08dbf0bb9ffe 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8696 From: Evan Quan To support the WBRF mechanism, Wifi adapters utilized in the system must register the frequencies in use (or unregister those frequencies no longer used) via the dedicated calls. So that, other drivers responding to the frequencies can take proper actions to mitigate possible interference. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan Signed-off-by: Ma Jun --- v1->v2: - place the new added member(`wbrf_supported`) in ieee80211_local(Johannes) - handle chandefs change scenario properly(Johannes) - some minor fixes around code sharing and possible invalid input checks(Johannes) v2->v3: - drop unnecessary input checks and intermediate APIs(Mario) - Separate some mac80211 common code(Mario, Johannes) v3->v4: - some minor fixes around return values(Johannes) v9->v10: - get ranges_in->num_of_ranges set and passed in(Johannes) v12: - use acpi_amd_wbrf_add_remove to replace the acpi_amd_wbrf_add_exclusion acpi_amd_wbrf_remove_exclusion v13: - Fix the format issue (IIpo Jarvinen) - Remove KHZ_TO_HZ and use HZ_PER_KHZ in linux/units.h (IIpo Jarvinen) v14: - Use KHZ_PER_MHZ in linux/units.h (IIpo Jarvinen) --- net/mac80211/Makefile | 2 + net/mac80211/chan.c | 9 ++++ net/mac80211/ieee80211_i.h | 7 +++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 95 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index c9eb52768133..4406b4f8f3b9 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -67,4 +67,6 @@ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) obj-y += tests/ +mac80211-y += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 1d928f29ad6f..aa24585359ee 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -507,11 +507,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) { @@ -667,6 +672,8 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, lockdep_assert_wiphy(local->hw.wiphy); + ieee80211_add_wbrf(local, &ctx->conf.def); + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -746,6 +753,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 84df104f272b..9dd51481fb87 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1559,6 +1559,8 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + + bool wbrf_supported; }; static inline struct ieee80211_sub_if_data * @@ -2600,4 +2602,9 @@ 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); + +void ieee80211_check_wbrf_support(struct ieee80211_local *local); +void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 033a5261ac3a..f2ece7793573 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1405,6 +1405,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..a05c5b971789 --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface for WLAN + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include +#include +#include "ieee80211_i.h" + +void ieee80211_check_wbrf_support(struct ieee80211_local *local) +{ + struct wiphy *wiphy = local->hw.wiphy; + struct device *dev; + + if (!wiphy) + return; + + dev = wiphy->dev.parent; + if (!dev) + return; + + local->wbrf_supported = acpi_amd_wbrf_supported_producer(dev); + dev_dbg(dev, "WBRF is %s supported\n", + local->wbrf_supported ? "" : "not"); +} + +static void get_chan_freq_boundary(u32 center_freq, u32 bandwidth, u64 *start, u64 *end) +{ + bandwidth *= KHZ_PER_MHZ; + center_freq *= KHZ_PER_MHZ; + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in Hz is expected */ + *start = *start * HZ_PER_KHZ; + *end = *end * HZ_PER_KHZ; +} + +static void get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in_out *ranges_in) +{ + u64 start_freq1, end_freq1; + u64 start_freq2, end_freq2; + int bandwidth; + + bandwidth = nl80211_chan_width_to_mhz(chandef->width); + + get_chan_freq_boundary(chandef->center_freq1, bandwidth, &start_freq1, &end_freq1); + + ranges_in->band_list[0].start = start_freq1; + ranges_in->band_list[0].end = end_freq1; + ranges_in->num_of_ranges = 1; + + 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; + ranges_in->num_of_ranges++; + } +} + +void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in_out ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + get_ranges_from_chandef(chandef, &ranges_in); + + acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_ADD, &ranges_in); +} + +void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in_out ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + get_ranges_from_chandef(chandef, &ranges_in); + + acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_REMOVE, &ranges_in); +} From patchwork Wed Nov 29 09:13:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472480 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="OxIAHbs4" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8BB31FF6; Wed, 29 Nov 2023 01:14:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B5ocyAclNEpg20nr29maeqJh5BsANYXMZc+DoJZUK9mFG6lGf+IzFHo1LKv5UGisDkwhp2QaXMMO7C+kLYuiBy2RzKvzbNTV2ZL/rsk/gDM10zEWcTKucF/gDoTF2ckXyGK0lugoByHUX/5NhTp4i6OpntqplmDe1hccRD4Od/5X1HtxiD7HebPEQE9/O3bj7/9mLjqUMoaTYaFkT9hD4tojlhzsTAFyorYeA517axwK3v1QVw6w2XCaXyuYqWNFsyNCaVYgduJfSFeKDpXZP67EqP2lY5etk9Po+h10XwEJWl1xwXQa43/caJtEWoX4sxl7KbQyZZshz1pbLML4xA== 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=Eq4Rd42wlQROzNEuYi5sI2kBGJwdt8GypGSMU480cBc=; b=e32BA1/4UJn3TLodkZyLvcRzHZ+3WUIBSFk14w6RVzJQTjIB1DEUTtKP8kAb9HfmCHu2b/fVykJw7CSnmfZ7qN/YQ0Y8jlk1xYyywTz+DX4nXQaawUSJ4IEJpL3wmX3rXkhjtnSRV0ydIjEiy1OQcikMZ+5fDA15dtkh3jd3q7cqhXO9vsOjfzY62Wgy2wFTO1Fkz3nOGbKZriRIfTLPHdH234BC8gQHV7N/cswhb3vbjjA+bNNwkdyqVwZEatyIqJTBqX09dTtEbTVi1BYCzQEWdFO+GwZYs4xUPlEkE6FnC5n91sCs2f7HpRV/KMOOWmosfqBqc7jPD1Fxt/by2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=Eq4Rd42wlQROzNEuYi5sI2kBGJwdt8GypGSMU480cBc=; b=OxIAHbs4Qq+sdyTHcxXxSBDDHJIr9VNVNH09IRBqDsuy7lh95IIrhYc9t5phm8F3cFhOPFdqTuhyvG2q8k/kqe8DGi7esSIPSjbBo9roJpbsnzBDLn0BM/eWxlPESD8/1JZUUh8dTCh+IN7BZ99b8jdaNT36+PZpnuKFSXODiz0= Received: from BLAPR03CA0180.namprd03.prod.outlook.com (2603:10b6:208:32f::10) by PH0PR12MB7864.namprd12.prod.outlook.com (2603:10b6:510:26c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Wed, 29 Nov 2023 09:14:49 +0000 Received: from MN1PEPF0000ECD4.namprd02.prod.outlook.com (2603:10b6:208:32f:cafe::c9) by BLAPR03CA0180.outlook.office365.com (2603:10b6:208:32f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29 via Frontend Transport; Wed, 29 Nov 2023 09:14:49 +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 MN1PEPF0000ECD4.mail.protection.outlook.com (10.167.242.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:48 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:43 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v14 5/9] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Date: Wed, 29 Nov 2023 17:13:44 +0800 Message-ID: <20231129091348.3972539-6-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD4:EE_|PH0PR12MB7864:EE_ X-MS-Office365-Filtering-Correlation-Id: 5db8c314-6f6e-4c2b-5c1c-08dbf0bba30c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KkT0zIFSBiUwe1rXaTAYvR/jWRfW8TK4kj721qUU+XJhGLKSX28tM/xZ1aatfpJX/GyzI5tJy/DyigylRkbRu/jVJxQka2QIDTv+JfJfa5ThGTRnDVkTpRLJzXEQQoeOSDplcwB2DE8T99NjU7iVaebXxh/Q6xVklMvpaRJvqssk+IVPfrb+baqgySqG19zD3WWtgnkx9ZQfeN6lZcbZkrT1QzChB395YXSdp7fgGY9PhfXlp3WNI2cFnwro9Khuju5JclT3PsSKhdtNDXso+BQlZaiIwubR9IQW4SPdSChmEv1c+3MOP2VxR2NXSQh6/u+mqDEppPXnzx/YcI1iH+zbxLwJS+c4pRfNTHP1ukkvS+NFuIUdYujPVwVZ5CfcaS3g/qERvzykqUMsh68eXaJYKJzq2M4ZG/S142cqTSgbRwdpXdFSfiX+VLAIROfCp7BiuBJar3MVAkn/ZAPYD5SXbuZ9vRkOclzcD135UNVN5JP2mJhUHBtni7C5L6SJSlu0EWsolmJ2L1qPZOYzeENHerUlUqNqtWL2/dIprSnPaQ4kdwItmcKcg7JF/i/hzHSikW97pL0n0XfHRraPmnBH5cwau3uWM8naAYO4ZdRbF7+Gf5KG/JRiIL2kZuiEbYTUu4KCQHFt+BeF0NAvpM3BXugUFDHY6R+nR3/2uk1JENkXrSUe/DhwTVKqqQp0wtE8//NSILeRUkBXEPOUezDFf5TaNPT22pQ882JIaNEBmMc5KhBMbyNbwkoygFGGzZquxSOTnNBLXrwXbRnoOJtsC/FFcNbwLsaWeuERDwY= 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:(13230031)(4636009)(136003)(346002)(376002)(396003)(39860400002)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(82310400011)(36840700001)(40470700004)(40460700003)(2616005)(1076003)(26005)(16526019)(45080400002)(8676002)(32650700002)(81166007)(426003)(336012)(8936002)(7696005)(4326008)(82740400003)(110136005)(86362001)(478600001)(2906002)(54906003)(5660300002)(70206006)(316002)(36860700001)(70586007)(83380400001)(356005)(7416002)(921008)(41300700001)(36756003)(40480700001)(15650500001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:48.7635 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5db8c314-6f6e-4c2b-5c1c-08dbf0bba30c 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: MN1PEPF0000ECD4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7864 From: Evan Quan Add those data structures to support Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello Signed-off-by: Ma Jun v13: - Move some struct variables to amdgpu_smu.h to reduce duplicate code --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 11 +++++++++++ .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 3 ++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 3 ++- .../drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 5 ++--- .../drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) 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 8def291b18bc..50bdf452bf5d 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -1476,6 +1476,17 @@ enum smu_baco_seq { __dst_size); \ }) +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; + #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/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 9dd1ed5b8940..b114d14fc053 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 @@ -1615,7 +1615,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 62b7c0daff68..8b1496f8ce58 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 @@ -1605,7 +1605,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 e2ee855c7748..e862d323caab 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,10 +138,9 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C - #define PPSMC_MSG_DALNotPresent 0x4E - -#define PPSMC_Message_Count 0x4F +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 //Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1 diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h index 6aaefca9b595..a6bf9cdd130e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h @@ -134,6 +134,7 @@ #define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A #define PPSMC_MSG_SetPriorityDeltaGain 0x4B #define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52 #endif From patchwork Wed Nov 29 09:13:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472482 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="klywkv68" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D25C1BCF; Wed, 29 Nov 2023 01:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GvDjXKlVGH3Ry3c+2M25SMHVKfY0bm78dh8WL+X27lr92HpwM7/yKBjksYpCFL2cE9sQPj/ZgUdZNE/yAEjpoTjKGOegwL4PEBhv132cRrfxle4nl1uYw370JJBYvF8Pa38lujKgSHByjbeCnZw5yt/jlIVdrWPAzgb5a83J1qflIc0L0gWDscRDhVr/kNieLR3MU5u4JdZdvYatsVGibJWRJ5KVxN83FA48ao3IjAExHmwThtwWNTgokFWLO6fV2Zr4HCODAB8K4W/jJqQTUeQlzM17hW4ofePcwtyI3vn+kqxWYiiCzeDpDH3vrzeMwic/g6k4Qr7azDsPzFLDvg== 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=SrXEFJm4NexmSF4kFbETnrGqjZ510VRnm0y/J5FBL+o=; b=Bf0qtONjV09bOBHG6ub1xrsf8SV/2KWc/F0G5umjbdsRr6GsyCULmCTBGiHp1oYyyW07PUBk65GZ5NfpIzdqke9N7/Laits26i9BieiaFVu0nlAqUG2RqCD2JX2EB6USGf8iBZ4o49QgqEBUcENuTAAOFjoZxsU4eSpDaJg4JVvnGAt4LgF9cYqXqjdLfl0i4dUxAkPmFwb83do+P/OSymrrIMJ4L6Po6BGQxv0+Q80hGM7EwI2vMNbP5Q3NHnpUKfvgKX4lCOPiQsmBdm2o2okKbVM6D2O9iT4CDU1XOVXrs7/EhovJHHJmcpcR29EXDMIngAfL53Y5LTaBOoR1Hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=SrXEFJm4NexmSF4kFbETnrGqjZ510VRnm0y/J5FBL+o=; b=klywkv68QZ3l+6EqUsjSyMD7G8xmN9nNV+d6342VcqivRUwqk8BJwBH0/cDhYsWwZWtbLdf+nt/PB1C9trGTnxJSxi9fsrDKsEYCAYbNKmbnZ00f4zjQxYYwbyaMlK6rAKul57LAUPOfxQwfeGqe95O+NsOAotdQ6CgRNVUW45M= Received: from BLAPR03CA0066.namprd03.prod.outlook.com (2603:10b6:208:329::11) by CH3PR12MB9025.namprd12.prod.outlook.com (2603:10b6:610:129::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Wed, 29 Nov 2023 09:14:54 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::df) by BLAPR03CA0066.outlook.office365.com (2603:10b6:208:329::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.30 via Frontend Transport; Wed, 29 Nov 2023 09:14:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:54 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:48 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v14 6/9] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Date: Wed, 29 Nov 2023 17:13:45 +0800 Message-ID: <20231129091348.3972539-7-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDB:EE_|CH3PR12MB9025:EE_ X-MS-Office365-Filtering-Correlation-Id: 08f69fae-9d52-4066-9209-08dbf0bba639 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qeZWbcRTT+/gFuIhfOUO9kdTr4wQAo6DLb1IMXzpLZStrh2svjhywuiYgZZ95YOb39Fp1LPp90WFLyxtolDokse8JBNznQ3/FAiJA0PM0PLGL2JsQG7GUw/iLPid/CEgBwzJVu1yk4wStSABNGztNOZRuzk93RoN+UqO4pzmcYTY97M8IxoY9k87IjhJuKjcvCJ3UiLbxPB2xnA2iSj53Mb49EEclywFsBA2n1YAFh2pl3kjNNMocHg14aWiq5p6vMFPEIqQ7iD0PcY3O3JfxLw+VgolWR4qvNt77x8OTz4BJtvKQJ2NBldl6g/ClLNn9hA6vfp3XZgjbgJWPghLcLvOugX+p3NyvKt1aMRJ5odCxgE1n0gi0jJ790o5vqYiqtSJI6r+rszlnDtNLMWATIuvTsjzclclpUzKwmxlgpXeWg0iji9XYVDRkzUu/CLVD8EiAo2jy82KodV0OxJAU5dPDd0elf/7ROnD2t0vpAv09ql4aZkEzZlYwEv3bmrMnNlDXK++zN+xSkBJXs5n0gZnb7OSsAu2RoLn9TDNvlZ5IyqhuwOoTt50QGIyqzGXkQIJzaytTt2RzzmOq4CwTAP5bReDFinODH8UWHYxGvEtqiGzwDSFOrc1dDsy1OS4SXqAXZSJ8UzM3vNLSJJAeUGoYQGxXH8qW82LLOo+l4iIxbSkLtgeFwJfLmuItctZJrQ9Ri9rqb1ijkSLsFHAdPNSq26ylFps7MesLcPG8u+WEJ7DYQdQ2dWNHbWv4k+NKlm6hagcj5J3XM4RZpCQm7C4avRlwgN9jCrK7W/TfJk= 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:(13230031)(4636009)(376002)(136003)(396003)(39860400002)(346002)(230922051799003)(64100799003)(186009)(1800799012)(82310400011)(451199024)(40470700004)(36840700001)(40480700001)(2616005)(41300700001)(36756003)(921008)(1076003)(81166007)(36860700001)(356005)(30864003)(26005)(32650700002)(83380400001)(336012)(426003)(7416002)(5660300002)(82740400003)(70206006)(2906002)(16526019)(86362001)(70586007)(7696005)(6666004)(8936002)(8676002)(45080400002)(4326008)(478600001)(40460700003)(54906003)(316002)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:54.1086 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08f69fae-9d52-4066-9209-08dbf0bba639 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9025 From: Evan Quan With WBRF feature supported, as a driver responding to the frequencies, amdgpu driver is able to do shadow pstate switching to mitigate possible interference(between its (G-)DDR memory clocks and local radio module frequency bands used by Wifi 6/6e/7). Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello Signed-off-by: Ma Jun --- v1->v2: - update the prompt for feature support(Lijo) v8->v9: - update parameter document for smu_wbrf_event_handler(Simon) v9->v10: v10->v11: - correct the logics for wbrf range sorting(Lijo) v13: - Fix the format issue (IIpo Jarvinen) --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 17 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 191 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 22 ++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 5 files changed, 235 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index afec09930efa..7c799403ad18 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -249,6 +249,8 @@ extern int amdgpu_seamless; extern int amdgpu_user_partt_mode; +extern int amdgpu_wbrf; + #define AMDGPU_VM_MAX_NUM_CTX 4096 #define AMDGPU_SG_THRESHOLD (256*1024*1024) #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 3095a3a864af..391ebf294565 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -207,6 +207,7 @@ int amdgpu_user_partt_mode = AMDGPU_AUTO_COMPUTE_PARTITION_MODE; int amdgpu_umsch_mm; int amdgpu_seamless = -1; /* auto */ uint amdgpu_debug_mask; +int amdgpu_wbrf = -1; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); @@ -961,6 +962,22 @@ module_param_named(seamless, amdgpu_seamless, int, 0444); MODULE_PARM_DESC(debug_mask, "debug options for amdgpu, disabled by default"); module_param_named(debug_mask, amdgpu_debug_mask, uint, 0444); +/** + * 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); + /* 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 1ead323f1c78..a03d0e9961f6 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1322,6 +1322,170 @@ 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_in_out wbrf_exclusion = {0}; + struct freq_band_range *wifi_bands = wbrf_exclusion.band_list; + struct amdgpu_device *adev = smu->adev; + uint32_t num_of_wbrf_ranges = MAX_NUM_OF_WBRF_RANGES; + uint64_t start, end; + int ret, i, j; + + ret = amd_wbrf_retrieve_freq_band(adev->dev, &wbrf_exclusion); + if (ret) { + dev_err(adev->dev, "Failed to retrieve exclusion ranges!\n"); + return ret; + } + + /* + * The exclusion ranges array we got might be filled with holes and duplicate + * entries. For example: + * {(2400, 2500), (0, 0), (6882, 6962), (2400, 2500), (0, 0), (6117, 6189), (0, 0)...} + * We need to do some sortups to eliminate those holes and duplicate entries. + * Expected output: {(2400, 2500), (6117, 6189), (6882, 6962), (0, 0)...} + */ + for (i = 0; i < 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 = num_of_wbrf_ranges - 1; j > i; j--) + if (wifi_bands[j].start && wifi_bands[j].end) + break; + + /* no valid entry left */ + if (j <= i) + break; + + start = wifi_bands[i].start = wifi_bands[j].start; + end = wifi_bands[i].end = wifi_bands[j].end; + wifi_bands[j].start = 0; + wifi_bands[j].end = 0; + num_of_wbrf_ranges = j; + } + + /* eliminate duplicate entries */ + for (j = i + 1; j < 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; + } + } + } + + /* Send the sorted wifi_bands to PMFW */ + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + /* Try to set the wifi_bands again */ + if (unlikely(ret == -EBUSY)) { + mdelay(5); + ret = smu_set_wbrf_exclusion_ranges(smu, wifi_bands); + } + + return ret; +} + +/** + * smu_wbrf_event_handler - handle notify events + * + * @nb: notifier block + * @action: event type + * @_arg: event data + * + * Calls relevant amdgpu function in response to wbrf event + * notification from kernel. + */ +static int smu_wbrf_event_handler(struct notifier_block *nb, + unsigned long action, void *_arg) +{ + struct smu_context *smu = container_of(nb, struct smu_context, wbrf_notifier); + + switch (action) { + case WBRF_CHANGED: + smu_wbrf_handle_exclusion_ranges(smu); + break; + default: + return NOTIFY_DONE; + }; + + return NOTIFY_OK; +} + +/** + * smu_wbrf_support_check - check wbrf support + * + * @smu: smu_context pointer + * + * Verifies the ACPI interface whether wbrf is supported. + */ +static void smu_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + smu->wbrf_supported = smu_is_asic_wbrf_supported(smu) && amdgpu_wbrf && + acpi_amd_wbrf_supported_consumer(adev->dev); + + if (smu->wbrf_supported) + dev_info(adev->dev, "RF interference mitigation is supported\n"); +} + +/** + * smu_wbrf_init - init driver wbrf support + * + * @smu: smu_context pointer + * + * Verifies the AMD ACPI interfaces and registers with the wbrf + * notifier chain if wbrf feature is supported. + * Returns 0 on success, error on failure. + */ +static int smu_wbrf_init(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + int ret; + + if (!smu->wbrf_supported) + return 0; + + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; + ret = amd_wbrf_register_notifier(&smu->wbrf_notifier); + if (ret) + return ret; + + /* + * Some wifiband exclusion ranges may be already there + * before our driver loaded. To make sure our driver + * is awared of those exclusion ranges. + */ + ret = smu_wbrf_handle_exclusion_ranges(smu); + if (ret) + dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + + return ret; +} + +/** + * smu_wbrf_fini - tear down driver wbrf support + * + * @smu: smu_context pointer + * + * Unregisters with the wbrf notifier chain. + */ +static void smu_wbrf_fini(struct smu_context *smu) +{ + if (!smu->wbrf_supported) + return; + + amd_wbrf_unregister_notifier(&smu->wbrf_notifier); +} + static int smu_smc_hw_setup(struct smu_context *smu) { struct smu_feature *feature = &smu->smu_feature; @@ -1414,6 +1578,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. @@ -1512,6 +1685,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; } @@ -1567,6 +1749,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) @@ -1723,6 +1912,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 50bdf452bf5d..84f0f53397bb 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -22,6 +22,8 @@ #ifndef __AMDGPU_SMU_H__ #define __AMDGPU_SMU_H__ +#include + #include "amdgpu.h" #include "kgd_pp_interface.h" #include "dm_pp_interface.h" @@ -569,6 +571,10 @@ struct smu_context { struct delayed_work swctf_delayed_work; enum pp_xgmi_plpd_mode plpd_mode; + + /* data structures for wbrf feature support */ + bool wbrf_supported; + struct notifier_block wbrf_notifier; }; struct i2c_adapter; @@ -1360,6 +1366,22 @@ struct pptable_funcs { * management. */ int (*dpm_set_umsch_mm_enable)(struct smu_context *smu, bool enable); + + /** + * @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 enable); + + /** + * @set_wbrf_exclusion_ranges: notify SMU the wifi bands occupied + */ + int (*set_wbrf_exclusion_ranges)(struct smu_context *smu, + struct freq_band_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 80b3c3efc006..dc1301f86065 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, enable) smu_ppt_funcs(enable_uclk_shadow, 0, smu, enable) +#define smu_set_wbrf_exclusion_ranges(smu, freq_band_range) smu_ppt_funcs(set_wbrf_exclusion_ranges, -EOPNOTSUPP, smu, freq_band_range) #endif #endif From patchwork Wed Nov 29 09:13:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472483 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="k5JXo8Pv" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C98F82118; Wed, 29 Nov 2023 01:15:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FBzKmbr+/cLUOMc82J9cCturc3hOTZ1qs0HOubmfBwf/m+0kLjAMMd//S3XQwXnVrOkh2sL4DrEddjbotzynEmB0PzghMJLhDW3HnwzEUAkIGSVEranhMkhZTkrRmP5sMPIci3eeIowEUlFzYLUFHGuGt28C/dNkAn2haFW1uNUn2GXaJVIO2ln+fafUtXXahd6rnBCPweDIQA5s+4tkIbDIRw29KuAgZqagOGRQjfKHfcyhUcx9TFKlM8SCt8HzZZ0exN6IuKf3L8BeAfSx+6Twa7ExOnpq5uRfPPpgO9uA7JSXvR2TnMHbOR9wBRW70V6qg0LlfyHGJgsbER5Tmg== 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=Ck0/Zec1rIA99wezp0Dn6dwNDDI5D2OZnYxse1/vjUo=; b=abN/y2HDYdBdErXczUYUP53inys2Cm36PkWGq3B0Mnfu4rFXcnMpi9H3Dn9T84UWvbDzZ78fl9tHJwcBkwT1WcZfh41SN89GBlIp6NOW0s4UqoIobNUfaMhS62HNrIetxyuVbWYwRh7KNs7NEHGJbW/Gqdnd8cwDwhtYA0n6oZg7Qus9fmU0WlsYKUInx1FYgx4RJzh+piPa75A1VFjQtKiFGAbM80g/Gdl0Y++Em26n0QjEqGgShD0uEd4Ux56jDnssWPUQpbNmc1hjwhJVuoOwiZGZ8F1rtIcV3HfSVnhA0G8jPQAw9cYKzzOaweKk5MLp44VeQUl7KuEwTumCkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=Ck0/Zec1rIA99wezp0Dn6dwNDDI5D2OZnYxse1/vjUo=; b=k5JXo8PvAsYHdPOAVHtIYeIaGW6XTpU2H6/AHch/D7WwQfgAlFeOaMyqnTfzvoCqb5tTAKIGGUQxhyv9nhLon88WeeBATQ1AvBJ4FXep9qLHmMON7p6vl0ZVTe+02z3oVWgFLkRESKz9I6ZXmUPXtIOC7Ix2okz0q9tAK418jyY= Received: from MN2PR15CA0011.namprd15.prod.outlook.com (2603:10b6:208:1b4::24) by DS7PR12MB6167.namprd12.prod.outlook.com (2603:10b6:8:98::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Wed, 29 Nov 2023 09:14:59 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:1b4:cafe::f8) by MN2PR15CA0011.outlook.office365.com (2603:10b6:208:1b4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29 via Frontend Transport; Wed, 29 Nov 2023 09:14:59 +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 MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:14:59 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:54 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v14 7/9] drm/amd/pm: add flood detection for wbrf events Date: Wed, 29 Nov 2023 17:13:46 +0800 Message-ID: <20231129091348.3972539-8-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|DS7PR12MB6167:EE_ X-MS-Office365-Filtering-Correlation-Id: e64844a2-b090-4a45-679f-08dbf0bba931 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sl9m8+h1dmjxIBlngOIXwJRUGLRngULI0/o6qc3aVLbYy6Xc636BGGo+e7CPcUe2QAqxEFNORM1iNBRpPXOERUM6WJYbiD0I1s/PJRbbTizJA52cNytCH0KwtgErZnkNXbm73hsd2GP7Rp4pgESDgaKBr+PAv+H/mi6VJm56kv7sYH2mbg+tGYtLZb0CVEGkuGobVIfvFJr/lGGXnEkIf3xF0I75VsgwOo/0Cli6LgeuIavxgOqyI/0/UW+C5e8ldbQyNfk+wyyPZcZPliJGOFS9byvJeJunZX3ppRLoCxJzfdZpQHdlb79tPCSOW9XqQ8hO1zIkAijTTPoubuGaUJ0wTSq3MhI3AkmY/RhUKslUR7H+YBsQ/9EoUnbMc4XMX7/Cx4jNNFrdIhpZHgZwCK7N2FztyO7qNvt12LLZCRolCfhB474Lg5Yv1hZn2/HSCcjOGlggWxsyCxgxqfZG9ANNVGkK240IPiNvcoNDE8/4T/xs+HVPntmGuT0rCWWQ6fqYrIOWF4ekheNndrWPgu4ZtZ8oMTnLpwt6ZjPjqFV+k7a2rhp9HlSmHwF9zI2WmQrpzHo8LsaMdLUR4ThTKe86V9zu22yvVLpPY2AuNz1pZjPqFtiFNJWuCeARAx2D/w+jp8S+Fd0pfaaoY3XNdOSmFWyw9hDN20SO0llNlhvRBSGV8nS11fTvqnJDQ6MGvK+XUjYJ/f3tOVmsfc0AWwWDwp1gS5F8bWwwF/k9XqXBroXOyrQHLbeRXa2fDowlJ8djnt/UaxR3xMpYkXEi7xdXD0yyqOVl9B3BzOnKaoc= 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:(13230031)(4636009)(346002)(376002)(136003)(39860400002)(396003)(230922051799003)(82310400011)(1800799012)(451199024)(186009)(64100799003)(40470700004)(36840700001)(26005)(83380400001)(81166007)(356005)(32650700002)(82740400003)(8936002)(4326008)(7416002)(45080400002)(6666004)(7696005)(336012)(426003)(36860700001)(110136005)(70206006)(316002)(70586007)(54906003)(5660300002)(8676002)(478600001)(86362001)(2906002)(36756003)(40480700001)(41300700001)(921008)(16526019)(2616005)(1076003)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:14:59.0726 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e64844a2-b090-4a45-679f-08dbf0bba931 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6167 From: Evan Quan To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello Signed-off-by: Ma Jun --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 29 +++++++++++++++---- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index a03d0e9961f6..b7ac9a460f3c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1410,7 +1410,8 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, switch (action) { case WBRF_CHANGED: - smu_wbrf_handle_exclusion_ranges(smu); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); break; default: return NOTIFY_DONE; @@ -1419,6 +1420,20 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, return NOTIFY_OK; } +/** + * smu_wbrf_delayed_work_handler - callback on delayed work timer expired + * + * @work: struct work_struct pointer + * + * Flood is over and driver will consume the latest exclusion ranges. + */ +static void smu_wbrf_delayed_work_handler(struct work_struct *work) +{ + struct smu_context *smu = container_of(work, struct smu_context, wbrf_delayed_work.work); + + smu_wbrf_handle_exclusion_ranges(smu); +} + /** * smu_wbrf_support_check - check wbrf support * @@ -1448,12 +1463,13 @@ static void smu_wbrf_support_check(struct smu_context *smu) */ static int smu_wbrf_init(struct smu_context *smu) { - struct amdgpu_device *adev = smu->adev; int ret; if (!smu->wbrf_supported) return 0; + INIT_DELAYED_WORK(&smu->wbrf_delayed_work, smu_wbrf_delayed_work_handler); + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; ret = amd_wbrf_register_notifier(&smu->wbrf_notifier); if (ret) @@ -1464,11 +1480,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; } /** @@ -1484,6 +1499,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; amd_wbrf_unregister_notifier(&smu->wbrf_notifier); + + cancel_delayed_work_sync(&smu->wbrf_delayed_work); } static int smu_smc_hw_setup(struct smu_context *smu) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 84f0f53397bb..b0d85ccb7d8c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -472,6 +472,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; struct amdgpu_irq_src irq_source; @@ -575,6 +581,7 @@ struct smu_context { /* data structures for wbrf feature support */ bool wbrf_supported; struct notifier_block wbrf_notifier; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter; From patchwork Wed Nov 29 09:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472484 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kD81BtWQ" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFCD61BE6; Wed, 29 Nov 2023 01:15:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OaS9wpu3BG5MF6M99I9BtC0lyGP8Jj9/D8hHL+4LGRYsQfIRzZHdMajuvcNo3M8uRZK0JlY0jhiicUjYcpqrxaOpEakYzwgcZt3zdPMytwLckxOhf+7+7puG2W6DddAWLuPq4x44vQeYdyNZOWzyZxQI6f2+Mlt5ACAvom2alM4A6MCHa5ZI5FY3w0iWAx2cQn1B5nF+oHGKENM0NdKlTIHZftl4MnHeZQVVqhJZSWL3uOjfoRFEjNZwYzi1T3IMewDcugCXhLqnCfS76qZhwrlbAYrv4qAPnvfS0Dd89kEW8cvmzBDaOPQAG+9dMYpyn8Y90m0fT34ei9snJ8BCxQ== 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=3RjSbbHzSwa60oAHpXK4C+TtRIPd4jE/RHHo2/xkcVg=; b=VgErDJKevfEL6gTH8+FW7dX6aWaN2VmyU553OQUHxwaQ37sfe1SdyCohQCzUIGXzjCHfnY2UXQhJku/WDZv3I8jfiPkL97slJK0b1JAaucC4F4bOfMpBjQ1kA+Y71YCaCoir8OipAFhoTewFtHq2QpmmdmIavGRRwhhMnwt58796DnrxGq7U4a65+uwLxHg8Qcw25nhT5JAceV5jURzhO8DTLF0lmSHAZPBRylQKWh59FCGWMcCd3yrPuzmrKqim6ldlhdKYmck//lLlgrxdB6L0+OcncqDkE04V79gQ6YQwZY5KZGmF4BYz9yVapLCixsiCXUJenH3d4y8MXd2reg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=3RjSbbHzSwa60oAHpXK4C+TtRIPd4jE/RHHo2/xkcVg=; b=kD81BtWQvQPkxkXvQAye+oekCpEnYRrm1FJDbb7L+iWL8RgJkNg5lPp6N1G8lehsHhV84JO1Z5DxWNfIxNuW29/znhpBJLCMHxYgIayIFLmoO/H1G8oWOuc/ud1DG8PP0lWOqhLxkHsrMSQgogK9m1nLt+LKIp8ZDulYs9uA7/4= Received: from MN2PR15CA0023.namprd15.prod.outlook.com (2603:10b6:208:1b4::36) by SA1PR12MB8721.namprd12.prod.outlook.com (2603:10b6:806:38d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22; Wed, 29 Nov 2023 09:15:04 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:1b4:cafe::91) by MN2PR15CA0023.outlook.office365.com (2603:10b6:208:1b4::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.26 via Frontend Transport; Wed, 29 Nov 2023 09:15:04 +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 MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:15:04 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:14:58 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Ma Jun , Evan Quan Subject: [PATCH v14 8/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Date: Wed, 29 Nov 2023 17:13:47 +0800 Message-ID: <20231129091348.3972539-9-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|SA1PR12MB8721:EE_ X-MS-Office365-Filtering-Correlation-Id: 95172ed7-07e9-49f2-cdfc-08dbf0bbac41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CtUCP659FKXaN8WIwkQdscV4pXkmN1/pLCnfEnK+zgep3wzMw3yqWWlKllhqce5wXfn/Y6fZqwCU4MtAdRXRd3D0GWl/Q7SzAxpQd54wPcG7wPwHDGiNh4R099z8dP9l1Pr/y/wRM2l6H2wVpxPqqRTlakZoYMXFIGA2+Q66q5LJdOSDvHvydm/kUk9VK4Kbl7Y3RgSiu4VarpQ2wGP0MOnbv4UodLQZPtObGmFF4dIoCLRayT7F1Ceid3YgFQNZ23AZ8/0DMYgi/HL6BxcrtBiXXZHWRvxHObMz4ML5VlW6ENrPxXEKOWFxoyY+m+Rzyh+Q5kS+v+ji5NIrxuzzvzn9RJ1ezw8niihp4aCoQ4u3xECUXfFHMd8hSyCP6iOksq0kNcjSqB5Gr50icNCQ6fo++HWeHTFFFQA4+5hO6qFQmtYEvIjj3BoC3Xghm7QjkpCiwHdSvI/Azd6LczWEoIyg7GksossjO/rorGs5Ti9ReqQg3/Qz1Qt88aOyI0ttuBUbzAfEO5OHqpCJE35bT/i2UBx/Fl0pGuxWRFpVp8F5Is57anaypzciwPD5pSof0PueK8LgJ6kAiDVqGK4VMX9HHW0k4Ns//IIDNS/Q9VYwMBpzjmbNli7iUQAuJEPlaGSM/TIvZ0oFk528ccr1W9agGyZ1jmKs7ujElcVxN348SxmqeXLbP6BfXpMI/D7J8NjoUpBA9gOt/jJx9mV3c6oxrmST0icFMovhXD5UCyJLJc+EDlnKiepAIOyCJEy0oDPV92jYjcq+nDuqVshzHNKZk2cf6wQVQNdoF41mGDQf42nUvwN/OqNesq/rXDt7YfHFogqYiomrSin0tnTHqA== 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:(13230031)(4636009)(346002)(376002)(39860400002)(396003)(136003)(230922051799003)(230173577357003)(230273577357003)(64100799003)(1800799012)(186009)(82310400011)(451199024)(36840700001)(40470700004)(5660300002)(8676002)(86362001)(82740400003)(316002)(70586007)(70206006)(81166007)(356005)(54906003)(110136005)(4326008)(40480700001)(7416002)(41300700001)(45080400002)(2906002)(36860700001)(8936002)(478600001)(32650700002)(36756003)(26005)(16526019)(921008)(6666004)(40460700003)(7696005)(2616005)(1076003)(83380400001)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:15:04.2132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 95172ed7-07e9-49f2-cdfc-08dbf0bbac41 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8721 Fulfill the SMU13.0.0 support for Wifi RFI mitigation feature. Co-developed-by: Evan Quan Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello Signed-off-by: Ma Jun --- v10->v11: - downgrade the prompt level on message failure(Lijo) v13: - Fix the format issue (IIpo Jarvinen) - Move function smu_v13_0_0_set_wbrf_exclusion_ranges to smu_v13_0.c as a generic code for later use (IIpo Jarvinen) --- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 4 ++ .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 48 +++++++++++++++++++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 22 +++++++++ 5 files changed, 78 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 b0d85ccb7d8c..dd187c081c94 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -23,6 +23,7 @@ #define __AMDGPU_SMU_H__ #include +#include #include "amdgpu.h" #include "kgd_pp_interface.h" @@ -319,6 +320,7 @@ enum smu_table_id { SMU_TABLE_PACE, SMU_TABLE_ECCINFO, SMU_TABLE_COMBO_PPTABLE, + SMU_TABLE_WIFIBAND, SMU_TABLE_COUNT, }; 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 9dd47d91093e..2b569fed1362 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h @@ -259,7 +259,8 @@ __SMU_DUMMY_MAP(PowerUpUmsch), \ __SMU_DUMMY_MAP(PowerDownUmsch), \ __SMU_DUMMY_MAP(SetSoftMaxVpe), \ - __SMU_DUMMY_MAP(SetSoftMinVpe), + __SMU_DUMMY_MAP(SetSoftMinVpe), \ + __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 95cb919718ae..07fe31ce26fa 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 @@ -301,5 +301,9 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu, int smu_v13_0_disable_pmfw_state(struct smu_context *smu); +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, bool enable); + +int smu_v13_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct freq_band_range *exclusion_ranges); #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 cf1b84060bc3..0dd3c7ad9d8b 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 @@ -2490,3 +2490,51 @@ int smu_v13_0_disable_pmfw_state(struct smu_context *smu) return ret == 0 ? 0 : -EINVAL; } + +int smu_v13_0_enable_uclk_shadow(struct smu_context *smu, bool enable) +{ + return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_EnableUCLKShadow, enable, NULL); +} + +int smu_v13_0_set_wbrf_exclusion_ranges(struct smu_context *smu, + struct freq_band_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_PER_MHZ); + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_PER_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, &wifi_bands, true); + if (ret) + dev_warn(smu->adev->dev, "Failed to set wifiband!"); + + return ret; +} 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 82c4e1f1c6f0..d74559fe3e83 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 @@ -169,6 +169,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowIHHostInterrupt, PPSMC_MSG_AllowIHHostInterrupt, 0), MSG_MAP(ReenableAcDcInterrupt, PPSMC_MSG_ReenableAcDcInterrupt, 0), MSG_MAP(DALNotPresent, PPSMC_MSG_DALNotPresent, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = { @@ -253,6 +254,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = { TAB_MAP(I2C_COMMANDS), TAB_MAP(ECCINFO), TAB_MAP(OVERDRIVE), + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_0_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -498,6 +500,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) @@ -2970,6 +2975,20 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu, return ret; } +static bool smu_v13_0_0_wbrf_support_check(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + + switch (adev->ip_versions[MP1_HWIP][0]) { + case IP_VERSION(13, 0, 0): + return smu->smc_fw_version >= 0x004e6300; + case IP_VERSION(13, 0, 10): + return smu->smc_fw_version >= 0x00503300; + default: + return false; + } +} + static 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, @@ -3050,6 +3069,9 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .gpo_control = smu_v13_0_gpo_control, .get_ecc_info = smu_v13_0_0_get_ecc_info, .notify_display_change = smu_v13_0_notify_display_change, + .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_set_wbrf_exclusion_ranges, }; void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu) From patchwork Wed Nov 29 09:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Jun X-Patchwork-Id: 13472485 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="1dGHcVWF" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6591C2128; Wed, 29 Nov 2023 01:15:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aXuzmrGRYTl7IP+YQ66/6pRGCiboNLnUVpiNfKoNxn5scLmTuC+1s+lSDn85Ti/IrWc1k23o8Ww4h4EGTP9Dvy1w11cLgL++EIcfhgk/EJW7HXq1WBioT/0amJON0cHUDNbmWUfLga+KpsThPZmvQBMdwFk3XQiSUCnoVRUtWWl4aGX1J8jYTt77N0J72gE31dQ3HxutgFrk7jbDgPdylfAuCAbRa/opu/Hzsl47stCNdnob22lBntRM+hoddNRQrUxlN5sS6IZkz5lNDAw0bOQDWo8xoLOHd1ECz+zQlGOi0zl1E4b2hWl+/y49w8f5jll4gXrJ8Sdc0fIpsjLwvw== 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=/FG/v7ogyS6xo4c1TLYkdS7kjTNds9VBLaPwExQZrCs=; b=e53e3lEKYBVSAsXrAu+26wPxhnbXsfj4B6fP8GIJ+ZgCFkf2jetrJJlmMUrEMvV9jCVYUaH0ivY3hmeu6OYX3D6FM4pwnKXhg//5to3jGqf9Fsw7JRN2aCtqLe0w0nm+wacMWXHtFG8RyZzIzEb9T7C8f1sK+RWGHqi/QhUxRBjL+O88WyTruMSM/2N7e19uGQrbS6AX0eeK03ddF0uzb9ripknRDK8io3twk4GEeafBWwt+kccIadLHXc/cVH0sr3KfC74HET6d3x/f7iusQMP3SLiK2WG24tFojeLy07jyFNCdBfD17h/osFdjDONcrAAtqRL7BuYO18oDV5GxEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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 (0) 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=/FG/v7ogyS6xo4c1TLYkdS7kjTNds9VBLaPwExQZrCs=; b=1dGHcVWFqDHv1m1AE38ElJnELDjpOa2Jy9uJf/1FCKrd0z5sjF5KMxInyy11QqXdwzWO22rzJVsH/5Y6XH8l7k7U5UPhHNAN8pLl5GDetDSkfohfLUtQ+08nJzXAhCd7WMgA//3XS9ALp+5Nw3yXPRCrHHDUFqP5mMeGmV5WLnc= Received: from MN2PR15CA0008.namprd15.prod.outlook.com (2603:10b6:208:1b4::21) by LV3PR12MB9401.namprd12.prod.outlook.com (2603:10b6:408:21c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22; Wed, 29 Nov 2023 09:15:10 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:1b4:cafe::2d) by MN2PR15CA0008.outlook.office365.com (2603:10b6:208:1b4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.24 via Frontend Transport; Wed, 29 Nov 2023 09:15:10 +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 MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Wed, 29 Nov 2023 09:15:10 +0000 Received: from compile-server.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.34; Wed, 29 Nov 2023 03:15:04 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v14 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Date: Wed, 29 Nov 2023 17:13:48 +0800 Message-ID: <20231129091348.3972539-10-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129091348.3972539-1-Jun.Ma2@amd.com> References: <20231129091348.3972539-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|LV3PR12MB9401:EE_ X-MS-Office365-Filtering-Correlation-Id: d0fc49ef-0bad-41c6-cc74-08dbf0bbafcb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AgRmZ8hC+ZuwEjzVvo+/PcGzlA8VquqnvEMbOiaVqTa4MaF8KIykKcCX7h5pHEd5jjpEtAKIvM5AfxzwKtoWJeljj/4aZV/HOiEyFaGwGgc7XwieL1NwbYnbilNn8mPv901iac9AqEJ5wRUDXxzTX0XRZralobocPhkRPKh/b0optOeKalRtvLe2FC2+yafIcfh+vGU5CQu5DUNUYPbl0wEMa23BSRjhYZAA70sXO41IVduty86sANBs5cTVEf3oN+KJUkv1CBwI3MCxtmIXODo+Bt874L8FZMo/4zc0Ji5Y3u0MM8SC4fWg/73Lc43Jd+Vda59QcJuLgyAyJAP82MXBkBYfVWoby2KpUsA0+rvQCylQaFMYIUXrqq7V4d59TAfU6dvFiBKp/hRxljrHje2mR0zxhtbqHA5kz2B6V57bAda17R688td1q47KaRRaMFq+K4nboomcBOwnYQVg1Ifdl9hIc+qE9QSDCdqlI80JZ3M60LmqMhaTFMYnoGSp0KrnPtTvgD3sznt+9KeBBknN+alIoy/oXIb0F0mUEprP6Z2Mxurq1nL4vOWRUPbUc+r3Yt4DlZQjZ33NUzRRhQigra4aLLVRaWaSukzDmktTAfdANYG5shZcQ8kKYIygOdP9M85oD/+UmSOJsp3Htgl0EPo1K3w4m6zkgWNX5/5SlCTUfjWhXCmptZfSztPF2jrmUOmOpGPYZuQNbhcoh5cvSLZtIH/SwgpmJQSykXRdXCnAtYzTvk1yShSvPpBQ+H6Dq250KPpOtplTpy35/YOBuFKh9QvaxDWfTDqXPpnvGxNrLKFtf696sV2pBXuM9hXXFyOgxMMH007nM5usYw== 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:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(230173577357003)(230922051799003)(230273577357003)(451199024)(1800799012)(64100799003)(186009)(82310400011)(40470700004)(36840700001)(40480700001)(2616005)(426003)(45080400002)(16526019)(1076003)(478600001)(26005)(336012)(40460700003)(6666004)(356005)(82740400003)(81166007)(921008)(36756003)(86362001)(41300700001)(7416002)(2906002)(5660300002)(83380400001)(32650700002)(7696005)(36860700001)(316002)(54906003)(4326008)(8676002)(70586007)(70206006)(110136005)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:15:10.1507 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0fc49ef-0bad-41c6-cc74-08dbf0bbafcb 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9401 From: Evan Quan Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello Signed-off-by: Ma Jun --- v10->v11: - downgrade the prompt level on message failure(Lijo) v13: - Fix the format issue (IIpo Jarvinen) - Remove duplicate code (IIpo Jarvinen) --- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 13 +++++++++++++ 1 file changed, 13 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 81eafed76045..eb507cbf5c3d 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 @@ -140,6 +140,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit, 0), MSG_MAP(NotifyPowerSource, PPSMC_MSG_NotifyPowerSource, 0), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = { @@ -222,6 +223,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, TAB_MAP(OVERDRIVE), + TAB_MAP(WIFIBAND), }; static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { @@ -512,6 +514,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) @@ -2567,6 +2572,11 @@ 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 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, @@ -2635,6 +2645,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_set_wbrf_exclusion_ranges, }; void smu_v13_0_7_set_ppt_funcs(struct smu_context *smu)