From patchwork Tue Mar 7 11:27:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 660370 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 B3F5AC678D5 for ; Tue, 7 Mar 2023 11:28:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjCGL2p (ORCPT ); Tue, 7 Mar 2023 06:28:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjCGL2n (ORCPT ); Tue, 7 Mar 2023 06:28:43 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2088.outbound.protection.outlook.com [40.107.243.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE1430283; Tue, 7 Mar 2023 03:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iCpB9axGZVChc42IdlFv/WVx4Yvx9v/g2jLJ3bsH/bduFgd2iWWaYmB5qCBWgIcWWCmHDP9fto0lKFVnuN+MZwmo0OmZe3Odl/YGFbNk8mIfTw/7Z4qshjhVrdVoleRcpQccPPlfwtaDR98hhqafaUg2t1xt68LROvDIMypXx1hyR1BG598f6C1JRyfa496syg6z2JYd6UdKptA5eu+PWEBrSs+QTP08ZpKpduf4jfyPmo9DYSEyO/A3noEYc52gAvBKmmwLgYxqOO3LcojTCupF/kOgU/z6wrFZCRaZNzp2Qd/PM5kXzYBVQpDFuyJYJliYwMsaqtPhYUpYfVBdLQ== 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=/SrTyn5JzOOvna1mFPcfW0xvZh2iUlGl5TCSd8BQiNA=; b=GOcAhIpEjLRwL61B017gmDOdhLmxCimX1zf4mDiLqUQPTho4yhQyT/AoLk8tcvLuQCeo33t/G05d6kWPnAZ+WwGUD9sCAOBHdgK3bd0PGrLzO4B+Pf1iDNrhPU7QIsAX2mzctKuoLDZkE38PtldZyX2uztUDXxpkK6B08YBgYxRdPor+rKiNkq0ia71RzfzJy37DF4mx1ioYq0r1cZBF8Ngy5Gr2ucBeyLtxDTF74xBWv1x/mj+5o1fsHMywIkQh56ItQe6vH53KDKCzGDzldx+oP6b9KG3c1HF8HVdC2L7/mGrlY0nPA1m9pzK2R1pT6A0AAT1aYhpxJqIMsY3tMQ== 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=/SrTyn5JzOOvna1mFPcfW0xvZh2iUlGl5TCSd8BQiNA=; b=o4Fotm8um0EUG36EHEmOrPJKHUyhs+Gibldi2Nq8ej80azalR6X7JZMAZtz07HLX9wKpm8BwyiDQd6zuBMw3OAhfOb4v/lw3ITKb0Yjosz/GYF/O+ObdX74xj3FyYnejF6Muk3qGWDrovtbw6pNc7pSSHjy/ZBlJ8H1aDW8IAxk= Received: from MW4PR04CA0299.namprd04.prod.outlook.com (2603:10b6:303:89::34) by CH3PR12MB8877.namprd12.prod.outlook.com (2603:10b6:610:170::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Tue, 7 Mar 2023 11:28:39 +0000 Received: from CO1NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::13) by MW4PR04CA0299.outlook.office365.com (2603:10b6:303:89::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Tue, 7 Mar 2023 11:28:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT012.mail.protection.outlook.com (10.13.175.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.16 via Frontend Transport; Tue, 7 Mar 2023 11:28:39 +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; Tue, 7 Mar 2023 05:28:24 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Russell Haley , Wyes Karny , Mario Limonciello , Oleksandr Natalenko Subject: [PATCH v8 1/6] acpi: cppc: Add min and max perf reg writing support Date: Tue, 7 Mar 2023 11:27:35 +0000 Message-ID: <20230307112740.132338-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307112740.132338-1-wyes.karny@amd.com> References: <20230307112740.132338-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT012:EE_|CH3PR12MB8877:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b194c00-0492-41e5-285a-08db1eff1944 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xD7VXBQtkKz9xwnXhG0J/Hlwl5xuv+Krlg9r129zl5WH+Rq2SpprUrxQHav3YA5PBwk/ADre1sT+u1hHKVwkoQ04ZnEkBNXOlBude8oUPW7xsGLSGB4OYjGZSIXtAv+PBZEz7oXkVIoVXkCqT6MqYrb+SUZcMRmr1ZNwNCtJXXk2iLOIoKnPUu22IJWkmQ9puVAKjxCTSYTzZZFvRYs22hlvtV/kO72hbKBoDWNL1dL7gAE8plnA0B+9R4oJnjRKASlkzd17TDnH1F33QBpe4CU5U5VOIKg88nmea3MTPidjhKwqDyNOh5agtupG4bZ40grdQ/rLPVL/gvJWoI9j7/faTx4nhQ2XwovSn9gwll1t/KwRdrhAEVYTaqpB4NFeWcBgB6KgxxLV74sbMza8bGZPg38xElmcGOepJNOuOCLMFaiPtvep8dGpPFovf8AjxyJO/lIK6CaUohUOgqQgg2yLRom+Qwy5eoJ45k+WLCF7dH6yDGOktoZBNMuzRKH3ZLeZ9OA8zwoPfTzpDjZTdfjtS5PMFqSo/BRFS1mNfdktMK9vnyZvwJnb84D5vdsevmZRBJlUaaz9+ORfw2j6hJc+HXjAHz14xe7eq1+eR09HDN9EaDuqdCU1wNGvta8dh4a+GUhr1sil9EcUHsTOm28p+JYus0NUE5WJ14219ByvcarOV8MOThHzM/uAN80CTdLB1BlO7L/ATG6Y79juD2i5WN46SkPYGdsM6GD7YkE= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199018)(46966006)(40470700004)(36840700001)(36860700001)(81166007)(86362001)(356005)(82740400003)(36756003)(6666004)(2906002)(44832011)(7416002)(5660300002)(40480700001)(70586007)(70206006)(4326008)(41300700001)(8936002)(8676002)(82310400005)(16526019)(336012)(186003)(47076005)(426003)(83380400001)(1076003)(26005)(2616005)(40460700003)(6636002)(110136005)(54906003)(478600001)(316002)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2023 11:28:39.0885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b194c00-0492-41e5-285a-08db1eff1944 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8877 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. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Oleksandr Natalenko Signed-off-by: Wyes Karny --- drivers/acpi/cppc_acpi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index c51d3ccb4cca..4fea6b8a26cd 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1488,7 +1488,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; @@ -1499,6 +1499,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 @@ -1507,7 +1509,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; @@ -1530,13 +1532,19 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) cpc_desc->write_cmd_status = 0; } - /* - * Skip writing MIN/MAX until Linux knows how to come up with - * useful values. - */ cpc_write(cpu, desired_reg, perf_ctrls->desired_perf); - if (CPC_IN_PCC(desired_reg)) + /** + * Only write if min_perf and max_perf not zero. Some drivers pass zero + * value to min and max perf, but they don't mean to set the zero value, + * they just don't want to write to those registers. + */ + if (perf_ctrls->min_perf) + cpc_write(cpu, min_perf_reg, perf_ctrls->min_perf); + if (perf_ctrls->max_perf) + cpc_write(cpu, max_perf_reg, perf_ctrls->max_perf); + + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) up_read(&pcc_ss_data->pcc_lock); /* END Phase-I */ /* * This is Phase-II where we transfer the ownership of PCC to Platform @@ -1584,7 +1592,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 Tue Mar 7 11:27: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: 660907 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 B2D50C6FD1B for ; Tue, 7 Mar 2023 11:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbjCGLaE (ORCPT ); Tue, 7 Mar 2023 06:30:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbjCGL3r (ORCPT ); Tue, 7 Mar 2023 06:29:47 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9178952F62; Tue, 7 Mar 2023 03:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KPJPSS51lt4mS0Hc9St3osuglShfxtJ2Yr1O732pXJtfiHPvR9XzIJ4egdhZa3zCCx2WtSLWLCcu4Lyr9Cnnh9iER1UB89ZbrvfyVd0ovi/kJhBgq8PjR6JZGbFcg4s3yis8btewDqLS/vm0Fv0Zpoywe8NRS5nUyio9ctckiCm+no0TqqcGIN89FRhLHs8/Q97PgzKJ+smR0/Rr1c+wALrnyTUowUSJLM3ins3tzw0yIEOFgXE/F/Hx5Y3vOOOn2ArJpijWci5+dNDaSvlqB9ej6LJsFrjACsdnqaAQ97NlNGDFJZ9x9POjOy1rGnzizMtHwJpBxtHsYWk5nxE5lQ== 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=tSAa14i57gl9dPrA+j7A0e2pRxhBX9sWQf13LNpTdqc=; b=nJyNAdfIUjtovu/YjvRj9TWCjTiDg5VZlDnH4QZUrEiTIInztxFXN4xz84aEX65deVoQL7p3t4HNp9Zbcoew3AsB3gtXiq2qe7dnKMfEURPbDYjmbC6DZeJ8Yo3ywKafgUCT5Wl4/TxDvGNtq3s20oCYJZodAtuqszKLGX2A8xQl9QsRKybDYBylTabjDsabA/NYmiaiS6ituOM5KNzjGthoTSkkqLcHqxBLLDd2Z3sYW27MaObAfplIdR2exdXOWyea9QGoxE7yp2rknroZEk+Y48pwtaMM0vtFqjFk2JCG4XURUUZkimQTqn/WR++Hmm2+3U11SAtErvVZJZEC8A== 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=tSAa14i57gl9dPrA+j7A0e2pRxhBX9sWQf13LNpTdqc=; b=E5uCQPHhzXHvfZ8IabO8Mv9IiN3H4ktN663bU3zsMK3KFDbge+YiNVf9/rM+xELrD+x+L2oMW2PaNG7h/i029yxcQiiUs94N/f5WxZNOSY5YGRVIdOxrYcxBYcfAndcbnearCY1m0Kkvp/GgMx5XAJlb+MOBq80pcokBSq+Dtz8= Received: from MW4PR03CA0158.namprd03.prod.outlook.com (2603:10b6:303:8d::13) by CY8PR12MB7753.namprd12.prod.outlook.com (2603:10b6:930:85::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Tue, 7 Mar 2023 11:29:13 +0000 Received: from CO1NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::93) by MW4PR03CA0158.outlook.office365.com (2603:10b6:303:8d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29 via Frontend Transport; Tue, 7 Mar 2023 11:29:13 +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 CO1NAM11FT110.mail.protection.outlook.com (10.13.175.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.16 via Frontend Transport; Tue, 7 Mar 2023 11:29:12 +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; Tue, 7 Mar 2023 05:29:06 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Russell Haley , Wyes Karny , Mario Limonciello , Oleksandr Natalenko Subject: [PATCH v8 2/6] acpi: cppc: Add auto select register read/write support Date: Tue, 7 Mar 2023 11:27:36 +0000 Message-ID: <20230307112740.132338-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307112740.132338-1-wyes.karny@amd.com> References: <20230307112740.132338-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT110:EE_|CY8PR12MB7753:EE_ X-MS-Office365-Filtering-Correlation-Id: 05108c1a-85c8-4427-2498-08db1eff2d5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1eYyMRSXz17B7gQ+//c9Gwu7VXP3SKCuEEiGPcsLycU0NsC9BDQO0JndYpzcn4IvSm/9pwNbMPdxxR3YvLGF8RYncyzoK3tXhgPpjzdSZIUW2GCfCFGC+Ousw+5/32endtlmdaosC7PYfCaJyQp8Rv6FtJ0cftNTam1MJ+gaQkPizbJYBIyMh13Ex71lafKvlJYSvu3KW38zPCM4H/skxtArQwNb+GiUxH5QOYYI0huU58xQlyZFW+42mflZdxfwx9u3najDiIal5tq2wWs+KyX/Wz/p5aQTCJmJVh9uf9aH0iI5e+Ed5jbquMMk63yPoD2pn7zJY+q75Y4UWlf4ukYZqtU/jlGxFkXcXf9wv+lm6EOzYRqDEBi1DRRFdwY0UYZ8HZyHaHLulSe5ZaTpJRblXp+U6S29Vd/9aBvl9QmcPP3yzWUI1wwO+LF76ig3LUDvUneYcgOwgIzWtn5GjX7rAip10kaF8E6V/jybYGX0ws3DIVnsOclH+bOGA7Hk4FNDbt/mwuOo09cDLKcDXNIcuxZXeq5BoVWamFqNE5jfkJE6g0PXf+RaWwyn3Q3GltBR4rxTNjQvRgTJS6vXG+1xBnunzjCNJeC8JzLpWY8nI1IEizMV4TOGsBq+/78gQYLAzwpSVjudZYGSJtJYziAZkdAa9rs84wQKjkkk4yTIz/7g+Kd/FGG+XjtjKFllG4D4swJFtfsrBKQkxg6V2/yCuiI0SlqVOesbLrh5H9Q= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(4326008)(36756003)(70206006)(70586007)(41300700001)(7416002)(8676002)(8936002)(44832011)(1076003)(2906002)(5660300002)(82740400003)(81166007)(356005)(86362001)(36860700001)(40480700001)(7696005)(6636002)(6666004)(110136005)(54906003)(478600001)(316002)(47076005)(82310400005)(40460700003)(83380400001)(426003)(336012)(186003)(2616005)(26005)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2023 11:29:12.7871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05108c1a-85c8-4427-2498-08db1eff2d5a 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: CO1NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7753 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. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Oleksandr Natalenko Signed-off-by: Wyes Karny --- 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 4fea6b8a26cd..02a4bfb54967 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1433,6 +1433,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. + * @cpu : 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 Tue Mar 7 11:27: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: 660369 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 CD65FC678DB for ; Tue, 7 Mar 2023 11:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbjCGLaw (ORCPT ); Tue, 7 Mar 2023 06:30:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbjCGLap (ORCPT ); Tue, 7 Mar 2023 06:30:45 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBEC567B0; Tue, 7 Mar 2023 03:30:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ago1p5S2Zi7U/v3X+MOaxC7hhqq58JVQ5IjLBGnnXPQMigLmxM37O5tdRvY9K69INv25zvYJgkio0Jp6yN+LPgjeAr63UEjtc3bKKFvTNWZOMu1TdwRXoTtzPHqewLoTmVrNzoQu6bq4K/s2qu/N68J8skpHqIrZphsjt7OPEioLkM1qAgvLzukE6juxa+fPK2DQQScoD2i8LUHk9WzgjYVhxuL8XRXR5jdR8I99WIEg9kowP8Y8k+S8CJ3aamf/sL0puhT77NRGr0RGAE8pWeACcuros/m1ZqDTLoE1baJ/uCufbc6EugGGFwauIbleqWbMAKzRnECkTspLF9DxNA== 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=Y6K56Vtva2K4+MI78IjTL4CHbuBG3tnEi6JeH3Niey0=; b=DhuaRyJyabZAKq9Cvd7nXc+UCZKWAPeqsTcRMdqtPt5/1/j9EzdbS98tDlvyUldHlHY14qYNgkVsAcirvNeSi2lTVdAvx0eCFR1lD0JXkfiz+M/PRwQngBaTGx11xMUsojGIcxN0XkwC4Xvg0PwNn48ZqJ27xVB14q/e5ogWHRQKIBjqiS4MqFM+TMXS1n2CvYpRXt6mm0dNQsVg13nMpl9J/OxW0nnNprjozRIonPYeKBwvT4rtY4fk0mJ4SPMlz8/uen3YfBmvENnDnVeKK7lsaLAz0G2U/YR6g8ZP7zmsXFH8H1jNTxWGgyx0WO3LbWg0PtsqV+eIExML0pC9Ag== 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=Y6K56Vtva2K4+MI78IjTL4CHbuBG3tnEi6JeH3Niey0=; b=5d8sZaTzTYF3rNUP5eiB+zBNfiCQMttMa/IqwpgHpS6HtSNAjCei29bj6ofhGfpeX6jvoPxNPKOxVBAe4+tUrYuYexFmFOgIfbedi3eIE1XCU7fx2IdRITystMlirGkhFtmOQUokSF6f/Fg0+63D4926MOnInFs/+WZb+A5xl1Y= Received: from MW4PR03CA0134.namprd03.prod.outlook.com (2603:10b6:303:8c::19) by SJ0PR12MB6808.namprd12.prod.outlook.com (2603:10b6:a03:47a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Tue, 7 Mar 2023 11:29:36 +0000 Received: from CO1NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::80) by MW4PR03CA0134.outlook.office365.com (2603:10b6:303:8c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Tue, 7 Mar 2023 11:29:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT009.mail.protection.outlook.com (10.13.175.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.16 via Frontend Transport; Tue, 7 Mar 2023 11:29:36 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 7 Mar 2023 05:29:30 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Russell Haley , Wyes Karny , Mario Limonciello , Oleksandr Natalenko Subject: [PATCH v8 3/6] Documentation: cpufreq: amd-pstate: Move amd_pstate param to alphabetical order Date: Tue, 7 Mar 2023 11:27:37 +0000 Message-ID: <20230307112740.132338-4-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307112740.132338-1-wyes.karny@amd.com> References: <20230307112740.132338-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT009:EE_|SJ0PR12MB6808:EE_ X-MS-Office365-Filtering-Correlation-Id: fe3369cc-bad3-42b0-2467-08db1eff3b9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rblhgAAoP3d5cC4BzXKUMnX8GHBfRtifH/4udRFaUwJcsQeqPaxbcDiu1QsZfRAnizcXZrO68az7UB7QnvypPVAA03U8LJSO7LVA5MxgzKvSclox6/1GAzVgOnb8HVzwY8hRsSM+IlAlEalIts/KyC4pVOdWMoJS9sLkbJjU6hXdagDgZc0GCfcmBfzD0etPWVYhxODeVHNK/RFAaOpBYTWAaijPMkmshfpEgCD3yG6hVZzytNDx3wHPQeiCfh4OhoB7gQOLew5JbsmjSOMI7CU7V8CioKbWs8s7084H5AimB2KdtTnvMoQRpRfIoGgWQnmOjuiJ3DaZ0JHOMd/js1quztNkWgU3u08wUo8zEf0K1oCZMEpiLfI0vXXMo/gjqW0n8MRlQVU/fQqr7Lxuy3tesCNZiMCexyssqn6xdBCmFeH/KkBigoR/OP3/xfhuCslP9+FmNcvJOEpTdFgjCTDC7WzWmNGXwFwiYrI1d+8px9h4eNbnzrjwYrBflgg7fQGc1HyEH59gfKat32ddfBxBrDJnGeBvkF+lDz+0O58Zh0Sz4HP73rtNowYyH/ROVzCVD6Io3rbEHpg7E77PATAZGiuoAkJKJqGPgD/JQf2NWsuzvJ+Ik/+RkqiqyNHGKEpJz/IlnUTqxZE331YI9LUL5ue40hyPs1tfR36t4BVCwGzWKkq+39PDxo4Ws6X7WpjItbtARMIlMFdKEX2t+q1lq1nYdZ9YHyNbcotSuog= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199018)(40470700004)(46966006)(36840700001)(82740400003)(81166007)(36860700001)(86362001)(356005)(36756003)(5660300002)(2906002)(70206006)(4326008)(70586007)(8936002)(40480700001)(7416002)(44832011)(8676002)(41300700001)(82310400005)(186003)(2616005)(40460700003)(47076005)(83380400001)(16526019)(336012)(426003)(54906003)(110136005)(6636002)(316002)(26005)(1076003)(7696005)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2023 11:29:36.7142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe3369cc-bad3-42b0-2467-08db1eff3b9d 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: CO1NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6808 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Move amd_pstate command line param description to correct alphabetical order. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Oleksandr Natalenko Signed-off-by: Wyes Karny --- .../admin-guide/kernel-parameters.txt | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6221a1d057dd..1e38f3ae0e62 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -339,6 +339,24 @@ 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 as a scaling driver, driver requests a + desired performance on this abstract scale and the power + management firmware translates the requests into actual + hardware states (core frequency, data fabric and memory + clocks etc.) + 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. + amijoy.map= [HW,JOY] Amiga joystick support Map of devices attached to JOY0DAT and JOY1DAT Format: , @@ -7059,20 +7077,3 @@ 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 as a scaling driver, driver requests a - desired performance on this abstract scale and the power - management firmware translates the requests into actual - hardware states (core frequency, data fabric and memory - clocks etc.) - 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. From patchwork Tue Mar 7 11:27: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: 660368 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 9FB7CC678D4 for ; Tue, 7 Mar 2023 11:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbjCGLbh (ORCPT ); Tue, 7 Mar 2023 06:31:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjCGLbc (ORCPT ); Tue, 7 Mar 2023 06:31:32 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2074.outbound.protection.outlook.com [40.107.100.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C6E454C85; Tue, 7 Mar 2023 03:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPhlRy5r8eMTrnquTz0yCmJQbnGrecdGU/7wMdlCtnnW19vSbpUHOGnu/dzPhlMtc+fVEMiNpq1sPj3sFgIp7K06z1Ny81k5qLKANrl/bx1YOzFP+Hd0O1l966NOsSmbDnz31YdmILnVEmriBb4Py5HlYdH/bwx+Eh1P/QOVuAGU8sAZE+9cVMmTSGJUzzspDHFZHj3jeJnjs/rkMQkTmAxr3rq3LtBv20nunQXqAxZWOmJ5VsgYPuCc0iihtiPSeSehmRh9zXWUO3isyRHoIu3NNtQA68SZO0ZEu+qBVGYpVrtPFP8TfQgv6XODkxw5/F7AUoGwCsbK9xyChDaPCw== 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=UOnZlLrGEYf1/bHyJj+hOsRjUJ2z2CxK+Pf03tzIqFM=; b=NN/PW7tFbvwKZGz6Q7MPQaA5OTCcselLkjfLGrgMw1UjyD14C7XRMEWQRUq/xufDGwkzPwQI2QiHwX8poa5G6UMmX0CwWI06kM6gltfLbG+zdy4cXyIZS1d0W4HDVD7b9ZUblem5uXpv+SYWxFptET8jGxb9N0t1Rz0JY97coC8USrL7k8H0oSZl/CJE2BhmSYVkPYOuXzQfK4GPYPoYi2LBJWVEsZO0+XQnQOw/o19swBclVq0ZpyCXne/AbuYc/C6FzX+T64KWPd1yslFF8O8XgTZmsr+K1AQw7ewXbS4LO1jObaaDJHfAqeGMKcXj1Bn4XlsSb5NZwa9WPXu5tw== 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=UOnZlLrGEYf1/bHyJj+hOsRjUJ2z2CxK+Pf03tzIqFM=; b=h03eehklU2syzUzCmtlsoo3E/Fn29cXtBXe/nYt9WnrkFmd6ArXIyIs5vHphLRDcC0VfB3EDtjjc+ctnHTTmglEJq/+bgHkFyxxdoT38n9gRjn51VQze5zfvkfhP4QtyTJ2HWYQ1kTrC2eMouTzNe1FLI+5EvaLrBzFsNCg6jE8= Received: from DS7PR03CA0244.namprd03.prod.outlook.com (2603:10b6:5:3b3::9) by BY5PR12MB4243.namprd12.prod.outlook.com (2603:10b6:a03:20f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Tue, 7 Mar 2023 11:30:25 +0000 Received: from DS1PEPF0000B07A.namprd05.prod.outlook.com (2603:10b6:5:3b3:cafe::c7) by DS7PR03CA0244.outlook.office365.com (2603:10b6:5:3b3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Tue, 7 Mar 2023 11:30:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0000B07A.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.13 via Frontend Transport; Tue, 7 Mar 2023 11:30:25 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 7 Mar 2023 05:30:19 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Russell Haley , Wyes Karny , Mario Limonciello , Oleksandr Natalenko Subject: [PATCH v8 5/6] cpufreq: amd-pstate: Add guided mode control support via sysfs Date: Tue, 7 Mar 2023 11:27:39 +0000 Message-ID: <20230307112740.132338-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307112740.132338-1-wyes.karny@amd.com> References: <20230307112740.132338-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B07A:EE_|BY5PR12MB4243:EE_ X-MS-Office365-Filtering-Correlation-Id: a5867b76-837c-4455-60e9-08db1eff58ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JY5kw0sn8HoqDGWNwgX6gxZReGkH0R88wOi+dconLSC7f2dk7juFrxJXm8//2y46F589d7KkKFDkpw6B7RGY3KHd2DrDaDAOqDhn1ZeVg79Jir0bhQpYpKYe6hKQiVmPTdTspGbZNomA2BxvqGNX9CvI8r031SZjU21VMqBG6EQ5suVTWkmEotUtLlJvoKVFs+AjZpAkk6sPa+33tx/iufnNISNluexdfH5W/xaQu8Dz4qkw82//E25wbjuRu7hx6V+mangh9q6/106L0doKE5RCiHOQHdjjh7EKve+VNw8IZTVOqgRkfTTEEbJUmo53JhSYc+781JWSD/nh8uc9MoB42v1iC/ZyPGv5Px4+jc6rYtkNQJCQglaDF24qCu3a5U38HiP3s9dm9vl68RZNFYDl0DjU2vf0+DjJb3VyOAgi443E5eAA0xn3CTifG//fdTrtfKmHBvkT1YWtnZQK0UTvFmxFhcX+5XSnjOz3YKXSBg3QJxrJhHepYWKZLI4RAPIf4jQIn1aN+6xKSrsB84MXJ3ErzOYwik9BNPxVcQaW8yk9wFGdcOOLKROdDYFrW4fKmQ0ogZMLPhY820PRR6R5ote/u7klVOdxqHX4n/NsB5xNIc+ucnwpp/B1cNNOfdfBk55Qo0Ct4HHPrHvq92La+2Up1LcpI/O5APqrK8WZRv3hNHq/HEcmpfGF5B8eqLuGbRdFovQIe7gKl2ClWYwU360CIL6z/iRQwcq8WhM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199018)(36840700001)(40470700004)(46966006)(2906002)(356005)(81166007)(36860700001)(336012)(82740400003)(186003)(26005)(16526019)(2616005)(1076003)(44832011)(7696005)(6666004)(40460700003)(82310400005)(478600001)(70586007)(70206006)(5660300002)(8936002)(7416002)(40480700001)(41300700001)(47076005)(110136005)(426003)(54906003)(6636002)(36756003)(4326008)(8676002)(316002)(86362001)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2023 11:30:25.5592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5867b76-837c-4455-60e9-08db1eff58ae X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000B07A.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4243 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd_pstate driver's `status` sysfs entry helps to control the driver's mode dynamically by user. After the addition of guided mode the combinations of mode transitions have been increased (16 combinations). Therefore optimise the amd_pstate_update_status function by implementing a state transition table. There are 4 states amd_pstate supports, namely: 'disable', 'passive', 'active', and 'guided'. The transition from any state to any other state is possible after this change. Sysfs interface: To disable amd_pstate driver: # echo disable > /sys/devices/system/cpu/amd_pstate/status To enable passive mode: # echo passive > /sys/devices/system/cpu/amd_pstate/status To change mode to active: # echo active > /sys/devices/system/cpu/amd_pstate/status To change mode to guided: # echo guided > /sys/devices/system/cpu/amd_pstate/status Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Oleksandr Natalenko Signed-off-by: Wyes Karny --- drivers/cpufreq/amd-pstate.c | 143 +++++++++++++++++++++++++---------- 1 file changed, 101 insertions(+), 42 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 61dcd7b89b26..7955cfc91c31 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -106,6 +106,8 @@ static unsigned int epp_values[] = { [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE, }; +typedef int (*cppc_mode_transition_fn)(int); + static inline int get_mode_idx_from_str(const char *str, size_t size) { int i; @@ -838,6 +840,98 @@ 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) +{ + cpufreq_unregister_driver(current_pstate_driver); + amd_pstate_driver_cleanup(); + return 0; +} + +static int amd_pstate_change_mode_without_dvr_change(int mode) +{ + int cpu = 0; + + cppc_state = mode; + + if (boot_cpu_has(X86_FEATURE_CPPC) || cppc_state == AMD_PSTATE_ACTIVE) + return 0; + + for_each_present_cpu(cpu) { + cppc_set_auto_sel(cpu, (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); + } + + return 0; +} + +static int amd_pstate_change_driver_mode(int mode) +{ + int ret; + + ret = amd_pstate_unregister_driver(0); + if (ret) + return ret; + + ret = amd_pstate_register_driver(mode); + if (ret) + return ret; + + return 0; +} + +cppc_mode_transition_fn mode_state_machine[AMD_PSTATE_MAX][AMD_PSTATE_MAX] = { + [AMD_PSTATE_DISABLE] = { + [AMD_PSTATE_DISABLE] = NULL, + [AMD_PSTATE_PASSIVE] = amd_pstate_register_driver, + [AMD_PSTATE_ACTIVE] = amd_pstate_register_driver, + [AMD_PSTATE_GUIDED] = amd_pstate_register_driver, + }, + [AMD_PSTATE_PASSIVE] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = NULL, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = amd_pstate_change_mode_without_dvr_change, + }, + [AMD_PSTATE_ACTIVE] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_ACTIVE] = NULL, + [AMD_PSTATE_GUIDED] = amd_pstate_change_driver_mode, + }, + [AMD_PSTATE_GUIDED] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = amd_pstate_change_mode_without_dvr_change, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = NULL, + }, +}; + static ssize_t amd_pstate_show_status(char *buf) { if (!current_pstate_driver) @@ -846,57 +940,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 = 0; 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; - cpufreq_unregister_driver(current_pstate_driver); - amd_pstate_driver_cleanup(); - break; - case AMD_PSTATE_PASSIVE: - if (current_pstate_driver) { - if (current_pstate_driver == &amd_pstate_driver) - return 0; - cpufreq_unregister_driver(current_pstate_driver); - cppc_state = AMD_PSTATE_PASSIVE; - current_pstate_driver = &amd_pstate_driver; - } + mode_idx = get_mode_idx_from_str(buf, size); - ret = cpufreq_register_driver(current_pstate_driver); - break; - case AMD_PSTATE_ACTIVE: - if (current_pstate_driver) { - if (current_pstate_driver == &amd_pstate_epp_driver) - return 0; - cpufreq_unregister_driver(current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state = AMD_PSTATE_ACTIVE; - } + if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX) + return -EINVAL; - ret = cpufreq_register_driver(current_pstate_driver); - break; - default: - ret = -EINVAL; - break; - } + if (mode_state_machine[cppc_state][mode_idx]) + return mode_state_machine[cppc_state][mode_idx](mode_idx); - return ret; + return 0; } static ssize_t show_status(struct kobject *kobj, From patchwork Tue Mar 7 11:27: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: 660906 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 4B3A5C678D4 for ; Tue, 7 Mar 2023 11:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbjCGLcQ (ORCPT ); Tue, 7 Mar 2023 06:32:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbjCGLcD (ORCPT ); Tue, 7 Mar 2023 06:32:03 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20630.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C784843475; Tue, 7 Mar 2023 03:31:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=diujgsvmhBVoHCCWnBRwkiQCAc+800K8j1d2KwrMOxx29ZwU2PdNc9Bj9dxVuFbGU5Shwo40QtvLDtmZDq/SXFN9kKuKvIRphaVybdx6GD68DJvkvlu4q9iXu7Ow+oO1Ia9jwb3bKnY0FXS5MmIbDOv7j4ulAOheTNFi/kyxwMNXNJ0YesN9QeUZ/HWuS3JA8ayfz5G1abQ2SElszPm0bl9ftTX1NJl331uAPcT3zHnqexXSMmTH67FSo+jjIqSdiHJzL2c/UZBSrr+u3AdrfSJvCYJJA7DC0sWLpgf2KTwlfiBb2/QO4I+j0TId002dtcV3G4clPPiIjlhnmNOu7A== 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=oqrccLHy/K9iCZa7u8ey+Sxd+xqfVbX3jNE54cX1UI0=; b=mE3dhRmEFwOSCUhPUHFk8opibbmNrsMBRUW7HVSD37red+C87IcAgFplS8pJH7q5U375QZhaFmdye1fdcwIZL5dKGlpGoIQwL7KarNxh7ThXQs7o1YIihT/wnU1nrD5DVCZ+REK6BA98lX3vZ4LSt3IAEFY88VXtwJDFsN/R3ciuKMja+rI3VwUlwe/bgIDOOi+Mcb/megXl1fOkuN53siWwAztvxlwoRz9HRTdm0M4PxOhO86SK4uNNpCkKFI3zpnPyWK8fvfIMr6HFTVyNU3etKkmg+ZDcCkcd6EW/l5Td+kFoB84zrJwDmRsCXevbB0gex0Oq92waZldLaAeZnQ== 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=oqrccLHy/K9iCZa7u8ey+Sxd+xqfVbX3jNE54cX1UI0=; b=KJuRE4125cBYBbeyr30LE1GKwAgLza94azU66UI7zcag/cnaEEXJ0IEmLaljgJtMJamLvVlbOp8NjVtbOzrktCJ0AU5YR92lPKc9tthqKWwDXscvj1uwbDaFhHHEAshQvSsL7raNBr3pf+7IbdXlH8BPeuH5ppLYCs8E5s/4zls= Received: from DS7P222CA0003.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::19) by DM4PR12MB5988.namprd12.prod.outlook.com (2603:10b6:8:6b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.23; Tue, 7 Mar 2023 11:31:14 +0000 Received: from DS1PEPF0000B078.namprd05.prod.outlook.com (2603:10b6:8:2e:cafe::a1) by DS7P222CA0003.outlook.office365.com (2603:10b6:8:2e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29 via Frontend Transport; Tue, 7 Mar 2023 11:31:14 +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 DS1PEPF0000B078.mail.protection.outlook.com (10.167.17.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.16 via Frontend Transport; Tue, 7 Mar 2023 11:31:14 +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; Tue, 7 Mar 2023 05:31:08 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Russell Haley , Wyes Karny , Mario Limonciello , Oleksandr Natalenko Subject: [PATCH v8 6/6] Documentation: cpufreq: amd-pstate: Update amd_pstate status sysfs for guided Date: Tue, 7 Mar 2023 11:27:40 +0000 Message-ID: <20230307112740.132338-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307112740.132338-1-wyes.karny@amd.com> References: <20230307112740.132338-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B078:EE_|DM4PR12MB5988:EE_ X-MS-Office365-Filtering-Correlation-Id: 651aabe1-ae6f-485b-8560-08db1eff75b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H4nJyLVBaZwV3BgL+ogLwUt+cPAU2BfrOROLEooVGL/xMLNdflGo+mz3gAaveYa9au3ANfy1X80Sd59aNSpNjFVfXxuQUh/Tt6NC33/QJ4isWTti8IXF0QJ//P649FyFV7cWfR999Sn2Ebqki8ajQi4kpZUPy9O6uXOlPj/KHluTG+ih+21IPv50NbFDgNJ8fHfJ+vFu0c0oDVaV9H8aLz3DfqvBgcPA4jz7UNKUbvkKHAC7oHCR5OquKhDf1VBwBBo64m8CWB/c7LrV43eMiVGGkQelwWpS2qb3FjQ1w0IJ5s7D2vk25oEnPnheQavMLH+5Ajf9MmaZqBqf4lbtnCLRRMc3F7GcZAPczwFGRVkRjNbrveJ8306/De+vZ0ceEMJu7J26B2Sy02Ji5wfOYxD6WRYkIHT512SUCe79O7TplhBgulIlgSYNlGC7zmcuDSrasKD8ajXP5qVm2FdBvdWUhzxH06uyC7RlJaAGrkuxcK9uhLY4qnMTDH0KX3A3Krq6M8cegbyxmrwe2VNKOeTyHU49oP8/V14tOorfJDy1nw2wkBHzZXq3VED/TIkl1SFgdgxiKkBsOBo+82xWd+EC22hhodxv1e1RgOIHpYG7Oiqdh55xDmpQA2+VBbmj8/cV8i0n7KKQW95fwM8JjC+UmWrWzZ4y35fM6s+WBgj5Xj0e+z66zzyKEEFtkcMMKxOTu3Rn25N7baZuiZzOJ6+EJcMO6ygO6/JBRMTYPGc= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(82310400005)(82740400003)(6666004)(47076005)(36860700001)(83380400001)(36756003)(478600001)(6636002)(81166007)(316002)(356005)(110136005)(7696005)(336012)(16526019)(5660300002)(41300700001)(1076003)(54906003)(40460700003)(26005)(15650500001)(426003)(70586007)(7416002)(186003)(44832011)(8676002)(2616005)(8936002)(2906002)(40480700001)(70206006)(4326008)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2023 11:31:14.2600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 651aabe1-ae6f-485b-8560-08db1eff75b5 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: DS1PEPF0000B078.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5988 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Update amd_pstate status sysfs for guided mode. Acked-by: Huang Rui Reviewed-by: Bagas Sanjaya Reviewed-by: Mario Limonciello Tested-by: Oleksandr Natalenko Signed-off-by: Wyes Karny --- Documentation/admin-guide/pm/amd-pstate.rst | 31 ++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 6e5298b521b1..1cf40f69278c 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -303,13 +303,18 @@ efficiency frequency management method on AMD processors. AMD Pstate Driver Operation Modes ================================= -``amd_pstate`` CPPC has two operation modes: CPPC Autonomous(active) mode and -CPPC non-autonomous(passive) mode. -active mode and passive mode can be chosen by different kernel parameters. -When in Autonomous mode, CPPC ignores requests done in the Desired Performance -Target register and takes into account only the values set to the Minimum requested -performance, Maximum requested performance, and Energy Performance Preference -registers. When Autonomous is disabled, it only considers the Desired Performance Target. +``amd_pstate`` CPPC has 3 operation modes: autonomous (active) mode, +non-autonomous (passive) mode and guided autonomous (guided) mode. +Active/passive/guided mode can be chosen by different kernel parameters. + +- In autonomous mode, platform ignores the desired performance level request + and takes into account only the values set to the minimum, maximum and energy + performance preference registers. +- In non-autonomous mode, platform gets desired performance level + from OS directly through Desired Performance Register. +- In guided-autonomous mode, platform sets operating performance level + autonomously according to the current workload and within the limits set by + OS through min and max performance registers. Active Mode ------------ @@ -338,6 +343,15 @@ to the Performance Reduction Tolerance register. Above the nominal performance l processor must provide at least nominal performance requested and go higher if current operating conditions allow. +Guided Mode +----------- + +``amd_pstate=guided`` + +If ``amd_pstate=guided`` is passed to kernel command line option then this mode +is activated. In this mode, driver requests minimum and maximum performance +level and the platform autonomously selects a performance level in this range +and appropriate to the current workload. User Space Interface in ``sysfs`` - General =========================================== @@ -358,6 +372,9 @@ control its functionality at the system level. They are located in the "passive" The driver is functional and in the ``passive mode`` + "guided" + The driver is functional and in the ``guided mode`` + "disable" The driver is unregistered and not functional now.