From patchwork Thu Feb 16 08:17:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13142706 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 B2FD4C636CC for ; Thu, 16 Feb 2023 08:19:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbjBPITC (ORCPT ); Thu, 16 Feb 2023 03:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjBPIS7 (ORCPT ); Thu, 16 Feb 2023 03:18:59 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 547732686E; Thu, 16 Feb 2023 00:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSTE7UMM2i/ME4nZp9Q6Klq5L+fZ3cRaKXfO8spkzAp8LfU/IDgq/VqWp3iR1J3nmJyfBWjaSDKSyqYO12iGYFF/AJFjmGc/aqVlVhW0MeSo0dtM2VtX9zfA73HB/PeQwkS2FWTkmPx7oM93aSSMEU1ENJLEGrg7CQYO28JOIVgrOVD2RbiMuX0s8zRo6m9Yuhc3scUGudrtZjTzajEUk8zUg3UGVI/4OHS6TDWsxKR0p+0NhB2mQbu40Kp/ehkdSydB50kL+wBGFpT3Z9j/i8iO25sfnw/P7+95iIDQIAE3rT7ShUxx5qgn6N0lqUb6tzofQmBV6p7LZyPOwkQNiA== 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=BSKDBxUmRAcUM3PI9beHLou2ususF+MgwWY1hu7cSh0=; b=JCrN1zqkAHFYljFt/NyXJbqhYbcKiKwalqOYC84M6BQmBRR141VqRLu2jCVEs3jBVmup1FxoBBJPGDdaB5vYEL693NYFcjx4u1dA00YJdSqoXk62lqqZYSvOwKxzH80Vv68/owWB8XBlltwYOe+fHr+iqdMoIZbiAzQe87RgJuDIJT/3ZPYLTt08HOFGVAFHcrcb1IWCspZpAyausaB9QsBtRsM4jUd/0EPjpsQMP56fHMFbn4CE3vpBJ2EhW0/ne+iKqcrsGQG21UB0N1LlJGOvsLSWTyq1Hx46xDb8I0ThXEpDgWrTdqWsoBT5XxYJ96DycYM/SgIfgys2FShUBA== 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=BSKDBxUmRAcUM3PI9beHLou2ususF+MgwWY1hu7cSh0=; b=h6Z7Z1DCthnA4lAW6y5PTzNXlXk2M5i8WveI3gdVWG1YH502mDAJab7A5f1kQcGCy5M6fCv1AiiyE45f+T+3PalnMfQcQpRZDQE1ujI99Sb7+OL/qEj/KQwFeCX+mtITeTiZqCEk/EI7Ia6sUH5uFTXulioC4+YRFeCj4paIo7U= Received: from BN9PR03CA0385.namprd03.prod.outlook.com (2603:10b6:408:f7::30) by DS0PR12MB8270.namprd12.prod.outlook.com (2603:10b6:8:fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 08:18:52 +0000 Received: from BN8NAM11FT097.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f7:cafe::ea) by BN9PR03CA0385.outlook.office365.com (2603:10b6:408:f7::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Thu, 16 Feb 2023 08:18:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT097.mail.protection.outlook.com (10.13.176.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.12 via Frontend Transport; Thu, 16 Feb 2023 08:18:51 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 16 Feb 2023 02:18:46 -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 Subject: [PATCH v7 1/6] acpi: cppc: Add min and max perf reg writing support Date: Thu, 16 Feb 2023 08:17:57 +0000 Message-ID: <20230216081802.38007-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216081802.38007-1-wyes.karny@amd.com> References: <20230216081802.38007-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: BN8NAM11FT097:EE_|DS0PR12MB8270:EE_ X-MS-Office365-Filtering-Correlation-Id: 37e771f6-107d-4e07-fac0-08db0ff66fea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 78KGImCB36weUKYvIIcUSoe6XsYiDcalnmBr4Tgx2MUEKhg0SjeYfP1M7dHSWld2hGEVohuUECaVzYyaHnzP3EuAFqYrB83w7tGCs5y77OwFIDpMlV/OrfcsCPHAvJuulcpBQ1ToWL+xCZQtlz+qbdZm5Tb/YmYqYOWjQdaETScEB6cYpl6jOVT/aua9S89wUhCy3nluFmyeJYjLBSXYXuTLXsTRJAvEF3U2i0JvlQA+3NtB6mfY+6hfrAi2ozAuhdVBg3lcWj+2juAfrh8KPV1+QzUe48piC/Pl/6D9zm3OlIwkhycwW04rSDaDuKjJfrFlS/OdJMlpTzUn453u1joKchbb3eYvooLVwSoy9YhSOB68fxKE0REe/3mg6A36nLAx4cwVRv8om6QWOsl0Rndv50cSHFigzRf9+WTzI9igV2zrtM3sIguevCZQ4EkIAYJGjsb7s0KU+E3v0md6AXgoWNwSxmegPcx9nLiVgVA9Pv1EvugBbGUYaBi5m4RpbtvGCHkMkf5P3q+rO+LvFtgnMQhOgp1s9wV3qYN89f9lAFnUC5dCq8HWC5HOqwJ1G2c7KXOyHcEsvszLa2w92m/uMSUsFEOUeiBO71ejHeBCmcgBFW/i0Od7kEqsGfa1z8OQv0WGxzofguTjjnyWLfEyl+hdXFr+4UDcDDozFd+4sZ4Gq2LyQeXXd3z3Gy6QaKWVWn+tRGe6EkbfGLGWMUJwWpkVWIuJjC9zwW4BpN4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199018)(40470700004)(36840700001)(46966006)(54906003)(44832011)(5660300002)(41300700001)(7416002)(8936002)(2906002)(70206006)(4326008)(8676002)(70586007)(110136005)(316002)(83380400001)(40480700001)(26005)(186003)(40460700003)(6666004)(7696005)(36756003)(6636002)(478600001)(2616005)(1076003)(16526019)(426003)(336012)(47076005)(36860700001)(81166007)(82740400003)(356005)(86362001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 08:18:51.6630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37e771f6-107d-4e07-fac0-08db0ff66fea 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: BN8NAM11FT097.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8270 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 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 09aa4c4f9bf5..ad19e4a91e4e 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 Thu Feb 16 08:17:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13142707 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 ABFEDC636D7 for ; Thu, 16 Feb 2023 08:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjBPITf (ORCPT ); Thu, 16 Feb 2023 03:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjBPITe (ORCPT ); Thu, 16 Feb 2023 03:19:34 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A7AF457E7; Thu, 16 Feb 2023 00:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iFOPd6wsaJGocgC/QaHy1ffrNE8Ze2UBJbmJOV6LAGM6uhrYwrAp2FebguXJYeXGd220CAKtdrgTSKv0fq/A8uPNccQSSkwdJggM35dUnBZ/n/6/EQj/pr5A6XlX5WLsLk0NqrdaNizdAPEFNVIGT22tjuXSspmBfz56L+jgOcrnNDtW/fQRbzQ6twy1ndkY63Yap0lEPSAHgIz3+AF3tpCBuf8/r+L1ogCCkNfbK2mdA56aNlTNFnNz1T75jnNoqaM2KNHsmEg93RPAJeH5k9uj9a78bdDNmuYLX6QAe0xeklx3xQNoFK8cHyJWC2PJuuSmjBkWW659jgXl3oODfQ== 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=s05DLwfqzGln07Ac5hEi1Vheaivud9Tu7PP/F7KN7uU=; b=M/p2V6ivaEHn93AjuAKhxH6uPhhOYYMqbXuyq+ZbUQeh3sap406o2dxrZk4LaTTDlVCeZO00D1J38GK6LF9p01TAd/VtOUUbe8AYXmSFhmk6DhTX5iUGSzafEPYPT7fTDLvv+EroutaPD344eQOp/HKnSNDtz4QDeYdKqZMvhq+UpSpnuaAfSldgJQ8cYeusu6SY3F4jy6AUUl0s/D9IgycD70YcCEVchXuArfio+y0hwjH2m3q/rcnIoGNbOah+VrMnvXmD1t6albBanrcehI4zjHdVzT1M71ubSF9y7udkxXZsFmnAfKR0/x2IeDISSSXKf0WDGCOjjTn8vblc2w== 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=s05DLwfqzGln07Ac5hEi1Vheaivud9Tu7PP/F7KN7uU=; b=bknSTmFNAktHybWqMjJKt5wa22AUenUyi9oEvAZAQeIgrdnsCWF1LXIjWQSBIvZuWyOo4jiIRRtE3O5PGHFH+0xeBLor9O4n2SG+y03mzf4TU01LHJi1V+0u5iXH5ck1rQTL3nuxNpZlsIV+/u0j5tVw8LSn8Tsr/je3KaWlhZg= Received: from BN9PR03CA0842.namprd03.prod.outlook.com (2603:10b6:408:13d::7) by DM8PR12MB5414.namprd12.prod.outlook.com (2603:10b6:8:3e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 08:19:18 +0000 Received: from BN8NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::4f) by BN9PR03CA0842.outlook.office365.com (2603:10b6:408:13d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 08:19: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 BN8NAM11FT086.mail.protection.outlook.com (10.13.176.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 08:19: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, 16 Feb 2023 02:19:12 -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 Subject: [PATCH v7 2/6] acpi: cppc: Add auto select register read/write support Date: Thu, 16 Feb 2023 08:17:58 +0000 Message-ID: <20230216081802.38007-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216081802.38007-1-wyes.karny@amd.com> References: <20230216081802.38007-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: BN8NAM11FT086:EE_|DM8PR12MB5414:EE_ X-MS-Office365-Filtering-Correlation-Id: 0202fdcf-4169-406a-f85d-08db0ff67ffa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TyXKeCGjiriB+KCn3AYZOR6J6kaACqtw4Ihudgw6X1ygK6EakNewlhYJ6HOAo7g39T6wdWjvMvChb5ZslqIDdKXUEXtLH1sDNl/HnsySUCC1jRjXdFwCXAF5BojO2fvPdXwFoLrfg9jsHs5xTFn4yf/xM0dp2zz4i5uqZ/mSVOyKNyfB1Kvt7H2YTRN57GELPJLeZOG12B0CB1ZBcPpWdXN1jcCci9FOAXoe2CiXVQXOCyyAjHL3kzxtis+re7gB9XuX69DmmNeGx+qOOnT+Xw7aZh84VPdC7mDTRql+KygksH6KUEO/3LQrHX/6uZlajw3LINSQTJAy6oXyL1pPAgF8LA9jbr8T47RtbnGEhOOGiTGluiaMP1EaePgWnArvoMEgE1S0Q1MuTbLK8bSty4flEn8lnlP8YRPc9FDL17dq/fSLfiWrmkHz6s0t6whU9JKK1v8pFx/YquyqCc8kPXn3S2hEV1nxoqFM2WeFfn4dYbHArliI1tvcHdnhn/NXeofd1bLA+3KSPnk0zhOlukz/uQ7mkAjxMU5OX5Y5QR9fnpBRavTp6Doxcl8ByjXFfWMn7+E8o/et0c1/7sT4xQ5ppuPWVp2x/lJ01ijhmeVJF/Di+yokK7HDPmtNeEv1dRcXZKn+mOz9heam/bcbdwRqIjBjHxB+NDYOSx5ml6R/h4X3HEsKAwa4++5sC5GeZ8OmnmPZjGM4VuW4n1sqKpain60RAEmlbPMzb3usoFg= 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)(396003)(39860400002)(346002)(451199018)(46966006)(36840700001)(40470700004)(70586007)(54906003)(4326008)(70206006)(8676002)(110136005)(316002)(6636002)(40460700003)(86362001)(36756003)(356005)(478600001)(81166007)(2616005)(16526019)(186003)(26005)(83380400001)(82740400003)(336012)(426003)(47076005)(82310400005)(41300700001)(8936002)(7696005)(2906002)(6666004)(1076003)(44832011)(5660300002)(40480700001)(7416002)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 08:19:18.6113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0202fdcf-4169-406a-f85d-08db0ff67ffa 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: BN8NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5414 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 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 ad19e4a91e4e..e2fbc3c92891 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 Thu Feb 16 08:17:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13142708 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 7E076C636D7 for ; Thu, 16 Feb 2023 08:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbjBPITv (ORCPT ); Thu, 16 Feb 2023 03:19:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbjBPITu (ORCPT ); Thu, 16 Feb 2023 03:19:50 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2042.outbound.protection.outlook.com [40.107.243.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2FC13B666; Thu, 16 Feb 2023 00:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gV/7PZJ6P8GKqXeFncADlcEdGzCME2SCaS0+CZmHZcwYkiVvzqzuCCUE2zs0OljYREQrc3p1+3pqo1fwcY6LASnLlXVanWZSD/b1YQYe79mITveSAoY31VWsGVYMYgrT7y5ZWsnGpB16Dc2gWtlxSrzTQPBwbB003veItRs5UDP8yb9r7It7ZHTnI2KU5S8FftrK6299RKrego1Xl7rYMNvbsTUCHDbaIllPZePv/tSbc8u5NCRy6aW0w57OuqiPoOCVXy3kVWE686IUco5BAkAMM2J616rHnJCWZaTr/GseWUX3I+6FXc0nbUPJlS0ldIrdC+Oorv+rXIgKSfK3Dw== 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=0i9nqTb4I2fb47vJVCPnK7PmkPVf096xB7bxM02GaEo=; b=EPBvPtCVSQJIvSuBz4EBllwaIXX0WqTl5Ypu9XOqUyCvp/MN4wBEAvet8cHxswz7FsqxN8htTgk8lKuchvoln4NystVMtzTWK/I7qjZq1XcS1Kpc9rh6Att63OTSewnICj0d98sLxl69Hnem12ZqPmW0XDFOfF4TG+d+2l+T9U+xJa7eHmJos1L/zZZoJQV23yiElnr1vbZqBAvdp9LiHWLewXu5JqprRr5DS8xbzu44fJIMJHBKtX/03sswn3qPDuUZq1kUDOFp1GS7bG0CeK+sLMD6DK1PzI1meaujYN93U9DdJ3TZJvq8aRSNMsjKNSeK4uKHXJRDRlLZLdfhjA== 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=0i9nqTb4I2fb47vJVCPnK7PmkPVf096xB7bxM02GaEo=; b=ZNgp+53s/mwGdn6MHc8JSB8ZyXBhVDfv5Rn0xqmEW5ryonRRHLoKf5b88BFyj49ypgYTnrFFk/eRC4UiBxWe/jdjqEv78DGUIF2inC5ExiAA6MMUH7kTSPTVHKBGjdu5ybJyG22cVaOFK1rE0pJcu/0NRszfhXzd6nx9LacjMWg= Received: from BN9PR03CA0792.namprd03.prod.outlook.com (2603:10b6:408:13f::17) by BY5PR12MB4306.namprd12.prod.outlook.com (2603:10b6:a03:206::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 08:19:43 +0000 Received: from BN8NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::50) by BN9PR03CA0792.outlook.office365.com (2603:10b6:408:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Thu, 16 Feb 2023 08:19:43 +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 BN8NAM11FT022.mail.protection.outlook.com (10.13.176.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 08:19:42 +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, 16 Feb 2023 02:19:37 -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 Subject: [PATCH v7 3/6] Documentation: cpufreq: amd-pstate: Move amd_pstate param to alphabetical order Date: Thu, 16 Feb 2023 08:17:59 +0000 Message-ID: <20230216081802.38007-4-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216081802.38007-1-wyes.karny@amd.com> References: <20230216081802.38007-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: BN8NAM11FT022:EE_|BY5PR12MB4306:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a5ec181-cba6-4fb1-043c-08db0ff68e78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WPKfyTpVwkG0pzRuTCVBk4WbicvL/m0U2OP9CyRXE7KVDiPdDQiSjtMcLEOLuSO/+bn/bnKchxzAfGRIbwk1n5IebFCClEf1bs/qgG/NEReWt3f2lr/LPo89Qhn96hAlzM3846GlChhKSGdfb7rk4y8NJn7z3xkjmwCMTnhlIi9hrbuPOugO59tjuUpoqlQBnD74ZX7UF2zNLw8OH3o6hehz0AbrNIszi7l/GQNSO+PG6rIn1EZ3eHoNladr+cHlcltfvTHKW2Bsur/FDXBhFKzeQcggyYfy9kYb9+i9dZtcIaLfohFyEBGHnhZAqDYqCdqGDxwkpbtjrGw6QFKR+kBnjZz9vXwwYzGL+9CGdOYi4tlo8UNI0AWH+O4IGNFGsxkz/f9QjQ9NzNssIZcxlJlSEQhM46xnGgVBowTCJkfrGcXah8lvuPdpDL6Bd1gvTX6Gj7FvfxZzEeQnJKpl9CmD9i84WLOHAJDFuDmqVDQ+fUwpTpNnn/UxZsRbjcg+vbPFGL8weyzhdv6zRe0yvkZpZlrv6DrO62dJPJiyaqlMGCExuiLzzL6idDsYGpCv1FL2DJUywfz8PVoQH8iFHZwfdcjrez+4xs9Ms4bKzjsJ92GbMCLEm6INe/dox+zh4HFYCNQzlZhy2a4IbTVUguqPtY1zWII4Ba1Fqb7Ktm9msONQcydsFrKWHhMnoRubmNmiyiwVhsmIQ2mUp6zZao35ZI5ucSV/cVulItz0ZJI= 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)(396003)(346002)(136003)(451199018)(46966006)(40470700004)(36840700001)(110136005)(6636002)(54906003)(83380400001)(478600001)(426003)(336012)(2616005)(6666004)(7696005)(1076003)(47076005)(36756003)(16526019)(26005)(186003)(44832011)(41300700001)(356005)(5660300002)(86362001)(40460700003)(7416002)(8936002)(81166007)(40480700001)(316002)(2906002)(82310400005)(70206006)(70586007)(36860700001)(4326008)(8676002)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 08:19:42.8877 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a5ec181-cba6-4fb1-043c-08db0ff68e78 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: BN8NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4306 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 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 e3618dfdb36a..6ffcfb73e62f 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: , @@ -7010,20 +7028,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 Thu Feb 16 08:18:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13142709 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 B906FC61DA4 for ; Thu, 16 Feb 2023 08:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbjBPIUZ (ORCPT ); Thu, 16 Feb 2023 03:20:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjBPIUY (ORCPT ); Thu, 16 Feb 2023 03:20:24 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2058.outbound.protection.outlook.com [40.107.220.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D2427D50; Thu, 16 Feb 2023 00:20:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPhweyGhkJOjIt738yO8UCaeHFEF8ekq55RK+QJ2lX8cpzQWavsBl2FFln58NSHeDGn2FMcTX7JifodxulEbZsRxFCkD6OBTxKnioTKA1SFtuVhip+VL47xn3FWLKtcZ8F5AweaPV3KzpTRalS6as+Wrx8+b9tYfrwwS+N1bgKT0g6Cj4jIicBy7hJi15MOZqJrGNjmiU4JLFmyaH0Wa3PySZ9Po/GaidinIshieQQaMR4IXugeBvOEDCcgi258n3mrkTFctlmmvm5BgIh+xWqjTZRcW6xzR7MDVvQHfzCAipAVomG4IoRANV+MHXSewFoFgqfIKvPc1gadLuNEw4w== 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=9Fl/rKIdJL8gnuex8+b4QqwsI8z3hc/jKb2/ZedWW5w=; b=X0XkHFz/x1g0g2CptI8uD5L0hWubJYQihiz51eqqo6t+ppaU8H/tdDIId1146RopT2n/9IG8KXzOTuaOasM4BDVFIMn53HFc2Aqq6KeTpYVHWhyBwn0VotwuHRV07LVSZw2m2R+2ql7pQk2WX1+mfnA41hjwtsXNbH6ZYZhJcbgiB70n1BkdZXJWUKC2FYKKePlL6aHk5mQmYwl9+7tY5pKPd5Qr12YEuY/Mdk4+wfSa6IFVgW3NTl6aQ58DC+rHnc8KaZ41fjFyidAtqQ7dr1sBJHkbTkxboitEpcioIRCMbkWyQ02VgMSweITnLDCQo6KF8sWLmHJZZR6QcqNm6w== 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=9Fl/rKIdJL8gnuex8+b4QqwsI8z3hc/jKb2/ZedWW5w=; b=x9XYXlwoMQMxr3LLSR/wE9HysBiGBGhW9JA+PZ3M9iWBxSeWzcHkbH308F/7brt0rVZqAxl9kxjRmJ+XvJV1lV+quWzwfX95pGYP8ZhWCWbMFOSnjZpFANi06aSN4WAq+yKy5z9m8OOpY7B8UcbfvWchidTq/aavHioybnlzdi8= Received: from CY8PR02CA0013.namprd02.prod.outlook.com (2603:10b6:930:4d::24) by DM8PR12MB5446.namprd12.prod.outlook.com (2603:10b6:8:3c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 08:20:13 +0000 Received: from CY4PEPF0000C97E.namprd02.prod.outlook.com (2603:10b6:930:4d:cafe::9b) by CY8PR02CA0013.outlook.office365.com (2603:10b6:930:4d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 08:20: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 CY4PEPF0000C97E.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.8 via Frontend Transport; Thu, 16 Feb 2023 08:20:13 +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, 16 Feb 2023 02:20:04 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Russell Haley , Wyes Karny , Mario Limonciello Subject: [PATCH v7 4/6] cpufreq: amd-pstate: Add guided autonomous mode Date: Thu, 16 Feb 2023 08:18:00 +0000 Message-ID: <20230216081802.38007-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216081802.38007-1-wyes.karny@amd.com> References: <20230216081802.38007-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: CY4PEPF0000C97E:EE_|DM8PR12MB5446:EE_ X-MS-Office365-Filtering-Correlation-Id: c080cad4-f43d-4b13-2586-08db0ff6a07a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m10Iz0pgOd89Zgm2/CYa07N1lkOPv3uEbrs6ji0ewalG0IBsmacGWNyXWcO6U98tDXSdeRqZsBAGA3t2tvpZs0P1f2voEyvQCCtMfGgrPtzUpDyexsEt5zcF/fYTBjGl5Ggul0eiIYOjlfAyJ45XrF5cXXKnkid9nNi5vGmBQQN+x+cwL0Zp11HqnqrjqUPIDVINKmlV1YuFrAjrzM4fh9qhb9m1+MBEJA4jPs6++xsYA1AQxseh1eLUKTTXSR6AzvMEOHyAXdsAgW11p1k/fh+ZgPCdyFBmovt8L6iakd/bPy+jhs5p3pupjhxR0Eh15Ggjm7XSiF2HHSYX5QZFv3tUTPpPKPDpLEThP5NjX9rTtC5jnBryGyYK58ao/BC2QcDLtmsqx0vn/rlB1xQs9M4XXIoL4Jv21V0SfpQsCnJNWX6BN5k9jhBr3IG13mrKC/liGIBjKVx7ozRJ5+hMo/kbbjddyZGJSiP797tlhNzLoLYB+bL5NrKfgf4yolDove4Agu3VX2j4eo3EuK2bz8PMVjQZ2oNauBrXepiAUvq8FkLsAkHuZ+Ue1KQVXQqaa1FQUQWsezQLgm1hqK4D7bFsevfD7FguINs6Ub7nmdFfqk2ZACdSJxUmM/C5DdiU6cb7nU6kkdyNbhxhTuXCCgRgGvnfyTj2aBAL6OlLJz1BkYrP7a5AiWFSq9tkC+k6KidkKgaysSYEclLYJq7/kk2oeYXSe8zQN5Nx5ZvKguo= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199018)(36840700001)(46966006)(40470700004)(7416002)(2906002)(8936002)(70586007)(8676002)(4326008)(44832011)(5660300002)(110136005)(6636002)(54906003)(316002)(478600001)(7696005)(6666004)(36860700001)(16526019)(70206006)(1076003)(26005)(186003)(47076005)(426003)(336012)(41300700001)(40460700003)(81166007)(82740400003)(40480700001)(86362001)(356005)(83380400001)(82310400005)(36756003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 08:20:13.0692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c080cad4-f43d-4b13-2586-08db0ff6a07a 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: CY4PEPF0000C97E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5446 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From ACPI spec below 3 modes for CPPC can be defined: 1. Non autonomous: OS scaling governor specifies operating frequency/ performance level through `Desired Performance` register and platform follows that. 2. Guided autonomous: OS scaling governor specifies min and max frequencies/ performance levels through `Minimum Performance` and `Maximum Performance` register, and platform can autonomously select an operating frequency in this range. 3. Fully autonomous: OS only hints (via EPP) to platform for the required energy performance preference for the workload and platform autonomously scales the frequency. Currently (1) is supported by amd_pstate as passive mode, and (3) is implemented by EPP support. This change is to support (2). In guided autonomous mode the min_perf is based on the input from the scaling governor. For example, in case of schedutil this value depends on the current utilization. And max_perf is set to max capacity. To activate guided auto mode ``amd_pstate=guided`` command line parameter has to be passed in the kernel. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Signed-off-by: Wyes Karny --- .../admin-guide/kernel-parameters.txt | 15 +++++--- drivers/cpufreq/amd-pstate.c | 34 +++++++++++++++---- include/linux/amd-pstate.h | 2 ++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6ffcfb73e62f..e1241141535b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -344,11 +344,11 @@ Do not enable amd_pstate as the default scaling driver for the supported processors passive - Use amd_pstate as a scaling driver, driver requests a - desired performance on this abstract scale and the power - management firmware translates the requests into actual - hardware states (core frequency, data fabric and memory - clocks etc.) + Use amd_pstate with passive mode as a scaling driver. + In this mode autonomous selection is disabled. + Driver requests a desired performance level and platform + tries to match the same performance level if it is + satisfied by guaranteed performance level. active Use amd_pstate_epp driver instance as the scaling driver, driver provides a hint to the hardware if software wants @@ -356,6 +356,11 @@ 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 diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index b8862afef4e4..92f8402ebb34 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -308,7 +308,22 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) cppc_perf.lowest_nonlinear_perf); WRITE_ONCE(cpudata->lowest_perf, cppc_perf.lowest_perf); - return 0; + if (cppc_state == AMD_PSTATE_ACTIVE) + return 0; + + ret = cppc_get_auto_sel_caps(cpudata->cpu, &cppc_perf); + if (ret) { + pr_warn("failed to get auto_sel, ret: %d\n", ret); + return 0; + } + + ret = cppc_set_auto_sel(cpudata->cpu, + (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); + + if (ret) + pr_warn("failed to set auto_sel, ret: %d\n", ret); + + return ret; } DEFINE_STATIC_CALL(amd_pstate_init_perf, pstate_init_perf); @@ -385,12 +400,18 @@ static inline bool amd_pstate_sample(struct amd_cpudata *cpudata) } static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, - u32 des_perf, u32 max_perf, bool fast_switch) + u32 des_perf, u32 max_perf, bool fast_switch, int gov_flags) { u64 prev = READ_ONCE(cpudata->cppc_req_cached); u64 value = prev; des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); + + if ((cppc_state == AMD_PSTATE_GUIDED) && (gov_flags & CPUFREQ_GOV_DYNAMIC_SWITCHING)) { + min_perf = des_perf; + des_perf = 0; + } + value &= ~AMD_CPPC_MIN_PERF(~0L); value |= AMD_CPPC_MIN_PERF(min_perf); @@ -445,7 +466,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy, cpufreq_freq_transition_begin(policy, &freqs); amd_pstate_update(cpudata, min_perf, des_perf, - max_perf, false); + max_perf, false, policy->governor->flags); cpufreq_freq_transition_end(policy, &freqs, false); return 0; @@ -479,7 +500,8 @@ static void amd_pstate_adjust_perf(unsigned int cpu, if (max_perf < min_perf) max_perf = min_perf; - amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true); + amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true, + policy->governor->flags); cpufreq_cpu_put(policy); } @@ -1278,7 +1300,7 @@ static int __init amd_pstate_init(void) /* capability check */ if (boot_cpu_has(X86_FEATURE_CPPC)) { pr_debug("AMD CPPC MSR based functionality is supported\n"); - if (cppc_state == AMD_PSTATE_PASSIVE) + if (cppc_state != AMD_PSTATE_ACTIVE) current_pstate_driver->adjust_perf = amd_pstate_adjust_perf; } else { pr_debug("AMD CPPC shared memory based functionality is supported\n"); @@ -1340,7 +1362,7 @@ static int __init amd_pstate_param(char *str) if (cppc_state == AMD_PSTATE_ACTIVE) current_pstate_driver = &amd_pstate_epp_driver; - if (cppc_state == AMD_PSTATE_PASSIVE) + if (cppc_state == AMD_PSTATE_PASSIVE || cppc_state == AMD_PSTATE_GUIDED) current_pstate_driver = &amd_pstate_driver; return 0; diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index f5f22418e64b..c10ebf8c42e6 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -97,6 +97,7 @@ enum amd_pstate_mode { AMD_PSTATE_DISABLE = 0, AMD_PSTATE_PASSIVE, AMD_PSTATE_ACTIVE, + AMD_PSTATE_GUIDED, AMD_PSTATE_MAX, }; @@ -104,6 +105,7 @@ static const char * const amd_pstate_mode_string[] = { [AMD_PSTATE_DISABLE] = "disable", [AMD_PSTATE_PASSIVE] = "passive", [AMD_PSTATE_ACTIVE] = "active", + [AMD_PSTATE_GUIDED] = "guided", NULL, }; #endif /* _LINUX_AMD_PSTATE_H */ From patchwork Thu Feb 16 08:18:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13142710 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 698A0C636D7 for ; Thu, 16 Feb 2023 08:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbjBPIUt (ORCPT ); Thu, 16 Feb 2023 03:20:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbjBPIUs (ORCPT ); Thu, 16 Feb 2023 03:20:48 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7472A47428; Thu, 16 Feb 2023 00:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4azDV/qnLxpHRPZZvbrZpgfz2fXiSjIApMhDxDtNhM2yndud77Nd6zxZXqF0fEQU7qooSV/In9AMmmgYYH/47mnyliDZ6QTpY+kd2uVHWnBv3/yCCSSVlvEpr0gNssxpb2aYWGja8wdYlLXqTIhioBKt65zQDK4Y+kdIBlorkYesgUUrcaY3749/JmCKpnq9inWQ/8mK3DtgwamV0A6BsM6SLCaWlO3bhenMUVuz0FK3u5LKkvTxobJAvgdaGcZ/7pmIMy4U+hiZS9x+GKBukFyzIbqTv7ruJwN5W8HG/a+VoEVKBYxirJ8fDFK6y0rtYoroFPebIcv5fDfpcNnzw== 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=2mQzrkMzR1yUMN1cxhzDagp52KhUeTlbE+MkooI79Fs=; b=GnQDmZ1y/CSGTRSm7O+juZppTossyzawIo5oLg827HhP3iuzI4h2sDwwflx7ypfPbUx0ZHMNA8XvvXYO6TkisPZXjF/87R7dH99O0Fbo6FSAMnqnKJckLJkPpltZiEie4jeHX2X2IMiLkfkbLyZCQFKuA8XDH8aoi15rzRnE1WChs7VCyM6L0X0M/5dksnJmbvxa1b0x7TMCXAS6CmagatEl33k+2ojQ25g4ixSyFK2eOVxl44L8dTbOS7I/yIVPG5nZeO/G5+9v0tLUWJBz/4gCud70+uYNCmrR96TbLxMf/smSl5LXCvlFVCVq3cOlxqC8vrzxua3CFYZPZ1gbLA== 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=2mQzrkMzR1yUMN1cxhzDagp52KhUeTlbE+MkooI79Fs=; b=KP17NtTM+dE5f+b9d6zXU7JTVDgJOv8DEWA/t5icHtrq0XLj1SbKzcj6npGcQ6GLMjOVdBXroqG7/vsCRFFP1LSlW4UbkmQmdmsE8oXk0IQr3MDrq9IJpkHskouW3dZvUl0rljSRTz8Vn9DyB8AGOkf2Sf9tzU42NZJAlCDbCDY= Received: from CY5PR18CA0030.namprd18.prod.outlook.com (2603:10b6:930:5::32) by SA1PR12MB7039.namprd12.prod.outlook.com (2603:10b6:806:24e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 08:20:35 +0000 Received: from CY4PEPF0000C984.namprd02.prod.outlook.com (2603:10b6:930:5:cafe::33) by CY5PR18CA0030.outlook.office365.com (2603:10b6:930:5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 08:20:35 +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 CY4PEPF0000C984.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.9 via Frontend Transport; Thu, 16 Feb 2023 08:20:35 +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, 16 Feb 2023 02:20:29 -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 Subject: [PATCH v7 5/6] cpufreq: amd-pstate: Add guided mode control support via sysfs Date: Thu, 16 Feb 2023 08:18:01 +0000 Message-ID: <20230216081802.38007-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216081802.38007-1-wyes.karny@amd.com> References: <20230216081802.38007-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: CY4PEPF0000C984:EE_|SA1PR12MB7039:EE_ X-MS-Office365-Filtering-Correlation-Id: bd9aba8c-31fd-4afe-96e5-08db0ff6adc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kfCta/7n3Er9LyUl9NgbhjwsZNX46Ky6RZ3K0nXD1wGLESxz2hijruy5PzJF9nvhnf04vsNuSCdHb/RG/Mi/McKJyxQW7jw9fxi8iv2x/DmREEWQzdm+qyIiYhFvOOZh9NwAnOl8PGEBJ3FKYHrM3dYNMz6+/ac/vVbM49+jhHLxXpgMGSdKueaPdesvQO4mWCDr0ui6zrOorwlmW0DhofV4dUZ5/Tt3GRpV5YXfO5/NwNlZMb+uO7PY5trEJkuGosRGcRebvE0MWTQBo2bvTLlCxsmMkeZXdIygNeUMsWV91UJmSZKwVsLIY54jT1OkyHOdKVFOuLbigYObzWymXEqqw1ovAQ3D9DgDjTU2pVQzBKt4l7TjAfgKE7Em9mIzldwY1zEjmJD4dtYuWtUTQ+KEt92/aMBxWYzYpUzlDzOkPNSWV6zHYdLh0bVjmPKz/MT/6x056cbykWfGjDppGkS6SXc6DFgJY3uR85eUvnK6dLKIHfb5VtJil5mC7TXo4f1aKxev+gu35nj6Uto8pL8XwE6I+wcxmPYYvfy8ERai/gbeSMhvXhrpbzzEGtugvv0s35O4IiB32zKk/EmqUpS+THZhFCtAe2k2rFgdhh/wjnlq/0lzdDvbJtPP5HPAsVTKWC/DU4oWy/IXgl/zDSVXB0ZTLgnLx03OZ/JhItUO9kZTWRWAYsdNoI4hZmumn4cV45KsbhGkykW1ZTO0bSti0EOo761bIbty/MkemJ4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199018)(40470700004)(36840700001)(46966006)(40480700001)(70586007)(1076003)(26005)(6666004)(16526019)(40460700003)(186003)(47076005)(2616005)(426003)(336012)(54906003)(6636002)(316002)(110136005)(7696005)(478600001)(70206006)(81166007)(83380400001)(86362001)(82740400003)(356005)(36860700001)(2906002)(8676002)(5660300002)(8936002)(7416002)(41300700001)(4326008)(82310400005)(44832011)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 08:20:35.3545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd9aba8c-31fd-4afe-96e5-08db0ff6adc2 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: CY4PEPF0000C984.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7039 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 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 92f8402ebb34..3ff047bbcfe6 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 Thu Feb 16 08:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13142711 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 9851CC636D7 for ; Thu, 16 Feb 2023 08:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjBPIV2 (ORCPT ); Thu, 16 Feb 2023 03:21:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjBPIV1 (ORCPT ); Thu, 16 Feb 2023 03:21:27 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E13474D7; Thu, 16 Feb 2023 00:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QyH4kqyJyP4LH+YmvU0rhzD0vlNFfnj9EesAe1dVGEO4cty5zWaLexSqTILJOTEh2ejHfMRvXQ47uD3imM1PIGRN2qwyUksdPHRBl9NQSz7XawbcIULtZjHhOxgFlhdU8k8FMfWvcq6u4QD7hdECil48gEtR7Kw3XQFwDoLOm+N0prGCBBZakcRlny8qfm7Lyb+hUJermmN6I2ge+l6E2RzmBZ+g3jj06Qt0U6Fixutxt23mTqkCbDu7XF2eoeD3a6SRhlAk+EXY3jPSwXVc2JPSzAlQh3u9O/oRKjnMjVeH9A7r9Cr6EdeodG7Cd8JqaImBwgYeAEw1fAKq0E/h1w== 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=BYHnwtjE4Ts7dhIt9xsEXMlV6Wkuhg50KYm9bT1XLzc=; b=bzA2muXW6Rm1s5x2NbW7g5OZbpSeYTQ1I6RmavEP7aBnoqD0P/VSQDYfnuHgEayUFJzXMQOHf0m0qPHWEG3owv8L2tIDrKezJCZCkIDEVgpJd8uEI4VMRuWmYSToPHPQMSoQwPEwh6BPgbqcb8J9oFTOHhlDx+kLjJ58c+KV39+2gFWE5EaV9SPle4YmJ11Bc7T3LkhjXhFyOH3SWhrsMOfwkVxm8109gocc0E+2J7l7OHKX/pUVtO8leJkPOtwoB+RApsVJ+prDBKTid6BDgg0oX0Gq9kgsIp19ZqxrolPGPUKj1QwV4MFENVZB5uoJLYIZSgdGZi1NRy7f4UCGQA== 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=BYHnwtjE4Ts7dhIt9xsEXMlV6Wkuhg50KYm9bT1XLzc=; b=hUq3ksOV1HCYv7SaCijG9tDwHBPSjNXo5ZmAWmawsCwgwGrkx1GegE5O+GQPs1m0XdDIAqzQmseuZ5sYP8cCXYuaZcUtAeEF6xsm0uw7gZOz5V9LFwF1VhLRra2t3apmiCVyHRUKEkdBGkZ5Pq2JAmnqPjavVn71kmO2ITE4oE0= Received: from CY5PR22CA0013.namprd22.prod.outlook.com (2603:10b6:930:16::23) by DS7PR12MB5933.namprd12.prod.outlook.com (2603:10b6:8:7c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 08:21:02 +0000 Received: from CY4PEPF0000C97F.namprd02.prod.outlook.com (2603:10b6:930:16:cafe::c1) by CY5PR22CA0013.outlook.office365.com (2603:10b6:930:16::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 08:21:02 +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 CY4PEPF0000C97F.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.9 via Frontend Transport; Thu, 16 Feb 2023 08:21:02 +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, 16 Feb 2023 02:20:55 -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 Subject: [PATCH v7 6/6] Documentation: cpufreq: amd-pstate: Update amd_pstate status sysfs for guided Date: Thu, 16 Feb 2023 08:18:02 +0000 Message-ID: <20230216081802.38007-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216081802.38007-1-wyes.karny@amd.com> References: <20230216081802.38007-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: CY4PEPF0000C97F:EE_|DS7PR12MB5933:EE_ X-MS-Office365-Filtering-Correlation-Id: 059181cd-603c-459a-b7c0-08db0ff6bdb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mBnl7vJRToMaV0U6FiFk4V9WUq8sv4R4Gpiml0hRKhEY5Ga8WxHIymUPkTKFurLENE3GGpfxVrYfDjKH1hJQCYeyvRyM97bi+R+llrc2UFw+/Xx9Hf7MzObNO7GtKWCTL3gAcpv/0DrfeRBw4IO8Nesl1gLWI2u6on80JkdtZ1snJ82vjfxm3zbaTJRr/G+Z9708zQSqoKM7pSrQ5NrVHMqEymDAa7NRyvx+fuAGGJy7DPHqegcY/TZChxfcpbzRXTHIXFYFn+Bc5iaAC/EzBshZRpt3c9NwZsSVuJ10/xdW3EBVlR4gM/7Cc6F8M8nLkcxuHl9uV5VHkAqavRA9K6gSYKeKbkAEPZi8ST1ncgHt9j1rdUu5FwxBugePEhF/XYPeeI1fzeXPD9wMjnTpFHm+VTp0Ysn2l1EpaVEaqK35UbHczzNUNnTSYYW5nL6BUSj/F1+3CpaPBxOyVyc5WWGCKIJEtdxeJwI1iZsYBReDGqKs6qJVSP8/3FLhT6lyrDKTOu05GOXJenzNP+PEC7Fna7lOlL5X86eKm0eyg+ujamCbu3W2MVffaYxVOs00FZHbW6mNLKqKJPLn0jtWWrqd4Pp8VvnQ/RNBRv69p+cEcmvPZkV/osS0f67PRdoRVRM0+VKwj6wpzOlkV25P7SGXlJSp9y5VgvdNiEKX4UnnW5fgcRr3ZJY6xq7wifPus1Ql820tp8Rn/BijYprDK0LqJ84ATbepGAkUmjvadhs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(81166007)(82740400003)(70586007)(8936002)(70206006)(5660300002)(8676002)(41300700001)(4326008)(40480700001)(2616005)(36756003)(16526019)(15650500001)(186003)(44832011)(26005)(336012)(110136005)(36860700001)(356005)(54906003)(6636002)(82310400005)(478600001)(7696005)(6666004)(40460700003)(86362001)(7416002)(1076003)(426003)(83380400001)(316002)(2906002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 08:21:02.1334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 059181cd-603c-459a-b7c0-08db0ff6bdb8 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: CY4PEPF0000C97F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5933 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 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 5304adf2fc2f..95d2d0a803fe 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -303,13 +303,18 @@ efficiency frequency management method on AMD processors. AMD Pstate Driver Operation Modes ================================= -``amd_pstate`` CPPC has two operation modes: CPPC Autonomous(active) mode and -CPPC non-autonomous(passive) mode. -active mode and passive mode can be chosen by different kernel parameters. -When in Autonomous mode, CPPC ignores requests done in the Desired Performance -Target register and takes into account only the values set to the Minimum requested -performance, Maximum requested performance, and Energy Performance Preference -registers. When Autonomous is disabled, it only considers the Desired Performance Target. +``amd_pstate`` CPPC has 3 operation modes: autonomous (active) mode, +non-autonomous (passive) mode and guided autonomous (guided) mode. +Active/passive/guided mode can be chosen by different kernel parameters. + +- In autonomous mode, platform ignores the desired performance level request + and takes into account only the values set to the minimum, maximum and energy + performance preference registers. +- In non-autonomous mode, platform gets desired performance level + from OS directly through Desired Performance Register. +- In guided-autonomous mode, platform sets operating performance level + autonomously according to the current workload and within the limits set by + OS through min and max performance registers. Active Mode ------------ @@ -338,6 +343,15 @@ to the Performance Reduction Tolerance register. Above the nominal performance l processor must provide at least nominal performance requested and go higher if current operating conditions allow. +Guided Mode +----------- + +``amd_pstate=guided`` + +If ``amd_pstate=guided`` is passed to kernel command line option then this mode +is activated. In this mode, driver requests minimum and maximum performance +level and the platform autonomously selects a performance level in this range +and appropriate to the current workload. User Space Interface in ``sysfs`` ================================= @@ -358,6 +372,9 @@ control its functionality at the system level. They are located in the "passive" The driver is functional and in the ``passive mode`` + "guided" + The driver is functional and in the ``guided mode`` + "disable" The driver is unregistered and not functional now.