From patchwork Fri Jan 13 05:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 642888 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 38CF4C54EBE for ; Fri, 13 Jan 2023 05:23:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbjAMFXN (ORCPT ); Fri, 13 Jan 2023 00:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232594AbjAMFXF (ORCPT ); Fri, 13 Jan 2023 00:23:05 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE7062192; Thu, 12 Jan 2023 21:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VGJFltBmgtttup+kK9BGXYUKFWOxMUnuB2+Er+yK5xIJxVSyDtdT7bFvDSYyL6POf+8wpFn3k7Lpmw14+5D6bZgQ50gGlAIOQyMgg5RJ7YHVRCoofJKuh6gD8vYq3/QghuMGqq8hzyuiTu+cyHBevByxnytO5ckccRcrrxyD4EuGP0PBriDh+w6bRKx1QEt9dVKQl0RdGqg/s9koS9PEP1TqCvDg3Kp5GXyzRmUffAmCR72OjDRK/JtJCrTDeodfReBd9JolC8VrImNfIk3911XcSlxd6bPZz+f6sW/tJzNDwoZwszm/MMHl6wMve++Pm6s1o4nh6x6gn87dMLuqNA== 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=Wm7ZDxu1XcY+5FrrYTlJeRqScBH0gJ8tZ0zxYBMBFUI=; b=DOD/rf/K5Mnx32mAOXPO5P1zSUsVlG6Li0E8jS+mjTdNzKZl/qgXo3vD7QRAWsOB6GmEClzUNucuY5fbXoBvCmrv1V+0NFmppcme4amkT+1DddaayFowHn47+c299Mah7SuXf/CCIf12FudGVYqP+rRSH1/v2fL6xYYrx72LOPtzQ2MtXm/bEj9qWA7jAimm5VBJixKIpVfg4a6PH3/MInTCvAYE1qj96w9FubpXcFDSoiT9Y2mibDGz/9JJy7/AE1NEKnOwDny+D38mjqiL8mHL/542l9fMeMlSzfsXD1gegTVtqYrJalBQmM2yZgd1Vp4axd4BJazV9lSVYMDYGg== 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=Wm7ZDxu1XcY+5FrrYTlJeRqScBH0gJ8tZ0zxYBMBFUI=; b=HAj207yz+WNOc3LAFvTTn7XXcAmRgKo3QfUGEVafM7W/ZQ3ENBf8Zix1KyVYlh1BfLm2XwSpGjuiL3qnukq2BdWSS9Y5PGPAbV/hSf3yfNM/LanHgqdhosdXemrXL/auA4gukqEgxdpGWxx+oo9oKpBdNHAu3eYqSjQhqWSXKO0= Received: from DS7PR03CA0181.namprd03.prod.outlook.com (2603:10b6:5:3b6::6) by CH0PR12MB5108.namprd12.prod.outlook.com (2603:10b6:610:bf::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Fri, 13 Jan 2023 05:22:55 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::bf) by DS7PR03CA0181.outlook.office365.com (2603:10b6:5:3b6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:22:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:22:54 +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, 12 Jan 2023 23:22:49 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Wyes Karny Subject: [PATCH v2 1/6] acpi: cppc: Add min and max perf reg writing support Date: Fri, 13 Jan 2023 05:21:36 +0000 Message-ID: <20230113052141.2874296-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113052141.2874296-1-wyes.karny@amd.com> References: <20230113052141.2874296-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: DM6NAM11FT064:EE_|CH0PR12MB5108:EE_ X-MS-Office365-Filtering-Correlation-Id: ec807ae7-6ba5-4ee3-bcd3-08daf5263976 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IPqXb4dLILolb3FNRUtYCrSoZc9jnXHBvjBdh9NbTy2LspmLXN6D8AHEwvHAaPB1l1bd2zPcdlGkWFQLVeTza+RAe3sAiaS7V1UpCT2xHP+3XhGiJ4SqirJGIlAKY18BGC9ah9uTpya5cj2YeK/d7f7mzRPndIfc80S3dh/1A47Y2/YvoEXf9sygEow9eypCoo0R5G9PfE49q/aeEMlEtuRnz0QJMVU0zemDVOiBeNrwOyjsuB1KqG40/Tt9HtBSvzJLYMl0TPbmlzjzz79jp3ddlIUsgbI1zYT3J45bnQB36C87f46cEeilT4cY4EmGwfCuugEr0M4bxajwuXRopPtqdyq99ZD2yJPUJ7twHTOy/n274lnCowq8hgr1/B1IQEFKrgivqg+HziCS3geJkSlDbwXTFLZkHvwjPAI7rJ90nah77h9+aEiH1SM9k4iH4yg4tKuUrOdRf8d02J95fr37kdFVa9ZqF4Hvx9S5VhCVKW34SMs6WYxesGzIwGFam4BTDD0Kkdp/4N1nzprfP8Pm8977wK0dXWJ1yXcCNmue17dHTulU01YcwyvsORzHdwwTcSM4hfVOl4mEoXlWq5KpcTvCJjhUvo9hcZ19EZJ4VimoHaFB6aahOfREAcCzsxHV6wnbjFdTllCRsL2ZRydA8I6E2TN6Z3jWsV0GVebhclKqNX99OPv3iVNJS9RKRVsWqrBmUVXlr8l+xAOttVHNUplq9JInjxJaUoZsTmE= 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)(346002)(136003)(39860400002)(376002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(47076005)(8936002)(26005)(81166007)(2906002)(5660300002)(41300700001)(426003)(7696005)(4326008)(8676002)(316002)(70586007)(110136005)(356005)(54906003)(6636002)(70206006)(82740400003)(16526019)(40480700001)(2616005)(336012)(86362001)(44832011)(40460700003)(186003)(1076003)(36860700001)(83380400001)(36756003)(478600001)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 05:22:54.7210 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec807ae7-6ba5-4ee3-bcd3-08daf5263976 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: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5108 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 PMFW about min and max perf levels. Add this support to make guided mode work properly on shared memory systems. Signed-off-by: Wyes Karny --- 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 Fri Jan 13 05:21:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 642446 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 8A203C54EBE for ; Fri, 13 Jan 2023 05:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232602AbjAMFYU (ORCPT ); Fri, 13 Jan 2023 00:24:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235210AbjAMFXs (ORCPT ); Fri, 13 Jan 2023 00:23:48 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94F8A6144B; Thu, 12 Jan 2023 21:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IypwchJig65LvplN6TD6peODRJvR2uLJY1lgoh3qrXkNPLYGMSDnVfr6ryqHxrGdDaTHItJNtLeoUYsafCoRXf3+oZLDImhGCq9OsownDXkFfxlNORg+jrxwU33AWe5nVSDDo70X32vdHpfSia0u7rwGSWDxEi3dPtP7eH2Rg4YDkyJCqgMzB8cWk4QR56uubA5vyMuESWIklBJXlgPmZrLk/oDBVMu5sOrpQClV7pkev92520wzmKRn+eA2T2HJoODMZEyVKaFjPwKGypZbkIx9pWhf7bwVI8738kWI2zUZFtFtrVKpyJgKYzDUjwLPyeUYZVrNwkG7hUe2rocwXA== 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=xHzrhqw0mZ+P9ayAqWvmbIHNuheEyALcVjg21ZwF1is=; b=WGPPV0B5nD5f8Yp59jpox5pz+l/VuITwELs4sECwAOZ1fGXzDBxeGqM0NuhI9IhuzOeRpDS8lF7xoHgpdJnlK41/U41tleiZFUjerW+FIBiQLBqAO01Az4pVFTco6sf4fY2z7pVhPbw3g2NzFhmbIkwQXftN6rP92CpoJW7y+QndrMbXS/fCXmmaCxQNYRUoUqswrhocAgv44XFMQXUK80oWOdrbBjLF4SJeNGYr8HPP1XJIT7JgwmspsaF3WMOpvfVHgZBqOMHGtbpiYEUArktk+7dLTK5kceje+3Q8/n5Zco77jnycJoK0Xpit3b/XSmoxYO9C8lswWJTHJiDwUA== 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=xHzrhqw0mZ+P9ayAqWvmbIHNuheEyALcVjg21ZwF1is=; b=SFrcmtOH4irnoaHNhSGMzTnjE3/iofyYj+lAlFouO9vjrqZrWECil1qSsggGl6gKCcMhIX6+uBJTTqgxLfP4uoXMt6aztLx7q+8sWwBlljJDasxc+rQKS7EunjuSf8C/kPoxDgZaauyp8toGGW+eyTcyzms5qmlg234Dib2a+Qc= Received: from DS7PR03CA0332.namprd03.prod.outlook.com (2603:10b6:8:55::19) by DS0PR12MB7605.namprd12.prod.outlook.com (2603:10b6:8:13d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Fri, 13 Jan 2023 05:23:33 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:8:55:cafe::48) by DS7PR03CA0332.outlook.office365.com (2603:10b6:8:55::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.14 via Frontend Transport; Fri, 13 Jan 2023 05:23:33 +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 DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:23:32 +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, 12 Jan 2023 23:23:27 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Wyes Karny Subject: [PATCH v2 2/6] acpi: cppc: Add auto select register read/write support Date: Fri, 13 Jan 2023 05:21:37 +0000 Message-ID: <20230113052141.2874296-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113052141.2874296-1-wyes.karny@amd.com> References: <20230113052141.2874296-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: DM6NAM11FT052:EE_|DS0PR12MB7605:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a4c24d5-c9e0-4f74-c9f5-08daf526502f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iXMKHIXbKzY+aaxqg7w6be7qaaH3/asQeCc8lSSKxOi/eX0atapumxtAAyH3d7uO7YU/SRbl0iDmnA3iqXmIqGFyhYLz0OYkhAvvkmrIaJxAhkW++mrDGC9zmHZlSS5Vo0u0UueCTvGrc49cL6K68Hc3eFLwGddA60uxuV/+oTEwBFqkh2HKKGAj95wBbWwwJ3N7UdNujHYLvKqVVfNd7kvesWPq2FCnJp9EmhMtALhTgQqk68Wjj+lLsUWzc5Y+dWUAC/R9k91kh0hcjilMUoufqYw8DvPF7LVMjLr1n6F2DbgIC21bYsLIpKHRTqcYwv2Qt5c/GvSxGWSk3vQQRKLUcdqVzXloIW1JwLhIV4/H8inr5hT7HwB0UIzp82SnsfSGCOhC6X1BE4+nSwaasOK3giXl7oGet7ydBKkvs7EjmUaAGdK1OhHATNQznYMlv3UXVX1zOirzFJUy0oaob30wepDVPlrfCez4IGRYCR7ZpfB7a/clerQ3NWS0jw3i4d7ltWcqiNDFwrfrIZcqwEF5oFwbgJyOeQ+fPn1VnmhtBizWi3pK//iUrEbsFQdeUZwse3qW/5OsCECY3ESFbbMd2HN2geWp8infmWMTy/wseUzvCHpYh2PjWK9F2CJwd1vIs6bJgdIRV0xntcFwoLAVG/HLP+2SS4aDaRaTDxk0aGElrGpOmtjoxV0Iu1lG4vYajYAmHWTyzKyAqb77AiDYXrejWESPnvsd90kmv5c= 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)(136003)(376002)(346002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(81166007)(36860700001)(356005)(82740400003)(70206006)(86362001)(40460700003)(6636002)(4326008)(70586007)(110136005)(54906003)(8676002)(41300700001)(47076005)(8936002)(40480700001)(83380400001)(5660300002)(16526019)(336012)(2616005)(44832011)(2906002)(426003)(1076003)(82310400005)(316002)(186003)(6666004)(26005)(478600001)(7696005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 05:23:32.8436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a4c24d5-c9e0-4f74-c9f5-08daf526502f 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: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7605 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org For some 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 Fri Jan 13 05:21:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 642445 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 852C8C54EBE for ; Fri, 13 Jan 2023 05:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235407AbjAMFYx (ORCPT ); Fri, 13 Jan 2023 00:24:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233025AbjAMFY2 (ORCPT ); Fri, 13 Jan 2023 00:24:28 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1852B6218A; Thu, 12 Jan 2023 21:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F0vcQrBXB8/uUDxD2wmhIGHozAY+ljTiKvMFQ6Smkrrgw+IfHmLXUIqREIOH+n/aj9xT1lNOxEo9VuxpkdoM49imRL8IZuB0p9+xfOT9Vzw2C2DcgtfLC3cMt8jn9vlBbZptiq2jmy8J67CGFMMnGYVNQZFAt5NUFjV+ZcvkFVoBYRb8pknldrM5uw/ouI6HVieo/1wMfCLNZguULXWLarLkut5ap4ssSUhv12PotNawNKC2yA2o9zmHvuYxlOb2vz1Y3U1/AWqIEDSAlkydHojxpV+Ng777sd2LtjCKkYupy4ReoBAYGJ/uW1shJFgpiEiIwfmHaewPH3H2+L5Frg== 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=8o7pOTB7rr581e9f3WW+ovZQfdcnvY07pEUymHiYvPI=; b=jXW91T9Qh56jbYd/Rd1L1p5Ftxc9237ttizPf8zMUBAfzkEePqEuf6oZYJGcc+j0eGAtiD5823xeNKqK3GNO2SoGFefyUMEVHZE7zEtdwY6kuxlETnSHUNPRJAUz6u1TZ9DRc/1LQ9sa/jo0YEZ8G69NtwyLKAadjppQtyZLVoEm/vLG7qajLd4cnveE+1JZx49pRnTtp53m+gEbILcbBod5BO8hRN9Owu1/C+WLqqDt+cYNow9rVObw4q5CCnHxC6Z6AOlBBAb2LnlN/l+KNDYkB7crM7ixqsZ+Oat38R3lAqbXa2zEsHHlDzFAxmErruJ8uF1BTtHEed9hAEitPA== 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=8o7pOTB7rr581e9f3WW+ovZQfdcnvY07pEUymHiYvPI=; b=uLqgVCNftlK5RDH9rSBuNjj0e7nCobrjtBi/dzkbXDyRpsydTXGSQ7Z8Qw5U3Nfw/YUB2d6z/dQdUENIutZ6Mt9py1FYAwpkqN6SATsj9si2eKVsF6nir5974jiceyGoptsWEppIaaxdEID1XtIKGbehse3sBLgzMZd2POqxRao= Received: from DS7PR03CA0143.namprd03.prod.outlook.com (2603:10b6:5:3b4::28) by IA1PR12MB7637.namprd12.prod.outlook.com (2603:10b6:208:427::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Fri, 13 Jan 2023 05:24:23 +0000 Received: from DM6NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::66) by DS7PR03CA0143.outlook.office365.com (2603:10b6:5:3b4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:24:23 +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 DM6NAM11FT042.mail.protection.outlook.com (10.13.173.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:24:23 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 12 Jan 2023 23:24:18 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Wyes Karny Subject: [PATCH v2 4/6] Documentation: amd_pstate: Move amd_pstate param to alphabetical order Date: Fri, 13 Jan 2023 05:21:39 +0000 Message-ID: <20230113052141.2874296-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113052141.2874296-1-wyes.karny@amd.com> References: <20230113052141.2874296-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: DM6NAM11FT042:EE_|IA1PR12MB7637:EE_ X-MS-Office365-Filtering-Correlation-Id: de3870ec-6d9f-4924-7453-08daf5266e2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LuSgGLbT7FB0NfKZ6IfQjEIBuzR6ffk3jibqhR/qPjKfHMZgT8k9K19YJsXvzSj56wOysvyULGoy72xeU6pfQjSkGNmzzQ0k8nO0Op+TMQuNHiUuTSG2svLppFqRWMtGPpk5UfbMb/i6Dg1v+Q2ZYedMqzPq1iq5Skb7AcYZDP0C+u7HNt8I0CVfdmtPliyr8lXDofpkPPxqXA7Qb/Bpo4ulsze3un/rtRNYnJ3d9KSH2+7IUv3R8P4Gli9rVbgUW1mLLHeRwFoQQU6DCfooIYFLMYBcXHojqkIgzCXYdx0ih6IUtBkj+AElTi6la19a3szay9HDtEeIyw/e3hzRqmMqZIfXbLYwJGNk0FTS7qYRhVbc2T/bvA2Gf9zd5PyAiMWZpee14ahULsiun/3bCOfRifIb+TIRyBZXx/eqCC0y9ikGh/6XSdmPqnisPxpTpOpsSZrb768xm7PT/F4X3qTjVCgL7/h9R1zaHupq36ZvJUKJXaOP4rVg7lzpxoptUEInB+bWofrKFd9UA++gXcwVOcQtb3ojoqXXfbAHkdhkVobUd7pFLEtTyooRbzACeRxjALHsJygXnUpYbmvi8aak8jtyEmBdk3Eqf7WdMRkNTO+u6ewN5MewvzC6XHL2WYW1WxEy1SmP4e6WJIqtQxVzsyCI8dEr5NByinK3zZedFR6KBSrlZzTrmC3pXxgqKgQN9DfgsYN/cVBQDbLtjYdL8CLfAzpa+FbpUkvhG88= 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)(136003)(346002)(39860400002)(376002)(451199015)(36840700001)(46966006)(40470700004)(36860700001)(6666004)(2906002)(70206006)(16526019)(36756003)(5660300002)(83380400001)(8936002)(44832011)(4326008)(8676002)(47076005)(478600001)(82740400003)(81166007)(356005)(41300700001)(426003)(26005)(336012)(70586007)(40480700001)(7696005)(82310400005)(186003)(1076003)(86362001)(40460700003)(2616005)(316002)(110136005)(54906003)(6636002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 05:24:23.1469 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de3870ec-6d9f-4924-7453-08daf5266e2b 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: DM6NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7637 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 --- .../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 Fri Jan 13 05:21:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 642887 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 2E0E5C54EBD for ; Fri, 13 Jan 2023 05:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232594AbjAMF0K (ORCPT ); Fri, 13 Jan 2023 00:26:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236478AbjAMFZQ (ORCPT ); Fri, 13 Jan 2023 00:25:16 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2057.outbound.protection.outlook.com [40.107.102.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39FB7621B5; Thu, 12 Jan 2023 21:24:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X3Gu8D7vU5yLSPrU4gWyAFmnTPhl/NYbfNczvhvdwHglEPtDby2opJdMKMdE1yFvhp4tG2KUG0ksEdrllipE6+oEi55PNJYCleHRKZ/GDQAUAmLrkHZL3ZSK0WkMY+nhwmkbq525ot5Y+5Y6P+zIvqBa1RUikylsVt5Pq/R75qTUrPx8hCOimXEQbcgGSNCsWNhy2+83fnyrQIb6bG0qu0q8183BnkjfmPlIkw+h8F218nJsdzgyBByD77NkTbhhzVn3Nef8Ue6K0iGEUCfkXlaAwJuCpTlEwVdJguVv3vS09kxCc8eQApgTRzPMxvDOUoujjTIuvnDMRPQOsp8u9w== 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=q6NdZDDlwli7C8W873FcbXa5fNvq5NIShjUGvulXh9s=; b=VwByethADYAlhka5axHBmHpm/dqjRioYaDNcD4apUXU4eJi9XNvI4fWT0LnNxfs3JHEEaGbsqLexbjCXwd+v9O2sxbBF8RSK2rSw18SbkyNl7B48I/goh/GJ1wyYbsQBpv8Ab3wD3VijKq4KuuZPzbINLNnl9PGIsfNgxavROgSaT0lG8uufvzWS7TycFh34LevG3HLDHEuWOut7xHaJ+jERKUw4uotpsrOY+DNI4CySgLB5DDAGI6y1eRgIsongy38aAWvZb5iAFFc07SIgyi8tTSSCCieAvleBa0at8hwa5KpRR/sXKsPP7FB/7fbwgwvxzx2hQzVbZcTaylljZg== 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=q6NdZDDlwli7C8W873FcbXa5fNvq5NIShjUGvulXh9s=; b=RPzk+7QrpfBeUFGgEKvAVD1kCXB/zEknS3ig3cdpgsmIsjgonmQ6xwjBEoofDB1rkSC8x5QyTjN+TxhePbOunt8ucPNys+VgP/grPWmZ/G/TGXUdWHY27xQEoGQBq6AtBdI9O57tkQAXNdQ0E6ANE8t5NKt9nUqNsNpDyFvl8lw= Received: from DS7PR06CA0014.namprd06.prod.outlook.com (2603:10b6:8:2a::11) by SJ0PR12MB7083.namprd12.prod.outlook.com (2603:10b6:a03:4ae::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Fri, 13 Jan 2023 05:24:54 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2a:cafe::81) by DS7PR06CA0014.outlook.office365.com (2603:10b6:8:2a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:24:54 +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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:24:53 +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, 12 Jan 2023 23:24:48 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Wyes Karny Subject: [PATCH v2 5/6] cpufreq: amd_pstate: Add guided mode control support via sysfs Date: Fri, 13 Jan 2023 05:21:40 +0000 Message-ID: <20230113052141.2874296-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113052141.2874296-1-wyes.karny@amd.com> References: <20230113052141.2874296-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: DM6NAM11FT004:EE_|SJ0PR12MB7083:EE_ X-MS-Office365-Filtering-Correlation-Id: f21002f1-6227-4610-03ac-08daf5268084 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YUXiHYyyvaM3ukiEXjlMVl7ynSZDTNA0vH6ibumTKvhUk1wxJsI9ZXkn0vdSemxseAH97I70ZeM2VPzc146VnAK+ZVeS4wQHl31kio+KoAkk0H1ZkJR5yVcqL5fwhD8fep+fbJyH05Uk1v83I2YmYCWnNF8kot3uGYoSzDxhIiIeosvmGXr1pbxYCP4MN7i0DobdDu/ZtjSTw9cLTEaWjDPgtKkMEPHf359KNRdNqO8+uA76vK/SiRWSYU2eJPhwvMeSnsN3z2gJptlZPEiZA1k9V99uP8OvZkDxLi5gYITjXKFSXkVDcO2vxq8az6ugy40VLf0t0aeg9thL3QeIokiqToRNdUbbJAbOUd4Glr/wYLhmsm6tmZcoy5h1H9I04np/NqA7PM3l84HKqjB5W6nJ6Wsd7dKNpe5omf0WA9XvFy9eTGjrpm0aakvGzpDNwi9uBJL0VozFeIn70Ekbc5m5yUaf+s9E4hKxRqohEuRi89fU5qp5lYLlGkZ8iky6eJ0tSvZd9fYBnw02FcMh7PGzw0HCSydpK+B9TXR0R3ks987hSQ/IesKCFHjpTvil5InnyB58vj0GDgKTtmISNNTKV9tolL8k+ddgQQUGEpmDTFd/AFaZ1DlpNz6/3ZbM3RHmP845JNruWZIQODr/OT+FB88XiCGhE7QsrU/tF0Dzyk/dqkolJSVFGQaIrcYWgD0vuiVw95GhhgY735j9HU4Rm2pfNV+FBdKbxbwW3Os= 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)(136003)(346002)(39860400002)(376002)(451199015)(40470700004)(46966006)(36840700001)(36860700001)(6666004)(2906002)(70206006)(16526019)(36756003)(5660300002)(83380400001)(8936002)(44832011)(4326008)(8676002)(82740400003)(81166007)(41300700001)(356005)(47076005)(478600001)(426003)(26005)(336012)(70586007)(40480700001)(7696005)(82310400005)(186003)(1076003)(86362001)(40460700003)(2616005)(316002)(110136005)(54906003)(6636002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 05:24:53.9263 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f21002f1-6227-4610-03ac-08daf5268084 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7083 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 | 144 ++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 35 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 20d78dad712d..4a2b559fd712 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; @@ -806,55 +808,127 @@ static ssize_t amd_pstate_show_status(char *buf) static void amd_pstate_driver_cleanup(void) { + amd_pstate_enable(false); + cppc_state = AMD_PSTATE_DISABLE; default_pstate_driver = NULL; } -static int amd_pstate_update_status(const char *buf, size_t size) +static int amd_pstate_register_driver(int mode) { int ret; - int mode_idx; - if (size > 7 || size < 3) + if (mode == AMD_PSTATE_PASSIVE || mode == AMD_PSTATE_GUIDED) + default_pstate_driver = &amd_pstate_driver; + else if (mode == AMD_PSTATE_ACTIVE) + default_pstate_driver = &amd_pstate_epp_driver; + else return -EINVAL; - mode_idx = get_mode_idx_from_str(buf, size); - switch(mode_idx) { - case AMD_PSTATE_DISABLE: - if (!default_pstate_driver) - return -EINVAL; - if (cppc_state == AMD_PSTATE_ACTIVE) - return -EBUSY; - ret = cpufreq_unregister_driver(default_pstate_driver); + ret = cpufreq_register_driver(default_pstate_driver); + if (ret) { amd_pstate_driver_cleanup(); - break; - case AMD_PSTATE_PASSIVE: - if (default_pstate_driver) { - if (default_pstate_driver == &amd_pstate_driver) - return 0; - cpufreq_unregister_driver(default_pstate_driver); - cppc_state = AMD_PSTATE_PASSIVE; - default_pstate_driver = &amd_pstate_driver; - } + return ret; + } - ret = cpufreq_register_driver(default_pstate_driver); - break; - case AMD_PSTATE_ACTIVE: - if (default_pstate_driver) { - if (default_pstate_driver == &amd_pstate_epp_driver) - return 0; - cpufreq_unregister_driver(default_pstate_driver); - default_pstate_driver = &amd_pstate_epp_driver; - cppc_state = AMD_PSTATE_ACTIVE; + cppc_state = mode; + return 0; +} + +static int amd_pstate_unregister_driver(int dummy) +{ + int ret; + + ret = cpufreq_unregister_driver(default_pstate_driver); + + if (ret) + return ret; + + amd_pstate_driver_cleanup(); + return 0; +} + +static void amd_pstate_change_mode_without_dvr_change(int mode) +{ + int cpu = 0; + + cppc_state = mode; + if (!boot_cpu_has(X86_FEATURE_CPPC)) { + if (cppc_state == AMD_PSTATE_PASSIVE) { + for_each_present_cpu(cpu) { + cppc_set_auto_sel(cpu, 0); + } + } else if (cppc_state == AMD_PSTATE_GUIDED) { + for_each_present_cpu(cpu) { + cppc_set_auto_sel(cpu, 1); + } } + } +} - ret = cpufreq_register_driver(default_pstate_driver); - break; - default: - break; - ret = -EINVAL; +static int amd_pstate_change_driver_mode(int mode) +{ + int ret; + + if ((mode == AMD_PSTATE_GUIDED && cppc_state == AMD_PSTATE_PASSIVE) || + (mode == AMD_PSTATE_PASSIVE && cppc_state == AMD_PSTATE_GUIDED)) { + amd_pstate_change_mode_without_dvr_change(mode); + return 0; } - return 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_driver_mode, + }, + [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_driver_mode, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = NULL, + }, +}; + +static int amd_pstate_update_status(const char *buf, size_t size) +{ + int mode_idx; + + if (size > 7 || size < 3) + return -EINVAL; + mode_idx = get_mode_idx_from_str(buf, size); + + if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX) + return -EINVAL; + + if (mode_state_machine[cppc_state][mode_idx]) + return mode_state_machine[cppc_state][mode_idx](mode_idx); + + return -EBUSY; } static ssize_t show_status(struct kobject *kobj, From patchwork Fri Jan 13 05:21:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 642444 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 49153C54EBD for ; Fri, 13 Jan 2023 05:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233125AbjAMF1C (ORCPT ); Fri, 13 Jan 2023 00:27:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233587AbjAMF0H (ORCPT ); Fri, 13 Jan 2023 00:26:07 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD474631BE; Thu, 12 Jan 2023 21:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7LrVNrdoyUSVWSM2U0GKevEJjW4N1OLImbJ0b1nxIQmb8npVUjNi3Mb7vaBWhyNF732MuQHeLmz5cEOAokJcz5YigTPX31sTvbFl9THxuqrrAGkIVdWcDPVMfrmpxHNRwnlsJrYForOXd1lDG7e+iV6WeOQjstcPQ23xbaT3DAvT+YM0gWx7k/dMqRMMY+O+YfkvO/OFWsCZJFlKnnzxUL5B0ZLX6E5X3vfkyaofu5tvkr+uTO3Z4u7zQQm3JkYkL9bIgZ7kZW/6Wyey2Xm7yjY7vPwk8Iu6yHasclXzhtrUb/usQLW1hZuX2WqVupEp5yTWgiN7B+demTX5WnlWA== 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=9erekdQ/mftikoOpNdo+ex6T2H+4bLNpiJgAumRNs2s=; b=X4O21ij7mcCGSWeyLclj6wNqjct+2OSh2lm8KRlk+J2TDy0LA2ZdLuToEtkRqq2w45LJ2aHUg4W7gHxGNdWk9GkEC76rTzEAqsbERoXdXNif6EPwWkZXKgGJoQ0pv1nLWDL2GhL8caoQ/0hFCz7gyTFIHS74eEqJLHzXIO5R+K6WGtf85A03iM2vL2v3JP3n4kj55Bf6GrMyUHM5Q3EGvWZM/34Qp2JecH97Zpsn2i1QfjyIlrDb5OVmmpPiZEC5C0w1SMElGMbbG5vR8W9BupxUZlY2uhbx/FukCfmuinw9T1WMaoWvyZzUcQP7ITly6NKHPpvGwk9fgsBCin4UXA== 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=9erekdQ/mftikoOpNdo+ex6T2H+4bLNpiJgAumRNs2s=; b=QgmBo4p+0EC4gD9DJX/9FNjCfs/8+iHWMGtwnQBdc/tmDxSie0ZEcVaROAldg+GPdoq1TpIxVmJDpXPKb2sOJ5oai1E56IMl9Rn96pOT+8SCtzOPw11Kef7gzF2LqsSkaO+pWJ43FmE107k+lMxjYuzul8xdahcZphA4y6r59ns= Received: from DM6PR02CA0161.namprd02.prod.outlook.com (2603:10b6:5:332::28) by SN7PR12MB7201.namprd12.prod.outlook.com (2603:10b6:806:2a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Fri, 13 Jan 2023 05:25:19 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::3a) by DM6PR02CA0161.outlook.office365.com (2603:10b6:5:332::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:25:18 +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 DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Fri, 13 Jan 2023 05:25:18 +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, 12 Jan 2023 23:25:13 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , , Ananth Narayan , CC: , , , Bagas Sanjaya , , Wyes Karny Subject: [PATCH v2 6/6] Documentation: amd_pstate: Update amd_pstate status sysfs for guided Date: Fri, 13 Jan 2023 05:21:41 +0000 Message-ID: <20230113052141.2874296-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113052141.2874296-1-wyes.karny@amd.com> References: <20230113052141.2874296-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: DM6NAM11FT033:EE_|SN7PR12MB7201:EE_ X-MS-Office365-Filtering-Correlation-Id: 49e31e33-4492-4387-7543-08daf5268f23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z0zipcBx9K2nb0ivuhMEhYlXRalMLTraQ3DmJEk0JbOMcZYP63gCF9PymManqpk1htxzM4blj0ftX4v2UNGxn3+nDEYm4g6mRl8yIOgIliqQh2mUlvrtUo03KWaTH2hn1gLwi63oWzQ+bbu30cP0eVkJCMi2ebbpjXhNpWiJ5DT0m7xH+wqjh2CB6iHy2N7ZPqlAfbG9QKztjs0g5LfwV3n0jggkfAai4NkJxJvH1pf4MgaMG/d7/Gd5Y2RH/pwZ1xcGvlBCQCuF9tmzfwlMfYzEifZVfbhyzJb9ECSJAdAtGRuFwZX4idGOmrd9uhk4v48s/isV+kJ6dXUQ3fCiyvR26yftwcr9S3gYfOdQYAjyvPKJs1vtMGee1NoSOJTx3QklyICKA6rEnVD9fqCGw468XDeXvxt5qj0r7O4QSkf/+p5spdXQOJ3x0FbPDP9WK/JWhCBsxcHZc5DsAaAooubHM6q9dMEX3Z6AA2UL7mPqP9CiJqDOdqTRBHulZXfaroKyjztwrSL+zsRlYVDTsEY/CIN9o/suvhjJLKFUOkvVtvB04Ecd+9uHkVPutrdLBNIZpE2BUUxwTv0Dpbalpp8etqJxlCVbcNM2hNo6EhmCqP39fvAnpoqpOLnppIquz7VDzjvjd+uKrcKAPrJbTONB4jYV3f//DixQyXJxQmODaa/9zjGOWDd7VBbklPV1+CXam+C3jjHVxC0dJT6nG8KUzboegY97TLNYIjrS9wo= 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)(39860400002)(376002)(346002)(136003)(396003)(451199015)(46966006)(36840700001)(40470700004)(8676002)(70586007)(70206006)(4326008)(316002)(7696005)(356005)(81166007)(110136005)(54906003)(36860700001)(44832011)(15650500001)(426003)(47076005)(186003)(2906002)(5660300002)(6636002)(8936002)(41300700001)(40460700003)(478600001)(40480700001)(83380400001)(86362001)(6666004)(336012)(26005)(82740400003)(16526019)(1076003)(2616005)(82310400005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 05:25:18.4593 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49e31e33-4492-4387-7543-08daf5268f23 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: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7201 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 | 29 ++++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 55396981266a..92fa22e45a2b 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -303,13 +303,16 @@ 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, guided +autonomous (guided) mode and non-autonomous (passive) 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 +341,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 +370,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.