From patchwork Wed Jan 18 07:52:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45085 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2212284wrn; Wed, 18 Jan 2023 00:28:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXuff6wtmo2KGMQ+qTyKEMzutD609MYUTkYjwJLRcz6TYQlLsp+5/3cuHCmIY3NLxyOxd54S X-Received: by 2002:a05:6a20:6997:b0:b8:a5a1:ed7c with SMTP id t23-20020a056a20699700b000b8a5a1ed7cmr8852180pzk.44.1674030533493; Wed, 18 Jan 2023 00:28:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030533; cv=pass; d=google.com; s=arc-20160816; b=qWyNLdM68Mepu4Cby37n2lnbvclD0GStxpcljL6JipdhMRbJPLkRupcYZFp6+8rFb3 W+wbJq7WlWdcEEh4SZwtGixuSNlkHMN5uIe+fvBULg7TmXvLO0e1pHVd+AObT/zJiQzE CIcbK8Vk1BJvHpwvDzk2srI8fvDfJ1dGIuvTjF6HFLsNCTHKFOOQ8LZVbuvM41DusQFM Qs1tduuqO7Qpe1GGparRNp2bSpKIS2XTSkl5BWjVxtUUmcRs3k1rOzG3XQCYmJLrOuny biLetPMBcJRHkwW/8Yvg7rFJBYrbB1Q5cKWJWAmdsORcLrIkXC+9zlEzRkaSvPnCTqBW vtOQ== 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=y2kg3NyOxDpCcsc9p7SzAIbT3cisV55IEpKRJajCNT0=; b=M6c8zq13tRqrBNPOH+QY7ZB3RX2gPN4aOAPEeryZkFVQKWhpYDv7QmYvxead8+zWFl NsBSq1HqZnBwNCu/pDPF9oNjg9l60S55FjIMS+3bN3ZJwcmr9bRuPdybj+8ZMumtktMp jcJzkTdir8D52Jg9rTgIaxP2gR+OYdtmcCn1evmHEYSxk9QBfIm4uARUErG1tEWj9iuT CxRXtLg6soJHi1pLmWCQ6cpKHnlP3aUb+uv9Sw9AE0eZGcU2DjUroU+3TBraxhVtTGl1 lkAgaHr6C9tB1XaENMoS5AFfGVlz01HgyrYGfIuRc46RF6ltBvyQl8hCy9q2qfDD5yUo K5pg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1nhH+li9; 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 a19-20020a630b53000000b004774d8c6191si34925416pgl.413.2023.01.18.00.28.39; Wed, 18 Jan 2023 00:28:53 -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=1nhH+li9; 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 S229557AbjARI0f (ORCPT + 99 others); Wed, 18 Jan 2023 03:26:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2064.outbound.protection.outlook.com [40.107.102.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 816F75AB64; Tue, 17 Jan 2023 23:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgSontSLiH/G2WZhD3oC3Au9SDDc/UR4dFVrgW5fLEdkuSGF5EMPqM6u5dS9P9QcUuhs9BgFMd0Q//4SccHB5KrdToZ+6O2AWUkFigeeBnc5Tc8jrBBY8bQKTpbZL3Wqzd8FmkISS7KmEr7i+jOqbRIrPBapvMKEGYOon+RqjiOJCgID+KWkgnjW+8dGSJ8LC2gQOnvQNRB7nwcsYO0yeFElm0+6DkjOGrwvLd0+bfXVv0PcZnBPCs4WdApTM1NmPYQmTxDGYIfhDnPZnaUXeWVlk7Q5y8FtEqMjcqJ56jPPWUuIn8wNiYx7SqLkI0YB6pUSlWqaTlI2vplGlVvnmw== 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=y2kg3NyOxDpCcsc9p7SzAIbT3cisV55IEpKRJajCNT0=; b=nYqqPRMezX419ibe5kMZMFpePLhA19EKKlcYisnE3OEo9joyB3itZG9Tz7Y/FVRE++DmioloPkGdB2VyEags5RzSifNTd1bevoDzhsoU8KpOI4JoxPz7+jRwkUwFT7ffHufOUL9WqmskN/wen0Pr1n9W2BdywP8Rzm0SD9Bj3SL3pQnmuOcOxPKLX729b86bRp1bXxq/J9xbxsQWGMnLtw5HI1HiiBkA+cApcVQ//eHTYKL2FIXO4BBMdY+yjoWqmLXbdA06W++tVn3b9ol6hOGctsSD5w0q1jn2q5/eD7CnfI0zZAUGJEM3JhXFvbJ4aF2ZnkDdUmI5RfDAnJaK+w== 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=y2kg3NyOxDpCcsc9p7SzAIbT3cisV55IEpKRJajCNT0=; b=1nhH+li9KDgWXj5VbEnVKKyiD5gruhU4Vx+gVgL5kEeQHPhd+2YVAentuo6boTny2GVcdx5RscjwwyutIYGgUbwQ3x0Pb3BYnoaVK75wq+4RQWNK4w1oojTzYrctRzQ3LizlO95Z7mZKDtM46cJBfuFdpypgGfxqYM76QUQNHfM= Received: from MW4PR04CA0262.namprd04.prod.outlook.com (2603:10b6:303:88::27) by SJ1PR12MB6121.namprd12.prod.outlook.com (2603:10b6:a03:45c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 07:52:51 +0000 Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::c4) by MW4PR04CA0262.outlook.office365.com (2603:10b6:303:88::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:52:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:52:50 +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.34; Wed, 18 Jan 2023 01:52:46 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 01/11] ACPI: CPPC: Add AMD pstate energy performance preference cppc control Date: Wed, 18 Jan 2023 15:52:00 +0800 Message-ID: <20230118075210.447418-2-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT060:EE_|SJ1PR12MB6121:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ebb6237-10d1-4e63-1ce1-08daf928ff6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U18OPDA2v2uUoIgAD4jXjsXbnrRy1L1dpwjwKjLCmciM/TWlAAXB0vRXur1H1Z+eIprxVXDh5sgsGp7Ad6UiEhsPggbzcwX9oBLK/2z3+XhdhfjoQmNkZKY/TWFQBUJ7dBJJylJvWyEy+YGxZDhtBm6nO4xlDUcuXRi8Yqutr1bDQi1cTktTCehbTW7klrwVny44J2cNOOI55hj8i10AvCdNGXiaT3tomJctkIJQ9bSaAjgzCXu0okMcwcjVbyE/NeSx646tUlJ8X/7fmRaj9E6S3eG2ggFYrTyPzDMUHQU0DdT+ZA699eeypO2JoddawVSFUiVhYbbVkvpJgcfLSojx3EnhFznX5Gkaryyj8eQMEsJeG8XqeRVUG/Fd2jiidJDQ2NxYG1wYoZGnB3GZIdKZQ9SC9yhfGPL5lYc6LzIBlHUeanbUUTu7G+23XJ4LBz6QXTHzcPgwGiwz5tHuJ0k3Z10Vdk730mlyZFvn2EtO/0QDIp3WCCCj+l8KqeWSF+eTO17XJ+kyxP6SDQCxkHTVb1f4o/bh3ub4fil3nLcDtECLOZCDGImJD7I3mEgueFroUPpRamHxi3q8WL1uW7daNVxW6HwlF4TpB/y9RK3B1gEMmY5nWYt+HDzwBoy5fVUJ5d6R2fJ+NWZ3tuMc7oal/AEOet8vf76NZwPbe8YxwBShBcJiONfJLFN33xQvdoRsS4eJ80R3zWplPFuUx5BCbEtllMVtjqncufNPV7M= 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)(376002)(396003)(346002)(451199015)(40470700004)(36840700001)(46966006)(41300700001)(8936002)(1076003)(36756003)(336012)(70206006)(110136005)(70586007)(2616005)(47076005)(426003)(54906003)(8676002)(83380400001)(4326008)(316002)(356005)(81166007)(82740400003)(82310400005)(86362001)(2906002)(44832011)(40460700003)(5660300002)(40480700001)(36860700001)(16526019)(478600001)(186003)(26005)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:52:50.3936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ebb6237-10d1-4e63-1ce1-08daf928ff6a 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: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6121 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?1755348240796264144?= X-GMAIL-MSGID: =?utf-8?q?1755348240796264144?= From: Perry Yuan 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. Downstream drivers that want to use the new symbols cppc_get_epp_caps and cppc_set_epp_perf for querying and setting EPP preferences will need to call cppc_set_epp_perf to enable the EPP function firstly. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Reviewed-by: Wyes Karny Tested-by: Wyes Karny Signed-off-by: Perry Yuan --- drivers/acpi/cppc_acpi.c | 67 ++++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 12 +++++++ 2 files changed, 79 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 0f17b1c32718..02d83c807271 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1153,6 +1153,19 @@ int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf) return cppc_get_perf(cpunum, NOMINAL_PERF, nominal_perf); } +/** + * cppc_get_epp_perf - Get the epp register value. + * @cpunum: CPU from which to get epp preference value. + * @epp_perf: Return address. + * + * Return: 0 for success, -EIO otherwise. + */ +int cppc_get_epp_perf(int cpunum, u64 *epp_perf) +{ + return cppc_get_perf(cpunum, ENERGY_PERF, epp_perf); +} +EXPORT_SYMBOL_GPL(cppc_get_epp_perf); + /** * cppc_get_perf_caps - Get a CPU's performance capabilities. * @cpunum: CPU from which to get capabilities info. @@ -1365,6 +1378,60 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) } EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs); +/* + * 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; + + 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 for CPU:%d\n", cpu); + 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..6b487a5bd638 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_perf(int cpunum, u64 *epp_perf); +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, bool enable) +{ + return -ENOTSUPP; +} +static inline int cppc_get_epp_perf(int cpunum, u64 *epp_perf) +{ + return -ENOTSUPP; +} #endif /* !CONFIG_ACPI_CPPC_LIB */ #endif /* _CPPC_ACPI_H*/ From patchwork Wed Jan 18 07:52:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2212589wrn; Wed, 18 Jan 2023 00:29:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXsaVKWwNlbItc0bp5qZTV0YU8jkNaI3ZmM24DFU9t/xASwZU7zVnJDcHGjBR1y+4mv45yfg X-Received: by 2002:a17:906:a058:b0:84d:4e9b:ace5 with SMTP id bg24-20020a170906a05800b0084d4e9bace5mr5410507ejb.67.1674030592500; Wed, 18 Jan 2023 00:29:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030592; cv=pass; d=google.com; s=arc-20160816; b=nPgosv1pmrKQytzl+wQP4ing4Y05vn9KB0rBmwmm3JZlXZtUsoxy1QYPDx4j8fjdm+ Cb6zz2t6d0g7G9geKlGjTB9BjckA9GlH0E6NzD+7dDHmgPz3dULxMPTNZ2UUBMxthkni rq5FM9exdhatHq7CswW1lgqvRRXRx3+vPv8f4ln9vWNbaZ7V1aOBnWFNVgjicxrOCcSa +fTprzqCOpnYigME36YYKGYHkCnas841CedcVRXXZMkQ+Dt2lckutx2SA56PPo5b5+MO ROYbkW5osqBqPgau5RMB/jEaHAVDdBHH5pZGNcDrduc7krcaxwiY7D1HHKtMxx4DwSVC n6fg== 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=Jr7Q03mitAi0UxfYb0SVlJs7m7zbY4Hr7jcyAHdI43E=; b=PTmbE6Pq6lQj0FbVYJomleU7w/L9irllWi4lzV9sHJlyX97QUPonzRhgjjTiRjwSoD xYKLmwyx0novpQkLHf2Rx+jih7vmOg1AkQKU6f2JlO9SamTw8O3O85tEOOFdP994XsRo 0VU9wT76/+lmfWDvZQu7sv9l8+or7jxInP2MsaFP29lKoA5Qhqpl1QxPMg1rw7IBBYT9 bUufV7ysPPTu1e3wiaPEYCdSr4DkKOmL6Q4gYDFVL1RtfE3l4tOGZVjUQJcxcDe3sOsw 7FTuPLDLkuUzzGias0rR5iTnqWAr6QHHci79dTv/butURDRzYpEzATFRFaGeQvZ56vSU 2aEA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=EGKpOKCX; 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 cw16-20020a170906479000b00876a2339b76si2393181ejc.400.2023.01.18.00.29.22; Wed, 18 Jan 2023 00:29:52 -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=EGKpOKCX; 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 S230060AbjARI1F (ORCPT + 99 others); Wed, 18 Jan 2023 03:27:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E1985AB66; Tue, 17 Jan 2023 23:52:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O2Owtn8JioG1hbivnxfce4XmgGmayDMHbk7BU+iD9a2c6/ANaBinCdRDlkWxpPiYLB6aBsOu1EQI2GLOsimHU6CiSYMm+ZtPEho1Ti9L09UpW23hrVIos6x//wnxaMImBOT0a0QyA60G0/zwlMTYrmMJhXjWIzuzRzLIJc//v0V7ol/K8Pf3ASn0EJ42RoDp2UiNQd2H4juHAatsdI0Ecvy81ftYqX3Cl+vIR3zqKaAkOARDlbkvwBR7nmaWM7G9zM6zPJtO/WVhU5EVdPzTDrK0dkf+aHEQ7GRsXFQ4OroQSP374360jSSiBluJxg7eX/YJJ4nagzQrr3JOMkAMhw== 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=Jr7Q03mitAi0UxfYb0SVlJs7m7zbY4Hr7jcyAHdI43E=; b=mE+YzDhT4VV+2RCkZdeX0uf4WRvAYS1aXOKl/BeLiBKFBzAiDGfQQ0MWPA8ahuFkXU2OF/9bJKuBDHIh6wEYES5tK/B5E744cP/9eiJdinFfwY34T4MIFB6ZTkrjzqe6bsyWDfaqechnwwOTqjV/bDXTIrGnerM4murngmEpG13rac3lRGgj01DFLNWWEYyDSXlKluS2iiYqN46EUfnhWq43F7m5xB4GPke66wnwVXosyz0wvu3kiJ34m58dCY63/2ta60JM697cYz75nnycHG/z8AXMIFiZ3d9qH1btCZ20A9yMuApPa6+E1JBsnNAK/upMRzYzfs1tjEXf/Z74dw== 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=Jr7Q03mitAi0UxfYb0SVlJs7m7zbY4Hr7jcyAHdI43E=; b=EGKpOKCXlDl8yLNXRT4E2AHCVAYH12OgSVhhH02tyQvv/XW+3tMwBcj+fQZU39Pl39RwGqjgSKFJNSkgX1+U6lEmiNKURa0S/TrOn+iJWaIRpxRpv55v6UPX1f4fE+PuxvVpBhOtbyYIZfGbaTDhuFYm3VlVvZfBwcXtnn9tvks= Received: from MW3PR05CA0024.namprd05.prod.outlook.com (2603:10b6:303:2b::29) by SN7PR12MB6790.namprd12.prod.outlook.com (2603:10b6:806:269::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 07:52:54 +0000 Received: from CO1NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::6a) by MW3PR05CA0024.outlook.office365.com (2603:10b6:303:2b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.12 via Frontend Transport; Wed, 18 Jan 2023 07:52:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT061.mail.protection.outlook.com (10.13.175.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:52:53 +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.34; Wed, 18 Jan 2023 01:52:49 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 02/11] Documentation: amd-pstate: add EPP profiles introduction Date: Wed, 18 Jan 2023 15:52:01 +0800 Message-ID: <20230118075210.447418-3-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT061:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 42618b67-1d9f-4289-4584-08daf929014d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BGnbmqQG7rjJx8Iy1hF9LTUlk8uNY8Mw4JK5ifQ5H90nRc+V3Gdy0bHQmB4+RSBD0d1892513+a9rPToBPdsnQCtri5gpqOT1BLY2q9LgiMLLVDf1u9ecrItiYcGkRUd3dHWkRsh8/6q+2uMK0ppKLkEj2syBM1duP3ynaScNk9gW+oEHgqFE71DZCy2vvFnHGNhpiNh1AMCD8rjXhXkDPWc6RVPuM9EdXFj7YROa7L88rmM6S0LGJF45LNhGPBxM1IU3QG1Vv7xmj1Z4uuWdZGITywn1OFwlzWxxLihiNCxlA3FSr60kPBA1WAbJ5+ESrHWaU0Vuu4rhZg3u4l8xgmJiYiXapRAReU63CXnVP8/eIY3I8d3ARVqRf/9VFwVdwNeQKK4YwBlInTkcOQ44u/51YUQlZsSp2DmgD/uHt4oP1BtVvDQC8gIa3gbtDWppFgLAxMJoM+ymnm3oNtxyikU/RnvpMoPScQn9PUf2KIVWD7FmGAOOR0yR08EO737E+4xMTlCR4n48YyXLJNkicsdGTE+A/qiPl2FGTa1flmiQ/GcvtNEBf6uRY65MC4S2hqZX1H87raZ8YPWG9VbtNA3aKXNmtqTzleDd37zdaMFzSzhmOo1JeUUFgHXb4wJ67KdOrKxRPMP544gznU6C4Xh9cPQe/F9uWfkcQ5r26IGf+SvSt/Wk07Be/QhjUkajPATJfEjIYvBxwEJZRwifcPGcGiXHsigx2cUK8sXh6I= 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)(136003)(376002)(396003)(451199015)(36840700001)(40470700004)(46966006)(36756003)(40480700001)(54906003)(16526019)(40460700003)(478600001)(110136005)(7696005)(26005)(5660300002)(2906002)(186003)(41300700001)(8936002)(316002)(70586007)(44832011)(8676002)(4326008)(70206006)(86362001)(6666004)(36860700001)(356005)(81166007)(426003)(336012)(82740400003)(2616005)(47076005)(1076003)(83380400001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:52:53.5757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42618b67-1d9f-4289-4584-08daf929014d 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: CO1NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 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?1755348302263256662?= X-GMAIL-MSGID: =?utf-8?q?1755348302263256662?= From: Perry Yuan The amd-pstate driver supports a feature called energy performance preference (EPP). Add information to the documentation to explain how users can interact with the sysfs files for this feature. 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" Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Wyes Karny Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- 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 5376d53faaa8..98a2bb44f80c 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 Wed Jan 18 07:52:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2212912wrn; Wed, 18 Jan 2023 00:30:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXsAA34hqeFvJZsOMXWaTJmeeUezyUhCuv04H1bLxQ/vxHTrxdH3h18nFY02sbrLRNQTpqAK X-Received: by 2002:a05:6a20:1b28:b0:b8:ca34:fd5a with SMTP id ch40-20020a056a201b2800b000b8ca34fd5amr4856015pzb.47.1674030646334; Wed, 18 Jan 2023 00:30:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030646; cv=pass; d=google.com; s=arc-20160816; b=Is+pqSmE3Cb88YkeEVX2OjiHTnuOKPjnZReJ+cOgSpCNBityulbU7qe0yGE3onWo9o l+Vx32oPkK4de89BY/GI7Q3gaprwDzC9R1jpRaXTvKNWugdp+n8De4YrKHRjyIIZjCld wWY3YK4URBrzFDzPaMVYarV+8mX5MbRnTLGThjbqw72Eq8cAkEirDT9KRtPUslbkxf3t KdAqvVKhY2yttBeJA5La1qNahqfGcFWOfdDq+uu838MrzL7KaME0ZSKmMHEiTrZu4FOr 47XO07ZXcDfoSq9OI/1dWoHUpqF+RMnjRc/RR4Q7Wf+f7s6Om2qvFg3TlhqFURswBQlq 9V4Q== 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=7ScW1LtXgXIQDtt8ttZjbM43sDYvxe8vg4oSuwvrVqQ=; b=skATo6yhUzOFG8ad1xSIos4Iqs9H7Qa8mrg7NqvP6Eb56DuHOPDMMKDCEliroSPGVc VNsw8EhMtG+VZvpaX5blYsuHlzQt3Mlx5GIJPUuRdgui6OyZAo5OVo34iHyb4ES5ApSQ L4wxwqc8gDLHntCxOoQi0MQpEidsVNj9ZVR8Lb3uwyiPy75f6eaL38iB9GoV5k8ner6p shGehha0Y89cD42ecQB6Aiq+xBystU9GU5UbofBdN6uOBo1wTH/Lplhvzl/ETTa2EBCp TRUroGd/ZV29NPyfCf4H/hZR44RFGnFrizZJdmj30ONmN4l/M7P2ivnLOXUJL4N1vHUb l2kQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=K7A4bXYY; 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 16-20020a631950000000b0047868802927si34080477pgz.818.2023.01.18.00.30.32; Wed, 18 Jan 2023 00:30:46 -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=K7A4bXYY; 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 S230131AbjARI2K (ORCPT + 99 others); Wed, 18 Jan 2023 03:28:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2060.outbound.protection.outlook.com [40.107.96.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42A35AB69; Tue, 17 Jan 2023 23:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hQgZ9DL1vDdlrJVIWumjxwqajufWvMv8oAn4q/koUe7i8rNv5VqJnUjefHFSNhHyW6iofpgiyxO+npVlP4N8u2/IqpJ17MVrplfV5k63JUkdI0GB6d/IBuLTVAfKZOzVDJ4lPghMRhM+68P23Dl1kpFSzcgR4QrlYA9u5QpubBR3j2M8UIr83TRmM+g2XfkelizVdccdw3i653bXrGKO5VpOP6ZJuvH5KnYi0/CUlOuwQiMNSKxFvJKEoT+PQD07KGt8BmNoEuidmlBVf/9+bxZz3gv3pvciNlCw+orGBjUUmMEpVsoEV1xUl0oGfrK1Xz9gVT2cMkZqeOtKI4ncEA== 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=7ScW1LtXgXIQDtt8ttZjbM43sDYvxe8vg4oSuwvrVqQ=; b=gzAsDWFOgCFFIubjTPO33YcNULqOqju1gCYOeI/4Iyayg98YjOk33kNFlC8SKJboJ6ZJ3pb2jgFJ683HUhscHJNK9K3QuDdnXHf2AswUppFF3C1IiCCTGlj2dNroD9lnOOV68RDlbdCL96nBgSgE+hSK8cM+jTg3bdwsq68rblEbHIRoXHemWM+X+OB2fM+5We9Qxhzwh6loVZJyWq5vFIJFR5ZtqMLsER7yIkuTDO3G868oJk+uf57AfGc9hCeOiTadFGJ6Vk6H7AYwYhPJVG+Zikvf6krZbGrxH+MC1mB+/5sdR8DotV9EqVl/T6o6lGiBv5pvFjQrEn/Zae7pNg== 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=7ScW1LtXgXIQDtt8ttZjbM43sDYvxe8vg4oSuwvrVqQ=; b=K7A4bXYYy4yd8feV5rDi8qBYXR+cVYVicXwprKu/W89dwdmtdqYuQkED+khhLARiUM+3N4PfcqT4bstvMJX0JrtIoZTBEcQy2N+MN5xUZJ/JZGTS8maeki/CB80sBUeFbrOhfP74QVAnepQlBuoCiJCsw5HHg0SunEuhWge+VWE= Received: from MW4PR03CA0221.namprd03.prod.outlook.com (2603:10b6:303:b9::16) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 07:52:57 +0000 Received: from CO1NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::b1) by MW4PR03CA0221.outlook.office365.com (2603:10b6:303:b9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:52:57 +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 CO1NAM11FT007.mail.protection.outlook.com (10.13.174.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:52:56 +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.34; Wed, 18 Jan 2023 01:52:52 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 03/11] cpufreq: amd-pstate: optimize driver working mode selection in amd_pstate_param() Date: Wed, 18 Jan 2023 15:52:02 +0800 Message-ID: <20230118075210.447418-4-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT007:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: 83af8b8f-aed3-4b1f-afab-08daf9290360 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tVxm22j04Y+5pUNhF7PTfNUsL/dSOMFP8foRVSTtTNdNMSkCn+xuEyNDnSjBuQ/liHkMmCsywi1fF0Wpvl5/krqn942NpG/yZ1I4TMwZjRwOnxHeoJipXxw5lK0VpxRDw6WnIVISUMzI/9V00pj9HPTXCPXZpx16n736gy0abcfenUL/rBiTEiM4zZ/vhSSen4wliek3cz+GRNQ7yRXqmDFkEz60pjUDdMO0HDDIZAoHrdu3DvlgmOC89HFfjhTr7kQMJUgFSrmPBYIdms95e+LJ0eDtUoF0POxpsfBjyb15IPF2reTm2qvdSevrO29lixyVXzO9NRhL9o9RFzRXtLWs0UPF4Fl03dAut0mmacZ0MGSA29JWbp2fVg6fsdZhPS+kDM0enJBkGtVB9qxGjnaTojg/N2rnIVKAIHmeVoOkJtKjsnwHNHFtzt4s7qNV55P0EsyoLgow4OXZSJvVk2uypv4kor3HbxlFWvB5HrbbeU41qN1A6m52mf9UaKryiDiDWYiQvzGuOnFb0p25Oh2pguiDqscPsKjMY1rpDa6ps5E6lM/hv79W9BqGdyLnHbAFJ8JNYtdCv7FKgVjB1DN8IRzJqjaGfygbIH+RvUWxu5sgsaoCeoSf7cGP5NFDItCvZ67T0N8TLuD6/NR1jGrbH1SFManetrEr//Tim6vYrL4F6igD5fZ3TRvZOLJ3cK+m4jFJGixjpvekjgTBJvTi1RJYlpQWefRr5WrApSM= 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)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(36756003)(82310400005)(70586007)(70206006)(4326008)(86362001)(26005)(186003)(8676002)(426003)(16526019)(2616005)(41300700001)(47076005)(316002)(1076003)(54906003)(7696005)(40480700001)(110136005)(40460700003)(44832011)(6666004)(81166007)(356005)(2906002)(478600001)(82740400003)(36860700001)(5660300002)(83380400001)(336012)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:52:56.9802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83af8b8f-aed3-4b1f-afab-08daf9290360 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: CO1NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 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?1755348359165971197?= X-GMAIL-MSGID: =?utf-8?q?1755348359165971197?= From: Wyes Karny The amd-pstate driver may support multiple working modes. Introduce a variable to keep track of which mode is currently enabled. Here we use cppc_state var to indicate which mode is enabled. This change will help to simplify the the amd_pstate_param() to choose which mode used for the following driver registration. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Wyes Karny Signed-off-by: Perry Yuan Signed-off-by: Wyes Karny --- drivers/cpufreq/amd-pstate.c | 39 +++++++++++++++++++++++++++--------- include/linux/amd-pstate.h | 17 ++++++++++++++++ 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 204e39006dda..1a8b31277620 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -60,7 +60,18 @@ * module parameter to be able to enable it manually for debugging. */ static struct cpufreq_driver amd_pstate_driver; -static int cppc_load __initdata; +static int cppc_state = AMD_PSTATE_DISABLE; + +static inline int get_mode_idx_from_str(const char *str, size_t size) +{ + int i; + + for (i=0; i < AMD_PSTATE_MAX; i++) { + if (!strncmp(str, amd_pstate_mode_string[i], size)) + return i; + } + return -EINVAL; +} static inline int pstate_enable(bool enable) { @@ -625,10 +636,10 @@ static int __init amd_pstate_init(void) /* * by default the pstate driver is disabled to load * enable the amd_pstate passive mode driver explicitly - * with amd_pstate=passive in kernel command line + * with amd_pstate=passive or other modes in kernel command line */ - if (!cppc_load) { - pr_debug("driver load is disabled, boot with amd_pstate=passive to enable this\n"); + if (cppc_state == AMD_PSTATE_DISABLE) { + pr_debug("driver load is disabled, boot with specific mode to enable this\n"); return -ENODEV; } @@ -670,16 +681,24 @@ device_initcall(amd_pstate_init); static int __init amd_pstate_param(char *str) { + size_t size; + int mode_idx; + if (!str) return -EINVAL; - if (!strcmp(str, "disable")) { - cppc_load = 0; - pr_info("driver is explicitly disabled\n"); - } else if (!strcmp(str, "passive")) - cppc_load = 1; + size = strlen(str); + mode_idx = get_mode_idx_from_str(str, size); - return 0; + if (mode_idx >= AMD_PSTATE_DISABLE && mode_idx < AMD_PSTATE_MAX) { + cppc_state = mode_idx; + if (cppc_state == AMD_PSTATE_DISABLE) + pr_info("driver is explicitly disabled\n"); + + return 0; + } + + return -EINVAL; } early_param("amd_pstate", amd_pstate_param); diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 1c4b8659f171..dae2ce0f6735 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -74,4 +74,21 @@ struct amd_cpudata { bool boost_supported; }; +/* + * enum amd_pstate_mode - driver working mode of amd pstate + */ +enum amd_pstate_mode { + AMD_PSTATE_DISABLE = 0, + AMD_PSTATE_PASSIVE, + AMD_PSTATE_ACTIVE, + AMD_PSTATE_MAX, +}; + +static const char * const amd_pstate_mode_string[] = { + [AMD_PSTATE_DISABLE] = "disable", + [AMD_PSTATE_PASSIVE] = "passive", + [AMD_PSTATE_ACTIVE] = "active", + NULL, +}; + #endif /* _LINUX_AMD_PSTATE_H */ From patchwork Wed Jan 18 07:52:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2212914wrn; Wed, 18 Jan 2023 00:30:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXsMaxD3/yFUJXch6gj01J+2M5IxXpCTKP6N43EchV/tMKFKvSoK9SduBHIcHHoROFVcIkmC X-Received: by 2002:a05:6a20:6f61:b0:b5:a231:107f with SMTP id gu33-20020a056a206f6100b000b5a231107fmr5469851pzb.12.1674030646366; Wed, 18 Jan 2023 00:30:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030646; cv=pass; d=google.com; s=arc-20160816; b=SBvGdC13ZbksWLv52KlzBq/phGe5vdhJUtmw8DjRy9D6gY/LTML9J4mmqiM8j8p96y Pd1Oejv+LTc4xxdJ6cJiG3fCXK57H1lSI2U6nukGH1qH1YwC1PdTPdlc7GBVML0bcBAO MtLRGuu2jg730HnL9GJYE7fy3DiSeu3A5HrdZO19sj6DS2Lnco35FQkNPwZ4bmsq7gTS /BcWscHFRv5DhUVHrMGmFKj4h658aNlP1CRfW92sscwNVnnC4L8T0kk8HtLYLNokiKKp kNuiAniQyZkgkbGdAJebqD9EOxyMAZw+pyRWMpsj/CNSpDqMxaQ5w06MTXNgp86m1FGI 1f7Q== 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=HwFEcAB571EkOO5sjjGRQj1LRlbCSDEM7z36Kq28YtE=; b=kTLIqhGqm/ijO50paj84V+eYlf7cbHsgMzjrLCxr3bLv48JADGcNT8mT+WXHtJq/qE /U6plFGrF7YrwAczjGk7eIFW0CuBoggAWkeluJBD7xhscKjaDCs8STe+jJC5nPPNMsK4 m+OdnXnseA0A+W8c6HyyqHpoGFlU7seebwL8TjiReoujS84/RAefdsTxBO1IDy7sVY3z ATPU4q8YCpkbx7vDuWnHxXmuZ4Sk6YzS3JX/rcM8otAKDW8YxtqZs+dWbvt3boYNyD1f lXZcC3gzdnzOo9K564cosKtw8a22esK1Yzg65yXv4tDr/XY3vN1KcgSZXOg0XQM2wUnQ vJ7w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=nYGpt6S8; 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 126-20020a630184000000b00476fdba9e11si33681696pgb.622.2023.01.18.00.30.32; Wed, 18 Jan 2023 00:30:46 -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=nYGpt6S8; 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 S229789AbjARI2e (ORCPT + 99 others); Wed, 18 Jan 2023 03:28:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68D625AB6A; Tue, 17 Jan 2023 23:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a0493iDfVEex6UqUnad+kGXhflaXfRkAXHv7LAjpiM3c8DCgM604CW0Rgf1sOVE4zJ3M6ov3MU1xrC3fOAYDe4wr96zEYcutgX8bcYVjZDXsApAueEOd4SYqZ0FCCzlj/Tm6Mui6a7C+leU4drHs+Jbgzx47NLsxyzFlfueJP9bEZfK6nW03qV1X51NHVYZuIAm2lpux1KGPSOuPVrXu3TyOeAyqtWPH0XrbTrtIoWZCX1ZicZG3lgl1H7kapqoglvFmj+YBKkAKCh3gAecWQiqvjx+E72HGtTT4VudPXIw/j2dr9TNsG+J07o9zfZLTmhrp/tQ/0JepfHogoQl1tA== 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=HwFEcAB571EkOO5sjjGRQj1LRlbCSDEM7z36Kq28YtE=; b=OTbcEwRcuuxAJnWbowAPOJZTyoO+M3yK8gbswP4efZlc6XhSK6RJJTOTkWyjGOu1w7ZlxWRqMjed4vhtk0L9RHNpFRWGtxxHWqtnnJxWVNv5saLlFiblmdoJOTIOkquufJBlq/+FySrEvqg6/C6T3b5TC7npYcS/JgTkQ0sWdrxoSm67QswvyRAgW9sJyYA7DYFWFnuLOUf8gzrRhzq54330mXuQQIZT5EkCiD+4znCVF0WS9QaqPuKJb6uFdusgCYEpBpAV6mLIG84KezJJ8SAV7f8reoie6xL9IdbqmhyEAjS3sxza8Jr/FzuMa2SxjhODYjL8J0Cy3aMLMamkKg== 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=HwFEcAB571EkOO5sjjGRQj1LRlbCSDEM7z36Kq28YtE=; b=nYGpt6S8SwdGjtm1pVDeuuDmN8xvWpM0K3SbuU4GmASlNKwo4QtEVqx0Egqw+dtwUhaj1CPbTggKvTlK0c7vLU7GPCg2x2jqpIm0/ct18gMiOl+/kgKJHxXDikEAV2VajxxAscP4TozdBDV6SSv7E/QHmrgJDt0QqAbMjXpCE/U= Received: from MW4PR03CA0217.namprd03.prod.outlook.com (2603:10b6:303:b9::12) by BL3PR12MB6643.namprd12.prod.outlook.com (2603:10b6:208:38f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 07:53:00 +0000 Received: from CO1NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::4) by MW4PR03CA0217.outlook.office365.com (2603:10b6:303:b9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:53:00 +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 CO1NAM11FT007.mail.protection.outlook.com (10.13.174.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:53:00 +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.34; Wed, 18 Jan 2023 01:52:56 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 04/11] cpufreq: amd-pstate: implement Pstate EPP support for the AMD processors Date: Wed, 18 Jan 2023 15:52:03 +0800 Message-ID: <20230118075210.447418-5-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT007:EE_|BL3PR12MB6643:EE_ X-MS-Office365-Filtering-Correlation-Id: 837de42d-f285-4a72-67f4-08daf9290549 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jjba3ByHg4ao8RJhcW7emfQU02HRzmp/tcxc56EEqViQ9F54u6eKqVRa081BQdiamphpMDIxlLhxRrgXcdgZtBQBjiOtDcXzVzyYiVg7Fs8IeS54CO9jqGAwgpZPcDi97rdsbrIDIXSY/YBTKcDczI9+bQwkz3UmLM+qQjiJjRU18FMUE6LTXCt/qcSVh7uU/aB7CmNkkK/JVAt4D01lXy/1QaYsXsRc6gzKcjKibQyhGNJaGcyGF2Wh0yiS0JjRFvkxJPPmuraTYyKXFJlQbXiKbLWO5ro9E9xJg3I9sCoc1/bOEqEuLyT6dXWvsTN0qfkNN3Y2JBdR4+lt7g6+NNB4G9Kq6zshjHIecuXWq27wYY3Wi3h5XvAuitnAa6fHkFRThglZ/gsuGEMcxSRAua2zOphvue8j6tdqdcdyVPLqbBcm7uKx2WVuZreIMuAo6PrjzZojpetOg/sc2c0UgmN7p67vAeTsNZwLXlniBDga2maRQPbuRH2J9tP6zi9VYQNzajo9ppr03idjk76wZU5dvdyNX1YgILBXCOHIXWK7Qg6+jmo74koZ6gP78h72WdruZGQDEX+g1E/eUXicW/sWmf8hX1V2N+d9DrIebTcWQxefpE6siNbBfTa5hImFEABr2yQBbt5O5guWN3CD2UIx5pHuen0OlIJll4P5s/cb2hVyxBf3kiIDCoRBvKfJeSOczfHv4pj+27tZ/3a6kFrUYoDz0GfZhhYukPx8i+U= 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)(396003)(376002)(346002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(40480700001)(82310400005)(40460700003)(36756003)(336012)(83380400001)(426003)(70206006)(4326008)(41300700001)(478600001)(316002)(5660300002)(30864003)(70586007)(8676002)(44832011)(47076005)(26005)(16526019)(6666004)(7696005)(186003)(110136005)(2616005)(54906003)(1076003)(356005)(8936002)(86362001)(81166007)(36860700001)(2906002)(82740400003)(66899015)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:00.1987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 837de42d-f285-4a72-67f4-08daf9290549 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: CO1NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6643 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?1755348359473743072?= X-GMAIL-MSGID: =?utf-8?q?1755348359473743072?= From: Perry Yuan 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 To enable the driver,it needs to add `amd_pstate=active` to kernel command line and kernel will load the active mode epp driver Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Wyes Karny Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- drivers/cpufreq/amd-pstate.c | 379 ++++++++++++++++++++++++++++++++++- include/linux/amd-pstate.h | 55 +++++ 2 files changed, 428 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 1a8b31277620..2109ad3fdd42 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -59,7 +59,9 @@ * 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 struct cpufreq_driver *current_pstate_driver; static struct cpufreq_driver amd_pstate_driver; +static struct cpufreq_driver amd_pstate_epp_driver; static int cppc_state = AMD_PSTATE_DISABLE; static inline int get_mode_idx_from_str(const char *str, size_t size) @@ -73,6 +75,114 @@ static inline int get_mode_idx_from_str(const char *str, size_t size) return -EINVAL; } +static DEFINE_MUTEX(amd_pstate_limits_lock); +static DEFINE_MUTEX(amd_pstate_driver_lock); + +static s16 amd_pstate_get_epp(struct amd_cpudata *cpudata, u64 cppc_req_cached) +{ + u64 epp; + 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_perf(cpudata->cpu, &epp); + if (ret < 0) { + pr_debug("Could not retrieve energy perf value (%d)\n", ret); + return -EIO; + } + } + + return (s16)(epp & 0xff); +} + +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; +} + +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; +} + static inline int pstate_enable(bool enable) { return wrmsrl_safe(MSR_AMD_CPPC_ENABLE, enable); @@ -81,11 +191,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_state == AMD_PSTATE_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; @@ -428,7 +548,7 @@ static void amd_pstate_boost_init(struct amd_cpudata *cpudata) return; cpudata->boost_supported = true; - amd_pstate_driver.boost_enabled = true; + current_pstate_driver->boost_enabled = true; } static void amd_perf_ctl_reset(unsigned int cpu) @@ -602,10 +722,61 @@ 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 offset = 0; + + while (energy_perf_strings[i] != NULL) + offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i++]); + + sysfs_emit_at(buf, offset, "\n"); + + return offset; +} + +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; + + 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 sysfs_emit(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, @@ -614,6 +785,186 @@ 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 int amd_pstate_epp_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; + + /* + * Resetting PERF_CTL_MSR will put the CPU in P0 frequency, + * which is ideal for initialization process. + */ + amd_perf_ctl_reset(policy->cpu); + dev = get_cpu_device(policy->cpu); + if (!dev) + goto free_cpudata1; + + cpudata = kzalloc(sizeof(*cpudata), GFP_KERNEL); + if (!cpudata) + return -ENOMEM; + + cpudata->cpu = policy->cpu; + cpudata->epp_policy = 0; + + 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->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; + + cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0); + + policy->min = policy->cpuinfo.min_freq; + policy->max = policy->cpuinfo.max_freq; + + /* + * 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; + + if (boot_cpu_has(X86_FEATURE_CPPC)) { + policy->fast_switch_possible = true; + 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_exit(struct cpufreq_policy *policy) +{ + pr_debug("CPU %d exiting\n", policy->cpu); + policy->fast_switch_possible = false; + return 0; +} + +static void amd_pstate_epp_init(unsigned int cpu) +{ + struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + struct amd_cpudata *cpudata = policy->driver_data; + u32 max_perf, min_perf; + u64 value; + s16 epp; + + 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); + if (epp < 0) + goto skip_epp; + /* force the epp value to be zero for performance policy */ + epp = 0; + } else { + /* Get BIOS pre-defined epp value */ + epp = amd_pstate_get_epp(cpudata, value); + if (epp) + goto skip_epp; + } + /* 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); + amd_pstate_set_epp(cpudata, epp); + cpufreq_cpu_put(policy); +} + +static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = policy->driver_data; + + 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->policy = policy->policy; + + amd_pstate_epp_init(policy->cpu); + + return 0; +} + +static int amd_pstate_epp_verify_policy(struct cpufreq_policy_data *policy) +{ + cpufreq_verify_within_cpu_limits(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, @@ -627,6 +978,16 @@ 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, + .name = "amd_pstate_epp", + .attr = amd_pstate_epp_attr, +}; + static int __init amd_pstate_init(void) { int ret; @@ -655,7 +1016,8 @@ static int __init amd_pstate_init(void) /* capability check */ if (boot_cpu_has(X86_FEATURE_CPPC)) { pr_debug("AMD CPPC MSR based functionality is supported\n"); - amd_pstate_driver.adjust_perf = amd_pstate_adjust_perf; + if (cppc_state == AMD_PSTATE_PASSIVE) + current_pstate_driver->adjust_perf = amd_pstate_adjust_perf; } else { pr_debug("AMD CPPC shared memory based functionality is supported\n"); static_call_update(amd_pstate_enable, cppc_enable); @@ -666,14 +1028,13 @@ static int __init amd_pstate_init(void) /* enable amd pstate feature */ ret = amd_pstate_enable(true); if (ret) { - pr_err("failed to enable amd-pstate with return %d\n", ret); + pr_err("failed to enable with return %d\n", ret); return ret; } - ret = cpufreq_register_driver(&amd_pstate_driver); + ret = cpufreq_register_driver(current_pstate_driver); if (ret) - pr_err("failed to register amd_pstate_driver with return %d\n", - ret); + pr_err("failed to register with return %d\n", ret); return ret; } @@ -695,6 +1056,12 @@ static int __init amd_pstate_param(char *str) if (cppc_state == AMD_PSTATE_DISABLE) pr_info("driver is explicitly disabled\n"); + if (cppc_state == AMD_PSTATE_ACTIVE) + current_pstate_driver = &amd_pstate_epp_driver; + + if (cppc_state == AMD_PSTATE_PASSIVE) + current_pstate_driver = &amd_pstate_driver; + return 0; } diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index dae2ce0f6735..9bfdabd9d930 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -47,6 +47,10 @@ 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_policy: Last saved policy used to set energy-performance preference + * @epp_cached: Cached CPPC energy-performance preference value + * @policy: Cpufreq policy value + * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value * * 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 +76,12 @@ struct amd_cpudata { u64 freq; bool boost_supported; + + /* EPP feature related attributes*/ + s16 epp_policy; + s16 epp_cached; + u32 policy; + u64 cppc_cap1_cached; }; /* @@ -91,4 +101,49 @@ static const char * const amd_pstate_mode_string[] = { NULL, }; +#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 Wed Jan 18 07:52:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2213836wrn; Wed, 18 Jan 2023 00:33:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXuIa+6Li+4cBXeRrbBlmm5u5SKbY0vOK8p6M619KkJ6OoprzBGmBzLrQ9a6TEwpws6R1bJM X-Received: by 2002:a17:907:7f93:b0:877:60a2:1c6d with SMTP id qk19-20020a1709077f9300b0087760a21c6dmr838531ejc.38.1674030806613; Wed, 18 Jan 2023 00:33:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030806; cv=pass; d=google.com; s=arc-20160816; b=sQjgWPbVQsici1MW2ojDHT1XkyZorRJFr7uqARPBNkgtDgqHh2IlVvkx2QEcFoTBxu kKg3UnS40rK1p8qY7LvpAvE78sD78YzRnR0d95ucatKOxbhf9aHMdodXpUzXaC/lGXPT 7Dmkob2d2MCalG3fVx88cWlh/eRZZq6oDbsYyH7ft77pMICYY/dx+A3VwaIdV3WEaG84 OoFSDslfA2LO5bkA2lBKW6WvAGmjReGcELHfTgjJhZyyFhESJLY406AXKJqUD+qUEFkf fZ4sG3FUM5nOraZEHjeV4UL0hgKSqx1l1uFqAn9ZqWX5zMgd5do2nFaQ3mtUl+OmmBwQ 5rqw== 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=oy8nDwUSRvXQ62VsnddCwoTZ9v1negEr0DKnbzsmDN4=; b=PmeGEBUpYwfgi8X7faTWSUQ6RUZvKNxtRhgc5T53WGZboja+aHu5gUhh/gLbivd7Ib 2gK8a8zb0UI54hRi02hyvu6Rj5ih2pVke3M6ELGIItwchHVAysD1bybqgkvShP3ihmf4 dA4bFpOlId3NcJUCtElYjsvf2fxBOIYFjvkk2ynQerX+CRSwdmqWMu+c6OuEg1qtvzhU msVag9ehRuwbv0LZSfpr6pNo34PjXkg+gk1mj6Gs4af6H+MssBnq11p8GhdxuaWAUszl b1oQsm/PfDcX63exJkLge+X5c67UckYw8O1ZvAQ122h0hODGByOS9xeJnXjeHMp2hjq1 GW7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=KFdWnRtQ; 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 i3-20020a1709064fc300b007ae76a4e35fsi5359771ejw.5.2023.01.18.00.33.03; Wed, 18 Jan 2023 00:33:26 -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=KFdWnRtQ; 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 S229980AbjARI3l (ORCPT + 99 others); Wed, 18 Jan 2023 03:29:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2069.outbound.protection.outlook.com [40.107.94.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5E05AB7B; Tue, 17 Jan 2023 23:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NUmRNG1CtXX6poVVmme63Y9uQ01ylwRw0ehdLidBOuXo8YIhmlhrkS6vEUvAJK1rU2rhaj9Vp4S3xrJdeP949bDzMd2ZZM8fWWmjAQbkFSDfwnkeVkZeCSP/YmJxs7Ow69iMXs77xNjUubwBfVcN5J6MuK6EDcvnEwWoEwbYSvqcKynFyqSCcmfd5ojAJBDz6d7fX39rOGzAqme8DcgQI2UOFw3/1CnjutpxHoKD3gRm3d6OqMPiXFyVYL9i61dfWzDQQ7y6qFqbhs2A5puYU/5Om9NAAymHPTraYiFJRSW77LYQHR8RrldP5wysNlQeN3vMt3Lp8u1tErn6sz3r2w== 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=oy8nDwUSRvXQ62VsnddCwoTZ9v1negEr0DKnbzsmDN4=; b=R+Ztmg0Gw9TZnqsaLWcOCgPWWZX8R9Hn64QAqzaY9gk5acQApk12I4sGC7D/yL6psIgZ/WlfaiGvS/GvggQ8Iv9p+1N7ERni3Otvq50a0Pyo6iJhktssdlB2c8f6l3DxbC2PpyPrbgSu8u1H9O3SGZYSIZ+zXa9HWVu2biH8hw8atMVUxKPbLkFXoUgKgb7Pr51kgqOycfZih0VfwBnDkbZSnTR0Npd+fdN8hgDLGGPmHS8jEW0ZCiwTC0z2FjUdcjj4qRJ7MIFJnhuH4388AE9mOva/rQlDEa5yBQ3qumCSZTSdLTr7uAm/1+V0xKoC3Jq+5PE57f90EnUVUc+0EQ== 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=oy8nDwUSRvXQ62VsnddCwoTZ9v1negEr0DKnbzsmDN4=; b=KFdWnRtQf47CgA5QkCc6mV/b/q2h0TwC4qZZQX2Dr+nbFQnUzqP80d0lpHcfXlI0CSNRi83syZtVJcPyRed0okw7XTcKeon4uE1KWT0mrFsABm66ExGZvdvNZQ/dZR0bjeqaboI5/jk9O8jpF7o1tck4WSOfHKWTquCxeHTFElU= Received: from MW4PR02CA0017.namprd02.prod.outlook.com (2603:10b6:303:16d::24) by DS0PR12MB7606.namprd12.prod.outlook.com (2603:10b6:8:13c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 07:53:05 +0000 Received: from CO1NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::72) by MW4PR02CA0017.outlook.office365.com (2603:10b6:303:16d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:53:04 +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 CO1NAM11FT111.mail.protection.outlook.com (10.13.174.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:53:04 +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.34; Wed, 18 Jan 2023 01:52:59 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 05/11] cpufreq: amd-pstate: implement amd pstate cpu online and offline callback Date: Wed, 18 Jan 2023 15:52:04 +0800 Message-ID: <20230118075210.447418-6-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT111:EE_|DS0PR12MB7606:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ed6160d-c674-4a89-084d-08daf929079d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o16+zzrKecxu+cvWzT/Kd++TL8r+qgxqqAcoji/KRDTEQ5II0wsDlUZUc4qI3UzkntdIjKyEp7lipO62WGDbjNGVkq2b0l4DHO05EudYiN0EpMLxpqVLZ1/+B0si0GF9qdEqzlK9F5VcoSmrfNg+IHb1chX1N4sPe0wQUY4MkAII9iCcerKXUZBJpEcjNen+l7bqfsZrfupa9SmmxV2sPA2wU0Bfp45m+3G2YF4uS6R7mAAssMPLH9QzLE8LrbiAO2otPopd0UPDB4eBfvdZyAO6apah/yPK4rWa5T/Xrd7TAmkN1vUJCCHNvD6Pi3vRuAmNECetN1QB5t/+P7G5WzYN+Ak76Pj/W6o1IxLScUfquTZL1Nj10ez+4Z40quqAns1tBWQmIPGHiZU/KZJy7xSCITt5vKB59RjcF1XMQ6NuefQdQ8iNqQtkOFdL2t6ewhcneB1Kl+6p//VzHfnF3OdyQeR0LiCoXywMZHcGXe3K/z/qJeRgVuLP33qEwHZIWppuDzhZfXmpW7DfxGQ6+QsNSR8Uv6ffQk3vckKCUPfMKjnuIi2rm0vdUktcx5vfFz6EDVQoEgciRrC6hZduqheANHdmUIPGVe6eUrQI/kwVtvBJONm/H/j1UzN35B+48tVZt2lUVNCURurgW5TxvAqJzsEF05oQCP7qpJlpF/YWekliO3qzqkUCJbFsBwplmZ0Yk4UdNrtVhLN+3YwzI+RJRw3UInpHsHjYySFFEfA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199015)(46966006)(36840700001)(40470700004)(54906003)(1076003)(2616005)(7696005)(70206006)(4326008)(336012)(70586007)(186003)(16526019)(26005)(47076005)(478600001)(110136005)(8676002)(8936002)(83380400001)(44832011)(6666004)(5660300002)(41300700001)(426003)(2906002)(36860700001)(316002)(81166007)(82740400003)(356005)(86362001)(40460700003)(36756003)(40480700001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:04.0710 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ed6160d-c674-4a89-084d-08daf929079d 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: CO1NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7606 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?1755348527260371844?= X-GMAIL-MSGID: =?utf-8?q?1755348527260371844?= From: Perry Yuan 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. Acked-by: Huang Rui Tested-by: Wyes Karny Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- drivers/cpufreq/amd-pstate.c | 82 ++++++++++++++++++++++++++++++++++++ include/linux/amd-pstate.h | 1 + 2 files changed, 83 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 2109ad3fdd42..1472a6382b29 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -958,6 +958,86 @@ 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 = policy->driver_data; + + pr_debug("AMD CPU Core %d going online\n", cpudata->cpu); + + if (cppc_state == AMD_PSTATE_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 = policy->driver_data; + 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(HWP_EPP_BALANCE_POWERSAVE); + cppc_set_perf(cpudata->cpu, &perf_ctrls); + } + mutex_unlock(&amd_pstate_limits_lock); +} + +static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = policy->driver_data; + + pr_debug("AMD CPU Core %d going offline\n", cpudata->cpu); + + if (cpudata->suspended) + return 0; + + if (cppc_state == AMD_PSTATE_ACTIVE) + amd_pstate_epp_offline(policy); + + return 0; +} + static int amd_pstate_epp_verify_policy(struct cpufreq_policy_data *policy) { cpufreq_verify_within_cpu_limits(policy); @@ -984,6 +1064,8 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .setpolicy = amd_pstate_epp_set_policy, .init = amd_pstate_epp_cpu_init, .exit = amd_pstate_epp_cpu_exit, + .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 9bfdabd9d930..e9e291b7c2f9 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -82,6 +82,7 @@ struct amd_cpudata { s16 epp_cached; u32 policy; u64 cppc_cap1_cached; + bool suspended; }; /* From patchwork Wed Jan 18 07:52:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2213059wrn; Wed, 18 Jan 2023 00:31:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXu0bjifF9wVs0PllyCaz4tiCs7GUFY+7MW8yPmppsKjWUFmoloptpYkoCeBwDVVMzVADXeC X-Received: by 2002:a17:902:bf4b:b0:194:85df:9f74 with SMTP id u11-20020a170902bf4b00b0019485df9f74mr13870199pls.8.1674030675909; Wed, 18 Jan 2023 00:31:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030675; cv=pass; d=google.com; s=arc-20160816; b=Cx89CidJJra+EBkRcraFbuJNipsYFrFc8U0n87q5EGPVXKWVXeOcCcOJwWNhyUGtjO 0Pm5EmRGiO/M1iXaIDC8VdnE5c7J4Js4NTJEpZv6gWYf4o2XpQbvzstoHkde9OV67ZF4 +cSELbCOeMixPAgbgl7obuqOqw2YVunxqIZRW2No28kTGqkmH86eDXOSoY4oEdm2XQ/7 MtJRUp7lmEjVsBPOwEkoaxSkQhvZS0/olNOyB7NoUxBTONRr7GWT1+QxpiV3hruBJfsf t3mSFcL4KdM7LEOtQsWPiAlmtbk46tVi9c7972+wfMLXhm/cbpV4p4Dh4aO4mHqAROLs 5aUQ== 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=/x+50q9XOpj/DHfjRYN5hTfcMIzg12lqGHqvEDE3IfQ=; b=Fiyx2x1ukWtGa5zivfh60tvy6tHO156EFY8YooEUOy3qGezCkNuwJYh8hsBDCuYpBe FgbnOBIYzaLb5fTXTVRyJoFnDXhu8VeCxZzueSaRrR1cyJ6w3uJ0bafIeIYLbDB6ExJI OIajy1gIRIVJGJClyS6EdsxtrNO+dGstc3ysNjLrkB7JqH2kcmYC2sUTc/Jwq9O4Sjd0 oPrboc/bV2tclmq5wUrkoluPr45hhyCBLaZXjszH6RD96NC+gjulUwbyvRPUVXSd+kmM vdb+mg3HaCoIY7Mm0z5jdMcLpPFQjKm29XgwNS2wMUjy53CR7GMcqeJwP6Mtf215JpTV gzYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=NVwARZQT; 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 s9-20020a170902ea0900b00192f6c63f54si38307387plg.502.2023.01.18.00.31.00; Wed, 18 Jan 2023 00:31:15 -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=NVwARZQT; 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 S229563AbjARI3B (ORCPT + 99 others); Wed, 18 Jan 2023 03:29:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A641A5AB7C; Tue, 17 Jan 2023 23:53:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RdZVvdx+Oypv4cMnrsAV9/eJie8DDaCDLwAtLctI0wo//Mw8ca+Mbbqu6YrLiKxZcjM7JdTqvuFcd24xdCDixNZ0PVwK1DzfL1EvezGajavXXeeLG/REHZG+9ccvSax+m7zqRFiKrldH9DpMr2uU8vzpbB1KDtjHZyTrPiCLNkgMcoGdYzfGRwU8QhQ0balqhWAUPX5z1Nb4StJjCsBoLKFLEeBYqy64UjPq14+G4t52+k/p8anTgKzFHMs+/Jaul8vOGyVKNk5F91Lmydq1oQRFfQqDYEUgvYxT6dAePcG6oABP3q8sR+kqU1g+OgEb/DAu23CT0khkVfdngLp+Mg== 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=/x+50q9XOpj/DHfjRYN5hTfcMIzg12lqGHqvEDE3IfQ=; b=Qswq6uqJl6ZFNKCpr05ikvRwDxG3TAK9U7KUx0c+agFxd6XmRisBg8SODH2tmldA8yjdOI0Ac44sbCi3Pz+RN12330VXjFCXIWueyn9VPKAT3rHabII6rWV9J/kL0IdpnwGBOyMMcseoTZHSwVJIKZ/PvW1vgfPRavzHFIefSDWorqGILJGI9KNoLDDK2WXoXb4lqVD7AEG09CltggMDdj7zAXpWjuV2+ABG08/qFSBNauy7GOFI8Z3YWQoK6bd58x8ziqDO2/jlxSAHQpM3caKFec9+A/oyK5hJskHFCv0FOXsCMUWXebYEZTD0EwUh0rmUJG3mUjUmjHEcC3P75A== 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=/x+50q9XOpj/DHfjRYN5hTfcMIzg12lqGHqvEDE3IfQ=; b=NVwARZQT41IK6uSST1PFL8+KHWu6VJDWLKR6NAaTeGFXSe4pK03TM9VqlIOTaJHOGGqgC8xeCzr0ITfFKtNNSuJnUKCfpsB9kx6+sNfIJtZ5KyNtP51jw789faH5JZ8oNqHEwvkjR1uegYAWJ4k+6ISoBYPyyyJjc4iNigboKv4= Received: from MW4PR03CA0126.namprd03.prod.outlook.com (2603:10b6:303:8c::11) by IA1PR12MB7518.namprd12.prod.outlook.com (2603:10b6:208:419::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.22; Wed, 18 Jan 2023 07:53:08 +0000 Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::6c) by MW4PR03CA0126.outlook.office365.com (2603:10b6:303:8c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:53:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:53:07 +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.34; Wed, 18 Jan 2023 01:53:03 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 06/11] cpufreq: amd-pstate: implement suspend and resume callbacks Date: Wed, 18 Jan 2023 15:52:05 +0800 Message-ID: <20230118075210.447418-7-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT033:EE_|IA1PR12MB7518:EE_ X-MS-Office365-Filtering-Correlation-Id: b08e4b69-bd10-4495-2099-08daf9290989 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E75gUG0GEBx0+7gCoJpoGr03oww7asNi4+OMhNrrVFo960FhJgUorX3sTqohdlaSVn/YrXczaTWDMYcfmiGakomiItbpymIyn4E7un8rWJiut+gbDqSsT74FGlkCove92Qc2lJB+RFhGBTWG4CGdAJB8c7vPi7zVWjAaxNDihxoc/2TPLMKoOkuvehQ5n/fkPF3INCpUd6wLf9YUzcjtR624aBJrdBfA9BKo3LgdCh3+bOssL3piFPpsPl9q1fFKQhbCtsHrdYVz18EIjtr26d6gUljdmEV/JwYazGlwJIUhDxW/z0dvyOjwH3zKWxxuFTM/o7VHYUdKwuafPDD7sgq2+0nPL80xJeNz6vjCPiPrw4BhAxPp+smyTpDzgkAfrg78qzWS7XmSaJDsRsCEA3DqnCbuTukOsYYy4hYfMLdlE2rTkkZIjEQ9ccXDHF7ZSsOvCceBL8HNllcxfkMxxEyI7TMx6Ty2Exc3hHyKwh4wytdITWTfTLsmjl7TLs3KrglsBUPGQGykM4V2rxm1hUSwam1nBwvOs/EGlUqVjS1svOnCC/bHH0oNfEL2P0cp4+Kj754hdQ0OiFlZnEJDRiBFzOcD593fQEdXD5pP2LxwNKt9E6A9XicxTPHe5POf73WdSWjsy56i5D07ngetdbVFjjQcDSWGB/XvWUcMDTCGznG6tWXnPbzqlwz0AM/AEmzx44LNlGg4bA0fYxj0kdQdhF38HoHGMLlSSwqJdmE= 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)(39860400002)(346002)(396003)(451199015)(40470700004)(36840700001)(46966006)(7696005)(478600001)(8676002)(110136005)(36756003)(54906003)(4326008)(70206006)(1076003)(41300700001)(70586007)(82740400003)(316002)(36860700001)(356005)(40480700001)(81166007)(40460700003)(2616005)(16526019)(82310400005)(26005)(336012)(86362001)(47076005)(426003)(44832011)(186003)(5660300002)(83380400001)(15650500001)(2906002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:07.3897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b08e4b69-bd10-4495-2099-08daf9290989 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: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7518 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?1755348389909928316?= X-GMAIL-MSGID: =?utf-8?q?1755348389909928316?= From: Perry Yuan 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. Acked-by: Huang Rui Tested-by: Wyes Karny Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: --- 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 1472a6382b29..9e1bee060597 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1045,6 +1045,44 @@ static int amd_pstate_epp_verify_policy(struct cpufreq_policy_data *policy) return 0; } +static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = policy->driver_data; + int ret; + + /* avoid suspending when EPP is not enabled */ + if (cppc_state != AMD_PSTATE_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 = policy->driver_data; + + 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 struct cpufreq_driver amd_pstate_driver = { .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify = amd_pstate_verify, @@ -1066,6 +1104,8 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .exit = amd_pstate_epp_cpu_exit, .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 Wed Jan 18 07:52:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2212953wrn; Wed, 18 Jan 2023 00:30:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXsaFOVocs9BDvk6bRHO+C3TpNpLHf1C69bINs7a4F8bi36Jta3pONm/RVmPar1LaAQt5qsB X-Received: by 2002:a05:6402:28c7:b0:47e:f535:e9a0 with SMTP id ef7-20020a05640228c700b0047ef535e9a0mr6555532edb.24.1674030656462; Wed, 18 Jan 2023 00:30:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030656; cv=pass; d=google.com; s=arc-20160816; b=GDaKb1qsBPWFk6rz3LzAdFNJ/n90zj/eSfbHtWVEPUQaHOZm8ePl+J3MXUcX9xH10Y zRcs6qZxP4kNNUmuLDBezyxdDCk771AMPvkbATll+Hjs2e6egeaU1jeExkM1mvRDAO+i C4JSYqQna0+UP1W/+mM3H4TVxY1qbLJxCso0HNMFdAMEf2UlLQMwzWNT+zhVQvE5Gu65 KhsWqfdTt0tqHH88pDmhJMnc0jpz+fuwFXqno5m/QeAgR3ZJ1aeSbfP9N4/3pTS8nvQc Mi2kqnNS54/neDv5c2eEt7yVjL3M1qGFtEwpTqz5Qnaf1olQyKy0ECmC5KARa4s5J7t4 SF5Q== 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=tlXvVHSTLtImk5AB2+ykPocLIEDOZel8yKjj0tTiuOs=; b=Krj6g5C5eX5JYLsQM9sgas+zIU6f8a+8zlsU1/IPvtm7CQxCMj3glBI/1dojYrbtAw 1J7mV8UVk9tgF9vKw/l4dN/JOhvlbZZ+bZGeQk98ReGX4rJNqoahanX8BNyaWO65IbKs GjgoewtGP0ekIzjVIB2xzVyvKDj2FAFbprhb7OIA7RlNyahzNykPx+Fwar4YUnbsT8hX g6NNB/q1o18eO6ZgajWO6GEnmeTrfevQ+9yeykMJ6Uk28C/AXJRfspNMQYWq0QxMre1v wUsT1nAYEsj3PUYrKqjaZFa+yuyjNE6pLP0v8ILddpFH0xM9VEJ4azozc58GTFskm83U vlLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Rn7ZZBrz; 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 xa14-20020a170906fd8e00b00787b9cd2fe3si34895078ejb.844.2023.01.18.00.30.31; Wed, 18 Jan 2023 00:30:56 -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=Rn7ZZBrz; 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 S229524AbjARI2k (ORCPT + 99 others); Wed, 18 Jan 2023 03:28:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F315B46C; Tue, 17 Jan 2023 23:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C00y96yIwMGpozpxCgddDfeSFjQnk1DBN+nLDtQrIAdI5z/xaBeKJYMfQ8rXH5JCnlpHlNBFH2mu6e05XFKixq6TlbI3WAuJn6oyWyzjmdGWnXl3X8a/szUPSMmpBg1EB6RWp33ksxlnLq42upmCoCvYaDS5UQ76kVchYNobG1nUgBncViXJ0ot2QM/8wWCMFPFsTMq0m/fVKoe32P+hJlFyORYiXPMZIboirxjd8eBT+Y1Y9+Rr4Yri140uuWYqTiMwAZnqfYp2iEKu9a4I9PY2kOZi/1jUzNqj+s0eOxKhPvaeHkEFZAFYGjoOdEae/F1bFkEhzulSxH7RHZaNsg== 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=tlXvVHSTLtImk5AB2+ykPocLIEDOZel8yKjj0tTiuOs=; b=SyG0A+8e3Cc9BTRgsofvqGWztnp6+pTyDlCT0OXLXPqLc8XbS1CODLT5MKLmpzGYtyno9ZTIaCt46D+7AFrTgeDpSAU1lNQCzM+TRPo3x5VsQa1JmFV9vutOxaYqFEjOabPWmM74cVKYi/avKe28vlt7FMO3IsZ0o40oFesHEXOPjXHT994ahE2cNuacVZQuiULkhsrISEXjBUABGOTpgzxyUA8MYWgvxoR9hVBV4IPF3TZLypCfvuI4UH35QMrE9oGADRvLZSe9Vx4zvIIxn7iOMJ9F4wIs/9BIgF7LgD5Uea3glTetX+wEVhnBehSY+DLbUqMlqGvjd2aanrC2YQ== 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=tlXvVHSTLtImk5AB2+ykPocLIEDOZel8yKjj0tTiuOs=; b=Rn7ZZBrzKwL7I7ldS2dupriohSWROim33AoujPSp/tCjN4C7Gej/g4ECfXxy3ttLyMJmGAoKaf0uyoB03CT6osP/2V+VC6YcACi/U6gEl5gDzVpcRGsOxK0bEdv3BNNdQgIldhPgTnDnY+5InWVyGTa2Wa4G9PNq77QUoG2lZMY= Received: from MW4PR03CA0122.namprd03.prod.outlook.com (2603:10b6:303:8c::7) by SA1PR12MB6798.namprd12.prod.outlook.com (2603:10b6:806:25a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Wed, 18 Jan 2023 07:53:11 +0000 Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::51) by MW4PR03CA0122.outlook.office365.com (2603:10b6:303:8c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:53:11 +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 CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:53:10 +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.34; Wed, 18 Jan 2023 01:53:06 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 07/11] cpufreq: amd-pstate: add driver working mode switch support Date: Wed, 18 Jan 2023 15:52:06 +0800 Message-ID: <20230118075210.447418-8-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT033:EE_|SA1PR12MB6798:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cf09d70-8d0c-44ad-b2a9-08daf9290b6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fxc+FQR0ijDu55uPi/Spo2MIz27apwgAGaA5oKa0+uD1Pq8KDEDzJ3yqMy9G9DNwc+tZtcypYlzrdJEncZvF7EVsoUy8YsbHSME8Q70JtwVgKKyLGQQmbKkCsZfq2r0pedsBuoH1+a9/KWALGzxPrEJX73MwB1SPqN4x9M7H5hvnjTycpctitpaGOTGVaiwnYLt0yRU3brgDCJsXXhMAp67buqgcPaaV8nNO8UX+n9m8HQVIWChSvGYMWQaNQzuz/kxx2A7uHrklgSrtyJpHhyZiOvCsYwcYJ+eWfnio917Pt4Z32jQp+Plh9SIkccz+fV6xvr5m0iFZ9QgNKlLhLHvjzA50xPn0+9lRn5tAqP2asB9dsj7BcSFkLvZcv0SJzMcr1Cua7MZxWqzZYZVyk+5sQhTw/BKAL1XijFpjQM+VW8DS2c1gaNNwySa3brzhOJyE4a1jo5boYnsfGad5g0794HwYYtsm2Khy0hqgJLUwBwb2rZfrRG12B6okT689GfqdxPJKB5PL7os/uNKHUKHTJ4iNwB6ZHe2/F0zb2f9IF9C0P/OpwYT5RxSxXEOKLOdAzZmK4JH9RgvuSQ4CoAjMU7S319aMJWXeGA8J6Lfm6kIcl94W+xIuCVMvKygdZE2/CkRqsIXqQZ/+dEW6ZIF8yS+HpWRp+p4jWSgixItMFjskgYIG6DZn5kEdJxw6lyTIEn5uIiLecZWCM2BtF1Wao4K/C3sETvQUOT/NtRI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(83380400001)(426003)(47076005)(36860700001)(2906002)(356005)(44832011)(86362001)(5660300002)(41300700001)(82310400005)(8936002)(40460700003)(40480700001)(54906003)(186003)(478600001)(1076003)(7696005)(70586007)(16526019)(26005)(8676002)(316002)(336012)(4326008)(70206006)(2616005)(81166007)(82740400003)(110136005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:10.5301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5cf09d70-8d0c-44ad-b2a9-08daf9290b6a 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: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6798 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?1755348369244057096?= X-GMAIL-MSGID: =?utf-8?q?1755348369244057096?= From: Perry Yuan 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 Meanwhile, user can switch the pstate driver mode with writing mode string to sysfs entry as below. Enable passive mode: $ sudo bash -c "echo passive > /sys/devices/system/cpu/amd-pstate/status" Enable active mode (EPP driver mode): $ sudo bash -c "echo active > /sys/devices/system/cpu/amd-pstate/status" Acked-by: Huang Rui Reviewed-by: Mario Limonciello Reviewed-by: Wyes Karny Tested-by: Wyes Karny Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 118 +++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9e1bee060597..2e5e594dc41e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -63,6 +63,7 @@ static struct cpufreq_driver *current_pstate_driver; static struct cpufreq_driver amd_pstate_driver; static struct cpufreq_driver amd_pstate_epp_driver; static int cppc_state = AMD_PSTATE_DISABLE; +struct kobject *amd_pstate_kobj; static inline int get_mode_idx_from_str(const char *str, size_t size) { @@ -631,6 +632,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; amd_pstate_boost_init(cpudata); + if (!current_pstate_driver->adjust_perf) + current_pstate_driver->adjust_perf = amd_pstate_adjust_perf; return 0; @@ -771,12 +774,99 @@ static ssize_t show_energy_performance_preference( return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); } +static ssize_t amd_pstate_show_status(char *buf) +{ + if (!current_pstate_driver) + return sysfs_emit(buf, "disable\n"); + + return sysfs_emit(buf, "%s\n", amd_pstate_mode_string[cppc_state]); +} + +static void amd_pstate_driver_cleanup(void) +{ + current_pstate_driver = NULL; +} + +static int amd_pstate_update_status(const char *buf, size_t size) +{ + int ret; + int mode_idx; + + if (size > 7 || size < 6) + return -EINVAL; + mode_idx = get_mode_idx_from_str(buf, size); + + switch(mode_idx) { + case AMD_PSTATE_DISABLE: + if (!current_pstate_driver) + return -EINVAL; + if (cppc_state == AMD_PSTATE_ACTIVE) + return -EBUSY; + ret = cpufreq_unregister_driver(current_pstate_driver); + amd_pstate_driver_cleanup(); + break; + case AMD_PSTATE_PASSIVE: + if (current_pstate_driver) { + if (current_pstate_driver == &amd_pstate_driver) + return 0; + cpufreq_unregister_driver(current_pstate_driver); + cppc_state = AMD_PSTATE_PASSIVE; + current_pstate_driver = &amd_pstate_driver; + } + + ret = cpufreq_register_driver(current_pstate_driver); + break; + case AMD_PSTATE_ACTIVE: + if (current_pstate_driver) { + if (current_pstate_driver == &amd_pstate_epp_driver) + return 0; + cpufreq_unregister_driver(current_pstate_driver); + current_pstate_driver = &amd_pstate_epp_driver; + cppc_state = AMD_PSTATE_ACTIVE; + } + + ret = cpufreq_register_driver(current_pstate_driver); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +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); 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(status); static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, @@ -794,6 +884,15 @@ static struct freq_attr *amd_pstate_epp_attr[] = { NULL, }; +static struct attribute *pstate_global_attributes[] = { + &status.attr, + NULL +}; + +static const struct attribute_group amd_pstate_global_attr_group = { + .attrs = pstate_global_attributes, +}; + static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) { int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; @@ -1158,6 +1257,25 @@ static int __init amd_pstate_init(void) if (ret) pr_err("failed to register 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: + cpufreq_unregister_driver(current_pstate_driver); return ret; } device_initcall(amd_pstate_init); From patchwork Wed Jan 18 07:52:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2213217wrn; Wed, 18 Jan 2023 00:31:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXuFs1TvvGchLbkg65+bomoNl5X+74HReCN30rBvI1GjbW8/shSiGk6bAkZ08lLJZEEmU/Mw X-Received: by 2002:a17:907:2bdd:b0:857:b916:94c2 with SMTP id gv29-20020a1709072bdd00b00857b91694c2mr1970557ejc.35.1674030709157; Wed, 18 Jan 2023 00:31:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030709; cv=pass; d=google.com; s=arc-20160816; b=MNHwzMgl87dGZd/9ZsFgxB6vz4SPbC6HLYoiB7C+M91s+eJIEne4OUpBrX+05CWRZv NyhnTL09nbuAsWVycCO+WKxgMOzvhokWHbXjskHVkxLZ7vkEWfh/1J84lZyV/VY647EL kMnYYgArLpvAidKEOABk9dI4yfkjdoEVJlP835JrcmRXtjvDB3NuhBa483/M/gNXqoWS HkMNvXNAOcINPzmYfIW5ElH1r1tcPrc0I8OPnaWNhWGyZZ8ii7b4dxfTjWzRwu232NKA L0faaDKUvkCsy5Bj/DAbJU52+tnKyYbRjbUErfIFhefo9qyQLn3QRbGv6w+5hOCZTLRc PDTw== 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=+pN/GQKK9MgCxkcMYrhkjw00Ga1ZbUCwtImYGqGqYF8=; b=tmkeKrbR6AvaxlwjVhtISOMngBi0HObThCP92LqF9umm1W46hL9KYovyO0q/OQ2YPg v5+YEFp/MdrSXuaqhqbH6mXknoAy3JE0DZ/ZGaPTnddblfr1yYGllqSxYUbulDE8RT7+ 3jAuUcWjxDLnWrqvClT55HAZ0h8w4eyUd4PcY+dJoqSm5P0iBWddR3mKIJ3YEZMdabV7 ejAl/Ubvh7muZBUImcIB2nhWcKPX8gWj1Pbl1n7v2bBNjlXuDRO8nCD1OJgyRq/HPlS6 ZwJOSD4BDI8W7+I/VJ5qlhdoHttOBaumevLQlJZOlpGGyHuhFQ6F4P7TpBentlmgMEIL vnXA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=vGESCMiq; 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 wu1-20020a170906eec100b007a1d4f0e7fcsi36097720ejb.655.2023.01.18.00.31.26; Wed, 18 Jan 2023 00:31:49 -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=vGESCMiq; 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 S229848AbjARI3S (ORCPT + 99 others); Wed, 18 Jan 2023 03:29:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbjARI0E (ORCPT ); Wed, 18 Jan 2023 03:26:04 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E1C65B58C; Tue, 17 Jan 2023 23:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EbsOIEEcbKfsK/oL34GJz0nN1i80E2hpvEXy2Ytg0BtIXpIBTLzOgrPBtS+DWRAiaA0gOhLfggIn/MmP7zDZSQvGkkhOStI2Zvbc1eRDk3V/QjJjt6xa4uPCPW5x3N+KYKyl63jH8yozMsQPLYPIYTxJSPaqDIvfSNpptX7xTb/6MQxdzM6FHhtcOx++8FL7t6CNVg/OmS6qydUrLL3htW0qRA4rJC6p8bC8xkDuk/nDIOA6gl+tQFnGhwHyTihLs/HS3b25vQM2i8WLGzlIGLYLBP7GytbpV+HusG3LzbbIqr++38IP0zg4g2EKOnI9mcRorzbMfeA/lwtjC2sOOQ== 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=+pN/GQKK9MgCxkcMYrhkjw00Ga1ZbUCwtImYGqGqYF8=; b=RFBKRxOebfiycEBC25Gk+/NxKjoj4l65zE3SJxGHMYIVdsbE0KoCmt3uLOEyYMwAV1xkeKNcQy07H6Cn+g/fbH/gDdAWTZCavDxHl9WRn6/OyJl0Wr/i4YS9dy+kBzfdTC+1PIreyTU2k61FkJf8ASBGnyFC8L6lSC+ll/K+aWCOnlod+kX/Sjq3gf3hSHa7jo52jvTAOnr9Zj6vrCiKND2CeECiSjgL9lL+1gN7JE5lPzQKVWdR9hwroeFtSPX+hmsTLm2yD/k9GVRVXKAfvrR3D+6mq/l3d7O5P7ar4na2RIMbIywmR1ky6CcS+SZXvZ6VUbeqnVfSJeF5BjFgVw== 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=+pN/GQKK9MgCxkcMYrhkjw00Ga1ZbUCwtImYGqGqYF8=; b=vGESCMiqcpuOBRv/9PqvtSFbTmMaw+rhITG+dmDXVY1HrKNKvq/lAs7awdLAeEPhlTzJ2HdUDQszrkYcnl96NV7mLiF/l1sE1di+48Cx3ks080yIkd1wzonZ39mKBzJqXCyvaLLyyTlcnm6YmJdeABXyRrSl2575sx+Iz16KqkM= Received: from MW4PR04CA0270.namprd04.prod.outlook.com (2603:10b6:303:88::35) by BN9PR12MB5081.namprd12.prod.outlook.com (2603:10b6:408:132::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 07:53:15 +0000 Received: from CO1NAM11FT101.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::47) by MW4PR04CA0270.outlook.office365.com (2603:10b6:303:88::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:53:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT101.mail.protection.outlook.com (10.13.175.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.24 via Frontend Transport; Wed, 18 Jan 2023 07:53:14 +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.34; Wed, 18 Jan 2023 01:53:09 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 08/11] Documentation: amd-pstate: add amd pstate driver mode introduction Date: Wed, 18 Jan 2023 15:52:07 +0800 Message-ID: <20230118075210.447418-9-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT101:EE_|BN9PR12MB5081:EE_ X-MS-Office365-Filtering-Correlation-Id: a5ecb011-b045-4eed-932c-08daf9290dae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eb4GMHjZCHYz3z+ENRlLD9wzQoi6mUhMpB2XxZnoD6rUKR+gWbPfUaYgUr+JXbBX07m+8GD9stq4pQGWPmLGWex3D0rd8EwP0Bf5jVjBlE6ktBrsSEs/sAMtwIqkJnnJEoibjdUM8GCLmOBW5QwewEWJenEmFtcj37U9+kJp6gjWOcwvkfp/myi0LgDgzff6CBoFOiAGKUGaP0zUtYyWgcG3kKgsPpE57NxVd8sxM8BNBZ3cbsLb66QvX3LzUlvmcH4ShOxbnFflQJntz0EIZqlYTp1wBHiBuzf45RCEvxVopZTNze7l+DqvTDDHfqJbAlIPvzXBdCOIFQZqUZtJ3TLWqXqoI4VbQtFJIwmzA9daF6aGr+0g/vhw1pnwRZvUfrEUTJLWa43DYVvG8PgKy2wunbi9dKJX6SNg/rUpgNqNPbl4fjSEXJOqbByUxzeeO8OBGyIGGZai13N+1kxTJ5ncn0GJFOca07Je7yUsAwzpw1uUxraCqoy7/GaTwW2SWU1CS1VwRUVdVz8q9XG/ij+gMaQBIr97tCJXnqURNno9LBF8OwLrYiLNVFgl6YSgVm7hrIsXEMMRY5fjKEerx8bfKZjc4cw/9hEyXwQfYPDUgrK7uL5cgeg3aE64s1eOi17PxTGYUh+3pRfOB3tYWobGhynAcga52IkMRa4R3ypE/yQaIfB5W0wR7gqZqXGlJzisVbQUTlxYq8kRYnbyG81hHJxQ5OvY/fn0FCn5t4M= 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)(346002)(376002)(396003)(136003)(451199015)(36840700001)(46966006)(40470700004)(8936002)(5660300002)(41300700001)(4326008)(70206006)(8676002)(70586007)(36756003)(2906002)(44832011)(7696005)(1076003)(478600001)(336012)(86362001)(2616005)(82740400003)(356005)(40460700003)(81166007)(16526019)(26005)(186003)(47076005)(54906003)(36860700001)(110136005)(316002)(40480700001)(426003)(83380400001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:14.2366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5ecb011-b045-4eed-932c-08daf9290dae 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: CO1NAM11FT101.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5081 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?1755348424582055721?= X-GMAIL-MSGID: =?utf-8?q?1755348424582055721?= From: Perry Yuan The amd-pstate driver has two operation modes supported: * CPPC Autonomous (active) mode * CPPC non-autonomous (passive) mode. active mode and passive mode can be chosen by different kernel parameters. Acked-by: Huang Rui Tested-by: Wyes Karny Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- Documentation/admin-guide/pm/amd-pstate.rst | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 98a2bb44f80c..b6aee69f564f 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -299,8 +299,30 @@ module which supports the new AMD P-States mechanism on most of the future AMD platforms. The AMD P-States mechanism is the more performance and energy efficiency frequency management method on AMD processors. -Kernel Module Options for ``amd-pstate`` -========================================= + +AMD Pstate Driver Operation Modes +================================= + +``amd_pstate`` CPPC has two operation modes: CPPC Autonomous(active) mode and +CPPC non-autonomous(passive) mode. +active mode and passive mode can be chosen by different kernel parameters. +When in Autonomous mode, CPPC ignores requests done in the Desired Performance +Target register and takes into account only the values set to the Minimum requested +performance, Maximum requested performance, and Energy Performance Preference +registers. When Autonomous is disabled, it only considers the Desired Performance Target. + +Active Mode +------------ + +``amd_pstate=active`` + +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 ------------ From patchwork Wed Jan 18 07:52:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2213021wrn; Wed, 18 Jan 2023 00:31:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXtsW7lILn3AOlOn5l+ZDvXPOPPT2ZgAjQD+RPSNze0K5lklFoVb+SERQbQ/6E0f77QdJbbH X-Received: by 2002:a05:6a21:1646:b0:ac:29b4:11bc with SMTP id no6-20020a056a21164600b000ac29b411bcmr5713836pzb.21.1674030670203; Wed, 18 Jan 2023 00:31:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030670; cv=pass; d=google.com; s=arc-20160816; b=yl7RbYTG2Wn6IltB9T5w2+Vm7nKLsekIm4SeMvF6DCw2XTqcJ57GJJWigZOe+OPUuu Z4E9E2RzWAv7FSSLu3+eQisbH2WcGgT+AdwQOmd15p6nzEPG7XDUuam+rvnyF4rWfo35 ruUsP/dx1oD0pmCDk30f6tNxvySW0gkKRVT/bvFoR4AU0whl9W/rDk9DCEzhk2FS2TCa yDwZpNXVvyFZh5IP58+LmEGfstEGRCEw5eiqDC01t0fL2rDVKpoPJHEyfihdAStdt6rp ASBMpvjuBAlmtgHVO0fQbZg917QqaL3yIWoHAKdpu4uQP4YeTZM7VwEsVG2r6ocjleHQ 0eCg== 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=i2GVHcLNR/twzU8JAKREu4Ip77DvURPO2RNl6+bGwDw=; b=waSyn8KPjrfnwhTS9FQ/jG+OWdrUF1ekA+0QXPXsI1i/MhSF1FKvg0NpRHKEgR6hIJ SFZWLdThfc8JJCdAOR83sLWBA6MTq2WJl1qxO4FYp0wCtv3kfFQJfdZAJIiw8zfXG+I5 XMvwE+T6pBYR/NFZU5LIfRYD0DxoFOsRVnWGqvhCM247AHI6d+ikakpjyXRnQxZigzU4 AY4xoFxWUWOIPJ6vhrRnNQFxodd0o5FVD/8rUCARD8Bi+XziOlKUzzk1tZZuUASCW0i5 RLB1FeDfb/skWdGtDOVIQlyxnZypCClGEi5HUKNfJBDigBECIalK7ewTKsvrAfI8iU2m BCBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=EbNLhfz6; 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 a4-20020a624d04000000b0058b79733cadsi23321100pfb.230.2023.01.18.00.30.57; Wed, 18 Jan 2023 00:31:10 -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=EbNLhfz6; 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 S229908AbjARI3Z (ORCPT + 99 others); Wed, 18 Jan 2023 03:29:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjARI0F (ORCPT ); Wed, 18 Jan 2023 03:26:05 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D695B5AA; Tue, 17 Jan 2023 23:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d2N0lV6aTmdSAoKZiGvth4IIo8tFq7ALMCyLz5ZTBfNvmozkEUUGFv0WNE3aFooIpOM3KqhBMG+gxrfr7pjVjtVM4aa26k4PqIwXNXaOcsebfQ18VlSkRkhUzklWAemvrWhn+K7U2tg2Hvyh9SZJkB5b2XjLFMUKEevix2nfjw4kTnn1c3FPAcL9kSqDRupQsGkrFvKfdbC5vdj7zHp8ni5Wnvbd4C66A0615jx2NyX/pL2zbxyWHuTYd6OTpSDZhacPMtABZkdzF2nXw26GC3NhBRfYiy1mEuAO+S99UySrYhqUuezN8FguqrY8HYq3YmjN7En8hm8dvaz1fNdPRA== 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=i2GVHcLNR/twzU8JAKREu4Ip77DvURPO2RNl6+bGwDw=; b=LK4f1sx6eWnyfViLwV3k7c2X+Zqo1yjLI5e9jpvy7VxU+KdIPGemgPBBWdtztKx0GZyrNiOWGbQ0SEZRawq6n4DJh9719wIpfg+IuvtPDueVxSptJ3ekpLGcaxd7ra1FcJqMkwRQyqdIx4bumrJ8ouYsuoc4aj9hAhEfE9LARVpGnZgnkx48azw2JA2qv4gEpCu9xfmpBAXzTKwthmNvcF3yAm1e18KPn6MZ+j4ox4eWodbSbydWXOWps3RCyBx9W5w2Ep3nx/kQotPThSFAyj3r1rJYnQUORAXXLJRFHEW83WwgMcJsJ0uzdUpbuKIUp1zkRI3XUSBARZR8hY9uMA== 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=i2GVHcLNR/twzU8JAKREu4Ip77DvURPO2RNl6+bGwDw=; b=EbNLhfz6gL9oDRizuRqeTbOTDFMe0dgWO/0hitMbeTQUkFBdJqPiIoIiUf/NExt9q9l39UPZDNq2+qfiF+N9e3EGT4CWuDQc/SVCTklDgqhofeSrBl11DNEJV/YSeREbSDdIF0/6+JU2kFnqFOZA1ZLX9CkIpOMK1KUU/ZuAnhw= Received: from MW4PR04CA0128.namprd04.prod.outlook.com (2603:10b6:303:84::13) by IA0PR12MB7674.namprd12.prod.outlook.com (2603:10b6:208:434::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 07:53:18 +0000 Received: from CO1NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::7e) by MW4PR04CA0128.outlook.office365.com (2603:10b6:303:84::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:53:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT017.mail.protection.outlook.com (10.13.175.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:53:17 +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.34; Wed, 18 Jan 2023 01:53:13 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 09/11] Documentation: introduce amd pstate active mode kernel command line options Date: Wed, 18 Jan 2023 15:52:08 +0800 Message-ID: <20230118075210.447418-10-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT017:EE_|IA0PR12MB7674:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d8e90ff-5559-4083-d689-08daf9290fa6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9azR7B7EWDLBjAirE/t2me130r/lHQXH/ZXNHpG74emI3tlYq9AwNai15dMPk/UcU0jVnf5zbguKccyMykyPacmVtzbtDBIQow8uZHrP2qCjbTtp+zbTvyxf30amhFjDKKpKhTLt3o46eZL7K6XxEX0prZHqUifhTw534HlSfswWxFI2YhJa4DqYJ+WCLqka5MB/ddbaZxMw6SZJg5neCnWyi/l6b7yKsBK/OGP2cAIei7CZm7kSQniMFqJouye5OtJJ8qSUSCCmdLRP1CebZuWU7Du64QpeMfQUVLJaFmj5mNcBK6H/5+Zu1KIW7fDCmL9/icJin7ko7yBQ3jNCkCn//ZqjUBbMcXdm1ZPueq8ZIfC0a5BSxOTE8c9eqMxU17kzm8t8Kf3UcUgXfITzPxcW0gavYMbdb/J8vMPOM3mCVghAN2asldH7QtibJXO+rfykDDjcpShVP8Oc1vbn8KAE874Gqw27T56C90/7Y8H0UtzofMmn819X7N6dxT7mEaE+b727kV+IXNvsCv54849KOtZoOysdM6MNmB/1ZKHFTRG2TLt88H6XBYVtUtwj4r/7yvXMsrbTzcgPXKfMwmLCUg9MQMXnawflKLdMkeBEET5+E95sLmtv2H3LlPmpK+W+Rj9PJFGvClMxCxB8ook7hlYZf25EUBNQ1yjJ3ft1w0AWnY4FWHRWKgTD6kp9PD3wcw2KY+F51f81/s7R3Oc6RC9f3hdUxaNDW6zaXCc= 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)(136003)(346002)(39860400002)(396003)(451199015)(40470700004)(36840700001)(46966006)(4326008)(41300700001)(6666004)(8676002)(70586007)(8936002)(70206006)(40460700003)(36860700001)(36756003)(336012)(2906002)(82310400005)(2616005)(44832011)(5660300002)(316002)(54906003)(110136005)(40480700001)(7696005)(86362001)(186003)(478600001)(81166007)(16526019)(26005)(1076003)(356005)(82740400003)(83380400001)(47076005)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:17.5570 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d8e90ff-5559-4083-d689-08daf9290fa6 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: CO1NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7674 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?1755348384115244004?= X-GMAIL-MSGID: =?utf-8?q?1755348384115244004?= AMD Pstate driver support another firmware based autonomous mode with "amd_pstate=active" added to the kernel command line. In autonomous mode SMU firmware decides frequencies at runtime based on workload utilization, usage in other IPs, infrastructure limits such as power, thermals and so on. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Tested-by: Wyes Karny Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6cfa6e3996cf..e3618dfdb36a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7020,3 +7020,10 @@ management firmware translates the requests into actual hardware states (core frequency, data fabric and memory clocks etc.) + active + Use amd_pstate_epp driver instance as the scaling driver, + driver provides a hint to the hardware if software wants + to bias toward performance (0x0) or energy efficiency (0xff) + to the CPPC firmware. then CPPC power algorithm will + calculate the runtime workload and adjust the realtime cores + frequency. From patchwork Wed Jan 18 07:52:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2213921wrn; Wed, 18 Jan 2023 00:33:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXssvI6k13MZT6Mb/3PGCxNTYWjfsVa63GWyAg4pinRB6HBC7GUAcg2o0nSvqfWSlzIbtKUv X-Received: by 2002:a17:907:3f20:b0:7c0:f7b0:9aed with SMTP id hq32-20020a1709073f2000b007c0f7b09aedmr7747997ejc.55.1674030819578; Wed, 18 Jan 2023 00:33:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030819; cv=pass; d=google.com; s=arc-20160816; b=z+9ZyiV+xb5fm5jlt8/ZqOEhGJuqwtLp3wcj4/4pZRJw9xPDtWUFc97pjvBLLxPtFN F8GXyg9PLNdd6T/H/j3lXhYTE1Y0k2WvP6ft4rxfAbe+9JeqiBJARMvVXx58uRnBJ1lW 9k2eGOdtbQV1CIIQgCaJpNNL8XCvvt8BNXxw+1G35JUSDSkZhNMW3Y8WJAfgMmDBSulG 7YsPC3fobFPj9ptbTWzXHvYje6UAx40i4uzSEY0NNa15nG7HYo9yrX1Gn+ckbjLbjKC3 n8f+NAyKhb7H2T/fibOA3gfKTmk/m/npT0iBdwWu/gUqFEDDiiRRQX2oYgiefkX+Umhz aU1g== 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=32pMiOlV7Ishsq6tGX0Ullqnoye0YjjxIeEj2mFpxv8=; b=kqiuXSaCJEZi8nrbsmR69Xtd2ii/Bq7CLEJtP4yuFXs8FOJVDKSaqJY8aQVmKmRReQ W2jKqBEFB1LH6laVh0+KWW9V4sK86vd9NYDgNEdrs3HWY5JazgljnMTSHJsW0MdYbO5p 3lv1jeqKxcRO9GWNGObFdA6jE6c3UOvKhfasfHHM9ZnbfahaU575DYJ30M9bkhRkQAyk 9cZUn2OOM3N+Y0Nr3eI7Dk2nyAk+fCEzfJ/R9r3dzw/Xg0NgU+BkyYRQS2fM+bUDD3yM U1JPVMk4so1yx21EVkxqcw+zRMwXTXLMFtSiSmMc3vxVODXdBhIsvBKp5F75P45fe5Wa kXTw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=X5YAWGxQ; 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 sh39-20020a1709076ea700b0087761dd9827si382170ejc.15.2023.01.18.00.33.16; Wed, 18 Jan 2023 00:33:39 -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=X5YAWGxQ; 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 S229612AbjARIaf (ORCPT + 99 others); Wed, 18 Jan 2023 03:30:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjARI0F (ORCPT ); Wed, 18 Jan 2023 03:26:05 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2041.outbound.protection.outlook.com [40.107.100.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A5FC5B5AD; Tue, 17 Jan 2023 23:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ba6Q93CJ82bZGbm/tp+nQU74FknRGo/v2/J8HlSdUTYevrGltyuuRwv3vYHio5J8HEpl0LOSo4YTaIopO0RbpIUFMnBs+akpBIRhS5XuwSq2k5AiyQrzl5/vtVIVFlztWDg9dTqc+enzCIubhvbzuyRhvJ7zj72JHteQ4LXOVgY62cVM5xwCqTkLNIlsFgzuUMZZhLT1FLM68r0LUOzkYsLn2cT4hIhRioi+ACgRt2Nt/5zk9bEIXbrq6rYQITGfn2y45mK3mw0aITUcYCQzoyRccmVNlhSkUzlDxrzINkMRJanTxdO8BwFioUslIztvnmwadhmbfqkyavphngqdkQ== 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=32pMiOlV7Ishsq6tGX0Ullqnoye0YjjxIeEj2mFpxv8=; b=UT6kKZFmGU5bbQi+p26hFMrevZf5Ri5ulwWL9nXqIUJ3OJR288aFKrmvEe5+BYf4Xj/LQl2IcHyr9j66zCLa169X0+DP383rxbD/wUylBYq6Rk4ApyuY7lTISX84dIWhSRwQSRdFZ9tj5U5TPJXacCtYreHLyT0yR/Wa6FGhR1r2AtovqwLoFrV9n4Ly1ZanA8PPC2mpBEsWaAMN5DIJztEOu5QN1OvDu5/IrwhuNjHHumMImZguAnKIH8ZO6Li8IUYW/oR5t/MYBhO/jmsdjD3MOSqyv8J3/9uvMZ8XPTCUhAi1jNJqsrQ7/mVeLLosaY/Ir9rLa/L7Z3g6FQCFmw== 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=32pMiOlV7Ishsq6tGX0Ullqnoye0YjjxIeEj2mFpxv8=; b=X5YAWGxQ9vFf9AkThIkXUTFyj9Vdk/B4ty9tKsOHAfEf/XEoLf/cSW5vDTIXSieHHuCGelh7LEl6qhUmLNHJxT3adAtbVHBemSfjKpguqpigEowI+Q6i20zMaqMFHhzpkSI2N65oTdbMuddTg34/iXR13iIpWukg/CT7b75RiDs= Received: from MW2PR2101CA0009.namprd21.prod.outlook.com (2603:10b6:302:1::22) by SA0PR12MB4416.namprd12.prod.outlook.com (2603:10b6:806:99::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 07:53:21 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:302:1:cafe::e) by MW2PR2101CA0009.outlook.office365.com (2603:10b6:302:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.5 via Frontend Transport; Wed, 18 Jan 2023 07:53:21 +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 CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:53:20 +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.34; Wed, 18 Jan 2023 01:53:16 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 10/11] cpufreq: amd-pstate: convert sprintf with sysfs_emit() Date: Wed, 18 Jan 2023 15:52:09 +0800 Message-ID: <20230118075210.447418-11-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT013:EE_|SA0PR12MB4416:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e2eed60-f4d8-4383-d3ca-08daf9291198 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CN6ACeba/fobCRD8eXR+sWzyZKDtBGq9peLAoUUgidRTjkG2mJLkeBQbzrJY00GnwDN07UsjPQwpajrcf22zsIkEs8vBjxiBBNW7S0HsAq1owkgEl9mky7rpsoAFv2a+oEQwMTHiwtFXa2VrnRbhHQyH3XeW4gsRP42q7QgmzEAS8rLw7SHIEBW1XqHwrXTFCI2inq9LXOKi56FDZND8kCOduCn2r+QwrqEXVi71JYJ/vbo/mWZSgF2GRmWb4FdiLnAr/Nnqk1fXFGMzZncHprxsxoY+Ycr5Ag6b39vESxf1QsiEXLVRp+ncuzBXhGYVe5YOUxzWWzumw6r5AugKIY8geM7sR6QB1sWeel4nEOAwzQYkVQwZfTzbStCLZDoIeK/OIYypo36Lt1h+uhr5l9QrnmscQKxKS/ObGRVLMY5CW3SeDDyaxNxwKCfx2AxJzn2D4MiivXfMjgGJuLdDLO+2+zGExTwMHgepKoVkTot5BU4HRJKU9cvW0N43iNC8IxByCjbWq3AKEu1jxlDEwHETz49EBcYhTfKpLpD220Oz5N9oCfcg1Zdad//oAdU/2nlzgtvD41VyLXDTsQrvj7sQV/IgEAmka5BrdpzZie/lqmyy3AGLzTykwlcfOsxEA7SX6QTXgslolup5UPl33Jip45ojWQbEsVpmpLIp/FzkWkulA3KjMFaGGfbqUoxVYbU1LFH0KXNd4uLlSsEeESkwIpje3mXOjrGjxG7L5l0= 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)(396003)(39860400002)(136003)(376002)(451199015)(40470700004)(46966006)(36840700001)(86362001)(356005)(2906002)(44832011)(70586007)(70206006)(8936002)(5660300002)(82740400003)(81166007)(36860700001)(54906003)(110136005)(6666004)(47076005)(426003)(7696005)(316002)(478600001)(36756003)(82310400005)(41300700001)(8676002)(4326008)(40480700001)(16526019)(186003)(1076003)(336012)(83380400001)(26005)(40460700003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:53:20.8987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e2eed60-f4d8-4383-d3ca-08daf9291198 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: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4416 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?1755348540808575845?= X-GMAIL-MSGID: =?utf-8?q?1755348540808575845?= replace the sprintf with a more generic sysfs_emit function No intended potential function impact Acked-by: Huang Rui Tested-by: Wyes Karny Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- drivers/cpufreq/amd-pstate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 2e5e594dc41e..c307d67a76ae 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -694,7 +694,7 @@ static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, if (max_freq < 0) return max_freq; - return sprintf(&buf[0], "%u\n", max_freq); + return sysfs_emit(buf, "%u\n", max_freq); } static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *policy, @@ -707,7 +707,7 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli if (freq < 0) return freq; - return sprintf(&buf[0], "%u\n", freq); + return sysfs_emit(buf, "%u\n", freq); } /* @@ -722,7 +722,7 @@ static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy, perf = READ_ONCE(cpudata->highest_perf); - return sprintf(&buf[0], "%u\n", perf); + return sysfs_emit(buf, "%u\n", perf); } static ssize_t show_energy_performance_available_preferences( From patchwork Wed Jan 18 07:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 45097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2214711wrn; Wed, 18 Jan 2023 00:36:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8Gxu/aHmN1uARBjHa//CesrCZGdvKSpQd2hry82ejCVZsQLxhzLCYACaqA0oeK5gkBkBf X-Received: by 2002:a17:907:d50e:b0:877:5b9d:2f9a with SMTP id wb14-20020a170907d50e00b008775b9d2f9amr1452988ejc.25.1674030982285; Wed, 18 Jan 2023 00:36:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674030982; cv=pass; d=google.com; s=arc-20160816; b=Y7h6GfHYBJ6+TZNfYLLd8okttK5lISxf8eWQtvSenJiFMpSy83MEhZbmd0xduNKuxz n51y4e/ski4stA7m+AVSQCnX1T+T8K7jFj4mftFicd1fyCcGd/0Tj8rMPP0sw4kZLTBX 6E+F+xouyAbxQh6XqZGuoodNUmAuDijEjaI/m1xOh4h5+GRfB9uEGCZ1JYytO1jNUrVA TS9JbZSBdp/oFSFQ3+tjfaKfTgfDMGDH6O/QvGEFjXFBgd48mb9GuYAo4of7Y5RfygTF UfwQyz7o2sdXVloX9OzojB80F0f8ejvVVLkxrZ2ozUHLJgyQDYxHX1iHbMhNcJVIkRQP hY3w== 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=UUSe1i5OPPJzwoPGgnbIn1pCp1Owlinq3a453rgR2AY=; b=htoeQVJ4yEMbNCDee9DhQS6yBgEoow6UvMJ1HmJUNMtWHr5rONzQhJdOgfcMvHqrnt 0vknmvYXio+aXYB8Mh5qGHL+0+NzzOTXOV83/piViRJTTNNijL3su6p0pwxCLJM8p3DO xygqa21k1/k8eMYqBtp7+YwbyBRHxYGKfN7HSBTvKt4ZDNea8SaHRdVXdpGqscdoBHgu IJnpH2ZqwzgYwm7jY9x37lAFotIvz9MQ+wpb8jsqmJHT+Z6mD2OZhkuuSgnu4vATR4jN pdIUhu4E1p8ShYTKHaG0LnodgiYgO8C++5sL5QKtfA/24C6ZSD42sbLi+jIWB1VK4Rgm lnNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=WYLAHqcH; 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 dd7-20020a1709069b8700b0078dd12d0a9bsi40826635ejc.875.2023.01.18.00.35.59; Wed, 18 Jan 2023 00:36:22 -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=WYLAHqcH; 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 S230118AbjARIfY (ORCPT + 99 others); Wed, 18 Jan 2023 03:35:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjARIfA (ORCPT ); Wed, 18 Jan 2023 03:35:00 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2062.outbound.protection.outlook.com [40.107.101.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D5E7E685; Tue, 17 Jan 2023 23:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+emd4Y7YF8M9/f+BHvaxTHZwJn1zILURuLemTYiuL9pS6AeuZjOwC/V15jPb/SV6LpEFf6nwNYmVh+98JHqbmiuh3JUG1tMjUxV4BRGfWvoTjcsl7yDjKtDXlr7MCdKNq1293j8RdIFiJN9UHP2rd2SpFh7kI0T0BkHTm1yfZGYdGxOeSJK9FANUPP7D+t8D5Acu0iA4hU9f79ps9Y4EJko3RdnCKx5iSP1SOLYO1gmz6o445gO1WUBlohO9Ryk1KdMZJMEaxEH8Gjz2Ee8I5sjkGjrFJT4S/Oi5dnqL5Xtt3t/E1ZgJqE5OvgW212K1ZUYoCSMvwQAFQmoXgFe3w== 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=UUSe1i5OPPJzwoPGgnbIn1pCp1Owlinq3a453rgR2AY=; b=gW3SUy61NklzthpB/Ql1piX8ySePR0a7PwEAX7HPhJPHUKUnoMjFHyTlF0yZVo0ECNEXX3Vda0UiDyoAhJjG9Jhqmx1K9YqAcJjQPIUtEjk9K29NrOAWOzsCeaVUcCcUHUmFuwdmQR3RjTE5wb++6czodvtukwFy42Y6yBESDZQe+fzsf+vr4/NGwjxKFewmBXqELFmi+2MNItwcaZhrCMAafT/EosW9eT394Ke/kg0uOO22ZvKyZWMCrTrCjOYbWt5teSJ/w8N6zsY9dCr/RU9VU0SqiqWEbpB5siwwQfTUOA8Q7c/zKXaMWcoTtomtDaW3x1vbXy4E5W7Z1fNKMQ== 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=UUSe1i5OPPJzwoPGgnbIn1pCp1Owlinq3a453rgR2AY=; b=WYLAHqcHcEW10kbhXHbsF2jLW044AyPgik0jXJE/1I6uXa64VintnomccVcm35dGJu14KzjxDxszUdtKayuCm2CRJFgSVwIecd8If43jUn6WmFbDwQaX4YhdnhvEutpog6lASU8hbvDF8kZPZntKp71Yy+N6dL0R73CpLwAoi3o= Received: from MW4PR04CA0350.namprd04.prod.outlook.com (2603:10b6:303:8a::25) by DM4PR12MB6230.namprd12.prod.outlook.com (2603:10b6:8:a7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.22; Wed, 18 Jan 2023 07:54:02 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::4b) by MW4PR04CA0350.outlook.office365.com (2603:10b6:303:8a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 07:54:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 18 Jan 2023 07:54:02 +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.34; Wed, 18 Jan 2023 01:53:20 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v11 11/11] Documentation: amd-pstate: introduce new global sysfs attributes Date: Wed, 18 Jan 2023 15:52:10 +0800 Message-ID: <20230118075210.447418-12-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118075210.447418-1-perry.yuan@amd.com> References: <20230118075210.447418-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: CO1NAM11FT046:EE_|DM4PR12MB6230:EE_ X-MS-Office365-Filtering-Correlation-Id: efc1bcc4-394d-4168-339c-08daf9292a1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XT6RrkMeXqJsPPMw/58+7zrMJOmMhKWevQPT9Svi9b1IQAOxRWimSTbYDUnrwBHpbN42WwnhQViCcdCqcW9rW5NhsjQ5j3IHqCtNcHhJPCCY6hv0RJYEEMOCtc2KDNuBUlZlDuKC4ZUSQI6IoQAgqjyIh7u2qUK5UAXedPzIo26cEFMRpWrlov2wh+L3Yr30AO0SPKsr2wgcmtXlfSjxg+R9va1bd2qyRvvsiShA2Z3vwXBWZod9kIcqfIfpwnAzHz3fcdKp5gu+B5ALSRLrYzhiFhDXfZ6VGLqeUhEF/5zw9bBWhjxIsL81DEL0Rw0KiY6lzO2BveI70AjJxsNB6ckNAxrrNTA2Sf8je9jQC+YseoemPMT52Dodysk7ZX2eTbB4Bt3+dJ6jgXaIBD53J/JFAG22tKHKefrvdVylifpfpo7wD9vC7u/VBlFbrztoNdXZgt9nSgNvXP31qsFt/ApnPbFB0Amntk59vtzY03tH8ZNHSZbxetBso8yfABbv31VI/ccJE/+8T0mKGtqFmgwt93HXOzgEscjj68544ADmm47P2GR05S7Onoq2ekvXeVZYh7MgtLOFtrCDOnAshh2g4nrmqxd9HhQsMs3o/YpCFSoEoXt7qtgaKJRd9F1XOpQuU/12gYl28Lqj7AsalW8HmigJbz6dwBzI61ITDbAYe5XPS03kAjfaYD9gpbfMraQw9ZHisskC0/vzSrPNv3cRJvcdqm0raFbmgn32SBE= 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)(39860400002)(346002)(396003)(451199015)(40470700004)(46966006)(36840700001)(6666004)(478600001)(8676002)(110136005)(36756003)(54906003)(4326008)(70206006)(1076003)(41300700001)(70586007)(7696005)(316002)(36860700001)(82740400003)(356005)(40480700001)(81166007)(82310400005)(40460700003)(2616005)(16526019)(26005)(336012)(47076005)(426003)(86362001)(44832011)(186003)(5660300002)(83380400001)(2906002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 07:54:02.0538 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: efc1bcc4-394d-4168-339c-08daf9292a1e 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6230 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?1755348711233134627?= X-GMAIL-MSGID: =?utf-8?q?1755348711233134627?= The amd-pstate driver supports switching working modes at runtime. Users can view and change modes by interacting with the "status" sysfs attribute. 1) check driver mode: $ cat /sys/devices/system/cpu/amd-pstate/status 2) switch mode: `# echo "passive" | sudo tee /sys/devices/system/cpu/amd-pstate/status` or `# echo "active" | sudo tee /sys/devices/system/cpu/amd-pstate/status` Acked-by: Huang Rui Tested-by: Wyes Karny Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- Documentation/admin-guide/pm/amd-pstate.rst | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index b6aee69f564f..5304adf2fc2f 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -339,6 +339,35 @@ processor must provide at least nominal performance requested and go higher if c operating conditions allow. +User Space Interface in ``sysfs`` +================================= + +Global Attributes +----------------- + +``amd-pstate`` exposes several global attributes (files) in ``sysfs`` to +control its functionality at the system level. They are located in the +``/sys/devices/system/cpu/amd-pstate/`` directory and affect all CPUs. + +``status`` + Operation mode of the driver: "active", "passive" or "disable". + + "active" + The driver is functional and in the ``active mode`` + + "passive" + The driver is functional and in the ``passive mode`` + + "disable" + The driver is unregistered and not functional now. + + This attribute can be written to in order to change the driver's + operation mode or to unregister it. The string written to it must be + one of the possible values of it and, if successful, writing one of + these values to the sysfs file will cause the driver to switch over + to the operation mode represented by that string - or to be + unregistered in the "disable" case. + ``cpupower`` tool support for ``amd-pstate`` ===============================================