From patchwork Wed Feb 16 07:35:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543211 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 CBCE4C433FE for ; Wed, 16 Feb 2022 07:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbiBPHh4 (ORCPT ); Wed, 16 Feb 2022 02:37:56 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbiBPHhu (ORCPT ); Wed, 16 Feb 2022 02:37:50 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2057.outbound.protection.outlook.com [40.107.220.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A317199D6E; Tue, 15 Feb 2022 23:37:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYXMif9JrzuwzADqkkCqFjnosqV4p/y5CTYOGLeVUlvwQKg3/pzP1pLbA+pHnhgnFc94lrK/ZdgXvsu5s364hwAi4nWlhLOaEInVyDw8oSbBXdQyWxUNbACwXUlZLGjzEkBuQxEAnrnN6uyv1o3VRjyWvKZQ42DU7lj70IepuBstNUhOrx9koGjK06vMxlHU51j/ouU7cHE0Uw5/z3p76dw6wPh0cpuHXsIN+tUnyarBY/jVmxL99LABVXnjYg+i8+zLM4pdM8iCazsvaNRIQ2FFFLRcDSFoOAZT7tXUIMOCyawalgWCMvI/nm+sDQbii+wRniLun+UKGjGZrBxCbA== 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=yy8TeewnnR2/h2tASJ5GXLvwUizrySg8Zlw3tMxk50g=; b=G+GvWo6ZvhyXhLYSIjbQ4a5FVAcj0K40hrFwzBXad6az5/I0NlZ2XpTOnOfDTmw6refSz1j9ZVzQV9wgDXKILm7+HN1e/j9ZCpCJGTj6puoozsgq+VhsbLdIhF3wEczs31xFumXNjDCtUfOgpbZUVbt8we1kYdfleoFb5XAPVdmptOmoFaTWuCKvOKMlCAptza11b2zHM/lXUVNt7aA31eSJw35xT3Q+g8+JdvRutqYIB0z25mB6IY4SD08uG8RCYOTtV+MGl2SgdmFr+Tc4jrhHDyBSuxJN/0Pd6TmrS6bkfHu40qANxffn+bwWBpNvTO/SQgGRAjGe0Q1ma8BFig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=yy8TeewnnR2/h2tASJ5GXLvwUizrySg8Zlw3tMxk50g=; b=zqkj6CbIa3di6amxIBKaLGtDsvRuN3kBuSzPeHRC2pMBsJ9IYpyiUdsVQYEKCW142Znq4Z0ZrCErNzunX53EmGxGNNRqWpZJzCy4xXxn3t9omo4oodJUT3WeZwQV+hnSo8IXb5Bxf9EeYBMUZ4qomvv73/Q8z/Dm33+ct1SKEIQ= Received: from BN6PR17CA0020.namprd17.prod.outlook.com (2603:10b6:404:65::30) by DM5PR12MB1210.namprd12.prod.outlook.com (2603:10b6:3:75::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.18; Wed, 16 Feb 2022 07:36:35 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:404:65:cafe::c) by BN6PR17CA0020.outlook.office365.com (2603:10b6:404:65::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17 via Frontend Transport; Wed, 16 Feb 2022 07:36:35 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:36:35 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:29 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 1/9] cpupower: Add AMD P-State capability flag Date: Wed, 16 Feb 2022 15:35:50 +0800 Message-ID: <20220216073558.751071-2-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d940546-c617-4b6b-b6d3-08d9f11f0f42 X-MS-TrafficTypeDiagnostic: DM5PR12MB1210:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: suWRhGI9mAIieQs3V8Kv1smEluICwlr66eRMeAXN5GQUzD5ixhrQgs0dySjP/qEErD1uSZY/FAzgR+ZmazAg1/yAJ4TlNxVKeJXzpj3YUeDqMGbr2ID1aw+hqb1f9MDjLgGVDSJrxRE71CRBBUkNQCrCFTs1fAQfBInZ5gdGkRhoSRqmLF2IniHXmN/UNq68xbZJk5tyP4P5SgPuBLwTNKC7FxGaF4lK2rXYoRPB0wNaSgeDRHl/KlWabCUSxGmDMMF/iEaTsufxhpQ/TnDDGlnA3R9UIQalAY/+EFtlw55RYdc9UJEIUHVLVEhoZxkj0nRBwsxYGJXXHeFhuQdVvWfSR5hcxaGXgIO1u1CbPQ/j/Cc97LNdW8I0gs/nTEBAH+urZnjQbb38XJfcohohXX+7LhnEIxtx68J6WyEQNLY3J68MOcG4VF2NFWPM0z421smGoCPyNNL6fBiLcSWuJuBfaNOqwtiZV+0PnM4l8DJI6Vy4BeL1uhNF8BOlm+nxPhhKD225dOUaE1w+SZziIZ/9hmJzlsDJqk9t3RUZ1shRyTungAfiXgCeQNKxSLx0hS2Ip6rBfvcbVlt3ozKhKwSO4XE7sbW/M1+tTji4eGI/OPHwCn+EbBGN58reTcw5fuRvvUKKWVWATw0Fmhl2pQ1twKm3ZKQbW22ux5XsYDCkSaXNDymSSGrpvQNT42ubTV4yPKSe37r2cGoKkguRZw== 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(54906003)(36756003)(316002)(508600001)(7696005)(82310400004)(36860700001)(336012)(47076005)(426003)(110136005)(6666004)(186003)(86362001)(16526019)(2906002)(40460700003)(5660300002)(1076003)(26005)(4326008)(8676002)(70206006)(81166007)(356005)(70586007)(8936002)(4744005)(7416002)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:36:35.1321 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d940546-c617-4b6b-b6d3-08d9f11f0f42 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: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1210 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add AMD P-State capability flag in cpupower to indicate AMD new P-State kernel module support on Ryzen processors. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/helpers/helpers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 33ffacee7fcb..b4813efdfb00 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -73,6 +73,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, #define CPUPOWER_CAP_AMD_HW_PSTATE 0x00000100 #define CPUPOWER_CAP_AMD_PSTATEDEF 0x00000200 #define CPUPOWER_CAP_AMD_CPB_MSR 0x00000400 +#define CPUPOWER_CAP_AMD_PSTATE 0x00000800 #define CPUPOWER_AMD_CPBDIS 0x02000000 From patchwork Wed Feb 16 07:35:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543209 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 F3FEDC433F5 for ; Wed, 16 Feb 2022 07:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbiBPHiA (ORCPT ); Wed, 16 Feb 2022 02:38:00 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbiBPHhv (ORCPT ); Wed, 16 Feb 2022 02:37:51 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2044.outbound.protection.outlook.com [40.107.92.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464061802A3; Tue, 15 Feb 2022 23:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2qA3zAhJjbvdWyUjOdnFYiYTlN1Q1GkOrSwXyxrVsQFMPnOQA5d3smMzD/KKMQ3VCkvdb2wAWyPbFXVrMOjT5K6qsvcE7Oh/AmYf5mHITjcdh8wU8Z+tslnsqxPVpqufcAQHj0eGMmq0CPqM0o/Ci5AXP89Rf868SxITegqlqcw14QbE9Agr5FEoq2I2CeOw+BeXm0MPiCwKNWsBBE2JQ1k9lTj0A3uK3VgKDFIfEMg2UFkvskvBZZsIRaJkJ7gc7+znCKBFSSXKccjJGg0oqtLBQLGEHe6EtavAJQwIEfBoEb3ydKiGN2RM8O6pVAoHUgyygdPL4aGvYqXdEB7sQ== 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=O5K0lvL9BTquP7/qoyBkBqBf462wzUoODlevyZRog3g=; b=iZxKf3cIpwINz9MXC8RKitXiI8EYr+cSXC0n2aQHDT6n1CUNIUIipdfnpYlEAeXaY2ATO1g8jH1RB1nWTUNnjfYsVNQk6tR32N9sVnK3i/x3g+1Z7u9DYA3cs0BwNID/gKNH/k5JMvCt62y5GXEq+RXQ+vzp6nsVRO/726XZA06cIDEucZFBaBQ3Scj/3Z4+N4DCulv46DZ0Asy/U8K7TRe+f4pIHFScp9mU3rJAm+9c8WyN4W2ucXthYX23Bl3RGb9mXP1w2Q0qGvkIaA1a911AWZkOWXOUlA91B2WOH28ZbjAGjiZMore7OmDuz9eXPdMnmPWOn8A07W4reb8tNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=O5K0lvL9BTquP7/qoyBkBqBf462wzUoODlevyZRog3g=; b=b/7G0v7iZR+raw60zGkblmQ4EeTmXOjncCskkiA+mNnuf9sLFsUQpPHHJU+0SGDUXjl8aOiBTT77XxK15zdKAFW8ZDjL6vF7PgTLRj0YLV1lYuLU3BpqQGHf45Fq95QIxgmk4rQsl1YoUToUE8XH1iigykx7uSCih9U/oSxu3jI= Received: from BN9PR03CA0850.namprd03.prod.outlook.com (2603:10b6:408:13d::15) by BY5PR12MB4098.namprd12.prod.outlook.com (2603:10b6:a03:205::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Wed, 16 Feb 2022 07:36:40 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::5f) by BN9PR03CA0850.outlook.office365.com (2603:10b6:408:13d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Wed, 16 Feb 2022 07:36:39 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:36:39 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:34 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 2/9] cpupower: Add the function to check AMD P-State enabled Date: Wed, 16 Feb 2022 15:35:51 +0800 Message-ID: <20220216073558.751071-3-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a451f2ba-f1b1-4f7a-9a9b-08d9f11f1208 X-MS-TrafficTypeDiagnostic: BY5PR12MB4098:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 758FztabVNA5FalIVK4sMxGoyZudc+Cie5vt/XJl16e6kt+wVOIsLfL0lKlwmkow1e0Anw1R0vilE/APv4YHCzXe3lb4yRK0GZ00sefyWKWBwmLJpCpAKBrW84SUW5jsLCOVu76areo7yIzgrqjXjph6pzUPaMbpPtby15tKHzAQA5WZTzimpr/0A2SxpZGyvpRK5koEqLEiTAaFuvFWMsbXabdjeL+YeyRc/ZzzyAInJckeKQmVm7igeXNEYbau8XyjyHCLAyybWvTuGqPwN/O+RADY4FduSqcn05ZnE9FvsUsqyuPruI8LdGf+qCU3/XruAEGBykavsWKvGY1jdPT4rVwvFFQt8Jt6WhSQCyyHur2+qN0zpNf6nNmdf6gy1Gt6VuhvUSRiQOWQ7yQFJpqEtRUcbmVkzeoFHDwksx5EvEMp8midDdn9KKGn/lvwoTh0RhYzkOQG3zhXLecPZ2nFY60aVo/bujsSem3hq07YOZ2vZJL0L6LNjkItr6NHG5bb03e8y8GGD2ObhtZFwv+0+pPPT6AiEfPSX/PGmTWbTN2rrAZvtAEAI5zK8ZCtZNN9i2+RT85Gxi9RafqWpRrucO80EBqiVqFyOp9j7wtyGaFt6Y+ebHTHzQbuxUFzg5ZBDL7nXi1bo+Fp+j5BhwJVB8BJfEqMNypOaiDDv3Uxtl24tqfVX8FLhUS1btInZUYjTC6FOFZxi7EafjmN6Q== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(5660300002)(7416002)(26005)(47076005)(8936002)(426003)(6666004)(36756003)(81166007)(186003)(16526019)(2616005)(336012)(1076003)(356005)(86362001)(7696005)(40460700003)(82310400004)(316002)(70206006)(54906003)(508600001)(8676002)(2906002)(4326008)(36860700001)(70586007)(110136005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:36:39.7688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a451f2ba-f1b1-4f7a-9a9b-08d9f11f1208 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: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4098 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The processor with AMD P-State function also supports legacy ACPI hardware P-States feature as well. Once driver sets AMD P-State eanbled, the processor will respond the finer grain AMD P-State feature instead of legacy ACPI P-States. So it introduces the cpupower_amd_pstate_enabled() to check whether the current kernel enables AMD P-State or AMD CPUFreq module. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/helpers/helpers.h | 10 ++++++++++ tools/power/cpupower/utils/helpers/misc.c | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index b4813efdfb00..557524078e94 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -11,6 +11,7 @@ #include #include +#include #include "helpers/bitmask.h" #include @@ -136,6 +137,12 @@ extern int decode_pstates(unsigned int cpu, int boost_states, extern int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, int * states); + +/* AMD P-State stuff **************************/ +extern bool cpupower_amd_pstate_enabled(void); + +/* AMD P-State stuff **************************/ + /* * CPUID functions returning a single datum */ @@ -168,6 +175,9 @@ static inline int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, int * states) { return -1; } +static inline bool cpupower_amd_pstate_enabled(void) +{ return false; } + /* cpuid and cpuinfo helpers **************************/ static inline unsigned int cpuid_eax(unsigned int op) { return 0; }; diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index fc6e34511721..0c483cdefcc2 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -3,9 +3,11 @@ #include #include #include +#include #include "helpers/helpers.h" #include "helpers/sysfs.h" +#include "cpufreq.h" #if defined(__i386__) || defined(__x86_64__) @@ -83,6 +85,22 @@ int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val) return 0; } +bool cpupower_amd_pstate_enabled(void) +{ + char *driver = cpufreq_get_driver(0); + bool ret = false; + + if (!driver) + return ret; + + if (!strcmp(driver, "amd-pstate")) + ret = true; + + cpufreq_put_driver(driver); + + return ret; +} + #endif /* #if defined(__i386__) || defined(__x86_64__) */ /* get_cpustate From patchwork Wed Feb 16 07:35:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543594 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 A2641C433F5 for ; Wed, 16 Feb 2022 07:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbiBPHhz (ORCPT ); Wed, 16 Feb 2022 02:37:55 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbiBPHhu (ORCPT ); Wed, 16 Feb 2022 02:37:50 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2046.outbound.protection.outlook.com [40.107.237.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFDE217227C; Tue, 15 Feb 2022 23:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YbkChu+uc6K3ZF/gOQH09QsZeVwz7bmkmxnXBMme6nQwPnRqyEL7P/snP89a7b33kxx55py69ukmn+PX9y/bHe0/oCnw5zM+KpoeR9UOso/FIk0NtAdi0Zr5WPWeGkuSR8FYPzsDqhjdLKeQhzAykuSGwsncYSqpbFJbG0dY67IcmMDJZsBU5TlYEvWAlwk5D1GXO+fQ67iZYzFBgELBZcRkfRiiCO5KaaurHMdwb3r9+cLl6drNB4GNzPyok2MvskgYxMLt5n5nwY2npNAd8KyvvU66fjBdtATg0MyhJpzHVReuFx/eO2oKKvpCNUftLFRSxHNPRvgUqcPeRLoaIw== 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=dSbHKoDmmLKln3/kxetImKM8rlt0tRMIUEteL7W0/GY=; b=XkRkT4bk/VNSk1o/jZ1EgdTsxhSuveLWsk/xFAK3zjElTRD9QE+OmgUUAw5e61gDTucGiu406yKQT+uvsr20KOuZUyqrozLByI4BA8GFdS9MV4anQlJ+GmI//qxVXhBgG8q4T7LePU+sH23tQqEnfjOHswGknvDm/NAkkPNo5QIUPfNy3wMBTlQVkD2aWrql5dAgpm9OOZW+x0qYxh+r0zLemfc6fwa0Z9wiHwg3preRkChnvaIrrdPaqzq99CS9Rg7+rilfQZRa94uzKzLE+Xpon364WJmbtEHMh/uttlJ9QoICD7t4gmdyn30taF33Yh0Dzv0x2OEfIiFBqldhEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=dSbHKoDmmLKln3/kxetImKM8rlt0tRMIUEteL7W0/GY=; b=p7Y85e6ms9/KVZLs38rH9yjqBzMYYKyQ1F5I4fXclVXvkJsv2tEKdnueV7B1MIZXR58ReBf2b+7QDY22r++tNfjeUo3IR9A6SWrXPdN/XRH5o/rQHjCIQEyuhkyppDpWaJ2qaHuff1BAPw+7yS8bZFOBBrUlVau0cCW4AFYEmlI= Received: from BN8PR04CA0034.namprd04.prod.outlook.com (2603:10b6:408:70::47) by MWHPR12MB1888.namprd12.prod.outlook.com (2603:10b6:300:112::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.14; Wed, 16 Feb 2022 07:36:45 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::7a) by BN8PR04CA0034.outlook.office365.com (2603:10b6:408:70::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Wed, 16 Feb 2022 07:36:44 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:36:44 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:39 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 3/9] cpupower: Initial AMD P-State capability Date: Wed, 16 Feb 2022 15:35:52 +0800 Message-ID: <20220216073558.751071-4-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 525bbadb-4015-44a5-feb0-08d9f11f14d7 X-MS-TrafficTypeDiagnostic: MWHPR12MB1888:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3ssn24aA9FmP5dE+vpi3SAmgImkA7xRgJg2Xj7JV7Ubf2Oa6ZmDt3pd/9HbRq+OWKBzqen+YqeW2pBzBjRgVjdsxrM1F8eRDpdsCEZQDhf5x8Y/YwGFl1Pqhd48H51s7J/bP/HFFg4YOwho6Y9BBLVqu+lS5XHwEGMYOkRmxDPj2s5dG/tYaoED4GPgptJvo+a3Db3LgMNxNVCtLKRbcYxgqHnQ1kUN5Xp/6CmvqeFLd0cre51S0VJkwjZymCYPOoX5vmcNNKJXFZCKZsBd9iCW7F4U2nw6XDAqPPU39U/YEwUd1swgF+By5Umh+RQ1X9F5zOFnjY0mYdFt+02vo1bWwox/GWgfi5uUO/zvnEMnKDguEnOV0sU9JA/p9w7SAmJD+0nUjtP/FbbY9MkqkShUYmabLSqjP0oR7Zm9lgTfaY2Fu3b0BwpjkztIgKGEaDzdUpsH3gr26tAVtgvf+d9ZxWpZ5kiCyIuABDKQNGrestSe5ACr/QwU1xgBCYxlC1WoSklZzsaXYC8j/hp+TdqtRfskCuO3klu0gTeiyFKaJ11WW+nm8d7WE4h41RKOC40MUoppdu5HyQrio7hhqBrg/mxB3h8fBIRHQMOKIlL84BX6HmKJNMSezzzq5w06lbDyrwBQePqxVoNbF8oQssNKqeM4kgNzhxMDNfZLST5BBmQPawwQnSzWi8DAtz5hZNYgpncmJZ9e4PXaTT01RvA== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(70586007)(110136005)(4326008)(7416002)(54906003)(356005)(8936002)(316002)(5660300002)(70206006)(2906002)(8676002)(16526019)(186003)(508600001)(36860700001)(6666004)(26005)(1076003)(2616005)(336012)(86362001)(7696005)(47076005)(40460700003)(36756003)(426003)(82310400004)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:36:44.4990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 525bbadb-4015-44a5-feb0-08d9f11f14d7 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: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1888 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org If kernel starts the AMD P-State module, the cpupower will initial the capability flag as CPUPOWER_CAP_AMD_PSTATE. And once AMD P-State capability is set, it won't need to set legacy ACPI relative capabilities anymore. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/helpers/cpuid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index 72eb43593180..eae91f11d187 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c @@ -149,6 +149,19 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) if (ext_cpuid_level >= 0x80000008 && cpuid_ebx(0x80000008) & (1 << 4)) cpu_info->caps |= CPUPOWER_CAP_AMD_RDPRU; + + if (cpupower_amd_pstate_enabled()) { + cpu_info->caps |= CPUPOWER_CAP_AMD_PSTATE; + + /* + * If AMD P-State is enabled, the firmware will treat + * AMD P-State function as high priority. + */ + cpu_info->caps &= ~CPUPOWER_CAP_AMD_CPB; + cpu_info->caps &= ~CPUPOWER_CAP_AMD_CPB_MSR; + cpu_info->caps &= ~CPUPOWER_CAP_AMD_HW_PSTATE; + cpu_info->caps &= ~CPUPOWER_CAP_AMD_PSTATEDEF; + } } if (cpu_info->vendor == X86_VENDOR_INTEL) { From patchwork Wed Feb 16 07:35:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543210 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 5375BC43219 for ; Wed, 16 Feb 2022 07:37:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbiBPHh6 (ORCPT ); Wed, 16 Feb 2022 02:37:58 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbiBPHhw (ORCPT ); Wed, 16 Feb 2022 02:37:52 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD87171875; Tue, 15 Feb 2022 23:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GxTlKkz8bmnN2o9mnGpEAIBxAnpSp9YysrXoZ/wAClpqj1An40W6sAQ7jWtrm+FzT+mBRKalzCwR+W4k87rRplpqgT6aUCfnD02cx2pUVNRKdIedHSNd82iepwpMauT668+E27r/0jhqfSjnjAwlGOQ/8Zo6KObn/FXsXARERfWc4PwUzYOX0bxBXNhwAbpy1H8/uC/uy4KzR97NqAHaIQWbwKQBLc/jtTxd4/d0p8jeJ9Z/iaUD0UuASlZo5W5ZNqRAtclzvyFjUPvy+WE6KnDTghruvUsM2IsyYO5nTOhW05V4IOP/DxXlNbPBld69q5AnlZHTwiASZBuC6ovOgg== 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=4RbkQn3dD3s1QYVuk934xqyMRVB5dSeR+NldY7tUrnk=; b=HwEWVBFXl/oUT+WCXaQRh9UL0ge9YvimQOQWZFHc0r+hRzQBxOJTvov+LHseGjDqXWb0IQv1iNCHJ0nfVZOjQd+gF9qRdCL6oLxGGU7y9h6GY9FAFTn0dcN/JGc7JuWyflUi2PX4K3CcabVaSHneCvmPjPVG4KlvZZM7T4MwPBz15cDMXK7hgCckBMEEpwxYUqkAHH42gY7j7nSJwI0Rfhcw2sLW2bGicbY668La4c1/Y3ioRfvXU9TdjL8aRI6XMiJg98vABmhjfeEr3/uwy+qAAcyiDVzgBUHVzMgIIBquf1QD7q8AsksP8ig6AaNMSTOgTiYXtObmleJ5KLvgvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=4RbkQn3dD3s1QYVuk934xqyMRVB5dSeR+NldY7tUrnk=; b=lieJObwJSVomQv1LgErQP1mYNQqKaNTT4O/VZd7caq75n9ReSRDZckbavkCkOL/HhmWPVeYSgHhP/aZOk1+GDjUgeT01XCxaw0rzLrwuSiL9uHqlreVEINerACCBA5sPw1XPTGKug1GWiCHSUBiCxJ+2/Axu+vWGuv43mwTvarQ= Received: from BN9PR03CA0478.namprd03.prod.outlook.com (2603:10b6:408:139::33) by BY5PR12MB4003.namprd12.prod.outlook.com (2603:10b6:a03:196::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.18; Wed, 16 Feb 2022 07:36:55 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::34) by BN9PR03CA0478.outlook.office365.com (2603:10b6:408:139::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Wed, 16 Feb 2022 07:36:49 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:36:49 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:44 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 4/9] cpupower: Add the function to get the sysfs value from specific table Date: Wed, 16 Feb 2022 15:35:53 +0800 Message-ID: <20220216073558.751071-5-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c3324a2-796c-4a90-5461-08d9f11f1799 X-MS-TrafficTypeDiagnostic: BY5PR12MB4003:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WiXft6a7JCFyU85DzHC/0Cyf95SAiYd6Ws1+4a3GQRy/MGtJmLhkUvs2ZM4HkwYp8qYf/PZpet+tF8GiBVChl22loZbhZSp6EgMcsTTrWrXqNGXnko0be8DaMzMQnwvga6nkBqENWuu1PKKic0MenFlz2KrbK87XQN7l4br3j0YLeASbIVwIvAkFR7ZV9PjOQJdgwXRzQeELgDhyR1cylfFSBzM+kdIiEkoToerIrtCiwZn50ITtIP2BWJhfNfg+nAfxHUnMZdQfd//aXkZ93bLlKyyR1kVVnk/iraZi5EqU65GXMyjnYTq3STPe37hobmPOnJM2PnAZn9Lz6GdF7ziSAEvyj/OVFEFct9k4hhf1Y0RVwpT3x2E03vws3v+WSO7IJ69bJXBZ9bQEKq+EPmxDpATdm2VoK70otsb5miDZZgMov8oEEUN/P/VmZg/zfd+iOyhxkvXKy3O2AFBFCabd3RRDkCQfODBJxon1c6W0h7RXeHkFmbQxbYpwbc5jHYd0WVB2BHDqWxWevEta5AaVlfPD0tLEC20nzaxEVJSB2B6wBP8/JGyb41EwbOicfRTl4yUC2Pjg9SMHiP2ijwEBBfBQMs5dqlX2yS+PqiMYKhFISTHhOUgxU8YAu42GAWRl96VoxdR5f+8XloWoJwxNHMJUzu+L5EPjSs6UouFJpZ2WuvqvRbqVqZAzd5/Tf/pkY1BbXZbseL+cFSZTk8eFLzPUEyNvUQPDK3MT8CM= 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(54906003)(70586007)(336012)(316002)(4326008)(2906002)(8676002)(110136005)(26005)(7696005)(6666004)(1076003)(36860700001)(16526019)(82310400004)(2616005)(186003)(508600001)(426003)(47076005)(83380400001)(36756003)(70206006)(81166007)(5660300002)(7416002)(8936002)(40460700003)(356005)(86362001)(15583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:36:49.1215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c3324a2-796c-4a90-5461-08d9f11f1799 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: BN8NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4003 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Expose the helper into cpufreq header, then cpufreq driver can use this function to get the sysfs value if it has any specific sysfs interfaces. Signed-off-by: Huang Rui --- tools/power/cpupower/lib/cpufreq.c | 21 +++++++++++++++------ tools/power/cpupower/lib/cpufreq.h | 12 ++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c index c3b56db8b921..c011bca27041 100644 --- a/tools/power/cpupower/lib/cpufreq.c +++ b/tools/power/cpupower/lib/cpufreq.c @@ -83,20 +83,21 @@ static const char *cpufreq_value_files[MAX_CPUFREQ_VALUE_READ_FILES] = { [STATS_NUM_TRANSITIONS] = "stats/total_trans" }; - -static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu, - enum cpufreq_value which) +unsigned long cpufreq_get_sysfs_value_from_table(unsigned int cpu, + const char **table, + unsigned index, + unsigned size) { unsigned long value; unsigned int len; char linebuf[MAX_LINE_LEN]; char *endp; - if (which >= MAX_CPUFREQ_VALUE_READ_FILES) + if (!table || index >= size || !table[index]) return 0; - len = sysfs_cpufreq_read_file(cpu, cpufreq_value_files[which], - linebuf, sizeof(linebuf)); + len = sysfs_cpufreq_read_file(cpu, table[index], linebuf, + sizeof(linebuf)); if (len == 0) return 0; @@ -109,6 +110,14 @@ static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu, return value; } +static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu, + enum cpufreq_value which) +{ + return cpufreq_get_sysfs_value_from_table(cpu, cpufreq_value_files, + which, + MAX_CPUFREQ_VALUE_READ_FILES); +} + /* read access to files which contain one string */ enum cpufreq_string { diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h index 95f4fd9e2656..107668c0c454 100644 --- a/tools/power/cpupower/lib/cpufreq.h +++ b/tools/power/cpupower/lib/cpufreq.h @@ -203,6 +203,18 @@ int cpufreq_modify_policy_governor(unsigned int cpu, char *governor); int cpufreq_set_frequency(unsigned int cpu, unsigned long target_frequency); +/* + * get the sysfs value from specific table + * + * Read the value with the sysfs file name from specific table. Does + * only work if the cpufreq driver has the specific sysfs interfaces. + */ + +unsigned long cpufreq_get_sysfs_value_from_table(unsigned int cpu, + const char **table, + unsigned index, + unsigned size); + #ifdef __cplusplus } #endif From patchwork Wed Feb 16 07:35:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543595 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 2B5A3C43217 for ; Wed, 16 Feb 2022 07:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbiBPHhx (ORCPT ); Wed, 16 Feb 2022 02:37:53 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbiBPHhu (ORCPT ); Wed, 16 Feb 2022 02:37:50 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2046.outbound.protection.outlook.com [40.107.100.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1478172276; Tue, 15 Feb 2022 23:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gIj8kaNTWnB3leKZX1JzlpMY/cidDVTJw/hoOF/Th8ikSqY52vnFvUKF8Tc4NPTqsjExoZr0ZVXoaykHZ/cpJLsUUxszUEYh9VOA3aMUhFUcIV4wm2V45zoUcFPKMWIUWEY1VSSm9VW5/VbKzINa5deRySpMwY7Lu6eRHpnPqpNRh2k4cEn9RR00+GATj910G6dtkZ7gk1ZPaHOSnPDNHbSyH0bHQ1rmFny4yshTCWwKBbCnlxkg6Voia0GtIscoEaMTMaXZYMyw1l80lcg8Jd+8jy6rkSkcQNQLAdUfR2Pkpnlq5jl1iqCKha22ebl2lzjeAa6+Sly8HM37ktxmzw== 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=E5iwzIdMOvVnHP6ggSINV8XsIMjw01pyhmcrOPIF31U=; b=jM46Md3FLlQxbxor6c2H2Z+JeoOOVjN7z7snYyPuT74HSC4IrO+RIY9yS928DwROkGT0W7B1QBK74anfrJy1tjIt5mzNSJx6wlUUfH7uoqwZs7ufNZiywVQ3MCfsKuZJZwSHrlHmylbb8JbkkOZLWLCIOeEewn9I83ilJ3jVvurQHufsfB9KVWpDU4Z14NAR35JIG3h0+1GaGQJTlGCvCJLzExWX8v33h/1Xkr7msAi5i0o3aT5NV1N6E11nlNa0bOxZUuuLodVMcyQtm3m54isurhnIYsHuTU9BwZesRPU+s88Mj6FaBpoCz21bVKM++t4WNLZ8kFtJhsjvtSpktw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=E5iwzIdMOvVnHP6ggSINV8XsIMjw01pyhmcrOPIF31U=; b=3/AqpLZQTsYBqKb1IKhlewY6Ma+Kwv2biqyqomeIeUkQ0ssqMWOqwVeQHUFQW/XDxIrozdhbUQZuW664b88tsB99AE6hkxh1EV/87sq9Ieaiatp1eMVdzB8nmTDRID924iAi8faMX8xxnngOxzHa9MiY3xsnwS3bSHY2dGZKVB8= Received: from BN9PR03CA0467.namprd03.prod.outlook.com (2603:10b6:408:139::22) by BN8PR12MB2850.namprd12.prod.outlook.com (2603:10b6:408:95::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Wed, 16 Feb 2022 07:36:56 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::2e) by BN9PR03CA0467.outlook.office365.com (2603:10b6:408:139::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15 via Frontend Transport; Wed, 16 Feb 2022 07:36:55 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:36:55 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:48 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 5/9] cpupower: Introduce ACPI CPPC library Date: Wed, 16 Feb 2022 15:35:54 +0800 Message-ID: <20220216073558.751071-6-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3208578-8759-42f0-9b1b-08d9f11f1ba1 X-MS-TrafficTypeDiagnostic: BN8PR12MB2850:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZcJayJqx9V17suyd9sgZKeE5jxDYHFO7iTevrLqDm330DU6WdeyJp/jHKYPUuBd2QVeejWzGgwXGsE/VR63OsJN+x/qgig+rVRc4M2evb1Sw+RIgb35TwPUJDKkcOb/I9H+7q01f6upT4bwCaU6zCcjw59TO4+8Ggd50ZUsOFYowKs9BXyW0E5A1Ds3mJVUAD2/xBk2i5AkiwLR8sv+k7aQfjtKkrkv0N0hoVOLxDAv0Yscewg0hjalBx4Ts4J+FImpHgmWM6SlqxF6DLp4aO+s20Ls3+ytb45u3Tv/9iYqkIAI8hbZlKJunPKDxHnjWpABypSmBxIIj2L8RmtnZgnn4++kg0OU/LLX5LEPK6qofC/SMXsNhhB0vQuLcC0XiC8LE2wwqugXFw4XdUNxp2efeZZNKZvjycBDEgwkYA56MlIJdu9R2qtwkvKPFKkFrgpP25hMsDjIAU7nvAeQ7GuxOgaOHCox2poGf5SVOXZGkHpIQSGBFnBBFXxE+iJcANPhScQLdVC9V4j7T2dHPu3KEGJ/Ai2F7NB8GcVmLvxfgi2tde+kUG3yupiwoZJMyrBebnUb0WVhmDwLoOzRXN4CbGqC3NnNL0EVHJvXwICggDf7U0A+lxhDtnJIZM1Xi9HwOjmLnQqBH0iHjVe5fnvdZyVdICzvaNEOb7AJgJx4WIKD0S75I5RQOSQhwHU2UeA0KXZSz7YHmP/yUv5u/ZQ== 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(5660300002)(36756003)(6666004)(2906002)(356005)(8936002)(36860700001)(7416002)(81166007)(70206006)(70586007)(47076005)(40460700003)(8676002)(336012)(83380400001)(4326008)(82310400004)(2616005)(26005)(186003)(1076003)(426003)(16526019)(508600001)(54906003)(110136005)(316002)(86362001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:36:55.8866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3208578-8759-42f0-9b1b-08d9f11f1ba1 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: BN8NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB2850 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Kernel ACPI subsytem introduced the sysfs attributes for acpi cppc library in below path: /sys/devices/system/cpu/cpuX/acpi_cppc/ And these attributes will be used for AMD P-State driver to provide some performance and frequency values. Signed-off-by: Huang Rui --- tools/power/cpupower/Makefile | 6 +-- tools/power/cpupower/lib/acpi_cppc.c | 59 ++++++++++++++++++++++++++++ tools/power/cpupower/lib/acpi_cppc.h | 21 ++++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 tools/power/cpupower/lib/acpi_cppc.c create mode 100644 tools/power/cpupower/lib/acpi_cppc.h diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile index 3b1594447f29..e9b6de314654 100644 --- a/tools/power/cpupower/Makefile +++ b/tools/power/cpupower/Makefile @@ -143,9 +143,9 @@ UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ utils/helpers/bitmask.h \ utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def -LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h -LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c -LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o +LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h lib/acpi_cppc.h +LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c lib/acpi_cppc.c +LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o lib/acpi_cppc.o LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS)) override CFLAGS += -pipe diff --git a/tools/power/cpupower/lib/acpi_cppc.c b/tools/power/cpupower/lib/acpi_cppc.c new file mode 100644 index 000000000000..a07a8922eca2 --- /dev/null +++ b/tools/power/cpupower/lib/acpi_cppc.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cpupower_intern.h" +#include "acpi_cppc.h" + +/* ACPI CPPC sysfs access ***********************************************/ + +static int acpi_cppc_read_file(unsigned int cpu, const char *fname, + char *buf, size_t buflen) +{ + char path[SYSFS_PATH_MAX]; + + snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/acpi_cppc/%s", + cpu, fname); + return cpupower_read_sysfs(path, buf, buflen); +} + +static const char *acpi_cppc_value_files[] = { + [HIGHEST_PERF] = "highest_perf", + [LOWEST_PERF] = "lowest_perf", + [NOMINAL_PERF] = "nominal_perf", + [LOWEST_NONLINEAR_PERF] = "lowest_nonlinear_perf", + [LOWEST_FREQ] = "lowest_freq", + [NOMINAL_FREQ] = "nominal_freq", + [REFERENCE_PERF] = "reference_perf", + [WRAPAROUND_TIME] = "wraparound_time" +}; + +unsigned long acpi_cppc_get_data(unsigned cpu, enum acpi_cppc_value which) +{ + unsigned long long value; + unsigned int len; + char linebuf[MAX_LINE_LEN]; + char *endp; + + if (which >= MAX_CPPC_VALUE_FILES) + return 0; + + len = acpi_cppc_read_file(cpu, acpi_cppc_value_files[which], + linebuf, sizeof(linebuf)); + if (len == 0) + return 0; + + value = strtoull(linebuf, &endp, 0); + + if (endp == linebuf || errno == ERANGE) + return 0; + + return value; +} diff --git a/tools/power/cpupower/lib/acpi_cppc.h b/tools/power/cpupower/lib/acpi_cppc.h new file mode 100644 index 000000000000..576291155224 --- /dev/null +++ b/tools/power/cpupower/lib/acpi_cppc.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ACPI_CPPC_H__ +#define __ACPI_CPPC_H__ + +enum acpi_cppc_value { + HIGHEST_PERF, + LOWEST_PERF, + NOMINAL_PERF, + LOWEST_NONLINEAR_PERF, + LOWEST_FREQ, + NOMINAL_FREQ, + REFERENCE_PERF, + WRAPAROUND_TIME, + MAX_CPPC_VALUE_FILES +}; + +extern unsigned long acpi_cppc_get_data(unsigned cpu, + enum acpi_cppc_value which); + +#endif /* _ACPI_CPPC_H */ From patchwork Wed Feb 16 07:35:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543212 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 7F757C433EF for ; Wed, 16 Feb 2022 07:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbiBPHhv (ORCPT ); Wed, 16 Feb 2022 02:37:51 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbiBPHho (ORCPT ); Wed, 16 Feb 2022 02:37:44 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F9E194152; Tue, 15 Feb 2022 23:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cBBmkqwcG0dVGwlyEXwUIQry5KQUuWAGoNnNzrkUdLLDyr+LzWquPeWFFts3/4ZK93NrlLQg+J1paVmsbRGuwv0WEBecyZYAhc2EAndbJh7i4FJRwcdj7W9LINHYOl7H8A+uFuu4yoU/0zKVLF3meqPlkSHeUN8fEBzdAa5LxTY+yeftMHBztxYxLttaokn8cFg7YxMPM3aGtwrX3/Os+D9uJmdKHDGM+ChT3tnxXf3VQzebjN9+EOJ7xyhOeurJbHCYh0jL1zi2fqumwFHlJv9hIgWMNZTsoqiPKEy81XBm8gpFSw2C7aQdSzUWUpVTUhq0HCvDSL9QsxL8pCuwyA== 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=Yol6P6KRnDUyQ4DPHJ3vilDlXJzt5hUiI1yau0/FGRU=; b=NOfsNC5AUM8fXWahZtASPqQvsbHu4hvwvO0T4PUAfyalmAajR9t+xkR1+FKGn3melMk83dMlE4MKOLR0WiYCLSFspOtr65xCRg9q9rFUdDhAlKYDVXFGTnJ3Gjwu9kM9hRk/Qs3qu4YPh/OxzkSMw4tDz4HeUoZFFdPa26YLK//4Y/eMhW/3t/s3Lq8NCbx36AqJ1u0HlL1iSqkdap2L2vlgB3j1TeeL2o3Tq/qaBtf3wjZYqdz5gW9XyVvrnLK/orF329XYkSl5+VnK1d844I7pHHYk8ulrna6BVAgDnmaufhyWhFWA5lBzVuBfMl/3PA/rTwsrGJHgcqAZKLTQ2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=Yol6P6KRnDUyQ4DPHJ3vilDlXJzt5hUiI1yau0/FGRU=; b=dYLWv1xvwcFutE++jZaFLO4Zo7Y4hFqPd8M880VYYvkZQof48CdT8r7a2RBiFmGhB4zAmCleF0ipa29iluv6oLWsxrfyBKCSkH0Z8OdVjW70CPGSbzBkgTeERpQZzC371q1UrJvRT6eLvG93lhuNnnQ42EhdExKtId8sXOzw8cU= Received: from BN9PR03CA0651.namprd03.prod.outlook.com (2603:10b6:408:13b::26) by DM6PR12MB3370.namprd12.prod.outlook.com (2603:10b6:5:38::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Wed, 16 Feb 2022 07:37:00 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::1a) by BN9PR03CA0651.outlook.office365.com (2603:10b6:408:13b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Wed, 16 Feb 2022 07:37:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:37:00 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:53 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 6/9] cpupower: Add AMD P-State sysfs definition and access helper Date: Wed, 16 Feb 2022 15:35:55 +0800 Message-ID: <20220216073558.751071-7-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7313c0e2-28c3-4add-e741-08d9f11f1e3b X-MS-TrafficTypeDiagnostic: DM6PR12MB3370:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4wHJCp7aIAewgaqKlJW4b89q8EItz0NkB1WfFs0eyiDBAccRwLALnxXoYYElBX7IB72W8subN19G89FK2Aidg+CpC0XXC17zzwCLlW8K9uApXaQrahTB5EfSeqKhgRmVuBj0uastqm2/I9PDQJ9LDZaPSKM4aiOTqAYXJJkzRdigrgpurXTeyKdoOJhH3sQlakjjR1EaW0uhBZHEkhWWv5XlypQ2/Lz3g6t6ZMiXGNltFvv8fTXWb+lVlfAPadNQv0KVZx3qJSGht5+6vUS850S+OVgTR9pu+JSTnGWo9SXA3oQTB4OcHtx+vwE8GGFrCESrRxzPLTSsHZrqyMDz3ZHWvMDB7Fu9JLpL3JJNIgS4meQtAtrujxEneZYQLy3gpmuWzeS2Elvhw6d/obQAyletK/pyQFnrIcv8LQ5MCKxRg9G9Sxp99WLjMXnFp2hEKO2fQXUxe5UTeHkRSdTEqRPXSl/n4okfU32i/t+hZage0LIQtljZr7uIn0ZjA0lMDnm3PhpZXKTnxzjbWOs1iAwXevHhyvMEhSw+h4TJByGWcSWAIE4kFuRSjceO5kRaxzrplrY1RZnxYMOmT25/JUpnFZzNSbfzC76O6TY5S7qDk73EY/YqrvgsiaBh9YtEiCnRWjJETmamga6erCeV1DbIBNY7HR8tAROEGSv2YCf6HxDuGOyTxq0EHJkgXVp9aR4vMUgTc0jG89eORQWi9g== 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(81166007)(7696005)(2616005)(40460700003)(82310400004)(508600001)(36860700001)(26005)(16526019)(356005)(186003)(1076003)(336012)(426003)(47076005)(83380400001)(86362001)(4326008)(2906002)(8676002)(316002)(36756003)(70586007)(70206006)(8936002)(54906003)(110136005)(7416002)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:37:00.2533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7313c0e2-28c3-4add-e741-08d9f11f1e3b 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: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3370 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce the marco definitions and access helper function for AMD P-State sysfs interfaces such as each performance goals and frequency levels in amd helper file. They will be used to read the sysfs attribute from AMD P-State cpufreq driver for cpupower utilities. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/helpers/amd.c | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 97f2c857048e..4d45d1b44164 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -8,7 +8,10 @@ #include #include "helpers/helpers.h" +#include "cpufreq.h" +#include "acpi_cppc.h" +/* ACPI P-States Helper Functions for AMD Processors ***************/ #define MSR_AMD_PSTATE_STATUS 0xc0010063 #define MSR_AMD_PSTATE 0xc0010064 #define MSR_AMD_PSTATE_LIMIT 0xc0010061 @@ -146,4 +149,31 @@ int amd_pci_get_num_boost_states(int *active, int *states) pci_cleanup(pci_acc); return 0; } + +/* ACPI P-States Helper Functions for AMD Processors ***************/ + +/* AMD P-State Helper Functions ************************************/ +enum amd_pstate_value { + AMD_PSTATE_HIGHEST_PERF, + AMD_PSTATE_MAX_FREQ, + AMD_PSTATE_LOWEST_NONLINEAR_FREQ, + MAX_AMD_PSTATE_VALUE_READ_FILES, +}; + +static const char *amd_pstate_value_files[MAX_AMD_PSTATE_VALUE_READ_FILES] = { + [AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf", + [AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq", + [AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq", +}; + +static unsigned long amd_pstate_get_data(unsigned int cpu, + enum amd_pstate_value value) +{ + return cpufreq_get_sysfs_value_from_table(cpu, + amd_pstate_value_files, + value, + MAX_AMD_PSTATE_VALUE_READ_FILES); +} + +/* AMD P-State Helper Functions ************************************/ #endif /* defined(__i386__) || defined(__x86_64__) */ From patchwork Wed Feb 16 07:35:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543591 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 B30AFC433FE for ; Wed, 16 Feb 2022 07:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbiBPHiB (ORCPT ); Wed, 16 Feb 2022 02:38:01 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbiBPHhu (ORCPT ); Wed, 16 Feb 2022 02:37:50 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7322118405C; Tue, 15 Feb 2022 23:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ka34EYtNo+Fwn+FpAJK54cMHimxzwGRKX9lOej+oMk76zRwksxnuDRXui83IMlDV4up/CCsqjEhamDfEM8hLs57ERYQq+99xUFwbM/yZdn8R86kc06+zSUN0yykBryqQ/6s+c3b9gMA/kASjZ7YK6GVSkrBBWPiLbETJucLp6cB2C5ekr5e6RSQ668RfGJIoJ48ZuYS+VYDuAgOXDxrrqMpA5lsBAeRKuNqXkD2SiNnb7twx741hrc3MS0H/i0r9QMUY8HrZzCV9H9Cq7CmSi473xR9BIxnCEkyIjcHiLFUIRoXy2Ur0jTAa7Hu9NktipsH6VH7D6EBVfkSHRhzPfA== 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=xA8jBDdLU3KAWwOP5ypihhXb7wKXVSEgUafhpCVEulI=; b=KAE9IBRaNRgDcCPIW8BvbcRXy0+gK+s6TVHcgGav43znPIXZnKrHFMB/PG+gardp1s0X5jSjIVP9OmhVG2q3nns+BVSjrPQ4T8Bc8/ikMH4aWX3P9iWYdQK5p2Lcrsu2iGAjwM7j5X4FUSEgpl/zkGNXUUUIySotdD+uB7gc5iUDER9GfZl5pXayDGWaDZD6asokU2usQjqhBwk+vH4mDxyC0KGrtV4UWqw/RHouW35tOP7qAc4PrQkNfSku32R/sKKKyFsMbxMxq1oLUttTAcR1Nrld+RsHaZqPrAnsNXhQ2OolftcWbqH6P9vMQo3TUb795OmGmiUF4zpINXwvDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=xA8jBDdLU3KAWwOP5ypihhXb7wKXVSEgUafhpCVEulI=; b=f3gi4pmCVLjBgp3EcZd33LkQFHeSndJKVEQFBv4jMmbe2R5m8cGKvGcVWZDdrsH6sC7mGLylsC4iXyb3j8jajoC1gx+KemIsJr/IPbuaDoDfBcfXuquWqlreUAIZa/tIZqyMcnGLGz3NyWKldCVOu0fU1dlLvbD3g/U5+FKEez8= Received: from BN9PR03CA0553.namprd03.prod.outlook.com (2603:10b6:408:138::18) by BL0PR12MB2436.namprd12.prod.outlook.com (2603:10b6:207:42::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Wed, 16 Feb 2022 07:37:12 +0000 Received: from BN8NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::78) by BN9PR03CA0553.outlook.office365.com (2603:10b6:408:138::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15 via Frontend Transport; Wed, 16 Feb 2022 07:37:06 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT007.mail.protection.outlook.com (10.13.177.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:37:06 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:36:58 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 7/9] cpupower: Enable boost state support for AMD P-State module Date: Wed, 16 Feb 2022 15:35:56 +0800 Message-ID: <20220216073558.751071-8-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24884339-441b-4d86-519d-08d9f11f21f6 X-MS-TrafficTypeDiagnostic: BL0PR12MB2436:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iefgkYwo7Ie9D4ABoFwFHlnLFKph7PLEA5iOpAG7LYAz+cu60v8mRwDG0XBWz1WEprQtPdoodekKFQdaWMxXEILbr3eM8e2wEt/2s7FQ9gvK5CICJvugC9FND3spd4f4HvnSJRhifrsEr1c3cJXg+aGtLc54jCByx7Y8exRA2rp+G7d1bgTAsPHPMQsDm2Jn8PTEbAgHeh2iVvJVu7CkK071w88F4BlEyC5t5Xn/Ks7BApFZHYlbHE0sxexnz2dU5vA+s4GCjnfVTB/tC9T1MMMX8nRXdfn2n15es7CUTrlm69EZWPKVfvV71REnQqGZYCDat6BIrSYBmDuTDXQBwbDmgNzHdZwWJrkf3U/eH4/5WKzFyQFoLOqx9yrTKfRgXfcs5bKmW1T7LIR2HoK/XutaH1m7LVBzBqj8ZVBNJDXJfKWwVtbdcok+9yam3zFt3ISMCrim0HTcw6r+zDHr71llbUZ/8nTudVkLXvg5ZT19P7ABv4PKJlMoQf1ot9r22CddpeSGpfEIjqNJM+RvX3GJOyQ+4lVV5sSWPPJCf3aIQBIQyQbzHe5fuUVCuACljxOfvuoBDQKGayWg6TYK3Wh8JUC1A61eHu1CrUe9xVxtizsFtqoW4/Q/PZgQHonwj6yy6LckbO8eBPSK6F2jq0uvgMWo91URMjOtYX1E8eWcZXxDmHoBHGt3g7OXDI2HvaGDjjQuIUqCzkO5Sk3RFw== 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(356005)(110136005)(54906003)(2906002)(316002)(81166007)(7416002)(8936002)(5660300002)(4326008)(86362001)(8676002)(70586007)(82310400004)(70206006)(36756003)(2616005)(426003)(336012)(1076003)(47076005)(83380400001)(26005)(16526019)(186003)(7696005)(40460700003)(508600001)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:37:06.5081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24884339-441b-4d86-519d-08d9f11f21f6 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: BN8NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2436 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The legacy ACPI hardware P-States function has 3 P-States on ACPI table, the CPU frequency only can be switched between the 3 P-States. While the processor supports the boost state, it will have another boost state that the frequency can be higher than P0 state, and the state can be decoded by the function of decode_pstates() and read by amd_pci_get_num_boost_states(). However, the new AMD P-State function is different than legacy ACPI hardware P-State on AMD processors. That has a finer grain frequency range between the highest and lowest frequency. And boost frequency is actually the frequency which is mapped on highest performance ratio. The similiar previous P0 frequency is mapped on nominal performance ratio. If the highest performance on the processor is higher than nominal performance, then we think the current processor supports the boost state. And it uses amd_pstate_boost_init() to initialize boost for AMD P-State function. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/helpers/amd.c | 18 ++++++++++++++++++ tools/power/cpupower/utils/helpers/helpers.h | 5 +++++ tools/power/cpupower/utils/helpers/misc.c | 2 ++ 3 files changed, 25 insertions(+) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 4d45d1b44164..f5ba528dc7db 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -175,5 +175,23 @@ static unsigned long amd_pstate_get_data(unsigned int cpu, MAX_AMD_PSTATE_VALUE_READ_FILES); } +void amd_pstate_boost_init(unsigned int cpu, int *support, int *active) +{ + unsigned long highest_perf, nominal_perf, cpuinfo_min, + cpuinfo_max, amd_pstate_max; + + highest_perf = amd_pstate_get_data(cpu, AMD_PSTATE_HIGHEST_PERF); + nominal_perf = acpi_cppc_get_data(cpu, NOMINAL_PERF); + + *support = highest_perf > nominal_perf ? 1 : 0; + if (!(*support)) + return; + + cpufreq_get_hardware_limits(cpu, &cpuinfo_min, &cpuinfo_max); + amd_pstate_max = amd_pstate_get_data(cpu, AMD_PSTATE_MAX_FREQ); + + *active = cpuinfo_max == amd_pstate_max ? 1 : 0; +} + /* AMD P-State Helper Functions ************************************/ #endif /* defined(__i386__) || defined(__x86_64__) */ diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 557524078e94..f142fbfa4a77 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -140,6 +140,8 @@ extern int cpufreq_has_boost_support(unsigned int cpu, int *support, /* AMD P-State stuff **************************/ extern bool cpupower_amd_pstate_enabled(void); +extern void amd_pstate_boost_init(unsigned int cpu, + int *support, int *active); /* AMD P-State stuff **************************/ @@ -177,6 +179,9 @@ static inline int cpufreq_has_boost_support(unsigned int cpu, int *support, static inline bool cpupower_amd_pstate_enabled(void) { return false; } +static void amd_pstate_boost_init(unsigned int cpu, + int *support, int *active) +{ return; } /* cpuid and cpuinfo helpers **************************/ diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 0c483cdefcc2..e0d3145434d3 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -41,6 +41,8 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, if (ret) return ret; } + } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE) { + amd_pstate_boost_init(cpu, support, active); } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA) *support = *active = 1; return 0; From patchwork Wed Feb 16 07:35:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543592 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 35BF5C433FE for ; Wed, 16 Feb 2022 07:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230328AbiBPHh7 (ORCPT ); Wed, 16 Feb 2022 02:37:59 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbiBPHhv (ORCPT ); Wed, 16 Feb 2022 02:37:51 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0CD5187E06; Tue, 15 Feb 2022 23:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQ0JTgr93gAmo/9Ua3hDDgd4N1FJGc4Sf3RGWA68ZflPviCwSSYYvB54i+bjUXgJ6sGvpNrbCDxxz7ZsPJquy6jMYnL3yXilCHj4ZSUrvZlQzQK1Q3dbMCk/LJxszxowiM8StFJyh4N9AMOrYELvAhtIPUU3b43vklKb3CzZ6d/QNXap9SjdoBTK9128Q2ZVuY8wdLuGeQVAmQ1hUsX+dODVLOSrqcxWFThiYeCKQEj1EDbvSMSYXkQHuZB0DhbtSn70LoOvbuQMvfEcAvR2BFHeZypxm67dvzQLHXKLycXPnM0Gv934n2KUEyUeicqhJ+aaudgnZY78l43AeQDyOg== 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=QvFQRM3Kvl5/VlKL8/woeNbPXhFxQXuwUSuzc8bAQKo=; b=JRPVrvJ0wXuqNKmaEmsX/BqRSRtDLebnYnlWlXtwysKw8Qq4c/klohLG+/NFK+ZS/arj9o8JIcsK/JcJ9TImrLfcszJpoSIIQL0kCF7UVdk848WVRs3u96CpAgHGdk/4k9ErfQIX1kZYhExl5SuV0LdWy7JyvXvFXcmEzW8ko8eJYqySApucf/oHLQRlIzyGmGc0mCGNfWlNw69uLYI4fBOCZeBq3Xs9qIDg2KCIly7HBjfZqGqCf6u6CGxjBl4QjwG8g4U+ncdPIUlp/TDIKBj07yFJ/+gW5Y2sg9wlhvH11qhndxvf5m/PWoO/Y//i9usjyRv23E0bw/uxnCukgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=QvFQRM3Kvl5/VlKL8/woeNbPXhFxQXuwUSuzc8bAQKo=; b=OXOsKSHSpqU2aZ3uIkW5ObM1QuB1l+Jl6Na3FHX5XmFKh52TKbvvKAUTqksB9xhuwTcU3dJGHxJTnkqA6pjf8d5UjlWoAka6XlMeEUKCP4NmhDraZuw1xfBZ/oxZE2d9YtkF/OkDlxSKSu+8AY+ksdPYmlks21/4883Px360tJ8= Received: from BN9PR03CA0652.namprd03.prod.outlook.com (2603:10b6:408:13b::27) by CY4PR12MB1895.namprd12.prod.outlook.com (2603:10b6:903:11c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.18; Wed, 16 Feb 2022 07:37:09 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::34) by BN9PR03CA0652.outlook.office365.com (2603:10b6:408:13b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Wed, 16 Feb 2022 07:37: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:37:08 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:37:03 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 8/9] cpupower: Move print_speed function into misc helper Date: Wed, 16 Feb 2022 15:35:57 +0800 Message-ID: <20220216073558.751071-9-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2dd5a6d3-cc3a-4e9a-bb58-08d9f11f2339 X-MS-TrafficTypeDiagnostic: CY4PR12MB1895:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /2sjMofuZsNy65zyK3QCsZbFw5aKtYsOXgN9XeD/cvqjRPfSRD0BK9YqKRiM60Wp/gXjo6iVWRc4Uw0W4OXhB9Z3dZyyA/Ol2topJ8qpSGU91ut3ooohh3IwKd8/rWUJ8mLiYoNHc1rojZTGBNypXkL9GzeIodN3pUi4J1TA6x5ZAyuNMt+02ylHGZODUX3zlizmPBTdtFUH2dKsJ0DgtT1FuBZj3eAbBVvf12Ag7qSUEMERa6bsFvaANIcWdiaGtG8gEzUu4Dj9m+oSqF1jI3ExB83t7NI2pMelKVdF5/gxX/bLhX9v1u6QXznR7SKhUrCfAgkL/DG7y084dv/Y9lMMJz1TUwe34kOkweDE2Q9UgCIHim0Qo89K283XWPseRZvq33A9gGZ5XY/+23FP800/iu1NQakNaQWyEtJ6RjO+e6cnzV0jQgdp0kCPxxIQeNvcWOjfwZURzTbLLQX0cPBCer9uHgl6m42qRxYNUg/jL8ROZ1cH4azi8XhJpcoylW9Aw7oPuFU3Rcay4z7dD32RZzFHXeW7xM9KsnulSCKTmwlTSLhm26OwM40urI0BBw7aFby0DJ7gjLO5owRpDEj8u8bXDxMdxtKWzwq+g3k/t+foNKbpeYlVzrmfjp2hONX7uQbw4vKB2XmpFJF4L7kxS8xENX9wp9XedD6MWGEgiSZkj35PYXer18hBJvP3ocKEuoCk8Az/n2g+4Buxyg== 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(4326008)(356005)(7416002)(186003)(70206006)(36756003)(54906003)(5660300002)(2906002)(86362001)(8936002)(8676002)(82310400004)(81166007)(16526019)(47076005)(40460700003)(426003)(26005)(508600001)(70586007)(6666004)(36860700001)(336012)(316002)(110136005)(2616005)(1076003)(83380400001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:37:08.6120 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2dd5a6d3-cc3a-4e9a-bb58-08d9f11f2339 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: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1895 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The print_speed can be as a common function, and expose it into misc helper header. Then it can be used on other helper files as well. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/cpufreq-info.c | 59 ++++---------------- tools/power/cpupower/utils/helpers/helpers.h | 1 + tools/power/cpupower/utils/helpers/misc.c | 42 ++++++++++++++ 3 files changed, 54 insertions(+), 48 deletions(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index f9895e31ff5a..b429454bf3ae 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -84,43 +84,6 @@ static void proc_cpufreq_output(void) } static int no_rounding; -static void print_speed(unsigned long speed) -{ - unsigned long tmp; - - if (no_rounding) { - if (speed > 1000000) - printf("%u.%06u GHz", ((unsigned int) speed/1000000), - ((unsigned int) speed%1000000)); - else if (speed > 1000) - printf("%u.%03u MHz", ((unsigned int) speed/1000), - (unsigned int) (speed%1000)); - else - printf("%lu kHz", speed); - } else { - if (speed > 1000000) { - tmp = speed%10000; - if (tmp >= 5000) - speed += 10000; - printf("%u.%02u GHz", ((unsigned int) speed/1000000), - ((unsigned int) (speed%1000000)/10000)); - } else if (speed > 100000) { - tmp = speed%1000; - if (tmp >= 500) - speed += 1000; - printf("%u MHz", ((unsigned int) speed/1000)); - } else if (speed > 1000) { - tmp = speed%100; - if (tmp >= 50) - speed += 100; - printf("%u.%01u MHz", ((unsigned int) speed/1000), - ((unsigned int) (speed%1000)/100)); - } - } - - return; -} - static void print_duration(unsigned long duration) { unsigned long tmp; @@ -254,11 +217,11 @@ static int get_boost_mode(unsigned int cpu) if (freqs) { printf(_(" boost frequency steps: ")); while (freqs->next) { - print_speed(freqs->frequency); + print_speed(freqs->frequency, no_rounding); printf(", "); freqs = freqs->next; } - print_speed(freqs->frequency); + print_speed(freqs->frequency, no_rounding); printf("\n"); cpufreq_put_available_frequencies(freqs); } @@ -277,7 +240,7 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human) return -EINVAL; } if (human) { - print_speed(freq); + print_speed(freq, no_rounding); } else printf("%lu", freq); printf(_(" (asserted by call to kernel)\n")); @@ -296,7 +259,7 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human) return -EINVAL; } if (human) { - print_speed(freq); + print_speed(freq, no_rounding); } else printf("%lu", freq); printf(_(" (asserted by call to hardware)\n")); @@ -316,9 +279,9 @@ static int get_hardware_limits(unsigned int cpu, unsigned int human) if (human) { printf(_(" hardware limits: ")); - print_speed(min); + print_speed(min, no_rounding); printf(" - "); - print_speed(max); + print_speed(max, no_rounding); printf("\n"); } else { printf("%lu %lu\n", min, max); @@ -350,9 +313,9 @@ static int get_policy(unsigned int cpu) return -EINVAL; } printf(_(" current policy: frequency should be within ")); - print_speed(policy->min); + print_speed(policy->min, no_rounding); printf(_(" and ")); - print_speed(policy->max); + print_speed(policy->max, no_rounding); printf(".\n "); printf(_("The governor \"%s\" may decide which speed to use\n" @@ -436,7 +399,7 @@ static int get_freq_stats(unsigned int cpu, unsigned int human) struct cpufreq_stats *stats = cpufreq_get_stats(cpu, &total_time); while (stats) { if (human) { - print_speed(stats->frequency); + print_speed(stats->frequency, no_rounding); printf(":%.2f%%", (100.0 * stats->time_in_state) / total_time); } else @@ -486,11 +449,11 @@ static void debug_output_one(unsigned int cpu) if (freqs) { printf(_(" available frequency steps: ")); while (freqs->next) { - print_speed(freqs->frequency); + print_speed(freqs->frequency, no_rounding); printf(", "); freqs = freqs->next; } - print_speed(freqs->frequency); + print_speed(freqs->frequency, no_rounding); printf("\n"); cpufreq_put_available_frequencies(freqs); } diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index f142fbfa4a77..4c24c25a7b07 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -200,5 +200,6 @@ extern struct bitmask *offline_cpus; void get_cpustate(void); void print_online_cpus(void); void print_offline_cpus(void); +void print_speed(unsigned long speed, int no_rounding); #endif /* __CPUPOWERUTILS_HELPERS__ */ diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index e0d3145434d3..d693c96cd09c 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -164,3 +164,45 @@ void print_offline_cpus(void) printf(_("cpupower set operation was not performed on them\n")); } } + +/* + * print_speed + * + * Print the exact CPU frequency with appropriate unit + */ +void print_speed(unsigned long speed, int no_rounding) +{ + unsigned long tmp; + + if (no_rounding) { + if (speed > 1000000) + printf("%u.%06u GHz", ((unsigned int) speed/1000000), + ((unsigned int) speed%1000000)); + else if (speed > 1000) + printf("%u.%03u MHz", ((unsigned int) speed/1000), + (unsigned int) (speed%1000)); + else + printf("%lu kHz", speed); + } else { + if (speed > 1000000) { + tmp = speed%10000; + if (tmp >= 5000) + speed += 10000; + printf("%u.%02u GHz", ((unsigned int) speed/1000000), + ((unsigned int) (speed%1000000)/10000)); + } else if (speed > 100000) { + tmp = speed%1000; + if (tmp >= 500) + speed += 1000; + printf("%u MHz", ((unsigned int) speed/1000)); + } else if (speed > 1000) { + tmp = speed%100; + if (tmp >= 50) + speed += 100; + printf("%u.%01u MHz", ((unsigned int) speed/1000), + ((unsigned int) (speed%1000)/100)); + } + } + + return; +} From patchwork Wed Feb 16 07:35:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 543593 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 A7A25C4332F for ; Wed, 16 Feb 2022 07:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbiBPHh5 (ORCPT ); Wed, 16 Feb 2022 02:37:57 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230288AbiBPHhu (ORCPT ); Wed, 16 Feb 2022 02:37:50 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2053.outbound.protection.outlook.com [40.107.101.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C111B19E70D; Tue, 15 Feb 2022 23:37:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CcdSdeE34mMyG0DDql+hMLnqrnTTJdNVr/WgjcYzMy8/OhYW9L54cceH92M6dQoUjgqoBHCFGYMia7clQ8IhuQFjjBNOeBfbQxAdyQgQCC2DtUxPfI9/01FFXKQmc1T40HMDKr+enIIizvYN1ktM/gQafTZrsHiK929bcAUK/O70zxTngwl9JhEOhcvlPGl8KhCoFyQasxphI0/gthWsr46l3F1y5Cb28DWI9IvGghTmYTTrEckiIGVcGGzPBqg8eOAtIki8+JZdB9OQq5FSVI+CbKMvvGr35hKZl+3tHNX9NpYDe2TYuR6NyancNOloFoppxV/rfkTbi5JniWtD0Q== 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=ntM2vAvRUEsIYU3tmYcaEbnt/SKffC1nD7ZJPLbXIKI=; b=UXZn7xrX7S18w5ZSVSVv06CwWso5s8213229akZo6bRugIy7mJJhFNisxxlPWFe4qpavPncpVZwrojy5Dz8gdKeX4mTTyaOKjbmDiL8ZmnLpt5BinX7hNLOfTY3dacJxuXfZ+7JullMTMQIuUtHxo7wa55hLsJrCsfDuffA5DKPdtbzRyiSLvkjp8kpvtgNO53Oc3DuoDcue2e/BbsVf4xD+sEPVTCLVVdG3goUHVvPhaUZYgqvrcGQfjtF47YSaJ5uVx64ggqkSqgB9CDBJv/VvVexwojmEkZPlEy7EY8TDhZBjo6xCVlSCdTVj7s/WmzVnhmHOxncROMZI5L3Z9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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=ntM2vAvRUEsIYU3tmYcaEbnt/SKffC1nD7ZJPLbXIKI=; b=IOBvRBHZWWXG2rBRlpl/x8WkncajSbi90xvgUHmTCzBx4MCsS7+VgtVWa7gryl3k3L8UzoTEn1QIIOna48fYQOTLqXHdAtRLRpoFsChWdnJioOUTq78fLXM6UMAVqixaAuRq2JjlHGpfFZDGB5MaC/5NMVWazKItZEPgPvqat5w= Received: from BN9PR03CA0659.namprd03.prod.outlook.com (2603:10b6:408:13b::34) by CH2PR12MB4808.namprd12.prod.outlook.com (2603:10b6:610:e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Wed, 16 Feb 2022 07:37:13 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::46) by BN9PR03CA0659.outlook.office365.com (2603:10b6:408:13b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Wed, 16 Feb 2022 07:37:12 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 07:37:12 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 16 Feb 2022 01:37:07 -0600 From: Huang Rui To: Shuah Khan , "Rafael J . Wysocki" , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , Perry Yuan , Jassmine Meng , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Viresh Kumar , Steven Rostedt , "Giovanni Gherdovich" , , Huang Rui Subject: [PATCH RESEND v6 9/9] cpupower: Print AMD P-State information on cpupower Date: Wed, 16 Feb 2022 15:35:58 +0800 Message-ID: <20220216073558.751071-10-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216073558.751071-1-ray.huang@amd.com> References: <20220216073558.751071-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05e6cb64-6301-4147-5593-08d9f11f25c9 X-MS-TrafficTypeDiagnostic: CH2PR12MB4808:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:655; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5xhJC08v6QirdcOxpjUi3Jhg7DXWZS1VbmRaP8cSz2hvDVIoNt5J8Vzp1jmSN5heM37ENvTM+CYM5AezugL5pFK6MynwnT7Q2L5ueiiXEogyAH9pAp+qaZLkSh7jkAZ5fkDKww77VP8f8fDkbqMDk2GUzKDbe84b4BISB0DtRtxwSPiK8+JvlsNSzhrtMstHFM9w27BcUgpuWmaQR+X3wxBcvYma6j2XDPj/xn+t9zs6iNfMVWJNQxg4SkwxTqTGh9m+Gf2V7eaFRq6RnKGACm9++GM+zYJWmOaz8IMGQfiWQX5cvfPjL7pKYYg2GGQF/z2I91Vkb6VOaYAFzZ5FlCbRl3nMKHEaIOZ4I6uBX7GkJpIFyKmgBaxENrQsqvSg531QIquXap8E5lxhEG+x/LkBb4DW4f+wCZRdvqir2gB4/XzQP2lp2cIwrQ17sJ0a1f7cU00s98WyCNhvrad2zfNTqgWYUHc8RnNhF68MoRnLJbGTsvELJOBHhdsdP2nb8KgufWByBPZQrrH2APfykmK5hRegjLj1fMQrCCRUE+khZRiN8Pw/r5jwdswjucA8uQjN2ROhOiJe6X2tR+sEmqJeMVLN/12NKj8SUFOYCLlj7CeNZMKCX+1RRUn05pzsbvbNW9WA3iXgq/bEVNuw7uJQ2BqSxIqbbvHcK5JQEu8DUaLFPKgbAEcndLdmqcS91E00z5enXNCINsnMHUWSUw== 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(1076003)(5660300002)(336012)(16526019)(6666004)(2906002)(26005)(86362001)(83380400001)(8936002)(186003)(426003)(7416002)(356005)(40460700003)(110136005)(508600001)(2616005)(82310400004)(7696005)(8676002)(47076005)(4326008)(36756003)(70206006)(70586007)(316002)(81166007)(54906003)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 07:37:12.9242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05e6cb64-6301-4147-5593-08d9f11f25c9 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: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4808 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org AMD P-State kernel module is using the fine grain frequency instead of acpi hardware pstate. So the performance and frequency values should be printed in frequency-info. Signed-off-by: Huang Rui --- tools/power/cpupower/utils/cpufreq-info.c | 9 ++++-- tools/power/cpupower/utils/helpers/amd.c | 29 ++++++++++++++++++++ tools/power/cpupower/utils/helpers/helpers.h | 5 ++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index b429454bf3ae..f828f3c35a6f 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -146,9 +146,12 @@ static int get_boost_mode_x86(unsigned int cpu) printf(_(" Supported: %s\n"), support ? _("yes") : _("no")); printf(_(" Active: %s\n"), active ? _("yes") : _("no")); - if ((cpupower_cpu_info.vendor == X86_VENDOR_AMD && - cpupower_cpu_info.family >= 0x10) || - cpupower_cpu_info.vendor == X86_VENDOR_HYGON) { + if (cpupower_cpu_info.vendor == X86_VENDOR_AMD && + cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE) { + amd_pstate_show_perf_and_freq(cpu, no_rounding); + } else if ((cpupower_cpu_info.vendor == X86_VENDOR_AMD && + cpupower_cpu_info.family >= 0x10) || + cpupower_cpu_info.vendor == X86_VENDOR_HYGON) { ret = decode_pstates(cpu, b_states, pstates, &pstate_no); if (ret) return ret; diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index f5ba528dc7db..c519cc89c97f 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -193,5 +193,34 @@ void amd_pstate_boost_init(unsigned int cpu, int *support, int *active) *active = cpuinfo_max == amd_pstate_max ? 1 : 0; } +void amd_pstate_show_perf_and_freq(unsigned int cpu, int no_rounding) +{ + printf(_(" AMD PSTATE Highest Performance: %lu. Maximum Frequency: "), + amd_pstate_get_data(cpu, AMD_PSTATE_HIGHEST_PERF)); + /* + * If boost isn't active, the cpuinfo_max doesn't indicate real max + * frequency. So we read it back from amd-pstate sysfs entry. + */ + print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_MAX_FREQ), no_rounding); + printf(".\n"); + + printf(_(" AMD PSTATE Nominal Performance: %lu. Nominal Frequency: "), + acpi_cppc_get_data(cpu, NOMINAL_PERF)); + print_speed(acpi_cppc_get_data(cpu, NOMINAL_FREQ) * 1000, + no_rounding); + printf(".\n"); + + printf(_(" AMD PSTATE Lowest Non-linear Performance: %lu. Lowest Non-linear Frequency: "), + acpi_cppc_get_data(cpu, LOWEST_NONLINEAR_PERF)); + print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_LOWEST_NONLINEAR_FREQ), + no_rounding); + printf(".\n"); + + printf(_(" AMD PSTATE Lowest Performance: %lu. Lowest Frequency: "), + acpi_cppc_get_data(cpu, LOWEST_PERF)); + print_speed(acpi_cppc_get_data(cpu, LOWEST_FREQ) * 1000, no_rounding); + printf(".\n"); +} + /* AMD P-State Helper Functions ************************************/ #endif /* defined(__i386__) || defined(__x86_64__) */ diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 4c24c25a7b07..f913de87622a 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -142,6 +142,8 @@ extern int cpufreq_has_boost_support(unsigned int cpu, int *support, extern bool cpupower_amd_pstate_enabled(void); extern void amd_pstate_boost_init(unsigned int cpu, int *support, int *active); +extern void amd_pstate_show_perf_and_freq(unsigned int cpu, + int no_rounding); /* AMD P-State stuff **************************/ @@ -182,6 +184,9 @@ static inline bool cpupower_amd_pstate_enabled(void) static void amd_pstate_boost_init(unsigned int cpu, int *support, int *active) { return; } +static inline void amd_pstate_show_perf_and_freq(unsigned int cpu, + int no_rounding) +{ return; } /* cpuid and cpuinfo helpers **************************/