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 **************************/