From patchwork Sun Dec 25 16:34:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp575924wrt; Sun, 25 Dec 2022 08:35:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGNoNIlw+XdFD17DCkFUdwVFDiz4or+slv0YVhiJDfwYSKiP+HW+0axaCCYYv3KvqUOvBB X-Received: by 2002:a17:902:7805:b0:191:bb:c207 with SMTP id p5-20020a170902780500b0019100bbc207mr16099570pll.37.1671986145357; Sun, 25 Dec 2022 08:35:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986145; cv=pass; d=google.com; s=arc-20160816; b=XiWH9ru6zE1HZXPGNlUTeTWpWIpRPEPi1+5KR7rWETHHqRd70Sc4irXh27ydnyU8ZU qjuteqDO6gKICxmU0Ftbqfx0T+XyCXNMx8STboJm8EiFLWgbhExdRu0I/RFRnow6DvTP fcUQ3DcYB9FPbK9OCDrelTVQB6Se3GjOc0GETwWeBuOojEdhNvkXe3bTozFUI5v0Bmiy /mjMs3BTCUInIlq8coJVtn2Crf2GETWxQiZdWjkvuButGgb7FthzceV2PEZaVhm8P4vO jeKw+4YWDl0fT2xNl26ZtPzTj8syZHk6KxaoNQpWoJ3vfoQxl9hFINXSXvZgtZguDSWf dHzA== 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=afDfwXcCFEv9Mx/n9ckRoywz+YnGkue90BUqP9OfSVI=; b=UekxliRI7juv4WUJYtJFNB4KulkRetfMGW3rcZ32MevC3xawFrHw7XorQYJS8ry7z4 ahZBrktIVvGYKcHLW0FF3k30S3jzMOmqicS64Pz5mers8q2Vvk/GZ2nLYQ3vLwqpHzK9 t+FBlCoylLgDEMEPUrdEFgyVr1knPiKbtiwhSnnCI991xSzp90Fq2CMSBXoMhX3BCgBV 2BEmCD3OgDjm69L/KHXX5fd+qo2Cu2LHYrys0Kjy2b+JETKENAwP697vZKO8UMbBwCDy d7k4ZHkFOmx9X1BmmKpn/c7qbk6RxpghLnUYwLE7f7FQXq3iBytpf3CE4Ph4wIDRpDOW Hcnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=wUpAtXt9; 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 bd4-20020a170902830400b00189d6969658si8511346plb.342.2022.12.25.08.35.33; Sun, 25 Dec 2022 08:35:45 -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=wUpAtXt9; 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 S231286AbiLYQfO (ORCPT + 99 others); Sun, 25 Dec 2022 11:35:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbiLYQfJ (ORCPT ); Sun, 25 Dec 2022 11:35:09 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2045.outbound.protection.outlook.com [40.107.100.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF65060CE; Sun, 25 Dec 2022 08:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bCssbWRzkMGxnQtsYGNMCt8zcWPi0YahcQkIVR1mFPKVVfqzP9vTkKmmvXLCwvsVgE/FO4CvNcQMhPdEp/FgecEW/DsJjmHhVW3gJ/wDhZksNdeqsV12mcVhmZBeOk+0uzd9wDGQ4szaksDB2brYq0wxORmdvXAv6xdekprNWZXfQ5vwpP7TsyFyn/y3Bzv7yBlhUt7X3jt8Mdu1zpDefP9ntmRfaZ/gfN1qDDrpCXC/PqpaQ1kLkUau3TmzeUXX3F8d5HySkrqV2gwIgJ7Jt8aM8LNhvFZ8XLNRxOJWVQeHuvbFfJe0gYSCSiiUc2tCLccI2kV6QYtHKeEB8qwJJA== 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=afDfwXcCFEv9Mx/n9ckRoywz+YnGkue90BUqP9OfSVI=; b=bKva3iR+URcJd4OS6FMvBQDTcZfihM3IKpb4R4qFGk8SAYNW3IYTDejVkid2K8BAWxQ2qo+Su/LFz86fohpxfCxQKrWCoFuS2gWB3XcmH8RSdIRy2YUbHECp06zK3nHoqzpWasdFKp3ho7nM0VNsL014jgCv5cjfwqi1BwLCgf7W4lnfpaQfgNBB4Bx8lcwHCTpPaPfnnc81Ixv/P5bbai89Bu4cZvecEwP4ViyCfscPeklv0TYRhhoZceL709HWU8/5XQo1ZE8cqaW4R8HvXwInQeNYU1+Zy1Ytrg9hprhgx9Ei5YsjQ+aNJAg6kaHfjLSsPY3TEkexzTVe691ACQ== 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=afDfwXcCFEv9Mx/n9ckRoywz+YnGkue90BUqP9OfSVI=; b=wUpAtXt9fOo33bQPqmZ8/DU+tViAU0S74oH1XGM8xeaDhoV3VtmBndxQx0PsjEmQfC7jgcTimWX5yTDJIyMgZotgd/vyFh0Gx7CDA2sAm6UqZ+XuuqEnvgxk1EBOyqJ39ufg+gXD02sZPPy8tQyfQmPjWN42yEtDRi7ozebo8ZQ= Received: from MW4PR04CA0303.namprd04.prod.outlook.com (2603:10b6:303:82::8) by CY5PR12MB6623.namprd12.prod.outlook.com (2603:10b6:930:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Sun, 25 Dec 2022 16:35:04 +0000 Received: from CO1NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::37) by MW4PR04CA0303.outlook.office365.com (2603:10b6:303:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35: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 CO1NAM11FT018.mail.protection.outlook.com (10.13.175.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35: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; Sun, 25 Dec 2022 10:35:00 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 01/13] ACPI: CPPC: Add AMD pstate energy performance preference cppc control Date: Mon, 26 Dec 2022 00:34:30 +0800 Message-ID: <20221225163442.2205660-2-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT018:EE_|CY5PR12MB6623:EE_ X-MS-Office365-Filtering-Correlation-Id: c76a7c19-bf5d-4389-750c-08dae695f9ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TMbr7AyTQC2uazF1cw6OsF0ahLCYCX3OT21LiduUS8safdnd855NxTgIwz2WkNiphe3av4NoGnddkcTKf7HkwVsbpbtPVjfdZsZPX3H1E3RhnBBMd4lL6BBNQVT0/h1YMFgWrpkCD/rMnasQURWX49qqwWji8qq9td+44GwvYONj7tz4e9znu2+Kp7avdUc2wgiO3b0yD/aLkiF6fD9ApRv4ic/mncl5RJrY4AKz216OWRXcrue9sep6jpIF6MBVcZiiJtUInPoyMYS8WUM5a033V9vU3bEr4YeQsIUwze/nFfUbM3dSh/R1p3+5jIH0KCxdpXIJbb/AX4JggULwS3C0rNU1tTq7cufc5rvro+xnlOnv8bQ17QJDhQyBSWd3Il5uDG1vB4fGCqrvfXGFWYxH9RlivPI/1SQM2caNKE1fyetAlxg3jRsAMFcqSTp7kxmsgjRuXHVnxK4XqgW3lmHP6d+VxfKaX9H8jgsUDWCzGOeTw3K9Hz3EV17RmOce93p9XFp38Ls70lxqYaVIxf59EqS7rYPxFrRJgRumpaast4ZWLiXeEqAf7+wdbqvu/lgVDcnbQqTzd/rjfXnTSwkLZMdJ0nP8gqyWx55oy1IdeLor9yOxtZddwlGEFmx8IOtQhwfKAF4tvwFeAFfca+Xr2m4HPIw0ZEeoK8M3lALIAzXlPA6MvlGUthL4ruF376wMUsbSixq14kfZiP/gDh/GbEnS+5ZoKu/Oh8iEVig= 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)(46966006)(40470700004)(478600001)(6666004)(2906002)(54906003)(110136005)(316002)(36756003)(36860700001)(82310400005)(83380400001)(81166007)(82740400003)(356005)(40460700003)(1076003)(2616005)(26005)(336012)(186003)(7696005)(16526019)(40480700001)(47076005)(86362001)(426003)(4326008)(8936002)(8676002)(44832011)(70586007)(70206006)(5660300002)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:04.2322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c76a7c19-bf5d-4389-750c-08dae695f9ec 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: CO1NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6623 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?1753204544486078802?= X-GMAIL-MSGID: =?utf-8?q?1753204544486078802?= 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. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Wyes Karny --- 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 093675b1a1ff..0ce6c55a76ca 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 Sun Dec 25 16:34:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36486 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp575958wrt; Sun, 25 Dec 2022 08:35:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXtPPum8Chc0X8QnCNEy4nkGw12fBWnTOh1DwvnHOmy8iEPnnsFK5jv3cctj7DQyzI2/bVEd X-Received: by 2002:a17:90a:1c1:b0:219:705e:67b2 with SMTP id 1-20020a17090a01c100b00219705e67b2mr18474550pjd.10.1671986152178; Sun, 25 Dec 2022 08:35:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986152; cv=pass; d=google.com; s=arc-20160816; b=XzrkxJnH6P30h09FAsORXoLKHmLrwo4bfP6aSfkctqKSW+hWifundl8VyFQgE9cc0I rqfvNN4K46pDtkXw+Bd6iCb0pvOkeXK2Oc9af8Gbopp9L0P+AlsAsywlEfxlwv+wMjBl /1pV5p2tGKzkk+8EmwzpGSPnqh++GHsonKHIMxEddQbtXAgEc9QvYFLUJfl/JrVzU2Nx 5pKw3iw8QC93pGY2GicnFlISJgMZDEwu2HJpxLVrbTUm/xWvVooi09X4nbVev/yriLkA vX21FZrl5WAEu4holySSxxf72bKpCtoUcUPmmQJBkh+DdUEE+0oZolJWUbcJb7cpnxKS K2Xw== 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=h267RDvz9Tsmg3si31fV5d06ETOHd1pgo0C/8fYd4V4=; b=N8zDcYRblbdH5bsoyLbc4YX8FREPrzXmi3Xj5RE0qVpt7wXAtXzgp18JCRoUbXCKuX +EQSzZ8fNbS+hNz9S9cXb1F4N2Brq/2r2UNYUO+vDPt/UTT9Wd99r8ZWd5kWQCWl3cI3 HNJbAn3cIqoKeOxpGUL8zoAe8h5CZIbECLAcfdxgSXSjcKkRZJLjg1msr/FFFYwV65pg NU7vK6GLPlmeJfayzMPAr3R4Sw4z4IyCG0BBeD7hrC7KVNB/rMzMa3rtRiiIAGKtYxZN n5iHbXRVmk4AvPCDYXPFjeLstvekTAUvSh0po8k5bYw6E9ohElmQFQNnENQmX/LzjNTe wzqQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Ua8HiQX+; 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 na17-20020a17090b4c1100b001fd8713170csi14382566pjb.179.2022.12.25.08.35.40; Sun, 25 Dec 2022 08:35: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=Ua8HiQX+; 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 S231302AbiLYQfT (ORCPT + 99 others); Sun, 25 Dec 2022 11:35:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiLYQfN (ORCPT ); Sun, 25 Dec 2022 11:35:13 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7960360CD; Sun, 25 Dec 2022 08:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wy+bLYjd+dLEUnQS4hsbQCdKP4ccOBPvZcBRoBAm7IMOe39RSJpghC/MdGjr4c1PyUuzmu2hqGvkPfBTQsc8pmSQ0CwXm5kfqDq+hJnRS3ZLb+PZG05CAFDD7PZoAiorYm4QOY2alfu2CdfxnCqvG2NNYu+JR8nmqdvy3P0Q8PYjj9TPEV6o/8kobhKANYm4iadypmjZO7x1h3nKPFlNUlgJz8klaldbKJXmrHER6JtK8pbDDddaen0eqAd/341+sd0WIv5xmfcDlHW4YBvV2CvXqSpmj9/otelZHjTH0kbdXm1TB55rzWANn3dm8J/wWWKshGe5I+nGWoG2OCVb1Q== 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=h267RDvz9Tsmg3si31fV5d06ETOHd1pgo0C/8fYd4V4=; b=H2lh6KF319wn3T3hrTS0H1E2xqaI2IgvRrKaqZ2kIaOpR+Ol3qCGC+GpMxVRFR9pV4dFN+au2GVJxEwE/AzPXCfTz44QNVKnzKlygGzTZ28hQBjW0gCdRRKKDJz31BxWFp9ZZVMHrujSWtEI75OkY+GanMVBd07y22eEzHN6QQAQaQAJwNbvqlyT7uztzs7S0KxrQ4p6TQQuRvkcPmcLYW/dWtkltu3i5dHwtfO5VcxAb24wiGP2PssfdVpiZQel8Icjph8CCgoaoRnRGaCT/EIaITy8DKjlGpvjI4qMfq7e1ggplXakoLUx+nI2W37P40K93bFxyQX1svA0HgLq4Q== 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=h267RDvz9Tsmg3si31fV5d06ETOHd1pgo0C/8fYd4V4=; b=Ua8HiQX+tgbaCsSDGExJjDvg4jumainbNdfhvMMhkE8+eIIlWqjSaHoKgqA2sVukD0/j2k7+8yYkTZIMgl977iQ0aAbfrueohbcJEFcEcge7vRvnzabNxx2wsjHHzpWrPG9sUiPTpdglrlbhKyuEobeqB05S0y7pg26cgVFoFhg= Received: from MW4PR03CA0070.namprd03.prod.outlook.com (2603:10b6:303:b6::15) by BL1PR12MB5948.namprd12.prod.outlook.com (2603:10b6:208:39b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Sun, 25 Dec 2022 16:35:08 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::bc) by MW4PR03CA0070.outlook.office365.com (2603:10b6:303:b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35: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 CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.14 via Frontend Transport; Sun, 25 Dec 2022 16:35: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; Sun, 25 Dec 2022 10:35:03 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 02/13] Documentation: amd-pstate: add EPP profiles introduction Date: Mon, 26 Dec 2022 00:34:31 +0800 Message-ID: <20221225163442.2205660-3-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT051:EE_|BL1PR12MB5948:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c19b861-278f-42a4-7b1d-08dae695fbe9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5a++Yg4I3ZOlPBF/ZJEELVFpiqEovEmqjyAikTEgDnOBY8cSK91Ja8EleJIGhnnvKWM4CzekDDrWgB8S/trQe/Ej0s9Fl+F70u5+KwAY8Hxr3YZC+2JOIFtMDkeaRj0ndIzUhfE6BpQHwL54H/fTC0NjgNQZLzWqbaJaCMBeNSU1awyo52U6W2z9zCF15v1/n2l2Aot48IySHpXy5etHmEJ6NKKEdVvd33qpthhgxIvrPoGp6BqHGyjgE8OPtOtdCu5n5f7GJDni/75SheVfNsRXZU/WcMCy/FvLStB8FMEGiE148SBC0W+bPdiUldXuoWQFvAx5pDH734tCA6VWUXNDAwIAeNG0v5VpU2p7u5VY3uGDlARzi9LOLuLTrEOPdltjw2rnDvwxu9frhPdSssOe/5VHe5zfpO7qu/BEbGDEQcf+BCsB4gJQpnoGLmqdrhXVTGHThywgv3FgbEGEYGuv8gVaLYQF5YjuR3dTpwGTAuAC9Jo8+G8Gp7Cv3X4YHbaT86qEQSK/Gt9zygpyLV564qtuOlx4DVpQ/msjVFWImqGwj6fMgXyGAHwycgmwxBqC3IVFgqpq5Wkpi2RoSfXLLw1zvCMjjJKYxt9mPQ110+UZeOqqbeJML3RVqEtAOYz5CugTQBv0KYnpjGnRoYYKUeb9KbnKB7/1rqqWMWYv5WCM3cF+caQGA744ac/sIdAC7Ay3z5Qr3TMwMdqIRmI6D/1I0El1/DQdmPsTFpo= 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)(396003)(39860400002)(136003)(451199015)(46966006)(36840700001)(40470700004)(478600001)(44832011)(70206006)(70586007)(1076003)(8676002)(2906002)(8936002)(4326008)(5660300002)(54906003)(316002)(110136005)(7696005)(6666004)(2616005)(336012)(47076005)(426003)(40480700001)(82310400005)(83380400001)(16526019)(186003)(26005)(40460700003)(82740400003)(86362001)(356005)(41300700001)(81166007)(36860700001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:07.5526 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c19b861-278f-42a4-7b1d-08dae695fbe9 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: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5948 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?1753204551699946606?= X-GMAIL-MSGID: =?utf-8?q?1753204551699946606?= 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" Signed-off-by: Perry Yuan Reviewed-by: Mario Limonciello --- 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 06e23538f79c..33ab8ec8fc2f 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 Sun Dec 25 16:34:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp575993wrt; Sun, 25 Dec 2022 08:35:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXu6JbckMAatUn4ySMHldXdTSDm5vyY2GYy46ia1rJvfliHM5kOqgc2VbXkdnh66IwrWBznK X-Received: by 2002:aa7:9698:0:b0:573:1d31:2b87 with SMTP id f24-20020aa79698000000b005731d312b87mr19627683pfk.31.1671986159442; Sun, 25 Dec 2022 08:35:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986159; cv=pass; d=google.com; s=arc-20160816; b=O7kRfmC2PUBiuliyBYUbEp9aRp3aznGpyyZiM1hiJDXOyLL+Xc5f5AR74XaGbWDQfQ Gj1Q0AhYKeMPCYkNVL589HSr+Olx7URBkRzPHrrPWGrBH8ATARbTPCZINYpw9PFsbUy6 8iM9pvF89jxB8W0M5UFiwBk904dsTPivgwpZrPTp64nmsdyiKKNtiaSoU54/StQTiGlD tFzG+22aSRRCGo2oy47EYc2cSgYMcT/HJUHSPcjIjXUrluzJ2idIT22aN6v78JhLDi3A oj8QnJWANvqyDnfuU/8powxcS/ghni8eoKJMD9LNVDYqBxD136SAmeI/tucPTzAhCu8C X1dQ== 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=R3amnQ77wK2Km0IPoODW0UP0G0LauRLRJr69Hwml7CU=; b=y28Sp5A/tFgwgPROC+zrt+/56jxUd3gaKqivo5aIhv0qt9IVwaE/Ynnh5yjaFoQH7/ XaWnwxTkEgFV5b24HgZ0IG5rvSGbeiBWqlt+6KOfKgrGsoqPrEgzy8s73TzrmLPM4XSo FSSevUUuElMERxOXW8ZmWuj0tMg21NtP+aH1bEixf7Tg4pE6GD0qzk2p2z0ZavtgUxyz bT5T0dVN1E57Qc2JxE3thV+yTa0HPQR9jt6s/5XYH4q4gs3xj70C4sV+RaEQjIiZ8SG0 8T93nFF12eT6U8GXq5GYSK9Glc3iZBNWKFUYqfkPjy1L5EeMlpwg/llmrkN1z6u9ot+5 gsgQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pC5zYjHZ; 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 t15-20020a056a0021cf00b005634d0b379dsi9572313pfj.115.2022.12.25.08.35.47; Sun, 25 Dec 2022 08:35:59 -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=pC5zYjHZ; 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 S231387AbiLYQfd (ORCPT + 99 others); Sun, 25 Dec 2022 11:35:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbiLYQfR (ORCPT ); Sun, 25 Dec 2022 11:35:17 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2082.outbound.protection.outlook.com [40.107.92.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65BD460DB; Sun, 25 Dec 2022 08:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J2H75r2KtKyRjTMT4QnTzNKY6uDnD6SdRvjUPlZ54hxdeDJkPO7uK4pbRFQT2ol9XADvhiFkl8TX5sqzs2fEyMhATPg7Pt9rI1Akemxix4nDm8BzN/pCGNCuu/Cpu5gUBLP1zuvAjrVw5pEGhhudq5kVHBOY4BweK8I5tS4KDNlN5Xs/+GSY7S468jp5CEYePIFShDQZhuAsKI0OLCKFWta441Tl9ROBxQzRBsRQ1e+nNbBpyouq5gSQtDsbbiggXK6eVgHcDGCfs04LPgfzWVVBDwjjG+r8xOqn1NZOkYHllgeenzKJ4D1VgXUNEnYXHlPM5cw7Gi6wYmqyrUzzgg== 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=R3amnQ77wK2Km0IPoODW0UP0G0LauRLRJr69Hwml7CU=; b=gjbvcO2R3kSYIOAMR5MZIFWyvo74bobGAxHMNcraetFr/OJFfeH/DBkTNj1vReaBe0/+dR2Gg7XoZE3bMGW+TDEyK9Zmpj7fymOfygwJ4NYe1FEmlzzqSTIljbD0j6lpj+seqQQFKXtuG8rM5WdnKsZccXjfd0Br2XQQX59zSD9aMOF0pnQxQnYpjIHcVA/xGy10aEZpz7nhz5/wgTP1sCd4FqAdTE31kJowVC0kDhaYgRDGxqqu2mc2ixo7U0wI082IQHR1A95R1MuvI6741iXvs29P5TYA8hdBrfg6vYdOLg3dEUx3Uk9oWmQD7OK2o4YV2gC+7g4RtidhpPEodw== 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=R3amnQ77wK2Km0IPoODW0UP0G0LauRLRJr69Hwml7CU=; b=pC5zYjHZ4hzFYGawvzKJBSucLK/sFs2g41D0wUaVoynxwqf7fmAy4yvjZhQKzj3xzZFZaNXyOY4hsOO8PnQNlQUO1rQ05rEDt6beCqGuIwlQNpfo2Om1z0HZk5MEKj/Na6B5+VYXqlgVVkACJ2Odt1fqIn3DV8JCjtIb8sWLqg8= Received: from MW4PR03CA0253.namprd03.prod.outlook.com (2603:10b6:303:b4::18) by MW3PR12MB4380.namprd12.prod.outlook.com (2603:10b6:303:5a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.14; Sun, 25 Dec 2022 16:35:11 +0000 Received: from CO1NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::41) by MW4PR03CA0253.outlook.office365.com (2603:10b6:303:b4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.15 via Frontend Transport; Sun, 25 Dec 2022 16:35: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 CO1NAM11FT093.mail.protection.outlook.com (10.13.175.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35: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; Sun, 25 Dec 2022 10:35:06 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 03/13] cpufreq: intel_pstate: use common macro definition for Energy Preference Performance(EPP) Date: Mon, 26 Dec 2022 00:34:32 +0800 Message-ID: <20221225163442.2205660-4-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT093:EE_|MW3PR12MB4380:EE_ X-MS-Office365-Filtering-Correlation-Id: 90f3a39e-0ea1-4240-d2a4-08dae695fdf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nL5zGS3aSaVCe2wGyrMOVv1bF62R+hEcFPfkhNdQnJOUY6W/OyQ+m42M+GFJ5zNzDmmaxfJ8drmt3jbu/WMjmpF3HKrN2h5b5uacuzM8VojQeJZtAx8H1SgY51MyoBTEC6B+VqEHGnCgHRZ+ToNgmNIwcIW+QrJKqJWEi2sWvWYtJOWZiREFUN4WYXhyLXVUWfZT6cqTxT69EAcni13gGrCcxG8EaMSTXhXjXgPhyZwqbXuhoPkKPW0Y1Fi4Bo9K9psLlYbaAsKA4HoHETm0FlpaZzO470wLTzV4fk+77tis0zfOmLJ2LwcWEnpWU1uRxIfD9CLcoBTkcF0GTJE8kdkLFO0GhrFJj2a709jgGjk/ZiIO66n7MS+BgHAlnCF6Svb4wkPzhRLteMzxNjDpaPIQoMypKQ4zKCfFGhHwAtWxHa4MovRgqk1f3n/Jtqcu9erwp87+SAHtOEaVG84P1ljQUsfDKMOB16wirRj4Qim+W0lsbbrgRKiyHfUdg9VFSNeZMRv9GfpAxH9GDPY7vWCMK/VqzoMw+JFPwqNnjKLPP+5thhWZtTFzWXaJiBPL7QAe/cMCWgKJSlrfcIYDPAcAGh2nkL3QCylxJnaFu2pIeozt/BWZb7u7ex5cl/u1QIvhCeBnGLepDBqPZLrrtW4FJwhQlq58X62UnNWOHIocYXt86c6dbyo/uR7BDgiOfxqUz07T//1DLxbM0qqbJeq8K2HxesepnAs4AToWZAQ= 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)(396003)(346002)(451199015)(40470700004)(46966006)(36840700001)(36756003)(82740400003)(81166007)(356005)(5660300002)(2906002)(70586007)(70206006)(4326008)(8676002)(44832011)(40460700003)(86362001)(83380400001)(36860700001)(316002)(478600001)(336012)(2616005)(54906003)(110136005)(1076003)(41300700001)(40480700001)(8936002)(82310400005)(7696005)(426003)(26005)(6666004)(47076005)(186003)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:10.9561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90f3a39e-0ea1-4240-d2a4-08dae695fdf0 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: CO1NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4380 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?1753204558873451615?= X-GMAIL-MSGID: =?utf-8?q?1753204558873451615?= make the energy preference performance strings and profiles using one common header for intel_pstate driver, then the amd_pstate epp driver can use the common header as well. This will simpify the intel_pstate and amd_pstate driver. Signed-off-by: Perry Yuan --- drivers/cpufreq/Kconfig.x86 | 2 +- drivers/cpufreq/intel_pstate.c | 13 +++---------- include/linux/cpufreq.h | 10 ++++++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index 00476e94db90..f64aef1e093d 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 @@ -36,7 +36,7 @@ config X86_PCC_CPUFREQ config X86_AMD_PSTATE bool "AMD Processor P-State driver" - depends on X86 && ACPI + depends on X86 && ACPI && X86_INTEL_PSTATE select ACPI_PROCESSOR select ACPI_CPPC_LIB if X86_64 select CPU_FREQ_GOV_SCHEDUTIL if SMP diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index ad9be31753b6..93a60fdac0fc 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -640,15 +640,7 @@ static int intel_pstate_set_epb(int cpu, s16 pref) * 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[] = { +const char * const energy_perf_strings[] = { [EPP_INDEX_DEFAULT] = "default", [EPP_INDEX_PERFORMANCE] = "performance", [EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance", @@ -656,7 +648,8 @@ static const char * const energy_perf_strings[] = { [EPP_INDEX_POWERSAVE] = "power", NULL }; -static unsigned int epp_values[] = { + +unsigned int epp_values[] = { [EPP_INDEX_DEFAULT] = 0, /* Unused index */ [EPP_INDEX_PERFORMANCE] = HWP_EPP_PERFORMANCE, [EPP_INDEX_BALANCE_PERFORMANCE] = HWP_EPP_BALANCE_PERFORMANCE, diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d5595d57f4e5..0693269fb775 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -185,6 +185,16 @@ struct cpufreq_freqs { u8 flags; /* flags of cpufreq_driver, see below. */ }; +enum energy_perf_value_index { + EPP_INDEX_DEFAULT = 0, + EPP_INDEX_PERFORMANCE, + EPP_INDEX_BALANCE_PERFORMANCE, + EPP_INDEX_BALANCE_POWERSAVE, + EPP_INDEX_POWERSAVE, +}; +extern const char * const energy_perf_strings[]; +extern unsigned int epp_values[]; + /* Only for ACPI */ #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ From patchwork Sun Dec 25 16:34:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576081wrt; Sun, 25 Dec 2022 08:36:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXsngEQbZoJce70RmoLSHGT/LVQVYsVcLr8a2RVOTFMuNSIIY42qagInfYNteJEBdeOw27Gd X-Received: by 2002:a17:903:2013:b0:18e:4121:4b46 with SMTP id s19-20020a170903201300b0018e41214b46mr15635825pla.25.1671986179529; Sun, 25 Dec 2022 08:36:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986179; cv=pass; d=google.com; s=arc-20160816; b=K0EhATV1kSOJyA2AhtT2oS6sxZjiHgRzAo8YmmzvmPqkoTVswTzBJb5fDQTGX8GxU5 GRxJAXH62M1+IKjheN/Kz2lgY7NnaIGlkI/oO+4MuKHI6IvglrRRFbMpoTui0/NvO3Qx ZRjmA94FEekmreTXUtAs7d+XZ4OSWU3XsVYI75a1p0n6hcbFGjCRXh7JFAV6KSWBrerp sphX+Ewm29Q8QT6x9oKC3l2XdR6ozQPzYEJmrAhNZGwVXQvCw5VcshSYlRSF9LL3uTQH cBjtd8OS1ae64YxrEcWAPgG0Pe1HPEBSrcdEE2nLCNgtZer0Y8MeyNCgeEcP/65q/q1e sgYA== 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=BKXpjY9aYWFFLNIkFsMgRO96SSIU4dgItG3vbJMFxj8=; b=sUjy8WnvsQ5YZYW6hRAbfxsoHfVwN5m5OKmK643GAxDws73CARRVMH//kQ9aFkH5n6 QHS/zywCquPK7NY49onqLU9xGx+/y9bzVEyrlOrzpWBXTcW0GYGgjp2RQrx9EP+JOo2K w2h/1qDFF6ieTFqqYgZiimsJUhsMsIUgP6LCMl1gNzHYlE01KdmNTNhGTJrN17wSY+wj VPnSFZM1PcDyjVj4rmH2GZiCrgjfDYMk4fgvMnAwYhanddMOLedIk+zOWitN2VmmRTy/ VtVJFnm4alm0utPq7pMkOi0b32AmAuprpCrsnTjV78KMOJyEh4IKczUugoXW5gOtXgui Ck0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=IxyaAxJl; 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 r10-20020a170902c60a00b001924febcabcsi8495999plr.420.2022.12.25.08.36.07; Sun, 25 Dec 2022 08:36:19 -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=IxyaAxJl; 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 S231444AbiLYQfp (ORCPT + 99 others); Sun, 25 Dec 2022 11:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231367AbiLYQfc (ORCPT ); Sun, 25 Dec 2022 11:35:32 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A67C60F2; Sun, 25 Dec 2022 08:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NKoZMtuCo1poWN6NKHpljutfYhW0TbSWd5WduK3fTQfPGkUSg7BADeYHrbZ626R3llrvWHGl5GxeYkdldqFIvbAa3JCHYmSRmXP1HPbNKqjlh6Y5qZTZvG4YDOeFue79BYluzCt+lyrTHitd/1gqmqwLyiSKTdAIUP0gxO5cu3CoI1utU5yA4LQCqxWSyo2QAfgUS8lOR9l7kgQMlsf9JSfJMWpwM0HgH7BurFtdR9RFg0s8IMPcp1qcyJXufL/qV6LJR12qMtCg+RM0mMmQ4t60WZiGOwRCsWLjWL7z6ZxYwaA+xSZSPPSjkzZ11DzcJR7WzG1MBvRbRbtpvU33Iw== 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=BKXpjY9aYWFFLNIkFsMgRO96SSIU4dgItG3vbJMFxj8=; b=A4MRKa3r27O0Pi+5cOWinolvyYDUkAVrF0LIYqUW8Pb/ij5DJ04G8XZG2V6wfnhURPHyRdSWEqbgDZrZBYb7x0Ns5RiLKWnDXHoMfgDKWh1K/8dEoguVUc4PpmXHhzPw7oo1hvu1K6cMujW73HlttlEQh8VTnW5acNqKK292N/HuQTHDWAXP95LkVCofYB1JqPxGMt6jXmFCB+Q6zXY+5LcMv0jV1HolVH73OQ/PadwoW7TOAfxCNrxluVDZpQSHJKkhQqpNFwyhIlaWTCB0lQrtyH+wqfCcVCS5tXiObvCiECRYwpQ03Z9Bnw3Ye24QcWab4eh2G2qblhGFrhuknA== 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=BKXpjY9aYWFFLNIkFsMgRO96SSIU4dgItG3vbJMFxj8=; b=IxyaAxJlkkhfOw0zz8bBIufRrkTIlRL72UXcBzqm6SSs5d7N8nj3NNPEK99H0WIhqjwyuvr8kj2kuK13IrfozrCPKoZFKa5n1MBBTYxp1o/9pHkNZiI7h+MBnH/1pLYxTv7E1kppwEOhqrbKEGyP5oEdjveR4ru7sjxy8LauQVo= Received: from MW2PR16CA0049.namprd16.prod.outlook.com (2603:10b6:907:1::26) by BY5PR12MB4949.namprd12.prod.outlook.com (2603:10b6:a03:1df::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.14; Sun, 25 Dec 2022 16:35:16 +0000 Received: from CO1NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:907:1:cafe::4f) by MW2PR16CA0049.outlook.office365.com (2603:10b6:907:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT082.mail.protection.outlook.com (10.13.175.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:15 +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; Sun, 25 Dec 2022 10:35:10 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 04/13] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering Date: Mon, 26 Dec 2022 00:34:33 +0800 Message-ID: <20221225163442.2205660-5-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT082:EE_|BY5PR12MB4949:EE_ X-MS-Office365-Filtering-Correlation-Id: 2775602f-91f1-464f-e95d-08dae69600cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sEO9h7c64vS7wrmDp1FZWdt3qTbZzkhIpbZ8X13q8i48wTW1bylnfdoA/6aHqLRZartnOslWfrVUTpnz9ZCcgTsTmX4Z525PhwQJNiczzrtBqp4xxV6z5xnfpe7YkCyWCHrwWyfUc6DuXGiMfKizukvTontxDXJwLSKc6fBV+zfewpPkX+/8U82NWOcQOYB4Bh/q0sy1kgMROQoEbmidx5h6Dt1VA4oMELqZVreq43FitMRj7zbJIC8KuJUDd5aPoOHfZHMmC4sJgEH1KdSnKbFv7CD9FlyhHk7KMxAtpqqaFM63xveq8JAVAwpQZVRZR1sVjyh8Gw1op8vMAIqlBnO4L0z0U7fY5IHEK7vIIRLYHIxDnyanMkofMKa8B/gpppVvJnGfZZ0uoYntge3Qv+sCDhytcQBiWYq9FhIeMQtAutkxFD+50vDYFYZfpNjGwa+B81zsV1E0a/b7VB4gwpSY3HXlz1+ZPLnZnthQcW/qa0t0SCPpaxyfU0MTB/ZChykkjXHjA+KuAnTGnY06Yqicubya4ejEU8iqRYJtbdXsJAHKB6DuK8GcJhnKKb+h7667a7Y2SeciZ3ztmL+MVf3Jw6PqCPVs4uPi8AGTmpEKJSVRt85NFhAQFrC9/LCDU1M9e8Lx62lE6XtdNTwgP4HSY0LavqWT7XKNODKaroQuPaawXdXtkMiOi9mb32SesU7ugkcCrE8H6ibK3LHv0umKb2c3/ivDqMIXST5poq8= 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)(39850400004)(396003)(451199015)(36840700001)(40470700004)(46966006)(70206006)(4326008)(70586007)(8676002)(478600001)(6666004)(36860700001)(36756003)(7696005)(40460700003)(54906003)(110136005)(316002)(186003)(26005)(16526019)(82740400003)(1076003)(2616005)(2906002)(44832011)(82310400005)(40480700001)(336012)(81166007)(356005)(86362001)(41300700001)(47076005)(426003)(8936002)(83380400001)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:15.7605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2775602f-91f1-464f-e95d-08dae69600cd 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: CO1NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4949 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?1753204579775595959?= X-GMAIL-MSGID: =?utf-8?q?1753204579775595959?= In the amd_pstate_adjust_perf(), there is one cpufreq_cpu_get() call to increase increments the kobject reference count of policy and make it as busy. Therefore, a corresponding call to cpufreq_cpu_put() is needed to decrement the kobject reference count back, it will resolve the kernel hang issue when unregistering the amd-pstate driver and register the `amd_pstate_epp` driver instance. Acked-by: Huang Rui Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Cc: stable@vger.kernel.org --- drivers/cpufreq/amd-pstate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 204e39006dda..c17bd845f5fc 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -307,6 +307,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu, max_perf = min_perf; amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true); + cpufreq_cpu_put(policy); } static int amd_get_min_freq(struct amd_cpudata *cpudata) From patchwork Sun Dec 25 16:34:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576290wrt; Sun, 25 Dec 2022 08:37:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXtfkDxuga8zPfG5fZ7dfOy/QN2FZ+wvURa9XNyihAY/M5eUAkceQoPNZ2HvJG78LPn7Stpo X-Received: by 2002:a05:6a21:e385:b0:b3:4044:1503 with SMTP id cc5-20020a056a21e38500b000b340441503mr985992pzc.52.1671986228609; Sun, 25 Dec 2022 08:37:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986228; cv=pass; d=google.com; s=arc-20160816; b=CmBnQWlHQyf4X/Gv8pNsOLTtxI964rLwhRBLooZ4CD3cokdIetB6YRzYRLFRl9Olyg GQ9+Ttt/fl6+p51smGvS6Z5ArqCN5A92jDXo81Ayjc8WFulyPNDHw6hXfrNGcEahRs8g DBo1YzzojeAt4AEhkToLtagZMDAagnq3TkiGguJ/zs684GQ58I3xQuKI7NQ+18Koxb13 o9ZXiQ3FE5dQ72K0ZXC5+JsRvHZyMUtr2W8lSHGAZdMWlOMMOsMfaG+9rxME78mtwFXF 0AoTMWpAiWdHmmbhwMKuvdZkGQPDSz5se7JvZvuTzYRFBUaAo9kv9xf8pbxntdHV7QGL 4BVw== 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=JyaNrW7/x7nEksv3aGo7IuUXThPw1VBfticrfUewgpE=; b=nByVrJlAIbsJaHHI9qvuaKdhjZefuwP4LDpcmR4hiPXwbmcCutSQT7D5uTwj4w1y0W 2hstQ07L03DgaqZ/pYfoIoQWzJHvrmSeGHlw9WMGdzQKZZrIHMh145CE5lOOCDrs4p0o SGW7S1DXjf9JGvZPBoRy5yp+bVc9OfXQyCYIL731I5qY9b1L9HuJFTC1ihEPmmDJobXM DCl0aGMRviFBY9KEeeutpSYA1AhMLmt1VijM0zf64yX9APLCa82Qg9mX5GBWaHYmN72A Pbo1SUOZaFffM9S6lO9GRQnlDtVNYSKtmzX+5ZbXga2pkJ2fQOVIPvzR14GP+ML4fJG8 1ulg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hmOFjnm0; 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 j1-20020a634a41000000b004790794f0a7si8866386pgl.1.2022.12.25.08.36.56; Sun, 25 Dec 2022 08:37:08 -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=hmOFjnm0; 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 S231429AbiLYQfj (ORCPT + 99 others); Sun, 25 Dec 2022 11:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231360AbiLYQfc (ORCPT ); Sun, 25 Dec 2022 11:35:32 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2053.outbound.protection.outlook.com [40.107.243.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91C96268; Sun, 25 Dec 2022 08:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tx8fNhkU9DBi38uoDDTOzUSdspaivgOZlnUhCObYTRvwduPtfS2xikVWPrsoafxvt7AFHiKjCcadrsMhMWHpDyWHXicd5St6xaptGKSH2f0+t270rjcJPGQIvS/xjI6rdeLG6ApALPC+rH8baXKpyfLozz/oFzJ5HzXM0zbDoYMMvtq8kXbhxR2G06tT6mRgpo8L8irmAzd95fKNr7owXboy44mZf1+5Qm4jCzGovW5hjYRRknXrY9t5o6GW/9QvgujRPbQG6wrwGQbQut7Py6t9H2TUGWTIOrdGeUEtoPeJKTpcjRgy0l6Nfq3yE7Rz4pFHRfl4nNM39/lJ6LCSQg== 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=JyaNrW7/x7nEksv3aGo7IuUXThPw1VBfticrfUewgpE=; b=fe3yyc3l7ljp4EoWUcM8G8YInoRwN+0FKJPctHch6g6kPnhpj68JiYqjcnFxCKx33R/Ku8cZIPty+ShV2d/oU5E7PmVEblAYf5asfnbHPgg1hlau2Pi8l6wSVIB1ni5rdCVf4qLvFiSslUQcROCh76UzxI3qQ8l3CylqtQLP1PgSKcEX0EwSLOBuZ43iKHcBeUTrhhUY1yyrJa66roaG0FWpscNNi2/HLMU8t0Mx+FEdefTaXw+aUhHkb6CYv4zMy19JWL/UyYkvP+Dyj70EOj4VRvtc3OSO33OuoKUIk/P322HuPPxZXWlY/OpLxM1rt4sWsKU1YCAC2CdFmeN9pw== 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=JyaNrW7/x7nEksv3aGo7IuUXThPw1VBfticrfUewgpE=; b=hmOFjnm0fLx6TlwruZb4S88hF5RS0GRv+5W2KlBbqnP4QkfEZ2/A8STi5FIR4zJZbyfS+hx6XClNRpW0sSOJQuLnuOrVEXydicWzFsDqiLn80b1PP43pzKj1qha+jPl1bpeX6Abys2F4PKWk/xGi8NEck9e+5pqZaWRA2dUCZJY= Received: from MW4PR03CA0255.namprd03.prod.outlook.com (2603:10b6:303:b4::20) by DM4PR12MB8497.namprd12.prod.outlook.com (2603:10b6:8:180::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Sun, 25 Dec 2022 16:35:18 +0000 Received: from CO1NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::1d) by MW4PR03CA0255.outlook.office365.com (2603:10b6:303:b4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35: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 CO1NAM11FT093.mail.protection.outlook.com (10.13.175.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:18 +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; Sun, 25 Dec 2022 10:35:13 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 05/13] cpufreq: amd-pstate: optimize driver working mode selection in amd_pstate_param() Date: Mon, 26 Dec 2022 00:34:34 +0800 Message-ID: <20221225163442.2205660-6-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT093:EE_|DM4PR12MB8497:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a432a3f-0251-4447-7e33-08dae6960239 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KxXDzerO97oVEZ7TR0WNB/JhyOlVqwio4YJVQMruB79SbUdfuyBlgpq/E32idLZlBZBbLXQzedpj/H3MBcEG9GyN2jmbH2b1sei+eLhmyaMsBAo9+bTS8RnZD98iML1pXEwKpZA0gxK77c5F99QEQmRvqAcLA8qDpVL9naOX8fZ8polWAsNcJ1HcZxossLdU1PwpxF8/kNSuez0nv6+RhIA04rtWGZf8XmQSB0w7HdsNYfPPQNBYLBLUiIm0w99WYZti8PsxjC35ZTpaEXASJSQ6tjm9HHRHioWjcfXC6ar2vFlobiI3XfF6m1d8RybEOBuZYwsIbX3RcJzlRKqVvTdj9ODOf6RqfrdqqxFTZS5YBMfFJRtgJMYEkSAWP+6OSNixJ+17GreVtaRueLw3vgGe6ot7LMaHEL3nz9ugXm7SNJ6d5TqBwBTHYODFnwMPW5YeuVfFRrB60CHjf6ARcjkrU45OM5UkX87M2rmxGebnMCfm5h53pi5sanqZa1xli0kLIvw6UZeUpdm6uyYo5eCB6UT657Bx4e9b5JDdo9rEFdlT1H5Ic9Wl82PI7QoVGerVWuUxIDnsSAxJvuIE+Dsb/e9YtGtKMuTQLtJywQo0pNL/lWQOsIsluNqlyEW2j8rhpuD7mXy2yI6panvd01bMjwJNsPGb97kN7qzVimnCKv/qUhgO1dwcP7W1Ukck9i9T9wlKFzC/YQXioqZgwXq3OQ3uroHzfHIKdXay8Pg= 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)(39860400002)(346002)(396003)(451199015)(40470700004)(46966006)(36840700001)(8936002)(426003)(47076005)(86362001)(6666004)(41300700001)(336012)(1076003)(83380400001)(4326008)(8676002)(5660300002)(82310400005)(70206006)(70586007)(36860700001)(2616005)(44832011)(7696005)(356005)(110136005)(82740400003)(81166007)(36756003)(478600001)(40480700001)(40460700003)(16526019)(186003)(26005)(2906002)(54906003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:18.1589 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a432a3f-0251-4447-7e33-08dae6960239 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: CO1NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8497 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?1753204631478386115?= X-GMAIL-MSGID: =?utf-8?q?1753204631478386115?= 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. Signed-off-by: Perry Yuan Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- 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 c17bd845f5fc..65c16edbbb20 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) { @@ -626,10 +637,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; } @@ -671,16 +682,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 Sun Dec 25 16:34:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576156wrt; Sun, 25 Dec 2022 08:36:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXsh3QXC/9f9aphy/npnrhDb5rZwRsFbnIQbgwVIu+6j5vpjWkwGdFc+yMvCztFLkjr8zJfH X-Received: by 2002:a17:903:2595:b0:192:50bb:7fd4 with SMTP id jb21-20020a170903259500b0019250bb7fd4mr16092760plb.68.1671986198249; Sun, 25 Dec 2022 08:36:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986198; cv=pass; d=google.com; s=arc-20160816; b=Try5zeTRzxSibEnl26PKPWclpU6XC7u77C/+zhk7ej2jOl/2OZmV9CcpdTPb1s140B Qml+CqnZXX9yVjSF8nvdpQjy4/Rc55pkIGniaBXhbShXvlr+jvsT/kiy254f5Ya9VEKB 5sqq6939xW+2Oe8O80hRVIaNaZyn/+ghYK6WqqdH+PanVzX5jghqTuRh7aaEOUn83tOZ NNd8iTjxh89npFYlXj8r5uJLLCp+veNKgzfjkt9ZMbPgwKwNytqugM8w+UgAWSYHsQFY hmV6IIL+vvxx6lJZVDorgkmIWs7q4Uo7g7rylJ693cT+ifiJ5xGNkH3oII+lYYDhNN8s Q/eQ== 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=KS37ra18bd4ZXi7TA3REOMVnZrEvn8cv5HLA90OmfYE=; b=zWm5fkbnO4PCgEfiY6u9PbRhHvOTqj/kZlTQKljA4Q6hiBl1Ecg2/XGrDBjwN8KvMg /KmuaaHgLmkeDnKmbbttJb44HDCre2BXFm8iog3xn1/5+UeqlUb/hP2/Pl+6799b8qcL VESiyiGkK9r0Zc4ecejEaVwRglE++iFSg6f1WNx4LtqLygXlevWC2twzJGURSQqeTKc4 9U02mK3Yj/3Hv9n5lXFxkpE6F9ULLbPng+41NuJJ3VylE26ClbOX9ysbbxJ4+07KMspx VMmKGgulXSdt+LwphVF2w1jmyKIk/dbEIbZ7C5Kxnff7O6gYtHiUrjvYLV70jxe5/0sj QB0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lCzKqUhm; 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 j4-20020a170903028400b0019267bf859dsi4777323plr.294.2022.12.25.08.36.26; Sun, 25 Dec 2022 08:36:38 -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=lCzKqUhm; 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 S231501AbiLYQgB (ORCPT + 99 others); Sun, 25 Dec 2022 11:36:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231414AbiLYQff (ORCPT ); Sun, 25 Dec 2022 11:35:35 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2086.outbound.protection.outlook.com [40.107.212.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CABC62E7; Sun, 25 Dec 2022 08:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=irXyJ9knLPED2t5wfglypxSZ97nWpeOMegmnTSOnVNW4uFQbdSiJFD6gAOzlgRnyoZ6M3S6upuTWZuacKVsjVMwDUApeyi78R3GhI0c3jt63LVbODMqfQpqGA6eQ8YCr1sH94CU86NRGxdLAqmdS4yU/v9kPkFluLBDlstdpBZDjZi5mgcdHrjq8cNEwG9Hs0ehTjQGuXe24/pvzicF1kk5C7dLZjZ880/Ic6oSBSkBE8Desx3If+R41BL2urN+fe8/cvB3BEaMulrr77hNSPmVGkPr6phVdjA6Wc0h8QRrUNYbRfpG6nGRMjU/oBWxp9TgByXZCpZrmL5yuO3TXxQ== 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=KS37ra18bd4ZXi7TA3REOMVnZrEvn8cv5HLA90OmfYE=; b=jN6UXihnmTOaI/42yCmjLp0uRMvahRfQBzYBrEYC2RB/1zop86hATR6t0s3xhaj/N+3RtdynLf1ktsTQRkhy5HAYRS+I/0hSi3BgI3vZ6zv3wFh3jNhVHle6onj6uTvxqTwTqZLYrTZIbrxmnIsOsB5sFBWGtOhX8vi+xQ9J4lvfyZuvlBb0Jz4gYvAiR6vrfdSgzvX4zHjfmnGQHDp1To0GMlhjcPLwU5fJ3ljFRnuWVuAXiWffQJ561x7LCJ09fDjRnDQ38poRt6/2vJs4CIocw55hFjhI9lYI97TD6SCa6zGEiJWB3wH3sR+2XxoEY0OR3eL9y0QW+x1e+okx6g== 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=KS37ra18bd4ZXi7TA3REOMVnZrEvn8cv5HLA90OmfYE=; b=lCzKqUhm2x14CPwb8BZ0FeDrNuutSp8JCVMaL0gAzfFlUpgtZt23dthjroRYJ0nrTMiGIgt3GPso8/PN9ANYkcHAZgTCfqz+GaaUA1nHCWADSlo4MJHfM6ElukUQhQUS8jWQYiqWLQo2mcIQjlFGD29RjMls3ZoKQ6sUt/au0sM= Received: from MW4PR03CA0252.namprd03.prod.outlook.com (2603:10b6:303:b4::17) by MW4PR12MB6802.namprd12.prod.outlook.com (2603:10b6:303:20f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Sun, 25 Dec 2022 16:35:21 +0000 Received: from CO1NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::80) by MW4PR03CA0252.outlook.office365.com (2603:10b6:303:b4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.21 via Frontend Transport; Sun, 25 Dec 2022 16:35: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 CO1NAM11FT093.mail.protection.outlook.com (10.13.175.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:21 +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; Sun, 25 Dec 2022 10:35:16 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 06/13] cpufreq: amd-pstate: implement Pstate EPP support for the AMD processors Date: Mon, 26 Dec 2022 00:34:35 +0800 Message-ID: <20221225163442.2205660-7-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT093:EE_|MW4PR12MB6802:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b18f85a-2822-4d12-d6e3-08dae6960400 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A9vj+CC6xVEr8FAx4SIWy+OwmsrWxrItl3+jpAgf1AjbhJ0e3qvOTYhni6Shx2ORhbTweuGmrke+aysiXTT2fg/o+nvnRRDB2aqP2Xjw9oITfgrb8XAsJN4rVC9gora9AwM557avmNdGf7TUO7WIiEX0P8O57Z/vgpVKnaJZtz4gN38LfYNYpchqOu/hkEo/NZtud5GuG6XRzFbas5gj9V/8AeDgSCx/MHlvenmvki9mql49qm7WqFyxnKEgRgK34XqxGwXhQXvlFgaDBX884M/Dj4k0/gqSVaA2pM7iwYvQYUS5OjrHjK9leolJ0LSSszuSCWMNxLAuEajpZPhmXjN38rysJROM2CxVwkPKvU9NPKzrcUYqeJDnowKhUN7+pmDuWtsRxj5S1yG8DXRkDZW6czFGiag9k+Car9Mst92dUssfiyCowULc891w/ZgNndzqQCsvEbrxQXlDyWI60qxZj8sapNEJFvSZi2PObnvBCTXF/za321adSoLbRvs5xuAJqm2qQrhhbpS5TJQdPUaeAJdPHefMw6zR54J5u1PAbkKIUUatDXu9jfNJgni72XH0BVsYCrj80ODbYVFOgHURXDLsJX/U/z2RlnN58nk/aQntmHu0qMfWv52QMIJgWYdvUWOWhp4ZAUKZS/IaXq84S311eYEW2k5u31pQAmqOc7MYG6/cOzArIe//5+2BNzyBiQC/fgd43LCiwflp7ln14PlCv+266+vZIXNHRC8= 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)(36840700001)(46966006)(40470700004)(81166007)(7696005)(16526019)(6666004)(356005)(26005)(186003)(478600001)(110136005)(54906003)(36860700001)(86362001)(8676002)(316002)(4326008)(2616005)(36756003)(70206006)(82740400003)(1076003)(70586007)(8936002)(336012)(5660300002)(83380400001)(40460700003)(41300700001)(30864003)(47076005)(2906002)(82310400005)(426003)(40480700001)(44832011)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:21.1430 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b18f85a-2822-4d12-d6e3-08dae6960400 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: CO1NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6802 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?1753204599725572110?= X-GMAIL-MSGID: =?utf-8?q?1753204599725572110?= 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 Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 374 ++++++++++++++++++++++++++++++++++- include/linux/amd-pstate.h | 10 + 2 files changed, 378 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 65c16edbbb20..779bbb58d909 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 *default_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 HWP_EPP_PERFORMANCE: + index = EPP_INDEX_PERFORMANCE; + break; + case HWP_EPP_BALANCE_PERFORMANCE: + index = EPP_INDEX_BALANCE_PERFORMANCE; + break; + case HWP_EPP_BALANCE_POWERSAVE: + index = EPP_INDEX_BALANCE_POWERSAVE; + break; + case HWP_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; @@ -429,7 +549,7 @@ static void amd_pstate_boost_init(struct amd_cpudata *cpudata) return; cpudata->boost_supported = true; - amd_pstate_driver.boost_enabled = true; + default_pstate_driver->boost_enabled = true; } static void amd_perf_ctl_reset(unsigned int cpu) @@ -603,10 +723,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, @@ -615,6 +786,181 @@ 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; + + 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, value); + + 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, @@ -628,6 +974,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; @@ -656,7 +1012,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) + default_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); @@ -667,14 +1024,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(default_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; } @@ -696,6 +1052,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) + default_pstate_driver = &amd_pstate_epp_driver; + + if (cppc_state == AMD_PSTATE_PASSIVE) + default_pstate_driver = &amd_pstate_driver; + return 0; } diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index dae2ce0f6735..8341a2a2948a 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; }; /* From patchwork Sun Dec 25 16:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576192wrt; Sun, 25 Dec 2022 08:36:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXs2SUz74kfAJnkaE1NALm1RzxBfW3WNic70IQ6+6g2t6rt/cz9eLFBXFxIym/fnoVbbscxU X-Received: by 2002:a17:903:200b:b0:189:6453:f455 with SMTP id s11-20020a170903200b00b001896453f455mr15301015pla.35.1671986205593; Sun, 25 Dec 2022 08:36:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986205; cv=pass; d=google.com; s=arc-20160816; b=ubiD0Bibj+j2DHza2wCUH1WDXUFRyoThu+PBPWbVRr1UaLW+9ft5KVf58ebvqy5mjW Wm3QMeDksbXbUdtribf6nmf+ktQ8OzaerZKSJZwuA1GYbPNM4cQ0FxM+Ecza3jKXEp+q jNrMR9FMP0gfTZHyG9CFclgMOJknuz7Nd0wgj4etFCR5NryhdTZtJB11rFBnbn4MNZkm lD1AHjst7e+BUl2esu6B5F7Cusig9ZHaa1vYiN3rBl1CO+U4NBFi/R4xqKqXmCSFHkMC fu6NFot9XG+3NzaejMv39uhObkLq6CQs8tq6fXkckNYIYeJwGTxJYu5M9PCFw6Zunv3e Mt2g== 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=pYiy1DvPRJYOUYYwhGxx00tzglSyMPuVl54CiYJwYlI=; b=THAw7Favs8G8euthKOOMpA8tB/CNESAg8TNNOs2fE3WTHCLpLZkAHoxLeOksYr56cv fXeYHD2SwitMQSm3k/CPjDyd9VxdVNkBY3562ubGl13c5S1FMXgStj3v2XuhslO4OJMO TMNoaC5KkPhkpXjXDRfJ5Ov6I0b1zicbYqd2kk4tkWkWNqmokSVUOsFjYHkZ8x1cUjBj cXR/qnp85lG29d7G+yPJodlXHOEzReZTT1xEGA04zoEHLh3bwsXpqZzqoHV6dL0T5N2s AIk5vBFpAApBdlCInfCOGcCrOGPfso6ApZdYgErY8oEsjsl6fZD8ZGkqAxWIZJLkGQKO pjiQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AsZ0dsgU; 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 y13-20020a17090322cd00b00189c3ee2b55si10058631plg.138.2022.12.25.08.36.34; Sun, 25 Dec 2022 08:36:45 -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=AsZ0dsgU; 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 S231532AbiLYQgG (ORCPT + 99 others); Sun, 25 Dec 2022 11:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbiLYQfo (ORCPT ); Sun, 25 Dec 2022 11:35:44 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF7662F8; Sun, 25 Dec 2022 08:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RMAY+ICMyXmMLM7IRfa5C5EyEFfZqXYLFJLfAlPWxFwP2AiwKW308ZLlWhluZiiAwYKQez5H+rm3XIaTO3VPhFm6vy5XF8SgjGifrwkH7aNKVmYM4PMf5DvKz2uotCGhTlPOTaeiaQMUWEprsgapfxeu0dMw8SuTerWv5n9B5xT2AgtKdPHK8xRgTGabRPqUHN17mta/Ufu3rha9gBjckRuzyQWj1pOtAbnvqvo9bG97cNR4NCuZMlURofOE/UveEFrmooOxKsLGkr6krJtqpkCTnZ2Q2FRNQT59ZQIQSoe+7m/Mc6ezcRXIsDG8HDNalVXADxBCWySvy20wyVntDg== 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=pYiy1DvPRJYOUYYwhGxx00tzglSyMPuVl54CiYJwYlI=; b=KtonHRM7zBdSXLPGje4aD4pD0Yu3qm6ZgGFKx66daAVDRqpDPs3rg6guaxOkHrg1YqRw5cCDIiJnwl/ljT4AxpOitKGhZn8rlO2yQw6p2UFIOa8B2fKuXbjjxtYcDRipGAF7VIcr6EoOm/HMqTRQlHbmkQGftOReZwgwrsJKIC6c/C9XsxrEfXxzYZShjf/UArX9r19aZ5DoUoDqdczxmxVlcY3pQ4vG7t/GZ7WEiPqOHyklKA1O5NqP+i4PM8pifEiqEoa9yETLdDDIOWYT8LTAjiLHTwTk+0s8n4psvtyyzTzfUwegrOEItyv4NTkx7a/ugiWNI4nKC1K6U/tebQ== 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=pYiy1DvPRJYOUYYwhGxx00tzglSyMPuVl54CiYJwYlI=; b=AsZ0dsgUAjZeAIqbKf0S9bjmy45VCdq4oHHSEK6hCCXaN9L87i7ecKxjoW+/1chpg5TLQPLY1e3KRZwElbRuVFcUdII8GCyYQA+p8veDJyKszXrK7uUIaM4+WHI3xV89lqkUqRcVV2ozw6FcPrVN/x+jkXhoCXtYWxabjLRxQnM= Received: from MW4PR04CA0078.namprd04.prod.outlook.com (2603:10b6:303:6b::23) by BN9PR12MB5082.namprd12.prod.outlook.com (2603:10b6:408:133::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Sun, 25 Dec 2022 16:35:25 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::b9) by MW4PR04CA0078.outlook.office365.com (2603:10b6:303:6b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:24 +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; Sun, 25 Dec 2022 10:35:20 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 07/13] cpufreq: amd-pstate: implement amd pstate cpu online and offline callback Date: Mon, 26 Dec 2022 00:34:36 +0800 Message-ID: <20221225163442.2205660-8-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT024:EE_|BN9PR12MB5082:EE_ X-MS-Office365-Filtering-Correlation-Id: 62716a4c-a315-42cf-0868-08dae696061b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Wn76+I+wm1U++Byy6WAYIMjzsevBMTe0t/HLXQPxZPV/9RU32QkUE2zLfLwkKsnmlvRFr4zZplb364c2Nx2ffAm5VKXxnA9Sf80bMchYMp3mGjThMassglEXssjRFYR6X5aC7bb8wVvFTSUMdm2XvzSIkQCXH6r8vrh1f3TnZ6AbxG5TMk33shXz69Qw4sA+bG3PWzIytTF3/rKBIGBdk0/0n+UY6MoNLuHlYMRWu+JkKcGu99aSTBqyDV3sB3sBRlVJP2iv340W63coOpsMvPMQIliGJGgodYaKAySl9Zvd+qxxtfItieGKsO+m4wqLh7BhvOJtw5Rbg4CGoQBCn6KHlof+OYRIm3shEDRD7UaP6J2aqeFmkKf2UqS302XyorEJugwZpYO8XI4XoP9ALP6xz4OkP1lbNsW88L/80fxtlD/d5r5UXhDZsfFbFr+fyUrBRSzSsE7WYOJDeef4JspYLHCqeR20JcPyo25yH9oKD8U7Th4eUvgxCq2KCeJF6cSRwrH6EsHSFWlDzsjFqcJ6ZrYuX5GVYZwDa9jaTVZrWBLdRoqhrtFvWxEt5IP5ZT6QYry0W+P0o/+pdDNJenZ0B3fBvdBW2T8+NJXqURZIW2PLgbA1Sf3WMzV4O1YoyIHx8hVwLdKlEASTw7PyoQxLgGz3yMwf6ueV2ovVzmBx6wn4f9NTSCrU/y4al1hDy50bkepiafC0Rcv9efhpfHirVPDuOeshTU3+joIc/0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(346002)(376002)(136003)(451199015)(46966006)(40470700004)(36840700001)(16526019)(26005)(186003)(5660300002)(44832011)(41300700001)(8936002)(70206006)(70586007)(4326008)(8676002)(356005)(36756003)(54906003)(110136005)(2906002)(40460700003)(478600001)(316002)(6666004)(86362001)(40480700001)(7696005)(336012)(2616005)(47076005)(426003)(1076003)(81166007)(83380400001)(82740400003)(36860700001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:24.6858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62716a4c-a315-42cf-0868-08dae696061b 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: CO1NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5082 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?1753204607390012404?= X-GMAIL-MSGID: =?utf-8?q?1753204607390012404?= 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 Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- 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 779bbb58d909..c671f4955766 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -954,6 +954,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); @@ -980,6 +1060,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 8341a2a2948a..15761a581e82 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 Sun Dec 25 16:34:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576262wrt; Sun, 25 Dec 2022 08:37:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv3eLI9wz6AqUAHsLBILtjuypCLiDM7Cq3NJEh0FiFBqejv9jtYqk2f1lH14hXN+P/CZRBC X-Received: by 2002:a17:902:dac2:b0:188:bf3b:4c28 with SMTP id q2-20020a170902dac200b00188bf3b4c28mr24834747plx.18.1671986221281; Sun, 25 Dec 2022 08:37:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986221; cv=pass; d=google.com; s=arc-20160816; b=Zox/Wm8ivFwk1X+zuHmgjtpxy3MkmyuL4kPWlmZh0FgnOZN0pmUOPtRna8/koyi3lk h4sfWUfn+8CE+s/vJSsYIiG3RPIZ4gECc34W3mi3Weyzvzx3vL93WnyFuwLkSHCnsBTY KyrH4OKdgYLT6oEIPQHK7AxtN15xlCi+FTp/XqN7H1sLkhAuiPfA2D77mOHCubEaqK66 bFm9LfWLFcNjRXn+XV5fcNJZsdJDIQ02de1VP2FqZZbRlN2JBf8aB5MImZIa9xi5O2vW y62r3IK6KRVqPXa/0BmwEk2fgCx5HSG/oxhahCiwZsNcchDwLp7vbR8sQ27yELWHHoyY CaQw== 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=7qAcVvH5GJQbf3CFCt2m9xJOjLkwgQgEmaK7w5hwaSU=; b=UUnAWlUpNc2ql+xgn8lMpQ5zXl/NlfFz+Eh/ARHuBpjoOayZUnzf1madjxJ25NFaSv WYs030lQ8kouqxzCOSg/KovWrF+IHkQiX9DeCwSJ8bkXPxKFd6/ZfGnXTmoSew0jMPrv FVQfpci8WtJcB7d/81xIEapXlIY3f+PO0ecLUuH9C2rL6FRXi5N8srZGGYqypnqMKkc1 SUwA0T4WT+DzRLnDvYSJHLM5Wk+X+lz4vl/fTsD6qtAKX01UiCrEkNniTBwz7NYJTH/1 HnROv2YaD4h+YcDzQQgmwQc0jlUTD2FZAYjCQtcARqIe5K0h1JResMlycX6bAzOeVklm X8LQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TVjdvwpo; 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 i1-20020a170902c94100b0019259b157cdsi8892015pla.314.2022.12.25.08.36.49; Sun, 25 Dec 2022 08:37:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TVjdvwpo; 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 S231407AbiLYQg3 (ORCPT + 99 others); Sun, 25 Dec 2022 11:36:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbiLYQf6 (ORCPT ); Sun, 25 Dec 2022 11:35:58 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2056.outbound.protection.outlook.com [40.107.93.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FE1D60EC; Sun, 25 Dec 2022 08:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezR3e2vHV+c0rFX/34lGh661DrgKFXd0MFQ0+4S3nVXIVH5qv2V41YNps4gG4U7OxC9AF/+X411QNzfOwf5X9JJhuEhKUiiGpk8o/l9FiWQ9MgEpaV8X4Z+h0rER549QcUZKt22eCHEJqD4TRZP738PXhnvQjdUvdwZzlqggbB9opH16eXLu9gmO/podvG+Ppri2CJyxZu+0FCM+E5QGh5RBElNReJGlA4lboC9G9PHuovSFcqr0852vBJVFDvRBRb63Z3SfjNNfIIzgpdZ8ndr/u/AhCYAqd2jnb41EeyVJDLIz6gI/kxFVBTuqxRxQgj3FvzZBGEgyyTPJ5Xur0Q== 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=7qAcVvH5GJQbf3CFCt2m9xJOjLkwgQgEmaK7w5hwaSU=; b=WI972L7RNcpSyQTbll7eWLqhq8IbyXC1CrmEu28DCE+WKMMGvbj328de0+EgRBuGUjpkgkv+9k6ltCub4seYxsirvE95bl6bmJhkZR5Wy1GJs4P8Nh4siiiuFVEuiRksT9B7gouuNu12cglJ8kjaVy/5BOuKjHykSnjMQ27Yh2LLSpkrpb6Hq/y3RHRJ0LWDpBGh5FxTj6t2424s6ISZ7Pn38a51VLTrBP50/utpH/LXEwzxrYRZ5Ia2/XKZRbRAHR4tbTomuiOv/b58BKroLejFuJzxpqBNFzayTEBYVjmS0GpTRceuOc1kKnwhEa1NsTA6BCvx+ggd4kdTxCt0qQ== 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=7qAcVvH5GJQbf3CFCt2m9xJOjLkwgQgEmaK7w5hwaSU=; b=TVjdvwpogSYzwjUiiInUd8WFNif5ePFM2VsZkdELL88nElBAz5lMlnQOadM81ekmm00WzhpFHVuwsheYm1wl86FkEyrRDHDFeUcZSODU10WNKYj1rHv/G/j3HACQ0ZiB/kXD45rLxjsKRGVcFiUVwOL6njJb2YqzcW2+6ezImY8= Received: from MW4PR04CA0062.namprd04.prod.outlook.com (2603:10b6:303:6b::7) by BY5PR12MB4885.namprd12.prod.outlook.com (2603:10b6:a03:1de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.14; Sun, 25 Dec 2022 16:35:27 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::d6) by MW4PR04CA0062.outlook.office365.com (2603:10b6:303:6b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:27 +0000 Received: from pyuan-Cloudripper.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 25 Dec 2022 10:35:23 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 08/13] cpufreq: amd-pstate: implement suspend and resume callbacks Date: Mon, 26 Dec 2022 00:34:37 +0800 Message-ID: <20221225163442.2205660-9-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT024:EE_|BY5PR12MB4885:EE_ X-MS-Office365-Filtering-Correlation-Id: bd86ff92-e60b-4c9f-b2ad-08dae69607b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wazv4fLCvdA3q1ud+SY4z8n2AAw2aqwQ9VCB8J1CesMMhXYJd4tkMwMIrbtptojDtyr7CY5J2k8gFMUcU8qlPMZK4OVP8Ztvjf2vMPSyS7pk7m+F29w2Khiqe+AekYYoLdzk4HJxmlXvfkqGguVJynBr0r8RUOdT+fvLgiS02UsGdB3dcatuUsPGX+qg23hEx4Q93XvTIrUTGJUzzaxJ4D0VZCflVMYou/SJBiEYSLFx7TP44Eh7AC9Us2g5DwzQFdDebMgXj0e2rHvaZau9an393w/YV7W4bemI5ehmZSRByUIXLFLCsPWDpklRgkortxyw+1BJWrWNihUBh673syirDWD/+GLX2e/OFFjrSSELXRxHwglG2lwuK3RL6EPQDiX1EZZGFoQ9LSZtnqFJdm+yEfBDtqLXnR6YFDZwmOn34Ca6874EZDxzK4+Vyi7/wlTddjhXhbGvJJv9QiggYGDaqtO5OchG5jCqAt4Kzpg+jX5q2/7pWiK3cSexfwXvMBB1kmrGoVzRtJ3kx1HtEXClYkx34XnumVj77Goado7dJ7Icfy3ylrwIKvGFOcKND7xwypAmzzBV8IsvtcH2O9a7HXvDVT+8A5Q+xgGQSdwnZNCcMmAXiJ/YZ5BnOo6KMc+tNfmnV7AxM/Io/lls4Z/CSF53mXCF5CpfFz0jtMbtDVMtj3wbi43C799WPiikIYHIoS5bGoz6ZRAwFfKHFD4tq6Jg0dkXobmzr4146oI= 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)(346002)(39850400004)(396003)(376002)(451199015)(36840700001)(46966006)(40470700004)(83380400001)(2906002)(54906003)(40460700003)(110136005)(15650500001)(316002)(44832011)(6666004)(36756003)(2616005)(1076003)(26005)(478600001)(186003)(82740400003)(16526019)(356005)(7696005)(81166007)(47076005)(426003)(36860700001)(336012)(82310400005)(86362001)(40480700001)(4326008)(8676002)(8936002)(41300700001)(5660300002)(70586007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:27.3574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd86ff92-e60b-4c9f-b2ad-08dae69607b2 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: CO1NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4885 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?1753204623864751979?= X-GMAIL-MSGID: =?utf-8?q?1753204623864751979?= 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 Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index c671f4955766..e3676d1a85c7 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1041,6 +1041,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, @@ -1062,6 +1100,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 Sun Dec 25 16:34:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576241wrt; Sun, 25 Dec 2022 08:36:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxBKi8HMysNyAVHrEN+2oy9g0a5cvRtPyJ1mKU0ryF8CGKG37QCrzez8ODpEZlQP//gbKG X-Received: by 2002:a17:902:e3d5:b0:192:6a20:3cb1 with SMTP id r21-20020a170902e3d500b001926a203cb1mr4722062ple.51.1671986216612; Sun, 25 Dec 2022 08:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986216; cv=pass; d=google.com; s=arc-20160816; b=rSCzQERX4K3JCfyGw9V7Pqo/ZDHCs+qnLPXIUl9FTjP5qmWL/I3UZt1kjEA60cXuFx uM0gEYByBY6IucIMeDVihplCUypnkwRtKoPIf7LmCUm7rBA8DZQpN1gS3y1+Xtdm9B1p YBDF3GeNw6/Egz/iyD8QUWKOjpXgSxPCRS3AlybwBMGeLC6zkyS2L9D6qb9ivD1/Ykcx DCdEaUJbIy2+Z5anXldsUDiNasKuCCJXVn/q8YBKL5H4nQ649jF9RvAFZu7aNsQoXsvT y0sYxPmaZqum6XOQGhxRLqYBq4/QF/iRW5FbiE292RYu05toy5vjjKgi8v0oqtpMRITG cEQQ== 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=DXc71Af5VP24THl2DnWkU0svquWahTh/H1XNW2L8BS8=; b=dTrlNdvaMBWYuYrI2dOrB59dfm/qZEcycKXXufMlct77uONFdN0fgByYlv7p9Nm39G xW88D6VFFj/KJC0zPmBDagkhzkULUcHAN37RCw7c90VEfIJ34ZSbuMBsFZ4Jhoo8H2ap DqhcRTjf9qdqR/oc+7/hgA2W4U30/vUi8y7vWNIpi4+tusaJZErpgu3ALTz4d5VsyGRG bHZc9qbrGFBYoWSbVHtf4aEabff5UwwzOfEtEAKlw4g+rhLP4a7KFiAKNj8sLoUI08d5 396vbrpPyFQWmb/Znqq8Z07RNawbT4iWypcH408B6E5dQRzgQtIAVCtxHwsjxVjtt+yY OSkw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=qv+c8L7b; 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 ba4-20020a170902720400b001884e351466si8202161plb.467.2022.12.25.08.36.44; Sun, 25 Dec 2022 08:36: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=qv+c8L7b; 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 S231406AbiLYQgZ (ORCPT + 99 others); Sun, 25 Dec 2022 11:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbiLYQf5 (ORCPT ); Sun, 25 Dec 2022 11:35:57 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91683614C; Sun, 25 Dec 2022 08:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dEJBWA9j5FKwYw0vofFU6MrrDOx8s/HnlIFzmBUJdhjcAht5timyBtQrgltD5mD5QlUkmtIVks+/Nf2GKFAb5fIKQB4gVtJqWXHJNj0PDy7qLzcA1m/gkDg+g7hRu4qVy8kZDFsHT1cHcFEiI0KuFxrY155M8GGAk0JMbUlKLhdJSQBYjD1b4ehFZfpWWru0rXjcBR0nLsfQ6BAPnhytb21AqFhkuWmXQz1mes5DodvPWUplIJiSfED0hzyTQ9sUIzFFxCStaqrEf5HTna5nHKBihwnJHKKw2vrg+2VUQ2Hv2182e3O6ZydfUjEVPGVGhxUZ4vUnar9vZBd3KMZjHA== 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=DXc71Af5VP24THl2DnWkU0svquWahTh/H1XNW2L8BS8=; b=MAxzOEBWofMgECRVV9b21QiJtdw8A/yf1yiCvHcWBqNZoaNqtKlbcV8f3ciYuiagTjlUhxz7Jxv5K6RmM4q8nlUMYvOoug8M0DWsascCiuXrj+L0PhcO/8kR+WRk5/YsmjV0uzm/nnCM/nEFV1hGfgT4UmduRTz2rHx24AMpRxcgTIMeIhcndEbXTNGi7MKKczYdDhIBzAopqGm9OFive99VbRIO4AMJLK1cRtDheSH8wTNLoIi5O/cceIjIxs3JZ5Tofj2DvxA35T7nKPrEFiw12MYnLqmH8C/BuA+qoptaAEh19/BMuhdf9c2jQOoJTHOV/iM0lBAgwMY1vOGlrg== 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=DXc71Af5VP24THl2DnWkU0svquWahTh/H1XNW2L8BS8=; b=qv+c8L7bIZO0q1gkRsxeG6ZAEdHD9h+i6svtQWRgdNslV4M8UQAbaUx/EHQuyWY403MyvRkNAWdp9Te+gJh6M/aYf+rDP3exmyX/CQOSlciY1mC4CpIMwr76rV1joBDhycHd1uWTnoxpAiVdzQOcSeGA+KxlSD771drcs2wc2AI= Received: from MW4PR04CA0134.namprd04.prod.outlook.com (2603:10b6:303:84::19) by LV2PR12MB5942.namprd12.prod.outlook.com (2603:10b6:408:171::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Sun, 25 Dec 2022 16:35:31 +0000 Received: from CO1NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::e3) by MW4PR04CA0134.outlook.office365.com (2603:10b6:303:84::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT023.mail.protection.outlook.com (10.13.175.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:31 +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; Sun, 25 Dec 2022 10:35:27 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 09/13] cpufreq: amd-pstate: add driver working mode switch support Date: Mon, 26 Dec 2022 00:34:38 +0800 Message-ID: <20221225163442.2205660-10-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT023:EE_|LV2PR12MB5942:EE_ X-MS-Office365-Filtering-Correlation-Id: a9ce22dc-1f17-4cf3-e817-08dae69609fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: svueFrAm1y1v+q5J0TNut+fR3YC9S+wu/z/1Qn2Mdmkfs0Rr5iU/kzB3LaN4Y3X+o/+0K4BI56+65uUJcwnPOp+yA3yTsAUYBr3yqiCUDi3jJ/hnS+GENlPGBkco9jYpyD3VqJG1iJCpLYf1FyMUvTSS+TIt5WsTJUtiUTUVyPPXzJURDENtSYfKOcareAk79ABapoxF6AdeWfEhy1a7etI+fGNkkMIwn1NW6JIT/aksHjZ30Xml3gg6XAC8IzOI6VCkmmG8anOTnmMq7hwUTuD+mtQ6isrhNcpAxbyqThZpk1mMIsQLb5tD8xSqBCL7k6ulW7uFCS6A6Yw2TwXbnzaSXPmUtfSjafT00wO+uvckShjdQb7QDC1jmeUAinV/EI3LZA2u0V79cvJSaXA46Pt2nOZ1XMR0RX8QT+VgInUZ6alx97oIN8gbVOGdPBZma0aIcI5A5VlulfX04/fy4b3LICcpWokCl7GCZ/+tuWUSHHNC64w4uYb+pz4l/HqPn5rTT6AFi7Lx7rGeA7FJ2w/F7m2pDi33ruoligZg2nhio/3osUNTa1JMGxUph3nBe3AyAAvjZZRM8ihkHjHyfNRL4z3RfWOMQXYBhe0EvF+ZopWkx9cGajspcp9osXX8mJUC4C6aTGD6OeRXUceI6YJd8VKP8Exl59g/wwTforcNcIq+4jMHbK78tz0iOUroPq/VsaUCWeyLSDrtu2qAjm71ta9X4yYdaZdqjxrrcmA= 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)(316002)(54906003)(110136005)(2906002)(82740400003)(426003)(16526019)(82310400005)(41300700001)(40460700003)(83380400001)(5660300002)(44832011)(47076005)(336012)(40480700001)(8936002)(36756003)(2616005)(186003)(70206006)(4326008)(1076003)(70586007)(8676002)(81166007)(7696005)(478600001)(356005)(6666004)(36860700001)(86362001)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:31.1614 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9ce22dc-1f17-4cf3-e817-08dae69609fb 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: CO1NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5942 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?1753204619028427904?= X-GMAIL-MSGID: =?utf-8?q?1753204619028427904?= 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" Signed-off-by: Perry Yuan Reviewed-by: Mario Limonciello --- 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 e3676d1a85c7..8ceca4524fc1 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -63,6 +63,7 @@ static struct cpufreq_driver *default_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) { @@ -632,6 +633,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; amd_pstate_boost_init(cpudata); + if (!default_pstate_driver->adjust_perf) + default_pstate_driver->adjust_perf = amd_pstate_adjust_perf; return 0; @@ -772,12 +775,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 (!default_pstate_driver) + return sysfs_emit(buf, "off\n"); + + return sysfs_emit(buf, "%s\n", amd_pstate_mode_string[cppc_state]); +} + +static void amd_pstate_driver_cleanup(void) +{ + default_pstate_driver = NULL; +} + +static int amd_pstate_update_status(const char *buf, size_t size) +{ + int ret; + int mode_idx; + + if (size > 7 || size < 3) + return -EINVAL; + mode_idx = get_mode_idx_from_str(buf, size); + + switch(mode_idx) { + case AMD_PSTATE_DISABLE: + if (!default_pstate_driver) + return -EINVAL; + if (cppc_state == AMD_PSTATE_ACTIVE) + return -EBUSY; + ret = cpufreq_unregister_driver(default_pstate_driver); + amd_pstate_driver_cleanup(); + break; + case AMD_PSTATE_PASSIVE: + if (default_pstate_driver) { + if (default_pstate_driver == &amd_pstate_driver) + return 0; + cpufreq_unregister_driver(default_pstate_driver); + cppc_state = AMD_PSTATE_PASSIVE; + default_pstate_driver = &amd_pstate_driver; + } + + ret = cpufreq_register_driver(default_pstate_driver); + break; + case AMD_PSTATE_ACTIVE: + if (default_pstate_driver) { + if (default_pstate_driver == &amd_pstate_epp_driver) + return 0; + cpufreq_unregister_driver(default_pstate_driver); + default_pstate_driver = &amd_pstate_epp_driver; + cppc_state = AMD_PSTATE_ACTIVE; + } + + ret = cpufreq_register_driver(default_pstate_driver); + break; + default: + break; + ret = -EINVAL; + } + + 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, @@ -795,6 +885,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; @@ -1154,6 +1253,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(default_pstate_driver); return ret; } device_initcall(amd_pstate_init); From patchwork Sun Dec 25 16:34:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576313wrt; Sun, 25 Dec 2022 08:37:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvVoKUFJ9nfOhDUuUaROtMq7FmUJjmFf/RgNTQoJ4j6LnpYcHVmMLiyD6QQdXGjOhkuNekr X-Received: by 2002:a17:90b:b04:b0:223:ab72:af8d with SMTP id bf4-20020a17090b0b0400b00223ab72af8dmr17961046pjb.40.1671986234310; Sun, 25 Dec 2022 08:37:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986234; cv=pass; d=google.com; s=arc-20160816; b=wF3awMwRg61+feG0KLK4tZzCpMdPkRTR4lAYl+e900zZNxgg+/EMsUlIHhj6mrvK9Q FaFCz9aKtc/v9sH4SXKKecI8xnlh8eZNz9k5eMZQXTuv+qKwk3lbT/lKCybgmbhgGAup IxVE0GUzevDuLeaA85LagnCDn8yJfHqfzUkXmv9OXay4A/Eow1TS4TVQsluawDqso+1Z aaNz6yx7PThCnOyyRr3N4XNCB/MVVIKPKwL96JjRBILSYkYCUf3gpqMSSkLIgvWUtvSm X2RY5zJzdbrje/Embsxfr/n37xMqdxDRb7QKwceZZyeUJhtveN45qPzGPAco2WwCKHqE xJXg== 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=iII+df8dnkVuEFvhtq5qZL88U36fP4G+zC7Ke47Rcp0=; b=lJpNSQl+1Vf98lyKjafU7g/mqH/2xwcikNzczQhNtL5YrkbubFnYA5s69j8nPSFQQr 4xbbeZTllXYuHFl5K1CQxQ3AmKIdwwLpDbqh7Yj52jfA34iq8JcdiGOMvxMZ4utLmKeA C83XekVDyP7Lbo5tfQK+6nCFk9veuGn0l/PxPpzMhC9moyM2dwVEqjXRgbgo54oN9jaz /iqre6Vuc9qAb30Emg8N1fgjZLGUqX/TPHPvx6Qg5XJsiC/Hi6I6yIszgXq8MUGNquvE gBhp9Jjws2UjD5lsT9I+hQnueknCKBWvd1rieMH/cj8+K5GUq77MudSLeAhr/yckrgtk 42MA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ICWWJlMI; 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 10-20020a17090a194a00b00219ce921f62si12560325pjh.174.2022.12.25.08.37.02; Sun, 25 Dec 2022 08:37:14 -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=ICWWJlMI; 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 S231425AbiLYQgm (ORCPT + 99 others); Sun, 25 Dec 2022 11:36:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231500AbiLYQgB (ORCPT ); Sun, 25 Dec 2022 11:36:01 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D11E76364; Sun, 25 Dec 2022 08:35:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8hyYRH9etO+CH5gWr+a5cqOcyrXpWKmPAtdHeoZ49m1+iv+2qhtTXb09XTev+HRKcuh+ZYoOwPu42WCmsK9fp+AUo1yfpHNq1LngopoO9B0IVrMwxmTFXJLTsZd/PpPoYP5QZg3I+eFCzZbxr92PojyCDvRg1d0TmFCltqne3nGq/qZ3rEmiOvTrgdX8MCf/77DVBqRF2M+XV6cpWFoTJsH+kYbtzQ/okw4y7kXi8I4IVIwaJMKkITcCphKGOfOhh/nE2mdDNP+BaG/BP6768U+k0A62ZnhX2DdzkeX1eCs2G/qbFbKObgL9ht+kMzFC2wP/BBDeuDbzZ18eb+uHw== 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=iII+df8dnkVuEFvhtq5qZL88U36fP4G+zC7Ke47Rcp0=; b=n7+IiPtzwLcEE+X2g85IQyEbWai9F9nWgyb+JiRGRMbilhd8bKSW94ZlJg9K33RVZRgZqCSRqfvwFiLk16T3a2wKySvxLnTECTS4pHlAyohPIDxonDNo90BaoLcConEJ4PvU0+bv+85kPpN2NhhznL7FvW56mXK7mtxijvQ7PQ1k/bRFsB/DDb9Smt887vY6g+c7hawiZQtMDIW1dWVTAeU2n+T2uL6URKh9NLxhaRMkB3LLIbhWFsY6KMsY/GxUBexTnCZQU7Mhkir2ZHO1xvrpUup9+MUxZFHUoH7gbwCbv1LTV/W9s5vNX7DdaZ2fV2+n0lTWQA5QFivO4RsfIA== 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=iII+df8dnkVuEFvhtq5qZL88U36fP4G+zC7Ke47Rcp0=; b=ICWWJlMIXEq5fKt413C9pl6ZeDLFDd5++4UFwWs9rRxz9EXaXRh/9epKJW8qo2tItdBBveXAuKY9J9CT0Uk9IUKWHJ9mz8SU7bQPMkTRJTX1shn6cSQB0JijwW/ds1BwtPVnwPkkTLis41Gu3Jq4dDjevMgeK/CVQ+en2wnUM64= Received: from MW4PR04CA0387.namprd04.prod.outlook.com (2603:10b6:303:81::32) by SA3PR12MB8438.namprd12.prod.outlook.com (2603:10b6:806:2f6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Sun, 25 Dec 2022 16:35:34 +0000 Received: from CO1NAM11FT071.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::4b) by MW4PR04CA0387.outlook.office365.com (2603:10b6:303:81::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:34 +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 CO1NAM11FT071.mail.protection.outlook.com (10.13.175.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:34 +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; Sun, 25 Dec 2022 10:35:30 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 10/13] Documentation: amd-pstate: add amd pstate driver mode introduction Date: Mon, 26 Dec 2022 00:34:39 +0800 Message-ID: <20221225163442.2205660-11-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT071:EE_|SA3PR12MB8438:EE_ X-MS-Office365-Filtering-Correlation-Id: 522e8515-0ef8-41e7-4a1e-08dae6960bf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0SF2DwV0ng094H/mcwzyjnDnoBmIKni7Dley1ai/zMaUbq7sbqxPKcsqBzwnWFCDmzbPxNfClwP/RXAuD8zRDkO2T/yddOdy9hFm9HyzBgJ3ZudrVj3tvz5W8o1agKQPSWag6r68+fx2wQ2uTw3sxKMwQ0m4p2yPp7ZUJzhooEVUDea6CNyxaztCHip2k0kGDtNP46qY87jm2odnPIQxgQ4MaCpREKnkX7D7rL4gjSNKUe0Zr3pJhjuG+TSt/rME8DIISmxoggNAuEwdPjIGCaszh89So2D56TNKZBNzTxsXlaOn40Tq4b682SSh5YTwUlt0u6OUbSoaXji4PdWd6BWN1QMHpGEvRLyhLUPURi3IUJqc3rZioQ6cPamtJaKwRaVVW5LMXte/C6xruQMblv9Po2uOlcZpbte6Tx6coPtz+OCpky3FUWVWKAMRrVmdTwThxmnqshkbYOQmz8/CJN+a9bdeXlBUZEVha9FteD54KLxae4BrGqknjJcA+ApUf26M2MpMQqTSi4YPEMUd3AneM2muDRoTBX2SjneTxxufxCvXObCrBr3SWlJbAMRipC5j8Nwt+FhCtS5aATk6sdjbh7i6BBv+bCdFeaucJmuKEKDpea4bbdur4xbRhRJbxuAiwzjG+SeiDbDwb8m5rqOGXNWX2syacsJg1r2XtZB5fZ0VmS3z5p4wJ4M3ZovpEO0LZT8pt1DOCvtHKs4o9fkNk1OzuaIPa+auduOFisw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(2906002)(44832011)(186003)(8936002)(70206006)(70586007)(4326008)(8676002)(41300700001)(110136005)(316002)(54906003)(26005)(478600001)(82310400005)(16526019)(356005)(7696005)(40480700001)(336012)(47076005)(426003)(2616005)(83380400001)(36756003)(1076003)(82740400003)(81166007)(5660300002)(40460700003)(86362001)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:34.5153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 522e8515-0ef8-41e7-4a1e-08dae6960bf9 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: CO1NAM11FT071.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8438 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?1753204637557175024?= X-GMAIL-MSGID: =?utf-8?q?1753204637557175024?= 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. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- 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 33ab8ec8fc2f..62744dae3c5f 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 Sun Dec 25 16:34:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576335wrt; Sun, 25 Dec 2022 08:37:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXtxiQsyE4F3VRPcNyjEqXihuBGU722s7xqK6IeNTA1vt8T7QuYUCCmoUSiGu/oF0tu7+0uN X-Received: by 2002:a62:e412:0:b0:56b:baf3:ad8b with SMTP id r18-20020a62e412000000b0056bbaf3ad8bmr17563091pfh.6.1671986238942; Sun, 25 Dec 2022 08:37:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986238; cv=pass; d=google.com; s=arc-20160816; b=JAqoXtS8Qqeyhuw/XxQQ9mRo6Lb1yO90aij/ZY+gzUl8ReAuTcyAUSdvsGfEwWlgO7 tpnGUdptyX46LiFG4RO1FWHCwoxiikOPTpoR8VsQePxEeC0YwklJCnuWZzjvQKNfeDau aseGNKBXeMJfo8h5asH7dytdsl1u/ZCeGrDZfqUB0T8JuCO+CpEjor5rLI8vyfQ37zLN QSXtV6i9NTUAusbqeJyccWgMxT9I0jCf0kjf1uez+BN1uu2iTj5/iG5j8Jxo3QBH07JX WRMpYcjsYu3YBJjWFP98FIkY9M1jQqyBthVqhXyWZPNcQCYmDFY9ryD8VNORUC4YOJC8 gmbw== 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=Fj0Sw6ImPImF5dKyf7qz6SM78Z547bVC8FKFub9x/Xc=; b=aLz7O9tzHpZgoEAqoTxrZIkDGwDWDGEmmkY+U40WJnSjTTDRHejgQDuZ9Ipql5cirK 4Ov1YywuS4h0783aqG1aEJvnitTOS8ya3TfgiRMQR24hmDA3fOr/9FCi5yY+ZhaVFoPr J7DOWIoy566hgklu9RJEu2mAaht+dI/ChhvEDu84P6V2U++orwJ0OY/1ZKxeEdbZFqDs OsAvfueP9RZ9bAEY+Y72LCtYhFrtUYMfeeBAwsahkz54SnPOFlpejyH7C1kh8crvwedB /Nv5ok2r3d6VmWE+0vR2gRi4Vc2HoA/msv7MDBgXvQWO/8PSCPYA/qsi0ks/0QA86cc8 JHUQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="WxX8uXD/"; 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 e14-20020a056a001a8e00b0056d7aaaf1eesi9402251pfv.122.2022.12.25.08.37.07; Sun, 25 Dec 2022 08:37:18 -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="WxX8uXD/"; 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 S231519AbiLYQgs (ORCPT + 99 others); Sun, 25 Dec 2022 11:36:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbiLYQgC (ORCPT ); Sun, 25 Dec 2022 11:36:02 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A016392; Sun, 25 Dec 2022 08:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ak4N05bC0f1suIYn3S0SoTKaBgLpNKlfxKqRcVo+GRzBvr3QLDinpGMoqnhA1SNz0QQpxwBkm2LKcrFmWjsFnseVD8mvzmlqXh7aLWSWeCZpNuwopTfDDZk75dgjf0AQ3+faOLUOM5Gzp+MdBGoHn89Slr+Tx6Kppb+pe2jXHM21y+srHBG2ZSnT36xpIALtATdn9xC+bL6WSjcwHiRe1nrlUAeS57LxDOXZcdR3Mu0nELhjVFkCSPBPWTXVIShj27TT5vOXgLIjanJLjvQHWkTBuDgpGLyH9D7A0xsSvj+YWXYZ3RgcQnMAUrbkX6xGVYdeCD7Uw2ORgLnhoL51Ig== 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=Fj0Sw6ImPImF5dKyf7qz6SM78Z547bVC8FKFub9x/Xc=; b=LnjLGeIQmxBEPVB8w1QhfaaVabWE6xgCxKmlIg9/SyPzJpfsfQwKyc21OwuEyrqPi6Q+2hms1OdT8JHlSWc0QemkHmdQON9pE7k3N04hMTWLV8QjlwGdbtHhV02HYEXpgxz1ECNPcnwU97z0HTDt6s078w1EcZe073sDElIvLXquvLIUHZtuTRrzQKXyVOn8RpWiVc36RzY0QxUFAuMDEikaCuIe3hZSt9Z6bw3EwJrSZnJUqqY9t28Pi1Ap2WaXGwWhPivcv0Y4L3Jjjaw2QzvBCbiUFuj/Sij7ehFk1xGQ+Z8+vWd/hoSiNYur9HTpl0kZBf3SlqU6DvqhMtIVgg== 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=Fj0Sw6ImPImF5dKyf7qz6SM78Z547bVC8FKFub9x/Xc=; b=WxX8uXD/ln+tj2+OahdZ4mSptWvD06TDlkqcKObwjNUQoaPo/Nl3WOQXSit7HxJoNJVr4VQmwV9zM3cQsyN0Czr57vE5PIROJGQnx0FR2RT/hCS/xaOwgeGl2zrBzlwF3ZyEjdhXhsMvS2Cl0W8VyamOdNpiJ/9RRFwh3e2zYlA= Received: from MW4PR04CA0267.namprd04.prod.outlook.com (2603:10b6:303:88::32) by BL1PR12MB5077.namprd12.prod.outlook.com (2603:10b6:208:310::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Sun, 25 Dec 2022 16:35:38 +0000 Received: from CO1NAM11FT102.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::17) by MW4PR04CA0267.outlook.office365.com (2603:10b6:303:88::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT102.mail.protection.outlook.com (10.13.175.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:37 +0000 Received: from pyuan-Cloudripper.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 25 Dec 2022 10:35:33 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 11/13] Documentation: introduce amd pstate active mode kernel command line options Date: Mon, 26 Dec 2022 00:34:40 +0800 Message-ID: <20221225163442.2205660-12-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT102:EE_|BL1PR12MB5077:EE_ X-MS-Office365-Filtering-Correlation-Id: 40bf84c1-71c5-41e6-29cf-08dae6960dff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IzjC+dQ8QWKgzARwKjUpqytpT+Pu5z5zTr3eEFgsuA4IFZc74QMPQK1J/GVrz2eSsCkbbkJiw/LLLh/8pgGOYXAiTPO1yOG6kkyuMb/39HW/V0831HXhCq8ds3vBXGlIOBmmGzS2wKrwSeFTtZ1jdzsk8RgBnfVqhT+4c7tz8WDesp4cNXdz+oNIuOnUDIzD3WTQa+8Oy+lQpb+VUv6A7dDwTSv1alTEO5qiqx0Yn3PrmV56In+mbT6hq6AIBTD0KwOSD+GqjUidSx91kdZEnElSCgWe3pnNfY3URPGtFKUN5PKfUsQp8w7oDc0cW+q7n0REOjvWWi+qQCxL2TA3t3lP7NRLrq9CmV/ryJC0BxOCg6BbC3A5UBYYKZOg6RgAYZlOOd4CCOI4VNOAuE3NuwOUW4FOqtSndaTBmD7JfoWhucvenrZIls57upPxTZgUKAyIzv2nY6nU1s7DDkj4Un+q3tHNeCaPsxeToJFL27pf3PKYFOXgKA3DX07AILZlkURBLGG6ZoB+7yInXzrHP11SL2EDnOx/76kwKGXUPqrKa1yrFQt+W33GpTGemqABRFydXc/eL2q3sujiLIok4H+ESq+YY14BxokHub3BOflT/O4tKzkJvqxaCsqLjn/ty0aRkNoDGhmvgSYPjIt/4OlihWWYUJ2d/y1/Xl44h5lpBiYIggeF9fngSlZS4ze8f7NtkaTenePOZGyGdlhe8Ien8Dja5XqXhY/opoBnjf8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(36860700001)(426003)(47076005)(336012)(83380400001)(86362001)(82740400003)(356005)(81166007)(2906002)(44832011)(8936002)(41300700001)(5660300002)(40460700003)(40480700001)(70206006)(82310400005)(478600001)(6666004)(7696005)(1076003)(2616005)(26005)(16526019)(186003)(4326008)(70586007)(8676002)(316002)(54906003)(110136005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:37.8936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40bf84c1-71c5-41e6-29cf-08dae6960dff 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: CO1NAM11FT102.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5077 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?1753204642327907414?= X-GMAIL-MSGID: =?utf-8?q?1753204642327907414?= 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. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- 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 42af9ca0127e..73a02816f6f8 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6970,3 +6970,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 Sun Dec 25 16:34:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576447wrt; Sun, 25 Dec 2022 08:37:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXsWFWwqj0BrW5zuxQkt04P8lvEB172jvHOcfcBY+l2dWPjNUCaDaWWd53eh3U6plnXBsZTv X-Received: by 2002:aa7:93ae:0:b0:574:f1bc:bbee with SMTP id x14-20020aa793ae000000b00574f1bcbbeemr18403561pff.31.1671986264991; Sun, 25 Dec 2022 08:37:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986264; cv=pass; d=google.com; s=arc-20160816; b=iHIPsp+VUW3pBXwot+AvxJd+Hzh+SmqqGheqnV0P89KWBQSVk+wp0YjVwCDpvsZlxi 6UHHEhwgjtc5mubR5KzLHW2Ql+ITzdXD8VJO657SU7rXHEAQQSeJXcmlf2RpNamN651t H5rJDj8TkJEQj8tMJUDJgnaQbNcx7svNzJ0DPsUgxtDaKFWyoZB4R/XE2lzHYz2viDAD DyGCDXPlNmr/4FyfZ+RZ5enxlVLLCYxmFEbpXgvBmi+l3UXd0twamm9n2s6tj0PjNPHD NZhYujPLIXS2G3M5HL75oSUXfevMWsoIZNjAdujr8GcG3ol8DR09j5EvRJTDunep8Jpc 7kew== 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=yJue3IARzR/+8PkgEGJuRSFCFzuMcT6eEVM0xNWREtM=; b=fD5hhWFe6EuusNPiYqWzw/9I9IUQX9jCgzRV3Vn2Az8n+S51C82y+HAMzj2gNRctmH PPora9aI3z5SebCvIsnS7uWStF7ER2O/fiDfnJet1ymCloAfavsDbHBOvF5TdkjJ1eGf nYGsvm6Np9/hpsEygt0jq3t1omKBTl5ab9jNGapOuuCz2z2nME5LMHse51+pn1VR6zB6 sHdsxuVgGlvqNguXIPjW6QsoCEaxWLKsnkXE2q0nJzd8SC4M7ABoEWS3zSrjNXIGGV4e gQvBKNvZUJQ27oA8qehHJ254Wsre1EMyYSLpKHIaJxg1LaufOVTFuLMTkOb0x5FJ5/q2 O01g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Hzeus24w; 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 i190-20020a6254c7000000b0056d789ba707si8669300pfb.294.2022.12.25.08.37.33; Sun, 25 Dec 2022 08:37:44 -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=Hzeus24w; 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 S231462AbiLYQhB (ORCPT + 99 others); Sun, 25 Dec 2022 11:37:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231449AbiLYQgU (ORCPT ); Sun, 25 Dec 2022 11:36:20 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2044.outbound.protection.outlook.com [40.107.101.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C622D10F4; Sun, 25 Dec 2022 08:35:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RUEZeUZkMt89iKUU+QBuzqz5IdijCTDcJNop/Db5E6P/c8grqy9G0DlkjPIWoOLsmWW1mmqnhO58zOYF21OpS5HTnYlMwEoyKvFn/rTctxGeEjCwpdm8jcbWxAlqH1xg6OcgOit+XOo040kezxPycwjqYZUeYpP2IFYE0c8tBqu8l1EMgeg4BJTL9shjK6Tdcq3IjJ+vbDLqqso81WiKFFmpvqqp7ddqrzKSpoEgGlPwRkErXds7iWqE38ZT8hY3fLELQbHvYZZ9UA6skd8z+VuI8FpRLMQUTiyUZaXueU++MHN0UXPa1k/YhW55gOs/ZJzEEBVyxecDo1Pk8aYvjg== 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=yJue3IARzR/+8PkgEGJuRSFCFzuMcT6eEVM0xNWREtM=; b=h+0ZPgy8O6cF3DZ1kyJoclewHC+X9xbUCq/NmyMA4BdAaRbredyNDki8+BE4kCOFHFjhETex3S9/tWxjpSO5vO7ymfloXw3JEOc+t/JwX55Xv8WlDHJLfLlBGDCc66Ghnuswt1H718Ox/MMZCwicpMw/7GmY89mK4kXFDRS8SRb+D3tlPTT95zXVYg0FlQjIpZQEXxViP8pn4iH0PrvaxV3lAMZTmNP8ls43h/MNtC3Ll4/BOZNPDF0jxqFmVgy3Cx4rrocJ+sFSvBqp6xPeuCG5257+A415H/s55V7vjAKlvorhzC2IWzkS0dSeJT/3z5lxJBAxSIJ3FbsU4MqRlA== 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=yJue3IARzR/+8PkgEGJuRSFCFzuMcT6eEVM0xNWREtM=; b=Hzeus24w0YpBUqzxLLHdN5/iDmI2OtZcNIH3nCKL5RF+ZOXI5oP4d8np34B1I8y7qXA9k/vh7zuG0X72uc0wGxV5IUYJhZdO+CtjqLKrNQjo23YQpdbvrSJsMMUjlLlnqwOE9mey36sD738ji6C8OC84CnbMLzGsxkybW+Daq5w= Received: from MW4PR03CA0354.namprd03.prod.outlook.com (2603:10b6:303:dc::29) by PH0PR12MB8050.namprd12.prod.outlook.com (2603:10b6:510:26e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Sun, 25 Dec 2022 16:35:46 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::98) by MW4PR03CA0354.outlook.office365.com (2603:10b6:303:dc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.14 via Frontend Transport; Sun, 25 Dec 2022 16:35:41 +0000 Received: from pyuan-Cloudripper.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 25 Dec 2022 10:35:37 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 12/13] cpufreq: amd-pstate: convert sprintf with sysfs_emit() Date: Mon, 26 Dec 2022 00:34:41 +0800 Message-ID: <20221225163442.2205660-13-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT050:EE_|PH0PR12MB8050:EE_ X-MS-Office365-Filtering-Correlation-Id: 62b00c34-aff8-4a92-a017-08dae696100a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tAk0hEuNIsaQDLz94w6Sugfh6vL3dlgqibHIHe2B62fYKLDpX9QkN3rItGtCKfXTGDjzEKnOftiqo1wiT8C6Oo1EZS00U1bSJkEZfveddcj1JI3MvMeMxA2Wq6FHHOccVtlId+Pspp3ViRH5mYijETu34BKDW146wdwQo4u5HriG+d2KnnoZFBIMnCfXtm5WnoOHkmG5LmZcVXe6PExhGb84uIgBW+md3Iw1g+NCbLC51LDQ62gV/FaEy9p3DRjQ8NbcRmZSvOHgv0kqibh2xKjaxwX7WhyCZSe18IoD6sxdYFEMO47DjspZvjAviHEGgx04nQatQ1ighYG5WbfFHZIG7EBqfrOhJnzRJLKany85Y0+lq2aFa3fOmD0VVr/raBm/znpBn8c+S5Xf3U8fh2ltzNPPCI/omNxtM6PSElf87nmBtIFfvb19wpV1xlih+r1N4hz6a75e2hb2034vMr70gMWN7PTLouuvHS3+D9DRn7ZgUpiQQzgQ/CB88OP5pO+GtM0T0LlGTgSvZabl3UpIC4Xh+Zk1fNFb0WF+7qwg6l44sOZJBWlHc7+zU/UWkykDL6I0LQ5gaTc448p03cBO9rNjGy2g6XA6ntzhdxMDXEZ/h2mrLjG1eC70UeMHuWFVkO/sSnFlTWoI0wS+H75OZMXqdL7LQSZK1BreQ4QgjJXihY9/RQcN4scT//R0jyuGr7Z9iTu9bIETPTfydK79wTK4ev2FwuAOy/VRPqo= 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)(346002)(396003)(39860400002)(376002)(451199015)(36840700001)(40470700004)(46966006)(7696005)(81166007)(16526019)(6666004)(26005)(186003)(356005)(478600001)(1076003)(83380400001)(54906003)(110136005)(70586007)(8676002)(4326008)(86362001)(316002)(36860700001)(82740400003)(36756003)(2616005)(70206006)(426003)(40460700003)(336012)(5660300002)(47076005)(82310400005)(41300700001)(8936002)(2906002)(40480700001)(44832011)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:41.3242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62b00c34-aff8-4a92-a017-08dae696100a 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: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8050 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?1753204669603096983?= X-GMAIL-MSGID: =?utf-8?q?1753204669603096983?= replace the sprintf with a more generic sysfs_emit function No intended potential function impact Acked-by: Huang Rui Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- 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 8ceca4524fc1..87450413cf45 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -695,7 +695,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, @@ -708,7 +708,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); } /* @@ -723,7 +723,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 Sun Dec 25 16:34:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 36497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp576531wrt; Sun, 25 Dec 2022 08:38:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXuk5/E0XifABnynuL/TuF16ZwuofWOwxQh/oxuGDHzc2S/Eh3Wyqely0hQpXQJFxv+4OEsy X-Received: by 2002:a17:902:ead5:b0:191:1b:68e0 with SMTP id p21-20020a170902ead500b00191001b68e0mr20768206pld.36.1671986285701; Sun, 25 Dec 2022 08:38:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671986285; cv=pass; d=google.com; s=arc-20160816; b=u8w5sEQwaO+xKlLpf7e1CiyXZrPTaKiG8PkHInIvWdI4GUEO2n0zQpvwR0pANDRPp1 TQYke7P6hdbzEzoji2cNn158o6ciLqsfDgbSAJqfIJP6LlAfSnsHRIR4jWaifenjj+8J ceCDlIeL80N2tKNTx7cOZbi9SCEROrVmu7akc4XczNc7VPie/YMlt0YrAy7KtpEzaabi cQbVHB8kC+PtlhTEFz18/Jb3edUNBEmJAiMjTt8m2BQrtPutwEZeJURPW3JWX1+An8JP to4laDoNJa0q0RPQ8y8tTKkA+nNlFwgtnXiHIPo7nfYMANA6edmrHRao2Eibkfl0srY4 wcWQ== 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=4vh5BIiGu8aWs7ta5xjjRUVc33Mldl/eriqxGSSrR6c=; b=UNdKHcgTOpo4u7/qYqdUshGkwRNLKlxD+LYLkWF6d6QcOkGo4dBbKUC7HrzsH/TFif 4Git6uhB3zZZwB/ditYSc+j6kMmj+7j0ZbPJswDEipRjdyd/NBcU32v8keNOxLVSnvHf VqIQIBxenYkrp3OnxiChFwvt1r23odZ67QqPs6y8oLGgZ4+qH2uGsbQkKSbiOzRLVLlv tvtCMY6rTl96XnjilKx3Icyh5PKL1rL2lXvrmV1bJg6k9hiy0w/1juRkn0lWM6ScygaS fVB57372DytmeObQILfH1SshFuqG/rv4ICmzFAmOSjjy5FFIipjqf+BWUGCl3e1vMONU K3BQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=F3e4Uiz+; 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 u9-20020a170902b28900b00186a8bd137fsi8769968plr.453.2022.12.25.08.37.53; Sun, 25 Dec 2022 08:38:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=F3e4Uiz+; 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 S231596AbiLYQhG (ORCPT + 99 others); Sun, 25 Dec 2022 11:37:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231397AbiLYQgY (ORCPT ); Sun, 25 Dec 2022 11:36:24 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2083.outbound.protection.outlook.com [40.107.237.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DDF2264C; Sun, 25 Dec 2022 08:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UPUydaXqFMs5YJk0gkbiyD2xyIKfp9ZbgMzGQvf/4adZNdyF2j9OCz5sCGAWDe+/L1ZzaAMpUbAOJ9ZI11go22FCi76cDWnU4sqD0OhbHjE8V4SqGA71A3nIiSOxPDNk1V/lFYO/Ny2G5mw2cXeLg9Mgm2OARvmSfS36ACj2Yg/Njm77xpXE1Q7EKYN671wd/7uZtfFXY1/38E4xktzPtvytDUgeO5I9DTNdR4wI7GYj5wZFYTQK5VNzaPrNBexTo1YqbPgJQ3Kkafm78Jue3kQOL2kJet45OuFHfnbbBSiJMp9RpLtEgHwkakcg8tZublPd9kf+hJiKTZUAHQGT0w== 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=4vh5BIiGu8aWs7ta5xjjRUVc33Mldl/eriqxGSSrR6c=; b=ae+z2lXJXaClxQB8GvOSZRYZiOYRyNc1fh/ekr0gfNPfGaW5gGJKtrDCY28T2z/NT6052FXw/1PzHsF4MoHtMU0dZRIDOlidza6ibLaRsvG1j5+t3BZ/HMs+TMiOka1uvLF2x6SvQmDlKeW0H+l8kDfsaM3pUF1ZcKLcBJvY93Huom4rYxi50ZTx2KDmPAKHysCXa+7OKtrGj4CBYOAxHaMX7OA2vA5A2qFd3DGPfdNBPDWbzwDPen9n3gNNauBT677EvoO0ZmUtGaEiqjct87zo7dR0LLYRo7fxh/6PQosXvajSCcOehEjJ6bBYExme5tLq+1isriHjSeXMpmwmoA== 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=4vh5BIiGu8aWs7ta5xjjRUVc33Mldl/eriqxGSSrR6c=; b=F3e4Uiz+pP3/13rwnhVPGrOxTkVlPcO6yfDInxSIHn6+x3tFNEW3GleFTMwAROQACbCefdbWPvBEeLh8py42WW9saukjgAHC2MaH8vWz8M9sXn8n8n7B7sLNYTXnailZRzGvLaRVEuutTrookhfIn/Os3w5AFi7k6Ny2V5ywJ70= Received: from MW4PR03CA0338.namprd03.prod.outlook.com (2603:10b6:303:dc::13) by SA1PR12MB5614.namprd12.prod.outlook.com (2603:10b6:806:228::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Sun, 25 Dec 2022 16:35:48 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::d5) by MW4PR03CA0338.outlook.office365.com (2603:10b6:303:dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16 via Frontend Transport; Sun, 25 Dec 2022 16:35:47 +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 CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.14 via Frontend Transport; Sun, 25 Dec 2022 16:35:47 +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; Sun, 25 Dec 2022 10:35:40 -0600 From: Perry Yuan To: , , , CC: , , , , , , , , Subject: [PATCH v9 13/13] Documentation: amd-pstate: introduce new global sysfs attributes Date: Mon, 26 Dec 2022 00:34:42 +0800 Message-ID: <20221225163442.2205660-14-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221225163442.2205660-1-perry.yuan@amd.com> References: <20221225163442.2205660-1-perry.yuan@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT050:EE_|SA1PR12MB5614:EE_ X-MS-Office365-Filtering-Correlation-Id: c0915225-55da-48d1-b3ff-08dae696139b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qCRWvtrMf61b7tzE10NjAZi+IYgUHIKcXwJ5m8Rl0WaoH32qi4hSdPTNteyN91csVVDCMQRc+EdUCs9g0/d14q3SW61/42AU8Cbi9/hgws+76TDm/mUlMhU4S6Ggr8zZ/CzJWzYSLcQPxjNI5uNtFO2eTfICjeGYq6fGSTFXhzXpBdhQaQZYyd1Q9MW5g5V3Oq5LqSdGAi8YKUGjEacmaSe9um6/adn9jNW76Q6x0ZKV5wH9IJS13xDN4VIywRUxLDr4c34lVUHY53jm9UY5c4tc2DFViSTnsB9eAbizp03p9XExYwg7waHUx3hbII3UAUXwU6bfiO+HxDW5ZsKxPLx03KtHsAKXy4AHc8uSw2y1pDQXNq/NrBgZDpHpOYJYFLIVTn3g++VRZ5vSlx4tg5GNBVUANBl6Tq8Dl/Xj9R3JgpGG1jq6w20Tx34eEsCVBiYpZ1YoBdcNnJenP6ycogyQiZ18yARXnkbWQOkIOnb1ydVlM9tOkvItlvi5cjVNPLVC4Izsu2ZvKNaIdvDTYlIPPxBegc+KInUIEjiuzGtJbjdz4pubvrhDnd79ixz5V7vbuu8KD0U4CI3aTIafWNKB+AH/nD43t8WgSqoluAsNTpXlK8DWmP3Xr6oaExlSt+TEnkRCFKXP/3ZehyNnvQyaRLdjJSYE9EKKknb7fLbLn3ZEdkOd0xydTIEn4hE6JprfO2eACfVGGdowDcdvuFYJIA1nSGg5aSbL6eNWq0Y= 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)(40470700004)(36840700001)(2616005)(316002)(1076003)(40480700001)(47076005)(426003)(44832011)(336012)(83380400001)(5660300002)(356005)(2906002)(82740400003)(16526019)(8936002)(40460700003)(478600001)(54906003)(82310400005)(26005)(186003)(8676002)(70206006)(70586007)(41300700001)(81166007)(110136005)(36860700001)(86362001)(4326008)(36756003)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2022 16:35:47.3082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0915225-55da-48d1-b3ff-08dae696139b 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: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5614 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?1753204691568459063?= X-GMAIL-MSGID: =?utf-8?q?1753204691568459063?= 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` Signed-off-by: Perry Yuan Reviewed-by: Mario Limonciello --- 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 62744dae3c5f..5f6379475b32 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 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`` ===============================================