From nobody Mon May 25 06:42:07 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013060.outbound.protection.outlook.com [40.93.201.60]) (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 53B8B2DECD3; Sun, 17 May 2026 15:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030767; cv=fail; b=F8vGq93C8suZOlJcZX22NsXYPlK9RZYcmyZYU1WZ7fyLS7rOJJBa5nCgNUsFxA7UOUKJGBTBCz7FyC3ODs+lSY3yDzUV2kAZFu71yfHUu+SkwQBNHmlFe/4IqgGsvR1ICDUFRbgNJ1Kn0xVKwksIMOeocS1cN8cY2wlxOs//dRE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030767; c=relaxed/simple; bh=Ga6mCKtPXANjkTNXGwr408UF3GVoauPzAJ779o7bPG0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DGjCIVn19weS3/cBqBw697KXRu7xhNFGYOlS2okPV7R6GWvgcBYyFtkDWyDO6haqiQCZJEwEcnrrr9X0czaRzAlXjQiQ2lhXxJAXu9XI0s2kXRHeufQTX9cuu0ZA13AISw5Uak4bGYlOi0NnmfPDHl93/DDmol9ehN13riVrtB0= 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=n/ob/Iiw; arc=fail smtp.client-ip=40.93.201.60 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="n/ob/Iiw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MbIDDg5kynvb7x37iKe8inwvGlhVpqKrB4332KAlSOu8ioswoaFR7ZSQ7K8TLnRVxbwJy9qFzuU1hoL3UEjOG9gcNy9f75mIX3sOOb3X1GIPqTI6EH3AiR/G0x+QaEEUMz2g/x0uDvCV1CkvsXLIShbEF0gSWR2dra22PwN3/e+He3NsKaRdapAt5xGgEZe/aRuYhnuZAcGDhU3nqZu7R3n/uQMeXUQUnXh2z4wllrvKBFmMgI5E5wXXGj27i8UMI+rvtstSz9rvr9oC5ZxYYrYEj8S82IDUfDXsMg/DammEyaBTttjTj9UqfFibFJrdT9CfjT2muJXf3+LH4Ml9Zg== 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=cXo1B0jJb2XVJz/1NnZd7NeHXHRTAQuQQ+lUrPIv1Vk=; b=XAAQAnJkoaVLas7TsJwsy4wReX+dppxxBeCCIFaTfQ5cS1SUEMho2B3Te/2h4LTrhC/2yhr5VbJB8oIIu5wtOmdtToOaXNxIRYVpzjmknn5cJVeTBQ6aAhksDW8X6yGfdv3GHlepVdZ5ekSvQBebhl5O5V7croSnM4oGhSkLdvX2r4/QGaRqjksIhCFMu+fGOLm+IfwHwCMba5JRj9MAF/j75U1ibcej/V+R5B57CL6iL/r7Iiu1InBlazjaj+wsW+liPV7cETVNzLXMEvEZqSNlvhhqY+9TggFGC5aFBjPXn9SsLRPy6pAMp56TfgpYIt8XiequkjVfqa6byeCYNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=cXo1B0jJb2XVJz/1NnZd7NeHXHRTAQuQQ+lUrPIv1Vk=; b=n/ob/Iiw2sPon9Fc5OcXQ+2qO7rq32KIbbO8iZpLPshLd+9b5+vLxd2ga7uexsi/HVtS+dL/q+F7wrBUbzKVJWv6V4U5w9IvvABtuVStKJWPpypKXK6Zk/EswQIv+r/KtRsYI2iGowo73bmE2vJrYn6b6oiv+crD83vieCsgxAA= Received: from MW4PR03CA0244.namprd03.prod.outlook.com (2603:10b6:303:b4::9) by IA0PR12MB9048.namprd12.prod.outlook.com (2603:10b6:208:408::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9913.11; Sun, 17 May 2026 15:12:40 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:303:b4:cafe::83) by MW4PR03CA0244.outlook.office365.com (2603:10b6:303:b4::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.25.21 via Frontend Transport; Sun, 17 May 2026 15:12:39 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:39 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:36 -0500 From: Muralidhara M K To: CC: , , Suma Hegde , Muralidhara M K , Muthusamy Ramalingam Subject: [PATCH v3 1/7] platform/x86/amd/hsmp: Add new HSMP messages for Family 1Ah, Model 50h-5Fh Date: Sun, 17 May 2026 20:42:05 +0530 Message-ID: <20260517151211.415627-2-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075ED:EE_|IA0PR12MB9048:EE_ X-MS-Office365-Filtering-Correlation-Id: 7707fda2-4f7d-44e4-4b9b-08deb426bc72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700016|1800799024|82310400026|11063799003|18002099003|22082099003|56012099003|3023799003; X-Microsoft-Antispam-Message-Info: Xtf0E1cs1RAGCLTaoGugdA+Q3rcVJat9b/GFvM96cldhT3Eqp1fLloo04AOUKeTVtR15vSTk+I1f8abfFsxl0q9yrghN0pEkmzprF/xcu6dH7DyzPU/3lmx0xl2NA8aWDHJybgmfZerMBNf9gjvWU1xhQ1+3LK5SGLfQlW53z7mNBcZFuEhfAVk3lD9S7lw7+wDQXkcSek5A+RA+zTVaHBSmBRZ80mj0bH2yX3k3X0ZZ2SqT38daBNnWgLYcCuypLU1/3EtijII969y5P9VJzGnd7umO/DqmgR2G7qb/oPoCBK7uM12S+aS5WLWzL5KGaFCI6d+acsSy/6kD68OyxvvC8yPidPTq0IxVOdqj1wBzDPsv7RRX5XgxUHdNf3AxAT3wXzz+AG6981ZN3EAg3TMviONXYnozcw9EmPJIahheiDedttmAIaSnjlM8wzX6o/9DXfrwDLSwI/9oEb/AZiLbCiHMxdRVW93KZdVjNNTu1z4iZN9rhrZ3ktT1ATwuQnApmFmDCSaUpCJMvcU4/vChVpNr+P3F8KiuCYlAJ3/L1nX04SpscF9mIkKn3KXoDobQGk1NZ6jv3QKns5ho1rmYB0FHbuPWwSrF8qxtqswQJK9eDyMJmnYmgIqjs3FGseOVWpFjGO8O9xAYJhuKaIeGe2QcQEeAXBHMEbZv0E5SUNeFsFytNcGG16Z+anc2u0EuMSY+8b0M0F7mdbMqnMjXccPKF0P6CPsoDVxVmqA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700016)(1800799024)(82310400026)(11063799003)(18002099003)(22082099003)(56012099003)(3023799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZzydO8lrzfpzq7UbNaJBr0weRbAtUz3Vzn6Fe7UeLFK2DJToIJzbpeVJkKLtRM1Fiz+lrzACQm1XtyxUbOX+7aqY7ap1IRx5tgAgfDx/I1NM9wKsYsLteSZKyRC3SARuTXdzJfM//RSoNJvlGQnHU5azwkTRm5iMXyKMRFy0xWp1j29MgMVmzZdGjEhnZeS1iBLFQhF7IoJlfSwO3/CrztllDVLY8Cn3v7qdBkJ66WQdUMZ2xfN+P4aifLI+/OJZC/vFfbFa09wk3B6AooPG3O5qldSPd3hiv1IEseG5lgxMuuTNg6BqiLgcArZG2462sMYk4H4cfYTz11gncVQxveEvZvd5ZGAY3PGUjxgKMfEAi0eTPQVP3BqZKDnkUoKsRXd3U+KwIoHq9y7GCSbCQDhQXHRjyhbji3tPftEaKvvyV5yE3jAECE7n+2TJ/6bU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:39.5197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7707fda2-4f7d-44e4-4b9b-08deb426bc72 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB9048 Content-Type: text/plain; charset="utf-8" From: Suma Hegde The new messages extend the HSMP interface to provide finer control over power states and system monitoring capabilities. Power state control: - Get/Set PC6 and CC6 enable/disable control (0x29, 0x2A) Power and thermal monitoring: - Get CCD power consumption reading (0x34) - Get Thermal delta (Tdelta) reading (0x35) - Get SVI3 VR controller temperature (0x36) DIMM sideband operations: - Get/Set DIMM sideband data(0x33, 0x39) Power management: - Get/Set Floor limit control (0x38) - Get/Set SDPS limit control (0x3A) System capabilities: - Get enabled HSMP commands (0x37) Bump driver version to 2.6. Reviewed-by: Muralidhara M K Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Suma Hegde --- Changes v1->v3: None arch/x86/include/uapi/asm/amd_hsmp.h | 142 +++++++++++++++++++++++---- drivers/platform/x86/amd/hsmp/hsmp.h | 2 +- 2 files changed, 126 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/a= sm/amd_hsmp.h index 92d8f256d096..603d62f8d4da 100644 --- a/arch/x86/include/uapi/asm/amd_hsmp.h +++ b/arch/x86/include/uapi/asm/amd_hsmp.h @@ -53,9 +53,19 @@ enum hsmp_message_ids { HSMP_SET_XGMI_PSTATE_RANGE, /* 26h Set xGMI P-state range */ HSMP_CPU_RAIL_ISO_FREQ_POLICY, /* 27h Get/Set Cpu Iso frequency policy */ HSMP_DFC_ENABLE_CTRL, /* 28h Enable/Disable DF C-state */ + HSMP_PC6_ENABLE, /* 29h Get/Set PC6 enable/disable status */ + HSMP_CC6_ENABLE, /* 2Ah Get/Set CC6 enable/disable status */ HSMP_GET_RAPL_UNITS =3D 0x30, /* 30h Get scaling factor for energy */ HSMP_GET_RAPL_CORE_COUNTER, /* 31h Get core energy counter value */ HSMP_GET_RAPL_PACKAGE_COUNTER, /* 32h Get package energy counter value */ + HSMP_DIMM_SB_RD, /* 33h Get data from a specified device o= n the DIMM */ + HSMP_READ_CCD_POWER, /* 34h Get the average power consumed by CCD */ + HSMP_READ_TDELTA, /* 35h Get thermal solution behaviour */ + HSMP_GET_SVI3_VR_CTRL_TEMP, /* 36h Get temperature of SVI3 VR controller = rails */ + HSMP_GET_ENABLED_HSMP_CMDS, /* 37h Get/Set supported HSMP commands */ + HSMP_SET_GET_FLOOR_LIMIT, /* 38h Get/Set supported Floor limit comm= ands */ + HSMP_DIMM_SB_WR, /* 39h Set data to a specified device on = the DIMM */ + HSMP_SDPS_LIMIT, /* 3Ah Get/Set SDPS limit */ HSMP_MSG_ID_MAX, }; =20 @@ -170,16 +180,18 @@ static const struct hsmp_msg_desc hsmp_msg_desc_table= [] {0, 1, HSMP_GET}, =20 /* - * HSMP_SET_XGMI_LINK_WIDTH, num_args =3D 1, response_sz =3D 0 - * input: args[0] =3D min link width[15:8] + max link width[7:0] + * HSMP_SET_XGMI_LINK_WIDTH, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get XGMI Link width[31] + min link width[15:8] = + max link width[7:0] + * output: args[0] =3D current min link width[15:8] + current max link wi= dth[7:0] */ - {1, 0, HSMP_SET}, + {1, 1, HSMP_SET_GET}, =20 /* - * HSMP_SET_DF_PSTATE, num_args =3D 1, response_sz =3D 0 - * input: args[0] =3D df pstate[7:0] + * HSMP_SET_DF_PSTATE, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get df pstate[31] + df pstate[7:0] + * output: args[0] =3D APB enabled/disabled[8] + current df pstate[7:0] */ - {1, 0, HSMP_SET}, + {1, 1, HSMP_SET_GET}, =20 /* HSMP_SET_AUTO_DF_PSTATE, num_args =3D 0, response_sz =3D 0 */ {0, 0, HSMP_SET}, @@ -305,16 +317,18 @@ static const struct hsmp_msg_desc hsmp_msg_desc_table= [] {1, 1, HSMP_SET}, =20 /* - * HSMP_SET_POWER_MODE, num_args =3D 1, response_sz =3D 0 - * input: args[0] =3D power efficiency mode[2:0] + * HSMP_SET_POWER_MODE, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get power mode[31] + power efficiency mode[2:0] + * output: args[0] =3D current power efficiency mode[2:0] */ {1, 1, HSMP_SET_GET}, =20 /* - * HSMP_SET_PSTATE_MAX_MIN, num_args =3D 1, response_sz =3D 0 - * input: args[0] =3D min df pstate[15:8] + max df pstate[7:0] + * HSMP_SET_PSTATE_MAX_MIN, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get DF P-state range[31] + min df pstate[15:8] = + max df pstate[7:0] + * output: args[0] =3D min df pstate[15:8] + max df pstate[7:0] */ - {1, 0, HSMP_SET}, + {1, 1, HSMP_SET_GET}, =20 /* * HSMP_GET_METRIC_TABLE_VER, num_args =3D 0, response_sz =3D 1 @@ -335,10 +349,12 @@ static const struct hsmp_msg_desc hsmp_msg_desc_table= [] {0, 2, HSMP_GET}, =20 /* - * HSMP_SET_XGMI_PSTATE_RANGE, num_args =3D 1, response_sz =3D 0 - * input: args[0] =3D min xGMI p-state[15:8] + max xGMI p-state[7:0] + * HSMP_SET_XGMI_PSTATE_RANGE, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get XGMI pstate range[31] + min xGMI p-state[15= :8] + + * max xGMI p-state[7:0] + * output: args[0] =3D min xGMI p-state[15:8] + max xGMI p-state[7:0] */ - {1, 0, HSMP_SET}, + {1, 1, HSMP_SET_GET}, =20 /* * HSMP_CPU_RAIL_ISO_FREQ_POLICY, num_args =3D 1, response_sz =3D 1 @@ -355,9 +371,21 @@ static const struct hsmp_msg_desc hsmp_msg_desc_table[] */ {1, 1, HSMP_SET_GET}, =20 - /* RESERVED(0x29-0x2f) */ - {0, 0, HSMP_RSVD}, - {0, 0, HSMP_RSVD}, + /* + * HSMP_PC6_ENABLE, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get PC6 control[31] + disable/enable PC6[0] + * output: args[0] =3D current PC6 control status[0] + */ + {1, 1, HSMP_SET_GET}, + + /* + * HSMP_CC6_ENABLE, num_args =3D 1, response_sz =3D 0/1 + * input: args[0] =3D set/get CC6 control[31] + disable/enable CC6[0] + * output: args[0] =3D current CC6 control status[0] + */ + {1, 1, HSMP_SET_GET}, + + /* RESERVED(0x2B-0x2F) */ {0, 0, HSMP_RSVD}, {0, 0, HSMP_RSVD}, {0, 0, HSMP_RSVD}, @@ -385,6 +413,86 @@ static const struct hsmp_msg_desc hsmp_msg_desc_table[] */ {0, 2, HSMP_GET}, =20 + /* + * HSMP_DIMM_SB_RD, num_args =3D 1, response_sz =3D 1 + * input: args[0] =3D + * Register space[23] + * Register offset in given reg space[22:12] + * LID of device[11:8] + * DIMM address[7:0] + * output: args[0] =3D [3:0] Read data byte + */ + {1, 1, HSMP_GET}, + + /* + * HSMP_READ_CCD_POWER, num_args =3D 1, response_sz =3D 1 + * input: args[0] =3D apic id of core[15:0] + * output: args[0] =3D CCD power(mWatts)[31:0] + */ + {1, 1, HSMP_GET}, + + /* + * HSMP_READ_TDELTA, num_args =3D 0, response_sz =3D 1 + * input: None + * output: args[0] =3D thermal behaviour[31:0] + */ + {0, 1, HSMP_GET}, + + /* + * HSMP_GET_SVI3_VR_CTRL_TEMP, num_args =3D 1, response_sz =3D 1 + * input: args[0] =3D SVI3 rail index[3:1] + Read SVI3 temperature data[0] + * output: args[0] =3D SVI3 rail index[30:28] + SVI3 rail temperature(deg= ree C)[27:0] + */ + {1, 1, HSMP_GET}, + + /* + * HSMP_GET_ENABLED_HSMP_CMDS, num_args =3D 1, response_sz =3D 3 + * input: args[0] =3D HSMP command mask[0] + * output: status of HSMP command =3D args[0], args[1], args[2] + */ + {1, 3, HSMP_GET}, + + /* + * HSMP_SET_GET_FLOOR_LIMIT, num_args =3D 1, response_sz =3D 1 + * input: args[0] =3D + * Set or Get[31:30] + * Set the Floor frequency per core =3D 00 + * Set the Floor frequency for all cores =3D 01 + * Get the Floor frequency of a core =3D 10 + * Get the Effective Floor frequency per core =3D 11 + * Reserved[29:28] + * Apic id / Reserved[27:16] + * args[27:16] is reserved if args[31:30] =3D 01 + * Floor frequency limit / Reserved[15:0] + * if args[31] =3D 0, Floor frequency limit, else reserved + * + * output: args[0] =3D + * Effective Floor frequency limit(MHz) / None / Floor frequency limit[15= :0] + * Effective Floor frequency if input args[31:30] =3D 11 + * None if input args[31] =3D 0 + * Floor frequency limit (MHz)[15:0] if args[31:30] =3D 10 + */ + {1, 1, HSMP_SET_GET}, + + /* + * HSMP_DIMM_SB_WR, num_args =3D 1, response_sz =3D 0 + * input: args[0] =3D + * Write Data[31:24] + * Register space[23] + * Register offset in given reg space[22:12] + * LID of device[11:8] + * DIMM address[7:0] + * output: None + */ + {1, 0, HSMP_SET}, + + /* + * HSMP_SDPS_LIMIT, num_args =3D 1, response_sz =3D 1 + * input: args[0] =3D Set/Get[31] + SDPS Limit[30:0] + * output: args[0] =3D SDPS Limit[30:0] + */ + {1, 1, HSMP_SET_GET}, + }; =20 /* Metrics table (supported only with proto version 6) */ diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/am= d/hsmp/hsmp.h index 0509a442eaae..b153527e0a0d 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -27,7 +27,7 @@ #define HSMP_DEVNODE_NAME "hsmp" #define ACPI_HSMP_DEVICE_HID "AMDI0097" =20 -#define DRIVER_VERSION "2.5" +#define DRIVER_VERSION "2.6" =20 struct hsmp_mbaddr_info { u32 base_addr; --=20 2.34.1 From nobody Mon May 25 06:42:07 2026 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011060.outbound.protection.outlook.com [52.101.57.60]) (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 9797D1C84A2; Sun, 17 May 2026 15:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030769; cv=fail; b=ZCXm0V/62+KutLA1gj6o0g+R0AytRU1W4d2zuPGSVO48AL0s/Ez9zpPikDDtw8YW1FPsfBDKWbFfXBXbEnLMCKtm9kRfXEEc3cuXjNak4rLqH2PB+TMcBF654FtVUgNBtXDQUjSjtCT0NurHoSAflIyq+MUdBFfAlBrvziecQ3o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030769; c=relaxed/simple; bh=cDX0JTV010ssd+HsFFsmuQ3cp1z1KvHhTjwn3rbLHok=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qbDC0X4lTz3nYutEFrACK+SDXUhmxTAXmDvqAUauJZjIxT69/Ve4gohiCqr0RRaX2hNg/stj5nmRDZ+LqUUPMmaTj2QK7n9NCntT9MekPkZPcx58XPqyznDbMXDr10qyK/ga1c0M9iF9+5/UXOPbRt3+YXAWnnO+YlyaZUMs2Lk= 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=ulSF5qDP; arc=fail smtp.client-ip=52.101.57.60 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="ulSF5qDP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CdjewzFSMKNuaiGMd8uFy/E6ETdq9JqSgY29/EU7k6Tt9ZRPs8NZSZ30pb63HfBhLIUGKNZUryrV4MA8NeDvBUJqN0T+KsTsdXjuHFuEfSOjz2FMRr6cNh55DioWLHd++VGxxEiddKsVzvxyGRufE/XamEin5jt7Lj0cxp7SuahXLOYqNMRoCPH6ZiaU2HAz3XtFHD3EEHsSMwgOJLf30DKB7G4xOiBnvHZFOVsMpbeVVKRHlMN5ebKIPeJJDs3Ns1+AjueG+8KQJM2ADC9tHSlm9RALgqNIvW7aRlVfLuxqSyyIPXo9nIBio8pnvMx4s4uiFhJq7E9o7eMQ4N4ECA== 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=EMK7RNrXVBsnd2qMlojNWiDgT3HIz8WUrBbyvGftEvo=; b=IJePRWniPX2Ew3/+szeVDiMYhTPv3xrLEaBqiEX2iUJn1puhCdzXbClYbWQ9W2wHFRyBhEjdTv/1iiQDCs98WdTAwD9hNulsaNJJjwbK+8RGV/DHednHeyNdWGav3grmvvv4H5iZEpljqaxzRpRsfdwaALbTNYBhCh7mO9Be+r39i+i/oFg09ekKZcTzy2mMHhb9TBC0RGpJyP4ZHdMZhSj4XPw5SV2o1fcUV21NmRp8bg8wk75Hds1U1wjsFjy3omcpyDivmqlnRnXg7PnZRUEtNlJTd7+jOQqv/YLmK2g2A274AFKqdZcZMzl9LPDO+bp2YmlzlLKiwhn5pSa7PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=EMK7RNrXVBsnd2qMlojNWiDgT3HIz8WUrBbyvGftEvo=; b=ulSF5qDPTklP6oGvWvTQ1BO0/KpJgH9c4jz3BFr3n9A07pLG5OTvImFzBcZeGvwwlmHR9oDxyOvWlZne6N5Jn+d0IHm8aJMGqVBnr2I1yHbS2CNeOLtP+sgGtQEIChhw1Bsch+fULywCnwIPLv4w2Vu15pyl2s6Efpy/RdJZAaU= Received: from MW4PR03CA0244.namprd03.prod.outlook.com (2603:10b6:303:b4::9) by BL1PR12MB5946.namprd12.prod.outlook.com (2603:10b6:208:399::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.22; Sun, 17 May 2026 15:12:41 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:303:b4:cafe::83) by MW4PR03CA0244.outlook.office365.com (2603:10b6:303:b4::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.25.21 via Frontend Transport; Sun, 17 May 2026 15:12:41 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:41 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:38 -0500 From: Muralidhara M K To: CC: , , Muralidhara M K , Suma Hegde , Muthusamy Ramalingam Subject: [PATCH v3 2/7] platform/x86/amd/hsmp: Add UAPI structures for Family 1Ah Model 50h-5Fh metrics table Date: Sun, 17 May 2026 20:42:06 +0530 Message-ID: <20260517151211.415627-3-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075ED:EE_|BL1PR12MB5946:EE_ X-MS-Office365-Filtering-Correlation-Id: 82ec0c2d-3b00-4e86-5c0e-08deb426bd5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|376014|1800799024|3023799003|56012099003|11063799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: BLzFqoux48NdzVkXAHFvLsOTPQVBWr/LGVf+rTNMKEqulDeR+u4/EJsCTyZXoR4lRfXKt2Es6SB8BrPLOtqsSxDvjOBF1SBO9aKlHBhCCZA1xI0xlxqBrpFUg+ML18rZWlftFvVD4Su/aA4NvVOPvZcOgLwpM7x3qqTv9K7Y9TUj80T9yYQSRukFXdtZQF4WkxpXON7ASKDS/KhptIBE8k5fkbvr6sIOX3Eg55mFKkPGfWGhKorappSBNgfVGzkFwpqGEUI5mqlO7CWIpLw1JyHrwlBSkWhr0sBfnOU+rMNnDPxqysh1oIxodp8O8fymxLyqxmCLkR9rWpyVbxvp8xagGaCYf86cSyL0KdD7hFc45HtFHqxap8eCq6wyOvVHz6BVRhzplwLQ5BGNQl7GvAarzPaBhACx97MmqrNC13GzjhQ814p0fYzssMhpxYZZFhEi2JUMgw82V5Ui85ZSzSNylZ7B4XbW5E85q/8uS/1amILV+r1y6CnTtOBXZqAYCp1siXdVWkAr1WpktO8F7lTEFyqzRAGlZXx3PuSG23MK2o9J1jb1lj+Ta8FrhhmlA5Ow6jSvlDXX9EU2iHTPgdP8naQTWy9ifyJ5BFEnn7Il/q9r1bXodO8aGO7QWRmidfNY7n7oKei0E93dYH6Pa/w/7ClwpbPM0PT/YAzK0Sxv9ljSpXBB9QtOX1F9LKOhKYCXb9MAvAQbi32TMv3ZAxJkGz9/kkSMMzmG96mlhTA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(376014)(1800799024)(3023799003)(56012099003)(11063799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vzi6GOrLjvk/PiF8s2tXh4BJz45DOeEU1t+60OZcE7TcUSf49esjf4G6NArwp9gXE8roCp7geoFpuBrxPZ7kgft1HByiTIynPByae5xHfa4D/9WYzHp7eVWx3PfQkSZBPS8C2i8Sxf8C24rucxQ4HH2MOLihi0NxHHHm4p7C8Vh/4cpZ8502vgAlILwkJhM5bZaWdHk2iKyc/BEHJDVChWjRVOLe0OoBa0Kb6gRsTnKxGmSo9O3cTPhLmJh3mXTt7HqPapBoYyfsInTLgO/FV0Gbq6ptx31ErB9u5KdybrH2sySlyel+KD0Y65oVQPacVgBJXuaPvAO5lc4NH93vpxG2VmZZD5JB+kYYf3exN/DJ7aXU89G/Bxsjwx3zpVSpPkvvsXuXVQ8BtN8DVFoOjoY/HB0prsVm+l0dPEZUpsownIc8l7qts/hIqGZpyLFu X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:41.0506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82ec0c2d-3b00-4e86-5c0e-08deb426bd5b 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5946 Content-Type: text/plain; charset="utf-8" Define the UAPI structures hsmp_metric_table_zen6_iod, hsmp_metric_table_zen6_ccd and the top-level hsmp_metric_table_zen6 to describe the per-IOD and per-CCD metrics layout for AMD Family 1Ah Model 50h-5Fh processors (HSMP protocol version 7). These structures allow userspace tools to interpret the raw metric table binary exposed through the HSMP character device. Driver enablement for protocol version 7 is added in a follow-up patch. Reviewed-by: Suma Hegde Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Muralidhara M K --- Changes: v1->v2: Split the change v2->v3: Move proto version check to seperate patch arch/x86/include/uapi/asm/amd_hsmp.h | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/a= sm/amd_hsmp.h index 603d62f8d4da..da3e3bbfa33e 100644 --- a/arch/x86/include/uapi/asm/amd_hsmp.h +++ b/arch/x86/include/uapi/asm/amd_hsmp.h @@ -575,6 +575,94 @@ struct hsmp_metric_table { __u32 gfxclk_frequency[8]; }; =20 +#define F1A_M50_M5F_MAX_CORES_PER_CCD_32 32 +#define F1A_M50_M5F_MAX_FREQ_TABLE_SIZE 4 +#define F1A_M50_M5F_MAX_XGMI 8 +#define F1A_M50_M5F_MAX_PCIE 8 +#define F1A_M50_M5F_MAX_CCD 8 + +/* Metrics table (supported only with proto version 7) */ +struct hsmp_metric_table_zen6_iod { + __u32 num_active_ccds; + __u32 accumulation_counter; + + /* TEMPERATURE */ + __u64 max_socket_temperature_acc; + + /* POWER */ + __u32 socket_power_limit; + __u32 max_socket_power_limit; + __u64 socket_power_acc; + __u64 core_power_acc; + __u64 uncore_power_acc; + + /* ENERGY */ + __u64 timestamp; + __u64 socket_energy_acc; + __u64 core_energy_acc; + __u64 uncore_energy_acc; + + /* FREQUENCY */ + __u64 fclk_frequency_acc; + __u64 uclk_frequency_acc; + __u64 ddr_rate_acc; + __u64 lclk_frequency_acc[F1A_M50_M5F_MAX_FREQ_TABLE_SIZE]; + + /* FREQUENCY RANGE */ + __u32 fclk_frequency_table[F1A_M50_M5F_MAX_FREQ_TABLE_SIZE]; + __u32 uclk_frequency_table[F1A_M50_M5F_MAX_FREQ_TABLE_SIZE]; + __u32 ddr_rate_table[F1A_M50_M5F_MAX_FREQ_TABLE_SIZE]; + __u32 max_df_pstate_range; + __u32 min_df_pstate_range; + __u32 lclk_frequency_table[F1A_M50_M5F_MAX_FREQ_TABLE_SIZE]; + __u32 max_lclk_dpm_range; + __u32 min_lclk_dpm_range; + + /* XGMI */ + __u64 xgmi_bit_rate[F1A_M50_M5F_MAX_XGMI]; + __u64 xgmi_read_bandwidth[F1A_M50_M5F_MAX_XGMI]; + __u64 xgmi_write_bandwidth[F1A_M50_M5F_MAX_XGMI]; + + /* ACTIVITY */ + __u64 socket_c0_residency_acc; + __u64 socket_df_cstate_residency_acc; + __u64 dram_read_bandwidth_acc; + __u64 dram_write_bandwidth_acc; + __u32 max_dram_bandwidth; + __u64 pcie_bandwidth_acc[F1A_M50_M5F_MAX_PCIE]; + + /* THROTTLERS */ + __u32 prochot_residency_acc; + __u32 ppt_residency_acc; + __u32 thm_residency_acc; + __u32 vrhot_residency_acc; + __u32 cpu_tdc_residency_acc; + __u32 soc_tdc_residency_acc; + __u32 io_mem_tdc_residency_acc; + __u32 fit_residency_acc; +}; + +struct hsmp_metric_table_zen6_ccd { + __u32 core_apicid_of_thread0[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; + __u64 core_c0[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; + __u64 core_cc1[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; + __u64 core_cc6[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; + __u64 core_frequency[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; + __u64 core_frequency_effective[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; + __u64 core_power[F1A_M50_M5F_MAX_CORES_PER_CCD_32]; +}; + +/* + * Metrics table for Family 0x1A, Models 0x50 to 0x5F, table version 0x007= 00000 + * + * Future processors within the same family and model may support a + * variable number of CCDs and cores + */ +struct hsmp_metric_table_zen6 { + struct hsmp_metric_table_zen6_iod iod; + struct hsmp_metric_table_zen6_ccd ccd[F1A_M50_M5F_MAX_CCD]; +}; + /* Reset to default packing */ #pragma pack() =20 --=20 2.34.1 From nobody Mon May 25 06:42:07 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010031.outbound.protection.outlook.com [52.101.201.31]) (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 6E4C83B4E88; Sun, 17 May 2026 15:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.31 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030770; cv=fail; b=mKjRKahLRKknq2KPlzAcuOdvRd1OR3VcdCKyPjbdepiUVhH2QPXfmMzzrykgBmwcJBlQeHSb5/tJEKQM+9bWvXi8VkYqJhs6nNu8Zt8zDKrK0WwglXUbKuMtVHd9enU2ZlzrTvPfYnG3yinniovLa/4UIcXlj4pVMFRYfm+cLN8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030770; c=relaxed/simple; bh=fbGja9l4xpwETjLM9ssSev+PJj+kDQspG8QFmx7uPvc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KOu9cWplKbLQzwlFMFSDWX7j0Mkzsq2/CIt88I3vXqwoIIpC8723tuLJyfimH6xqeIE9odZEbeEKj1jfMB/H56N8SK8RW/wAIISZvxkOlSHmXK3oP8Eo1LYcsjVBv/X3GsbAp310eaiPpkAuRhWWZrw1J2ZyOPHTKmLHB+yWG7A= 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=bBJ06lNL; arc=fail smtp.client-ip=52.101.201.31 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="bBJ06lNL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RtzBMmH6tDA7Qo5yvdyhuO1ICdgtLtTvR9OzUkEXkDr6LB103PtT+hJKFX2WVvXcDgGTb9jzVX0bzL09IbFpg8hPrH2qJRcfG36ha7/NzBeHl2vv9wQCuaC42gj8T7obZQoXVkd7adPo+IF4zGnwLcEZ2uludgMskRV2tHnDFNsCh6JAPgiiFLq+eFa+Hh1BJi1biW5tjI7lJjAuoYYvWh7xs8Gft7VnBW9ass8sV6WRk+folrhHOlrKsVzxAGeXAH9OWeWMtLG/x/m2HD5TVYO290zY2c1JPMhDOotc8bodnbN9PgpyMJOVQf+pK5fwFP5gENJbB1VmJtWd91ahFA== 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=mhst37EG5Yd/6D3gSVvZzMNi668AXSGlV4lzE9d4ZM0=; b=n6cRFHBmC9B+EB58bjbgiEriDPpdEEBURNMRYiMAP2RMEyFeR3eTibSe9KdakwlwmzXoEC5kDCDpX9FU9Hf4wksTqZhbCID1HzHJkW9OnuEGhV2ejxvb8d4Hzg0Oj0w17BMVur2YWp/AWyjz1BF3rhkoykYx9Ghf30j8FzBMJPIL4OCEhNga876Si+giyo8/ltEa9RIUckt2QYjwapfw7q2O0aZm4t7g/MH+xdNfIq0AoAD8/b2rcyqLV5And0X84/xlBIDK/IAEw8136d15e+EJkChmOWddcqL/Av2UDujzwVX8gGyeKKLi3uLwXnmXxzBidoOCy8X/RxwSTZAyYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=mhst37EG5Yd/6D3gSVvZzMNi668AXSGlV4lzE9d4ZM0=; b=bBJ06lNLngTsLUEQszmcoxU70akSVGBlT8B2POn+nUjX4BU0JxoIXzEj5LOM2S7fdMrnPzGnlinDh6rkJ+NQ6IpD0GgbDp7dMNyK4ZNGsQMVgYOsJ28npDj9TZmgJ5c65BApOLNr/ilWBgo4IEJkvJqgB7IhIGjoU7aXLifttss= Received: from SJ0PR13CA0028.namprd13.prod.outlook.com (2603:10b6:a03:2c0::33) by SA3PR12MB9226.namprd12.prod.outlook.com (2603:10b6:806:396::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.19; Sun, 17 May 2026 15:12:44 +0000 Received: from CO1PEPF000075EE.namprd03.prod.outlook.com (2603:10b6:a03:2c0:cafe::69) by SJ0PR13CA0028.outlook.office365.com (2603:10b6:a03:2c0::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.48.13 via Frontend Transport; Sun, 17 May 2026 15:12:44 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075EE.mail.protection.outlook.com (10.167.249.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:43 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:41 -0500 From: Muralidhara M K To: CC: , , Muralidhara M K , Suma Hegde , Muthusamy Ramalingam Subject: [PATCH v3 3/7] platform/x86/amd/hsmp: Unify response_sz validation to an upper-bound check Date: Sun, 17 May 2026 20:42:07 +0530 Message-ID: <20260517151211.415627-4-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EE:EE_|SA3PR12MB9226:EE_ X-MS-Office365-Filtering-Correlation-Id: 1672178e-f9d6-4c89-1d0d-08deb426bedf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|1800799024|11063799003|22082099003|56012099003|18002099003|3023799003; X-Microsoft-Antispam-Message-Info: C0NTJlnrMCn57Idgm7GwNEWf+DNGUhb2jZTYv7VwSg32nztiEotgLY+7UYUyTkAbrUGlvPXYOkBUgaU3nLe9DdUGUMdeWzT3RG5FR45pjLraFO/yXgC1BOjr/LggkjblFqtTvo3NUA/zjTs9+4JC3mhs+A+1rHymWb20RmSSvSLsf8CIi4sJgYPvav44kZX7/7ctqsIXVvJVAtXm6c5Fkd8sfpBXeO6zmxGSzln0uJyjGTUvVuyX38kj5JXD/KLrtlwt9NAosZU0ha3+bUNyxLOiilT+NPvm0oLpITyeal7/yY+mD9l6oVY1lpPtA15RSyj+H2DH+Er2n+rRde90OWi07kB6qfAquzCTIHvKONNq50y1974SkibIINt+FN/Dw/sdV3hvi2sS/BteMBCWx1Clp6iNjZGHRpi3DXUGWlpliplBuZ+bzK2o+edZqL9OQMN5IR3QNH/m6QLp6Tl4dxf6urLMQldir4JLD1pg/QySiroJOWV0D0eSsQkPKHkmG5Sn7fpD1hiZnOJrddbLY+lj7vT7T+kmYFjqsev6jqQFHo4vRNRznBGKgUa7Sg6SyVpo7JIN+/+l7UDBVKbnbzIplSTgfR6J85O/5wYZQN61JLB3OQCWBm6o1rpraX0QbDMCUMN3DAnIDM0z/jT5E2U3UJWHY54KKp0XJq5D+ScfNxA1mDFSi76vVyce6JyR2wXzLdnQHzBr68j/wbAtzsY2rwIrNOuTKvRTqtsz3Os= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(376014)(1800799024)(11063799003)(22082099003)(56012099003)(18002099003)(3023799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I3uLLblJ6RiVBlfRvHD6OOWHlm0v6FWmCQeoTDEaS0lDGHFbGg+JGk1SoaHhXH887Z1dsiqJer1Y/u4nV3MXyKE5nR8op8i6VbL3vHs0+doaL5mQ7sNaeMM6m3KRljjnewncW+UX5MOpauVNKo9jU7qjSL/e+Z85UrOeFe/UNK6m1UXzyj8ZYIsUSaq3yXPoMACNx0yE24vCreT+6RIFqMnsUyhxdmapwvBTltRV0Gi5ThZBawLc9VPz0JYNfSTmyHAZjbrs0+7Q3eCZZS9jo9KkaDeqGUNx3A8gOqLnOZdv94Onmfuv9gyNfzNHbzoTCq8mxH73YsjG2WnfIy1/vi6gQtWxkvsCs4T6hY3DkvnwkkPdwarM2y6jnKz+2widzYMA4KwTxK0rWKoodvOOKZYfxVM4tQuSnscVFJ0aOSZSab5v1qrS6urEFzsttNxw X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:43.5898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1672178e-f9d6-4c89-1d0d-08deb426bedf 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075EE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9226 Content-Type: text/plain; charset="utf-8" The original validate_message() enforced a strict equality check (response_sz !=3D table.response_sz) for HSMP_SET and HSMP_GET messages, while only HSMP_SET_GET messages used a relaxed upper-bound check. As HSMP protocol versions increase, existing message IDs may gain additional response arguments on newer platforms. The strict equality check rejects older userspace callers that were compiled against an earlier hsmp_msg_desc_table[] and request fewer response words than the current table defines, breaking backward compatibility unnecessarily. Replace the per-type branching with a single upper-bound check for all message types. This allows older userspace to request fewer response words while still rejecting any request that exceeds the hardware capability defined in the descriptor table. Reviewed-by: Suma Hegde Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Muralidhara M K --- Changes: v1->v2: New v2->v3: None drivers/platform/x86/amd/hsmp/hsmp.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/am= d/hsmp/hsmp.c index 631ffc0978d1..9bad58fef304 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -182,20 +182,15 @@ static int validate_message(struct hsmp_message *msg) return -EINVAL; =20 /* - * Some older HSMP SET messages are updated to add GET in the same messag= e. - * In these messages, GET returns the current value and SET also returns - * the successfully set value. To support this GET and SET in same message - * while maintaining backward compatibility for the HSMP users, - * hsmp_msg_desc_table[] indicates only maximum allowed response_sz. + * As the HSMP protocol evolves, newer platforms may define more + * response arguments for existing messages. Use an upper-bound + * check so that older userspace callers requesting fewer response + * words than what the current hsmp_msg_desc_table[] defines are + * still accepted, while rejecting requests that exceed the + * hardware capability. */ - if (hsmp_msg_desc_table[msg->msg_id].type =3D=3D HSMP_SET_GET) { - if (msg->response_sz > hsmp_msg_desc_table[msg->msg_id].response_sz) - return -EINVAL; - } else { - /* only HSMP_SET or HSMP_GET messages go through this strict check */ - if (msg->response_sz !=3D hsmp_msg_desc_table[msg->msg_id].response_sz) - return -EINVAL; - } + if (msg->response_sz > hsmp_msg_desc_table[msg->msg_id].response_sz) + return -EINVAL; return 0; } =20 --=20 2.34.1 From nobody Mon May 25 06:42:07 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013053.outbound.protection.outlook.com [40.93.196.53]) (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 4E7F33B8BA5; Sun, 17 May 2026 15:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030772; cv=fail; b=i+apHOtnk+E6BcIyC6BFhpj9e9q4GwiY0Hww6F0pZw19dVFgXmrT/UhzVZYW7r+4YSmPWRZOtw2FlpRGXjsXSp7M9gh7ykFE+wpI8n7DAnufbz2S5coeQSljqf6/59q/RsrhxwYrdNy9tucvJOIaF1+RGCEC9ayvtHQbBxoz/4Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030772; c=relaxed/simple; bh=1GsqC3oGbTNhjp/Q0co+4N0mk3PTf63mzBL7Mpf2kzg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZdLi43dsOvYHoCv2RuGnAlVaJgLqEXy/OgYDzL8EBrPD9JOqIOBxoVeJ6OrTF7yW4QK66Iic7lT/Ss4YBodfCEtSohs4aK1ZtstCKU75o0ws/f31BY5usiyjms0kLQlAT4YOiAJp3xWi2aWwBfe8P83lxlBkoLKz0c7BQWHQqRI= 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=U/lXvzfb; arc=fail smtp.client-ip=40.93.196.53 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="U/lXvzfb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mgKPg5z9jLY0PNlvXNZf84WLaoPhoWXP7yhneAGhpMkqP6qTJNjhGwn9Fyh4fKZD3wEKVkPxQ7eYLiFR65UtrCB1afH4fwe0wFM1bfQQIt9dNLH5Rh6/CSRO++FAkzEI/6oqlvjUdHYmw4SDeBe9bPtFzgebOOMW2FBrLHwnLSdlglFPjjsop+bU5KhpcJGR9isQNkM209/whxA+B6V5fjXw8ItsILDk/m4cFqzaUjGsy2ytNdv7OWXTu1VFxb6DjnIVYvk+Sco2JAxNBIaYzvRILbxwQAZPxFRZQaQJ2QLK0AfFGEfznk6LJtPYEjGV5wo/3rBJpGj0Hcd+EGZejA== 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=kJ0o0ja30RSVOfKnp8EP24zS1mekGAZvcQyCYNKC6Ns=; b=RgED6NIRghrIqnJKbzDTCOE5LWu2QM+0EeKbEnMNNxd/ctwQPlqPEgtlfrvHjyRr2eEuPHOuYsQG7DkS5Upx0BsJqgwOiuWRfeyQPmVD7sHlaKSpjQ85YwdDC9mAdNrhA52cz2aSFzfGZeCDtMdRuAaI2yhxiE1XSwlI4Sia36ioj7/Hxsn9riLHPZ3mfZ+m8zq1Ivu++fPMOivV4U0Zn4iXts8tzYHsQ60lQVaLTiyYHWCYgdPVYOdn8j2ljjKM+TF0Lu6NfBG+pmEZluG+SxdizgVqkRtRsvfzxhuXusAu/Ku1NwCdD7gbLwfxAfCO2lDLe91RH0jiLAhOmROJ6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=kJ0o0ja30RSVOfKnp8EP24zS1mekGAZvcQyCYNKC6Ns=; b=U/lXvzfbT40zT7NSxHUM2xiZ7w/diW43498QlADDx1XPUb+WvtTl1XsXNJG5gor+aBhXKo+tpQrQKKSD52BUgGyqRHR9XHlRDqvTn54S13DPyzuSHNOCfJlwsXL5cTgo4onyNDknEyoGoVSEfNUXfbLQ6sapG0lY8xOI5VWudPQ= Received: from SJ0PR05CA0126.namprd05.prod.outlook.com (2603:10b6:a03:33d::11) by LV2PR12MB5893.namprd12.prod.outlook.com (2603:10b6:408:175::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.21; Sun, 17 May 2026 15:12:46 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::2c) by SJ0PR05CA0126.outlook.office365.com (2603:10b6:a03:33d::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.25.16 via Frontend Transport; Sun, 17 May 2026 15:12:46 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:45 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:43 -0500 From: Muralidhara M K To: CC: , , Muralidhara M K , Muthusamy Ramalingam Subject: [PATCH v3 4/7] platform/x86/amd/hsmp: Source metric-table size from firmware Date: Sun, 17 May 2026 20:42:08 +0530 Message-ID: <20260517151211.415627-5-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F4:EE_|LV2PR12MB5893:EE_ X-MS-Office365-Filtering-Correlation-Id: 54c244b3-2d3b-4fe3-0b74-08deb426c016 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700016|1800799024|3023799003|11063799003|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 5t7pu5XiQJnuBmG2cwnPY8N/KNqvSVWjM9M0hcfwyUIhg2pwIBqt1l68qX2fGYAGxfiXrEFT3Q/E76auMcP7xW5ujpwtjGfIXB/m4YraqpqUnSzGkVmqwnGNNi6YMHYqsr7jtjsgHVfofx5Pi5Zl5UeEB8iQMKp5mzrMYib1FRXG44qiJsR7k0a6Dveduk2PSn91fT4Ho1/E3GwZ7KYYaP4V/W901C6WGPMLuHsKAfS4xsKMATelLWXaBpFKO4pk+HdE5kf/19PWwuhpER4tRg8f6DcbTFfg30/tqG8qLCHmTbaCPxO+uvgYEaqvCQpAtYl5fw5lUiQbjF7gnW+zxiLKIMNxGb91v663R34ZhGiP+zfb7v91yOStNObQWrYrhidPLietwPgjscZxIfdAZelYz+OnNItHdcR6+pwSyCJsiuXGk5aVum7K2VE/W+lxVR9hue1xfudguRDDlweEOQ3HTK8qeggwEanqA1LT83ibIAEGME8fgKvheX1/MShIUlxo0tk02DLcM8JFG6NcXMMWDrSndDGXDdOorzUpRkjXggJJv5QHgUKI94rUTCeqElD8zyMbR6Kq12hq8MqChkj6r7ExbqZg3C4p/BRp1SU3M4Jx4rHl4LA1id5/n8d1xg3PbH5gyna982XQDb4ut3VZ0tM+oISPYDt599pwmfPLyax9+1NhxOUiTqSJRi2vM2HNsDcw/0mICLAZRoRTQYF28SGTr6zV6SJbw+pB/8o= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700016)(1800799024)(3023799003)(11063799003)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mQ4whrIBoEvBUgstyhkFswfpDoHA322oERbzJqpJysycXgMSJyXBifmfDx7OoP4LII5VTtXh/abdYYtcM+2NoEHNGptuzEB9dxbX8oFJD+JDB9g3i2P6KqxH0/KJLR3b4AkdmcHeM9rwStFtUtDd+kRbQApOHYY4UjkCR1YjOQjaBA7OfgDMl2r/68W27ljaPCO3msB/7E4m7YfvR1O2+/eDcTq/mBmU2pwE51WgvfkLQ1y0/+RSbf45d6IRFk6Fi83qGTCSDoW1g60tzbRJ/Wp6ikQaGlJAvwYXlylBm68BBuTjIWKlbwQsRaSr4nEIbv+vtdeNxj3HH/T6dKb6OoJTjqpmqtNkrEahCrgpDvMF+TBzGhY5cuuwAA/Vh+40gll5VT9iKXGPQIULCHJzTVvdSHrjxFWqY3TGDL+lvBACBBZ0k/lXCmqazhW0bgLs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:45.6274 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54c244b3-2d3b-4fe3-0b74-08deb426c016 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5893 Content-Type: text/plain; charset="utf-8" The driver currently hard-codes the metric-table region size to sizeof(struct hsmp_metric_table) when it ioremaps the DRAM region returned by HSMP_GET_METRIC_TABLE_DRAM_ADDR and when it validates buffer sizes in hsmp_metric_tbl_read(). That layout is fixed for HSMP protocol version 6, but Family 1Ah Model 50h-5Fh uses the larger struct hsmp_metric_table_zen6 (~13 KB), and future processors are expected to grow the table further. Pick up the table size from firmware instead: - Bump the hsmp_msg_desc_table[] entry for HSMP_GET_METRIC_TABLE_DRAM_ADDR from response_sz =3D 2 to 3 so msg.args[2] is read back. SMU on Family 1Ah Model 50h and later populates args[2] with the DRAM region size in bytes; older firmware leaves it as 0. - Add size_t hsmp_table_size to struct hsmp_plat_device, holding the metric-table size discovered at probe time. - In hsmp_get_tbl_dram_base(), set hsmp_pdev.hsmp_table_size to msg.args[2] when firmware reports a non-zero value, and fall back to sizeof(struct hsmp_metric_table) otherwise. Use the same value for the devm_ioremap() of the DRAM region so the full firmware-reported window is mapped. - In hsmp_metric_tbl_read(), validate the caller-supplied buffer size against hsmp_pdev.hsmp_table_size instead of the hard-coded sizeof(struct hsmp_metric_table). Behaviour is unchanged on existing protocol-version-6 hardware: firmware returns 0 in args[2], the driver falls back to sizeof(struct hsmp_metric_table), and both the ioremap and the size check produce the same result as before. The ioctl interface added later in this series uses hsmp_pdev.hsmp_table_size to size its kernel buffer, validate the userspace request, and copy out the full firmware-reported region for protocol-version-7 (and future) layouts that exceed the standard sysfs PAGE_SIZE read cap. Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Muralidhara M K --- Changes: v1->v2: New v2->v3: None arch/x86/include/uapi/asm/amd_hsmp.h | 5 +++-- drivers/platform/x86/amd/hsmp/hsmp.c | 11 ++++++++--- drivers/platform/x86/amd/hsmp/hsmp.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/a= sm/amd_hsmp.h index da3e3bbfa33e..b86bbc929395 100644 --- a/arch/x86/include/uapi/asm/amd_hsmp.h +++ b/arch/x86/include/uapi/asm/amd_hsmp.h @@ -342,11 +342,12 @@ static const struct hsmp_msg_desc hsmp_msg_desc_table= [] {0, 0, HSMP_GET}, =20 /* - * HSMP_GET_METRIC_TABLE_DRAM_ADDR, num_args =3D 0, response_sz =3D 2 + * HSMP_GET_METRIC_TABLE_DRAM_ADDR, num_args =3D 0, response_sz =3D 3 * output: args[0] =3D lower 32 bits of the address * output: args[1] =3D upper 32 bits of the address + * output: args[2] =3D DRAM region size in bytes */ - {0, 2, HSMP_GET}, + {0, 3, HSMP_GET}, =20 /* * HSMP_SET_XGMI_PSTATE_RANGE, num_args =3D 1, response_sz =3D 0/1 diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/am= d/hsmp/hsmp.c index 9bad58fef304..cf9392f99298 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -356,8 +356,7 @@ ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, = char *buf, size_t size) return -ENOMEM; } =20 - /* Do not support lseek(), also don't allow more than the size of metric = table */ - if (size !=3D sizeof(struct hsmp_metric_table)) { + if (size !=3D hsmp_pdev.hsmp_table_size) { dev_err(sock->dev, "Wrong buffer size\n"); return -EINVAL; } @@ -398,8 +397,14 @@ int hsmp_get_tbl_dram_base(u16 sock_ind) dev_err(sock->dev, "Invalid DRAM address for metric table\n"); return -ENOMEM; } + /* SMU returns table size from Family 1Ah Model 50h and forward */ + if (msg.args[2]) + hsmp_pdev.hsmp_table_size =3D msg.args[2]; + else + hsmp_pdev.hsmp_table_size =3D sizeof(struct hsmp_metric_table); + sock->metric_tbl_addr =3D devm_ioremap(sock->dev, dram_addr, - sizeof(struct hsmp_metric_table)); + hsmp_pdev.hsmp_table_size); if (!sock->metric_tbl_addr) { dev_err(sock->dev, "Failed to ioremap metric table addr\n"); return -ENOMEM; diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/am= d/hsmp/hsmp.h index b153527e0a0d..e7f051475728 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -55,6 +55,7 @@ struct hsmp_plat_device { u32 proto_ver; u16 num_sockets; bool is_probed; + size_t hsmp_table_size; }; =20 int hsmp_cache_proto_ver(u16 sock_ind); --=20 2.34.1 From nobody Mon May 25 06:42:07 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011005.outbound.protection.outlook.com [40.93.194.5]) (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 DFBD13B9D84; Sun, 17 May 2026 15:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030778; cv=fail; b=QXwSCRBinGNKnlGcVXqFr60sGLrwwzdGMez6hOCKWLY43fwegNFf24WT1PLAZjwnB9pYhkpnl2eB7ym78u3PBYTi1hlR77nPuK2oKeri4+jVPtLxTfkUYQj0F+owA+Hpb+N2MkZTdlCIHP0npP/CcZUOLyfClB1GhWrRfNg8ykQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030778; c=relaxed/simple; bh=GzWc1AOF70NDFEYk40rRVA/jQ1AnhUu1Qw5AJMah2Nk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iPjuUSstx5DSxtfdRgWEGeXJXVKqxbm3yRqbek8gYkDGtMWzpk/beDcjDE6RftregPEkQPuRUqAN3IJIN2YpxK6VmNwNbOgXj4LeaKVOXBHT+hqFQh+QPTUDPNUDWBtSiHvg+plCA9y6wy8WrMylw5CO9xe8I4xrC72KJbOzpy8= 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=F/TxHj20; arc=fail smtp.client-ip=40.93.194.5 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="F/TxHj20" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f4Lmzy3l05XXKlVVYTPOMw82g6EY78xr5xUJoFvGTTC19k4yKupdibngx87mdutNkoeFgnGq6DdqqIITvDAKg7xvAt5oPfTmZRID3/4jO/dubWD2NUFya6Mzf49AbOXp3lYTJ0gS1elJ/uQmeKn4AS7OIJdMC36ujeFFRD5rfzfyXkTi4goJ3be3AU6HqfuWP4rOUZEKyOVFzmqZ6OHKkn9GJv9B+ZCwXkbOjvvDQukY/LQjgBU7DSuLApIkZDf8ktUEaV8GIF2M03ldSRV0pOLypLzpcHN2mE3VGVSGe1SzE++J0Kp1KqD2WE8qRZqLvKiiA3EEGsckuusU398o9g== 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=Sjzubx7yWzRdj0AmsaK4zgRCfyjr32T24Clhn6FpOgw=; b=onE0rVVf7WgjZ9tUZzK0HoQxEqpsADkMgd0WZwWU21wGMgv4wrTRxJH03tzqtNvNUKhZHL0a1+t+wA/KRJx16dqWmpd8z74ZeBtDjB4kWZPBdpV3JgxRMHSHHkZOq5QkZ7wqBhIB1chSFlIgBm7HYJNPzSWOrmPa5OuFDNFPwIlKq23oWc9zIIKnu25yXnfIrzk7JfuaAPUveDvDpcr3uYDlYdNuvw1enlPV7B58EPTbtHUQnWN6T+I3C5fav2MCbnxR/ormh07a5HMfqu+SaxiUyU9kmJWATCxoacTVrPes0jsiG6dYnCbGCeG2N8dMTrKEQl5TMgodrS5syNiYCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=Sjzubx7yWzRdj0AmsaK4zgRCfyjr32T24Clhn6FpOgw=; b=F/TxHj20uNXzbRCTFMFbDWeCbY8PkAU+3BcwRsgFusSCqtdgqh1QmhSTY/sLZE0ZK83LAnJitEXUj1M61WFSWAu0qFV4w5tIUzdlrx66/EY9qJJB8PY1LwbDJgWfQ9WXPaxzx+TlIif5s3x/b9qLuKqlyymGh1bnDgzAAGmvdds= Received: from SJ0PR05CA0146.namprd05.prod.outlook.com (2603:10b6:a03:33d::31) by MW4PR12MB5665.namprd12.prod.outlook.com (2603:10b6:303:187::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9913.11; Sun, 17 May 2026 15:12:48 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::2a) by SJ0PR05CA0146.outlook.office365.com (2603:10b6:a03:33d::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.48.12 via Frontend Transport; Sun, 17 May 2026 15:12:47 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:47 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:45 -0500 From: Muralidhara M K To: CC: , , Muralidhara M K , Muthusamy Ramalingam Subject: [PATCH v3 5/7] platform/x86/amd/hsmp: Add IOCTL_GET_TELEMETRY_DATA for metric table reads Date: Sun, 17 May 2026 20:42:09 +0530 Message-ID: <20260517151211.415627-6-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F4:EE_|MW4PR12MB5665:EE_ X-MS-Office365-Filtering-Correlation-Id: a52828e9-f336-4f44-e309-08deb426c14c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|1800799024|56012099003|18002099003|22082099003|11063799003|3023799003; X-Microsoft-Antispam-Message-Info: oqMKpqn0kQk9qRRGBlh3IOqZgBZLQCbolPgUlYPq6yosNCxHY1iSaD8vc1Npo4RFhPDxg6lr8gtIu89Yq4nZ0upu4ltUDawIqWw+V2FvwA66sZVV00iJI1VqIw2akerg6tDU3a7dn/vXclrUledrBWm2uRwKUPRTZFY0JmYniRT9RmdFPddEkZ/ItDmz+AInVRZJ6xBlfnD/GE/XhiS7v78aCNkUin0e70G8Al0065ERBsiMDbUVktAMglQ+8fYs73ece0WlVKTxkM18LO9lhTTA2EQd6HGwCSjVaGjyq8UVmO2zRQBg5TUP4+ttITJG1qnC2+MPD2frz3X7YBdCdnoVkt4yld+9nyPtkl0YbT+bS3xIeicRgBJX1WtmK3N4p5HiBmYd7rDGh1c+fZUibTEigyOEQAsguIGh+FQ7mYvP3ABf9hVnDrNOfFY8w3EaLpt7Wqb5gjA7VZN4FbTvCRJP6TsApBLGgzeIu8BQ9GJXUvI0i0je431QCbGnCKIvpO+gdmWMHvHfaiIhY7y+V8fH2Bf1XeDNmv+eDc3GhX6bCrGlyz0onQ8/+RWrHKRuB1/LXQvXiJmSe4gruP246ZdpQ0p+alDV9rgfd2o/hpQtvUsCEFS/uyDZmMFEcpsIs176PXbYsoixMSi+3W79NQp1vouAyBDwiVAlu70MinseeRySokZb/fyNCHecd0KNcDVcTnTknePn+ZuZxKLY8Y88wn7IxV8iacFk32O7swY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(376014)(1800799024)(56012099003)(18002099003)(22082099003)(11063799003)(3023799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /KNfDLY99Eo60iOapF3qdw1QEQJStuO37LacxDppPmVOikxoT21O0ClquamBjtR++HoVMg3qf/D99HGWe+Q9h7WIKFFoVSNxVetXY4sitpH+K7wksebUr2Vyv0OznCAcM1rRkDR+X4sq/h7oYBtXumZNEsteQ35zvFiHnSiXY4dHBCa+6mYFB+H6riIxHyi3tCVUm5t/qOHq2lBV6XrBDXJRsJLIO1mdS3Ws9D5UcaL5r/74z322NDrq6adYbiCF0uDLe2hOnBsXhWzptaW/Q9hn+pex2YtUsPEXBGk+Cv1k2yVxfjHi5W9M7zowLLjC240Pat3/GSqWNHVBDsEKpmYjTV7kileM7KITof+kVIESGVRXC/YamUgkRdPykmLHZZZTS7UaRwLBMx5Wp9u6QwNkvwjPezF26OTgCiWpsDxrR9y2Hi2yWLlNAgiHFe5w X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:47.6619 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a52828e9-f336-4f44-e309-08deb426c14c 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5665 Content-Type: text/plain; charset="utf-8" The metric table for Family 1Ah Model 50h-5Fh (struct hsmp_metric_table_zen6) is approximately 13 KB, exceeding the PAGE_SIZE (4 KB) cap imposed on the standard sysfs binary attribute read path. Rather than introduce new sysfs infrastructure to support binary attributes larger than PAGE_SIZE, expose the metric table through the existing HSMP character device using a new ioctl. Add struct hsmp_telemetry_data and HSMP_IOCTL_GET_TELEMETRY_DATA to the UAPI header. The request structure carries the socket index, the required buffer size and a __u64-encoded user pointer to the destination buffer, so the same layout works for 32-bit and 64-bit callers. Fields are ordered with the __u64 user pointer first so all members fall on their natural alignment under #pragma pack(4), giving a tight 16-byte struct with no implicit padding; the trailing reserved __u16 is documented as "set to zero" so future kernels can attach meaning to it. Userspace sizes its buffer using the matching UAPI metric table struct (hsmp_metric_table or hsmp_metric_table_zen6) for the running platform; sizes that disagree with the firmware- reported table size are rejected with -EINVAL so a short copy can never silently truncate the snapshot. Dispatch hsmp_ioctl() on the ioctl command, route HSMP_IOCTL_CMD to the existing message handler (factored out as hsmp_ioctl_msg()) and HSMP_IOCTL_GET_TELEMETRY_DATA to a new hsmp_ioctl_get_telemetry() helper. The new helper validates the request, allocates a kernel bounce buffer with kvmalloc() so it can hold the full table even when it exceeds a single page (zeroing is skipped because the buffer is overwritten in full by memcpy_fromio()), calls hsmp_metric_tbl_read() to refresh and copy the table from the SMU DRAM region (under the per-socket mutex introduced in a follow-up patch), and copies the table to userspace. Unknown ioctl commands now return -ENOTTY instead of falling through. Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Muralidhara M K --- Changes: v1->v2: New patch based on bin sysfs v2->v3: Replace with IOCTL method arch/x86/include/uapi/asm/amd_hsmp.h | 43 ++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 85 +++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/a= sm/amd_hsmp.h index b86bbc929395..3d085298dd52 100644 --- a/arch/x86/include/uapi/asm/amd_hsmp.h +++ b/arch/x86/include/uapi/asm/amd_hsmp.h @@ -664,6 +664,40 @@ struct hsmp_metric_table_zen6 { struct hsmp_metric_table_zen6_ccd ccd[F1A_M50_M5F_MAX_CCD]; }; =20 +/** + * struct hsmp_telemetry_data - Request descriptor for HSMP telemetry IOCTL + * @buf: Input. Userspace pointer (encoded as __u64 to keep the layo= ut + * stable between 32-bit and 64-bit callers) to the destination + * buffer that receives the metric table. + * @size: Input. Size in bytes of the buffer pointed to by @buf. Must + * match the firmware-reported metric table size for the runni= ng + * HSMP protocol version (see below); any other value results = in + * -EINVAL. The kernel does not write this field back. + * @sock_ind: Input. Socket index from which the metric table is read. + * @reserved: Reserved for future use. Callers should set this to zero; + * future kernels may begin interpreting the field, so passing + * a non-zero value today is not forwards compatible. + * + * Placing @buf first lets all fields fall on their natural alignment under + * the surrounding #pragma pack(4), so the struct is a tight 16 bytes with + * the same wire layout on 32-bit and 64-bit userspace. + * + * The exact metric table layout depends on the HSMP protocol version repo= rted + * by the firmware: + * - Protocol version 6 -> struct hsmp_metric_table + * - Protocol version 7 -> struct hsmp_metric_table_zen6 + * + * Userspace queries the protocol version (e.g. via the protocol_version s= ysfs + * attribute) and uses sizeof() on the matching UAPI structure for both @s= ize + * and the allocation backing @buf. + */ +struct hsmp_telemetry_data { + __u64 buf; + __u32 size; + __u16 sock_ind; + __u16 reserved; +}; + /* Reset to default packing */ #pragma pack() =20 @@ -671,4 +705,13 @@ struct hsmp_metric_table_zen6 { #define HSMP_BASE_IOCTL_NR 0xF8 #define HSMP_IOCTL_CMD _IOWR(HSMP_BASE_IOCTL_NR, 0, struct hsmp_message) =20 +/* + * Fetch the firmware metric (telemetry) table for a given socket via the + * HSMP character device. This avoids the PAGE_SIZE limitation of the + * sysfs binary attribute path for tables larger than one page (such as the + * ~13 KB hsmp_metric_table_zen6 used on Family 1Ah Model 50h-5Fh). + */ +#define HSMP_IOCTL_GET_TELEMETRY_DATA \ + _IOWR(HSMP_BASE_IOCTL_NR, 1, struct hsmp_telemetry_data) + #endif /*_ASM_X86_AMD_HSMP_H_*/ diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/am= d/hsmp/hsmp.c index cf9392f99298..3a02d683dea0 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include =20 #include "hsmp.h" =20 @@ -287,7 +289,7 @@ static bool is_get_msg(struct hsmp_message *msg) return false; } =20 -long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +static long hsmp_ioctl_msg(struct file *fp, unsigned long arg) { int __user *arguser =3D (int __user *)arg; struct hsmp_message msg =3D { 0 }; @@ -343,6 +345,87 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, uns= igned long arg) return 0; } =20 +/* + * Fetch the firmware metric (telemetry) table for the requested socket and + * copy it to the userspace buffer described by the request. + * + * The metric table size is variable across HSMP protocol versions and on + * Family 1Ah Model 50h-5Fh exceeds PAGE_SIZE. Userspace must therefore + * supply a buffer at least the firmware-reported size in bytes. + */ +static long hsmp_ioctl_get_telemetry(struct file *fp, unsigned long arg) +{ + void __user *arguser =3D (void __user *)arg; + struct hsmp_telemetry_data req; + struct hsmp_socket *sock; + void __user *user_buf; + size_t tbl_size; + void *kbuf; + int ret; + + /* Telemetry data is read-only; require read access on the fd. */ + if (!(fp->f_mode & FMODE_READ)) + return -EPERM; + + if (copy_from_user(&req, arguser, sizeof(req))) + return -EFAULT; + + if (!hsmp_pdev.sock || req.sock_ind >=3D hsmp_pdev.num_sockets) + return -ENODEV; + + tbl_size =3D hsmp_pdev.hsmp_table_size; + if (!tbl_size) + return -ENODEV; + + /* + * Userspace must size its buffer using the appropriate UAPI metric + * table struct for the running protocol version. Reject mismatched + * sizes so we never silently truncate or short-write. + */ + if (req.size !=3D tbl_size) + return -EINVAL; + + sock =3D &hsmp_pdev.sock[req.sock_ind]; + if (!sock->metric_tbl_addr) + return -ENODEV; + + user_buf =3D u64_to_user_ptr(req.buf); + + /* + * The bounce buffer is overwritten in full by memcpy_fromio() inside + * hsmp_metric_tbl_read(); use kvmalloc() to avoid the zeroing cost of + * kvzalloc() on the ~13 KB allocation done on every ioctl call. + */ + kbuf =3D kvmalloc(tbl_size, GFP_KERNEL); + if (!kbuf) + return -ENOMEM; + + ret =3D hsmp_metric_tbl_read(sock, kbuf, tbl_size); + if (ret < 0) + goto out; + + if (copy_to_user(user_buf, kbuf, tbl_size)) + ret =3D -EFAULT; + else + ret =3D 0; + +out: + kvfree(kbuf); + return ret; +} + +long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case HSMP_IOCTL_CMD: + return hsmp_ioctl_msg(fp, arg); + case HSMP_IOCTL_GET_TELEMETRY_DATA: + return hsmp_ioctl_get_telemetry(fp, arg); + default: + return -ENOTTY; + } +} + ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t s= ize) { struct hsmp_message msg =3D { 0 }; --=20 2.34.1 From nobody Mon May 25 06:42:07 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013023.outbound.protection.outlook.com [40.93.201.23]) (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 ED7C32C21F1; Sun, 17 May 2026 15:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030775; cv=fail; b=EyFxTz+omseru1IV+8vx+F0lUCU9Ws+NgCpr2Wyh6uC08q1AiTRtBfoQFOlqPjUyuZsRqAzk1fZ5x2nFhx7n9rnGMDE0jLe0BhEbbD3OypXGjv3ikZ3o5PrkjjEGf9oAie97M+71SlkSK52e0KxpaSz8obYgCkQrw805Vra+/5I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030775; c=relaxed/simple; bh=Jpz64DRQFaBOhK9NImATkH4mGu1956AqIE4R4jud8L0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Unf9wVwUCRUTXodyu+GrWiPiAYzemKLfOLmtEwWkzVZpTidVt9dpMbHTPitDJjabQguoF8J3wawuSabIRzKHmh7AklD1ltcTCVHHdedOgPqV9yrDft2XG3Lz1VK4fsS7omXR271Gx3lejarYv6oGb19ttxib9EnRsj3nz33Om/E= 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=qWlIqKhQ; arc=fail smtp.client-ip=40.93.201.23 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="qWlIqKhQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nLL+AGXDu3N6t7VcMWLqGqj5qNqrL1jmhM6MvmTlKK9dunrdbvf1U6BpSTeBsOSqxLprpMSkDGOFEMJkUjLQ0BgEAFSHclYf/rk6vtVQjAnSJHqpM7Zh00CjJP+S4Qxu8FxGiSexHxzrzfETw6hTIwqhUh4newkTBDouY0r73kdAhTmSwo1c2WwvlsrNRyaSTMzN5HJsSiIdQtyzaEtjt3OCBeM2O56WbwuAENu08pbsRgQJ38kLS8fisUwGML7iW7oO6Du1WRjksPXuFrq5odEpqb4dK8R+OofPZB/5Vl0HL7iAg7JWNgKAOuIgJt/lDJ+forAPrqRzkOow0tOEBA== 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=n/8Y0elS0JfKzLsDWv3u6jfyB32z85VoxqK9Cq8/oAQ=; b=lcmmysoKLcy/ZebKmOxpWMnkXMKcDs9x9Oc1ckwMK2pDnGYrjfh2Btk66DQoqdTNqOzc6dlsaMo/1FDGprh3hRo6mCDA1B5rXbwvM5BtlnT5QFMN2FLcCP/2Xq3fdZDy5dJAeiwmqovElyiX6pjp02F2aD3U4XL7tRcdkryjxUKUe014GQej0aJoqXoAmP6s1xD1LbAGjbEbaXpIjtYc0t93eydkHxTs8bv5QmUf3zhaQ9GErxFN8m2I2/LAL1o0M4tvgu6kp7xXVPFh/8hw9PcuKkm+ac9HHSouFxP7AQkv/0mbuEwYH09jxdDuya7Oh0fJ9hxCo+X36I92GbRNtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=n/8Y0elS0JfKzLsDWv3u6jfyB32z85VoxqK9Cq8/oAQ=; b=qWlIqKhQTdBRMpR6cKq1L5mXcoF+ZfEFNU5lilzC2JtK3oTPrUBhXL2HGJ0cENJccnRcmVID7A5GkZvq0i9vMrDtk+T97yjtYk10DTGntl8+ZViCFnN9SuYqnlnkf8PMFXweN+NHDALUOXURa8l2IqeqfRVW5okUmfoUzyfVc8g= Received: from SJ0PR05CA0148.namprd05.prod.outlook.com (2603:10b6:a03:33d::33) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9913.11; Sun, 17 May 2026 15:12:50 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::17) by SJ0PR05CA0148.outlook.office365.com (2603:10b6:a03:33d::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:49 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:49 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:47 -0500 From: Muralidhara M K To: CC: , , Muralidhara M K , Muthusamy Ramalingam Subject: [PATCH v3 6/7] platform/x86/amd/hsmp: Drop ACPI sysfs metrics_bin in favour of the IOCTL Date: Sun, 17 May 2026 20:42:10 +0530 Message-ID: <20260517151211.415627-7-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F4:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: b3b3099c-6bc5-4ffb-9f97-08deb426c27f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700016|18002099003|56012099003|22082099003|3023799003|11063799003; X-Microsoft-Antispam-Message-Info: rng89EC/ESwDqhOfPKT38uO5Xe6bNm0Q2w9wvl+CdO/HOyh01x+mWnmyixUJ2bV3WMYAD2BQ2GMakhWQQNfHxkVTqZmupgKE7YrvzNVzaDr24JVgswSydXwVbxj27w4v0sfNhjh8n++4FCVjBejNpK4ErZkWCHIhrVnfU7rJjWmXZIcbkuCdMn3gr47to/DtiaxiNenQn7oeJoGoXDHdplz3xzf4Bf49RQo0HlKlF5SN+OlLYzO2n3/ExRxNjiOvQBgGf1aHZmejvJjLRpYhYrEyqyBYs/yRmS93nr6IHsLdshlkV3L6pD3U8UMrCUgMKlcCgv5KrYBDcIPLl25inOG7oJVaGVn5cnuww+yE3aQ0eJ+Z27eUZ9L92ozeiH/X3ABeDlMKHZiQa1Y4vmEn0HNtQ1mQfAu3Ha34GwX1qScDSvOFgP5M7S0IFkxr9mH+6TA7tUkvCnoz0B0zPAadKWhMwMPtrRk3F0fYAecId65tBBm4Nw4bkOevjz5TLAnBNWFVEkxpHc6AatHPVm7iB1/KcqkdNHJNCWPraticJjEkCcCG5F+xMFUS//B1nMs1jc27lqEpwfukHGuNCUuxSttlpXUWP1pdBe11KTE94fatGVV66TTdH6LsBi2ozolcrGM7kZwwxMhP8XAkFZQC8oV3VkUAQ46+hxiCbt3r4gVn9GaDFfkj3RuAN2vphUdWYZJjG9ZCnRk7IGc9YYVUwV6k57lJRtblEjRAbXVw8M8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700016)(18002099003)(56012099003)(22082099003)(3023799003)(11063799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cD0UsEiwM8zscsjpHwLY49U94STzZofvOUoXnLS31qtzBJR7isEAALDkEoLJ8W4llkEih1Or8uZEKmqqsKzmBbycIYrwbZ5Ez7VVQVxrapqensj/X2kVWOwvd4XykRqzB3T12zyDZld5Gg+sSOnpuFusoKzup0klAGhkkZruZA+0gZeDJATIov/CIeWgYaENRhOQHbr7YOgqiWMp7VymmfMrAcrcZ+A8fSnWzKQgg/rGHQUCdUwrKGG1fxzGCf+glLjyMbnfISmaE7DnnXxEcX4oGhycvSjFblWbCKftGzvR1EtuAL0/pVf+pWDmvSAR72Eyyg8yiChH6oINQx0c67o5pQYB16vtj84oiB21KdD93KHwi/X05I0COBRLu+gq7em1K6A/P19a5ccjHR1rvRqNnn3AcueCiBzU55ZYKh1rYrEVlx2AREMnLLiM7Ti8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:49.6742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3b3099c-6bc5-4ffb-9f97-08deb426c27f 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 Content-Type: text/plain; charset="utf-8" The HSMP_IOCTL_GET_TELEMETRY_DATA character-device ioctl introduced in the previous patch is now the canonical interface for reading the metric table on the ACPI driver path. Unlike the metrics_bin sysfs binary attribute, the ioctl is not constrained by PAGE_SIZE, so it works for the ~13 KB hsmp_metric_table_zen6 layout used on Family 1Ah Model 50h-5Fh as well as for the existing hsmp_metric_table layout used on protocol version 6. Drop the metrics_bin bin_attribute from the ACPI hsmp_attr_grp. Widen the remaining proto_ver gate in init_acpi() from '=3D=3D HSMP_PROTO_VER6' to '>=3D HSMP_PROTO_VER6' so hsmp_get_tbl_dram_base() is invoked on protocol version 7 (Family 1Ah Model 50h-5Fh) and any future protocol version that retains a compatible per-socket metric table. This populates sock->metric_tbl_addr and hsmp_pdev.hsmp_table_size, which the ioctl handler requires. This is an ABI change for users of the ACPI driver: /sys/bus/platform/devices/AMDI0097:*/metrics_bin no longer exists. Userspace must read telemetry through the HSMP_IOCTL_GET_TELEMETRY_DATA ioctl on /dev/hsmp instead, sizing its buffer using the matching UAPI metric table struct. The non-ACPI plat.c path is intentionally left unchanged: it covers Family 1Ah Model 0h-Fh hardware that is fixed at protocol version 6, and its per-socket metrics_bin remains available for existing userspace tooling on those systems. Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Muralidhara M K --- Changes: v1->v3: Remove bin attributes drivers/platform/x86/amd/hsmp/acpi.c | 34 +--------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/am= d/hsmp/acpi.c index 97ed71593bdf..49765fefe1fb 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -231,25 +231,6 @@ static int hsmp_parse_acpi_table(struct device *dev, u= 16 sock_ind) return hsmp_read_acpi_dsd(sock); } =20 -static ssize_t hsmp_metric_tbl_acpi_read(struct file *filp, struct kobject= *kobj, - const struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) -{ - struct device *dev =3D container_of(kobj, struct device, kobj); - struct hsmp_socket *sock =3D dev_get_drvdata(dev); - - return hsmp_metric_tbl_read(sock, buf, count); -} - -static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - const struct bin_attribute *battr, int id) -{ - if (hsmp_pdev->proto_ver =3D=3D HSMP_PROTO_VER6) - return battr->attr.mode; - - return 0; -} - static umode_t hsmp_is_sock_dev_attr_visible(struct kobject *kobj, struct attribute *attr, int id) { @@ -491,7 +472,7 @@ static int init_acpi(struct device *dev) return ret; } =20 - if (hsmp_pdev->proto_ver =3D=3D HSMP_PROTO_VER6) { + if (hsmp_pdev->proto_ver >=3D HSMP_PROTO_VER6) { ret =3D hsmp_get_tbl_dram_base(sock_ind); if (ret) dev_info(dev, "Failed to init metric table\n"); @@ -506,17 +487,6 @@ static int init_acpi(struct device *dev) return 0; } =20 -static const struct bin_attribute hsmp_metric_tbl_attr =3D { - .attr =3D { .name =3D HSMP_METRICS_TABLE_NAME, .mode =3D 0444}, - .read =3D hsmp_metric_tbl_acpi_read, - .size =3D sizeof(struct hsmp_metric_table), -}; - -static const struct bin_attribute *hsmp_attr_list[] =3D { - &hsmp_metric_tbl_attr, - NULL -}; - #define HSMP_DEV_ATTR(_name, _msg_id, _show, _mode) \ static struct hsmp_sys_attr hattr_##_name =3D { \ .dattr =3D __ATTR(_name, _mode, _show, NULL), \ @@ -559,9 +529,7 @@ static struct attribute *hsmp_dev_attr_list[] =3D { }; =20 static const struct attribute_group hsmp_attr_grp =3D { - .bin_attrs =3D hsmp_attr_list, .attrs =3D hsmp_dev_attr_list, - .is_bin_visible =3D hsmp_is_sock_attr_visible, .is_visible =3D hsmp_is_sock_dev_attr_visible, }; =20 --=20 2.34.1 From nobody Mon May 25 06:42:07 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010032.outbound.protection.outlook.com [52.101.201.32]) (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 B12E635A3AF; Sun, 17 May 2026 15:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030778; cv=fail; b=lZwzx9Eu/wgUU4FDAX2q9BMykIA2vTHeMztw6g5FOdVlEZl0+9dDph7UUW+whOzGxQtmUukR08xPkne/BhENeMk8C8yVCvHmbktTfCnSRYI/NMRKor2wZjomi7Nt6Erw2XWU8NgRZGfwMFt+xAUOwnPXe354zt6nE3Lzf+lnsTs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779030778; c=relaxed/simple; bh=76l4/edzCTA9l3wG8k9IJ78ROb6tj5gFGgbV5oV+xUs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nvYiw6EWpVnp8QZj1Egd99w1Rm6lVRkcOCnC2gZNA7QaTUR1GMY0UXpb29CY3+27nhU/+aZd5b7p4AzpWEmK4jnkrFGgwqI0mm+plmpmImuzQGNwYfxR0VF/FJrd6hTZwilSeCzGOAG6Z/Gii+yxgC6bWCaaeiD1FJFaWsaOCbE= 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=0hfaFTr0; arc=fail smtp.client-ip=52.101.201.32 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="0hfaFTr0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OE5AWeSmttnybO7ycilkezRQkATgWVqPrlaw3f2i8Y7SKOn+Rj0g+2ebWZx0zCoHs48aWPTXo9sJQ/rDX5wm6vcegVxxq909QHH0v3Bv/y3hHiTkdM6kbmECiPhrcLvksPktSmoX7Sqrifsn3x/MWtKaomZOfYjZ1NKAZJMet9dCl7s+KtBsjwzlwFrBgtNWV6tn+eBR3DG1fV5rLjE3ECoRFbn6DP3D0FC+rIRrPF+4Af/a8S9jChc+BNIzvHftgLzEbEGyhaxV0wdzKeSBsBKxcTS5bPdjXcjHNW0RK7h6mN/NNJ+B36LlSc57NXenuHQ2X+Mkmy551C444aVfbg== 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=+ne5hhFMssWtvyyRLkgKvlmSVvxyq7lR4rn93MWfU1c=; b=R3Ha41vy836fkJQ6d2/AF6Hf5NG6jTq2tRG2O25L4KdEGT8pv7DxAE7YMX83x/UTFvAbFKGKqwZ7JpO5H4F9OnCpRfmGOLi6CHXKMymYWDlwVChIEqKYBolR/Dsty5+5pzejRFXmlSoYZMFvdxrcOjYhmmCfDaXZGCVLX+b18x3XRr65F9ezavWpbBX3SHz4hkqkYoo2o3etK93FEMjZox9E8W/xPpHG3pwkFk7pTHbbKRr6gLFyGcm4vDrmnWs3Dt8rOLTw4fTqGWLUFfMHjwMsDeidINtaPQUp5QE5aOoI3JgBoV2KFwwIDJzHvTL6mVc4wwJ2H2sAiIN2LHThOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.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 (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=+ne5hhFMssWtvyyRLkgKvlmSVvxyq7lR4rn93MWfU1c=; b=0hfaFTr0ffoElkQmr+5zTMXQCGlsO7iRDFOp47eL4se3cjIUGC/V/irtcq6yH0ewL4PS88slPaBdHk/xEMT5iYMGi0sfe9gCSB5jv5pfL7xAYf7DKCVn2zVzc8CPFlTLyeYSUQ2JJRxIgEOlaH5igTGWxTpg+x2n/f45u+OlG3o= Received: from SJ0PR05CA0129.namprd05.prod.outlook.com (2603:10b6:a03:33d::14) by DSWPR12MB999153.namprd12.prod.outlook.com (2603:10b6:8:36e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9891.21; Sun, 17 May 2026 15:12:51 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::99) by SJ0PR05CA0129.outlook.office365.com (2603:10b6:a03:33d::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.48.12 via Frontend Transport; Sun, 17 May 2026 15:12:51 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.11 via Frontend Transport; Sun, 17 May 2026 15:12:51 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 17 May 2026 10:12:49 -0500 From: Muralidhara M K To: CC: , , Muralidhara M K , Muthusamy Ramalingam Subject: [PATCH v3 7/7] platform/x86/amd/hsmp: Make metric table read locking use guard(mutex) Date: Sun, 17 May 2026 20:42:11 +0530 Message-ID: <20260517151211.415627-8-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260517151211.415627-1-muralidhara.mk@amd.com> References: <20260517151211.415627-1-muralidhara.mk@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F4:EE_|DSWPR12MB999153:EE_ X-MS-Office365-Filtering-Correlation-Id: 6093c752-8a48-4cfc-0a49-08deb426c353 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700016|56012099003|22082099003|18002099003|11063799003; X-Microsoft-Antispam-Message-Info: +VGbRF/dTiOmlpkGZOsjXnyL6rxUh7G22gxEgPViMr6/J2gn9cV1Wxgrk8oGdk2pH6x+fLj9iYSP8zmiAo43WZunNTJJOUCnXo+igSQwT3CkY1YUDoIH5zCjYXa52hsUHCK21RqPwsYHpgp8G0bJ587kpxG6EK6M2/Y9AUMyS94rujhgdqJoGC18T9kqZDuU9hN0Nz1uIYlrGBmoO+b6/oIQF6YNo2QQdPZ8LYTlaYeC2gB7NxHpeBFegJinXBorck0zou5U/sVCjkeDC0p4Lsxve/TnElwwURfJUEHixA5ZMRYQtUe9gCe8CMj8CSw+A2D4FLaxrIsL9DdcCvFf9HFqcEuKwfaOgsICwaMgUL9kzTT40iHGbNKL9PzzOgYnqW9BwY/MiN5i+b9g0onT48AoTW3FmP7qZj3t4T68RU78VJJl8W4Cz3Z2ywywNCr0LJU0OCt68zsqp8pPZHQdJXqcCi65BSX2BiFE+6YLmVa8pJ5ABUrZblTXEWbANb2nK7dekdEBz/FKyurMTiU+pjYzD6mPnH/DoDZTXknEpIJWhSAVurcW1N0j29FNBrwe6iGY49P7XU2qeEmn0rCB8OlCxvxyKvti03rUJKZnHDvCXE0aczLmXFN7hgqBm/qitNKtWiTSKE1unn/1qMzrC2BRHM3aWEHyOo1nJHBd2yQMRVBvFaGvn6wAIRGJbryn+G0EVbmhjAEfmARU/wkjuZ1QIsNrAzNeJ2yCR4LLY48= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700016)(56012099003)(22082099003)(18002099003)(11063799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FObMhEyCHPNlsdIdU8g6Y/l5a6eelLb3RUePEWtSWAvAa0Jz32GRkUChFzbx4LNutJKaShnKdO70cc2ltMNWUOQJcl3cY2fZ00FvK+b0qFmi7x50gOrIvDvchlTwVgzc7nx539DELDzuKgVzt3t1661DaYdLsDS+zb+zC9WuX3Z8Dcrv06kiKBSiyaNvPe9PhWSTYk6CDh0TgfNR831r9bU+g/Yx6Kdwvn/xiftsMtI7Og7Ntlxcrwyoho9Ej/vJdeSviOh9vtTyeHT+NQu3o0avU1N8tNwGrFBST9nhZOdVOoPGZyYe6Mj+JaQdId8o6isJKXXYeyVA3N1DCIciYh7n1pxn716acX7paBYbIw1zj7imkyxtvpc+GqfqKH+pYqWlF3BkG+8m1PHS85eg+EepUfM/grZzIjV3HMllXdLUk88kyV8dkLNwmC1y9l8v X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2026 15:12:51.1134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6093c752-8a48-4cfc-0a49-08deb426c353 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DSWPR12MB999153 Content-Type: text/plain; charset="utf-8" Add a per-socket mutex (metric_tbl_lock) to serialize concurrent reads on the metric table. Without serialization, two simultaneous readers could interleave the SMU refresh command and the memcpy_fromio(), producing a torn (mixed old/new) snapshot. Use scoped guard(mutex) in hsmp_metric_tbl_read() so the lock is automatically released on all return paths. Initialize the mutex with devm_mutex_init() in hsmp_get_tbl_dram_base() and return an error if initialization fails, avoiding manual mutex_destroy() cleanup paths. Co-developed-by: Muthusamy Ramalingam Signed-off-by: Muthusamy Ramalingam Signed-off-by: Muralidhara M K --- Changes: v1->v2: Add lock v2->v3: Replace mutex_init to devm_mutex_init call drivers/platform/x86/amd/hsmp/hsmp.c | 8 ++++++++ drivers/platform/x86/amd/hsmp/hsmp.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/am= d/hsmp/hsmp.c index 3a02d683dea0..2fec897a95be 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -447,6 +447,7 @@ ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, = char *buf, size_t size) msg.msg_id =3D HSMP_GET_METRIC_TABLE; msg.sock_ind =3D sock->sock_ind; =20 + guard(mutex)(&sock->metric_tbl_lock); ret =3D hsmp_send_message(&msg); if (ret) return ret; @@ -492,6 +493,13 @@ int hsmp_get_tbl_dram_base(u16 sock_ind) dev_err(sock->dev, "Failed to ioremap metric table addr\n"); return -ENOMEM; } + + ret =3D devm_mutex_init(sock->dev, &sock->metric_tbl_lock); + if (ret) { + dev_err(sock->dev, "Failed to initialize metric table lock\n"); + return ret; + } + return 0; } EXPORT_SYMBOL_NS_GPL(hsmp_get_tbl_dram_base, "AMD_HSMP"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/am= d/hsmp/hsmp.h index e7f051475728..f7b1cbf19932 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,8 @@ struct hsmp_socket { struct bin_attribute hsmp_attr; struct hsmp_mbaddr_info mbinfo; void __iomem *metric_tbl_addr; + /* Serializes concurrent metric table refreshes from the sysfs path */ + struct mutex metric_tbl_lock; void __iomem *virt_base_addr; struct semaphore hsmp_sem; char name[HSMP_ATTR_GRP_NAME_SIZE]; --=20 2.34.1