From patchwork Fri Oct 13 02:57:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733610 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 26C89C41513 for ; Fri, 13 Oct 2023 02:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbjJMC6P (ORCPT ); Thu, 12 Oct 2023 22:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjJMC6O (ORCPT ); Thu, 12 Oct 2023 22:58:14 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A622B7; Thu, 12 Oct 2023 19:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wv1BQ7kN5PJCVH7J50F92aG86VBd6DfeQr2+L89L5zMWyyi16VKyOsCLj1WBIO0JO6t8CCnr7JJgYUuogepnrR8H2qcu9iB87vHH2L4NAgXfHbsELsfydjxCgQUVvW9mcOPDmb40SvNXWxHDH4IjJ6I8/79Hr99eMLbX1Vj6tNsT+J0SMMBk2bLU//cx8DZwtyi+QCl/QFIivOyED9fwYNxHz7ydtNVbAgvOihB/O66vMQH+xbPpW4KCCPHMdO9NqxjzIoMGPxgLzKpVc6TweJko2bk7Dj4etm+FpEzwpNkj/3W/WWkrNsb8NOtHmJ4YyHECzxHr74ZW9640kkZd2g== 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=nzEIHZpUA3AMJxzqDK5FWIBnTdRjO3KqmrHE7LsmiW0=; b=h0h9mZvjHeNT6s+rPfTwYr6PVNuP+THz0e16OhjF4FSUDmbdDk2VkU4UYQ6BGlkerJMczJFOrWDzIm2pdLjL4mAydf47cb3IVF0smqZk7QIjMO2EGMsT13qMVb8PvH0spoEsqMCk3a7b9LU+0BKHkDrOF3aiv4tTa/1ADJbeYzZtTM2Hy5b+7e3OomSDYxNe9sYKXmd3xVJ/CawI6iS9ed1N+CbTwPjYfwpJzhtRd5NTN1h6T0dc34jzJMOZO+9uF9VP2TQUdW1fFdumzE907Ye5PvUfqLqHG85R3MI5l7wquOHtI9ISAzVwiiunKOS/KjfN80ApCU8Y5fKL/jyK5w== 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=nzEIHZpUA3AMJxzqDK5FWIBnTdRjO3KqmrHE7LsmiW0=; b=tk7BZmLptW06vntZpdGea71JTO+V23ydaSlqldqU14nN1EJvxClryL4SPT/B3LEOp/f73m/1Zrj62HQNOHDpr5c9xmEJ0MocACJ+2WNQuKXBn89vM+9cLxu/3IFw6Us4xf92oKB87hka9AvjH7yrX871N7QlJR+d6uIYRNtqkcc= Received: from MW4PR03CA0226.namprd03.prod.outlook.com (2603:10b6:303:b9::21) by IA0PR12MB8303.namprd12.prod.outlook.com (2603:10b6:208:3de::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 02:58:08 +0000 Received: from CO1PEPF000044EF.namprd05.prod.outlook.com (2603:10b6:303:b9:cafe::1) by MW4PR03CA0226.outlook.office365.com (2603:10b6:303:b9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 02:58:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044EF.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:08 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:01 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li Subject: [PATCH V9 1/7] x86: Drop CPU_SUP_INTEL from SCHED_MC_PRIO for the expansion. Date: Fri, 13 Oct 2023 10:57:35 +0800 Message-ID: <20231013025741.3332520-2-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044EF:EE_|IA0PR12MB8303:EE_ X-MS-Office365-Filtering-Correlation-Id: f834a5b9-5570-4a71-a937-08dbcb983ab1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +WkhYQ/b3pk1uUxIkILhRJ8RawqtiR3H2tTncf7juJUsmD/KU5eDMx7dndAk85RUVSyZOffpT4f8e5BgEgfkiu7D02JfpN5C+kYFCjQJr9HOUKWC69HRhDw7wfvSDWf7aRFKTgZrmWDSyHMk9UrJFHuHrGFH0e3ocjP3NCpTww3lK/N0E21GIQ7+PNmWQjyy2IanZunG3ExSOcFOH2UiyRK8sG/nW3V7NMhQ8PpexDEqYx315N9vhxCSV5If+aeqoKfWBUgFz0/+TqZAgtjIC225O3SNQOJLbs9I92FQKJ6BRjSb4MyzMe2eBprwdavHtITxnmsWKXt8ogPzR25xHkvpYf4lPXUbtyY0evRktIrCbqMABp08O39MYzDOXW3YTDXwmpl3+Xa6CTOwXSNlXkf92zFRahq4l2lr5/2nwQulCalu8JmDwOdjPQXW/TDsWp2axH1JkxQfVnj7RMdykz1xzupa2bfwuLTRqirrJkK/UMfiL3z4t8Bsy5VSSqZAwlOb3Vl0vH5kEiYPWC5i4QM2YGt4TfTVNph+2A4zcI1OxEM9YEb7DdCvRp1DTY5BBwJ5lbg2iAJ834878TYxJARo4KnyxA7srolwPCYvPrpmHzrxt3qs8IWrym06CilspB8rxz8bJSUDLoBeNiNNN0vPH6+MbLO8a59hMhEx4x8P4MSRX9cji9kjWPY+nilM28hp4acO/JGWAm4cfa8BRXtaBrqLcLh5248yK7U0xmEVGWlDQZuYRQAgW/u9sUp/DcS0eCLP18HnAklP5VOplg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(376002)(346002)(136003)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(82310400011)(40470700004)(46966006)(36840700001)(40460700003)(356005)(1076003)(2616005)(7696005)(478600001)(6666004)(47076005)(336012)(426003)(16526019)(26005)(7416002)(2906002)(83380400001)(4744005)(70586007)(54906003)(41300700001)(5660300002)(110136005)(70206006)(8676002)(6636002)(4326008)(8936002)(316002)(82740400003)(40480700001)(81166007)(36860700001)(36756003)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:08.1683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f834a5b9-5570-4a71-a937-08dbcb983ab1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044EF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8303 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd-pstate driver also uses SCHED_MC_PRIO, so decouple the requirement of CPU_SUP_INTEL from the dependencies to allow compilation in kernels without Intel CPU support. Tested-by: Oleksandr Natalenko Reviewed-by: Mario Limonciello Reviewed-by: Huang Rui Signed-off-by: Meng Li --- arch/x86/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 66bfabae8814..a2e163acf623 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1054,8 +1054,9 @@ config SCHED_MC config SCHED_MC_PRIO bool "CPU core priorities scheduler support" - depends on SCHED_MC && CPU_SUP_INTEL - select X86_INTEL_PSTATE + depends on SCHED_MC + select X86_INTEL_PSTATE if CPU_SUP_INTEL + select X86_AMD_PSTATE if CPU_SUP_AMD && ACPI select CPU_FREQ default y help From patchwork Fri Oct 13 02:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733985 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 8ACF4C41513 for ; Fri, 13 Oct 2023 02:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbjJMC6W (ORCPT ); Thu, 12 Oct 2023 22:58:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbjJMC6S (ORCPT ); Thu, 12 Oct 2023 22:58:18 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2077.outbound.protection.outlook.com [40.107.100.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 578CCBB; Thu, 12 Oct 2023 19:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MRh9booojb2PUi8c/v6xiwYTBmts0pnICAUgRgCfDggaWkm06n1jVV2d8mN2Vd8kD3qReRv23n6Zpl8oDXvuT+q0QoeRtNv0WIQ1KRDxNIwy3nmgy8DRaQ8FUgBkc9jQE9liVbbTEh27Wgmf8OYd+nUb99kNIwpVRZWDLWvIRG5PnkJxhTCXVGg2NPG+DXcT1mle7H2IfuYugHPyCcW13srkJCucOQ/WNoyTeeMc80+Hoc7F9hAd56umaIEdUjqvw0yhVh1Uu7aWv2SHByFjsN5DDlyMTRwUXNfofS5C8diLAF88qc11lEkCaHxUwuOtzT3NEZevRt3AdX+FQFyObA== 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=AlF2WKiSUPyODRJ7ueMUccEPh7maCKY1Dj6+XRqyp7A=; b=RGTtfBBRENrPUDtU75chx5P7fyIIToJ+nXRx15fEqhGbdXIX2+5JOSzTKwiyRRUBXbLxmfey2zGxvIoxm/+XjlhXVWyw7evwrslZqLTpKdPQDsTMFkfl08ZB8i35bdz3AY9u8UTmzzufU9BCWcGC6C0kcdQgtdpLlZTvsekYji8ZZbbp4LjKaVpf+Js7rTIy5MorDLbRx5AQHa9IiT8A82WP0LZpCl0s34tkmxk0yEBFh1WzR+9ccHmgoTYfG6qA28KiyTOP7MVUs3qaZiDeGRZYFs4+JTV6EDb1iWns1zg5OJ4+WeAEv969l07mgFUx8zqWxG6K+/mxhCBCpMHQ/g== 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=AlF2WKiSUPyODRJ7ueMUccEPh7maCKY1Dj6+XRqyp7A=; b=0mz+fOC0BAYWWiyiVlUfLDPlXUoUjwcyfCgNm5ttURPba8H+VMmV9+E24teDt4iRPTbCZkj8ImcfE+xmfQAPhtNLkLTWGRWmM82piaKKM5I1NM4vUO1Ww/Hr/kqByisHC5RW+PeiwLaDoU2+5cSGoI16rOvQfBKdD9JnLgJ3FPI= Received: from MW4P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::12) by PH7PR12MB5853.namprd12.prod.outlook.com (2603:10b6:510:1d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Fri, 13 Oct 2023 02:58:12 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:303:8b:cafe::86) by MW4P221CA0007.outlook.office365.com (2603:10b6:303:8b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 02:58:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:11 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:05 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li , Wyes Karny Subject: [PATCH V9 2/7] acpi: cppc: Add get the highest performance cppc control Date: Fri, 13 Oct 2023 10:57:36 +0800 Message-ID: <20231013025741.3332520-3-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|PH7PR12MB5853:EE_ X-MS-Office365-Filtering-Correlation-Id: 540aa639-883f-452d-9732-08dbcb983cb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BI5K7RfbfAnmQLVAy2m5ZqE03TXMrhqZOdlOcjqq5RbeivNCFFlyv+v0+i+Gag9ee6R+kEd9lurPMZOAUimSHRdIwiiCVgv10bBoVG0p9rgDR0wXMGUsiItPd+PBnst2ak6IF2adDMqkoChLDQ73pLrHXRX4fpYOqUMLEK6ezx0L+u5VDtKNdiMg80hed0ozaX38WBKC6GpUL1N8h6/7gLiMFLEb8UBKbGXDSpqdHAqoq0kgbGpkRJuOF44hE49z2orLRYr9J++r3dXcGyGXV4DeJxkiA6fsVcsNgd3KpqGIPKKtLjVuOf99mCRC4UnInTvxBcR02qe+o/aMsS3Dp0Y7y41xHXCon4x9qvQmygPjNQPetJysgh9pkAaUh0dhTpFamKE6tTKPZqpP0ka536w0yGsKWH3y2YyyE02e+E14t6E+yMJPM1LaoK6Ehm1nm9YpxgVDxcJF+ard5YsQbAF6cWWIDHSmIi+sYG5C9h4WsBAq0i09DAGhwF4pfSkCQvZMqjPKPZuNgnoSjOB/Ljx7ks+NYsykIR7Jzp9WJdh0ybZjpHlzwUR3udBoggGugXCE4mODzrWgDTajlLi5BvT2nVrzBj1l7S69FR1xZ6qcjL1slwzlyTT2Qg41lSM70SiLO1DSbZrTapCza20+Y9QygGDSpeKEzEthwpgn9YsPzcb9L07QjFtZV+3EDvVoQ/r6I4UyDcBp3g5L0H1nQ7RaTB9tb62AhjKev7EHIwM40EVkRvyXLOG8t7ZVLn1aIzC4cNKpAmLfBBnUZmtXyekHKodmMd+kdF/FmChs12I= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(346002)(396003)(136003)(39860400002)(230922051799003)(451199024)(186009)(82310400011)(64100799003)(1800799009)(40470700004)(46966006)(36840700001)(426003)(26005)(336012)(70206006)(40480700001)(54906003)(5660300002)(36756003)(36860700001)(6666004)(478600001)(47076005)(86362001)(7696005)(41300700001)(1076003)(40460700003)(356005)(316002)(6636002)(82740400003)(70586007)(7416002)(966005)(8936002)(4326008)(2906002)(81166007)(8676002)(2616005)(110136005)(16526019)(15583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:11.5324 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 540aa639-883f-452d-9732-08dbcb983cb0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5853 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add support for getting the highest performance to the generic CPPC driver. This enables downstream drivers such as amd-pstate to discover and use these values. Please refer to the ACPI_Spec for details on continuous performance control of CPPC. Tested-by: Oleksandr Natalenko Reviewed-by: Mario Limonciello Reviewed-by: Wyes Karny Acked-by: Huang Rui Signed-off-by: Meng Li Link: https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html?highlight=cppc#highest-performance --- drivers/acpi/cppc_acpi.c | 13 +++++++++++++ include/acpi/cppc_acpi.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 7ff269a78c20..ad388a0e8484 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1154,6 +1154,19 @@ int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf) return cppc_get_perf(cpunum, NOMINAL_PERF, nominal_perf); } +/** + * cppc_get_highest_perf - Get the highest performance register value. + * @cpunum: CPU from which to get highest performance. + * @highest_perf: Return address. + * + * Return: 0 for success, -EIO otherwise. + */ +int cppc_get_highest_perf(int cpunum, u64 *highest_perf) +{ + return cppc_get_perf(cpunum, HIGHEST_PERF, highest_perf); +} +EXPORT_SYMBOL_GPL(cppc_get_highest_perf); + /** * cppc_get_epp_perf - Get the epp register value. * @cpunum: CPU from which to get epp preference value. diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 6126c977ece0..c0b69ffe7bdb 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -139,6 +139,7 @@ struct cppc_cpudata { #ifdef CONFIG_ACPI_CPPC_LIB 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_highest_perf(int cpunum, u64 *highest_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); @@ -165,6 +166,10 @@ static inline int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf) { return -ENOTSUPP; } +static inline int cppc_get_highest_perf(int cpunum, u64 *highest_perf) +{ + return -ENOTSUPP; +} static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs) { return -ENOTSUPP; From patchwork Fri Oct 13 02:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733609 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 B8BB7CDB482 for ; Fri, 13 Oct 2023 02:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjJMC6c (ORCPT ); Thu, 12 Oct 2023 22:58:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjJMC60 (ORCPT ); Thu, 12 Oct 2023 22:58:26 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1167A9; Thu, 12 Oct 2023 19:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ejMLXYLvIlG6hKs7gMI65d11n7g8UDv5F0oolt0zl2SnJapuhGxWRJ/RYNzxe3xUCkzZ9QhCrTpg1/+MED3mCPa7JvPIB5y3t/N/tMGzlYE+ISbOtWvaSwZ2NsGz92+4J3cqvsgazKO0so3CAJz/DESoLXmHAcH1v1N6tXyFl9nGP1SeQErrU60O1mMzO3qSpTb8LtYSluMqc6q80zLNPiIIrEd4owwxD5nEcpA1BBZMNMz+RKM+hWrRNSchszPIHbUfYqd63PBLSeo4kpHPhP3KbMU2LLk/ezywdn3yQW0Kss6jxTVhTwuDPALdv0XLmdBFFrw4hw8TGyCi0/zzEg== 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=mpqCLwo80Q+CSCXFfWuoADKctj8OoSbA2jq+gzqAQZM=; b=G+N5g5Yz8zUlL4aatumTO4aT8vQgbRgna6mtOSEr6n4JIevTrHLaCnX1HCNCaCa4d7ZFqfwbpgyVNPp+LCUm4HXZmfatBWEl4PskZ0q20qMxG+CyWb8qQ0bYACRoV3epRWbiOWbvhhKy/O3Nvv1ieDwJbD6R7D0PddlHvFN4qmCIe0Va5SUOnQrkyU0ouWmJYwlgGGyHhW65PeCzY/M8vQucvQYTJ4Y1C5RIvmzR0Dm7Ijnl1d+AxvvjZx7m46LkBfVnDeN9OwsEB0bcOnre+MAbz+3XgKbem9le4qE7purEuA85cmcp6vPxWjuKQUJPB2DsWeYao3txV9qcPgvENg== 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=mpqCLwo80Q+CSCXFfWuoADKctj8OoSbA2jq+gzqAQZM=; b=OSIvkKfFKsCMCXapvApPYpJX4PZ7/DXvSE3bAFztXP/mlTCw1Za25TsvNDhO5/hT5maGE7D/lsaP56fIXyr15dD+U3C773+on1IoHLYTz4WCGUJBCEhcLAdm20dp6Lu37FEi1mI24dFlkLLADDEwXYPTJb0edhuV6UmxLuy5Igw= Received: from MW4PR03CA0217.namprd03.prod.outlook.com (2603:10b6:303:b9::12) by DM4PR12MB7645.namprd12.prod.outlook.com (2603:10b6:8:107::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Fri, 13 Oct 2023 02:58:17 +0000 Received: from CO1PEPF000044EF.namprd05.prod.outlook.com (2603:10b6:303:b9:cafe::d3) by MW4PR03CA0217.outlook.office365.com (2603:10b6:303:b9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44 via Frontend Transport; Fri, 13 Oct 2023 02:58: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044EF.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:17 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:11 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li , Wyes Karny Subject: [PATCH V9 3/7] cpufreq: amd-pstate: Enable amd-pstate preferred core supporting. Date: Fri, 13 Oct 2023 10:57:37 +0800 Message-ID: <20231013025741.3332520-4-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044EF:EE_|DM4PR12MB7645:EE_ X-MS-Office365-Filtering-Correlation-Id: 96177df9-29f9-4615-dedb-08dbcb984039 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VrqieBSLhZq6yAtFw2FLyyV6CISnzjs8Fe5C5gZCnrYycRBOnwA33HGW7XgOWftg5/mVmzCN3ZJtTuUkJ1Z5oEfOH6KLp/Z/c+E3FYfS9WXJwUcRfDQpbWeYxhXZRsE+6TJU4ZdqZigfiN9qSGBflc5OPCjbcROJYRfUmRwRJ346ibCGNrx8yqD9rJPIikPMWFj4p82n1qVSt2g7hTf3/kaHBRDJJaJRRFXOUyN+vvMdvoPfc9hC2tTFGH8VEimSNpwDC082CRuqf7xGHTJs6SfgaXgis6xVxHs0OAZqf3LqNoCMvlqsoTKf5WE9KYef93mqwAol+aoEuY6m+kwkMwdnL9sVlKyW2ZpclyQBj/nxxbL4pyTu1FvSm+txbkXCqnm2d02g8GSb1OaAkU4kOijgPZekde1JzmlLNJUzVeLKtl87dCy9sQVk47EZj8NPtAysBsXfv/u3BOOUdhHonNCDAhZPZHHF2VTHM/fRoOyKEQyrq8s+bUx3971WJMeehkgID0S916JjAduPIJcfvAdhuD9fdKV5Hpnpi6EtzAmWfxtpyNcISLoAXANYDv53ma3H3A/WZqzVRgKH2QjZsC0z649/dhu2f6RgojuuGePph1dtsDRlY/SHaWC8w4orqwd36RpZvMAtgIfrLwWEqHBPyKSwoTsX+Ntij+Nof/LG9vNBmje0jPdYy++8w5nLzyibGfdQDDd5VaE3Ds/RFhLnBBI3jJh2YmLoKYhNYY2huBTXixPGnjisxVZ24iTBWhLxqVcs5GkIPxwgqiYFCg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(346002)(376002)(39860400002)(136003)(230922051799003)(82310400011)(186009)(1800799009)(451199024)(64100799003)(36840700001)(40470700004)(46966006)(16526019)(26005)(336012)(426003)(81166007)(1076003)(2616005)(8676002)(47076005)(7696005)(4326008)(8936002)(2906002)(7416002)(478600001)(30864003)(6666004)(70206006)(70586007)(41300700001)(5660300002)(316002)(54906003)(110136005)(6636002)(40460700003)(356005)(82740400003)(36756003)(86362001)(40480700001)(36860700001)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:17.4652 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96177df9-29f9-4615-dedb-08dbcb984039 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044EF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7645 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd-pstate driver utilizes the functions and data structures provided by the ITMT architecture to enable the scheduler to favor scheduling on cores which can be get a higher frequency with lower voltage. We call it amd-pstate preferrred core. Here sched_set_itmt_core_prio() is called to set priorities and sched_set_itmt_support() is called to enable ITMT feature. amd-pstate driver uses the highest performance value to indicate the priority of CPU. The higher value has a higher priority. The initial core rankings are set up by amd-pstate when the system boots. Add a variable hw_prefcore in cpudata structure. It will check if the processor and power firmware support preferred core feature. Add one new early parameter `disable` to allow user to disable the preferred core. Only when hardware supports preferred core and user set `enabled` in early parameter, amd pstate driver supports preferred core featue. Tested-by: Oleksandr Natalenko Reviewed-by: Huang Rui Reviewed-by: Wyes Karny Reviewed-by: Mario Limonciello Co-developed-by: Perry Yuan Signed-off-by: Perry Yuan Signed-off-by: Meng Li --- drivers/cpufreq/amd-pstate.c | 155 +++++++++++++++++++++++++++++++---- include/linux/amd-pstate.h | 4 + 2 files changed, 143 insertions(+), 16 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9a1e194d5cf8..58aa9ddff29e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,8 @@ #define AMD_PSTATE_TRANSITION_LATENCY 20000 #define AMD_PSTATE_TRANSITION_DELAY 1000 +#define AMD_PSTATE_PREFCORE_THRESHOLD 166 +#define AMD_PSTATE_MAX_CPPC_PERF 255 /* * TODO: We need more time to fine tune processors with shared memory solution @@ -64,6 +67,7 @@ static struct cpufreq_driver amd_pstate_driver; static struct cpufreq_driver amd_pstate_epp_driver; static int cppc_state = AMD_PSTATE_UNDEFINED; static bool cppc_enabled; +static bool amd_pstate_prefcore = true; /* * AMD Energy Preference Performance (EPP) @@ -290,23 +294,21 @@ static inline int amd_pstate_enable(bool enable) static int pstate_init_perf(struct amd_cpudata *cpudata) { u64 cap1; - u32 highest_perf; 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. + /* For platforms that do not support the preferred core feature, the + * highest_pef may be configured with 166 or 255, to avoid max frequency + * calculated wrongly. we take the AMD_CPPC_HIGHEST_PERF(cap1) value as + * the default max perf. */ - highest_perf = amd_get_highest_perf(); - if (highest_perf > AMD_CPPC_HIGHEST_PERF(cap1)) - highest_perf = AMD_CPPC_HIGHEST_PERF(cap1); - - WRITE_ONCE(cpudata->highest_perf, highest_perf); + if (cpudata->hw_prefcore) + WRITE_ONCE(cpudata->highest_perf, AMD_PSTATE_PREFCORE_THRESHOLD); + else + WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1)); WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1)); WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1)); @@ -318,17 +320,15 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) static int cppc_init_perf(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; - u32 highest_perf; int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); if (ret) return ret; - highest_perf = amd_get_highest_perf(); - if (highest_perf > cppc_perf.highest_perf) - highest_perf = cppc_perf.highest_perf; - - WRITE_ONCE(cpudata->highest_perf, highest_perf); + if (cpudata->hw_prefcore) + WRITE_ONCE(cpudata->highest_perf, AMD_PSTATE_PREFCORE_THRESHOLD); + else + WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf); WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf); WRITE_ONCE(cpudata->lowest_nonlinear_perf, @@ -676,6 +676,93 @@ static void amd_perf_ctl_reset(unsigned int cpu) wrmsrl_on_cpu(cpu, MSR_AMD_PERF_CTL, 0); } +/* + * Set amd-pstate preferred core enable can't be done directly from cpufreq callbacks + * due to locking, so queue the work for later. + */ +static void amd_pstste_sched_prefcore_workfn(struct work_struct *work) +{ + sched_set_itmt_support(); +} +static DECLARE_WORK(sched_prefcore_work, amd_pstste_sched_prefcore_workfn); + +/* + * Get the highest performance register value. + * @cpu: CPU from which to get highest performance. + * @highest_perf: Return address. + * + * Return: 0 for success, -EIO otherwise. + */ +static int amd_pstate_get_highest_perf(int cpu, u32 *highest_perf) +{ + int ret; + + if (boot_cpu_has(X86_FEATURE_CPPC)) { + u64 cap1; + + ret = rdmsrl_safe_on_cpu(cpu, MSR_AMD_CPPC_CAP1, &cap1); + if (ret) + return ret; + WRITE_ONCE(*highest_perf, AMD_CPPC_HIGHEST_PERF(cap1)); + } else { + u64 cppc_highest_perf; + + ret = cppc_get_highest_perf(cpu, &cppc_highest_perf); + WRITE_ONCE(*highest_perf, cppc_highest_perf); + } + + return (ret); +} + +static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata) +{ + int ret, prio; + u32 highest_perf; + static u32 max_highest_perf = 0, min_highest_perf = U32_MAX; + + ret = amd_pstate_get_highest_perf(cpudata->cpu, &highest_perf); + if (ret) + return; + + cpudata->hw_prefcore = true; + /* check if CPPC preferred core feature is enabled*/ + if (highest_perf == AMD_PSTATE_MAX_CPPC_PERF) { + pr_debug("AMD CPPC preferred core is unsupported!\n"); + cpudata->hw_prefcore = false; + return; + } + + if (!amd_pstate_prefcore) + return; + + /* The maximum value of highest perf is 255 */ + prio = (int)(highest_perf & 0xff); + /* + * The priorities can be set regardless of whether or not + * sched_set_itmt_support(true) has been called and it is valid to + * update them at any time after it has been called. + */ + sched_set_itmt_core_prio(highest_perf, cpudata->cpu); + + if (max_highest_perf <= min_highest_perf) { + if (highest_perf > max_highest_perf) + max_highest_perf = highest_perf; + + if (highest_perf < min_highest_perf) + min_highest_perf = highest_perf; + + if (max_highest_perf > min_highest_perf) { + /* + * This code can be run during CPU online under the + * CPU hotplug locks, so sched_set_itmt_support() + * cannot be called from here. Queue up a work item + * to invoke it. + */ + schedule_work(&sched_prefcore_work); + } + } +} + static int amd_pstate_cpu_init(struct cpufreq_policy *policy) { int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; @@ -697,6 +784,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) cpudata->cpu = policy->cpu; + amd_pstate_init_prefcore(cpudata); + ret = amd_pstate_init_perf(cpudata); if (ret) goto free_cpudata1; @@ -845,6 +934,17 @@ static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy, return sysfs_emit(buf, "%u\n", perf); } +static ssize_t show_amd_pstate_hw_prefcore(struct cpufreq_policy *policy, + char *buf) +{ + bool hw_prefcore; + struct amd_cpudata *cpudata = policy->driver_data; + + hw_prefcore = READ_ONCE(cpudata->hw_prefcore); + + return sysfs_emit(buf, "%s\n", hw_prefcore ? "supported" : "unsupported"); +} + static ssize_t show_energy_performance_available_preferences( struct cpufreq_policy *policy, char *buf) { @@ -1037,18 +1137,27 @@ static ssize_t status_store(struct device *a, struct device_attribute *b, return ret < 0 ? ret : count; } +static ssize_t prefcore_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%s\n", amd_pstate_prefcore ? "enabled" : "disabled"); +} + 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); +cpufreq_freq_attr_ro(amd_pstate_hw_prefcore); cpufreq_freq_attr_rw(energy_performance_preference); cpufreq_freq_attr_ro(energy_performance_available_preferences); static DEVICE_ATTR_RW(status); +static DEVICE_ATTR_RO(prefcore); static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, &amd_pstate_lowest_nonlinear_freq, &amd_pstate_highest_perf, + &amd_pstate_hw_prefcore, NULL, }; @@ -1056,6 +1165,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { &amd_pstate_max_freq, &amd_pstate_lowest_nonlinear_freq, &amd_pstate_highest_perf, + &amd_pstate_hw_prefcore, &energy_performance_preference, &energy_performance_available_preferences, NULL, @@ -1063,6 +1173,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { static struct attribute *pstate_global_attributes[] = { &dev_attr_status.attr, + &dev_attr_prefcore.attr, NULL }; @@ -1114,6 +1225,8 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) cpudata->cpu = policy->cpu; cpudata->epp_policy = 0; + amd_pstate_init_prefcore(cpudata); + ret = amd_pstate_init_perf(cpudata); if (ret) goto free_cpudata1; @@ -1527,7 +1640,17 @@ static int __init amd_pstate_param(char *str) return amd_pstate_set_driver(mode_idx); } + +static int __init amd_prefcore_param(char *str) +{ + if (!strcmp(str, "disable")) + amd_pstate_prefcore = false; + + return 0; +} + early_param("amd_pstate", amd_pstate_param); +early_param("amd_prefcore", amd_prefcore_param); MODULE_AUTHOR("Huang Rui "); MODULE_DESCRIPTION("AMD Processor P-state Frequency Driver"); diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 446394f84606..87e140e9e6db 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -52,6 +52,9 @@ struct amd_aperf_mperf { * @prev: Last Aperf/Mperf/tsc count value read from register * @freq: current cpu frequency value * @boost_supported: check whether the Processor or SBIOS supports boost mode + * @hw_prefcore: check whether HW supports preferred core featue. + * Only when hw_prefcore and early prefcore param are true, + * AMD P-State driver supports preferred core featue. * @epp_policy: Last saved policy used to set energy-performance preference * @epp_cached: Cached CPPC energy-performance preference value * @policy: Cpufreq policy value @@ -81,6 +84,7 @@ struct amd_cpudata { u64 freq; bool boost_supported; + bool hw_prefcore; /* EPP feature related attributes*/ s16 epp_policy; From patchwork Fri Oct 13 02:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733984 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 9D057CDB482 for ; Fri, 13 Oct 2023 02:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbjJMC6e (ORCPT ); Thu, 12 Oct 2023 22:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbjJMC6d (ORCPT ); Thu, 12 Oct 2023 22:58:33 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2077.outbound.protection.outlook.com [40.107.212.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7230106; Thu, 12 Oct 2023 19:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n1eMGRHMbCjOlSCA40BLXSayPLXA3HtxkX7E/oFWosH/KYMLbBXabVuhg2pemVsgzVehrwnMLkEysbewYQaZ0zD+VNhm8TzVm5qkDvfK84aaVdHK29+0slGVWoUrMuzIY9bTe9EsJjqLAGbgw9jlpe2+KNT6Btpu1rSyyH37g3hYgclgaji29etniv3XD+rJjFKA0VXeHpUtANivtfAVWFbMfyvlDfTkO3rMCn6xFo5+aqViz3B9ViCiavH3tVfGHBJ3ylStlYToSOYtkUeoAOAnD2oxhDS9svxZATChy1OjiJYk0lvtveWtY2ZqUJOA9ZhXFUO3o3MtPCao8qLgXw== 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=u81fCoyEPYWzmqwoPR/Ru7/X4lSkrPvJrlw7WWkJo04=; b=lnQG8D58rmGlaGfzbkuspVzBGoaf6xE4I9EO5O1EJ/tgZBQWxxOQxFnkAz1kP/1lIkIau9Xwx7EYkaJHKV+8VMQvv8N/QIt1vCl78meaoE6RC7YTIgfwWLc0AEmJRPZ40b4p+oaiG17Jn2HU4kplRFdhbrzI+32z+2naR2o2g2Q5PY5milFb934UIsGRjHYsAE2LkVcC5wNGwoF8nGC4pqs6YBg4zQIu/a7zLhh5Gi0B7gew5VbCPfydi7dSv+AjFTPe8k8fPhyZj9z5vZT7qyuGkzl+UrAtke20paqve9DYMpLegX5fk4q+9nfMkdtnUgp1FOYYjA+v595JsuhqpQ== 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=u81fCoyEPYWzmqwoPR/Ru7/X4lSkrPvJrlw7WWkJo04=; b=Vn3f9WFO2fcBcsQeudvMQxQndsp5Fyrzmez/Lw9xb4Nm6Rvcv3cLF7Irx+dL8ds17h6BYeqosT3KJ4r+QWNpszQiO/0AP8fbM5yq0PiYVWcEyqwMM9/5sclCu2pbqghQK+A6ITbyEYqVktYQ0zjrXwbHNugfKfKpii7nRxmIAeI= Received: from MW4P221CA0029.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::34) by PH7PR12MB7819.namprd12.prod.outlook.com (2603:10b6:510:27f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.46; Fri, 13 Oct 2023 02:58:22 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:303:8b:cafe::a) by MW4P221CA0029.outlook.office365.com (2603:10b6:303:8b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.43 via Frontend Transport; Fri, 13 Oct 2023 02:58: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:21 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:16 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li Subject: [PATCH V9 4/7] cpufreq: Add a notification message that the highest perf has changed Date: Fri, 13 Oct 2023 10:57:38 +0800 Message-ID: <20231013025741.3332520-5-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|PH7PR12MB7819:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d881ec1-ff1f-475f-9f28-08dbcb9842cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uwHXtwwCLV9j66cP+vs1qI4Aks4LXeJvpmZz0b1xl/r20rqjmoH3j9qtiCoLmqDyq1gTYkDR0S+oeeGWUO3zsgFazLIaZ5l/g/BnIJ8acxI0odid2I/BfQwuFq8UGFLXG49Ys2hpBIKzCxTXHyYdzat00G3zMStgdYu0nVXbPefbbEoQHPBiBpRSzFHVShpQ60fTyTYTY1twL1Af/7Wdb+kVDZPxC2LtJIzCd1hNZBB9i6Pg9UrT2q5qK7p4qOo5sANhRWRpmxY1s1ktUHzhl3VYFAbKiXO/kvRikGx8CjCy+C3j9LJsmaxB/Y4fHYevkYkpWv9RjZK/N+Yv2/9+z86ReqIryWPuFn1sHwpmMV+N9wCPyVAfXRXpSdjKiKGLqUvm+4MahUpfFp3jBI3Jj7nubYOaDRXyaKVMMdVa5JdSKyxOjPIf4SsdZnx2FNLChYSuoIpMaRS6wdRjxOq3PcU/Y+KYtq+/wij+UmncK9Lc3PTUJ+UzcaubHpbiTrWuAayZf66sU3cx2wkkYQDfG80/S5y4yuEAoViGCs03YSFaJHnehqhhQCIu6Zt8ZCMi1bxH39VJY/p11LVkY0vLHWPlZveiiyunElxkYYombH0WkjAeX96UlNepfELyvOrgDMydXiv74Ijzc7ZxXxJ4eqOGNdF/YKzPz9lsAe5znt/kz++jOD/fTXT/8I7r4+86f2TSrFAgiju+pp6YY8l1NLHUwR2XK+D1nxkKXOAco6IeHhvqSowlZb7SwFeh2SZFWtTeew87dT+2ilrE49VJE7kXKe6zBBCjOOZe5K9Dpho= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(39860400002)(346002)(136003)(230922051799003)(186009)(451199024)(1800799009)(82310400011)(64100799003)(40470700004)(36840700001)(46966006)(7696005)(83380400001)(36860700001)(47076005)(16526019)(82740400003)(40460700003)(336012)(426003)(40480700001)(7416002)(86362001)(4326008)(2906002)(15650500001)(5660300002)(966005)(8676002)(26005)(8936002)(6666004)(110136005)(316002)(70586007)(70206006)(6636002)(54906003)(41300700001)(36756003)(1076003)(356005)(81166007)(2616005)(478600001)(226483002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:21.7512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d881ec1-ff1f-475f-9f28-08dbcb9842cc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7819 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org ACPI 6.5 section 8.4.6.1.1.1 specifies that Notify event 0x85 can be emmitted to cause the the OSPM to re-evaluate the highest performance register. Add support for this event. Tested-by: Oleksandr Natalenko Reviewed-by: Mario Limonciello Reviewed-by: Huang Rui Signed-off-by: Meng Li Link: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#processor-device-notification-values --- drivers/acpi/processor_driver.c | 6 ++++++ drivers/cpufreq/cpufreq.c | 13 +++++++++++++ include/linux/cpufreq.h | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 4bd16b3f0781..29b2fb68a35d 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -27,6 +27,7 @@ #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 +#define ACPI_PROCESSOR_NOTIFY_HIGEST_PERF_CHANGED 0x85 MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION("ACPI Processor Driver"); @@ -83,6 +84,11 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) acpi_bus_generate_netlink_event(device->pnp.device_class, dev_name(&device->dev), event, 0); break; + case ACPI_PROCESSOR_NOTIFY_HIGEST_PERF_CHANGED: + cpufreq_update_highest_perf(pr->id); + acpi_bus_generate_netlink_event(device->pnp.device_class, + dev_name(&device->dev), event, 0); + break; default: acpi_handle_debug(handle, "Unsupported event [0x%x]\n", event); break; diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 60ed89000e82..4ada787ff105 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2718,6 +2718,19 @@ void cpufreq_update_limits(unsigned int cpu) } EXPORT_SYMBOL_GPL(cpufreq_update_limits); +/** + * cpufreq_update_highest_perf - Update highest performance for a given CPU. + * @cpu: CPU to update the highest performance for. + * + * Invoke the driver's ->update_highest_perf callback if present + */ +void cpufreq_update_highest_perf(unsigned int cpu) +{ + if (cpufreq_driver->update_highest_perf) + cpufreq_driver->update_highest_perf(cpu); +} +EXPORT_SYMBOL_GPL(cpufreq_update_highest_perf); + /********************************************************************* * BOOST * *********************************************************************/ diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 71d186d6933a..1cc1241fb698 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -235,6 +235,7 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); void refresh_frequency_limits(struct cpufreq_policy *policy); void cpufreq_update_policy(unsigned int cpu); void cpufreq_update_limits(unsigned int cpu); +void cpufreq_update_highest_perf(unsigned int cpu); bool have_governor_per_policy(void); bool cpufreq_supports_freq_invariance(void); struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); @@ -263,6 +264,7 @@ static inline bool cpufreq_supports_freq_invariance(void) return false; } static inline void disable_cpufreq(void) { } +static inline void cpufreq_update_highest_perf(unsigned int cpu) { } #endif #ifdef CONFIG_CPU_FREQ_STAT @@ -380,6 +382,9 @@ struct cpufreq_driver { /* Called to update policy limits on firmware notifications. */ void (*update_limits)(unsigned int cpu); + /* Called to update highest performance on firmware notifications. */ + void (*update_highest_perf)(unsigned int cpu); + /* optional */ int (*bios_limit)(int cpu, unsigned int *limit); From patchwork Fri Oct 13 02:57:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733608 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 30B56CDB482 for ; Fri, 13 Oct 2023 02:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbjJMC6n (ORCPT ); Thu, 12 Oct 2023 22:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbjJMC6f (ORCPT ); Thu, 12 Oct 2023 22:58:35 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7066E113; Thu, 12 Oct 2023 19:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ivDGmkUOy0g+BhFXmM7yJeaySjOCAjqbaRQqS/XoSvN7T6XCwe7UzZhgkqN0md9V1maRUPfoY21cLI9XiVlFHSIjeryjjbBSLBPhU3wxV6yQJpyux/whwTnovMcqLMoz3cEp3RIE0l11cbvNSTyxQu1JIY+gmV7NZaePKg2YRUPzC2L1CN2iRKjWAtF4VBdl40NoZnzo6h2M9NSAWxM+17MFpKxMofXRLjn1FyjKb6VMqH1F9blzAGg9rPOlnSNMwLDH8GfJT8B75vJFIbNWYs/tTSO1ljyetFRXCozSJtRZGlD0pGy6P9d2wDVtZehwcba6fy07/q555I9XjUN7cw== 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=mpXE1rUl8nyODQwSd71k/trHjXcB687DjkPor+RwsC4=; b=cx7NzD0S98OeeIe3EJ9oujBWf+nH50onbWFjDL4bUcmfXLfZkt4+Gy9xmmWn1tcfUO0JSvaqFF4Tv+CS2XF2tRCEn+E6/+UXpLxdX7cttm4Dahnuiv0ITKh+y6ufeQfcP3d8KiUgK7mppkD4CQNmbg/ok6SgmMv3/oMhM9zlhW2TTvYDElTJFbr90nAuAclyzAFx8ETx4SVm2/+x4sHYCrPGUCFBO7i5KNqjkghUZa4lauK1g6dmctxRwPi/0rC8peq5J2kwDzBnsg+5ZxUL7+Ta9jz/mKlnWbrx6mljz2AdgywjNDWifT7FDA/mOxhEs6i/aDVGh57IQDNm5KOkXQ== 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=mpXE1rUl8nyODQwSd71k/trHjXcB687DjkPor+RwsC4=; b=mQx5WgaVSmE7chigFRgak542FG5c6VpU0XCxG7UeVACwi+ElrLgEjj39kf9n/WbVyMdsCP1HRDodUFXiV8fCICdXnVesJkpzpE0o7qgc2Wm0yhaEWJbY5QwyS1tf8DCHICLjAMw31niLYj0alfWABsiW8rKxU+zjtzvvvnFIw14= Received: from MW4P221CA0018.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::23) by IA1PR12MB7518.namprd12.prod.outlook.com (2603:10b6:208:419::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.46; Fri, 13 Oct 2023 02:58:26 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:303:8b:cafe::8b) by MW4P221CA0018.outlook.office365.com (2603:10b6:303:8b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.29 via Frontend Transport; Fri, 13 Oct 2023 02:58: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:26 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:21 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li , Wyes Karny Subject: [PATCH V9 5/7] cpufreq: amd-pstate: Update amd-pstate preferred core ranking dynamically Date: Fri, 13 Oct 2023 10:57:39 +0800 Message-ID: <20231013025741.3332520-6-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|IA1PR12MB7518:EE_ X-MS-Office365-Filtering-Correlation-Id: d64c1185-3dd1-4236-b8a4-08dbcb9845af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9f4OQuNbEjNx40mGK9l2g4tT+82i7JFIng5+WuwiWSmAb/chYj/6Jkj+54Fz6pmkWzZUzdl1IcLt4/Tw86IDzqJa8l7igV5SzMs3f9rsCTj6JBq4JCTg3czG+gFhN6YA9XJFdvpx8fwkNmRdx+TiwdlZASSxJ7KQi8+BlLqrd0A1K1mPayoNqhyi2sFVpiyTkyRuXUs3sXZ4rboSF4cAn813VyZewQwm/Dw4LfglU9uCHhVyHBuH+gFJb9U5l1XsFlhpf98CKXgNl47pqzJrW6TgMf93G9ifXMy37JsJmx1he3vkJpcBWTYkd9kmrvzzyAaxZk2pYFQXBQ9Txl0/lrN4HlA8EV1z58bsV+nOGKm5oPll8NQUpv33DWrIqMp2yAj0BLVBrX7IfzYZlLG9P6IHJtTpdCyZpVZGNcBJwx89m+LIdKms+njX00hPe1JOsKQMd/PWvE6OMAbyhMTBvLIRtTXY1N6xZC9FsjAhqFlzQFBNC2jnR2Qstuv3P6YIX124Qd1xCiWznRIAoxraHGOOijNaAjouaIwSdHwqZnWuPXchlmBoSnIYVeCVUPOswoKBuYJ+fPB8Ot85P3QByOJ6KfDKFoZ9bqVlECt0otTMcCimiSkNM15FWUgmFMHX+KMtZeplylCfuVvOLs3OuGz1ugP5vDB/l4yS5LJ1PItHDy6G9jJDuc6PAiqg9kF8VDFwYYKvLM58Yq7zIuXuLBxEKGvjDk69+ZmAycWx58+GegPfBnrw5cxnCrtF2kMpqZ8ZT6SurcgUjjQ7uo5e2A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(82310400011)(40470700004)(36840700001)(46966006)(82740400003)(36860700001)(356005)(16526019)(26005)(2616005)(81166007)(1076003)(5660300002)(8936002)(8676002)(4326008)(36756003)(7696005)(47076005)(426003)(336012)(83380400001)(478600001)(40460700003)(6666004)(40480700001)(316002)(54906003)(70206006)(6636002)(66899024)(70586007)(110136005)(7416002)(86362001)(2906002)(41300700001)(15650500001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:26.5949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d64c1185-3dd1-4236-b8a4-08dbcb9845af X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7518 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Preferred core rankings can be changed dynamically by the platform based on the workload and platform conditions and accounting for thermals and aging. When this occurs, cpu priority need to be set. Tested-by: Oleksandr Natalenko Reviewed-by: Mario Limonciello Reviewed-by: Wyes Karny Reviewed-by: Huang Rui Signed-off-by: Meng Li --- drivers/cpufreq/amd-pstate.c | 49 ++++++++++++++++++++++++++++++++++++ include/linux/amd-pstate.h | 6 +++++ 2 files changed, 55 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 58aa9ddff29e..7e37d0d40ebd 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -313,6 +313,7 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1)); WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1)); WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1)); + WRITE_ONCE(cpudata->prefcore_ranking, AMD_CPPC_HIGHEST_PERF(cap1)); return 0; } @@ -334,6 +335,7 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) WRITE_ONCE(cpudata->lowest_nonlinear_perf, cppc_perf.lowest_nonlinear_perf); WRITE_ONCE(cpudata->lowest_perf, cppc_perf.lowest_perf); + WRITE_ONCE(cpudata->prefcore_ranking, cppc_perf.highest_perf); if (cppc_state == AMD_PSTATE_ACTIVE) return 0; @@ -763,6 +765,37 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata) } } +static void amd_pstate_update_highest_perf(unsigned int cpu) +{ + struct cpufreq_policy *policy; + struct amd_cpudata *cpudata; + u32 prev_high = 0, cur_high = 0; + int ret; + + if ((!amd_pstate_prefcore) || (!cpudata->hw_prefcore)) + return; + + ret = amd_pstate_get_highest_perf(cpu, &cur_high); + if (ret) + return; + + policy = cpufreq_cpu_get(cpu); + cpudata = policy->driver_data; + prev_high = READ_ONCE(cpudata->prefcore_ranking); + + if (prev_high != cur_high) { + int prio; + + WRITE_ONCE(cpudata->prefcore_ranking, cur_high); + + /* The maximum value of highest perf is 255 */ + prio = (int)(highest_perf & 0xff); + sched_set_itmt_core_prio(cur_high, cpu); + } + + cpufreq_cpu_put(policy); +} + static int amd_pstate_cpu_init(struct cpufreq_policy *policy) { int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; @@ -934,6 +967,17 @@ static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy, return sysfs_emit(buf, "%u\n", perf); } +static ssize_t show_amd_pstate_prefcore_ranking(struct cpufreq_policy *policy, + char *buf) +{ + u32 perf; + struct amd_cpudata *cpudata = policy->driver_data; + + perf = READ_ONCE(cpudata->prefcore_ranking); + + return sysfs_emit(buf, "%u\n", perf); +} + static ssize_t show_amd_pstate_hw_prefcore(struct cpufreq_policy *policy, char *buf) { @@ -1147,6 +1191,7 @@ 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); +cpufreq_freq_attr_ro(amd_pstate_prefcore_ranking); cpufreq_freq_attr_ro(amd_pstate_hw_prefcore); cpufreq_freq_attr_rw(energy_performance_preference); cpufreq_freq_attr_ro(energy_performance_available_preferences); @@ -1157,6 +1202,7 @@ static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, &amd_pstate_lowest_nonlinear_freq, &amd_pstate_highest_perf, + &amd_pstate_prefcore_ranking, &amd_pstate_hw_prefcore, NULL, }; @@ -1165,6 +1211,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { &amd_pstate_max_freq, &amd_pstate_lowest_nonlinear_freq, &amd_pstate_highest_perf, + &amd_pstate_prefcore_ranking, &amd_pstate_hw_prefcore, &energy_performance_preference, &energy_performance_available_preferences, @@ -1505,6 +1552,7 @@ static struct cpufreq_driver amd_pstate_driver = { .suspend = amd_pstate_cpu_suspend, .resume = amd_pstate_cpu_resume, .set_boost = amd_pstate_set_boost, + .update_highest_perf = amd_pstate_update_highest_perf, .name = "amd-pstate", .attr = amd_pstate_attr, }; @@ -1519,6 +1567,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .online = amd_pstate_epp_cpu_online, .suspend = amd_pstate_epp_suspend, .resume = amd_pstate_epp_resume, + .update_highest_perf = amd_pstate_update_highest_perf, .name = "amd-pstate-epp", .attr = amd_pstate_epp_attr, }; diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 87e140e9e6db..426822612373 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -39,11 +39,16 @@ struct amd_aperf_mperf { * @cppc_req_cached: cached performance request hints * @highest_perf: the maximum performance an individual processor may reach, * assuming ideal conditions + * For platforms that do not support the preferred core feature, the + * highest_pef may be configured with 166 or 255, to avoid max frequency + * calculated wrongly. we take the fixed value as the highest_perf. * @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 + * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher + * priority. * @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 @@ -73,6 +78,7 @@ struct amd_cpudata { u32 nominal_perf; u32 lowest_nonlinear_perf; u32 lowest_perf; + u32 prefcore_ranking; u32 max_freq; u32 min_freq; From patchwork Fri Oct 13 02:57:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733983 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 29CF9CDB47E for ; Fri, 13 Oct 2023 02:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229581AbjJMC6s (ORCPT ); Thu, 12 Oct 2023 22:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjJMC6o (ORCPT ); Thu, 12 Oct 2023 22:58:44 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98759106; Thu, 12 Oct 2023 19:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aQ4aIgv5xjFOzYEgnXZAD0r0MYPW+J3yqx3VfYl4AFvhj+BphpWCxWvju2J1n8XaLb4nze5G/NKIdRng3FKOIAKZcKi07TNPk3OAorYmh6B4Vk+s9ZT8KOMpMX+aehEKrsD79859dv8FLM/4s34vu1BNKgBUWCEYGKZXvffzaXdr1km0z8m1E1u+Q7r8EQzta6IsatdDu8bzjno196KAP2BU5dpsamWI7UB83aGNvk+DS/Fu5YJ2oDoV3oP7hC/MdulqAw/YloI+WOoDD3ACVS5K3RvFG2p9sjLPoBt3JQR/oENIhiB4XfSaS4u1UNhnbk55UNiiVxxpqUggk+vrHw== 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=M+Hf7usC0hQZ6XEfTNBCV+zk7l8w2H29ZawyubckUuM=; b=awi6crvUDHi5lCnxvmsCrw3o0YXLzdkHTr1GHc/Cg0BVfzZuH7ApVASXiwY2H24DAnzBkgZhSlEHiD/SJfVI/R7p2/40ps0Lmgw/KIUrJ4KGonDGsAMm8FYhqIYUgl0cxKRQaoEMGglSfHuLgrmn3ZrJERbmtM4H0D81VVJvvRLULvwRaSy/6IkEi9xmaQTEnVHGQ+aTrv/tWsLeZ81EkHShCPE2YBKHfAK5nLyA8WdraFKD88ut1OBHynw0YLJ01BNuHz3naA6XDcXOd47B973lm+iFM1Mo4Rc12yxJ2PlTA8SDEWXzyFT1SL1AsHHTCQhSMYzydBtOJTOedanUfw== 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=M+Hf7usC0hQZ6XEfTNBCV+zk7l8w2H29ZawyubckUuM=; b=ar66tvz8yQpzJ2SvToZu5xvt/jl0E1iMpuHSENQDa/C1/WVLiaD0cipfk16j/6/8HGcnYcJtKTb8dBw0cxriOxAWobQz3khJJ+xIE3ZKFg8z/FnM/nshfClQXC9G9ERegecVWCEbexU7jIyIk7eT4wGx0TeUj/R/JAw+13suAwA= Received: from MW2PR16CA0037.namprd16.prod.outlook.com (2603:10b6:907:1::14) by SA3PR12MB9200.namprd12.prod.outlook.com (2603:10b6:806:39c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 02:58:32 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:907:1:cafe::7d) by MW2PR16CA0037.outlook.office365.com (2603:10b6:907:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36 via Frontend Transport; Fri, 13 Oct 2023 02:58: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:31 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:26 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li , Wyes Karny Subject: [PATCH V9 6/7] Documentation: amd-pstate: introduce amd-pstate preferred core Date: Fri, 13 Oct 2023 10:57:40 +0800 Message-ID: <20231013025741.3332520-7-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F3:EE_|SA3PR12MB9200:EE_ X-MS-Office365-Filtering-Correlation-Id: bd6e18d7-1a6a-4a95-1cfe-08dbcb9848cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xR/H6tdRKlYC+o8RIteZu8eyT6eWOC/HMcD4lQu868QLeJu9TqjNO5+UYHMlKtI4M2jWNxNtt79nIIsaGTT/6d0fRrxqPE4P1F/5oebDWLyaVeGu9ohP4OuRnVcm8xIgFsIPZqbACefC4Ba9uVmwngpsjXexxLkjTJEf+bKVeDy/yJNEGP3PX73PpZt6FbBjoHV38CDqykSdUeSujN7szzRCqSj9CUXlGlyFoOtHkfDo1+SEbNWgDJfRwKCWtaulL3hwsWrHX6GQ7aWRkeg+cOc+eF7A7itGC9pAWLfUuHN+NT3rITACr/gOfzCQZlQW2yLU6x7H65PUz36lNtXB6EUF1K/NZVQhfhfxT46Y3Rp+Ztj4EcVd8XX8KbnIfRmKVJqNiKfP+lOVC8A7ecoWOOmjCFtIOVEDRp8iERiypy5WfACrfk7DQSLFx29IZIsH8TGSTHvGWhI6ztIOtIQf5lEeaDGmoJU/NJT5QOEDxj/7naN1+z0bs3QK2FHwtJnpGZ0fVd3M0UIeDNVFbo7+TqpHiFGdiIkQMzut1SWR9KkZR+SdFA5qZPOFpQ8+41wbNxpxKSt0eID94kBmzFRjQEtAklEHt8bz4TyfHLKGbSUq2iAUVm/Q9lI0PfBwI7vCThc9/WUm3ZMZDbgif5EtcwmiagrC6QUpN614vi/1vCqeofUZoJhpEl8NebGFHrCdA1Nj1/1j+8RExPnXkE7GcIa6boFzIjt36CS7VpITuTEPwb4j+hUPLsXa30L5FAuoBylduCU7TsRSAeQr3NcufA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(39860400002)(396003)(376002)(136003)(230922051799003)(82310400011)(186009)(451199024)(1800799009)(64100799003)(36840700001)(40470700004)(46966006)(4326008)(8936002)(8676002)(54906003)(70586007)(6666004)(70206006)(6636002)(316002)(7696005)(5660300002)(26005)(2616005)(478600001)(16526019)(336012)(426003)(1076003)(41300700001)(110136005)(40460700003)(47076005)(83380400001)(36860700001)(40480700001)(82740400003)(81166007)(2906002)(356005)(7416002)(36756003)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:31.8076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd6e18d7-1a6a-4a95-1cfe-08dbcb9848cb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9200 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce amd-pstate preferred core. check preferred core state set by the kernel parameter: $ cat /sys/devices/system/cpu/amd-pstate/prefcore Tested-by: Oleksandr Natalenko Reviewed-by: Wyes Karny Reviewed-by: Mario Limonciello Reviewed-by: Huang Rui Signed-off-by: Meng Li --- Documentation/admin-guide/pm/amd-pstate.rst | 59 ++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 1cf40f69278c..0b832ff529db 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -300,8 +300,8 @@ platforms. The AMD P-States mechanism is the more performance and energy efficiency frequency management method on AMD processors. -AMD Pstate Driver Operation Modes -================================= +``amd-pstate`` Driver Operation Modes +====================================== ``amd_pstate`` CPPC has 3 operation modes: autonomous (active) mode, non-autonomous (passive) mode and guided autonomous (guided) mode. @@ -353,6 +353,48 @@ is activated. In this mode, driver requests minimum and maximum performance level and the platform autonomously selects a performance level in this range and appropriate to the current workload. +``amd-pstate`` Preferred Core +================================= + +The core frequency is subjected to the process variation in semiconductors. +Not all cores are able to reach the maximum frequency respecting the +infrastructure limits. Consequently, AMD has redefined the concept of +maximum frequency of a part. This means that a fraction of cores can reach +maximum frequency. To find the best process scheduling policy for a given +scenario, OS needs to know the core ordering informed by the platform through +highest performance capability register of the CPPC interface. + +``amd-pstate`` preferred core enables the scheduler to prefer scheduling on +cores that can achieve a higher frequency with lower voltage. The preferred +core rankings can dynamically change based on the workload, platform conditions, +thermals and ageing. + +The priority metric will be initialized by the ``amd-pstate`` driver. The ``amd-pstate`` +driver will also determine whether or not ``amd-pstate`` preferred core is +supported by the platform. + +``amd-pstate`` driver will provide an initial core ordering when the system boots. +The platform uses the CPPC interfaces to communicate the core ranking to the +operating system and scheduler to make sure that OS is choosing the cores +with highest performance firstly for scheduling the process. When ``amd-pstate`` +driver receives a message with the highest performance change, it will +update the core ranking and set the cpu's priority. + +``amd-pstate`` Preferred Core Switch +================================= +Kernel Parameters +----------------- + +``amd-pstate`` peferred core`` has two states: enable and disable. +Enable/disable states can be chosen by different kernel parameters. +Default enable ``amd-pstate`` preferred core. + +``amd_prefcore=disable`` + +For systems that support ``amd-pstate`` preferred core, the core rankings will +always be advertised by the platform. But OS can choose to ignore that via the +kernel parameter ``amd_prefcore=disable``. + User Space Interface in ``sysfs`` - General =========================================== @@ -385,6 +427,19 @@ control its functionality at the system level. They are located in the to the operation mode represented by that string - or to be unregistered in the "disable" case. +``prefcore`` + Preferred core state of the driver: "enabled" or "disabled". + + "enabled" + Enable the ``amd-pstate`` preferred core. + + "disabled" + Disable the ``amd-pstate`` preferred core + + + This attribute is read-only to check the state of preferred core set + by the kernel parameter. + ``cpupower`` tool support for ``amd-pstate`` =============================================== From patchwork Fri Oct 13 02:57:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 733607 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 9FE72C41513 for ; Fri, 13 Oct 2023 02:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbjJMC7D (ORCPT ); Thu, 12 Oct 2023 22:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjJMC64 (ORCPT ); Thu, 12 Oct 2023 22:58:56 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071.outbound.protection.outlook.com [40.107.243.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D0DDDD; Thu, 12 Oct 2023 19:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oA1AU0d/H4z2Xbg8YRvgiUQ6/MDordUJC9AZgUqjDgp/9KCKb86HISriwhXW8XbdSKQKXnt29lIU579qZARTicMzzWio7RO7xwPE75Mtjc1YV/r2XjMc4B/9cC9kO/fAJAMbz1aYmpZWx8exfSXQXJo/GWqEXKj80/brYZMflFV3enbf+poy3ZPbym4LAgcBS8ezFB3/LmfeMmxHVVaTOHMtcEEiiBLV3j2t7Xf0rAkY9RvUqZp7nTSD5om8zwrP3+LewNefOIsELic84qawlEAIursC/sd5afQc5rDSlIYiW3yYTmTa/XgXQSvVgo+qIqIi5TsYOpzIUwrmglJfQQ== 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=3BATVT8xDKQmxK5ddKWQeikq5vTddHGyEfuh2meRohc=; b=YCxqq5dxEVLUoflJtK+1gEgDwfmFQ9uOPP8LQnssYRoBrJ51qmbeYOpFZJHVsijJjn0WG/rLUkBoNCutK6eJcgUq6aoV9QkAPyCdW7BqfCHmIhrhyfYEqfz5rehBuJwJ8g/5oJzrUpoAaP2VVGrKcVnztd6WlLlwfLLCDoQ7OPSyUvTRj9nG+0tl5IpYH/IUAAF+4DHWLf4gK2vSSa/TU8hptVNd5MDUGNZhJQW3MRkP+nZnS+Qq2ldOYRveRyzD9+nV9oRAX/qVSbGQ6kPv63vjWPgaJnFsb4rrY+kxzdMyE2mYAOWDcWMAzpcjkv+TuKFyZgIpTLyhKUGcMNCODA== 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=3BATVT8xDKQmxK5ddKWQeikq5vTddHGyEfuh2meRohc=; b=IxW7pDJCVqfuJRlAT5gnjvuxfWZ2CJs3vqP1sCqA/NcMbe5l3K4phA7u6ahk1Jt/Y4ag3iUWLX9FHVgEl9XltEBIzpAp7U/RjgOTly4TdBL9aqb+eijCtENuMmCEsFVKDy5qFWu6i1kFXmUHfqcAW5uYo/KMME5pzwJpVMpCYmY= Received: from MW4PR04CA0260.namprd04.prod.outlook.com (2603:10b6:303:88::25) by CH2PR12MB4876.namprd12.prod.outlook.com (2603:10b6:610:67::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 02:58:37 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:88:cafe::1b) by MW4PR04CA0260.outlook.office365.com (2603:10b6:303:88::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Fri, 13 Oct 2023 02:58:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 02:58:36 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 12 Oct 2023 21:58:31 -0500 From: Meng Li To: "Rafael J . Wysocki" , Huang Rui CC: , , , , Shuah Khan , , "Nathan Fontenot" , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , "Oleksandr Natalenko" , Meng Li , Wyes Karny Subject: [PATCH V9 7/7] Documentation: introduce amd-pstate preferrd core mode kernel command line options Date: Fri, 13 Oct 2023 10:57:41 +0800 Message-ID: <20231013025741.3332520-8-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013025741.3332520-1-li.meng@amd.com> References: <20231013025741.3332520-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|CH2PR12MB4876:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a06fa91-9e31-4d93-0640-08dbcb984bbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WXAQELx4UB6K4K7/BxYZxajtXdm+MsQoQ8GIMc3MZtv7lBykuwLrFjEFHKS4vNJ1ROto9a742LMHKI+dlL2LhOM/V8AdLHW7mQa5yECm78Gop5XlA12G1mYa6QL7n6sDc0GX5LGYNYJkneKphh4o/kTrOzLBFXON6qiT6IV0deN+6RleEk6L8PTLh6jSV8esCe3obeVUBW2DUR186LXQfIl6sKtNyf6S5/Nvrj9InjfPKdFx2kx7hknVq9TnH3eVFB0KlpbD3+TVKWWgLq2mssTH00aUdOSDNg05bO7N1vaBfwqgc/IKnUGQ46DnXtnmKo01/RNlKsYTfSktp5fCbE9JqL1KPb9LYAHIFnQN4o+k7r4yS+KjncjdERTUmyi2qco1QBBJMCZXUcptDWNxfAaXzXadiFIIskuq8vBXtQKn7PeYMbR0y843UK3jH5mHM6BM5TagfKRfqwazm4LTqQo3rZvwpBRnPpNBt6r2EINeufcWAtAwmks8lC2ty/7sFq6Puj3cX5jC9KdWvhw/fMDzw6Um40Z0bZZs/Tp2i8nidmKcIrZhWvJroxdNJAphNi2UBCCBhodahvfOYx4AyzCnj2CJuhJo4IXxbaxDHPpgKJ6Gdf0OBgVRZYXjAVILq0SRXt/W/YLODMscBtqAxCtTKpy1OCcUqVyyOC7KWcbZBd0OO6DpF017TTx+ltekTcVMEBeyZrjLtt9K1TR7TZK767awhvDraAEV7rXi4r+fZrVDBKWlN2sJDvSqKhfcChZ+BCd+t1dBOhJtfiqrzB5qdTwnUqByT4y3FqIzqeYyLAkOb6li+BTd3QX99RlN X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(230922051799003)(186009)(1800799009)(64100799003)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(54906003)(41300700001)(316002)(6636002)(7416002)(8936002)(8676002)(4326008)(478600001)(70586007)(70206006)(110136005)(40460700003)(7696005)(82740400003)(81166007)(356005)(86362001)(36860700001)(40480700001)(47076005)(426003)(336012)(83380400001)(26005)(2906002)(16526019)(36756003)(1076003)(5660300002)(6666004)(2616005)(36900700001)(14943795004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 02:58:36.7666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a06fa91-9e31-4d93-0640-08dbcb984bbb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4876 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org amd-pstate driver support enable/disable preferred core. Default enabled on platforms supporting amd-pstate preferred core. Disable amd-pstate preferred core with "amd_prefcore=disable" added to the kernel command line. Signed-off-by: Meng Li Reviewed-by: Mario Limonciello Reviewed-by: Wyes Karny Reviewed-by: Huang Rui Tested-by: Oleksandr Natalenko --- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a1731a0f0ef..e35b795aa8aa 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -363,6 +363,11 @@ selects a performance level in this range and appropriate to the current workload. + amd_prefcore= + [X86] + disable + Disable amd-pstate preferred core. + amijoy.map= [HW,JOY] Amiga joystick support Map of devices attached to JOY0DAT and JOY1DAT Format: ,