From patchwork Mon Jan 25 17:34:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 370396 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 9BC48C433E0 for ; Mon, 25 Jan 2021 17:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E81422ADF for ; Mon, 25 Jan 2021 17:36:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730780AbhAYRft (ORCPT ); Mon, 25 Jan 2021 12:35:49 -0500 Received: from mail-mw2nam12on2075.outbound.protection.outlook.com ([40.107.244.75]:59840 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731117AbhAYRfe (ORCPT ); Mon, 25 Jan 2021 12:35:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5QQyDmVVIWy9thW/TFW3KFL5EzknSc6kswlPW4VoSeje53gkzoKI/FEvDgzWn4EHOnc/c/Nd00tpgCT6Nah3WuTBwgHSYwQLWYGpa4bYY+k3WOUn6JZqHZcvvZIGwA8n1GiSZuhaUrWkrFCtsL6PWvXzk6MIMbZl7SAOreR1yK2KoDDNw5og9BSCNhS/VEQttk0sVdE4Q5C/O31tGpeNVF7IteCioEGu4FKoxiHJopl5SrM+BloVjMrAHC2CnwOt1YooESi6UJ7h2VBo4P8sJx4ZAfKReBsIU95shRBHJsItiytRsC/dy94O79fsP+4hJDYCTZtc4YjLIUpIjmR0g== 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=OOAz/qDbYdLMyjuPrK9IBlO9CCw6yGcar5x5CrlswsI=; b=a739HRWW3dRGOeMxZY464p10D8RGHSIxIR2/IMixSYcE2lX9X5jmXUzV+2gBMJ7TOc88SHVYfDaeIvINlwm4YvH6hlRm+6oRsqd7hww3X6+Xr1eOhms1Qwyjm3YMpV/I/teyPB9LtviJIKtXvw3xfrEq5iTAYY9psEpLP/CBtvcIsrtNmzP5cKPcjjS5IlA8Nhf4PzSASjccwGtl4zS68kxwRyEg+Kank6JB6tLcS9D755/81ukqzNzIWjQBqo+WyZCTI1qrtcT6MOxmxALoOoGdGTItzspctFRVr3aVTvsio+ED5MCmeiuQlbNCzpdsxOqz9FGxP9ltmC3lVcaIcA== 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=OOAz/qDbYdLMyjuPrK9IBlO9CCw6yGcar5x5CrlswsI=; b=yF9glXqgy0XicJk4a9SWFzjg1ElTBR8d2GoYgGxKnwsSe77CNWpH7DmGHLOXuDn9piuVYBYTJojqwI9WzFAY7iaIovruBnB5E6A1tBOPzdrFj053N/mcyDYcXvKKoZDYo0sdXw4OJ1gxlLIY7h1El7e3QeFuSKuwDMyI9pH6zM0= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2765.namprd12.prod.outlook.com (2603:10b6:805:77::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.17; Mon, 25 Jan 2021 17:34:33 +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.019; Mon, 25 Jan 2021 17:34:33 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:34:36 -0600 Message-ID: <161159607626.68367.14656572319107224636.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN4PR0601CA0023.namprd06.prod.outlook.com (2603:10b6:803:2f::33) 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 SN4PR0601CA0023.namprd06.prod.outlook.com (2603:10b6:803:2f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Mon, 25 Jan 2021 17:34:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 03d4efe0-8362-4d95-eeeb-08d8c1577a43 X-MS-TrafficTypeDiagnostic: SN6PR12MB2765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uauxnX7W4TUOBO5eFVGpSY7PymnbrgcT7Vs4x1up50JVPt8jAqPVURd/iTWR8Nf3mOiDxEMAPz9a41mN0ZTOLvqcSIXxu0iRh3KeiSqNsGRih6Olzc77KBn5REd0WNnRlUD22L6RTjydiYOuMW/pkq3N4ZPkpJgc+i1PV/eLqPSqzRswBsfHnfTK3Ml91LnwSCG7+TgrBeA95qzQJaIcyHHwIV7ELgrC9d6bVUdZPxnJtUItjyq0whvCMfM7oxOc6v5NGvHLSfUcUtVDpk9UHRHJzJy5DL3kF/sGatB0TYA9+7GdIm8dm6I569ZYsqoJC7074RyUtyIDlujtMc6GarBik6yH+rG69iuIu41s7oKKi0NLUKHiVBpSa0VVKAeyP6PeLOYoe+47I3LXvMbv0lZHexCtXJil2fHe1qntjfnHfWKS8Qh9qTRzLjUQ08iwqnKAeL6ugesHPuLQOKj+dw== 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)(366004)(39860400002)(376002)(346002)(136003)(316002)(186003)(26005)(103116003)(2906002)(15650500001)(16526019)(8676002)(44832011)(52116002)(7696005)(956004)(8936002)(83380400001)(55016002)(966005)(86362001)(4326008)(478600001)(5660300002)(66556008)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?78OBylJKZCUeu/8ZCvt7c9pUYKb?= =?utf-8?q?2ufErHcEVoB9hGiR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1Pu1rWZmQhcpLUm9GT9mZh1WqMZXull+4CXikbrwmfXIwVU?= =?utf-8?q?EsxFz+w83i+1C5m4sCf4+PyZ6GbTtOFJQ4L9X2a2I4xZ4WCY5BY2wCwc?= =?utf-8?q?nQH4RJ2ZqptU+t++UNH5EOdo96Aw48fsrx3QRTg9zUh+UHF/1gViL?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03d4efe0-8362-4d95-eeeb-08d8c1577a43 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:34:33.2042 (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: nG7MyG7Gs+5si3AH+ZHi8yut+Wue5YFMtI0n+E0oG58Tq3NQsbm5kxqUE4gE1Pb2yf86YumUcEMY8xk1dZIGpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2765 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 (1) naming. There are no functional changes as part of this update. 1: AMD Processor Programming Reference (PPR) and BIOS and Kernel Developer's Guide (BKDG) available at: http://developer.amd.com/resources/developer-guides-manuals Signed-off-by: Nathan Fontenot --- Updates for v2: Add links to PPR/BKDG in commit message --- 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 Mon Jan 25 17:34: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: 371026 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 6E18AC433DB for ; Mon, 25 Jan 2021 17:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42C2022583 for ; Mon, 25 Jan 2021 17:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730898AbhAYRgR (ORCPT ); Mon, 25 Jan 2021 12:36:17 -0500 Received: from mail-bn8nam11on2089.outbound.protection.outlook.com ([40.107.236.89]:8288 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731131AbhAYRgG (ORCPT ); Mon, 25 Jan 2021 12:36:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOuBVLM2pE1/Wjwgz69VYK/dm/0r6XsivOhirtcQiCr775VctuUfsQrKO1tTTQi7zscxLGErgjhZjThaHTHRfK/eHxlnEMMjCHH9/+M+exMcX5MdnWsZFjrerIrwjkSDmv0JTcdXIQ4ndfvgWdfIk1JxBdmd2OIpyUKXfrKSQBqSlfPhx/NmZ0ZA9gZ0EurWU8sWrLWEDgqVY5AUCaTilg5brbFCsFmTiXFiXiMcWVnILqURtyS9h2ca/x/zlEOou74eedP4I5pfr1MmmZh4buSqilm6easnzmT/CBVVKSG1HDH/UASTyiT9Mg18YjEyW1zt/ZoY1jiGrF69IeATQA== 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=diRu0cQ3azoFneNFMil7CZCY3wshrTlJhpREUFV16U/IsomipfLQu/FPv8RuV4ybz0ghLo/l0pNPi0k2pujlOxx7sZUAeu9Drg52dlRf6bxc380Ze46SmMkMP59yQfbSw1Ap1VyJpGC+0rPsARQvvZliEMrXCu9wiMbAiA6IVPjHZPeeSB9hF9Z3jqeuJwu9HChPP+ehQ32fsbPP8bXy6Tb7CNXQiKrSOwLJptAC8mNEg6H/nUMty2okc5RYNrvPhdsrQ96IJ2vVqFTqPRaSfPQ+Qbe1Zblo+TPcgkur1nSVRriQBvMcU1aSjZ/0k3slxB586V5/UwjaOjAENyH9Vg== 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=L/UCdZkjS+lXjv8uQl8BLgaMBi/bP1c8eDBHypbGSBp8vev6pi4WwKJZXeqsYK302WPm1vx9YwvSzZy+FIxviqhHQbZt8s+5k4mib0yCD+RLhTd57Ti2QbuJSOSLqdHS7IYuFxd34MQfHW78E4TD107AdFGukRQXyjVo5oy8LHE= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2765.namprd12.prod.outlook.com (2603:10b6:805:77::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.17; Mon, 25 Jan 2021 17:34:39 +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.019; Mon, 25 Jan 2021 17:34:39 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:34:42 -0600 Message-ID: <161159608261.68367.2896652465354925993.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN6PR08CA0022.namprd08.prod.outlook.com (2603:10b6:805:66::35) 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 SN6PR08CA0022.namprd08.prod.outlook.com (2603:10b6:805:66::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Mon, 25 Jan 2021 17:34:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2b13e174-6c8e-48b6-6912-08d8c1577e24 X-MS-TrafficTypeDiagnostic: SN6PR12MB2765: 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: tsSQJrDcwENMkScIv2Xr3FzNuWGehSPBBeHcH25TKbDqhkA9wNdYrjEg5o4PQ69l2UIFRBM1U/9ePWEgXemtLJd3Kqyp5kcoKh9d42gg79eOYaMe4ehzBOnAC455AI379HejbnaOM2oVWggUlIPz8Ory5IOz4RpVw3sX++R3khUADHX4xcfTLgTH3V7Gaf2Bx5EfGR4V+dhDLrudTx32oG9NvFz2AtlWHm5TtsTaS4BUy8yMHah/TY/BbM0vVTwSmkWhEAnE+JyzC4EtNxheyw/6E7GF1JPgnXsHrG5HUbgCr7Z7vSUwNLKTfPIZkpX1dDjE3ZPHqbG1uEO7ftoAonfpfRKQbrr+beVIFe8PQ9D4sqJupnfS1pFqrgYaln8V5bjNmoaVygeU0iSHjQBPkA== 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)(366004)(39860400002)(376002)(346002)(136003)(316002)(186003)(26005)(103116003)(2906002)(16526019)(8676002)(44832011)(52116002)(7696005)(956004)(8936002)(6666004)(83380400001)(55016002)(86362001)(4326008)(478600001)(5660300002)(66556008)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?E/u8d44Mchxz4oS4gutMfPK1TNY?= =?utf-8?q?prfV3QAlIIr6CtTfc/n7DxuOGf2J/2m3wh/eBEQqOZ+C2+x1I6cllyr9?= =?utf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5W5c?= =?utf-8?q?pUpgZEmZo9nVpbi3g0Cf8XugvPlGVj4Fmygdn4x/spTeopC3e9O/kFMa?= =?utf-8?q?gf/R34PScMIYV3r0vRpq16vwQ5dpt4szso2YLCCEXNqXJiZvTTy91?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b13e174-6c8e-48b6-6912-08d8c1577e24 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:34:39.6845 (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: JFzU78FvezwvUnoIpEf2M4oqLslsFM70KXCdtJ/fWqY39tYpiy1TkE4gdI1CU03NCEjP5/j8bN/3vrV5a1K8mQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2765 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 Mon Jan 25 17:34:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 370392 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 044CBC433DB for ; Mon, 25 Jan 2021 17:44:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABE3C22583 for ; Mon, 25 Jan 2021 17:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731033AbhAYRnn (ORCPT ); Mon, 25 Jan 2021 12:43:43 -0500 Received: from mail-mw2nam12on2075.outbound.protection.outlook.com ([40.107.244.75]:59840 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730772AbhAYRgj (ORCPT ); Mon, 25 Jan 2021 12:36:39 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zb/ChoI5shzv8Cl4e9DzepMQZ8nDtlzLLiP877cA7hDyhvHGv4qnUjI0lKi61ggTyu94FzLmsyXsWFAy1XX2he3emnKtO7VW2Dwb1VNXI51eUgYL7t47pfZQ5byELCeTBoBp+/7YiXrKroiIJfno4wqvfxCQLOwHupW67kpsNO/v6qrMEUOfoeM4+HliAMOOiN+Jbe1/csJuMyDAgOuyEl+i/3f+qm1BuSiVqjdYuxjK65ktqwuXfHlTHqSm7X+SB9RpPkuN6cKEBFrWkSHe1ERjTZfVH70dQOL9ipnFSeD0a98KkV5w0iRWumLn5NKtAb1j6M13AysEXE6jzXzjwQ== 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=5cL6i9wKjzgDN86at3L0bVNq1WXDu2CSE5wnmq5MADU=; b=oSUIXajq2L1UI1nz0DQrhmSIfYJ9i/ibjmZyUNziaAG61sRMWLNh3s9ASIeqA0OkvsajVkdD4YPNAkI3kW/hSl2rCgLSvG/mljckIttEspkck/GaKk4p6CMa4d1Jo01kO2xmmQGVM35y8hXkwy8P5ktfdZdtRGzcMnlKRv3f0epy0pC9oIQsTumNH26f4f9+8T6iYrKZP0L7k2XZOYNnQF2Bx03N2BnxUNmlQd/Wznqvs6gOW15zkiVP6wK9vaPCU/iR2T4+OulidGu/4rTXyHPUtHEsWD33srGXOVIc5YCqziGC3NYxP2tNCgvxDsrhZrCi6Cvn+F/nTl2e1V3UAA== 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=5cL6i9wKjzgDN86at3L0bVNq1WXDu2CSE5wnmq5MADU=; b=LxN6sBkdnLy0QSGNJGhSSIw69D8YBd2Lis0pLEZotgUnGr7pSkrjw31sFhZ3grZLKgA74XY0PVJM+4LzTPyHw+LepGYyIz1KEA4bS1o1PUjbpuZ0n47fk+VAamcF9eArSKAjGZ12K6IpVJp0mJ9HTzqxfe1xxYRxlKzN19USDpo= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2765.namprd12.prod.outlook.com (2603:10b6:805:77::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.17; Mon, 25 Jan 2021 17:35: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.019; Mon, 25 Jan 2021 17:35:01 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:34:49 -0600 Message-ID: <161159608909.68367.2355673294254507345.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SA9PR13CA0024.namprd13.prod.outlook.com (2603:10b6:806:21::29) 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 SA9PR13CA0024.namprd13.prod.outlook.com (2603:10b6:806:21::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.5 via Frontend Transport; Mon, 25 Jan 2021 17:35:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7b98740c-72db-4864-1e7b-08d8c1578b26 X-MS-TrafficTypeDiagnostic: SN6PR12MB2765: 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: +4QYuDJ0sTlZzpLbrL1mlxe7qljytCcW8djnfutgnqdbcYgy9F0RysSRnxBYq9HkVtsiOZGZYIVOVjlKO1VtdPnGesScc84QMUf+7g/I7eDI0al1klz8HpWv8cRNkYAE3VzvsXHF41v+ab6Ha20gTQT23Ji0+9G1Nqji9oPfe3H47mKpNH2OmwJYovq8SAKAiy7p/T+qaBtkk9Fw0DsHU5dMeuiqndaywJJPbeJD3AQ+4EVtj4M2xjHEgj8/YTIRMJN18UnWDSTPYwCEZ1pEFwA6kTLSH49MjU3e3Eyf8QVxJwhsvqTsN/hlStKUpfjHdQNiA+kkhrNrKwtC5K5cB3Koe/m98Mtyx9nVPQipKKxPWfibNcdKOg5GpPTt0RkiuVAuBMh0Y418JBbx8a1inw== 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)(366004)(39860400002)(376002)(346002)(136003)(316002)(186003)(26005)(103116003)(2906002)(16526019)(8676002)(44832011)(52116002)(7696005)(956004)(8936002)(6666004)(83380400001)(55016002)(86362001)(4326008)(478600001)(5660300002)(66556008)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?5lr355L2mPG/oIeIrcDggjMB60n?= =?utf-8?q?ZE9PMSxW8LCzcyWJK7VmGI9C2zI+ckbNJZ4GpYFYO1TgFw2jrCi9YWjX?= =?utf-8?q?uMYVckNYfU992BUNhv49JKbeJFOgNBpVW0C8O5v1lcE7DuG9P1+2urbn?= =?utf-8?q?KXOrKCAYDS+uhQho0X4DLRKbCKwTNA9kAvBMaC7divo86eBRer4dx21S?= =?utf-8?q?+EmpRm75nCIEdRd2rPGvOrsIle87im5z2x0Y1xLW2vTQWQvzS4CRfO2G?= =?utf-8?q?MH+4TgaqHRuX77tWMvqp+e83B5aleBf8upHv91fruTPLPudqElk24mcW?= =?utf-8?q?K54XZTzkpVIZixLb3JxuDNtQM8T5ZXcHxvnX4UiRCqAbXY7K3ufiEL61?= =?utf-8?q?w5j2NQu03w1KUyY/tJlTf90/MwRskKna3T8XmcyFFB21P3uLI8WLgK5m?= =?utf-8?q?fybJ2R4ryAgUbG4g1gSYFJxCL4jhvgEUlqi1LQLIB/TFy7sdz3+LDuOw?= =?utf-8?q?UVCc0rG4E/A98d8NkAxw8uwL/GpfOqdR/B5naVczE8WbC45LWaEl332D?= =?utf-8?q?yJ2Q9y8KIG54tcK4B5n2xFeZNvVJ95hE2rzyhA4e3Y/id5K40r/6rycg?= =?utf-8?q?QoKqJz1H0hxWooatxRsvHfVDRmvbiSPpePH1HwDbd6bB4cV1ri3+d0uh?= =?utf-8?q?Id2mU1X/fz9I5v5YVpDaNv7R479GWNTwbBFhQwY6dtvqlMzC5VUjyr9w?= =?utf-8?q?EcjzApVxm3uEtkYyLf9YQSrnhg3mu39rYNv6ZpQCD0Yq19ANbDvln/gG?= =?utf-8?q?t9iZie3H/7j1fU7CXWqYs4pR1PdkFN/S/96KJu42D7htdFcF3ZbdAfj/?= =?utf-8?q?0v6/+0IECi5oeLiC2Bh6YmxWRW3fDJR4kxk2QxpyQi2RukHkVeaVc1FF?= =?utf-8?q?c3Sd9FY3z60aLE4z28Rh8sUKORy6OWLR2K7vm43iG1QZ17czP9XgklLm?= =?utf-8?q?urfeuJ2Mvu0XVbPhhe4ddlWz0YxUaXmYczGb2odlzzAprxGdifEmnoZE?= =?utf-8?q?Y/8Qg1R9MNUauYhnuYR3ZqYFdh01zx0kyOw988uO9gMAHgjIvg+vFSj6?= =?utf-8?q?kSGeEecURy7DXHUh4I/3q3relgpPK/b16weicoAl+5lWJb0n0e8OK?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b98740c-72db-4864-1e7b-08d8c1578b26 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:35:01.5041 (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: wc4s6h1EEd2n0e94xDlOnF9JTdfLT5gaKIj18yJEeEkY3ZlXTM+K+g6TI1qgKVWEBEpAHhlp5IgW3fxrhbnLVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2765 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 --- Updates for v2: Update and add back previously removed comment. --- tools/power/cpupower/utils/helpers/amd.c | 9 ++++----- tools/power/cpupower/utils/helpers/cpuid.c | 12 +++++++++--- tools/power/cpupower/utils/helpers/helpers.h | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 34368436bbd6..8b69c7ff639a 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -94,11 +94,10 @@ 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) + /* Only read out frequencies from HW if HW Pstate is supported, + * otherwise frequencies are exported via ACPI tables. + */ + 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 Mon Jan 25 17:35:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 371025 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 E218BC433E0 for ; Mon, 25 Jan 2021 17:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE82622583 for ; Mon, 25 Jan 2021 17:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731077AbhAYRoA (ORCPT ); Mon, 25 Jan 2021 12:44:00 -0500 Received: from mail-bn8nam11on2089.outbound.protection.outlook.com ([40.107.236.89]:8288 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730979AbhAYRgt (ORCPT ); Mon, 25 Jan 2021 12:36:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q6Hb+n+kwrYFGKYbeli8I6dLdDDWiYP1sE3Y4r3aPcy2hXv9BSe//6EKCB1qH34HS1Z8TdwYn85+2iB2ndlmG4V+oRGoLUI3wfVrBG1rFS5PrIoipKhaEnDu5Bt7PHCn8siieiEA+Rw6PlM23JEx+E7EV5h+igru+ScYKlZzweaLi8ceWy1B6N7v4CA/rcWqqh60enZLOdLOXZIxRE5J3bmN+bYPgufWURTtWBUrYrS8Dfv/jfSupQHkRxJQT6fE8Aza7fFKT/7zg2xySTGSlLNTj4FXWKKOZUBLHC0occtWlFPwDKYb/jJWRJYhl3agewwZ0WZWtmUc+WorB2x3Ew== 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=/J8Om4WkwaoWHbFFZPAnY9swnA9beeLe9Zi5T8DaBuI=; b=CoeMG21WVU5+4yXnbSN2K92hwsPGPy2lmzGpHih9+HMenfOQpEfMpFKGBaH1pHWjA6A/vFfUTdPLKCNTe0cvFrhHGIHl9bYnmrbPo7m2sdAEM3wF7qKoXDZXqM6w1ODK8Rt4FMFvKgYQndV0+L8iWSQbdWnxL8INMqrk0ln3CMuhb/oJkbfbiUSYrOX1eS83M1yEfWeV2aK0zM5tKZg85x8Cdh7hWsL2QF5xIVZZfCWxkdQAIikPqL8MgTBHX5eAoSInmP1ZwQviK7Ns1t5GNnR2uxbeyGH4nMYKFKVgRmEwaUfJITYreZlIO41AOytjGzk/18QE2txr31iudEit1A== 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=/J8Om4WkwaoWHbFFZPAnY9swnA9beeLe9Zi5T8DaBuI=; b=GmMnKf9T671YiQr6GqAYJNQF7ADRGzYFJrkbEy9fId8tK2BU38k7a40DhDPi17enxGbY2DYyakvaBQzM7og9z1Q4h3yc6tqxCwokIJjQCDBfLlFQqfj/Fk15iTYxGVD5qzlhN+3SHHsa0VZlfsWoNMartHVxQnL4fBzEXDGtq54= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2765.namprd12.prod.outlook.com (2603:10b6:805:77::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.17; Mon, 25 Jan 2021 17:35:07 +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.019; Mon, 25 Jan 2021 17:35:07 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:35:10 -0600 Message-ID: <161159611089.68367.4122824171734411902.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN6PR08CA0028.namprd08.prod.outlook.com (2603:10b6:805:66::41) 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 SN6PR08CA0028.namprd08.prod.outlook.com (2603:10b6:805:66::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.14 via Frontend Transport; Mon, 25 Jan 2021 17:35:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 47b999cd-ce89-4b68-94a3-08d8c1578ec2 X-MS-TrafficTypeDiagnostic: SN6PR12MB2765: 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: QITMOANpANLQ2b4HdLNASZxNthd1uQ7g5h7clWvPrv/tTx60+cZ992gusp019KYfuTb8Ql98DA4CyFbIS6yySP4OpRCsosJoJ3yIqiNL+5DlLb/n69F7mo3/e38em6gWotwLQPSdcgcr7RwANgnBJHtEyokgqa4KSQDj7avi0dVQNvtntq6/Nl+uE+qnRfd+22ZbeWSwEZMVVVkZ4dQdJmH3ODMjTIA5PmMBIGEwQBo9oR3flhg13rmwqJXUFDHDQ229w9O5p3rnw7VtRUXJgbWWJ8XqwIL6rmILFmhCG8301r0341mi73Az5pT+GqSb7DtbpdkvRVSU7c9RN6VIHOba7mZvrsEdjvJ0DfPSjsEjiyLcL2jv3yMmlM1gvUQd40rHQXM6GU6mYLNXMAPv4w== 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)(366004)(39860400002)(376002)(346002)(136003)(316002)(186003)(26005)(103116003)(2906002)(16526019)(8676002)(44832011)(52116002)(7696005)(956004)(8936002)(6666004)(83380400001)(55016002)(86362001)(4326008)(478600001)(5660300002)(66556008)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?2d3U9V3saMhoAk5gWNULjrAN9/D?= =?utf-8?q?yuXW6JKCkemCnmmK3/GlFptPrPgis5ftYkKYAAIB4Jnd/fZFvTbzMszs?= =?utf-8?q?XbbYRHcacnA3R/o++iBNXmk9bXVFN7Pmrf+BODEmJBHelXVPvQCXIh7G?= =?utf-8?q?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cuAmoz?= =?utf-8?q?CBWlNLb6tr4QAuQkynmurNuYtWahGndwbVoSFCaPJvn+B9wXRyfIC?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47b999cd-ce89-4b68-94a3-08d8c1578ec2 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:35:07.6006 (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: 75Qok1YIIDSA127/xmPXCKxwgMhWTjkn7LwhDG4IuQU02kHbFDvhJMdX3I0ZwybRxsO0AkYMkiYSIsxCU0dLEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2765 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 8b69c7ff639a..fc2ac1e6bfb2 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; @@ -104,13 +104,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 Mon Jan 25 17:35:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 371027 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 B9837C433E0 for ; Mon, 25 Jan 2021 17:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B6B722D04 for ; Mon, 25 Jan 2021 17:38:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731121AbhAYRiY (ORCPT ); Mon, 25 Jan 2021 12:38:24 -0500 Received: from mail-bn8nam11on2056.outbound.protection.outlook.com ([40.107.236.56]:9184 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731062AbhAYRiC (ORCPT ); Mon, 25 Jan 2021 12:38:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TwDgP4ttdc1YF8xqouccZRd1G8RmNTJ/jBCh/k4mVnz7WtyqCobo4JeySmu52IXBcfdYhynXdcP0R4gvjp/P7P7zJrToKKb1WxVoqP4VT+81M4KP9RZvbvj0CQFPfh4HAVGnyjL3Us3Hmc2iJIEDQY4rcMhyp8GyU1V/LTIra4AQ7sfgUurnItFIFYyBWn2Sw1OTEUKqTYSPdxAF4Cb3cWxNlZluj05dwsokrRUzh8GlqrHGDQZEux5lSF5glO/ZsUDoEhgrzh39Rv5i7yxc3NXXC7ANhbbyHbiJrMphZCEqP6b3mdC+QEmX3Mm2F7WHYkK/ZDwqx91K1EPTde+g3g== 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=MWHDiV8j8OmwLOw/CF0KVffpbO2qgqqJDz1z/1TqlAo=; b=CM6TESDvh4tVIF4YEc6jeV5xjpke627N0Fda1GkrhD4NRIRQPtB9FFGykylkQAHUMLaODMM25f5FMZjajupyPgIhjAYoEOC0AkvBAjd9816PfX+eYn7/8HTiN82v2vYsboO+uPMsRfbcctWFIpa8Q5KpfXUHs9gaE7DMfYfvl2rOkLBENC2Kw3DWAU9YekQsy6qqYHSoyP95J8kmPsAkJOxdflCIFph51L4o0hUh73TqVUZnffJGHGRPIvBPMU8tnIhjssMmlLJP1kC5B6Cs5Blu5cJVG1tVc7WASH86PSdmB6OQ4/Fge2NZghFDPCdmBepK6+GRTgEkkoxoiqc3pg== 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=MWHDiV8j8OmwLOw/CF0KVffpbO2qgqqJDz1z/1TqlAo=; b=G493KOqh/vMRClxsxHBMLPCdHFcdoUvA0tEg0Q06XloDNPJeYzlARlbaogNRETa3D5/Vc7pnFdAOHEoKc2vkhFrSgQY2PxH4NPI5JrHK424mYUNKNuqI3IelDdfVmXs2VzSy6SKi69cJKuIwe9NJ5D90RDZUM2F/MTXwNnYYNPI= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2765.namprd12.prod.outlook.com (2603:10b6:805:77::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.17; Mon, 25 Jan 2021 17:35:14 +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.019; Mon, 25 Jan 2021 17:35:14 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:35:17 -0600 Message-ID: <161159611702.68367.3845483997295905170.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN6PR08CA0019.namprd08.prod.outlook.com (2603:10b6:805:66::32) 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 SN6PR08CA0019.namprd08.prod.outlook.com (2603:10b6:805:66::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Mon, 25 Jan 2021 17:35:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d0ab65ba-b309-4cf9-d911-08d8c15792ba X-MS-TrafficTypeDiagnostic: SN6PR12MB2765: 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: 9LlNbzZp65hTlar+Nqb/cLWds+cuApVkPLhDMak4euuQHbM9Xlu/XzjJ4PReSbJBa1ZkjSgAyWvRUnKsLx8/5fai8IYXwWYJjFfOGIXxPe1fo3r6LgUTKhuOFhtGkx1o31aK7+vfRoWMm3dF5U2TJIeda1MWDgoYv8wcjiPWo+oAsIXzIZvMCDbmseU/JSrU571UGcFKajReXEwXDysi6QY9g1BZrlULNxkfshsvIAOdKhPUknwpAfHyjG28Pa/yGXpfFfTpXi4jiUcSyEqoulRhggvx+qW6NnW0V+8kZsww+KUT+/t0gO8N1a8N9w27fIIOeE6/6yeRlYnDxhWwvQ++XrhGagpWiIAqHpuhcQ08yOl2oF/6c9UvVjoz+DBd3ZKDD+MgOmgVUWs4NALG7g== 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)(366004)(39860400002)(376002)(346002)(136003)(316002)(186003)(26005)(103116003)(2906002)(16526019)(8676002)(44832011)(52116002)(7696005)(956004)(8936002)(83380400001)(55016002)(86362001)(4326008)(478600001)(5660300002)(66556008)(66476007)(66946007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Da2EToDWDpZajhagIdkwCp8?= =?utf-8?q?97vny9KgTQywTML1mIy7uQ2HXxZAUi0wtPMYo7G4ZxdbMhrfI53+wd8W?= =?utf-8?q?Ba0SufcnEuGYxYSMtLALFsxPmAn6/L5Rag3NPNxT66dFCAIWvtHuQ9h5?= =?utf-8?q?Hn6DLdhngLZyzU8F2kfAjrmkZKfC+/FAEEf+8jVYuwBNaxEEfHyqSqX6?= =?utf-8?q?vwopNmh1EM7HFM3eNBSI8XIc9JH41Oi7gIbXl+v/r3OJQuanSQ0yP?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0ab65ba-b309-4cf9-d911-08d8c15792ba X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:35:14.2318 (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: zSlUjDA6rL+ZJSTmELTUU3qlF5iAH/xZpGvpGjq+wfSDQtUIThByJrXgBQuzP+SphahPqLCJ+zyMBG13rb0e7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2765 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 fc2ac1e6bfb2..b4731daa6820 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 Mon Jan 25 17:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 370393 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 3549DC433E0 for ; Mon, 25 Jan 2021 17:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06A5122583 for ; Mon, 25 Jan 2021 17:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731129AbhAYRnu (ORCPT ); Mon, 25 Jan 2021 12:43:50 -0500 Received: from mail-bn8nam11on2041.outbound.protection.outlook.com ([40.107.236.41]:64288 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730850AbhAYRgp (ORCPT ); Mon, 25 Jan 2021 12:36:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JjD+urSjvrz8V8PaFn/a/hRk8W/aqvr5FHePPOekKqj1U1mgy8vfMYRRc1AhRJ7e2nQeueXsFp3X8fNbPzXemalcGqdShwyTpdBSS2Yz0PkCs4L0hhWUT8/MojWlQEsMs7+YKeUP0Su+/ljIy7tjaj+r5AVdfUD/gtjjkYP/tB3Xb/2GEjtAc70JdubHGqI+W+Z+aPWneoD5iYXg/kkl1cUlJSgoTapSrP9b/kRaXgcdC8D/nDVf76kwcWh53QEfJ2gqeRr9cDgIaru+mpF+twjpLXHjkKz9nvcp+Q9rX0mDOurXVM/jJrpu8qVemd+rF3ce9xPwZSFNlqr7MVSqvg== 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=XceB1BCT5EN97DuHT6dB6Q54FxGRuygR5bRGOk5yhbk=; b=iZSdw0aVL1i45c8m4vuw7WEmWF82rlqeA8ZG9iFVmL2oYReQldT2y+kz8e6wb6c92rvKtYoAH0ZrTqxbhym6uCfoP7Vt8QpM4ew9CgnTvL38X6mqvcvpxQmvxNUlbbaTstiYJEPH/K0TlWY5gs0NgIDlZD/SEMsaxvnKPis39CJCR0+OVa+gSNgUSPm8OEZ36+r49vUA2n/iKY7zZQASuBI+nHJguUOodh8tUZ9mk7NfJByeva5g69hXRf98qwCTHh5Ncy8yofbzK0n66Ovcj7Qk0z1Y9dbOo+qwfqpIJ6YKicklv2571VhE535VSOu2S4ZuMBapNpfp0Po7aq3FjA== 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=XceB1BCT5EN97DuHT6dB6Q54FxGRuygR5bRGOk5yhbk=; b=xD9ORPsJ+yzxfhANipfLEp4/hu/q2h6AGsfciaFUwRZjITpFUw1MvIn71k4GgiiJHahjjfFJZTBPGopxuOdU3VR3My+G9sH4dgI0AiCFHhjOmnYbfPE2FT+pk9OHfQ5xuIfjXDwpDnOPi5ufEGGpDA2iogYcGX/RCrr75lRiY1g= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN1PR12MB2576.namprd12.prod.outlook.com (2603:10b6:802:22::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Mon, 25 Jan 2021 17:35:51 +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.019; Mon, 25 Jan 2021 17:35:51 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:35:23 -0600 Message-ID: <161159612365.68367.13306256100078302569.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN1PR12CA0086.namprd12.prod.outlook.com (2603:10b6:802:21::21) 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 SN1PR12CA0086.namprd12.prod.outlook.com (2603:10b6:802:21::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Mon, 25 Jan 2021 17:35:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4ac6ab13-0961-47e1-c60b-08d8c157a913 X-MS-TrafficTypeDiagnostic: SN1PR12MB2576: 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: 2JM5vLy8wUd6NII0FxsQY0IKq1M2+WEZlTPrDh9RtSJ/6VDSbpazIwhT5s/uU0+JZP63hE29JceKlkpSRpkxeR1U7dyTcIb0k4aYnS95l8syvTde/xGV+U7C/25rCr79ipW3nP7/+1Xd1+BwONT2SJ3kZUqAF4T06Geg/OScNWMizT0iekK2KrNHOP9XzzDz3wPtV+2vJWu6DmpAuo7awtRzPPv/+XIMxzkH7ZHWHrAs1uoIpPVp6qOUNh9qAW4Yt/BtUNOYb4SagQQva9QC6ezDsQgNDnn1AjvYpuicDk/oqRMvjOLGbjwkKtRxfyQBkRpWA8Youc3KgLHxLPa3aWkJQle6oRwd0dOv6/llFrs58klNnQJ7uAasOoYhk3jjiLntTB9TIvmlZxC93MMvLg== 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)(366004)(66476007)(66946007)(66556008)(5660300002)(4744005)(7696005)(52116002)(8676002)(956004)(4326008)(83380400001)(44832011)(2906002)(6666004)(86362001)(8936002)(26005)(186003)(16526019)(498600001)(55016002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?FwWUlh1lCKPXiW4hk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+Je1+S?= =?utf-8?q?z09AKIy8MNV94c0UFnf5SDPhplUDA/gbs+2ebAAUQtnUTUDYpjHWHTUT?= =?utf-8?q?AT/VM0BrAVdiVWUEXttVAune8E7dkX1kk+8lI8B06b+arq0T2/levox0?= =?utf-8?q?VqiCzSQSc6zURDEeOusvRG8inpHPOLi0DWJp1AmZ9UpMbehmCVOH5?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ac6ab13-0961-47e1-c60b-08d8c157a913 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:35:51.7105 (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: pxNeFQjZ0rKxIYjvP6fdUsjEPVwzruH5yiAq4G3QGvzzFZl1d6S/EspF6+2VQaKco513XCbTfWAG5jQ534SVAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2576 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 b4731daa6820..216240e2b771 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -113,9 +113,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 Mon Jan 25 17:36:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 370394 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 63945C433E6 for ; Mon, 25 Jan 2021 17:39:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C17322B3F for ; Mon, 25 Jan 2021 17:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729818AbhAYRiU (ORCPT ); Mon, 25 Jan 2021 12:38:20 -0500 Received: from mail-bn8nam11on2067.outbound.protection.outlook.com ([40.107.236.67]:55220 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731068AbhAYRiC (ORCPT ); Mon, 25 Jan 2021 12:38:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bb1jgxKcuqJU3XjzTPyIk+ex3IcRoGVtNVs++zcDst0JXi0bo6C9bvV95V8w7GMmNFugnUCCI1YERoAwgUpld1PnUv03SRFtuPjQVWrt0gmIxW1QqU38y1pxyfjO4n5cd5kTTpo5rNn2HBU5I/sWqflbauBx2aj5GKgbg/N1f5sibTScWCOc465XoH1qXHkODhwmbJf3B6IDDoIDBg908aatKpC2/nySrzU003CxNh1TQzEj2Zvs3q1mERQTcnerXTaKwuvtGu8bccsuJ8Uzne8bGseYHWlXy5eQQMzQkPuiZE3GOnkjl+W8hh9nZBujwrh1/ooylmYYZMSy8RUVqg== 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=CVCXZm7orfvAjfcDNWKOf/1kAYD72qGKMCGdVVvrBf4=; b=QHSb/jwN4rci/KVwMJiZGxxbuSjgzuSxDMR7oVlQCxyp27Q6F+fl7dawYpJJQW3e7qMvAifuB69ibFy/vGYObzgrSlsqT3JkVhBOzWM+9PdKzUo/A76goPEfJ4hDppz5CxJPRpHs0ph10OaNRYoHXdm4YvDByb7vBRy2oeo6Ljw/rhCJnHC7F/JG8ONL4MHNFOl81tQb/PlKqbkVj1Tactkbam7eduB3YmZo1nPYJTPtilVZqFwDy6MxhU9ttRrX3ZNs/kersM/ln6h4PibDZfMForSaY3BFJ3gthgSkJ1XWHz2Tiu+ttTkHlhRwtjFmsijw27SUwzZkOd2uVJgMpw== 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=CVCXZm7orfvAjfcDNWKOf/1kAYD72qGKMCGdVVvrBf4=; b=gCuXFLK75dcVROrHk67nZozzs503rSEbCbJXjVpwsXxFDdKyMAHL39o6+9jsjHD1G9yUO5AfrMAne3O9Pan1uajBIoIC1GE5A1rTR2cQhor+IzkgFROIPzG8TqSnyc5Mp9diWdxBf0PhxRESI3QqW/YdxZfzNke/WPb3yINz0XI= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN1PR12MB2576.namprd12.prod.outlook.com (2603:10b6:802:22::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Mon, 25 Jan 2021 17:36:14 +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.019; Mon, 25 Jan 2021 17:36:14 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:36:01 -0600 Message-ID: <161159616115.68367.1898001254335287663.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN7PR04CA0181.namprd04.prod.outlook.com (2603:10b6:806:126::6) 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 SN7PR04CA0181.namprd04.prod.outlook.com (2603:10b6:806:126::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Mon, 25 Jan 2021 17:36:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8c1a4438-3342-4d13-df6f-08d8c157b651 X-MS-TrafficTypeDiagnostic: SN1PR12MB2576: 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: Lt6U1ZR63PDiwXAIzmI8o+NlkAp1VqVXj2KX2FaJrtSwv0sETmghrMqF3RrdRA9XAGBN0NWDA3vPaxb1EUepGxD9X3+YDdDtUj6lPjHhTZjAxB747wX7gasz2KP2wLTP4lsNEIzJWQstXXpuEwy14Dyw37oFtypZJ5oYRei83PGgWClAHtSVJn6XuklR6R4HXtRb2slQLYzFPrVk6zluN2RrnXft1tVCF69Q20oUwA+TlLVf1PU8qJzjobwOsundA5pmTqu/Ppk0dip74J4l3ElTfard5oOFAYUQykRXM0l1ERadtNXN2hlpkYJjsxw8jGiSxK9zi6DeyAu7H0mszaPu0b80/1idvgYcAfyibfN3wuaR4V1v/GBeaTXzgZ9eps75yHkwENfFau+jF9amKw== 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)(39860400002)(346002)(376002)(366004)(396003)(136003)(66476007)(66946007)(66556008)(5660300002)(7696005)(52116002)(316002)(8676002)(956004)(4326008)(83380400001)(44832011)(2906002)(6666004)(86362001)(8936002)(478600001)(26005)(186003)(16526019)(55016002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?8l8Y+q3C64VyOmrvklxVcoGF7t3?= =?utf-8?q?WqXCllM+spNfdK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q?eW9RQqra9KGzUJrxfYRMYINanb6XUnQdy5ljj57NsJnJU/14d28KdqBC?= =?utf-8?q?Sap+3kuS+NoKIu6XNxDtGlFhvThsBw+mTomLtP9fTsmw+rXUwZzir8sM?= =?utf-8?q?l8QFNbozLUHmY+/6f/ukSaB5/Rw/QMWcDTNM4n8ZO55SyRlvenIXA?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c1a4438-3342-4d13-df6f-08d8c157b651 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:36:13.9268 (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: WrZl8+s7SwFcwwrYNyL5ctvRKYUv6ii1sh9fh1O1VuYw9CT0V5FoO160k1fcvmD0gGcbwIwk3X/E5Ue+E0lZHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2576 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 216240e2b771..97f2c857048e 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; @@ -118,7 +117,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 Mon Jan 25 17:36:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 370395 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 34F38C433E0 for ; Mon, 25 Jan 2021 17:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFA82221E3 for ; Mon, 25 Jan 2021 17:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731025AbhAYRhz (ORCPT ); Mon, 25 Jan 2021 12:37:55 -0500 Received: from mail-bn8nam11on2041.outbound.protection.outlook.com ([40.107.236.41]:64288 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731165AbhAYRhb (ORCPT ); Mon, 25 Jan 2021 12:37:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQFlFlxWMIRWp9E60xmfUaIOQtDmoQQcOgvcMpSdWu4jWtApBI1AKa3GPWmMz6qxLgD8WgkSEGtINBxO+iqQVKWdV+keezl99nIv6spBkslNaxR08lZ9MLxoakwz07wyhK+I/JHvPVGYedJGlgTw7RiAe4u4eySFZaOJydJcwaxK7+u59Tu2N5TeHdKdf5gb6OqG7DJiVoyqybqLWLLfH+m+As6Zwt2Q1cppEJGU+v1R7GY44BRjxuLTu1lGbDFr1iqRda0ROpqurdV9o4hqWHDAuZ0H294WBw4hTwxkY6cydKQu3AMT6MD2zBsf6zV/DD7T8qxD1I0rTxbR45f1Vg== 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=i5QWLEqnfnSJhz4T+K5NGfeXlyRjegkeQZPClJ2YQn2ZSy/OnYnLG6KRft/ZyWP124+2xkK10AN7eyufG6svUAlWfBorlcgqD9wEFT6yrkIVEnmtLMt+s/r4aN2A4Do3vJzZUF6NgERRrgUK+sl3j3WpvVi3HhoW3xgo2KQLuTQnHGawejTsVH67EEc5P5hYJjanChvCtAzh8/cSl4VwOTHzgntqs4NxRmh23GxTi+YWZZYf8bLIsy29EyMn9HlTkG9gMcrXmVvFo8LjyOEAkDNOPWSH5oQZxO5oM+Eh28GTPjYhFW1fst6F/+kFQu2EIsqn13z/0qoIkpEqtm26Rw== 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=AE+tmfxbugAPWlFPBevCgg30PK2+GTFaNcjl7534WnB3Ro6RsPkVI2syjG+tOiJTfSdm+UxxBjxtuvi5ccMvf0SU3vlBFLO72aimk8RUaFKP3iSH4m0rREBbnk3sj4PJtj5PWIBrQ3DOI8QrsTOQrnl5w83YbrPjg26v0UotHZ4= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN1PR12MB2576.namprd12.prod.outlook.com (2603:10b6:802:22::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Mon, 25 Jan 2021 17:36:20 +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.019; Mon, 25 Jan 2021 17:36:20 +0000 Subject: [PATCH v2 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 Cc: boris.ostrovsky@oracle.com, joao.m.martins@oracle.com, konrad.wilk@oracle.com Date: Mon, 25 Jan 2021 11:36:23 -0600 Message-ID: <161159618336.68367.17545859893619697961.stgit@ethanol01c7-host.amd.com> In-Reply-To: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> References: <161159600371.68367.14890273216040482793.stgit@ethanol01c7-host.amd.com> User-Agent: StGit/0.17.1-dirty X-Originating-IP: [165.204.78.2] X-ClientProxiedBy: SN6PR08CA0014.namprd08.prod.outlook.com (2603:10b6:805:66::27) 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 SN6PR08CA0014.namprd08.prod.outlook.com (2603:10b6:805:66::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Mon, 25 Jan 2021 17:36:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f7c64a63-8166-4bfb-2711-08d8c157ba5a X-MS-TrafficTypeDiagnostic: SN1PR12MB2576: 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: PZSgtZxUIG78YBT3ho+l69I+/VILYcbzXqV/tdrlCEUY+fgUsFxwhJakPfgLYDsE5A/m0pWP4uJdMkIVQ+z4xYnCLLwSPBJosgHRbzwRfoAYdrotF+1BsKsXnEyvuLlIdhP1tLMtz96E+GJNimO8vmc7gahuWCHlloh3ZcPzK96076fJl4llwYD4MVrr7C3TsW2+wXHh89HGlhfGImHUBh+AqTPv57KSxa7c/8VcW1dyxTx8Yss8hsODrzYxe6K7H8fuxOxOEVJ0Elnl8BpipxtJ9cXkV9pyg+S81HX1ctwhEUQpAaW9Cy4YbwNCItXAAoje7+XYC9yYKADvvOuL4RBChl2f1er/GYVT1iKWOrNkA/lCHfxJlXmaz7PhgLsTpBv9JP56rs3f2ebRHMKiNQ== 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)(39860400002)(346002)(376002)(366004)(396003)(136003)(66476007)(66946007)(66556008)(5660300002)(7696005)(52116002)(316002)(8676002)(956004)(4326008)(83380400001)(44832011)(2906002)(86362001)(8936002)(478600001)(26005)(186003)(16526019)(55016002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?zjh0UFgD9MxSAEcSn9GzfmwmmOk?= =?utf-8?q?jVEZ0iLEDrJG34Uf1JcfLzS2moV3qan0o8McCSToFBRLArIsiNFmc6IP?= =?utf-8?q?3FFVVA4SFRyS/nJ7YRa4fOttkSmB0amT56xKMjZSK83nVOB/k+wvDbu8?= =?utf-8?q?cfbHm/kGqIZNF/vIUZtSiZt/ar64Jofaarso3q6HigII9t1SKUWr2l8j?= =?utf-8?q?EEQiO7Ul7Fq0ucETwYYUS41tRtICi1bJtC9z6a4CRNToPOj5IovaaZ3n?= =?utf-8?q?lLO3pSCVAsIGbaMmT3vNhFXVbCML/Tc6i8feX8X7nigUMxbQaNrvFdu6?= =?utf-8?q?pNpmJ8sLxuZ1YVreURPi43suVPmxffcFAsoGowsDY/kVmnrfvWy5m0Hq?= =?utf-8?q?HhRYqO0qPvS9iAsr/3hGW10Y28m9Mb1u0yj2LR8ylxG1wxX7J+DI//p1?= =?utf-8?q?aWqQ2VNZp5heKMd1rnhlEeJTvuUUoy3RQz8SbfCdiU/N/J/5ZJErnrUy?= =?utf-8?q?wjTFCsYHiAIGC+dKf9ybxuYmRb67Ile5x4NICfJ+VN7WQMcTQgY+5tG4?= =?utf-8?q?TWaVWtXfGhwzN0hYGeYKgjyo2uAQ5jCXwVwQ0/HZO1uC5eV8fykwo4jh?= =?utf-8?q?ZWZYNk62A/x1ceI9JGLt80nLZH4lW7B5OYm1ZQwrOyAegBYLQJgHmEpc?= =?utf-8?q?+V2V7vLukdBeie0kHIXq7FDv40W50hp38pdCenh0zBmlzFrUHLwCuKwJ?= =?utf-8?q?5R5m1tshf6EmuWg1pYFJH2JJZjStDefW3QyivMskMxJ6L9YX7AGSMnmm?= =?utf-8?q?YBJiVooANO/sclyIHMjJf2BktYVb9tS+0oHujapLCumfnSsPaWZx5ahT?= =?utf-8?q?yONYaut2fOc7w+MrwvHrSIuSBHXO+y9diFgaBnRfwhz38gTNBgynKVap?= =?utf-8?q?dgUKX92Q8c0RvpnnRw7wdUb4gRCVMcH6iez/IsvoD8tTHMrcJ2Ol2Lv5?= =?utf-8?q?EswW6h+zzwYcY3UkJmy/ezJzVjyHgSJkNV3Bm3sTUQT60JjAv7yMb+5A?= =?utf-8?q?RThToo7XL8WIOwBDkB+iMYeRvGRqtpZVuGsvpH6BeI3klMcolcPYCc41?= =?utf-8?q?oDVvjx6pTTKKv+ns506nJW0xredPYD9//u1wo3oAoNTdm/ujVwnxb?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7c64a63-8166-4bfb-2711-08d8c157ba5a X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 17:36:20.6900 (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: I4y7yHrb/0kzoVVSJsH8HaVHgbZK6s/Sd1tLDvzKbJG1T1RatT5+tMiQEtLqcMWCmnmoNAmBQvf4F3JHbwmnBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2576 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;