From patchwork Fri Jun 16 12:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13282725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B328EB64D7 for ; Fri, 16 Jun 2023 12:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235412AbjFPMHY (ORCPT ); Fri, 16 Jun 2023 08:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345210AbjFPMHV (ORCPT ); Fri, 16 Jun 2023 08:07:21 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7FF32D73; Fri, 16 Jun 2023 05:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LYzBElM84eAUbTWMaH/5NarcmfDXxrk9hDwkG8jjD2SPGI52CakNCD1hRqRjGSa8NdybLPZ9wqSlzQPsL4emF6t0mO97sb1cGD6awFphD+/+u8+ocagErybJscYORExOSkIpkTliilaxjLGt3ImMjqs2k0iQ9ByQc9J72ogBFQd0xLr0Fh3wwgEEdusAox73YysakJmi46NjBwic0XAcVOUUEYRsP9jMwLssEm4Z0qyldK88pUxE+njqufHv8qfs7xSN9AU0WIj3leYYGoegaJSyifaxGhMkKdx7PdhA9FBZ0iyNphdeJk3tMKCQDCy7L5os3xJ9boMxBn4ckbSCYQ== 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=AlYkodrzglfXDTN5fkJDf+04scGep/JAEY4NiAyB7BU=; b=dqCzcpxo8OrpWsWaq4vR9iFx+y9wWzNoT7DFZzds4XZUySnDbICSRo2MmC6Tx1GEZEGA3R/2p+tAHpuJxJ+reNYAw/ZOt7lJgv7INodxRsgI0z2Wz6ET0eGx9blgbkqXcLHeAlXMXeOI+MpDgsiXD7jFw83dO9Qel1AXxOqSEA9yR6kg8WHLyZcjkMIwBV/xxThmvgAT9ODEDL05CjbjJDv8H1CDJM20Re9dvRPsErrHcx+9l+fwmHqLrbFmnMg/EvguWT7qzFlEcy3LLiUGl7SF4+n58aFRT23J36AQp/P0qUdMGF/4UkifyaOTfVYzA/WF4teYGIs22QXTIeyjsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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=AlYkodrzglfXDTN5fkJDf+04scGep/JAEY4NiAyB7BU=; b=CCEVxH7RMARH0JCFnAX2qDar2zfAROMHQUIMSz04iuYTsWkfm7JohHdwoQ9ySr65sbzfPcDzghAjwVWLLKJu9Qv9RBzHWTCVMcsKL9jmC+h0jSGNhy22DQfuturhxOwMKyerfTt9ZRP/KC7+yEXAukRlAxEdv+WtRPiDTFyB7V8= Received: from DM6PR06CA0022.namprd06.prod.outlook.com (2603:10b6:5:120::35) by IA1PR12MB8334.namprd12.prod.outlook.com (2603:10b6:208:3ff::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27; Fri, 16 Jun 2023 12:07:16 +0000 Received: from DM6NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::78) by DM6PR06CA0022.outlook.office365.com (2603:10b6:5:120::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 12:07: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 DM6NAM11FT028.mail.protection.outlook.com (10.13.173.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 12:07:15 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 07:07:12 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny Subject: [PATCH v2 1/5] cpupower: Recognise amd-pstate active mode driver Date: Fri, 16 Jun 2023 12:06:16 +0000 Message-ID: <20230616120620.147643-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616120620.147643-1-wyes.karny@amd.com> References: <20230616120620.147643-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT028:EE_|IA1PR12MB8334:EE_ X-MS-Office365-Filtering-Correlation-Id: b8d2400a-62b6-45fe-53d5-08db6e6239d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7GhpWJzdaG9beKHgrNZcdl+Lkamae3PZBt0mRE4RFHZDf8K88lzWZvoeOVw8i+hU69YZPGuTEUrScThz0WENpyCgQfpdxZxODJ2x9fh/JcWCzWOjFTucOva2FrbULgLwYwBV1AYlWgr1HCQTjcvSEpKeYPvFUGsiYzszeLheC/jfLmmW0kg1vTvaseXQSQNs4Ca81VY4rHxQrKwLKymYkBsu25y86KN6KOB2VheaAEZA57t1IdZgUwOhZ55G3w/sCKxRA/90T2SJTaUrDyp1AtMIQWk/9u0aKM/kX6Rvk7rt0HfGYmUnkEM4ougSoV9GkPEDHIjzBELRBY7/PsctlDcJAC7rIIeSKSpo+eq38Ryx9dhrZGmonbEahMpD+LxP4qufee9VJ3P21jyHSBdu50WmFPDgFNybl0zIF952oYMX5ayZNSfce7fsf9SuLp3L3+ZIxwGO7VjDu2GPeGFDKypNGAkQinkq/FB8n+9sGHPB/t3SgB7lH3wbBf0iwDWlKncHx9zAgp0O6Z4w3AyPnQB6qPDytpMVP9PZ5hNiUCm0bDY3rRtqKPhCJAXJcY3UzCCgUxbSGQ+yCkMl2EEH5Sx+yIqyq9E0P2TNUTs2mQbdRE7znd6t+BeUL45yQATNC8+qlkd6mNvvlDKDZhf86Cs8xIXupZH+FACgQJFcmLq1M3M1tUdPIHDF79UXgmd4zsxLaT6EVivlI004Zev65+mXF4Vzh+cuPbIhNKPRxqnN4lohDb1seL3g1qLRG/9VzHW6MoOgNl3NI3Xg8Ac0UA== 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:(13230028)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(5660300002)(478600001)(54906003)(8936002)(40480700001)(8676002)(41300700001)(316002)(7696005)(1076003)(110136005)(16526019)(44832011)(186003)(4326008)(70586007)(70206006)(26005)(2616005)(47076005)(83380400001)(40460700003)(36860700001)(336012)(426003)(4744005)(2906002)(81166007)(356005)(82740400003)(82310400005)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 12:07:15.7496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8d2400a-62b6-45fe-53d5-08db6e6239d3 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: DM6NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8334 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd-pstate active mode driver name is "amd-pstate-epp". Add this to the string matching condition to recognise amd-pstate active mode driver. Reviewed-by: Gautham R. Shenoy Signed-off-by: Wyes Karny --- tools/power/cpupower/utils/helpers/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 9547b29254a7..21f653cd472c 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -95,7 +95,7 @@ bool cpupower_amd_pstate_enabled(void) if (!driver) return ret; - if (!strcmp(driver, "amd-pstate")) + if (!strcmp(driver, "amd-pstate") || !strcmp(driver, "amd-pstate-epp")) ret = true; cpufreq_put_driver(driver); From patchwork Fri Jun 16 12:06:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13282726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96A87EB64D7 for ; Fri, 16 Jun 2023 12:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345215AbjFPMH6 (ORCPT ); Fri, 16 Jun 2023 08:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345003AbjFPMH5 (ORCPT ); Fri, 16 Jun 2023 08:07:57 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7BB30EC; Fri, 16 Jun 2023 05:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tk39yDq+8Z9OkyG/lKZULMzr5mA2VRsQRdFHe8Z/2VbNPp0ABTphZHM1u411yTTl6ugs50qO1irWflen7bgd5YPpzwhnrfqA1vHrfm5TETVnm5X3LUSpeNH8dFEIaWEVhRgEvN6wAL8axraDRz4Ap3yZTdoWoQ7xz60tbrWmVdjqmC22MtnSFrWh1njpbEzaWDJGP41w3GDSwzYGj9Buoxr2cfWpX1qQ6S/mv9q+jvJmOK/9Ib7ChQzkt3BB1eKOIloMVNbZhXPJ07OP9HK8L7vQvJmSPMXlTkmi9lDu5pBk95HMkmSquhstEX4WoE19X+73Fnr5SjaUq+g8GxFOhg== 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=msASNRWEBAp4EC0xUpPcYVisOmGSsjbxZ+7Gs974wLU=; b=eu5ig4PZZFuxiWZEXMH4FV2bf6w9sweIy5gbWl/3Ffh2cXVkSNzU8KP8GE91QG4AU2gkfsG+G5h++PImdwoedqQl4MJ9LLanpIBjcKtzKqr4Oss/WTxtzc/R5I9MzjlzhlwrJmD05Py2gLRQQzTvSJAk0Hr5EMe841dHXSiTOlGa5lcrDCzxlwkKH2mufVpvJhyXiMsMhqq6A8Eoc8ciIzcRU909Mjm47fRCYQP82itgCTHZbFLo4cCfqPKOuns4GKrMriX7/GBkgCPpctCPThj4hm9g50BoPJ3FiJ/tZhFYEkFke2GjIb4inoul5TG0bmFPAps/kGozjI56Kr/wzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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=msASNRWEBAp4EC0xUpPcYVisOmGSsjbxZ+7Gs974wLU=; b=lIY8nXQ4hbrwg4e7c3ssvJJ6Lj7j6ba999czdCmGTaW1nmt2cJ7lvFwWyvNDy9zNOETdjFoHm9gmaMBGv1x2FnRu8/MlDSbxP8lsEfvJyW7h6Ayi0xQQlw7TcbNJ2JC5yw9udyAPDySXML5Yq0LakH4NT9c9+ZCWKSQKtSSjyDA= Received: from BYAPR06CA0044.namprd06.prod.outlook.com (2603:10b6:a03:14b::21) by PH7PR12MB6539.namprd12.prod.outlook.com (2603:10b6:510:1f0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29; Fri, 16 Jun 2023 12:07:51 +0000 Received: from DM6NAM11FT097.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:14b:cafe::c2) by BYAPR06CA0044.outlook.office365.com (2603:10b6:a03:14b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 12:07:50 +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 DM6NAM11FT097.mail.protection.outlook.com (10.13.172.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 12:07:50 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 07:07:46 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny Subject: [PATCH v2 2/5] cpupower: Add is_valid_path API Date: Fri, 16 Jun 2023 12:06:17 +0000 Message-ID: <20230616120620.147643-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616120620.147643-1-wyes.karny@amd.com> References: <20230616120620.147643-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT097:EE_|PH7PR12MB6539:EE_ X-MS-Office365-Filtering-Correlation-Id: 9083bc07-6022-4b73-2e1d-08db6e624e66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wDmh+44y0+VfiFIlE3XnWTU8BKr1Js+OqCJb3rDLCecgTVUsSPeTqAsZYm1m6Q8Gd0Vhjw76SNQxI1+p2UdTT6cxuHx9vYmb18VPLA6vCkYFR0UOeyYvlCCMEiVWj1TatbdTGMsXM19Je4p0pFA7QIRrLTPpFh8+fUZQT7plE0+/D4dKCVC78BlJSpSPxfaGXX7rP9U6HSZzNM2VFxkfV7MMIAPQQ5CKMgJfrH5zNB+W6EHGbLCfEUdiPEUjaHPdwzXyGWFR9aily/9J7KPCZRV5hcGUMSBGzwG/9yklWuj+fSQMYmmGCP0juoonJ753/IZ4lJBRV/EKr2PKzNhjhaf+UZeabBpm2vDzRzghX1wrfxjK2EFlVpAJHtfpU/ERQxh7RedggMK5Qj29P3xASR6qnX/FTVgIVrwCP/7YpUNJx6/HLIFdQkKId7GC92QR1DimV4u+T2D+0u99hdVEf/BTNsQg6NFtXENnN4mvfB5KyOZUWNGPo5HNq3MI8ij+3ll+6fsRuPCGUAvNT2PxY4S3xGfwIGTfYwqoN1KxatjYu1DgCOh6nMpfCyVNbgCJmn/WvRN46ioT8YNafJ5TONHnKRTgIZXzG4JCyHbUFK0uwZAXfPEV3+JwYd7reya5wCbNGMUKQdCGQ0AIUWpmXKkMkW+VEpEeq7aQbrDpH6PDTCH0pNiHTjyBbZbHfGr3M1lC6mlsMBtPd7RmpKL/dAVCPHI8u15Psbk7GoeEU1YWMzwk5rS1LXGkP/Hc48YbyeWpEYSzzeW9PxiO4QWvaQ== 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:(13230028)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199021)(46966006)(36840700001)(40470700004)(47076005)(336012)(426003)(40460700003)(83380400001)(2616005)(2906002)(356005)(82740400003)(81166007)(36860700001)(36756003)(40480700001)(8936002)(8676002)(86362001)(110136005)(54906003)(82310400005)(5660300002)(41300700001)(4326008)(6666004)(70586007)(70206006)(7696005)(316002)(16526019)(186003)(44832011)(478600001)(26005)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 12:07:50.3445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9083bc07-6022-4b73-2e1d-08db6e624e66 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: DM6NAM11FT097.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6539 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add is_valid_path API to check whether the sysfs file is present or not. Suggested-by: Gautham R. Shenoy Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- tools/power/cpupower/lib/cpupower.c | 7 +++++++ tools/power/cpupower/lib/cpupower_intern.h | 1 + 2 files changed, 8 insertions(+) diff --git a/tools/power/cpupower/lib/cpupower.c b/tools/power/cpupower/lib/cpupower.c index 3f7d0c0c5067..7a2ef691b20e 100644 --- a/tools/power/cpupower/lib/cpupower.c +++ b/tools/power/cpupower/lib/cpupower.c @@ -14,6 +14,13 @@ #include "cpupower.h" #include "cpupower_intern.h" +int is_valid_path(const char *path) +{ + if (access(path, F_OK) == -1) + return 0; + return 1; +} + unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen) { ssize_t numread; diff --git a/tools/power/cpupower/lib/cpupower_intern.h b/tools/power/cpupower/lib/cpupower_intern.h index ac1112b956ec..5fdb8620d41b 100644 --- a/tools/power/cpupower/lib/cpupower_intern.h +++ b/tools/power/cpupower/lib/cpupower_intern.h @@ -7,5 +7,6 @@ #define SYSFS_PATH_MAX 255 +int is_valid_path(const char *path); unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen); unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen); From patchwork Fri Jun 16 12:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13282731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF9EEB64D7 for ; Fri, 16 Jun 2023 12:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345231AbjFPMLT (ORCPT ); Fri, 16 Jun 2023 08:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbjFPMLS (ORCPT ); Fri, 16 Jun 2023 08:11:18 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2044.outbound.protection.outlook.com [40.107.93.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C2430C6; Fri, 16 Jun 2023 05:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cmkoNB0j5FwzR9sJX2YTDc9Lm36nMLtdBMctDC1Ob9R1OPJWWTQ67JXKLe0AIOltOYRougC1MOoOY0ZK/D96tWDCYSxQeDPvcVjugA9oczQMPHajYvor6/f8MhoAPX5Rm+q1l49rgi6E8QiUbDT7BCOpC5wDsnz4XMru+m+fIG5Yf3bFh84oWaszYdyzkcum0gcojgNI+QbueoH0EymYYtmvFCEjsOlt58wIg5cnUxZTasv2QBG2Qt8O3iXE/KrgQ0xYajhrj3beH70WqtHgLoJDbvoZ7LhqMJo6TirSW95thuE6IQIp2NkQg8iQv+bmbe+GZKPL8ZjesJel6MsZpw== 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=9TERMzjVqf1BUCKOG11qcP7PHls/ICBgjVODltQVQCE=; b=MkjIjoQF+YRPaFh1pyrveR3Wx9NQA6e3Y60anQsoWg6yStvcL6cJbVpJMSXjBJMfMYBFJ/xYgpnPanFtjm3Bgq5ZwM2XFiIegn869GyI2cTFGxNt78f5j0aNp/fy71CS6v0a5VbaOiPN+12aL1+aR+0BXbmt+DrQHh3gC44EO1/JFHFVmnNkphSWJ3Ar+OoQZkl9J67LKeOkS+cDu6fQubaV14TERM9xRWCN6yKjrkLteZhnGDPRd8nh2/utj6ImOz8BbpDaZzaUn1l1WbietJlG3Tk66lJVRpMpgnZC+R1rZV74znO8cRDShE2Ala6BIvsIUelijEHWiyagvI/pTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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=9TERMzjVqf1BUCKOG11qcP7PHls/ICBgjVODltQVQCE=; b=HdtAGgK2nto+DaAU5tGCJPRqepUDmhhgtEo/9de0OQ+N/OhHY68xtT5KtLBEKAr47TRi3/hji9ScIuHmlyXPO4+nVyjSln+TmjThC6YLSyXCA1gRf+FRqXW8GcXm35tF5FHMtOndCViGDsj8oNQ6NkYs5z542yS4tvcTgI0t6lU= Received: from BN8PR04CA0043.namprd04.prod.outlook.com (2603:10b6:408:d4::17) by SA1PR12MB7344.namprd12.prod.outlook.com (2603:10b6:806:2b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 12:11:13 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::9) by BN8PR04CA0043.outlook.office365.com (2603:10b6:408:d4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25 via Frontend Transport; Fri, 16 Jun 2023 12:11:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 12:11:12 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 07:10:12 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny Subject: [PATCH v2 3/5] cpupower: Add EPP value change support Date: Fri, 16 Jun 2023 12:09:53 +0000 Message-ID: <20230616120953.147676-1-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616120620.147643-1-wyes.karny@amd.com> References: <20230616120620.147643-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT020:EE_|SA1PR12MB7344:EE_ X-MS-Office365-Filtering-Correlation-Id: 0697563b-3836-4cd0-b763-08db6e62c726 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TfktDpHnsJWdVuIaRlzKxflkGzGhpYdk4n+JZXihjwovuwPV7Md6qYzkJrW/qr9gJHHE2H/SA8mL+kbJpqE75W77mDt6C+/MANtCfwj5FZZrzfS+uiBsJ7Ew8Yp+d+VJZKjMKvRG0jnl1yl9hQXXDh5L13N6zTnUhmoNrwqBia7n30xzdAxeLXWzE0RFGX2vu+z17a25fVqItryZw0cIbI/Cv2nFy0Rx1InVGOppUmUGpAEImn7fMQkosbCOLtSh0fR15w7pKAQNy6q6NlQpv8idjzyTg8PM3Kfen/YuHAxUEOVhTcwTUo+pvNQhPUW6tyjCIXKKZ3RWNsC37YqWAPqFoTgRjDNvHU4C4I1wb5aLk6dBwq+BeFv8ml1wR0abqlQGK5OW0FhMRgidlkebcZljou/orBDHi/VwABGYlYlV1lRtLgpJoSj3kXRyr4xDvH89kDO+Hr4n3y3ENXCOHqmjtCA8rOPy77vcd2hGoM55Q0FqeH11bwVe9dKTuCbM80nqQ2uxxwOrRz456PlubLk/f68uj/28ZmdyJv6sKWVCRvsc7+oQZteGOS/3sqEYlcpkE/RDyVxIs0dGMoR26y+at5+6QqWhOod2op+/MQRwwICuhR10wEuaSv83vZRXHECA9Gm/2dmd3Efsp6G8ezFKkD0YcwRuXJNdqm3pQsiRAfXySEa4vGyMLxCg5xIIkU0ZhrMKCa716hZWYRtN3o8GkRSjvN9tXVPP1TklJ4AYMZ3O8jC6sM1hT3jIYh9D2IKpvU6XMOQlwE2aRDKgaA== 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:(13230028)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199021)(46966006)(40470700004)(36840700001)(186003)(16526019)(36860700001)(336012)(1076003)(83380400001)(4326008)(70206006)(2906002)(70586007)(26005)(82310400005)(47076005)(426003)(2616005)(86362001)(36756003)(40460700003)(356005)(82740400003)(81166007)(7696005)(41300700001)(5660300002)(8936002)(8676002)(316002)(44832011)(40480700001)(54906003)(110136005)(6666004)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 12:11:12.9642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0697563b-3836-4cd0-b763-08db6e62c726 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: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7344 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd_pstate and intel_pstate active mode drivers support energy performance preference feature. Through this user can convey it's energy/performance preference to platform. Add this value change capability to cpupower. To change the EPP value use below command: cpupower set --epp performance Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- tools/power/cpupower/utils/cpupower-set.c | 23 +++++++++++++++++++- tools/power/cpupower/utils/helpers/helpers.h | 5 +++++ tools/power/cpupower/utils/helpers/misc.c | 19 ++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index 180d5ba877e6..a789b123dbd4 100644 --- a/tools/power/cpupower/utils/cpupower-set.c +++ b/tools/power/cpupower/utils/cpupower-set.c @@ -18,6 +18,7 @@ static struct option set_opts[] = { {"perf-bias", required_argument, NULL, 'b'}, + {"epp", required_argument, NULL, 'e'}, { }, }; @@ -37,11 +38,13 @@ int cmd_set(int argc, char **argv) union { struct { int perf_bias:1; + int epp:1; }; int params; } params; int perf_bias = 0; int ret = 0; + char epp[30]; ret = uname(&uts); if (!ret && (!strcmp(uts.machine, "ppc64le") || @@ -55,7 +58,7 @@ int cmd_set(int argc, char **argv) params.params = 0; /* parameter parsing */ - while ((ret = getopt_long(argc, argv, "b:", + while ((ret = getopt_long(argc, argv, "b:e:", set_opts, NULL)) != -1) { switch (ret) { case 'b': @@ -69,6 +72,15 @@ int cmd_set(int argc, char **argv) } params.perf_bias = 1; break; + case 'e': + if (params.epp) + print_wrong_arg_exit(); + if (sscanf(optarg, "%29s", epp) != 1) { + print_wrong_arg_exit(); + return -EINVAL; + } + params.epp = 1; + break; default: print_wrong_arg_exit(); } @@ -102,6 +114,15 @@ int cmd_set(int argc, char **argv) break; } } + + if (params.epp) { + ret = cpupower_set_epp(cpu, epp); + if (ret) { + fprintf(stderr, + "Error setting epp value on CPU %d\n", cpu); + break; + } + } } return ret; } diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 96e4bede078b..5d998de2d291 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -116,6 +116,8 @@ extern int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val); extern int cpupower_intel_get_perf_bias(unsigned int cpu); extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu); +extern int cpupower_set_epp(unsigned int cpu, char *epp); + /* Read/Write msr ****************************/ /* PCI stuff ****************************/ @@ -173,6 +175,9 @@ static inline int cpupower_intel_get_perf_bias(unsigned int cpu) static inline unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu) { return 0; }; +static inline int cpupower_set_epp(unsigned int cpu, char *epp) +{ return -1; }; + /* Read/Write msr ****************************/ static inline int cpufreq_has_boost_support(unsigned int cpu, int *support, diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 21f653cd472c..63c3f26ef874 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -87,6 +87,25 @@ int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val) return 0; } +int cpupower_set_epp(unsigned int cpu, char *epp) +{ + char path[SYSFS_PATH_MAX]; + char linebuf[30] = {}; + + snprintf(path, sizeof(path), + PATH_TO_CPU "cpu%u/cpufreq/energy_performance_preference", cpu); + + if (!is_valid_path(path)) + return -1; + + snprintf(linebuf, sizeof(linebuf), "%s", epp); + + if (cpupower_write_sysfs(path, linebuf, 30) <= 0) + return -1; + + return 0; +} + bool cpupower_amd_pstate_enabled(void) { char *driver = cpufreq_get_driver(0); From patchwork Fri Jun 16 12:10:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13282732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31B40EB64DA for ; Fri, 16 Jun 2023 12:11:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345243AbjFPMLU (ORCPT ); Fri, 16 Jun 2023 08:11:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbjFPMLT (ORCPT ); Fri, 16 Jun 2023 08:11:19 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2070.outbound.protection.outlook.com [40.107.96.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4552D73; Fri, 16 Jun 2023 05:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LXsyCo/iOusLAwA4ayQYSxPSxvmrq3aaWkfqSmvPH/OpMDvJm+DJ9MThxKuPnU8+bMmvr6hN572wWn+oqTRPmKy0y2NKN/ooQhw0Q8ezxQxXs3fpawCOa8bA2yDVVPXY00lj3B1QWPb15bhpnSPy1BWumVpkuhSsYqKBCXs9erPGFFOaSj/RDWQ9bMvDdma+CXATRflWHxw9Le7T5iYoQKmtqtsOla0ZasrCYlRdxUL/o5LOEw0TqSUR9U6E7Th5qGq0cvujOqliJfFEVgMVHGGfOWGyPUUsN6w4BtqaT/HRrzR9XmiHZ0X3S/6Qf0zrcRaHuQw0zIGBfA7puqjItw== 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=rcYkWBmz9+0nsPHn+lwN7BOkQmpVnmdo4nPnKWX/c0w=; b=BquAvGPEQ3dqp8cfzC0IojpuyJWOZAZxg7Z+MYg/YJjmB9ktGG7mYurAdGjSXCl4En5Eeh4RRQWrK4qgdQNQx0FgotAnrj7xnFhOvJLbfGk5ToU2QTZMiV8fJq2Qt53F92cQmrl/mkPaoWsCLbYe2l+JuYedmrXZIhWvQkrXJYjG0m8Jh/4E5R8mDYhjDj+Dxu156Aj769TifbYCaPQvo4I2n57efxGDz+2sKH0K4P58Pkji2T8FLQwE+g3ZNemaKH57hwYyIlN9a5Vwr5mynVuSOAPdBGkFXvCXD7He54eMD+Q16M+L1eJspfVVbYEbWaaPJKN52KS75RT6WDdJVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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=rcYkWBmz9+0nsPHn+lwN7BOkQmpVnmdo4nPnKWX/c0w=; b=Xmw5cKqTFKGz0SPYyph2YwehpLn74fHAFxlViKfBqCug1H2I6XmF3tfwdD6/TLESkpkhLlxjvTGR5Rqk2Vv9uECKCUo4znWJ4fny8kPRmd/w7mV5eiJtL074ZLbzFux91xp9BoAIMCjSyv7Qe1yCZJF3tLCqeavSYP8KJeZLHCQ= Received: from BN9PR03CA0634.namprd03.prod.outlook.com (2603:10b6:408:13b::9) by IA1PR12MB6411.namprd12.prod.outlook.com (2603:10b6:208:388::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 12:11:14 +0000 Received: from BN8NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::19) by BN9PR03CA0634.outlook.office365.com (2603:10b6:408:13b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25 via Frontend Transport; Fri, 16 Jun 2023 12:11:15 +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 BN8NAM11FT048.mail.protection.outlook.com (10.13.177.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 12:11:14 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 07:10:44 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny , Huang Rui Subject: [PATCH v2 4/5] cpupower: Add support for amd_pstate mode change Date: Fri, 16 Jun 2023 12:10:26 +0000 Message-ID: <20230616121026.147691-1-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616120620.147643-1-wyes.karny@amd.com> References: <20230616120620.147643-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT048:EE_|IA1PR12MB6411:EE_ X-MS-Office365-Filtering-Correlation-Id: dda589c2-52e2-4c74-319c-08db6e62c82b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RlKc/OODGPM1LREbwXqQTZzM9sylVyt6Vdz4WZwCLjMil57CsImICR2YJoaxLJRBvVXr06k5em6RzAkTX2cbDxUlxaZ1CZraIfBwOaDprRGgPCUEJilUWb41fxq4JjNFrUEWNqW34SgYEGgb4NvgrKE1yGO/Q7mRvFR6Gc66bnETGcmK8/WUrQrRFXR4dDNiitgHejQJG++n7/EGoriW7IsZztWCkyph7d308UkXe8hEX1GY8UtN6Q1CEXJv7cy3UEmXOYmNwQbwZP9dA2drniqYeBACy/x4s6VA483xNufxwBlNliokyZ2HT6EnMx7hNh6+GASi9zJea8Z+ULH0Hef58T1ExHCq/Lh+HjqEJUy/euIncGtFppvdVHSyWM8/XI4IbfV2Kb3nwln3uYilV9yMqYYl8gSC9fyIrK9Jx8fHKMWmAWcfxrd/z6/u/1acRtd5tBZnG9398Li6buqs1I8nw2CRHbgTNexL4D8exwD+6oCVI527KFZQCmkXcYSOBkG0cBlxDxuNtm4mm+xEXl6ICevj5YWmYk40vNRnYXjfWKO31zBqOfqpxQdZV3y0J0qR4EExSdAV5jAXr808Ujb8J7oNWwdwBviG/d9GSlXMYNW7VvJTxy0tNNLdWi8sKikuIYQiIXi04EDenLqKRWuyr4OBD/pM2jdMj1HTD7tt7kycEwq2RcM8OTcTrtNCXOixww4oXV8G1aJO1531buuVHSoUffHIR4lupro8hFiCFvR7X7H1gOzqLc+TZ64pwvruQOupexkAQb58BBt0eQ== 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:(13230028)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(26005)(7696005)(8936002)(40460700003)(8676002)(41300700001)(36860700001)(36756003)(81166007)(478600001)(356005)(82740400003)(82310400005)(1076003)(70206006)(4326008)(86362001)(70586007)(54906003)(316002)(110136005)(6666004)(40480700001)(44832011)(83380400001)(5660300002)(186003)(336012)(426003)(2616005)(47076005)(16526019)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 12:11:14.6712 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dda589c2-52e2-4c74-319c-08db6e62c82b 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: BN8NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6411 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd_pstate supports changing of its mode dynamically via `status` sysfs file. Add the same capability in cpupower. To change the mode to active mode use below command: cpupower set --amd-pstate-mode active Acked-by: Huang Rui Reviewed-by: Gautham R. Shenoy Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- tools/power/cpupower/utils/cpupower-set.c | 24 ++++++++++++++++++-- tools/power/cpupower/utils/helpers/helpers.h | 3 +++ tools/power/cpupower/utils/helpers/misc.c | 18 +++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index a789b123dbd4..c2ba69b7ea54 100644 --- a/tools/power/cpupower/utils/cpupower-set.c +++ b/tools/power/cpupower/utils/cpupower-set.c @@ -19,6 +19,7 @@ static struct option set_opts[] = { {"perf-bias", required_argument, NULL, 'b'}, {"epp", required_argument, NULL, 'e'}, + {"amd-pstate-mode", required_argument, NULL, 'm'}, { }, }; @@ -39,12 +40,13 @@ int cmd_set(int argc, char **argv) struct { int perf_bias:1; int epp:1; + int mode:1; }; int params; } params; int perf_bias = 0; int ret = 0; - char epp[30]; + char epp[30], mode[20]; ret = uname(&uts); if (!ret && (!strcmp(uts.machine, "ppc64le") || @@ -58,7 +60,7 @@ int cmd_set(int argc, char **argv) params.params = 0; /* parameter parsing */ - while ((ret = getopt_long(argc, argv, "b:e:", + while ((ret = getopt_long(argc, argv, "b:e:m:", set_opts, NULL)) != -1) { switch (ret) { case 'b': @@ -81,6 +83,17 @@ int cmd_set(int argc, char **argv) } params.epp = 1; break; + case 'm': + if (cpupower_cpu_info.vendor != X86_VENDOR_AMD) + print_wrong_arg_exit(); + if (params.mode) + print_wrong_arg_exit(); + if (sscanf(optarg, "%19s", mode) != 1) { + print_wrong_arg_exit(); + return -EINVAL; + } + params.mode = 1; + break; default: print_wrong_arg_exit(); } @@ -89,6 +102,12 @@ int cmd_set(int argc, char **argv) if (!params.params) print_wrong_arg_exit(); + if (params.mode) { + ret = cpupower_set_amd_pstate_mode(mode); + if (ret) + fprintf(stderr, "Error setting mode\n"); + } + /* Default is: set all CPUs */ if (bitmask_isallclear(cpus_chosen)) bitmask_setall(cpus_chosen); @@ -123,6 +142,7 @@ int cmd_set(int argc, char **argv) break; } } + } return ret; } diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 5d998de2d291..d35596631eef 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -117,6 +117,7 @@ extern int cpupower_intel_get_perf_bias(unsigned int cpu); extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu); extern int cpupower_set_epp(unsigned int cpu, char *epp); +extern int cpupower_set_amd_pstate_mode(char *mode); /* Read/Write msr ****************************/ @@ -177,6 +178,8 @@ static inline unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu) static inline int cpupower_set_epp(unsigned int cpu, char *epp) { return -1; }; +static inline int cpupower_set_amd_pstate_mode(char *mode) +{ return -1; }; /* Read/Write msr ****************************/ diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 63c3f26ef874..9df9af8a969e 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -106,6 +106,24 @@ int cpupower_set_epp(unsigned int cpu, char *epp) return 0; } +int cpupower_set_amd_pstate_mode(char *mode) +{ + char path[SYSFS_PATH_MAX]; + char linebuf[20] = {}; + + snprintf(path, sizeof(path), PATH_TO_CPU "amd_pstate/status"); + + if (!is_valid_path(path)) + return -1; + + snprintf(linebuf, sizeof(linebuf), "%s\n", mode); + + if (cpupower_write_sysfs(path, linebuf, 20) <= 0) + return -1; + + return 0; +} + bool cpupower_amd_pstate_enabled(void) { char *driver = cpufreq_get_driver(0); From patchwork Fri Jun 16 12:11:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 13282733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15388EB64DA for ; Fri, 16 Jun 2023 12:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345260AbjFPML3 (ORCPT ); Fri, 16 Jun 2023 08:11:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345271AbjFPMLZ (ORCPT ); Fri, 16 Jun 2023 08:11:25 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2043.outbound.protection.outlook.com [40.107.92.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A05730DD; Fri, 16 Jun 2023 05:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwxAE6GQJBAv/x9mSuFpZq0YdMGkVt8g+JBJzqlIO48dpZePTSy1h2aTOCsSTNSKptbm71/CCV+5qe8ebzStRjx+/sSK8SInpIz6Wycn+Qr2iVj/IHALpQJBm1QI+fNKHJ89ul5gFjn9mbhNc+bLN6Px+EjLYBHoFpJ+R0Reh/chKjhxxG7BLT3jOaX1cN8I5dw5HPp5ussnKal1AcxVza/RXtqUFhk2xQZMUTyJeAFPybcl0I3+cA9QAzzqVcMLFfi1swBxliNoqhmldoGtyqQEKZ9/ORS4JeZC+saHzoz3Z8XVkAiu/86tqRf3aORQXoI2XcY0rANqJl8MOvUMkg== 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=gdjX15518sDy6igKp2883S0MJ5+0SWanq+D+82aCDX4=; b=C3G8gdkOgpS5N4Si+c3QhBHj+bLhX3bUvd+1rLOVx7HwVYbaHpQU7vp3ApLJaU7RXdjz5dPEAylUX3I3ZWgAj/5PD/lcpmVwp4a5dF9E6FVg1pfEpQQ867zDuCEiMP9K+ZJxAJkxr9tqrclAW9/PYzqfb7vVk0zhtegY04UGnIwou+noZkxLP4mdfEKgbJ+QR9R5DiUu8St3Zh+BT9Qj3iZFv+Ip9vcSHuC8WZbF/wGPaFFb/NwwuYdq2BnQH3KEDdQQuwhhT+MHrRspL5DjUHh5NA3Yb1S8b0HrjSIr0l4AQ8geHqhFkvAv+/Cd9YtvmtnIY4CRHrbHkcBxRbJGVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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=gdjX15518sDy6igKp2883S0MJ5+0SWanq+D+82aCDX4=; b=d2XiITTsrCeN3Ku7lOiRvlwZhszOHsTB9StL81rvpVyioU40op6VswgWyyvW1toBJGQc/RE8a8gNqe4snwt4JfFAweMSf8+YewBt2KkYdzH208iukXK09B8puHapA/15iUmQseqFlR7d+CFVdzE4+P6BMLHrTdBCfCHEzYGAh2U= Received: from BN1PR14CA0009.namprd14.prod.outlook.com (2603:10b6:408:e3::14) by MW4PR12MB5665.namprd12.prod.outlook.com (2603:10b6:303:187::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29; Fri, 16 Jun 2023 12:11:21 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e3:cafe::4f) by BN1PR14CA0009.outlook.office365.com (2603:10b6:408:e3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 12:11:20 +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 BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.25 via Frontend Transport; Fri, 16 Jun 2023 12:11:20 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 07:11:16 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny , Huang Rui Subject: [PATCH v2 5/5] cpupower: Add turbo-boost support in cpupower Date: Fri, 16 Jun 2023 12:11:01 +0000 Message-ID: <20230616121101.147706-1-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616120620.147643-1-wyes.karny@amd.com> References: <20230616120620.147643-1-wyes.karny@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT035:EE_|MW4PR12MB5665:EE_ X-MS-Office365-Filtering-Correlation-Id: fec781fe-c496-4af2-5942-08db6e62cb8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: koI8eecrAvHanNVWfG8FK+Dc8wnfGjzPPslS+KNNWmhCyNX4jpedCk+1BlQ2naHI9O2ADlujJ3HsvrHUQVkpjUyCZ0sxSnR76dI08NGcAIrjbgk5WGnbYHH94x8T8FfiHi1khVfD7yGb+Pyu4NtyY+NoEr3bw/tJGaWU/evLBb6TtfucOpXafuPpE85JPnzPSKBDTng+MGD9/h6IdaZJYRAdAhhRXAf07uxm4gfxBmS9kYLiIgoLNzR5r5YFsf3zGyvIi1FFDfe1TqXKYJYPyQRaOwrxDmHlFpElPgC9J1A0cyQoWFtMXApcw2I5wdbQrVEfIlLXVBMo0UeGJZu0UEYHGBa7ghQebkdVgqP/x7TbhxH9vceEF0hoB1Bcm8qoYNJUBoAnh7cZIAJsaFNA1sf5nq2r7KQFJsZJ8LETwiV9FVlXmYKkVdA3aO4Sms55ZBrvtEnwDDLvyj+lr6tLIC7H/8DV7BzOWiFV2LxD/+x6S0SgddsFVwN+hMI8YphZ6/Y/m+/9Vh66wyBTvWdxztd2+T2J/l+W+1ZI5JfhWdJCD4Swuo+jtIpoa8I9x+VIOGEzz5KynoejbjwsgkfIXViUm45wgJtAGeX4xAYFAgW7JjOhju5xt8X2tHe7CLpto3/2dG7NVqJ1L04IhTwU2rT2yu4Hyz0ipBMgvvUUJL8O3VnmwnkbWTCbFQ4GQ/3NLkRVorvfRpMVUk09lQ5Tq+pGbVWRKaQyY+qsvnF8Ly4XweS+nDmqpHvjAq5Tu4Zr9sbCgDNetU8e32+Z9SynCQ== 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:(13230028)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199021)(36840700001)(46966006)(40470700004)(26005)(1076003)(36756003)(186003)(16526019)(478600001)(40460700003)(7696005)(6666004)(40480700001)(2906002)(316002)(41300700001)(44832011)(86362001)(5660300002)(356005)(82740400003)(81166007)(8936002)(8676002)(82310400005)(83380400001)(426003)(54906003)(336012)(47076005)(2616005)(110136005)(70586007)(70206006)(4326008)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 12:11:20.3608 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fec781fe-c496-4af2-5942-08db6e62cb8f 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: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5665 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org If boost sysfs (/sys/devices/system/cpu/cpufreq/boost) file is present turbo-boost is feature is supported in the hardware. By default this feature should be enabled. But to disable/enable it write to the sysfs file. Use the same to control this feature via cpupower. To enable: cpupower set --turbo-boost 1 To disable: cpupower set --turbo-boost 0 Acked-by: Huang Rui Reviewed-by: Gautham R. Shenoy Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello --- tools/power/cpupower/utils/cpupower-set.c | 22 +++++++++++++++++++- tools/power/cpupower/utils/helpers/helpers.h | 3 +++ tools/power/cpupower/utils/helpers/misc.c | 18 ++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index c2ba69b7ea54..0677b58374ab 100644 --- a/tools/power/cpupower/utils/cpupower-set.c +++ b/tools/power/cpupower/utils/cpupower-set.c @@ -20,6 +20,7 @@ static struct option set_opts[] = { {"perf-bias", required_argument, NULL, 'b'}, {"epp", required_argument, NULL, 'e'}, {"amd-pstate-mode", required_argument, NULL, 'm'}, + {"turbo-boost", required_argument, NULL, 't'}, { }, }; @@ -41,10 +42,11 @@ int cmd_set(int argc, char **argv) int perf_bias:1; int epp:1; int mode:1; + int turbo_boost:1; }; int params; } params; - int perf_bias = 0; + int perf_bias = 0, turbo_boost = 1; int ret = 0; char epp[30], mode[20]; @@ -94,6 +96,18 @@ int cmd_set(int argc, char **argv) } params.mode = 1; break; + case 't': + if (params.turbo_boost) + print_wrong_arg_exit(); + turbo_boost = atoi(optarg); + if (turbo_boost < 0 || turbo_boost > 1) { + printf("--turbo-boost param out of range [0-1]\n"); + print_wrong_arg_exit(); + } + params.turbo_boost = 1; + break; + + default: print_wrong_arg_exit(); } @@ -108,6 +122,12 @@ int cmd_set(int argc, char **argv) fprintf(stderr, "Error setting mode\n"); } + if (params.turbo_boost) { + ret = cpupower_set_turbo_boost(turbo_boost); + if (ret) + fprintf(stderr, "Error setting turbo-boost\n"); + } + /* Default is: set all CPUs */ if (bitmask_isallclear(cpus_chosen)) bitmask_setall(cpus_chosen); diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index d35596631eef..95749b8ee475 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -118,6 +118,7 @@ extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu); extern int cpupower_set_epp(unsigned int cpu, char *epp); extern int cpupower_set_amd_pstate_mode(char *mode); +extern int cpupower_set_turbo_boost(int turbo_boost); /* Read/Write msr ****************************/ @@ -180,6 +181,8 @@ static inline int cpupower_set_epp(unsigned int cpu, char *epp) { return -1; }; static inline int cpupower_set_amd_pstate_mode(char *mode) { return -1; }; +static inline int cpupower_set_turbo_boost(int turbo_boost) +{ return -1; }; /* Read/Write msr ****************************/ diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 9df9af8a969e..fc822a0e6b7b 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -124,6 +124,24 @@ int cpupower_set_amd_pstate_mode(char *mode) return 0; } +int cpupower_set_turbo_boost(int turbo_boost) +{ + char path[SYSFS_PATH_MAX]; + char linebuf[2] = {}; + + snprintf(path, sizeof(path), PATH_TO_CPU "cpufreq/boost"); + + if (!is_valid_path(path)) + return -1; + + snprintf(linebuf, sizeof(linebuf), "%d", turbo_boost); + + if (cpupower_write_sysfs(path, linebuf, 2) <= 0) + return -1; + + return 0; +} + bool cpupower_amd_pstate_enabled(void) { char *driver = cpufreq_get_driver(0);