From patchwork Tue Mar 29 01:59:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555069 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 61A94C433FE for ; Tue, 29 Mar 2022 02:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbiC2CBq (ORCPT ); Mon, 28 Mar 2022 22:01:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbiC2CBp (ORCPT ); Mon, 28 Mar 2022 22:01:45 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061.outbound.protection.outlook.com [40.107.243.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06A15F4D6; Mon, 28 Mar 2022 19:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JAkfkV666HHNadsQaRxWjlbR5Kpndfym1iSsPOMWGDAAU5EAdAOPFajheioLr9e+Hm55WUNCLK4nidMY2fZBVCOLdCeBkMzC9ysKsqB7MqVxQVVDa2qAHq3xcqB5s90ITRwqXWIPAQD4JoeKL60vXTVQBD7oBO9DcqDRwLcPwutsZ9L8/a+qetK9gTBScK/F3Ru/+FDNu3/kDebhciIa9xizJxN5E3drEWyJ1d+taBWn2nsnzcIg5ZU2C297tJtXwZNq30io95/TSFVH/WS0f0vtOcoA7q48PFfflTD9L+qjowAHjGxl5zjpfZm8JcbLQcM4LEblzFAjuxrgcve8uQ== 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=IZKx6wPfMRfaf76kByvsdVKI4n7f3Z4Z0doV92WyDcA=; b=lNce6NKUOtQYRp/QR+dTX+VrUGTOjo8P9AhKLsXhg85s9Pm83aY0ZFqKbBrVSQbwAcQdx04WWQo5aJMEaac4DwTH/0BcEcoIhLcpS91G80KdPp3d8pDsneTyeWbAwR+V305Hst7fVcsz2/1slHy1bUd+DjLZtnfOR8Ri7B2xLPa6IhOZN+QKVRQFWGNM5IaL1rGhSdzUBRFbJ4A41PzOaL4pCqVpj5ZNOBN+HM3KBESqJS9dmtmokwFmWdf+knD0ECMZC2XJOMzv+e5EiZEiKvkL4sg31wf1s98Bwl9pnp2xvtsMd5j6qnxqSkPBCQ89bM3E271QpQx8fWzW/lY8AA== 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=IZKx6wPfMRfaf76kByvsdVKI4n7f3Z4Z0doV92WyDcA=; b=QDAb1doAsrl2QRstR0fD23k8UR05ij5p20sonMB+vBaO5CESjYaHdh6i/N6Dq9mUntXadeR0SKRpwlH9RbXbDEEvCLf0HE6lkfUdXd6SvoXnYFJ13Ljvkb0pGQiN1biCcd+Nr9l+XDiYSVYKv+WKjtn0oSFsIDD8LAGynfyUyj8= Received: from DS7PR03CA0248.namprd03.prod.outlook.com (2603:10b6:5:3b3::13) by CY4PR12MB1672.namprd12.prod.outlook.com (2603:10b6:910:11::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Tue, 29 Mar 2022 01:59:59 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::75) by DS7PR03CA0248.outlook.office365.com (2603:10b6:5:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.16 via Frontend Transport; Tue, 29 Mar 2022 01:59: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Tue, 29 Mar 2022 01:59:58 +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; Mon, 28 Mar 2022 20:59:54 -0500 From: Mario Limonciello To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , open list , Mario Limonciello Subject: [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Date: Mon, 28 Mar 2022 20:59:45 -0500 Message-ID: <20220329015947.565-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220329015947.565-1-mario.limonciello@amd.com> References: <20220329015947.565-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: bbb39446-9069-4725-3414-08da1127d432 X-MS-TrafficTypeDiagnostic: CY4PR12MB1672: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: Z3mI7EdGcsdWc2vADAHQn7IWPNiW8F6lVE7miCDqKrgrNRQlmp2D3ekiUQsJCmiMFce3wElZYUVC4KWHHw+WIiwf6maCw7wB++RcJJdugRX/8vRh8Fcbh6/01y7oD9Id5MGhzpj1TY20cBo5yW30d1M5ji9F0Sq/5dU2vtV1Tzk9pkqAI/zcDaJ+aU/VkPxyJ1ZtK68nhIUle3pTEdc5nWM+XeIAwCNWRIlxZHMPaLI/+B/O04uSfasy5c1ukq8wm5G1z/xUrh+gsY7EoRxqWc5agWSWul8tgZnmT2P804Jht7oizeFYKJTCMa5Trs/BnVj/5AhQFnZwv9d0B2L3mBUDlQOft+ltbzPv7ohyv8nlzc8VIpo+wPST1BW9bZPAmVf4O1i0vwm3Zpa49jfSLYP86I2SfzodtZqD7RBZOKVxotltqUQfWHm25EOYbZsImDw75pZB3WJQFWFQsN+o9nC0ZKei1mbenKC69pCNkirXL8RndWgNoVoq79LcthIWeLM9mVidMCqU+t5d+Cz/gkuKqMaFDvML/PyaBc6945WV44d45Cvp/RzDBoDABY7bxs4qCAcnsi6IyDDQmRqpEtbbhIDJYrhmfoC9sIWVuckEvujc6F7ajW5wS+aOIOWrG1eSriGPsuC6W8v6lb0Ro41aS/6dSN29zvoL4gfCbLqYbdwFrN+wPGm4eAoLuuuuCBL7Smi2K9yKIVTRtKGM6A== 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)(46966006)(36840700001)(40470700004)(47076005)(8676002)(4326008)(70206006)(6666004)(2616005)(70586007)(7696005)(508600001)(83380400001)(82310400004)(40460700003)(36756003)(86362001)(36860700001)(336012)(426003)(44832011)(8936002)(5660300002)(54906003)(110136005)(16526019)(26005)(316002)(1076003)(186003)(4744005)(356005)(2906002)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2022 01:59:58.6709 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbb39446-9069-4725-3414-08da1127d432 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: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1672 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 Reviewed-by: Huang Rui Reported-by: kernel test robot --- v1->v2: * Export symbol instead of changing internals drivers/cpufreq/acpi-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 3d514b82d055..92ac978c1c53 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 __exit acpi_cpufreq_exit(void) { pr_debug("%s\n", __func__); @@ -1043,6 +1043,7 @@ static void __exit acpi_cpufreq_exit(void) free_acpi_perf_data(); } +EXPORT_SYMBOL_GPL(acpi_cpufreq_exit); module_param(acpi_pstate_strict, uint, 0644); MODULE_PARM_DESC(acpi_pstate_strict, From patchwork Tue Mar 29 01:59:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555478 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 D1A4EC433EF for ; Tue, 29 Mar 2022 02:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbiC2CBr (ORCPT ); Mon, 28 Mar 2022 22:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiC2CBp (ORCPT ); Mon, 28 Mar 2022 22:01:45 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2081.outbound.protection.outlook.com [40.107.94.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE532DABC; Mon, 28 Mar 2022 19:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JUWsRGMJ5+bB24X0NxIdFPPG6e5tX32G7v/jOvu1ce3dW3GK93TLlHNzKkHbSMz7bnyNxTU6pdfg6SqsfzNT9oadfQGSV+peY/G2RXOOhZA6up2+WGs1cChmbABPAlzyz83G6KdebdJUSl4zIAiObxSLc8Rsr5WFTGT4vfhCLqrXkXFPt5dmsZXbEcW3twkTT1DKmRPSVR77Iay+yZQf+mLEu9+n7IAVYXxe+jkwsa0fgDzKIvoPeA2g2H3dWcmTlctHHpqcMbj04H94hlKAzFhDSuuBe+BgBMnRjO9fKTD1kQayGvIXaa11gBGBUVTEuQ+bdPULOOrIxuymLFn0oQ== 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=t7b0a/n3EcVwAMYUlKPOj3ZNQSRX9uRlXJ2/fHY7ILw=; b=N9JOawXhusy1Pl8iFj9+jkG+iYSws1rA3WsMVnK+c5cv6p/EkTL31kPEM5x0EF4IKdemEmG+KYV0AutwPJxu8UbSFamZNu5ZMT1iqeolThL25oIacG4audNUe1LYuGHYgZ8KiPOa153EBOk4Nu1+I7GhtblpjLIqOQ2E9GG079HbIRSgi+QTGlx5xNv2vAg7sQ/fXklnQtBhZzNV1rhrqHZfMfocTmiaTp7hGvR4266OBJog04frNiMspfw1ROnQHvvJzQawnouEae8YEFEm3wtmEkupXwNNEi/spadYosOZpGc5PK0gm+OWTTPEFZ30Yh/uwRVMo7WAKANCkWUwzA== 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=t7b0a/n3EcVwAMYUlKPOj3ZNQSRX9uRlXJ2/fHY7ILw=; b=amAaTuQ7ocfEann3jTWnYUtrqKQsBBBz5Nh5A1em2O/L6OhTP4lM/yTBRlykqhX4MNeQqJKhOAxCCicANkyluC72WrikA8DGrKkjpcUKUpo9aFpnUHbG+UcB0+esj2KDj0Wk/dzoHvgzYzerQSgK0RBor347nP138BPwsNC/RxM= Received: from DS7PR03CA0268.namprd03.prod.outlook.com (2603:10b6:5:3b3::33) by CH0PR12MB5217.namprd12.prod.outlook.com (2603:10b6:610:d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Tue, 29 Mar 2022 02:00:00 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::d4) by DS7PR03CA0268.outlook.office365.com (2603:10b6:5:3b3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.16 via Frontend Transport; Tue, 29 Mar 2022 02:00:00 +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 DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Tue, 29 Mar 2022 01:59:59 +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; Mon, 28 Mar 2022 20:59:54 -0500 From: Mario Limonciello To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , open list , Mario Limonciello Subject: [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Date: Mon, 28 Mar 2022 20:59:46 -0500 Message-ID: <20220329015947.565-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220329015947.565-1-mario.limonciello@amd.com> References: <20220329015947.565-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: c3a07a08-67a8-4903-dc2e-08da1127d4be X-MS-TrafficTypeDiagnostic: CH0PR12MB5217: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: TNpr9LKWQicsuIsa5FX5GlZgZylVXXbLtMzDGGHR0pqr2aUesKRsfxI+3PloItIm4CIVu3JVXvbCVAVIk4NKiR9jqDkBJ9Fqnw4fUGtfzoVme6S63NSVb/1xuCBuQFLSFOV5EIBxaKS068bccXCaxix6kSkIK+3lQbTcjzhHLxb6EHtIaFJ7LBUBM447Me/1BBhY8UcVhmLhfe7nnjVa0QrLrDBH2psT7kGa/nMPruZz2Bozp1eWfkTmgpgsypwXtc6F4S+g5vvRG20FR4zSqB22j4UIEnqINjWIpZIWcUOnzWMHp/uDcodWF/6ttwZeFoP1l8QcAsW+jMlergMIQYDKIm1quggYJxZFk3eaI/G1xhGxsQfPnSsdxE0+KYl871hExgbIJOR14r0oGGgtAXPZpyaH+bRtOsF3I1IXQ2ilwz+58a/OMcOqtHpjXSYHa8+VW2NTfR3iZf67AnUPWsivGuH+BOQKnAmp6LIanIazi3Zx3F4v9qj+qVSIjE+rsJy0T/fkiiaT0Ncann1jz8lz2W2ArRxM124FMl+3WsoN3c/eYh80tRS2iOB0r+3R7ip/IZG3KrjLgEiE8Lg18T85aG0WrEu0uhjv5BTcemYrpkzjH/dadViobiDkiQLx0BM8TLVOn1p0kY8XOUrdq6edbHOaO95B5U/bo/Thx/e7WWO53nFgnjIeN9DVQ97YB0m9812YYWZ1LaHtjr2dig== 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)(46966006)(40470700004)(6666004)(110136005)(2616005)(81166007)(54906003)(508600001)(16526019)(186003)(26005)(336012)(1076003)(70586007)(8676002)(47076005)(316002)(36860700001)(426003)(4326008)(70206006)(40460700003)(82310400004)(356005)(83380400001)(44832011)(2906002)(86362001)(5660300002)(8936002)(7696005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2022 01:59:59.5927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3a07a08-67a8-4903-dc2e-08da1127d4be 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: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5217 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 --- 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 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 7be38bc6a673..7dc2e344f222 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -63,6 +63,12 @@ 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)"); +static bool replace = false; +module_param(replace, bool, 0444); +MODULE_PARM_DESC(replace, + "replace acpi-cpufreq driver upon init if necessary"); +extern void acpi_cpufreq_exit(void); + static struct cpufreq_driver amd_pstate_driver; /** @@ -643,6 +649,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) @@ -653,9 +660,15 @@ static int __init amd_pstate_init(void) return -ENODEV; } - /* don't keep reloading if cpufreq_driver exists */ - if (cpufreq_get_current_driver()) - return -EEXIST; + current_driver = cpufreq_get_current_driver(); + if (current_driver) { + if (replace && strcmp(current_driver, "acpi-cpufreq") == 0) { + acpi_cpufreq_exit(); + } else { + pr_info("This processor supports amd-pstate, you can enable it with amd_pstate.replace=1\n"); + return -EEXIST; + } + } /* capability check */ if (boot_cpu_has(X86_FEATURE_CPPC)) { From patchwork Tue Mar 29 01:59:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555068 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 4C41CC433F5 for ; Tue, 29 Mar 2022 02:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229966AbiC2CBs (ORCPT ); Mon, 28 Mar 2022 22:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiC2CBr (ORCPT ); Mon, 28 Mar 2022 22:01:47 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2048.outbound.protection.outlook.com [40.107.237.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 207185FF00; Mon, 28 Mar 2022 19:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLHGNfCckfEvDu4pLyahTquwLadNvqyU8EJWByyzm2e4cij0c73IPVmn1i8rbc2yO5YNo5NQcUQ5np6LSmumWmpr6qw5UObiIBt6lhbiUzP3o6SoHU66TlvJpH5H5MJzFJsYKaMfvL82JtqjmQPU+zuuTWcst9FJTeJCQ16BeKZtFMTDZ84G31xSeySZGMFeBFd9v12oKuTOuRkEyoDFZIGb2ioNGiXkL4FeKsG0rpkUbC3OV5wbkVg3QvJTUYPvtBdCN88i34IWXIwRdg5c/QaunjqChR9HpPIVA8YR4ReW74f8dGaZ3ba3RNypblv4LIYSRQA1yxrg6XPHkfgKUg== 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=2o9TYKYWmMlrLfYqR1q3xd+ORprXeP9B79TT0Dj/pzw=; b=P+VNsSa8lL0NON+IY5PX3WqKFRIdoBLCW8RrRyM7uuoCe/W5nFUh4BjkESov91lOnW4FN9K261lPJ4bLVNPc3JRQbt4emBnRv/bfhO1sz/zDSyH4HsneS4UdqFc3QcFVC+EeRP/WaHsaKjHGaRRXOALVqNjQ1Pug2HfMcjTKxs54vn/k83+lSi8FJw872rYt5ZA/iKPIHG/3EtVzvZlJ//uv4dxS87oKh0DuqcPaEXoY4MB373+DKqTdJjFDJqHu5KaOD8tmBfVrH/1KV0qHCLnqjbY0i+16b0CuMi+Tl+L25INiG/9Y97FocF4wRVzxBLrljk/oyKUFRJWzEx9T+Q== 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=2o9TYKYWmMlrLfYqR1q3xd+ORprXeP9B79TT0Dj/pzw=; b=ewy6Q2wIR1Pkc74xasAKE1NUn/x8WvCh3hRTfkLZ8BqTvhIKfkIOCCUBff/iZdTPtvoytWZoXprma8ba6AKwKDijKSOhN21HKEcWU3R1gQWDrs8Oy6hWdccbeTMS4/ynFPohXvlH+6XzWvEwLLJxjBgDgAoZ2nBHXii6H7thnmU= Received: from DS7PR03CA0250.namprd03.prod.outlook.com (2603:10b6:5:3b3::15) by BN8PR12MB3074.namprd12.prod.outlook.com (2603:10b6:408:65::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Tue, 29 Mar 2022 02:00:00 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::3d) by DS7PR03CA0250.outlook.office365.com (2603:10b6:5:3b3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17 via Frontend Transport; Tue, 29 Mar 2022 02:00:00 +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 DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Tue, 29 Mar 2022 02:00:00 +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; Mon, 28 Mar 2022 20:59:55 -0500 From: Mario Limonciello To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , open list , Mario Limonciello Subject: [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table Date: Mon, 28 Mar 2022 20:59:47 -0500 Message-ID: <20220329015947.565-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220329015947.565-1-mario.limonciello@amd.com> References: <20220329015947.565-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: 3711fea2-8d3d-4756-71db-08da1127d538 X-MS-TrafficTypeDiagnostic: BN8PR12MB3074: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: ImQ6dfrjCR+IK2dKE82TRnunh5eFKlXCzExYjsqkRoQUVAWefM98tHk8XKAGfPv1CgBJQxYMqzceMHWA4gMSVWCwqR8V2etmvfcE9rYzKTrHtVcJkb40kZcV5IUevajX/rmP074NsFowe6TRnzRsDX53vrTINvthjV1oK+xNFi6ncrpnXRqM/6r/pJwjNpxar0X6pE2pOJyUOnBhOc9SQm9gbqPsQl+jI3grJCavC7T8AlJXE2PZVMv5PilHJqYhqbPr/RX1sPlGgTYzZ+OZGBVm8jhrrMu5Pg0GoL5FVXaoRkUjLJy7tNOyYKT48fHeDjqkL6V7yqMF3CV5frGOi4VVjVE/CncIY1EXFABXf0Gy/+erbCIVC607mDU8cSebVTLNdSukDXuWvFOqtp8SeMOYJEXBvSg9uyUFU5IbRTNCtS229vmkXvd4483KDbJoHvThSy2cGf3u7I9AcBCZRXRJuRadzh/zGaOjcYB9W7ji+7XXWgN4RXSxHpLvoHUQDjCQmghwSmqg/bdp9KBzhnn8raZEHHSomA1876f5Uo9zbJQPpFuY0Qzs2WEJGxZWunQMPJ3aONQ+cGzmrQ0dGXD0KAYza8gSoJmUb+5k+9YX+RxfSO+ZmpUIt8p4CktZD7xHXhrtb6JlNJ+2/QOK6U7ohK5bfG3Lwfg9cEVewW47r6ZVJX5czidcSdaFNtc0OpI/w7O6V8pfug9CmTZjwQ== 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)(40470700004)(36840700001)(46966006)(110136005)(82310400004)(54906003)(508600001)(316002)(7696005)(70586007)(70206006)(4326008)(40460700003)(8676002)(6666004)(86362001)(47076005)(5660300002)(8936002)(81166007)(336012)(426003)(83380400001)(36860700001)(44832011)(2906002)(1076003)(36756003)(16526019)(356005)(2616005)(26005)(186003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2022 02:00:00.3895 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3711fea2-8d3d-4756-71db-08da1127d538 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: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3074 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org `amd-pstate` currently only loads automatically if compiled into the kernel. To improve the usability, add a module device table that will load when AMD CPUs that support CPPC are detected. Signed-off-by: Mario Limonciello Reviewed-by: Huang Rui --- v1->v2: * Add comment to indicate need of SBIOS support. drivers/cpufreq/amd-pstate.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 7dc2e344f222..9f78849654e7 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -705,6 +705,17 @@ static void __exit amd_pstate_exit(void) amd_pstate_enable(false); } +/* + * This will only match the HW feature, there still needs to be appropriate + * SBIOS support, so it's possible that in such cases this causes a module + * load with -ENODEV as the result. + */ +static const struct x86_cpu_id __maybe_unused amd_pstate_ids[] = { + X86_MATCH_VENDOR_FEATURE(AMD, X86_FEATURE_CPPC, NULL), + {} +}; +MODULE_DEVICE_TABLE(x86cpu, amd_pstate_ids); + module_init(amd_pstate_init); module_exit(amd_pstate_exit);