From patchwork Thu Nov 10 17:58:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp294454wru; Thu, 10 Nov 2022 10:08:02 -0800 (PST) X-Google-Smtp-Source: AMsMyM7H1YRba5VQAwKkrei8RMYbPVNQKtQd71AB47Y8C0OWGmGF7pAHlN56+JuQ731zOolWSVih X-Received: by 2002:a05:6402:cb7:b0:461:17e9:4ea3 with SMTP id cn23-20020a0564020cb700b0046117e94ea3mr2901649edb.49.1668103681844; Thu, 10 Nov 2022 10:08:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103681; cv=pass; d=google.com; s=arc-20160816; b=UPRypo0FRFqGb8EQEcHRW1dKd1Oh4S2TahKmOeMwVloN8eE+KukWjEszcX1VHRcVq+ mdLf+YugV29eFrCeoB1cUqHUS8EWvtUsDNSPB629Aym3wjV+ZonVetrA0UsebQHzt2u9 QmWwPd3KjduqkcK3pDkHfOHDMiqIW1tJBs7HWi5ZWhj3OSGS6XGKgAOEBzfwGl8BazNo qtRkjOHnkopKXw0ApINz1U+bbCl/0lxEgJBnM1doYvPumOP7mV1K4yvpmKZucGz4nPov ftryy/av9ZHiv3B6OR2s5mWwFjFsl1TT+8zOA70D+KXe1i9lq8Ou9JCc7JjisAinuiKh /a4Q== 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=Ez8uo72CVG7SAWYMv0jK3unq2c24Hz4ZH5D21jPoAHg=; b=jrDmDsbz0EDKECoqnUpNRmvmlUppL499pn4JIlADq+vqvAjk894FOQEUl6CBHoIFzy EOjZotx+uzkVzal3qhBghjG28eKkVe33Ut8D9rR1bzmdg6uH4NJonfUnokNjyvpkSwy7 nccUw886FSpC3qAJkcJKYlLhzDR10p/gkd9sugp7N/K/qCLIVrpqBfXKW8cGKGfniBva iK4V02pT1pCm3pPdAA8CrnCczSMjTzkKw1jtOHpvXG6VQMz9eSXH2pQ4IrH7ENJJ0gkC Yd2rldyGxQRpdVamhEWV1mblA84nYCLyr9bElT86juEsQtzBVDjTTOpulStd8GNELXLY NUXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=3r4LC6K1; 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 sb6-20020a1709076d8600b007ae54733c69si17060437ejc.542.2022.11.10.10.07.07; Thu, 10 Nov 2022 10:08:01 -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=3r4LC6K1; 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 S231529AbiKJR7b (ORCPT + 99 others); Thu, 10 Nov 2022 12:59:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbiKJR7W (ORCPT ); Thu, 10 Nov 2022 12:59:22 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBFF64730C; Thu, 10 Nov 2022 09:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNjVTPrZQ12fLE3aOrDRFAchMpnRqXMrrOKGjFlmF2d59XJQbA8dalOnc7bj+W43wtFzaX0Fo0omRscuILdTp1j8ASRlwj4B7yo706qI9YvSk9Bzuh3oNh2AI/zd6HfHGDYzmSWj4W2gr4KIlwstoJtFkdV4OKICUf5JF86/ygJLxjJN8Jfb6CTZESHT8Rb8wUSKEn1WoxbI85B6hnqzxlcx/b5LYlWsYLpk4Tb2w7OWWA2z/cbkldTVOSM1qWBHOzeB0qso10hFBaPFsMSV9HgbDwa7z9jP/kopL0UFQRlQV/4oNUSj2+y7A9o7rDrurIsIlF+7vO30Jk3/ZG/e2A== 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=Ez8uo72CVG7SAWYMv0jK3unq2c24Hz4ZH5D21jPoAHg=; b=XUwaktPMakn8cZ/UJWG85HrkGPnkUI4XZuHHvVfzT9iQdrShNab3/+fwJ2Gc8QE4ESwum//IyCBa8k5hNDpUfvBEhSM0plcFZcHvibZG1skGhOf6QTTZN7k9BvvmD1+f5Fr9p+k4Hbl8g00qEk3qauYxSteyADmU8ymcvlSEBHTyHSm0AGi8okQNYphXaAbY3FyAFMLWfFTJTh2BU+fXTQGoXVjgIWAWJwQKpu1KoDWABB0NGVuQ4RoZ22QoKp1UojZCAbtLUOmlii7x+wsXHK7TRjbxldiEZGtywcb2bG2D8lrzHBB+xvRJtXKrNWDzIgFoJe+HCAecB3CTI+KLmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=Ez8uo72CVG7SAWYMv0jK3unq2c24Hz4ZH5D21jPoAHg=; b=3r4LC6K16LCRZmCz5qheMzMvMgN07LtSNm+cKBngrZ0u+HgcCiQ5sFc811r4RUpq68J4aXxrLAZNPVu2Ko+MAFkZ/cfjhf49/h8uWyKxKnkz3ISRTJ94dRr7VqvcZK1kIdvwzNmPeIWQAfhaA8LZdUNEZ7HeIQE6lyk3I1T5/kI= Received: from BN9PR03CA0396.namprd03.prod.outlook.com (2603:10b6:408:111::11) by MN2PR12MB4301.namprd12.prod.outlook.com (2603:10b6:208:1d4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Thu, 10 Nov 2022 17:59:16 +0000 Received: from BN8NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:408:111:cafe::5f) by BN9PR03CA0396.outlook.office365.com (2603:10b6:408:111::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Thu, 10 Nov 2022 17:59:16 +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 BN8NAM11FT051.mail.protection.outlook.com (10.13.177.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:16 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:12 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 1/9] ACPI: CPPC: Add AMD pstate energy performance preference cppc control Date: Fri, 11 Nov 2022 01:58:39 +0800 Message-ID: <20221110175847.3098728-2-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT051:EE_|MN2PR12MB4301:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f0bf5b0-ce77-44cd-82bf-08dac3454873 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y1lxgkeVpsMIRNERdLK8NOBHvrhZLwMMp4h6wnj0fmi4AyRqaAAnS6vepKxXc6FRnPqn4NGKCzDWE/Otjw1IsPIbwkBK1Nvo2m4S2LZ97Kf75Wwsx9llR7Lone6epqZrsR2B8E1OR2jTRcLl3EvPhPKiCDEhNuqge1KHrBxGy21EIPJY7zsyofO7xd3Lzkx6vfuA81mwWRsGN5J9gyJ0j4PGo/HuQgXR75x0ImtEi5NFb2/brNI1+BjS4mqoRXwM8LoUb96pGcBskIe3iO1Y7a7Xyt101jBCZ+IXeXNgOPke7BL4viaqtDOU5OJtPF21KFsGbkB02t2rzr3gBcTcI0VdXcHgphclOPuzG69Ky8B29L6jdqk+wj0kwHyb4foxsn4Ubn695NbVhrXmmLgx4PRokaH4Y223D+3REY48eX9HhglO0E+R5DVeavVRJvcJbH+3xlMxsVBblQ17Nj2nv+Rat2nRxifan3O1e05qbblVXZbuSCyOMQ/8BJnrZjdoquxI1Sm8/nUQ7m95Ps9L4rIORn2o2NT2g0fvQNzyJu5aaLYShYzO0AFcKzzChOOS+8Dx5xQ0314QzzNIt+XFcOBm1WwvcTyZv5ckGENKcBZOv4lT7uK1GYjF6XEdcKwGHHDDAceFcjh1PDDCmFNvR55Q5UPFc9tM3OQ/GY6su+TXsQfiN19inBNmDx7oHfkVblhSGXpdEpE4T4eHHWTxZ9StP4Q0eTMd2E3gCS2jq62RBoEmkiYh31WbidgbcTjCgS5JJ8O9XDVBfc9uKPBOeLFqw4tfWv1GUJwqMpnX8PTBlXC1St1kbyncw5V6grnW X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(478600001)(2906002)(2616005)(1076003)(36860700001)(16526019)(36756003)(186003)(336012)(6666004)(83380400001)(81166007)(82310400005)(356005)(47076005)(82740400003)(26005)(4326008)(40460700003)(7696005)(426003)(8676002)(40480700001)(70206006)(70586007)(8936002)(86362001)(316002)(5660300002)(41300700001)(54906003)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:16.1567 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f0bf5b0-ce77-44cd-82bf-08dac3454873 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: BN8NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4301 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133486299621247?= X-GMAIL-MSGID: =?utf-8?q?1749133486299621247?= Add support for setting and querying EPP preferences to the generic CPPC driver. This enables downstream drivers such as amd-pstate to discover and use these values In order to get EPP worked, cppc_get_epp_caps() will query EPP preference value and cppc_set_epp_perf() will set EPP new value. Before the EPP works, pstate driver will use cppc_set_auto_epp() to enable EPP function from firmware firstly. Signed-off-by: Perry Yuan --- drivers/acpi/cppc_acpi.c | 114 +++++++++++++++++++++++++++++++++++++-- include/acpi/cppc_acpi.h | 12 +++++ 2 files changed, 121 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 093675b1a1ff..37fa75f25f62 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1093,6 +1093,9 @@ static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf) { struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); struct cpc_register_resource *reg; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = NULL; + int ret = -EINVAL; if (!cpc_desc) { pr_debug("No CPC descriptor for CPU:%d\n", cpunum); @@ -1102,10 +1105,6 @@ static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf) reg = &cpc_desc->cpc_regs[reg_idx]; if (CPC_IN_PCC(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 -EIO; @@ -1125,7 +1124,7 @@ static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf) cpc_read(cpunum, reg, perf); - return 0; + return ret; } /** @@ -1365,6 +1364,111 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) } EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs); +/** + * cppc_get_epp_caps - Get the energy preference register value. + * @cpunum: CPU from which to get epp preference level. + * @perf_caps: Return address. + * + * Return: 0 for success, -EIO otherwise. + */ +int cppc_get_epp_caps(int cpunum, struct cppc_perf_caps *perf_caps) +{ + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); + struct cpc_register_resource *energy_perf_reg; + u64 energy_perf; + + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpunum); + return -ENODEV; + } + + energy_perf_reg = &cpc_desc->cpc_regs[ENERGY_PERF]; + + if (!CPC_SUPPORTED(energy_perf_reg)) + pr_warn_once("energy perf reg update is unsupported!\n"); + + if (CPC_IN_PCC(energy_perf_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, energy_perf_reg, &energy_perf); + perf_caps->energy_perf = energy_perf; + } else { + ret = -EIO; + } + + up_write(&pcc_ss_data->pcc_lock); + + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(cppc_get_epp_caps); + +/* + * Set Energy Performance Preference Register value through + * Performance Controls Interface + */ +int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) +{ + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); + struct cpc_register_resource *epp_set_reg; + 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]; + epp_set_reg = &cpc_desc->cpc_regs[ENERGY_PERF]; + + if (CPC_IN_PCC(epp_set_reg) || 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; + } + + if (CPC_SUPPORTED(epp_set_reg)) { + ret = cpc_write(cpu, epp_set_reg, perf_ctrls->energy_perf); + 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_epp_perf); + /** * 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 c5614444031f..a93393b05171 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -108,12 +108,14 @@ struct cppc_perf_caps { u32 lowest_nonlinear_perf; u32 lowest_freq; u32 nominal_freq; + u32 energy_perf; }; struct cppc_perf_ctrls { u32 max_perf; u32 min_perf; u32 desired_perf; + u32 energy_perf; }; struct cppc_perf_fb_ctrs { @@ -149,6 +151,8 @@ extern bool cpc_ffh_supported(void); extern bool cpc_supported_by_cpu(void); 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_caps(int cpunum, struct cppc_perf_caps *perf_caps); +extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable); #else /* !CONFIG_ACPI_CPPC_LIB */ static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf) { @@ -202,6 +206,14 @@ static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val) { return -ENOTSUPP; } +static inline int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, boot enable) +{ + return -ENOTSUPP; +} +static inline int cppc_get_epp_caps(int cpunum, struct cppc_perf_caps *perf_caps) +{ + return -ENOTSUPP; +} #endif /* !CONFIG_ACPI_CPPC_LIB */ #endif /* _CPPC_ACPI_H*/ From patchwork Thu Nov 10 17:58:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp294224wru; Thu, 10 Nov 2022 10:07:35 -0800 (PST) X-Google-Smtp-Source: AMsMyM74QFeE4MpQljM62F9GC+edwZxWtmlu7O40BO/LHdtcjuhQLDKVGDaJAWC4eM88CpDJQgEJ X-Received: by 2002:a17:902:d48a:b0:187:2b1d:10e2 with SMTP id c10-20020a170902d48a00b001872b1d10e2mr52958934plg.86.1668103655120; Thu, 10 Nov 2022 10:07:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103655; cv=pass; d=google.com; s=arc-20160816; b=kYpGKe/Cix8C3OjXWBjpkd5QdfWJJt3qTLwWl8uqBEbs6wTT574Wbg61daDF3O/UJ1 BXwZjiZWuDUyRv0x03a3yg0wKdrHl3LYYttK8gWcAUnuzVza1pQk3JTaUPCAgd2Me2mC vWj81/aIftovB0O/n7A+zaR2RzXqKVbwEEgJ43IBQScT75keQGpgWiahGH/28MRkWd0y cR3Y22vU5NDIdXh9mfSNGiBdvP1XhqenC+LzlUOK0Oop9Nl4Yqzqla7khud8xps28+fR zDju82qBPQ3VZgQUtF1mG4twwGC0VwLjr3I0UDCJm0IZJNFPK93XfEANQPko/zHSOeU8 u5cw== 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=XIaIq+OPQdQhhx7Im5ObgwhaWDiNSceNa7rhrD8XXXk=; b=QMyNH6ZcrfaYeNzFLkUyjIb/rm0iC4OsucqqAPpyb/WqEa3QQL4dB8AQae8bFARqru N0kgM/Nf1YIWhF1CVnA7BKPCGcKrvjJZloNEcwFsXhKIWf0MSlh0xIaY4h1HGPWUFLT9 lu7R1k79wFhd8z5U+hMMynvUDVMJlL4M5uU7v/ETe4s/nhYnyVBEddwT+eqlq2Ad+jTF DjDpg9COarIGme0l8uUdM4ORE69BVr67YB/obvYEsJ2Ae+N1SPCcy1OdsxEYN6dpk6at o9jZnSrDxLN8R3BjJw9qE8dKlwWSTFLFpwS/qyIlDhL6iY3EgtcnmTpjh7n/ImNCivmM MlFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=W3PDm0ZO; 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 n6-20020a1709026a8600b001786f5de8f2si19800118plk.95.2022.11.10.10.07.21; Thu, 10 Nov 2022 10:07:35 -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=W3PDm0ZO; 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 S231626AbiKJR7f (ORCPT + 99 others); Thu, 10 Nov 2022 12:59:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbiKJR7Z (ORCPT ); Thu, 10 Nov 2022 12:59:25 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8d::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE77C45EEF; Thu, 10 Nov 2022 09:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ih4KWc6xTA806J9+SwZsd0x8JzN53XaD94jyeBXJq/b7eVU2NK2SzE+o5HtrZyUSe6UO9MY7xCFRnG/Ym7glzDzkXsSEWOZuvnkHhLGlqfsGSg5ZtJWDrDVR41GyxA705Ddpj28KiK+kqw1g4myb0/l/hKM4mYmiltApTaFnNvEwJlB24DpCOOIXzfkAtGT2dIBP8RP+EPm/WC0Yw+QOwbVJcfRjATwQz0KNjTFx7WODL4wb1vIaYebtBm2PGfIIHB/epNBTu4pBxAqdlHjatSxyoAlCMxuDxDCn9zdWXBrb7cDesHShAmcbUPK6M7GMFV2iKBokUAeycZHHG8N0tg== 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=XIaIq+OPQdQhhx7Im5ObgwhaWDiNSceNa7rhrD8XXXk=; b=geTIajeAaFY9ify1wW/KBt8st7zVy0dAIFHkCqk3nTFyzQ8yQEU6ibEdSrV5vSqAM/9zuuCV1/12jkB03QMKIKUnv0uRBNcOnK/Y72ccFcP5niXXuQyBCuASzyIyq2MMy0iLtesb4GvKUgubPv5SH33ZyWIjksYnSbslEUydLylUqMHiH5eno/DJsdlOa95CCdIW0LbsyTbG9oQwo9c2FcKWtdUGY52zKdwLdV+QGGXs6AqpEsJ3VbJwKZaSdwKnog0dEhepoxw6Dk1jmKxNcelpD1C2NfFD3MfeyZkZA0Hh0EAEhSV7/OpvR2sJ8zQNmUtB8k5V031n8YnL5koPfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=XIaIq+OPQdQhhx7Im5ObgwhaWDiNSceNa7rhrD8XXXk=; b=W3PDm0ZOnQz0j3ED+fq69yRChy3wxciT7At6P3DsXVxxkFufNLbK75GzyRPKeQWCxINN0rPay+FOSC01gcP/akzps3Fqs2GSN9xbACnFXn6qUTvDwMkpTe9ZxBrl0na3pME/m1iVExnbMG+XeXiWCjIslI4kAiirt+niP9GlDrE= Received: from BN0PR04CA0035.namprd04.prod.outlook.com (2603:10b6:408:e8::10) by DS0PR12MB7778.namprd12.prod.outlook.com (2603:10b6:8:151::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26; Thu, 10 Nov 2022 17:59:19 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::51) by BN0PR04CA0035.outlook.office365.com (2603:10b6:408:e8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:19 +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 BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:19 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:16 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 2/9] Documentation: amd-pstate: add EPP profiles introduction Date: Fri, 11 Nov 2022 01:58:40 +0800 Message-ID: <20221110175847.3098728-3-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT009:EE_|DS0PR12MB7778:EE_ X-MS-Office365-Filtering-Correlation-Id: 1317a143-6da2-43f0-4c18-08dac3454a9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M/NIRFtOHWl1IvFyoEGx+CmsybKKC3vZRX9hGvmg8UJ6CnhD/Jhq21BnHp7zhVl/HtLdU+JQGetNqsCk+lWQhNbNBA6DuBrQYULhK7T3VQG7orc4IF4losZ5fpGzGVtKtTx5HQLXvSeKNLehGLJmvDpaZ97gExx5XHmAZVvTspylbKNuUDy4whr/LZw6gjgu8SvzwF9m9XS3/+hmcziftXdx501VPq+pXlJKWyjwfZKgdZ5kOhr1q63hgIGfOwo5NRUSprzANIfaQ4YYf61Muo1b6YPh9sPypYlLIn0bChN5UcDKDLfA/oDRT5+nrB91oCL2xEwILRqGrz0Mk1Xwvyuy2xNo9fUHYHIn+UPoV53V6i4h5s6JoejPDd4oJRVg469P+FZ77RJMkWIbzQ42nBVERrICiL7DOGrL8P2OMivtRamuj35F2mNcxvikCYxoyAyftULR/0A1WERV8RUjnOev3wNyeDgO3gkU8zVr7dpwiQsWYtwTnb63eqz8gr4GYSIAagz4g04yFlnpV8rITcOHp4AGkzQrENM66Zr2B29kMsgdc530ITzhzcEYaz31QoHJO+hw5u+wf6tJ9v9kNBi2wJ7fkt9VZcoXqma3gwwdXQhbboXVF8+tNxPJWyEwdl7MlP06H9BhxkyDl6uNwBG3I3a1Bqz8pp3SPfUNgR1lOETMUKTHKxX2EmQomiTN5xePLn9/prfD3OHr+SoS21mekkNHgF3rTQbZ23rhw86eX+BkUuHvtGx1UXk8fQz2izh2MAcbCovtOjDfjsfBw11lAh3bTgni4pUn5lze0QoiaeEADmnlp+TiIA2FUGYP X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(8936002)(5660300002)(82740400003)(8676002)(41300700001)(7696005)(70586007)(4326008)(2906002)(83380400001)(316002)(36756003)(40460700003)(86362001)(110136005)(54906003)(26005)(40480700001)(82310400005)(478600001)(356005)(81166007)(6666004)(70206006)(16526019)(336012)(47076005)(186003)(1076003)(2616005)(426003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:19.7925 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1317a143-6da2-43f0-4c18-08dac3454a9e 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: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7778 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133458532468002?= X-GMAIL-MSGID: =?utf-8?q?1749133458532468002?= The patch add AMD pstate EPP feature introduction and what EPP preference supported for AMD processors. User can get supported list from energy_performance_available_preferences attribute file, or update current profile to energy_performance_preference file 1) See all EPP profiles $ sudo cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences default performance balance_performance balance_power power 2) Check current EPP profile $ sudo cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference performance 3) Set new EPP profile $ sudo bash -c "echo power > /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference" Signed-off-by: Perry Yuan --- Documentation/admin-guide/pm/amd-pstate.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 8f3d30c5a0d8..e7488891b12f 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -262,6 +262,25 @@ lowest non-linear performance in `AMD CPPC Performance Capability `_.) This attribute is read-only. +``energy_performance_available_preferences`` + +A list of all the supported EPP preferences that could be used for +``energy_performance_preference`` on this system. +These profiles represent different hints that are provided +to the low-level firmware about the user's desired energy vs efficiency +tradeoff. ``default`` represents the epp value is set by platform +firmware. This attribute is read-only. + +``energy_performance_preference`` + +The current energy performance preference can be read from this attribute. +and user can change current preference according to energy or performance needs +Please get all support profiles list from +``energy_performance_available_preferences`` attribute, all the profiles are +integer values defined between 0 to 255 when EPP feature is enabled by platform +firmware, if EPP feature is disabled, driver will ignore the written value +This attribute is read-write. + Other performance and frequency values can be read back from ``/sys/devices/system/cpu/cpuX/acpi_cppc/``, see :ref:`cppc_sysfs`. From patchwork Thu Nov 10 17:58:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp294391wru; Thu, 10 Nov 2022 10:07:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM6DI0Oxjc1tZY2EOHrRLM2qEPw8in5njLRGnZUe+edO3bW3fey/uxZHqOY5ZL/bLCAhVPZ3 X-Received: by 2002:a17:906:38cd:b0:7ae:1d11:bc99 with SMTP id r13-20020a17090638cd00b007ae1d11bc99mr3275195ejd.762.1668103675048; Thu, 10 Nov 2022 10:07:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103675; cv=pass; d=google.com; s=arc-20160816; b=R7H0k4K03EIJpoloXD/rUOtRasrSssJ5hkRRW/5Bjry+g23oA2gOB6VHDavksQReW5 GIpVKMlNMV8rfuLfa3uYO60skkXORV6fbzzQHa/wsrSGXDMzkAO7qqQur4PrMZ/JcMpZ 3LUcGxwa26b4DutsARANvwQA4NSQljAriw+q/INVK+oKn0+aBm/S+q+lgSUlrPKfqQ4e sQCckM+YB2GebTnGqBymieZUxcmt4gA/S/DFaUqep1NMCL3cPku+UZk4LB48bFjKf0jY 2v9JFmb/cq2+nxqvpi5Dg/4a9iZ7NI7lyfOw48o+oIR+ySnNVgDsZnuFO7hhW8UqN9La RP5A== 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=hPT0UmJdFUfvE2v/nVV6GqC34565KJP4VI/WPmG7sMA=; b=GS58l+gHQshhg03XLIwd1weTsplBXDxo1tQCxTjbb10pYPMB2Su3/EPcWinR0oKfAw ZrVDW0EtpfS4s82eMUskm1+ak/HIJlTtk9mX4MkVKwMRqlYGRsTmQoz3qjxbpof/kty5 zMcsNSnAFbgtk5ObghBIjQ8jJFk92bfhr60X6P6FDDQ/gLU3+MDFq75JHfAJl8D/e5in CNyx1Eq3K+J2a3qhAhBw25+uO09IBT9hTNt1lIJmUJhq4U8Req6062BhXv1/JqNB8Vc0 vs1WsKNeDxnjSaupTTXxg+x/KyxbY07ThhqnJY4ivudgCM7lA+93d3q5tGxw07lpWcl+ JE0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QiKtDVlx; 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 z10-20020a1709060f0a00b0078331a3b123si6691522eji.572.2022.11.10.10.07.27; Thu, 10 Nov 2022 10:07:55 -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=QiKtDVlx; 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 S231703AbiKJR7n (ORCPT + 99 others); Thu, 10 Nov 2022 12:59:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbiKJR72 (ORCPT ); Thu, 10 Nov 2022 12:59:28 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2066.outbound.protection.outlook.com [40.107.96.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7585045ED7; Thu, 10 Nov 2022 09:59:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IRZreHG+ORThdqKZDli3aJ3IaGztcJlPnFXGNmZSS3VJHGe9MEexxI2oxk7aHybsS0LqLwn5n2EZoScu04MgKp6YnnTFqF63EhMLofF3nCuotGNy/uF8o+UU1YrbhDeqCL6eGegk5OweFKaBBonluQCiRRmPIViGeYyvm+MLC+uYc38xJX/iY1oMrXQi9kYRhh55KFO/E6EqAZBNQUVx36PnpLCHtXv6KrR1EuWhSW6mpuOU2VivaqoKwWkxBrEcOvCnnZSRnYvCsmHtg03jUlINt2UCdK6RAPp0QALXbuEVJf5skE6WYnedUiQK8UhUhY6tv8e0Brx2AJdW44USsg== 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=hPT0UmJdFUfvE2v/nVV6GqC34565KJP4VI/WPmG7sMA=; b=UGKmypoodukrA1Rwz4r4TF5iCTGy2sGbYfA/uvEadOISIusAYASbgXG8LxGvkaaG6cU969lxtB/MoQg5WQ6Hrn95iTRkxIeXq9bfBRrpcfclyzGayAVy1+rcx2G0wNq+kDKe0djSiXpXCZjKrrQQujAH4kTq1V5t40lnPAlzRh/qW3mYkFHsqhXatnzdwUfmDix9YcFhA5Deudwg5AMCoEJPXt9EsNqAqfcSYiPuS42kEflG8OaeIwAE5FiL/l9YimqgB9z6CqSeyFqHCC8cZb7CaJehhH1NBDjytNPaRrCh3rBiVAY2j4qxiWtqN/fDoZJ/LgkPtFS3ww+Fwm8gdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=hPT0UmJdFUfvE2v/nVV6GqC34565KJP4VI/WPmG7sMA=; b=QiKtDVlxeKnt/nvSRSsJNS6YRzkoMMtoe0rC3bYa+XzjKWlPFoeBw5SYfMa6xoztLV6iNQkTwXK3VYukdQjjDKnc/Vp6xAKP2IVWqLIA8StscFr00l3verYYVVCnHCxAh2vrtL4wn3OdUOd/89qm7lgRRST5Jv9KkSyc+fakCjI= Received: from BN9PR03CA0053.namprd03.prod.outlook.com (2603:10b6:408:fb::28) by IA1PR12MB7517.namprd12.prod.outlook.com (2603:10b6:208:41a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Thu, 10 Nov 2022 17:59:23 +0000 Received: from BN8NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::2f) by BN9PR03CA0053.outlook.office365.com (2603:10b6:408:fb::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT017.mail.protection.outlook.com (10.13.177.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:23 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:19 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 3/9] cpufreq: amd-pstate: change amd-pstate driver to be built-in type Date: Fri, 11 Nov 2022 01:58:41 +0800 Message-ID: <20221110175847.3098728-4-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT017:EE_|IA1PR12MB7517:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ded03ca-a9c8-4d9b-d0a9-08dac3454ca6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U0+VArbQF1KcnPz4a9f4rKRBSppdIbuYoSk1X4jvykIDso94z2oWhwaVXBUGqqnsrQIeGcWlW2bgWNAB71J1ulsYgRlBjjOWfZj3mWrh4uspMpEnZ7jOMCx+y2UJad2AlahyItw5y2n91PqZs1k/JQa/2yttvpNxvUpQUS1PMqYb8pFAEN1MbvZ/lsWEuxS/V1lRq7H+/GcbNKWPFS9WTvC4UVWjjAOjRdfoc4EgK1sSw34FZwpaQHgR6F6gqySpO77J1b7iZJN+woPLWnKXPA9PyRuySdpFPntKhV0lfLamWxI+C7wUZCcjuHtLGcqRyREBZTV1+8TG583OROkz55WDS1SNFL6QNdBs0GKfb2vGem9p1FQYSaTn75PRpap2aGfNmRIbxjvKNH48F4HnMN8kMVpoF/nMH9ja+FcNSsc0S5C4abfQxrscd0DVZiE6DfPTR//Ffxvq1emysH7i/zA+uercHnKIMgx+/YhJOz0+tFxTmVVxiEnHvb7NF8C8Kn71iW6fdfz8HfO2S5/9JRJ9/WVlv6Xo4iaOT0dtvTMPWlWXp4OCtXiMjeaBg7lCePjrztCm+31urteqnCksvLxRdCYHbYoZ8uz2Kza5aIPcpWmpZdvakXGWw2kd1GLzoK96vfeIdCQkfD4/2EGMX4KnJQWQAOXmp+Uh7TVqpJKfIpo+2v8IQvuooglsa+WM2LJTP9eW0wd9k5Hk0UQDuPjfnWiXS193+lzbWOhErayy7YITsfzDyzdtVYMUQFJh+aEFJiwAGhlwyDQhtDK/CH+EFKtvfPUq2ti4/h1MoJGdZSLrJUPCO2mWyiTjW+6t X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199015)(40470700004)(36840700001)(46966006)(82740400003)(336012)(7696005)(70206006)(36860700001)(8676002)(186003)(2906002)(40460700003)(5660300002)(83380400001)(47076005)(40480700001)(426003)(70586007)(8936002)(86362001)(26005)(4326008)(41300700001)(2616005)(36756003)(1076003)(16526019)(316002)(82310400005)(356005)(478600001)(54906003)(110136005)(6666004)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:23.2194 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ded03ca-a9c8-4d9b-d0a9-08dac3454ca6 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: BN8NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7517 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133479181520465?= X-GMAIL-MSGID: =?utf-8?q?1749133479181520465?= Change the `amd-pstate` driver as the built-in type which can help to load the driver before the acpi_cpufreq driver as the default pstate driver for the AMD processors. for the processors do not have the dedicated MSR functions, add `amd-pstate=legacy_cppc` to grub which enable shared memory interface to communicate with cppc_acpi module to control pstate hints. Signed-off-by: Perry Yuan --- drivers/cpufreq/Kconfig.x86 | 2 +- drivers/cpufreq/amd-pstate.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index 310779b07daf..00476e94db90 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 @@ -35,7 +35,7 @@ config X86_PCC_CPUFREQ If in doubt, say N. config X86_AMD_PSTATE - tristate "AMD Processor P-State driver" + bool "AMD Processor P-State driver" depends on X86 && ACPI select ACPI_PROCESSOR select ACPI_CPPC_LIB if X86_64 diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index ace7d50cf2ac..85a0b3fb56c2 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -59,10 +59,7 @@ * we disable it by default to go acpi-cpufreq on these processors and add a * module parameter to be able to enable it manually for debugging. */ -static bool shared_mem = false; -module_param(shared_mem, bool, 0444); -MODULE_PARM_DESC(shared_mem, - "enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)"); +static bool shared_mem __read_mostly; static struct cpufreq_driver amd_pstate_driver; @@ -653,16 +650,24 @@ static int __init amd_pstate_init(void) return ret; } +device_initcall(amd_pstate_init); -static void __exit amd_pstate_exit(void) +static int __init amd_pstate_param(char *str) { - cpufreq_unregister_driver(&amd_pstate_driver); + if (!str) + return -EINVAL; - amd_pstate_enable(false); -} + /* + * support shared memory type CPPC which has no MSR function. + * enable amd-pstate on processors with shared memory solution + * (amd-pstate=legacy_cppc enabled), it is disabled by default. + */ + if (!strcmp(str, "legacy_cppc")) + shared_mem = true; -module_init(amd_pstate_init); -module_exit(amd_pstate_exit); + return 0; +} +early_param("amd-pstate", amd_pstate_param); MODULE_AUTHOR("Huang Rui "); MODULE_DESCRIPTION("AMD Processor P-state Frequency Driver"); From patchwork Thu Nov 10 17:58:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp294670wru; Thu, 10 Nov 2022 10:08:20 -0800 (PST) X-Google-Smtp-Source: AMsMyM4dv797eos0jwEgT7FNVjFJyAeCUPVSwpBown2PuaLFKG0VgAAoogdWajqT6NmHUtBb27KN X-Received: by 2002:a50:8717:0:b0:461:aa10:cb0c with SMTP id i23-20020a508717000000b00461aa10cb0cmr2963560edb.383.1668103700119; Thu, 10 Nov 2022 10:08:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103700; cv=pass; d=google.com; s=arc-20160816; b=JXPgW5v+Xo3e4efDv/a3t04aCo0oU7CCYh5khP85FLiOiCL0FSs6/Gudcy4xn1tkyL a93Xf4pMXgT/pPEVhgOajFimAZp49V+B1LzetBCojrIlRWN2QJF7V/KN76HXI/0a8R4J Seg5gS+X7bpCPqEH0vB93RBwr0BtKiT8OM4BFjG+UQ21qFpNBuNMcETuQBraD3po2iNF 7qmIro+HouChcGF5mJT1t/2QeBLtIsUKtndNuzOTUHLh9A4RyJMKez2w8spzWHSDomME dD1MkE4z/TzSNMHdOX70kjg1yrwjXwTs8BI3RRs8J8kFNCdRsTMFBt4gQPoeIkaQ8uf4 aOMw== 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=v+5k49sTT3ndU5xvhlLCFpmGpuszq/9rsln3ImBn9vU=; b=Ft6WvEnLD1K5qstwynz175JJ04d7DP0KltrKa90+jbWerDbv981XC53jqLHAe82HiV RCWw6tAEaztgZSTUKiEiIO/GQz5kMk6iqDt3HMjgf93nFUIYXcl+lK6Fv2GvcQsHly7o neG/sX4Y1IOsYbX5dogSWzpbCTu6lcuxJxL9HMm/n8naRtv+i8grwMJkhYu8wQbNk5xB 1My49X1A9jgwXB2DqzCV4oWCLXedrnmRM0qHEg7tEWIxCyCGUJKBRhSFA6j/nCWCJMhX nXiYhKroMI2OX5ZJpJuZCKWvI5MjDAJxn5w1qFDYOp2knmUQojo+0TDN0qpeFsP2ZPaK 5mLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=zUYVoIlM; 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 y24-20020a1709064b1800b0072b0f6f1456si14284643eju.612.2022.11.10.10.07.54; Thu, 10 Nov 2022 10:08:20 -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=zUYVoIlM; 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 S229673AbiKJR7t (ORCPT + 99 others); Thu, 10 Nov 2022 12:59:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231536AbiKJR7d (ORCPT ); Thu, 10 Nov 2022 12:59:33 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3A145EE2; Thu, 10 Nov 2022 09:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lYn/WAijyWjPoHm41au4kYq51vpNCMfynTgDqpeRBT3JYxKAXeUMPfAOOslwGeEQvNOeo0l9TsAt9L7m4iwTorOHmGqdcYhX2+OhvY+pTLZedeS5YVNjdLwMncfaeuVbki5xsZopjqZHinmtLOQDHo2p8F7I1OxagHQxwK8+KlPHILcSd8d47q2WWrsAkSUyKmzx/Xsac2GUUBJdI/0nQjXgYEae3cu5cmVlHm83mVQnL5JZRy6jzf4b66VasMLvIucTTEn646w5ksaJPXPLA23Oak+QDImSnRRIlsX+6zNaUkXnDf/0jvOXlY5V7vz7kBYVrxFK4TjLlS2SEUdqwA== 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=v+5k49sTT3ndU5xvhlLCFpmGpuszq/9rsln3ImBn9vU=; b=H0skZ/tGr356qhraOfQjgQVPJn2uOuBdwIbkSw3y/iZzThrgJWpLZEUHn6wwCBt1RTnlaGsJQRjl0yYR6OlU29sIhojr38rydZ2xUnP5Uh1ixPz9x03/KSHosxLCwk51ZCvW5GCN5a1t8hPYS5nia3o35EvEuqoA6VLA12nZW1gcdx9xu6chGXxY0h7JWUqMIQ9yE4zohdUeT0QmLpUqbjZAPUxCG7+H6n4xSRhLlaC1Xqr7Jbl61ath4tmC9OApIsIBNbLQfmMuVwyQpH2nPf9KcC/gA2PEuYuC9yJRxMUqoaMoT7ALnLc+0QcoJsQB94mud1e41PaK5elhgN7sBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=v+5k49sTT3ndU5xvhlLCFpmGpuszq/9rsln3ImBn9vU=; b=zUYVoIlMdZHASeONOaLuLBa57LoTzYDDzfyDC4qcb81xhcnR2LoryYeRmXN7ioPFyYGM53qudjMqA6eHl93eYWQvsYkzU/cB5T9yePgaEkkfU6sHei2SU0eUxwOONDsYKM4nhM7ksix6nVYwT4fFqZiHOttpaOhD1xELa+egHSc= Received: from BN9PR03CA0875.namprd03.prod.outlook.com (2603:10b6:408:13c::10) by DS7PR12MB6023.namprd12.prod.outlook.com (2603:10b6:8:85::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.25; Thu, 10 Nov 2022 17:59:27 +0000 Received: from BN8NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::d0) by BN9PR03CA0875.outlook.office365.com (2603:10b6:408:13c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:27 +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 BN8NAM11FT038.mail.protection.outlook.com (10.13.176.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:27 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:23 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 4/9] cpufreq: amd_pstate: implement Pstate EPP support for the AMD processors Date: Fri, 11 Nov 2022 01:58:42 +0800 Message-ID: <20221110175847.3098728-5-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT038:EE_|DS7PR12MB6023:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a680f37-fbab-43f8-dbee-08dac3454f1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xtcDKMPD9AEpAy3Gu8sK1ZD9+np1BjLsFIAuZejF/r91SlNyjFWr+dX6rsKIChQL030koz/qwznsor7fyzflJz8lCumlHK/rN5hlwpx509qVq8l9jaFh1OJJjbITzCRidgMWAjoXisxcZ0HcuLW9k+yYNISoUaUmkzkuy1uROg2hETLOOzmvCsRHXFR3xdnXRCGOqGrxk1BnIt5UuuVPcU4V5gPFK/74QBiPzB/EDL3lr37NiHv2P/7hgixBAUHmeRreFsfqDJXhfs9L0RB7BqEjgVrZAzsn/pRDLCirELDM0W3UpsNIXGIAsbRk0/xsO1vFO3+nETjgbA/dx9AMEqDuMVu0EyMKElcF796JiLMVRHRjjZDTcvQgFrcGFjxtUs+SPdIYifd5XZkgroq6TMHF5Hv62tkqQKoA7QVNnWvLnvUJR9ony4PVaSeQ0Po5JUd/omzfYEYwyOmDHvxIXb0NzLBsv3P6yLsI5SDenlThp8d5yZMVoVxCBZOZElpz5EZxBYOPExmNpfHokch+WKLrIjpOftrEif7ffXSXeVNSck/TRAMsRnlLLdYx78XE13Gb7HOfAbWjlL1X/RGFBOKiMN2/bjWBW1rjHk6Wr44JvQt4USzyVl3wdQZiczwMyJ5DYe5jgmPBL+n6Zlpkr7dL8w4WLf3rc70cWwvqdsEM1zbs+Ad6drqeR8uvT12FRAZjwgP5kHX+8g6lO1a1fz4p6D9xIwD7CT0yFFKz2HliNyrs0KPWCV1kgwQSAj1QC8E/F0ktyXkrsqzciVjmr2uZnW28rWUcgfHKZJrQRtM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199015)(36840700001)(40470700004)(46966006)(36860700001)(83380400001)(8936002)(86362001)(478600001)(356005)(81166007)(54906003)(5660300002)(82740400003)(40480700001)(70206006)(6666004)(70586007)(8676002)(316002)(2906002)(186003)(2616005)(426003)(30864003)(26005)(47076005)(1076003)(16526019)(7696005)(40460700003)(110136005)(82310400005)(4326008)(336012)(41300700001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:27.3550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a680f37-fbab-43f8-dbee-08dac3454f1d 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: BN8NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6023 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133505652186176?= X-GMAIL-MSGID: =?utf-8?q?1749133505652186176?= Add EPP driver support for AMD SoCs which support a dedicated MSR for CPPC. EPP is used by the DPM controller to configure the frequency that a core operates at during short periods of activity. The SoC EPP targets are configured on a scale from 0 to 255 where 0 represents maximum performance and 255 represents maximum efficiency. The amd-pstate driver exports profile string names to userspace that are tied to specific EPP values. The balance_performance string (0x80) provides the best balance for efficiency versus power on most systems, but users can choose other strings to meet their needs as well. $ cat /sys/devices/system/cpu/cpufreq/policy0/energy_performance_available_preferences default performance balance_performance balance_power power $ cat /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference balance_performance Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 652 ++++++++++++++++++++++++++++++++++- include/linux/amd-pstate.h | 81 +++++ 2 files changed, 726 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 85a0b3fb56c2..7b3a12772582 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -60,8 +60,131 @@ * module parameter to be able to enable it manually for debugging. */ static bool shared_mem __read_mostly; +static int cppc_active __read_mostly; +static int cppc_load __initdata; +static int epp_off __initdata; -static struct cpufreq_driver amd_pstate_driver; +static struct cpufreq_driver *default_pstate_driver; +static struct amd_cpudata **all_cpu_data; + +static struct amd_pstate_params global_params; + +static DEFINE_MUTEX(amd_pstate_limits_lock); +static DEFINE_MUTEX(amd_pstate_driver_lock); + +static bool cppc_boost __read_mostly; +struct kobject *amd_pstate_kobj; + +#ifdef CONFIG_ACPI_CPPC_LIB +static s16 amd_pstate_get_epp(struct amd_cpudata *cpudata, u64 cppc_req_cached) +{ + s16 epp; + struct cppc_perf_caps perf_caps; + int ret; + + if (boot_cpu_has(X86_FEATURE_CPPC)) { + if (!cppc_req_cached) { + epp = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, + &cppc_req_cached); + if (epp) + return epp; + } + epp = (cppc_req_cached >> 24) & 0xFF; + } else { + ret = cppc_get_epp_caps(cpudata->cpu, &perf_caps); + if (ret < 0) { + pr_debug("Could not retrieve energy perf value (%d)\n", ret); + return -EIO; + } + epp = (s16) perf_caps.energy_perf; + } + + return epp; +} +#endif + +static int amd_pstate_get_energy_pref_index(struct amd_cpudata *cpudata) +{ + s16 epp; + int index = -EINVAL; + + epp = amd_pstate_get_epp(cpudata, 0); + if (epp < 0) + return epp; + + switch (epp) { + case AMD_CPPC_EPP_PERFORMANCE: + index = EPP_INDEX_PERFORMANCE; + break; + case AMD_CPPC_EPP_BALANCE_PERFORMANCE: + index = EPP_INDEX_BALANCE_PERFORMANCE; + break; + case AMD_CPPC_EPP_BALANCE_POWERSAVE: + index = EPP_INDEX_BALANCE_POWERSAVE; + break; + case AMD_CPPC_EPP_POWERSAVE: + index = EPP_INDEX_POWERSAVE; + break; + default: + break; + } + + return index; +} + +#ifdef CONFIG_ACPI_CPPC_LIB +static int amd_pstate_set_epp(struct amd_cpudata *cpudata, u32 epp) +{ + int ret; + struct cppc_perf_ctrls perf_ctrls; + + if (boot_cpu_has(X86_FEATURE_CPPC)) { + u64 value = READ_ONCE(cpudata->cppc_req_cached); + + value &= ~GENMASK_ULL(31, 24); + value |= (u64)epp << 24; + WRITE_ONCE(cpudata->cppc_req_cached, value); + + ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); + if (!ret) + cpudata->epp_cached = epp; + } else { + perf_ctrls.energy_perf = epp; + ret = cppc_set_epp_perf(cpudata->cpu, &perf_ctrls, 1); + if (ret) { + pr_debug("failed to set energy perf value (%d)\n", ret); + return ret; + } + cpudata->epp_cached = epp; + } + + return ret; +} + +static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, + int pref_index) +{ + int epp = -EINVAL; + int ret; + + if (!pref_index) { + pr_debug("EPP pref_index is invalid\n"); + return -EINVAL; + } + + if (epp == -EINVAL) + epp = epp_values[pref_index]; + + if (epp > 0 && cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) { + pr_debug("EPP cannot be set under performance policy\n"); + return -EBUSY; + } + + ret = amd_pstate_set_epp(cpudata, epp); + + return ret; +} +#endif static inline int pstate_enable(bool enable) { @@ -71,11 +194,21 @@ static inline int pstate_enable(bool enable) static int cppc_enable(bool enable) { int cpu, ret = 0; + struct cppc_perf_ctrls perf_ctrls; for_each_present_cpu(cpu) { ret = cppc_set_enable(cpu, enable); if (ret) return ret; + + /* Enable autonomous mode for EPP */ + if (!cppc_active) { + /* Set desired perf as zero to allow EPP firmware control */ + perf_ctrls.desired_perf = 0; + ret = cppc_set_perf(cpu, &perf_ctrls); + if (ret) + return ret; + } } return ret; @@ -418,7 +551,7 @@ static void amd_pstate_boost_init(struct amd_cpudata *cpudata) return; cpudata->boost_supported = true; - amd_pstate_driver.boost_enabled = true; + default_pstate_driver->boost_enabled = true; } static int amd_pstate_cpu_init(struct cpufreq_policy *policy) @@ -582,10 +715,62 @@ static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy, return sprintf(&buf[0], "%u\n", perf); } +static ssize_t show_energy_performance_available_preferences( + struct cpufreq_policy *policy, char *buf) +{ + int i = 0; + int ret = 0; + + while (energy_perf_strings[i] != NULL) + ret += sprintf(&buf[ret], "%s ", energy_perf_strings[i++]); + + ret += sprintf(&buf[ret], "\n"); + + return ret; +} + +static ssize_t store_energy_performance_preference( + struct cpufreq_policy *policy, const char *buf, size_t count) +{ + struct amd_cpudata *cpudata = policy->driver_data; + char str_preference[21]; + ssize_t ret; + u32 epp = 0; + + ret = sscanf(buf, "%20s", str_preference); + if (ret != 1) + return -EINVAL; + + ret = match_string(energy_perf_strings, -1, str_preference); + if (ret < 0) + return -EINVAL; + + mutex_lock(&amd_pstate_limits_lock); + ret = amd_pstate_set_energy_pref_index(cpudata, ret); + mutex_unlock(&amd_pstate_limits_lock); + + return ret ?: count; +} + +static ssize_t show_energy_performance_preference( + struct cpufreq_policy *policy, char *buf) +{ + struct amd_cpudata *cpudata = policy->driver_data; + int preference; + + preference = amd_pstate_get_energy_pref_index(cpudata); + if (preference < 0) + return preference; + + return sprintf(buf, "%s\n", energy_perf_strings[preference]); +} + cpufreq_freq_attr_ro(amd_pstate_max_freq); cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); cpufreq_freq_attr_ro(amd_pstate_highest_perf); +cpufreq_freq_attr_rw(energy_performance_preference); +cpufreq_freq_attr_ro(energy_performance_available_preferences); static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, @@ -594,6 +779,415 @@ static struct freq_attr *amd_pstate_attr[] = { NULL, }; +static struct freq_attr *amd_pstate_epp_attr[] = { + &amd_pstate_max_freq, + &amd_pstate_lowest_nonlinear_freq, + &amd_pstate_highest_perf, + &energy_performance_preference, + &energy_performance_available_preferences, + NULL, +}; + +static inline void update_boost_state(void) +{ + u64 misc_en; + struct amd_cpudata *cpudata; + + cpudata = all_cpu_data[0]; + rdmsrl(MSR_K7_HWCR, misc_en); + global_params.cppc_boost_disabled = misc_en & BIT_ULL(25); +} + +static int amd_pstate_init_cpu(unsigned int cpunum) +{ + struct amd_cpudata *cpudata; + + cpudata = all_cpu_data[cpunum]; + if (!cpudata) { + cpudata = kzalloc(sizeof(*cpudata), GFP_KERNEL); + if (!cpudata) + return -ENOMEM; + WRITE_ONCE(all_cpu_data[cpunum], cpudata); + + cpudata->cpu = cpunum; + } + cpudata->epp_powersave = -EINVAL; + cpudata->epp_policy = 0; + pr_debug("controlling: cpu %d\n", cpunum); + return 0; +} + +static int __amd_pstate_cpu_init(struct cpufreq_policy *policy) +{ + int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; + struct amd_cpudata *cpudata; + struct device *dev; + int rc; + u64 value; + + rc = amd_pstate_init_cpu(policy->cpu); + if (rc) + return rc; + + cpudata = all_cpu_data[policy->cpu]; + + dev = get_cpu_device(policy->cpu); + if (!dev) + goto free_cpudata1; + + rc = amd_pstate_init_perf(cpudata); + if (rc) + goto free_cpudata1; + + min_freq = amd_get_min_freq(cpudata); + max_freq = amd_get_max_freq(cpudata); + nominal_freq = amd_get_nominal_freq(cpudata); + lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata); + if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { + dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", + min_freq, max_freq); + ret = -EINVAL; + goto free_cpudata1; + } + + policy->min = min_freq; + policy->max = max_freq; + + policy->cpuinfo.min_freq = min_freq; + policy->cpuinfo.max_freq = max_freq; + /* It will be updated by governor */ + policy->cur = policy->cpuinfo.min_freq; + + /* Initial processor data capability frequencies */ + cpudata->max_freq = max_freq; + cpudata->min_freq = min_freq; + cpudata->nominal_freq = nominal_freq; + cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; + + policy->driver_data = cpudata; + + update_boost_state(); + cpudata->epp_cached = amd_pstate_get_epp(cpudata, value); + + policy->min = policy->cpuinfo.min_freq; + policy->max = policy->cpuinfo.max_freq; + + if (boot_cpu_has(X86_FEATURE_CPPC)) + policy->fast_switch_possible = true; + + if (!shared_mem && boot_cpu_has(X86_FEATURE_CPPC)) { + ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value); + if (ret) + return ret; + WRITE_ONCE(cpudata->cppc_req_cached, value); + + ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, &value); + if (ret) + return ret; + WRITE_ONCE(cpudata->cppc_cap1_cached, value); + } + amd_pstate_boost_init(cpudata); + + return 0; + +free_cpudata1: + kfree(cpudata); + return ret; +} + +static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) +{ + int ret; + + ret = __amd_pstate_cpu_init(policy); + if (ret) + return ret; + /* + * Set the policy to powersave to provide a valid fallback value in case + * the default cpufreq governor is neither powersave nor performance. + */ + policy->policy = CPUFREQ_POLICY_POWERSAVE; + + return 0; +} + +static int amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) +{ + pr_debug("CPU %d exiting\n", policy->cpu); + policy->fast_switch_possible = false; + return 0; +} + +static void amd_pstate_update_max_freq(unsigned int cpu) +{ + struct cpufreq_policy *policy = policy = cpufreq_cpu_get(cpu); + + if (!policy) + return; + + refresh_frequency_limits(policy); + cpufreq_cpu_put(policy); +} + +static void amd_pstate_epp_update_limits(unsigned int cpu) +{ + mutex_lock(&amd_pstate_driver_lock); + update_boost_state(); + if (global_params.cppc_boost_disabled) { + for_each_possible_cpu(cpu) + amd_pstate_update_max_freq(cpu); + } else { + cpufreq_update_policy(cpu); + } + mutex_unlock(&amd_pstate_driver_lock); +} + +static int cppc_boost_hold_time_ns = 3 * NSEC_PER_MSEC; + +static inline void amd_pstate_boost_up(struct amd_cpudata *cpudata) +{ + u64 hwp_req = READ_ONCE(cpudata->cppc_req_cached); + u64 hwp_cap = READ_ONCE(cpudata->cppc_cap1_cached); + u32 max_limit = (hwp_req & 0xff); + u32 min_limit = (hwp_req & 0xff00) >> 8; + u32 boost_level1; + + /* If max and min are equal or already at max, nothing to boost */ + if (max_limit == min_limit) + return; + + /* Set boost max and min to initial value */ + if (!cpudata->cppc_boost_min) + cpudata->cppc_boost_min = min_limit; + + boost_level1 = ((AMD_CPPC_NOMINAL_PERF(hwp_cap) + min_limit) >> 1); + + if (cpudata->cppc_boost_min < boost_level1) + cpudata->cppc_boost_min = boost_level1; + else if (cpudata->cppc_boost_min < AMD_CPPC_NOMINAL_PERF(hwp_cap)) + cpudata->cppc_boost_min = AMD_CPPC_NOMINAL_PERF(hwp_cap); + else if (cpudata->cppc_boost_min == AMD_CPPC_NOMINAL_PERF(hwp_cap)) + cpudata->cppc_boost_min = max_limit; + else + return; + + hwp_req &= ~AMD_CPPC_MIN_PERF(~0L); + hwp_req |= AMD_CPPC_MIN_PERF(cpudata->cppc_boost_min); + wrmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, hwp_req); + cpudata->last_update = cpudata->sample.time; +} + +static inline void amd_pstate_boost_down(struct amd_cpudata *cpudata) +{ + bool expired; + + if (cpudata->cppc_boost_min) { + expired = time_after64(cpudata->sample.time, cpudata->last_update + + cppc_boost_hold_time_ns); + + if (expired) { + wrmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, + cpudata->cppc_req_cached); + cpudata->cppc_boost_min = 0; + } + } + + cpudata->last_update = cpudata->sample.time; +} + +static inline void amd_pstate_boost_update_util(struct amd_cpudata *cpudata, + u64 time) +{ + cpudata->sample.time = time; + if (smp_processor_id() != cpudata->cpu) + return; + + if (cpudata->sched_flags & SCHED_CPUFREQ_IOWAIT) { + bool do_io = false; + + cpudata->sched_flags = 0; + /* + * Set iowait_boost flag and update time. Since IO WAIT flag + * is set all the time, we can't just conclude that there is + * some IO bound activity is scheduled on this CPU with just + * one occurrence. If we receive at least two in two + * consecutive ticks, then we treat as boost candidate. + * This is leveraged from Intel Pstate driver. + */ + if (time_before64(time, cpudata->last_io_update + 2 * TICK_NSEC)) + do_io = true; + + cpudata->last_io_update = time; + + if (do_io) + amd_pstate_boost_up(cpudata); + + } else { + amd_pstate_boost_down(cpudata); + } +} + +static inline void amd_pstate_cppc_update_hook(struct update_util_data *data, + u64 time, unsigned int flags) +{ + struct amd_cpudata *cpudata = container_of(data, + struct amd_cpudata, update_util); + + cpudata->sched_flags |= flags; + + if (smp_processor_id() == cpudata->cpu) + amd_pstate_boost_update_util(cpudata, time); +} + +static void amd_pstate_clear_update_util_hook(unsigned int cpu) +{ + struct amd_cpudata *cpudata = all_cpu_data[cpu]; + + if (!cpudata->update_util_set) + return; + + cpufreq_remove_update_util_hook(cpu); + cpudata->update_util_set = false; + synchronize_rcu(); +} + +static void amd_pstate_set_update_util_hook(unsigned int cpu_num) +{ + struct amd_cpudata *cpudata = all_cpu_data[cpu_num]; + + if (!cppc_boost) { + if (cpudata->update_util_set) + amd_pstate_clear_update_util_hook(cpudata->cpu); + return; + } + + if (cpudata->update_util_set) + return; + + cpudata->sample.time = 0; + cpufreq_add_update_util_hook(cpu_num, &cpudata->update_util, + amd_pstate_cppc_update_hook); + cpudata->update_util_set = true; +} + +static void amd_pstate_epp_init(unsigned int cpu) +{ + struct amd_cpudata *cpudata = all_cpu_data[cpu]; + u32 max_perf, min_perf; + u64 value; + s16 epp; + int ret; + + max_perf = READ_ONCE(cpudata->highest_perf); + min_perf = READ_ONCE(cpudata->lowest_perf); + + value = READ_ONCE(cpudata->cppc_req_cached); + + if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) + min_perf = max_perf; + + /* Initial min/max values for CPPC Performance Controls Register */ + value &= ~AMD_CPPC_MIN_PERF(~0L); + value |= AMD_CPPC_MIN_PERF(min_perf); + + value &= ~AMD_CPPC_MAX_PERF(~0L); + value |= AMD_CPPC_MAX_PERF(max_perf); + + /* CPPC EPP feature require to set zero to the desire perf bit */ + value &= ~AMD_CPPC_DES_PERF(~0L); + value |= AMD_CPPC_DES_PERF(0); + + if (cpudata->epp_policy == cpudata->policy) + goto skip_epp; + + cpudata->epp_policy = cpudata->policy; + + if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) { + epp = amd_pstate_get_epp(cpudata, value); + cpudata->epp_powersave = epp; + if (epp < 0) + goto skip_epp; + /* force the epp value to be zero for performance policy */ + epp = 0; + } else { + if (cpudata->epp_powersave < 0) + goto skip_epp; + /* Get BIOS pre-defined epp value */ + epp = amd_pstate_get_epp(cpudata, value); + if (epp) + goto skip_epp; + epp = cpudata->epp_powersave; + } + /* Set initial EPP value */ + if (boot_cpu_has(X86_FEATURE_CPPC)) { + value &= ~GENMASK_ULL(31, 24); + value |= (u64)epp << 24; + } + +skip_epp: + WRITE_ONCE(cpudata->cppc_req_cached, value); + ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); + if (!ret) + cpudata->epp_cached = epp; +} + +static void amd_pstate_set_max_limits(struct amd_cpudata *cpudata) +{ + u64 hwp_cap = READ_ONCE(cpudata->cppc_cap1_cached); + u64 hwp_req = READ_ONCE(cpudata->cppc_req_cached); + u32 max_limit = (hwp_cap >> 24) & 0xff; + + hwp_req &= ~AMD_CPPC_MIN_PERF(~0L); + hwp_req |= AMD_CPPC_MIN_PERF(max_limit); + wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, hwp_req); +} + +static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata; + + if (!policy->cpuinfo.max_freq) + return -ENODEV; + + pr_debug("set_policy: cpuinfo.max %u policy->max %u\n", + policy->cpuinfo.max_freq, policy->max); + + cpudata = all_cpu_data[policy->cpu]; + cpudata->policy = policy->policy; + + if (boot_cpu_has(X86_FEATURE_CPPC)) { + mutex_lock(&amd_pstate_limits_lock); + + if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) { + amd_pstate_clear_update_util_hook(policy->cpu); + amd_pstate_set_max_limits(cpudata); + } else { + amd_pstate_set_update_util_hook(policy->cpu); + } + + if (boot_cpu_has(X86_FEATURE_CPPC)) + amd_pstate_epp_init(policy->cpu); + + mutex_unlock(&amd_pstate_limits_lock); + } + + return 0; +} + +static void amd_pstate_verify_cpu_policy(struct amd_cpudata *cpudata, + struct cpufreq_policy_data *policy) +{ + update_boost_state(); + cpufreq_verify_within_cpu_limits(policy); +} + +static int amd_pstate_epp_verify_policy(struct cpufreq_policy_data *policy) +{ + amd_pstate_verify_cpu_policy(all_cpu_data[policy->cpu], policy); + pr_debug("policy_max =%d, policy_min=%d\n", policy->max, policy->min); + return 0; +} + static struct cpufreq_driver amd_pstate_driver = { .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify = amd_pstate_verify, @@ -607,8 +1201,20 @@ static struct cpufreq_driver amd_pstate_driver = { .attr = amd_pstate_attr, }; +static struct cpufreq_driver amd_pstate_epp_driver = { + .flags = CPUFREQ_CONST_LOOPS, + .verify = amd_pstate_epp_verify_policy, + .setpolicy = amd_pstate_epp_set_policy, + .init = amd_pstate_epp_cpu_init, + .exit = amd_pstate_epp_cpu_exit, + .update_limits = amd_pstate_epp_update_limits, + .name = "amd_pstate_epp", + .attr = amd_pstate_epp_attr, +}; + static int __init amd_pstate_init(void) { + static struct amd_cpudata **cpudata; int ret; if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) @@ -623,19 +1229,37 @@ static int __init amd_pstate_init(void) if (cpufreq_get_current_driver()) return -EEXIST; + /* set the pstate driver disabled by default if there + * is no early parameters set + */ + if (!cppc_load) { + pr_debug("disabled to load\n"); + return -ENODEV; + } + + if (!epp_off) { + WRITE_ONCE(cppc_active, 1); + if (!default_pstate_driver) + default_pstate_driver = &amd_pstate_epp_driver; + } + /* capability check */ if (boot_cpu_has(X86_FEATURE_CPPC)) { - pr_debug("AMD CPPC MSR based functionality is supported\n"); - amd_pstate_driver.adjust_perf = amd_pstate_adjust_perf; + if (!cppc_active) + default_pstate_driver->adjust_perf = amd_pstate_adjust_perf; } else if (shared_mem) { static_call_update(amd_pstate_enable, cppc_enable); static_call_update(amd_pstate_init_perf, cppc_init_perf); static_call_update(amd_pstate_update_perf, cppc_update_perf); } else { - pr_info("This processor supports shared memory solution, you can enable it with amd_pstate.shared_mem=1\n"); + pr_info("This processor supports shared memory solution, enable it with amd_pstate=legacy_cppc\n"); return -ENODEV; } + cpudata = vzalloc(array_size(sizeof(void *), num_possible_cpus())); + if (!cpudata) + return -ENOMEM; + WRITE_ONCE(all_cpu_data, cpudata); /* enable amd pstate feature */ ret = amd_pstate_enable(true); if (ret) { @@ -643,9 +1267,9 @@ static int __init amd_pstate_init(void) return ret; } - ret = cpufreq_register_driver(&amd_pstate_driver); + ret = cpufreq_register_driver(default_pstate_driver); if (ret) - pr_err("failed to register amd_pstate_driver with return %d\n", + pr_err("failed to register amd pstate driver with return %d\n", ret); return ret; @@ -657,6 +1281,20 @@ static int __init amd_pstate_param(char *str) if (!str) return -EINVAL; + /* + * Disable amd-pstate driver by default for now + * append amd-pstate=active or amd-pstate=active + * to enable driver loaded + */ + if (!strcmp(str, "active")) { + cppc_load = 1; + default_pstate_driver = &amd_pstate_epp_driver; + } else if (!strcmp(str, "passive")) { + epp_off = 1; + cppc_load = 1; + default_pstate_driver = &amd_pstate_driver; + } + /* * support shared memory type CPPC which has no MSR function. * enable amd-pstate on processors with shared memory solution diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 1c4b8659f171..7e6e8cab97b3 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -25,6 +25,7 @@ struct amd_aperf_mperf { u64 aperf; u64 mperf; u64 tsc; + u64 time; }; /** @@ -47,6 +48,18 @@ struct amd_aperf_mperf { * @prev: Last Aperf/Mperf/tsc count value read from register * @freq: current cpu frequency value * @boost_supported: check whether the Processor or SBIOS supports boost mode + * @epp_powersave: Last saved CPPC energy performance preference + when policy switched to performance + * @epp_policy: Last saved policy used to set energy-performance preference + * @epp_cached: Cached CPPC energy-performance preference value + * @policy: Cpufreq policy value + * @sched_flags: Store scheduler flags for possible cross CPU update + * @update_util_set: CPUFreq utility callback is set + * @last_update: Time stamp of the last performance state update + * @cppc_boost_min: Last CPPC boosted min performance state + * @cppc_cap1_cached: Cached value of the last CPPC Capabilities MSR + * @update_util: Cpufreq utility callback information + * @sample: the stored performance sample * * The amd_cpudata is key private data for each CPU thread in AMD P-State, and * represents all the attributes and goals that AMD P-State requests at runtime. @@ -72,6 +85,74 @@ struct amd_cpudata { u64 freq; bool boost_supported; + + /* EPP feature related attributes*/ + s16 epp_powersave; + s16 epp_policy; + s16 epp_cached; + u32 policy; + u32 sched_flags; + bool update_util_set; + u64 last_update; + u64 last_io_update; + u32 cppc_boost_min; + u64 cppc_cap1_cached; + struct update_util_data update_util; + struct amd_aperf_mperf sample; +}; + +/** + * struct amd_pstate_params - global parameters for the performance control + * @ cppc_boost_disabled wheher the core performance boost disabled + */ +struct amd_pstate_params { + bool cppc_boost_disabled; +}; + +#define AMD_CPPC_EPP_PERFORMANCE 0x00 +#define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80 +#define AMD_CPPC_EPP_BALANCE_POWERSAVE 0xBF +#define AMD_CPPC_EPP_POWERSAVE 0xFF + +/* + * AMD Energy Preference Performance (EPP) + * The EPP is used in the CCLK DPM controller to drive + * the frequency that a core is going to operate during + * short periods of activity. EPP values will be utilized for + * different OS profiles (balanced, performance, power savings) + * display strings corresponding to EPP index in the + * energy_perf_strings[] + * index String + *------------------------------------- + * 0 default + * 1 performance + * 2 balance_performance + * 3 balance_power + * 4 power + */ +enum energy_perf_value_index { + EPP_INDEX_DEFAULT = 0, + EPP_INDEX_PERFORMANCE, + EPP_INDEX_BALANCE_PERFORMANCE, + EPP_INDEX_BALANCE_POWERSAVE, + EPP_INDEX_POWERSAVE, +}; + +static const char * const energy_perf_strings[] = { + [EPP_INDEX_DEFAULT] = "default", + [EPP_INDEX_PERFORMANCE] = "performance", + [EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance", + [EPP_INDEX_BALANCE_POWERSAVE] = "balance_power", + [EPP_INDEX_POWERSAVE] = "power", + NULL +}; + +static unsigned int epp_values[] = { + [EPP_INDEX_DEFAULT] = 0, + [EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_PERFORMANCE, + [EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_BALANCE_PERFORMANCE, + [EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE, + [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE, }; #endif /* _LINUX_AMD_PSTATE_H */ From patchwork Thu Nov 10 17:58:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp294617wru; Thu, 10 Nov 2022 10:08:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM7ykIpVDebtiF0ToTGH5fBD9wQbDikp9/eFeVTPAp4wysVTC6djCKhTcaONT1uDNE0sDRff X-Received: by 2002:a63:1a23:0:b0:46f:c464:ee5a with SMTP id a35-20020a631a23000000b0046fc464ee5amr3006075pga.399.1668103693420; Thu, 10 Nov 2022 10:08:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103693; cv=pass; d=google.com; s=arc-20160816; b=aKr8qLtD6vhAvIn4KroQxNrTWLTR3brtVScPNKxwIlOYoovqUCLqvx/D7W3aGjIFJx 0qHl55zW0GMYs0KtM9vUH/X6lDP35ZAAe9qR4KrWIklQdqmOkLTy3DWIaxIhlIiKAVPh h3vLUIPW1ZfIBmLc5YZLa6ehH5hOX2vXb4tN8Jr5DnjKX1KG2y0UqtYW7ZzS33oynVKE hA72Xexyyl7ow4GmHg5rUHBFpuikUw9jN6LnfEjXCOt4hRwetW2e2xrQ5dJG4HfLU+hd tqYs31oXa1S4Sl+gu9m6ULAucBVozcrtokcs/LrfwT6UvojN/Aw8POXFqOj15K+K3LBn bQTA== 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=nqKZeO5kKpEC7sJX7NI7io5dvJwXoaa7bGyUL+075Rs=; b=vpOTtGRselKYWNABlu5g8qMjT4ycYlySsb2unkUi6AZ/UEb0bcTDDOCyBKzHJ3n6ba IeLAEqXI/f/yZzKxwsjCZA+Ol/hsBbmq4oxh6u2zBRK+UQ7b3PZyKh6yWONWgq2TMD9Z 2PJ4VvD1cDx5sQQoQJF+FVo87XwZ0q4bqEgcT57LXtBSBOrVNszYA/0I4qrRt6G73Hp2 vzJiyfZythMzAWxvwC2GTBvWXv/hNJqqw62CO00pimGgRLJM7+sfHTgV0mA/bMd1zw3t p0vChTCg7x2GoltBhFIUjNc5Kc2APR8GIUl2hcFwgnnGCHmeRC/V7fr65OfCpaU1wBQ+ xlVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TroB4fTX; 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 c17-20020aa78e11000000b00557c8a20395si16843572pfr.120.2022.11.10.10.07.59; Thu, 10 Nov 2022 10:08:13 -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=TroB4fTX; 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 S229588AbiKJSAC (ORCPT + 99 others); Thu, 10 Nov 2022 13:00:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbiKJR7f (ORCPT ); Thu, 10 Nov 2022 12:59:35 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4233443858; Thu, 10 Nov 2022 09:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AUp2jOlvO/jOY557maRI9v8eZ/2kiGBQ3/HlNNBlFugI8dd/FYqbdVT8ou54w4KSVh76AtUVnD0SH+JP0m66xS1NoU/QWPnZdxrYo8g4fzcQ6c3ypA7THtaBhqX+3vy9QBlPbkp8BdOa+P8BkbCVWSPsXYr4uxVQPEZzmLRjQq0GKtjj1ji8rU9MsHDmp6hXLygSKMCWZ1MOru67X0DQF/nTmyA6cH1/Un0RBzM6DPgfv0uRecb7XFhhecGLU0vLqANq1+NhPGSn/f37zRUO6pzH08uvGxndhVsZV3z2i/qgmRWSMZzJOZ5B3vzgJGINm61bSRI1xv6ifAb1U+h6sA== 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=nqKZeO5kKpEC7sJX7NI7io5dvJwXoaa7bGyUL+075Rs=; b=NLIsTFf0HiRan4fQgDDDoYpxGnIz/Tjm0MDAa0dkUJWHs4ZnRYrythy3YsvZYKtdkDOTK2VtlPlYAybWcHEAII9gjg5I9VuuJrqDNcxkbtDFpDMibaYCcET3RzPjRXTUkP8x2DippTti1l5pSp3cyjUMwilztzWAI89lTRfbIIX24yjdKetJev+af+k5/lpYchKv8VplxdnS/wykicB/XgZtT1q6+npxUypU5Z3VQfs0bxi1CSk87kBOhsJoBi3TWkiP+5LrqWr31we7goRgcbKsVmkQuJj+31rjhYNZ+kx36vw4dDN/o5d6mP8gYZ5bqagGLukNbPrme6Uu5LhOEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=nqKZeO5kKpEC7sJX7NI7io5dvJwXoaa7bGyUL+075Rs=; b=TroB4fTXpV653iDlnXO1oTPzT6x4xDohQ9+Xv3++il4OaYA9STWQa+DaPo05NzmHPlBRnGfjexecaMCtRsDQRSpw7PVhTzBrMTYOerFlNPG7tCtmbKYR/auLfvlW7SrF5C5YxbCFjuzwafyKu/Fv93YXrqdpLv/ugByuB3Mwrfc= Received: from BN9PR03CA0355.namprd03.prod.outlook.com (2603:10b6:408:f6::30) by CH2PR12MB4040.namprd12.prod.outlook.com (2603:10b6:610:ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Thu, 10 Nov 2022 17:59:31 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::76) by BN9PR03CA0355.outlook.office365.com (2603:10b6:408:f6::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:31 +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 BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:30 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:27 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan , "Mario Limonciello" Subject: [PATCH v4 5/9] cpufreq: amd_pstate: implement amd pstate cpu online and offline callback Date: Fri, 11 Nov 2022 01:58:43 +0800 Message-ID: <20221110175847.3098728-6-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT025:EE_|CH2PR12MB4040:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ad52e69-d97b-43c9-5d45-08dac3455141 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dM3TTYwc6iipndRAkR1p4piEZe7EHQw50E35gk2W4TJyd2ToeqVl+52ZMHj8ViROEq1TQP33moMZFaa1N8WXQzcIIerA9cz7FWh7fmIOAMqEDrtYIHuT4v+GQixh93LKC76/4HH2XWRHOEbOK0CgvlHOCztlSYz9NDFz0nnHWtIstVt4MBuaabOdz+0aztc8Zv5BCzmtLLlqruKiZQJOo1MdAggkLR+zakJtvjDLGpJlQpLDblkLJYvVl7R17LxCN/Pd3MzvC/4UzsREGurVgybRA1V8S1jPQtSc1lizJjEFwtWR2mJc7FdCKHRDjIIa/36WQaGDjdnQfdvbNpUZNKz+UBcI7xvHdojS2/VjTc0XrOWdEpA13472oC7QuTHQQ7CpTpv4bWevTMuOOsGfApGE9hsUGo7INYGNaUU8WkCPAZ0hAHJjn0ZYLvbat1cAKW3xgXifSXjYjmWYA8zO+WzimwZe5ZKIT9M8ECsqmEpUN87FxjJ30dqQoqI4r/ftxbuF/gVjpyFPFFOq5c1lcnAutT0YVpFsmTR3pR0R/hStCeLBRmftt2jesXsduHlDGMPnkhxtHPwho8C27TIGCCunZOHyx/nycaAp+cNRBCW8Zee2n0ZkX+Dm4K0nEzJVXnVcgcH93HTjiUt1WkQsPSolMjdSCmP4bt0QCqUzarez0mZOy7+mzQQ8kDkygNiIMp4XLNtmDFnVCU3uFi2Wej4k+q8J+ClfzyNJqxgq4Fl0bQoEA6ae9jLRd6XIEQ0/Mc4eJN34CrOaEDi5bHKqI3fAO9jXP3rqm+l/0z9Mn/2lyYgbMBkK12vSReZB+u5p X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199015)(46966006)(40470700004)(36840700001)(426003)(36860700001)(86362001)(83380400001)(82740400003)(81166007)(356005)(47076005)(4326008)(41300700001)(40480700001)(82310400005)(5660300002)(8936002)(2906002)(8676002)(7696005)(26005)(6666004)(16526019)(186003)(2616005)(40460700003)(70206006)(316002)(70586007)(110136005)(478600001)(336012)(1076003)(54906003)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:30.9275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ad52e69-d97b-43c9-5d45-08dac3455141 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: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4040 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133498683707718?= X-GMAIL-MSGID: =?utf-8?q?1749133498683707718?= Adds online and offline driver callback support to allow cpu cores go offline and help to restore the previous working states when core goes back online later for EPP driver mode. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 89 ++++++++++++++++++++++++++++++++++++ include/linux/amd-pstate.h | 1 + 2 files changed, 90 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 7b3a12772582..9a9abb755a18 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1174,6 +1174,93 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) return 0; } +static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) +{ + struct cppc_perf_ctrls perf_ctrls; + u64 value, max_perf; + int ret; + + ret = amd_pstate_enable(true); + if (ret) + pr_err("failed to enable amd pstate during resume, return %d\n", ret); + + value = READ_ONCE(cpudata->cppc_req_cached); + max_perf = READ_ONCE(cpudata->highest_perf); + + if (boot_cpu_has(X86_FEATURE_CPPC)) { + wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); + } else { + perf_ctrls.max_perf = max_perf; + perf_ctrls.energy_perf = AMD_CPPC_ENERGY_PERF_PREF(cpudata->epp_cached); + cppc_set_perf(cpudata->cpu, &perf_ctrls); + } +} + +static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = all_cpu_data[policy->cpu]; + + pr_debug("AMD CPU Core %d going online\n", cpudata->cpu); + + if (cppc_active) { + amd_pstate_epp_reenable(cpudata); + cpudata->suspended = false; + } + + return 0; +} + +static void amd_pstate_epp_offline(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = all_cpu_data[policy->cpu]; + struct cppc_perf_ctrls perf_ctrls; + int min_perf; + u64 value; + + min_perf = READ_ONCE(cpudata->lowest_perf); + value = READ_ONCE(cpudata->cppc_req_cached); + + mutex_lock(&amd_pstate_limits_lock); + if (boot_cpu_has(X86_FEATURE_CPPC)) { + cpudata->epp_policy = CPUFREQ_POLICY_UNKNOWN; + + /* Set max perf same as min perf */ + value &= ~AMD_CPPC_MAX_PERF(~0L); + value |= AMD_CPPC_MAX_PERF(min_perf); + value &= ~AMD_CPPC_MIN_PERF(~0L); + value |= AMD_CPPC_MIN_PERF(min_perf); + wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); + } else { + perf_ctrls.desired_perf = 0; + perf_ctrls.max_perf = min_perf; + perf_ctrls.energy_perf = AMD_CPPC_ENERGY_PERF_PREF(AMD_CPPC_EPP_POWERSAVE); + cppc_set_perf(cpudata->cpu, &perf_ctrls); + } + mutex_unlock(&amd_pstate_limits_lock); +} + +static int amd_pstate_cpu_offline(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = all_cpu_data[policy->cpu]; + + pr_debug("AMD CPU Core %d going offline\n", cpudata->cpu); + + if (cpudata->suspended) + return 0; + + if (cppc_active) + amd_pstate_epp_offline(policy); + + return 0; +} + +static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) +{ + amd_pstate_clear_update_util_hook(policy->cpu); + + return amd_pstate_cpu_offline(policy); +} + static void amd_pstate_verify_cpu_policy(struct amd_cpudata *cpudata, struct cpufreq_policy_data *policy) { @@ -1208,6 +1295,8 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .init = amd_pstate_epp_cpu_init, .exit = amd_pstate_epp_cpu_exit, .update_limits = amd_pstate_epp_update_limits, + .offline = amd_pstate_epp_cpu_offline, + .online = amd_pstate_epp_cpu_online, .name = "amd_pstate_epp", .attr = amd_pstate_epp_attr, }; diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 7e6e8cab97b3..c0ad7eedcae3 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -99,6 +99,7 @@ struct amd_cpudata { u64 cppc_cap1_cached; struct update_util_data update_util; struct amd_aperf_mperf sample; + bool suspended; }; /** From patchwork Thu Nov 10 17:58:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp294800wru; Thu, 10 Nov 2022 10:08:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6tLzLGTYPChzDQZhjXXl6bWC7d8zf6b4bkkEkncRsqTHGyDb9D2S2OKa2frxFOL0yQ1nLU X-Received: by 2002:a17:906:f292:b0:7ae:8a69:a169 with SMTP id gu18-20020a170906f29200b007ae8a69a169mr2415542ejb.394.1668103712282; Thu, 10 Nov 2022 10:08:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103712; cv=pass; d=google.com; s=arc-20160816; b=Sty5T2oROeaPp+zrc2xuQxgCegI36/zskrvmmBAWVDhKWhXKtore/PR6XhA/wXwIHV Cnp2wm1HZsiwcSFGlkwakZW81+OFpS9dP1GD4UzxW44zB1lQr+qB4zK7HnbPq9srhLvS Vn5JXYX5rZQ1Kyjq1izRtX4izWfegmhN2gmlF7xNJU7eaJnXi4HVQSmx86zU5B7YrkJP mhWH+MPpp11R1TEEGDuEDaF/Yc8e3sjPe1CFX/IRLl1y6PEmz0Ta0/yiP9ZTxZvXmmE7 Mngu+PgWgCVS1eo7UX7pMn2y9o3QfrJdPYnEEl/PWtwavsHDOHarQXxFC0j9qqQlGnS1 /owA== 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=ahoQ6TafYVsvKiCzN5J76aLP+KQBCq70Wep5Trl7hpQ=; b=ebS85LdUhMOENq5Gd2yuiQ212rTXRBzwHcTCq0DEXr78xo7uRiQmQO6da7lHvzduho 9VVgBEmkdRzYOWr49Ei5sbK1z3L7ybyC1jfKhDSyE17/yjSQsclPOUUM5efDVdZQTv3/ IAcVPXVNXbintPuw7DEv9vdMXaMF0PAEZ6kWsUmdASbqyAFv2PyTKRWYAO2V0nnBjams juCvSBiOJHaSZYugD9nSoPrTubrR1/WX9t39ER5osafI2fa0oY1ssmAFMRPo9rP/GgMV E+EwtZlDaXjsk2DEh5mz9qRW3v94BIIrEZcQIfnGG71hCKWNx7frylmnHdX8cP3kawD1 6ItA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AHsbdfmA; 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 y8-20020a056402358800b00461e582ef0fsi218756edc.381.2022.11.10.10.08.07; Thu, 10 Nov 2022 10:08:32 -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=AHsbdfmA; 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 S230505AbiKJSAg (ORCPT + 99 others); Thu, 10 Nov 2022 13:00:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbiKJR77 (ORCPT ); Thu, 10 Nov 2022 12:59:59 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2083.outbound.protection.outlook.com [40.107.212.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54FC64D5C2; Thu, 10 Nov 2022 09:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jf3rSWDOX/W/dM03s7VRmW97S93AV1zxRfrmeTUYRI5eK7L9wx6r36PR7umWgmEBBzBomMBurKVOTX1zKr1J4GYp8cxiFt66kGCJa9tETQcuYtfDcgqv2D8nKx49EXmefT43u7XLJWqIkj1Q+cGxiuKhQaqeEf1ymfpvX3NHGYoYW7CW6n468rE5vFsqfGp+UfYOVRzSgOgJfBMmJ2p+mG18epep/9xPNyMWWnoM/7dxs8JdmF5jM6kCsGl925cUsqBLYMedjY4r286cuJz4NUuKhoBuD5SLhjFDt1QdDuOjT9AWVGNwDP8AxEmoLd0KlqYBscpD1dpN8QbDcTF/mw== 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=ahoQ6TafYVsvKiCzN5J76aLP+KQBCq70Wep5Trl7hpQ=; b=Az9O+lEljWKloWY98dZtueafpP2n+t/eCqcUgK2IgJmLqXHYzxMgwZxyFqek4a4+fnY94H92NnUaa55NMi+WjDAXSJgcrCvAtQFhh7d4HD389O2YDls49dH4EyYzf+EYQxgLwgFTQSVKk77jzbTEZy9YDJWtJSREeeu7/1fK/NClfcuyQRzDoeF1GyeWyU1T40wEIGOnsIV6uiHEnGEvVs5Ij6v3sy1oXSy2X9RdnxBfAotvcgnmdJhYoZm07zSU6bN0fZ6i84TtUbGh5GNFOsuD3O/GbJylg2+Q6XnoWx71tdizHWIN9VswykD6V+WTqOHGxU1XfA9uXi+smHSC6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=ahoQ6TafYVsvKiCzN5J76aLP+KQBCq70Wep5Trl7hpQ=; b=AHsbdfmAuT53/zMskiHO5L43ZpKKTK+9/pn8jX6NNd7adSuF47q+KHoUB0LJQv9+xbYOLS8CU9emII3ENk4QkPD6CpRCh01ysiQtqS2Tw6f6PH7xkPgu1EbVx/XDCstGo+qDi5UMDQaYY2TLSSD3sAv6tL0Iodpq24o0axM3h2g= Received: from BN0PR02CA0055.namprd02.prod.outlook.com (2603:10b6:408:e5::30) by CH3PR12MB7498.namprd12.prod.outlook.com (2603:10b6:610:143::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Thu, 10 Nov 2022 17:59:38 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::7d) by BN0PR02CA0055.outlook.office365.com (2603:10b6:408:e5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:37 +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 BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:37 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:30 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan , "Mario Limonciello" Subject: [PATCH v4 6/9] cpufreq: amd-pstate: implement suspend and resume callbacks Date: Fri, 11 Nov 2022 01:58:44 +0800 Message-ID: <20221110175847.3098728-7-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT107:EE_|CH3PR12MB7498:EE_ X-MS-Office365-Filtering-Correlation-Id: e976bcd5-4a7a-4634-5023-08dac3455530 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m5MVXf2dMUnqo+xsjmse5tAw+j9E5RAgUtlR0jQpHxF3iQaNRa1zh5E3KZqVaj2AvGRwtCE9rMeR8CAW52ip/Sro1wRTAOOBeJWzl0XaNxl/SmmaVPDlE8P2Uvpov/Dbi371Z4VX1wrhLP4+nBY1KFcZ+k7rRtS1lko/qmWF6Fg4nQU60v90zD2PWRt8T8iUdjV0KmG+2CfmYmoY4ik3G1Y+oN3kpZddPjSlK7b/2KLoP6t2oJlAErnlj26GoYUXlPWkYh8bwD1hYMUccW9/UWAYDIPY62WucOwKHACSeXiHyO1+1h76ObnpDOfOtBSqSPhQhAfLlh1exsF0KxanE3TbNi3A4nz8MIMDx6Kn3u3xarI1+WR8scBaGY8I8tR7pCfsA9okcev4NAP7GKsmTFiX5YeKu0dcE28EvaFCndGmtWBDOM/lQcxktJB5mIITy3m7FTTPrKRPD3UpAEgnrUKX9EzM3c/K41UoFaS/D+M4BM02lzObyH8QGE9K525ARcW1CMmcxt+gCnlAOskmn9ZDXHFbLeO3cZrC9N+F9RXn//hqFZvCemZf9NvT/fiUcMnMgzange+MIZojVplFDxlr4TuLxk3mtXiMvat3Um3i1QrTIQPcv87/tCsTxuibg0pjxSCIlEjFh4EB+kpsxgmxkqwBY+aMCSxfU0ByHvESTuxgB1zbQXsWlj5P1s72+R+gAOVbzn1nY0ZlUFvpcVdORa/QLmGEE/z2lrCZewKO1gGLsIldx8os04ehZbbQGzoKAhngx0FOoix5ZyNuRQmkbfNY0+U+B8asFgFEZrQaxlTDyG7OalCiJs3eCnoX X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(41300700001)(70586007)(86362001)(5660300002)(70206006)(8676002)(4326008)(316002)(54906003)(8936002)(82740400003)(81166007)(36756003)(40480700001)(36860700001)(40460700003)(356005)(1076003)(83380400001)(7696005)(26005)(110136005)(6666004)(15650500001)(478600001)(82310400005)(2906002)(16526019)(186003)(2616005)(336012)(47076005)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:37.5267 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e976bcd5-4a7a-4634-5023-08dac3455530 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: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7498 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133518241659630?= X-GMAIL-MSGID: =?utf-8?q?1749133518241659630?= add suspend and resume support for the AMD processors by amd_pstate_epp driver instance. When the CPPC is suspended, EPP driver will set EPP profile to 'power' profile and set max/min perf to lowest perf value. When resume happens, it will restore the MSR registers with previous cached value. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9a9abb755a18..645706d65173 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1261,6 +1261,44 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) return amd_pstate_cpu_offline(policy); } +static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = all_cpu_data[policy->cpu]; + int ret; + + /* avoid suspending when EPP is not enabled */ + if (!cppc_active) + return 0; + + /* set this flag to avoid setting core offline*/ + cpudata->suspended = true; + + /* disable CPPC in lowlevel firmware */ + ret = amd_pstate_enable(false); + if (ret) + pr_err("failed to suspend, return %d\n", ret); + + return 0; +} + +static int amd_pstate_epp_resume(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = all_cpu_data[policy->cpu]; + + if (cpudata->suspended) { + mutex_lock(&amd_pstate_limits_lock); + + /* enable amd pstate from suspend state*/ + amd_pstate_epp_reenable(cpudata); + + mutex_unlock(&amd_pstate_limits_lock); + + cpudata->suspended = false; + } + + return 0; +} + static void amd_pstate_verify_cpu_policy(struct amd_cpudata *cpudata, struct cpufreq_policy_data *policy) { @@ -1297,6 +1335,8 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .update_limits = amd_pstate_epp_update_limits, .offline = amd_pstate_epp_cpu_offline, .online = amd_pstate_epp_cpu_online, + .suspend = amd_pstate_epp_suspend, + .resume = amd_pstate_epp_resume, .name = "amd_pstate_epp", .attr = amd_pstate_epp_attr, }; From patchwork Thu Nov 10 17:58:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp295163wru; Thu, 10 Nov 2022 10:09:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM6ky5mjWXnesjd7kfuII6INt0D1sPWE3H414/qMnU1kMnDELYenuHnSZ9Lxl95bXhd6FIMq X-Received: by 2002:a17:906:ac6:b0:78d:3341:aa8 with SMTP id z6-20020a1709060ac600b0078d33410aa8mr3300359ejf.96.1668103745837; Thu, 10 Nov 2022 10:09:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103745; cv=pass; d=google.com; s=arc-20160816; b=SvQXk1TtHimqYOJhU4JeDDiVBdrr9eBD1RBPmGFSDmDdnicPJ8gnMvl9HTP12IjVkl bD08kZr8rEF0sPrTSUaiULC1rRdeYi7gwpgyAlWg4jdlnEBCx1mns8d2cRbGiys7KJlH qUdvzJKaoJ2vv+m7K7SnebaChoauyZOj9ps3CSMH5mbqhiSgU0MXDd9+HBCMas4dFh2y DCo7o+jl0w7Oj+SVB23+ljXRP/NiCllzAiIUDRnIIKpoxUh7ftssQPspKt88CIP6Qm/D 6bIY0bsPIFSEbVtmHrRdti2tFF3/RuHXqD+oSCRgZIgYdr/JZh2WQhJtD8k/JRHUhOpV AShA== 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=5XvbAsGwctxiPGDpM4BvEKmqsb8MKYiFVGhS7LjHld0=; b=ULSpSgzu0L2rS6fkTdKQqsLvHXSp1wCU3P6bnh4Y2HAkxGhecfQ7mUYJQLPzlz97Vw n6u+5Ykm3Y+FfReXx9Kkxtq3GujLWwF46Rv+qCY/7Mt1x+paajPwy8yuRao+dYucRTMv vIJ397+OiSKJe9U2vG0gI8g/70p6el/MMMtzj87EK931M2XrnC2CjA852xjaO6HJ5Dpm WyWGxlWLJZzG2MydQiAGedfuEETvGHo1YRF5nmHTq5dpocsirTQPVpe99aXHsTd/6IO/ kEvy1vFtcgdPexKqkHvnSHxmLMLARXdwJksYWBTJgV3qonwF1s4aQA3QjVXqsJYe29LA pQlw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=MOxG+3JE; 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 hr11-20020a1709073f8b00b00773b8e3b6a1si21258024ejc.805.2022.11.10.10.08.41; Thu, 10 Nov 2022 10:09:05 -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=MOxG+3JE; 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 S231648AbiKJSAl (ORCPT + 99 others); Thu, 10 Nov 2022 13:00:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231751AbiKJSAB (ORCPT ); Thu, 10 Nov 2022 13:00:01 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20631.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D0E4D5D2; Thu, 10 Nov 2022 09:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XuglJS0Dp4YIck3PN4ln+8NlcEL/LSXH9ySheUtagZ5ILl3YtUnsMb3v1WUdeORX9ie/oSE0YExO5X2FzqFNlKKMNwAfuhmzBB3umot+JMWR3CflvBgwYhnQwlbnKyq20j6Sxs+sgaapC5F5P6KJ8blJcDQlS+L4WcMnhk2gt7IJsWwqGLhiaWhVGpINrzBUamxsxjrZmc859pH/WZ1AzS8RIbQ0JmvR+6VlP5eVS5EzEAG7+dzAq44SEDkrTHVx5o+RBunTy/+BlQkaWR8bc14OkLgoG1XC+mpgnDdxqQSBIRdGls8If7jlM1TuOxrPDVqEz4z8MFtqf33NF5BeAw== 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=5XvbAsGwctxiPGDpM4BvEKmqsb8MKYiFVGhS7LjHld0=; b=nlS1qXGBT5XjwjqnQ2mR0PDd841H/0c4vm9i/DTv89TNRKGD+f7swcVXh/GVvXQG/pahylu++lfOiKNhZFeyR2e3EDtPhu2oqUTyYMRVXM6E5Ox80Qj8dmC2N4GbzNDYnSf7qhjVypAsyMW1XFbhrtfRUoGn4/KFp/ymeDOg3fpNRTBey/EBf0GKRWc+AmYmOQjfEh030C8gCjryauaW6r6sf5BPIXlHpiksl8ad51CKltbEOoyutmcoRD3SSB8cGNLbyBAPzEqfEIEVafG5REmfPDNUr+Cmvl97eX/WAAtbxPEl417UKHZ/cisNu4AS6WGTW4ZEm4KchMLpS/4erw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=5XvbAsGwctxiPGDpM4BvEKmqsb8MKYiFVGhS7LjHld0=; b=MOxG+3JE67OpIOC1hvvrKqedFdu+vC5maUEPLo0WWLqrmpEaeQbvxL+QRTsDrdb2thGe1ZwVc57BlDfrULPZpg7cl6iSgpW/eW4ggJ0F66q7Y87UQdDg/6UxvKK+OZUtxgc79UYDNUk6v3lpPg5dg1n00ld2q1e9CgXkmPot2aA= Received: from BN0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:408:e5::21) by CY5PR12MB6226.namprd12.prod.outlook.com (2603:10b6:930:22::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Thu, 10 Nov 2022 17:59:38 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::4d) by BN0PR02CA0046.outlook.office365.com (2603:10b6:408:e5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 17:59:38 +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 BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:38 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:34 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 7/9] cpufreq: amd-pstate: add frequency dynamic boost sysfs control Date: Fri, 11 Nov 2022 01:58:45 +0800 Message-ID: <20221110175847.3098728-8-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT107:EE_|CY5PR12MB6226:EE_ X-MS-Office365-Filtering-Correlation-Id: de1b6c66-9f9f-4f66-47f6-08dac34555ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3p+YtEezixGwoRxF0S4tkW/XSzQXKS9LYRfiAl4daXnJBkUGLPlK8a0+D/FMxRAMcKJXOCjrhmHUHbw/e7yHuPGYQeIPQRrA9KmGLXewsqXScyq8Uhgjv11WLH0BX3IUlLMNOnJFB1NbNxQSnnQPqkQhtqZ4Q8pNt8Q0qqBFNNSMIpEtpvBXNAMX1YV95S3A7jCHjkoZdq5HgR5Ae/NIpcZ+rQOBO704gdoicTDoMF5MmicIHafPwDuJhJvi4QTBmZ5VFaRbSXFHZeyrdswniAV/v+jSIu8Mgt78JLqmat6mUytoxB1JYfhlkQvw40kZuVED8IqZPQDjGFY6es7wf9fHaXzRcciYNL6AYDGDm0yaeCzVjktNV7yIlelI/znh7mJucc+HOIO2dPPtweOEo1ieF2q7TNR4BwPBcOpxuU8dns/kxaS9egYcuYDLrtL2BjfPeuAncYOS5OHbqvIGYp+2CQqXnokldRyptdK9LOg32VNRGIZdG8og57LOSm3j0N9HMd67vdH03kw/TPoH7CYpIOZFzdUbeSot7jR8n4fkZDVJOGnNahaInI+qak3lc9CAypiqipudyC2GcDPr0ZMOEsw5+A7D9Kgx6ypD6tM8p77vWIxMC783o/R/tGduBQJTLDYuTz81RVfALjhoawWVpKRdJGFT5gFfdnZIm+8aEjvSIcJyB4zD101ifT7a4ehPEOO/6VjTICayNNmY8SEdBecD1+6Xs+n1dvC5zi10z3AEjdQbISLTuK+ULmhF48R3rqp9qpocd0gE9GsvK2IYtJJDjjTfA9n6Smb1YGD48EhIcOCs5VsxMz37qF6xrLTKakYM5Zbou18eve9muQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(346002)(376002)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(54906003)(70206006)(86362001)(41300700001)(110136005)(8936002)(5660300002)(1076003)(356005)(81166007)(82740400003)(2616005)(478600001)(40460700003)(2906002)(36756003)(7696005)(4326008)(26005)(8676002)(36860700001)(316002)(70586007)(426003)(16526019)(336012)(82310400005)(47076005)(83380400001)(186003)(6666004)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:38.3391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de1b6c66-9f9f-4f66-47f6-08dac34555ac 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: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6226 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133553590349408?= X-GMAIL-MSGID: =?utf-8?q?1749133553590349408?= Add one sysfs entry to control the CPU cores frequency boost state The attribute file can allow user to set max performance boosted or keeping at normal perf level. Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 66 ++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 645706d65173..b71bfbbb7639 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -765,12 +765,46 @@ static ssize_t show_energy_performance_preference( return sprintf(buf, "%s\n", energy_perf_strings[preference]); } +static void amd_pstate_update_policies(void) +{ + int cpu; + + for_each_possible_cpu(cpu) + cpufreq_update_policy(cpu); +} + +static ssize_t show_boost(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", cppc_boost); +} + +static ssize_t store_boost(struct kobject *a, + struct kobj_attribute *b, + const char *buf, size_t count) +{ + bool new_state; + int ret; + + ret = kstrtobool(buf, &new_state); + if (ret) + return -EINVAL; + + mutex_lock(&amd_pstate_driver_lock); + cppc_boost = !!new_state; + amd_pstate_update_policies(); + mutex_unlock(&amd_pstate_driver_lock); + + return count; +} + cpufreq_freq_attr_ro(amd_pstate_max_freq); cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); cpufreq_freq_attr_ro(amd_pstate_highest_perf); cpufreq_freq_attr_rw(energy_performance_preference); cpufreq_freq_attr_ro(energy_performance_available_preferences); +define_one_global_rw(boost); static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, @@ -788,6 +822,15 @@ static struct freq_attr *amd_pstate_epp_attr[] = { NULL, }; +static struct attribute *pstate_global_attributes[] = { + &boost.attr, + NULL +}; + +static const struct attribute_group amd_pstate_global_attr_group = { + .attrs = pstate_global_attributes, +}; + static inline void update_boost_state(void) { u64 misc_en; @@ -1398,9 +1441,28 @@ static int __init amd_pstate_init(void) ret = cpufreq_register_driver(default_pstate_driver); if (ret) - pr_err("failed to register amd pstate driver with return %d\n", - ret); + pr_err("failed to register driver with return %d\n", ret); + + amd_pstate_kobj = kobject_create_and_add("amd-pstate", &cpu_subsys.dev_root->kobj); + if (!amd_pstate_kobj) { + ret = -EINVAL; + pr_err("global sysfs registration failed.\n"); + goto kobject_free; + } + + ret = sysfs_create_group(amd_pstate_kobj, &amd_pstate_global_attr_group); + if (ret) { + pr_err("sysfs attribute export failed with error %d.\n", ret); + goto global_attr_free; + } + + return ret; +global_attr_free: + kobject_put(amd_pstate_kobj); +kobject_free: + kfree(cpudata); + cpufreq_unregister_driver(default_pstate_driver); return ret; } device_initcall(amd_pstate_init); From patchwork Thu Nov 10 17:58:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp295165wru; Thu, 10 Nov 2022 10:09:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM5IHa35KCUaKyW2c+oiXeO8xFDyfhZzkFU0JSax4mzYUXHQXqzZ8yl4PdgOlRnGxbqbk2v9 X-Received: by 2002:a17:906:ad9:b0:78d:b6ea:174e with SMTP id z25-20020a1709060ad900b0078db6ea174emr3332147ejf.95.1668103745935; Thu, 10 Nov 2022 10:09:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103745; cv=pass; d=google.com; s=arc-20160816; b=ZZZcCdP6vfUH5337ttutrXwICw0iP4m+4Oov1trrQuavSfht92UaKqinkwvFNQhXIz IiayljK2qQmte0BoU0ffQAOTemqxaRUGTyJZWV1heAqcQxw0kUUrQWdeQbKqBVaYsvHi Gdi+6Ut5oKPsGZ0tENUZCtGaqwm9ayBoYRs+D8JlxCsLbZId0HOU+OeH0AOkh6bYZkqE 9p9FmaaZS8OEZpgEZx78CKlLZr0TFn2v20bHx8tqC8aPcO1p3+bx9msSMBPWOGTZ0H97 ohA77tWPALweAxMnR8ZzAEs/H50hBzbWE1df/ahjHTEVJSbjxNZYm/dQ0qbPF/E/ibEA CPlg== 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=h0Vg++G6NTCpEK3CPxdr1P7oz16Ijhl8gM43pSpJxi0=; b=DYMU7wedICZUltMSm744X/ZkFd75E+ZLSRCMDOPSv4owXakwMpXQvenSuRqV0c5iNR keFfy9JS/ciUWFkpBjJvg7Keq9NdcEFSPycepno3O/deCgES0VXm/pqxK6ZNAHY7AWqp OsDvWkmjog4y4Zp6ihuo9g0rt/1BMi8EE/wTnmDhL8+8jyx+aKzE31EwwD6j07QtaPIW xWEnkyuGBwk2/fUOfdB6lsLtB2jt42wukUjmkFDllEU7jxlZ02t8ArqZtV3aG3H2yzWQ oo/R2FvkVJvYF+wxo1CTNMn8YsHIO1ggfAROW4+T5M+hkplq+iZvWmGvSXn6LmA4X+D/ o3pA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Cd00ybCK; 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 hb7-20020a170907160700b007ae743c61ccsi12286635ejc.848.2022.11.10.10.08.41; Thu, 10 Nov 2022 10:09:05 -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=Cd00ybCK; 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 S231702AbiKJSAp (ORCPT + 99 others); Thu, 10 Nov 2022 13:00:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiKJSAD (ORCPT ); Thu, 10 Nov 2022 13:00:03 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2063.outbound.protection.outlook.com [40.107.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E674D5F1; Thu, 10 Nov 2022 09:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VFzaPlgkDXgEx+6mUZF3ckPD5YnSoctMAOwy5o5u+CBoj2YJGPmILQ24iAPmPupZzZoOM+bG0IScqTarNtaIo7xe5gSBQAX1nKuy9F2ZvGKV8PBW/sgNLZS/gxT6a6FULwCrZUSoHiIhPdhhq1fP7vKJ/zCEZwMKS0pHqFXwJP9eXP7ZqclcDOfMnXuxM3A55B2RzFjrtgoTkkVbvqfTLXsKF5hBlmMalPrht4eDrUTkOwRah8C5wh7ELF8Rs8b+per1dC8O0vZWfhEZLfAXffCD5Knh8SQ8d0MnR2yz9/oHoE0DCruZfn/Zjcg31KDY8G35CeWbfRJmqAkuNswsEg== 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=h0Vg++G6NTCpEK3CPxdr1P7oz16Ijhl8gM43pSpJxi0=; b=EtPNEk0yAhszdEzjdKxQU+cjDh9xZDPH8f8ifDorY7CvZDjz1SNmZ5Po80IK7XitwgiOGIjMCJCem//3f+CU316Gy6f8oMYkcVnR++fJ1Pey0Y3e9rbOMqcuQ8hWnTgJbmnkoxgp9/bP7+bLI2gtJGuBdQ8HSAqDngL7RZr9s+xYCKs/R0dntPHqwvQw5JpcV84iFsUqqM2KGJVR8GO5NS3Tab5X3JFLAgWeDP4L9Ob/v4cDtD4kCUgyRl4yYPAmWQMdI+AwlMqESnYlJXctIcOOropq5pheNf008IhdTEWkbgyYesRmwOIysY4JukhZeA6MjTVKkRLCp41u91hOqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=h0Vg++G6NTCpEK3CPxdr1P7oz16Ijhl8gM43pSpJxi0=; b=Cd00ybCKl399H+E/B1wnopehOKsVBMkIS6/EnRp++F/IWYlAtcWOPWXCYwdvH+TsOsJSH4ThRxKEScVUgkXCsZTpGmMlPW3LtHvYIDkpdCFBmrLrsOiMf74ZANdM7uDi4GQt4LSEQ7jFUGlkOIuqT6ZeKi/S53+qYufTRaVIefs= Received: from BN9PR03CA0168.namprd03.prod.outlook.com (2603:10b6:408:f4::23) by DM4PR12MB7575.namprd12.prod.outlook.com (2603:10b6:8:10d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Thu, 10 Nov 2022 17:59:42 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::33) by BN9PR03CA0168.outlook.office365.com (2603:10b6:408:f4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Thu, 10 Nov 2022 17:59:41 +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 BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:41 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:38 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 8/9] cpufreq: amd_pstate: add driver working mode status sysfs entry Date: Fri, 11 Nov 2022 01:58:46 +0800 Message-ID: <20221110175847.3098728-9-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT005:EE_|DM4PR12MB7575:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cb6216d-e96f-418a-d98e-08dac34557ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yjAyGGgTmT1W6RpohkG0NVB5OLBds/gnAV1rJZ9HDljs664kgw1Q+JLBxPrSWXLbhp5rTMYxilUleWLp75EypGJ25fCidRQdKMXNu60MDUesxoYiUtHhF7CoKNlCiauZGcsqIsWbMKKzJQpHFiZW014AJ6ueIK32LU0SiU7GNkr5ZiEsfPeGanc71q1niYEi+ufMMV7btkvDTeQOEEiiPLgye7YAXi6AFSfO+4mjg1TSzbYg3yUTdi6juDaEb6gc1Atx1sIhqItBwmDjEFcLL8ngXibkO5qIm0jXj9oxXWfhmUeBJ9UnQOQsYKIOp9q9F67STrIPs1eb0+Ita+4HhCMppZnZ3dQjUIXJL3e6RvHdIl+M/3FsIiTJbu7nRb6OlGTIWeUXeIiP3s9LQgYSbmvPkbhd9JY6ACe0xibQ5mNbR4LZWgIKjWpOeu/pa8XzeaBMe7kdvduq4NAJTkk4DSY/h8d5EaFfFuHgUEsGO3U5l0hnBgTKEy8RFcqBhZt8QCUBCNV6In19ToGPLaWf4lbNnO7YYgQyDXvjJcE1nTlIrJWu4k2uVpKqLsA+x/TUHybb7aLwU/WEngXzUkbjY7Cia2DrqAahRXwW1m/p3179BlYHLKJWoYExfUYZ9wiGGTvZb45sF4Isgu5SvWrDohysX+HbRIGfaZL8zfjWQr88v3wuhjKUP65vFY/+mMkJMg8tBT4AlUwgYuJTD7mZpwH2/dm9vNEyuqnx4VwCQ04RDGgTgqeKsDPlCA3mygCZuYn2/PKWrv1Grtdd5wRsuy44GzcgpcLacHGz1/oI06A= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(46966006)(36840700001)(40470700004)(40460700003)(356005)(6666004)(86362001)(426003)(82310400005)(2906002)(1076003)(16526019)(47076005)(70586007)(36756003)(82740400003)(4326008)(81166007)(83380400001)(336012)(41300700001)(36860700001)(70206006)(110136005)(26005)(2616005)(7696005)(186003)(8676002)(54906003)(8936002)(5660300002)(316002)(478600001)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:41.7114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cb6216d-e96f-418a-d98e-08dac34557ae 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: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7575 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133553163142221?= X-GMAIL-MSGID: =?utf-8?q?1749133553163142221?= While amd-pstate driver was loaded with specific driver mode, it will need to check which mode is enabled for the pstate driver,add this sysfs entry to show the current status $ cat /sys/devices/system/cpu/amd-pstate/status active Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index b71bfbbb7639..6a3b610cb084 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -65,6 +65,8 @@ static int cppc_load __initdata; static int epp_off __initdata; static struct cpufreq_driver *default_pstate_driver; +static struct cpufreq_driver amd_pstate_epp_driver; +static struct cpufreq_driver amd_pstate_driver; static struct amd_cpudata **all_cpu_data; static struct amd_pstate_params global_params; @@ -798,6 +800,46 @@ static ssize_t store_boost(struct kobject *a, return count; } +static ssize_t amd_pstate_show_status(char *buf) +{ + if (!default_pstate_driver) + return sprintf(buf, "off\n"); + + return sprintf(buf, "%s\n", default_pstate_driver == &amd_pstate_epp_driver ? + "active" : "passive"); +} + +static int amd_pstate_update_status(const char *buf, size_t size) +{ + /* FIXME! */ + return -EOPNOTSUPP; +} + +static ssize_t show_status(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + ssize_t ret; + + mutex_lock(&amd_pstate_driver_lock); + ret = amd_pstate_show_status(buf); + mutex_unlock(&amd_pstate_driver_lock); + + return ret; +} + +static ssize_t store_status(struct kobject *a, struct kobj_attribute *b, + const char *buf, size_t count) +{ + char *p = memchr(buf, '\n', count); + int ret; + + mutex_lock(&amd_pstate_driver_lock); + ret = amd_pstate_update_status(buf, p ? p - buf : count); + mutex_unlock(&amd_pstate_driver_lock); + + return ret < 0 ? ret : count; +} + cpufreq_freq_attr_ro(amd_pstate_max_freq); cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); @@ -805,6 +847,7 @@ cpufreq_freq_attr_ro(amd_pstate_highest_perf); cpufreq_freq_attr_rw(energy_performance_preference); cpufreq_freq_attr_ro(energy_performance_available_preferences); define_one_global_rw(boost); +define_one_global_rw(status); static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, @@ -824,6 +867,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { static struct attribute *pstate_global_attributes[] = { &boost.attr, + &status.attr, NULL }; From patchwork Thu Nov 10 17:58:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 18265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp295452wru; Thu, 10 Nov 2022 10:09:34 -0800 (PST) X-Google-Smtp-Source: AMsMyM6uYnt4KyRJxXiBv4XshKUPdBOEjS31+gbCSLluXo0iOXmNCtXAwb/DsARKjGY/QQ/oG0DE X-Received: by 2002:a17:906:7d4c:b0:7a0:b505:e8fb with SMTP id l12-20020a1709067d4c00b007a0b505e8fbmr3380110ejp.281.1668103774336; Thu, 10 Nov 2022 10:09:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103774; cv=pass; d=google.com; s=arc-20160816; b=F13/Z+TKEKADQZ7BOrxL8FpPUfcmCXhAimwL4h95S7buG088MyVuKS0cV3gouTfr1F LzMLwLN8FkSGssBVIR6DCCEVSqAeQaimhaNbjRc3wLnZhVA9CsRorXYI3k8cDhwDCmaZ 1aCiz3rUWQ51IdVNvlrVMYAW8JFfAzlUswldrqmrCVGidoLPjrrs2/Dpi/gMipehXxd9 +OYBAeS9wS42/h4OGCt+ELHwJhFEuGPwtS0RY5Hqin/JvZCGhM2eqOU1Ievolz3gMkQ+ fBoQhmXUy5xRCxeX5/XU1riB0ja1mDAaRHAs0/1onnY3EDb5T/A1iXqxuhDmiVxM6Yg4 L2fA== 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=UlQqrX4X2vwY4rfCZlUSL8UAgHnVKaiMh1Q8cKzN7Qw=; b=Ao/C5wBuFGGrk6qixhPeuEJOJ2VrKLknnpp6iV3U1Z7Z/tfTJ+1QAvK2wjpcm9DW2V tcIq33toBQSVWJy6nBDhzXzsE5dxj4Vr4NMcigWJv5MTInHZqqXcpatMaxngYj6WPRwK rEXCGHFTplOD3DtXAIG8VPnwt2y14HQ4lr2VDE/7+dYeBL3llh6g8+k0HHz+2ijwVI3n nkCKHufCFGSq1ePPKMBml8i4gNG/Mf0qHGHPKg5zMjbOto3sLZHPnDTEPMPR61MLJKd3 bmzRGw+4ro8sQUtuz0Ay11VuzstHegCkPJsdTEQUWEoO1S74w0yGNC1wQiGeFI8R6nEh 13Kw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=t1VDD1KC; 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 ds6-20020a170907724600b0077a19529760si4842ejc.65.2022.11.10.10.09.09; Thu, 10 Nov 2022 10:09:34 -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=t1VDD1KC; 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 S231714AbiKJSAv (ORCPT + 99 others); Thu, 10 Nov 2022 13:00:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbiKJSAJ (ORCPT ); Thu, 10 Nov 2022 13:00:09 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2084.outbound.protection.outlook.com [40.107.93.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A09684D5C9; Thu, 10 Nov 2022 09:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eBopCSqXuwaBR8PfOexIfnh12cOCbTRJsNJXsW9yMlpDoQeS18e9MHVQ5yb4XQOH8WXHzNmw7FjToL6aGdrztFjefoeo9qSDk/35uDRG1v7/T9wnoiIGE8YjqK3F4Us//U3Nj29tJuZp9s7fdSkD7n80c47gBXlVg7+7tHZicyg/713huECScWSEWUVdeiC3HklBdYu9kKFJwfu3qvxdXjsgPY5jMp7X868fR1ZVAoGLkpcyFp5eagNLRJ3Ch0/JdjRb4WjdH+SXRbApMQejUnGCBYR64kH53j29M5Ljbc1TTul+evC4k0/G5S2fW20folV/VN75JZByKRJFFLuq1A== 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=UlQqrX4X2vwY4rfCZlUSL8UAgHnVKaiMh1Q8cKzN7Qw=; b=liN77i+JoEyUuJOXt0YJ393JGYbVVwWn2ccUVI69QieTBU+j/5CCe4ZlHO/LTua3UJwAypNSyXLU0Yab/tWN2vyygAfxE6YJwc2gZyd8EmY8P73h8VPnmNsFIlLFWUI1p/pL8TG9tXn8mpxJZes5UQKODLBVwerGwz4hJy+7j1kKj+y6H3FDuGP8vTa5CQ9QCU/E31rhBlnlBwl0VAJ0A01Kguchpc84SgFl/+3Yhp+oe17h8mmju5mLyF9wtu+Kg7zfwjAuxqJYwJvpLpa0HWwcxdilxynn0uBGWRe2XWE8mwc07Q4nWRLAPYqJmxp9Bp4T3yldzmJ9WLQfHqo4UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=UlQqrX4X2vwY4rfCZlUSL8UAgHnVKaiMh1Q8cKzN7Qw=; b=t1VDD1KC1g9Aok0LItP1jGK9psyu+rf4L2zhZiahVHp+WrIU4V1+hLQosAL+xJEzLqQXfPBbMO416LmAqPucoxztImnvg8mooz1ll+0pOKvit/MaTwk8RrQiAuDAIXjDmb/y/tHpEafS5pmEOBc7z6KwONIAEbduv8FamxzN+zk= Received: from BN9PR03CA0900.namprd03.prod.outlook.com (2603:10b6:408:13c::35) by DM4PR12MB5103.namprd12.prod.outlook.com (2603:10b6:5:392::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Thu, 10 Nov 2022 17:59:45 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::15) by BN9PR03CA0900.outlook.office365.com (2603:10b6:408:13c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Thu, 10 Nov 2022 17:59:45 +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 BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:45 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:41 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , , Perry Yuan Subject: [PATCH v4 9/9] Documentation: amd-pstate: add amd pstate driver mode introduction Date: Fri, 11 Nov 2022 01:58:47 +0800 Message-ID: <20221110175847.3098728-10-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@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: BN8NAM11FT003:EE_|DM4PR12MB5103:EE_ X-MS-Office365-Filtering-Correlation-Id: 19ca713c-13fd-4e53-1129-08dac34559e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NQ7lSsyk58y/FWbsLOaXjI27X5Yovv8wRlppUD+bO/cf/Sdpv/VsLBqepJUg3TE6kbeuQBvN4eQMjfDnDLFoGB5e2wcoa9IBtSNCitJI/kEZ44ubKyBYK7juISPo2zAxwg5JT2c1QOCtAVxv03urANprondyiKZ/YFQFdhnNij8Eqnx17ZYbAczj773x3g30D180YyIHI1kJBaFkMlgOTgNiQuuKRvfkm/CAfnwbQtYp3bVtkKf2l9Mi1ljL/ZR3O/FdLfkXJb42jtX8wKYsC8+Mk6woKaIeNVbDaUkhwtyhkLZjsXMghUizylNBkmOxhN8heqKy6CB0D9Kt8TAiWPMbtN9ti8KAAUi/jriGJ91mkPqzM2Ltnk76E8TBdJh6dHGF/6URz7OTYDZQcogZo5rPO68JJ7N3jKf1Qvq3TmOSbyXhhT/q7MzwKm9JzyljhN+5Hh/OWyrf/bkjpo23PwAUkj4oOjDjFcO4cN+zL5jr7qhOwcE1MOHq9Ks7ctC2OxVWzNZdLACT5jqo0gcgCpjQ/6qra6RTwYhsc4r88hCo8bhgnGZjL+BRzDLOzWBjipSBga0ZXiTvyOVp1zNRI2Rp9wF0sDkw7S543DEabo7zTmoIQCfljEftB+i8Ia5oDf4PFRbwtusXw+sjVzAOkL36u1u5TiZaUhVdhKvinQAb6aha4gP+M/IBWBlPlQm/Py6RzVKa/9y88zff2fds/IThWa2N/e3Wwfy7yO4mZpJHTpLC0A8nhV628Cc3tSoRQok6lIdOWMxlpTnbQf5aCiOlbxuCwD3ESsFIh5HaOqT1hJcoQi+rptYbNSLenu6W X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(1076003)(8936002)(47076005)(426003)(16526019)(5660300002)(186003)(478600001)(2906002)(336012)(83380400001)(2616005)(36756003)(7696005)(41300700001)(36860700001)(40480700001)(26005)(82740400003)(81166007)(70206006)(316002)(8676002)(4326008)(356005)(70586007)(82310400005)(54906003)(86362001)(110136005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:45.3894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19ca713c-13fd-4e53-1129-08dac34559e0 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: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5103 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1749133583273082102?= X-GMAIL-MSGID: =?utf-8?q?1749133583273082102?= Introduce ``amd-pstate`` CPPC has two operation modes: * CPPC Autonomous (active) mode * CPPC non-autonomous (passive) mode. active mode and passive mode can be choosed by whith different kernel parameters. Signed-off-by: Perry Yuan --- Documentation/admin-guide/pm/amd-pstate.rst | 47 +++++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index e7488891b12f..6ba02a658b31 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -302,11 +302,11 @@ efficiency frequency management method on AMD processors. Kernel Module Options for ``amd-pstate`` ========================================= -.. _shared_mem: +.. legacy_cppc: -``shared_mem`` -Use a module param (shared_mem) to enable related processors manually with -**amd_pstate.shared_mem=1**. +``legacy_cppc`` +Use a module param (legacy_cppc) to enable related processors manually with +**amd_pstate=legacy_cppc**. Due to the performance issue on the processors with `Shared Memory Support `_, we disable it presently and will re-enable this by default once we address performance issue with this solution. @@ -321,6 +321,45 @@ If the CPU flags have ``cppc``, then this processor supports `Full MSR Support `_. Otherwise, it supports `Shared Memory Support `_. +AMD Pstae 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 choosed by whith 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. + +Active Mode +------------ + +``amd-pstate-epp`` + +This is the low-level firmware control mode which is implemented by ``amd-pstate-epp`` +driver with ``amd-pstate=active`` passed to the kernel in the command line. +In this mode, ``amd-pstate-epp`` 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 according to the power supply and thermal, core voltage and some other +hardware conditions. + +Passive Mode +------------ + +``amd-pstate`` + +It will be enabled if the ``amd_pstate=passive`` is passed to the kernel in the command line. +In this mode, ``amd-pstate``driver software specifies a desired QoS target in the CPPC +performance scale as a relative number. This can be expressed as percentage of nominal +performance (infrastructure max). Below the nominal sustained performance level, +desired performance expresses the average performance level of the processor subject +to the Performance Reduction Tolerance register. Above the nominal performance level, +processor must provide at least nominal performance requested and go higher if current +operating conditions allow. + + ``cpupower`` tool support for ``amd-pstate`` ===============================================