From patchwork Mon Feb 6 17:21:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13130402 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 86E50C636D3 for ; Mon, 6 Feb 2023 17:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbjBFRXG (ORCPT ); Mon, 6 Feb 2023 12:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjBFRXB (ORCPT ); Mon, 6 Feb 2023 12:23:01 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2A359C7; Mon, 6 Feb 2023 09:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fhy4F2jh9Ymk6a1RwRGvK9VsXyIhgqBO+ELbNzdh3WvyxryrYSTn2bGZuSUGbmh7P2y+cH0aR+hQ26UcEf5sq9FLY3HxpzcvgUubSVcJEJzOUDSIG6d/cZem+prZ1uTUjLzghBD60R2zvZZ0TtU0tTe80PMV9GkU33jZInR6u+V9PARVvknLg44FP6VIRfv0pHOcJ+PMtNNqJJTwo+M9R4C0cNsr0h3lorRD/LAuQK+Rjn+b4BZ51s01aiBmXcA8BXEdE5K5c7I6wW+MrdUZIcPWv3lm43qrQAr9BpFqrwyHFA/u4H40qz0qTOBFprhHvKeglstt0a43LfjeAlFIPQ== 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=rsiOFCzxXXHGF0WkBet0AUOBlPFFzUwh9PMsK4lNcwQ=; b=gQNXvkQJuQ8VZN/vJudHKu0dIbASn/kyGQVdCEoogZ/a4D7b8mdR3OnZcUc+41LC6cdkd0a5upfyMZ+nNJQb8i5L8COM7VR4BJIgnxhw96eCZotlAfVlG+8MLlind3JAzDHGtWZ0O2Lz0nQAEIorO/AeQBo+bQtXLnBH6BviJqaaoGjVUtei0XkzdB9ik3hGt94EvvU3n4b2T6bjXWLzwxMNGLOwHDVxs1vWD/kgGmhfCFBDKm1ZVFTHTk9dkr3XPYdDG6ov3jrO7VRgXRmGv3cbR63r2bC9FjSsYcfp6H/3dwtQty+l0oLRZeHPv7Br9EeWcmq3ubGWzkm/BLHmXQ== 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=rsiOFCzxXXHGF0WkBet0AUOBlPFFzUwh9PMsK4lNcwQ=; b=Gc9EmVwn7476vbQDJlUk2p7Jbd2j9nzB+sd8in1TAVzfuCtJANUwzUdSPTzLivbtcv8KymHwXjQmQ6lUQ9xyPpauS5BdwuoOvmY4bHrMCgP2CevO+zlwUIZYk6yTDtm2CQBwMEdihSLb/D9Z9yLaNpJre95Lr55Wbw72ylE7m3g= Received: from DM5PR07CA0061.namprd07.prod.outlook.com (2603:10b6:4:ad::26) by DS0PR12MB7607.namprd12.prod.outlook.com (2603:10b6:8:13f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 17:22:44 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:4:ad:cafe::a6) by DM5PR07CA0061.outlook.office365.com (2603:10b6:4:ad::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35 via Frontend Transport; Mon, 6 Feb 2023 17:22:44 +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 DS1PEPF0000B074.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Mon, 6 Feb 2023 17:22:44 +0000 Received: from beas.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.34; Mon, 6 Feb 2023 11:22:39 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v6 1/6] acpi: cppc: Add min and max perf reg writing support Date: Mon, 6 Feb 2023 17:21:52 +0000 Message-ID: <20230206172157.49887-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206172157.49887-1-wyes.karny@amd.com> References: <20230206172157.49887-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B074:EE_|DS0PR12MB7607:EE_ X-MS-Office365-Filtering-Correlation-Id: 524a6c09-0c94-4c02-d225-08db0866c285 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9RzAwhfcRs5zzjbB6cyPFAw0HKSRc2WPVhy53MN2t739sDPaWgtIBwkHRVRqNoQToTId8DpkKpANWY3UT70zEOCplZGyJrLmhwdR3+mr53Pk8ub9ISLdN0e2n6z5txuxclowtQ00zcxkfErlwDymN8nK6GTjLRgA35pZ9ndInnQfD6SGq7pVpdbIkNMRAaTJMclGH2g7paa5GErzAJL588ki4db34FSUjgvkRT3z/QDF5G/e2O6MAUetDaOxbEJtMNL4at3TuHgmir8FgPqShWfqwEM7ywgHvS6FVYYnAsuDmLv84Fwu4NH4YZ7IV8Kzug0lo6IOBA2acm7ZW9CtqhNQICKTTarYeKWdUu/EgmLBFx6PFxbRMACeFSw/MzO3BxvuAJIrQNopgiSPKqiBlDMOSWIp2dK1yeaoSNT4GXOKVegJpLKtQWQ4agJYRW2tm6793zxs2zX9HMt7pVJoguOlDI/7YFrBAm4aoI8+3tQjjnoRtrO7c7SC+w4lCH6rsjZwD2pcziesBFSvTHTIPm3GIucf0ZHOjPSkO0pZfJ5G7e46YkM1dCSp7d/ZMyBjTkGTbtHT1lxEh9M2D944AUG8mHFoGQLoEpVEkqqRhCQDfmOqfzMAKAjKwtqXUBR6uXgLzGhpiqPQF13IKVd+tj3WMTKIrTw3EmRBVDudQt9bkbWUETpNYgfgefPL6JiX2jCMkdN23WRnRabrlxX4Yh+BDHU8capUThxfHi+ZHX0= 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:(13230025)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199018)(40470700004)(36840700001)(46966006)(16526019)(40460700003)(82740400003)(83380400001)(81166007)(356005)(70586007)(8676002)(5660300002)(70206006)(41300700001)(4326008)(2906002)(44832011)(7416002)(36860700001)(6666004)(8936002)(2616005)(1076003)(478600001)(186003)(26005)(86362001)(316002)(110136005)(6636002)(54906003)(47076005)(426003)(7696005)(336012)(82310400005)(40480700001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 17:22:44.5512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 524a6c09-0c94-4c02-d225-08db0866c285 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: DS1PEPF0000B074.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7607 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently writing of min and max perf register is deferred in cppc_set_perf function. In CPPC guided mode, these registers needed to be written to guide the platform about min and max perf levels. Add this support to make guided mode work properly on AMD shared memory systems. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello Acked-by: Huang Rui --- drivers/acpi/cppc_acpi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 02d83c807271..91f9ef75f7de 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1487,7 +1487,7 @@ EXPORT_SYMBOL_GPL(cppc_set_enable); int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) { struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); - struct cpc_register_resource *desired_reg; + struct cpc_register_resource *desired_reg, *min_perf_reg, *max_perf_reg; int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); struct cppc_pcc_data *pcc_ss_data = NULL; int ret = 0; @@ -1498,6 +1498,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) } desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF]; + min_perf_reg = &cpc_desc->cpc_regs[MIN_PERF]; + max_perf_reg = &cpc_desc->cpc_regs[MAX_PERF]; /* * This is Phase-I where we want to write to CPC registers @@ -1506,7 +1508,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * Since read_lock can be acquired by multiple CPUs simultaneously we * achieve that goal here */ - if (CPC_IN_PCC(desired_reg)) { + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) { if (pcc_ss_id < 0) { pr_debug("Invalid pcc_ss_id\n"); return -ENODEV; @@ -1529,13 +1531,19 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) cpc_desc->write_cmd_status = 0; } - /* - * Skip writing MIN/MAX until Linux knows how to come up with - * useful values. - */ cpc_write(cpu, desired_reg, perf_ctrls->desired_perf); - if (CPC_IN_PCC(desired_reg)) + /** + * Only write if min_perf and max_perf not zero. Some drivers pass zero + * value to min and max perf, but they don't mean to set the zero value, + * they just don't want to write to those registers. + */ + if (perf_ctrls->min_perf) + cpc_write(cpu, min_perf_reg, perf_ctrls->min_perf); + if (perf_ctrls->max_perf) + cpc_write(cpu, max_perf_reg, perf_ctrls->max_perf); + + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) up_read(&pcc_ss_data->pcc_lock); /* END Phase-I */ /* * This is Phase-II where we transfer the ownership of PCC to Platform @@ -1583,7 +1591,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * case during a CMD_READ and if there are pending writes it delivers * the write command before servicing the read command */ - if (CPC_IN_PCC(desired_reg)) { + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) { if (down_write_trylock(&pcc_ss_data->pcc_lock)) {/* BEGIN Phase-II */ /* Update only if there are pending write commands */ if (pcc_ss_data->pending_pcc_write_cmd) From patchwork Mon Feb 6 17:21:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13130403 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 39CD3C636D4 for ; Mon, 6 Feb 2023 17:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229973AbjBFRXX (ORCPT ); Mon, 6 Feb 2023 12:23:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbjBFRXQ (ORCPT ); Mon, 6 Feb 2023 12:23:16 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2069.outbound.protection.outlook.com [40.107.223.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C266A2BEE6; Mon, 6 Feb 2023 09:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jAFc2X7dcvtiY+Lekw5bVAtHPUZTHzJC0O8pS6pB0G5aYZtsLBeegxkC/GBDSNvomAeGL2K+qtotvcN+Lb+r2TTO7KuV4AsiIs3TcQ/CapHjV6nrYSk7XW8f49qVP0UHckeYnrM8+d1OuiqBNwZYSJmhb5cc75pz2rfSu6qNz4H1P8R76d2b0VJIRLyyfHBDR7nAadDGRXS8Qm5oGL54qhGDfglPitk3e5Zf47TW5yEuWJju3jfWReDTtbSB6YYmT+sHeEqljTzU0dwcS4H5aQ1fcSOPUKuOOIJo3gmJWIyb26uvFofmifx0/ihs452rPH4ng4sYugxdJe6PikiKxw== 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=82aGwNYippQcfrJSwAkDqSbcGKrbCFCBCOh5PrQN9Dg=; b=Kj1IMGsXcYEPZb/HzRiyOWjQyXljXzqrb2VtF6E+rJN28RduGLbEQmc+0AKGocAEC9k8vKiYpszeRVtN4f5WIDxkFUypTZ+S54W3OMSsfekDmGRJvmE9/hOmuoY86uXXovr0E0HfNXMAd+uZu+TS3hI8KoeyvH5By2wam4W/9FygvLV4QgmB5ssX8aWb2kKIRn29wA/zx64DElVpmR5pwwGXVLmXm2hNWEXILfXKJeJ7T2usehDJ//9CWIvIhp0iS+W26/dXojrL5rtvSnspXEGqIdPCIlGQ+GquOZyN+GYJ5A9tX/fn/9EYrVY6NqLfDhFuA+mH0oYifkJ2RLV9ow== 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=82aGwNYippQcfrJSwAkDqSbcGKrbCFCBCOh5PrQN9Dg=; b=ou6EFsiNHe4pUyR8DkvGOPbcejK2kSyI7earj3+UeUl08s41FDlpEXtvjplfuQsFpIWAG6SXqWRb8dYSpUik4v/NIBwMLixoSnzKG1cpozp6IzC3oAktmyqFPgQnFjojfw5e3N8VTIObRNOGd9ANN/2ntYKRdSH0eXmFP4t9Ddg= Received: from DM6PR12CA0025.namprd12.prod.outlook.com (2603:10b6:5:1c0::38) by BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 17:23:10 +0000 Received: from DS1PEPF0000B077.namprd05.prod.outlook.com (2603:10b6:5:1c0:cafe::21) by DM6PR12CA0025.outlook.office365.com (2603:10b6:5:1c0::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 17:23: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 DS1PEPF0000B077.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Mon, 6 Feb 2023 17:23:10 +0000 Received: from beas.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.34; Mon, 6 Feb 2023 11:23:04 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v6 2/6] acpi: cppc: Add auto select register read/write support Date: Mon, 6 Feb 2023 17:21:53 +0000 Message-ID: <20230206172157.49887-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206172157.49887-1-wyes.karny@amd.com> References: <20230206172157.49887-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B077:EE_|BL1PR12MB5286:EE_ X-MS-Office365-Filtering-Correlation-Id: 48493ca8-e662-4d4e-5967-08db0866d1d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hPgfxVnyGmzB2emdYjzgIEMsAFDcuqe7InTHke+Xp+gTKug3cSgcpABjyhsgavaSP7Srp+pA/9GI8+9h0MRNlX2xF1ze6Xf+GKb62O7IgrjM+bGbP7gT1HKj04fLPYOPE6VooKw0uVa6QsWjKxcKGiZlVYv8dFA/Hv/9o3ynUkluqmf1zZtktiYdauvcKZ+kLdwYsM60J1XgAgZ5zWUtvyB7Ln/b4kqjG5Xl1Pfsgmxqs5x9/JKEARLAdBY0Ifxyij+2nEjitkZhuoetyL26NTnG2359L6klvaGq6IwkRnnwlFymboPu0Z+3IrdRz1pEjie//drk12rxNzWhommfpSxvCFxCLzBG4/nRfdjr7SgeDPaete2CpL+tFASWgB4sRTnEDBGctCJIE5gt3LzbP9hjmNpMpokT+qVt0RRfr/YcWPUFRPjypGkkZ0vGlgx/9VAW3YDDhzvsE5SNpiLoGbAaEHiHl7MC/p+NBVsDkF3w4pZ4nDbDMQ9KeqWGMUitj5RAcofzvGxF525GfoU6F3CCVNPrT2Wxh1EgVm86w7t9uCZsMD8F09vuwGo46SfjT9G4hKBKk3S0s33xpPSYi0xO64I03DFJiYktKX7VDp7Mg9wBIS8FwbXmUB5zVjxsFI9LjRsD3PAngg9H2L0CM98lpesla5i6uTM9IEITfNGbqDg5ytKeJeaZdUaYkfA4ZqVUhw0fCHeif9VLsDMJFd0gk00v+zDz1ZvY5X00M5w= 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:(13230025)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(36860700001)(70586007)(82740400003)(81166007)(356005)(83380400001)(70206006)(8676002)(5660300002)(478600001)(4326008)(41300700001)(7416002)(2906002)(8936002)(44832011)(6666004)(1076003)(2616005)(16526019)(186003)(86362001)(26005)(316002)(6636002)(110136005)(54906003)(82310400005)(7696005)(36756003)(426003)(336012)(40480700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 17:23:10.2185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48493ca8-e662-4d4e-5967-08db0866d1d2 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: DS1PEPF0000B077.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5286 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org For some AMD shared memory based systems, the autonomous selection bit needed to be set explicitly. Add autonomous selection register related APIs to acpi driver, which amd_pstate driver uses later. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- drivers/acpi/cppc_acpi.c | 97 ++++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 11 +++++ 2 files changed, 108 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 91f9ef75f7de..1806006a51af 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1432,6 +1432,103 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) } EXPORT_SYMBOL_GPL(cppc_set_epp_perf); +/* + * cppc_get_auto_sel_caps - Read autonomous selection register. + * @cpunum : CPU from which to read register. + * @perf_caps : struct where autonomous selection register value is updated. + */ +int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps) +{ + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); + struct cpc_register_resource *auto_sel_reg; + u64 auto_sel; + + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpunum); + return -ENODEV; + } + + auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE]; + + if (!CPC_SUPPORTED(auto_sel_reg)) + pr_warn_once("Autonomous mode is not unsupported!\n"); + + if (CPC_IN_PCC(auto_sel_reg)) { + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = NULL; + int ret = 0; + + if (pcc_ss_id < 0) + return -ENODEV; + + pcc_ss_data = pcc_data[pcc_ss_id]; + + down_write(&pcc_ss_data->pcc_lock); + + if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0) { + cpc_read(cpunum, auto_sel_reg, &auto_sel); + perf_caps->auto_sel = (bool)auto_sel; + } else { + ret = -EIO; + } + + up_write(&pcc_ss_data->pcc_lock); + + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(cppc_get_auto_sel_caps); + +/* + * cppc_set_auto_sel - Write autonomous selection register. + * @cpunum : CPU to which to write register. + * @enable : the desired value of autonomous selection resiter to be updated. + */ +int cppc_set_auto_sel(int cpu, bool enable) +{ + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); + struct cpc_register_resource *auto_sel_reg; + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); + struct cppc_pcc_data *pcc_ss_data = NULL; + int ret = -EINVAL; + + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpu); + return -ENODEV; + } + + auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE]; + + if (CPC_IN_PCC(auto_sel_reg)) { + if (pcc_ss_id < 0) { + pr_debug("Invalid pcc_ss_id\n"); + return -ENODEV; + } + + if (CPC_SUPPORTED(auto_sel_reg)) { + ret = cpc_write(cpu, auto_sel_reg, enable); + if (ret) + return ret; + } + + pcc_ss_data = pcc_data[pcc_ss_id]; + + down_write(&pcc_ss_data->pcc_lock); + /* after writing CPC, transfer the ownership of PCC to platform */ + ret = send_pcc_cmd(pcc_ss_id, CMD_WRITE); + up_write(&pcc_ss_data->pcc_lock); + } else { + ret = -ENOTSUPP; + pr_debug("_CPC in PCC is not supported\n"); + } + + return ret; +} +EXPORT_SYMBOL_GPL(cppc_set_auto_sel); + + /** * cppc_set_enable - Set to enable CPPC on the processor by writing the * Continuous Performance Control package EnableRegister field. diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 6b487a5bd638..6126c977ece0 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -109,6 +109,7 @@ struct cppc_perf_caps { u32 lowest_freq; u32 nominal_freq; u32 energy_perf; + bool auto_sel; }; struct cppc_perf_ctrls { @@ -153,6 +154,8 @@ extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val); extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val); extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf); extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable); +extern int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps); +extern int cppc_set_auto_sel(int cpu, bool enable); #else /* !CONFIG_ACPI_CPPC_LIB */ static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf) { @@ -214,6 +217,14 @@ static inline int cppc_get_epp_perf(int cpunum, u64 *epp_perf) { return -ENOTSUPP; } +static inline int cppc_set_auto_sel(int cpu, bool enable) +{ + return -ENOTSUPP; +} +static inline int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps) +{ + return -ENOTSUPP; +} #endif /* !CONFIG_ACPI_CPPC_LIB */ #endif /* _CPPC_ACPI_H*/ From patchwork Mon Feb 6 17:21:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13130421 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 92EEFC6379F for ; Mon, 6 Feb 2023 17:24:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbjBFRYI (ORCPT ); Mon, 6 Feb 2023 12:24:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjBFRYG (ORCPT ); Mon, 6 Feb 2023 12:24:06 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2064.outbound.protection.outlook.com [40.107.244.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E643329410; Mon, 6 Feb 2023 09:24:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b63q4Nzttfy8DUdVnZNni1FCE6CFxkcsN2ONYiKaRGtQ1bGZ2UhIXKCHcc97RxT6z6UNvgafPUJeFxSlO6w5ruxl0BZUdpAam80m88EbOFe5afa96T82dWpOPt+R/nNtQiEDnifz0iVUmAnV+5ATMl/83hMco4VyW/0s7KivLqZ+8DLXUTipWoiihrlPUrxvEABAnf7gs6gTe7mZWOQIJfpeUWHXFRwLciHVtCIjBxst1NmzSMfvLThAAs3CbFu/Id/c9QQKW6dVFy2gzwfIjrouUEHKaRGj128pP0RNKd7IN60yb83dKQWsyf4orn1ZCFU3xZyFKqJziC0jbnNf2Q== 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=aYS91MZIbP0JmSXe/fYMpjE2WWvVJT5koY3ce/HMxec=; b=iTVwd03BYBW/UntkBEF6UhX9AftiZNOxztPi8ipHqbAoqSMv3oqYQ0VdHaRa7qEZWzXLNc/vF7emXbhMBIPJBMupxOnQOGeZGog8glUcMV0XC3oTn38IFpR1UOmRKOXK/ieGZnN1Vb+a8VIbbDolqsXZ6g/5GUQ9fAkWVdmKs99h89WuvHJ+EiMMaAm5GONgaCWRcDiCFgFn0Jt3C/tTVoQUjz50JkTPzeEuzOS+I1ZhOVC/ROZaUDTlP7kEC53IrF8vaRdSErK12dIHFiQ31wj759Q4Yfd0TKxeFhXHyjRvePvWk+DpPRhHXo5Xgnqqpbv78k0SkPFF7yWUd4FWfw== 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=aYS91MZIbP0JmSXe/fYMpjE2WWvVJT5koY3ce/HMxec=; b=5WLlNY1Icm18OI6aVzVnMvBwB4OErEDnyu/7WSh/toMvXwFNLQc5EHF9OKHU1a5mKkS+gKAHLFh/8Y1qWlv4MMlWBWxPf9yl28RwRfRWdm6gHvhxGBxhEytNdI/5o7vsnZdL14Sg32dMsra9Uge9Gmhk7mIFylrNq/4ZfshguzM= Received: from DM5PR07CA0064.namprd07.prod.outlook.com (2603:10b6:4:ad::29) by BY5PR12MB4180.namprd12.prod.outlook.com (2603:10b6:a03:213::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 17:23:59 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:4:ad:cafe::b0) by DM5PR07CA0064.outlook.office365.com (2603:10b6:4:ad::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 17:23: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 DS1PEPF0000B074.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Mon, 6 Feb 2023 17:23:58 +0000 Received: from beas.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.34; Mon, 6 Feb 2023 11:23:52 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v6 3/6] cpufreq: amd_pstate: Add guided autonomous mode Date: Mon, 6 Feb 2023 17:21:54 +0000 Message-ID: <20230206172157.49887-4-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206172157.49887-1-wyes.karny@amd.com> References: <20230206172157.49887-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B074:EE_|BY5PR12MB4180:EE_ X-MS-Office365-Filtering-Correlation-Id: 88441f20-037a-4a67-125e-08db0866eed8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5fVQhgrc3PGF3WKE2Vs4V2SyBD1Rzi/7V56Mq4pSQuq68bGuZr3HIrkbRVimYQS9svNx3agzsvnMONSM6PO8afDsbxiIoKJg5b8Q2g7iXl9nD24CTGSYyq0jyI6oLY9U0LHKfvjUDUq3O7j3WfdccNkDOrpzN7S3zUwKW/wLrLzsk1kSwwIv/2/KQ10EQ+IxsnuFX+IpYn3XCKgo68gxk8kdVvqHSP06mi5Te/nvR7YUsRHwxACoMiFe+bvZiEOQs+te89eGbn2+7R7n59IiZVfw9UstAoMih4Ay33dBhYxgdZDSf6xJaYUdFGKcG8FP6hARZXU2Ptgw4lUtegD9300hV+3aM3UucbO/hJtDwuBrHny3cs8hYN5iQ1yHmYYl3ImWj8mhM5iDNlUphzIR3qrh+9WelywXeRZGGoFCi+fzAgI0tk1gTXz8QuGQ/zOsw9wJIYWzZrgbzSu/rarqSEjHYNbNxq5DEBi6fFxqi5rMkRUU8RP4dL7heu7F/FaKHCSRyoqmFU2hOhG0qsP7YLUXbIiO/cmgz3f5CWDYTGoM9sUYd86F6fT5yK9cl5tW3sWlRk+rggqr7MmNQxh62ayfWAdHJMoaMw7wJM6eUr4fiDfG33h+iVc7UFHg1oZU3tRe2NxYg2sq3WZCooF1oZoXQCVQmH5Ct/8AmHnXVmM239mXlWS2CXzjwr0llETOElQcghE2sILvw2TbPGm4jMgc3cDyGH0zcWF78YoGXrM= 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:(13230025)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(186003)(16526019)(36756003)(26005)(1076003)(40460700003)(356005)(82310400005)(81166007)(82740400003)(47076005)(54906003)(110136005)(316002)(36860700001)(6636002)(5660300002)(41300700001)(40480700001)(8936002)(7416002)(7696005)(2906002)(44832011)(478600001)(336012)(426003)(8676002)(83380400001)(4326008)(70206006)(70586007)(2616005)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 17:23:58.9100 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88441f20-037a-4a67-125e-08db0866eed8 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: DS1PEPF0000B074.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4180 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From ACPI spec below 3 modes for CPPC can be defined: 1. Non autonomous: OS scaling governor specifies operating frequency/ performance level through `Desired Performance` register and platform follows that. 2. Guided autonomous: OS scaling governor specifies min and max frequencies/ performance levels through `Minimum Performance` and `Maximum Performance` register, and platform can autonomously select an operating frequency in this range. 3. Fully autonomous: OS only hints (via EPP) to platform for the required energy performance preference for the workload and platform autonomously scales the frequency. Currently (1) is supported by amd_pstate as passive mode, and (3) is implemented by EPP support. This change is to support (2). In guided autonomous mode the min_perf is based on the input from the scaling governor. For example, in case of schedutil this value depends on the current utilization. And max_perf is set to max capacity. To activate guided auto mode ``amd_pstate=guided`` command line parameter has to be passed in the kernel. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello Acked-by: Huang Rui --- .../admin-guide/kernel-parameters.txt | 15 +++++--- drivers/cpufreq/amd-pstate.c | 34 +++++++++++++++---- include/linux/amd-pstate.h | 2 ++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index e3618dfdb36a..56d5c189e458 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7015,11 +7015,11 @@ Do not enable amd_pstate as the default scaling driver for the supported processors passive - Use amd_pstate as a scaling driver, driver requests a - desired performance on this abstract scale and the power - management firmware translates the requests into actual - hardware states (core frequency, data fabric and memory - clocks etc.) + Use amd_pstate with passive mode as a scaling driver. + In this mode autonomous selection is disabled. + Driver requests a desired performance level and platform + tries to match the same performance level if it is + satisfied by guaranteed performance level. active Use amd_pstate_epp driver instance as the scaling driver, driver provides a hint to the hardware if software wants @@ -7027,3 +7027,8 @@ to the CPPC firmware. then CPPC power algorithm will calculate the runtime workload and adjust the realtime cores frequency. + guided + Activate guided autonomous mode. Driver requests minimum and + maximum performance level and the platform autonomously + selects a performance level in this range and appropriate + to the current workload. diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 168a28bed6ee..6582c922ad3a 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -308,7 +308,22 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) cppc_perf.lowest_nonlinear_perf); WRITE_ONCE(cpudata->lowest_perf, cppc_perf.lowest_perf); - return 0; + if (cppc_state == AMD_PSTATE_ACTIVE) + return 0; + + ret = cppc_get_auto_sel_caps(cpudata->cpu, &cppc_perf); + if (ret) { + pr_warn("failed to get auto_sel, ret: %d\n", ret); + return 0; + } + + ret = cppc_set_auto_sel(cpudata->cpu, + (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); + + if (ret) + pr_warn("failed to set auto_sel, ret: %d\n", ret); + + return ret; } DEFINE_STATIC_CALL(amd_pstate_init_perf, pstate_init_perf); @@ -385,12 +400,18 @@ static inline bool amd_pstate_sample(struct amd_cpudata *cpudata) } static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, - u32 des_perf, u32 max_perf, bool fast_switch) + u32 des_perf, u32 max_perf, bool fast_switch, int gov_flags) { u64 prev = READ_ONCE(cpudata->cppc_req_cached); u64 value = prev; des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); + + if ((cppc_state == AMD_PSTATE_GUIDED) && (gov_flags & CPUFREQ_GOV_DYNAMIC_SWITCHING)) { + min_perf = des_perf; + des_perf = 0; + } + value &= ~AMD_CPPC_MIN_PERF(~0L); value |= AMD_CPPC_MIN_PERF(min_perf); @@ -445,7 +466,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy, cpufreq_freq_transition_begin(policy, &freqs); amd_pstate_update(cpudata, min_perf, des_perf, - max_perf, false); + max_perf, false, policy->governor->flags); cpufreq_freq_transition_end(policy, &freqs, false); return 0; @@ -479,7 +500,8 @@ static void amd_pstate_adjust_perf(unsigned int cpu, if (max_perf < min_perf) max_perf = min_perf; - amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true); + amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true, + policy->governor->flags); cpufreq_cpu_put(policy); } @@ -1279,7 +1301,7 @@ static int __init amd_pstate_init(void) /* capability check */ if (boot_cpu_has(X86_FEATURE_CPPC)) { pr_debug("AMD CPPC MSR based functionality is supported\n"); - if (cppc_state == AMD_PSTATE_PASSIVE) + if (cppc_state != AMD_PSTATE_ACTIVE) current_pstate_driver->adjust_perf = amd_pstate_adjust_perf; } else { pr_debug("AMD CPPC shared memory based functionality is supported\n"); @@ -1341,7 +1363,7 @@ static int __init amd_pstate_param(char *str) if (cppc_state == AMD_PSTATE_ACTIVE) current_pstate_driver = &amd_pstate_epp_driver; - if (cppc_state == AMD_PSTATE_PASSIVE) + if (cppc_state == AMD_PSTATE_PASSIVE || cppc_state == AMD_PSTATE_GUIDED) current_pstate_driver = &amd_pstate_driver; return 0; diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index f5f22418e64b..c10ebf8c42e6 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -97,6 +97,7 @@ enum amd_pstate_mode { AMD_PSTATE_DISABLE = 0, AMD_PSTATE_PASSIVE, AMD_PSTATE_ACTIVE, + AMD_PSTATE_GUIDED, AMD_PSTATE_MAX, }; @@ -104,6 +105,7 @@ static const char * const amd_pstate_mode_string[] = { [AMD_PSTATE_DISABLE] = "disable", [AMD_PSTATE_PASSIVE] = "passive", [AMD_PSTATE_ACTIVE] = "active", + [AMD_PSTATE_GUIDED] = "guided", NULL, }; #endif /* _LINUX_AMD_PSTATE_H */ From patchwork Mon Feb 6 17:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13130422 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 D3336C05027 for ; Mon, 6 Feb 2023 17:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbjBFR0D (ORCPT ); Mon, 6 Feb 2023 12:26:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjBFR0C (ORCPT ); Mon, 6 Feb 2023 12:26:02 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A72E2CC6C; Mon, 6 Feb 2023 09:25:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgzElGjobOz4ryznXkDqBjNTXw/OPbgnuD4prx8yOb/RAyxgVtHztEftEEFli9UjQcpOYkRznh9qxhTaTkBS+I0rPDtKL1olFPQkpPNhTU3256jIvJWV2lp1DtJZjyo4EmEW6jgmHr6kqUXbA3ZG1Sbl9gEZFmBXqhOjC91GWCBbg/cDnh9H+2L+/BMa2l9bxYyrCsFR5tmaSHy2NmpwZKKtZfImBTaqLKkE8BlEUA8pB4LYO/mMbKuUPrHKEg4zwdndls/0AiAzyMMbyaT0FSwhxr5HGk5RqIwFwVwcSbFELBFR/mq7i/3CJghTyuhZ2/sL80YlHb256kKBRhozRQ== 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=ZJhjuqN2cpI9XA5Cy3XLLnCmRSprrL92K3P9WmylBUw=; b=R5lZaKFiW2b4pOA43Dhr/fv5NPwLZN0j7CG7M99C5YjwvliMC59llCFbh5wSzJWns4YBBZI7EkTdpYgM1HErIW7cxJNaNRvig1tZze6Oif7m0O6MVKw+//8KtaRYPbqVOmHZRFHkWulWYvGaHu/b8AdZ5zUSshC4STJUzkiu1M4fTU1WJU0xFzxzNtVYqIK9GjJiVTeWn2JwmebzGDCFwBjDH4Jhp+CW4LrEagS6G9uV5O5MAfLtd+mMbMv9lWjwKapmcoKRTBM2yr+PXJYljHAsGGAP0HopsxW0BeSjJVRZCr6Wf+X+9rIUG3xODaiOoCJdAYqPvFbMVOgJymvxDA== 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=ZJhjuqN2cpI9XA5Cy3XLLnCmRSprrL92K3P9WmylBUw=; b=PObCIR9F89/Fja9hncRHpAJqiOIQnzJPC8Q75PflNMX8BKrnvOw8uKPipiAN2yTIPKksLWwV3gIiXy94Kj+QmDEqrgNjW40zRQLW8hxo0cVjMNDAWKlkVjNlcm/rVeRzRK0T7hGWaHXENmbfaHg/W1dEPaSN9tMXYDq7OKbbs+k= Received: from DM6PR06CA0093.namprd06.prod.outlook.com (2603:10b6:5:336::26) by SN7PR12MB6670.namprd12.prod.outlook.com (2603:10b6:806:26e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 17:24:25 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:5:336:cafe::64) by DM6PR06CA0093.outlook.office365.com (2603:10b6:5:336::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35 via Frontend Transport; Mon, 6 Feb 2023 17:24:25 +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 DS1PEPF0000B074.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Mon, 6 Feb 2023 17:24:25 +0000 Received: from beas.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.34; Mon, 6 Feb 2023 11:24:19 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v6 4/6] Documentation: amd_pstate: Move amd_pstate param to alphabetical order Date: Mon, 6 Feb 2023 17:21:55 +0000 Message-ID: <20230206172157.49887-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206172157.49887-1-wyes.karny@amd.com> References: <20230206172157.49887-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B074:EE_|SN7PR12MB6670:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ff93136-4957-4c96-c86f-08db0866fe6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +4K7FAUmofyFjyvHo31LdvgRvru7UOaQWC11XmAnNeyK8c4bLHQ7jqz8aE8yF3P/WA0Av4i+5/gloTVpKgJmPL01MLnJFMwUmrKNVdYc4uAr+dKBcCYarZnbf6hrludI+/Vzn0zmAiVT68iXejfkla0DKqh2NyecbjPMlXcVEu+UbBvwUpj/bZA5AYl88mvO/BMSXyVU22ZU1NJMhg8RdEXUZcmeEZ5L7AagltK2NWrrwokzdcNpCDVaA9nvpwFQMgLAsTgw672vehAPcNmUuarYA6r38Q9I9YnbYPbkXtds/YYjAYedrYyOr0iOs7/7WqjU/cB3reyq6m9t+cyzjoIiIe9IbpuIlU9jDyrcDosGsl8NtX3/8jsyacKFxOVzQ6aLxlIviOKJPyIIYASuA9MUSwhTYTc5GOeJGcrh4spx/YXYunC2b2Wxu7OWXZhoWCO/aM/E0omEROT2cYerMnxOcXxAfzwMD4zjvT1jktkcmOtt5W9RvKkBYDN7Cm2YlRHHBPzo58O6+L6j48CCrkxouNR/DFklYYFv0r5txJWf+gD4wWMNeoXCAxckU4DtvMBlSTz4fWd88k8/u8OdSwcooyQOsbK5BfmuoLJ868Wd9TFHmy0TIohB3K0Z8DmrQxlZiCcmN4IfTv64WaF8T6sH8pmtUsGGCpj253/PB6PjVmuuB9o2HyS5Owb15xQnHtmGLjggqvpHlYepnMehWY1fwtxNU14t8zEKSQ3/RX0= 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:(13230025)(4636009)(376002)(396003)(136003)(346002)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(7416002)(5660300002)(41300700001)(8936002)(2906002)(70586007)(70206006)(8676002)(82310400005)(83380400001)(4326008)(40480700001)(16526019)(1076003)(6666004)(54906003)(36756003)(110136005)(6636002)(40460700003)(478600001)(44832011)(7696005)(186003)(26005)(426003)(86362001)(336012)(2616005)(47076005)(82740400003)(316002)(356005)(81166007)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 17:24:25.0504 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ff93136-4957-4c96-c86f-08db0866fe6c 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: DS1PEPF0000B074.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6670 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Move amd_pstate command line param description to correct alphabetical order. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- .../admin-guide/kernel-parameters.txt | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 56d5c189e458..d7685b4268ba 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -339,6 +339,29 @@ This mode requires kvm-amd.avic=1. (Default when IOMMU HW support is present.) + amd_pstate= [X86] + disable + Do not enable amd_pstate as the default + scaling driver for the supported processors + passive + Use amd_pstate with passive mode as a scaling driver. + In this mode autonomous selection is disabled. + Driver requests a desired performance level and platform + tries to match the same performance level if it is + satisfied by guaranteed performance level. + active + Use amd_pstate_epp driver instance as the scaling driver, + driver provides a hint to the hardware if software wants + to bias toward performance (0x0) or energy efficiency (0xff) + to the CPPC firmware. then CPPC power algorithm will + calculate the runtime workload and adjust the realtime cores + frequency. + guided + Activate guided autonomous mode. Driver requests minimum and + maximum performance level and the platform autonomously + selects a performance level in this range and appropriate + to the current workload. + amijoy.map= [HW,JOY] Amiga joystick support Map of devices attached to JOY0DAT and JOY1DAT Format: , @@ -7009,26 +7032,3 @@ memory, and other data can't be written using xmon commands. off xmon is disabled. - - amd_pstate= [X86] - disable - Do not enable amd_pstate as the default - scaling driver for the supported processors - passive - Use amd_pstate with passive mode as a scaling driver. - In this mode autonomous selection is disabled. - Driver requests a desired performance level and platform - tries to match the same performance level if it is - satisfied by guaranteed performance level. - active - Use amd_pstate_epp driver instance as the scaling driver, - driver provides a hint to the hardware if software wants - to bias toward performance (0x0) or energy efficiency (0xff) - to the CPPC firmware. then CPPC power algorithm will - calculate the runtime workload and adjust the realtime cores - frequency. - guided - Activate guided autonomous mode. Driver requests minimum and - maximum performance level and the platform autonomously - selects a performance level in this range and appropriate - to the current workload. From patchwork Mon Feb 6 17:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13130424 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 A0C07C64EC3 for ; Mon, 6 Feb 2023 17:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbjBFR0a (ORCPT ); Mon, 6 Feb 2023 12:26:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjBFR03 (ORCPT ); Mon, 6 Feb 2023 12:26:29 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B08682CFC2; Mon, 6 Feb 2023 09:25:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QCTKZxnM7HO77nK2EkDhBcKN/Xl17/B7biNmlXV7t3e+Ql7Hs6R6hDnkUG8G9FoylMgo3KXv3ZsjhoXmYrHlwQxzke0WYpIpt3YO4TAYGlKunpq4aiQuhgpudJEnv7BkDw/hlKjrLbw/5sv0R2hvIJ8AnZSH2CPD606X8D2VvGTwhaiK0+9mC5xSXCFWT6MfZZfJIdfJdzx1j4mYDk+QPPpo0FOpZn3QTqoZ2IiMZ4qRIIM5iZtMcDagbljrZkSCn2AWyKycyh4w7UYM8hK5U2XugaCtA/G9yJZHbZJp660YisG1GIPAinyiWT1G2MhFRdsBoRiUU8t3srznuOb97A== 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=+Z1XsLW+BHt5QJlZTUgs5bieXo3vQEvZL9DKkOeE+/Y=; b=RoQh2DuA+xB66hP0k1qafxrPgqXNe40RfwBqy3IYags6UQhX/961J/NLRdwjPUL9Vs2al9IfQ4pb41GYcMKUjfTqlGUft41nA1eXvG+YSAKOgLwtRghdxFvSJzOkNvrrIHFQOyX40EusnBdMco/9gBKlzp5EA6NxmeB6WUs31kJJDaL0Yg+y61mXRhRDVFe0g9TzU9VGIDYH60l0FWQk9DUWKkJvYV6S40fWIqvA+pt6+lFBWSM9YuQd5qxbTdnuQUyijny5KbzbGc5qpAA15Hc3MV2FYMpfWNvh63ZBJKwGd4/XUgrVHmi8NncYViSnLwdoPr3ywrmF6vgi3xfqoQ== 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=+Z1XsLW+BHt5QJlZTUgs5bieXo3vQEvZL9DKkOeE+/Y=; b=Ey4kXvcwTWgehXahy4n5L+KXBWHKd5tw2dRH7leV+lqq7exjqzCMZYetyDPoICvN7J4k45EQO2EIz2avQ4C+tHMt4Paf4LLhJw5mVyCRClwwydXfaFmQ8/LVGaQInMLCS4R6Nrn60POPGP4+fJklDC24eTB9oGyrOzAESKNQWH8= Received: from DS7PR03CA0158.namprd03.prod.outlook.com (2603:10b6:5:3b2::13) by MN2PR12MB4144.namprd12.prod.outlook.com (2603:10b6:208:15f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 17:24:55 +0000 Received: from DS1PEPF0000B07A.namprd05.prod.outlook.com (2603:10b6:5:3b2:cafe::59) by DS7PR03CA0158.outlook.office365.com (2603:10b6:5:3b2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 17:24:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0000B07A.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Mon, 6 Feb 2023 17:24:55 +0000 Received: from beas.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.34; Mon, 6 Feb 2023 11:24:49 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v6 5/6] cpufreq: amd_pstate: Add guided mode control support via sysfs Date: Mon, 6 Feb 2023 17:21:56 +0000 Message-ID: <20230206172157.49887-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206172157.49887-1-wyes.karny@amd.com> References: <20230206172157.49887-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B07A:EE_|MN2PR12MB4144:EE_ X-MS-Office365-Filtering-Correlation-Id: d9a79d49-ef52-4b3f-0560-08db086710b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BjjNETiuP91p34+GmlJfWfF1LSLCs8hT/tNK6tIbqXSaiFI13VdRZ0HA7lhz3d7Td0H8PfeauoljMDXN86wyQgY+VyX/teHj3Tk6FhGjupZ51V4wErqc0oHgIC+pVEkVSpAiGLnDElF31M5oXBmBWTLqrk/19jD2a4JDkimVV7ns2V2GuRka/PAGSeq/VzQ/FP4GpfYRPNfaNX4sLtUcS6hnHPoHmQSLAVeVK4YJZrj5rpqvSsknCBBPXsxxDtIYt+m07N0DiioCuVBgcVWvTX6ucmUN9f2B/G84XulZtDPwBT46+RIqKgDMruyGt9LUkSozwgNR7r3QZoaiI8IRz4vij9z0GXfmVS1anSZKXHsIM0mNLnJNuopzrzgXgSnDIsIN0rJaZAKwjmELuBwlrht3nP2XUQ1tomWHxKAlNgPm4YbAYzmvaLr/yuvJAZWXWBhM+l4oTJmMHRKNRgES/W2fwo/VXWO3NfARAPtq8hIw+0lyk2a9NoQIJVuPjgEd8nf0KuhFklZewfoKe2Fg2QGWryc0GUS6ju/+rp+U5DZt8j5V1qZeimn+R2tjWX7J8hhRi/hynVELe4oT+gMTgNVv5bR45r7xH2JebOPwYkaVY0VBD7FqcvhS23F26PropgeE4nqbj/0ZnjvuQbVqrz/VXoPeEBtxipNZQE9TTOaAFt82lmXUENs8YWbDb2hzgxZanof393ksm3ivJKNHHQIEGONV+GNoqnO7Icpehmc= 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:(13230025)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199018)(46966006)(36840700001)(40470700004)(36756003)(4326008)(70586007)(70206006)(356005)(8676002)(81166007)(47076005)(110136005)(54906003)(6636002)(316002)(36860700001)(82740400003)(7696005)(26005)(1076003)(16526019)(6666004)(40460700003)(5660300002)(44832011)(186003)(7416002)(86362001)(40480700001)(82310400005)(426003)(83380400001)(8936002)(336012)(2616005)(478600001)(41300700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 17:24:55.6900 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9a79d49-ef52-4b3f-0560-08db086710b0 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: DS1PEPF0000B07A.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4144 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd_pstate driver's `status` sysfs entry helps to control the driver's mode dynamically by user. After the addition of guided mode the combinations of mode transitions have been increased (16 combinations). Therefore optimise the amd_pstate_update_status function by implementing a state transition table. There are 4 states amd_pstate supports, namely: 'disable', 'passive', 'active', and 'guided'. The transition from any state to any other state is possible after this change. Sysfs interface: To disable amd_pstate driver: # echo disable > /sys/devices/system/cpu/amd_pstate/status To enable passive mode: # echo passive > /sys/devices/system/cpu/amd_pstate/status To change mode to active: # echo active > /sys/devices/system/cpu/amd_pstate/status To change mode to guided: # echo guided > /sys/devices/system/cpu/amd_pstate/status Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello Acked-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 149 +++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 42 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 6582c922ad3a..4e74f59804ae 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -106,6 +106,8 @@ static unsigned int epp_values[] = { [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE, }; +typedef int (*cppc_mode_transition_fn)(int); + static inline int get_mode_idx_from_str(const char *str, size_t size) { int i; @@ -838,6 +840,104 @@ static ssize_t show_energy_performance_preference( return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); } +static void amd_pstate_driver_cleanup(void) +{ + amd_pstate_enable(false); + cppc_state = AMD_PSTATE_DISABLE; + current_pstate_driver = NULL; +} + +static int amd_pstate_register_driver(int mode) +{ + int ret; + + if (mode == AMD_PSTATE_PASSIVE || mode == AMD_PSTATE_GUIDED) + current_pstate_driver = &amd_pstate_driver; + else if (mode == AMD_PSTATE_ACTIVE) + current_pstate_driver = &amd_pstate_epp_driver; + else + return -EINVAL; + + cppc_state = mode; + ret = cpufreq_register_driver(current_pstate_driver); + if (ret) { + amd_pstate_driver_cleanup(); + return ret; + } + return 0; +} + +static int amd_pstate_unregister_driver(int dummy) +{ + int ret; + + ret = cpufreq_unregister_driver(current_pstate_driver); + + if (ret) + return ret; + + amd_pstate_driver_cleanup(); + return 0; +} + +static int amd_pstate_change_mode_without_dvr_change(int mode) +{ + int cpu = 0; + + cppc_state = mode; + + if (boot_cpu_has(X86_FEATURE_CPPC) || cppc_state == AMD_PSTATE_ACTIVE) + return 0; + + for_each_present_cpu(cpu) { + cppc_set_auto_sel(cpu, (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); + } + + return 0; +} + +static int amd_pstate_change_driver_mode(int mode) +{ + int ret; + + ret = amd_pstate_unregister_driver(0); + if (ret) + return ret; + + ret = amd_pstate_register_driver(mode); + if (ret) + return ret; + + return 0; +} + +cppc_mode_transition_fn mode_state_machine[AMD_PSTATE_MAX][AMD_PSTATE_MAX] = { + [AMD_PSTATE_DISABLE] = { + [AMD_PSTATE_DISABLE] = NULL, + [AMD_PSTATE_PASSIVE] = amd_pstate_register_driver, + [AMD_PSTATE_ACTIVE] = amd_pstate_register_driver, + [AMD_PSTATE_GUIDED] = amd_pstate_register_driver, + }, + [AMD_PSTATE_PASSIVE] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = NULL, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = amd_pstate_change_mode_without_dvr_change, + }, + [AMD_PSTATE_ACTIVE] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_ACTIVE] = NULL, + [AMD_PSTATE_GUIDED] = amd_pstate_change_driver_mode, + }, + [AMD_PSTATE_GUIDED] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = amd_pstate_change_mode_without_dvr_change, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = NULL, + }, +}; + static ssize_t amd_pstate_show_status(char *buf) { if (!current_pstate_driver) @@ -846,57 +946,22 @@ static ssize_t amd_pstate_show_status(char *buf) return sysfs_emit(buf, "%s\n", amd_pstate_mode_string[cppc_state]); } -static void amd_pstate_driver_cleanup(void) -{ - current_pstate_driver = NULL; -} - static int amd_pstate_update_status(const char *buf, size_t size) { - int ret; int mode_idx; - if (size > 7 || size < 6) + if (size > strlen("passive") || size < strlen("active")) return -EINVAL; - mode_idx = get_mode_idx_from_str(buf, size); - switch(mode_idx) { - case AMD_PSTATE_DISABLE: - if (!current_pstate_driver) - return -EINVAL; - if (cppc_state == AMD_PSTATE_ACTIVE) - return -EBUSY; - ret = cpufreq_unregister_driver(current_pstate_driver); - amd_pstate_driver_cleanup(); - break; - case AMD_PSTATE_PASSIVE: - if (current_pstate_driver) { - if (current_pstate_driver == &amd_pstate_driver) - return 0; - cpufreq_unregister_driver(current_pstate_driver); - cppc_state = AMD_PSTATE_PASSIVE; - current_pstate_driver = &amd_pstate_driver; - } + mode_idx = get_mode_idx_from_str(buf, size); - ret = cpufreq_register_driver(current_pstate_driver); - break; - case AMD_PSTATE_ACTIVE: - if (current_pstate_driver) { - if (current_pstate_driver == &amd_pstate_epp_driver) - return 0; - cpufreq_unregister_driver(current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state = AMD_PSTATE_ACTIVE; - } + if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX) + return -EINVAL; - ret = cpufreq_register_driver(current_pstate_driver); - break; - default: - ret = -EINVAL; - break; - } + if (mode_state_machine[cppc_state][mode_idx]) + return mode_state_machine[cppc_state][mode_idx](mode_idx); - return ret; + return 0; } static ssize_t show_status(struct kobject *kobj, From patchwork Mon Feb 6 17:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13130423 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 01B42C636D3 for ; Mon, 6 Feb 2023 17:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbjBFR01 (ORCPT ); Mon, 6 Feb 2023 12:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjBFR00 (ORCPT ); Mon, 6 Feb 2023 12:26:26 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20616.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::616]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 954222C674; Mon, 6 Feb 2023 09:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ipjD9UHr23JqREv3jljYr13KhQXFOPzaUwL4wQZaI6fGEl1HsplHl2UZg+ftY6F42PpLC5TNrifCVP2lGxg7DG25VtQhSPh52j0X6c83InoWV2DBloGYhwl6YYCZWkED4O4pEnft/LDva7zBarHwS4gvQQvAvDSXY2FUXUT2j3rI6Ez/Ou3uVXfHnjfoE/AzaqWBArbMl/TwKtd2Xj0yqn86ma9L4kN7cEUEQIfIQLnRIyQxmNR2ZdkCzfE4opdesZHRSqag0P1ttO77DMQW11Ttlj5mBe9zQUrQvYwBjOoZJuGM49Dn+OfA7TR446qjgiP4tP5ZN230gP7V050w6g== 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=Dg0Vkj3D9j46jkTDW3/wPndEHLKjgqWxLF5vzaqN5d0=; b=YM2LceXX4XvbaKnBGnnE8AYuNPepWWo4Bsg4Qqg8BVfQFeqLyr0+i/6MGRWx+lb7T/1m2ENWCQ+S9DGawfd00aSr3Z6ztB81KUGqTXwKsNMPDeKO1WdPGgwgSt1ufuyGoUsIW+N5wq5AhU4U+BxfIGdO6k3q+xRdFiZYdhM/US9X6/BzdjK5Nq3y6wMO9hLfo/UKWyF1lr+AOXjnrJABp089uioE36JnWYracsCuvLCgPIpWJB/cfDpIBFj0c7/Y6jTpq/ZR+97BlwmL0ECfM5bzsP9YABL5syh5+y6Lv/qyQPjK+DsBQiHOizbo3kwZ374kcAV0UcLGD2L6WVf8Bw== 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=Dg0Vkj3D9j46jkTDW3/wPndEHLKjgqWxLF5vzaqN5d0=; b=Hzm8RGUEuMl5EWzut3+yn8G6j49aFatrWu5ytlPKTltDKH8IX7ZBZxhZ81VpyDdzg+jV0C3ule8+2WcWez+0ZDLRAZ6271mr1zb6bK4CYV8vVGgJDcxe4jx/4UXkREVOy/NeowbN7MTAhJ6YbPPdXIIRsr42HMkP628QMaMOkKk= Received: from DS7P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::28) by MW3PR12MB4412.namprd12.prod.outlook.com (2603:10b6:303:58::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 17:25:24 +0000 Received: from DS1PEPF0000B073.namprd05.prod.outlook.com (2603:10b6:8:2e:cafe::43) by DS7P222CA0029.outlook.office365.com (2603:10b6:8:2e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 17:25:24 +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 DS1PEPF0000B073.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Mon, 6 Feb 2023 17:25:23 +0000 Received: from beas.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.34; Mon, 6 Feb 2023 11:25:18 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v6 6/6] Documentation: amd_pstate: Update amd_pstate status sysfs for guided Date: Mon, 6 Feb 2023 17:21:57 +0000 Message-ID: <20230206172157.49887-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206172157.49887-1-wyes.karny@amd.com> References: <20230206172157.49887-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B073:EE_|MW3PR12MB4412:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a0f0b86-059e-45e1-1634-08db08672172 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bWOVmcgtTqjzDnwY66ecicQvxnBhdpkMSIkzUtDoq4upkHzhutnLLHKG1q9bd6kz4+zxPCy64QKwKPMCJo3rhTb8a6PcUU/VzVvzT0iefSL5BseTyRlAtgKzdpm27CerIRLU0wbzsDBfnIdAiIk1Sc3O0yesOSGdTmJh6Pxq0Air1t9x3+lDUwwhqQF2UIfKrrKjhz3ZLTMvchGm8Vo/YFvZ/Shk8WFhlj7V2ZxJ2+2tvWoRi0Wze/wXuJ8dPI6rwkGJVcIumVHPw3O6B1j8cpI7lDPrHK3nGqCDTGi5pS9hmbt7DKZJCykZi03162qgy2ha8TUHy3kFbr25oEIGNAR/wLv24VMm1NxVIrPFonjJr6tyoR7AnKo4Ppl0L0aiS5wQmQoc8q1uv1JZ0PHcYDw6WlUflqQZ0YnSjpgy9beRs0ruNZSeG5c9c7hYIT+EWrbmwN/dLCQtGukVUJwGtPBhjnCJ/t8Jn1H2vM8mNePDcfRi4QF+se1I7rr/WVNd3WauZPPjHETdqYtPuP9J5UfpWh59+JKScD5kS0ihDm4MXIxm0rxgG7OskFId35ctuREpeXcsKATZmaQe05DqGtpPveQUkogmrVc/b3U6MY0OC5vXv8oTV8VmgRR7VOlSXZ/g/dZI1sADLgSEtLosm5ggfZxCgTO6BCmvxjMHutu1bxQQvjMhE/i40O5qnaX9TBmT/o/dNPzk1fM4Z21s0vDxp4G24tUD8f+mwsGwebQ= 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:(13230025)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199018)(46966006)(40470700004)(36840700001)(40460700003)(36756003)(7696005)(6636002)(54906003)(316002)(7416002)(110136005)(70586007)(1076003)(8676002)(5660300002)(2906002)(44832011)(15650500001)(41300700001)(8936002)(4326008)(70206006)(478600001)(6666004)(82740400003)(26005)(36860700001)(356005)(86362001)(40480700001)(16526019)(336012)(83380400001)(426003)(186003)(2616005)(81166007)(82310400005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 17:25:23.6960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a0f0b86-059e-45e1-1634-08db08672172 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: DS1PEPF0000B073.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4412 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Update amd_pstate status sysfs for guided mode. Signed-off-by: Wyes Karny Reviewed-by: Bagas Sanjaya Reviewed-by: Mario Limonciello Acked-by: Huang Rui --- Documentation/admin-guide/pm/amd-pstate.rst | 31 ++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 5304adf2fc2f..95d2d0a803fe 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -303,13 +303,18 @@ efficiency frequency management method on AMD processors. AMD Pstate Driver Operation Modes ================================= -``amd_pstate`` CPPC has two operation modes: CPPC Autonomous(active) mode and -CPPC non-autonomous(passive) mode. -active mode and passive mode can be chosen by different kernel parameters. -When in Autonomous mode, CPPC ignores requests done in the Desired Performance -Target register and takes into account only the values set to the Minimum requested -performance, Maximum requested performance, and Energy Performance Preference -registers. When Autonomous is disabled, it only considers the Desired Performance Target. +``amd_pstate`` CPPC has 3 operation modes: autonomous (active) mode, +non-autonomous (passive) mode and guided autonomous (guided) mode. +Active/passive/guided mode can be chosen by different kernel parameters. + +- In autonomous mode, platform ignores the desired performance level request + and takes into account only the values set to the minimum, maximum and energy + performance preference registers. +- In non-autonomous mode, platform gets desired performance level + from OS directly through Desired Performance Register. +- In guided-autonomous mode, platform sets operating performance level + autonomously according to the current workload and within the limits set by + OS through min and max performance registers. Active Mode ------------ @@ -338,6 +343,15 @@ to the Performance Reduction Tolerance register. Above the nominal performance l processor must provide at least nominal performance requested and go higher if current operating conditions allow. +Guided Mode +----------- + +``amd_pstate=guided`` + +If ``amd_pstate=guided`` is passed to kernel command line option then this mode +is activated. In this mode, driver requests minimum and maximum performance +level and the platform autonomously selects a performance level in this range +and appropriate to the current workload. User Space Interface in ``sysfs`` ================================= @@ -358,6 +372,9 @@ control its functionality at the system level. They are located in the "passive" The driver is functional and in the ``passive mode`` + "guided" + The driver is functional and in the ``guided mode`` + "disable" The driver is unregistered and not functional now.