From patchwork Thu Jan 19 11:50:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 645340 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 5E4B3C46467 for ; Thu, 19 Jan 2023 11:51:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbjASLvU (ORCPT ); Thu, 19 Jan 2023 06:51:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbjASLvS (ORCPT ); Thu, 19 Jan 2023 06:51:18 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::61c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB5A646086; Thu, 19 Jan 2023 03:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Er7t9wN9bYry+DRqpqPOSmRBNHkwUQfQch08BH5L9IB9PaS+JywmuQ3ZNW2gzdSxBQAwegr4NkaCk7ta5Yh2Y9Zmt9EfPfFgdAtKfVVrbvBB3pIi4CdAh3/lUNHbH1i9uaVvzs9q0FCGrjEd1SYyCargg16ONHwOdthK5xmYqegpfTZaB5csTX2W2bcUwWdStGCqTAHLGL6kdwSByNpHX8ThAsljgg1kxKQMeDHrziwMX2i3d1pbQqq7kiAhfu6IXLYYsgP81YoQtyN188hurAgD0s/SCVPQdUAYyGIYLGH1S8EgSe61Gga7XcDr/8qfeL3O+JXXWYduBpbz25pfdw== 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=UAmu7Y2MS+O8fjWpELf1F2AX3fR9gUXskyFwpXcHx9Y=; b=N1/iP3SKi01lVvneAcZalvSEqwhy5vKdq8hGR4njeew+Yxa5BfPA/A3SH6YAeTifmxIdr9LLdosaoCJsOgf9SJqjZ2cZsSHUuMtztJnjd7mVCbk0HGQxYtD8ajLhTyvwqO8G4lIRs/Ru0xQGJN1vtSm2on0SBd7FvggXiw9kdk/vh5X2HFki7mgbFAq8PDI1cnzG0wOOlpdxLIEuVql4k9UDVthLjK32WkQXdIqZjzhiDf6I048bXlqdfiDL2hCEWpD33hoCJOG/esXZRZWMwSTl+ComOuIJRg2y3ZNu59SRjv/QyKwmSR6f5YjsVc+HFaEsHuw0DNr55U23HTLxBg== 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=UAmu7Y2MS+O8fjWpELf1F2AX3fR9gUXskyFwpXcHx9Y=; b=CTOAPsnRDDvLeeSGRCKFUa4cUVOGIU4+2TgSPruj5clPW40NHEBJDJe8VAzukAP9gQhVBX1MAocjQ3koyQpW+xA7V6uURLQoUzbF0bQWx765O0fdm+1ci3t8WqIKEKg/BVnd/LWPLTRmGYb6rNE7ni2OdQ0hEtvDjDNgZgfuuMg= Received: from DM5PR08CA0026.namprd08.prod.outlook.com (2603:10b6:4:60::15) by CH2PR12MB4312.namprd12.prod.outlook.com (2603:10b6:610:af::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 11:51:07 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:4:60:cafe::fc) by DM5PR08CA0026.outlook.office365.com (2603:10b6:4:60::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25 via Frontend Transport; Thu, 19 Jan 2023 11:51:07 +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.6002.11 via Frontend Transport; Thu, 19 Jan 2023 11:51:07 +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; Thu, 19 Jan 2023 05:51:01 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Wyes Karny , Mario Limonciello Subject: [PATCH v3 1/6] acpi: cppc: Add min and max perf reg writing support Date: Thu, 19 Jan 2023 11:50:12 +0000 Message-ID: <20230119115017.10188-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119115017.10188-1-wyes.karny@amd.com> References: <20230119115017.10188-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: DS1PEPF0000B074:EE_|CH2PR12MB4312:EE_ X-MS-Office365-Filtering-Correlation-Id: 35d22499-4cbd-41e6-afd8-08dafa137350 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MNyRYn5DH410EwtGE16jrcYqQ7szWWExEenDiTCAi6be9089W46u/9cc6HSAhgnVQUO7Wp7uW3JOOXv898dBg8fThboJuGKWTOcGAn2uluNCLre4p0fBu1aqPufYuPybwBMjg9TMHquVZ2pl1D3HPdbHN3QGqB4Dg59YxnTbfOGbwQH/ppuFa6AwgK9OghsQElXZkUFcGNFIOZitXHhgtNxltQ2czG73mXJ5J2L8MP876MsrauTBkEfKdTnMK+mewToyDXYX6+nV6bE8g3P/bVmHnKuhUQEH/bjWB3MkfjZssAEgAM6zVXBoCAngw7tNmo9RMro9JmS6gcTw/8MNlJMnEVSAHyIK2UStZzfJb7rncQTvYq434SrSa3tKcGpqORagKXyDkHPE3qw/nKZWNMHHp5ueY5JIKDgSWSS4d6HCp0tpAoeTdWqn3Q8W0SjTgDUyjihzkayqxGLpr9R0MFtiy+KgQUPTsZd2JXsTLjQQXXTf1T5Q+kCwkMhMD91n+BuR267eaIxpjSIE4ghWZ426roWdj/RvZUqiJyIWwjkvtUkf9bd5Qw4VLXe7SZouwTus1rKQU+iWE+vpJpP54u270q5mZvw+0aX1wWWulp3n9BA3qDTANF1Y08R01bh5gwS3WWP8a2chO8ki4lrz1Rj/TujSFeyocgVHOM/RFOCSnqBHkXnZdn7vhERh2kVg0EMDX0OsQXppY8bSA464qq6N1Yp4IQwngMq+RCx/i98= 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:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199015)(36840700001)(40470700004)(46966006)(44832011)(16526019)(186003)(26005)(2616005)(478600001)(6666004)(1076003)(6636002)(110136005)(7696005)(336012)(54906003)(70206006)(70586007)(8676002)(4326008)(426003)(83380400001)(316002)(41300700001)(47076005)(7416002)(8936002)(5660300002)(2906002)(36860700001)(82310400005)(40460700003)(356005)(40480700001)(86362001)(82740400003)(81166007)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 11:51:07.1555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35d22499-4cbd-41e6-afd8-08dafa137350 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: CH2PR12MB4312 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 --- drivers/acpi/cppc_acpi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 02d83c807271..c936ff503965 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,11 @@ 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); + cpc_write(cpu, min_perf_reg, perf_ctrls->min_perf); + cpc_write(cpu, max_perf_reg, perf_ctrls->max_perf); - if (CPC_IN_PCC(desired_reg)) + 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 +1583,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 Thu Jan 19 11:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 644529 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 3D5EBC46467 for ; Thu, 19 Jan 2023 11:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjASLwB (ORCPT ); Thu, 19 Jan 2023 06:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbjASLwA (ORCPT ); Thu, 19 Jan 2023 06:52:00 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2043.outbound.protection.outlook.com [40.107.223.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED693302AA; Thu, 19 Jan 2023 03:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LD/ib+pei047tkZsycf7B0nSRddMsdTRS4eGYilD70idZDvn5dikiK5nafUGdI3MlemqZAFrJyoL3T4hsvmspFAhobvt+iI0VsfblIqmI3hp93y2zfrDGq83NBgarCGd6c3jeo5r2BQLHtPJlBbF/wqWY0+XjNRQ+n3zu0bzqJFXIXM8/GwtgKUroTrQnC00sONQj2MKPuroedVb1+IJot/1BnbGT3CaXEL9BMLvkWwt9FAS6jd2rCAZ0SF90jvSsIjFNbdp8Z/LMU4dzZkoG6MIrNAgq6w76uR4UKheYipCiFDm6j23cNFr1iJQJY1wbtOUcOQYERaDOaicJ7VZXg== 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=bhVkymXeHoZowm758idB9fs3vqfG/nYfIbxZHkSfneI=; b=Gk89lK4iRvX7cYHSDXJ+tGyEsFKIP/kQKY2jRIZcwRKSNX54D70Pt3Yp25gYOFjHPtWLXi1hXubmTYXFm6aiaMzKr+fHjIRqJQGKTPLSLBFPhsf6vd+VoMMbF2RtqFaiS6KZca0jvFeAXuc32xyg+VSxPoDjMno3LoCpPSEcJe8r9vnaOg2jZaqnXs23EgFBgXgmmPDNVMhVgJmZ0pPHyK28Y96R+TYtdwoIAqplR+nQhR5Ks2i+LLVA2ML1YQmtOxupH+lGt/LahIGBhPe9HgPVB5wiQh7cs2PB965Wqdhsi/Y8u4cdG5r7U7OiHYApOHu4wPnUCnsFWey2Cmhw4Q== 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=bhVkymXeHoZowm758idB9fs3vqfG/nYfIbxZHkSfneI=; b=4Z2Mp+x7jY2C9rrDk449WSp/ZK+BN9LqnrFATbzJv1soG0qOu6IdunK/4ieABPM24AlWu7BVGeY42jLpKy1ZYpIKyXO3yHRJvf7QVMm+/HhDQFXeguuv/DPSwrxxWukVLEIJmLoLGRBXzIIh9IOlOPRioB5BcLJ1XEJTYjOyb+E= Received: from DM6PR03CA0032.namprd03.prod.outlook.com (2603:10b6:5:40::45) by BL1PR12MB5349.namprd12.prod.outlook.com (2603:10b6:208:31f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 19 Jan 2023 11:51:57 +0000 Received: from DM6NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:5:40:cafe::f0) by DM6PR03CA0032.outlook.office365.com (2603:10b6:5:40::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25 via Frontend Transport; Thu, 19 Jan 2023 11:51:57 +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 DM6NAM11FT028.mail.protection.outlook.com (10.13.173.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Thu, 19 Jan 2023 11:51:56 +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; Thu, 19 Jan 2023 05:51:51 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Wyes Karny , Mario Limonciello Subject: [PATCH v3 2/6] acpi: cppc: Add auto select register read/write support Date: Thu, 19 Jan 2023 11:50:13 +0000 Message-ID: <20230119115017.10188-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119115017.10188-1-wyes.karny@amd.com> References: <20230119115017.10188-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: DM6NAM11FT028:EE_|BL1PR12MB5349:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a63b335-fea0-46d1-1589-08dafa1390f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MRvvuNDNxlMOhSIGXfWvoGdOVnNNButv70DzHhnvbQYmb4yuYa75VoHwQsThck8ufBN+SbNRSXWtEEkilUkusg810zYhEgXR4hhI2XX5x8vCFj1PDfdXoydVdip4Gx1lOX+LQaLfuGs+5xnCt+DhVxN3rMRWNX/p5ZkXXBiDmR0R2odCLIYy8BbQQ4dS7zUHkLjJ3IUImaKFlxfpRsp/AQZt1wThDhgrjmXOLlCrSh5HK/ffF30zybb7yhJ864gEL0uPwgEOARaabInY933m0k0y9t+uV002+DWPADiPUyYN8szj643Nst3B6nUeRKhvsRs8A3FGx51IycT2yH4z/0RLBPVNB44dqU1lmvo6BhBeJ5gLboOOiPnshTEq1FQru0y0fMGAY0ZAFKdikBGcYQ72bN0R4HPxwoY1Jq1WDautNefyS8/0IwotHCyGPD+HpXphIrLhoLtWr6P3eMtHASYpTS78x+lHD7D3xgU5RtXkOX2dqePU7ZH6RjlQJNXVLkxJMKzXlfutfWAjJN84tE8/bB8ghFayUYGESes1YmjJCcFRCPo1i40C4IzP2X0Lw0GrMOq6fCtFiuZZ8dWpncnQd32mFrK5DSkHz7KgMDzeKGXC59AIsa/y8UY17b4l4Zl4gmm99Rs4Sj30rh9/9k9XRyabUUDX4FzCQ8VgcaZwigVeJIdzkkWVynJHW+O6tk2jeYdU9e/Xcibh+6rhbRLtleMxQuHu0d3k65jm5OQ= 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(40470700004)(36840700001)(46966006)(8676002)(4326008)(70206006)(41300700001)(8936002)(110136005)(6666004)(44832011)(82740400003)(2616005)(82310400005)(316002)(6636002)(54906003)(2906002)(70586007)(1076003)(16526019)(40460700003)(36756003)(5660300002)(7416002)(86362001)(478600001)(7696005)(40480700001)(186003)(81166007)(36860700001)(26005)(356005)(83380400001)(336012)(426003)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 11:51:56.8606 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a63b335-fea0-46d1-1589-08dafa1390f1 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: DM6NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5349 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 c936ff503965..e47b2cfe022e 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 Thu Jan 19 11:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 644528 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 571BDC00A5A for ; Thu, 19 Jan 2023 11:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbjASLx1 (ORCPT ); Thu, 19 Jan 2023 06:53:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231162AbjASLxX (ORCPT ); Thu, 19 Jan 2023 06:53:23 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BFC169233; Thu, 19 Jan 2023 03:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLavcqkf4xKVln22w0q5PPx2APTKw0sbuu90XpZdiFJdLzEX/E8nCyLQk4F0Rv+wZrvv5gcd+aFJlSqS31D78Rqw7W2thyRo0Yxp55c0fPAJsnU0k0CjG698ynLKZubSo25JIZTmMOScko8zjeEIb61raOjF9F4wFtkO5dyPmr0xwm5rKa4Y/MjHn7xx6oyc4x5P/V4hJfONR9WzlPRvg0WWdVxX/Ih8Y+NWL+PnTxrrBXKKww/qnhqNpHosUccYHWov/YgCP5yIDPvaDOEFyZfaeE1k27yc9ElGKKutR3r5gdrd9qmNxT38O30u3Iz+tJevE++nXnlI41vhUnzm1A== 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=pSCb9E7hlwVFlUz5E0Q0t2Sq3suv8GG6PLWOYj7pyfw=; b=Ynf8GHvb3MBfFXFDbCMzwvUYHcIZnDusj5cTNMHSZLFUu8OyesjdSllNk2K6KDYZ4Pcgh6TXWNK/y/u+x+lRp5tvhRhE/jFu9mb+kuJSKulzcwxJEjvHv8Rfmh8V82dt801jWBC2uLa1QlkTZvYVVwxCv7l79Re218EWTX3QKwEL2EYGmiFk0WpIeuFp4xMyuX5/ngNmvunFnQ/J00xc2c3E6RRgd685hIe+r2+j30oETqKb2HWxCj5LXqkS2ADuYgkpMguQ9eMT+tyb8pD6YxivjrNXXHhabyo4MD3rkFvSe0awZfSJUoMIv9knxxhTacTcmYMu4E7EDAmFaD5ZlQ== 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=pSCb9E7hlwVFlUz5E0Q0t2Sq3suv8GG6PLWOYj7pyfw=; b=aDP4KhLQqPl7eIPctZzNg9msYqF7adX/pLBVcXDBenGvSByvIAdqVR9OzYtbb1TX+28zqEQEICtRV6n5A+5f9O3jEB+8Ji8V5+tuQHKWezt4C6hMI3QUoZ/0lcbvgzaXTihrhFmGjgtsMOvIufkyCL+i8N5R22P4xTaz0SBk3Go= Received: from DS7PR06CA0007.namprd06.prod.outlook.com (2603:10b6:8:2a::25) by SA1PR12MB8095.namprd12.prod.outlook.com (2603:10b6:806:33f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 11:53:05 +0000 Received: from DM6NAM11FT072.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2a:cafe::bf) by DS7PR06CA0007.outlook.office365.com (2603:10b6:8:2a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.26 via Frontend Transport; Thu, 19 Jan 2023 11:53:05 +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 DM6NAM11FT072.mail.protection.outlook.com (10.13.173.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Thu, 19 Jan 2023 11:53:05 +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; Thu, 19 Jan 2023 05:52:59 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Wyes Karny , Mario Limonciello Subject: [PATCH v3 4/6] Documentation: amd_pstate: Move amd_pstate param to alphabetical order Date: Thu, 19 Jan 2023 11:50:15 +0000 Message-ID: <20230119115017.10188-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119115017.10188-1-wyes.karny@amd.com> References: <20230119115017.10188-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: DM6NAM11FT072:EE_|SA1PR12MB8095:EE_ X-MS-Office365-Filtering-Correlation-Id: bdc8ad86-81f1-4fdf-68be-08dafa13b9cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Td4LXZlssfxy76raut38FMI+1GmPObV455NuVPjXhn9AtoZWlM3uXpdkqk3rX8ZaQPp5WvnKpw0vKXsV0lmQv3+WFrX2PBxu5TmNZCskiBllCz9a/aU1mqgjbirK4gfjOM2XiizGNCqmOFdDWTRT+vFixZL5JLtnru/nhrCHKXZNaXf6zn1VqIwdpcILCog7RKW9yTkkML1xiHaN6GI2uCdobXWO8+m8TlWvSkt8ogym9ijqZD4E2HM6Ke9EYkJaaAB+1ffF4ilSUMw1W83nhmIiBsKFLutp4c6oJ7pdC9UWrNa36R/F9F/jEzih6XaZ2HnGK+f4nK4GlPZlRF/m6YRc0cZuDNaF52k3UCqa5wX3ZSNLl4kXNLX4BiTaTb2EBG8UZvYTKLOnU3kWf9lnNqq7TvDTopOKbJcBPjXbGIa1YHjDqXwSJSSX0IJMHCH0rxsnRUG6mpqAriHfOoSRpW2JSFN5JNqRG3Zx9mU0hFiFknRpfizq8pWrSxbW4Qh2WF0rD6HoZqpC8+zLMMlTxg8ZnPXbSqfPuLPvIVcG9nCtlUCkwbvPvwlw7bHUXFdwFKZTdV3Y/2b2pdhq2OzQlEBETIzVQVgatEi3e/3F0cEKXs2XvZ/weF4cW3iAiixHtl5dH9Yr8J+DpsYwTxHsGeREhSKI2K6Zp1tZcWqiQErJePvvgrT4S7G9VKqwLpGriIge0olUW2Hb3j3nbouLHXkDiilnq/GltU4MZxbSNzE= 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:(13230022)(4636009)(136003)(396003)(39860400002)(346002)(376002)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(36756003)(426003)(47076005)(8676002)(41300700001)(70586007)(70206006)(7416002)(44832011)(8936002)(26005)(478600001)(16526019)(186003)(4326008)(83380400001)(1076003)(336012)(316002)(110136005)(82310400005)(2616005)(54906003)(7696005)(6636002)(6666004)(5660300002)(356005)(86362001)(36860700001)(2906002)(82740400003)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 11:53:05.4134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdc8ad86-81f1-4fdf-68be-08dafa13b9cd 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: DM6NAM11FT072.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8095 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 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 + tires 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 - tires 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 Thu Jan 19 11:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 645339 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 CCDD5C00A5A for ; Thu, 19 Jan 2023 11:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbjASLyN (ORCPT ); Thu, 19 Jan 2023 06:54:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjASLyA (ORCPT ); Thu, 19 Jan 2023 06:54:00 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2074.outbound.protection.outlook.com [40.107.92.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A4244B4B9; Thu, 19 Jan 2023 03:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WkvyqLivzf4BAbp1NC7PvbU8ioqHq7p/X9o0MR16NxqG34HK+QR3HH416kcq6bz/ifKy3iF36UxRlgpsBtp4ty2aYrZNjIQ8pP83oSbYwZ6RtXjuoOu2UeDU38Mr/24IPEBe+jD3jdNPsRMzhw7aka6o5Ak2NhHKAlhaN0pMJNNKthVEUojFrxw67fFC+Kt2ZKb3dNaT/rV7AQQQClcQLabEV1EhmhHBCHosg7df159l6svjFF0qYHYmJPt5XGCFQgs5s6T7l+Lz5JYbpXXeCRMNJ2k7ia6GsTcS5fJsRK3zj4uflbV0Q+gv7C/f2XuwwnXlY/Z+o+NZsf7DhneTmg== 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=ySkUoIANDrWEcEwIJ3J40AhyqLHlwikYn2xI1eJyKNE=; b=lLXN95LWZtFesCr76K8zb1D3Dd5JHFq6KS4QdLZt5OdRQudW4XWq4ae3Nfk/Uc4bPVEo23UcPu7B8KuyKhZk1fvgwI4xyl5pbE+YkSgeLZy5Nu30cqXAxmFbkRy8N54+6yVgtCE7t98eOr9M3GDESAEWzL4L7pR/gHCrcXaVQ5YK7vpHR5RkTsnIvoOhXLed2S22v2XAsZ1qhAWPR4V03DJND85Vzz6CMWmQM81gQm2aRoYF6y+BH4ogCotBPo81DkMH0VPN0+yqd48v6mcTrVM288IFRkvuiJtln0lY76LeSNspRCSNECIEKAMy6BuNI/DISQ2CR8C7QR3dOHRq2A== 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=ySkUoIANDrWEcEwIJ3J40AhyqLHlwikYn2xI1eJyKNE=; b=R4sBAR0A/hTOS4VXgaq+7+VDsBAFhq6+AkKeYjHQ4C611sZ4MRtcYuvuf4UpH+3rmXpQJ3WbzFAzrnbzw6mloaSYiwyA+D1wD/th/LCKRx283zsD7SsmOuV40c/8u5ZQyh2gXp53wMmNscf2si1U0Rx4IogOsz72tPwoZGEJUWY= Received: from DM6PR05CA0038.namprd05.prod.outlook.com (2603:10b6:5:335::7) by DS7PR12MB6070.namprd12.prod.outlook.com (2603:10b6:8:9e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Thu, 19 Jan 2023 11:53:50 +0000 Received: from DM6NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:5:335:cafe::13) by DM6PR05CA0038.outlook.office365.com (2603:10b6:5:335::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Thu, 19 Jan 2023 11:53:50 +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 DM6NAM11FT106.mail.protection.outlook.com (10.13.172.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Thu, 19 Jan 2023 11:53:50 +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; Thu, 19 Jan 2023 05:53:45 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Wyes Karny Subject: [PATCH v3 5/6] cpufreq: amd_pstate: Add guided mode control support via sysfs Date: Thu, 19 Jan 2023 11:50:16 +0000 Message-ID: <20230119115017.10188-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119115017.10188-1-wyes.karny@amd.com> References: <20230119115017.10188-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: DM6NAM11FT106:EE_|DS7PR12MB6070:EE_ X-MS-Office365-Filtering-Correlation-Id: 235c9367-6684-4717-7135-08dafa13d4d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: heLDthIxPhEZZyZQ8NrZDUEG1YjCYXONbrn36yk/nGwUQA7qO9Eez9i3buoPlQP91njev9r8zgVGNPvP9OXpqnxb+IX6/7fJIx++Wzfg7CUh5vbZ3aHUD157o0V89CSMlExHKF2Vu8MGyiI07Gz4PSlr11YXe5WGEmTwT6Sx1HDUXxJNrgQfbuN5c6Rh83Uy91aGUFlkuDV1YlKc/eLaxaIbnfQwEtk3Ai4l32AxRL6NO+815J7MNpa759hYDnuYY7XFwWUk2Xx3fjgWklcBUMycr7aAxbdxchSjLUB2Yav8SNMxlMAz+hzdSHGWy1J6hTq5WTCp3h+AfdK4ykUItJ60bn8ZBTgYKHI/fi/ynUHO2Sye0NoTQNUFNCJci8fBsvrZhex71SUOlUX68sftapYBAOkYsGyncZIvXi1uaCCvOihxiCHSCXW+2qspXwu8dVfnFF+bPq0PekZBqAWt/pbEBzuSSK6DikJY3v0H0R7H+ZcAFmEzQtmopqUL6ppZsLRD/UmqjBPAISafKQKlj2IlG+ETe1Vv1dYTQAhgtkd8YDLQB/jPZ2LTOdR9Y6NiGCYGhkFyUjvl4J/HRMjpeuDk3NxFAniCThErzdf0GAZvpolDlQ6G8Rt/Vzg7HhFytlQjI9WIYUjC/RRw6n5HF9xu4qdoGVrT0bjS4baC/fcirNWgXYIEsztuhHDSiK4CjY1/Vnkxcfds7Q232dmTAUhv4rMoFq17m+QBZZIgam4= 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:(13230022)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199015)(46966006)(40470700004)(36840700001)(44832011)(478600001)(186003)(16526019)(26005)(2616005)(6666004)(6636002)(1076003)(54906003)(110136005)(7696005)(336012)(8676002)(70586007)(4326008)(70206006)(83380400001)(47076005)(426003)(316002)(5660300002)(8936002)(7416002)(36860700001)(41300700001)(2906002)(81166007)(356005)(40460700003)(40480700001)(86362001)(82740400003)(36756003)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 11:53:50.7318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 235c9367-6684-4717-7135-08dafa13d4d0 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: DM6NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6070 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. 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 --- drivers/cpufreq/amd-pstate.c | 150 +++++++++++++++++++++++++---------- 1 file changed, 108 insertions(+), 42 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 6736ad260485..8b234628ec47 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -65,6 +65,8 @@ static struct cpufreq_driver amd_pstate_epp_driver; static int cppc_state = AMD_PSTATE_DISABLE; struct kobject *amd_pstate_kobj; +typedef int (*cppc_mode_transition_fn)(int); + static inline int get_mode_idx_from_str(const char *str, size_t size) { int i; @@ -797,6 +799,105 @@ 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; +} + +/* Mode transition table */ +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) @@ -805,57 +906,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 Thu Jan 19 11:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 644527 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 9676AC004D4 for ; Thu, 19 Jan 2023 11:54:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231172AbjASLy1 (ORCPT ); Thu, 19 Jan 2023 06:54:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbjASLyU (ORCPT ); Thu, 19 Jan 2023 06:54:20 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2062.outbound.protection.outlook.com [40.107.101.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBABE4B4B9; Thu, 19 Jan 2023 03:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eG5ikeyxmo3AB+/6/MRoSKy31P4KE6pF2OjxlUCRkmKWxdxc865vUcXbHw7dhI4x+ZrCfMRJcGDGr7fzvwDxOEpg4BjMrBB5wYUzrjJo9ILfZwF5KGh7LTyO6NYhMnxpuYrRxOxAcqebXmblj4UCipYJTvmMSx4xVMzx6SDMp2oNW6yLaSrjoOXXD9W45v1LdkSbbdrt1Nq4M3X1iBTNl99l0QATmLFNZcVUaYuxjSsRt16adyRTH8Z/EfVwUQPELuPOa2gcJgwhAzo6aPYvohGLePY5N46B+c82YM14DYCM7CB5Rs09D6cpbjlIxQOmqcGo1i2CQOLyFfl5qrR3NQ== 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=e2+bi/RLp60NJfFTa706oIDyFewKZo3lNCtGPoDlh+w=; b=eKjKHj5KCt4CuZTB+pqOIWZjeaQQuJxy0gYt3fmvQ7iXDXwRpSEkafZ0Vyu/RjxX/I+Uv2FpPqBY/VHvZk0H8yq4/qx9vwkO34F31XCaX866ljnjQ1MjbprPebC2VAETgu8+XGUTom+hVfqTbnJjdKH3QLQxvEYkXpTNFcsgkAL15XXMv6H5qgbbjtw6XK/FVTZ79AekaaQcgG05tYClWhIzJCkaAUeQRhxzrpSFW0eq5lou/MWVuwH+J01S8+EQNKR7g+ESxHqnfombY1EhW4wwu7vNGQMFonPe/o8fbCBDPugF7gKag2n8N22tyXBUX9hXsrIZS3DDatfNoTGg1w== 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=e2+bi/RLp60NJfFTa706oIDyFewKZo3lNCtGPoDlh+w=; b=ARfAczN+1d3iBfOCbV3HguCSKQgSKeyZH1YWZp2G0nVHKJ0qkVMb07438o7GneN+uvgnhLgVlGK6M5NRAoeDp0HvFrEN4yZIPT7lOKYhEPy/Orpvcxo4ic6UVoALe1I2DVjGmpCbrQh+LSIv0677IW+wTefhhbfP4CHRnsASNV0= Received: from DS7PR03CA0260.namprd03.prod.outlook.com (2603:10b6:5:3b3::25) by PH8PR12MB7303.namprd12.prod.outlook.com (2603:10b6:510:220::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Thu, 19 Jan 2023 11:54:15 +0000 Received: from DM6NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::d) by DS7PR03CA0260.outlook.office365.com (2603:10b6:5:3b3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24 via Frontend Transport; Thu, 19 Jan 2023 11:54:15 +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 DM6NAM11FT038.mail.protection.outlook.com (10.13.173.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Thu, 19 Jan 2023 11:54:15 +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; Thu, 19 Jan 2023 05:54:10 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Wyes Karny Subject: [PATCH v3 6/6] Documentation: amd_pstate: Update amd_pstate status sysfs for guided Date: Thu, 19 Jan 2023 11:50:17 +0000 Message-ID: <20230119115017.10188-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119115017.10188-1-wyes.karny@amd.com> References: <20230119115017.10188-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: DM6NAM11FT038:EE_|PH8PR12MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f6677d9-5564-4482-3b7d-08dafa13e375 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zM8F1K9DEwFvsWTRevyzEg3azDcSXouNxW3bnjXsBirbOhPXUaqC6N5TvBjjVqUA7Vc9ivOUcrvWAJ2kwRuzDNI9NzLsT5cOGWKmRZbCIdBQEoU2mgAFbbGPDGIhZZa0JKyY8LNX/nc1FlvSfbSy0Y7RVsHUJGTjwbPMgbfhekpUYhwzoEwpRYS3aecULBnOGB7LDncesESSFxOHL75LUksgq6b7eGb6W+qZR0225lBgSNn+f2+cLd9Nvkpxst71uRYyr2yEo+ZcONV99LLpw5PeKdXUy2kYk4j1u+u1ZX127bscuexBn64Gz/h4WcvwBt5rw6d5RZn7t3XU2Um1VjCD41VPcqKs5Nj0xADZ3oA7F8QNaMWj8ZTZZNZdmNT2IcVmx5z4mgeYL1auMgQ6eNGbid1k24MieUG37UvWx/rpf1WRn4ZGS1Emx1vDOvisJYUmoTWBAxR6v0iJ6xzd10x+c+TkBfdJx1icNdzp7NeowybL08GdrippPDwb8MbS9+C0J4dU3iJpPV6HN4jqE0KllCtljd5HkUPqxl08rAVonGzCuYAbsZcwI7YpOBEZG2fjSeF3Fv8L0FMfH5wZ9bXebB0wOnx77R9tqFJYPHU4cRFW+ea1wpV4aEXQGtsUKfM+XBLoQWRsJOeEHLzCQCqZ8+2pFNLYrbE6xoy0827MShpKojn2RvCv2khxJ4ibqMGIFWbfKUpRsOsv07u6Pc+Hh0GETKhtPCEL87MqlqE= 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:(13230022)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(7696005)(16526019)(2906002)(110136005)(186003)(1076003)(54906003)(2616005)(26005)(6636002)(316002)(41300700001)(426003)(83380400001)(15650500001)(82740400003)(36860700001)(336012)(8936002)(82310400005)(8676002)(36756003)(4326008)(40480700001)(70206006)(5660300002)(478600001)(86362001)(7416002)(47076005)(81166007)(44832011)(70586007)(40460700003)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 11:54:15.2998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f6677d9-5564-4482-3b7d-08dafa13e375 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: DM6NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7303 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 --- Documentation/admin-guide/pm/amd-pstate.rst | 32 ++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 5304adf2fc2f..d85a141109e5 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -303,13 +303,19 @@ 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 requested + performance, Maximum requested performance 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 +344,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 +373,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.