From patchwork Fri Mar 25 05:42:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555491 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 38186C433F5 for ; Fri, 25 Mar 2022 05:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358366AbiCYFnk (ORCPT ); Fri, 25 Mar 2022 01:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358357AbiCYFnh (ORCPT ); Fri, 25 Mar 2022 01:43:37 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2081.outbound.protection.outlook.com [40.107.237.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 535D05BD18; Thu, 24 Mar 2022 22:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPco7CLzVHBj1fHeFBi1rsXaI+nnf4kAtsaLFIJdpi+MQUL08lfKuoBpVHetKzOi8TebUy2IfmUDypcX8/o/e7f7RSgtuTve3JTFXFRe0vN8ILg6lZzFnzZdL4hYMBGJaQjwVzB7g8Ps0Ku0rAkgOUJge2/lD3TmeqFRPxHqHGWPhekUEpTHkQlehb0wQUjMLTVOKuzQ8yVvyw8U91AhEzjyOyo6BmAcGVs0kSF+fUarW9ZeIWyQ1lzWiDdDknLvbXva2190cmrFr2jTM1j6PMEymXJYS0/JH5HXI6WqWXs7q9v8KVMcxu5icftFPVpjp8jTZ57Cw0Ita7FUpY3AQQ== 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=OjhH8cZC8O/uMrXHISn1l1eK18iR0z8NPc51X44UYds=; b=hiaCvIBgye0eQc42iZ8hHNKoCEjLw+iXEyf1llnQ4J1RW8/WEgxXAMF0wVMoD5KvRyc8gGIjSr4tUDp+qm/rRUSgYkZuDs7vll+JfYmW6N4y9Zuz9OyT7tD9i5nc0gkRWEopR/N+s9uNya76YkWHND/Ilr24qSjeO6JjkT6RA+vZRtvFVgWsKnGvI3TLSj4a7M6xDmBZuSMBR/Rh054jkZYMqA4CLVZTn/dk0jezKH/XJ1BCI2LEv8Hhx3EDwsLKmn+tIqHOivz+k5XehY1r1zZPtmYXLCIHrwxfRp6NQXF+ijA/umbBpfhMWhYTvjEdx0Cj2IuinrZ2eFhAOlSYWQ== 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=OjhH8cZC8O/uMrXHISn1l1eK18iR0z8NPc51X44UYds=; b=WsVsWXAgR6YzBxMd0bRAWVZthl7E5YdMIwl1CzyO47JNHtpr69c73McLHmowNxgdmENsYCyyyKKoIOD7XLdTJ5YncxVQyPeZHigqaG2uviHHjpCl+8PW5aklwxdygXH1S9v1KsoVv8Ehp9tyMllfNXHddrVgr6I8oFVANR3xWso= Received: from MW4PR04CA0091.namprd04.prod.outlook.com (2603:10b6:303:83::6) by BL1PR12MB5946.namprd12.prod.outlook.com (2603:10b6:208:399::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Fri, 25 Mar 2022 05:42:01 +0000 Received: from CO1NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::d6) by MW4PR04CA0091.outlook.office365.com (2603:10b6:303:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17 via Frontend Transport; Fri, 25 Mar 2022 05:42:01 +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 CO1NAM11FT067.mail.protection.outlook.com (10.13.174.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Fri, 25 Mar 2022 05:42: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; Fri, 25 Mar 2022 00:41:58 -0500 From: Mario Limonciello To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , open list , Mario Limonciello Subject: [PATCH 1/3] cpufreq: Allow passing NULL as the argument for unregistering a driver Date: Fri, 25 Mar 2022 00:42:26 -0500 Message-ID: <20220325054228.5247-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325054228.5247-1-mario.limonciello@amd.com> References: <20220325054228.5247-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: 956a18a0-6bd1-4bf7-e30e-08da0e222f24 X-MS-TrafficTypeDiagnostic: BL1PR12MB5946: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: nrlr7+4A0a1YaZTtnuBHAWofr9T2EvXqI4/kWiILU6/kakfICdI5Ya4qqV03msCEtec7gSO9hLS0K+wyLRuqLwnZKTtdj3iSvPZHKT/q5vVXYa/15gHCwpOa65/c2y5FGqPPAYyv2EUA9BaAdG+CsdbahFdTNoV3fQJaIjXxKb9o1kekw9SZhvCq8djFf+MkOXCSWpKsCQ56sDfSZrsBPNE3RoLo0u88Utbka83o66Nc6in8G7SpKtpgl4zgNJGBq6UcHxsrCjEr7EMG2gDWPZlhFx1Y6n3t0bXQBhgd6Tqrsya61Dte0NU6gOTfZEqehP4bHFXlKMXmBAcub+2GrCHk4CFZ3hA4jM4l6f1BxispnyZT5iGMlPj2meEpHGyCT/xum3WS7x1aEJeT7UOLnmuOgAc5Wfic9fLRvpBd8h1LPDmWqfEgZbmthjuOmUw4tnbAUOH23k9KF9fgjFBQYD9eWNl8MZnrzIiG43RYZ8AkgCuO1k4odmuaX5oY0p7AG7dGS+XQT/F6AEKlRuOtPJu52bwrsM323vu23FJxlG8yE1J/zFTiPUwoG0m/9Er2ZYuYuUGf12YvX2X0sI2dsMn9u+cFdz19aZkxs91sY87k1ZdLtcXYGyl+5Sjim65MQUp3tuVYF7GmgnJxNPSCnb9imCM3FocSWZA/Hw1Hebk8StxMjxGf7JFDHHfsL7Bv9K8EPDbSlkiY255bp77z+w== 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)(46966006)(36840700001)(44832011)(7696005)(2906002)(40460700003)(508600001)(316002)(26005)(186003)(110136005)(36756003)(81166007)(356005)(54906003)(6666004)(70586007)(1076003)(4326008)(86362001)(5660300002)(8676002)(2616005)(70206006)(82310400004)(83380400001)(36860700001)(16526019)(336012)(426003)(47076005)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2022 05:42:00.6938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 956a18a0-6bd1-4bf7-e30e-08da0e222f24 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: CO1NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5946 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the arguments passed to `cpufreq_unregister_driver` are matched against the currently registered driver. This means that the only way for a driver to be unregistered is if it's module is unloaded. Loosen that restriction to allow other kernel modules to unregister a registered driver. Signed-off-by: Mario Limonciello --- drivers/cpufreq/cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 80f535cc8a75..4711c17a89bb 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2885,10 +2885,10 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) { unsigned long flags; - if (!cpufreq_driver || (driver != cpufreq_driver)) + if (!cpufreq_driver) return -EINVAL; - pr_debug("unregistering driver %s\n", driver->name); + pr_debug("unregistering driver %s\n", cpufreq_driver->name); /* Protect against concurrent cpu hotplug */ cpus_read_lock(); From patchwork Fri Mar 25 05:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 554176 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 360D3C433EF for ; Fri, 25 Mar 2022 05:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231767AbiCYFnj (ORCPT ); Fri, 25 Mar 2022 01:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354788AbiCYFnh (ORCPT ); Fri, 25 Mar 2022 01:43:37 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2079.outbound.protection.outlook.com [40.107.243.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F964C55B8; Thu, 24 Mar 2022 22:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OewItdXDxv5G/o1H4B44idny6TCTzzsqdC0e1DmUfGYxQ2aKPbHgvQP3tyVhMtvZr8T/9cIhwgS1VWURIz5F0Rb3LYXDqKQWRrMA9fQBMA2DgkGT0yHCu6JZFh0xWY7kVyxIJeyOuoWApwamy5L3PGXv3ncfC8xKF6m2VcYvREPUEEplg/xCZ5SSDyQp3Xq+jU5g1nlU8gdd0LJ8GVPA52sT6ijSTssMh1zPx99mQUq3ljsRrtRV1/17MLInBu1Eed7i65XZeVu5EXOP41YR4K79hlztu3lpLk5mXyQ57RyUb7cK75cn81XVIBc0uRmsBhmYJzvKwIZ4NxnKxGRf1w== 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=fonkNK680iAi+GbGOhyZSme2CTU0cqXpqINleBRPXGg=; b=F+LFT8ueiVjRFZwAge3iwLjjE55AIec+AAfPUOlqjF1EvDvE9C+1QUieV8oS6s0Vijwhtj/ek3QUrklPplAXbthBhhJexbIW9ytI9fKQjoY5pLFL3c9qCgfA8zk8nTevilh4LNssMrMqASpVYmfpJSu2HSobTV8xu1rOPwepB4H1puM2MTjQPihekAt1UXVCY11eU7jnU+Y2nFWQDoy9AcMrsN1kfCY/HvPB98LbD5nQ6f2mueBb1T6yxwAxNtTa5YYAA5aFswqqy8I+o1bIfz4ZpeQxK8H/x4D08ZmZ+JP2+haWbxpm/i4GwXFcZ7SUNqOxB5ljMeBHU9/2srsgNw== 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=fonkNK680iAi+GbGOhyZSme2CTU0cqXpqINleBRPXGg=; b=YFF0BnY95KA6DIbYrFW5OOlaXZVoa0/Wne7sHbwjbvCXrBuZs+3IZueKCKgxr2jYSrjdwK3b75s3xtFwLRk8H5/RG627qFp7PIcjvdZNhgGJnWjCLG6SrXLDd+fsAsaArgUxp0wFppaTYJwWJuluWf+5QJpIiQSaPpiDFfBrn5M= Received: from MW4PR04CA0101.namprd04.prod.outlook.com (2603:10b6:303:83::16) by CO6PR12MB5475.namprd12.prod.outlook.com (2603:10b6:5:354::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Fri, 25 Mar 2022 05:42:03 +0000 Received: from CO1NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::77) by MW4PR04CA0101.outlook.office365.com (2603:10b6:303:83::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17 via Frontend Transport; Fri, 25 Mar 2022 05:42:02 +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 CO1NAM11FT067.mail.protection.outlook.com (10.13.174.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Fri, 25 Mar 2022 05:42:02 +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; Fri, 25 Mar 2022 00:41:59 -0500 From: Mario Limonciello To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , open list , Mario Limonciello Subject: [PATCH 2/3] cpufreq: amd-pstate: Allow replacing existing cpufreq drivers when loaded Date: Fri, 25 Mar 2022 00:42:27 -0500 Message-ID: <20220325054228.5247-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325054228.5247-1-mario.limonciello@amd.com> References: <20220325054228.5247-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: 1e2dafe4-5dd9-4dec-5de2-08da0e223026 X-MS-TrafficTypeDiagnostic: CO6PR12MB5475: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: 1dMeXSpOWTDWjwlPZXrpgA/wyz30qWHp5MCMsl5uW3NWDQ3rKlhne7Qql2JAvAqX1uwipwrK7fna5XaGtLSmslUqKrMJbhfhy4ps3tkUID2KBbYpOgFMxXSZ2vt7QWE3xydst9p6efFpbck8tYordMCDzM4LWNoGUOCpA8oDuF/rWDrdfK02TbrJdtOybNxCVs+OBeyYrXdHnj4AkLPd8YSzZhX6cB+GC4VvupVDldDhPVwasD74n8tYcxEOrFjalF20MyjIzIntKVlJ6qIRbXTqaosZ0zfxDiRGSstjwzaI9JsjdQrfuLz+vjFnr/5cSjz9hKixEeObTQtg1xq7NCQUY/54Q+LTTjQSPis8sJheCOK/h7Xo+V1yigi/Yw52SQOjiAfNQ5taAsRo27wA5b6YyNHUs3DqO4udyZS/XQAx0RNvshD5GO/4Rt3uNYiCRcJDHZv0ztAI6W3nNeGEz+pA/IEVEdPu1pZkMAqHKqffD5BYqwA9AL/9lDXyRcJbo/AL/iko2PiR6xOhjZostDabtoAfvb1IAQv7TfFG3O2Xf4cs0fbxB85Yk2InsL5DsYLxY+cWa9/tgQDh4XaKn6ml7bKC6ClwsrdJbTYnHikijnp2I8hW5Bho/dlnUpSbbnG/+fEr17ncxS5u7Qg9d/5L/mj/7u/BcSBdM3LstdY3+d9qzlv9sXVVGT/KvocJLawjzzF1sozOlsQ0zhdTng== 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)(46966006)(36840700001)(81166007)(40460700003)(70586007)(8936002)(2906002)(47076005)(356005)(2616005)(426003)(7696005)(36756003)(5660300002)(83380400001)(186003)(44832011)(26005)(16526019)(1076003)(4326008)(70206006)(508600001)(336012)(316002)(8676002)(36860700001)(86362001)(6666004)(82310400004)(110136005)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2022 05:42:02.2563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e2dafe4-5dd9-4dec-5de2-08da0e223026 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: CO1NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5475 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 --- drivers/cpufreq/amd-pstate.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9ce75ed11f8e..31a04e818195 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -63,6 +63,11 @@ 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 other cpufreq drivers upon init if necessary"); + static struct cpufreq_driver amd_pstate_driver; /** @@ -598,9 +603,11 @@ static int __init amd_pstate_init(void) return -ENODEV; } - /* don't keep reloading if cpufreq_driver exists */ - if (cpufreq_get_current_driver()) - return -EEXIST; + if (cpufreq_get_current_driver()) { + ret = replace ? cpufreq_unregister_driver(NULL) : -EEXIST; + if (ret) + return ret; + } /* capability check */ if (boot_cpu_has(X86_FEATURE_CPPC)) { From patchwork Fri Mar 25 05:42:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 554175 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 99C18C433EF for ; Fri, 25 Mar 2022 05:42:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358379AbiCYFnp (ORCPT ); Fri, 25 Mar 2022 01:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358365AbiCYFnj (ORCPT ); Fri, 25 Mar 2022 01:43:39 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB75C55BA; Thu, 24 Mar 2022 22:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gvYnKx+VoaeHMC6/D1cexuSrQP+WfyikC2b1cbeAYmgPn0UVPBoTRGEg8ZnYxjXVqYfAc7NHkqcyIrGy0NxralxZfVRMgvq2m4XNx5nfZwoelCiMrvo9KEKLu/qR6XSGPsNF32V/PxRNX56VY5iWxr+awh9gV/g2+3C0xVGB8WtD54q8tYu3EOt6LITu0qMBAI+PMwRfTkrDexvowm8i68lWZ1+HHNd7XUdvU9RDkm13ivsPBsxNHhT6OPekGq+TjzybvkXhQDNSObhkK3+mUEMbdkRyI9WpY6cG8zEHpKvjddxm7pBSJQZihLXIGf+fp9dgsGJs9ua7TRNanCWMDg== 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=7CGsHSEQJXnt77wx7yyCge/9mAd3jPFALjLkRT07oEE=; b=UGgBRd8XAoMZCHDGpVX/IA0L6B3SG3myZxsd9HvE9UQK3r3goGN4SjveFHa1jLvvwku3Vbhmpbdgznb+bl69Fd/kHX8UXUWD+GzIMBuQIvmPvsvaU0ZJsSGNzQVhDkgf7G0+QLj0AwUVnLJG6CRMu6BY9PqO7d170XwQjsIcyy3+eJQM+Guae03Wdp5UFR3LdXUOjxAyfyekdxCagVH4yHXz2HAb97+vWZcp9TvR0vDwRRcB67/Dw3ErCKxzMkryikD6RGs3yhDSoYBlGha79QeQe3hWIfNioayJ0p2dLfSMdqzzoyxHsK0PnGFOOUZhsPopFLrF8GjK/FMDYfJMEA== 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=7CGsHSEQJXnt77wx7yyCge/9mAd3jPFALjLkRT07oEE=; b=pa0RCZzIhToV5jHajaKFkYdlDt3V2DH1gX8/523g/uJQHq1Kq4SnZPs6VAlnTMQJZPBEsRymRG8EfAYBktCfjeC9wPJMXksAtQ/bkEe0zKmsKhO85YKWZfJ5tTaXi58OFnggKl5WpX2fiqAydgkIEcjb/NCPyDSssx78VhoId9c= Received: from MW4PR04CA0098.namprd04.prod.outlook.com (2603:10b6:303:83::13) by DM5PR1201MB0042.namprd12.prod.outlook.com (2603:10b6:4:50::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.15; Fri, 25 Mar 2022 05:42:04 +0000 Received: from CO1NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::e6) by MW4PR04CA0098.outlook.office365.com (2603:10b6:303:83::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17 via Frontend Transport; Fri, 25 Mar 2022 05:42: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT067.mail.protection.outlook.com (10.13.174.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Fri, 25 Mar 2022 05:42:03 +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; Fri, 25 Mar 2022 00:41:59 -0500 From: Mario Limonciello To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar CC: "open list:AMD PSTATE DRIVER" , open list , Mario Limonciello Subject: [PATCH 3/3] cpufreq: amd-pstate: Add a module device table Date: Fri, 25 Mar 2022 00:42:28 -0500 Message-ID: <20220325054228.5247-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325054228.5247-1-mario.limonciello@amd.com> References: <20220325054228.5247-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: d242e7e0-2722-47cd-7bb1-08da0e2230c8 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0042: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: XiKUJEeEfno5kWwLR/e6M7NTbpJBmWQdkmL+QOjDWgEvhszgNomQwxLGl/jaYywZbUfSevwmOutnonhtQsn3Pyw5Mi2WGIBCEHoNybZLCAUs9UBC4G3DU2TgDKMIOAj3eZGK5IYwOSxzh+3LLuhPMlwb2g+5eDYcDEICAC3YdVankRznp9UUqjtEaeJn+/1+AAnzQ/+bST8ckSnjY744RjjMPkg+Jhif5EsLfyh0xTXnHgijiyclRKCSGHyuYB9uLvVYG+XKyWAWfcFzFcLWEBEPjERy3oH5rm/8M8gjZgdVr/AnWE/xjFAEOMFQaQHs0S5teHZ3PQ35NJT4Tq3VezI2q8pRgAiVZ/qrMCGiqWXuUHMAuOt8JAlhX9bbxds6I3/vZui3uq1jNbbz2pXvFGvwDQHFRFYQfhYaE9TZQcjQQ20kr+6COj2zaIfcZb2RVLAn/vr4k3EAEZqIX+okBX/oeY63DetvvLKv9Ns/ZUSgwNlA5n8VskS/ttclNA6GWGWDUzPwwgpBuNoRoA4N+B2JshKB7XEMR1WNctBNMy9IA4ZXsaAoO4KY6qlMYqOukIFg24xBwe3LRV1aZ7/RwZ5CK0mI+OtmtRgqcA3jXmjrNPVeFpjvso3uROHR29ZPvtZo3IHH0UajLpJbRIPrmw8n8z5DMcbed5ddG/HtPNeIkiDmDMDj3duL9uxVDSUCG/4vyPB/xQDkA/1LCY0v2A== 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)(2616005)(1076003)(186003)(336012)(426003)(81166007)(356005)(26005)(86362001)(40460700003)(5660300002)(36860700001)(2906002)(70586007)(16526019)(36756003)(8676002)(70206006)(83380400001)(4326008)(4744005)(47076005)(6666004)(508600001)(7696005)(82310400004)(8936002)(54906003)(110136005)(44832011)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2022 05:42:03.4125 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d242e7e0-2722-47cd-7bb1-08da0e2230c8 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: CO1NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0042 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 --- drivers/cpufreq/amd-pstate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 31a04e818195..44490292fa72 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -644,6 +644,12 @@ static void __exit amd_pstate_exit(void) amd_pstate_enable(false); } +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);