From patchwork Mon Jun 19 19:04:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 694371 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 3AC03EB64DB for ; Mon, 19 Jun 2023 19:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231793AbjFSTFv (ORCPT ); Mon, 19 Jun 2023 15:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjFSTFt (ORCPT ); Mon, 19 Jun 2023 15:05:49 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39FDE101; Mon, 19 Jun 2023 12:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=djLcdE/w8l8lMjCSJdWbDnD4iOqWWqV2P3e7oL9QTpvtVYEo/6iV4KcAu6CpP8v5sAY6Ow97xnNsjpQw3G/YCKos3KITXaHEpw1ykDf+mIkmb7BJqTGUIQF/TjeoVqFFD5Lqz9Ukbw8nay/vSBZok9Nt+ugHUvCXErVnnuARld8uc4zK/luXgKLa+FWQY9j4LY9vd0ITjHxx6PRz7eq+kEk8/qm6nn44noDaVaWqql7PUHW+4UfprRZJ9x6ENnLQN/fkf1x1Nt84vWk/yMpI+ccOy2+3l71X4juZqV+023Z9vonpf+V9QQNpsJJGBaB6Fw3nGy5AKmXAe6PbLqgC6A== 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=bHcEL9FAExU/6yuRYsG+FsS2p0pbRi6Ph0vnHhf1Ffc=; b=nUOA5iQobtjfx1JIEq0CU9ZLbbADJ9mdblfmeaIkBL8oh4xj+uvRsEqEzc06CuA5LXSmLBY4haRmYKJZx5yqCL4UW5UnQRg20ggoWZkrcYzFmiUxZh43GyB0fE4NkW/b/8RTyB/kg/j6RDSZkfEyBevX+r7QABr0XZPXlSaubPN4aU0qkmDboRsCtxOAXTPnHdfOB8KElUYCmGz5/JtCzXiWy10iFJhaaN7Y5hlrdCusQZbg/hsjp8B248KKyZcEJsVbStky7pttZamI3tK30q/C6vDKYuaGKCLq4a0hLHdC97Fu0BB8iRNMEKWV8DJXTHnhM6k8w2bbs25zv9Jthw== 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=bHcEL9FAExU/6yuRYsG+FsS2p0pbRi6Ph0vnHhf1Ffc=; b=3u0RnCcNBItjfNLSBR0e2qzPFCwJxnIHc5EfcRCMJC8JEjCIi9nVHuPId/ir7ZZQP/N9iECcj8diQYp/rQZoSmD6q4nYqkBmLwL3sTmmtqJaOH4Zqas+9vxqV17gOj2Y4Wrypoe3Maemo6gDL0vUPUkjsbc815St2hD9Q/QSGrs= Received: from SA1P222CA0116.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c5::20) by SA3PR12MB9105.namprd12.prod.outlook.com (2603:10b6:806:382::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Mon, 19 Jun 2023 19:05:44 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:3c5:cafe::7f) by SA1P222CA0116.outlook.office365.com (2603:10b6:806:3c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.44 via Frontend Transport; Mon, 19 Jun 2023 19:05:42 +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 SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Mon, 19 Jun 2023 19:05:44 +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; Mon, 19 Jun 2023 14:05:40 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny Subject: [PATCH v3 1/5] cpupower: Recognise amd-pstate active mode driver Date: Mon, 19 Jun 2023 19:04:59 +0000 Message-ID: <20230619190503.4061-2-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619190503.4061-1-wyes.karny@amd.com> References: <20230619190503.4061-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: SA2PEPF00001507:EE_|SA3PR12MB9105:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b0fdbca-030d-4b65-9fbb-08db70f82ee7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l/bsir/Trezz490mtsIW+fMN1RdRsCs6A1KY/pgP++Z2rxHRtTncX/zTnAWJc8VLcvN6so4Fod1deS5vF5Dt1G67cV+8e/gMV+i6Zlo4ju/oFJ2Vxdosy3xc328utzxKVTcG410O6+T+88DxbhK11iR/bg9L91r0M0UVcDPrjaXN6gvzgy0DpFm/JIfS4UXrvlqSJJyiPCIuPDRoUDLoaVeN5quT1l0EYc0vMfTIzsBUn/EsSBRBDimCfyc0ieo2nrqzFFBrXQM9t5FX/Ww/U7Sx0hx9GxByFy2cS+GU7N8pvn7bi9yOaRCDbdEyMbxjcvvnoskwXm9ygUV9uUkq+dS5/q4DdBoiXU7WmUIk/45Ns7TkNq2uahqI/+YaUicWMT73jzW5N0oCsVMCea/aOgO4YfiEB3Cr0Ruyszpon0xBwA7UGAXKeCNMA5crTrELFYwTYooRoKA+1iDR1I6GorYhw7U3G9fJrZmZP1HCaxWmlQaSIUCHc8aPIWddiuvNJ0sc2kDKbTOhwgIxn6L0bFt4K+9KfcQ+NV77q1slolInwHdAmcXgbcIae00c8dJZqKx9vb4TzF41Sf14iYu6C0VlUQxtStMtve8ZmilQenxZ2EDodwFcDpBQTcVZlh7R/Tf/pe11M+Iwkvr3qbl5SGWsCi9tigJ74gqvj7whz2dvUfLel+63yHXvkwvMnkb5r5pL5QnT75B0wG1Nc74oKWt7IBx+r1aQOnHOPdjySdtrGMLCDJPmSSiaP3haclYCJTCQ/Ex/wmRJv1Hf4IensQ== 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)(376002)(39860400002)(396003)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(4326008)(54906003)(478600001)(110136005)(7696005)(40460700003)(1076003)(26005)(16526019)(186003)(40480700001)(6666004)(4744005)(36756003)(2906002)(8676002)(41300700001)(8936002)(70206006)(70586007)(316002)(5660300002)(44832011)(82310400005)(83380400001)(47076005)(86362001)(426003)(336012)(81166007)(356005)(36860700001)(2616005)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 19:05:44.3564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0fdbca-030d-4b65-9fbb-08db70f82ee7 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9105 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd-pstate active mode driver name is "amd-pstate-epp". Use common prefix for string matching condition to recognise amd-pstate active mode driver. Reviewed-by: Gautham R. Shenoy Signed-off-by: Wyes Karny Reviewed-by: Mario Limonciello Tested-by: Perry Yuan --- 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..0c56fc77f93b 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 (!strncmp(driver, "amd", 3)) ret = true; cpufreq_put_driver(driver); From patchwork Mon Jun 19 19:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 694682 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 6A66DEB64D9 for ; Mon, 19 Jun 2023 19:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbjFSTGT (ORCPT ); Mon, 19 Jun 2023 15:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbjFSTGS (ORCPT ); Mon, 19 Jun 2023 15:06:18 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53B8E65; Mon, 19 Jun 2023 12:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aUuzT1DCh3iaRxUOr4ytvTeTAwDrPy+luTh3+FcgE+96/uOEN+7P1KMeOQuKbMz58X16oUc2PHWhgdskkP5B/Outlv1iUqsM9M1pub4WI+vKluzZhZpN43HMbGRQtf0UfLm70hJNZRiHJyiN07RgTUPXV7M9kwOjswA2xIlrk0RNtrGH687gst7KnuUZPyj9Isch0Ee9ZaurRzKix83zE/PohZuLn9wrhNALkzXuK4E9kcESjtLAcNOB4YrG4Ro1PtS+n2F13mhJkcRQ9OvxiH7kqfZqzMLQUcUMHGGXcUgptMWOkt5LyECllP2ZhirTvHvSreIZOi8UDsqj6JUXLw== 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=NQlqZYlreNSY3LyI7KoCib8kaJACbv3iuZxvQEl5aYM=; b=j/2xnWaxSdgFQUBRrC6Rk0PLD7ELtZXwm2Egr+NplBGvSjC9Es2g9NP+ozHaG9tKyK83d01hHmgSzNbZ7ZB7xXGX8MgMtR/4FtYLOENwt827Ja770HWpkUV+8hJTgXLEdtx+FNybfmq78XGS5mzXUSmayVs57tP+tgPqTNz/GaqCu78W4/MWQmpiE89KKS6szEQkckp04hwABXPE2GC5JVEjHe4I2vQ+z02yG2vt3QBsa4Oi+MBHQ7SU+kyCrXJM9cFKKnU+eCx2+9J1lsVSRaUCqDsomyXnahEOOE/IIT7sr5nd0shXVMJH0lTBfCm4iKWBCx0W95yGBYQGH6wvpQ== 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=NQlqZYlreNSY3LyI7KoCib8kaJACbv3iuZxvQEl5aYM=; b=0ZgYgcujxJfH4/xPl+bgfWoMd2mlXeT3C/VyuHzrg3QOPHg/4gSQZzqO4B6SeLTdAgGQSZvHmyKcw7ulsk2BAldx8zXC3sST10SXq6vbj5YiqpcDX+/YNBAWLGyXMqNoac1zZKOJoWDcj3h0vT60VSbYL8GWw+neUfXgqc9IleE= Received: from DM6PR12CA0022.namprd12.prod.outlook.com (2603:10b6:5:1c0::35) by PH8PR12MB7448.namprd12.prod.outlook.com (2603:10b6:510:214::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 19:06:08 +0000 Received: from DM6NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1c0:cafe::1e) by DM6PR12CA0022.outlook.office365.com (2603:10b6:5:1c0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:06: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 DM6NAM11FT041.mail.protection.outlook.com (10.13.172.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:06:07 +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; Mon, 19 Jun 2023 14:06:04 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny , Mario Limonciello Subject: [PATCH v3 2/5] cpupower: Add is_valid_path API Date: Mon, 19 Jun 2023 19:05:00 +0000 Message-ID: <20230619190503.4061-3-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619190503.4061-1-wyes.karny@amd.com> References: <20230619190503.4061-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: DM6NAM11FT041:EE_|PH8PR12MB7448:EE_ X-MS-Office365-Filtering-Correlation-Id: 42badac2-b557-4164-44d2-08db70f83cb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4DNQltl/dMjhRtYixeqAwHYVMTLH6MT+U98NHxZAIQHqdk+99WkX0Ybnjxe5XVFQoMaNIn4Eihyz2RwB8wXNJoASyRAVQxhkbSPiUA7e9LcNQ5i2HGsabTfgZwENiiLg2qQb6si46v5EsajbD9TCnYLUGdF/M1Mnvl9MiEnlFuyjJjit9as+0Ojz3nSIuNYKMX1BHE8Ee6pWIIHC/VjQ9J7LRHwfnwZdFzN/TB0+9havEJtTy6wAUF2thQUikomaTu/ITrXfk62Zkw2IF5BVMsQ7n9uOayKNPllyqEA0vuaifCgXcV1wH403Ow6d5Bz3sFpANOEjaMvoF7yzEBkI12DzTxkEPC5ARkPkpnBeOWzs3RUHtGOpIbG2O3M0Q4hihrbbLiDxvn4v+iokxIVDj8Dw/Zho8M5DYKs+oJA0Wqtw2RiSoBZgnOXfZdD+El67gQD8CNfIl1Kljg4IDW+DpmSl4enRVw7DENna/khQ7urz/LFYHomYOF2Sd4mNUAiN51kU1iu/gZgJ1VHDY07wpibe4i5HeYqspnW+9dpuZr86bzHR2DNJFl/E2MqLf6kWbrvKoLZsamz1c36WwbsmhbLjQV4LvTj7TzL4FRCrN6P3D8qKeDf5xdnfPcgyimn0oVuETIyrihLMwXZWFVp3cuJgxEZ++pK1E9GjYEwSHYw3Jt4hPXf5pgGgVj8+DSCphlr7R7CuSSgD/n4T511Itij+U912uIx36YBVGCKM9Wa8GsO5PPgb4coE/MEwkeOeiaXkTdFCYUMtcRRcG9gdxw== 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)(136003)(346002)(451199021)(40470700004)(46966006)(36840700001)(478600001)(70206006)(70586007)(36756003)(8676002)(4326008)(41300700001)(81166007)(47076005)(356005)(40480700001)(2616005)(426003)(83380400001)(336012)(82310400005)(44832011)(86362001)(7696005)(5660300002)(6666004)(2906002)(110136005)(54906003)(316002)(8936002)(1076003)(26005)(186003)(16526019)(40460700003)(82740400003)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 19:06:07.5251 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42badac2-b557-4164-44d2-08db70f83cb9 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: DM6NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7448 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 Reviewed-by: Mario Limonciello Signed-off-by: Wyes Karny --- 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 Mon Jun 19 19:05: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: 694370 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 8468CEB64D9 for ; Mon, 19 Jun 2023 19:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbjFSTGj (ORCPT ); Mon, 19 Jun 2023 15:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231698AbjFSTGj (ORCPT ); Mon, 19 Jun 2023 15:06:39 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2057.outbound.protection.outlook.com [40.107.243.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A906101; Mon, 19 Jun 2023 12:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVgpebMkyxGpZKHvZdv7z0kIvxPcKSYMP6YZgG7AOL9olikRtNv/GQzuC1SpTOwP+fPk+6x6vM2HGSZTSWI5MmwKUQ1JjVcX+rFro+gH76939reFwHi4079MfTEKidQ82Tm1lKBwetUbDhoNQom9w599VedEBJpB0RKm5v9WsOnnDCmU2p6ZG2Ie/vLN5h8n4JhqZBc0hP3XusqghXr0LnYDDleDg+W3GlpiO2LZAH653huHvFIu7b9n3VbsM0h2j5rBtL8zrawCtSx3iweGhj2U+RyNrAYhGiyZ+jAqrh07yAqxha6gTUWPSGE3dVXQLLTf6iHOPjQ7y7amzr6tYw== 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=VGBYuDo8QdbLUjo7rbf9sUcTMSouuHaPzszn/tX4Fhs=; b=dsgYIzkxLpjk69/JT14Q8nH8t9PzG3xCYt1hzji/mFQkjfYvbq1X+IR1jvpaoYP93ckMzobOmxzLuECeKN8yt/+Bsa5zyAfOHIGKpNfICUnYXRsxfjfutwEbEW31/LFMcYtnESjjKoWFrwNRXvqAOOeG/J9jN/1XUiIJbzQTj+58jHj+aRDV6372iCmflV4/nQX7JbLONGIqrOaZjqR+HN1JHaQFF37ilaD89zk6aD3oBLNSzyzOA7A/aRqqHcxFUQPRrqByCwmwuMrdE5XmXDOYOo3KxsYX3zunuNIvBygYbQRJsbEy6AjqWIZiCqCj+MlCbSJTF/AudKWtxMK4EA== 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=VGBYuDo8QdbLUjo7rbf9sUcTMSouuHaPzszn/tX4Fhs=; b=pX8OYU3VYHRWSgMnPV3e5iru4hPSrOI691yK1QIWMLYacXjFhiZpA1NfLV+fJdP+cUukvFqesdxjmSRCFfBLQeh+q5+F+Ro8RD47qhDqTSv6OamMqgRZGSKCkIcxTLF65v1c6NZ41C1hcsbOZtI8F4UmtlGdYL39jQKipeBdX4k= Received: from DM6PR07CA0055.namprd07.prod.outlook.com (2603:10b6:5:74::32) by DM4PR12MB8571.namprd12.prod.outlook.com (2603:10b6:8:187::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 19:06:31 +0000 Received: from DM6NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::d7) by DM6PR07CA0055.outlook.office365.com (2603:10b6:5:74::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:06: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 DM6NAM11FT091.mail.protection.outlook.com (10.13.173.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:06:30 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 19 Jun 2023 14:06:27 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny , Mario Limonciello Subject: [PATCH v3 3/5] cpupower: Add EPP value change support Date: Mon, 19 Jun 2023 19:05:01 +0000 Message-ID: <20230619190503.4061-4-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619190503.4061-1-wyes.karny@amd.com> References: <20230619190503.4061-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: DM6NAM11FT091:EE_|DM4PR12MB8571:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c39d282-5eac-468a-8b7e-08db70f84aad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3h67hhOZy1FUk9XZUEud82Ub1KnPLbXLRbjbuFuY+472DXaxPiU6jop68tAhmJld35cvBqieJSI3ZMtfc8ZYcF1GLWyJnWNv+tEZAjusf8KT3SN1Yav2ueFRMHVCs+Wi70RcXH2MoM8kguwE2iPLai5xf3S11gXOew8YgJXS+DTHKnDHobnYH8pwpcpMb4B9baLHFP2LTN71PZkiXx+AVKypryalTBuvpqTvwC7+vT5VSh8E9AUuN2x1b+U2I8GlIxlcD/mjlH8W8tbwSp+hzx/mKAJ6O9Zn/MBgZOwMSiiI0xE0Xncst49dBUtJnlW0bHNkEm1ewlvZNNlZF6TeKETp0Gvqu7Nras3OFRrwP4DLChvAj4i16T8UoWMVcqX2eVz2mXrNJvOBjzxCTFT+tPIqfugkpvDlDKXrtnGGgo/Y1B0K6slZF3PL8DBolL2HRBRfMqknXCwNJkuocF4UvCMWd1sFuad7WNEEIcte8ov/+bp5TuNSbV7ktlaDKblGKQcC9QyTPcPcg3eULPwd7MXXFRq7flxQsAx5EoZLZlJl4lCFryQ5K7Z4UYdfDuGXkIA2OYThJ+DFxvjCZKPcKv4OKechM1NtsTw/0EhvCKvNimm+w7dRaPYa1o7zprmmxIcE5zWGQD2O2UdoNfdr8399Y9vD+Ymb4e0c9dSvvfoILQO2YKOZkBInKOZ/D80D/NhStGoe1v0eXjOSjNupBlS24PA1iRtucNngo13roQRBeqTY46F+U5GZaNCNlaS3d9evOEIXu7BcKNK2AKIzEQ== 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)(376002)(136003)(396003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(5660300002)(44832011)(8676002)(8936002)(70586007)(82310400005)(4326008)(70206006)(316002)(41300700001)(40480700001)(86362001)(40460700003)(2906002)(36756003)(7696005)(6666004)(336012)(426003)(186003)(16526019)(1076003)(26005)(2616005)(356005)(81166007)(36860700001)(83380400001)(478600001)(54906003)(110136005)(47076005)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 19:06:30.9207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c39d282-5eac-468a-8b7e-08db70f84aad 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: DM6NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8571 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 Reviewed-by: Mario Limonciello Signed-off-by: Wyes Karny Tested-by: Perry Yuan Acked-by: Huang Rui --- 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 0c56fc77f93b..583df38ab13c 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 Mon Jun 19 19:05:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 694681 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 7DA28EB64D9 for ; Mon, 19 Jun 2023 19:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbjFSTHP (ORCPT ); Mon, 19 Jun 2023 15:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbjFSTHO (ORCPT ); Mon, 19 Jun 2023 15:07:14 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2085.outbound.protection.outlook.com [40.107.95.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314B2B7; Mon, 19 Jun 2023 12:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B9N3oYt8/a4HuHmpYr6hjFHI5HAYgSdZmlX1pRPkQcfyFWZlnpCTYJURcUr/QjTZs5hzqlqrjnItgXDvVkcbNFpD7O2w32FU718Aeuds0Cl3B34wxuL67AmN2O1N47jvgo2cGlPjYbk09EJ4KASZoxbMRzCiJi0mpi7WyUnHBFDy6XgjVPomIZDK/XpwKIf97gXYV3qPBupcD2C9dxVuN4fCNdr4Wzwtoa8fy4omh2eHmZSio7mLOkjCRYVghV+DgRVZGMklCWID4rnKTfVkKj0I5lLYvV0ASAcR7V9y5T6fP12efrBvC/e1mFbya10kWgD7U/Uf0tuwtaYVmg0xjw== 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=k97+rv59nQ+x+6738TZ/YVw5sNsK1eeN0TXOGfd8xic=; b=By0WV96gOxQl0xRWjVueBr+cdB0KLX0cKo3o6p47c4byWLF8ouTSJ2BRW/uFEheFGzDbkMnPXELwdHagzbZzsQ6AxfBxVo07MekYfH0k3SXdYQRoNpmP4saC7ZZk/fWPP+p3NBL+A/HPXsrS0gzYmYP+qX0zM6cSST3M7qnuN6IR0l+n/3cCG6OPQQQcs1p//hIuoegJIVzHczMPxOEFyAXBBsHVMNDLBEgO8kLg/bYvdHI3m5Y1PE02/o9PgJHrrKcmjryQU5YsoifT013xhrS1qCbWsW8WyJ9z9yXWvJK9z89tKQeve8jGt0w4Opqb7UVgw8I1uSglWcOiZQM3qw== 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=k97+rv59nQ+x+6738TZ/YVw5sNsK1eeN0TXOGfd8xic=; b=SS4XhM8bK5jzn0Vz7PW+UFRYMalGJK5pGJ5Kv3cGP2d9zxQNt+VQQi/QcWx+QftFPI0mvkyLAMaGIGfLs4TvnqVu4r8exT7+JdnizY7R/UWgXAjFFVQb+q6cKy7qGfwq6Y6RNSSf6i10KaMj51XT264MeEfUmji+CT6n39H8u0M= Received: from DM6PR03CA0097.namprd03.prod.outlook.com (2603:10b6:5:333::30) by CH3PR12MB9098.namprd12.prod.outlook.com (2603:10b6:610:19e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Mon, 19 Jun 2023 19:07:11 +0000 Received: from DM6NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:5:333:cafe::14) by DM6PR03CA0097.outlook.office365.com (2603:10b6:5:333::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:07:10 +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 DM6NAM11FT048.mail.protection.outlook.com (10.13.173.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:07:10 +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; Mon, 19 Jun 2023 14:07:04 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny , Huang Rui , Mario Limonciello Subject: [PATCH v3 4/5] cpupower: Add support for amd_pstate mode change Date: Mon, 19 Jun 2023 19:05:02 +0000 Message-ID: <20230619190503.4061-5-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619190503.4061-1-wyes.karny@amd.com> References: <20230619190503.4061-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: DM6NAM11FT048:EE_|CH3PR12MB9098:EE_ X-MS-Office365-Filtering-Correlation-Id: 61fac32d-d12c-4f75-dd34-08db70f86231 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D+yYFnbmuAJ63Xu4fDK/QCy3F35fIBWuPRp1Ja53V1UNMoQjB4G2qpJ1QEN9fHwM558Az/gD7iGow4MtVjZF/rVOm6/crI5igQFBcq9LQQ4UqHiOhZkZbOSmCT036VCICSKoDV835hiYVLhHx/B3czcG+vj6ygMxmfRdOZeMKghVtfI5IDUQKmst/IYJ0FbEwTCmQIiCfbqYxM5OQ4Tmu4/UsYN2yddWr3k576kiIOhiiEHLpSUGMTVTGJLjB0Pi+CPliZpaW4Tb+r47xcjBhMGVcqpa5Bvgxd7JnsVCM8+XAWUkeCB6+IdrqLpOeLaDPTTa6Du0nOdgGtV7FV+YhPLcpSf1bTNyvRn0htl1neWkOlStAobRx8XJZcitN/JKaQyUgAFMrE9RZXGPbgrq53mWPBdFf2yD7hk9AqUU3gxDLEYqMJ+89+uGvkvVUlw/F4LO7OVmXAuugSbx4dRRIBUyuGyFQ1pPRIJxm4gtu1TmNV1/fLZ3F3harXKTnJqjHuJ9AAlZiyjyFQbUmOHOt1+Y3ei4gjhiHjKWi+pI9OVyiDlIdDtR+faaQh0L8Pe+o3gpu8S3JlF5IghMXi4owXu9tgYUeY+VV5k9aqFMf7QGQX6ynjWbCy9ZsQzUZ7iyB5T45h2wqk7kq5MhzOy8nWvmJP7RUmIOh0UW6HTdjwKckRc4gJOSM9MRr4CAXfUAZ7KmK9Qz07S4YUvyZQfy2pzNHvSqEZ0osXGKvrLjTPNZk/OH7ljvBHmRXCyijxBjNfzaMV2pvaiXo82UOIA1oA== 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)(136003)(346002)(376002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(70586007)(4326008)(70206006)(86362001)(36860700001)(82310400005)(47076005)(81166007)(83380400001)(336012)(356005)(82740400003)(2616005)(426003)(7696005)(26005)(186003)(1076003)(16526019)(36756003)(110136005)(54906003)(478600001)(40480700001)(41300700001)(8936002)(8676002)(2906002)(44832011)(316002)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 19:07:10.4067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61fac32d-d12c-4f75-dd34-08db70f86231 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: DM6NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9098 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 Reviewed-by: Mario Limonciello Signed-off-by: Wyes Karny --- 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 583df38ab13c..075c136a100c 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 Mon Jun 19 19:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wyes Karny X-Patchwork-Id: 694369 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 CD87DEB64D9 for ; Mon, 19 Jun 2023 19:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231247AbjFSTHo (ORCPT ); Mon, 19 Jun 2023 15:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbjFSTHn (ORCPT ); Mon, 19 Jun 2023 15:07:43 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582581AE; Mon, 19 Jun 2023 12:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YQwJjY7ivxr5l0LR+o+JA+V2LoYqpXMEqM1Tw4G2XeYFmrIgt8jD/ejWnp4gt4oYmuB9dPE4SHqcc1beEE2mEctPBox/2zXsB+mi66OpUasV/w5LssJxKaTM4XJZ3osrobC9HgEdmsdpl2VFef5cH6EDEQD+CNV2dgtFUP6VLtgFKDta0Uc4bgM2q8hqP17Gq0It1y2AxWId93kDpejd+3Hc5YXRlJZGR3F6QIJ1uE7FSkml1eA7wf0BUedIdA2lmMRn0COfbfKhTc4h3Dzgn1rtgeLoH7GcHSSj4BA5EyjfBFfVgFi2iixrwFmdJUrXQKU2weaQGyoNK4ZJJAShag== 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=lb61VrCRar2xVQyym63bNwofAPs7QOgKWrlNAW+Nw9k=; b=kkN/CR9H7ha40dlzJPnhKpgs0SbQjhEDfiEZmePFj/KJaTOJ9QSehKXu4HJ6wGu3E+ZQHawlzSGyvG7vjoPSQIpHTAEnP0jQrtLKHEu5huFPYRl5qBRTTMur+2jk+VM4HuyYeXtTgDvkv/OWyhvHg6lIh7N+g4FZ1S7oM3dqp+PrVENPmAGCX7xYYwCtNOt+t15jLkrKJgCrKjsypQ72QTDGayH9jiQCzttjc05tX1EVDdZYgA1Z3mIFVAnpcQxZP+g9Y1nCfb29wC6OLN3fiCklsUUn1X7BaJY6OHLh5cVgG6eulgFOzZytQ4/1DT0r9mXe4jyQTHyeVitx+w1/5A== 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=lb61VrCRar2xVQyym63bNwofAPs7QOgKWrlNAW+Nw9k=; b=tchLXv/gWgjmaQBKpATu1SwGBsP4QKsRNTIatXJYMFnqB4vdHsCbrwXPbTrtxECwW72p5eKKX4rLxruJr09z7syniYqi58FgVtidNr66NoJJg3sXllEfp4qmc+L8IqWXy0oZcLipgvRstv+CZgyo5hR2YwMGLdPxAgnk0UCVArA= Received: from DM6PR06CA0064.namprd06.prod.outlook.com (2603:10b6:5:54::41) by DS0PR12MB7746.namprd12.prod.outlook.com (2603:10b6:8:135::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 19:07:37 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::cc) by DM6PR06CA0064.outlook.office365.com (2603:10b6:5:54::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 19:07:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.35 via Frontend Transport; Mon, 19 Jun 2023 19:07:37 +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; Mon, 19 Jun 2023 14:07:33 -0500 From: Wyes Karny To: , CC: , , , , , , , Wyes Karny , Huang Rui , Mario Limonciello Subject: [PATCH v3 5/5] cpupower: Add turbo-boost support in cpupower Date: Mon, 19 Jun 2023 19:05:03 +0000 Message-ID: <20230619190503.4061-6-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619190503.4061-1-wyes.karny@amd.com> References: <20230619190503.4061-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: DM6NAM11FT046:EE_|DS0PR12MB7746:EE_ X-MS-Office365-Filtering-Correlation-Id: 20071c42-e5fa-46b6-5449-08db70f87265 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fv+Z5rPbRVpjddwQat3RmQ96VbcK8rxTov9jdfsG2JNBJavd9lInDx3UAcGQ9tINJwAfdIUb66I81GAKPe1ixcQg/7TCAodMU28c2RWowy+RacRLYAB9iQEC9dwWpIstOik55VppFKgDi6T3K8aiMXw5roNBw5p6e/0/1y1k5XrduV45UqZGp459DnFf9tGtwaqBqLdbbQXZAZHig8D8pbiO8NSmHk5nQuXx+mNtDEGb0xuBBsU4l1kazem8EhdA8u98rLMuyI3tlH1eb8xfMJhrvrPlGS92tFflmo9i5frPjTTNbpIdTj0g/lN7i19BigmVf19fOtiu3IMb7HD/tRlJldjNxv9dKFF4X/zXcnJ8I4HkGI8GSQfmmnbU0c640YwVQp7fg1W6ZKd9Lt3BEj/mT4UztpctszggpKz1+tfEgP/ghTHSBeyu6lS3dB5rbItnWOeQZRIvxo4eMuWs4opuvPMC1NJrM7b1yuhqGflawCpARaqhezW5NCkrhCkvi+JarS6bc59XnZCAJbDuSkfBoib2kS9b+5AX22EwYV3Io8d8KXxOx307fezBZ+3PjdNeux3EjdKDe28wsC3T2ehoAT5QJi9fYwZXyBD6/dr3YjwqZNEWujX11TJK+2bvrPyZ7S7Pn6EdF5992GkrfmlzFkESzSPaevpUZxxAOHSA6L85tQy6O7wEsnAVU1kduvyKZsg5zWagKGO1TidulKMkytq7rrkC+ZK/Yvz9GI/Qrqwtlm9kvoKp0CahuMPTXQSrm2aVWCPpMbz+Sn8B/Q== 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)(136003)(346002)(376002)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(41300700001)(5660300002)(44832011)(8936002)(8676002)(2906002)(40460700003)(82310400005)(36756003)(40480700001)(86362001)(1076003)(26005)(54906003)(186003)(110136005)(478600001)(16526019)(7696005)(6666004)(81166007)(70586007)(70206006)(356005)(47076005)(36860700001)(4326008)(316002)(336012)(426003)(2616005)(82740400003)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 19:07:37.5719 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20071c42-e5fa-46b6-5449-08db70f87265 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: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7746 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 Reviewed-by: Mario Limonciello Signed-off-by: Wyes Karny Tested-by: Perry Yuan --- 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 075c136a100c..76e461ff4f74 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);