From patchwork Tue Jan 31 05:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 50599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2568845wrn; Mon, 30 Jan 2023 21:24:26 -0800 (PST) X-Google-Smtp-Source: AK7set+QughxsFaMIxQVB3X3NVSFYPMI17947SE1MAeD5kFW+L7ELa5VESQmVJTfR5paNX1teVQy X-Received: by 2002:a17:906:344d:b0:878:a893:48db with SMTP id d13-20020a170906344d00b00878a89348dbmr15320699ejb.65.1675142665867; Mon, 30 Jan 2023 21:24:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675142665; cv=pass; d=google.com; s=arc-20160816; b=HbPyQXDhLLPkFzrK/p+bKxud4M2W57UmgY48SvR0HT74hFSdD2cA7hVbJGuly0zGqZ Ehrkam0/thgctzJ0zAX5eStyN/rd75XVEwYk+LaF3Akbhsx399ck2iqoAyIw0s6caKEK 1UDD2kKdo85hdFMjIHDCpNUgR378+OPlnYAc82WUQhNnjQD4JqxHBGH0DzfMfC19WBKd R0PH2c5eqrNLBXxduMqeJF52pFZtMEuK0gooi/2JnG1amsB4VwplvpG1hT8Phz1jyQPJ JQ+zDmGHWEr7vXEadCfODtpBGBh07+a+MTpCPYNG0tyCMgSzZOk7AHtg8WSWZ7Whe4cN GcqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rsiOFCzxXXHGF0WkBet0AUOBlPFFzUwh9PMsK4lNcwQ=; b=fkOMjz8zcpXeLdLINv5pBarsEmRqug3IgNwgHl6eCbYYoyVs0xxXJDzZ+YEbQ88+Fu /9W0cCI8PAT1FM/JNYLmSVgO8t6tmKU1N60pl36K4DVYdV5wesHZ2AN1dP3vwC9Pv6/K MQyabGVKXxzAfJZi3n9jkMXRmiKpV20Pjs7PJpg1smGJyvDKrXespWmxdYznHvLHK5E2 S58zVJDuwF4AOs4GgOob1G80OfZpX9h7PS40Rk+Lwfpv0e5TDFsTcIYtYEcUP1SXemtC +McK68We8Lp10Z2+ko1PE80+xEALlmb88pf85Gjt5Wd7czb/A/0pjOEt011WeAhJ0MKy BOYw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ob8fwsLJ; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wc9-20020a170907124900b0087bdb587c42si11890136ejb.854.2023.01.30.21.24.01; Mon, 30 Jan 2023 21:24:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ob8fwsLJ; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjAaFWn (ORCPT + 99 others); Tue, 31 Jan 2023 00:22:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbjAaFWg (ORCPT ); Tue, 31 Jan 2023 00:22:36 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE08E06B; Mon, 30 Jan 2023 21:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOzt2dbtbmpzUP4W5B5AnnbNmnon8LOyqJU3TJ4bqxqURoSVcMI4Zi3xXQQMkCGkHxPlm7l7iTEgrLu4WOk6ZZlViLL24r6xanfeTn5NUDlvPBN//6pTa3dma81L3g9fw1ISCm2Wx+r0F76MQWjipZ60JkkQGNA8tkhEL/lUEQ7KRoYcTCMNZe5HUf8DPgOfZKPZhbNL/9/0o9mt60kwcGXLV1SeSfePVkbPPNg16DuuQmrW70VVVzoyJuX2AOp7AF0RghbGmpmjVwrdABYEiVyqdSv3kSU2j9Y4P2pILJ15hce85gNwuM3y+A/vcC/wzHGcrrWWsN8BndHaUauJdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rsiOFCzxXXHGF0WkBet0AUOBlPFFzUwh9PMsK4lNcwQ=; b=hf+ZCL0Q9gRcFmN4XI1xRNrQ4aWEpPn1+zw1GkQm9lrUXvFj264PjLsxOxl2Dbc7FeY8vKYvH0kDSq/89jQeEOInGED0jIhYidtabY/M+cfjfLaZcYOiAtLB9J4Tf1JLNa+8id1Yy8Z2K/e2xcRcklzPDXkeZ9/JLBmOFKG8pYwNpc3vpuFdryihY92T5pHJKBg11CQcbmogA9ulpzQLNLv7ZxZK7Jrwl5ufmSlcEEQgQkondHqoNWME4ferqddzJqMDOnOezpBJV+ovqDZkHOwqOQgw+j9T67TDsPHnTDnGB7n5m80+waDz8eRmKmYPF/8spJ7gon040tXH8kxgGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rsiOFCzxXXHGF0WkBet0AUOBlPFFzUwh9PMsK4lNcwQ=; b=ob8fwsLJWal8W9GhpU8GeSqQ8jqzt8mc4DzN5xBBHAl89hVNDFjgPKCoc1FCddXDFxJGLHgcNZ67fNlHzdwKFC0JS2WhgMdERb1gpLkq6qTsLjkbaFaYdPTCUvDN4bm7EzwRiKVogbg7sZHB5OFzGk2VGkj6uiakMEo43en7+Q4= Received: from DS7PR03CA0262.namprd03.prod.outlook.com (2603:10b6:5:3b3::27) by CY8PR12MB7416.namprd12.prod.outlook.com (2603:10b6:930:5c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 05:22:30 +0000 Received: from DM6NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::64) by DS7PR03CA0262.outlook.office365.com (2603:10b6:5:3b3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 05:22:30 +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 DM6NAM11FT008.mail.protection.outlook.com (10.13.172.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.31 via Frontend Transport; Tue, 31 Jan 2023 05:22:30 +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; Mon, 30 Jan 2023 23:22: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 , Wyes Karny , Mario Limonciello Subject: [PATCH v4 1/6] acpi: cppc: Add min and max perf reg writing support Date: Tue, 31 Jan 2023 05:21:36 +0000 Message-ID: <20230131052141.96475-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131052141.96475-1-wyes.karny@amd.com> References: <20230131052141.96475-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT008:EE_|CY8PR12MB7416:EE_ X-MS-Office365-Filtering-Correlation-Id: 8938f719-32a8-46cf-2dc1-08db034b263d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CLOT0INK6iudCZ1qaaUzFt5/Gk6HInG4HEJdsPSLOq88jFBYauqZ69LXK870+qdCPugEWLQWRMktB4bUiWKFhKcnfPbQw47E94JRQOCG3pjZFXjeeoEpMW3US60BbuNXiGQaFPi3sp6S2vdwsWnP4ugIUQYQeValvWdeMS3z/fye+QCEdZ81KR9sCKFH4HJwwv3FqO6eokIy6lYhrNKdglf1/78Q5dZB7Axni+JJEzlYMkGUzRanBw9OM2j1Xzd27l7I4CNBap8m3TYrUGuVU9EQmKBJEfEHv3Pz4efDOMYNRXANxNbwt12SNs2QYnp5f4p+5KPnzV7NtJhJr9v6JsHo0knn5WG8ZdN1v1nxAo9Jqlcu8/6/5w/GnzSy+9rMtywWOZ1tybTZfYKZ0CrDJZihBAkqqFcPJwWDOd/MYaEQcpWru/8iEAxrhsvJV8FlsNwP//VxqzErtBeCOq00WACSOvYEwOgJ4up0V6gjphCzIVVjEv92bL4SXqA6CLu+BPHTKJGA05AOYVND1nNEhqCTLpnf0lJ62EP3ERe3HlBf805pl1uaFzwVJUznPXNaHbRtYzFVI7pL/0SoBcEw4IHLUGCJoWSM9cJMSQOGxiqGQZXnIww/cZ5rh73YEw1odT2M/ja+2Fqn/oGeRISHvkFAVXVaVmodG2slBga9wjA1m7UW2yFpQesK2WVJ6EcmjpwNoi1vWBndGddyfifQfVDPwWGE58U5Ci0W8Z+YPmc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(39860400002)(346002)(396003)(451199018)(36840700001)(46966006)(40470700004)(426003)(336012)(82310400005)(83380400001)(47076005)(40460700003)(86362001)(36756003)(70206006)(70586007)(8676002)(82740400003)(36860700001)(7416002)(2906002)(4326008)(44832011)(81166007)(356005)(40480700001)(41300700001)(7696005)(478600001)(316002)(110136005)(54906003)(6636002)(1076003)(6666004)(8936002)(5660300002)(2616005)(26005)(16526019)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 05:22:30.1250 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8938f719-32a8-46cf-2dc1-08db034b263d 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: DM6NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7416 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756514395951311488?= X-GMAIL-MSGID: =?utf-8?q?1756514395951311488?= Currently writing of min and max perf register is deferred in cppc_set_perf function. In CPPC guided mode, these registers needed to be written to guide the platform about min and max perf levels. Add this support to make guided mode work properly on AMD shared memory systems. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- drivers/acpi/cppc_acpi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 02d83c807271..91f9ef75f7de 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1487,7 +1487,7 @@ EXPORT_SYMBOL_GPL(cppc_set_enable); int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) { struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); - struct cpc_register_resource *desired_reg; + struct cpc_register_resource *desired_reg, *min_perf_reg, *max_perf_reg; int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); struct cppc_pcc_data *pcc_ss_data = NULL; int ret = 0; @@ -1498,6 +1498,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) } desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF]; + min_perf_reg = &cpc_desc->cpc_regs[MIN_PERF]; + max_perf_reg = &cpc_desc->cpc_regs[MAX_PERF]; /* * This is Phase-I where we want to write to CPC registers @@ -1506,7 +1508,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * Since read_lock can be acquired by multiple CPUs simultaneously we * achieve that goal here */ - if (CPC_IN_PCC(desired_reg)) { + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) { if (pcc_ss_id < 0) { pr_debug("Invalid pcc_ss_id\n"); return -ENODEV; @@ -1529,13 +1531,19 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) cpc_desc->write_cmd_status = 0; } - /* - * Skip writing MIN/MAX until Linux knows how to come up with - * useful values. - */ cpc_write(cpu, desired_reg, perf_ctrls->desired_perf); - if (CPC_IN_PCC(desired_reg)) + /** + * Only write if min_perf and max_perf not zero. Some drivers pass zero + * value to min and max perf, but they don't mean to set the zero value, + * they just don't want to write to those registers. + */ + if (perf_ctrls->min_perf) + cpc_write(cpu, min_perf_reg, perf_ctrls->min_perf); + if (perf_ctrls->max_perf) + cpc_write(cpu, max_perf_reg, perf_ctrls->max_perf); + + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) up_read(&pcc_ss_data->pcc_lock); /* END Phase-I */ /* * This is Phase-II where we transfer the ownership of PCC to Platform @@ -1583,7 +1591,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * case during a CMD_READ and if there are pending writes it delivers * the write command before servicing the read command */ - if (CPC_IN_PCC(desired_reg)) { + if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max_perf_reg)) { if (down_write_trylock(&pcc_ss_data->pcc_lock)) {/* BEGIN Phase-II */ /* Update only if there are pending write commands */ if (pcc_ss_data->pending_pcc_write_cmd) From patchwork Tue Jan 31 05:21:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 50600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2568994wrn; Mon, 30 Jan 2023 21:24:58 -0800 (PST) X-Google-Smtp-Source: AK7set+dSAfi1GXYoCgC1CvWK2Ao7tFIS/u0qaSnKbK7zE0xeZVDddRYs6mTsjZB9TEvm+M8byIn X-Received: by 2002:a17:906:6dd8:b0:885:fcbd:40d5 with SMTP id j24-20020a1709066dd800b00885fcbd40d5mr8935551ejt.59.1675142698415; Mon, 30 Jan 2023 21:24:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675142698; cv=pass; d=google.com; s=arc-20160816; b=QeJic7Py4BIRhV5in9ssDi9jVdQcpza2ZlbYAv20vTjehI5MkVk02qrrFb0QbUK3cv L3Q5Hl+LNNG/DnAtQ1AldaC6Cl1h8PGvfIK1TQK6RttaycEHXT9NSDsFITcjM2fvNpcN MI07vbD0V7aNWNK94LkNR8Y+wHkNBb0icBvUBdv9Jh66gZ4fQoUAyOojJbkheVrurm9z igZ2eb2wFWM5NKzFj3fmnlZW53zpjo8XwWVuliJ1AMCh+spMmMx5DXarlMau3drGbiP2 /wvvLb628XEc5z+ivwM7MPGEtBRAQVpwH8H7W32yCsi6dme/OWSgPouLhROgQLlF0yR3 AlCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=82aGwNYippQcfrJSwAkDqSbcGKrbCFCBCOh5PrQN9Dg=; b=SYTusqsspooQrzBiLnHrwgssaeEpJaciH4r6smS6FRjzr1yQg5qsjcTxSabCW7ebQB f0kT2Ato82VWWPLv4yDtd0S8xt+6Aawqbmery1k9NTIzPNiogPYZpnwBAAgPi1oeY3oc 5xWHPtWOnqVmjsS2MBlSIM+wcTFHoNhm5cSoWkXHLZ9s5Ieqk6rF7jMvpx9jv6IGFgLF 1APLh0V5EoPoifOK3WGGkk6p4b4UBg1Om3mKg3YSM1fyf/mZwKfiOSEQ2uC8V2YNBlDt Hk8RjSWqP1KqnF56gA7YhHThxK2UXs4BF/DTwBu0CLg/V6RS2IrrPfJirzyJ+9ikb3PH vBcQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=MGcxQO2v; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020a17090610cc00b0087f812bc0a0si12782785ejv.860.2023.01.30.21.24.34; Mon, 30 Jan 2023 21:24:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=MGcxQO2v; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbjAaFX0 (ORCPT + 99 others); Tue, 31 Jan 2023 00:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjAaFXW (ORCPT ); Tue, 31 Jan 2023 00:23:22 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2064.outbound.protection.outlook.com [40.107.92.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2529AEC6E; Mon, 30 Jan 2023 21:23:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jv8W53d3hDq22aWcmQgYafAYpD5c7YkOLuYNZLCmZOWYxXDHGQ+YTywAwVqYei5o8H4Vq54SyI8cq+Ljoea4CHQwyeqAQRu3/7O/AlgTLb0Lpst6cKHWkk7iVLnC7pxj1AGkJL41qsDw4eGDOPbX7TFnci0BOG4I7WO7S5l1Rx1oJ3XAc2r3GxE7Vq1nRiljEJm27YnUWYzO8nDHFtm6+ek8MFywymXm6F83nSVQeVP9G/yPy3z66R2+18XKQubgsYm1Bm18GdDSxDahmG0EHHxzK7rd4PL6utrF3LNvsRgrXArM0FSzkRW7o/4ABlw06ImSLylD4VUR3t6V89XDeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=82aGwNYippQcfrJSwAkDqSbcGKrbCFCBCOh5PrQN9Dg=; b=DkyDCtCRkFG9CI6EqeSkCJ1OttNQjVZTEBZLLJZOQR+t4nz9OkNgUyDd2Y2vUKpbxEgNksfYvCSR3kx8JSEWFOXpmG47Xpk4syUl6fBknhbI3KFRvscX4MOyUUzgSQTq7hzMZbddq4g6gtRpFDj9IvpstBAABvYLcpDY22v09OeVKCuc/R3Oo5TYL1PmF+Jb6tSfR183BZUDQPV/2MTOkFYtOQv8pdzB/7NevV2WlhH/AF60KrEL/7ItRRacIM30wIc6LlxFEtrYhnHX+qpS8F7AxgzpD8Tl87RKb+ATxW0fSWM6DKqYefPN8Qi3eUl+lzm4YBTu29c0O1E5AxQc9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=82aGwNYippQcfrJSwAkDqSbcGKrbCFCBCOh5PrQN9Dg=; b=MGcxQO2vQKF0n+zd5yF/ivFGTana88NqdwnMLvMgAk9283rWakuTHA3+VOoUqfHHYAsISF5nzO7aDKcvu2hwJBSWmp/+1/O12PM0wytHKjvxTORrwTFU2J1iNw2oNMs0m4XtcWzhHdE8fJlmAuPg0jWnZkZbLybYk5YRgphLhho= Received: from DS7PR07CA0001.namprd07.prod.outlook.com (2603:10b6:5:3af::10) by SN7PR12MB7936.namprd12.prod.outlook.com (2603:10b6:806:347::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Tue, 31 Jan 2023 05:23:09 +0000 Received: from DM6NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::10) by DS7PR07CA0001.outlook.office365.com (2603:10b6:5:3af::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 05:23:08 +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 DM6NAM11FT111.mail.protection.outlook.com (10.13.173.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 05:23:08 +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; Mon, 30 Jan 2023 23:23:03 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v4 2/6] acpi: cppc: Add auto select register read/write support Date: Tue, 31 Jan 2023 05:21:37 +0000 Message-ID: <20230131052141.96475-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131052141.96475-1-wyes.karny@amd.com> References: <20230131052141.96475-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT111:EE_|SN7PR12MB7936:EE_ X-MS-Office365-Filtering-Correlation-Id: aa2921ee-1476-439f-9592-08db034b3d4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B5LDsw2hqUJnx2LnVLHRT0MayVbY5ObtcQ+TtPY0XHYdvbAD3hrcerogvta1ucyos+Qhops+0xhSEvXk8ieBfKAaVVOiVjDtDI1sBr/XkkNCwQNHYwdX/HADwxVLNk4REZsTEr7/tD6+4/SvT8SZlrHQsfvfQWdNeYuyH4M34XcCeOGq5Uw0hCw8/gpusgG7PbujUH4p52Z8chkqH5HVDfWnvY1eyFiBZNY6RkBhgaH9FXr36UvNyUbqZScWVejR2z9rqbWHVpMgMP/nfHBjHdCqRXd9lIXaPlnQGbWbp685fB9Nvn9U10t590fxuegZUvZS2g9EYvX7pel/NqO00JQlhIYPxNxP9rfKwfElUcmBWwfZc1zohNRDEs11l/qXOG/dMiwkKyIuGFM6pLS2RslTNfv/YpEpixww+I0gscCVptF0rk/86lgw2079GUw8VyIS85JNQhoCgPFS9K42NFlYaQYrruaUvJhed+grVxjStxsHDmUltAnjWKn32Yxg0BFrET8n6OjfJVUpmgk0fvI8Xhz81eMDRDX+s9+lIwX6035k2XUYXsg+aqAVymPST94CDdIhorwdE/c8EqQ9/iR/Mh8h87l1pLrsFi9TZhw4zgau5clZJR+E+aZFqus3Hrry2qs5a4GusiOGZdGHqmuXkL00GmSlQo0DyQhNPBNgRAgjnKnqd2IYjFCc4s+xQf8TTKpXiCcNwd6TF9Yugg9k6TmRd6yV6XPUZ6GBW5Y= 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)(346002)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(86362001)(356005)(82310400005)(2906002)(36756003)(110136005)(7696005)(41300700001)(7416002)(6666004)(54906003)(478600001)(44832011)(40480700001)(8936002)(5660300002)(186003)(2616005)(70206006)(70586007)(316002)(40460700003)(81166007)(26005)(83380400001)(36860700001)(82740400003)(16526019)(1076003)(426003)(336012)(47076005)(8676002)(4326008)(6636002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 05:23:08.8133 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa2921ee-1476-439f-9592-08db034b3d4c 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: DM6NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7936 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756514430179967878?= X-GMAIL-MSGID: =?utf-8?q?1756514430179967878?= For some AMD shared memory based systems, the autonomous selection bit needed to be set explicitly. Add autonomous selection register related APIs to acpi driver, which amd_pstate driver uses later. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- drivers/acpi/cppc_acpi.c | 97 ++++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 11 +++++ 2 files changed, 108 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 91f9ef75f7de..1806006a51af 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1432,6 +1432,103 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) } EXPORT_SYMBOL_GPL(cppc_set_epp_perf); +/* + * cppc_get_auto_sel_caps - Read autonomous selection register. + * @cpunum : CPU from which to read register. + * @perf_caps : struct where autonomous selection register value is updated. + */ +int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps) +{ + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); + struct cpc_register_resource *auto_sel_reg; + u64 auto_sel; + + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpunum); + return -ENODEV; + } + + auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE]; + + if (!CPC_SUPPORTED(auto_sel_reg)) + pr_warn_once("Autonomous mode is not unsupported!\n"); + + if (CPC_IN_PCC(auto_sel_reg)) { + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = NULL; + int ret = 0; + + if (pcc_ss_id < 0) + return -ENODEV; + + pcc_ss_data = pcc_data[pcc_ss_id]; + + down_write(&pcc_ss_data->pcc_lock); + + if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0) { + cpc_read(cpunum, auto_sel_reg, &auto_sel); + perf_caps->auto_sel = (bool)auto_sel; + } else { + ret = -EIO; + } + + up_write(&pcc_ss_data->pcc_lock); + + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(cppc_get_auto_sel_caps); + +/* + * cppc_set_auto_sel - Write autonomous selection register. + * @cpunum : CPU to which to write register. + * @enable : the desired value of autonomous selection resiter to be updated. + */ +int cppc_set_auto_sel(int cpu, bool enable) +{ + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); + struct cpc_register_resource *auto_sel_reg; + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); + struct cppc_pcc_data *pcc_ss_data = NULL; + int ret = -EINVAL; + + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpu); + return -ENODEV; + } + + auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE]; + + if (CPC_IN_PCC(auto_sel_reg)) { + if (pcc_ss_id < 0) { + pr_debug("Invalid pcc_ss_id\n"); + return -ENODEV; + } + + if (CPC_SUPPORTED(auto_sel_reg)) { + ret = cpc_write(cpu, auto_sel_reg, enable); + if (ret) + return ret; + } + + pcc_ss_data = pcc_data[pcc_ss_id]; + + down_write(&pcc_ss_data->pcc_lock); + /* after writing CPC, transfer the ownership of PCC to platform */ + ret = send_pcc_cmd(pcc_ss_id, CMD_WRITE); + up_write(&pcc_ss_data->pcc_lock); + } else { + ret = -ENOTSUPP; + pr_debug("_CPC in PCC is not supported\n"); + } + + return ret; +} +EXPORT_SYMBOL_GPL(cppc_set_auto_sel); + + /** * cppc_set_enable - Set to enable CPPC on the processor by writing the * Continuous Performance Control package EnableRegister field. diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 6b487a5bd638..6126c977ece0 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -109,6 +109,7 @@ struct cppc_perf_caps { u32 lowest_freq; u32 nominal_freq; u32 energy_perf; + bool auto_sel; }; struct cppc_perf_ctrls { @@ -153,6 +154,8 @@ extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val); extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val); extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf); extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable); +extern int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps); +extern int cppc_set_auto_sel(int cpu, bool enable); #else /* !CONFIG_ACPI_CPPC_LIB */ static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf) { @@ -214,6 +217,14 @@ static inline int cppc_get_epp_perf(int cpunum, u64 *epp_perf) { return -ENOTSUPP; } +static inline int cppc_set_auto_sel(int cpu, bool enable) +{ + return -ENOTSUPP; +} +static inline int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps) +{ + return -ENOTSUPP; +} #endif /* !CONFIG_ACPI_CPPC_LIB */ #endif /* _CPPC_ACPI_H*/ From patchwork Tue Jan 31 05:21:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 50601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2569103wrn; Mon, 30 Jan 2023 21:25:22 -0800 (PST) X-Google-Smtp-Source: AK7set8iskaJ/jv3eHxhZwXLYZIGGQnSM33PhJv1UsZaSGucV05rKgcP40ag+bTah5ZYbP4iBA62 X-Received: by 2002:a17:907:780d:b0:88a:f42f:579c with SMTP id la13-20020a170907780d00b0088af42f579cmr4363649ejc.77.1675142722016; Mon, 30 Jan 2023 21:25:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675142722; cv=pass; d=google.com; s=arc-20160816; b=J1Z1TdkAvbfxwPmUz+0LX/kw4IhKr7sAIEzea2vVJ3M3IBnmD6A4Y2Bh7Rq3ZS93H2 /EA7hzLRJTX5LTR1D6YFwsG4IMRhDJ5P0FgdbGxtH8lezI15GZvVlWSeXAEcqGbOk0RV KF/L+JrGQgwK7jsLslRtNFFxUK459412bAnLiCB4PtlEzl1dCmyUwdLS3PPlHK8YGGBJ 7/zR6EBFqjI02VRJDoBj5VB/WwJYUEOssj5UlICOt9EY3cgd0nhpsHZA5YxWbR2yaBBD GVLT+ozErQpIXgLUVmLUbQmkjW7sPix2XJJXFVsiWHtvMOnAiA/7nzkYRUFHZ2uzSj9M uv1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gBTPp5CWYMBCGH8BVliMJ7YvKPqJKBIKaa40LWW9Da0=; b=DCNAtN3ysNzRnuh0IJF5VUyW/NEnyrwOWrkAwP+Ta6GVBX0laLu3UhZUKCMdrAx8Yu ChRW/F8KihxnS6mIcKs7JuR/8xP+yKjOysPJ26SFCtji+hnK1Wwk1J+xFna6Y9LrYPj5 IT+YBB+zhuNJYjcI38713N4xnk89Lw8uUlKZPFXbAukjoDcgTxJ/Glm9SWzcbXphq63v QBH1lvBb8jGKRycP6S56Wsdf/2fruz5RYFZ0lIG1RphnzZLkbFmfHRWzick4XEET0yCo lq4dT5mtEx6AHSuOqazRByr+clhZ9st7nv5eQD/via9sfIxksFHcqi3FD70CJjXwoxcs J0Tg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hiNJk3yG; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vg13-20020a170907d30d00b007c10bb5b4b3si18446320ejc.681.2023.01.30.21.24.58; Mon, 30 Jan 2023 21:25:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hiNJk3yG; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbjAaFX6 (ORCPT + 99 others); Tue, 31 Jan 2023 00:23:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbjAaFX4 (ORCPT ); Tue, 31 Jan 2023 00:23:56 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4182C1C591; Mon, 30 Jan 2023 21:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QD7+2g3+agYleXngVQP23PwZF0ft6uMCnN5ghSUfos2vtxxYjJfuUb8KLlkdJx/h+jPGMFMGIXxpjwOuO28QWRwECfCLKinxfwaBsLO7wk7+dTXx11PN6kgijg3UINiIz7qpzaY5gFfbCORQBFwcHKMGbC6ZdxsqVc1C2V2sBaQ7KjEBnoNUoVNk0O4PYLsmJXHD9ixdIrCyCGJlNRyWvDD/waV9d6rQWzfzH60JBJrAIFn9wy3Ca9g1nBCa2FRz9tnr3faOBIP1OvLJe9paeGCbKgXQ2y/cEWWcdHFPlnuQTmqhj9B092E+dwtWDrL6DlqVnC5N12RAoPjHxJHoWg== 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=gBTPp5CWYMBCGH8BVliMJ7YvKPqJKBIKaa40LWW9Da0=; b=lB7PGCNSmKTOW9n0zxQnaoqiE50RWk0faqzFyz6LvJ85q3mWYNbinl9HbSEvteE5Nlk2VU8DZbg1rlpfa/ZhZQiKbU2pLnQ9v/gDtOUkIz0oT2GQHryivhmUNL6f/H40SIE/n/qUyE5rD6WxxIV1Spj5m0btKubUB2aJriXqJ/mCy+C2y+SKPIMmsqFY03yfEVE1K2scPev+94QhOh0Zs7o+y3jHRt3kuDYG1IGgp5vWnK/qvTTzgAoSta7T09Gum1Ioi9vnPpoMBtswJDZsdIa9F/lceHle9Vr8g5LTkLHIsfMepqWMYiXvfFzVw7oFR/FZN3yGfU5QYEHdQ+ibmg== 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=gBTPp5CWYMBCGH8BVliMJ7YvKPqJKBIKaa40LWW9Da0=; b=hiNJk3yGTt2ww1C6osSzepnkffYWtnXMMqGkyhRxrEeFAY6ETffTwsmNP6GaqmHt2ScNB6Ldeq7H8uijRjrPd3E0wTAPTCrqS4iR7iz5+zzoH75TyonDXIN5nGK+EFoSMQm6RcMRx8F8NPbBb9yhVsH9MmFrYGCCylhbIbU/jCU= Received: from DM6PR07CA0085.namprd07.prod.outlook.com (2603:10b6:5:337::18) by DS7PR12MB8369.namprd12.prod.outlook.com (2603:10b6:8:eb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 05:23:52 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:5:337:cafe::e3) by DM6PR07CA0085.outlook.office365.com (2603:10b6:5:337::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 05:23:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.30 via Frontend Transport; Tue, 31 Jan 2023 05:23:52 +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; Mon, 30 Jan 2023 23:23: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 , Wyes Karny Subject: [PATCH v4 3/6] cpufreq: amd_pstate: Add guided autonomous mode Date: Tue, 31 Jan 2023 05:21:38 +0000 Message-ID: <20230131052141.96475-4-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131052141.96475-1-wyes.karny@amd.com> References: <20230131052141.96475-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT004:EE_|DS7PR12MB8369:EE_ X-MS-Office365-Filtering-Correlation-Id: d86bc7f4-8aed-40e7-eb7d-08db034b570c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R5F2MIjGbEiEr+fGMAuQ3Zi9u1Vd1gZgzCtpNFi/r+pf0oeagWHHspHNZqiw35HQYJvY1wA4zJKaYxkys6LKWCFex7dfwPqdnqapGVkYGKBlQ72Cv5fxjWC/3F8zS/B6Ylwqa9jkfxuBU/Z13EFGehR/rIcDQMnEp3Nqv5RvXphcTs/CXK6L3/nYffEPzwudiYWKWFlfTmJrp5ULI7RVaHKldb2xvzjS2SqCVFYs+K6lUSQfnj5gPtvsp5jg1uBcCTjIDz9AMKAAUWgJDZS/wiTfjMu2orUUh7IP3izVc5ZvpizxBpKffHcp8hhCfWK8E54Ts9WfW2USqvyOPNdwQiirx763vlRG1ExqBXP1EPD2NXWETas8EnhbGkcsXB5ZGJmSnDl/ai9eyZ3Yl98nc0PAtIYNxz5C6h6a1wMzbk90uh4vFO5Q5G4ZcyB25tMrCYrL0m7P1wJjLom/cCw9NYZzJDYkWhh1OFnMx3lT8qwUrwrAWqVnxnejlz4RnHWUMd7pXzTmYKgK8asLsbeQoLKZHxZ9l0qHI17e7GyZoPmzTSSGbhMldpCG+r6ZJHpiXv5bZ4ytiztRGtBZXoa7O9XbZ/efkI1F7slECCx4nIQ3Pae9k8j0x0MRjfoKFT5z4qQpzgx2Sk9nr3pNneIP6DyW/S1LrouE/FddUEJRxA7G4IWLixisejIufTARziSefIqGRERh4phtvd2Vq0AqZftTdYzYL+vpB9FIiCUndSM= 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)(346002)(136003)(39860400002)(376002)(451199018)(36840700001)(46966006)(40470700004)(82740400003)(86362001)(7416002)(110136005)(54906003)(5660300002)(356005)(44832011)(1076003)(36756003)(40460700003)(26005)(6666004)(81166007)(186003)(6636002)(16526019)(2616005)(316002)(2906002)(82310400005)(47076005)(40480700001)(70206006)(7696005)(83380400001)(426003)(8676002)(336012)(478600001)(8936002)(70586007)(36860700001)(4326008)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 05:23:52.0170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d86bc7f4-8aed-40e7-eb7d-08db034b570c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8369 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756514454862584286?= X-GMAIL-MSGID: =?utf-8?q?1756514454862584286?= From ACPI spec below 3 modes for CPPC can be defined: 1. Non autonomous: OS scaling governor specifies operating frequency/ performance level through `Desired Performance` register and platform follows that. 2. Guided autonomous: OS scaling governor specifies min and max frequencies/ performance levels through `Minimum Performance` and `Maximum Performance` register, and platform can autonomously select an operating frequency in this range. 3. Fully autonomous: OS only hints (via EPP) to platform for the required energy performance preference for the workload and platform autonomously scales the frequency. Currently (1) is supported by amd_pstate as passive mode, and (3) is implemented by EPP support. This change is to support (2). In guided autonomous mode the min_perf is based on the input from the scaling governor. For example, in case of schedutil this value depends on the current utilization. And max_perf is set to max capacity. To activate guided auto mode ``amd_pstate=guided`` command line parameter has to be passed in the kernel. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- .../admin-guide/kernel-parameters.txt | 15 +++++--- drivers/cpufreq/amd-pstate.c | 34 +++++++++++++++---- include/linux/amd-pstate.h | 2 ++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index e3618dfdb36a..0d8486325c9a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7015,11 +7015,11 @@ Do not enable amd_pstate as the default scaling driver for the supported processors passive - Use amd_pstate as a scaling driver, driver requests a - desired performance on this abstract scale and the power - management firmware translates the requests into actual - hardware states (core frequency, data fabric and memory - clocks etc.) + Use amd_pstate with passive mode as a scaling driver. + In this mode autonomous selection is disabled. + Driver requests a desired performance level and platform + tires to match the same performance level (if it is + satisfied by guaranteed performance level). active Use amd_pstate_epp driver instance as the scaling driver, driver provides a hint to the hardware if software wants @@ -7027,3 +7027,8 @@ to the CPPC firmware. then CPPC power algorithm will calculate the runtime workload and adjust the realtime cores frequency. + guided + Activate guided autonomous mode. Driver requests minimum and + maximum performance level and the platform autonomously + selects a performance level in this range and appropriate + to the current workload. diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index c5731fefcbef..48ab4684c3a5 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -267,7 +267,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); @@ -344,12 +359,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 guv_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) && (guv_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); @@ -404,7 +425,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; @@ -438,7 +459,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); } @@ -1238,7 +1260,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"); @@ -1300,7 +1322,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 e9e291b7c2f9..85e980b8e0ac 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -92,6 +92,7 @@ enum amd_pstate_mode { AMD_PSTATE_DISABLE = 0, AMD_PSTATE_PASSIVE, AMD_PSTATE_ACTIVE, + AMD_PSTATE_GUIDED, AMD_PSTATE_MAX, }; @@ -99,6 +100,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, }; From patchwork Tue Jan 31 05:21:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 50602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2569442wrn; Mon, 30 Jan 2023 21:26:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXsOAEpISYmBJ2x8lomhkyak8QtRRIkDLhveapSaNLokYUYDAwdTlIg2UNk08JpraN+j4aX+ X-Received: by 2002:a05:6402:493:b0:46d:53d7:d21e with SMTP id k19-20020a056402049300b0046d53d7d21emr53215651edv.27.1675142797056; Mon, 30 Jan 2023 21:26:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675142797; cv=pass; d=google.com; s=arc-20160816; b=xdU83VkAJD1vuR4lQGDpplO3FMfRVrpD112+JwZ8enLJbb9jVKzHlYnh2V18sgSGHZ 3JTsW7hKghrD3SLXeXXhO5TeF9/0xKu3dsu19zA7FK5+hvsRVXV/VMiR8Lj2hKPLhk3K tdePQYfd5lQJ+yt0YP3M4WEQAqk6ZbybdKFG+vw/s29R+GPo01nlXgWqj2Wwfl7XNw8t l4uYDVLPExYVwH9W81pDYjCarVzVXSOcccxG9OXeIt5vRs6C2IAwHuyRpmMDeYEG3nxa KJM5otiGpppo3yxexZrakdafAlfzkLWIYpyaQeWTeaiBsNAyG2ze4GlCJI2AW6C3m3LM 6XUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pSCb9E7hlwVFlUz5E0Q0t2Sq3suv8GG6PLWOYj7pyfw=; b=h3dT80EM/Vw9XEMQULw144YaHfh4bZR3mURvySQwVkmrP8GPhOalaaEBjfIgl95FF/ opcibdwdImp2n4ldnaESHKfgO5lAzW/5IIaEdyruKo0i6ZK3A3sm+kXJGwUqr3m3cckh KPW0WsFnCbYfQLkeoZQHVA2doaUpI07Yu6XgqwkLtV+hXF5GdZLody3S0Bc4BoCEBX0c hBF6tviQUZXmIhl2JEXv7PbaLyj70anY5Lps78D6bI4O5SxII7/jhBfnRgcbjVezvtnE T0kdUilRYj7Kqww5ENnDkN89wUm+MPQX8q7RzdLTfTcGR8tqhq8gCmBPt6YtiGgh2ImA H8FA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=t2JSJhZh; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec1-20020a0564020d4100b004a21506e0b3si1244352edb.462.2023.01.30.21.26.13; Mon, 30 Jan 2023 21:26:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=t2JSJhZh; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbjAaFY5 (ORCPT + 99 others); Tue, 31 Jan 2023 00:24:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbjAaFYs (ORCPT ); Tue, 31 Jan 2023 00:24:48 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2072.outbound.protection.outlook.com [40.107.243.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4D1F3B3F9; Mon, 30 Jan 2023 21:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CF1itaDT1tWJpMXtSngtoiHu0GkXjg/OmeglBQbd7uJzuLewaxCOzyfDNNEGlfdtnTA1NNadvR47Vk168QmpC804Cv5a+bTVG0k7e9wX8Uu9E+Sw2TQZ7jITSTmmkzBCW+MwwcK2+a/puuPMqLua83vMNltVCKHx6r3ydai3AUrVjBkg0PAvLX+uugxZ8+rzwYtyboCZkrMqFVbZIRxZABzCmaw+SAoqejYu4X74iiR8Voh6d9fHzzHZeSTPSPWd+SImsipXY+dsodzbWJqK2gbPaLItwN6kfqhrWLYYWqaCJ0/CBrFdfNDRODXnT2OtT3r5tXgBYuBZDTrB6W5wVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pSCb9E7hlwVFlUz5E0Q0t2Sq3suv8GG6PLWOYj7pyfw=; b=lunItLAoj6khvCHnECJe6+1pgpEO10VtlhO4FJeQMcfLVJq368EU95r7HAlOSU9WLOx1YW7j2AYIKdJPO4ipUXBIh3ZF1r9TcAJWGZQIkIlO0lG2kCGeqGueEpIge0TRopm/C1HVjhs7NM1X0WmOT2mB8TP8eAqj1vj7bkdgIhlvrNsu5+vUgBs3D7cyMX0tSOVTLlmUGWQW0YgrGusH/Zd6yo66KF2WlVIw9005uX+XODfa4Yb5yf8iJptJMQde1ocIRGUyro+QBlR7DjZpUIW67ZFIBU8b6oT6cun/8iHX5yt+8YBec/yQK3qLjTedroJ2pEi1CvzVXMKtyyNHIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pSCb9E7hlwVFlUz5E0Q0t2Sq3suv8GG6PLWOYj7pyfw=; b=t2JSJhZh+hWKyxGalZFCc06LjpdQj66hSzp3Jg+MaDlf15YK5v5ISe98UzUi7sSOpz2gcj+D/0kUghCzdhSItgOJloA9cv9Q7zpvNWRbL1LzmPgx6YIyVDk82aPkRmNXwV2JJhfunw2/504IW/XNPqFDoJbbXJDRTF6fWifkpB4= Received: from DM6PR21CA0018.namprd21.prod.outlook.com (2603:10b6:5:174::28) by MN0PR12MB6176.namprd12.prod.outlook.com (2603:10b6:208:3c3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Tue, 31 Jan 2023 05:24:24 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::66) by DM6PR21CA0018.outlook.office365.com (2603:10b6:5:174::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.4 via Frontend Transport; Tue, 31 Jan 2023 05:24:24 +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 DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Tue, 31 Jan 2023 05:24:24 +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; Mon, 30 Jan 2023 23:24:18 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny , Mario Limonciello Subject: [PATCH v4 4/6] Documentation: amd_pstate: Move amd_pstate param to alphabetical order Date: Tue, 31 Jan 2023 05:21:39 +0000 Message-ID: <20230131052141.96475-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131052141.96475-1-wyes.karny@amd.com> References: <20230131052141.96475-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT021:EE_|MN0PR12MB6176:EE_ X-MS-Office365-Filtering-Correlation-Id: 71010477-6942-45e4-3c7e-08db034b6a43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o4Eq8Fay4llq20Wtvq5XhJgAvasmjuaRU+smYZWJxwa4MJEW3hvstoGcmfKLxe6UY1J5taINs7GB6W3FhnGm1bx2HLMQRY11qg+A73qnsUvFucdrqnar1AngX3y5Hd0/3e8IRtIZWSpBaeBFbELYOUuCYHtwIf1CbMH4KohNH76W7eDyAB7w6CF/zLJvVdQbP0jY14K+lLt+9H4wFbBLPO8h+pvzWjW8AzuazRI+/7aZes3PynU3ov1PkPENZTCeOzDbriusnzQgEOdHkiqBkoHLPJblUH1OzOq+3nJhiXFZEFLRFlnMsyiLJnRmbn8H0EI37lEuJfLc3HcPWdVcqxKaYUM/5xYnp7goZBP6pIojA6/ZcRowHBCWsgceeFt6hNJMAkzfcEPEWLwwWdfUDV7Y8BYgp9ErdP2J+5MaD1uR+EszRaZeFMEGvBQ5egRRuCweKdQI9BVETWOsLyUkUPUgq7+0OeEemYh5YGiaBdmTOJZA3uVlRBakFbzhYBsUAKFSJxoYo+1g30i94BXJi7VEWbp/Q/eVoxDZPmeS1meDk0uG0Cr2Gx6tw1uqAAOVzkEN5wOcare52eDn5wBsd266O0CDYSK9xSB2kdxv3JlsH4iwW6OO9Cd3LrednAAQydALReMHp3RTQGvyuyJjdwWN3arJWgRkri/V2vYEcabh91PSlT/qqENW3JtJ06i9XMAV6wLGtQ+9EFNE9H+lcM88y48uTUMtZ1/yFe2GCy0= 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)(346002)(376002)(39860400002)(396003)(136003)(451199018)(40470700004)(46966006)(36840700001)(47076005)(7696005)(8676002)(70206006)(4326008)(36860700001)(41300700001)(70586007)(8936002)(336012)(83380400001)(426003)(478600001)(86362001)(2906002)(316002)(6666004)(40480700001)(82740400003)(82310400005)(1076003)(81166007)(6636002)(5660300002)(16526019)(186003)(44832011)(356005)(26005)(7416002)(36756003)(110136005)(40460700003)(54906003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 05:24:24.2497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71010477-6942-45e4-3c7e-08db034b6a43 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: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6176 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756514533689787793?= X-GMAIL-MSGID: =?utf-8?q?1756514533689787793?= Move amd_pstate command line param description to correct alphabetical order. Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- .../admin-guide/kernel-parameters.txt | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0d8486325c9a..5f6a3a34251e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -339,6 +339,29 @@ This mode requires kvm-amd.avic=1. (Default when IOMMU HW support is present.) + amd_pstate= [X86] + disable + Do not enable amd_pstate as the default + scaling driver for the supported processors + passive + Use amd_pstate with passive mode as a scaling driver. + In this mode autonomous selection is disabled. + Driver requests a desired performance level and platform + tires to match the same performance level (if it is + satisfied by guaranteed performance level). + active + Use amd_pstate_epp driver instance as the scaling driver, + driver provides a hint to the hardware if software wants + to bias toward performance (0x0) or energy efficiency (0xff) + to the CPPC firmware. then CPPC power algorithm will + calculate the runtime workload and adjust the realtime cores + frequency. + guided + Activate guided autonomous mode. Driver requests minimum and + maximum performance level and the platform autonomously + selects a performance level in this range and appropriate + to the current workload. + amijoy.map= [HW,JOY] Amiga joystick support Map of devices attached to JOY0DAT and JOY1DAT Format: , @@ -7009,26 +7032,3 @@ memory, and other data can't be written using xmon commands. off xmon is disabled. - - amd_pstate= [X86] - disable - Do not enable amd_pstate as the default - scaling driver for the supported processors - passive - Use amd_pstate with passive mode as a scaling driver. - In this mode autonomous selection is disabled. - Driver requests a desired performance level and platform - tires to match the same performance level (if it is - satisfied by guaranteed performance level). - active - Use amd_pstate_epp driver instance as the scaling driver, - driver provides a hint to the hardware if software wants - to bias toward performance (0x0) or energy efficiency (0xff) - to the CPPC firmware. then CPPC power algorithm will - calculate the runtime workload and adjust the realtime cores - frequency. - guided - Activate guided autonomous mode. Driver requests minimum and - maximum performance level and the platform autonomously - selects a performance level in this range and appropriate - to the current workload. From patchwork Tue Jan 31 05:21:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 50603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2569478wrn; Mon, 30 Jan 2023 21:26:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXvgad8HjpMSGO8fAVIzyQu7RFdcD6a/QPuEPxna63giv1K42sy9OR0Bza9MCGlQbdYEJuw+ X-Received: by 2002:a50:ff12:0:b0:492:8c77:7da9 with SMTP id a18-20020a50ff12000000b004928c777da9mr50931136edu.9.1675142801042; Mon, 30 Jan 2023 21:26:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675142801; cv=pass; d=google.com; s=arc-20160816; b=yK41yEp/x+TLtK8DKeFgWIcnV9flHy2dhyKwb1yKW4t8rKE19VqI2HM1Wzidc6qaRA 6XrNn1NEktNGBHqv/sYbroP+TqKrpAu/C8aXuDsaOvPeY9Hu4pv0/zXJ2tKXGvcNkVnx 5sd9hAydqnQiWAHR6Rl8wRpIA2cI0j7KKDowOyxOp6xXSeXErwsZ0PR0Jt9zYycrx1ry 2V6/w1yrrYlXcDHEsQuInA17WVXYtzzAc6jhw1tquMkKmiPhbiBX2nk763TaVNhnAFcE bS7t7gU/RAW25u7hypcOjlAknjoqC2WcDRx3Dq1CjfYX/CIpl4yQiwHEp5GWhLNiTbhH Pkug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N1UfNsWUdZq5knJuCy+u7zeY0WlCV0QodY6FHXABrGI=; b=C20Yv2D4DChM58kIaopWDXbZG+DQbmerCvhW95HWCgE5JNHr/CRyHJFEiWXLsfO1BI 0FMpMoGAMoIZYvj2uuSsr1neLaDAREdq+vtxenQANsFarGL8ihMO7KfSwIRRSIUB3FVy hhfg+C7POrOoEnGZO1trsrgB3ci4GVhUAKWrDK/c3Jqj1sb0pdI8rtMzR5Dg0PyW8Geo wWmvZuuQO0432/l89UyVLEh4T1elrMJBkJ5QorbXEyabUb+PZ5RJz38/SFKc368+TETa sKT0lvrnvnHtXjkeqsrDuW6PpyjJEZF3wwLBEZ6z/OJM/s8oAioGZBCo7PNng7gBHBJM NDtg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=qizoNgwe; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eq12-20020a056402298c00b0046aee4c4ebfsi16852525edb.105.2023.01.30.21.26.17; Mon, 30 Jan 2023 21:26:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=qizoNgwe; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjAaFZN (ORCPT + 99 others); Tue, 31 Jan 2023 00:25:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjAaFZG (ORCPT ); Tue, 31 Jan 2023 00:25:06 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41AE21C591; Mon, 30 Jan 2023 21:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y1Y5dzLSnt/uugGQE4eeOMOcyftZxbPWtnQeL9wl1eMI3sNi18t3hR32rZROEUCqm+GIj0fjBzcuLQa9KCpihfojvS6ELzTuxpPzjwDK79Wci6mPzn/ykl/DBGt7AYVmeLxEphwlVT3xsUdUKn5I7FAQlhw2y74ijTBD+28UCD+9+j6/JZA3+FdJzVD+kK3CWO40s+p6i3ZaWxhs80jKUmAUOFLhebQfcLygABBjjZ6CWnxZRGla6KejEsP7ksQqzStPh6w14zLplEVe2boDQuOcubvxXnfNnaPv6owuwHwNaQ4+N6h8bDtVp4wJY7YrZPrgyPIOLoKZvKa/6P3HHA== 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=N1UfNsWUdZq5knJuCy+u7zeY0WlCV0QodY6FHXABrGI=; b=PuKlrAq1VyBrMzfSDXqxvu2kalos6/cf42ACbluaOAo0YzmQDUcFDGXirfCyoUGuSezApC4JdRa5STkUIuKDiJ+wQtEoTx9HovLijyJ19J8xb1sC1utmWG8dq2agCFhVywp7wxKbsJwayF6OJ4hHZ4LR0O16nFSRYaRj5lgmXWOBxL1Ixb2A2lgRhxjQbti6CpxkvZ9DNT7xwC7oC9H2U9Hn2z46qXJIqiGTNQvG4hNqro7QFS+kzV3R2H9zh2nm2xAox9CWwG90LBnhW9mbybbsaJfLHeMIyyPQLro6MCD3JqJtPC7O33HsYi71KE7jEVQZdZYakv80znMBsTeGVA== 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=N1UfNsWUdZq5knJuCy+u7zeY0WlCV0QodY6FHXABrGI=; b=qizoNgwehJHly0PJvYdCgKdNt0N81gQE0z8GyHbUsQ1iUl4NEFTOhVmGriQrV4J8jD3ntbW5VMnZgpgi79YzBSydDSuPiwihZkFgP0rQoG1O2vL5cAF7DBtYMMSRRRs9gmpK0E2Aoo5RIsT8xpJVlu1f7ihkU6vS6+cqY+IdsjA= Received: from DM6PR14CA0056.namprd14.prod.outlook.com (2603:10b6:5:18f::33) by DS0PR12MB7994.namprd12.prod.outlook.com (2603:10b6:8:149::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 05:24:51 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:5:18f:cafe::cd) by DM6PR14CA0056.outlook.office365.com (2603:10b6:5:18f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 05:24: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 DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Tue, 31 Jan 2023 05:24: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; Mon, 30 Jan 2023 23:24:45 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny Subject: [PATCH v4 5/6] cpufreq: amd_pstate: Add guided mode control support via sysfs Date: Tue, 31 Jan 2023 05:21:40 +0000 Message-ID: <20230131052141.96475-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131052141.96475-1-wyes.karny@amd.com> References: <20230131052141.96475-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT037:EE_|DS0PR12MB7994:EE_ X-MS-Office365-Filtering-Correlation-Id: b90b7c73-ad0f-43f2-e8c3-08db034b7a48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xoYjJMvxgvByZJ785wHIPhCt16dDdJf30b56u8m0wJEtOUi8p6kyxw16o64LpLzZ4S1/XPJXG1Di4+kHOO7heHgmNkxmRhvMaw+a66LdEvCZyarN8P23xExZleCjIW4Fg38fSsfo68w4IPlG73CN7AL6pNa56VZraqQtYnHh+CRPkJOqO3jYVW5USLtwst2SgVR+wvy2+B/nl0FASEwvvCbIXcOlDP7uAAuxive/b+8VgUbWWunPYriuK6LTpbPJeTVnJPwJZgj3lcs/dfbtMMCTB58gnVuyu8fEzEjYQbNWr5N0YbsV9Ca3eK0ngTf7+E0hYnJogwAE/JiV9Sa1S8N3tC3e8RqWBAPN5rixcmQdbq3eXjZGFVOOSSzbq8eW+WvNfn6vskHs65XqH0OkFOWMSucyuUnfeK7Esk1fcOJJYms6+UZEVYdFLeEsKH0IWyeviG/3jnvzydGSBpmCVX3X2uXaK7t2acLOA12MpGarzJ77l7mwXyM5OZUU5d6Bp49IKB66dHFJElv/lyOvHl0EoAy7vz4Ncjjv5fYza8J5+l3GAJsQVKFB8rBAkX5kAtCgs28I/7XxyG12fJmXlhknA5lRk/l0Cw+k3Pr3GcFGE1r8Oi6AMo8IV7bjkoaaYY15qjak/UDgKZePV2GEFhHFLLOlnQwhznZoLsUG6J1xk6HH/Npa/CFr0hB8l/nJyxGLAHfVARgPNZegxqZ5NZW7LFMy9CaV/9UUNcE0OCk= 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)(40470700004)(46966006)(36840700001)(36756003)(70586007)(70206006)(6636002)(54906003)(110136005)(316002)(82310400005)(8676002)(4326008)(5660300002)(41300700001)(8936002)(7416002)(36860700001)(86362001)(81166007)(356005)(82740400003)(6666004)(16526019)(186003)(26005)(1076003)(83380400001)(336012)(426003)(40460700003)(40480700001)(44832011)(2906002)(7696005)(47076005)(478600001)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 05:24:51.1305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b90b7c73-ad0f-43f2-e8c3-08db034b7a48 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: DM6NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7994 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756514537667744829?= X-GMAIL-MSGID: =?utf-8?q?1756514537667744829?= amd_pstate driver's `status` sysfs entry helps to control the driver's mode dynamically by user. After the addition of guided mode the combinations of mode transitions have been increased (16 combinations). Therefore optimise the amd_pstate_update_status function by implementing a state transition table. There are 4 states amd_pstate supports, namely: 'disable', 'passive', 'active', and 'guided'. The transition from any state to any other state is possible after this change. Only if the state requested matches with the current state then -EBUSY value is returned. Sysfs interface: To disable amd_pstate driver: # echo disable > /sys/devices/system/cpu/amd_pstate/status To enable passive mode: # echo passive > /sys/devices/system/cpu/amd_pstate/status To change mode to active: # echo active > /sys/devices/system/cpu/amd_pstate/status To change mode to guided: # echo guided > /sys/devices/system/cpu/amd_pstate/status Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 150 +++++++++++++++++++++++++---------- 1 file changed, 108 insertions(+), 42 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 48ab4684c3a5..6c522dec6967 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -65,6 +65,8 @@ static struct cpufreq_driver amd_pstate_epp_driver; static int cppc_state = AMD_PSTATE_DISABLE; struct kobject *amd_pstate_kobj; +typedef int (*cppc_mode_transition_fn)(int); + static inline int get_mode_idx_from_str(const char *str, size_t size) { int i; @@ -797,6 +799,105 @@ static ssize_t show_energy_performance_preference( return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); } +static void amd_pstate_driver_cleanup(void) +{ + amd_pstate_enable(false); + cppc_state = AMD_PSTATE_DISABLE; + current_pstate_driver = NULL; +} + +static int amd_pstate_register_driver(int mode) +{ + int ret; + + if (mode == AMD_PSTATE_PASSIVE || mode == AMD_PSTATE_GUIDED) + current_pstate_driver = &amd_pstate_driver; + else if (mode == AMD_PSTATE_ACTIVE) + current_pstate_driver = &amd_pstate_epp_driver; + else + return -EINVAL; + + cppc_state = mode; + ret = cpufreq_register_driver(current_pstate_driver); + if (ret) { + amd_pstate_driver_cleanup(); + return ret; + } + return 0; +} + +static int amd_pstate_unregister_driver(int dummy) +{ + int ret; + + ret = cpufreq_unregister_driver(current_pstate_driver); + + if (ret) + return ret; + + amd_pstate_driver_cleanup(); + return 0; +} + +static int amd_pstate_change_mode_without_dvr_change(int mode) +{ + int cpu = 0; + + cppc_state = mode; + + if (boot_cpu_has(X86_FEATURE_CPPC) || cppc_state == AMD_PSTATE_ACTIVE) + return 0; + + for_each_present_cpu(cpu) { + cppc_set_auto_sel(cpu, (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); + } + + return 0; +} + +static int amd_pstate_change_driver_mode(int mode) +{ + int ret; + + ret = amd_pstate_unregister_driver(0); + if (ret) + return ret; + + ret = amd_pstate_register_driver(mode); + if (ret) + return ret; + + return 0; +} + +/* Mode transition table */ +cppc_mode_transition_fn mode_state_machine[AMD_PSTATE_MAX][AMD_PSTATE_MAX] = { + [AMD_PSTATE_DISABLE] = { + [AMD_PSTATE_DISABLE] = NULL, + [AMD_PSTATE_PASSIVE] = amd_pstate_register_driver, + [AMD_PSTATE_ACTIVE] = amd_pstate_register_driver, + [AMD_PSTATE_GUIDED] = amd_pstate_register_driver, + }, + [AMD_PSTATE_PASSIVE] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = NULL, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = amd_pstate_change_mode_without_dvr_change, + }, + [AMD_PSTATE_ACTIVE] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_ACTIVE] = NULL, + [AMD_PSTATE_GUIDED] = amd_pstate_change_driver_mode, + }, + [AMD_PSTATE_GUIDED] = { + [AMD_PSTATE_DISABLE] = amd_pstate_unregister_driver, + [AMD_PSTATE_PASSIVE] = amd_pstate_change_mode_without_dvr_change, + [AMD_PSTATE_ACTIVE] = amd_pstate_change_driver_mode, + [AMD_PSTATE_GUIDED] = NULL, + }, +}; + static ssize_t amd_pstate_show_status(char *buf) { if (!current_pstate_driver) @@ -805,57 +906,22 @@ static ssize_t amd_pstate_show_status(char *buf) return sysfs_emit(buf, "%s\n", amd_pstate_mode_string[cppc_state]); } -static void amd_pstate_driver_cleanup(void) -{ - current_pstate_driver = NULL; -} - static int amd_pstate_update_status(const char *buf, size_t size) { - int ret; int mode_idx; - if (size > 7 || size < 6) + if (size > strlen("passive") || size < strlen("active")) return -EINVAL; - mode_idx = get_mode_idx_from_str(buf, size); - switch(mode_idx) { - case AMD_PSTATE_DISABLE: - if (!current_pstate_driver) - return -EINVAL; - if (cppc_state == AMD_PSTATE_ACTIVE) - return -EBUSY; - ret = cpufreq_unregister_driver(current_pstate_driver); - amd_pstate_driver_cleanup(); - break; - case AMD_PSTATE_PASSIVE: - if (current_pstate_driver) { - if (current_pstate_driver == &amd_pstate_driver) - return 0; - cpufreq_unregister_driver(current_pstate_driver); - cppc_state = AMD_PSTATE_PASSIVE; - current_pstate_driver = &amd_pstate_driver; - } + mode_idx = get_mode_idx_from_str(buf, size); - ret = cpufreq_register_driver(current_pstate_driver); - break; - case AMD_PSTATE_ACTIVE: - if (current_pstate_driver) { - if (current_pstate_driver == &amd_pstate_epp_driver) - return 0; - cpufreq_unregister_driver(current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state = AMD_PSTATE_ACTIVE; - } + if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX) + return -EINVAL; - ret = cpufreq_register_driver(current_pstate_driver); - break; - default: - ret = -EINVAL; - break; - } + if (mode_state_machine[cppc_state][mode_idx]) + return mode_state_machine[cppc_state][mode_idx](mode_idx); - return ret; + return -EBUSY; } static ssize_t show_status(struct kobject *kobj, From patchwork Tue Jan 31 05:21:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 50604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2569632wrn; Mon, 30 Jan 2023 21:27:21 -0800 (PST) X-Google-Smtp-Source: AK7set/XG1EVnoerQHvWBnRbpkOi526Lis9VhaGrYlaMeM2p43WOXwKKz2ssVW+AYENQiydmLOkH X-Received: by 2002:a17:906:4d5a:b0:88a:723:f646 with SMTP id b26-20020a1709064d5a00b0088a0723f646mr4440438ejv.75.1675142841082; Mon, 30 Jan 2023 21:27:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675142841; cv=pass; d=google.com; s=arc-20160816; b=UrAgPidL7233VbE3FXFHrZuTxkmslcbVe/LoEL6jm8AQPf99ucjr0ptffVmwjq/T1c xHS89tuY3fpoDwUgNACu9g5L7ZWVvXhEQCFApULnyx3oEEv8cz5d9DZXbDzZafbgzawn TdfgqzuMDyia1IRC0B1wNVgRIPL+fzDpC5vvrIRQMRDqw31pYFqlQVVGWCsgegOiRa1X j5eAGGL6m6y5dl/mhmXIThlQBDmPk8v7q8c24oRRo6FepZV12GyMmIgTJ+ZqKqSa5pXr Z81WUA8+OFgLYOgu55d0h1Feb3clefa0v7sA5zW2+oqF8X+O9qnHeTiFiZGafry98LaQ G9Cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=soJKWscNntUtGILPE7LnMJipVFI6FVSiNDMc4q/beTk=; b=MIDWimI/HbgIuBqW+bTFnXOly7+4GyYWetfdeYbcWB6xSqX4T6m3zgCxgLrzx435n4 TosPyE0/UpYFvKhKJt90Abh5+0uKYnGHqWdnljgHRk6DErpNrFgQdjUQ3yP78QaNRx64 8ndyYWq7E6/VJO6KCT7xqDeSNjtGvEGJ05fgDRwphp2ayH6IJlbf5mx4nDJI28fRYqlr ZjvDxWxY/23ouBG6LpBnld1Sxx6AQG1U2uXsp6/yg+s5bjfEEnwKgfStJPci0QzErx9a q0kTJFKEr9pZybbL97sBiu64b4ijsMg2RB8j00bFlkqQl22PG52DA7S3WQ1Yl8iUAbkJ XCRw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=j53OdXrP; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id et4-20020a170907294400b00886e4a97694si6404602ejc.863.2023.01.30.21.26.57; Mon, 30 Jan 2023 21:27:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=j53OdXrP; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbjAaF0P (ORCPT + 99 others); Tue, 31 Jan 2023 00:26:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjAaF0J (ORCPT ); Tue, 31 Jan 2023 00:26:09 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563EB3646B; Mon, 30 Jan 2023 21:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nK5EIGsfdsh2E/L4qPIqK0FwP+AKFjSE6a5N0bSFoNMTomtvWfI+d0mAGmhIZcId9Zp4LMu+UG20TzqoRtF0lNvs69SWyKhpYpAeag9kvsf+duRM1q9Jw63xTe/dOz4PerJ6L5ZwE1lDvSe2DAEX6cTnLQ1QPbGlzFz28BXtNgTsm+XtVLSA6SRTI87ekPdS6gEt7eZbHuB8qAcWJso7M8VlE2bjcsQAKujmmyfTuRbTHpCVwRKbeWwZ8XVSGZX1zXMW8eVX7mN7/WWzKsAfBC8+dz3jjVsQZSLmpSC+zaJt259OQEurX3LWU7YabGBlz5n3EjUTiw6u3Uw5AzeloA== 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=soJKWscNntUtGILPE7LnMJipVFI6FVSiNDMc4q/beTk=; b=Nr+dM1J2sGaP+soFWNtzp+/yo9wEZxTWDj/IfT03wExXOMM88aOLTpc0dxPiZk6nAiuRbZuWFBf6HeERxfEajjJcJI9GK8tUR3WIxejL1NBPD9t5HMQ/ke+QrvzKasArNMPpgZxdSH6ipoTNTHT6rScDFKeVE0p4Lr8ByisCK5C+oXOanKyPkfVJJZ6B+LT3aBPnVT3pwMXyI2dEt+MBtr8OIOwnybXcCzvnWrsLkXeX8e7sZ1ndQ4io1s2U/STyDhMcS4ebzhvvqBREzoqesSWPNDRF3G3s2SMs7z8fR/qzQhpQbCMYoPM64r2w3IWzIENG2I2m6QuyApg/NCTHNA== 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=soJKWscNntUtGILPE7LnMJipVFI6FVSiNDMc4q/beTk=; b=j53OdXrPQgldr6GIr+AzYAUtm+j6frDuC/at9+LIKKeHRJ2cyWm9i9m4v9gsk4H8WKSFaAOYG9123pGpDJhr1c3vCq6DFHD9PGJmyvFpLq8azgrZi9d/SWLGMJhBsy3OlcYx2NsiZ0zQy+0ql6Rtu1cLPc9ZMa6BVmDBJ3uLI1I= Received: from DM6PR02CA0123.namprd02.prod.outlook.com (2603:10b6:5:1b4::25) by IA1PR12MB6308.namprd12.prod.outlook.com (2603:10b6:208:3e4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Tue, 31 Jan 2023 05:26:06 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::2d) by DM6PR02CA0123.outlook.office365.com (2603:10b6:5:1b4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 05:26:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.30 via Frontend Transport; Tue, 31 Jan 2023 05:26:05 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 23:25:09 -0600 From: Wyes Karny To: Rafael J Wysocki , Huang Rui , Jonathan Corbet , Viresh Kumar , , CC: , , , Bagas Sanjaya , , Len Brown , Robert Moore , Borislav Petkov , Ananth Narayan , , Tor Vic , Wyes Karny Subject: [PATCH v4 6/6] Documentation: amd_pstate: Update amd_pstate status sysfs for guided Date: Tue, 31 Jan 2023 05:21:41 +0000 Message-ID: <20230131052141.96475-7-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131052141.96475-1-wyes.karny@amd.com> References: <20230131052141.96475-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT003:EE_|IA1PR12MB6308:EE_ X-MS-Office365-Filtering-Correlation-Id: 42be5acc-4bb2-4d0e-890a-08db034ba6b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q4tIpauU7JZZJbRukX/39viEJ7tFsP+7ss7cL37FJKVV19EDIw5nt2vz/knoY+kuln3EhI6891W9JVt8NWIcsev4Bz8SF3VsiFs7bIKxmf5aFZ6FZR66Ggct1HKGScsvuceBqQaNGVQ8zWVo+xy2YSWQxyS+a/RLBUNXScuyYxUQ/FwUxmKUGEnQcIQnyZVz6mhH+FFl9mzBJsqcTgk4TFBJ/EEQtaNIaBE1osQY5mxAEbqbaenJWLhhIqfPzDZveGPafbU1kp4X9LCZ6QEIaxyApO8Fk98nMk9Km74cxxQopDf450py9+ObMNGGKyGBs/O52iKxxPMMuQrKfRgc2j/4cAR9m0KOxHy+BdE4U+xBKdoszpgwAFtFGOt84xqL6GetQv0w1YxnuMWhLwTCPT9i+H9xLIgCq0X7b6CTqIT45Ob2jfRBREtiElf8uH8wKvgmgDlLyJdADBlNxaygWVkDP3ikNuTHgZd7jtR+HZcBSzn8yJEqyAUM8ctmdbg9eqyM5epPYg/GQCvfT5dF+QbfRCn5spxcl9m7l0U2WpgzIshMD9Dfp2A8QNgmWLFp/msxL0jxhXLUVGVyTHXT4YBPKEOOgYXWG5cigJibDOUTzwps/EkoaFc/pzr9+/bqxlS3VZ+hcCjvsyFWTUpIjNY2Cp8RN9pZnZJYEkgf6Sk8hfjXLHkIXljfjO1ogw/qLzpzCpjyFtPB0syzuLJxtZgh9SFtcU5XYJ2M41m7SpI= 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)(136003)(346002)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(40460700003)(316002)(110136005)(54906003)(83380400001)(70586007)(8936002)(41300700001)(70206006)(4326008)(47076005)(1076003)(6666004)(8676002)(478600001)(186003)(336012)(26005)(16526019)(2616005)(7696005)(356005)(6636002)(426003)(82310400005)(81166007)(40480700001)(36860700001)(5660300002)(7416002)(36756003)(15650500001)(44832011)(2906002)(86362001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 05:26:05.6490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42be5acc-4bb2-4d0e-890a-08db034ba6b3 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: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6308 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756514579640028038?= X-GMAIL-MSGID: =?utf-8?q?1756514579640028038?= Update amd_pstate status sysfs for guided mode. Signed-off-by: Wyes Karny Reviewed-by: Bagas Sanjaya Reviewed-by: Mario Limonciello --- Documentation/admin-guide/pm/amd-pstate.rst | 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..56a3d11f51a5 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.