From patchwork Fri Jan 22 17:38:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEBEDC433E9 for ; Fri, 22 Jan 2021 17:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3BA523A9C for ; Fri, 22 Jan 2021 17:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729446AbhAVRnA (ORCPT ); Fri, 22 Jan 2021 12:43:00 -0500 Received: from mail-eopbgr750055.outbound.protection.outlook.com ([40.107.75.55]:28967 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729886AbhAVRj4 (ORCPT ); Fri, 22 Jan 2021 12:39:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AamTa1AminTNpsCegRoqGIQi7fab78aJNwLOYW9xHjJThzvcA4PydSI44pmQRLzF7nfgFrJ/OMSSOgdVoSZzsT71y8e4bx1ww5Z7WD2NYA7s85ymdee4YWCUzBHhlXrrahG71jtSMZ37q7+c5qjmO15Qk1JHk1JdZ8axIPFoaenw/yN1St8XmNaot/xlb+rN0kn4bv3LmwnFuiSqREYhrI5io6dSkPwRXnlHMm7uVg6uTlHJbn0Vcrw2Gd3c7xdJEYJF7EAfdVWutfxHCt0Wx/q5KZ+DjYKPs9n/w3ynLFRxvWfmkUHxZlaAAedzBAe73r8nc97zfilT/CaDil7mNg== 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-SenderADCheck; bh=mTrsC0sm2d5Uc3hxMyML9fg0zQNw7jGsvtgEWX1uBdI=; b=ja7y1eyY7oajsCHO56QfpbwrtCbIUQWoLKMGLnyHsZQaNZskkg8wY05x8RoLAkSXIclnAg3LKxs6/yVezV8qL7l44Uut8jRBtkkIZhjTfJEowm7dXxTb7m3HGRgQdSSIS7L0tiB+YKU74farI6q/3w/W3mDm2WgifAC3u22nqQj6Nb9blEc4U3H4ThxlN+kvV9glof4wONRONvDMWDktysVHYMXx1s6bv1zO5gGcesNoLrPFSpCxelGGiX3uhc7p3q045Y59NZA/niUGzDD90qYXJuoXn4pelWWSrZfC6gu9kq1qlczWGhigEKHvx6JPaH74a1Sxl1yQFyMvzpovmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=mTrsC0sm2d5Uc3hxMyML9fg0zQNw7jGsvtgEWX1uBdI=; b=UG0LGn0rsfkGEL1xVWJCr0U0YLBvG0mNfFZZM0caUh1za+ypxm/2cy13cvKP9p7fR5hy6azfk2UmxVxEtxtccWP7OyvIMCfeDmM1F20NhwbpPVvDb/NXah/xXy8cvRPumW854XnyVFC76G2oP9pItwPJC2u8TeOzcgWcgELBgYw= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:38:37 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:38:37 +0000 Subject: [PATCH 1/8] cpupower: Update msr_pstate union struct naming From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:38:35 -0600 Message-ID: <161133711513.59625.9843026563692886689.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0030.namprd17.prod.outlook.com (2603:10b6:610:53::40) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0030.namprd17.prod.outlook.com (2603:10b6:610:53::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Fri, 22 Jan 2021 17:38:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7edc9c06-8de1-4b9d-5b16-08d8befc8c85 X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zl3NNcb17aIQ3Fm7xH4z9meIXHvP5D/RseXEtfgBMCJXZh/FxUnKl7QECSfdMX4FJ6W5awBjwlapS03LeE95w4qlhLA/rzJ4W1F/TXfCRPXx5948v9LGwHMr8eBELbjHchbxA+tcQCBoEuq4yVl1iAchp2J1hhXisGbM9cPwMhr/jQm18ACcsEq8M7PxNQrYaftxWgPWccscF9yVwmhC4tkIsO0loNlmPeYIzV7Yt4mxQoBbMsYGm8I4Rli8DRcv6Qxf0B/pjJUVYt0XPMzW3j9Bgxakt+6nEfqouCjaTZb2GLsTE02WZJf80Y3u+mxItKu0L9PfVGdJxFZLfRSBF1FmqBCWUW7rZWM0LRlk6s9N38/f42DqPJZ7i3efHC9gFhL4EdDGnRegXFjtpvJa+g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002)(15650500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?n6vIFIuyE1mFTuWM6gu89t/Vgs1+fy?= =?utf-8?q?QlCNR3koYGWw7/3zsOVx9lNFD/bK0oMDwEJMWIIoDiU14L6s2vlf+xCB+DPzxMoP8?= =?utf-8?q?ZGineHIWn3/C09XLJaOxp8QaORO2FgWXUZ44zBk6PjM2010UUSkQaoPrvLea9HR86?= =?utf-8?q?SRpDYAHUtPm6M1WFg0CupEmGk4aFqruhU/mtazGDR0NlokGTdLpTSqiQrM3K2EKhy?= =?utf-8?q?eB9dBoZL73S+PeAUkFehU2QgdOASQMYxOJeCUrWzZqyiNt+zh1hsWNFQo2MVMwYvF?= =?utf-8?q?ZE9kiEfH/gfncGaZIijtR3BVUFfqm7ezsJNFfXyjh73XL/UOtvdHShIa0s4kT2yjv?= =?utf-8?q?BsYikM+OhC8bMmK5bGowtRkW5mNXAEfQrwCUlgGj0BSifC2/WktTIqQ/9B+/Rybmc?= =?utf-8?q?nofDE8Kr9a9eX8AXE/6uWsRY84+eqIyB+sQIaUGvxIHa8nMiQgmzbPwSujQYZ/svw?= =?utf-8?q?AcFRzI+rrKQKAEUNDW0Cyl2vTUZcoJ7e+/29p4bDqNmJIcWaRS98TDygU1uvEYrcj?= =?utf-8?q?bUorCOJOjtO0WlZCf5SP47nXV6RQmnr9KNoLtLcxeKJoDz3QsG+/J0nKI73IDG09T?= =?utf-8?q?pVu9RWTO2lfvoZWGJM6Ew4/kAwcosqr45n9RUp9uoIZZ48rv8z53knPI1OiUXhpKS?= =?utf-8?q?RHiTE78GLmpmxM8ckF/WNs38i6i9G+N9zBgn4OFlaLO7ENcjN7XJs7W59olLctE/6?= =?utf-8?q?Fi13AHMdCT9QmyXB3t1qqOfhW+0FLlGjsUzkTk07wjlGSuuAyLqsqcxF196mbTXd3?= =?utf-8?q?34Ht/fnZl8zc7Kjeg8LnfejdVK9WKxiRTcVwYY1JmI62P8M4lbw/yMRKGYJw0bTaf?= =?utf-8?q?ivsTkjusVUMwsaO7n6aaEk3TbN5BjbegdgNK2dWxL/GuGLMutCbGCnQsHUAGubpXG?= =?utf-8?q?1uH+1/hE7nsoPhp7orUtD2AX9kEnrCAIa+l4eYLX6FeY6u2NdTgc5b8kScLT5hrn2?= =?utf-8?q?+a9ydSkXmnnHWrEd25uaC+dnS/Mwthu+4xLGpavCrKDe/ef/erufNXVK42XnMu9gF?= =?utf-8?q?Fkr4LxHdzqx1jvYPnj?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7edc9c06-8de1-4b9d-5b16-08d8befc8c85 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:38:37.2480 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: q54u+i/JQQ1blm6/sJ+svKVF8dhUYFxDYW34Y5ScVGKzqm8rhBEbqKIUVBNXMDQcGiaZqB6LGTOJ0+9MHX2qSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The msr_pstate union struct named fam17h_bits is misleading since this is the struct to use for all families >= 0x17, not just for family 0x17. Rename the bits structs to be 'pstate' (for pre family 17h CPUs) and 'pstatedef' (for CPUs since fam 17h) to align closer with PPR/BDKG naming. There are no functional changes as part of this update. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/amd.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 7c4f83a8c973..34368436bbd6 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -13,7 +13,8 @@ #define MSR_AMD_PSTATE 0xc0010064 #define MSR_AMD_PSTATE_LIMIT 0xc0010061 -union msr_pstate { +union core_pstate { + /* pre fam 17h: */ struct { unsigned fid:6; unsigned did:3; @@ -26,7 +27,8 @@ union msr_pstate { unsigned idddiv:2; unsigned res3:21; unsigned en:1; - } bits; + } pstate; + /* since fam 17h: */ struct { unsigned fid:8; unsigned did:6; @@ -35,36 +37,36 @@ union msr_pstate { unsigned idddiv:2; unsigned res1:31; unsigned en:1; - } fam17h_bits; + } pstatedef; unsigned long long val; }; -static int get_did(int family, union msr_pstate pstate) +static int get_did(int family, union core_pstate pstate) { int t; if (family == 0x12) t = pstate.val & 0xf; else if (family == 0x17 || family == 0x18) - t = pstate.fam17h_bits.did; + t = pstate.pstatedef.did; else - t = pstate.bits.did; + t = pstate.pstate.did; return t; } -static int get_cof(int family, union msr_pstate pstate) +static int get_cof(int family, union core_pstate pstate) { int t; int fid, did, cof; did = get_did(family, pstate); if (family == 0x17 || family == 0x18) { - fid = pstate.fam17h_bits.fid; + fid = pstate.pstatedef.fid; cof = 200 * fid / did; } else { t = 0x10; - fid = pstate.bits.fid; + fid = pstate.pstate.fid; if (family == 0x11) t = 0x8; cof = (100 * (fid + t)) >> did; @@ -89,7 +91,7 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, int boost_states, unsigned long *pstates, int *no) { int i, psmax, pscur; - union msr_pstate pstate; + union core_pstate pstate; unsigned long long val; /* Only read out frequencies from HW when CPU might be boostable @@ -119,9 +121,9 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, } if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val)) return -1; - if ((cpu_family == 0x17) && (!pstate.fam17h_bits.en)) + if ((cpu_family == 0x17) && (!pstate.pstatedef.en)) continue; - else if (!pstate.bits.en) + else if (!pstate.pstate.en) continue; pstates[i] = get_cof(cpu_family, pstate); From patchwork Fri Jan 22 17:38:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E07FCC433E0 for ; Fri, 22 Jan 2021 17:43:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACB3D23A6A for ; Fri, 22 Jan 2021 17:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729553AbhAVRnV (ORCPT ); Fri, 22 Jan 2021 12:43:21 -0500 Received: from mail-eopbgr750077.outbound.protection.outlook.com ([40.107.75.77]:62028 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729966AbhAVRk0 (ORCPT ); Fri, 22 Jan 2021 12:40:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wwl5uUsj3UUuUhmUoUvdZOEs1hfXMr78i6NpCXWEQEExaXSFTTQRR7PkiJy6wbAM7ldjSXn/sTyJ+/yiGEh8aH3wHuQOCTrWjqjO6IehGBQpe8722ARnR/OfsHNqq+hQ0KQaRYhL5WNf6LxEw9J3CeQqXQ/Ug3GVZgOGT4wCzM/GQlUSrhhNwVsqOK7/lMyyQ62xTcPdBLIvqUOUFIO6j5szY1S1IYp/YCKUDXsvp+eFTw2icWQr8HO8dl1fRv6LDyIYiivkJor3uC37oIK6YCJsoNGU/AI8EU+CBZGXqhHzFHC76+mWBrVV/8hMNMgWgK+G0ekZtqrT7uHYgbZiEA== 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-SenderADCheck; bh=cn0bBx0QSOwdowiDo83k/VfMBKecf7j2Obn72M1zODU=; b=ajpZvV10PZiMwVYrIZ1r8LjWgZ8oCIgU6Eh1MpIYdcVUHnyIe0Xi9/ru/MiV3i7bYCbsFDoqEJBuF3uuAkCIMkkNlI0VU9EmCuBqPXw4pzYiYParZO1S27dAxw8sbl++IlNOt0i0Nw+84nn/qcfWf50JfVXedZdVzLyCtdGgaQjeiYNL/6z/6nFRNyb8U4dPiSyKM9mxiKuLjodFEmoExJn79FXeixhUii+XCpv8Mv2VGe2cGWFsI75e9AUILL3IHVhGw8UJ5eQQjhqep1enQsLTi7HhUARY8XD0sWhbBymC9uXg2RpKdthY+WFubpe9mkKtub89rdH/mZLnREslog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=cn0bBx0QSOwdowiDo83k/VfMBKecf7j2Obn72M1zODU=; b=LE+WaROeB/MFaroUhJMpvEo3WuMAL3GN1hE3JuYvHVQrTjWGwOIZzRHnTnYPWhMTBTP2CPVCFbgMH8J65eQR9uM+ng0lbeML+ksDEzJnezk7r60WeT+B676f15N5pvktYDVbmG6PBNR8TslXlya/L3iYzGE2SChCHkMq1R9O5cE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:38:45 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:38:45 +0000 Subject: [PATCH 2/8] cpupower: Correct macro name for CPB caps flag From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:38:42 -0600 Message-ID: <161133712259.59625.5128921373130739940.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0029.namprd17.prod.outlook.com (2603:10b6:610:53::39) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0029.namprd17.prod.outlook.com (2603:10b6:610:53::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Fri, 22 Jan 2021 17:38:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 65faa609-94b1-4003-d939-08d8befc9123 X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JjPKqJ5DvNNBIQuKpOr9FaaDH31m5pAwwxp9iSoyyzUbqJI7NTpCUnPSRN15KJvze6Rde5tEbaEP5Df+97G1nnFyVH0gDaO6aYT7C18PiK7gQ76kFCza10bCgcSjS7253v8YhBN42NSRTUzs6YxGrp19iW4O5ZjkHzrwjk41w8dpqUsIbc82RHpR+UjaixH+NR1vnWfzY2m5uEBrXWq7u5+PYBAoSfi6g0mp6uJQ+PZpU1ba9y4FBaw6WeZHWA0+A1e5bCQB61h50yEoYh0NFHPEsR/ASAGlf6oha0DMpsOW0tE0QjXpehNkkfhJKms0qijiqofbiRW3awKDT0cYE+7YG8lwFFlraGKOKh6rh5mc4bW//OX4iA8Orr0EN/zpzTwxySo/tXphgldkYw1V9w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?w9TIvDgM5U2ULB8bZt4BzhSZwpXcvV?= =?utf-8?q?pSK3pTT72h+i4SZlP6ah2mdqqAP7jGD6Ao598xBLVyUCbZngua+VUHqC0MK0otsE+?= =?utf-8?q?h+BPdMorhnUvWOw8+2/AVqDpmxRqECwAaXDrMeUyp+u6w3NATX5IyUctfQqtMlX1I?= =?utf-8?q?vB2BiIM6Zq5CQ2WL1MOEDcqWcwKqEgUJxtz/TdrSZgNzTSoUtK2SPNivOIctDOZpo?= =?utf-8?q?T8jjiNLy73VkXtOEwI89eI9TNhVln1W3bGaWAygp/GbDm/NXuMMnJ0c0PjRT9tzTY?= =?utf-8?q?jZMbdQhhAAs9iPH0OUL5NkQe8+iN48gCytwQ7wxXOktJ1HQ0lNZjLGZTZwTX5Eo92?= =?utf-8?q?jbsxA/4lufIKg6cEYZKZ132aU1EwmctTDYzXrGwv/TD9krj0ww5gIbQaVlzujGmcS?= =?utf-8?q?Lq2hX14zRbHIBZtWACmG64akftX/YNNY2GGsymkFeOgzLY5xumIn1Z3btpxX0Mm62?= =?utf-8?q?3Y9KXj+aP/KV7cvBp+yysByYFsDDhUDUPFhv7b3MTF85SH+dvmE1Z3Qam67nlROxM?= =?utf-8?q?6xhMFhZSzOe82fymQt/Veh4hbS2UXnUlngrnNUAF5yHg/7+EQ6UmU5+J4ZVv5fFoQ?= =?utf-8?q?YPUby2qbiUuQ9xzr8MULW0ZlsgwJolpMAXeAm8hHIQgBfpwbylSPQ9KNRiBL4JdLs?= =?utf-8?q?AoexzppKcJJ/jHCad+4XMC5ljlPQw5fFgn0xLAWPJGG/NsdaSdRKxCIFjNsPAWVN1?= =?utf-8?q?GQztZkJCK2NTPBq52q1ckVdZetJCy+cwY296VR+mYkwYp+cI7B9S6cwkHiopUk+sf?= =?utf-8?q?ECdUpDPOEPNOHga1daAE1rgqQ77Y9iWx0/wD6W2kW9t3LvrqoLr8Ktzomvt2j+6JI?= =?utf-8?q?UJQuagZSPFYDfoB8bpWs2/idlDlrIJhwlcv/a/qdQ3btXA7ggvShmOkdKHAAOkejM?= =?utf-8?q?PRWC040PSF2sZ23NPElq43AZLGI6+XGekigb6dZ794tCV2HfzFsrfumb5ByE/U8F5?= =?utf-8?q?7dXrG4Eb3c4pqjSR5dEHnEj+IuT074dzOfruXpgMuTKwXV/YFqla4WlHoTePIpq/F?= =?utf-8?q?Y1Y+Hs3pr56DZoxt71?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65faa609-94b1-4003-d939-08d8befc9123 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:38:45.0216 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cLYGZ1/k7+SarJPd7+rXZ51xtvbSMDaumjNSn01/D5ddbaxjWefNPDH0wIoq5Cmej13Ja7PkcqooD63J6l0+lw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Robert Richter The name is Core Performance Boost (CPB) for the cpuid flag. Correct cpuid caps flag to use this name (instead of CBP). Signed-off-by: Robert Richter Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/cpuid.c | 2 +- tools/power/cpupower/utils/helpers/helpers.h | 2 +- tools/power/cpupower/utils/helpers/misc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index 73bfafc60e9b..f9a66a430b72 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c @@ -130,7 +130,7 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) cpu_info->vendor == X86_VENDOR_HYGON) { if (ext_cpuid_level >= 0x80000007 && (cpuid_edx(0x80000007) & (1 << 9))) - cpu_info->caps |= CPUPOWER_CAP_AMD_CBP; + cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; if (ext_cpuid_level >= 0x80000008 && cpuid_ebx(0x80000008) & (1 << 4)) diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 0642e60a6ce1..a84f85a9dbd2 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -64,7 +64,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, #define CPUPOWER_CAP_INV_TSC 0x00000001 #define CPUPOWER_CAP_APERF 0x00000002 -#define CPUPOWER_CAP_AMD_CBP 0x00000004 +#define CPUPOWER_CAP_AMD_CPB 0x00000004 #define CPUPOWER_CAP_PERF_BIAS 0x00000008 #define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010 #define CPUPOWER_CAP_IS_SNB 0x00000020 diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index 650b9a9a6584..f9bcce9c72d5 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -26,7 +26,7 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, if (ret) return ret; - if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) { + if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB) { *support = 1; /* AMD Family 0x17 does not utilize PCI D18F4 like prior From patchwork Fri Jan 22 17:38:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51BEEC433E0 for ; Fri, 22 Jan 2021 17:48:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25AD023A6A for ; Fri, 22 Jan 2021 17:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729473AbhAVRnN (ORCPT ); Fri, 22 Jan 2021 12:43:13 -0500 Received: from mail-eopbgr750049.outbound.protection.outlook.com ([40.107.75.49]:65531 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729888AbhAVRkE (ORCPT ); Fri, 22 Jan 2021 12:40:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBgvDlf/HjoHMwqEPQwlkq6DV/opPfh4tNmeAvJMe+ipSL7HgKA5rhpzt2owDcs/49WP23Ui7bvNtMNDmvD7WH3547qjrfkus0KUEItdU73jRjtZOJqQoJEBhaHC0tLHmxml1NEsmoOAgRlrbvcmCluLCOZpaoCVR5Kp7Myy5yzd6O5QsXc3J3kvdeUb2y96VddRIrfcflumd6y2y7mwteTcv1vAMvpFE1WCEuIB9r3hi/F4aXMHWdR4Umv0cM3+cocKf4kIj0bOqFRmBMyzsZ933zA2iReGF7PABbi6zGuGUytkRo57LCQdrBe6IQZ9uwBdbYi0H5DdsC6L4cqVrg== 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-SenderADCheck; bh=OJUoQ3StMdxRzQQX9xHGFjdmDfUqzYLE/+49817GFf4=; b=ZDfV9+xyt+3hCH7xeMIPbtinTxbMW/FM73cZxJYENVX1JolnwvnTdCgh2sNsODpJVxpEwEq7dpBKzfJJ7IF6h+QFAKf495Gewen7C1zuJrLoNp719zWeX5I519gBLA3+xZY9B7cy4a/oSOfdW7ursS+h69JdULHHmkYHSXGFTp80nQ0HTKzAcBIRCivlshLvz+KijzYNILv2wKkr+IVdURcwWZh9W2T1o7GBOnqz88p5SSx2js6BX/WtBSp4nIIOdg6fgqz/fh/eOP8Tt0rIVX815kR99sCsoup00q366PTXaPIiM1MRLGY7qILKejtgADc9SiClPXIHDaR2Eol7OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=OJUoQ3StMdxRzQQX9xHGFjdmDfUqzYLE/+49817GFf4=; b=VQn1FFt+b6THJ4IpqAh1yQlplQ/32JFepW1pPYcej3YAXrid4crQrckTpzh0C4MolTXeAQrPkvqWEdo32RmWxxvxp/8eHqXfiBLihyxDBuVXQkTd9LvJBj5GEwyrgAI1utxx/Sx0cloeQGROnDSsN5p3CJtbGmYiCbXXmKaCu/o= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:38:54 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:38:54 +0000 Subject: [PATCH 3/8] cpupower: Add CPUPOWER_CAP_AMD_HW_PSTATE cpuid caps flag From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:38:50 -0600 Message-ID: <161133713035.59625.1577978944767511822.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0028.namprd17.prod.outlook.com (2603:10b6:610:53::38) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0028.namprd17.prod.outlook.com (2603:10b6:610:53::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 17:38:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 52c3414e-b678-4af9-8990-08d8befc9697 X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c6NYZYvWVqxsCXKGQK6U0IKJ7/C+gARtD5SnCbPJOWsZxCSGvN4LEIPt7kyoaBlQhJTWUkBAgqx3nkgVE6dreV4OjwTI7Ukdog0nK1r5MnPhdAHFfO3rwz+O3Xo3ar37bTu6h0xZz2hVF5tJAiAYyFTL3mkC61QKQQsL64OVDtmcllAt+54qVFl6nXVpawHXqwVaLV7u4yJ6jL1ZjE88Fe58gAfyofMgRxqwp0TLUghxzJbfPMzUz7RHJRl1HifvzFP96JxYr+/lPItVf/6K+hIypp9wgUqWEKwmajmy6H+c9y0MGZQAM9tnr9CrFPfdp4OW4yJOlDE3Va+qnv+Cdg1kF2eNgZs0GWO873CSUEhG+GBkuV7nsqwLnRyoZ5EGqwfjoUJAkDFDM/YMYnPqeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?gTQ0GUwv7XlcfywQTLZl/vb4QFMWIl?= =?utf-8?q?8gLywVdMXv7ONN4P3UgfdMR5YtpSRJQ8C3cxe9Lygov4UjKlPuMDQQXf89v3yPw9P?= =?utf-8?q?0luz/srjkwKzroWcCJ3LRV1BM6Nvx9m96mCYSLDjaAyUXEn6CICj8Q3qKWjiEzD15?= =?utf-8?q?TiTTX6FFO4UF6sdYhdcX3QpVmf3+WRt1Q+IDWwLhHvhPiWk/KvcVLDjgaAD9OCnkR?= =?utf-8?q?81fw/MMNagDp3DwfrLzhX6EtVVVRaorxS4Y6N1weiKekibi0qyZ0v9SKY0WKS0gAr?= =?utf-8?q?j7hYklbDM3m2kSfrv0gSdmMoJMfJJrDWQFTm5ofkxpREMEkukzWDKpMvoAUsuNmRZ?= =?utf-8?q?rRgCXsh9yVsfI0ahXV2ncsTOVILbxMbY3NnbiVpuXfHwdKZ3BaCO0z27TITev9ztU?= =?utf-8?q?YbwhiZwZoHX+AwRpcMa76HJS+ENVvr5jJfs9dv9g1nuvAUwDzoICGxAvXUz0pxSEz?= =?utf-8?q?qhi5J4PaUIAoSsNwbAs9BMr17bCrCvQci3M2LEzd+l4qbE6zAJBRAQU3Cy/pNDnY0?= =?utf-8?q?sw1zsNd0svFg/tg8EsWkxYR9V1oTE0/5I0SSwJEC9DnQDjT+zTz5ODTKG1f83IKF3?= =?utf-8?q?aVGTEOJBwp1jidlkb8K7klWnffn1l6JSKTxa8+g8bG20HWiwlmKMDXA+QMRxQz2Ep?= =?utf-8?q?C/2ND6eEUJj5hFsZ5faTGKmyvIc6ky1ZTBh5u1uPv9Q8+fKvGad/SNqLbTjA4xshE?= =?utf-8?q?wr4vjPfCLodrr3tij0INXlfxsyiI7drNbqmmxwrBZ69ytn17LFivdwaxBZzqwuf8L?= =?utf-8?q?L3Sw10HYwrdH/nLWTJc/fktS+rJIU3fLxUsDH6ofqW8/fgLbzKkbcbeaFv/EDR/5f?= =?utf-8?q?+Smet6sqdJ+BeazTJap6VBXeN8bl5kdze09g62OhIoRtmanEwOs2GNgJ8cKoHve4+?= =?utf-8?q?7XJ9HGMO22vGVDHRNBNQcnI7r9tY++lmlQvSVzJZHZ/B7o8BBH6I5jxRvvBdqGEMN?= =?utf-8?q?qM3qYQHDUNUmAx7KKhyHlPyKclwI9GYrwxl8ZguGmwjM5Tdqc1/a7w9kuR3H9G/s5?= =?utf-8?q?s5QyzKF+2wjcOZ0L2D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52c3414e-b678-4af9-8990-08d8befc9697 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:38:54.1734 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pZR53DGNqD9VNOcL6aVv26MFENQCcsZifapByK/qGoAYkBvRVQEf/lAL+z2hsSFbAsy/3uhKlFY1hwQqV0o6iw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a check in get_cpu_info() for the ability to read frequencies from hardware and set the CPUPOWER_CAP_AMD_HW_PSTATE cpuid flag. The cpuid flag is set when CPUID_80000007_EDX[7] is set, which is all families >= 10h. The check excludes family 14h because HW pstate reporting was not implemented on family 14h. This is intended to reduce family checks in the main code paths. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/amd.c | 6 +----- tools/power/cpupower/utils/helpers/cpuid.c | 12 +++++++++--- tools/power/cpupower/utils/helpers/helpers.h | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 34368436bbd6..496844a20fe2 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -94,11 +94,7 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, union core_pstate pstate; unsigned long long val; - /* Only read out frequencies from HW when CPU might be boostable - to keep the code as short and clean as possible. - Otherwise frequencies are exported via ACPI tables. - */ - if (cpu_family < 0x10 || cpu_family == 0x14) + if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_HW_PSTATE)) return -1; if (read_msr(cpu, MSR_AMD_PSTATE_LIMIT, &val)) diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index f9a66a430b72..d577220a193b 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c @@ -128,9 +128,15 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) /* AMD or Hygon Boost state enable/disable register */ if (cpu_info->vendor == X86_VENDOR_AMD || cpu_info->vendor == X86_VENDOR_HYGON) { - if (ext_cpuid_level >= 0x80000007 && - (cpuid_edx(0x80000007) & (1 << 9))) - cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; + if (ext_cpuid_level >= 0x80000007) { + if (cpuid_edx(0x80000007) & (1 << 9)) + cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; + + if ((cpuid_edx(0x80000007) & (1 << 7)) && + cpu_info->family != 0x14) + /* HW pstate was not implemented in family 0x14 */ + cpu_info->caps |= CPUPOWER_CAP_AMD_HW_PSTATE; + } if (ext_cpuid_level >= 0x80000008 && cpuid_ebx(0x80000008) & (1 << 4)) diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index a84f85a9dbd2..5f61eefff5b2 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -70,6 +70,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, #define CPUPOWER_CAP_IS_SNB 0x00000020 #define CPUPOWER_CAP_INTEL_IDA 0x00000040 #define CPUPOWER_CAP_AMD_RDPRU 0x00000080 +#define CPUPOWER_CAP_AMD_HW_PSTATE 0x00000100 #define CPUPOWER_AMD_CPBDIS 0x02000000 From patchwork Fri Jan 22 17:38:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76010C433E0 for ; Fri, 22 Jan 2021 17:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A97923A81 for ; Fri, 22 Jan 2021 17:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728604AbhAVRuF (ORCPT ); Fri, 22 Jan 2021 12:50:05 -0500 Received: from mail-eopbgr750074.outbound.protection.outlook.com ([40.107.75.74]:1797 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730098AbhAVRlD (ORCPT ); Fri, 22 Jan 2021 12:41:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=COplq1XfCN/LWkvniij/Gmi4SihYVPndF99aNSHxvitJ2JeIjcE9d+EwJ+RY0+JmItgZU3lBXcbAjUotGsVA98D7G1hJtzVwdBwO72i0sajj1rEGOC9bS0EQTHoCiXU9JM2jUGVaYcMW/iwrR9SKDOacJ6FX0pT3Zb/3vfnQ3jghK3Sa7He/JxpzyriBurE+AucifaPWeDtCpUe+FrfcB2NLm1dgtqvZRleW4w9veimhZNnF9JhNK1WZBMtNdvYKnaWhnZVvIevf4OS95Ubvo80XAa/wPl7cod2kryrZ3UYlY7uB75xwvmJnC9W3YQFkPlsLUEFpP2ROHXqUZFP2NQ== 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-SenderADCheck; bh=YCkuxf/L6Zz22ylL2SG+gWNRJlmCcKBQlEIZjyS9Hdg=; b=Yfq3PFqhcYn7s9LiQ5CySx2J+/ba+43b4/Yk1nAKNKj6nyvsOt2WJGmI4diw4WlsfAJXuFgRqb/STUzWBqHJe+31s4zeehI1/AM2W06KKzP5a06tBzQRvqj1Bmh5NzJzqBvekANywbfPuxuOmHeShteAW8lwY6R9wN8ObopTTx9CR2QHJuOxaKzBcH/qEIBR6wZj16YMPwugL+6s9FDxUlJKgEip78JFCwVDvcdEZqZNyeZACz1d8WAQlvMh4xiqmIFyUItuHnUYBJxLlLuIcxh084e0nqiXQgYw39E74++qP49H8CesVJ0gt5I8VYFh+eQTXRvNlN3QIPA1vggreg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=YCkuxf/L6Zz22ylL2SG+gWNRJlmCcKBQlEIZjyS9Hdg=; b=IIrfrFDlGCpA958yD5U30jhIqiqAz9HoZQ6wfmu1gecyPDiIW8iC06Ng6cHvoTpbLjl8/kWeIY9QCEjM2pCUoG8gceKxRbAZ32kf4ZyTc+3X4nZDegdodd6yP1165+e9uqcJ8ebSi+0r9FVD/nNlutBkLH98zKBK+C+GNDw7rhc= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:39:01 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:39:01 +0000 Subject: [PATCH 4/8] cpupower: Remove unused pscur variable. From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:38:59 -0600 Message-ID: <161133713953.59625.16161917133620548390.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0006.namprd17.prod.outlook.com (2603:10b6:610:53::16) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0006.namprd17.prod.outlook.com (2603:10b6:610:53::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 17:39:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 16c85543-edb7-4e63-0096-08d8befc9b1f X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 052uk/fbj34yUZjn2g8ztyW/QlzlhHkhoIr+T6f00KZKkcRH8JlSa2tsaUWznD2MZKC1HjJ45wM6HVQmrmGObaSA6zKsGMXgL214lhq20M9w09FvLcD//NJeQNbwqWbb1uzjTp5SMdwVcV3rmg5/KimCGVph1ceMp5OMpJ/6PY1Qqf45VHGGecKIZnZYqBZx2dKOTozWBXS+elUTRTVpRYRt/DBqiY9C3zxX1WwXV3EJL3nvPGfsanv36UZ/Zp3fEwI2VVTbF1IjuS6LAXQr7/exCZw/Lhq1DDiXplnpDnDPpHAtuBL1BHRpcKCozYk2AAALtvM7TJl5IeYiDiKK3YBI0h8dRt1FpGhHqySw0HLXYllIefC9KzvbM9kfFFdmE8W0EO5YFm5nMRev6uLDmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?QOKKzUYzHan+G6QpomJ4RTFCa+8+WX?= =?utf-8?q?hZNreVaOgFE2hcHtQv9pLlULqAxc5Hd1cpjze/Eh/jlW7Ola1vlsVZ6blGElv2saO?= =?utf-8?q?wTmoIBBa7mT4JqOVAC0VAhmon0r1QbPDYWkp6TuXo7pEEhffFOqvfoGc47GW+5Pbd?= =?utf-8?q?c/g4YUNgaQHoh+X4fUgw0TM0uZhP3ZQpXtb4RcRhHVSL54yda4lft3be+fJrME8Wb?= =?utf-8?q?iqj/xzewIjpa8oP2IlrMiAVQHdoXDTgc3aiyjI0iMIBgzzoNri0afmSmEix7NTAlw?= =?utf-8?q?OpN6Ap9WSGI6lIV5RRn84gBmRikWSSbYNBM9CthkCCEirUhPrXAcNGkPISxft+WX6?= =?utf-8?q?iETbTfjavyQVGiJaqEbUKRV5bUVVnPn0+VzXVUSkPvhh9s/0XhLOkw4yQ0gElS5zD?= =?utf-8?q?v6t3krtyuB9xLi4/06Lc0MUNCixyNj95d4rEvt5rn51khQsDpAsxj4UvOWwxtKTG8?= =?utf-8?q?cqHuV5a/tsWg7b6sEt8A/drugdx1vdWveY/pppvGz/jdXZ4uifME9135K0znVSoG+?= =?utf-8?q?+GkZlEHt8O4h2nomw7SWmH5I+hP59yEQDlDJx5qYpfWWMPqiJPYyit0X7Ej+yEDvu?= =?utf-8?q?TbwGHZhquoQA3bfZnOJ59VH/fE4qGFDxY93JOoRGrsxR/isr3lqkxE2RnQqcXUeqv?= =?utf-8?q?8TmrDyqICLG8q22oiBpppfgkhARHFHlZPmWPnCBnYl1stFm7nNY3jsjeYP9vc8mkR?= =?utf-8?q?JMXJPRrZIMgLts+lSF1i77s7gr32AhcVbINIuAVQzYh2N2pO7IYyfxQ38gQv6cpo0?= =?utf-8?q?9kaau6oUwMoqyRg5I01ZR0NrSufGHwSpCHkzNNlaZ5Xa28Bo2ChwCgNade52U50+I?= =?utf-8?q?JPhkgrWVBRjw3qVZ1k3hJR8vQVEmEcJdWJ2XrKYxjVd9UENZY1e1gfowioqPRuQJM?= =?utf-8?q?yd9Pyrl98RXsR4h8UY5CPskVyEFfeGv7LYy/RhUUP1WN/tbWSPytqLIBEnFi8YNHE?= =?utf-8?q?B5tOg5dG6fGatileaRHJU++12Zh310MkhZ6rH1AIbz7mNCPrDzG6VErq8KavgMPKw?= =?utf-8?q?lEHs7U7szgYU8E0i+z?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16c85543-edb7-4e63-0096-08d8befc9b1f X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:39:01.7760 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z4PTKeu5al1Rx5/Y+U3vTc4nrdk/nV9MSYTd+IJwpjk+uisaahkw6oFymGkrMfFZW0eGs/DIpu10C2Fv+VbPjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The pscur variable is set but not uused, just remove it. This may have previsously been set to validate the MSR_AMD_PSTATE_STATUS MSR. With the addition of the CPUPOWER_CAP_AMD_HW_PSTATE cap flag this is no longer needed since the cpuid bit to enable this cap flag also validates that the MSR_AMD_PSTATE_STATUS MSR is present. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/amd.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 496844a20fe2..bd4db2e9a8a0 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -90,7 +90,7 @@ static int get_cof(int family, union core_pstate pstate) int decode_pstates(unsigned int cpu, unsigned int cpu_family, int boost_states, unsigned long *pstates, int *no) { - int i, psmax, pscur; + int i, psmax; union core_pstate pstate; unsigned long long val; @@ -101,13 +101,6 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, return -1; psmax = (val >> 4) & 0x7; - - if (read_msr(cpu, MSR_AMD_PSTATE_STATUS, &val)) - return -1; - - pscur = val & 0x7; - - pscur += boost_states; psmax += boost_states; for (i = 0; i <= psmax; i++) { if (i >= MAX_HW_PSTATES) { From patchwork Fri Jan 22 17:39:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F34C3C433DB for ; Fri, 22 Jan 2021 17:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B902A23A6A for ; Fri, 22 Jan 2021 17:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729236AbhAVRnX (ORCPT ); Fri, 22 Jan 2021 12:43:23 -0500 Received: from mail-eopbgr750049.outbound.protection.outlook.com ([40.107.75.49]:65531 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729994AbhAVRkn (ORCPT ); Fri, 22 Jan 2021 12:40:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Trz46bQM3bIREqEhvRNCqV1Peq7xGuP5Zt9PqfjzDH9UPWrp94GMi8GO/JX8lZdzAr+NfMuSgvy9N7L4W0wvnLuUf3OUEc1jsv9oA2GAuA/lrHw3roLBASOoDbeBjaTNbcO12l91r+lvIteAxUboGiLHZvETCLafK+ZcJcBMzJCXqLLsYM/M6dBnBT3sniT9hM9lxRrgtoOFm0bU/EsCd9EdDNt7FxQ2dIUz9DUxiyvBB0C3PXNuyvD9n6vXsrYRAHtmOFlSWarc2KfAog06q7NataV4/Pale7x43mUlDfgx2qjvyLOETkRXW/3y1rGcsjt0y9Mgx7efPmM2kUR+iw== 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-SenderADCheck; bh=35NZcGzNKLvl3GTTFopu6Pul61xhg7f8apjvx0INRNM=; b=juh0M3BPwSqEhIk1W/I/c/YEcoOR88Lpyo5O7co3ba6BxkvilZeI2OZ1BnIDYuvH0NztH2AJbU3q3K3GpsjPtjbN3L99i1X9/+GkktZ0OLXAaBjaexnn33F7TBl3lhBIu2Jy7bkha9Y4uDon8lLnqXXXsC4qvASYEE0Uxa/AFza3L8wEYVLTOITVZzW8arwh1gsVSHOPf82XIvJlo0Doz10CtR5mMRfYItjanmc//8OSuzWODHzwkgMc5vo9pmYv7aY47ndqxqhE+RbW0T1XtyRGyscAQbx9x38M9rvoMYJkNRf4adqbH9g7SdUhpT2zMduH00VXLirnEEftahxi1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=35NZcGzNKLvl3GTTFopu6Pul61xhg7f8apjvx0INRNM=; b=WzU5ydpLqrB0oyVQfZwpA+fEzJW/igodNvWgpjFrw6gU2ut3RXhCXcWeR+SuGyq1/9A/OHfpZ++9vvifFYOvnJvDC9H2d7e9XVHEUzah+WLoJp6QXPVY2f26KEeVEMJeqWq/8sNWJZdTr4Fhgo5R1PcspXGI1weBmOiyH4Hftek= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:39:09 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:39:09 +0000 Subject: [PATCH 5/8] cpupower: Update family checks when decoding HW pstates From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:39:07 -0600 Message-ID: <161133714713.59625.6299790565871909582.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0009.namprd17.prod.outlook.com (2603:10b6:610:53::19) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0009.namprd17.prod.outlook.com (2603:10b6:610:53::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 17:39:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 14954904-da75-454b-25b4-08d8befc9f9f X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G0MEg+OVOIF+tUWTe/scu6hBeDz6amIqR3ovG8sZkH9XcVBBYwCKQFVzPl7ujFwXS7muF88ZGdSfLrYX8PrFVWPZlayUt7RqlO1KqPh+xF02YQ0FhECind9WRmaIkuMW2gVOyYhqntI9Skzfm+2UOs5QYSNztI4xWfR3uNBMogL6LmmSsgjhWWiGH34bydQY9Q/ofYsjPnIb4UyJYnLCd0PLRt8bjGLICAKj8xtBmMoGyJei2J2S5bZObCnKdPOJ0vzMpd+kLIU5hkylSdVC4X+qG9vug7CMsUY8WOKQpWubO9p0CAQG88GBYyuLuwkI5UfP2XBiayix8mn/Kqd5h31nReGL+tedX2nMI+CHEsk0utrmanzKK0Rx1NUdizgJZBhHPByO6eyQ1yqFyQaKWQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?KpgXfp2nc2PsGFhqM5geDQfN0lSRGi?= =?utf-8?q?0zIvyQQKgLGMheP8+tOLmtXzT6SXLwhHinI8XNlU8f/X5SqP8hOKk2C06cAr4lDFt?= =?utf-8?q?g1/Co0uiYBVT9GPljNPy+yWKpouJhFv72swJ6gViteMoMPSucALWChsmCbTBg3S3H?= =?utf-8?q?lMkNTi5wa5IsmpuBDZKwkPJQmF9Cs/JsraST1pZt0+UO0k5TH6JvJum9kvM34l8n/?= =?utf-8?q?C+T5tAT2xs1BTpxthpF4BxQVsvLf1okK+Ik4OksVXi+JHhQlGfuVdAHDowfWH6D6F?= =?utf-8?q?VwvXx53bECDCM8/5TtZhpXPHsuaNZAedJvCyd1pnNwVKfuAjGs8ofFZr2XcN8la9v?= =?utf-8?q?4EJgz40ZpB7X33jRpKbFyqNRqaQjHc2DU243VCH9AxjfccfjQ3r4IP+sDE+k6Pm8D?= =?utf-8?q?UVqZYX7xhsSFsTYM3E8imrYjgUITH60Zzm37SFYewNVQSLEml6bdD8vLNcMUg+GrM?= =?utf-8?q?9AIQIKzk3DUHg5e1KzFkOhJe5NO+c+Vt+LZizHh3QfVF7nwX2VWo2mpz8jWCYBaxn?= =?utf-8?q?tnSGelDsSvghuNUWblmFFWSoKD96Nz6Y5bPKz/JvLsYQpo0MqlyLLh2NS3a07gHoz?= =?utf-8?q?E0xkF3CJNwQ59WNb5fmwrURDc+F/kwXp7j3bDdqfDhfxnGTBehv1JhqaHjj7sChk6?= =?utf-8?q?NhKDhqEDvtAT7DuMI9BnPK00BuFSzTzHEby4+upQbqBDNcR3lKmEgtSR9DPcdPOc6?= =?utf-8?q?JNoSFMoHpliqcII2qeNnnv+SUZY5qGIGQCVd0nYCqKzeGOq2CDZMtqGR5wdUdbyTb?= =?utf-8?q?i1V3tZ5Db1JNgOP1qMMlxe90alX2Wr0cQEKsEtbFqMGxeRZJxoDUXTz+jcSm9FfnP?= =?utf-8?q?KpubFvAsYyvXgqfsMLgn/EDdIHYfYq26DeqTPmHvspC2G5wi3wgmplTYzgsOVCyTP?= =?utf-8?q?FO2f267W+8KqWlMZMV8tpWuQM3ODMKWyPYxfkR97t/Edc2in/3+3lbpwyzD+7KgYc?= =?utf-8?q?sYRmyzlkyfanHzwO9tbNSKP7IBpQ9ApW/R+U31GFRXTV+SWfnvqSu6Lnojz1Iuve7?= =?utf-8?q?7mt9qPFqnNiqUh9O//?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14954904-da75-454b-25b4-08d8befc9f9f X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:39:09.4496 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LuDEbv5UbUbIJTZctUUGCeHIkvt65tZ2P4ZKdE+ldOMhBNzjOh1Yv0uXScnEqkI2XrT8khdMpsYa5cvcU5nMSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The family checks in get_cof() and get_did() need to use the correct MSR format depending on the family. Add a cpupower capability for using the pstatedef (family 17h and newer) to control this instead of direct family checks. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/amd.c | 8 ++++---- tools/power/cpupower/utils/helpers/cpuid.c | 6 +++++- tools/power/cpupower/utils/helpers/helpers.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index bd4db2e9a8a0..519a21e92666 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -45,10 +45,10 @@ static int get_did(int family, union core_pstate pstate) { int t; - if (family == 0x12) - t = pstate.val & 0xf; - else if (family == 0x17 || family == 0x18) + if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) t = pstate.pstatedef.did; + else if (family == 0x12) + t = pstate.val & 0xf; else t = pstate.pstate.did; @@ -61,7 +61,7 @@ static int get_cof(int family, union core_pstate pstate) int fid, did, cof; did = get_did(family, pstate); - if (family == 0x17 || family == 0x18) { + if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) { fid = pstate.pstatedef.fid; cof = 200 * fid / did; } else { diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index d577220a193b..db2e88ceb67b 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c @@ -133,9 +133,13 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; if ((cpuid_edx(0x80000007) & (1 << 7)) && - cpu_info->family != 0x14) + cpu_info->family != 0x14) { /* HW pstate was not implemented in family 0x14 */ cpu_info->caps |= CPUPOWER_CAP_AMD_HW_PSTATE; + + if (cpu_info->family >= 0x17) + cpu_info->caps |= CPUPOWER_CAP_AMD_PSTATEDEF; + } } if (ext_cpuid_level >= 0x80000008 && diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 5f61eefff5b2..e4dc44ced770 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -71,6 +71,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, #define CPUPOWER_CAP_INTEL_IDA 0x00000040 #define CPUPOWER_CAP_AMD_RDPRU 0x00000080 #define CPUPOWER_CAP_AMD_HW_PSTATE 0x00000100 +#define CPUPOWER_CAP_AMD_PSTATEDEF 0x00000200 #define CPUPOWER_AMD_CPBDIS 0x02000000 From patchwork Fri Jan 22 17:39:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EA48C433E6 for ; Fri, 22 Jan 2021 17:51:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FCA523A79 for ; Fri, 22 Jan 2021 17:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727350AbhAVRuT (ORCPT ); Fri, 22 Jan 2021 12:50:19 -0500 Received: from mail-eopbgr750077.outbound.protection.outlook.com ([40.107.75.77]:62028 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728555AbhAVRlL (ORCPT ); Fri, 22 Jan 2021 12:41:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SBbCFmt1I2qzImAtbNVFZRSFv1JlpfC51Hj+Vfje5f+ibbO7k5uYq7P/uNjvh2mo2wkHfXYOnkHSrNn8EVEcd3TRxLydmNAVqd6UJNRCGMP6B1+TzYt4jpdgj6BWfvFY7H/pPjMfh3Uy8qzggTQzfd+WAZfbEFbpVnCZmslJLjcC/pYuFn28yZRt/A3YYHL7z2sM21iaaGVnfGdXLse15xHecmTGAOxAuPLlhkGLAIW3TGOSGcKgt5OgRtUEBViNhE0Qzce4SnObYBMTEsqKVCLViAEOzr8WIjmD/a/y0HcMPKqgF5F24zwutZB5mCE7LhlEbCNcz9o52wf4pbfiXA== 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-SenderADCheck; bh=Rvc6+K4QVeMwEz74t3Y47bkKLZj/lGJC+zumFr89ZxU=; b=b6Daf1wjGUxsrMUkprPieqMp7g3EZPmb4BzZFTip8QplcBO+Xrd2Nw+gPwDJQc5K7Q33MgdVdg1J4XDUrxWv5mqsFiCJjHWvZ+noqofg5j9X5OPo64El4WnqL2AMmrIUyGsipNpwiysT6Dkg+Hvd1vOq1bNhpGX0hmJMfsNL5zPaJG+89P9KztoTdt9/wrE5gGEuYKPFx9X5WsisUO8J0pPUzKcL14Kos/Q7rnt8V5U4I/kHEIyR4+JFJXdJnUngxr842EiSwGgyRA6Z/M2K88jL6P0ZMV3gqE6BkCBaBjRlWwaNSJsOlXeuJpTDio5vKkVAlTWZtrWw0dd0Xs72Rw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=Rvc6+K4QVeMwEz74t3Y47bkKLZj/lGJC+zumFr89ZxU=; b=GigE/4RSdn2z3eZ3qOjerBebICYSdDpFlxaS5C0ItMyXn300C2UoV1mO0x3DdLf4QeATn/xpGeoxzcTccLGaMQSqnz3AqOz313fzmVMM0amzM6hfWnC3Ko6Q1gVltM7TpjHM6SVbdg1QlhQQhTX7wNtpLOzbNodr7ksv1ddzN5M= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:39:17 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:39:17 +0000 Subject: [PATCH 6/8] cpupower: Condense pstate enabled bit checks in decode_pstates() From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:39:14 -0600 Message-ID: <161133715479.59625.495972759377981936.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0021.namprd17.prod.outlook.com (2603:10b6:610:53::31) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0021.namprd17.prod.outlook.com (2603:10b6:610:53::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15 via Frontend Transport; Fri, 22 Jan 2021 17:39:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fa641c56-b00c-43d3-f6f8-08d8befca432 X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pLwNqg4NHBxdjrNx0Y31/bo5rFUZDpAOUgHAPMrPJeI/Ojd2n4XY+WRoUquM0JornVHAfQfp6sK9eJxrKfzVRlIBM1XZo1RFhOoSAQaxZ5ibtN9n/hpCbAZoSOLbBWhaPdK4rfzDv8P4NoZoEO51uftcL0hK+94TWF1/w6YllbJadu2PXPOLhOe5maPqXns7HagDJg1AolBf77CR8TVYxKprP3hOk8p1Nx/CMi1b4LSXX2ISy/0ipUCimmoCbGe3JUYGqzENk+4GXJnKLij4QV/air61K6lxAv72ls7//h4So6R6GjftPFT/VOSUWtwOLodQnnPNllJLha/BbRzr8UtQVGcMu4gPhnP5Os7uFaCQEggxLXydmvLKf3jvRKvdtSJWE3Vszta4TN6fceZXQw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(4744005)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?jJnk9YZULhLc/Ecd6P47lLisYfku/M?= =?utf-8?q?LbI7DhdIbFeszG7FwBueVQGuJXtmMmkVASA+DCxGM2AQ4rdm/HF2/rCNul4Lm/iV5?= =?utf-8?q?c5VgNhRAx6xlD4WUlP9fQ60A+DpKUSJAcOEQZUe9atso+PUVWiISGWLSaIREE2LpD?= =?utf-8?q?ULG1GiYrRlmUA9j3H8nnTRxu95xcsa+K1A9aZgDHxxSDhoUr3OiUKv9/SZkUqp89x?= =?utf-8?q?5mMrHjbpIlcyy0c2TmWMRjY+Lt3QM79iLH0RplnGVhyS8H8yJlYBDyApQqw0Unr5W?= =?utf-8?q?FgzUydMgDgfZ8l3xTaVFMpdqkwxDACK7aP+PVD0FNp4vCC6vbQdWgjGxVkwkJUWRM?= =?utf-8?q?TtJFl3QmxXx+QnVoORanr/7lFsNxod7TxtDtffFMgx3TtiOj7rcdRWg9iDeIQRCd/?= =?utf-8?q?FZC7hKjYgPe134JmivjSTX+c+3d1PFUGc93zCmeDD+oap68Ans4HFzFYnwL7mJNzp?= =?utf-8?q?7DmqEO99jjLgPwM2iGv70LSb4QPT7ovtan8SAWx3vG7jatZVRyX3OIiFE+GFuJioI?= =?utf-8?q?GqdiqIxh2eNCQOvfzkV1wjJk7wzBve4+o9/aB1Oe4Fk5Z5TlR/DTCdMhSxzUqoEMp?= =?utf-8?q?nhXsMENhs8XwIYfX4Yxqq/bh7V1uIdeWilzwMkHUGAWdufC2QZ1x7A7VJhI6N0+oy?= =?utf-8?q?nYKUGCNnlw1J/m+Fx7oXF6nSf2u0fgxRkEP2nhvOi9g7dmD47FCHkaLFZqE5SmB/w?= =?utf-8?q?p1oRtz4PMVoMYAvmE2O3i7GpZj3qGTB0IZ+9kE5WDrD7d4kxtsEaocHPLOVizcIBb?= =?utf-8?q?L5M1uK6c6dPwxVfU2MZqu4UOrrBoEGvycMIWR55U7KJoVWYRjYcsf846vI7pBtEtP?= =?utf-8?q?Qwvji+P/aJHry1BC+Wk+oSVzyzHCpMYLsf8maf4Db0EJSjBBoN3SI7IIQILRrz9og?= =?utf-8?q?14vUQsYTId/6Z+rqhFpq4YMAx1Tc8pzYcQIBXsvTBO7fFrzRMK/ugoi6HV8yUE5YF?= =?utf-8?q?xEmAIzTBmPnTg7owhicCN8YnFDFsvW27ldfn01BD5Pd/iDNm3HyXl2QeFnjZ8Tddr?= =?utf-8?q?pewXcXR6hXmPERJ32U?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa641c56-b00c-43d3-f6f8-08d8befca432 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:39:16.9864 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IQsBMK8tAVh+TI0Kceh4dwMno4w0f3Y9kM7TEjo/ejr0kAUtq8ACb2yCyCUNSACmVu5zgyBnMYEaPiqRL1eJSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The enabled bit (bit 63) is common for all families so we can remove the multiple enabled checks based on family and have a common check for HW pstate enabled. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/amd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 519a21e92666..20694c3f367b 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -110,9 +110,9 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, } if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val)) return -1; - if ((cpu_family == 0x17) && (!pstate.pstatedef.en)) - continue; - else if (!pstate.pstate.en) + + /* The enabled bit (bit 63) is common for all families */ + if (!pstate.pstatedef.en) continue; pstates[i] = get_cof(cpu_family, pstate); From patchwork Fri Jan 22 17:39:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A00EEC43603 for ; Fri, 22 Jan 2021 17:56:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7275A23AC9 for ; Fri, 22 Jan 2021 17:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728667AbhAVRu3 (ORCPT ); Fri, 22 Jan 2021 12:50:29 -0500 Received: from mail-eopbgr750049.outbound.protection.outlook.com ([40.107.75.49]:65531 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728499AbhAVRlM (ORCPT ); Fri, 22 Jan 2021 12:41:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQMn79JOYfBET+ry8LPwO7yheD5v1br7TAJICN2cWrvtHLTuTrPydwM3VusPBv/P3gSTL79YmnIIW8R4IJmEXFcmL1Z3Ami72ak0Yh8sHll9PiXqFF5zHEcYGOewoOMhYoiAv/fS54vFTfIoFloMRFbeqrJOAmSRjPjmgfCqKVyG2VP+JndAWdxZ0fKBcIoLHsRirBPnibyuFWYci6whHcENo098eWuz1yrKDCGHWYrJjlnrVd3TBUvssg6KWZM9SH+Tuc0+Q7ZYMBuuJSnF7JF4b+TCjbXjBmGKadbSgf98c6VHjJwy2M/kwX8dzdVhxsVkcrKwbd556tVER2v02Q== 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-SenderADCheck; bh=BMJ3hvuFNrjL/0qR4WRV+UarsQBnqKw5GoB5Z9n+Wlo=; b=fJ8B5N1ilw8uvYrUig3W3IJq16xGJgBPZ3a1L1nz+8liL+OJwiTSPkTvY7ehBOZCH/qL0eVUcUWJbdT5JcUx9ZPJfCDzRBJGNTVq5DvaJsVplzNpspYInbMt3lBE+H1hCpHn17EzojchhfZxEp6r/HWRPqdVQPCugaziAkS9xQbhwcbPQfD7YgITcz1Ctvbwb0D/WqOMVxQqOS4fvIw8NNOpwLVH7zeZX//uRdggvz0qxOMySrP6Ub7FJIx+Ki6Lw9tzNNbj4h3GPnAx55kulIZwgOXMKORyglmhiIny5rt8nRsoCDwNYB8UMQTJi1CCrq8MIi0cR9JkEMPCb4DeaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=BMJ3hvuFNrjL/0qR4WRV+UarsQBnqKw5GoB5Z9n+Wlo=; b=i2wnxdAySLTBENOIvxllK9MjsAf7Ekg5wMpGfEwHCa0Jx+3J4W/AYYEI4J4J+p0nmxVk/4zo6QddcLYrYy8Uq5+MEsbtRNe4saMZtu4Wegx7rLZmY3uIDcov8xZ1AGrg75TaiD+HA66McMlFKXwzun8JbXT03lWm6RhQ40X/MT0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:39:24 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:39:24 +0000 Subject: [PATCH 7/8] cpupower: Remove family arg to decode_pstates() From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:39:22 -0600 Message-ID: <161133716232.59625.8399970891746681982.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR17CA0005.namprd17.prod.outlook.com (2603:10b6:610:53::15) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR17CA0005.namprd17.prod.outlook.com (2603:10b6:610:53::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 17:39:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 53bc23b0-effa-4952-1aba-08d8befca888 X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gjhy1MKG/yMTWaKVN1zcNSdvAX2fJwYwNGvAAa/uJG51ycdq5G6GCNAiOd7ghoLDDt5bmu+3tmMmfmlG6wA6UVhzxjVpAvMVycN/B5Oiyioj0eB40W8HmAdmFv2lng/svabhyIjOvqsEuaqyU6iECuWYVdg/msOGXQ1NSf2ofwGPS4uef4zSHPzXMdN6/+BImvpxUXItnQz8S4en9pq99SBP4ek8tkPd78y6UvwaD4wGioB+VGgWkEDN4CZ/mXFNQo3/Q+z2UdS03GwZvDzac+phs81iBzYbk07oPvluwRq6bksJxPq0IHUoXph+cwHb6Y2yKLEB3V+kWdnbLUWbrnpvSK/qi6t6tephBnxkwHyXKczL153iIR6/2aIjdxtoFesj0Hm7SHtM3foz0E5fqw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?GhLBgq/GbTq7gxUZIOI95WzQfnFwpw?= =?utf-8?q?ReGyxvH7SYaZgLuuq+Z690A+tvH6p02WbYh25TirfV46sTjGOE+Q83ov589qEhFuE?= =?utf-8?q?iFvW1cKXvEhNwEaf884Rc1ZAO1S3DLsz4Yv1LWXNFcsgz5zRAF1E+rweAFDWHVPvD?= =?utf-8?q?RLIqJNBzBmDsmzfZMHdt0DvBFy2qpqsfpNYU7s8k/nSjZowcFZJ4lDlvVP1FzXgDw?= =?utf-8?q?7DpYBMWf+JXvfHuNO5FMwEst/TJpUpTN95lTjD3WaxdtCdL5AYPz082Rtb3Z1P8LE?= =?utf-8?q?rXaVJekEEZRypDNEGvI+eouAz5Ws8LWCoyC/tQ9nQhg0S50lK/Yf9BGn+nFoJvvyr?= =?utf-8?q?ehy95M7FEL4ZjdaAUqQPbCwbgMXlxyQQrLRR+MC11vvnPXDYdm+dV/jAx6yOwQYgd?= =?utf-8?q?NZDwgts9c1qvJmyeU7o7avpXLu2SZ8o07bucNcNgwX6gg5EPj1zkrOeV4IPIOTxYs?= =?utf-8?q?cGrvklTNiTV6p59YuVrdHZL6/iH7oY2GprZlspJvnVnHSVXYM8gIVUFtYB+NEQMf4?= =?utf-8?q?HKhhYKp45PQ8MxKJbJojAMS/J1oXMnqb5NHzoc8kHft03qYAhmpJnrp5VxfjJWjzf?= =?utf-8?q?9w6M7jAH4esbPu8HU1tB06Fw3kkC7G1W9Z9KA7ZpDCwSJu/gTNe7aOSjMaw/PTdDN?= =?utf-8?q?IFzhM4pov5bVewNUVm7tMxLS59+b5KjUHO37ncxDSTPuXw/2zNqqwC3CLuYblzGXq?= =?utf-8?q?OGd3P08JLcWQOLKF+s7qfL/xcwUBlSmi4fufPniF4XD/tV6tByRVF3UwXyyDmU7Tx?= =?utf-8?q?ThiXZN138YHGaH06/OvuR1DsI2BebT1FkXr4ZYBju95Xa1VvNz3s5CvHVcCCXLDuo?= =?utf-8?q?zaNbzC2CQr8jIrkeDi+3S0MJCOOEGy01LFvVYkw/T0hFRCfiRDYFR9tyaYMKKp2uu?= =?utf-8?q?lZttwX/yZLOoQkoBs+UkzDP1DM+PmiQeBBNPYnzV4TsjCLUX3chOX9J7R0bmaHq0k?= =?utf-8?q?eQWZIIINO+Xs77RfiVYBV7BA2Gho3x+pEZNU97VFxJvETZjdK+Cgns1Fr+fY3fCI8?= =?utf-8?q?twDBcrXUoxV1/r9vWE?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53bc23b0-effa-4952-1aba-08d8befca888 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:39:24.2512 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: reKWG6G22JmjookkMt3cRvkkN5D6mFRILE7X227fcZPNxIDiDhBSdARjfvF3hyrCrBTG/cbXCBDi/CCYLL3aEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The decode_pstates() routine no longer uses the CPU family and the caleed routines (get_cof() and get_did()) can grab the family from the global cpupower_cpu_info struct. These update removes passing the family arg to all these routines. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/cpufreq-info.c | 3 +-- tools/power/cpupower/utils/helpers/amd.c | 19 +++++++++---------- tools/power/cpupower/utils/helpers/helpers.h | 9 ++++----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 6efc0f6b1b11..f9895e31ff5a 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -186,8 +186,7 @@ static int get_boost_mode_x86(unsigned int cpu) if ((cpupower_cpu_info.vendor == X86_VENDOR_AMD && cpupower_cpu_info.family >= 0x10) || cpupower_cpu_info.vendor == X86_VENDOR_HYGON) { - ret = decode_pstates(cpu, cpupower_cpu_info.family, b_states, - pstates, &pstate_no); + 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 20694c3f367b..01bb85121216 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -41,13 +41,13 @@ union core_pstate { unsigned long long val; }; -static int get_did(int family, union core_pstate pstate) +static int get_did(union core_pstate pstate) { int t; if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) t = pstate.pstatedef.did; - else if (family == 0x12) + else if (cpupower_cpu_info.family == 0x12) t = pstate.val & 0xf; else t = pstate.pstate.did; @@ -55,19 +55,19 @@ static int get_did(int family, union core_pstate pstate) return t; } -static int get_cof(int family, union core_pstate pstate) +static int get_cof(union core_pstate pstate) { int t; int fid, did, cof; - did = get_did(family, pstate); + did = get_did(pstate); if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) { fid = pstate.pstatedef.fid; cof = 200 * fid / did; } else { t = 0x10; fid = pstate.pstate.fid; - if (family == 0x11) + if (cpupower_cpu_info.family == 0x11) t = 0x8; cof = (100 * (fid + t)) >> did; } @@ -76,8 +76,7 @@ static int get_cof(int family, union core_pstate pstate) /* Needs: * cpu -> the cpu that gets evaluated - * cpu_family -> The cpu's family (0x10, 0x12,...) - * boots_states -> how much boost states the machines support + * boost_states -> how much boost states the machines support * * Fills up: * pstates -> a pointer to an array of size MAX_HW_PSTATES @@ -87,8 +86,8 @@ static int get_cof(int family, union core_pstate pstate) * * returns zero on success, -1 on failure */ -int decode_pstates(unsigned int cpu, unsigned int cpu_family, - int boost_states, unsigned long *pstates, int *no) +int decode_pstates(unsigned int cpu, int boost_states, + unsigned long *pstates, int *no) { int i, psmax; union core_pstate pstate; @@ -115,7 +114,7 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, if (!pstate.pstatedef.en) continue; - pstates[i] = get_cof(cpu_family, pstate); + pstates[i] = get_cof(pstate); } *no = i; return 0; diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index e4dc44ced770..8a0c11c6ec63 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -127,8 +127,8 @@ extern struct pci_dev *pci_slot_func_init(struct pci_access **pacc, /* AMD HW pstate decoding **************************/ -extern int decode_pstates(unsigned int cpu, unsigned int cpu_family, - int boost_states, unsigned long *pstates, int *no); +extern int decode_pstates(unsigned int cpu, int boost_states, + unsigned long *pstates, int *no); /* AMD HW pstate decoding **************************/ @@ -145,9 +145,8 @@ unsigned int cpuid_edx(unsigned int op); /* cpuid and cpuinfo helpers **************************/ /* X86 ONLY ********************************************/ #else -static inline int decode_pstates(unsigned int cpu, unsigned int cpu_family, - int boost_states, unsigned long *pstates, - int *no) +static inline int decode_pstates(unsigned int cpu, int boost_states, + unsigned long *pstates, int *no) { return -1; }; static inline int read_msr(int cpu, unsigned int idx, unsigned long long *val) From patchwork Fri Jan 22 17:39:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 12040125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5117C433E0 for ; Fri, 22 Jan 2021 17:51:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A542923A79 for ; Fri, 22 Jan 2021 17:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728922AbhAVRuj (ORCPT ); Fri, 22 Jan 2021 12:50:39 -0500 Received: from mail-eopbgr750051.outbound.protection.outlook.com ([40.107.75.51]:45732 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729194AbhAVRmJ (ORCPT ); Fri, 22 Jan 2021 12:42:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IR+zsExp6jkUgZl5rkHEB0ofmBjvLQyfmvm7Hz2toR0LuAIXNozH3RcCmnJ84XSSv2/afVXIutwjbXuHx2oBxbZqn+l3qCP9lizP0eiDC8z/FPrE8gFkJd8NIXP/GDtjjc/xA9zyAG9vnjugCWDkkbaA1rjNqLad87MaQlomqmzsf+ygNCRMH62M1164GrwGVOOf8+vVeeOwEfw6FrGCvLRy2e/APPYP7x+grJJDSnCzdzmyt2nbqdJ2AlcyhDEWeMR22zHCNXzUDUCuLB4g6PilNNWpCaGibJwC6h7Go3ChAfnEYF+jPq8hWj1wjjyqvXJN3Rkx9w2AWgx3evbxVw== 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-SenderADCheck; bh=bNDm1aRoQ3tc9/79od1t+dZqam/WZcpmnoz3H8TSuR4=; b=QzhisZeORRUzumR41Ggrz7jMp1lIGReyCUpjY93ptOsVSfUjrhXQ3cqy8bIzacsD+I6kMfycO69kEyMWSgsu+5lW8DXHZ+l3Hib+gP/1fBP46jEonFseI6++JxXv9YEktBXfS+2rBjh5hjPV0KncpR9u8M6N9dReEpHZBPIdGUow+DBKocpknOydW1t8VVo1PaWjlQWEtZoY0so8oKmDOEabdvdoGrMac+Sg8iKlTgnuedSY0JeC/WzeJScE/7dxHYN7E1k3WBqslj0Cx4ocGDvAIN4fE9Aefx+cLgfBWaKmSIz00+Jl5xWZowOzv2sgWpL77W3JOHSJfZ3C1/1vUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=bNDm1aRoQ3tc9/79od1t+dZqam/WZcpmnoz3H8TSuR4=; b=jKPPEVdSrsYooL6c3qvbLwc+6HYGo/8TrSopnroQCj8Y6pdHUhgwga16eXspsjUzSWMDXqyg9LtHtJQeAGbCJGZpxbG6X3KiTQvP/Ey4AK2/7wAbNV5maJ7qrjrSWbreol/KOx72xn4YWSpBrQLm5NvBO9XsjrwuXevHv0R1JXQ= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2846.namprd12.prod.outlook.com (2603:10b6:805:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 22 Jan 2021 17:39:31 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::71a3:7df5:647c:1665%6]) with mapi id 15.20.3784.013; Fri, 22 Jan 2021 17:39:31 +0000 Subject: [PATCH 8/8] cpupower: Add cpuid cap flag for MSR_AMD_HWCR support From: Nathan Fontenot To: rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org Date: Fri, 22 Jan 2021 11:39:29 -0600 Message-ID: <161133716957.59625.16797245497945634973.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: CH2PR14CA0058.namprd14.prod.outlook.com (2603:10b6:610:56::38) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ethanol01c7-host.amd.com (165.204.78.2) by CH2PR14CA0058.namprd14.prod.outlook.com (2603:10b6:610:56::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.14 via Frontend Transport; Fri, 22 Jan 2021 17:39:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ae93474f-6c2b-4dec-5631-08d8befcacfe X-MS-TrafficTypeDiagnostic: SN6PR12MB2846: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b7eRN+RiYiKNydR72oTccXIKJ2B9Lv+AcQ1cLNG+EolqfCtSujSntq5APybzHBuAxhBCgjvFQkfhCqQJilYBzaSlTHeFZg+BWixVE9iXUNAK4aRbwuf1bv1oiuPudc+cIl68N+0GlnJAn+2FBgiqW8ELBeXbWaotqrOqPtQKzZj7G4n/0NA1Nn6h1kyCnGxQQj5IZQevtc/hyayFHps/QJlL+V593LrWBwjvyshVrdRd4W+n7e1+GS9W1OXn2ioQ7PAhkJYpsUVFJb9GqsXIICPoJ0qgXYLZTyaaHWf1d5u/rBmRTakXzftz2YNNZRi/M2CnegwSPTb5NaMVvhmq0aKROlHRAD9tPNFPZeWVEgM92xG84oNMt9mEB0nMgTZMFuNh4r00Uv9MDFae1cw3Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(103116003)(8936002)(52116002)(86362001)(44832011)(7696005)(66946007)(66556008)(66476007)(956004)(5660300002)(316002)(83380400001)(55016002)(478600001)(186003)(16526019)(26005)(2906002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?/oYOqhCPSL2BL4zNJkoj6mMO1ylYoO?= =?utf-8?q?NpUEjPgRkk8kt0oiQn5Uf/x7voz4z3Gj9Kd64jNizNtCmoWlhYnmYcFS2sKq3TXEB?= =?utf-8?q?ugHAzeKXc2Z6LtTizuFxkHjlEojnaCQ/8zMAYADcpgxc9Z4ZAo5Nff69c7uu8fKYc?= =?utf-8?q?S/L80ejAoMYRGjFNouqI0IQoIPR/iAuHSRgxjkkk2r4uCtx4M+UUECC7Byjn+mmx/?= =?utf-8?q?UMWZa+5vqtHgCcWsDYXsrei6JkC5i4mEas1mbvOPlcY1YzTUcdxiTkqJ74r01w2dG?= =?utf-8?q?UoAVANqlliEJ6vz4c4bgj4qoIU5yTpgQoVP9/FetrXiFEZnlQsmfSjMsr+akqP+y8?= =?utf-8?q?CIRK3nQyiJHnajqFjC7n8UVbIQZLvzgdfx99Mq1fdeIUJ4dE4AE6/Br113l3XRhxx?= =?utf-8?q?ulV++qX/sZodnAX8mMmMSmztqeVeAWsDUDKqmsHkd33UGJJV0LKNjaclCPoxYH5kv?= =?utf-8?q?tBLxlBUcArTVCCWC0di2LmbnyA+JP3lQoafiWLTBddhPF36zTlbJlHdAisPL8Haa0?= =?utf-8?q?ROafUQXBvLDZ4tsxeCsaMZJ4ulDwd4fdKnovfmIjlnRHrLrIiO68c6YfGtA4geg8u?= =?utf-8?q?PdPLUtJxEToMVl9GDUYpKOfUOinnIUR22DfoncVWw0m+dAw/ms1n2pXbYGaR3PyWq?= =?utf-8?q?yLzs2+H7Ak6cPNHPGj11uVNzVTrTpGacOGrpD8icq8wsJw4KpvkQvvTS0puSpTlR9?= =?utf-8?q?iinUJu7+slnPi/fTONnCIXMxPWwSo56R2OOl0qlrF+HsZ+g/2qZG7/gPahXfEOUsq?= =?utf-8?q?YmOH4oW0yTwz/7bqZNxB7tAtXpNWSN5Jgl+5t01kNFDEuW6HwGAINu3tBSZeLDxxt?= =?utf-8?q?v/E/bqwi9HqvTGZ19xkhAzQQYuEC6R/YibDIiDgA8ETwUuv2lehwuswx0qY9S9ob7?= =?utf-8?q?5c+lmmwKXLlLWzxmcYmu3mVTFMJg8X7f/Wlm0YfSE1/RqSBsacXtkIBOrlX1JamZH?= =?utf-8?q?YyxQn380KfZyYRpa5IKIXA0ktuxFaz7QgDgpz1gqhRQ/TjbWUcXGNZqy66SPQtHVO?= =?utf-8?q?pXaemt933fsjv+dVlb?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae93474f-6c2b-4dec-5631-08d8befcacfe X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 17:39:31.7469 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nZAIBtJwMUt9s4UIcDNBcVtonDezZsokaNTSRYM3YkIYw6fMeOkF76dzAzmpi0d5KZC0O0Sq5vPGs7BKFosrEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2846 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Remove the family check for accessing the MSR_AMD_HWCR MSR and replace it with a cpupower cap flag. This update also allows for the removal of the local cpupower_cpu_info variable in cpufreq_has_boost_support() since we no longer need it to check the family. Signed-off-by: Nathan Fontenot --- tools/power/cpupower/utils/helpers/cpuid.c | 6 +++++- tools/power/cpupower/utils/helpers/helpers.h | 1 + tools/power/cpupower/utils/helpers/misc.c | 7 +------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index db2e88ceb67b..72eb43593180 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c @@ -129,9 +129,13 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) if (cpu_info->vendor == X86_VENDOR_AMD || cpu_info->vendor == X86_VENDOR_HYGON) { if (ext_cpuid_level >= 0x80000007) { - if (cpuid_edx(0x80000007) & (1 << 9)) + if (cpuid_edx(0x80000007) & (1 << 9)) { cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; + if (cpu_info->family >= 0x17) + cpu_info->caps |= CPUPOWER_CAP_AMD_CPB_MSR; + } + if ((cpuid_edx(0x80000007) & (1 << 7)) && cpu_info->family != 0x14) { /* HW pstate was not implemented in family 0x14 */ diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 8a0c11c6ec63..33ffacee7fcb 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h @@ -72,6 +72,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, #define CPUPOWER_CAP_AMD_RDPRU 0x00000080 #define CPUPOWER_CAP_AMD_HW_PSTATE 0x00000100 #define CPUPOWER_CAP_AMD_PSTATEDEF 0x00000200 +#define CPUPOWER_CAP_AMD_CPB_MSR 0x00000400 #define CPUPOWER_AMD_CPBDIS 0x02000000 diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c index f9bcce9c72d5..fc6e34511721 100644 --- a/tools/power/cpupower/utils/helpers/misc.c +++ b/tools/power/cpupower/utils/helpers/misc.c @@ -16,16 +16,11 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, int *states) { - struct cpupower_cpu_info cpu_info; int ret; unsigned long long val; *support = *active = *states = 0; - ret = get_cpu_info(&cpu_info); - if (ret) - return ret; - if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB) { *support = 1; @@ -34,7 +29,7 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, * has Hardware determined variable increments instead. */ - if (cpu_info.family == 0x17 || cpu_info.family == 0x18) { + if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB_MSR) { if (!read_msr(cpu, MSR_AMD_HWCR, &val)) { if (!(val & CPUPOWER_AMD_CPBDIS)) *active = 1;