From patchwork Wed Feb 1 06:58:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 51195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp231627dyf; Tue, 31 Jan 2023 23:01:46 -0800 (PST) X-Google-Smtp-Source: AK7set/r5KVRqXX9p0HU+beE29/LzzFW5/KNfmxYXoqAPW9KvHx8Snj7ZG7EUYX0wKwcm2TG6ZbR X-Received: by 2002:a17:903:230e:b0:198:a715:d270 with SMTP id d14-20020a170903230e00b00198a715d270mr2974625plh.10.1675234905967; Tue, 31 Jan 2023 23:01:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675234905; cv=pass; d=google.com; s=arc-20160816; b=iql5nRGJ4IPiWcbIVm8zl1GTtu76fjULOIyHeeGOUBOubjTcc1ft65459r0jgFRh9p G9yzqwMQkVSgyS1yr1aP1xXf3VX8Scqe7Yvm7Y/r3l54FR7INM9AiT92MW/h/ASqhLQS KnAxO+xkyXLX6MZmrMklxVwQpwNCGcYk+KVQXaHlKnkcvGjIJ04krf8xbCYGgAxczkux Il1Fg28v5oR1mn99Ez6dqiszDpWGzF8/xKgPYJyP858RpHADWoOmSIs2m1kR5tIvIqzh EeUzD0GJYQxc3Bd7vje/o2xrcacU5ZDA6JNR1Kn37Wbl2YOOnLr5X+qDh1ncEeSWGyWb oNlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rsiOFCzxXXHGF0WkBet0AUOBlPFFzUwh9PMsK4lNcwQ=; b=hrvrdSn3OjTlXev8Sj2paZkBZcn88MuskJssPf5tSh+tXAO77G4fESz99YnAHo5mQU Wb+ho5IbgaU9HCObbZQf/g17c1LIRtmReN6HJzDlRlcGK44qnQZRjg9pK1A7g2/rXiMi 7D9rmEA/tKcVL1/0O+NC5t2/0epjUKK4mLfysfYwklhLh9sWrP6bXKm7Q+YHg5ffj+dB 6PDpKVkb/Ag9dBUMp2Yi7IkXxq4x4Z+y2bmt+VYUSchfME86wxTH5mrRNh7b/qKxag1F R5UqfwTqQwmt4BeuHvSZ1AZHJFzd17nULMkrDc5EohsrlhCsn0IWNIWxZv/LhHTPZiuy 2jtA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=S2AfdBfy; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a170903124b00b0019268ac5d36si20733739plh.355.2023.01.31.23.01.33; Tue, 31 Jan 2023 23:01:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=S2AfdBfy; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbjBAG7l (ORCPT + 99 others); Wed, 1 Feb 2023 01:59:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231718AbjBAG7Y (ORCPT ); Wed, 1 Feb 2023 01:59:24 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E30B04ED2B; Tue, 31 Jan 2023 22:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=msEzLFnk3625uHVTWTtNft2meg67+SM/mryAqKRkePCE60plxohpyoJ6T2nVFh/UU3RxT4RUt5xYdinSWlO+w22Qm+S505S4cMZ/Zz7NRlTwm+zR35FzV0HEy/uEUX+LButHqmqJTdWO8B4k1V2bShf3RzvzDBmM6iE5EgYa5Q0uJSF1MO9g+vUkQgaKX8tTI1J9pmAglq7zHvYp/gYpe+lA+dusz8A19NVTXcLLoOXGjs2mC8zRyk6UQd6Ywec83eoIE9LLXVP2eW97OQEQfVWxTr2sbMJUSS1sCYMB0b534l236XQLl7+15y+7Ar7n9W+LAzdGgliZghqHeVEExg== 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=WCOT7k0hDwrxYWRjd8QEzcVJ/I9pz5mHqk58dw7sRyVqIPivrqW+LiKgWNJVplVPyuBP/h9TqWn8sOrktYgabdRCRCEz0MgjVbMCglzKzXbGHTmZqrpaJuagaUk0s7vob4HImTxvFosZJwbEQiWOu+xpAOunuydG+gBTFN8Iu6XP9pQrhLJCQ322MQb0a6QqU/xgjUJui6M5/3ZVqEDhUmIwceph7TFL8IHDYMrvaS3+VZy97hnBFEGOvrHjx3bkA+LSHW8d3LgAEwxMbknb+0uLqUB638FPd+bofgBGkZ1xR7iq2+2HlV1B90a4gKh3O4I17LMorRS6bLvBbWX53g== 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=S2AfdBfyMJhpPbGEefwNZIycOMDOYEnQDoGLQH/k3KZOZabXJu8tS+DI2gFcptDkaf5msDPTqzqkwu+E6WZN5f5Uei1teHno8Q96+MxeVW0jxbFohzzyr2L9rfgJZ17VEFp1DgAbd7Awi/upAECNngcGPFCGuxC7QcApnQkZ4Gc= Received: from DM6PR08CA0065.namprd08.prod.outlook.com (2603:10b6:5:1e0::39) by PH7PR12MB5853.namprd12.prod.outlook.com (2603:10b6:510:1d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 06:59:19 +0000 Received: from DS1PEPF0000E658.namprd02.prod.outlook.com (2603:10b6:5:1e0:cafe::33) by DM6PR08CA0065.outlook.office365.com (2603:10b6:5:1e0::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 06:59:19 +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 DS1PEPF0000E658.mail.protection.outlook.com (10.167.18.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.21 via Frontend Transport; Wed, 1 Feb 2023 06:59:19 +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; Wed, 1 Feb 2023 00:59:13 -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 v5 1/6] acpi: cppc: Add min and max perf reg writing support Date: Wed, 1 Feb 2023 06:58:18 +0000 Message-ID: <20230201065823.189828-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201065823.189828-1-wyes.karny@amd.com> References: <20230201065823.189828-1-wyes.karny@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-TrafficTypeDiagnostic: DS1PEPF0000E658:EE_|PH7PR12MB5853:EE_ X-MS-Office365-Filtering-Correlation-Id: e4934e3a-0a43-4b7a-2854-08db0421d72d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m+/tmFji4dU1AcLyWStnJA11O748gOf9xBdhwZmH+f95oA8rDat3bv/yYtwo6dx8Ig1VbxtT890uoZs4i5lBjVOIPD4zCmhXNbPckpdYG+Au573qR2fniFklQDQwHFbHYQ2koFS7qRi0AnAh2Ol2UwxGalN3J+ukahdjSDBGEtbeX0GDrAPqvavVDQ5B5tQrwxjJdW8Vx45b0pslyvWuVv6fB9BZNZnO+VsSYv9BG0XBhzAX8o8h/53E1u6+mHz2UjstH8eYfImP6LKS69x9LxRsdyuV+F5mIFcvlopKDzptE5YDrY1UhNvayJvWVd+HOaZ6tJVoWKCCwh+0vpJe6IOhdcJn1PrvGT6k5kCYqNNLqjlrHVO8vsi9xU7WWd0f+Vg/XFEkPqg2z67vl4Dl2ixfhOaIbVKwyauQYaXbGY2rbaINRxeJiLPSijV1dd/ZZNiu4n9Dqyv4coOMohxR+Cecc/LEfi56sj9HaQi/vbHluxtDtqw6EI0yr/vJFDwFZ8eN/wa1/A7m/AyPH8P66XzmzdHBVKx6cZIj8K+mdAXuuRZD9dw0wSWABtwAQiZJSYniiOSKp9ik0hKCqrIAGeqp/dUaRqVjs+dE6XJ4d/LIES06VVKkM4KE+qQVZqtvVAE7zFtdIoX43UzFxaYGBduVBgn7aJgoxquHFqrERRyst3YqhpibGwJYYxqBaS7pTDkFpecQ8EUOhQ1GM2zGiYTdlbMwyl0qjX6A9bEPKxI= 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)(136003)(39860400002)(396003)(346002)(451199018)(36840700001)(40470700004)(46966006)(36860700001)(426003)(83380400001)(82310400005)(336012)(47076005)(40460700003)(86362001)(70206006)(36756003)(6636002)(316002)(70586007)(8676002)(41300700001)(82740400003)(7416002)(81166007)(40480700001)(356005)(44832011)(2906002)(4326008)(7696005)(54906003)(5660300002)(1076003)(478600001)(110136005)(26005)(8936002)(16526019)(186003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 06:59:19.2924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4934e3a-0a43-4b7a-2854-08db0421d72d 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: DS1PEPF0000E658.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5853 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756611116780561782?= X-GMAIL-MSGID: =?utf-8?q?1756611116780561782?= 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 --- 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 Wed Feb 1 06:58:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 51196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp231994dyf; Tue, 31 Jan 2023 23:02:19 -0800 (PST) X-Google-Smtp-Source: AK7set94V1GNCW3Qo4CKh5Vdx8fyZaGjfKsZOSP+iI/TUmaxiCrFaa59B4C3pDGTH9KuJ+sgMGgm X-Received: by 2002:a05:6a20:8b98:b0:bf:4903:22fa with SMTP id m24-20020a056a208b9800b000bf490322famr446247pzh.11.1675234939009; Tue, 31 Jan 2023 23:02:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675234938; cv=pass; d=google.com; s=arc-20160816; b=O99ILyfyHZvPzZ9z/3df9lLifdDIDLCElHzlZ98rZKDfdirLT7OOrNv7r+aEF3GFX1 MFSawSkK/6WCcKr9skV3pb92vdJGKIZHHZVtw3DRZNF+w7ZNJKgbV4iBCRBKc5oIwwf+ sT9X6wnfOb/i93cFG6F3azq4sLCTYEA5Whpr5QjJq45/py71gTerQNRbudY7rN5GYare gv7dH/JOMvolXom6PeX/ezdCh1rS6rtXm22XRI51WxVQQFVw7tku+4vy7tUhFkwkvZCQ jv9HFe29J1Jjgwp/ziX4JNNfgIzBqmSJ/XrDK9aAG02ZZ98TH0FaR7zivUWeXXPxJ/Du C34w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=82aGwNYippQcfrJSwAkDqSbcGKrbCFCBCOh5PrQN9Dg=; b=p64+2LPzTvmcyHgIxDpPpFoyvL5YgjMxONS6u08sZfn5mBcDjbKRmHxQNC09oABVDa yPSr9nEqOAacj0yfqIH86fmeqTD8Xiz3gDtUakuxTQx7AVljoeSHQWGiremuoJ702xdg 8Pbt72KY7QEnGRPLfbIE5h6+RmitCbeipB25lc1iqwZ2hyiKmQ+byJdjXaZkU/o9DPAn gHomMWjru+2VYhqPlcURuElZvxFImwce9GbMg1Si7DnGBaw3RriixB5A5BHnM6SXqbT0 c3+q3QWN7K19J34Mi4j0CrEIXeJY8nqkOd5PddPc5PAaHRHDXSJfOzO1+BP2VIRQhxjH hJIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HzjQlBO9; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a63bc12000000b00476f43ccfa8si15869634pge.849.2023.01.31.23.02.06; Tue, 31 Jan 2023 23:02:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HzjQlBO9; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbjBAHAZ (ORCPT + 99 others); Wed, 1 Feb 2023 02:00:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbjBAHAM (ORCPT ); Wed, 1 Feb 2023 02:00:12 -0500 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 1A3775B5A2; Tue, 31 Jan 2023 22:59:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=flhVzV5Ri0jM5biTCKQz+3rejFNUPSGKaHLn5j2DCmbYURFV7o9Z8ikNxiWKohP21ynBBWWxnWKzQpP6uEFhQo8NrdxDBHE/C3m+l3ElvtilcOmMHOZdQQ+soBSvbdm4tsgKicbOoIEhyConVH2/7VvdeJ4pTG/xEvk52itSb1aGo1WS0RO9GEr+XK8dzi5loOQy8pM3SYuAapzKu8Y7Kx1ac24E99QA6o6ytac3V5G8HiA0+AA8PuscVxfvIor2xdZ1W5AjbLlBySb1LaQSmT+vl1HSaAxn+6MztRpeqGDmcyEedRXS/pI48psWWD59lXhqFfXWznh1/9G3m7822A== 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=fdb/xQEtJrrYsDCa32NuxGu+a5Wk9HmHwmv91S6wB7qjM2PL6QrTMcRKd8BCTXIo1buBEldV3+/Kcz/2Z9jVsDYUOZnoUjoX0Y8HSDk4ICP9nRpbKQXGlwkHswrUZzsZzXOZa8o9bHmBlDhZk+IzSOXF/9j60tCWk7l3uRvSkEMZvWfM7aNbvzyPxEuLrkIxiyKaTa+xPGuX+xi8AqHgNFGjFv2hcwEbMaa134v8tWaOKbp7Vxmiz1XeSpJkvdFK/pa7xWIofUp6t5thSPSnDAhTqZGNIGJTo/Uz5A3MQrZhYUxFOQRFcUmXFoN3R4K09VfEJiH/mMLaWOjWJzFKYw== 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=HzjQlBO9e31uS5Vx8QRA8m7odNssQxpI9D70KbDNCZ0w/BxoiXgy2S+qOQwYTXNluJ7ninPerAvusA1EPHVgMR6QVkEBCqalR8mO1iRzFPAiTNWC0sBeFOdUurUcW+VdI3tlcVzLNpNRMxXLWfEXR2tA/+gUDNnablsznhG2q/Q= Received: from DM6PR11CA0012.namprd11.prod.outlook.com (2603:10b6:5:190::25) by PH0PR12MB7862.namprd12.prod.outlook.com (2603:10b6:510:26d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Wed, 1 Feb 2023 06:59:47 +0000 Received: from DS1PEPF0000E659.namprd02.prod.outlook.com (2603:10b6:5:190:cafe::d6) by DM6PR11CA0012.outlook.office365.com (2603:10b6:5:190::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 06:59:47 +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 DS1PEPF0000E659.mail.protection.outlook.com (10.167.18.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Wed, 1 Feb 2023 06:59:47 +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; Wed, 1 Feb 2023 00:59:41 -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 v5 2/6] acpi: cppc: Add auto select register read/write support Date: Wed, 1 Feb 2023 06:58:19 +0000 Message-ID: <20230201065823.189828-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201065823.189828-1-wyes.karny@amd.com> References: <20230201065823.189828-1-wyes.karny@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-TrafficTypeDiagnostic: DS1PEPF0000E659:EE_|PH0PR12MB7862:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e2cdb46-1e35-4acd-9c66-08db0421e7ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2L5A+Va3vHi3yL81e+VhLOLRY0Wa3DpzUrBwd7v4EbTv4QR3AMU/pM80dAuhGwzkVEQrOMOUdzqIMvH/BtUUXP1CoWVWd8DhmM3/sKTKL0Ym87G+ZRLtMfoUcDgtBmTV/XekfjJVlxXMuxT729nCbapBflWbgtKaLoUa+yrHkn8L8BStbhHI6TBH0o0cFHQ+r+cC5CL1oUVzVzc1atH+3gdWjkhyfhO62l3QoZ1MNGE3fbadlRxtsL3C7YrxlyHJKJjFjGsffxWSp5o28qq0CVwlOPhG09V//RwAHWE2pOj8/eUM71Gry9fwDwTHdErRROfLY5BZ38Tx+MdMNjJEamxOgYf0DlTolVfJMuYcm68TCB72Ysd+W4xXUGVBt/c4rXcqeOi9OMWFcDzaOgA7WM+3qjUfbuDmxIBKa4fvEjewJPopIPt5IS6/uPp7eEOkHyk/BCezpx0kMnZ40bq8rIzuxXcARI6oc3KNNQOgxGug0oGaMObFmFykLMAjeU4dAVzGccQaJBeYXZ13+ukBiMI9wYoFhX8qEiUzsy07QsYZ/Cs0+43IZ1J2YpgymRYpWkDclfFMjaRYGbaPZ02xQtyU5vV/HebgDazaWW5+cqImLKmn1rpCVylprkCNi5gQn6bM2kUqDsxuS9hULZU4R1wLdoWcWuE6WGNQECtn8M/1I1+mE/D2EyIExN6tsmNMDCU7Q6r9ZlJC0jA4nhETfBW2lficdJvRAI2UewdBbg8= 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)(346002)(376002)(136003)(451199018)(40470700004)(36840700001)(46966006)(316002)(110136005)(6636002)(356005)(426003)(54906003)(41300700001)(44832011)(2906002)(36860700001)(36756003)(5660300002)(81166007)(40480700001)(7416002)(8936002)(47076005)(83380400001)(82740400003)(40460700003)(8676002)(4326008)(70586007)(6666004)(70206006)(2616005)(478600001)(186003)(26005)(86362001)(16526019)(1076003)(82310400005)(336012)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 06:59:47.0474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2cdb46-1e35-4acd-9c66-08db0421e7ba 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: DS1PEPF0000E659.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7862 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756611151435816288?= X-GMAIL-MSGID: =?utf-8?q?1756611151435816288?= 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 Wed Feb 1 06:58:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 51197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp232238dyf; Tue, 31 Jan 2023 23:02:40 -0800 (PST) X-Google-Smtp-Source: AK7set8dWYG2KVlgMasVdozw9a8iVgS4FZiepEBIEFF6aUNqRSlHCvJ0PIpvu7Kyc6DBm4DzwsoN X-Received: by 2002:a05:6a00:22cc:b0:592:4dc2:a2c7 with SMTP id f12-20020a056a0022cc00b005924dc2a2c7mr1420988pfj.13.1675234960307; Tue, 31 Jan 2023 23:02:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675234960; cv=pass; d=google.com; s=arc-20160816; b=gbchHCtWPVPjbrJ09NtAujej+svOatE5K4THMPOG9ZA42nIAhC9bifjnjFXK2ieaj5 XDmwK/1Z6gSbuyMBOgov9qaWZGFSS9D9+1EEsKU7Uz+T32xGmzDoNwX35bApWbSwMuPz pTCgz9jfu9g/C/hc8djCkZGwSYnIMUJfCa2Et1MmiRF2r9EODfygq8zgllAov/jnssDp pDXggC/y40eErG0/sTuhFOKiQLOLAkQKbf5OOMaxatyWXQxnc0inIohhhqv9OTR3IScc j7pQ2DZR1g9lw8PqLSit1+Clr1/MOtead8ZQjJSBQq9uxR+KRUSAnM5U3zLV+Xrflf9e WUmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AZ2v0sOzphUm9PmGAUqserPeBYocBB0x6+KV6IksPfQ=; b=snATvXm6Jktm3TKTRUX0wzc9Nf5O/tpqrzSch7/el/OFj1SRd1AgEl+Vhhy6S8N/pQ PTIzvz4aqvqEMECbXt+A+F9Cghejwg2IV7WfvVm3ht6fRJnfBOOeN2sGB5zinNd82lON tbRU4fQiIf6sj3QtlRlwS5Zo3zk8TxUDc1IsxlyQlG0ZjT49s3jTvisqNSfP2YmQ79Sf j/4uvniX6CMI5fzq7eUWJtS4Q81e+4AmoX1BDxDv7hxoVuzTXCovMxaRft0rQ3suO2JE MR94KhVYPudI97icz3qpmdy0s6VFxwWZuQr7GSteFjBWAyI1054sdZaJt7oKvOs1Fqg4 9eoQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BIQUEh4d; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 26-20020aa7911a000000b0058bc7462962si17591882pfh.80.2023.01.31.23.02.28; Tue, 31 Jan 2023 23:02:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BIQUEh4d; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbjBAHBu (ORCPT + 99 others); Wed, 1 Feb 2023 02:01:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbjBAHBs (ORCPT ); Wed, 1 Feb 2023 02:01:48 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20624.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::624]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3120B5CE6C; Tue, 31 Jan 2023 23:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S9WirQV6Y3q96asZUmMtBlJdD4LoNfy2zsOmKtCltAT51MB7nteB78PL1dBUxo61RzABg3QUPv56f/fkmvo3RR+yc9oziP1JlQbStjaN/BJfU57x0kHHc/zVgixzGiBvuZ2gEuA+/aY2GRMX57dTI5movyUDwcQ1msdPRoz41KkE8HxcAO2fUXJIeG1m0tQAq2vtz9qsHS1/njiN1uPFPzAnMOGR4MOJpjva2w8+Y++9D3jq1XJIIFD3OnuLv22bg8lJ16Ubj1M9IUtTxe5xlv9oMCVtg7B+Wj2+q+5U+xBrHuErE8pfYDEUPA6k6m7b8oFrgzcALwLfc9A2gsXgAA== 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=AZ2v0sOzphUm9PmGAUqserPeBYocBB0x6+KV6IksPfQ=; b=Cnx1a20uCo802JtvjxhjneIbM8ngJIG8J+2Ia0/CPbbjEqZBhBvmqXAXGu5MzjZjce9Sf/ks/oBCWruclMxZCJgw8bEN9bCI8+lowobXG5X6WrS4fnocC6rBakKgijgLF4HCkYG5wMofZ6duQweLIYO857BOGwvwqdq07uOuyb6QPySwZras8YQof7l08zJoDRW94wIrBPk0q3pgstw2RkaalyjDzqVvfSUEwUybCM0hRWv8uIUbvGdYwhqtmnWDpgsqh5pZiOY8yagEGGW1pyfvE93TeE6MWMSkFi5+OB9rhlunbXe13NDwW6JXXRVLoqRXJXqEi22qt02TxuLlDA== 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=AZ2v0sOzphUm9PmGAUqserPeBYocBB0x6+KV6IksPfQ=; b=BIQUEh4dFpCOtv7Xprvo+P/mGa9VMfSB5DtlebEY7TmoE2fLXrBzWzhdKJykdRn/oS1e1f6rxDT6njpupzkd18JHNGBalT5LO7B6XEmKqNbLVbWfbln3wECV4ioEve/3lDQlHTM7+B16rIYqFVp8X6wHdzCkFxLHOyhNW9UGHOw= Received: from DM6PR11CA0034.namprd11.prod.outlook.com (2603:10b6:5:190::47) by LV2PR12MB5774.namprd12.prod.outlook.com (2603:10b6:408:17a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Wed, 1 Feb 2023 07:00:36 +0000 Received: from DS1PEPF0000E659.namprd02.prod.outlook.com (2603:10b6:5:190:cafe::a5) by DM6PR11CA0034.outlook.office365.com (2603:10b6:5:190::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 07:00:36 +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 DS1PEPF0000E659.mail.protection.outlook.com (10.167.18.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.17 via Frontend Transport; Wed, 1 Feb 2023 07:00:36 +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; Wed, 1 Feb 2023 01:00:28 -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 v5 3/6] cpufreq: amd_pstate: Add guided autonomous mode Date: Wed, 1 Feb 2023 06:58:20 +0000 Message-ID: <20230201065823.189828-4-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201065823.189828-1-wyes.karny@amd.com> References: <20230201065823.189828-1-wyes.karny@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-TrafficTypeDiagnostic: DS1PEPF0000E659:EE_|LV2PR12MB5774:EE_ X-MS-Office365-Filtering-Correlation-Id: b444612d-25b0-4cdd-79c4-08db04220534 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qp0U+mlK8QUs+fSoPSt5n18AwZtkWqYWDzwocS3/dcIQieW+yOeWrS9FVuudymS0qcsMmfltSHY4rViSlieY6NOPPJB/5PWnpIck8iIUweV38j/hTZEp1su55cyGvxJiYT7KpHKmKc/IrzI57og6KnJ+O1UJz9uKT5Xbap7TWcA7k3T/iUDFchvsgfil8IyqDDuccdBUj1oXKxIhUspeI4gz4PYYVE2N2pgPZDs9LAXVoZjMBlrKW8HYnvpGzO0CbfFhfZN2quvmYtdWtqJ4QsSu5aL7++JlRpvGrdcSqnx8DVhX3c6+j81gqg0usLJupK0NGK7ZZkOg/JPom8vU/bvqtVj0v7ePVlkV7KQ8q3DxEezVQGkjk4dgrbsGcNFxTtFgPAha5PsMBncBvNdCZLcpf2RQyNKGqptT519p0Sr7u2a44EB9kvfyF5VUyZAmmdpVvFBW5CEPPDYW6MfrRyzhTynWSW+QMKu/16NEJJsIjqmXk8u34mrR7zruYLvzyllpzpoS2gZU3zUd80Ht1ewXy1TJBhTTU0kaJEX2xgmo4CBl+3swgbPOkfVBYWDRXZ1RwHf9aAbX6rSf35TEWvpx/C7yyuGxhjdcX7zF27DASFtG1c97xGCULjcHeDuMD8IKk0otjtwdEQzrLv0j7YH1yda26Pr8QBnEZBVEnNMh1wdspH1sCtSvibgJEy/YRFrIjd0W5MlgaeXjbu7V9f0KuSFtvmcYTwCBWv6zaaw= 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)(136003)(39860400002)(376002)(346002)(451199018)(46966006)(40470700004)(36840700001)(86362001)(356005)(478600001)(82310400005)(110136005)(2906002)(54906003)(7416002)(41300700001)(6666004)(7696005)(6636002)(26005)(44832011)(5660300002)(40480700001)(2616005)(8936002)(36860700001)(4326008)(81166007)(83380400001)(82740400003)(70206006)(70586007)(426003)(40460700003)(1076003)(336012)(47076005)(8676002)(16526019)(186003)(316002)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 07:00:36.5000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b444612d-25b0-4cdd-79c4-08db04220534 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: DS1PEPF0000E659.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5774 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756611173493138840?= X-GMAIL-MSGID: =?utf-8?q?1756611173493138840?= 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 --- .../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..0d8486325c9a 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..e9b9327c249d 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 Wed Feb 1 06:58:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 51199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp238191dyf; Tue, 31 Jan 2023 23:13:54 -0800 (PST) X-Google-Smtp-Source: AK7set+9xLQmSD5qMtUFdxsSdqP6B9fWuzFTjLuKKFqHw87C4yXrjz/HYxPzNX4hIShqP8y7GOLo X-Received: by 2002:a05:6402:1f83:b0:4a2:51db:c7c6 with SMTP id c3-20020a0564021f8300b004a251dbc7c6mr720355edc.8.1675235634489; Tue, 31 Jan 2023 23:13:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675235634; cv=pass; d=google.com; s=arc-20160816; b=Mjk8pPZBumb3bIk/hn7rEakBgkE4etlI6XkOnUPIew9tUJZQCv1NywOqR2Q7hkI1Sm S9A1ig+pe7PZSiZ7fSUau68Y3afhzehfbguRLb6w4iF7VTa8QLh1dJriDhMXIMF8Bxg0 CePg0w8ToFseVr6t5/y9wHFTpOjecyumsNER5S3XU+2fdJAXo6Et7BI6SD0gQqJ02Njl c+2/3rV39uzw1sPYSU5E8jIPPJLdf6OoK51WxJBlAxZc//88fSJs1S3zwTrE510U3d6y jBr6Npgo8nYrncOSNYNn/UOiu50AyRqwIoC0S0lMql0vQobTIzTOUtiYypicV6aXrAY7 oYMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ints53LEHZwvZLUph0iHAnvFkvCtAya8pcuc92Njd3M=; b=xby0696gAhL/w1sSJjiNfQzdYj0VdSBI0WJkYKZgzM8kJ71Tcim4Z6i1ssU78EHslW y1KSv+/R7b/prFiGy1hedyW6lh9mJwUFKjmp9fFhCXQsm1lxjRRy/ByqsIVZ13X1C5BN I1ulud+nDQvJ9z1LcStU3uX3ih7KO755784Bu1P2NQC9XuhTnExTTkoZsJoAyvlkAnCi OBUbjzqaR/Q0hwrGomY1BBFl5/s1zQePSpH4z7TDT9+qqxFfBD8/GDM9slN9cmFBliuK P6xHtfEngGnhxsivVeQLhgYlJ04/RFEbNd+QxLz54R+l09LhU0HpyI+KGBvp8Lyrhhq4 x87Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=jMnKdpnD; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056402517500b004a2434e55c4si10101562ede.2.2023.01.31.23.13.29; Tue, 31 Jan 2023 23:13:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=jMnKdpnD; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbjBAHEK (ORCPT + 99 others); Wed, 1 Feb 2023 02:04:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjBAHD6 (ORCPT ); Wed, 1 Feb 2023 02:03:58 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2077.outbound.protection.outlook.com [40.107.243.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3415256884; Tue, 31 Jan 2023 23:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=edY3ex+JALzPRjMxUOc2Bo9BKpAwJr0IOw8iAx0R9He3q8d+nPwnTOVwOhDEw5THWFvCht3xye4LTbwsnyg0tkVZcOhmAKKhTLL76hFM5jk6CgzAnlHSc62eejKWgNqBv/1vwyFYzcWJ/23mQUfj4CMjjUOOo9fibHQEEd6WlR/RKGzyaRgbTxiA4HzaaTtTi8Fslb1CT2+o3uqkmIdho0pDatS1fhkHpCMfLQxbsOh16zukKw1H/Itu6hu6qaq8rDM8/RZH1VpozzMU+GrFrMTbSC5sy2UNOneMYlHKZuS80r2PIBg9/D6dtlZxG1gtONa0KIP24dopvfyJpZRHAg== 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=ints53LEHZwvZLUph0iHAnvFkvCtAya8pcuc92Njd3M=; b=CBCTupOpIIiNPaPQlNhJurrlyKt3HqFzgccn4RPwAKM7UP6ug3Lib/xLSiCGCRfNhb8lEIcX6yA092jjqaMsYGnc4fJaXadtDGnOmRjaf7txDo8vJDvTddx0c7+P/13y6smRtMeBRFoNWYRZJHw+eQ9MzRIBh40YkyMg9hBhtJgmSK+kc2OaYr4lv0VWuc3z+CGhm2hBOXl/0ZrxSNZjCMdjRRA2ZbfJFl+40/4PPsUApfpAFq0pMTQ2IiJh8AUy4pOfLuSJpSJIFLqeHNzRobwA+VWcSZMQgoBQ6v2cs5mQymrAbkSM7pkFoRChh7cHIlHCx+BSyDCjQBg29LfSjA== 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=ints53LEHZwvZLUph0iHAnvFkvCtAya8pcuc92Njd3M=; b=jMnKdpnDAii9bmAARieL2Nvn1T2/YkFCSElthWK2qPyTFiuZCqIk67W+z/omzw1UFS/tuk+66YrBzqRpaFE7/oeGIkPecw3g73NzgiXvR9IHoLDZR81RmiJFnfXiYhOZSM829pZ4CvEJ7Tf1yeGRrGglhphe2fiLktfI5+e3qDk= Received: from MW4P221CA0005.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::10) by MW4PR12MB7432.namprd12.prod.outlook.com (2603:10b6:303:22d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.23; Wed, 1 Feb 2023 07:01:06 +0000 Received: from CO1NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::8d) by MW4P221CA0005.outlook.office365.com (2603:10b6:303:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 07:01:06 +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 CO1NAM11FT012.mail.protection.outlook.com (10.13.175.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.24 via Frontend Transport; Wed, 1 Feb 2023 07:01:06 +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; Wed, 1 Feb 2023 01:01:00 -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 v5 4/6] Documentation: amd_pstate: Move amd_pstate param to alphabetical order Date: Wed, 1 Feb 2023 06:58:21 +0000 Message-ID: <20230201065823.189828-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201065823.189828-1-wyes.karny@amd.com> References: <20230201065823.189828-1-wyes.karny@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-TrafficTypeDiagnostic: CO1NAM11FT012:EE_|MW4PR12MB7432:EE_ X-MS-Office365-Filtering-Correlation-Id: e9d7ea46-90bf-4ed4-ce74-08db0422173e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PMjMQRYZVuLMLotOhaQ6KVxIiul80d62XhOeJOanD3hs56E+nNerwozXdjK5hcGeztfLPYTjzuTZhsSTUnYFObWiYDMIHbpp4xDU57qYV1zJoR+xMagKToFhSPegTfCEY0pC2SW++mMrYVnc+GFhZ+J7knbn1UXlB0mXHpzheE3EtBgZFT4Y8nbF3z1ArMu4+UM849A72FEuVeo/GXCi1I8BQRYhwH0d8IuJPyU0Lny5/l1CUFdmCtSf/t8JmUWj4ca6klD3d87PcrbjeLOZGEooe3YwNRW2Xqmq67pi/5ZzyQwYBjujVs4nn9OvIxC6NOPvLGmyqvbGkVrgSyPevAA+G5fBOrc+T8asQbt8LZCXpAFpdgU2he5CqLNBbmGabFdRkebPa82kOOJ8B8AFvXt93HWrU/MUmNIHHv3Z22wnJCWlmcmkfL56+nRUbrRTBIA0WoELiTBmpHHYIcyiyB+chmpMVdQyPmhqa+198fDzgh63XK46nc7cPv8WoM94a/iKJOk5CrSJxWeqfIZ9AHn1BxC6v64xG1D07kG8tLwQbW9cVEGwHXboyQer1QH2ATDPKYuA4Kq9Ug3d3QMIqyjm4QhqljF8Pnk2USbFiDBbbqpgE8Nps2vXoV1Gpk4X0Bg4HK2N0QixUchRgwtt/cOdmrqFjV9KblM6HWUHPAYptXXOOJxDmVJ1bWwhqOLkCkY2wwKdQapYhEb+PPaFbADnjQGBFwGqF9W96wNImSg= 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)(346002)(376002)(396003)(136003)(451199018)(36840700001)(40470700004)(46966006)(2616005)(82740400003)(40460700003)(186003)(6636002)(1076003)(36756003)(7416002)(316002)(16526019)(26005)(356005)(40480700001)(81166007)(44832011)(7696005)(6666004)(2906002)(86362001)(478600001)(110136005)(82310400005)(54906003)(5660300002)(8936002)(8676002)(36860700001)(41300700001)(47076005)(70586007)(4326008)(70206006)(336012)(426003)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 07:01:06.6885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9d7ea46-90bf-4ed4-ce74-08db0422173e 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: CO1NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7432 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756611880368815257?= X-GMAIL-MSGID: =?utf-8?q?1756611880368815257?= 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 0d8486325c9a..5f6a3a34251e 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 Wed Feb 1 06:58:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 51198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp234385dyf; Tue, 31 Jan 2023 23:06:19 -0800 (PST) X-Google-Smtp-Source: AK7set8+Egr23OjdPI/towBiKOkrKICHP+LJHjOQUQZYa67Epm+6wlBDuKVzJWFZVuOJVwuHk04d X-Received: by 2002:a17:906:fcb2:b0:88d:ba89:1837 with SMTP id qw18-20020a170906fcb200b0088dba891837mr592378ejb.8.1675235178726; Tue, 31 Jan 2023 23:06:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675235178; cv=pass; d=google.com; s=arc-20160816; b=PQb0SLYWCWCCLwPcihGRa0+gZrLp+zr1WzEsUYy4g47YqwxkbiMek52vgJ6UEabhlP 6EecrawuxjEyJoDoOLhl6C+HPJ4Zc+lP+IkbQ4IrfQEcfm5XxhOdSNafHUEPBByK9zBA FOuOgnUdzehOXzDJA1uwbQWtkBoxVHoT/g0H7LjpXoWDoVX3pzv1iX2PVh4jSoxWbukd r+9DVMhaRp+ixKBmyPLT5c5tvOQlu22jSkQVNzqazE46DRptX7sDe4Dh4d6Fem9dRiVG K31oRReWjf3s1C3l2n6O6jqY2duRlscmtjL423h5ER5eamB7o5WDt5pTbqHN+U5x3rCP a44w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HG8sMo1SMnfyIQsw7eMXfdmW59SQ18zFaXGPz13Ch28=; b=ebewXxMHQv58vgdXZv/a4fWu8K2+VxMxrqNPzR/3i/TOLpc/z8VYj/6fLhkjMlOtVl EIAh17BKVYO4yjGTd1wQVAWwrX9ba0DaOFxthQDv/Ylsqni6xNr1I/Pgwmzjit/Rnzie 7k/6ij1Y1fUQVGSFOoFOMt1Kg2n2zl/tC/pIZHqFMMnE8Ur8YiVb87zUCWUwCXHRZ/Bq ZgSqUBDG8TzBTWC/NM0ihI6+orfb0mILdHkdptSe1Z5vPjqQKnjNA7DJOM94GjgZr5bX B/l9+f5SUyA9SZNx0WcYKS/K/HyCTaue+v5Yg+MXOREXYuax9dKXsSdGAZQUXb94vRrP eAjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QK4Ozadg; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay16-20020a170907901000b0087bdacdb25esi16358952ejc.299.2023.01.31.23.05.47; Tue, 31 Jan 2023 23:06:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QK4Ozadg; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbjBAHEC (ORCPT + 99 others); Wed, 1 Feb 2023 02:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbjBAHD4 (ORCPT ); Wed, 1 Feb 2023 02:03:56 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2048.outbound.protection.outlook.com [40.107.94.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEA3D32533; Tue, 31 Jan 2023 23:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mWwsfMY1VMBmRxAR0h7GGwlgLqy878q/MsIvW6HQfz2zhw/w+eC4RARWcsIXD92pXOAbvWIPm16Ekf0USEWQ2KsAr/v5jlX6SmKXZa+cOfBdMqjpE22pzh+LVhHNDGMsm9IAMyMfnVGQBCEXGWlZw5JjmD0mpVJ07xyD/b1goiRv2lN/31gNYImEx9oyNCcVSDd87XbPMF8FTzQGPERwDb4dnp3UmcSNtvfso2V3L+8LOuTnSLMwMgTtJoQerLZ9beEvdsLliU5SoTHaMIkCclWPqcekvUAwRGRiwgQIqm1g76ecMthAHy62bVYH3W2Mhc3QIYvyTza/i8eYCcH0Hw== 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=HG8sMo1SMnfyIQsw7eMXfdmW59SQ18zFaXGPz13Ch28=; b=imdAgYD2Cjr1TlURQVUsFYvBopto/HPtnjo0MGIsrV56UUBx842xeCUbZRP7+f8RL5AlnYLsEZe6q33wSK11bGiLpydaXj6rFoRiP7x91G8TqeRwvfdgVWgIzWqwMzBw+W8OQRTrjXjTB5w1PJTE1UgqyF9hcLcpplebgGAcf4V9XqU56Zg36EWC0aJorzj3bVf5Y74AYlDXoQS6WkTJz7r+siGamXENELwKbfOpkmfjc0GqZwBLW8W2xwbQAcujGjtUqeomKK8YfMhz1v6TzBY+GsoczJh8TGYoivijzhIPuw/oTq1b3LOXhDUPn7tVGktG+xfSjbKF878rz1I9ow== 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=HG8sMo1SMnfyIQsw7eMXfdmW59SQ18zFaXGPz13Ch28=; b=QK4OzadgYd57yzH2LEUApTCugS7DRuaYeXtAw5GQSsv0oHToC8okCElrg4iP889pvk9lnxxu/ZHnqMOyG/UW9miplpeAThoA+VRXWsU4UvZsCrrMh0ibLgFc0F3U3bIRFViEBlHOAVT6lhO11+fXGLuojQglr1GRpWQTQKnOYbo= Received: from MW4PR03CA0140.namprd03.prod.outlook.com (2603:10b6:303:8c::25) by DM4PR12MB5120.namprd12.prod.outlook.com (2603:10b6:5:393::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24; Wed, 1 Feb 2023 07:02:51 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::41) by MW4PR03CA0140.outlook.office365.com (2603:10b6:303:8c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 07:02:51 +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 CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.24 via Frontend Transport; Wed, 1 Feb 2023 07:02:51 +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; Wed, 1 Feb 2023 01:02:01 -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 v5 5/6] cpufreq: amd_pstate: Add guided mode control support via sysfs Date: Wed, 1 Feb 2023 06:58:22 +0000 Message-ID: <20230201065823.189828-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201065823.189828-1-wyes.karny@amd.com> References: <20230201065823.189828-1-wyes.karny@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-TrafficTypeDiagnostic: CO1NAM11FT046:EE_|DM4PR12MB5120:EE_ X-MS-Office365-Filtering-Correlation-Id: 591d958e-2f2a-4298-9a40-08db0422559f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d83bjFWtz4kni+kctJYGRLLIBzpzPntPCfmbJtMq/8rdp/MmsWndfYrxxVqCx+RB6T7PPpbMwz3r8RIz0N5W2mep9cgHVMx83s36zXTA2izO0O5qud3pv/l7EF9rmNkAJJ6bwU/Iy+hWpcrVQbsEtHvaso1ANOS6bryjlEkep8xkUf78CwJUzlUQsTGxiHt6kcs3MHxSxDm9ml8aml9VFSNUIoBd3RuQa9Oj0OSSI8d4NykNmqHXDjOEK3f84Mz9jcb2QE/GD+whB1IWg4msMXWRI6XFOsrldIk6VPrUiQLf+G9IcwHsBjrFAIFJoJrBYwDbqjfygMS2FGsztxGtJfOsWrIwWWIVFvFSkQOiDRMKIdMKRW/d6gNWVgIkwlltGkbhasY3p+vbxx65J7BMoLBjAfxvNPDfxhGz7HejZjopI/1vw8Nnufy/NAvdhjYRDmWksg0qfU+FBS6xUS+wIynFSu2Lt2wLza70kbr1OUkzcSnO3YbSwFTmOHFqw0g2eKD7uOMX6grsxiGL1b/L/iHzXLmwAM9eNKhGoqbp3Sy+nBP48sRcpNnrqsFdY/mzu5vwSuW7QIIZRVsce4HiEgCdSC1d8waG5+1h9ckoTVwby+ueOH3ZdPSt2n5upwUKnzRgS7zmGjPpt/zcJxjMRX4N4fqBOG7JWrAQmFcwNXKyQB+LfyPN5otvVRpJJfGQDacH36cKhyHjMP4jdWMZDz7/0awpXu4rhouRzLGaGjw= 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)(376002)(39860400002)(396003)(346002)(451199018)(36840700001)(46966006)(40470700004)(316002)(2616005)(82740400003)(82310400005)(356005)(81166007)(26005)(16526019)(47076005)(336012)(426003)(83380400001)(186003)(36860700001)(6636002)(40460700003)(44832011)(36756003)(7416002)(54906003)(110136005)(5660300002)(40480700001)(2906002)(6666004)(1076003)(478600001)(86362001)(70206006)(70586007)(8676002)(8936002)(41300700001)(7696005)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 07:02:51.3573 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 591d958e-2f2a-4298-9a40-08db0422559f 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5120 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756611402723988202?= X-GMAIL-MSGID: =?utf-8?q?1756611402723988202?= 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. Only if the state requested matches with the current state then -EBUSY value is returned. 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 --- 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 e9b9327c249d..6631aef8258b 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 -EBUSY; } static ssize_t show_status(struct kobject *kobj, From patchwork Wed Feb 1 06:58:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 51200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp239405dyf; Tue, 31 Jan 2023 23:16:02 -0800 (PST) X-Google-Smtp-Source: AK7set8mwfGY98xl6hdWoCykz3rMGukltFOqsyHazbik7aQf6DeG1xlT2Wx/QCHEs0fyrwjc+qzT X-Received: by 2002:a17:906:5054:b0:889:5686:486a with SMTP id e20-20020a170906505400b008895686486amr1371890ejk.30.1675235762020; Tue, 31 Jan 2023 23:16:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675235762; cv=pass; d=google.com; s=arc-20160816; b=uBmObXAvmuTLGzx44TubTcLyg4zPeGrIFb8FR/lb1XlDMF0BuN7p6MSM1H7SrbRWse pleFX3y1zUj4HDcNLfKHJJRfjoM0RkgQK73auqCevVYDQcSHhO7y34xHcnmksrB8lvoz 3+sDl3XHlKtgOw0ry8eI6nsbsjbfaP5uHHgy0piPlj2ZWCeoXJPG4jwnjN9LHikp1eVa NsH86IGe38pstbIG6d+XKKwoMOFdz3kFSp3A270/Cgd/S889LlH0/mRPJDdeLoARt/b1 hRFzuiu0lhAUS3kyByYlKWJCcE9pp4dzsM18+3ROCk4eEUs50dmUm42My3PVeq/6o9cd DV7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4n0RpfNBZd6GB8zi6rx8maW2j8088D2LzBQWffsVsrM=; b=bv9vOHh8isSP6TuyiMKn36hjEmEMxabn+gDLeI3JGsYiXvNe8c7OyUR37mBfNEncev iPxUlWIIpkHnvt2HFESNCoTYzDwk9t3j9A+yAeDo2yRhiFBTzj+kiAMFBQMnEJN6SUjV P/aidTqZuOdCIoEKcg5YXuXBw1320IEXED7Lpd6IZi6D8zM0ZLHyk5hqMfX+n4i9sTC1 ZraeQ3jQvVB3WpVkDznwobNFlSg8d3SKu5tnGQ9TnK0fGr/AuP3g8xWYc2X355Tn95hK 30OOeUrBOYQ03issNtZOUvq14PFhqFA/2V7nrGwqgt2dyT1e+pXh+uPMsWPLzXad8SuN 1Ung== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lvEEiUCX; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fe24-20020a1709072a5800b0088c68695915si4410152ejc.961.2023.01.31.23.15.37; Tue, 31 Jan 2023 23:16:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lvEEiUCX; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbjBAHEF (ORCPT + 99 others); Wed, 1 Feb 2023 02:04:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjBAHDz (ORCPT ); Wed, 1 Feb 2023 02:03:55 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB343402C; Tue, 31 Jan 2023 23:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pfl0x402Cr18ChPko+xDFsUMXE0HtedtfaPdu9iV5kVicGhaD7yMo/6+CwqPsTOeIbT47d2IRboRPsKK+5e5b/bAr945kiRQm/Zs9wSVujQ4h0BsEM+7O/0CBSGuyHQ65W5tw1XbHvtUtM1agniYeGHLO+5EEkdIi5WubkJTMptRD5iql9KXtwmNde421np6pjerL46mHNy0eIR6QwOwF/vgxWTRmYuNP+QYKZoa1/r+e3q8reWpZ4nnZl8x+jB0pkup+CLllqDTqvBz+imDaFhK1smSieDlk8Wqu/Nl6z8UKI4ySK8tgi3jAyYKPTsawIdQGmwv6RkkOr9uPh3zNQ== 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=4n0RpfNBZd6GB8zi6rx8maW2j8088D2LzBQWffsVsrM=; b=LT+Fah+I4t5dezmOO3K/iZDNMpiq8xiSe7CNYfsfRTg6KX30LwMXyrR2/4NidRdLq5hrR7/w4Xt4JHqzvcPLiwZKFAvRJnZ+KWJbMrCCMpjZaPrXzl99GLYLSybaI8TEW9Yy9wgY2iG9sMh1wcaU+njv/V5vC0s0Q6jebdA3WjBJj6ZZv26KviXCAdlkmpljz22Akxb9Ovf7Xi5zoJimna2JboD6imVPWLMZpE9e3o1ic7L4qahQoWqk/N0+h+gRO47cLnKPQVMhuRWOrCxv04/XeuFsxxr9xDKznhU47rfm36ruZURXqkmVCS5aOOcf1hRdgRBAZnTzbNWo6vgKyw== 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=4n0RpfNBZd6GB8zi6rx8maW2j8088D2LzBQWffsVsrM=; b=lvEEiUCX4Hm0MsRUY0Jv5WdvuJ9+7u+tT6h9bwSm0JHbwoPiqYCr4cwVEWsAfWI5flBltinkMg1ZX5O5JPNLxTUwsJN50eB9VSK8OJXWo0a9vvIv7BH5IGtjBAj+fsWkJtVdeDps7X2mMfvu2+z4gFS10tRQEnVcApJeFXhfZs8= Received: from MW4PR03CA0144.namprd03.prod.outlook.com (2603:10b6:303:8c::29) by MN2PR12MB4422.namprd12.prod.outlook.com (2603:10b6:208:265::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 07:02:56 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::8c) by MW4PR03CA0144.outlook.office365.com (2603:10b6:303:8c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 07:02:56 +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 CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.24 via Frontend Transport; Wed, 1 Feb 2023 07:02: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; Wed, 1 Feb 2023 01:02:50 -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 v5 6/6] Documentation: amd_pstate: Update amd_pstate status sysfs for guided Date: Wed, 1 Feb 2023 06:58:23 +0000 Message-ID: <20230201065823.189828-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201065823.189828-1-wyes.karny@amd.com> References: <20230201065823.189828-1-wyes.karny@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-TrafficTypeDiagnostic: CO1NAM11FT046:EE_|MN2PR12MB4422:EE_ X-MS-Office365-Filtering-Correlation-Id: fb48b480-35bf-4177-1d04-08db0422585a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p/y9/ewF6g2ESQmcxRXNjCgudOUmhaxGVChGkK+Xx1rhCL9sD4UbSFAmql/X3GaZqCZReabLPeQlM+DxYxomBs7+eEEoLAnHDpeglwpgctoxffHbWUjgmdaWNgLLfhfF6N3Ra++uP0OW9BZ9YoeQe9xVhu8PM8JcTzC5DKFRJz6vz5wpnkC0po3bQL0K/dAL63+rn7J5D9AGixPL0U8MtpaBnhb6LwW+1gtbAnGp/NutldyncwZOl1I8wjBjMwOjpCzhzdvblvzs/1Vg1C0fIQ3dpW5WK3kv7b/GVbyULcg49rLkmXAS3bXMUtuJZmUvdjSPSdu6CpmNSYEZdgzsStCk2m1whAJZDzWrVpvYONt9CGve/2N1xjyj6M87MQEFAKjynXKx+mvTqTlpUsfOUy/bCtLvYZn7kJ6D/VEK0X6VXJOnFMLwPK8hfYe9tpg2aScxkpMNPPRhL/sNd/JhPSBtEgO0Aa/WuOSkTlKKg9im+0TvvW3UvtT/JG/QM/yCzrv/4A4hnf2VMbR4/WWo9Bu2XlFCIs6tjp7VpKqa5tQvpoDo9rHBiIfld1JIimbZa6MUnXA0c33+ZHVJLVlL+7c1pixnZ68Uj1nbUW0odr9vC4AjgYdHuctZowDcu3CuO345hg5IMNap7L4riR9uEElBfD1kh5RV1OkK+GrAJS52FmhgaFOR6rarRiCRgtxjmvozIwos0K5YTgwjHB3pdw3qWHKdxsc+skXaL7PtLsc= 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)(376002)(136003)(346002)(451199018)(40470700004)(46966006)(36840700001)(2906002)(8936002)(15650500001)(8676002)(4326008)(44832011)(336012)(478600001)(36756003)(6666004)(426003)(186003)(40460700003)(5660300002)(16526019)(7696005)(47076005)(26005)(2616005)(7416002)(1076003)(40480700001)(86362001)(82310400005)(41300700001)(356005)(83380400001)(70586007)(70206006)(82740400003)(316002)(36860700001)(81166007)(54906003)(6636002)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 07:02:55.9350 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb48b480-35bf-4177-1d04-08db0422585a 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4422 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756612014090696742?= X-GMAIL-MSGID: =?utf-8?q?1756612014090696742?= Update amd_pstate status sysfs for guided mode. Signed-off-by: Wyes Karny Reviewed-by: Bagas Sanjaya Reviewed-by: Mario Limonciello --- Documentation/admin-guide/pm/amd-pstate.rst | 34 ++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 5304adf2fc2f..17fafe5d6625 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. @@ -368,6 +385,9 @@ control its functionality at the system level. They are located in the to the operation mode represented by that string - or to be unregistered in the "disable" case. +Note: If someone tries to change the state to same state, which is currently +active in the driver, then this will return -EBUSY error. + ``cpupower`` tool support for ``amd-pstate`` ===============================================