From patchwork Thu Apr 14 16:47:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 563829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56A0FC433EF for ; Thu, 14 Apr 2022 17:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243256AbiDNRGE (ORCPT ); Thu, 14 Apr 2022 13:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244879AbiDNRFp (ORCPT ); Thu, 14 Apr 2022 13:05:45 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2089.outbound.protection.outlook.com [40.107.93.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F20125E0; Thu, 14 Apr 2022 09:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dRLPDJDDMGQR35P0GlZIj+jtowbamRysKVZWv5zFNE+IUJ1OH5SY+8xhmxT8WdtnCQRviF9E680AMV6m5XjVv2YO0m4n1j4FjbqETr/oas233zIAc2foW10urWUgdkQcSGJ8s3Z2o9zxLaZFfod4ZEwi1o75NS1F/AYwEtdBJuITM9Ra+KlAaaezT9IAdRBC04VqcaOVsT9wH1vPfqL+ME21Tmd29GqJYDA/lZVoA5nhJrRYwCyPb222QTXUDpghSNPi6moeUZ2SERd/7GSskUxuI3QqdBh10I7od4hSMRxhwwuqkoCVoQEH5XdjOBebYLvHUD+rfYYE//CNnM9hEA== 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=QsH9v9VH2C3CZrHYQj8mjGeSpGLVTuZ58YPEeXGvtjg=; b=DVHhVPzLuAE42nMIVahWvgco6H++2hJH1SAjF0pVdCRQjoI3+dUMqU6H05bX5U3NNchSaSlFMuj3v4kzkyGj3vbs+mlX/+1P22sf/i2SOO2ChU5t+PnDrwZ9l+Jn9W3hHNZOlYx1JNfOZlG9EuLrsg0dyMXdw2zbYGJvh0oL7EP/4Ym1jE+3Z94hLaRtTqnEDvjOu9dmzOjok4vjoG9aRy7mZUC5NtPwXvllXhcbdyigfG81WJN8TEggnPPhzZt0okksooF/GeUxMp8xajbYdcmsF/BKuRSPeOvtAT9ypBAvJIAyhRuBm3vCHyAztQm6DVNoE5Cq47LuceFhEaPkPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QsH9v9VH2C3CZrHYQj8mjGeSpGLVTuZ58YPEeXGvtjg=; b=AwQKvf1PuKsts2sBfBgYJ5blbTNb6c9XZo6d7YrjAugFS3lcyTTnDseMB47d/S47ZP7bk6/hP1hxd4LrXCQcbeoBILXZdHWmRmwvkVSk+c3TmV3hWa3pSEwTU0ADaZIVKQ7I+4hbwsjWW8GgnCRDc45m6yaC3ZbbPzAPSmI9/78= Received: from BN6PR2001CA0019.namprd20.prod.outlook.com (2603:10b6:404:b4::29) by BYAPR12MB2613.namprd12.prod.outlook.com (2603:10b6:a03:69::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Thu, 14 Apr 2022 16:48:13 +0000 Received: from BN8NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::84) by BN6PR2001CA0019.outlook.office365.com (2603:10b6:404:b4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20 via Frontend Transport; Thu, 14 Apr 2022 16:48:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT068.mail.protection.outlook.com (10.13.177.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5164.19 via Frontend Transport; Thu, 14 Apr 2022 16:48:13 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Apr 2022 11:48:07 -0500 From: Mario Limonciello To: Rui Huang , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , Perry Yuan , open list , "Mario Limonciello" Subject: [PATCH v3 1/6] cpufreq: Export acpu_cpufreq_exit for other drivers to call Date: Thu, 14 Apr 2022 11:47:56 -0500 Message-ID: <20220414164801.1051-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220414164801.1051-1-mario.limonciello@amd.com> References: <20220414164801.1051-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93a64e5b-59b8-44f4-c3c6-08da1e3690f3 X-MS-TrafficTypeDiagnostic: BYAPR12MB2613:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6XZpx5xkHH+VGlI5etn80u53SnSD5Mw+OsQcz+d8rDLwlg0hPOrL9RgDOU0N7mn1THnUiC3cwWV+Lql0qA46NAFExmbHwFfUsyxKG7T+PhlXnxUK8GzF1hXIuZx7ARZMYnTs8ZDaf3sLSqOORPzVrxYfNq3USOIAvAVNiGc+Mniaf3W2DlyL6/1I/b4O5ANCvUj1g2rJbOvqxNgLbFcuYTXWCat2j3X88QAfDlRo4kamx7JWcH3y8HPZkdQ+TsnGC8FkII5lQjqALiumWRFwvFnN5++YHsPzAAe2hyBeFp9Mx003wOktw9kqwhmkLjdzGMOmpzXkiw4Mipy26eBgTccfG0g90B/Mu2WDjLFfJzxQfg8k4L126wqb+dgQivmn2EjLpDmExpAwHmPzcOiMcdT3busC2t3PV2ZdfVUcDv6Ht93S8LyhcJ2O4QtI1Ixd+9C+4O1DSXfTFsHKndhjOxm3vpV0xHUzt4WueyTDj9MsvzrDP4a/7uDDylf4MrEJKr6YPnbZMaMEpiSKFvDMlvfuYSUctexsYrHXRlfO3T7s4WF8S1OHGd4uqNomvoIC5i4ZKOmKrJWbfMHdmjIJzVdMehAiYNfqWoVANQlX92yhb4weQEqMvu2YFlbUw+tyGtsb/cBUhYRNk2MA9NDBP8EyMOw8/jguBsloaZaqsNZwktLNJUlBwnI4uKLZmKC/kdj6WQ8HErHxJMBKUmEq5A== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(2906002)(40460700003)(508600001)(5660300002)(44832011)(8936002)(82310400005)(6666004)(1076003)(81166007)(186003)(26005)(16526019)(7696005)(2616005)(356005)(54906003)(110136005)(86362001)(83380400001)(36860700001)(426003)(316002)(70206006)(8676002)(47076005)(336012)(36756003)(4326008)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2022 16:48:13.4683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93a64e5b-59b8-44f4-c3c6-08da1e3690f3 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: BN8NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2613 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently, the only way to load an alternative cpufreq driver is to unload acpi-cpufreq first. Loosen that restriction to allow other kernel modules to unregister a registered driver. Signed-off-by: Mario Limonciello --- v2->v3: * Move to include header * Create a new symbol to prevent NX protected page fault calling exit function from other modules. v1->v2: * Export symbol instead of changing internals drivers/cpufreq/acpi-cpufreq.c | 10 ++++++++-- include/linux/cpufreq.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 3d514b82d055..38358ed1f932 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -1033,7 +1033,7 @@ static int __init acpi_cpufreq_init(void) return ret; } -static void __exit acpi_cpufreq_exit(void) +void acpi_cpufreq_exit(void) { pr_debug("%s\n", __func__); @@ -1043,6 +1043,12 @@ static void __exit acpi_cpufreq_exit(void) free_acpi_perf_data(); } +EXPORT_SYMBOL_GPL(acpi_cpufreq_exit); + +void __exit acpi_cpufreq_module_exit(void) +{ + acpi_cpufreq_exit(); +} module_param(acpi_pstate_strict, uint, 0644); MODULE_PARM_DESC(acpi_pstate_strict, @@ -1050,7 +1056,7 @@ MODULE_PARM_DESC(acpi_pstate_strict, "performed during frequency changes."); late_initcall(acpi_cpufreq_init); -module_exit(acpi_cpufreq_exit); +module_exit(acpi_cpufreq_module_exit); static const struct x86_cpu_id __maybe_unused acpi_cpufreq_ids[] = { X86_MATCH_FEATURE(X86_FEATURE_ACPI, NULL), diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 35c7d6db4139..223bf9760117 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -273,6 +273,9 @@ static inline void cpufreq_stats_record_transition(struct cpufreq_policy *policy unsigned int new_freq) { } #endif /* CONFIG_CPU_FREQ_STAT */ +#if defined(CONFIG_X86_ACPI_CPUFREQ) || defined(CONFIG_X86_ACPI_CPUFREQ_MODULE) +void acpi_cpufreq_exit(void); +#endif /********************************************************************* * CPUFREQ DRIVER INTERFACE * *********************************************************************/ From patchwork Thu Apr 14 16:47:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 563828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44D5FC433EF for ; Thu, 14 Apr 2022 17:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243306AbiDNRGF (ORCPT ); Thu, 14 Apr 2022 13:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244949AbiDNRFp (ORCPT ); Thu, 14 Apr 2022 13:05:45 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2048.outbound.protection.outlook.com [40.107.101.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32E449CB2; Thu, 14 Apr 2022 09:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZU0gBkRK4Inim/KM2M1Bhh5xck8Yfz5POfQrii7D9oXm+cyDEWywZjY5V2GbE8ANJV0R1r5zrulsDPK28u7pstUonQPZWUqKwdWULtlq/Yjr8dtYuaUzRd8MKWjCFUmVWKNE8luqvsLuHM/VIkAI17F8ZDJa335bd8gw1AMJBX3fmUPDFaWCqCftgr7rmkKNem3BT5c0uSoJ01ctFJ09/Bp7NAA6xXMzzFitaDeUqzpoydcUt2aPOBwHwiYEv3uhT6G5geMyQv7hvtyKpPAHOM1wi0c2CauonqHH8kIMvatl5pBCZO2nledRejS+gSWjQvsn5zW0JZIDhDbWOzJ1/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Dv46hVZhOh36hdtM/zKZRvRF3Pwxj0M6Wex6v4rRaEI=; b=bjJW3EvqcsaZrE7/3nixvlIjftT2pOicrn79Cc56nMFVeQMRKfS81SaDNeLwR23w0ei+HeuFf2MS/2LQ0PmGnSbk1E/RnvX3i6l515bNA6GdvsP9p/GakCAiwPR/oPs8WBRO1xwpzF0K5j0wsR/uLv8Nyl5bnOFXy3g1BphZsEl6r3V7qLypDJ7qz7PWqtGP8i/yp+0xxSpAbTOispj+wpAiZm3ZSg0RhLB81MIaCpI2O1/UydOjkbXLCn+H+V+/y4a/oZe+ShpfRZhiqep8Il6A1BSXn1SgSbzENtSVPiD5dbpWIU85dsoOtTkqg8BzFEpmq9qug58s2HpnEsfFSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dv46hVZhOh36hdtM/zKZRvRF3Pwxj0M6Wex6v4rRaEI=; b=ia5GOs1n5BCgotVeKhkZfbquRLtLzdTTCJ1jSOFBpD38hcmoMOGWPPGE71EMIac6i6y/8/eByEYQ/oQn54/o7tE4nRQLnURMwt+Gd4QyggYbahcsQS/TFZ+I4CWJzSzZz7qD2RRM8/Uu+9Yh5RaPYDNPaX6ePJtZcymFFNshPKI= Received: from BN6PR2001CA0013.namprd20.prod.outlook.com (2603:10b6:404:b4::23) by CY4PR12MB1671.namprd12.prod.outlook.com (2603:10b6:910:c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Thu, 14 Apr 2022 16:48:15 +0000 Received: from BN8NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::90) by BN6PR2001CA0013.outlook.office365.com (2603:10b6:404:b4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20 via Frontend Transport; Thu, 14 Apr 2022 16:48:14 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT068.mail.protection.outlook.com (10.13.177.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5164.19 via Frontend Transport; Thu, 14 Apr 2022 16:48:14 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Apr 2022 11:48:09 -0500 From: Mario Limonciello To: Rui Huang , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , Perry Yuan , open list , "Mario Limonciello" Subject: [PATCH v3 4/6] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Date: Thu, 14 Apr 2022 11:47:59 -0500 Message-ID: <20220414164801.1051-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220414164801.1051-1-mario.limonciello@amd.com> References: <20220414164801.1051-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1160d358-80d6-470d-4230-08da1e3691b7 X-MS-TrafficTypeDiagnostic: CY4PR12MB1671:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M0MBncQEM/yrcCun4yRsVanUUgBZVWmOMJqMRDCFWi3sH6m+Q+WdanGBomFBuPbyD+Aw6evkiBrz7BX67biNUjHhdBSmtIXQSt84cg8DIs6o9lBkbIR/JHzi4c4DJeck6QwnT9Uswd3kY68OT96LCSy3BDYVvnA4juGp4h6HFFas8S6oehPGh0GL8BA7KlcE4usFXTe10vLnQjYfDhsRgZtsn8BsKvZG5XvAc7WnH4bTC9cXbR/5IZmfkWY2SMXRbChl0UWZ1ThV5y0BxVjPYExXjW5JoCyE5n34m4s26xBkfqnAFRQ1vR6tisO7NFVbqHtLOWapu313aqk1B5RaE1Xcy4d+jl3OTH76dceAxyNYON5VqBUB5GFw94nJ9e0iVTV/KenD/2acWUmIkH6AFb1NmlUpgB4H+vG+ms00TD/bW4FhOhknEfn1XLGn7+z5qBd74vtr450WHhT98sm9pOmffS51oOx2B24By/g3upCq1TFUpuy/uEsc5Y0afeHiNDn5AKe4QStiOFPAj4y7x9Y6GSWdP4LFEPN8Oqz3T/2hi2buJRdQtJ3wLI0LvzrDorr8dczp7uBd4RT4sPEjtNSTeDTfO/zdrcsN2WDbCRROynIin+B0+g6ffHJYFlDII4gl1kWpPmzXorAiH7Lk//ETaS7UaJO93i3AEDrsUePVoW6Upco7/uYad6nt637TG8qJKpUmRNbRVYCWnkzuCg== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(110136005)(54906003)(316002)(4326008)(70586007)(70206006)(8676002)(36756003)(426003)(16526019)(336012)(83380400001)(1076003)(186003)(26005)(40460700003)(47076005)(7696005)(6666004)(36860700001)(508600001)(356005)(81166007)(2616005)(86362001)(82310400005)(2906002)(5660300002)(44832011)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2022 16:48:14.7495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1160d358-80d6-470d-4230-08da1e3691b7 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: BN8NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1671 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org `amd-pstate` can be compiled as a module. This however can be a deficiency because `acpi-cpufreq` will be loaded earlier when compiled into the kernel meaning `amd-pstate` doesn't get a chance. `acpi-cpufreq` is also unable to be unloaded in this circumstance. To better improve the usability of `amd-pstate` when compiled as a module, add an optional module parameter that will force it to replace other cpufreq drivers at startup. Signed-off-by: Mario Limonciello --- v2->v3: * Rebase on earlier patches * Use IS_REACHABLE * Only add replace parameter if acpu-cpufreq is enabled * Only show info message once v1->v2: * Update to changes from v1. * Verify the driver being matched is acpi-cpufreq. * Show a message letting users know they can use amd-pstate. drivers/cpufreq/amd-pstate.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index d323f3e3888c..8ae65a2072d6 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -63,6 +63,13 @@ module_param(shared_mem, bool, 0444); MODULE_PARM_DESC(shared_mem, "enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)"); +#if defined(CONFIG_X86_ACPI_CPUFREQ) || defined(CONFIG_X86_ACPI_CPUFREQ_MODULE) +static bool replace = false; +module_param(replace, bool, 0444); +MODULE_PARM_DESC(replace, + "replace acpi-cpufreq driver upon init if necessary"); +#endif + static struct cpufreq_driver amd_pstate_driver; /** @@ -643,6 +650,7 @@ static struct cpufreq_driver amd_pstate_driver = { static int __init amd_pstate_init(void) { + const char *current_driver; int ret; if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) @@ -666,9 +674,19 @@ static int __init amd_pstate_init(void) return -ENODEV; } - /* don't keep reloading if cpufreq_driver exists */ - if (cpufreq_get_current_driver()) + current_driver = cpufreq_get_current_driver(); + if (current_driver) { +#if IS_REACHABLE(CONFIG_X86_ACPI_CPUFREQ) + if (replace && strcmp(current_driver, "acpi-cpufreq") == 0) { + acpi_cpufreq_exit(); + } else { + pr_info_once("A processor on this system supports amd-pstate, you can enable it with amd_pstate.replace=1\n"); + return -EEXIST; + } +#else return -EEXIST; +#endif + } /* enable amd pstate feature */ ret = amd_pstate_enable(true);