From patchwork Mon Oct 28 02:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839289 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2067.outbound.protection.outlook.com [40.107.220.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00C311885BF; Mon, 28 Oct 2024 02:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080998; cv=fail; b=DPYrfhZ0sDG4XTNYHebX+MGBdwCxhxhX6RtXLgY3z0U6R+jicGyo2kEWdJq8AisM75BmWyaELK700WuGud03wcj+0HkxNi7DxTMRJBcJFr6e/2JhqqLkRokCdi0DNR+qXogPXWtKCYAC2WaY9CibyEiPi61FY0u2c31kNLn14xo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080998; c=relaxed/simple; bh=CCkmceErCb/j2gFvufuZkzoxAkR6JEeyG7gxO5N1uQU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dhNKphWs23ffqqriUXEUCIzecJ0utkz/ytZqYHpulk/NpRkBbOhWaY3WscvtjKVOTcnH1W09mxOj3KeK7ughhtlgy42He+X8q8FKBk4fnbFH2aVdJ+3nKY4U/h0n1GJqeL9xXvC59BXht+XCMvi5owFfRUkzwmBbSrF8mWaErkQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=i7WWgpyl; arc=fail smtp.client-ip=40.107.220.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="i7WWgpyl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S9yJ4RzwuaXHXo2Zn1RD+hbWEu/U4BAm7jt1Uuj6/kCO5BHZGs01cRwgpr0JjLCmvZo0MRKMSxmcQ2NF3zDNhsgwMSd86zCZoKVreK4FjjgzdzOVF6g4DHwX2fHob+PG3Xf2u5ERDMdSY97cb3pbNqbaXA5mTNzLFYBDWjpbt7U9PSMiQ+z5TZXpsuUqvAXDLLE/JOIcHCZwGYOUYFK+9Tf5GIE9S0U7FPzsLj0YcH0qMEK+zEjkk2uZIg40zdyp+AWp+qdCHg5b6FP7/UF8prtAK3AI8qNB1OrQT4YTqeFSrWczZTJJpbtnrMDLeZAbarnv9Xm5x810NmUu/gNcoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=1dtm26VWZsdxgOSbXChHpJAJvwwSusxTcg9XCfWU258=; b=Ewmw4DVbySd76y1k+0/MYIML9pMUDoajzZgSU3NIDsZ+oHmQMwYlV54QFWIuOqt5RfSeXIRDk6jYS8DQzTOAV+0wQS5S+AgSe0A9cxlkFjnvnKarLJgN2xqNQjGllFNR/YZhh7hbKCWyCGr5GCAl57Ds7jJVJh7aGqlVJwl/HTCjs+2Yr9G+Tl70iBAvpyOWGqil64z52QTXQOmkwtalfvWu1PvUCDDwQ3pbii71amkw8AgNugYCLUGhTlc3dDL5nN70S49jCDjukHR1gddy2oIyWpjKZ1wluVB/IhumhIRLFOsylBAAReFHpq7svRCnO9LD/3wGM2iOORHmtKlm1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=1dtm26VWZsdxgOSbXChHpJAJvwwSusxTcg9XCfWU258=; b=i7WWgpylTF3zcKM9SytN2psS9aMZ6Uwr6BvsJM962kHew8Og6DQjEvGpCDlMWjwHwPiFnqbMF8GD8MtyFKMxBatZFo4PDY6Aiw+hO0Ab1EhgOpwfhalr5BZrKHOIawXvIHX1z2DOYYhOhNyYTeaUu9MOZ11NRlR0dsixXn7XMTU= Received: from MN2PR06CA0023.namprd06.prod.outlook.com (2603:10b6:208:23d::28) by SA3PR12MB7877.namprd12.prod.outlook.com (2603:10b6:806:31b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Mon, 28 Oct 2024 02:03:14 +0000 Received: from BL02EPF00021F6F.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::54) by MN2PR06CA0023.outlook.office365.com (2603:10b6:208:23d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:03:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F6F.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:03:14 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:12 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" Subject: [PATCH v5 03/13] x86/cpufeatures: add X86_FEATURE_AMD_WORKLOAD_CLASS feature bit Date: Sun, 27 Oct 2024 21:02:41 -0500 Message-ID: <20241028020251.8085-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F6F:EE_|SA3PR12MB7877:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f4d552b-0209-4085-dc6a-08dcf6f4ae90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: xqGrxs/kE32ewap0LALrv5laYvqf8awISVXa85tnAcbmGVC9oK6r6xJtEndlw38EMLYdSUZ+upT9ZYVosrY9+O34p1R+Mqy/iRHYJxTIqEzSqwX8ncKdR4SGs8JFPu3LBxJnE2upHXHJbw6VdQRHNA3CP4209CnMMJHk2nX02XlCISjnYsbizjreO3hg/SVAzWY2tD6hzggF1w1nObVQxxEBmQhdXnqVF23jYQtZ3PgXVgY0LZ5He/MrOSsMNJ7poBRwSfqOjEwz+Lpiz0+SuTdnaz9BYonbbWVvj73oHWiIiLxfx4CFmtwC0EG3+fNBy5195kpNCI7fTBBdq79hPl3kxK72Rbtpxb8k7vvsOOsLtm3OHkUu1mdEDCZk16COA0TcQr1uRumpnAo/zzRIIIX1JUw+N9iNM3bBOhJoSY+JICV42XDYMmjT0qe7Wt/3FUYbg/5Z6UjX3wTsVp23Ms0gNqlMeBZ7denuPa12omKv2cGeknlNFx/8UlAmxeWRKwcjlLxUPX+3yQ3o8nErfCWnZgH+kMR7HHu9VN/bYX7I3//UuYECQNWfd7+hbxSg3RUhgmMkVTp48KIwcKOF1e9sZyy0lvZVZeUHTcbhEVBXPxFQYNjDtqHvhWVfuEGjC3fCytsHkLvFRVDCWOX/0HnAsN3cbaDmtgmcKJ/VAOlkMhoEIi9gV1ElpVgqx6+1BSXleMyHiGt+cKaQ1K7Vn+P9hwO/JNAUETVdNo0pUSrtYJa5YhoOtC5cXmh61s91RacVlZxK029rL+RgrZ8C8FGLSQvZ5x7q7aupJOrWyKkItbfkn3EGt/L/iNtYNggwnE2WHZnDdMNTZJNwoxcOkGfpQH07rE3tacNTKpvBpZpFH3++R+mu/3R8jg7aq4uB58mfJqRd+X/9kS3P1YPmBNbbIfxgP6kmvQmmA50tT4mBigvtQ90GM/IUSOLLSn5P4ps8CcnT9q+t60B/rizEAyHHqKzikVShq5M180YC45IrJNPG2uF9NfYFbbAvUaC4nSiOCGxMgq6DoG4qnLr+MTiELv0bSDmYEP/5XsCqROL5cmKcLksGeTDyja4riaslX4rs9YP3jGsz0SYoynI/fu4fn0vEhZwbqyqJ3rOJXLZNrYms4eHO9GPQ6VgMPoxcNpSihv7MR8oH/9V15PT7Sa4SMdStT/WFZJ4KpnNlNeMV5MRJiKlw9B749xMJ9UidXhcDIfsxQA4gLzRBOF0U0XXVOi2MkvAXhImVk41rJKgxVbw7vle/+RkA9KnGdGDF7ZsdtizeCr0I90qvfWaa8wFKZCExpFlRvvf4uN+MewGZbW7VnqhdiYGosILwXcSAVRh7ZVbtqu4SXDQZIEkjrb/kqLH11ud/VFI4sG43ac65oWp23f66iF09wOpXzNoWo619ERRlTNqCfAYGue4Wrg== 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:(13230040)(1800799024)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:14.0325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f4d552b-0209-4085-dc6a-08dcf6f4ae90 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: BL02EPF00021F6F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7877 From: Perry Yuan Add new feature bit that indicates support for workload based heuristic feedback to OS for scheduling decisions. When the bit set, threads are classified during runtime into enumerated classes. The classes represent thread performance/power characteristics that may benefit from special scheduling behaviors. Reviewed-by: Gautham R. Shenoy Signed-off-by: Perry Yuan Signed-off-by: Mario Limonciello --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 1216a0588ba8e..05e985ce9880d 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -474,6 +474,7 @@ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */ +#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */ /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 307a917415343..1e54332594443 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -49,6 +49,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, + { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_PMC_FREEZE, CPUID_EAX, 2, 0x80000022, 0 }, From patchwork Mon Oct 28 02:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839288 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2075.outbound.protection.outlook.com [40.107.100.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 090B4189918; Mon, 28 Oct 2024 02:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081002; cv=fail; b=YnAdm6g84/VjKG44tIm8ycEuECxtNiCoDJ7Ah2p0o6hqzuRb17aICQtvHE3W49r1BRCLH5ey48lxr0cgWRxCs8t+tcxsYwxeQ+Pj04pDaaiKlLS+R05ZIJ5lz3WX7ZMOMJ3xBOPXa2v6gQhTvhLxHY5wH/5RW736IPHorsktbMw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081002; c=relaxed/simple; bh=6/GNpT2p5G0nMQWNGh63AxQqGIghyA/swYKFuepemJE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p4DWB4knOwUEK+uP14cJPGPEGdASRG1VRMUUaIhySuHA73nj2EcM8PcDNPlZj0awh4uiDg3VA1XPhl2YhJFuQlNpLuyGnYdgfNcPx25txtYQf7O8nv5AdJwRcuc/ccr1RD3FvExKS2qsBttNdu7Oy/A2jJkYkYXcKr1LdqVAAIA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=YbcBoiG8; arc=fail smtp.client-ip=40.107.100.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YbcBoiG8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vKpKHwuhHeSXuotvnUOF9u77WbeiseYgHXa7w+K8Y1G17ia+PZ6ahWPG+BFC1mFBIKS4d+c7uGRxQ8ulIXAzQK2Ieb8t8OyLE8GjwdAlaQrE2LsEplzRWorZmFxCH849OPwpRLa/pJObImmWH3jI9dfug8b91qvue+x9HKcMobarlXqzpvBDsfJ/l59GLmHvOZdsWuFi5jtcXpb558IDk7KP+RBfl6KgV+rjqmxpnnZLyeWblB4569BPLJs+DJv9g9J51aOxfvlbR2vQE08FnzMwbPf8NtJy0nf/SDDffMhS/nt4drg4+v0nqHO2o4gfObFk0ohPC3MgkqkX4sNTgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=MK4bqI2kTIwrrtnwYodnqVtCHNR2bI5U4bV4Sc3i77M=; b=T+YnyB4FvyMZRZGC/CY4g7RFYcz2jzUf529IV8CMKpYhlKLMUXvdZi5ZS9SgJDwtiCaQzOEp90PZIRzAnEIq2TeOh3F5ngY7rlzcRCoiUmCy4T57bp7oWswirM7fGbXov9W2fsqkoQy6p1vE9wL0GQlI2F0t/gJCqHi89t/IZxNBcfK9RhzpEUJAUhIrGRSdqpgRTaYuOUKw2TUaxP7rGwhh1/vvHYfMwPUHw+Wkgsj8Nds5KXmi478Yqt8iO+m5WrgSbehrBRSL7gaUr8YosewkSu4uR3xrAa+a6aFZUdgpy1qq2CMNHiNv0/hxO54WRzyABvmCdnAhfYJ/9+a0gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=MK4bqI2kTIwrrtnwYodnqVtCHNR2bI5U4bV4Sc3i77M=; b=YbcBoiG8JLlpG/jMm5dWF3cm62xE8WyRG1Oj0a01eeSg5Au1c04Y/iEzjo6AYb/V+y/83zvK3T3QAvN+1AtMzRzaDHDs6fIw7E9qa2z00IVp706eGIP9BWIBAcjW74PgI6uMpkttHFapiIEf1kwB85NgTGrywbRC+QvYjTt9mI0= Received: from MN2PR06CA0013.namprd06.prod.outlook.com (2603:10b6:208:23d::18) by CY8PR12MB7337.namprd12.prod.outlook.com (2603:10b6:930:53::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Mon, 28 Oct 2024 02:03:16 +0000 Received: from BL02EPF00021F6F.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::4d) by MN2PR06CA0013.outlook.office365.com (2603:10b6:208:23d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:03:15 +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 BL02EPF00021F6F.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:03:15 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:13 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" Subject: [PATCH v5 04/13] x86/msr-index: define AMD heterogeneous CPU related MSR Date: Sun, 27 Oct 2024 21:02:42 -0500 Message-ID: <20241028020251.8085-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F6F:EE_|CY8PR12MB7337:EE_ X-MS-Office365-Filtering-Correlation-Id: 66a6bdaf-5df8-44c5-f829-08dcf6f4af8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: /Jxh3DSewsjOMxKl1Y3r9aKsexnFaLfGS1FLTDgF4K/ctF7XExWK4INGE/AKqRP/5eCZ6sRAtB1ycVkbZZSUguIGX8TGZTsjCaGdVfYdLWd4D90lHiUbhwGtAA3zw0Vg26jnMGLvkOM8hyR5fEeEmpgN96+UAENKpvYiRiseznA+E5a1dX+cpn43Xi5melUZGoINVSXj6zH6141wqsRcBoWPLryWmBoY736bfoWU5riGI6lpyX+UlNenFHXhVqsUMiB6dcqc1LDLjlFaFRvYLGqH93Kd/UUtOoValntG0O6wpBOqt69Cna0BitMoVk9biVraeJkysL6PKqqKaEUEg/rZ0J7V/NNqYuV1ssTcf5I4g7f3b+bY1abty/EIZi4uQDWyEWtXEaYxfH+dHbniSC/842X1VjTzP2AEEaGbfPFm9LZenB0g8+dX1dCeNaimMkyk2sybGEzkbfvBqRegcXGrYKyrOl2eFC5nb8/wcebNalpHFpi5xKAti433m1QHgueEnx4/tMRx2LW/My7x5fBqSMVa/YtiV5l+dvI8+Xx5uL2/YqKxiuYltSea0yWICpBhQNGm8zW9MPFeHMd/E47gtuTJfA6TR7DWVvAaYldFKyn1FRIOqJmGLcS2iLPB4g5vRIIfxwjzlOK9ZkMv1FJcoTqnrKsnxTSq70TsXI9gL1XWEL6R5Udvr7CBXynFmzm7SEErRDDP3PYx1/pKAChLzbGhDdFuaOUmqPAKXYrgS5W/415hiISWEeR2w/BKvnnFqvdnCDwebFBIMovG9bEiEr62aEMs+S5q3A32gbPXDeOzHFAoiArFfyDllk281SYUO9PZLy8keFhx8uY1MP9HOqqOXoASqqGQSTHcOOzJhZ8RtqCEI2hvJ+VWv5r/NVry6SPkNxOhDLMAF4tibQxo1JX1ENATl/Xpy/p49Fz46R6s92oQzqLpSChIhWiuvHQDy3TyrkUNQS4N2ktOMNOX862gLA5o4DNoKWhjwZ6L6CnUkDYGGXJNy+VKR+wPJH1iUj2juKToFxsh+AG6uf7VVZCk6BsBOSsMiizDOn8awZlNTQpOkUGEBgDPXCrDVd11itJoeCpLWw+jCFPgBKoklO9RA2rVkzd1oUGa8asFO7vm0I/ltggiHm+effNETK6R/To+kLBlZcbv0rX7zIlC05Kp0SI/vscLdzYdJpIk+8MaCTAkjEjTADu4jhoMfSRwJzRHyQUWftwpXSBk/zVlo7oelD0TGooLdgS4b+FWDNwx+JBmKkMI5rhmTYRgiS33NRM52UlM9iuUVhnDffN/FM/pMX9LZbgOArCS3/bVGfi2O26hdL7t+D/AsLuO1gsHv5k8zH+Nxn8aJRusjO4f5dIR9Ak7dl6EeEp+wOgjWNqgYlsItCAsUemKq4wPYKlB7h7Ff5f9xzheKy4rUw== 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:(13230040)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:15.6887 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66a6bdaf-5df8-44c5-f829-08dcf6f4af8f 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: BL02EPF00021F6F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7337 From: Perry Yuan Introduces new MSR registers for AMD hardware feedback support. These registers enable the system to provide workload classification and configuration capabilities. Reviewed-by: Gautham R. Shenoy Signed-off-by: Perry Yuan Signed-off-by: Mario Limonciello --- arch/x86/include/asm/msr-index.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 3ae84c3b8e6db..0cd5ffe50f4a4 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -712,6 +712,11 @@ #define MSR_AMD64_PERF_CNTR_GLOBAL_CTL 0xc0000301 #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR 0xc0000302 +/* AMD Hardware Feedback Support MSRs */ +#define AMD_WORKLOAD_CLASS_CONFIG 0xc0000500 +#define AMD_WORKLOAD_CLASS_ID 0xc0000501 +#define AMD_WORKLOAD_HRST 0xc0000502 + /* AMD Last Branch Record MSRs */ #define MSR_AMD64_LBR_SELECT 0xc000010e From patchwork Mon Oct 28 02:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839286 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB3F6190685; Mon, 28 Oct 2024 02:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081006; cv=fail; b=gBs1i1GF1D3PFCS0KZQmWAbppPCTuVn3ZjhZmpCn86F3WvDs7x77xmdPcItafQjTckNgHsaSmIh+AK7QJZTD2qB6mIdb3YupHoy5AIZz2ClFiqPAu8uflVegOjAYSmX0QbBWZIRimTHayQXjSKPS/dkSnC/KWet5BSAGpNAdvf8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081006; c=relaxed/simple; bh=bDG6YPlTYyO5FxN5nPIcCuN3qUVAj9w1jUAV5gAiOVc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dkjMNHymeva/2lI4L6nCT+ehiEK7uLSZc5z1vdYIimugYWDieDdfz/RGM4c/iETUjrw8Iy07B9xaq5LH+FxI/sFCXxH9nvFrlhuVsdzdLdI/wC5I68Bv8KX26peWYoUcPv8K8cgyvYYSBN5p37NpmHQg4b1as2EO70IWjyO5rwI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VoD/2auJ; arc=fail smtp.client-ip=40.107.237.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="VoD/2auJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L+VI8SfQwaG9hRB6gLv8D0VUPop3eMWBfLbwbHLXlCHJYA4tw0J5ugSfYjiQz0SWmCeI/BTHnKkRk0CEVome0WnznSULhVoOwaERJwBXdS+kbh2hSoHRXAPyrRTf7p8G28GlGBxdPFo3UpXxEsoTX2F9ZDdngA67O6Dv1Wg45VAAAXjkPvaPtnxlA9ARYgnVfBC4wnUazKRzVUI9Z4Zk1rkotiSDwO02pCx+zvs4VDR6aYDnQeImBMZS9eatzSH0UNVyvQz9m3rr7nAo4gj7MdOco4yWm1//bDvHIe33M8C8WK9cyrqpB0KVpOA3kN6oT292GuPgu2mwNLVhyBvQKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DIWBewZCbvsLy2Y8C+VvYVLy64BV7JfQyT2KFRrIq2g=; b=ptn6ytXHZVwnIduTzjNNbUAWH/ai3RhJL1oXKrazug28bN1k4G9rBYX3aCz4LrOMxSDgOCIJr05IQR6USwNi7sTvitEFbPbQlfkDmWoB3nDFPeY5BPpqn7G1RDTTD4PoCPbpXlZEhxhR2y/MTDGFeQap5q4J/o+1GKP2YEHXBetNjYplxkcSMiTt2msEoVaRBvLA1T6HdG74q7WOSHrgk0Pfa2az/uqTw876RofTKmYrVwlxEC+e2a1hI8kKBV7kTgFybJ2W1ucvS232rwkjfBlpUBNSbgPA5P1CPSQ6BZZnZA8UaMHigBuJltQBebQIie9suzWV3IFwQvg/SwsTXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=DIWBewZCbvsLy2Y8C+VvYVLy64BV7JfQyT2KFRrIq2g=; b=VoD/2auJ77YlOrSJbhBPU3NfMAkYAeaECgchB1o7S+6E96kqCdNVPfOEVowUiLw3e2z9OkRkqOTDGbleelHDIf4g9OR1Tav02LnuL3ZGYoe8LyE8sdczQBta5jDkoa3FgGuIQ4nNrEED97hI9G7oUT39oifIBYEtNZuaNnl4oZE= Received: from MN2PR06CA0023.namprd06.prod.outlook.com (2603:10b6:208:23d::28) by DM4PR12MB6542.namprd12.prod.outlook.com (2603:10b6:8:89::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Mon, 28 Oct 2024 02:03:17 +0000 Received: from BL02EPF00021F6F.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::d8) by MN2PR06CA0023.outlook.office365.com (2603:10b6:208:23d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:03: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 BL02EPF00021F6F.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:03:17 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:15 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" , Perry Yuan Subject: [PATCH v5 05/13] platform/x86: hfi: Introduce AMD Hardware Feedback Interface Driver Date: Sun, 27 Oct 2024 21:02:43 -0500 Message-ID: <20241028020251.8085-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F6F:EE_|DM4PR12MB6542:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f485666-def7-436c-13e8-08dcf6f4b08f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: uwJB1hC+b/c7AtFxpJ8jY7JIs/GbDHtlLevQCL3TKPcS6iBI80vCOflo62xaxElgyVjI+xCKlmw0IcyPqtAfavOfjW/ukjScyUZCrY7K1fyP1hnjuC0cgDgWDuNzEoutDz8qVbfyafEymC0AQfeLYl0CfP0TITDY35AgdVc4QWertzyurStaMpHG2nlmwyADWOGeq4v488f6I6EhdAKkDetEI623uDmLAWUqqX0Xse8qTaqdFEfNdLsWvGL0GHtGsqQGItWoMN1MjueA+CKGEAE+GOoa9bilv6wG0/WtZb5KNA9bIm68NaLs+QuNLQEVU/SEk3x3eZ0cOMO7apSk71uOau0bhiyUn+IxNMJ6Kzc6YpR9Hbh0m4N9BCkwTH1FQ7Z0HIZdG10XycHFjSzltkWf3KY665+eAte+9Sn6KLdxm22gAPX4K+WadRZfXD1Cc92LxiKT+rX6ITioyyoVCFF0+YU24tsvC7TNwGAlkTiaGr2MxY+Hmu01NBfHNuLsFQrSenc33hRNGpgYqWzrc1RRYYOdywFKVcvAadWHwfX9umJbTcorMehOsvbDmR2b1XkTamH+gA7vA6M19y2x/1x5KEWYGqKapPwC52Z74DXaiM/1RcPzqrB+mSKBsS0DPmXW/CxCVt2P+3dZra7aNXVvpi5IQShxc6bR8eimYwxrO28NR9RXYxuaAgEaAiOcb2vqweup023oJeBrinfN5s55Lstk2YDy4+4eAL2lC/cHfQDBAgurlKlvsFZ8CEBwU0aDns1e7vyF1z8BT+lrQs3yNDwLNohjDXYTpnbaH2MU4Zi0euuqfxdeYFyLx8/fle2BkN0x4rKqjJBk2K7ILwTbqU5GelwO74JWpoTLVH4f01W9RcXyyhNARtIWVrm4L/U7J0aQPK3Y9C+PCiEy4hNnDg+Pgt+XuFxqbONXr/R3uijmLngX2G58q+qtcuEZN2YLHpVf4BZjRxraZBDO/kDge1bIHKD/0HzOPlooQPEucTdj976lTJX7/RTg+4fabKrQzwILWvIzPWyhFThLHDqSv85KnyXsZJozxauZpkAxVGtqnBiMDw+QDvVqlBZrUOMR1BJ3IfRGFol7qkNpVTEZjpjOQh0t+sxEYlsLyTu/Lf6OUSP1SMTZ1EyWlQ/hSZhqObEyRzCnbL7OoYECd/Ib7v+CS21cXTAqUL1XuFenit6aepURGbSVpoZeONtJ73FEC4ZD5OZJBrNKJ/332UWil22PhwlVu52ya/Soehd5LV1C+gbBRQZTujo84Y4OgFjCrw6vxK2V9oBvR8CkKT35V56XRgrpljEN+DtjXzcdo/Ind5FM9ieV0LTfeX84MEIx0mnpF8+6PKut5xYFIkf1dKfLPb4VfW95+2LAL5keT/lCuRQqACKH9iaR9rLZuepKLVEXbqul4WKIobYiCw== 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:(13230040)(1800799024)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:17.3762 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f485666-def7-436c-13e8-08dcf6f4b08f 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: BL02EPF00021F6F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6542 From: Perry Yuan The AMD Heterogeneous core design and Hardware Feedback Interface (HFI) provide behavioral classification and a dynamically updated ranking table for the scheduler to use when choosing cores for tasks. There are two CPU core types defined: `Classic Core` and `Dense Core`. "Classic" cores are the standard performance cores, while "Dense" cores are optimized for area and efficiency. Heterogeneous compute refers to CPU implementations that are comprised of more than one architectural class, each with two capabilities. This means each CPU reports two separate capabilities: "perf" and "eff". Each capability lists all core ranking numbers between 0 and 255, where a higher number represents a higher capability. Heterogeneous systems can also extend to more than two architectural classes. The purpose of the scheduling feedback mechanism is to provide information to the operating system scheduler in real time, allowing the scheduler to direct threads to the optimal core during task scheduling. All core ranking data are provided by the BIOS via a shared memory ranking table, which the driver reads and uses to update core capabilities to the scheduler. When the hardware updates the table, it generates a platform interrupt to notify the OS to read the new ranking table. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Reviewed-by: Gautham R. Shenoy Signed-off-by: Perry Yuan Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/Kconfig | 1 + drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/hfi/Kconfig | 20 +++ drivers/platform/x86/amd/hfi/Makefile | 7 ++ drivers/platform/x86/amd/hfi/hfi.c | 168 ++++++++++++++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 drivers/platform/x86/amd/hfi/Kconfig create mode 100644 drivers/platform/x86/amd/hfi/Makefile create mode 100644 drivers/platform/x86/amd/hfi/hfi.c diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig index f88682d36447c..c3f69dbe3037d 100644 --- a/drivers/platform/x86/amd/Kconfig +++ b/drivers/platform/x86/amd/Kconfig @@ -5,6 +5,7 @@ source "drivers/platform/x86/amd/pmf/Kconfig" source "drivers/platform/x86/amd/pmc/Kconfig" +source "drivers/platform/x86/amd/hfi/Kconfig" config AMD_HSMP tristate "AMD HSMP Driver" diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile index dcec0a46f8af1..2676fc81fee54 100644 --- a/drivers/platform/x86/amd/Makefile +++ b/drivers/platform/x86/amd/Makefile @@ -9,3 +9,4 @@ amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o obj-$(CONFIG_AMD_PMF) += pmf/ obj-$(CONFIG_AMD_WBRF) += wbrf.o +obj-$(CONFIG_AMD_HFI) += hfi/ diff --git a/drivers/platform/x86/amd/hfi/Kconfig b/drivers/platform/x86/amd/hfi/Kconfig new file mode 100644 index 0000000000000..08051cd4f74db --- /dev/null +++ b/drivers/platform/x86/amd/hfi/Kconfig @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# AMD Hardware Feedback Interface Driver +# + +config AMD_HFI + bool "AMD Hetero Core Hardware Feedback Driver" + depends on ACPI + depends on CPU_SUP_AMD + help + Select this option to enable the AMD Heterogeneous Core Hardware Feedback Interface. If + selected, hardware provides runtime thread classification guidance to the operating system + on the performance and energy efficiency capabilities of each heterogeneous CPU core. + These capabilities may vary due to the inherent differences in the core types and can + also change as a result of variations in the operating conditions of the system such + as power and thermal limits. If selected, the kernel relays updates in heterogeneous + CPUs' capabilities to userspace, allowing for more optimal task scheduling and + resource allocation, leveraging the diverse set of cores available. + + diff --git a/drivers/platform/x86/amd/hfi/Makefile b/drivers/platform/x86/amd/hfi/Makefile new file mode 100644 index 0000000000000..672c6ac106e95 --- /dev/null +++ b/drivers/platform/x86/amd/hfi/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# AMD Hardware Feedback Interface Driver +# + +obj-$(CONFIG_AMD_HFI) += amd_hfi.o +amd_hfi-objs := hfi.o diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c new file mode 100644 index 0000000000000..a92fe74b415e3 --- /dev/null +++ b/drivers/platform/x86/amd/hfi/hfi.c @@ -0,0 +1,168 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD Hardware Feedback Interface Driver + * + * Copyright (C) 2024 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Authors: Perry Yuan + * Mario Limonciello + */ + +#define pr_fmt(fmt) "amd-hfi: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AMD_HFI_DRIVER "amd_hfi" +#define AMD_HETERO_CPUID_27 0x80000027 +static struct platform_device *device; + +struct amd_hfi_data { + const char *name; + struct device *dev; + struct mutex lock; +}; + +struct amd_hfi_classes { + u32 perf; + u32 eff; +}; + +/** + * struct amd_hfi_cpuinfo - HFI workload class info per CPU + * @cpu: cpu index + * @cpus: mask of cpus associated with amd_hfi_cpuinfo + * @class_index: workload class ID index + * @nr_class: max number of workload class supported + * @amd_hfi_classes: current cpu workload class ranking data + * + * Parameters of a logical processor linked with hardware feedback class + */ +struct amd_hfi_cpuinfo { + int cpu; + cpumask_var_t cpus; + s16 class_index; + u8 nr_class; + struct amd_hfi_classes *amd_hfi_classes; +}; + +static DEFINE_PER_CPU(struct amd_hfi_cpuinfo, amd_hfi_cpuinfo) = {.class_index = -1}; + +static int amd_hfi_alloc_class_data(struct platform_device *pdev) +{ + struct amd_hfi_cpuinfo *hfi_cpuinfo; + struct device *dev = &pdev->dev; + int idx; + int nr_class_id; + + nr_class_id = cpuid_eax(AMD_HETERO_CPUID_27); + if (nr_class_id < 0 || nr_class_id > 255) { + dev_err(dev, "failed to get number of supported classes: %d\n", + nr_class_id); + return -EINVAL; + } + + for_each_present_cpu(idx) { + struct amd_hfi_classes *classes; + + classes = devm_kzalloc(dev, + nr_class_id * sizeof(struct amd_hfi_classes), + GFP_KERNEL); + if (!classes) + return -ENOMEM; + hfi_cpuinfo = per_cpu_ptr(&amd_hfi_cpuinfo, idx); + hfi_cpuinfo->amd_hfi_classes = classes; + hfi_cpuinfo->nr_class = nr_class_id; + } + + return 0; +} + +static void amd_hfi_remove(struct platform_device *pdev) +{ + struct amd_hfi_data *dev = platform_get_drvdata(pdev); + + mutex_destroy(&dev->lock); +} + +static const struct acpi_device_id amd_hfi_platform_match[] = { + { "AMDI0104", 0}, + { } +}; +MODULE_DEVICE_TABLE(acpi, amd_hfi_platform_match); + +static int amd_hfi_probe(struct platform_device *pdev) +{ + struct amd_hfi_data *amd_hfi_data; + int ret; + + if (!acpi_match_device(amd_hfi_platform_match, &pdev->dev)) + return -ENODEV; + + amd_hfi_data = devm_kzalloc(&pdev->dev, sizeof(*amd_hfi_data), GFP_KERNEL); + if (!amd_hfi_data) + return -ENOMEM; + + amd_hfi_data->dev = &pdev->dev; + mutex_init(&amd_hfi_data->lock); + platform_set_drvdata(pdev, amd_hfi_data); + + ret = amd_hfi_alloc_class_data(pdev); + if (ret) + return ret; + + return 0; +} + +static struct platform_driver amd_hfi_driver = { + .driver = { + .name = AMD_HFI_DRIVER, + .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(amd_hfi_platform_match), + }, + .probe = amd_hfi_probe, + .remove = amd_hfi_remove, +}; + +static int __init amd_hfi_init(void) +{ + int ret; + + if (acpi_disabled || + !boot_cpu_has(X86_FEATURE_AMD_HETEROGENEOUS_CORES) || + !boot_cpu_has(X86_FEATURE_AMD_WORKLOAD_CLASS)) + return -ENODEV; + + device = platform_device_register_simple(AMD_HFI_DRIVER, -1, NULL, 0); + if (IS_ERR(device)) { + pr_err("unable to register HFI platform device\n"); + return PTR_ERR(device); + } + + ret = platform_driver_register(&amd_hfi_driver); + if (ret) + pr_err("failed to register HFI driver\n"); + + return ret; +} + +static __exit void amd_hfi_exit(void) +{ + platform_device_unregister(device); + platform_driver_unregister(&amd_hfi_driver); +} +module_init(amd_hfi_init); +module_exit(amd_hfi_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("AMD Hardware Feedback Interface Driver"); From patchwork Mon Oct 28 02:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839287 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2042.outbound.protection.outlook.com [40.107.244.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C371B19049A; Mon, 28 Oct 2024 02:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081005; cv=fail; b=UCPqK4hW1Gn6r6TNo2B171K/d1oR/rdv7QZfyOBYjMA1qpWy/a1sALQZ/r/smHx7KLBKViBujUkJBbMsHttm9WfDzdMJgjxNnBMYDd3FdZOW7p/0xUD5cjeMBQiWyhbUY/sddkiB7ngWl38ZxygoisibLd9dNgskyzrlI8w+xyA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081005; c=relaxed/simple; bh=m9DsvIoyEVL47DOfQjdYURoN40jhquPqlSgfKI+U5o4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LD80j/ZLTT8lebSSEapaT4HAjHZSxNg3084J30ygubxxoWm8sUK6b+X4raoOA1OKgc6fl0KOmHpd5Tp53JhLut8AFyGH9FDwB1mEq0kcIz/Jmu8Ax6xDADVrIw+I/L5oPUFkXeR5jhwHtMg2Xgby29BPlUQNjDG6q2YOxgo9nWM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=45ArENJc; arc=fail smtp.client-ip=40.107.244.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="45ArENJc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Akno6drfO3XebR141R475ILzdTIFC3TvJWA99vYW42ZqGTL7a8nyE4Ca5NKIjDRDHAuJCqeITpnJquZw50jZLWiUcL45wJNTCJNIuBRNhW5B81x2DlJw6YyYS2YShzALbKCo4zNZsv5J7Ke57ru5B9eveKFjUdnbpw7YGlLyxSwmup2phPnXCiZhKXAUjbjN/9cLg/ccAFEOXTncyBnLTyvjNfCjsBpfw0rrYWgse0HlG/PtzsyA4MpTALGLoc+afiarC2CvwVaR3+zJNlLb23wP90YLlyUQFe/1/Mzt1a2kOT12J3cvaofkDpQT8M7j4nimnZUJFjM8deVEgZg18Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DKmKNuX7W471NSvyi+N49QiC6bAANemeibU1F0ELCI4=; b=M8rU5b/IdUz4Ux3Ao1y/v8kmB85F3PhYIXv4BV7+mEckpQgcqx0h6DwIMbxuwugbBu1/Rxk7rJdJTnK0iJFPhkT4/YIOE/yMicuWk7kt0vzE1xUiOAxiF8gygQ8AunV0CpLuwdql7niINp/Yan+v/m2lnxOfMtMNVph/1ee7kg3Ny/pC2G85rCvk506FMEgRW0ii2qa5cf/8A+AUrPdMqgQ49ikCc2WHuyLpyeViNUdgBewhFqSmZxrhN+HD/ZbO32q0gPlnjCqDRe+HtwY8BqoEenhY8PZ6WZlcTBJyzp6jjcGNRx4E9Ijp+CqOQX4+LrAsDro4WTpO/fBnkPqsbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=DKmKNuX7W471NSvyi+N49QiC6bAANemeibU1F0ELCI4=; b=45ArENJcFAJT5U9HR5yNtGiJe+gzBMTnmRimgyMT/+zWrFH22HXSy5sGTW+4IEHud7YSuRPbClLajwUX3Tv9/Lg7z8+lr5h4+sEs19sIYSC5GYyh6brOj50ZcxKXkgyruf3fQM9P6X7CE9AwuNTCf6EJLd/qxO1U4FhTT/C7qiM= Received: from MN2PR06CA0003.namprd06.prod.outlook.com (2603:10b6:208:23d::8) by PH7PR12MB7211.namprd12.prod.outlook.com (2603:10b6:510:206::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 28 Oct 2024 02:03:18 +0000 Received: from BL02EPF00021F6F.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::5d) by MN2PR06CA0003.outlook.office365.com (2603:10b6:208:23d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:03:18 +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 BL02EPF00021F6F.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:03:18 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:16 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" , Perry Yuan Subject: [PATCH v5 06/13] platform/x86: hfi: parse CPU core ranking data from shared memory Date: Sun, 27 Oct 2024 21:02:44 -0500 Message-ID: <20241028020251.8085-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F6F:EE_|PH7PR12MB7211:EE_ X-MS-Office365-Filtering-Correlation-Id: e753bb60-41f3-4c60-4974-08dcf6f4b106 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: zzarXss4h3pdFil/wFhg5DMbh9EgryKr/0TpgxNbMW6ud+afs+De6QyHMmD5IcC3AHJPDVp16orIB1o8sEivTBZoWdXccnAi2qVKD9qFRfkMy6qAu/qNouKbiPqXcgbgF9lzs/lQ7dyQ2sCjZ0aI2vl5jSr+VRD6HuTJt1SRgrkRiwlY6pe92zo5U59Jh8wbyetR15rkjHTe494DWLGxVfKx8TxNzvKJaKKQW4zKRB99pCTC8GrLds65OjdytG2fuX6Q6X52V/Vd/Ybvant+mHte1Jx2swB8SXg49Z51fKbiq9s6sBdN+8xnweBTqSJl6SpvwQEt0ymjLVWgoXh7LGE0QatGNSeVKjrIj1ZCHTyTh0Z9fW47ml4aGEfrfa81S82Y8DyrRYXWVwvMNruhIfft0A43SxDXE7Et/MY4/3224YBogwfV2LRw7q62oCPlReXl4mrMeSQiTgaU8ATTz1qoL45YAVVEU3crHi4oITTbKL77fmQBo03MAbLecCvdVzOMaPTpSA9JjFVVlE4vDhEXiY/FVa2+ZUdnCQrVn7D0C4K2repZ0wEYVETk0DGcedHsOoC6XcO7xuNrA6vHZjIUwQIONMG0gdKFv4ubj6Sj4klnhxAQpUwcqrJuefe9xm7HOCfJ3qqV9XWYewo+OhDFbIeOGrPhq3Aae9Bso8n2h/y9IvjQ3bHtT+YsyamMU/7sTHmX2jm1d9hqIBAMBYkJ6uby0VsWP5KGMqjVHVha6icO0gM5+OWeuBNaxpSXtzamfIM3ydgB8/WnT8F+u+4a5JQFfoHa8ryrqDCDCS+Siy6wbL9vbANmozdRrY+IwMNvqdj31PvoueK/XW0wbE1YxJ44o5JQVFubU64dhnU/JcWk8bL3VuiS/zRhtGxxa45hLhTADbPSURYdqXYTRgjK3/xSFjDdzlYfE8GaxgR5gfVjzgNAcY3ib9sUI14aYi8EzTwYIO4wjbW8lNf4ZwxmpoAvUv6i66MWALtcgnYvTdCMhHGEfezSYqTR6aQP3SlQIW7rqT566pol36f3AzD3zcbeeNSiB+F5KNA1koR2fwD/MP9LLFGorIFhmp6F39zgWKEu+1YfacduPhr+1NX5xAj904flaanE0KbkiMR9jGEhfWttuF1gUGZ7rLMzqpZavJ0w/0dKcoJaUbEv6HgJNSIY3Xvi5+41EAnZcsilgP0UuMmMNC+rf+3PjnqctHYqUR2NTx4/m0QzD6Cuimefwba86oGBjEsgXc2af/zI/pQwJ3bOyENk7Ofuiktsnad4gUr4yw2GX9MmmxK16zn+WKbuF5BogJRSSNW2HDj4RMtgQ4r8yeJw/1Ra1F+umugGYg8V/NIVGGLw73B5dxHNPANG6zeJmbeFyACvgrxPC5RLArrslCbG/Bbke2IF3dh264iHO4wit3qDQb6S1A== 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:(13230040)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:18.1418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e753bb60-41f3-4c60-4974-08dcf6f4b106 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: BL02EPF00021F6F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7211 From: Perry Yuan When `amd_hfi` driver is loaded, it will use PCCT subspace type 4 table to retrieve the shared memory address which contains the CPU core ranking table. This table includes a header that specifies the number of ranking data entries to be parsed and rank each CPU core with the Performance and Energy Efficiency capability as implemented by the CPU power management firmware. Once the table has been parsed, each CPU is assigned a ranking score within its class. Subsequently, when the scheduler selects cores, it chooses from the ranking list based on the assigned scores in each class, thereby ensuring the optimal selection of CPU cores according to their predefined classifications and priorities. Signed-off-by: Perry Yuan Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/hfi/hfi.c | 196 +++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c index a92fe74b415e3..b5cfe20c11052 100644 --- a/drivers/platform/x86/amd/hfi/hfi.c +++ b/drivers/platform/x86/amd/hfi/hfi.c @@ -18,21 +18,73 @@ #include #include #include +#include #include +#include #include #include #include +#include +#include + +#include + +#include +#include #define AMD_HFI_DRIVER "amd_hfi" +#define AMD_HFI_MAILBOX_COUNT 1 +#define AMD_HETERO_RANKING_TABLE_VER 2 + #define AMD_HETERO_CPUID_27 0x80000027 + static struct platform_device *device; +/** + * struct amd_shmem_info - Shared memory table for AMD HFI + * + * @header: The PCCT table header including signature, length flags and command. + * @version_number: Version number of the table + * @n_logical_processors: Number of logical processors + * @n_capabilities: Number of ranking dimensions (performance, efficiency, etc) + * @table_update_context: Command being sent over the subspace + * @n_bitmaps: Number of 32-bit bitmaps to enumerate all the APIC IDs + * This is based on the maximum APIC ID enumerated in the system + * @reserved: 24 bit spare + * @table_data: Bit Map(s) of enabled logical processors + * Followed by the ranking data for each logical processor + */ +struct amd_shmem_info { + struct acpi_pcct_ext_pcc_shared_memory header; + u32 version_number :8, + n_logical_processors :8, + n_capabilities :8, + table_update_context :8; + u32 n_bitmaps :8, + reserved :24; + u32 table_data[]; +} __packed; + struct amd_hfi_data { const char *name; struct device *dev; struct mutex lock; + + /* PCCT table related*/ + struct pcc_mbox_chan *pcc_chan; + void __iomem *pcc_comm_addr; + struct acpi_subtable_header *pcct_entry; + struct amd_shmem_info *shmem; }; +/** + * struct amd_hfi_classes - HFI class capabilities per CPU + * @perf: Performance capability + * @eff: Power efficiency capability + * + * Capabilities of a logical processor in the ranking table. These capabilities + * are unitless and specific to each HFI class. + */ struct amd_hfi_classes { u32 perf; u32 eff; @@ -41,23 +93,105 @@ struct amd_hfi_classes { /** * struct amd_hfi_cpuinfo - HFI workload class info per CPU * @cpu: cpu index + * @apic_id: apic id of the current cpu * @cpus: mask of cpus associated with amd_hfi_cpuinfo * @class_index: workload class ID index * @nr_class: max number of workload class supported + * @ipcc_scores: ipcc scores for each class * @amd_hfi_classes: current cpu workload class ranking data * * Parameters of a logical processor linked with hardware feedback class */ struct amd_hfi_cpuinfo { int cpu; + u32 apic_id; cpumask_var_t cpus; s16 class_index; u8 nr_class; + int *ipcc_scores; struct amd_hfi_classes *amd_hfi_classes; }; static DEFINE_PER_CPU(struct amd_hfi_cpuinfo, amd_hfi_cpuinfo) = {.class_index = -1}; +static int find_cpu_index_by_apicid(unsigned int target_apicid) +{ + int cpu_index; + + for_each_present_cpu(cpu_index) { + struct cpuinfo_x86 *info = &cpu_data(cpu_index); + + if (info->topo.apicid == target_apicid) { + pr_debug("match APIC id %d for CPU index: %d\n", + info->topo.apicid, cpu_index); + return cpu_index; + } + } + + return -ENODEV; +} + +static int amd_hfi_fill_metadata(struct amd_hfi_data *amd_hfi_data) +{ + struct acpi_pcct_ext_pcc_slave *pcct_ext = + (struct acpi_pcct_ext_pcc_slave *)amd_hfi_data->pcct_entry; + void __iomem *pcc_comm_addr; + + pcc_comm_addr = acpi_os_ioremap(amd_hfi_data->pcc_chan->shmem_base_addr, + amd_hfi_data->pcc_chan->shmem_size); + if (!pcc_comm_addr) { + pr_err("failed to ioremap PCC common region mem\n"); + return -ENOMEM; + } + + memcpy_fromio(amd_hfi_data->shmem, pcc_comm_addr, pcct_ext->length); + iounmap(pcc_comm_addr); + + if (amd_hfi_data->shmem->header.signature != PCC_SIGNATURE) { + pr_err("invalid signature in shared memory\n"); + return -EINVAL; + } + if (amd_hfi_data->shmem->version_number != AMD_HETERO_RANKING_TABLE_VER) { + pr_err("invalid version %d\n", amd_hfi_data->shmem->version_number); + return -EINVAL; + } + + for (unsigned int i = 0; i < amd_hfi_data->shmem->n_bitmaps; i++) { + u32 bitmap = amd_hfi_data->shmem->table_data[i]; + + for (unsigned int j = 0; j < BITS_PER_TYPE(u32); j++) { + struct amd_hfi_cpuinfo *info; + int apic_id = i * BITS_PER_TYPE(u32) + j; + int cpu_index; + + if (!(bitmap & BIT(j))) + continue; + + cpu_index = find_cpu_index_by_apicid(apic_id); + if (cpu_index < 0) { + pr_warn("APIC ID %d not found\n", apic_id); + continue; + } + + info = per_cpu_ptr(&amd_hfi_cpuinfo, cpu_index); + info->apic_id = apic_id; + + /* Fill the ranking data for each logical processor */ + info = per_cpu_ptr(&amd_hfi_cpuinfo, cpu_index); + for (unsigned int k = 0; k < info->nr_class; k++) { + u32 *table = amd_hfi_data->shmem->table_data + + amd_hfi_data->shmem->n_bitmaps + + i * info->nr_class; + + info->amd_hfi_classes[k].eff = table[apic_id + 2 * k]; + info->amd_hfi_classes[k].perf = table[apic_id + 2 * k + 1]; + } + } + } + + return 0; +} + static int amd_hfi_alloc_class_data(struct platform_device *pdev) { struct amd_hfi_cpuinfo *hfi_cpuinfo; @@ -74,14 +208,19 @@ static int amd_hfi_alloc_class_data(struct platform_device *pdev) for_each_present_cpu(idx) { struct amd_hfi_classes *classes; + int *ipcc_scores; classes = devm_kzalloc(dev, nr_class_id * sizeof(struct amd_hfi_classes), GFP_KERNEL); if (!classes) return -ENOMEM; + ipcc_scores = devm_kcalloc(dev, nr_class_id, sizeof(int), GFP_KERNEL); + if (!ipcc_scores) + return -ENOMEM; hfi_cpuinfo = per_cpu_ptr(&amd_hfi_cpuinfo, idx); hfi_cpuinfo->amd_hfi_classes = classes; + hfi_cpuinfo->ipcc_scores = ipcc_scores; hfi_cpuinfo->nr_class = nr_class_id; } @@ -95,6 +234,59 @@ static void amd_hfi_remove(struct platform_device *pdev) mutex_destroy(&dev->lock); } +static int amd_hfi_metadata_parser(struct platform_device *pdev, + struct amd_hfi_data *amd_hfi_data) +{ + struct acpi_pcct_ext_pcc_slave *pcct_ext; + struct acpi_subtable_header *pcct_entry; + struct mbox_chan *pcc_mbox_channels; + struct acpi_table_header *pcct_tbl; + struct pcc_mbox_chan *pcc_chan; + acpi_status status; + int ret; + + pcc_mbox_channels = devm_kcalloc(&pdev->dev, AMD_HFI_MAILBOX_COUNT, + sizeof(*pcc_mbox_channels), GFP_KERNEL); + if (!pcc_mbox_channels) + return -ENOMEM; + + pcc_chan = devm_kcalloc(&pdev->dev, AMD_HFI_MAILBOX_COUNT, + sizeof(*pcc_chan), GFP_KERNEL); + if (!pcc_chan) + return -ENOMEM; + + status = acpi_get_table(ACPI_SIG_PCCT, 0, &pcct_tbl); + if (ACPI_FAILURE(status) || !pcct_tbl) + return -ENODEV; + + /* get pointer to the first PCC subspace entry */ + pcct_entry = (struct acpi_subtable_header *) ( + (unsigned long)pcct_tbl + sizeof(struct acpi_table_pcct)); + + pcc_chan->mchan = &pcc_mbox_channels[0]; + + amd_hfi_data->pcc_chan = pcc_chan; + amd_hfi_data->pcct_entry = pcct_entry; + pcct_ext = (struct acpi_pcct_ext_pcc_slave *)pcct_entry; + + if (pcct_ext->length <= 0) + return -EINVAL; + + amd_hfi_data->shmem = devm_kzalloc(amd_hfi_data->dev, pcct_ext->length, GFP_KERNEL); + if (!amd_hfi_data->shmem) + return -ENOMEM; + + pcc_chan->shmem_base_addr = pcct_ext->base_address; + pcc_chan->shmem_size = pcct_ext->length; + + /* parse the shared memory info from the pcct table */ + ret = amd_hfi_fill_metadata(amd_hfi_data); + + acpi_put_table(pcct_tbl); + + return ret; +} + static const struct acpi_device_id amd_hfi_platform_match[] = { { "AMDI0104", 0}, { } @@ -121,6 +313,10 @@ static int amd_hfi_probe(struct platform_device *pdev) if (ret) return ret; + ret = amd_hfi_metadata_parser(pdev, amd_hfi_data); + if (ret) + return ret; + return 0; } From patchwork Mon Oct 28 02:02:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839285 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E423518B47D; Mon, 28 Oct 2024 02:03:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081010; cv=fail; b=rKmUDywladLICPEkzb0eJ37/FEZ6YwIsJCE4VxwMFLwKJ6EtDkqK2qxIrVbERiIzOFlYevNiDvfHiBTxLNx99LWQanmN+1IOJd7Q6ohRxe7WDkvHx4jLzkdH4M7Ay2rnSxDwmO76bI0w6iosAVT+RUs0mwBOrYijZDIfYsDMqKE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081010; c=relaxed/simple; bh=LNPjM+dPgjMNL75vlopqQfkr8adV7T737JOpjxZs+8w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZHe9w0CP59uuScnD2Ib3HtVFlve7UA1axQttSYHC/7XQLdJWUP7oYOv/TKUDNkEB7ISVJ8+HcApf7CPJE9jHXqg/EPr1JbaEmZEhpEKzWHIxmh8FQoSXACI7nWymnH8ZLRBBCIFLknMMPhaMeRqG9N6fiBKceSKFpNLIkp47Li0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=RWSgHfqT; arc=fail smtp.client-ip=40.107.92.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="RWSgHfqT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JoN+ZqzDlDTjNQIlpbppj77F9b5Z7pA35JV/Pj90DQ+u2R6sw2Xw4r16rwQJQBTYTJCKIZE8NWUn1m0TLLTHh06Amy6kdui2v83B26QBIsJU8tWgggF1fG4cx2goU35okA7WeOopR2EkTcl3TDRRzmm6BVpDxf7/5jiiiYFJTq3XSJurhCBA4eH1eCfNYIKlzzxYYTyxhzS55Scst/MDy5+cSbKGTPYT872dxpaeGbhBDWg8NTb8gmI7YOnnMrGdGXZl1YMR9VTZ03qN4TlpRCKw4vxZneGTlB31jYjCzEuB60aaaPVnQ7yJh2mACl9Nw9IH/eg0QlFHTHFDZ7W5ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=haXGWBrAZ0fxfa3qxHK1ETSJPyswEvws5g3hvbtCKk4=; b=vXfixM5EuG2pQNNUyFGgMjEjo3eLkw+g1x2E9uFoIlBnV8m4KtYIOIE2n5nqHypFl1hzvvYFCdTX+L7wMNFNkEPLcX5zpYhgPhbt0mOvZ/P0ubBcA1c41iG/piEk1YCimofNeNx4yvefQZHOeVJg7LG2hZqStTZzNPCUxWXjcuzOWcSSNgjGlp+mdmJsb7cfmJMaJZ2Vh/Vfaz7GAtZS5isn72r7UOzfWS5Br8C9XPKpXby4ULzOkBPSolcggtxlBD7HdfEJFev7BrbK2gF6O4DCGHendwFPLJ/jwyYaOYZSV9go7gBhnXWcFxrfGEcPcyJCGHRKJHQ+ph9Oh/5Kvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=haXGWBrAZ0fxfa3qxHK1ETSJPyswEvws5g3hvbtCKk4=; b=RWSgHfqTzzMQYGox9fi77J5WJG3bhPQ7Hm5ZWJgNX41srkeklr1JAwa8WvrszC/1Qe/OUEefVD2uPjKY+ENZSE729tcVZuXqOwQ8/JDS4v2UBhtcPe2uJtNBYHqpsLhHO2oijDiRs94KHdEkILIWU8m1rDaFx53dvRzSFvdD1LY= Received: from BN8PR12CA0011.namprd12.prod.outlook.com (2603:10b6:408:60::24) by SN7PR12MB7276.namprd12.prod.outlook.com (2603:10b6:806:2af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Mon, 28 Oct 2024 02:03:22 +0000 Received: from BL02EPF00021F6E.namprd02.prod.outlook.com (2603:10b6:408:60:cafe::8e) by BN8PR12CA0011.outlook.office365.com (2603:10b6:408:60::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:03:22 +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 BL02EPF00021F6E.mail.protection.outlook.com (10.167.249.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:03:21 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:20 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" , Perry Yuan Subject: [PATCH v5 09/13] platform/x86: hfi: add power management callback Date: Sun, 27 Oct 2024 21:02:47 -0500 Message-ID: <20241028020251.8085-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F6E:EE_|SN7PR12MB7276:EE_ X-MS-Office365-Filtering-Correlation-Id: d3b86400-e6ad-41c9-f066-08dcf6f4b338 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: lTpeNeRyEUrvq+M1fTKtqZmOtWMLCQca2ETMmseEIL/oGQxXYGKQ6n6Sy88uPXImfeK/6jJC0CBCKmQDkr5EV7ie/p1NDblN+OzwU8CtAT/0BxZ5nf33H2DgIrHNDYaVxwVAYgvegu41S8edbJHtnkmJRZr42MhKhRpIFOeKFulfpKJ60KTQJ9pkMc8BA3N8+iVNX3yAChPc2B6Mm4/KQQvN6BShZK5FKF1TxMB2rTKqe/4tsLEuhLA6iQ0oq5a7w4eUMh85gZfcfmapyEOQogn+AWYl+JMm1aJ0eJC9p4R+n13fCnynkeGazRMwVEyviR2Esm4ZkFVXgPdzvAsWs2saW/IoTpC5DsgudAyTNwbjFxZooOHPny97IQPZITv/mHahpA/gGEv0ptBV3ogwFvXA2j3seoS4RCGXOH8hp8vmejudLMVFDBX1s9/d1DzCOdxH+FSsT4KMwDDWIE84nXVGOCQ8DNFM5NtXWwed/TV9bdne/YuGYhR67VwKbmXuTvfbFw9QYtZgUXYwU9AdCjc4Wh7Qs3k7c3vbOhjAvgBMBrJW6emPK/sb1rXTcOXkNWOqOyO5gF1oMMiIJMVqxAlW+5+OEBDM6xi9Tc3c8iFB1JVN3KSO9oDevBd41Z0lPdxEfs3O8fC5kzodJuy7Fx7qHihVn/y804OncvQHEGuTpYD/Ei3qORh8XLbvZW/Ny8pO8htCqpAuLbIyz2JAHRYgDHEsqSYwHsJbHnfHaxO33bL8fAYh6HgYT3NPGg0fLxkCoPFBHbBT8oKvQSG/StPAj+0KwF3wqJd+4ZtF35sLadVHLEQ7LdlJWirKGKNwLQc6QoG/QUqHnGeiVfwuIVcEjwRMzRg8USbg4LsYvMTfp2e6PLD5QYBlC5mCXLP8SufwJx7i3X4i2psp7/fBt3aIMunluSlndpJTKiWxy26OkUCHt9W7g5bJKLElC9JPPTLFrOCz3Slftq3U8tJFdHdvc4nnzij9SwZ1qZsH4MOG28+OoDRCJhFvtYsFtDgtJkqFo6jTIb62vL1UiShZ+MVw3i+/EXh02nhuAOjm97eiSWOv0e17/Eckmct2koHONoPDg9p+k6UoIUS7Abof+v/h4yWe8V4djxjJkYwzjGbXEd2HRBS4PKzBGnm3ag2UbCSHHfup3Welobv4pY8O6MIH8DSBL+43ThKXEupqHintxinbKtlMQh93PoXFJCdny8FTav2TC9jsODtMdtUaGw/o3NkGRBsT86ZcU76HlesBAFdnaC/eh/qVYR0JiGzhbl/FAlbpP+I/iXAM5qDmgT2oLfkSntlbY7aYwht0Bns/LK5BEhx4rnWOlGrlrnykFXXS/TyN4ZVHCHNucf05sTlAd3wFjvtXa7xKCjcxQM/dT4e5kcnD+0nLW+X1QYWfW1n2xK0vm++yWB2GEwhTQQ== 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:(13230040)(36860700013)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:21.8449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3b86400-e6ad-41c9-f066-08dcf6f4b338 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: BL02EPF00021F6E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7276 From: Perry Yuan Introduces power management callbacks for the `amd_hfi` driver. Specifically, the `suspend` and `resume` callbacks have been added to handle the necessary operations during system low power states and wake-up. Reviewed-by: Gautham R. Shenoy Signed-off-by: Perry Yuan Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/hfi/hfi.c | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c index 70ddde37f283f..c8fe03d0c9ccd 100644 --- a/drivers/platform/x86/amd/hfi/hfi.c +++ b/drivers/platform/x86/amd/hfi/hfi.c @@ -388,6 +388,38 @@ static int amd_hfi_metadata_parser(struct platform_device *pdev, return ret; } +static int amd_hfi_pm_resume(struct device *dev) +{ + int ret, cpu; + + for_each_online_cpu(cpu) { + ret = amd_hfi_set_state(cpu, true); + if (ret < 0) { + dev_err(dev, "failed to enable workload class config: %d\n", ret); + return ret; + } + } + + return 0; +} + +static int amd_hfi_pm_suspend(struct device *dev) +{ + int ret, cpu; + + for_each_online_cpu(cpu) { + ret = amd_hfi_set_state(cpu, false); + if (ret < 0) { + dev_err(dev, "failed to disable workload class config: %d\n", ret); + return ret; + } + } + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(amd_hfi_pm_ops, amd_hfi_pm_suspend, amd_hfi_pm_resume); + static const struct acpi_device_id amd_hfi_platform_match[] = { { "AMDI0104", 0}, { } @@ -434,6 +466,7 @@ static struct platform_driver amd_hfi_driver = { .driver = { .name = AMD_HFI_DRIVER, .owner = THIS_MODULE, + .pm = &amd_hfi_pm_ops, .acpi_match_table = ACPI_PTR(amd_hfi_platform_match), }, .probe = amd_hfi_probe, From patchwork Mon Oct 28 02:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839284 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2058.outbound.protection.outlook.com [40.107.237.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A8B7192D8E; Mon, 28 Oct 2024 02:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081012; cv=fail; b=fVx6W3r+6WmKdbelMcjfUTi1mOLHrCJL5PHLV6/1bRqMZ9Vw/9Tq9YOebkVTajO7OwmFtIp7U6B7ffBfQwuzIpyOkShSCYwRGE3OjdjDB9OPoeQEOVqA+bpE2ss1V8qSmKTOubXYDhUWmeHLrNGZZBG2qjXWOropPoYdie0lCEc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081012; c=relaxed/simple; bh=WeiwuPFtV668DILjCh+jYeKXuUIMohMCdU2H/SIJEFI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FfI+uZeq2P5atvtlGUMta5jBpFRtTDVQg+sm5huCOnGBusK4GSISP7GKloGSjf4nW0c+jj017nnx1h6wFrLc8i4y0kORd3I3JgLj0qqq7sg+FhzWwtNpjY/JcbDGhlBWBFJOY2/xkZ+6u0JswHt0Gu5QAn8JGEO78Pg0Pnr+vIs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=kGRsZZdt; arc=fail smtp.client-ip=40.107.237.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="kGRsZZdt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XXzti22TsskghoMgmAMyM5RGwu2hAO0c6Ym1WdYcIcpMiMAERVRM2cRR6bWrbx3+nwCdJ1ZgjKLjmfeXZLhT0xnX+dAQJ9BCPnOKa5ywQsj566XhM+38JyPnfNQd3ONMRjZz0a5AsWLheNq1NOHamLUK4YpdInwB9VVPQhciOFFPXNlYiOSS+mxuNEk/JdU6WLLGNo006S1pzR2gbLWQ7cNzUf+w/hpI+Zds3jQfgY6AQ6UOyhrUIktxeRNCX/wtqW5g37ETUmS3SexNRStmmMrMmE5BIyncQ0lmbMaGIf4dfp68qA71IgcNAXp1N3MrB7XL459NHyax/b34+rHjgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TrV2O76s3V5JeIAZkW21NWsWDkIGx4rTXtlK/PQ+zN0=; b=SFuY5Wk+l2TUuv3yV4YLeY6QOKCmsJWbaF7ZJOraOqBnuL3NWOUFU4TbASTqnGWpoMgdUdkGyWEfFrMGuLSZ4DzEZLqudmHi6qahig5ot5hGHDNjP5G4gl5FduYZdk0WkGeFLRtU4LDkqsrjB+PMw6DJicZUTjbx8h/md6IdPQxgSAN2tbwBZViXeNs/za8P4XxYCzKoMCvg9r7qYl7sew9mLYmEUmuKd3t92skP0kZOmQmLGC407KxWXjLdI8cSG1Ga4x23TbTDI3hloDsRHYwg8nixg95RI9UMB3yc6JHjwRp1haTUJL0HSV1bIbaQVyCvNi9kd7FmkhJveLq5qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=TrV2O76s3V5JeIAZkW21NWsWDkIGx4rTXtlK/PQ+zN0=; b=kGRsZZdtHmg3xkX2WkjklL6b6ECEofRI/NG6SssyaUbMVF+G1N1oDOHaxxpBivOYnH0qtNhEVyhZcLqg57NC+0G0YsAIR+CE271sLIz9H4hPFN7y5oAViaNP2c7xpXwrMutlAQKhf388ZadNqV4mi6pGMCzDocKCXXvL1YqVazo= Received: from BL1PR13CA0199.namprd13.prod.outlook.com (2603:10b6:208:2be::24) by DS7PR12MB6285.namprd12.prod.outlook.com (2603:10b6:8:96::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Mon, 28 Oct 2024 02:03:24 +0000 Received: from BL02EPF00021F6B.namprd02.prod.outlook.com (2603:10b6:208:2be:cafe::1b) by BL1PR13CA0199.outlook.office365.com (2603:10b6:208:2be::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.13 via Frontend Transport; Mon, 28 Oct 2024 02:03:23 +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 BL02EPF00021F6B.mail.protection.outlook.com (10.167.249.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 28 Oct 2024 02:03:23 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:21 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" Subject: [PATCH v5 10/13] x86/process: Clear hardware feedback history for AMD processors Date: Sun, 27 Oct 2024 21:02:48 -0500 Message-ID: <20241028020251.8085-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F6B:EE_|DS7PR12MB6285:EE_ X-MS-Office365-Filtering-Correlation-Id: 23312e33-30d6-4dc2-c7c2-08dcf6f4b409 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: KOj7rhOc7Ix7ZqLUJw9ulkabjJkekFZeW7TSVHvAmSxPDWPuugmNFYgSXeaP7yd80Mu4vSrAG8oeT9iz4OBL2CYDdq2bRVesWf56znEk4S3QstIVhPZt/iXlEZmeWgE4TkCy06TOaN29AdzcgtXJ0bCtxo1Eh3sseMOko/YJQKUVyGr3AjIAxV+3ubJNf5KJ3yP5VvImK6FaNj8BANgbjwXyTtm3p12uT5aAvFBTo4Q9ipLP5z9lasWVeYx+yFGuNqMDA4KQXzyefeda9yzLURqiIpIs8csDDUVrLwo2T1erYGEdRShH9sQYDjHct8z2XAxoDN7r6ihrwmqC0FLcjtPTpqfj44pn2XIIWaIa8620/V1injUsCmNb/LvPrXN1Arwu6KykckYJ/uvQRlr4FBS02umBaZMYH0YW8GqwKHDQLaY84O0xDC1/b/d6w5TAFWR7W/LdqB2EZ+yORcMaSFkX3zKadT5SvdrwHx0oHnN3tiv/yPP5tdNqNvfCGEeH3yTOeZ7IxkTSkuSjQ40aUW3rKbL/HGqPLyPaYeOiujoYwWApEPPSNtRpRItIdE5K4LzMoyLhMrm8tjL6QCi9nOSgWPhwrfFZMkmiroU3KDf596g3KU4oRvFNd6Qm4kbvI6+/FA3N6VUyY4zbCt8wmlkzqbZfJ7tLjmaL1wwCIcxXGIuF6zTjhlFo4NNDEPujrpaFJKjgn2r7hr3HrNnNyNoxXl+2PVImKx2wOdenqG7oHXGCXRmfNvLkGWKmUi8SUMPy6XeE9e5McoowGcZqfsVf0uzhkVCsDRk7/7TNFm6koJTQj35zoCePMJQn2I6ey2R5HkAa3ggOV0rK+FdGVsj6bs+HsM7CvZNuNjXQR71guU9vnd0SK6qKpCnFOraXfNrmO+cDQSfvv47K5Nto9vlMj8wkrAxYO/LTiWsrreRtoOeyNBJfN5PhjC/4UJPcrSwM1ZivuNdLSafiE8Lvg2IhUYo8TYSElfPQnBPVdQzme8sajoRZHkjpQWIwo1RwKC254u1Bh/r6nXTUsL/sX5pXArRHviwLJYQhFJkT8IwNX/23v9WxFYjoduSNPc/BGYcHgIG/k1Iw4YNlbHmHad2egEadGoPuLtIK9HX4vDHBPlTXx4oTH1KaSd9AY332mtxsw2bGzjtn+tqNldF+vfyD8V4lT1WQznA8A1C85+3TRC8r//1YXbbz9B2o+o5thkpNsOnXw3w2dvTLrYzRlKJk+JvpCoKGS2WKtLLSusvnTOnvz9ljAkeABXNtrlPS1Nv/UetCVgdn0FKyfq5n8wtUuBLf9eya38nxuKX5g77ySDTTw5ztA+hECfEOyL6KBYRHNQCYmrIC8pMw7fg2yRiKrlMb5FPC+TRl0svHnCJxuu8VndoUaQV/ACSAbrRSCCfZvhiiRrwgKShSw/x6Xw== 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:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:23.2135 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23312e33-30d6-4dc2-c7c2-08dcf6f4b409 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: BL02EPF00021F6B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6285 From: Perry Yuan Incorporate a mechanism within the context switching code to reset the hardware history for AMD processors. Specifically, when a task is switched in, the class ID was read and reset the hardware workload classification history of CPU firmware and then it start to trigger workload classification for the next running thread. Signed-off-by: Perry Yuan Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- arch/x86/include/asm/hreset.h | 6 ++++++ arch/x86/kernel/cpu/common.c | 15 +++++++++++++++ arch/x86/kernel/process_32.c | 3 +++ arch/x86/kernel/process_64.c | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 arch/x86/include/asm/hreset.h diff --git a/arch/x86/include/asm/hreset.h b/arch/x86/include/asm/hreset.h new file mode 100644 index 0000000000000..ae1f72602bbd0 --- /dev/null +++ b/arch/x86/include/asm/hreset.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_HRESET_H + +void reset_hardware_history_hetero(void); + +#endif /* _ASM_X86_HRESET_H */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 07a34d7235057..ed99b5c88ff7e 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -403,6 +404,7 @@ static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_C X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED; static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning); static unsigned long cr4_pinned_bits __ro_after_init; +static DEFINE_STATIC_KEY_FALSE_RO(hardware_history_features); void native_write_cr0(unsigned long val) { @@ -481,6 +483,12 @@ void cr4_init(void) this_cpu_write(cpu_tlbstate.cr4, cr4); } +static void __init setup_hreset(struct cpuinfo_x86 *c) +{ + if (cpu_feature_enabled(X86_FEATURE_AMD_WORKLOAD_CLASS)) + static_key_enable_cpuslocked(&hardware_history_features.key); +} + /* * Once CPU feature detection is finished (and boot params have been * parsed), record any of the sensitive CR bits that are set, and @@ -1951,6 +1959,7 @@ static __init void identify_boot_cpu(void) tsx_init(); tdx_init(); lkgs_init(); + setup_hreset(&boot_cpu_data); } void identify_secondary_cpu(struct cpuinfo_x86 *c) @@ -2410,3 +2419,9 @@ void __init arch_cpu_finalize_init(void) */ mem_encrypt_init(); } + +__always_inline void reset_hardware_history_hetero(void) +{ + if (static_branch_unlikely(&hardware_history_features)) + wrmsrl(AMD_WORKLOAD_HRST, 0x1); +} diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 0917c7f25720b..6a3a1339f7a77 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include "process.h" @@ -213,6 +214,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) /* Load the Intel cache allocation PQR MSR. */ resctrl_sched_in(next_p); + reset_hardware_history_hetero(); + return prev_p; } diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 226472332a70d..ea7f765c6262a 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -709,6 +710,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) /* Load the Intel cache allocation PQR MSR. */ resctrl_sched_in(next_p); + reset_hardware_history_hetero(); + return prev_p; } From patchwork Mon Oct 28 02:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839283 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2069.outbound.protection.outlook.com [40.107.96.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D99061CC882; Mon, 28 Oct 2024 02:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081014; cv=fail; b=Re2U9qFqQSJVGIm80CalOlfNeNfy8GhtL5WMkmcrDDX3Bp9FNFKTOFkJqegLWwX0D5h8Rcrx8WEy5ut9gafrEbTzwRU9IPAtw8YZPIBscOqRE2z8Wi9fZPWQHLhzm8vhp0WSrvgJ4yQVbrTES7AWvP2fdNRazfx/uz5GYxdLU2A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730081014; c=relaxed/simple; bh=v20A+qYcbUcJYDh1KpTP4gkfDSx1jIxGDQLp4XRswGw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l5H5u04Bi5uLv4jhi1iolGw5m0ovgfQ4mLu6Fqn3nYaGiDz6hSCxguaZrbhCIUuIs5iOI5nBlMFVts5UO4kfCdbWiSOd+Goo/N6QLg+yLng4h8W5S0CslMNksfCPAScEo/Gcf4Xvi0Vr1IA2FK9NI8F5RF+RaErG3eK+LuPiLB0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=n0NJvWHJ; arc=fail smtp.client-ip=40.107.96.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="n0NJvWHJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fiuYT9ipNrFWYLkD3KkgHZpL2bmKIhnRc3Yb2QSI3zpHO6ZgpwHpRKLyh3ZppqG+Y61Qu+rpY8SvDWTIaEhPt5YNtqPGlzQbjjJ1H3E5ygHpjP4VbhUx4rwrplR4Yp74MaljriKiJXDH4G5AjKKNGmFLn87IVESt+kThC4CGBzJjaNZkAUbUKg1KZ8+ohi3J1CXqAzdD7WYNskTs3KVGbSkBBVqgqT67OjU5UWHGwdNnH6WVvpHLw/gNtrtD1rqnYr8wGfD1gr+UMtiXoW3XYGQ+lz9sgnY0W/RybAps5x52G4vHkmBKrmPJKTnB3hBh77bZjkdO1+Pv7ysypFhWZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kxV7Q56HF37N215gSoJzMyoaTl4ZgHOlFr7GHMSiEq4=; b=i0aJhvOVyN05lbMqV5GK+V7WL/1XXDC7jDSXikCy/SiHxvoEOquh9wB4traBoUXBlTDUd38mel9zoDSqOFtcXlQRUzj41TeP2QRQZZgw1xTUK3DwpT3b7aLzj5xb/aKzsCe8cf3yShDQoj3vzFmfMfduBmpjpIQffw7SUVIbVm8u0PYqB+0Ze+9rlBFYdBREd3qTRGSndqaJBIBKyKUR9yyV+H3tuS6ECji51rNafI1IQxraLVCI/dtfHxkPA/FUwR0ky3/Hp7aeEOQdHZHYIVOLBCXeVlXP4cyySM5xQBTCC/arIaILs8Jlb0SKWx77iGDSTI/fk03hv0lVsLBUFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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 (0) 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=kxV7Q56HF37N215gSoJzMyoaTl4ZgHOlFr7GHMSiEq4=; b=n0NJvWHJyYao4WR4kJvrrhVP5Mq3+eiOBhiq48Qqj+x2VI7QGSx7ASNbi71opUPllNPFuPGeTTvPHZqf4QThFgaHBpwapWma2eBZFo66SYQCMDzWPKhHpyEc7g2M1645Zq79qoqBdlUDF4cgvBRJe9P1BZsSI62fT8S0AY0Y3MU= Received: from BN9PR03CA0921.namprd03.prod.outlook.com (2603:10b6:408:107::26) by PH0PR12MB8774.namprd12.prod.outlook.com (2603:10b6:510:28e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Mon, 28 Oct 2024 02:03:26 +0000 Received: from BL02EPF00021F69.namprd02.prod.outlook.com (2603:10b6:408:107:cafe::27) by BN9PR03CA0921.outlook.office365.com (2603:10b6:408:107::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21 via Frontend Transport; Mon, 28 Oct 2024 02:03: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 BL02EPF00021F69.mail.protection.outlook.com (10.167.249.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:03:25 +0000 Received: from AUS-P9-MLIMONCI.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.39; Sun, 27 Oct 2024 21:03:24 -0500 From: Mario Limonciello To: Borislav Petkov , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: , "Gautham R . Shenoy" , "Mario Limonciello" , Perry Yuan , , , , , "Shyam Sundar S K" Subject: [PATCH v5 12/13] platform/x86/amd: hfi: Set ITMT priority from ranking data Date: Sun, 27 Oct 2024 21:02:50 -0500 Message-ID: <20241028020251.8085-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020251.8085-1-mario.limonciello@amd.com> References: <20241028020251.8085-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: BL02EPF00021F69:EE_|PH0PR12MB8774:EE_ X-MS-Office365-Filtering-Correlation-Id: ad50181d-bb6b-46c5-8775-08dcf6f4b59c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: pz4QFsU9id0eGHjmOUFO2G3HNCmWd05oYIt6QWCN2KTJDup8QfLG7t+lekoeyJYe13CF7MgNckq+k0661TnlRijfmXbRGkVippz+rWkeKb9wtmxHuesweSEdG4GyjN31Tuzi7gLneiZp3+ZF++RKonw0i81zZ8amYwuemc4QfboaIh8O/gp7NwHp4KWOTY5JmquQRjEOziAcq4f45PUVcs7zXekP05AMTG1rGhGe5dDUlP4dL9EOPjBGa2HpL++wlKJe6NIl+UkAuLYo2EZSyKA7yVH5ZpAw2uqJDcJIJieo/bsVusnoMW+garIzIvCmjG4k7xXqIcGspBbWNEkJBwIl7CzzTi4orev8WcvFBFP9IeRleU4fDXSurZSgdOz+xTZdiKCE2QqdhfdktZMOisRivw7gedfpQvhwwz165WCTYXcHmbGMs6YOBWXWzvp06EOIsY2GgYNBQ6+ewDWBBMzEHeQeUF7vkfjfcz2xqTJxPzInWtsIvDCMQ7jC/suzgT8rCdJWZ2kNm+HlGHME+Czjk4CLXgq61CvAtZWNGkcuoTmoG8Ba3MjNXUH2bZwvxjVWL7curzEb5zRvhL3p0yj8raCHjkZEIdrXN0ZfM3mQ8YAS9m2NXbblYtXapbLTWUkOB+C3BPqqO8hxUXkvDHOi/Ypf5qMif80DvOC6n/xdKjJKMWym66dJ71rGQCUOoiDDf0i8YN2uIyQYj8LOQHKJ/ePjdCAPCapWWKLV+CpXamGEP2eC9prLVxK7NuwDKuf1LkGYUrq16dkoR2l1DX5bIs1krPw1g7b9eHwP9xHGGMSG+RFq5wWiZFGQJ1EtGPG8mr+sn4u8qctd5qly+Bvr9EzKJrRUNzwrvY1hZylVQkfDPhcfLCkABSvglgtuZQkzTqVYNgWZysFZsNlk8eeE/C/qJsxR9QwrT2E8qaZzJURv2kggQ0cohxSaayXN3YybriUO0whUfdIxtP0XsDLrzat6EyCXRBK7710SDJOpm5aEIKJ/JO/+Qn3jPfZwDz8FgSDCSdj+Sqwzm5hid+lmaR4O73pm9QhvVfShsi47fYQy/ZlX5jvXAFM0gJV5wFWzOzDHq0xSKmWIbrxNDeAiUPHuRRvh0/S0URTGeXa/j+FBN9o6rJzr2BnS7czRzI7SiZg/D/nzh7XnXiGORcrhjnC9bBRWOLi+Ibtq/LjHtfr6eJpPGyWEIsXvdI+ezyss/bstry4EVucTAppJbODsq6W890TmxEhwd70j9Ps9OqbTsqdZX7QPYY0I4X6miibZDcIs2yNQJBkc3HcqeKA469x9f9leOnbox3MjjEfHr5swD8I8Suow0AHc8T3EdjI6FMURgV+sMaoGSbClHShElOv6h8u6PHPv/WvWMSaMJky9cxDgb/6HXuuzLglR4Z74dt1Cd3ZPzbX9iDkSeg== 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:(13230040)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:03:25.8530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad50181d-bb6b-46c5-8775-08dcf6f4b59c 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: BL02EPF00021F69.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8774 The static ranking data that is read at module load should be used to set up the priorities for the cores relative to the performance values. Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/hfi/Kconfig | 1 + drivers/platform/x86/amd/hfi/hfi.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/platform/x86/amd/hfi/Kconfig b/drivers/platform/x86/amd/hfi/Kconfig index 08051cd4f74db..4dfa7641b35bf 100644 --- a/drivers/platform/x86/amd/hfi/Kconfig +++ b/drivers/platform/x86/amd/hfi/Kconfig @@ -7,6 +7,7 @@ config AMD_HFI bool "AMD Hetero Core Hardware Feedback Driver" depends on ACPI depends on CPU_SUP_AMD + depends on SCHED_MC_PRIO help Select this option to enable the AMD Heterogeneous Core Hardware Feedback Interface. If selected, hardware provides runtime thread classification guidance to the operating system diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c index c8fe03d0c9ccd..50407ab805169 100644 --- a/drivers/platform/x86/amd/hfi/hfi.c +++ b/drivers/platform/x86/amd/hfi/hfi.c @@ -116,6 +116,12 @@ static DEFINE_PER_CPU(struct amd_hfi_cpuinfo, amd_hfi_cpuinfo) = {.class_index = static DEFINE_MUTEX(hfi_cpuinfo_lock); +static void amd_hfi_sched_itmt_work(struct work_struct *work) +{ + sched_set_itmt_support(); +} +static DECLARE_WORK(sched_amd_hfi_itmt_work, amd_hfi_sched_itmt_work); + static int find_cpu_index_by_apicid(unsigned int target_apicid) { int cpu_index; @@ -242,6 +248,8 @@ static int amd_set_hfi_ipcc_score(struct amd_hfi_cpuinfo *hfi_cpuinfo, int cpu) WRITE_ONCE(hfi_cpuinfo->ipcc_scores[i], hfi_cpuinfo->amd_hfi_classes[i].perf); + sched_set_itmt_core_prio(hfi_cpuinfo->ipcc_scores[0], cpu); + return 0; } @@ -459,6 +467,8 @@ static int amd_hfi_probe(struct platform_device *pdev) if (ret < 0) return ret; + schedule_work(&sched_amd_hfi_itmt_work); + return 0; }