From patchwork Tue Feb 22 15:34:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545153 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 0D869C433FE for ; Tue, 22 Feb 2022 15:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbiBVPf0 (ORCPT ); Tue, 22 Feb 2022 10:35:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233084AbiBVPfY (ORCPT ); Tue, 22 Feb 2022 10:35:24 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B0016305C; Tue, 22 Feb 2022 07:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZzoue4qnopXwJCilAk3QeQ5AOUm6Tv0wHzaKucrc4sgNZlwxRybDLQg0fF+Ui5LR2mRq/OOsvZ+WSqZDhUOwPVeSSoPYUggceYHi8PjzIzqkqAxWUnuK+vyUVn72iXC/WNu7ATkbOPgv14yDl7HhbAlOQ8R8+jw2mxfbeDmb1JVRue1F3uONjFvYW0ERMYNEqzYzQ5CF/Lw5vghaXflZVp9Piz/F8QOtAXrKliQIK2bu33tqJyPztdf845xiUFaIxfNYStkWxhREJEozmTkRcYOohxk3C+Eu2SYUGJGitPR0WxFCFbFjjTipW87NhpOPkYz1O4h9YwLeHYIxmBtQA== 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=oK9okzPyW7i8orRLXLmdarIV7KYUvABI2o7hW1xPlBWdi5xFFlgV6ROyKoItuTwaAp3YFbaj0PUU7rr0oSvwkyLoL52nUUu+Ub62H/iRoOCvZlACuHpFKjGckyHWrF6IwqNhbkoH3uCawWuavoQ+anN2ML6SJggaqQf67/NkErjOrs8zg0d/u36S3ActrNYERTwA2R3//53hZMkXn7YkoDfpwqFGnzXZic0Jx8vJAdGNdYdk99JwP0VLl81I/OZudF2VLIxwaw7sU9ZzeVdXiDhmqhsZ3lmc7bSSNsd8cvd+rCeTHL5EIBsbadvtTkvCLpNY3orWJz/YXhV1c0jhJA== 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=c50TDP0T6qdrSC2n+mP75cY4xBH6aJ5kIi/x3Up0oRt3KHfc6T2mw0SbI6/vy6p1Ld/vtqIvmvJeRVltl07SryAUw4XUs60XXK5WnHQ+E/Muz/c7jXZ99M4/J6J2TDgwuAD5bp8WYxYGmQtTHHzvNzqiH8KoUTzoZXuYu/KhULI= Received: from DM3PR11CA0021.namprd11.prod.outlook.com (2603:10b6:0:54::31) by MWHPR12MB1376.namprd12.prod.outlook.com (2603:10b6:300:13::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.17; Tue, 22 Feb 2022 15:34:56 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:0:54:cafe::be) by DM3PR11CA0021.outlook.office365.com (2603:10b6:0:54::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22 via Frontend Transport; Tue, 22 Feb 2022 15:34: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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:34: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; Tue, 22 Feb 2022 09:34:50 -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 v7 01/10] cpupower: Add AMD P-State capability flag Date: Tue, 22 Feb 2022 23:34:17 +0800 Message-ID: <20220222153426.2216974-2-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: b892d513-f342-472d-938c-08d9f618e075 X-MS-TrafficTypeDiagnostic: MWHPR12MB1376:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nCDEqYvIeod14w2wdMzSM8F6S2VKi49AYa016XaT4YzaY2Tea7AEJMTi6fwNg9tqEVN3jX1b9mWkHW6AYeSJ8GLhYyVwzFYgbuzCF0cBeEMwmAzADAT4HF4UlZrjQaVeNyAuren/KEpJRUZ1bU6b/jfSe2v7Xhm/hkQlFgFw8hDuFSNPKlpL3FlR6ffQk65H/4YIpui+h8BMR3t67p/zHOa6OEXnv3Fo0sY+fYS3lQEcO4rxEPcumamXGENAz/Eggtux7Y3Qwp6gUA5qy0GiEfaY+PIBDpKqnzkNvSba7umuZr+B6rODcfcE8d5CpV4Q51Uo6i8ryr0muleWWHmaBQ1iG1blh1Uchn1D/A79YaWCHBhlfpviKb2IUzTynLbmC6uaA3NQmTgf2XUJ9dLX/i2K3xIgLFrVkF3VAZvWTK2A7xl+C+Il9015E+jooysKytea51K/ouLJgJrCtimMGnhlCY4eRp7SiHyEw0CqIIZl+otdXasEZ14z35oxT2F5xT1abLNO1XKsfW7KOB2vu8jfa5GdLoWGzQ6Mc5zYBMgduApdEMuSzMnFyDb2IEBuOz1CjCrzPo3SHLfAaVPjSYShYnFfouRkpmjAYfMQfCzZ/bAbF9jrH3z2q3KajBMuLcVkDjc2qrDljKlgGW/Roc928fmJfBqe+QzpGmSwF2KxEv7IGVluArrO7ILIHbYJfT2TPUbSJXBZWSg6N7F8OA== 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)(46966006)(36840700001)(40470700004)(86362001)(40460700003)(7696005)(26005)(186003)(81166007)(2906002)(36756003)(6666004)(356005)(36860700001)(47076005)(16526019)(8676002)(70206006)(70586007)(316002)(54906003)(508600001)(426003)(336012)(82310400004)(4326008)(110136005)(8936002)(7416002)(4744005)(1076003)(2616005)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:34:55.3992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b892d513-f342-472d-938c-08d9f618e075 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1376 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 Tue Feb 22 15:34:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545502 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 E3731C433FE for ; Tue, 22 Feb 2022 15:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233168AbiBVPfd (ORCPT ); Tue, 22 Feb 2022 10:35:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233405AbiBVPfb (ORCPT ); Tue, 22 Feb 2022 10:35:31 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22EA163062; Tue, 22 Feb 2022 07:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dx6YvNEK7jAcWHCQhiBwSs6WFOE4LW2OIkuKnQy7/QZ1Y60OuDylJTkQmVtpyEk6kH9Y9uBkX/3RAKrfKO8PtYacTMpvMeHe13JSYYJzyUp+8PgfCSLYaTRh9oseH1RM9iOGJllZ3UZ3M+xA26siA6VZ1RjGrv8hn1YtcbTiWuRLjVI5+4KXGSe/pe6jBrX9wIUkyrqp2ns5iMsgmQtJV2OG1OKHeQ8XGm/yh/mCID3ysIhjQDJC84NIAQE9qTpoCVpzCY6n6OwMef1cL9YuydgtTlvQ0yZ9/texoESk7qLRsClq5tbvtgdFFO+icR8ZS8FWNXQcyWjL/o18q/UCng== 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=IR0wBb+b8UoTM1GoiX/M5OJbOl1cycbDU15JfAwfGLw=; b=FsNkp1noyC6qwz4Vm3XTXOH0XH3g5Tg9ynJlyzmDbk7Hg/Vh8y7od1Fdz8ZAzJt33ja+3blGRlt+ZlNEI+cz/CtzhYbH+1yXXFeuq96+SFUrCxXmLe0OLLF6EwbEKWYB6e4h0Q9R1DGnDD2Z2g0eEP5DnvQnd44RDuHWq4fHnVNTbXyShlYFB8GQThOlJ4W5obKFDvavPyUdHFcxgYfG8483plgnrb6jgScPlBSQLt0I9e2OxIfVbbyy/PSqCx7MqLrk4jnIvfW/ZrLMjJmC/IK6aRXkbQgXxvRPkuiP2goLDqRrGpjxVi3P4hPJ4w71wWxG8q3CzwyaqrWWhfQQYw== 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=IR0wBb+b8UoTM1GoiX/M5OJbOl1cycbDU15JfAwfGLw=; b=ITZFVR7sOAj/+2WMW9JLf9mu8f8a0hlbyVDNAOHEBjT1dMALqSbDMEY9uCSKF5jZKiRUgOvkNcXRgyqOyevAs71BejZycEGGqkwqLPeH4rejZIGti9616BgzS6OMMKfeXYGASLmBwZrd2yjV2p18Q36nB2sA9mb2oFPizecUMZM= Received: from DS7PR03CA0148.namprd03.prod.outlook.com (2603:10b6:5:3b4::33) by DM4PR12MB5373.namprd12.prod.outlook.com (2603:10b6:5:39d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.22; Tue, 22 Feb 2022 15:35:00 +0000 Received: from DM6NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::58) by DS7PR03CA0148.outlook.office365.com (2603:10b6:5:3b4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21 via Frontend Transport; Tue, 22 Feb 2022 15:35: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 DM6NAM11FT031.mail.protection.outlook.com (10.13.172.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35: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; Tue, 22 Feb 2022 09:34:54 -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 v7 02/10] cpupower: Add the function to check AMD P-State enabled Date: Tue, 22 Feb 2022 23:34:18 +0800 Message-ID: <20220222153426.2216974-3-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 06af5af6-0287-4fd3-0561-08d9f618e351 X-MS-TrafficTypeDiagnostic: DM4PR12MB5373:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0MFC94RKjT47mzjy7sEPcRW8oZwqdAPMSi3vzJ98/ZTDiWb2V8IVDYP2NVsd/6EC+DDDgJrzYtJ7KqawotkRoWueXOIrRNzlKuGdxwubi/T6oC6/tiytqxUeT35KddaTn5aJ7VNR5KzjMmeK+r1d43Bysxi0rLVq1mpinfzk0/6ks0N109b9Qnx6hDQOtozkpE+oX+TK5v+NsdLN0UQY1+wefdvLNGTOFiVSrBZtXahrUDrmelbwO0Z733QSg5QFFnAc4d/AdJuWJEaqz2f6sRODtxB79vu5X6X9E6NDHv6NC6T23Vre6YA0KmaE451oOZkRVdyFoRPHP/6OQrY2OiEAlNbvkyz5QNf1FNZNXb4DbyhSNAIot0CF84mEbjzYIWmnb2Dw7Kg5S7pEXhBchgMa2B3Zp1PGhlQn7cTBmEJf872D0NgrirsnKlZKElLXyX5ieCKWFP0KvGfNWJPGedi2ay+QipxOHBA7SdE0K6IOyZETxmRI12EAz6y7frWpfpcVdqLhDzT16Qvo+6OhEs0VYudsLke7WScpugAtUwzuZNOEIL/DrzJi7Oh2Y+yJ8TmYnypwxdiJTROyLXe7xk4JwxLdk9P38PgvF2oVvxj4NorkSSyCBTvV1YZX/ow3eZusnn2j3IKr/dGusQWNj8awA0QfW7PLigC+d4H0YU3njJ8i21nSZ3VO98vl/cWPVjHlvsEOUeVHzkUUVFZL5w== 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)(46966006)(40470700004)(36840700001)(336012)(7696005)(70206006)(6666004)(316002)(186003)(110136005)(40460700003)(426003)(26005)(82310400004)(47076005)(86362001)(4326008)(36860700001)(8676002)(54906003)(36756003)(5660300002)(7416002)(2906002)(8936002)(2616005)(1076003)(81166007)(70586007)(508600001)(356005)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:00.1927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06af5af6-0287-4fd3-0561-08d9f618e351 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: DM6NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5373 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..62771a086871 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 **************************/ +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 Tue Feb 22 15:34:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545152 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 00BF7C433F5 for ; Tue, 22 Feb 2022 15:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233491AbiBVPff (ORCPT ); Tue, 22 Feb 2022 10:35:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233493AbiBVPfd (ORCPT ); Tue, 22 Feb 2022 10:35:33 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2062.outbound.protection.outlook.com [40.107.100.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0448A163060; Tue, 22 Feb 2022 07:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HeQrJv+k7WXd6h+hEX/rHEwMYGyaAI0hapTSFPDhxrUlY1MNv5qmCQGkMhKqotzSOk/EzU06CemhAknI7OKC9fyDO8dM0tIPmallF47qZj/Ivl055P4jz0RzjziOErrglL2Dq3b5j1F5intEOGl+xDUF9M8+GwoETs3HhG3wBDsLODGNyOU44bsm+C/ggkuvnMxcNtSvM8imEHi3OgtVwFQrFqUjGxTrYWXQ7EonCE+qhYVW6jycVcSb9gOPevZ+96IIjFgJNcn7fnzgsnKDkEpHkJJL8ncuihQeJkhcgIkqXHoxPJqsJdj54XiPiIkM3qcZkWlD1Y0DAkooA4bxtw== 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=hZYahQu5iEjhfP3QAOK+o2FnB8+7hpWZZwWdhhQpHSC/fX3idN4Dlhp0jgK6R2tMGEqclQh6Ljx8xfDz+A8YRoVZ7EJOpTNr6qtaJqikSeF4f+uGd/ujd8Zir1KAn8mkb6qZx1jhrLFxQ5/Oblyp9VDSQA83DQijkC07HlYTZ/TC+zkQBu9R6AvZC6uYv8xqBAwSXuMxEIi7f6FEWEwPxakMez53zpPF7atUJjNKATAOcpD/bi42MkSgBeUo7J3K9lGijptCxEiD9hKRboS2UGuOcwO4gb0ee2BHzFRqD+Zc1f2DOTF4Lt/dVGgbMFyrMWnOJM58wJawFgx9iLkE+g== 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=r99ackZXrKbrDodUV/imlIfwYJRRoNHgXXULiv1p81m820Hb/MZb4xrWuplBZMs8WW21cI+FjxDPkLPq40vEdfUmSLI/UITw6AACx03tvFp7bFs1PvAz4smWjoLWS2ZhU3CL7NzRlI1vQXLjcDtx/TT84KWPUhD6RRNSxkv4paw= Received: from DM3PR11CA0007.namprd11.prod.outlook.com (2603:10b6:0:54::17) by BN8PR12MB4771.namprd12.prod.outlook.com (2603:10b6:408:a5::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.17; Tue, 22 Feb 2022 15:35:05 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:0:54:cafe::9d) by DM3PR11CA0007.outlook.office365.com (2603:10b6:0:54::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21 via Frontend Transport; Tue, 22 Feb 2022 15:35:05 +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 DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:04 +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; Tue, 22 Feb 2022 09:34:59 -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 v7 03/10] cpupower: Initial AMD P-State capability Date: Tue, 22 Feb 2022 23:34:19 +0800 Message-ID: <20220222153426.2216974-4-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: cfbdf9b4-31e0-4a93-4a82-08d9f618e62a X-MS-TrafficTypeDiagnostic: BN8PR12MB4771:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o0xb/Ka1XQ3xKEPa+Znocvn2yQhR+LKS9HCxjaN2rtYXlx6eeYDAFYXsKPoanvD4Ik9OEzIeSUn1/MPEMtm2Rm4qNl82Q52x5WcI+ESRGQ7I8HDP66KfHuHaizcid0SFIOynC+IZ3Ka76yjRoaBDpsIlgxVwUsZS9j6rrlp62ZlSx64U6o6giUnHpsbKtFwdJdUJLQhBfzaGXwQl+hQtFNLV3GVEgYqcfyXEY+A0DDHZ099rcefzXVuHpa7hwT+sRFq06kH19mTaRusPI+QyIbFSlG/DXqPPB2fuEIfPpr+5fQqjtohf+lgpoYOH3o04TaxJT1hXJjs4x3JLV21K6PTDr0LlS7bFIF/9QRpkVQRnMoUpb7+CxceqD91YNQQk9QsvzsKIon2bz/gjv62OjdqUiIvKBLILFUnBJ9HizEoaN/7mBYe4D9Hb4IZAX4U82FeSQGItyk8VrG4gwEbcUvb/FKa69nQXd394vVtfgIj/D84XN+Dqrnbz7F6FsaKiuJDMWZLyjBvg1AgxxRABUXFq4Zb+QRDlj9PKwSr2S15SBfjfOgcdsgkCUdK8/N0CFAbzFWzDhbD3gX+Khhn5O+83NS8OxmrZrkxxfzZK4cl9NEQF7wrn4rQ+fJABkuNqNoL5zeI+u23U+DTs4MHBrVoFXo/xvZjeBnqA7IJwi9N8hLZvhk82e7CWeyTzifmEe24FthnYRl3SGLIr0Vs1Uw== 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)(46966006)(36840700001)(110136005)(54906003)(40460700003)(7416002)(47076005)(316002)(36860700001)(336012)(2616005)(5660300002)(2906002)(1076003)(8676002)(36756003)(426003)(7696005)(508600001)(70206006)(356005)(8936002)(81166007)(70586007)(86362001)(26005)(16526019)(4326008)(82310400004)(6666004)(186003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:04.9721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfbdf9b4-31e0-4a93-4a82-08d9f618e62a 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: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB4771 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 Tue Feb 22 15:34:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545151 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 40D3AC433F5 for ; Tue, 22 Feb 2022 15:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233251AbiBVPf4 (ORCPT ); Tue, 22 Feb 2022 10:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233524AbiBVPfr (ORCPT ); Tue, 22 Feb 2022 10:35:47 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2042.outbound.protection.outlook.com [40.107.236.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3073163D47; Tue, 22 Feb 2022 07:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RoASEehTer57OAZbwwljmAUOxTBmJXKr5MLFmWq4ylrKU/BkYQ8+lIm3xd07YSy8ZLB42VIwq3/W6jU9kJNl/EIoEk3Gsh0V/F5ql820iCVxb6xnPacRnGMS0KGzldYoPip7ZMGIMWTI/Q095O4rPJHCtXLPyHxnhnbsbW8+rK3kcYrNaPTjmw+n8nz7Um+R/J1iqsVB1r8GquddAxDZqHnQZIExp1Z/+7gsC4diuTbdnBFPxJ7NFYL6249if5zULNFacxFDdytfo5ryNWGqWXMauW+Mp+/6Wc3IG18N2J7Sajjky4f87fYzE3HaOLcKX9bZoUqf8Oz0qT4f8z+RZA== 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=EsCkX7QoRw25vkfoybD4NlCtdj6eCweUKUNCEZE2v6Q=; b=aCgp50IoMqgYNPRwBD5lOlsb39Wsxv3ZETJgwhI7ODIjSYfJ13M71LjifexgU9pi43oELa+oygldgdcwkwjbvS7eNgoCn8ymU5zo4nAPPtnz5/NZbJsAeYHtHZXZbGi/Lvs2TIAqE8nrO6RhvxoQlEg4p+ygObSGoNV3oV752dIPOdY34OPCJVBvYpOfWV2uxuHotcfsLzl9sNa+nc26EhnZD130jD3ODjeeEnO9ZPFOojXqU2T1/V41ztAi/qosUkNs5hyHiP0b44slYbOmlO4WjPmNq39sKxYStuHRpG00KQZXpKPNFIZzpVOcHfhDTpIlqsatgqQ3x3i3LpmE0Q== 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=EsCkX7QoRw25vkfoybD4NlCtdj6eCweUKUNCEZE2v6Q=; b=apFxeHxlMg/1ISxjOJD2LWuxcMQW6/iKQRCRAH3weIUPs3Irc40Ctc7T0YZ+an39uVX1nc0hVL+nbxHH4J/PwZvX9oloqYEcGzSlEuLYCjG6YBvO43ck88fcaZijpR51G+huAKT3AshsWZZkmf6yezuK2sWAGEc87+AbY5Hx9Ek= Received: from DM5PR19CA0052.namprd19.prod.outlook.com (2603:10b6:3:116::14) by MW3PR12MB4427.namprd12.prod.outlook.com (2603:10b6:303:52::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Tue, 22 Feb 2022 15:35:11 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:3:116:cafe::eb) by DM5PR19CA0052.outlook.office365.com (2603:10b6:3:116::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21 via Frontend Transport; Tue, 22 Feb 2022 15:35:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:09 +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; Tue, 22 Feb 2022 09:35:04 -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 v7 04/10] cpupower: Add the function to get the sysfs value from specific table Date: Tue, 22 Feb 2022 23:34:20 +0800 Message-ID: <20220222153426.2216974-5-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 3ac9eae6-c85a-4438-26cc-08d9f618e926 X-MS-TrafficTypeDiagnostic: MW3PR12MB4427:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fFRt1QmcrQ1c24QRLJRBTd+jxE9j3RoZ77h3cO83yFyYXShjr0hTjKKi6hgmaKKA0KKTR/vt4UmNqc1WzhHwLzWFgcBmsjsrvUWuvBdbVpJ7ALWaKCkaN83kbyjwAKlXj1F2lx3EYkN1Amb6yalquMGVa+syGDQEjukLJTiKT63Vk0GdWw/O2RmjG0mcPKNkVHB2+ZaMyA+5ddXCQh1hgZgWBCUmqzx4VCQcPfOJdPEGALa6dyPQLk1WIXiE+9DZzbmnDYN+M5oDza3qwZZBzktCGKBKCb/oIgqbmAX8EaVbWCc5NWazly3soy4zGAlS9z5GlX26/7zgSE894XHz8+I2nvo4m7rFf9RsELdvFGTV9oETPVQzTQ6Yk1B+xjhc+YrZGEl0n9ChCDLU5ESHWBYB2NDbtKN7mMI7YUvhGKHQPsbHnjeFrFeFnDOtR9SupLKTSSzQhg0NkMGCvayXMA/8IVpDjOwtZIKmPu9d1qngburKplyH5zyJZi3Ww+w/1JaciYrTLbyJJhitjiQUXeLPr8Ky73wkRFQ+2MD70ykCl7tF+i2k4Dujd65aKxa7B9xVoI8vI5/8JCN/v6G5C1ltWX+9MJGf5aS4f9/AOr9gpGdDeLJloaxR7K0lysRuaX9VVNvE7b2myutk8MWPuxMZq5+zDzrSrXh3Ay/2K36+SbJViSa5aka4aviCBGSQgI1W3fZvF+F7gD1Yx4QcBb+2P7C3j0lmF+KnGmI5hYA= 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)(46966006)(36840700001)(40470700004)(70206006)(82310400004)(70586007)(2906002)(8676002)(8936002)(81166007)(6666004)(508600001)(4326008)(356005)(7696005)(5660300002)(316002)(7416002)(86362001)(16526019)(426003)(1076003)(2616005)(36860700001)(336012)(36756003)(186003)(26005)(40460700003)(83380400001)(110136005)(47076005)(54906003)(15583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:09.9781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ac9eae6-c85a-4438-26cc-08d9f618e926 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4427 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 | 23 ++++++++++++++++------- tools/power/cpupower/lib/cpufreq.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c index c3b56db8b921..1516d23c17c9 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 int index, + unsigned int 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 { @@ -124,7 +133,7 @@ static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = { static char *sysfs_cpufreq_get_one_string(unsigned int cpu, - enum cpufreq_string which) + enum cpufreq_string which) { char linebuf[MAX_LINE_LEN]; char *result; diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h index 95f4fd9e2656..2f3c84035806 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 int index, + unsigned int size); + #ifdef __cplusplus } #endif From patchwork Tue Feb 22 15:34:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545501 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 82A2DC433EF for ; Tue, 22 Feb 2022 15:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233516AbiBVPft (ORCPT ); Tue, 22 Feb 2022 10:35:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233492AbiBVPfr (ORCPT ); Tue, 22 Feb 2022 10:35:47 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2043.outbound.protection.outlook.com [40.107.95.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CACB163060; Tue, 22 Feb 2022 07:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F6PbjljuA+9b7HDYiHzYMj6JkMQug5gzCcpKVHpOJty20DLQAQb1j2KJ4ZPpWBRThqDt26JXHR6Z3K8YdFDbmo/V3ELTS7tVHxxLyPCibHDD7IwskEQowv0otyU3gnARAEOwMJzcbOOtbgvuYbxpBaHmfm7zqbyraeszYNliBt8xCn90fOSIKr5orhpPX8mF/Pe0l+eMsYhOzbVmSWMg1E3ki6AsJ6hlMoHf4kafB+jn73MzFN/isuDjGseYatZFUVSgACvF5fDOsZC5/yAmn6RL2/kAXiSbvl8ergU5FRC5RKS78p3bckCJIQmi0tzLGqIH+0feAiiRlf417ENZUg== 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=tZe5bDP64hYKiHZrC0wX8i/vH7xVvrgomx7/1q2O71M=; b=AtVf9VEhVs0PvTo5hB+aRxHib21rP59tI+qs4LUbIDpZi7S7vZ+esw4/PiJLdFMb0/qGYFl8b4uTkQeXnaV70IEcCUTuvNMxI/3xj48njiE5nElHGZqnFpGffYvX877mKLF9/x4jr72FI+nBO3W84yY3m64V+KtAkLjaYWdX6zgj1LJBpudOZ+RjHCbTTu2MjpFizIy8fRTUlsM8pvhhKG9vaRxKm0hpq6PVeUbsQLo/grIFkPX+nc3kGEUKb+12H9jhTgUKs71c6DjcJBdo8Ix6gtpDW+S6NiGVe4QN+3holmCxb/ROqZSNJFE8v5a2GyvUcgevHRy+2UsvFEQQ6Q== 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=tZe5bDP64hYKiHZrC0wX8i/vH7xVvrgomx7/1q2O71M=; b=VdyFNxJIFjvvXXFxosPqg3DWGmVh42wyYwaD0J7szLZdRBBaEnanl7HYrgUydR0seEJGi+4xk+0z7ok0V0OTtGEVndwZ7eyOBn8IFU+x1i4IlH8gpsd+VOnnZLbKPyXyM2b0a+QTebdFW4Zr0OAtRCu6MSFenzagtYDWdZoF/E0= Received: from DS7PR05CA0049.namprd05.prod.outlook.com (2603:10b6:8:2f::27) by DM5PR1201MB2505.namprd12.prod.outlook.com (2603:10b6:3:ea::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Tue, 22 Feb 2022 15:35:14 +0000 Received: from DM6NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::f) by DS7PR05CA0049.outlook.office365.com (2603:10b6:8:2f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.9 via Frontend Transport; Tue, 22 Feb 2022 15:35:14 +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 DM6NAM11FT029.mail.protection.outlook.com (10.13.173.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:14 +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; Tue, 22 Feb 2022 09:35:09 -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 v7 05/10] cpupower: Introduce ACPI CPPC library Date: Tue, 22 Feb 2022 23:34:21 +0800 Message-ID: <20220222153426.2216974-6-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 19dcd77b-f2e1-42ef-310e-08d9f618ebee X-MS-TrafficTypeDiagnostic: DM5PR1201MB2505:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7prKZ4eZBPzQg7MZYcj22egJDHHyKiyVX7O5AgjM09uY1Jb4e03UQYoH1UAUs33/WIzxr3zQkatOL4sxbxdxnjxA660cgYfZ5F3uENfBOhg15fGzeGE5llaFl14ViHsr1h+UqMQxyS7ZJNXgUTWCxiK8JVsVUYcJPh8nGUtMZlGcHoF5/MGRHYL7qGd0y1RFc1nre4e8mgxHU0ohETMTedGfKOiQ+z/cNyg4GnP0rKxHwt/DWWuWB2XPsNOj+YaqvPCE7VhvdtDUYyx+aX0UaSUI4s7yHm+vrzZNGuAgCSpwQPM/3Z3muOpiv/4lXaXBxs1JuNjxstG2HyoDE2wNfMQgvtGY319XIoAfiA+QjPAa8C8dTSVAP9zVjuSsw8PVZl5UJUQpbnlshrfevG67KcUnVkb1WGWpMhBPWk8ula+M6d9unFWmjHumnKimkNzbA1SQ2hcpEt8a7wzoWksuj1qI4/5TnDs4DzleI7NYZygskaRoj2zi2VXyypkm0YGPqP+Sj7bshtI6gRKpPkgWbJtdLVAEtBO4Nk0z5W1aMTnR9xJvGOz8Jptl30mDXnz8hgEeIRCFPPhqw0f4RLpDDZ+gNpw9xtB/ppmPd9FPDcnfFWcNixMmttIooCRn7LWwglcBavvR5RtyCG6deMsEJTTVJx/S3sGEfAxsYJ0OHQUHuydtizcQbobVGpbBN5MsbjSTNq9SwCg8/lzh3tSurQ== 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)(2616005)(336012)(316002)(7416002)(16526019)(426003)(36860700001)(1076003)(5660300002)(86362001)(54906003)(36756003)(26005)(40460700003)(83380400001)(186003)(110136005)(47076005)(82310400004)(70586007)(70206006)(8676002)(8936002)(81166007)(2906002)(508600001)(4326008)(356005)(7696005)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:14.6602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19dcd77b-f2e1-42ef-310e-08d9f618ebee 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: DM6NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB2505 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..c401ac331e9f --- /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 * const 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 int 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..85ca83080316 --- /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 +}; + +unsigned long acpi_cppc_get_data(unsigned int cpu, + enum acpi_cppc_value which); + +#endif /* _ACPI_CPPC_H */ From patchwork Tue Feb 22 15:34:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545500 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 87526C433EF for ; Tue, 22 Feb 2022 15:35:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233588AbiBVPgM (ORCPT ); Tue, 22 Feb 2022 10:36:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233545AbiBVPfu (ORCPT ); Tue, 22 Feb 2022 10:35:50 -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 62B5B163066; Tue, 22 Feb 2022 07:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dcyd1B2zHXBA2YYxXo/PeTAE+q9qNPZZU2UiEhmD4EjdZ+/cytWGQwCnubPa/tzS7jYQ5y1i7Bt9U8YOUi47oIvqsRg/kiuhMoTUaobRjPV4yhe6H3PfNpvVXoS4cwo6EBINKz51PdIj0Nnv8UTgmqexQlru+ERyi3EgXoAdtJRgsQeTCN2jVWLgJq8q15bfrd02b9vzjWnhSnFt70LZKAlnvUugogK/zOx5uqxqIU5vy0cJDzVz7ki8/0T9AO1MXGbnpqX8yTKAkU2jGnWuRQJjP8y+qYhj04BnMRNUDyzHUecq3CBAv8snZZrOonGQnv3KXtgIChDr7YIyJGG4Kw== 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=BC4JiBjmfdK03dQWJXqOnwk9xNkmmb7Elfsu0Oxwl0P9DgUUWMLLalb7yF8yi/2oR2pywiwqowS+7Mn+JqL2G2sZsnMBWXSE3GVZXqDqBQDouQZnOAJpYwufycvYT9WH+2tnbvvnmHqyBBN2zqoWvViMPHqWqZddurStqPdmAiA9LbQ4Eg+Nz0tbaXstLAzQsz792m+LFZzpOEvA9/0WYq6O4hp9kXl/NXn2byWq5Z+HuR7IuxWRJ3VtSupIZfAu6QAQErKtLxXzgVsNP9qd2qsmk1HKNidhsQUQR95mbuQW4KDb37Atylun30CIOgpf1KjWYBGRRBz5ZAojzUvWMQ== 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=V7sitmmTZcQIeK623UIPfB7yIAkD1tFTctjPtbk3zKG9H/KqAGMda92boasgT8GTqXUbJgss8ZEHlAlO09L2jvXMLQJwLmKBfdg8RFzgE1l/DSaSv35rN2RZLY5lDsKK70NQxJO016iyQZz/ZOs6geYEAcXVjxvZAYy11OcKBdQ= Received: from DS7PR06CA0023.namprd06.prod.outlook.com (2603:10b6:8:2a::14) by MN2PR12MB3088.namprd12.prod.outlook.com (2603:10b6:208:c4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Tue, 22 Feb 2022 15:35:20 +0000 Received: from DM6NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2a:cafe::73) by DS7PR06CA0023.outlook.office365.com (2603:10b6:8:2a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22 via Frontend Transport; Tue, 22 Feb 2022 15:35:19 +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 DM6NAM11FT056.mail.protection.outlook.com (10.13.173.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.20 via Frontend Transport; Tue, 22 Feb 2022 15:35:19 +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; Tue, 22 Feb 2022 09:35:14 -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 v7 06/10] cpupower: Add AMD P-State sysfs definition and access helper Date: Tue, 22 Feb 2022 23:34:22 +0800 Message-ID: <20220222153426.2216974-7-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 7cde8743-5e5f-4064-ab35-08d9f618eefa X-MS-TrafficTypeDiagnostic: MN2PR12MB3088:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qs17vQd3Yc1fPWhIhbzlheEi9hdLZFQEpEg/jUxajdmpP5GidYaZKzq/E/JXyPzOl2vFjNFzpSh0597RwpkSvy2oDcW+M748NOaoryqR66m3Ukcq5wXSozfpvSpGFe6QEwCXyuh5zD8NmJuAi/Wcy/3VSQCIII9xu6AxboWuF6m2ooftoXIKtnx+Yq7/13PtGr2eiVsv0P4zaSoMm9q3cE8SN5O1b3ZcmnYeOUOCe1QtRQT/ZozMt5tn3i2lsnz4HS9fOocNGVRGrHajjZuXw96/retyB0qeUMjVUIF3rEs5/+/3zG+caXirsCRQKuwQ7PZyITsqhMmfXDryrq0OvkjCjrWT4EGL90KFbicEdN3BAOym5dkd6YKyOlcS4zaXPOkQoGGb8/nRuX9/m10SAJb86SSqhFpb/0rL2wUL6J+plGRlIZZquG2TdqzzsBuKq7GLyJ4TP0SRrYVIjB5FtmYcLU9f7mJjczsYxIdU6Lp/sMKn9CdXeP90ZN7nBx0fAY+kYS7qcVLxamm6crZCHUwuhaxIwzVAWo9W+/uN4YTxQnkbcmJ4hzEALNZ8jrlt79irhNCb8mr4F06ZWn81FSe9HCI+4+AWDuPIIf+Pkyw6vJad87qFijfDA2oomqb6DYfPzuQdImIb3fz/yV3MdPn/RCbA39BjdD64IlZtQv48/uzaJGN9a1msvqfIWgZnKoEeLpARWWr4NPAn4sZH4A== 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)(186003)(16526019)(1076003)(26005)(426003)(336012)(70206006)(54906003)(2616005)(316002)(356005)(2906002)(81166007)(70586007)(40460700003)(36756003)(86362001)(47076005)(7416002)(8936002)(83380400001)(82310400004)(36860700001)(508600001)(4326008)(8676002)(6666004)(110136005)(5660300002)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:19.7751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cde8743-5e5f-4064-ab35-08d9f618eefa 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: DM6NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3088 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 Tue Feb 22 15:34:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545150 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 7192DC4167B for ; Tue, 22 Feb 2022 15:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233555AbiBVPgR (ORCPT ); Tue, 22 Feb 2022 10:36:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233247AbiBVPf6 (ORCPT ); Tue, 22 Feb 2022 10:35:58 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2083.outbound.protection.outlook.com [40.107.95.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0103163D52; Tue, 22 Feb 2022 07:35:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3nc5jRUm/RvsRc/UKoDoYBwUiJM7HrSW3p6MVUslnZSHm2j80zOVh9J4/fDpXUZTO4VMowyZ7zDtX46Pdj/nADnhBeAVYH2n26fgFt9R4DxgVp1RiLQFAd6o7FR9WDht0VMYz7X0C12P3sK6CXWtiR+cPJDakBS9tsYMRtiKvM4AdHLlsvDS2haLaSRdJk/NsG6io5twek20loC2HKS7c8DytVXaqKgDqqku/xe6R9vPQnaclJa4WdqEVJuvlhmN41S1Nw+REruNHjgcv5bHzudJk4l3mFV6TdXpc/Zrkz5WM2Q4z0XvoGwLJUJn8M4lLuzYzLAa/5r5sQrx6tolQ== 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=uz07zVC8cj67pjbnl/vi8YOpJrgczM0tkZce7Od41g0=; b=QI9ULVOQVQAUjAvotEdInOLJNZXC3RxIepIGf2MPUDw9Tk/BYgMkatVkc1hXnnjW7dAYzkg8pirT/SZHoH3G6/sSMrTdDjWockZxYnVOh6AI3ENGXRXc9NOxcA5EBBkBtSf+90xDI1Yd4YIlSlkP9gz2kIkUSEZCr96b0Jf+vHzpIiDBluBTejLM7bw9YY23A11Rpx5ASzFVif5p1CX2nzEMVlPW6bw9OdWcxuGvaIsu9aHXh8Pv7iALQKiy0cX6KMygmsWKc88xiaP2PgS4s/SE1JL/gViW5UvCGFiV9XT7BabcsXsK/V1qtaDCJ3uhRExjSLtWPouuSZx1+9OhxQ== 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=uz07zVC8cj67pjbnl/vi8YOpJrgczM0tkZce7Od41g0=; b=F1uEMyG5EMgxFCAx1iZkoV5QDq+9sFWujbnGsvPI0Y0uw4VLLCqUzTClzUXlMtW1FOizitTf2QXLP4bI7X1H/tgNS8iWYAL9XJLmtradt5maR8TgQE2WOWiZWM4CPBFA/GMtQpkqmRmHa/SoZ5Wpuf9aCBcpdJPXa5Y+pJyq10I= Received: from DS7PR03CA0090.namprd03.prod.outlook.com (2603:10b6:5:3bb::35) by PH0PR12MB5498.namprd12.prod.outlook.com (2603:10b6:510:d6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.23; Tue, 22 Feb 2022 15:35:24 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3bb:cafe::39) by DS7PR03CA0090.outlook.office365.com (2603:10b6:5:3bb::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Tue, 22 Feb 2022 15:35:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:24 +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; Tue, 22 Feb 2022 09:35:18 -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 v7 07/10] cpupower: Enable boost state support for AMD P-State module Date: Tue, 22 Feb 2022 23:34:23 +0800 Message-ID: <20220222153426.2216974-8-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 97d75fcb-6ec3-4c7f-55cb-08d9f618f1dc X-MS-TrafficTypeDiagnostic: PH0PR12MB5498:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rimlLIZvF6zof4QmXPrMhxJTG5ZylgxfW38QvURCKhwffBr3sWJe5I0pYknYHICucJfQ7zLH61InUSSNwEV6PAaDiqX+spaZEULqy5hum6XRifkwIC+wU8sm/0CIyB0nSswzgQFcAD5hYN1JZAQwSUmvT4j1lhT1m4USCHI4l5pBlVG3GRPM/7KBVKFgKqWT9tvVfPr+VSSc128m/vVuQ/MXtCVLT4uw3zdiEzP15UpGGVfW5+bPW3CCHYTeaIyap6wMFULpEaVQ/rc9eMtWOKW82bboR3VRjWids+g2HsaD7hP3D2qwecpL8+zdC/s8WmMgWJOggcqD6WbKarEETFGKijVawt1xTDlSLi1Z/XgTu8oEfDZM9KlEpqQi2kpuHLgEKdYjl/BQ1AcSH6TAjlZ9A580ukBlohDygKLXSuOZOw2f1WkKpJHJlf2ePfq0R+IOJ+NSNbP01A3rwcqHkQcaHJfCd2KpoIlWtlDE0N5eUQzr70khkSX1gBPC05FiVqkoZJYA0CSBntKqjLuuSCVUcqVD87ZTKVqmwMEAZHbJtYTuAFuOzRjlR00F5PBxza6BOhYTHHD/9RPSEFvtlxAU06qFtdDqvItWw4T6dJ9/unazNhIo5kbMtp0rHl4HdwRPE3S6k0YWYw1hz+OLszzrlaB4Ytt40W6EQq1CzZw82yez3FElGzUyUwjb0NYwXIqSG25DRiAGdEXr7qW11A== 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)(4326008)(82310400004)(110136005)(83380400001)(70586007)(70206006)(508600001)(336012)(8676002)(316002)(426003)(7416002)(1076003)(8936002)(5660300002)(2616005)(356005)(6666004)(47076005)(36756003)(81166007)(7696005)(26005)(40460700003)(86362001)(186003)(16526019)(2906002)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:24.6095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97d75fcb-6ec3-4c7f-55cb-08d9f618f1dc 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: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5498 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 similar 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 62771a086871..326491e11c6e 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 **************************/ bool cpupower_amd_pstate_enabled(void); +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 inline void amd_pstate_boost_init(unsigned int cpu, int *support, + int *active) +{} /* 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 Tue Feb 22 15:34:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545499 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 77AE9C3525B for ; Tue, 22 Feb 2022 15:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233576AbiBVPgS (ORCPT ); Tue, 22 Feb 2022 10:36:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233574AbiBVPgI (ORCPT ); Tue, 22 Feb 2022 10:36:08 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3491164D01; Tue, 22 Feb 2022 07:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NweVAgTBj5gN0exlTPGplOPTVN8Dc5NDuJS6qvZ9zMTSugnOfzLccOZyKhjv8GJM1P3aCoGMYeUZ4PQOoTreGKlPwGCeOWlgC5ZF8s6ziQFAxN+DwRmbuVs8Z4whUiJVMjk4teSfMpHzG11+BhwEfkJOtLbgLK88yDTpxp//nE+Hh19zn9BuvaImnK0nFHheCt1F4RnwootZVedGHHoEqu+PqdhxdxmCjdTmYkuCwo+UkGDw/g4NZgB/aLS3XI2uXEtfSOPUmAsVwYr4/l0vkZZAx3YSZsgNMyF+czUk6NGdU3Buok64rWgNUvnJaf0jmm+J0hk2tjL7LxeY06bHfQ== 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=PMNLMZVzUW2YdiqmtmxHGym4ga1Wvo7eKoqFM3xREQ4=; b=NxQpAIlrsLhwYtJRut+rl2WS8KKets9pLuJoiiTbKgemmNMTSmvn9V8dt6RFY8jyT2+1qyxfdVlr/8haT5PLSmjCnjde+gqKquTtYhrtSJVKd9+U/BA09xXnuReTe0IXutZM6Vzj5NqHyMH+kL2oxzx/FlwMWT7amAcsCGb/EPhuQWkUqSfQaBbgq9nibe3iBTdSdUGmIWBarlwaqAHws2c/6frTOEuILPwBJi1ZWSCOLnFtmKapRxAgLS3ykoLpeb3YMtfEBgWZejjQyg1cf2Bdw/2Ll2Np9FxBfsdmqcQv3E28ayCbfSACSV2/bsk4+1b5HR7yhUlfqmItiXAmRw== 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=PMNLMZVzUW2YdiqmtmxHGym4ga1Wvo7eKoqFM3xREQ4=; b=VhkQkKEbx3A/1lQPdI+8JaySwA/gbKFmaFvpzCripqM3k6AzjY7IJdvti739wg/0hEE50nLyXkKiwCBclVj1X4AsMdJMHqYN1YQRkwAaar/VAemjUG4NVwP1UBaMUerm7GKeHBtOeENVU1XTOmGjRcOExNQqx9URSP28I7NV2IY= Received: from DS7PR03CA0072.namprd03.prod.outlook.com (2603:10b6:5:3bb::17) by MN2PR12MB3920.namprd12.prod.outlook.com (2603:10b6:208:168::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Tue, 22 Feb 2022 15:35:29 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3bb:cafe::e5) by DS7PR03CA0072.outlook.office365.com (2603:10b6:5:3bb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Tue, 22 Feb 2022 15:35:29 +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 DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:29 +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; Tue, 22 Feb 2022 09:35:23 -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 v7 08/10] cpupower: Move print_speed function into misc helper Date: Tue, 22 Feb 2022 23:34:24 +0800 Message-ID: <20220222153426.2216974-9-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 24348850-70ed-4375-148e-08d9f618f4a1 X-MS-TrafficTypeDiagnostic: MN2PR12MB3920:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RcRFlyGQrGc5smaxAiao6jAcU/OgWcJfDmYY7dp1aLpGn00BuFIsArEQbT6S1MAZ0Wlh2YTGgQ5swzPkhF/CFx1tNBMY63U8Z0MvAbt3omRhWExP+G3hpU1obptYxobBkEPBEhvGnAcYHkvmeff37W1Af4psfy+J4YRDtol8bDmlEUpQ37S+2PhDDTTOk2qEDS0czydJDpU+w3mj1XHlMhRCvOAfsOT/gjHxcVM0uxbnAjsztjZgSAmwVSZ5TObxBx1Mst1E3Cx0+Hu0Tx6b/6fj92qUibUBcmBb4aKL2wfmFir7jjIkEp2sMs6jb7VViv5nXcSOaRfwK30dzbnAYNThcRTrO0WaIf1761tonroi+s4agL0+iJn++pw6cTsAJlGPyCQeouTd53wZiFeXtYVAn/mbSJPXtXwIPxywo0m5zV26JrQ8WmWjlYwYTxAj+gs8p2jiu0AFhlvhq38jEJ1SUmdU7U2zaZmEzOrHn3d9nT+CD8uNyvmifX90TL1WcwNJTB9/m3+X+yOd8rytIK9VWRQM1Z0JX7w+rSnyTjEb08gTsTSuzKHukfPCD/QxTQlK3/EfMHS2LwRRbyR+69OQzgkVSjVtqDF1fKxJ46tlEGqnC3w/QzL9vdM/v4JhFQUac/axaZPpeD6Pw/x+ir4UmzqNNTCionXSTNUgLsxck32W6HO0jpTrIXTe4F8HvMR2pNvIjRm/PzCByUn+iQ== 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)(36756003)(2616005)(40460700003)(7696005)(508600001)(47076005)(36860700001)(2906002)(1076003)(186003)(16526019)(5660300002)(4326008)(110136005)(54906003)(8936002)(26005)(8676002)(316002)(356005)(82310400004)(86362001)(336012)(426003)(81166007)(70586007)(70206006)(83380400001)(7416002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:29.2231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24348850-70ed-4375-148e-08d9f618f4a1 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: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3920 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 | 40 +++++++++++++ 3 files changed, 52 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 326491e11c6e..fa2a8c1b1d26 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..9547b29254a7 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -164,3 +164,43 @@ 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)); + } + } +} From patchwork Tue Feb 22 15:34:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545149 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 13077C43217 for ; Tue, 22 Feb 2022 15:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233585AbiBVPg3 (ORCPT ); Tue, 22 Feb 2022 10:36:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbiBVPgM (ORCPT ); Tue, 22 Feb 2022 10:36:12 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2070.outbound.protection.outlook.com [40.107.220.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182C1163D75; Tue, 22 Feb 2022 07:35:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WeAz3sPNNER3HKeAedHZc5IL60MtX3L/bdGSZTzB5FNJH1tVbIWhT7XVUAw9LLzwoNE7OFyi7jTLDWki8QOcLLkuHjlMQTGf1FQNg4qxZA6OGqxqhOYkk0KuaBTwOz7TfNy8PGrr5R0tFQD+nAzdkiD0ATrP15Tbc8KBplOdgSoxozfGdk/krOJMPuJKGRba0oOfM6Nb0na3Pz0RbQ/iOLxCcishg8+JkmdU36md7i3/jUeVBzEQQAhPqUAP3pwSI2NaAF9J7kPIfCUP3DKy77sf00eqspj/x9C1Dk/zhbfRWIQwfjhcoGDbMigk7IHFVcTe2cv2GVP5D2K80r6xjg== 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=Epeeg02BuMnxNEbUPrAQ+z3CF1R0ncvHQPRNW0S56J8=; b=TQ7d6qzPpTLPebzc/OXsf8RZQT+/E/QG8NhGn6WeXA/KnX4LhifucIML3KskIOe2bmgfUvd5G1dsAK+hCAlPPkhAYHj/cKG9CBv2LvUN6H4LNq6yI3cJcfBhGMltG+YF7nSRxN2ICcWccxcgoF7xbDuJYN0JT69LLOSNyoxx0xCfNtCBcmkwkOJLQJqBU0id/sZwXhoyqZtBHuMlsLducdB+KGzljeyVPXgnd9SzugyXPKJHWOkF+6tLq5aF/9nsOebaxm8ZTFDRLyAAYGLhFz9Ko4+mvpZN9/+IQqlUrfka9Gdh1HMhlzKbWqQ0ee1zV91Gu5uNFVYyHGKgKjdWBA== 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=Epeeg02BuMnxNEbUPrAQ+z3CF1R0ncvHQPRNW0S56J8=; b=QlOYXfzCu39umAB1Q9H+muxideB+4B20o6Flsvwb6V0WYbiXUeoxIe4ScHmsPKVOhUZeLCTNvlb7/ByJjcqK7SQl2oFDmQ0j/ItNT4P6yxkbbphTHLrK0vqUi3BuvCXZdrfbOineakvYeChNcb3HyrrursyZg7AeTxflFEVu0Jg= Received: from DM5PR07CA0030.namprd07.prod.outlook.com (2603:10b6:3:16::16) by MN0PR12MB5978.namprd12.prod.outlook.com (2603:10b6:208:37d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Tue, 22 Feb 2022 15:35:34 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:3:16:cafe::c2) by DM5PR07CA0030.outlook.office365.com (2603:10b6:3:16::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22 via Frontend Transport; Tue, 22 Feb 2022 15:35:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:33 +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; Tue, 22 Feb 2022 09:35:28 -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 v7 09/10] cpupower: Add function to print AMD P-State performance capabilities Date: Tue, 22 Feb 2022 23:34:25 +0800 Message-ID: <20220222153426.2216974-10-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 3c313cdf-fdbd-4d5e-c873-08d9f618f765 X-MS-TrafficTypeDiagnostic: MN0PR12MB5978:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UMVUez9j1LF4rrItoCOvjNPmPzJR1tDIyym/q8xRkmMqSrXK+9XLmlaON2EFG0Juftk6TwGNvxfB5y7lHi4QHwyhxD88kyuieNOW1vMh6MwCe7f8b8IPhwii7S+CRd053arMyh8OmpJuxfF+7P2fgIXyOXryK+uMRmNdUT68QbBA7M4XlUceRia88D03yqvfj+2oN6HlAu7+wpSjl2DJkm/wDpPYHW+RwI++ABZAtPTgou8wicPRJu1Z4iGbOJPXRGcHCXRs41M6iGsdfeFyFTrcK4OuJyX09tkDQAMKT0bTmYYJ3vfQceZuLXB3vzAlxQ8aq6VM0PPEKfTYf6SZmHmi+ZIKd7oEm4C8zjAkBcWEn7utg+XfleZ6mM7ymHhOw/5Kc55AR0Du6nk71qJo4qSFkGw9YALm0Rgo3mU4v4TCJ1KEJX369TU13gJ242V/27FUi/aWNUdGSy4pVgdr6Um3yQ5wiL6jDGYLdC1887IFSabLRAdpiQWNSy1J3Hx4j9ZdKeZoFrNJL80/0tZVXrYjjoZ+Y3+2VA2bcPV/++7LikLyw8XsMBb0yDFHZAHDTX7VO6BmfxkXFBz+odJ2P54/hra81UdmrcmsLWDcG4itrAkee/XlTpOPMFSJwJ84JMTMdQmFGQ/b/x3iWzDBlWhyB8qBPtAOmtM+PJYRoAodL6jzaogMJhZW9ODNJllH4Is2X+kgznbw8GjudF149Q== 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)(26005)(356005)(186003)(1076003)(6666004)(40460700003)(47076005)(54906003)(110136005)(2906002)(83380400001)(81166007)(86362001)(8936002)(36756003)(336012)(16526019)(82310400004)(316002)(508600001)(36860700001)(7416002)(2616005)(5660300002)(7696005)(426003)(8676002)(70206006)(70586007)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:33.8832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c313cdf-fdbd-4d5e-c873-08d9f618f765 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: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5978 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 add a function to print performance and frequency values. 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..235243ec5ce0 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) { + return 0; + } 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 fa2a8c1b1d26..96e4bede078b 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, bool cpupower_amd_pstate_enabled(void); void amd_pstate_boost_init(unsigned int cpu, int *support, int *active); +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 inline void amd_pstate_boost_init(unsigned int cpu, int *support, int *active) {} +static inline void amd_pstate_show_perf_and_freq(unsigned int cpu, + int no_rounding) +{} /* cpuid and cpuinfo helpers **************************/ From patchwork Tue Feb 22 15:34:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 545498 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 DEF86C4167D for ; Tue, 22 Feb 2022 15:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233508AbiBVPgi (ORCPT ); Tue, 22 Feb 2022 10:36:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233607AbiBVPgN (ORCPT ); Tue, 22 Feb 2022 10:36:13 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15A8164D2E; Tue, 22 Feb 2022 07:35:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FK2Jv28KTxEpDleSbjEVIlTvCI7KT5jwDBrS0FN10X//MsNg4MHQ+2DWRXwrBM+iFFYoYixiMxC1OMmA3LhrrBIuy47bNpToR/KoW/+YmzpjqlpKfdD308fINTXDttVprQRe340Rcxi2lBv9U6Y/U4/+0Rq9yh2/E2Uet/ymMc/VZQbN1gKhlYj3S4qlRgv1696cEG4GCBgKlP6bCPshlOyH77fO0RBsea5QmvFRzXiyP9IAcjIb9ublGwVoW0WqxeQUuzJcPHYmxnuy4Pp9nqnugJ4SMtdCEFO4urlhYqAzU6ZzL+MM38j3YptRJ6da5PzH8iK8FwYI8n58TPWyAg== 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=0HL/SAV/WHo81zRVKFOYyDSgxHhmuNxe0NctIGASBKU=; b=lJzBcl+rAVGfc6A5cDZJweeb3TeJW2JkrjyY4LoD3PtdZFyKVexwWTUu7fW5Iovv713Mp22eXy3rSoz4usu8asiBoaJqvOYujkLDYdx8viATNb688rNPW+PR0UnVpHoAuuEcVWniRBgD2ddfFtJfMUVLg3m4yKUVVYvubqq29T5pKAeNluflaGom/pQ1/vKngkw+1vEbnfxqtg9yiNJsfzuUpW6Tf1mCS0rkyyB/Kh51b3pq1XugtWoxJpytzIwiBCXhsqV4O9JvwXg0YUSVjrwqI2siRY1NWCQemO8kAbqpzSF4yUXhFOfzjt7J113M1/rY74kA9QDvI8LIgX/xrQ== 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=0HL/SAV/WHo81zRVKFOYyDSgxHhmuNxe0NctIGASBKU=; b=CnbAuBqGRcd234RPzYrfe0PJUTO1C8bqw6eUfAOeobagXpLk8zaA3SHuAnpjClvJXx9E492TB9slvHq9H6pdxAgfPIGwBV2O7dl+BelKf7pMzdJ55z+15WyXjJ4U+z4qWc5R0iUPYluruqWrJrW9/Ko9hrp4D/2E8uleN2mac2o= Received: from DM5PR17CA0072.namprd17.prod.outlook.com (2603:10b6:3:13f::34) by MW2PR12MB2474.namprd12.prod.outlook.com (2603:10b6:907:9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.24; Tue, 22 Feb 2022 15:35:39 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:3:13f:cafe::12) by DM5PR17CA0072.outlook.office365.com (2603:10b6:3:13f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22 via Frontend Transport; Tue, 22 Feb 2022 15:35:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4995.15 via Frontend Transport; Tue, 22 Feb 2022 15:35:38 +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; Tue, 22 Feb 2022 09:35:33 -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 v7 10/10] cpupower: Add "perf" option to print AMD P-State information Date: Tue, 22 Feb 2022 23:34:26 +0800 Message-ID: <20220222153426.2216974-11-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com> References: <20220222153426.2216974-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: 137bd525-880d-4405-ddea-08d9f618fa35 X-MS-TrafficTypeDiagnostic: MW2PR12MB2474:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0dev52UD9Y0CEc2JMkbW8iHZWMIJYLkgYXSI4gysgk9FYN76iW09pPZchVfDbf5jHxdw1ZU2h43GKylJYJLHeWAY5y3SQ0MuZoxY0D2VWI6qkp/z48iJDLH+EcBltva09p4kOr0zeH0jkScXxJjcWScKi5ct5WHEkNvuUWRIRaQTQzWwYNQ7ziCSXrhS8cs4DaO4U2DszeL3VpK90JyKaArZBBMOzIsnMlAXQv06QNvbVWIwVRLl78A9tPT1r3QXMytUhOY+4GioZr+BTQkKQHhJ2eGY95dl2ZKm41cBj9L/UCcPE9ZWJUV+05mD5smlcK4mNrYGTwJL4qK8jbclgq7Ds+G0adAULbxYARIYf7Tk7D/OjWwgmP+gI/bNAR47lV/M/zwjqR3STKMv+SY5BksRUWU2IfoLXdd+o4PAMVyyCh1TJgdwj9avMqbqWU7dFtR5CuKLBaXry30eyXbzIE/pUmjJZnxajCDSU9AyCwYFpt9riNr1FFFW9wttQS4ino4aMK5QHasrDHSVAzXwWapgROoNrQ9AXL4sewhi5HwZv0UqzO/VIekwkpk7c1mNiXMTPiqNqw0RSB4+IHCT/FjQrXDgrdhj5ptHNB9iqhsJobx61Hc4+aV58tfy0L047Z5D0QQmcw6KbdtoXBs8rtSlagbmCBUz/NrrDdYLnGwJh8nWmVADRiJ7C+QBYdP0Uc2fEuJrE6PJII/9gCuzOw== 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)(46966006)(36840700001)(6666004)(316002)(54906003)(508600001)(47076005)(8936002)(40460700003)(2616005)(36756003)(7696005)(70586007)(110136005)(4326008)(426003)(7416002)(82310400004)(86362001)(336012)(186003)(26005)(16526019)(1076003)(36860700001)(81166007)(83380400001)(70206006)(8676002)(5660300002)(356005)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 15:35:38.6024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 137bd525-880d-4405-ddea-08d9f618fa35 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2474 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add "-r --perf" option in cpupower-frequency-info to get the performance and frequency values for AMD P-State. Signed-off-by: Huang Rui --- .../cpupower/man/cpupower-frequency-info.1 | 3 +++ tools/power/cpupower/utils/cpufreq-info.c | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/man/cpupower-frequency-info.1 b/tools/power/cpupower/man/cpupower-frequency-info.1 index 6aa8d239dff9..dd545b499480 100644 --- a/tools/power/cpupower/man/cpupower-frequency-info.1 +++ b/tools/power/cpupower/man/cpupower-frequency-info.1 @@ -53,6 +53,9 @@ human\-readable output for the \-f, \-w, \-s and \-y parameters. \fB\-n\fR \fB\-\-no-rounding\fR Output frequencies and latencies without rounding off values. .TP +\fB\-c\fR \fB\-\-perf\fR +Get performances and frequencies capabilities of CPPC, by reading it from hardware (only available on the hardware with CPPC). +.TP .SH "REMARKS" .LP By default only values of core zero are displayed. How to display settings of diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 235243ec5ce0..0646f615fe2d 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -438,6 +438,17 @@ static int get_latency(unsigned int cpu, unsigned int human) return 0; } +/* --performance / -c */ + +static int get_perf_cap(unsigned int cpu) +{ + 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); + + return 0; +} + static void debug_output_one(unsigned int cpu) { struct cpufreq_available_frequencies *freqs; @@ -466,6 +477,7 @@ static void debug_output_one(unsigned int cpu) if (get_freq_hardware(cpu, 1) < 0) get_freq_kernel(cpu, 1); get_boost_mode(cpu); + get_perf_cap(cpu); } static struct option info_opts[] = { @@ -484,6 +496,7 @@ static struct option info_opts[] = { {"proc", no_argument, NULL, 'o'}, {"human", no_argument, NULL, 'm'}, {"no-rounding", no_argument, NULL, 'n'}, + {"performance", no_argument, NULL, 'c'}, { }, }; @@ -497,7 +510,7 @@ int cmd_freq_info(int argc, char **argv) int output_param = 0; do { - ret = getopt_long(argc, argv, "oefwldpgrasmybn", info_opts, + ret = getopt_long(argc, argv, "oefwldpgrasmybnc", info_opts, NULL); switch (ret) { case '?': @@ -520,6 +533,7 @@ int cmd_freq_info(int argc, char **argv) case 'e': case 's': case 'y': + case 'c': if (output_param) { output_param = -1; cont = 0; @@ -626,6 +640,9 @@ int cmd_freq_info(int argc, char **argv) case 'y': ret = get_latency(cpu, human); break; + case 'c': + ret = get_perf_cap(cpu); + break; } if (ret) return ret;