From patchwork Sun Dec 19 16:35:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10AB3C433F5 for ; Sun, 19 Dec 2021 16:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236126AbhLSQgJ (ORCPT ); Sun, 19 Dec 2021 11:36:09 -0500 Received: from mail-dm6nam12on2085.outbound.protection.outlook.com ([40.107.243.85]:12512 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233228AbhLSQgH (ORCPT ); Sun, 19 Dec 2021 11:36:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F11lspCW8UNC2d8befTPTsU1hZIaWaaF94P7GvzStDwXw0ECyUtuJrvuOpQutJk6Vc5IdJ3TX/D0ghPfdlpHTl5M5puofyPeuAQk76e7MJdjWGb2K1e6SGBwlfEtlpfk1KoIY51mCuun8wUaRBVMdFfmjgOZocIM2BCYguO9MwoPE/GoAfAynZwKucNv7kqqzOvNO8lj1bpp7kne6w0kmn8zY9lAMNn60x0mgmM8EumwdWxJijAIXJsbKATRXcsG/fMa1Au+i+KX2fty98BsJ2v4TMz2lgkafcBD2ntUJoVKlypusyv8pBdZYlDWK2YKmD5PrWs+BvKOtHCGH2dmfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VFpsTHzsc4S/yAm2lai1tvTk8AIOTj4EwQTjCfegOTM=; b=AQC44MITP+tHMZBMTFnTW8Blkqs+6Ngmaz5tM9xzAyttsAaqgQQ+qOa0ncoC89/m6NfR1xemwl+W3nujcLGr5Pbq2EASFyoIDAMymztqEqqwXyvyh9HMx1YnHJMsDFlOrRy6LCTiwxElSaZ2j12RBj/wkOnH0+otN1579/HJ9gC2icXmcERzoh9thIzkiYSAzNCFzT/UAWfKyNl8U2j6aQwtgSZbNv5XdsLJMQCy/flnC7Y96bxLtZGUDpS/N83/bEppib0jwin+v/NfsLtC64ZqIdaP2VPSjQqb5JVuLwW0q/hNtr+n+uMdpvubGSuGMQb52VUHd2nzUpVS2wasew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VFpsTHzsc4S/yAm2lai1tvTk8AIOTj4EwQTjCfegOTM=; b=CUW59tB83Wyo049EVQeVqt8vfkH+ooJ1CY7etfRTF9e/3VzTX6cFxLU+1rYyBQIo+GVDPQcjQZbBhfyDutfKfB7dvI1mA5n5h2PaagPpsLNSkX/Uuuv9wKZhiuReO8tl8n4QQm0j5XT2bLkoFdgNHJ6nFmc6gyibUU7yakjOCqA= Received: from BN0PR08CA0009.namprd08.prod.outlook.com (2603:10b6:408:142::13) by MWHPR12MB1232.namprd12.prod.outlook.com (2603:10b6:300:10::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sun, 19 Dec 2021 16:36:03 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::a1) by BN0PR08CA0009.outlook.office365.com (2603:10b6:408:142::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17 via Frontend Transport; Sun, 19 Dec 2021 16:36:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:02 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:35:58 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 01/14] x86/cpufeatures: add AMD Collaborative Processor Performance Control feature flag Date: Mon, 20 Dec 2021 00:35:15 +0800 Message-ID: <20211219163528.1023186-2-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f121c60e-6192-4181-f0a9-08d9c30da57f X-MS-TrafficTypeDiagnostic: MWHPR12MB1232:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0s0XeBT6rIZWyT6lACNp7L6g/kk3a1yZV45xXPcah/8Uyb+8zgNrJhkOevGkvH6uVJzDlr6d4aIatZdI10I8rk+k5542DXs5A8PuiPJm7+347S0d8cq6gqv2pCQUzG+Mqr/F1mhznf/6QSTfiUg3gr0niio0mlyOMp+Lt0IGi7hZLIgDpeSjtliSykmkpsIxsL6eK5WqYlVNpYpAuDP4o8xN0feq1vEICkfP/4SxKJCVJJ8x3XZh+SedlAETvXtxbzxyoUvzMrHARsDVO82CH71RKiHZUO7vpjyKiiECabYTl7IBn/dPrL3J0awP+fe2ns4jQgYViVNU13dkOtQK0JtR6S4YCJ6dsoJjpiCI/v9eDpUoPYAXmyTHkrD1YsnFr83wv7o0soS4Z0+15eVJ2lSpGnRoftmPDlM/Xi8Tr9qHDLRXdMAEvBA442zwgerhOaSXWR57PFUyykLVfsOcK/lRCxZy9h0U9wrIb/ImxjhqlCM6mGK4fPoRDcJ7xYNhgx/DwSSQh2ksqLtc3bviY5N1Jdnt9gVWO8lGmrTCq6kDiH1sMuMBhIKzRgBoV2sguHnBt9mHnKCWxr9ZVHmgucNrO0HBOs0xlc9/AxNkvlToSU9NNpCDQ/UUk9ArzSQfPZ6sDzEwp50Od/8Oqjs2quYnF7uU08+hmnmesFkHepw4FrKi+plS50wfsri8qhdamgxLwpdha5PAGszUjiNZGiDLIKQMblwaDkuNQVJcy4waFu2vH0BJ0L4UmvJnID50NeCwHHSCmonGnGuEe697MhyrkD6xHsPGLjbhTX7CZGI= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(54906003)(7696005)(7416002)(110136005)(2906002)(8936002)(8676002)(86362001)(36860700001)(316002)(356005)(508600001)(81166007)(47076005)(82310400004)(6666004)(336012)(1076003)(4326008)(40460700001)(2616005)(5660300002)(186003)(36756003)(426003)(16526019)(70586007)(70206006)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:02.7823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f121c60e-6192-4181-f0a9-08d9c30da57f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1232 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add Collaborative Processor Performance Control feature flag for AMD processors. This feature flag will be used on the following AMD P-State driver. The AMD P-State driver has two approaches to implement the frequency control behavior. That depends on the CPU hardware implementation. One is "Full MSR Support" and another is "Shared Memory Support". The feature flag indicates the current processors with "Full MSR Support". Acked-by: Borislav Petkov Signed-off-by: Huang Rui --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index d5b5f2ab87a0..18de5f76f198 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -315,6 +315,7 @@ #define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */ #define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */ #define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */ +#define X86_FEATURE_CPPC (13*32+27) /* Collaborative Processor Performance Control */ /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ #define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */ From patchwork Sun Dec 19 16:35:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 266D5C433F5 for ; Sun, 19 Dec 2021 16:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236148AbhLSQgL (ORCPT ); Sun, 19 Dec 2021 11:36:11 -0500 Received: from mail-bn8nam11on2041.outbound.protection.outlook.com ([40.107.236.41]:54208 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236131AbhLSQgK (ORCPT ); Sun, 19 Dec 2021 11:36:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PSRv0RFJxBWMM7XedPmb4gtX21lKC210iwDWiACodixd/2NqUTPawkQBG5k78vHRtCYifsy278uRQRu4o19U7+/gmedjzBGKnHgPklC19YCfvEnXpWa6EP/lxVq+AwzwCvnm4L/7kP2vItpiI+E6K+0MS2Rpz9ktOnrVpH1Po+szNWTjrbGw+mGZn1MFoMyTA+rW4asovoaPJ9CQ5cks2VlgynFHWGc0D3bbyL2/ZefzSHIUxW9jjlPfOLTo8hmfJSInGOVfjGJ8kfHbax6OqHjMMmrXvM/ry/TCmccXi0F9qw7md9ZDuSNTx12fs7sLamg42YOeFfJdK1IkMNr3oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E8kgyOkrddODGeP9fLYswG8P2mhNQkaTgXSoOqeB0ZY=; b=HqFJEUh23EycKjLyX1JyovfDdGg7Bl6SO/awMcKDqEukMtTMHn79ZDWrF+F8F+09p2In2T2bc+API6EShHo/NKq6jyE78711r1JzGIs38rd807NuwaA22ptN8NloREWkYwiuEu72L/EDH/KTr2PaEQNqqZkwJllt/tU1MisoqE1Gcbyl0KuMrpLjpkj54gxeWxbqMDbuEXXLkBY+HCzulYkTs2gTamMk0+v6NLdrCNb2l0RtEudkBLyKdA2n+SC8Q9Chu/VRoPjHq31CntYGJixgEsrPw0dSJcD3woCn2mZiJWeYxAlYiEee8mwuiZVy/hviRjNFyhV8u7yuqsDqdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E8kgyOkrddODGeP9fLYswG8P2mhNQkaTgXSoOqeB0ZY=; b=t3/SB1Cwmj0lITfoB9ZAzoWJrzQBRPRW1B/ePtK9iPY9XGzaoJYAYB6vofs1CzB/jlsNWXfNn/w1hkhmzniiHUsXs7AV0w5K1j0/fD1a3hnMW64iBfvVxWkkCFHCYm2iIDXHSHHSQfdu8Xh3574u53Vc3DSWyfs7ScCDKeV0c9M= Received: from BN1PR12CA0027.namprd12.prod.outlook.com (2603:10b6:408:e1::32) by CH2PR12MB4311.namprd12.prod.outlook.com (2603:10b6:610:a8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sun, 19 Dec 2021 16:36:08 +0000 Received: from BN8NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::bf) by BN1PR12CA0027.outlook.office365.com (2603:10b6:408:e1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.15 via Frontend Transport; Sun, 19 Dec 2021 16:36:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT043.mail.protection.outlook.com (10.13.177.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:07 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:02 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 02/14] x86/msr: add AMD CPPC MSR definitions Date: Mon, 20 Dec 2021 00:35:16 +0800 Message-ID: <20211219163528.1023186-3-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9e029b3a-eea8-42f7-65ee-08d9c30da842 X-MS-TrafficTypeDiagnostic: CH2PR12MB4311:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1107; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TP3M3/4UMgnW5g8xpvteolpHCawUTw8dtUBnkHZwb9l+Fk3l8Qn5phqoUP98eU3Ie4Juh61C6axxB4S2gWiG8FIHERa8cnV1SjzTVuPxZda4P8fbuJD9qqfcH/ymqVQnaXJrBaoD3Y/qEDRithxTOOt2nh6h7HVrdxWy870pWOskICh8KXafupu7uRBJi4AYB4n2ZFZo49p7+r9mqHVY9IApWwF430CFLLAj959xuz0Ac6XOTfT0N/OaevOaNkCxiDgkLm5CVRS7cy9jgCAij43jwYXEYxa+t9NvS+pMusXdYZ/sOMCNMhgExq36qhzKi2HVIJPAvfqYyFj1IShwA3l7A1FjRIgtp//7B9FeoAjVificlwefaD7tErnPCrEXntQaudgvKRsm+ajNJtAt119XzDiSPEKMHVUrD6F3gX31FPhIk+nIEJrpmxPdGPgfZVAyNTp4Q3eInROVN9k78AXhCHcY/FJNZ0gcVEZooZWPi8qeHxR+39uAeF4VICfoQtZNki6MkWoAa+aISSa16QpRz+fYM+zonFcYwD+JySVyvfH+2hucHySEi6BUyiLSyFKdCVe3213cJxUlMPfTVrP1XVxxTj6UbsoLulmVpg/TX59cbdVS/7KLpsNKxVCQL9RSe40dCUU7k1+HBmCuCUoEfDCNKp8Ia+wwwsYs/UMrBebnf1xyAty11SW3274Za2jklYus93+i56Pf4gwcS4PokfI5DMmTXGN5kTtL/d2ZXRUaYud2e5Uu3xGK5ch/MqxI+KsqhnGjjy687rCn1yyg4GA5FRMbUqtEVT8zpqs= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(1076003)(2906002)(7416002)(316002)(110136005)(5660300002)(36860700001)(86362001)(36756003)(70586007)(81166007)(356005)(4326008)(70206006)(508600001)(82310400004)(8936002)(47076005)(16526019)(186003)(6666004)(40460700001)(54906003)(7696005)(26005)(426003)(8676002)(336012)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:07.4111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e029b3a-eea8-42f7-65ee-08d9c30da842 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4311 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org AMD CPPC (Collaborative Processor Performance Control) function uses MSR registers to manage the performance hints. So add the MSR register macro here. Signed-off-by: Huang Rui --- arch/x86/include/asm/msr-index.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 01e2650b9585..e7945ef6a8df 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -486,6 +486,23 @@ #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f +/* AMD Collaborative Processor Performance Control MSRs */ +#define MSR_AMD_CPPC_CAP1 0xc00102b0 +#define MSR_AMD_CPPC_ENABLE 0xc00102b1 +#define MSR_AMD_CPPC_CAP2 0xc00102b2 +#define MSR_AMD_CPPC_REQ 0xc00102b3 +#define MSR_AMD_CPPC_STATUS 0xc00102b4 + +#define CAP1_LOWEST_PERF(x) (((x) >> 0) & 0xff) +#define CAP1_LOWNONLIN_PERF(x) (((x) >> 8) & 0xff) +#define CAP1_NOMINAL_PERF(x) (((x) >> 16) & 0xff) +#define CAP1_HIGHEST_PERF(x) (((x) >> 24) & 0xff) + +#define REQ_MAX_PERF(x) (((x) & 0xff) << 0) +#define REQ_MIN_PERF(x) (((x) & 0xff) << 8) +#define REQ_DES_PERF(x) (((x) & 0xff) << 16) +#define REQ_ENERGY_PERF_PREF(x) (((x) & 0xff) << 24) + /* Fam 17h MSRs */ #define MSR_F17H_IRPERF 0xc00000e9 From patchwork Sun Dec 19 16:35:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03E00C433F5 for ; Sun, 19 Dec 2021 16:36:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236149AbhLSQgR (ORCPT ); Sun, 19 Dec 2021 11:36:17 -0500 Received: from mail-sn1anam02on2084.outbound.protection.outlook.com ([40.107.96.84]:34790 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236150AbhLSQgP (ORCPT ); Sun, 19 Dec 2021 11:36:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tl8OSB2JNt4p3s/+wbqAHPp/8FM46xfHU8NzXLHxeK4YQVsaMptEcPZeK0/j9/PI9JC9WurM+XwrC4O0FmU+oeZhvO5LWDraoAeZVZ/V/+8xw99CpCbFS9mxk1I2Oa/tUTqVX/dDDg5iVpakpHtMIQEYAAOb5KLj3HinqFuQAEYvhHr13UuO1LmHF1vcMoYap3R9RqxV00Nyc/B6Ev9Qnx/BAY9oX3/Lv9HUMq47lxn/UlFVj2WxgefrrhxxBgG4pgFtV8sFhxNejgdlDHS/DFGmKM0GNFVHO8mcVgvAD1RQUqBGH/sio5GKrqsI3eBLVdtFJ3ifnk/dCDFVN4RRkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oIfQxURDoLiRdYdh3RmTxNuSKDBcomrDa15EUoBmGq4=; b=knPwU2GcTZfTS7CLUnfq0gEj0ERWglKWwzQtjGf3kjFo+Ssx7WepPccghY4x69W7+ydonj38ocIFQUTJGrGAAaeeO0JGggCLFSMLfC3Cdu/zMirMBVo3HZ2LT6OIJLkxLjl2f8YA5O0cyuyQnYMjT0RSzC+7o35x664a1LuKN2KoBLcRRfY9R5TQOYZm4qR5CHeN70g60WSd09489FjHtWpwKccbVDgSWpbH6F4miVhUuyoi2n1OzXanfZz/MwIDUzZhGWFROjSKr8QQxGh8NiiislEDZdNRijveu6Sk28MetxBotQc+kM8lnmnZfRNpANFbANj55M5zEQZG6ZK3qA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oIfQxURDoLiRdYdh3RmTxNuSKDBcomrDa15EUoBmGq4=; b=00vWxNg44zsWMZZcZRGrG+d1R5v7nYzFLySXF+ZxVn32m6is/CDVdccZ4clE5tRifd7DMcVIpPc8VbhDjiI9nA9QDBFk7LC6J2bI3rqY5DA7lMH3CruH8dN4qdlnq0FPB2PQ+RuKQFPLms724JB/QG0RsjIoipUP9M/G2rA0Lqc= Received: from BN8PR07CA0017.namprd07.prod.outlook.com (2603:10b6:408:ac::30) by DM5PR12MB1434.namprd12.prod.outlook.com (2603:10b6:3:77::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Sun, 19 Dec 2021 16:36:12 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::88) by BN8PR07CA0017.outlook.office365.com (2603:10b6:408:ac::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:12 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:07 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 03/14] ACPI: CPPC: implement support for SystemIO registers Date: Mon, 20 Dec 2021 00:35:17 +0800 Message-ID: <20211219163528.1023186-4-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2ec3e51-f9d8-45d4-2d07-08d9c30dab19 X-MS-TrafficTypeDiagnostic: DM5PR12MB1434:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yqk0Ny2F4NCvzbHep+EB8K+/0xdXRX+Kc1MZeWv7s85/4vAGEVgv7eeckOZFd/ywK1/uVAWaUn6Dlu1YcdQfuOqzscuLluQDG8IFrwu1jAyD6BVkhKq/3y+A8M2HblmSZOkEY+nFWgxwWLyOCgN6No3UbQE0rjAhjSKpFsyrq9L6TmZDX0VTAY9escKj1rPUBX1zuoej1ZOPyZXmpi8WFTr62O04sKRiuOgCpcthqktSeFYJUz6WK+SxPwZU9w51ki1oi6pk9I1/0X+UC8rWlky2uflEHtAXPy3EGAE91ai2c6YFpIvlE6pbo0LobhVKvq1PMoZKYqtyaryVLa2j2j5ghaOT6sLBebfMGaSVdkssrJvRx0MR5utrK1B0JPCoPbkf7ukV4JM+vAQdnecmU+MYBKXYV7BuM0YbLbLzSBVawEmTuOiPYNfborZ/CBQXjFQa49CJS+MIZwvsUrx5S1NsdioBZRQyGzrF0NkqKSidbUOOCre0Pq81c44pgVdwREREdNPsU3bsdsxUVziyfBz9PIn/pLeeJfTilG6jla/7k8lmBsgnds/fq5dHHc5CWq8cgXZdH7J9ebYk5CIm6TzK4nN2xK8k6oNPqkSZ2kvOt96FTvtDAw/U0yN1RdIE1nfPB55bLsobWkd3WnmgxMrOQaB23QA792e/uwVqrPvRPPrrfaUuSwA4bTyGcpaP6Hl0iEOV6n5r3krBctQyoYLrcpSw0pr0lDFhIFZgmjHMG669V00JRyqe14IXq8D8RbDiNZU5mVVX+zo/aN3zCzR+QEF1tayyDDExxxYDb1M= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(70586007)(356005)(47076005)(26005)(40460700001)(36756003)(4326008)(508600001)(186003)(16526019)(7696005)(81166007)(82310400004)(70206006)(336012)(2906002)(2616005)(36860700001)(83380400001)(6666004)(316002)(8676002)(426003)(8936002)(7416002)(5660300002)(110136005)(54906003)(86362001)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:12.1712 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2ec3e51-f9d8-45d4-2d07-08d9c30dab19 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1434 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Steven Noonan According to the ACPI v6.2 (and later) specification, SystemIO can be used for _CPC registers. This teaches cppc_acpi how to handle such registers. This patch was tested using the amd_pstate driver on my Zephyrus G15 (model GA503QS) using the current version 410 BIOS, which uses a SystemIO register for the HighestPerformance element in _CPC. Signed-off-by: Steven Noonan Signed-off-by: Huang Rui --- drivers/acpi/cppc_acpi.c | 52 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index a85c351589be..df2933c28bec 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -118,6 +118,8 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); */ #define NUM_RETRIES 500ULL +#define OVER_16BTS_MASK ~0xFFFFULL + #define define_one_cppc_ro(_name) \ static struct kobj_attribute _name = \ __ATTR(_name, 0444, show_##_name, NULL) @@ -746,9 +748,26 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) goto out_free; cpc_ptr->cpc_regs[i-2].sys_mem_vaddr = addr; } + } else if (gas_t->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { + if (gas_t->access_width < 1 || gas_t->access_width > 3) { + /* + * 1 = 8-bit, 2 = 16-bit, and 3 = 32-bit. + * SystemIO doesn't implement 64-bit + * registers. + */ + pr_debug("Invalid access width %d for SystemIO register\n", + gas_t->access_width); + goto out_free; + } + if (gas_t->address & OVER_16BTS_MASK) { + /* SystemIO registers use 16-bit integer addresses */ + pr_debug("Invalid IO port %llu for SystemIO register\n", + gas_t->address); + goto out_free; + } } else { if (gas_t->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE || !cpc_ffh_supported()) { - /* Support only PCC ,SYS MEM and FFH type regs */ + /* Support only PCC, SystemMemory, SystemIO, and FFH type regs. */ pr_debug("Unsupported register type: %d\n", gas_t->space_id); goto out_free; } @@ -923,7 +942,21 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) } *val = 0; - if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0) + + if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { + u32 width = 8 << (reg->access_width - 1); + acpi_status status; + + status = acpi_os_read_port((acpi_io_address)reg->address, + (u32 *)val, width); + if (ACPI_FAILURE(status)) { + pr_debug("Error: Failed to read SystemIO port %llx\n", + reg->address); + return -EFAULT; + } + + return 0; + } else if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0) vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id); else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) vaddr = reg_res->sys_mem_vaddr; @@ -962,7 +995,20 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); struct cpc_reg *reg = ®_res->cpc_entry.reg; - if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0) + if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { + u32 width = 8 << (reg->access_width - 1); + acpi_status status; + + status = acpi_os_write_port((acpi_io_address)reg->address, + (u32)val, width); + if (ACPI_FAILURE(status)) { + pr_debug("Error: Failed to write SystemIO port %llx\n", + reg->address); + return -EFAULT; + } + + return 0; + } else if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0) vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id); else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) vaddr = reg_res->sys_mem_vaddr; From patchwork Sun Dec 19 16:35:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 358E8C433EF for ; Sun, 19 Dec 2021 16:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236150AbhLSQgW (ORCPT ); Sun, 19 Dec 2021 11:36:22 -0500 Received: from mail-dm6nam10on2068.outbound.protection.outlook.com ([40.107.93.68]:37792 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236173AbhLSQgU (ORCPT ); Sun, 19 Dec 2021 11:36:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LSgk6GnXYUJXZorqWMuz9AP5Q8YN//W+IiJU8+hBX1ZoWRjIpxvYmscny46jyVDyCFlNFVUOsmHvYtgYzIWyqU1ESywxFRBM+sLuLpuMRWwYeptz3SPe7G3AZmjc4Ic4QFqZm/5vT7tI8RwkCbqrGkkH/ugI47tQ0o/nO6gWanlrKGXyw6g6//t+OFsXU3pdzpzrFc3M1iku33J87nBTT2VgB3VoiHOGtZKz93VNVPugaiQDQVI0a5r5CYAKjCksm7LYcloG+rv94l2nIY92CLbckSpDJUAZWqUhdSjDWMtj+bHuJBR3hFi2CpdsM1IIBdOIpuANCgyhHJwzzFHmsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u3UU5d76mg+7cQStoPV9EmAx/srF2ZK8NyHHbv51EwA=; b=dgK6qrfbasIZnsWUbrROKaiiAGZsRc47wiL13OXVcigOYd22vZVt8EMMjMNHkcBLcEokDUtKBFkMXxBrbwxXSBlUz9XIzfkR4HNMkjnfy3v3xxjlg3AXymoO4cXasgv0MGK8d69AALH1lQWZJHjP+WLqDV1FCRQT0jDMDkjCPFRdke6QsQ3RUIjxFwFcrIxZ879U5YC7Wff9EvygKIir3L528u3GWAB+fZNqK0YWrBy6E+NyL/UUo5ATtCYYK8LE3LB0srSVIWTxqnCgPR5F1TCCwrgmyOs3BVD+8CKR15BP+GzdUafYn3g+3PTjX1SxKRUJ0i2ajkKsKu6yS30mUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u3UU5d76mg+7cQStoPV9EmAx/srF2ZK8NyHHbv51EwA=; b=2jEBS5mqXesACitntGsPRsRiPV0zNOaGdsRxGzs5713Bdu/0daiGyd3uzktcCKd0n/fiyESFKMUpST/mu52mnnaWJboNIvhzBFvwnLTg4tYnfS0is8dAAsTOqy111uD0JIilIles9rM+MaFurryrBSs7ViOgee/thYXjiP4Huis= Received: from BN0PR10CA0020.namprd10.prod.outlook.com (2603:10b6:408:143::11) by BL1PR12MB5158.namprd12.prod.outlook.com (2603:10b6:208:31c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Sun, 19 Dec 2021 16:36:17 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:143:cafe::24) by BN0PR10CA0020.outlook.office365.com (2603:10b6:408:143::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:16 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:12 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 04/14] ACPI: CPPC: Check present CPUs for determining _CPC is valid Date: Mon, 20 Dec 2021 00:35:18 +0800 Message-ID: <20211219163528.1023186-5-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fe883ef-cbd1-4947-0409-08d9c30daded X-MS-TrafficTypeDiagnostic: BL1PR12MB5158:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S2nomj8FuPATTKLCSjlalSZLE7bF05/TjbKGdDuvF3v1IxP8a9GjCW0L5eE5zZ5TkcGqsBLh/jccKt/ZKILlEMqmnKnso8UlCx8bDc+JQ+5JAve3K+nnp0QX0yBT1YJNefcGFDKYb/BKz3UVfEIdCnJWfK+S+5fXt8dzjIDEkUH/DkcOMQXleraZA7CO/3uy/8TTbPkgxpk9xj+8BELWUc5NmRLCTy31v+C3mOCujdfKAqGSoPXMcH6Xh2NK6Fe02t8sna3TKL2DFmPFnaMsCoz07tUXSK73IB26Fbdul4AZna78ziytml31nRyybzz4O1e1DE2vJPt9vBSgPT4tNy2koBr3kPFhcgBYar6Wl/ll+LnugPqWiIV7Hct0TsDFlvNohyCOmaMVemSxo/YwdagjcSl/Hre/KJvmJXcwDlex4xgBIIksNMo8t/+w8QiPaaMYU62T3ggwrg1RnayXO4rJX4q1q5p8rh5Mdmk2IlO6z5y55M9qICZtGEqBcAzn2/7Z/gDrUMDp1hlXRM5a8WI6IpzyWWOQm8Wf05CYrS0FZrz/ed56pDO6pPBgMtV+1z+dMSArplH2iTuKGPhzrzHFRq+NLu9lnuBb3W2MZ4DHVDh4T88qUYH14sMsWLFq3I1sKMQ2oUyMlha1YRs/wO3Alzj1dzDJMALMuck3LG5rBNSugfJzFpFYaQasLWWF76t2TCZLIO0nXJNsPJsQ1XpnV2rcouGU4oPUbDTAXBEvhJFbbabE2Br61Ubt/Y1hTEHm76NviIo0cVcmTCxMnAGnnCBtlvRMh8y5MJPGHUk= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(426003)(336012)(16526019)(316002)(2906002)(8936002)(110136005)(7416002)(8676002)(5660300002)(4326008)(82310400004)(40460700001)(508600001)(54906003)(86362001)(47076005)(26005)(81166007)(83380400001)(186003)(36860700001)(70586007)(356005)(2616005)(36756003)(1076003)(70206006)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:16.9305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fe883ef-cbd1-4947-0409-08d9c30daded X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5158 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Mario Limonciello As this is a static check, it should be based upon what is currently present on the system. This makes probeing more deterministic. While local APIC flags field (lapic_flags) of cpu core in MADT table is 0, then the cpu core won't be enabled. In this case, _CPC won't be found in this core, and return back to _CPC invalid with walking through possible cpus (include disable cpus). This is not expected, so switch to check present CPUs instead. Reported-by: Jinzhou Su Signed-off-by: Mario Limonciello Signed-off-by: Huang Rui --- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index df2933c28bec..0c4f7005818e 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -413,7 +413,7 @@ bool acpi_cpc_valid(void) struct cpc_desc *cpc_ptr; int cpu; - for_each_possible_cpu(cpu) { + for_each_present_cpu(cpu) { cpc_ptr = per_cpu(cpc_desc_ptr, cpu); if (!cpc_ptr) return false; From patchwork Sun Dec 19 16:35:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6687EC433F5 for ; Sun, 19 Dec 2021 16:36:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236173AbhLSQg0 (ORCPT ); Sun, 19 Dec 2021 11:36:26 -0500 Received: from mail-co1nam11on2068.outbound.protection.outlook.com ([40.107.220.68]:35008 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236160AbhLSQg0 (ORCPT ); Sun, 19 Dec 2021 11:36:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lQ2xOU0YjlWej5ag12RcZlKRZpOnbLpBpxOKX410wQtWa8csuSghTaGIdjRhrEnRhLM3clLsLp4eNEaXt+RGbZ5xKWDFCKouK8PKHg2vY+L8Ke1fPxfOChRkQn8CG6WDfZdAJUeLxQU/odJ1hcA1L+vJbu3pv3zkWo6iqBbWtzfJOgAI1F21U/BJqx3FfylyQa3+pNuI/KydxQYCZi65fgMZmvTt/+IKOzg0YYAHXL6CFDxEBdypFSd697YKXjcpGjKChHT724AwkeBi/7LX+t4NFjizahAek4k/H7Sil/ES1u1BDbBIu+x5Mlk003vr0k/VYbR0zH6++L0d0f8xDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h2U2NKv1TFMPPogbMA/QS2BdL5i+mp1ILjQzAkLh9LY=; b=esipFoIn2k4Ggh/1YnISw3JGe1cSEpIH/quQ2vjk0rxDuK1/gTDlqnhH1O3NiUmuIEDWpLib1fVLTT0r9FgB5YntXYXEGI2Sfz0TdVLBAM0ZAYpKJ6SiISyh9lVptZr82WwBfZL9FuAIY25ByvxihBUz+3BPLzuI0S9CjyB5JGwNoSnGbYPogbcr5ZbLcGbkqHOK08k8nIXB4g96Dvy31yJ+Nc1exZqQuCpA8jECSkz0RPBnb2v93d+Eea572w9SBRTdGo6FjufkAwMGTgrXQlxWvl/Y8J/akuBkmNhpOh+OH5W5w16Lr6HjGmludTYHgJnL5gizkqwBjGWBM5+xdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h2U2NKv1TFMPPogbMA/QS2BdL5i+mp1ILjQzAkLh9LY=; b=D8Q9yR5ebmuyXepI76ytq9BvkiYFtaYsmH0fYyDyQMSIZnOyR1KZRkKO50Nto6Y58uPUSuf6KVieCzsDjlgheguoFRPj2xVYPiqtWdY8OXIdLuxwYYqFkwChp7VT/Fi1OBpycydjyhkxfYEdNuNd7TA/T9zQYmX/3ICCo1/Ng/w= Received: from BN9PR03CA0373.namprd03.prod.outlook.com (2603:10b6:408:f7::18) by DM6PR12MB4283.namprd12.prod.outlook.com (2603:10b6:5:211::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Sun, 19 Dec 2021 16:36:22 +0000 Received: from BN8NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f7:cafe::4d) by BN9PR03CA0373.outlook.office365.com (2603:10b6:408:f7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT061.mail.protection.outlook.com (10.13.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:21 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:16 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 05/14] ACPI: CPPC: add cppc enable register function Date: Mon, 20 Dec 2021 00:35:19 +0800 Message-ID: <20211219163528.1023186-6-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c5b4624-c7b1-4426-e85b-08d9c30db0bf X-MS-TrafficTypeDiagnostic: DM6PR12MB4283:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gNEy2+WfyaQhaSL37+JfDnY0suD9zy2rJg21ssIRdbR/ivMR2pgh2q6URjTKezJ5UQlq6aD4ESY+hCs9w+zlK0kg76chjwK70ZuRU3f9LrFWFAkfBkaRYjYlkfdMEdtjUAVyHnqEgsvkBV2H7TFdiLrQP6l1zCgFXJYUuPoUfKChSY+mCfRFIEclwZxV6o4k7/I7GUSNkXUDw3xcyaGneaj5S4CurbWQbMLtAeNvVuxb84kKg42DJTRdx6KOqFOKKHcwMMW+d3zsNR+kuPBQUycks4TUHq2JniwESlEwVgwWj3+ICSqJOyhc9Ewh+H7LzJ5CvAfdwKYcogkp9Co240OyzUZZjdlmkB7AyzDGVY7jnXE6+80eIIMDB6cKTO4tj4KG7YxIsMvOb1Ew8igvU+Y9+X98Ug95MA3eHlCphvT8VB7IuI1YecGVbJcv/uvcMvMsB3KXQVXlu+m7LW4M0IOf5QBRSxouRMk/he183kVSVYODLCHtCgHRa01/7r6QaRA/0qYTMFPgsKnaqeZ2D3FJglFsQGBzLwKnXjZvNPrTbf8Ft8xmZAFO6SndPBEASYbhIQfYvNPJKcHmvwv00kkZNpCUnNOCofinsHXdg9eXR2eRxD0ioVAQTTLc63iVvBZ2F4i/GX/q8vpvQ+RNccESuLsQDxxH6u+riJeTQwUj3owqzIWIT5PjRPNCnl5fedJLcvuJlvtmSUZLFt7el5BS1BxdQOjt/lANDA9hqUxm80wCr/JGqVabf0e7lVlLlrm4PdjfI5AYpD2DERqTLRtVot9IH+WrMHAied1GJOY= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(8676002)(316002)(83380400001)(426003)(336012)(2616005)(36860700001)(2906002)(54906003)(86362001)(110136005)(1076003)(5660300002)(7416002)(8936002)(47076005)(26005)(4326008)(40460700001)(70586007)(356005)(36756003)(82310400004)(81166007)(7696005)(70206006)(186003)(508600001)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:21.6525 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c5b4624-c7b1-4426-e85b-08d9c30db0bf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4283 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Jinzhou Su Add a new function to enable CPPC feature. This function will write Continuous Performance Control package EnableRegister field on the processor. CPPC EnableRegister register described in section 8.4.7.1 of ACPI 6.4: This element is optional. If supported, contains a resource descriptor with a single Register() descriptor that describes a register to which OSPM writes a One to enable CPPC on this processor. Before this register is set, the processor will be controlled by legacy mechanisms (ACPI Pstates, firmware, etc.). This register will be used for AMD processors to enable AMD P-State function instead of legacy ACPI P-States. Signed-off-by: Jinzhou Su Signed-off-by: Huang Rui --- drivers/acpi/cppc_acpi.c | 45 ++++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 5 +++++ 2 files changed, 50 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 0c4f7005818e..6c0a55a17dfc 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1268,6 +1268,51 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) } EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs); +/** + * cppc_set_enable - Set to enable CPPC on the processor by writing the + * Continuous Performance Control package EnableRegister field. + * @cpu: CPU for which to enable CPPC register. + * @enable: 0 - disable, 1 - enable CPPC feature on the processor. + * + * Return: 0 for success, -ERRNO or -EIO otherwise. + */ +int cppc_set_enable(int cpu, bool enable) +{ + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); + struct cpc_register_resource *enable_reg; + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); + struct cppc_pcc_data *pcc_ss_data = NULL; + int ret = -EINVAL; + + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpu); + return -EINVAL; + } + + enable_reg = &cpc_desc->cpc_regs[ENABLE]; + + if (CPC_IN_PCC(enable_reg)) { + + if (pcc_ss_id < 0) + return -EIO; + + ret = cpc_write(cpu, enable_reg, enable); + if (ret) + return ret; + + pcc_ss_data = pcc_data[pcc_ss_id]; + + down_write(&pcc_ss_data->pcc_lock); + /* after writing CPC, transfer the ownership of PCC to platfrom */ + ret = send_pcc_cmd(pcc_ss_id, CMD_WRITE); + up_write(&pcc_ss_data->pcc_lock); + return ret; + } + + return cpc_write(cpu, enable_reg, enable); +} +EXPORT_SYMBOL_GPL(cppc_set_enable); + /** * cppc_set_perf - Set a CPU's performance controls. * @cpu: CPU for which to set performance controls. diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index bc159a9b4a73..92b7ea8d8f5e 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -138,6 +138,7 @@ extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf); extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf); extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs); extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls); +extern int cppc_set_enable(int cpu, bool enable); extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps); extern bool acpi_cpc_valid(void); extern int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data); @@ -162,6 +163,10 @@ static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) { return -ENOTSUPP; } +static inline int cppc_set_enable(int cpu, bool enable) +{ + return -ENOTSUPP; +} static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps) { return -ENOTSUPP; From patchwork Sun Dec 19 16:35:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61DBBC433F5 for ; Sun, 19 Dec 2021 16:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236188AbhLSQge (ORCPT ); Sun, 19 Dec 2021 11:36:34 -0500 Received: from mail-dm3nam07on2082.outbound.protection.outlook.com ([40.107.95.82]:34368 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236160AbhLSQgd (ORCPT ); Sun, 19 Dec 2021 11:36:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IiGHSc7+Zr0kLP4G+cEdBkIcSnU0sdtOq2n9c81r1WV1qQCoUH7y03J4iYqd888S4yIo/nVzIg+JeT5NDXWayDTXOmIjCGi/6gu04CoGUXefOrka4TpL5Qd7EA8st3y50AxM+8ZqttmZfHFvmuqJkADkkCrXNF1Awb1UtXB9SKg2i7+TAIXjCY/+/GOClZ+EJRVtAbL3Cu3jG3xlWNw1EJrw/5ZU93GC9RgrCdpllkZIFZ6P5hSxZiAUCK5wjEpgltYOqBU1tcU8DTaeggIHpz6Rrp9IfRO/KJYxdUIHP/RXntuuZxf4WhUHEy0bqpqAAcVoBTqkWw5TMQOVmD9NEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f/YZNx8dqWVW8i5iymqkkyOg0pOd6Z0GSAuyX5YSmX0=; b=RsQTVPelB03AXr1Z2HVNM4vt5AfU54c0wrEUnJnESmitbzN91+/7fmA9VTeGeUBUYK72RkKsR3ElCjM1vjTajh+8Bb76uE4/BmifhruddQtrlrwL5kbEQRc7TjDyMTwsmAgxHYf/O2coc9IdW7Nk2uyEbYhBpUENHNqdgJh4eZL8xc7JWGPUNy3J1OBznsJMuCJrF/ywVObD2QgsiMgrkaV0G+Ck3clNOlCa/Lk3aGOos7F6CunsXr8NX9cS/bSG6eGOICB61E3A1geYlfuGP/n2yIW7tzM9EPym+Cg1Sja8ulhrbUZ82Saf4sCCcP59grCRbmzKSXNZBpgmWOHNQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f/YZNx8dqWVW8i5iymqkkyOg0pOd6Z0GSAuyX5YSmX0=; b=MCwaNQE5LzD/ErFe4nz5pq5ahTghWoPYgxrF+VpsKt/ajux4DcFykWRT/CdWQhXYXgDnP7DSw0jt9qsIoTXsQsXF5JHQB8A9Yd1nKpQe6b0fbYDqB5aymJMPfq6oK54nTezfy+ZXYof4CoqRZk3p7IQwsPrWqDFEOx71xI0Wgcs= Received: from BN9PR03CA0552.namprd03.prod.outlook.com (2603:10b6:408:138::17) by CH2PR12MB3655.namprd12.prod.outlook.com (2603:10b6:610:25::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sun, 19 Dec 2021 16:36:26 +0000 Received: from BN8NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::6e) by BN9PR03CA0552.outlook.office365.com (2603:10b6:408:138::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17 via Frontend Transport; Sun, 19 Dec 2021 16:36:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT024.mail.protection.outlook.com (10.13.177.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:26 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:21 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 06/14] cpufreq: amd-pstate: introduce a new AMD P-State driver to support future processors Date: Mon, 20 Dec 2021 00:35:20 +0800 Message-ID: <20211219163528.1023186-7-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c9e2837-a75a-4d28-83ea-08d9c30db3bb X-MS-TrafficTypeDiagnostic: CH2PR12MB3655:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TLRneR8wotzaQbpj1U38WZCckYgQP4jFE0N9/pjFUbh6ITMmbV+vaFTX2oAlxOAkCildDwiliUyTcphqj5rnDoNZ+2wnzb77qK+uUdiZCSZMuLc/nQD6vI1crWMxknfFqw0P0zzOlAyEhb+aU6nZS6MSyQY27hpFDqBc3vpWsewLhei6LONozcXT/ZUBk6zEWHKPJr19qNfPoGC4PtvZY0XycvWihbXQzqtsYME/yDQbmnCGUaQ8PP/q5NCO53KzvndfdRYlqJLf/JSifXvH044jrLTswFurGuJcTS0/FD+B5owB9YaXEBuS3k4QDwigeY/eCbrp2g0tCve17YSjpscWjvzc0oa+WgVcgvEDn+ULblpJYRxI1SLpVRzZS25bDo/uk5lWAvYUvKdy7kEGVDkBywm9ixuiMaZLTAWny9qS8fCRYEVsqd86JN+BbnBbd7djkRTrbQMsGRZCwXjD/sQg2gScrP0baQQXJpoKmn7KC99fXvS8oQ4Ewr0L4zbi6KFWuioFTR788iXK/168sBKQ7tq8rxUm9ppu6+NBlAi9Ayke4EqqPzfbNczYS9nZLzq6YOI+LztskCx6jYJ8XvuSsLXgkSuDwx2XafUoA4tB30FsKPp83EFT9ChN0wlicCABLTmuYKXKjt3c5dhxT5FToaeEYa2+SuUViz2zgzpcOBElJH4+8CkUPTQWAHgf0ZB4KuBcl/KImUMtcKFzVmSnmEciFBfMKZ1+SXZDv80OuR52nejcijMtrCE94+wVLgZTfVwIVHxCkb1SnE3bKUsJCYUaQqbTMeTeOB8Sq5p9SmjCUf4dL9R/2lX2dVDqJeNW3sXJQ9RpVTG3DYCotUbIDxP7W98dlV3rQEhcGXeUhcslmbWSJ6/yb92M+zgT X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(426003)(86362001)(26005)(186003)(16526019)(2616005)(36756003)(30864003)(7416002)(336012)(1076003)(316002)(2906002)(110136005)(8676002)(7696005)(508600001)(70586007)(36860700001)(70206006)(966005)(83380400001)(82310400004)(47076005)(356005)(40460700001)(81166007)(5660300002)(8936002)(54906003)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:26.6725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c9e2837-a75a-4d28-83ea-08d9c30db3bb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3655 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org AMD P-State is the AMD CPU performance scaling driver that introduces a new CPU frequency control mechanism on AMD Zen based CPU series in Linux kernel. The new mechanism is based on Collaborative processor performance control (CPPC) which is finer grain frequency management than legacy ACPI hardware P-States. Current AMD CPU platforms are using the ACPI P-states driver to manage CPU frequency and clocks with switching only in 3 P-states. AMD P-State is to replace the ACPI P-states controls, allows a flexible, low-latency interface for the Linux kernel to directly communicate the performance hints to hardware. AMD P-State leverages the Linux kernel governors such as *schedutil*, *ondemand*, etc. to manage the performance hints which are provided by CPPC hardware functionality. The first version for AMD P-State is to support one of the Zen3 processors, and we will support more in future after we verify the hardware and SBIOS functionalities. There are two types of hardware implementations for AMD P-State: one is full MSR support and another is shared memory support. It can use X86_FEATURE_CPPC feature flag to distinguish the different types. Using the new AMD P-State method + kernel governors (*schedutil*, *ondemand*, ...) to manage the frequency update is the most appropriate bridge between AMD Zen based hardware processor and Linux kernel, the processor is able to adjust to the most efficiency frequency according to the kernel scheduler loading. Please check the detailed CPU feature and MSR register description in Processor Programming Reference (PPR) for AMD Family 19h Model 51h, Revision A1 Processors: https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip Signed-off-by: Huang Rui --- drivers/cpufreq/Kconfig.x86 | 17 ++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/amd-pstate.c | 386 +++++++++++++++++++++++++++++++++++ 3 files changed, 404 insertions(+) create mode 100644 drivers/cpufreq/amd-pstate.c diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index 92701a18bdd9..a951768c3ebb 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 @@ -34,6 +34,23 @@ config X86_PCC_CPUFREQ If in doubt, say N. +config X86_AMD_PSTATE + tristate "AMD Processor P-State driver" + depends on X86 + select ACPI_PROCESSOR if ACPI + select ACPI_CPPC_LIB if X86_64 && ACPI + select CPU_FREQ_GOV_SCHEDUTIL if SMP + help + This driver adds a CPUFreq driver which utilizes a fine grain + processor performance frequency control range instead of legacy + performance levels. _CPC needs to be present in the ACPI tables + of the system. + + For details, take a look at: + . + + If in doubt, say N. + config X86_ACPI_CPUFREQ tristate "ACPI Processor P-States driver" depends on ACPI_PROCESSOR diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 48ee5859030c..c8d307010922 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o # speedstep-* is preferred over p4-clockmod. obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o +obj-$(CONFIG_X86_AMD_PSTATE) += amd-pstate.o obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c new file mode 100644 index 000000000000..70b69c660192 --- /dev/null +++ b/drivers/cpufreq/amd-pstate.c @@ -0,0 +1,386 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * amd-pstate.c - AMD Processor P-state Frequency Driver + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Author: Huang Rui + * + * AMD P-State introduces a new CPU performance scaling design for AMD + * processors using the ACPI Collaborative Performance and Power Control (CPPC) + * feature which works with the AMD SMU firmware providing a finer grained + * frequency control range. It is to replace the legacy ACPI P-States control, + * allows a flexible, low-latency interface for the Linux kernel to directly + * communicate the performance hints to hardware. + * + * AMD P-State is supported on recent AMD Zen base CPU series include some of + * Zen2 and Zen3 processors. _CPC needs to be present in the ACPI tables of AMD + * P-State supported system. And there are two types of hardware implementations + * for AMD P-State: 1) Full MSR Solution and 2) Shared Memory Solution. + * X86_FEATURE_CPPC CPU feature flag is used to distinguish the different types. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#define AMD_PSTATE_TRANSITION_LATENCY 0x20000 +#define AMD_PSTATE_TRANSITION_DELAY 500 + +static struct cpufreq_driver amd_pstate_driver; + +/** + * struct amd_cpudata - private CPU data for AMD P-State + * @cpu: CPU number + * @cppc_req_cached: cached performance request hints + * @highest_perf: the maximum performance an individual processor may reach, + * assuming ideal conditions + * @nominal_perf: the maximum sustained performance level of the processor, + * assuming ideal operating conditions + * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power + * savings are achieved + * @lowest_perf: the absolute lowest performance level of the processor + * @max_freq: the frequency that mapped to highest_perf + * @min_freq: the frequency that mapped to lowest_perf + * @nominal_freq: the frequency that mapped to nominal_perf + * @lowest_nonlinear_freq: the frequency that mapped to lowest_nonlinear_perf + * + * The amd_cpudata is key private data for each CPU thread in AMD P-State, and + * represents all the attributes and goals that AMD P-State requests at runtime. + */ +struct amd_cpudata { + int cpu; + + u64 cppc_req_cached; + + u32 highest_perf; + u32 nominal_perf; + u32 lowest_nonlinear_perf; + u32 lowest_perf; + + u32 max_freq; + u32 min_freq; + u32 nominal_freq; + u32 lowest_nonlinear_freq; +}; + +static inline int amd_pstate_enable(bool enable) +{ + return wrmsrl_safe(MSR_AMD_CPPC_ENABLE, enable); +} + +static int amd_pstate_init_perf(struct amd_cpudata *cpudata) +{ + u64 cap1; + + int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, + &cap1); + if (ret) + return ret; + + /* + * TODO: Introduce AMD specific power feature. + * + * CPPC entry doesn't indicate the highest performance in some ASICs. + */ + WRITE_ONCE(cpudata->highest_perf, amd_get_highest_perf()); + + WRITE_ONCE(cpudata->nominal_perf, CAP1_NOMINAL_PERF(cap1)); + WRITE_ONCE(cpudata->lowest_nonlinear_perf, CAP1_LOWNONLIN_PERF(cap1)); + WRITE_ONCE(cpudata->lowest_perf, CAP1_LOWEST_PERF(cap1)); + + return 0; +} + +static void amd_pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, + u32 des_perf, u32 max_perf, bool fast_switch) +{ + if (fast_switch) + wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached)); + else + wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, + READ_ONCE(cpudata->cppc_req_cached)); +} + +static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, + u32 des_perf, u32 max_perf, bool fast_switch) +{ + u64 prev = READ_ONCE(cpudata->cppc_req_cached); + u64 value = prev; + + value &= ~REQ_MIN_PERF(~0L); + value |= REQ_MIN_PERF(min_perf); + + value &= ~REQ_DES_PERF(~0L); + value |= REQ_DES_PERF(des_perf); + + value &= ~REQ_MAX_PERF(~0L); + value |= REQ_MAX_PERF(max_perf); + + if (value == prev) + return; + + WRITE_ONCE(cpudata->cppc_req_cached, value); + + amd_pstate_update_perf(cpudata, min_perf, des_perf, + max_perf, fast_switch); +} + +static int amd_pstate_verify(struct cpufreq_policy_data *policy) +{ + cpufreq_verify_within_cpu_limits(policy); + + return 0; +} + +static int amd_pstate_target(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation) +{ + struct cpufreq_freqs freqs; + struct amd_cpudata *cpudata = policy->driver_data; + unsigned long max_perf, min_perf, des_perf, cap_perf; + + if (!cpudata->max_freq) + return -ENODEV; + + cap_perf = READ_ONCE(cpudata->highest_perf); + min_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); + max_perf = cap_perf; + + freqs.old = policy->cur; + freqs.new = target_freq; + + des_perf = DIV_ROUND_CLOSEST(target_freq * cap_perf, + cpudata->max_freq); + + cpufreq_freq_transition_begin(policy, &freqs); + amd_pstate_update(cpudata, min_perf, des_perf, + max_perf, false); + cpufreq_freq_transition_end(policy, &freqs, false); + + return 0; +} + +static int amd_get_min_freq(struct amd_cpudata *cpudata) +{ + struct cppc_perf_caps cppc_perf; + + int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + + /* Switch to khz */ + return cppc_perf.lowest_freq * 1000; +} + +static int amd_get_max_freq(struct amd_cpudata *cpudata) +{ + struct cppc_perf_caps cppc_perf; + u32 max_perf, max_freq, nominal_freq, nominal_perf; + u64 boost_ratio; + + int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + + nominal_freq = cppc_perf.nominal_freq; + nominal_perf = READ_ONCE(cpudata->nominal_perf); + max_perf = READ_ONCE(cpudata->highest_perf); + + boost_ratio = div_u64(max_perf << SCHED_CAPACITY_SHIFT, + nominal_perf); + + max_freq = nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT; + + /* Switch to khz */ + return max_freq * 1000; +} + +static int amd_get_nominal_freq(struct amd_cpudata *cpudata) +{ + struct cppc_perf_caps cppc_perf; + + int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + + /* Switch to khz */ + return cppc_perf.nominal_freq * 1000; +} + +static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) +{ + struct cppc_perf_caps cppc_perf; + u32 lowest_nonlinear_freq, lowest_nonlinear_perf, + nominal_freq, nominal_perf; + u64 lowest_nonlinear_ratio; + + int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + + nominal_freq = cppc_perf.nominal_freq; + nominal_perf = READ_ONCE(cpudata->nominal_perf); + + lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf; + + lowest_nonlinear_ratio = div_u64(lowest_nonlinear_perf << SCHED_CAPACITY_SHIFT, + nominal_perf); + + lowest_nonlinear_freq = nominal_freq * lowest_nonlinear_ratio >> SCHED_CAPACITY_SHIFT; + + /* Switch to khz */ + return lowest_nonlinear_freq * 1000; +} + +static int amd_pstate_cpu_init(struct cpufreq_policy *policy) +{ + int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; + struct device *dev; + struct amd_cpudata *cpudata; + + dev = get_cpu_device(policy->cpu); + if (!dev) + return -ENODEV; + + cpudata = kzalloc(sizeof(*cpudata), GFP_KERNEL); + if (!cpudata) + return -ENOMEM; + + cpudata->cpu = policy->cpu; + + ret = amd_pstate_init_perf(cpudata); + if (ret) + goto free_cpudata; + + min_freq = amd_get_min_freq(cpudata); + max_freq = amd_get_max_freq(cpudata); + nominal_freq = amd_get_nominal_freq(cpudata); + lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata); + + if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { + dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", + min_freq, max_freq); + ret = -EINVAL; + goto free_cpudata; + } + + policy->cpuinfo.transition_latency = AMD_PSTATE_TRANSITION_LATENCY; + policy->transition_delay_us = AMD_PSTATE_TRANSITION_DELAY; + + policy->min = min_freq; + policy->max = max_freq; + + policy->cpuinfo.min_freq = min_freq; + policy->cpuinfo.max_freq = max_freq; + + /* It will be updated by governor */ + policy->cur = policy->cpuinfo.min_freq; + + /* Initial processor data capability frequencies */ + cpudata->max_freq = max_freq; + cpudata->min_freq = min_freq; + cpudata->nominal_freq = nominal_freq; + cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; + + policy->driver_data = cpudata; + + return 0; + +free_cpudata: + kfree(cpudata); + return ret; +} + +static int amd_pstate_cpu_exit(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + kfree(cpudata); + + return 0; +} + +static struct cpufreq_driver amd_pstate_driver = { + .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, + .verify = amd_pstate_verify, + .target = amd_pstate_target, + .init = amd_pstate_cpu_init, + .exit = amd_pstate_cpu_exit, + .name = "amd-pstate", +}; + +static int __init amd_pstate_init(void) +{ + int ret; + + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + return -ENODEV; + + if (!acpi_cpc_valid()) { + pr_debug("the _CPC object is not present in SBIOS\n"); + return -ENODEV; + } + + /* don't keep reloading if cpufreq_driver exists */ + if (cpufreq_get_current_driver()) + return -EEXIST; + + /* capability check */ + if (!boot_cpu_has(X86_FEATURE_CPPC)) { + pr_debug("AMD CPPC MSR based functionality is not supported\n"); + return -ENODEV; + } + + /* enable amd pstate feature */ + ret = amd_pstate_enable(true); + if (ret) { + pr_err("failed to enable amd-pstate with return %d\n", ret); + return ret; + } + + ret = cpufreq_register_driver(&amd_pstate_driver); + if (ret) + pr_err("failed to register amd_pstate_driver with return %d\n", + ret); + + return ret; +} + +static void __exit amd_pstate_exit(void) +{ + cpufreq_unregister_driver(&amd_pstate_driver); + + amd_pstate_enable(false); +} + +module_init(amd_pstate_init); +module_exit(amd_pstate_exit); + +MODULE_AUTHOR("Huang Rui "); +MODULE_DESCRIPTION("AMD Processor P-state Frequency Driver"); +MODULE_LICENSE("GPL"); From patchwork Sun Dec 19 16:35:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8F82C433F5 for ; Sun, 19 Dec 2021 16:36:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236193AbhLSQgh (ORCPT ); Sun, 19 Dec 2021 11:36:37 -0500 Received: from mail-mw2nam12on2063.outbound.protection.outlook.com ([40.107.244.63]:2848 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236197AbhLSQgg (ORCPT ); Sun, 19 Dec 2021 11:36:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQn81BlBWDxah/8CTaSHCqfERyVwuXi0y8H0KnLswoBPR38T48utWXyf70vYHH6HAfU8TTy9ZtXRhfUzc0GWHOLEJUz6iapvBHCK/l75BLat3bvzORwfRXAOF894trIC4QufYIIA5U/ZUA3CkTdU0DAkmeeRl+sEIMhSTVfxXBH/RG2K5kd0MldT5CWFq3LE8PuiTXwVKyli+ckCmTi0ayo9h9AtK1mzN6bGAiB1Cp11eeA6/9+AZCm5Z36zWiOpQHP24GmOwph/Au1s+b9y9ar0S19BG+hM+59Lrg9Qxs//dJUT1xiPPKFrLpalRNwEJ1Yugj1YvaCg0eArOMX3lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iqUc/o7LeoErK5Nkt2WCgSbKt3z3dA9m6dnRTq96jg8=; b=ob4ubYMySgoFSpffWcbaztZcuSW6qkD4g/Y4rjTnwogm5eh1c4uHZWJKMQmGrHNKBcIy9EWfpSiFk01uCgPgtxAYwDyL5IlGrbElCwwKPEgj/ZGXySFWNSNfa2MpOSO3octBGTN2yjyHCl05Ebb0xgkDMjpZDiBxg3V31kv4F6zxt/o2LVU+4aHOhSI/VVzjmhumWAjaZsurRy2gP2OGNk+Kjcxd7dRSsj6X9Qfe4zJwie7K+gzcFJuz7e5PkwKABYRyVR7mlANbdyqcTVTfAthqTXC2Z751G5GdWQ4kWOSzvCtDxEpQAiRJaHLqJxHyAyeuh8RmMYLxrDKQq7XsPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iqUc/o7LeoErK5Nkt2WCgSbKt3z3dA9m6dnRTq96jg8=; b=5NkqQrkprM/YUqXr5O6GN5foPLB9CblSKxN9Wl2SceYGC/rCEWF6Yl0BkH1O4pUU6ddBOVhEsvPZYAhGUHUmc/jRuVdOBytUisB3nBEMpoIbU5COagKjI7ENzKPDNKRocGa5iCOv/26cxGhlBIDJWoSMBbdOIj2HpQ0TO5Fgf38= Received: from BN9PR03CA0690.namprd03.prod.outlook.com (2603:10b6:408:10e::35) by DM5PR1201MB2475.namprd12.prod.outlook.com (2603:10b6:3:e6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Sun, 19 Dec 2021 16:36:31 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10e:cafe::91) by BN9PR03CA0690.outlook.office365.com (2603:10b6:408:10e::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17 via Frontend Transport; Sun, 19 Dec 2021 16:36:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:31 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:26 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 07/14] cpufreq: amd-pstate: add fast switch function for AMD P-State Date: Mon, 20 Dec 2021 00:35:21 +0800 Message-ID: <20211219163528.1023186-8-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6703db7-2534-42f3-3a55-08d9c30db66f X-MS-TrafficTypeDiagnostic: DM5PR1201MB2475:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wbTyTToy5W+tztiCBGae1Ir7GB3ehL2UBDBUvsOosepxC0DoVtUADsC31xuvYrOMztOpAJbKhKDp0KoeSy6dNEZ54BEBjxvnrbGal8HBQwcvQ0n0p98PuC7RXU+KCIoZWehqvhL38ULWkEmZgA5mOOYUcHWUIE1c4uZY7SA0BdLqyk4+tugFll4aUNqD9IrcYdYd3wH67QlQCkzaEOErrxzpsywPUZ6jB1/z4SPZdCZwc/Sn1XWLnDkE7RhTRJzmfKadKZxu3SISDc9DYKOIalZvd4zMkY0y4WMM4A+bJzNql8ohPotNOLnDHphz+TVu4GWwWqY42T+G1pdauRfjUzA+aScjCCKHzdcMiceStqcIzpt0TksGGHSYCd/O7faKmcxXV+kOFivVW+BC3X+sZImhM+17ToCoCfn26hGT1LYFL5h+JiWtSiwNFd1Q9T9aUoM7hVQFHJxBnkJuxfd56sxpzRusv3x54M8tdXBgBOe6ajEzg4yhTTqf0L6fIm+wJ6GPUvg56RTbK8QM48v57jTLY0MPODBNjYyKoXnipOTxw4y6h9nTlbH6pL2ZUQ4kw8J5aZN0O5uicApwZQpdDA9fYycRaB2fdqYikdXeuWF1FbbtkE/tawph4d3i4RF6vx5Amc0US8S38IED9GzC7F7MRD6kTQ1uVH5c/Eozyg2S5wdqP3mKt7FLQUnmVe6LTI10zPnLFS+qqHG9TaWcr42dUBcJs5/WtTM7zHhol5z8HJlpfOUTcJLFvwObETcLHbMKVRojKo06xG3tMHFUeaBTZNqhA8mvf7dlrWDP6pg= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(47076005)(86362001)(36860700001)(16526019)(70206006)(1076003)(36756003)(82310400004)(2906002)(7696005)(2616005)(186003)(26005)(7416002)(83380400001)(6666004)(508600001)(426003)(54906003)(5660300002)(316002)(8936002)(70586007)(336012)(356005)(81166007)(110136005)(4326008)(8676002)(40460700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:31.1945 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6703db7-2534-42f3-3a55-08d9c30db66f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB2475 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce the fast switch function for AMD P-State on the AMD processors which support the full MSR register control. It's able to decrease the latency on interrupt context. Signed-off-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 70b69c660192..14e8a566ea17 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -183,6 +183,39 @@ static int amd_pstate_target(struct cpufreq_policy *policy, return 0; } +static void amd_pstate_adjust_perf(unsigned int cpu, + unsigned long _min_perf, + unsigned long target_perf, + unsigned long capacity) +{ + unsigned long max_perf, min_perf, des_perf, + cap_perf, lowest_nonlinear_perf; + struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + struct amd_cpudata *cpudata = policy->driver_data; + + cap_perf = READ_ONCE(cpudata->highest_perf); + lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); + + des_perf = cap_perf; + if (target_perf < capacity) + des_perf = DIV_ROUND_UP(cap_perf * target_perf, capacity); + + min_perf = READ_ONCE(cpudata->highest_perf); + if (_min_perf < capacity) + min_perf = DIV_ROUND_UP(cap_perf * _min_perf, capacity); + + if (min_perf < lowest_nonlinear_perf) + min_perf = lowest_nonlinear_perf; + + max_perf = cap_perf; + if (max_perf < min_perf) + max_perf = min_perf; + + des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); + + amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true); +} + static int amd_get_min_freq(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; @@ -299,6 +332,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) /* It will be updated by governor */ policy->cur = policy->cpuinfo.min_freq; + policy->fast_switch_possible = true; + /* Initial processor data capability frequencies */ cpudata->max_freq = max_freq; cpudata->min_freq = min_freq; @@ -329,6 +364,7 @@ static struct cpufreq_driver amd_pstate_driver = { .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify = amd_pstate_verify, .target = amd_pstate_target, + .adjust_perf = amd_pstate_adjust_perf, .init = amd_pstate_cpu_init, .exit = amd_pstate_cpu_exit, .name = "amd-pstate", From patchwork Sun Dec 19 16:35:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA714C433EF for ; Sun, 19 Dec 2021 16:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236203AbhLSQgq (ORCPT ); Sun, 19 Dec 2021 11:36:46 -0500 Received: from mail-dm6nam10on2088.outbound.protection.outlook.com ([40.107.93.88]:62273 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236217AbhLSQgo (ORCPT ); Sun, 19 Dec 2021 11:36:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YvrmWGL6RYdPcGXL/8nFjMEEokhMWfXD1LNMXMT7HoKHVb1BUgk9qKW1O5r3903l76G72SIPh3V+KxETBYwG0p6yRGG/mWRpBuXI8z7a6LpMdl5tet6fIMtbZO2IZBuUD4sw/XcgUYXj8b4wojBUHgx31srnY7PSg3KJ7SSL2001szJH2UUoYZQfxL0ol2sVaWxJjGdh21SpCok/NwZBaqdmiNLk77vENorIusyj9J81Nqm5WFVihlkBuXnkKTUsKX11g5vAHX2+Plaa63cZP6UezBqCdKegRnscccUH2joaG++GZ4VvruKnWmn4pb4fazc9bTY9URCWSPUjOxKZsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W4kofuvLXlSSIG90eoO+W7aG/JHiKFyGYrrKhIaJD2w=; b=ce7/yb7oNvx4eg4GNj/5hIFDSU0b9sshAqLBiId1i69Z45DdDTrvbTa67efgdyFsCYM4n4yCyv6H/525TUoYP2SwvHJ3LxfiEWJUAgiPTHkgSsKEGuFYxvJsqc1fgXDMaeVDDNcBofUVL5ijcApvT9xPpdw3Sw9IVzP2ibzcwYUczBfnTP57dt+e423pI05KeNIkkFomHG32aCVpoltV4ztPq+mJHAxIlSCjEG/UgLPgZdW5lWivmDmUdH30zL7fN0C0ixfhXHVMmWjzbXzDiVHyaKy8sK0gGNDR2D1aNoEsPZshHqAq/Ewu7MivJmHax/gj2NSUx8XWKsme6EmVjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W4kofuvLXlSSIG90eoO+W7aG/JHiKFyGYrrKhIaJD2w=; b=1H64Nhljp6UPx5DBH3dFLFKrp0wPNZ2jPgGcL67Bple8ZeOZO+3Q8osiPioyMefvtiUce+/eXGZ0xMmSt8LZcDWabJO4mSLMCXyvihiyBe+ZTaS4ZBF8qfnvyvw0dusWizgMMKjLOeqNqnXoiYnXCwG+4Pp5f0dRGsoJAK65UrU= Received: from BN9PR03CA0578.namprd03.prod.outlook.com (2603:10b6:408:10d::13) by CH2PR12MB5545.namprd12.prod.outlook.com (2603:10b6:610:67::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sun, 19 Dec 2021 16:36:37 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::fc) by BN9PR03CA0578.outlook.office365.com (2603:10b6:408:10d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17 via Frontend Transport; Sun, 19 Dec 2021 16:36:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:36 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:31 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 08/14] cpufreq: amd-pstate: introduce the support for the processors with shared memory solution Date: Mon, 20 Dec 2021 00:35:22 +0800 Message-ID: <20211219163528.1023186-9-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9dd5166d-f082-4bee-5245-08d9c30db9b6 X-MS-TrafficTypeDiagnostic: CH2PR12MB5545:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bwddfgNNJBxhMKEh6CFXH6luTlsXHYL89g+RzQ0a2lMVdayQ85GXHbsa+tdi2NDJYEjCXDyF2Q2W2fc37beAApSqTxNWxAaQcvRYHVw3AJDEufODFGHnmM3k1oplXvxdnPEbAvktRBU5TfSKym3S04aVajwKpk/J50PvGIDRQwpfxuw//KYv0MDWyyfGpvUjnYJql6xaLvu6FasZpCl+RJkfZYM+wLXbX6V7b1IYF9mr/55M3cmKCmDTGJXrrHAVZgaiCnFtG08wLrZrAkDAAWWQRqBAJXKbo5ZB9CCpapJUpPyUabykaUqRnwaugnIEHg608qYI4PvQ7bZKQHVg44LhgzyK9YeozVPgv1+Ph9Qaa0bCFkE8jGMrbG1L8NLpSuuzAOOhb7mhxVRPRkw5Kp1nkEMyO1NgmGOF+2HbF0Gyprk40GbtmHFmFqoUSAHaCsY2gkBKZEmmcqHDkW2ZUMrCiEO6JsG7kK3QYFzqwByHTYG6jvyKlIVgzHEwQMZgHXI8c/JhgZWXsVipfB2JVqQq+T1JLmdvjIHopQmc07unB8I1ebtZRI6Gp96j7JAH2WbP5nshWScMPUzLxey8SBMsktj/wY6w0C/ZVnPr9J2ULgfjh49Pi4h5Rzx0PbmEHSb9Ne2kt69szD0fVk2upavm38lDy9NPyvms5vM2k2qxMo7Zl2O847pOLKr7KdSeKkxtKJfzJ4j62+6D4sQIVNGNOobpOAJx3/2HaSAZmGKa/EclEFEU9ZuXtiu9fl7wDz6JKjoczy5xH0LPHgexkmTnLgeYRBgTEoMVwPWzC08= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(426003)(6666004)(70586007)(336012)(2616005)(1076003)(70206006)(47076005)(36860700001)(4326008)(7696005)(5660300002)(16526019)(356005)(81166007)(83380400001)(316002)(8936002)(82310400004)(86362001)(40460700001)(2906002)(110136005)(8676002)(54906003)(26005)(186003)(508600001)(36756003)(7416002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:36.6891 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9dd5166d-f082-4bee-5245-08d9c30db9b6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5545 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In some of Zen2 and Zen3 based processors, they are using the shared memory that exposed from ACPI SBIOS. In this kind of the processors, there is no MSR support, so we add acpi cppc function as the backend for them. It is using a module param (shared_mem) to enable related processors manually. We will enable this by default once we address performance issue on this solution. Signed-off-by: Jinzhou Su Signed-off-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 105 ++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 14e8a566ea17..25d4f0563a84 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -48,6 +48,20 @@ #define AMD_PSTATE_TRANSITION_LATENCY 0x20000 #define AMD_PSTATE_TRANSITION_DELAY 500 +/* + * TODO: We need more time to fine tune processors with shared memory solution + * with community together. + * + * There are some performance drops on the CPU benchmarks which reports from + * Suse. We are co-working with them to fine tune the shared memory solution. So + * we disable it by default to go acpi-cpufreq on these processors and add a + * module parameter to be able to enable it manually for debugging. + */ +static bool shared_mem = false; +module_param(shared_mem, bool, 0444); +MODULE_PARM_DESC(shared_mem, + "enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)"); + static struct cpufreq_driver amd_pstate_driver; /** @@ -85,12 +99,32 @@ struct amd_cpudata { u32 lowest_nonlinear_freq; }; -static inline int amd_pstate_enable(bool enable) +static inline int pstate_enable(bool enable) { return wrmsrl_safe(MSR_AMD_CPPC_ENABLE, enable); } -static int amd_pstate_init_perf(struct amd_cpudata *cpudata) +static int cppc_enable(bool enable) +{ + int cpu, ret = 0; + + for_each_present_cpu(cpu) { + ret = cppc_set_enable(cpu, enable); + if (ret) + return ret; + } + + return ret; +} + +DEFINE_STATIC_CALL(amd_pstate_enable, pstate_enable); + +static inline int amd_pstate_enable(bool enable) +{ + return static_call(amd_pstate_enable)(enable); +} + +static int pstate_init_perf(struct amd_cpudata *cpudata) { u64 cap1; @@ -113,8 +147,33 @@ static int amd_pstate_init_perf(struct amd_cpudata *cpudata) return 0; } -static void amd_pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, - u32 des_perf, u32 max_perf, bool fast_switch) +static int cppc_init_perf(struct amd_cpudata *cpudata) +{ + struct cppc_perf_caps cppc_perf; + + int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + + WRITE_ONCE(cpudata->highest_perf, amd_get_highest_perf()); + + WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf); + WRITE_ONCE(cpudata->lowest_nonlinear_perf, + cppc_perf.lowest_nonlinear_perf); + WRITE_ONCE(cpudata->lowest_perf, cppc_perf.lowest_perf); + + return 0; +} + +DEFINE_STATIC_CALL(amd_pstate_init_perf, pstate_init_perf); + +static inline int amd_pstate_init_perf(struct amd_cpudata *cpudata) +{ + return static_call(amd_pstate_init_perf)(cpudata); +} + +static void pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, + u32 des_perf, u32 max_perf, bool fast_switch) { if (fast_switch) wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached)); @@ -123,6 +182,29 @@ static void amd_pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, READ_ONCE(cpudata->cppc_req_cached)); } +static void cppc_update_perf(struct amd_cpudata *cpudata, + u32 min_perf, u32 des_perf, + u32 max_perf, bool fast_switch) +{ + struct cppc_perf_ctrls perf_ctrls; + + perf_ctrls.max_perf = max_perf; + perf_ctrls.min_perf = min_perf; + perf_ctrls.desired_perf = des_perf; + + cppc_set_perf(cpudata->cpu, &perf_ctrls); +} + +DEFINE_STATIC_CALL(amd_pstate_update_perf, pstate_update_perf); + +static inline void amd_pstate_update_perf(struct amd_cpudata *cpudata, + u32 min_perf, u32 des_perf, + u32 max_perf, bool fast_switch) +{ + static_call(amd_pstate_update_perf)(cpudata, min_perf, des_perf, + max_perf, fast_switch); +} + static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch) { @@ -332,7 +414,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) /* It will be updated by governor */ policy->cur = policy->cpuinfo.min_freq; - policy->fast_switch_possible = true; + if (boot_cpu_has(X86_FEATURE_CPPC)) + policy->fast_switch_possible = true; /* Initial processor data capability frequencies */ cpudata->max_freq = max_freq; @@ -364,7 +447,6 @@ static struct cpufreq_driver amd_pstate_driver = { .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify = amd_pstate_verify, .target = amd_pstate_target, - .adjust_perf = amd_pstate_adjust_perf, .init = amd_pstate_cpu_init, .exit = amd_pstate_cpu_exit, .name = "amd-pstate", @@ -387,8 +469,15 @@ static int __init amd_pstate_init(void) return -EEXIST; /* capability check */ - if (!boot_cpu_has(X86_FEATURE_CPPC)) { - pr_debug("AMD CPPC MSR based functionality is not supported\n"); + if (boot_cpu_has(X86_FEATURE_CPPC)) { + pr_debug("AMD CPPC MSR based functionality is supported\n"); + amd_pstate_driver.adjust_perf = amd_pstate_adjust_perf; + } else if (shared_mem) { + static_call_update(amd_pstate_enable, cppc_enable); + static_call_update(amd_pstate_init_perf, cppc_init_perf); + static_call_update(amd_pstate_update_perf, cppc_update_perf); + } else { + pr_info("This processor supports shared memory solution, you can enable it with amd_pstate.shared_mem=1\n"); return -ENODEV; } From patchwork Sun Dec 19 16:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38BE1C433F5 for ; Sun, 19 Dec 2021 16:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236202AbhLSQgq (ORCPT ); Sun, 19 Dec 2021 11:36:46 -0500 Received: from mail-dm6nam12on2048.outbound.protection.outlook.com ([40.107.243.48]:33408 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233242AbhLSQgn (ORCPT ); Sun, 19 Dec 2021 11:36:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bVSs8ysJ1sOAy4RkgoAopePp9mJK5HRnyObFAN5qpT/bWcF1UT7krK2ASyHTJq9Z6f6NDWiYEysdbHwKR23OZQ3wByMG9DofW5JuYMambCk94jUIkiypRRuWswgouc3U0ueUoC5Z6m3e/7JNzO6EQaykUhF+RzYJPNADyk1GSch27sNd9Bdn9M/R+JDmAtYBpSaiRNgHgbPg+Y3fGFhuVBXCL1/GoGM1p1jDHVV0uQB1S8gxd7lWO+8xjhL0RvHm8Y8bHH5/HhiezEfljtaMLoahdKy6hrWhzEeQjl8oub6G84z9D8UPINfxVr3gim5mlLE01zjtlImOOD2PSumJ1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l9tzQyaRzYBPxFz5y4SUrWigvn/BifH9eIh6YGHrdc4=; b=hEr2APLTSht3NwFfQn57FRbGyx8VRCu9NLYGC421PODqu4b9k2tDQTVV1Fny2sHlPWhoyYyRv9vBfTKEnNp8nopdrXgRazfm6eYCUrkr0AQVUlkQmPAHPzPnbiXq2OD6svHdtVTYAnokczNCqFt3qVvDrBE0EenOAnVoGEmNYiXEKs8iePl7E5SvKoTm0sGLeO7Jvx1YWoGcC1EDYjEKVlvwty2V9rvtl5x3z84RC2BlKHFY14855XLztc71cOwPs0oUmaMgxTNPa/ubbpoPR5h0mO5G+UeEZ2+Xdr66p9MA5EEm0+Ej+Ls4FLF/fk24OCYMd1vUAIZQVukXRyYtkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l9tzQyaRzYBPxFz5y4SUrWigvn/BifH9eIh6YGHrdc4=; b=sOjmd11vS8H64RB4iBJMSNJo0umziOtx7FlCIXl9FhhlJx0NGkIhMTiUw+YvycSbtb2d24UG7LZng+zyGPZkuTazLScOMW2Och+WgjjwJHQ27mFb2vVOHQCM59Hgfef3lvoXWPivQqPi3jmhKVCX/iSORKCPRytPgI77IEVAlTc= Received: from BN6PR13CA0005.namprd13.prod.outlook.com (2603:10b6:404:10a::15) by SA0PR12MB4559.namprd12.prod.outlook.com (2603:10b6:806:9e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.15; Sun, 19 Dec 2021 16:36:40 +0000 Received: from BN8NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:404:10a:cafe::ef) by BN6PR13CA0005.outlook.office365.com (2603:10b6:404:10a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.10 via Frontend Transport; Sun, 19 Dec 2021 16:36:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT008.mail.protection.outlook.com (10.13.177.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:40 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:35 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 09/14] cpufreq: amd-pstate: add trace for AMD P-State module Date: Mon, 20 Dec 2021 00:35:23 +0800 Message-ID: <20211219163528.1023186-10-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 064c7fe3-2a5f-43f8-67f9-08d9c30dbc21 X-MS-TrafficTypeDiagnostic: SA0PR12MB4559:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:635; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zxHmHpc0v/uafJHd8PqGAnHC5ygmGXl9hJMj6DuJItb2OkwwJtLt++Wm26WC57IVoeF3IdFs5f8CeyhnmiLJ5szXqjfWNLyqUrlEKjdfa3nA9icUIjmnHh34FME1rEPxqmBR80mK1pU2BmdbzTPMHeZAwjXK5cfpUPYTXj/bVl2Kq+B2CJIVbPVcYbvsTdIoSPeqLVpc7/W12kNwXUGAVH/A65agBY9ML0RDK9X0zhCBkxATFN6Ovu3yGiyvt/ARLOXRDwtM6jRS0DcWiPTEco3zMvrMl6zcSG5juLyYW5vPHjGB1/A9Do8aac6U9ctWw3b4KWYOXj+qHLFpwIGeszEqIQN6+Fj3M8Ubtl2PGhqlaTzyRUFG7Z8NKn4+b2RFLAXIEhU/nezoikImMlDPS7r0PebYDhMx0PazGM/2WMNWDcHSziKvsloputVBfJfY6OHZEMs2MMH1GJ9EJKkGqCOxju344QDNqtBPtrRnul4uWgQzfrwyjR1bPuKuyseTuQ9GCkYEnq+e/TrY3LqwMbVRohZHp4hdFMMHKPxO6UVPIT9gGHO9yThA0ZKJOvIAvhL5x6L/BO7TZEW1qwWCTelXLLjxWVP/lMjQ0428saHmXoHA2Y6Kd45h61iKpoA2v0rQyh/GrF0LGvUbL1FxHBTnlofNBOLlggQI8MXNG0YC9hrT6HbpIVVWJMWK9i+aCo88aTNozma9hJgntYBfyyemKyDS5egFk9DVBx7OWtL3d1y2dX5mE47rznUH2x0CBHTuS240cETh8XSP0g5wIIAKHHc+VgW1UUzX11FeipQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(4326008)(110136005)(186003)(8676002)(2616005)(70206006)(8936002)(16526019)(5660300002)(47076005)(54906003)(316002)(356005)(26005)(86362001)(6666004)(70586007)(7696005)(82310400004)(81166007)(36756003)(426003)(508600001)(36860700001)(83380400001)(40460700001)(2906002)(336012)(1076003)(7416002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:40.7488 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 064c7fe3-2a5f-43f8-67f9-08d9c30dbc21 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4559 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add trace event to monitor the performance value changes which is controlled by cpu governors. Signed-off-by: Huang Rui --- drivers/cpufreq/Makefile | 6 ++- drivers/cpufreq/amd-pstate-trace.c | 2 + drivers/cpufreq/amd-pstate-trace.h | 77 ++++++++++++++++++++++++++++++ drivers/cpufreq/amd-pstate.c | 4 ++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 drivers/cpufreq/amd-pstate-trace.c create mode 100644 drivers/cpufreq/amd-pstate-trace.h diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index c8d307010922..285de70af877 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -17,6 +17,10 @@ obj-$(CONFIG_CPU_FREQ_GOV_ATTR_SET) += cpufreq_governor_attr_set.o obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o +# Traces +CFLAGS_amd-pstate-trace.o := -I$(src) +amd_pstate-y := amd-pstate.o amd-pstate-trace.o + ################################################################################## # x86 drivers. # Link order matters. K8 is preferred to ACPI because of firmware bugs in early @@ -25,7 +29,7 @@ obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o # speedstep-* is preferred over p4-clockmod. obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o -obj-$(CONFIG_X86_AMD_PSTATE) += amd-pstate.o +obj-$(CONFIG_X86_AMD_PSTATE) += amd_pstate.o obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o diff --git a/drivers/cpufreq/amd-pstate-trace.c b/drivers/cpufreq/amd-pstate-trace.c new file mode 100644 index 000000000000..891b696dcd69 --- /dev/null +++ b/drivers/cpufreq/amd-pstate-trace.c @@ -0,0 +1,2 @@ +#define CREATE_TRACE_POINTS +#include "amd-pstate-trace.h" diff --git a/drivers/cpufreq/amd-pstate-trace.h b/drivers/cpufreq/amd-pstate-trace.h new file mode 100644 index 000000000000..647505957d4f --- /dev/null +++ b/drivers/cpufreq/amd-pstate-trace.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * amd-pstate-trace.h - AMD Processor P-state Frequency Driver Tracer + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Author: Huang Rui + */ + +#if !defined(_AMD_PSTATE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _AMD_PSTATE_TRACE_H + +#include +#include +#include + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM amd_cpu + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE amd-pstate-trace + +#define TPS(x) tracepoint_string(x) + +TRACE_EVENT(amd_pstate_perf, + + TP_PROTO(unsigned long min_perf, + unsigned long target_perf, + unsigned long capacity, + unsigned int cpu_id, + bool changed, + bool fast_switch + ), + + TP_ARGS(min_perf, + target_perf, + capacity, + cpu_id, + changed, + fast_switch + ), + + TP_STRUCT__entry( + __field(unsigned long, min_perf) + __field(unsigned long, target_perf) + __field(unsigned long, capacity) + __field(unsigned int, cpu_id) + __field(bool, changed) + __field(bool, fast_switch) + ), + + TP_fast_assign( + __entry->min_perf = min_perf; + __entry->target_perf = target_perf; + __entry->capacity = capacity; + __entry->cpu_id = cpu_id; + __entry->changed = changed; + __entry->fast_switch = fast_switch; + ), + + TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu cpu_id=%u changed=%s fast_switch=%s", + (unsigned long)__entry->min_perf, + (unsigned long)__entry->target_perf, + (unsigned long)__entry->capacity, + (unsigned int)__entry->cpu_id, + (__entry->changed) ? "true" : "false", + (__entry->fast_switch) ? "true" : "false" + ) +); + +#endif /* _AMD_PSTATE_TRACE_H */ + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . + +#include diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 25d4f0563a84..fa2268df4f2e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -44,6 +44,7 @@ #include #include #include +#include "amd-pstate-trace.h" #define AMD_PSTATE_TRANSITION_LATENCY 0x20000 #define AMD_PSTATE_TRANSITION_DELAY 500 @@ -220,6 +221,9 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, value &= ~REQ_MAX_PERF(~0L); value |= REQ_MAX_PERF(max_perf); + trace_amd_pstate_perf(min_perf, des_perf, max_perf, + cpudata->cpu, (value != prev), fast_switch); + if (value == prev) return; From patchwork Sun Dec 19 16:35:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AF23C433EF for ; Sun, 19 Dec 2021 16:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236197AbhLSQgu (ORCPT ); Sun, 19 Dec 2021 11:36:50 -0500 Received: from mail-dm6nam11on2069.outbound.protection.outlook.com ([40.107.223.69]:57120 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233242AbhLSQgt (ORCPT ); Sun, 19 Dec 2021 11:36:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TmYVM6VJq8isMa/D8csUUwJnjZXdHVzx67HO2L0FShYhaTxABAnIcTrf9gaaxaJekigLLTcvWSI7bZMsnqUfpbFYSMqD9LZnltFEr6Vge8mnOl8ezkxFdnGp6ouwzNnjv4WaobKrfna5X6Chu0DH0itUMedpePJQLQzCpmkHZtNUjQVRJz5ZfAg2vy7ROrNJTh7tXeUrYvlhDqXI9dfgBQs/T2M1tYx5UnoXQVgeJ1vB5XEA5TqbAnbvYJ8lepwU8yD9TnqUIJ4+20xCyL81nNGDC3C2fwbij9cj7BHm8YjmCWdvFOEDvmeqjnepoujHvy9Od4dtnY5ZIrrlTVn/kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wsweGZd59ASmysXDcH4gaST+YsTEnJ8wdyuLHN4Veq8=; b=brW0DKmdt1TGMuKepqWVUM9xQ9iMPCYWDJUz0SWnbFx2m0NEL8Wq3eMJhMb2/64IFZUST29+U9ipSQB5NxbHrwDpyL7ZD5bom/IY+YorQZxCpvhAD+JjDPVGpf4dLnOuQWfqkWyGDh/voQxbVGu7+ReqH21Jzu8XHrGX7gB/94/md1lxdpnQv4YuHr+X5Qpb525hzaa/tZ+ZgeW1GaBnILlLqXxAg0zbCvQV2/i+XScrN8EWBFTYUk1IfZaOdilawh1oIoWFiF4DCYUKFH5gRx+68WAiso7tn1j1PfHEG5Ass0axbp/ISx+izXJ1dc2nZi8agZvhbzpiSqW5H216Vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wsweGZd59ASmysXDcH4gaST+YsTEnJ8wdyuLHN4Veq8=; b=bxn6PUDLXcGAIWR4zUVmp2UblU5B9+hdhiByHhk+mZWjuQHLuJ8dB0XGE2ufZAK6fF6FJftN4c9LNZiSLle62sJPTWa5t70aQ/iLa+gPGfP9abxZ5coH1GYnpPxtihJD0bZxXdr7uVkInbCVRtkSuniA7VtqRWaxEhnmRgR+bHY= Received: from BN9PR03CA0358.namprd03.prod.outlook.com (2603:10b6:408:f6::33) by SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Sun, 19 Dec 2021 16:36:45 +0000 Received: from BN8NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::5a) by BN9PR03CA0358.outlook.office365.com (2603:10b6:408:f6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT048.mail.protection.outlook.com (10.13.177.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:45 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:40 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 10/14] cpufreq: amd-pstate: add boost mode support for AMD P-State Date: Mon, 20 Dec 2021 00:35:24 +0800 Message-ID: <20211219163528.1023186-11-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 648451ef-2824-41d8-1841-08d9c30dbedd X-MS-TrafficTypeDiagnostic: SA0PR12MB4430:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /iGLzrXs8RGAhvfROp2swjGp9lwWf3IcM8JPSvVdocK0mUnvVQbftWPhxpLIf0a/prbTX7GrNC7GU1zzOuTBAc6WonNmM+bBGJyyg2VZRD8IUrvgrmORmC60T3Gw8+Jq9GaNBg9b8QJVK8BLY88p5U4jM8eBBcbG5hfZ/O5DSKBjuugdz8pfSH9/C1s7b6X2IIwIC5wwMdqIpNVVcV9i7Yf7mAze010GQ2kVY/8Htt3I87AtGr3ZTKV+uBOfCa+pxCoVxTVwiowfzeTt05j1WhC95Ndgy2V5mu6tgLqVdibnt6pGsvc1pi5s5vyeW8EhXrra5QspmNc725rnopiEtNaFLopkU1j4c81oPzPenDLA/eEFpKCkGw7rY3rGGl5hFFTjJaAN/LfCm1luombTE+fkkewk/yFSe/HhazOoZdUmTJgI4AuTBRj9wt1wXc6dULAzbqiohjysHrOLdA9npPeao+ohFikQwzkRG2vQmYFoT3J0bcTGN8DEWDtY/TXsa8ejyecqeFr+EgO8wOWRo7QNbswDM0xNSK9m172vM5uVunotvkGYOlIBedNW/gS/DNiyDIHjSFOdkimqFJAfr/L61FuVhYI/H8Mcwnie4OE/EyJ1fO2d2S+JoJONKudhtj/GBAEc8hWlB/taTjPnDTZ3FC+3VaNcFl/LzQ4sZrLh8peGiZRRl2hFBKmLwF8XLh5Y9OoLxZPKyyXg+hDqgkG71JqpYOQu0RrGVIlh8ExnzWuO6BFxkOJoIVXLFRpb33GqVRurGY8/7R5r+eH5obAHcAYJc+mpiLUqj1rtLLQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(40460700001)(81166007)(316002)(82310400004)(6666004)(36860700001)(8936002)(2906002)(83380400001)(86362001)(47076005)(8676002)(356005)(2616005)(426003)(70586007)(70206006)(7416002)(336012)(36756003)(1076003)(110136005)(4326008)(16526019)(54906003)(26005)(5660300002)(508600001)(186003)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:45.3353 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 648451ef-2824-41d8-1841-08d9c30dbedd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4430 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org If the sbios supports the boost mode of AMD P-State, let's switch to boost enabled by default. Signed-off-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 69 ++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index fa2268df4f2e..4ff4fb7c3de6 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -87,6 +87,7 @@ static struct cpufreq_driver amd_pstate_driver; struct amd_cpudata { int cpu; + struct freq_qos_request req[2]; u64 cppc_req_cached; u32 highest_perf; @@ -98,6 +99,8 @@ struct amd_cpudata { u32 min_freq; u32 nominal_freq; u32 lowest_nonlinear_freq; + + bool boost_supported; }; static inline int pstate_enable(bool enable) @@ -374,6 +377,45 @@ static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) return lowest_nonlinear_freq * 1000; } +static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) +{ + struct amd_cpudata *cpudata = policy->driver_data; + int ret; + + if (!cpudata->boost_supported) { + pr_err("Boost mode is not supported by this processor or SBIOS\n"); + return -EINVAL; + } + + if (state) + policy->cpuinfo.max_freq = cpudata->max_freq; + else + policy->cpuinfo.max_freq = cpudata->nominal_freq; + + policy->max = policy->cpuinfo.max_freq; + + ret = freq_qos_update_request(&cpudata->req[1], + policy->cpuinfo.max_freq); + if (ret < 0) + return ret; + + return 0; +} + +static void amd_pstate_boost_init(struct amd_cpudata *cpudata) +{ + u32 highest_perf, nominal_perf; + + highest_perf = READ_ONCE(cpudata->highest_perf); + nominal_perf = READ_ONCE(cpudata->nominal_perf); + + if (highest_perf <= nominal_perf) + return; + + cpudata->boost_supported = true; + amd_pstate_driver.boost_enabled = true; +} + static int amd_pstate_cpu_init(struct cpufreq_policy *policy) { int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; @@ -392,7 +434,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) ret = amd_pstate_init_perf(cpudata); if (ret) - goto free_cpudata; + goto free_cpudata1; min_freq = amd_get_min_freq(cpudata); max_freq = amd_get_max_freq(cpudata); @@ -403,7 +445,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", min_freq, max_freq); ret = -EINVAL; - goto free_cpudata; + goto free_cpudata1; } policy->cpuinfo.transition_latency = AMD_PSTATE_TRANSITION_LATENCY; @@ -421,6 +463,20 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) if (boot_cpu_has(X86_FEATURE_CPPC)) policy->fast_switch_possible = true; + ret = freq_qos_add_request(&policy->constraints, &cpudata->req[0], + FREQ_QOS_MIN, policy->cpuinfo.min_freq); + if (ret < 0) { + dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); + goto free_cpudata1; + } + + ret = freq_qos_add_request(&policy->constraints, &cpudata->req[1], + FREQ_QOS_MAX, policy->cpuinfo.max_freq); + if (ret < 0) { + dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret); + goto free_cpudata2; + } + /* Initial processor data capability frequencies */ cpudata->max_freq = max_freq; cpudata->min_freq = min_freq; @@ -429,9 +485,13 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; + amd_pstate_boost_init(cpudata); + return 0; -free_cpudata: +free_cpudata2: + freq_qos_remove_request(&cpudata->req[0]); +free_cpudata1: kfree(cpudata); return ret; } @@ -442,6 +502,8 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy) cpudata = policy->driver_data; + freq_qos_remove_request(&cpudata->req[1]); + freq_qos_remove_request(&cpudata->req[0]); kfree(cpudata); return 0; @@ -453,6 +515,7 @@ static struct cpufreq_driver amd_pstate_driver = { .target = amd_pstate_target, .init = amd_pstate_cpu_init, .exit = amd_pstate_cpu_exit, + .set_boost = amd_pstate_set_boost, .name = "amd-pstate", }; From patchwork Sun Dec 19 16:35:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 208CCC433EF for ; Sun, 19 Dec 2021 16:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236243AbhLSQhA (ORCPT ); Sun, 19 Dec 2021 11:37:00 -0500 Received: from mail-bn7nam10on2067.outbound.protection.outlook.com ([40.107.92.67]:17377 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236217AbhLSQhA (ORCPT ); Sun, 19 Dec 2021 11:37:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lP7MCgGI0488lShJrmfgZcVhVRqP0p9WIxFlveWcn5uUV+aMxNzOzoynDRw3eJ/xRzsVJeXk3u1DnHBViPWO5gQKviVOXHzRn9PsuGSwj/SZkKyCh81gsEaNLdpYm6G/3SEpVcGyeVPhC9xKsEPDJUEJxMSqrkq+dHt3JS64a7tdB3osL669pHJYqxMyE2VrNCsXvzipJIzLP1Tuq9ICFcsp5a/J1hwzdzgKDn63FNcCaqpEmF+KOyUSKeR0EjNaNmsa14mzbV2OVH5A99KrsfC50kewTQ5h0g46uH/LI3DJEeF/O1tlpGQA7vsd2AqDuh4AjHk/1Fglu2wY+a4zHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WCADWS0Do5yGHmksgD+xJ4LH7aHFJHM649Y32G0bczY=; b=a1oS0X+pPExBN1rR7WsumrMgTNwf1Ni0PT1GyIgSd1W5/k3qUcycUSc0btHFvT260FmXSdacuGJmkcYoRE/tbRjVch/Y6VLSlcXKiHB9PJBZJu77j+7SDJph7QFiv60KIpw4ORQmzFzSpyp/ZresgmWAkWiZYLK3ZofmgRTNwiU2kL5Blnf//lSjMFnm7tzYxwv/KIhmaxnYcwe0JtByL4vu7Z8Idfl1SArN0XpEEok49jxeY/E7TKmQDsRh5kZ5Lb9DkQs+ZPwu73xpBx6fjwtbjFoY9SNWMqw6Orxsoqwg+qbP3S+ZrqNkVTABGcCG0N+io6UHcYn0hG7jMN+txA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WCADWS0Do5yGHmksgD+xJ4LH7aHFJHM649Y32G0bczY=; b=hndx2ya6fSWiJDgqh3rPU2XDZjUj3D9KLzB4QGXNkaOG7S2O9LIYX9+ZbkUdj+K/c9oWTn06QSw718W6H4PwVIp+rnEovfDLDVq8pIQKER5qi6Xhdy0wlibSmJHsZDS7bnDZv0jK/dv09HFfki0S7nuvYtiFlhUrB7rV2gKZDSo= Received: from BN6PR17CA0060.namprd17.prod.outlook.com (2603:10b6:405:75::49) by PH0PR12MB5498.namprd12.prod.outlook.com (2603:10b6:510:d6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.20; Sun, 19 Dec 2021 16:36:57 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::e) by BN6PR17CA0060.outlook.office365.com (2603:10b6:405:75::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.15 via Frontend Transport; Sun, 19 Dec 2021 16:36:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:57 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:45 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 11/14] cpufreq: amd-pstate: add AMD P-State frequencies attributes Date: Mon, 20 Dec 2021 00:35:25 +0800 Message-ID: <20211219163528.1023186-12-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7bacd5a4-510e-4e53-92df-08d9c30dc5fa X-MS-TrafficTypeDiagnostic: PH0PR12MB5498:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IGuAdvywyZ6NV4EuBWIYR2pNOkn/WaKxiMu3gEef96KOO7SaLp232OdORdnV1ROIrhdyyC+rCZskI0q19b3anNw0IMst7OgA6N5asi5+L6xfwRCWGX5cPqabBrfXsDd2+yWmMpURgXJ3Lgy7a7pozBXkYTFtMlw8tqoujPj2QTPbaj0pSAZKbhFIo8FdOh5YEe882H8aMIR2I6PlW72HJj8Lq7drNfWt9WLag1ZJI78RovNQf8nbvxlmushucNrG+aogV5/HLRlzxG1OU6eeYvCvnFwyhPPHqec/cmulEn7z2k+XmoMflgR8vDjbzP91VLxecX7UyvzGfbhjkUJYRUUqFbcoTTTQoztY20QMs4mdvHQGGMCmdG0Qi7EbGQ5iWgBXjKHD0eaUYpKCrduOsZA5cVHe+6zE83eynMvcIWgRIxNq4qbIvtlZWpA+5tA2/1ZsqJ/2izfxqT62WPDm7OiPT6Al3TQji4Jw5DCLuXdqVxAjbfAcFGzQm1PCJUY9K+v+xHra4rIML2yqmgS0uxvW+DQBAo73qhHt9xQ36WO57Kc0PF7+ibQxoNUe+H+nFb40MtZjxfO0VNwVpRgC83qvtE2LBb6K7KfcqRT4LrxByHB08QPl9YZcOWCLMgREM+PLAKwJd3NLBqy9tuXu3z6WzZ3+aBIEc2BssOxW87myMsh0VNA81A8P+f2OLQTbmNYmLUfT1qhafLCUW+rI6nhDzBUyPi7QydRkK3vqbt7p784Hct8xsUYuE6jenWgZtEwTpaVMVF8YTzwyYL1BD6ubdgRMTIabzrSImovgB68= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(2616005)(83380400001)(7416002)(70586007)(36860700001)(6666004)(110136005)(1076003)(8676002)(54906003)(81166007)(316002)(70206006)(8936002)(2906002)(16526019)(4326008)(86362001)(186003)(82310400004)(36756003)(426003)(7696005)(508600001)(40460700001)(26005)(5660300002)(336012)(356005)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:57.2725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bacd5a4-510e-4e53-92df-08d9c30dc5fa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5498 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce sysfs attributes to get the different level processor frequencies. Signed-off-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 4ff4fb7c3de6..dd8c0e894532 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -509,6 +509,52 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy) return 0; } +/* Sysfs attributes */ + +/* + * This frequency is to indicate the maximum hardware frequency. + * If boost is not active but supported, the frequency will be larger than the + * one in cpuinfo. + */ +static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, + char *buf) +{ + int max_freq; + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + max_freq = amd_get_max_freq(cpudata); + if (max_freq < 0) + return max_freq; + + return sprintf(&buf[0], "%u\n", max_freq); +} + +static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *policy, + char *buf) +{ + int freq; + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + freq = amd_get_lowest_nonlinear_freq(cpudata); + if (freq < 0) + return freq; + + return sprintf(&buf[0], "%u\n", freq); +} + +cpufreq_freq_attr_ro(amd_pstate_max_freq); +cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); + +static struct freq_attr *amd_pstate_attr[] = { + &amd_pstate_max_freq, + &amd_pstate_lowest_nonlinear_freq, + NULL, +}; + static struct cpufreq_driver amd_pstate_driver = { .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify = amd_pstate_verify, @@ -517,6 +563,7 @@ static struct cpufreq_driver amd_pstate_driver = { .exit = amd_pstate_cpu_exit, .set_boost = amd_pstate_set_boost, .name = "amd-pstate", + .attr = amd_pstate_attr, }; static int __init amd_pstate_init(void) From patchwork Sun Dec 19 16:35:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 860DCC433EF for ; Sun, 19 Dec 2021 16:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236099AbhLSQhD (ORCPT ); Sun, 19 Dec 2021 11:37:03 -0500 Received: from mail-dm6nam11on2049.outbound.protection.outlook.com ([40.107.223.49]:52097 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236249AbhLSQhC (ORCPT ); Sun, 19 Dec 2021 11:37:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CpFUjKVf8kpxw0TRXzWqyvZa1x4TlgdPiEaOe8qW8R4lhKoCG6nJZ+UEGi+qEBPWHSfh1Q3O3R0Dim0+F1x8Uzkf63lEMNt5JlFNql/0VCRc7WpF4kzWMZOnPCIwV2vFs7xSgt89leLRp60TbEkEBCTbGER42GFXafRRjII0k0Av/2vXXp2c2O0GZANXzCpmKIJgn0ICq6I/TWrzYaO/Zep8ExYAlIG9JEpwkYqrVTqijEk2aApQuBoAxBt4xpMVy0jECp1g/nifoHAIaqHddJSq2wHkJVBzdNdYaKkv2qspkvfuIMmCLGxHlS/2Cqaawsilgk27dvRZrTjGFDPb8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iw8lIw88TsUzNkCpch3PbhH3RZiBPX3LpCAnucPFsEc=; b=JVeOzTCVu2l34kOSWIV0IZzUTl+xISzXl+RDnPFMhM8aF45rWJxX/ddZZ6I5epcE0xS1Vt7WopdQBnIx084f1RrDgU8XKT3zmiLeiD2pBOD21OFo+EdZ1q4ZxHmQj2fhVkYSwLBeOlkoYHMcjLmSZMIhx/BLETvcWHYuRPgjBV0EEvQIeTdY6RGmKne68/isOzxTtkIKzKUpgsXzXvBVHv6t+jlAm2H4oBD2mJWsf+cfjQt4FD1Y6fa1YKU5mebaSX256ktJpgdSzHE3/imPjR/ngSHrlRjLLIEavXuYzrtBcqfs6/VfpOlG5N6iMagorwKLhudyym5nsURVpVaOvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iw8lIw88TsUzNkCpch3PbhH3RZiBPX3LpCAnucPFsEc=; b=Re9WFMB/Trb27ehkXUYJzK/PytMjQHtxXm/d+2wFdY6fCNqmnFc4c5p2eiST6jZaWAUiNHvG5WAj6Yn2iIIDBuh2vQKXj+pvBCxYQKxZoh4VEtoRGpkVhVtM+uCas8mcQBPeCwFv+MwejEl+ZC8VUCtinEiPbMpBpy8XkxuJmrA= Received: from BN6PR17CA0058.namprd17.prod.outlook.com (2603:10b6:405:75::47) by DM6PR12MB4844.namprd12.prod.outlook.com (2603:10b6:5:1d0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.20; Sun, 19 Dec 2021 16:36:58 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::25) by BN6PR17CA0058.outlook.office365.com (2603:10b6:405:75::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:57 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:49 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 12/14] cpufreq: amd-pstate: add AMD P-State performance attributes Date: Mon, 20 Dec 2021 00:35:26 +0800 Message-ID: <20211219163528.1023186-13-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9976c41b-c32f-4365-932b-08d9c30dc655 X-MS-TrafficTypeDiagnostic: DM6PR12MB4844:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hlmK5qFxpMueLgDWAa6clBimsj2v+TruJekMdAtHZRMWTlKGGv8NMIl7ShRzwtn60dZMXJZxU5xeFN0TRviw+b1k+jO5Jrrv4TzeCnSg28jg9QLe+7R0ry0uQ+0d6ecoFTYTN6GF6DzU+KJtOWbWMaajZqzrILpBbwRKVCasLi6C2bVIuZFQXqHWrwOU9apKevLQ6vmri0B5W1KTnXDXKtInIuMaOo0ggHMQRD7gZPkhegr6wy1WgiLN9QesZ0pr2Q+kUPqnRhCqrhVe0vZUpm3HZ6ByXTbOWCBRsaqW+txQBQDpRfMuUkqd/ayY4dyw9vjb2QUfP9+hK/jfkkO910Z9cqr+Kcw11vKnkNJauhi5+hRJMX09Z0j43xz6vKSA3HhW0m0i4kjMZ1vU0mySAUrHLZUHAhhOWKQGFDeiGodJkaxl3YQWN9KisEaL0m5cy2Gt4dkhsoqeGBbrb1ZeRUATtep+jo0/SuzvX8TX6jPksvt2Yeao1df37vXwzTOUyeHsnFZl/vOXPAjj4K0cghUBbnj//zalo3hEJfgEkypqAtjJVTxscGWF50ALpgbtV7zxnh9YD5GHRSjJM8FUNC+Neq4OTYN2bomeHl54zI9OVCijrjTTpLI5iPZNAl6RkfriIyMlvnxOVJnmnP3YsYoCi43Pyi+ylGSYVRtTGbrVBl15SNL4rFABKaZsD53adnR6+hDzRvh34fFF6UgRMoB7GeEhdmv7O8ZSxyZQ37U1+zGrHRderNpOkBtg9Q/8OW2IqkJRctPBI1s13hlL+N7/rtIWZzDJzEkbzACNIlc= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(8936002)(81166007)(36860700001)(110136005)(54906003)(7696005)(356005)(8676002)(1076003)(6666004)(70206006)(2906002)(7416002)(426003)(86362001)(16526019)(47076005)(336012)(70586007)(508600001)(5660300002)(186003)(26005)(36756003)(4326008)(2616005)(82310400004)(83380400001)(40460700001)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:57.8699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9976c41b-c32f-4365-932b-08d9c30dc655 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4844 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce sysfs attributes to get the different level AMD P-State performances. Signed-off-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index dd8c0e894532..2471a311fb4d 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -546,12 +546,30 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli return sprintf(&buf[0], "%u\n", freq); } +/* + * In some of ASICs, the highest_perf is not the one in the _CPC table, so we + * need to expose it to sysfs. + */ +static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy, + char *buf) +{ + u32 perf; + struct amd_cpudata *cpudata = policy->driver_data; + + perf = READ_ONCE(cpudata->highest_perf); + + return sprintf(&buf[0], "%u\n", perf); +} + cpufreq_freq_attr_ro(amd_pstate_max_freq); cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); +cpufreq_freq_attr_ro(amd_pstate_highest_perf); + static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, &amd_pstate_lowest_nonlinear_freq, + &amd_pstate_highest_perf, NULL, }; From patchwork Sun Dec 19 16:35:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 525971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AAF5C433F5 for ; Sun, 19 Dec 2021 16:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233201AbhLSQhT (ORCPT ); Sun, 19 Dec 2021 11:37:19 -0500 Received: from mail-mw2nam10on2088.outbound.protection.outlook.com ([40.107.94.88]:43456 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232418AbhLSQhO (ORCPT ); Sun, 19 Dec 2021 11:37:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bRpVWYvcEdmyNCne6n22BLAO6SW5uOINrQHa8g0IimZdVXaQiKvOWVpLh0pe4uZYS5EjV4UrpF69L3GcYrN8UobdqzLJi+xe50k9yByqF2hMJUw/KGQ5kqc8+IwyHRVkySrGrwSLfWWYsckoWDrSbSyRNfSabPzCBXhX8BzVpkfn/b+Bt6nf19d/BuhmD8q/3H1VZxvbhc9g4d/3fwIZb7H/295IVq0fm/Oxcgko+/ypHiKZx7Cw4KvNoNn3e7/MpkChVaD16KSmHfhMF1+eODlGTeRCZ+e3jCYj6YN3J/rDR18vQ1KcimXev9i1GpXTeYlFVocTLGWsOWCa2YhFeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=koNtPSRgnko5x3Y1jjoBr1Ls45ZLJ7VzID3sQ5ygSQY=; b=N+upBzPYOHX3Lm1GwO1TCEdCTN/18fgngJqbOkkQTbKkcGp/YmUfEI7MG0aJSL795fF9NrqFesaq5m3xCs7fMwmJIsmoe7YYJ3z6CuyXLeTK7G8jPYnC9OURDHuOWPXzpB4vCpt19iP4cku1boCOshPf8lVTrWQBnBHV7UJ+qE2/2uminZC2Tsp+6tBUC+LWpqvXb/8bv230L/XI+ffAHEXO1CJk7cHsGMxYGmjY5JpeIncghBHaOJS/ddYyKcD4lTwaPKczhuDAsyf4gKWeXvNJCfJFbypEH8QxkQTD7cEXbD/rI5DZJBGStkqeleiFpRutBaUlmhcEWouIZnIt6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=koNtPSRgnko5x3Y1jjoBr1Ls45ZLJ7VzID3sQ5ygSQY=; b=hrULssppet0KC2wD4TM6pFQuEaB0aawFQWKn27kNO0iU1+iQBZG1zmyHzW/Rz4mho86Q/bKw9wWcAdOPriwAS9HFDOWOZxQ2qNsxAL2biJjekhiTpGVFuSlbMNSvp96+229fXcD6JWgBbmj9kQK3EbCi9fBZvmywCj8XEmjEmF4= Received: from BN9PR03CA0388.namprd03.prod.outlook.com (2603:10b6:408:f7::33) by CY4PR12MB1414.namprd12.prod.outlook.com (2603:10b6:903:3a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.15; Sun, 19 Dec 2021 16:36:59 +0000 Received: from BN8NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f7:cafe::5b) by BN9PR03CA0388.outlook.office365.com (2603:10b6:408:f7::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT061.mail.protection.outlook.com (10.13.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:36:59 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:54 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 13/14] Documentation: AMD P-State: add AMD P-State driver introduction Date: Mon, 20 Dec 2021 00:35:27 +0800 Message-ID: <20211219163528.1023186-14-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d1b23fd-4112-418c-5261-08d9c30dc71e X-MS-TrafficTypeDiagnostic: CY4PR12MB1414:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NJPN225wmH+YjabjdcCh1YBS/qAaZmRjyGm+69P6dKGekswPog39zhvNdg07Q34LEg/5UHRjwQH/NWXeqXqjEziEce5DI/AjAhY6IG6RSpjbKbEu1tUGMEcHD0j6x3QoWiNaufP4PURWGMuRpXpGvUizRiSgbcQQwW1vFgTmhVw52SzdCakYkm+XmzQAfDG2X3r721dzcuH6Mpil21bi2niCovIVy07BimxrGIA2fTux6IquzACM6zGXpWzqNRCV49RpXMnXhiO6x7v5euhRo0L8ir693kz2TtkaKwEov7aRpowOKOOTkoPcLoLPQwe1doMxgD1T8io1k8BLjFkizmsIFHhDMWBrFQFm36VdMt5rJ9nIClZWI8AJ/nV6DGccnuWXdncVIRbFiP0bYE0cn952lLVX4BLk0LHXLKrnGXp5gCC+UakcMUkS0osz6YJ/poB3mOC+N3fAy0dv9vVYu+cRIzMuly/AGlUC+Volrhm6ljeijNJq+OjmtaoRdYex3pc8nNtxKbyyVcVPnJQvMfeVmJJUf1Obz1lJwVH/Dla2XjnndI+R8uLYyQQsYyWObI0h4PTcUaZodAL5/Lfdsb1i+YQjLn0C347YtZ6E+0cWZR3pSZyUiqKS47K32TdN9Q6pPZ76vOJH+zsU49i1W/+aSaSWCgucz2z358UWj0e+LScrXl8Npd9nyvM+m7ec5m2VB/o8QT4K+R8zuoxXdr7YIKk34iOV0FC2WgRen6q+uWzGB6cKlqwPffTjBV9wp65qf4DEu2BVYH3eW+95H/PqnbavZKzRT85EBl8xXgMqNAjsxstgp4fYEaDde2SMoYbVGqDok60Ll038jjE8tGhfDWbe1tYaWEg5i7NTSi4IkVWQqVhs35gERtxUP1rqU3m84UBQc1KMR/kZBrPizBuDWOHrv8CAH9mKapOmg1Zn+mawigo594Id0wRkXkpoPeRiMkZNbBGFnJBdCV3CHrLFmJd+Ofn9EyZMPazE5x4= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(5660300002)(82310400004)(6666004)(316002)(356005)(1076003)(36860700001)(81166007)(426003)(40460700001)(70206006)(7696005)(70586007)(2616005)(30864003)(336012)(86362001)(16526019)(4326008)(26005)(2906002)(83380400001)(7416002)(186003)(8936002)(36756003)(8676002)(54906003)(508600001)(110136005)(47076005)(966005)(21314003)(36900700001)(473944003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:36:59.1811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d1b23fd-4112-418c-5261-08d9c30dc71e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1414 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce the AMD P-State driver design and implementation. Signed-off-by: Huang Rui --- Documentation/admin-guide/acpi/cppc_sysfs.rst | 2 + Documentation/admin-guide/pm/amd-pstate.rst | 383 ++++++++++++++++++ .../admin-guide/pm/working-state.rst | 1 + 3 files changed, 386 insertions(+) create mode 100644 Documentation/admin-guide/pm/amd-pstate.rst diff --git a/Documentation/admin-guide/acpi/cppc_sysfs.rst b/Documentation/admin-guide/acpi/cppc_sysfs.rst index fccf22114e85..e53d76365aa7 100644 --- a/Documentation/admin-guide/acpi/cppc_sysfs.rst +++ b/Documentation/admin-guide/acpi/cppc_sysfs.rst @@ -4,6 +4,8 @@ Collaborative Processor Performance Control (CPPC) ================================================== +.. _cppc_sysfs: + CPPC ==== diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst new file mode 100644 index 000000000000..6bafb9354ba0 --- /dev/null +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -0,0 +1,383 @@ +.. SPDX-License-Identifier: GPL-2.0 +.. include:: + +=============================================== +``amd-pstate`` CPU Performance Scaling Driver +=============================================== + +:Copyright: |copy| 2021 Advanced Micro Devices, Inc. + +:Author: Huang Rui + + +Introduction +=================== + +``amd-pstate`` is the AMD CPU performance scaling driver that introduces a +new CPU frequency control mechanism on modern AMD APU and CPU series in +Linux kernel. The new mechanism is based on Collaborative Processor +Performance Control (CPPC) which provides finer grain frequency management +than legacy ACPI hardware P-States. Current AMD CPU/APU platforms are using +the ACPI P-states driver to manage CPU frequency and clocks with switching +only in 3 P-states. CPPC replaces the ACPI P-states controls, allows a +flexible, low-latency interface for the Linux kernel to directly +communicate the performance hints to hardware. + +``amd-pstate`` leverages the Linux kernel governors such as ``schedutil``, +``ondemand``, etc. to manage the performance hints which are provided by +CPPC hardware functionality that internally follows the hardware +specification (for details refer to AMD64 Architecture Programmer's Manual +Volume 2: System Programming [1]_). Currently ``amd-pstate`` supports basic +frequency control function according to kernel governors on some of the +Zen2 and Zen3 processors, and we will implement more AMD specific functions +in future after we verify them on the hardware and SBIOS. + + +AMD CPPC Overview +======================= + +Collaborative Processor Performance Control (CPPC) interface enumerates a +continuous, abstract, and unit-less performance value in a scale that is +not tied to a specific performance state / frequency. This is an ACPI +standard [2]_ which software can specify application performance goals and +hints as a relative target to the infrastructure limits. AMD processors +provides the low latency register model (MSR) instead of AML code +interpreter for performance adjustments. ``amd-pstate`` will initialize a +``struct cpufreq_driver`` instance ``amd_pstate_driver`` with the callbacks +to manage each performance update behavior. :: + + Highest Perf ------>+-----------------------+ +-----------------------+ + | | | | + | | | | + | | Max Perf ---->| | + | | | | + | | | | + Nominal Perf ------>+-----------------------+ +-----------------------+ + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | | Desired Perf ---->| | + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + Lowest non- | | | | + linear perf ------>+-----------------------+ +-----------------------+ + | | | | + | | Lowest perf ---->| | + | | | | + Lowest perf ------>+-----------------------+ +-----------------------+ + | | | | + | | | | + | | | | + 0 ------>+-----------------------+ +-----------------------+ + + AMD P-States Performance Scale + + +.. _perf_cap: + +AMD CPPC Performance Capability +-------------------------------- + +Highest Performance (RO) +......................... + +It is the absolute maximum performance an individual processor may reach, +assuming ideal conditions. This performance level may not be sustainable +for long durations and may only be achievable if other platform components +are in a specific state; for example, it may require other processors be in +an idle state. This would be equivalent to the highest frequencies +supported by the processor. + +Nominal (Guaranteed) Performance (RO) +...................................... + +It is the maximum sustained performance level of the processor, assuming +ideal operating conditions. In absence of an external constraint (power, +thermal, etc.) this is the performance level the processor is expected to +be able to maintain continuously. All cores/processors are expected to be +able to sustain their nominal performance state simultaneously. + +Lowest non-linear Performance (RO) +................................... + +It is the lowest performance level at which nonlinear power savings are +achieved, for example, due to the combined effects of voltage and frequency +scaling. Above this threshold, lower performance levels should be generally +more energy efficient than higher performance levels. This register +effectively conveys the most efficient performance level to ``amd-pstate``. + +Lowest Performance (RO) +........................ + +It is the absolute lowest performance level of the processor. Selecting a +performance level lower than the lowest nonlinear performance level may +cause an efficiency penalty but should reduce the instantaneous power +consumption of the processor. + +AMD CPPC Performance Control +------------------------------ + +``amd-pstate`` passes performance goals through these registers. The +register drives the behavior of the desired performance target. + +Minimum requested performance (RW) +................................... + +``amd-pstate`` specifies the minimum allowed performance level. + +Maximum requested performance (RW) +................................... + +``amd-pstate`` specifies a limit the maximum performance that is expected +to be supplied by the hardware. + +Desired performance target (RW) +................................... + +``amd-pstate`` specifies a desired target in the CPPC performance scale as +a relative number. This can be expressed as percentage of nominal +performance (infrastructure max). Below the nominal sustained performance +level, desired performance expresses the average performance level of the +processor subject to hardware. Above the nominal performance level, +processor must provide at least nominal performance requested and go higher +if current operating conditions allow. + +Energy Performance Preference (EPP) (RW) +......................................... + +Provides a hint to the hardware if software wants to bias toward performance +(0x0) or energy efficiency (0xff). + + +Key Governors Support +======================= + +``amd-pstate`` can be used with all the (generic) scaling governors listed +by the ``scaling_available_governors`` policy attribute in ``sysfs``. Then, +it is responsible for the configuration of policy objects corresponding to +CPUs and provides the ``CPUFreq`` core (and the scaling governors attached +to the policy objects) with accurate information on the maximum and minimum +operating frequencies supported by the hardware. Users can check the +``scaling_cur_freq`` information comes from the ``CPUFreq`` core. + +``amd-pstate`` mainly supports ``schedutil`` and ``ondemand`` for dynamic +frequency control. It is to fine tune the processor configuration on +``amd-pstate`` to the ``schedutil`` with CPU CFS scheduler. ``amd-pstate`` +registers adjust_perf callback to implement the CPPC similar performance +update behavior. It is initialized by ``sugov_start`` and then populate the +CPU's update_util_data pointer to assign ``sugov_update_single_perf`` as +the utilization update callback function in CPU scheduler. CPU scheduler +will call ``cpufreq_update_util`` and assign the target performance +according to the ``struct sugov_cpu`` that utilization update belongs to. +Then ``amd-pstate`` updates the desired performance according to the CPU +scheduler assigned. + + +Processor Support +======================= + +The ``amd-pstate`` initialization will fail if the _CPC in ACPI SBIOS is +not existed at the detected processor, and it uses ``acpi_cpc_valid`` to +check the _CPC existence. All Zen based processors support legacy ACPI +hardware P-States function, so while the ``amd-pstate`` fails to be +initialized, the kernel will fall back to initialize ``acpi-cpufreq`` +driver. + +There are two types of hardware implementations for ``amd-pstate``: one is +`Full MSR Support `_ and another is `Shared Memory Support +`_. It can use :c:macro:`X86_FEATURE_CPPC` feature flag (for +details refer to Processor Programming Reference (PPR) for AMD Family +19h Model 51h, Revision A1 Processors [3]_) to indicate the different +types. ``amd-pstate`` is to register different ``static_call`` instances +for different hardware implementations. + +Currently, some of Zen2 and Zen3 processors support ``amd-pstate``. In the +future, it will be supported on more and more AMD processors. + +Full MSR Support +----------------- + +Some new Zen3 processors such as Cezanne provide the MSR registers directly +while the :c:macro:`X86_FEATURE_CPPC` CPU feature flag is set. +``amd-pstate`` can handle the MSR register to implement the fast switch +function in ``CPUFreq`` that can shrink latency of frequency control on the +interrupt context. The functions with ``pstate_xxx`` prefix represent the +operations of MSR registers. + +Shared Memory Support +---------------------- + +If :c:macro:`X86_FEATURE_CPPC` CPU feature flag is not set, that means the +processor supports shared memory solution. In this case, ``amd-pstate`` +uses the ``cppc_acpi`` helper methods to implement the callback functions +that defined on ``static_call``. The functions with ``cppc_xxx`` prefix +represent the operations of acpi cppc helpers for shared memory solution. + + +AMD P-States and ACPI hardware P-States always can be supported in one +processor. But AMD P-States has the higher priority and if it is enabled +with :c:macro:`MSR_AMD_CPPC_ENABLE` or ``cppc_set_enable``, it will respond +to the request from AMD P-States. + + +User Space Interface in ``sysfs`` +================================== + +``amd-pstate`` exposes several global attributes (files) in ``sysfs`` to +control its functionality at the system level. They located in the +``/sys/devices/system/cpu/cpufreq/policyX/`` directory and affect all CPUs. :: + + root@hr-test1:/home/ray# ls /sys/devices/system/cpu/cpufreq/policy0/*amd* + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_highest_perf + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_lowest_nonlinear_freq + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_max_freq + + +``amd_pstate_highest_perf / amd_pstate_max_freq`` + +Maximum CPPC performance and CPU frequency that the driver is allowed to +set in percent of the maximum supported CPPC performance level (the highest +performance supported in `AMD CPPC Performance Capability `_). +In some of ASICs, the highest CPPC performance is not the one in the _CPC +table, so we need to expose it to sysfs. If boost is not active but +supported, this maximum frequency will be larger than the one in +``cpuinfo``. +This attribute is read-only. + +``amd_pstate_lowest_nonlinear_freq`` + +The lowest non-linear CPPC CPU frequency that the driver is allowed to set +in percent of the maximum supported CPPC performance level (Please see the +lowest non-linear performance in `AMD CPPC Performance Capability +`_). +This attribute is read-only. + +For other performance and frequency values, we can read them back from +``/sys/devices/system/cpu/cpuX/acpi_cppc/``, see :ref:`cppc_sysfs`. + + +``amd-pstate`` vs ``acpi-cpufreq`` +====================================== + +On majority of AMD platforms supported by ``acpi-cpufreq``, the ACPI tables +provided by the platform firmware used for CPU performance scaling, but +only provides 3 P-states on AMD processors. +However, on modern AMD APU and CPU series, it provides the collaborative +processor performance control according to ACPI protocol and customize this +for AMD platforms. That is fine-grain and continuous frequency range +instead of the legacy hardware P-states. ``amd-pstate`` is the kernel +module which supports the new AMD P-States mechanism on most of future AMD +platforms. The AMD P-States mechanism will be the more performance and energy +efficiency frequency management method on AMD processors. + +Kernel Module Options for ``amd-pstate`` +========================================= + +``shared_mem`` +Use a module param (shared_mem) to enable related processors manually with +**amd_pstate.shared_mem=1**. +Due to the performance issue on the processors with `Shared Memory Support +`_, so we disable it for the moment and will enable this by default +once we address performance issue on this solution. + +The way to check whether current processor is `Full MSR Support `_ +or `Shared Memory Support `_ : :: + + ray@hr-test1:~$ lscpu | grep cppc + Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm + +If CPU Flags have cppc, then this processor supports `Full MSR Support +`_. Otherwise it supports `Shared Memory Support `_. + + +``cpupower`` tool support for ``amd-pstate`` +=============================================== + +``amd-pstate`` is supported on ``cpupower`` tool that can be used to dump the frequency +information. And it is in progress to support more and more operations for new +``amd-pstate`` module with this tool. :: + + root@hr-test1:/home/ray# cpupower frequency-info + analyzing CPU 0: + driver: amd-pstate + CPUs which run at the same hardware frequency: 0 + CPUs which need to have their frequency coordinated by software: 0 + maximum transition latency: 131 us + hardware limits: 400 MHz - 4.68 GHz + available cpufreq governors: ondemand conservative powersave userspace performance schedutil + current policy: frequency should be within 400 MHz and 4.68 GHz. + The governor "schedutil" may decide which speed to use + within this range. + current CPU frequency: Unable to call hardware + current CPU frequency: 4.02 GHz (asserted by call to kernel) + boost state support: + Supported: yes + Active: yes + AMD PSTATE Highest Performance: 166. Maximum Frequency: 4.68 GHz. + AMD PSTATE Nominal Performance: 117. Nominal Frequency: 3.30 GHz. + AMD PSTATE Lowest Non-linear Performance: 39. Lowest Non-linear Frequency: 1.10 GHz. + AMD PSTATE Lowest Performance: 15. Lowest Frequency: 400 MHz. + + +Diagnostics and Tuning +======================= + +Trace Events +-------------- + +There are two static trace events that can be used for ``amd-pstate`` +diagnostics. One of them is the cpu_frequency trace event generally used +by ``CPUFreq``, and the other one is the ``amd_pstate_perf`` trace event +specific to ``amd-pstate``. The following sequence of shell commands can +be used to enable them and see their output (if the kernel is generally +configured to support event tracing). :: + + root@hr-test1:/home/ray# cd /sys/kernel/tracing/ + root@hr-test1:/sys/kernel/tracing# echo 1 > events/amd_cpu/enable + root@hr-test1:/sys/kernel/tracing# cat trace + # tracer: nop + # + # entries-in-buffer/entries-written: 47827/42233061 #P:2 + # + # _-----=> irqs-off + # / _----=> need-resched + # | / _---=> hardirq/softirq + # || / _--=> preempt-depth + # ||| / delay + # TASK-PID CPU# |||| TIMESTAMP FUNCTION + # | | | |||| | | + -0 [015] dN... 4995.979886: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=15 changed=false fast_switch=true + -0 [007] d.h.. 4995.979893: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=7 changed=false fast_switch=true + cat-2161 [000] d.... 4995.980841: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=0 changed=false fast_switch=true + sshd-2125 [004] d.s.. 4995.980968: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=4 changed=false fast_switch=true + -0 [007] d.s.. 4995.980968: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=7 changed=false fast_switch=true + -0 [003] d.s.. 4995.980971: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=3 changed=false fast_switch=true + -0 [011] d.s.. 4995.980996: amd_pstate_perf: amd_min_perf=85 amd_des_perf=85 amd_max_perf=166 cpu_id=11 changed=false fast_switch=true + +The cpu_frequency trace event will be triggered either by the ``schedutil`` scaling +governor (for the policies it is attached to), or by the ``CPUFreq`` core (for the +policies with other scaling governors). + + +Reference +=========== + +.. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming, + https://www.amd.com/system/files/TechDocs/24593.pdf + +.. [2] Advanced Configuration and Power Interface Specification, + https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf + +.. [3] Processor Programming Reference (PPR) for AMD Family 19h Model 51h, Revision A1 Processors + https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip + diff --git a/Documentation/admin-guide/pm/working-state.rst b/Documentation/admin-guide/pm/working-state.rst index f40994c422dc..5d2757e2de65 100644 --- a/Documentation/admin-guide/pm/working-state.rst +++ b/Documentation/admin-guide/pm/working-state.rst @@ -11,6 +11,7 @@ Working-State Power Management intel_idle cpufreq intel_pstate + amd-pstate cpufreq_drivers intel_epb intel-speed-select From patchwork Sun Dec 19 16:35:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 526229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF77C433F5 for ; Sun, 19 Dec 2021 16:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236228AbhLSQhL (ORCPT ); Sun, 19 Dec 2021 11:37:11 -0500 Received: from mail-bn7nam10on2072.outbound.protection.outlook.com ([40.107.92.72]:43744 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233242AbhLSQhL (ORCPT ); Sun, 19 Dec 2021 11:37:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SgRxyIV/BawkyROCGGvU3gMwYDthCJqMke0TNp2ytZSwqp04UC2XydO0WAOiwVBlePVzIOsVi7/yPEXHylKPwGbhA4RLOeYp0Fcxh2P0/P55MxbdkzYm+hjd8PmDU4fYUkVZEqBbSWptVUB1xCiNB+b5tKe78i5rBkNTGW3fvqEJIR75UcbRUl8y54mfFrdlI/lRz03pOrL7+qr7BTg7bVrF0P82CjjYjjkl8m9L08ll7VLOuRIoOQ7Tnz+R6b9kiY0y1TcDL2Ic7M97Ipr46eWai/VnOY0I3TbLM5dL4X5Ip0K73KlREiPe8/rC0BZhXUbc1EHo1JVEIDULMjKrXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t/LfjMYioRuigC5rv4WSx+ehE7yjhQnxsEcC3qCNrDc=; b=i3CNcPExjJG/3PFX4RmsB36GTyjnCtIKrLMyGZJ/pz9nZ+2cdrLUrNLCbRWPK7fV+rgxov97gks1QcKvw4W6BlCcUGrHx03k1TTotYrW7h4q69pWJYYuFe4vDwHSjIthYk0XZ9jbK8HD35hXGk7mYxOMLdefOPmaehNEt4bLwMN52EtWQ0cg5mNhj9uDQnN/Zq8CNYJfceLRaM79DlvOZKdHFe0CT5fH9qC4o4/famfWHURw169i7TpgjC2VfN7TXfFhsZt82E1kvyHua5InUZMHX56BhD+x3vMokKovy/HCWPId7YZdb6/Ap2jEWyNr2ATrHkItpDJdIEyHZKDyzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t/LfjMYioRuigC5rv4WSx+ehE7yjhQnxsEcC3qCNrDc=; b=w+p/GMAtvdUf1Z1Nfj43JS97azgDCh6GKKS+VCOYeGGEHNuhHA7wEhuDoJYMvxTq9xvbtCl5aH5PgRSxWD9M0rJzOdeQiBONQbN2uxfxN8pHR3W2KE4xUtX6z/IFimo2lWEleWr63b4es/oKXiYEGlQbbIQ93GgDEncds2thu90= Received: from BN0PR04CA0041.namprd04.prod.outlook.com (2603:10b6:408:e8::16) by DM6PR12MB4516.namprd12.prod.outlook.com (2603:10b6:5:2ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sun, 19 Dec 2021 16:37:04 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::32) by BN0PR04CA0041.outlook.office365.com (2603:10b6:408:e8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.16 via Frontend Transport; Sun, 19 Dec 2021 16:37:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4801.14 via Frontend Transport; Sun, 19 Dec 2021 16:37:03 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Sun, 19 Dec 2021 10:36:59 -0600 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , Steven Rostedt , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH v6 14/14] MAINTAINERS: add AMD P-State driver maintainer entry Date: Mon, 20 Dec 2021 00:35:28 +0800 Message-ID: <20211219163528.1023186-15-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211219163528.1023186-1-ray.huang@amd.com> References: <20211219163528.1023186-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b910686-adf5-432a-6b5d-08d9c30dc9e1 X-MS-TrafficTypeDiagnostic: DM6PR12MB4516:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: msZLZJdgT2VA9K8OU4KVxiQgWMBES1otf4jccY11RdkhN7NUABhNPf188D25fkjs1kBCUKfDW3oFcpg2ADzO/zjbLO2M7RdPO/XOfLAwAN2RLGjEvcSb/Q/Z26l5mMaWvIboHhjsXBWniwgpXsRv20zcOzax2oGFgx+lqWD5Sny9HBMEcLnYMqoGEJOdjYkf4h2iwGPmBMTB34aKnoOC/vDjhNT/m3OW10CGGWO5wdkxbIVACvhmTx9U4lxVk2UTeLLxrdCR04V+VBO3UNXuVzL9NCotNw8kKXlc13ikdqNp7wHAZk0LGtm+BnlvRcSDKIY8qlKLWWThrzjyWIEwBUpAmRLcJ25oBBqlIircqefT0JEtbxloA42UJwIMqxzhfT4E0wnfFbNEYIC+tFmlzsem68peQVPFz4jmImOGU5flWsno2sIzDDOr+KGE/k9UPSKW6Ddf7HB7qMr+U/YCV/6OZ9f5l4EeesqUn2eLMHGUwDWNpKa6GUTmXlEMgNxHRN461vv0zyYKy26bf19ygF7EwEkfy+q3dKfn55kBm8eqdxr05GfEgr36WLLaQJ2qquzPr0euCOw7TiEbJoWnBMZhflUcbbz7IUZ/eZgH7RLnim+MdISgBC0u9fI1jUMMrHF18jVZEHsVSB4zTqLTiBeXQY352yKA547wO79WIQQ/Ntdn7+M39Q1OaLYc5JB+XK4wK1k7i2z2frsf9Z4dsYEORatYB24iM7Aj27eBtwYFQWSd96zGXmZNgQYCtxHdR90YsxdYS6a57CuWbNEOzb7soX2AEZj0SAw2Igqr5so= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(8676002)(16526019)(966005)(356005)(83380400001)(26005)(8936002)(508600001)(4326008)(336012)(110136005)(54906003)(36756003)(70206006)(5660300002)(81166007)(70586007)(7696005)(426003)(36860700001)(2616005)(86362001)(4744005)(2906002)(316002)(7416002)(186003)(82310400004)(40460700001)(6666004)(47076005)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2021 16:37:03.8151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b910686-adf5-432a-6b5d-08d9c30dc9e1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4516 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org I will continue to add new feature and processor support, optimize the performance, and handle the issues for AMD P-State driver. Signed-off-by: Huang Rui --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index fe347675fb5c..8e0666a552df 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -975,6 +975,13 @@ S: Supported T: git https://gitlab.freedesktop.org/agd5f/linux.git F: drivers/gpu/drm/amd/pm/ +AMD PSTATE DRIVER +M: Huang Rui +L: linux-pm@vger.kernel.org +S: Supported +F: Documentation/admin-guide/pm/amd-pstate.rst +F: drivers/cpufreq/amd-pstate* + AMD PTDMA DRIVER M: Sanjay R Mehta L: dmaengine@vger.kernel.org