From patchwork Sat Jul 20 17:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737865 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) (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 272101EB40 for ; Sat, 20 Jul 2024 17:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497589; cv=fail; b=IB0jAeZ8qDE6KeQx02OEwMLFw/jm0budiBbMzCjaUlBY6goMpmDODMLBdD+sXU3CNvP0R1W+DBZCgS3ieHmDelGGhWZo8N+rdRd9cafTjju9C+1mhCwqNKbv/6gEKrPY3wAdFA+YrWKDZqzCVNvG61TtxpMbLnG90FnKemB5/kk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497589; c=relaxed/simple; bh=wRGoYZraYYSdUFcKWyKQTz2nqWTygemGTWS++xQzNgs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=IY8OHSOLvbKIxcy3fUhyg4nx0NEP/NnkYAQpnYRqA4Ad61QLo2Wp8sUb9AoBFZkfDx6MbsVqlhvMa7rjmZs8MCx//q3UJ0/69wa1P9th+WWmzkhtWQolcCW7ZDcUkGPvMegIygKUccuW9hKvjeKraImww7bMopVWG6EYL+gs6Cg= 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=jsXnd9xg; arc=fail smtp.client-ip=40.107.223.83 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="jsXnd9xg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wcDyAHFfovFcqCKcDDbxcGBbJfhgmI825DymSx93ZV0UvHTFfXbeUenjl1zSRGbXrQCTm/Sl+Od/iFHtBC0NOVxwJlmSXr4hcS4d+P7wLpc5BYa/e2IWEBXOEKxYBY6HXfhSpe3KSY1o3AR22gBWwKIMdxHjfOIILbOx45Z5PuT8h0jcyjZepkI8MOfgUSF3vbtudRLCQyera+2FxJt0mSCYeU8FkznuF6kUFWjl5z/wiEuumaApMQP9yPCjc3KN29aTJLddbZXPKySEEN7xociWw9o+0A3x9SCe5xOh8Yp7DzAkwdtIf2GeJ5wwqzglEXeU6EBStUQZA0c9C2eyWQ== 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=UVws/B3GnJ9ASsu2GOgnh8U+NaZKPytyKWjlV2XxKYc=; b=NDsAZYMbkZxW4+wRiqJj+Aen+/3a7yKGm/8dUJiLFjf57s2OQTbLGXGQO0y3WzqDBsQT0OYmE9VhE3xWumAgej7Y0dWG56Psh7W+XtnqD12F3+wRTDE08nm5AOtM3ocjv3q/bEHjTu5tE3VL3pFf7LiLpQGgiP0GinOxoSyqbakGL0wLoE7asbQd/1wwzyhxOJF5fYxz1DvJYJksUUPiY35YF0hoK3PswPHMYb1ye5UvE7pRkZLFjat60JRpf6doRAZYQYhCOIuDgRDdAiUuBXwSk7AdQBk2A8fdW//kLVZZsrPSlIp71tGINd8pPp5NLRfbNppZcJjOzsAmipB+fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=UVws/B3GnJ9ASsu2GOgnh8U+NaZKPytyKWjlV2XxKYc=; b=jsXnd9xgPW9Nyc5jfjkxMdu0XjBOJaCsKXHMZf1J5XihfCdUMKQv0zB0iSCer83539FaIHM4dLpotva57eM+qs5l/F+6v2boCUxY2QOq5vTseZ3htrY4zKprfXHQc334bw5lTdQUDbHlQatHV7JcPgx3bOTRfMFNr2nwHn1IXLQ= Received: from DM5PR07CA0051.namprd07.prod.outlook.com (2603:10b6:4:ad::16) by PH7PR12MB6635.namprd12.prod.outlook.com (2603:10b6:510:210::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.17; Sat, 20 Jul 2024 17:46:24 +0000 Received: from DS1PEPF00017090.namprd03.prod.outlook.com (2603:10b6:4:ad:cafe::53) by DM5PR07CA0051.outlook.office365.com (2603:10b6:4:ad::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46:24 +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 DS1PEPF00017090.mail.protection.outlook.com (10.167.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:24 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:22 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 01/11] platform/x86/amd/hsmp: Create hsmp/ directory Date: Sat, 20 Jul 2024 17:45:42 +0000 Message-ID: <20240720174552.946255-1-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017090:EE_|PH7PR12MB6635:EE_ X-MS-Office365-Filtering-Correlation-Id: bc8da700-be4f-4671-0c8a-08dca8e3dfe1 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: SH0I/cNi4U/2Slm96ezWNbri99Reg4jvjB1yAaWmoaD8EDCiInCWLjfTJhNVdBerT7hreWfeqfVQtjW3D31KCOxtktxOZjF5ffCMi2pwVQuNtiidxa/c+tp6C8BWpQCC/IcqiPEL6wXpUfzCmz4qB5a+MgcdRFEg4MrYB0pQM+cEyjGKseoZhyzBccvHyvCirhAwGtqlK1+K9exnMYfJsATQildyCFGt3rdWTYv7l/zGaqeUgEbI85Td4fT8jbRXqLVJS6vSHGcCvD2AAZXQ+JO2H8yfgvde+LI1ofyr9ocsd78sGwl/RHIuJ6Ea9tpdFu+MKmv6LSeJA7DMph6Twu5rH7itT5Tf5dxL7s2cprBAJF72urrGsNAFXSo0bb2jjPFlCuax26FjiviDYjDPfWnlgwQD+XgGzznmsdvYa+bhMo9bLFITbri+C9juYm80+6FfXKVXU9e5xAB3e2/iEl8G+a2fd4FkRDWisBrIIvL7M99HVwzDATEQOFxYFwuCKPJEaZx1ZWuuGmEJJCi40H474OSQ9aUg1t8bD3ERRc0tIyhr017YjF25NPAQD36HxDAyiUG652RQ/B/qxMdWF3WKLvia8yxIKQb+Ri6Hx6dMgTG/AOrVQap1co7o89la2Ei8pXCGd3NjToaSXtTl3XPwqOLQ4sm5+X610NaDmFAQk3Ko1owvG3FIycdYZ748VJ8I7KlyVeRrW07by3vKSlyG1v8ChAy8SbiMdPkzpH7ABvXynGH8XBEX+eBD5qlGvCTkys/xSLoqfypwAW1r6BkV1TJHgplXDxnpoVYhCEiODtxIE/rbjJtJlr4Z+grl4REWOnTGARIVYwsvm3kpcionNLiU58ToZolIusu9cGegYcxchNZMmLAA7b8BHTNY0i3F1R2ZQX45m+frasqv9+jDs9Jl4G0noy0mgiBP+UpBBxxnbI4GJIiBI8d8lgkjf9X2ERmkcpriuLSdRNETScm6ZJPVY+gMXCby/5OB++DuC2LnC6/4hsuYrsUFhbchQnx/Xa45ach5hEJA5B1+atuPROIsWqfWbNNMJBmP3QS4v5dn4VCpEjKPr4q8UvNuAxYDMgY13F2o1qOkGAdR5FTqEVaR0O9OxzLUIrYhHg8B8XVEUX3k4FZaodmHula9DxhrEmaBOx/QITRPjTeDdpm0X0WzVTFshLouw3C6NkiWl9x2NXEpm5V/PzDDLVOVJ1sxmWCh9OXz9XChETha9Ge/JPcl4lnmcLMlvSahYTc4viA93sHpmsGYu9/D+4WB4c0TJiyTYSVsnY59boWonbDdu6eWGQfsm7LkkLPe9c7zqGQ4P9j9eCFhEs0yYJ8bVBFEXrjY0ImpkVzU1WmAYvlHhK1aY2Dr1WigNsLa8bSj+pYnq0LorG4vkMVMdhGl9GGTvfT1VS+INDhlow44ld4WT+s7Q3xmJS9OvErRu33gHpaNKp5GWS7WD+MVtCUL 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: 20 Jul 2024 17:46:24.5784 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc8da700-be4f-4671-0c8a-08dca8e3dfe1 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: DS1PEPF00017090.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6635 This is in preparation to splitting ACPI and platform device drivers. Create and move hsmp specific code into its own directory, no logical changes. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v2: None Changes since v1: None MAINTAINERS | 2 +- drivers/platform/x86/amd/Kconfig | 14 +------------- drivers/platform/x86/amd/Makefile | 3 +-- drivers/platform/x86/amd/hsmp/Kconfig | 17 +++++++++++++++++ drivers/platform/x86/amd/hsmp/Makefile | 8 ++++++++ drivers/platform/x86/amd/{ => hsmp}/hsmp.c | 0 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 drivers/platform/x86/amd/hsmp/Kconfig create mode 100644 drivers/platform/x86/amd/hsmp/Makefile rename drivers/platform/x86/amd/{ => hsmp}/hsmp.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index d6c90161c7bf..a7d79d1f7ec1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1037,7 +1037,7 @@ S: Maintained F: Documentation/arch/x86/amd_hsmp.rst F: arch/x86/include/asm/amd_hsmp.h F: arch/x86/include/uapi/asm/amd_hsmp.h -F: drivers/platform/x86/amd/hsmp.c +F: drivers/platform/x86/amd/hsmp/ AMD IOMMU (AMD-VI) M: Joerg Roedel diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig index f88682d36447..2c671cc17d63 100644 --- a/drivers/platform/x86/amd/Kconfig +++ b/drivers/platform/x86/amd/Kconfig @@ -3,22 +3,10 @@ # AMD x86 Platform Specific Drivers # +source "drivers/platform/x86/amd/hsmp/Kconfig" source "drivers/platform/x86/amd/pmf/Kconfig" source "drivers/platform/x86/amd/pmc/Kconfig" -config AMD_HSMP - tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 && ACPI - help - The driver provides a way for user space tools to monitor and manage - system management functionality on EPYC server CPUs from AMD. - - Host System Management Port (HSMP) interface is a mailbox interface - between the x86 core and the System Management Unit (SMU) firmware. - - If you choose to compile this driver as a module the module will be - called amd_hsmp. - config AMD_WBRF bool "AMD Wifi RF Band mitigations (WBRF)" depends on ACPI diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile index dcec0a46f8af..96ec24c8701b 100644 --- a/drivers/platform/x86/amd/Makefile +++ b/drivers/platform/x86/amd/Makefile @@ -5,7 +5,6 @@ # obj-$(CONFIG_AMD_PMC) += pmc/ -amd_hsmp-y := hsmp.o -obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o +obj-y += hsmp/ obj-$(CONFIG_AMD_PMF) += pmf/ obj-$(CONFIG_AMD_WBRF) += wbrf.o diff --git a/drivers/platform/x86/amd/hsmp/Kconfig b/drivers/platform/x86/amd/hsmp/Kconfig new file mode 100644 index 000000000000..b55d4ed9bceb --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/Kconfig @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# AMD HSMP Driver +# + +config AMD_HSMP + tristate "AMD HSMP Driver" + depends on AMD_NB && X86_64 && ACPI + help + The driver provides a way for user space tools to monitor and manage + system management functionality on EPYC server CPUs from AMD. + + Host System Management Port (HSMP) interface is a mailbox interface + between the x86 core and the System Management Unit (SMU) firmware. + + If you choose to compile this driver as a module the module will be + called amd_hsmp. diff --git a/drivers/platform/x86/amd/hsmp/Makefile b/drivers/platform/x86/amd/hsmp/Makefile new file mode 100644 index 000000000000..fda64906a5e8 --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for drivers/platform/x86/amd/hsmp +# AMD HSMP Driver +# + +obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o +amd_hsmp-objs := hsmp.o diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c similarity index 100% rename from drivers/platform/x86/amd/hsmp.c rename to drivers/platform/x86/amd/hsmp/hsmp.c From patchwork Sat Jul 20 17:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737866 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.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 397771EB40 for ; Sat, 20 Jul 2024 17:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497591; cv=fail; b=h5CRCmnFB+G5tUnWBaJHiX6qLSl8R84FZBcN5doIGS4YxDoGMlD37M9bgD5u7UXFhH7xTUhAVW2LARBU4bIhS0Q5ROlEhXVw9elsLTtV8a0QEfddxtUZV/SwyVEz/TFqCMOWoamdALwGJV5K387wHNTl5Q3A3YoYGayMRIQOJC4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497591; c=relaxed/simple; bh=zz60Ck+H2NX/3RiAjysxasRfWeSV5Bd67VrWcXmneec=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u9qmnOpdaDPrIt/ju9QTgGxOebW5HsZIUxDV0BFER7zX2Icb0/0dgrnyrKcCzjgraKFgSmrB6jMjzb6gozSCcvzRt8JFKVXm39avjfQo9NPDCFpr98A1xE8rCK99PxoLtvBHGgPk5UDPp794tkHRXa/Lrs3/RV+jT1Rn7t3xmUw= 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=POjm0Qro; arc=fail smtp.client-ip=40.107.93.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="POjm0Qro" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CYoTQYPBn6/5vGR+oMGSgeMSeoY2f4ZyCbdCgFTx+Gj/0JaaP1sKHY2AfZ1HUWXH4zcve6ko3/WwxHD735ylHrRf+vGxgtrZYAh5/xVeiGGrnCgjzoD2Vz170yi/l+yw1zXRHJNTx8Fh/6TeJfnA8uYrscTz5939gNoISiBFzEWrwHNUUikkTgQ4eoLAAvdM0Aglwim77s9YRWT72DzG3+Fny1B/p3IO5GBr43gOJzWO/qAh3gsH1jgxu/7F04ME7kyEebTOziaTBIDRHSY1rpzsPkuuo+XLUCP9+kfCPSKm9E5LPvg3y2K6N4jD0sMejjzCP0L6vNjSeoaKY1XUNA== 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=Ztupg6Wi3XIWuPjDdczin0CN0rrQ8w6vd4IgMwARPUY=; b=P1+hfidRw0xYy6mKOrcaStCjdkfhnKkZCChKVIGCVkz40gzP9hqlSlEp8SDWvIgwz/qpGiHs0WZDnuQ23Vlnl+lDJRUHzfW6eEee7N3+55JcR9zYWV330pX2z+UfipKh3688w3uPEQkKRVUb0nlItPlEc1WAz3QDoAcEsoZhXNiSgvrruJ8x9PH48y+WNcd5wnMCYYTXP9hxn9oZKQTuRbd0CTc3OUC+uwiHq4IM8ea2DdfwHyHK2A2NroXKDXyVyOVLrZbUKf6fnvIbDusM3SVDBdUO30op1/Amql9uF92DjE3eKwlDzlL+H+aprqwyoYOmHeqAsT55g2gMU6FcXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=Ztupg6Wi3XIWuPjDdczin0CN0rrQ8w6vd4IgMwARPUY=; b=POjm0Qro/+0xrQkayZFt/OsD+cz6zJEt9kPohTyHXlJCyJ2Rz+ompIaZZIpEQ+6GDhMxrGKqb6N0rnXqIeL1AHQacMO40Q158RIfy+x0K7LdfSDkLk7VqVzzfluZ/0eeBseOppndnfp9VYL6IffV5L78kdQZiuyn9XPUV6B+ZaY= Received: from DM6PR01CA0030.prod.exchangelabs.com (2603:10b6:5:296::35) by IA1PR12MB6162.namprd12.prod.outlook.com (2603:10b6:208:3ea::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Sat, 20 Jul 2024 17:46:26 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:296:cafe::9c) by DM6PR01CA0030.outlook.office365.com (2603:10b6:5:296::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16 via Frontend Transport; Sat, 20 Jul 2024 17:46: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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:26 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:24 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 02/11] platform/x86/amd/hsmp: Create wrapper function init_acpi() Date: Sat, 20 Jul 2024 17:45:43 +0000 Message-ID: <20240720174552.946255-2-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017091:EE_|IA1PR12MB6162:EE_ X-MS-Office365-Filtering-Correlation-Id: 199cecce-7aa3-4a0c-5345-08dca8e3e0fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?erhPsiY5YEqcIP0Uvx+3hnZ4mB70JI1?= =?utf-8?q?rNX+KryxyEWAtxRqiF8VbG3ED93tz+FdlfDpk+GSV2aYNUBk+/1XfEDbLqA8hKHtt?= =?utf-8?q?G0phUEKu7INuZ+YohP9XkjCgD8+rnGa7PNmTQIv2NOFwJyw9eup4xAyjuUkxymqfA?= =?utf-8?q?ZW884Y6MbBgzfKxXqxgobkC3QGzs4XEL9P4ugYYd1yNsgSqhNNLOlZwgKIcDbgNv2?= =?utf-8?q?lYrZRHGv4Rmv3J+xwLG/+175h8TZboLeLY5iDBiaXfJkU4QSlhD+mjYoXMpppUOOz?= =?utf-8?q?dzrT9eZVb1V7Ef96YMPEKJi/ym9MRfVdjbn3TZcK677tenXHLPxYMP/2aNW7vAkOi?= =?utf-8?q?9rYDahvSZYgxd6VxgUpU6JpDCPh5XSF4ZyjFMh6nFW/xUMcEMgRbcqVlOftIlSIdC?= =?utf-8?q?adDbueN17Z98arLPe3kRqFQ5Vmi6WhipeVjROyAy1/0W9ZGURHupSELyt8StMt2aU?= =?utf-8?q?RTdu3crEAotFDGX/aB4NOvC/qptgX+nq7EJRwJnnrwJJKvzmir1dunc4uuMrMzHeI?= =?utf-8?q?ZLEDTyZ0FAvYRAMQ7VEdNbqLmPchoyFBujhp3L07w2JcpyQpfHdK9Jc1Qj7nE5K7K?= =?utf-8?q?sW4boq7BOvfFsa47kSZvwDcE/oyKKZeufOlZTBk5AJJVopZ2a1yI4Mbrjrnndkchr?= =?utf-8?q?Q00VRgPw4/ANsuwPwwsvFkqQ00Y5zXivmZuAIIdRrMe3QowGhjcL8kw5XbGVEToII?= =?utf-8?q?RByN/+1mnMbmPzeNJVp3qyw815DoDbWwklYst073cXeiC/ERTjg3lGHwr6TgAdnRf?= =?utf-8?q?iDa/iO03N3+dwgvCxa7i978zXeK6eQ/7PVoFRDp+wD96Uh4y1AcUWOIcD0aAgsxmv?= =?utf-8?q?+sseVnGcizTtGYyPVHHaTrYhXym/iQ/q93u769mfKR6+wfTKFTkvnES7Fz4DMDeDl?= =?utf-8?q?2WwLuqWDWcv3Uzu8z9eMqWjvUhBUoeufc3sgvYNib7Da+Rgl6VD/BwPF7z2TyrrTK?= =?utf-8?q?4XIOItpzoidssNDz51QyVs1kW1bA4VptEL66On4OuX4kcD1srMcGajMn+kfiNqxuQ?= =?utf-8?q?YvFUz8vCH+CGtqUY21jHFKmDD7XNlflJp3e95bcyQeOLGwnZIkpgebCncTox4OrMQ?= =?utf-8?q?d92zLAR6x3RvmmY22QONT+MnxL2gj9NxttRhj0kldg9Osr/WSv2ADoj4CtGmOdssI?= =?utf-8?q?6TmAnzMHAfvuDgpxHeKBG156dDD8DTB7CIkKlviP5VLjwRiVgvhdG4/a+GBvM5ZN6?= =?utf-8?q?CE5usQ7MSg+5DqBH95LdT9hNtyV6Zve5epQcTYgvq0runjovB4CRLKuDed/nl84+b?= =?utf-8?q?ZWCXdp+Z96jif2yhN9vvC1aS5RSRP29lVfTkqDkkmOaJK8qnlDzuOi+YQwf35OZ7x?= =?utf-8?q?4k7lKburQqCogR+apLmIIeKidxGfaXNoHd55keev/j2c55x1BOEpKwJcAdoh0XyYP?= =?utf-8?q?XBSDOdCKS/C?= 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)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:26.4414 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 199cecce-7aa3-4a0c-5345-08dca8e3e0fd 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6162 This is in preparation to splitting ACPI and platform device drivers. Having init_acpi() helps in smooth code movement. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v2: None Changes since v1: Add "Reviewed-by: Ilpo Järvinen " drivers/platform/x86/amd/hsmp/hsmp.c | 91 ++++++++++++++++++---------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 8fcf38eed7f0..10ab9b2437f1 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -778,6 +778,11 @@ static int init_platform_device(struct device *dev) dev_err(dev, "Is HSMP disabled in BIOS ?\n"); return ret; } + ret = hsmp_cache_proto_ver(i); + if (ret) { + dev_err(dev, "Failed to read HSMP protocol version\n"); + return ret; + } } return 0; @@ -789,10 +794,53 @@ static const struct acpi_device_id amd_hsmp_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); +static bool check_acpi_support(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) + return true; + + return false; +} + +static int init_acpi(struct device *dev) +{ + u16 sock_ind; + int ret; + + ret = hsmp_get_uid(dev, &sock_ind); + if (ret) + return ret; + if (sock_ind >= plat_dev.num_sockets) + return -EINVAL; + + ret = hsmp_parse_acpi_table(dev, sock_ind); + if (ret) { + dev_err(dev, "Failed to parse ACPI table\n"); + return ret; + } + + /* Test the hsmp interface */ + ret = hsmp_test(sock_ind, 0xDEADBEEF); + if (ret) { + dev_err(dev, "HSMP test message failed on Fam:%x model:%x\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + dev_err(dev, "Is HSMP disabled in BIOS ?\n"); + return ret; + } + + ret = hsmp_cache_proto_ver(sock_ind); + if (ret) { + dev_err(dev, "Failed to read HSMP protocol version\n"); + return ret; + } + + return ret; +} + static int hsmp_pltdrv_probe(struct platform_device *pdev) { - struct acpi_device *adev; - u16 sock_ind = 0; int ret; /* @@ -809,46 +857,25 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev) if (!plat_dev.sock) return -ENOMEM; } - adev = ACPI_COMPANION(&pdev->dev); - if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) { - ret = hsmp_get_uid(&pdev->dev, &sock_ind); - if (ret) - return ret; - if (sock_ind >= plat_dev.num_sockets) - return -EINVAL; - ret = hsmp_parse_acpi_table(&pdev->dev, sock_ind); - if (ret) { - dev_err(&pdev->dev, "Failed to parse ACPI table\n"); - return ret; - } - /* Test the hsmp interface */ - ret = hsmp_test(sock_ind, 0xDEADBEEF); + if (check_acpi_support(&pdev->dev)) { + ret = init_acpi(&pdev->dev); if (ret) { - dev_err(&pdev->dev, "HSMP test message failed on Fam:%x model:%x\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - dev_err(&pdev->dev, "Is HSMP disabled in BIOS ?\n"); + dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); return ret; } + ret = hsmp_create_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); } else { ret = init_platform_device(&pdev->dev); if (ret) { dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); return ret; } - } - - ret = hsmp_cache_proto_ver(sock_ind); - if (ret) { - dev_err(&pdev->dev, "Failed to read HSMP protocol version\n"); - return ret; - } - - if (plat_dev.is_acpi_device) - ret = hsmp_create_acpi_sysfs_if(&pdev->dev); - else ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + } if (!plat_dev.is_probed) { plat_dev.hsmp_device.name = HSMP_CDEV_NAME; From patchwork Sat Jul 20 17:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737867 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2053.outbound.protection.outlook.com [40.107.236.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 89BB31EB40 for ; Sat, 20 Jul 2024 17:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497594; cv=fail; b=bxcyEHof97l35jme4DCvLU9OD0KTI87ix/HEFa2tGl0P078hZDjJinP6EgCcG/kIyuLLB7cli5n5ZpmP5VIH/9K1sWWHChC6cttoaiZqxOEKUvNxPc5Lh6J59bRXpTgQgVVKjMpF83ab0otwBKYvJYi+tZMOhKjwvUVo72kE7cc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497594; c=relaxed/simple; bh=QYfIyi/B+2hU3/d2gIGwdu6DXy0t0RMxBR9qs9sBusQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Uw5r/ZwZSfu5Lf76Y8hvAnj9xCxaDxh0mpf67Aks50z6pBg9qXiZPX3S3WHZqUDJVooVrVN6pcULvBgdqK6o8s4/4XgTnBilHAweOcU9kN7lsiUJDC4f4qY3cY3G4yH/7UyaURPfo9W9p4A94a97NWMwMjFIv7IAg6klmQHdaKo= 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=AFoObK3u; arc=fail smtp.client-ip=40.107.236.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="AFoObK3u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jl9Dh1xsN6ijZ0UXRrpymibhzq+XR1GQdIaePpBmdUweF6GhGABBXttOmhtbu2iG3p2b1niRgZmF3+f3HtycPq6Y8ci02vNPAA0vD77b/xySinv5tTu9bV21lW46J8OEK6hisVPuMkJBpi5cfn20SnXUBFsAQ3MGFEJUlGArEFOYo2vA16fngQ61QntrRS6UBb2J6FyAO18MgTVdYXw6rLSTA45ZZCvhnQ9J2ZjrVaPnicu2nyqeE+c0quytxa/iT2274CqLMTlVxksSgmwZg/T4HKSBdcAEIthKQJQbAl4B/2IZNx6XUBauhvuMTiAEQvzJqHFitDBuKxZ7cz6Pqw== 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=hgmxpaHx/Qi/fpo5F1g3XDumO4rUhG3gRWaz5Mzmkd4=; b=DGVFVtNR3fgVYOR1d8jHCpuORqPwf3Wg+OJrcx2ben/yxeVvmeMPXdsO/3/tzwuCDx6P+c+1aJeyVM75rx45cepfU1EkDOiB+sH3jDeb4HpYTOxR0viPnPOXarSyrTt72u7N7JzCWFc+uUuT0FAMgsbS7CKZ1AEur1zoOsLYYxgeHv/akzB6E/4lRBaosN+DfiadDql70aQxT4IrNlB7T/h1Ncb2nc0LIzJoj5BEqywaVNnUV3ZiIGwm2SCWHGo+O7A1xU0MY0jb78Mr4IqKY2bkXfSGU0LlLxkj2r0/PTc+1b883ZM041VQ5jNPUopXK4qusl+DFbcMW1OJ+p3qrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=hgmxpaHx/Qi/fpo5F1g3XDumO4rUhG3gRWaz5Mzmkd4=; b=AFoObK3ucV60sXGUMAqQ+S+USncjQ587K7dP/jC2ixPovpQ2DnYTfjXgZe5QjiYrBDAVJpjILDEg3wf+nme15IaV5RGxVUbxjR4JhB3h06DUsBF8bqp+HflhWBteFrs/YFcwFU/cCPy9Jn1ZlDyOXF1nYro84lVqmPRsQbZ/vxk= Received: from DS7PR03CA0302.namprd03.prod.outlook.com (2603:10b6:8:2b::11) by SJ0PR12MB6967.namprd12.prod.outlook.com (2603:10b6:a03:44b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Sat, 20 Jul 2024 17:46:28 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:8:2b:cafe::8a) by DS7PR03CA0302.outlook.office365.com (2603:10b6:8:2b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20 via Frontend Transport; Sat, 20 Jul 2024 17:46:28 +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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:28 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:26 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 03/11] platform/x86/amd/hsmp: Move structure and macros to header file Date: Sat, 20 Jul 2024 17:45:44 +0000 Message-ID: <20240720174552.946255-3-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF0001708E:EE_|SJ0PR12MB6967:EE_ X-MS-Office365-Filtering-Correlation-Id: 3746a8e5-7410-4121-3026-08dca8e3e22f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?f7zUXNr+fdlr9mHVK6xyUuN4hxQiGV8?= =?utf-8?q?ym3WuIaM33Y+ZBmVOzS488P/wfevYPs24yLm6UjMekut8ldeGaHWAHXW/35swdGVN?= =?utf-8?q?xjfCGrnlogyDd4WDtY247fnmdJ/D9/FU02EP7FcS98boa6JfQXF/QVPTUz+fgB+HQ?= =?utf-8?q?72fa/u21znuVSxXGst0MvUDYxi00JRkHHkEFwN5a4022pOfK2btd9xm4sC/hLbkrE?= =?utf-8?q?DC84+vDeEzWSPkRUwy8KAGFjwOyHO5ih/AVEUycpULkp65oHStspDUouLuZMYs589?= =?utf-8?q?Vp7DIL1ItM/sZbP3hhiKNArAkVtRwV4s2HwXza3xe9f/zjElH+dG8Utex3TupBf2D?= =?utf-8?q?WfNN4flq3Fs5wgwfScyxijXGsRIaeUM5FVXkZPq1QwRH3NzvQmLmfhvG+FIYsJ4Nd?= =?utf-8?q?i1GLWr1fWlC9Eo1DlF9DYpchOydEcodrnThqEd57hwl0NSPP87hSet+6F9f1uHhre?= =?utf-8?q?Hj4pJ60z+4ch2MnPCns2F5z5xV98RjuAxXugm9OsTEJebrL/L+l6PtCJU34puprpC?= =?utf-8?q?KN5Vl8vPepfAu9bkeFtmy1aUUBnPW1CYrd1ZHuAHKSuubSpjkksBIUw6JuY93p0pk?= =?utf-8?q?N2F8abZGnDRCCUyrelXfbc3Exct9FmplSm0HCvsjQXqR+4nkToyLVOXxfhenwt5u+?= =?utf-8?q?Et8Dqak+gdi7c5jpe4+CQqyx9QTxRo3kc3VhByE1Qlq19aiYqD7hAJO+BiWjhAyZj?= =?utf-8?q?GojAChHrH3MmBqo3fbHT8MQ0vlH+4y0WEfBOQ54OWsZm+4YHZ+IKtdhkgM98Xga6c?= =?utf-8?q?NVXFNi9O10uqWxPkc+gnKYeict230cg9Fzb0JSNsOaPJBKkUVeMp700H59mNEOlLx?= =?utf-8?q?2iwtaduRi6AUhfooynah55h2xJNA4+ACS9Fz943pMMee+pvZ4uD3/s6cQ3iudISXN?= =?utf-8?q?n3XEapvHb6JT+zAaa9MOyS5ly++bQQTwKdO89wEAoLUijx50q7EhqycTRkAXXaYeA?= =?utf-8?q?8GqvN+obE4mUhzhqGA/b+0h2Wp59QgLjpuJahTn2q89XOJwr/+ASrnY96nG3ZiAAq?= =?utf-8?q?tUrZMxFgILNHQyvhT4knQ72N1XOMcJbJPymHwKR4IbkqtnoSGRn2gWRfMSjF3HwbT?= =?utf-8?q?dT5h/eDyzhLNoW3azWmlusJYC4GjveogaQ4QUE+kXSF0ndOIQ6Lx8cX+92xO4uvJF?= =?utf-8?q?AXoL8L8foMh62xGkElMdr61KYFUaH840S3G7zpkQzLjWOE2oYd0Y0RwvO33GXCDQP?= =?utf-8?q?aHDy7k89ob5tGntpX22rIadIoJ1uZ+GiDTcb2hLosUQyhoEQ4wVGrctneVNkrJkdx?= =?utf-8?q?GAj2jelRrSCkWAeUSl9OOkj01Ki8RtgRs0aURKJj87D30AAwkPubW2BhwC0JPzJO/?= =?utf-8?q?Cw8uyD4MDhnFkWwiS460YHIO/Sui4o19aWiWwtZp/7zO0/b0T8PimvIvvpqSyFoti?= =?utf-8?q?vSMtL83evRb?= 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)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:28.4459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3746a8e5-7410-4121-3026-08dca8e3e22f 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6967 This is in preparation to splitting ACPI and platform device drivers. No logical change, move common structures and macros to hsmp.h Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v2: None Changes since v1: 1. Correct typo mistake in commit message 2. Add "Reviewed-by: Ilpo Järvinen " 3. Arrange header files in alphabetical order for hsmp.h drivers/platform/x86/amd/hsmp/hsmp.c | 42 ++-------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 54 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 40 deletions(-) create mode 100644 drivers/platform/x86/amd/hsmp/hsmp.h diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 10ab9b2437f1..2c9ba51b9614 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -9,15 +9,14 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include "hsmp.h" + #include #include #include -#include -#include #include #include #include -#include #include #define DRIVER_NAME "amd_hsmp" @@ -51,48 +50,11 @@ #define HSMP_INDEX_REG 0xc4 #define HSMP_DATA_REG 0xc8 -#define HSMP_CDEV_NAME "hsmp_cdev" -#define HSMP_DEVNODE_NAME "hsmp" -#define HSMP_METRICS_TABLE_NAME "metrics_bin" - -#define HSMP_ATTR_GRP_NAME_SIZE 10 - /* These are the strings specified in ACPI table */ #define MSG_IDOFF_STR "MsgIdOffset" #define MSG_ARGOFF_STR "MsgArgOffset" #define MSG_RESPOFF_STR "MsgRspOffset" -#define MAX_AMD_SOCKETS 8 - -struct hsmp_mbaddr_info { - u32 base_addr; - u32 msg_id_off; - u32 msg_resp_off; - u32 msg_arg_off; - u32 size; -}; - -struct hsmp_socket { - struct bin_attribute hsmp_attr; - struct hsmp_mbaddr_info mbinfo; - void __iomem *metric_tbl_addr; - void __iomem *virt_base_addr; - struct semaphore hsmp_sem; - char name[HSMP_ATTR_GRP_NAME_SIZE]; - struct pci_dev *root; - struct device *dev; - u16 sock_ind; -}; - -struct hsmp_plat_device { - struct miscdevice hsmp_device; - struct hsmp_socket *sock; - u32 proto_ver; - u16 num_sockets; - bool is_acpi_device; - bool is_probed; -}; - static struct hsmp_plat_device plat_dev; static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h new file mode 100644 index 000000000000..5afc7167fac1 --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD HSMP Platform Driver + * Copyright (c) 2024, AMD. + * All Rights Reserved. + * + * Header file for HSMP driver + */ + +#ifndef HSMP_H +#define HSMP_H + +#include +#include +#include + +#define HSMP_METRICS_TABLE_NAME "metrics_bin" + +#define HSMP_ATTR_GRP_NAME_SIZE 10 + +#define MAX_AMD_SOCKETS 8 + +#define HSMP_CDEV_NAME "hsmp_cdev" +#define HSMP_DEVNODE_NAME "hsmp" + +struct hsmp_mbaddr_info { + u32 base_addr; + u32 msg_id_off; + u32 msg_resp_off; + u32 msg_arg_off; + u32 size; +}; + +struct hsmp_socket { + struct bin_attribute hsmp_attr; + struct hsmp_mbaddr_info mbinfo; + void __iomem *metric_tbl_addr; + void __iomem *virt_base_addr; + struct semaphore hsmp_sem; + char name[HSMP_ATTR_GRP_NAME_SIZE]; + struct pci_dev *root; + struct device *dev; + u16 sock_ind; +}; + +struct hsmp_plat_device { + struct miscdevice hsmp_device; + struct hsmp_socket *sock; + u32 proto_ver; + u16 num_sockets; + bool is_acpi_device; + bool is_probed; +}; +#endif /* HSMP_H */ From patchwork Sat Jul 20 17:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737868 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) (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 40A051EB40 for ; Sat, 20 Jul 2024 17:46:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497598; cv=fail; b=cSmo6d6k+MxpxOY4aLHXjlGiDGNuxP6JigazFBUsBUnjMKjJSegORAjkwL2pWnulByVOE3boRL9ZweUJ/uy4LCCzKA0gfZbc5S8fqaBQBmySpa0Ldh68Xx0jnw4BCMV9YZ5oE+nqmCc4nnTlyvKEw7XeAEhGwWeeStuO3UHBTdc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497598; c=relaxed/simple; bh=0oNPXUd5vs5OTGJvbjmkM+tSQI8O+GldrJXlwOD9pOY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dscdZyO2NzW8OdKJpIdWsTOw8BV1CPiwdj2Qh/REucUk8PCsq1/ppcmErsfybcndzYunczEiKeNgEwcjq0VoMi/hQG0nwopUfdDIJ+fRM0Bwp0hZvpT+MHUb/mlgpujqI6z3i+eJ/Hzck6ei4IHm8R/MIr9+ITNHL6mJPyw6wyc= 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=2uPsD2TU; arc=fail smtp.client-ip=40.107.94.77 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="2uPsD2TU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PPgudXErrNssYrIdJnnRq4qP/nk5Dh9oeza2u1Radq9ldPL2EkCtIRP6vBwLehx141QAlbeNWQqRrOE1nQjDRSn0CK8/npnWmo3ohXxcc4RbB0KhOHYk1wVI5Ifl8d0H7QWN6gzDq8eE9JIMHfjpctuLkPF6eG+iVx4iC24SVBCRHnhn625kL3Q2iEo+H19GCr+9IxXRrUPrjdG5AeIAYv7OtUdRyClQi2lHGvFcdtqsg95pCvox26oMkQHsiYneDvxeO0inzUsf9x7wlF7QSWiny9vvdyOazSd+IpeUvA4TVIPUo1Se6fGtMD60SKENOV/jLC1eSodTFMDLqTxfPg== 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=nDP8rNo+Y5FSO/Y7yAsu8nVxi//2uTcImkDNAx0XqQI=; b=vuYGu9LaxjTrGsZAvwyvT67Z5TAReKu853sNKTUkhhZ//3a9KsLucG7Uhv0IQtC/wgiXqZ316JwaQiBSujU/plL9yIVJmrDhV9I3PzUQIxc5CwUKF/D6wGWwMWkauLvwBb5jVmQ/maEX68W7XyJY6C11K5mGpQchI0L3OP242ImXGGMCKsJIODQ0wGXyxMp8zKnxqvQMCgFRNPCIgYoajKjT34p/KtrEZDFRGvCq05Ke+fbArD6FeUgTo26j9YtKgwnQxjIXms1BHXQH+XpBS8JNM8L5/a44GGVT8G18v3vhhHXi9IWi5J/PIjjLdLbVWu6xFHKp/7cULGgyeWnQyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=nDP8rNo+Y5FSO/Y7yAsu8nVxi//2uTcImkDNAx0XqQI=; b=2uPsD2TUKnEB2FG15Y+8GjkuYiITemQiPvbqm5F5UkeMjb7716Iam+S0enftYAtsG/12tQ4Mgd+eqBbDaaVFGsff/L1/ZS9jYfbFGrm52TS6TNoKEcHLwmsf7VIL9MSjL4A8y1HCkVn7COrpcXWvYqQLXN4jf5Xje6TApZeIbxk= Received: from DM6PR03CA0087.namprd03.prod.outlook.com (2603:10b6:5:333::20) by MN2PR12MB4142.namprd12.prod.outlook.com (2603:10b6:208:1dd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Sat, 20 Jul 2024 17:46:31 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:333:cafe::b8) by DM6PR03CA0087.outlook.office365.com (2603:10b6:5:333::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20 via Frontend Transport; Sat, 20 Jul 2024 17:46:30 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:30 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:28 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 04/11] platform/x86/amd/hsmp: Move platform device specific code to plat.c Date: Sat, 20 Jul 2024 17:45:45 +0000 Message-ID: <20240720174552.946255-4-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017095:EE_|MN2PR12MB4142:EE_ X-MS-Office365-Filtering-Correlation-Id: 99748277-84d2-4f4f-37e8-08dca8e3e387 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: snZsGQ4YTx5wEoJXneuj7zeNaIiLHdq1JOO0aDMjxRBsezOze8xNRx8JbccFXQkFgav27FGVsD+7jOjjCA5oIvGaI1S7UdiGWKF5s5uREPgsXvLh9fmzWXRXp+I6insf3vo/1WcWAFyv8L8vu0NPyIqOLFzEaoIJZgaNRESPRQIUyo3CbtcrqG+72+rrvhTz3b28o6bPEO+6RSErukDqcNjd27getJgAobB/cvVYYQPy4CvBug8ZFJdR1NkRMDvAzsovHi1nxqvjpwtzQqG2Qrzmzp69lSv2U36HNiWD4zowbq6elBeTcBR8YE5As6GsytxLNuLA8Mvm/nHTIQjVT2HV5ocJyo0bybpIzU+X+RZPb7JvB1KTqQlQ6+4Ua2MBRnLuDU5SEy4p37LM5bZ9X8hwx0ZPuQBBb6lL6p10CwBiIlxVlGoZ0TWNLvvsR2gEAWgF8ibQ+z6V0kqyAlF9KaLRuBvtbuQV66qwv/xNj0zhJ+Qgd14nkMHr/Valbs7DTZUSigV7EzPOa6HDaFvEiVIRM071Gc2CgBlDA1PBY/HuwgDRT7s5dgieNZSZOj9n0Qnp9uZuNwUrNMUcX/gRvdOLUQbaW9ulPvjJlT5YHr1E63GP9ScY1YVzGcbRI4Nfguh9C+1iYkwmDBW3//CpfjDmQxZyqPlTDeQCva0nNqEan9nX1zTw3WS/UMp9TuhlkS9p5kx/E4z9lYfspIyOoMBhk8izvbaiVWYtSHuVLpxnQ8TsAuOxr2lDpgSuUaGFh37cZ2i6RiOtCrAJ9ghe4UqxSBeGGXp0V2A6YzztPp5atrdbXYyp2TpyCjtXiIDJ43iRvfaXX49LatgMIjdDouYemUcpwg4076WP3L/pcJgjZiYkMwX5t4fhaBNTxAJ0aKhWlsnaATHq3XmlNA28pRbzxKNtXlpoy7hxNbq/ScG3atKGq8bsA2FM7JXiA7HBOSJe1pokrhzAbCsfk8IpzdsVFnqHwWHZpSOH/1F5jTHXwoLaEE2Ojn3P8ytz1pBLaBhZxJ1OZlpV0BYzLr6+Zhy5+PtEDsAnpYOdU7VvxQ7qVH3Ki5Cl5n8pJDFJjiC6UcQVhgW2uPFHtmFyILXz3+OLuZ89ZmS0HWCmI5L4qow41mwJIa9fuAVqc/YogVhpChBkUgtEOSgaUg9D+FHXLiv0Uu7vUtz5vQDU2Us+Z4QA1ZoTOHHy8INiRSh4hT31lWpnA/tGHfNtmkJl78TfKCKT9OCmQzGXNkjRY3KiTakZrwF4c8Bvrjz3EAVTsOVUE1THbJuZ2bMz2jk/kAnZ+iS4anbUJB/i2PlO0q7KnbnFhoPapHPlNWy6EOmwsDGnKX6cI1tZPBcp1wB+eUpqCJybprDjWOIuKqfpd74iBkc+rsYRrzUg82tRhDmhQg9Pvn5gSfKQ19NAbepPvai1q/F6baOL7Df86M5xgfdI94x5aqVDpjgsx0LZ3xsnxZPz 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:30.7006 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99748277-84d2-4f4f-37e8-08dca8e3e387 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 Move platform device part to plat.c. No functinality/logical changes. Common code which can be used by ACPI and platform device remains in hsmp.c. ACPI code in hsmp.c will be moved to acpi.c in next patch. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: None Changes since v1: 1. Include new header file device.h in plat.c 2. Arrange headers in alphabetical order 3. Add an empty line between asm/ and linux/ headers drivers/platform/x86/amd/hsmp/Makefile | 2 +- drivers/platform/x86/amd/hsmp/hsmp.c | 350 ++----------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 17 ++ drivers/platform/x86/amd/hsmp/plat.c | 338 ++++++++++++++++++++++++ 4 files changed, 371 insertions(+), 336 deletions(-) create mode 100644 drivers/platform/x86/amd/hsmp/plat.c diff --git a/drivers/platform/x86/amd/hsmp/Makefile b/drivers/platform/x86/amd/hsmp/Makefile index fda64906a5e8..fb8ba04b2f0d 100644 --- a/drivers/platform/x86/amd/hsmp/Makefile +++ b/drivers/platform/x86/amd/hsmp/Makefile @@ -5,4 +5,4 @@ # obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o -amd_hsmp-objs := hsmp.o +amd_hsmp-objs := hsmp.o plat.o diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 2c9ba51b9614..d15a978ff71e 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -12,16 +12,9 @@ #include "hsmp.h" #include -#include -#include -#include -#include -#include -#include -#define DRIVER_NAME "amd_hsmp" -#define DRIVER_VERSION "2.2" -#define ACPI_HSMP_DEVICE_HID "AMDI0097" +#include +#include /* HSMP Status / Error codes */ #define HSMP_STATUS_NOT_READY 0x00 @@ -36,45 +29,12 @@ #define HSMP_WR true #define HSMP_RD false -/* - * To access specific HSMP mailbox register, s/w writes the SMN address of HSMP mailbox - * register into the SMN_INDEX register, and reads/writes the SMN_DATA reg. - * Below are required SMN address for HSMP Mailbox register offsets in SMU address space - */ -#define SMN_HSMP_BASE 0x3B00000 -#define SMN_HSMP_MSG_ID 0x0010534 -#define SMN_HSMP_MSG_ID_F1A_M0H 0x0010934 -#define SMN_HSMP_MSG_RESP 0x0010980 -#define SMN_HSMP_MSG_DATA 0x00109E0 - -#define HSMP_INDEX_REG 0xc4 -#define HSMP_DATA_REG 0xc8 - /* These are the strings specified in ACPI table */ #define MSG_IDOFF_STR "MsgIdOffset" #define MSG_ARGOFF_STR "MsgArgOffset" #define MSG_RESPOFF_STR "MsgRspOffset" -static struct hsmp_plat_device plat_dev; - -static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write) -{ - int ret; - - if (!sock->root) - return -ENODEV; - - ret = pci_write_config_dword(sock->root, HSMP_INDEX_REG, - sock->mbinfo.base_addr + offset); - if (ret) - return ret; - - ret = (write ? pci_write_config_dword(sock->root, HSMP_DATA_REG, *value) - : pci_read_config_dword(sock->root, HSMP_DATA_REG, value)); - - return ret; -} +struct hsmp_plat_device plat_dev; static void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) @@ -253,7 +213,7 @@ int hsmp_send_message(struct hsmp_message *msg) } EXPORT_SYMBOL_GPL(hsmp_send_message); -static int hsmp_test(u16 sock_ind, u32 value) +int hsmp_test(u16 sock_ind, u32 value) { struct hsmp_message msg = { 0 }; int ret; @@ -283,7 +243,7 @@ static int hsmp_test(u16 sock_ind, u32 value) return ret; } -static long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { int __user *arguser = (int __user *)arg; struct hsmp_message msg = { 0 }; @@ -339,12 +299,6 @@ static long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return 0; } -static const struct file_operations hsmp_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = hsmp_ioctl, - .compat_ioctl = hsmp_ioctl, -}; - /* This is the UUID used for HSMP */ static const guid_t acpi_hsmp_uuid = GUID_INIT(0xb74d619d, 0x5707, 0x48bd, 0xa6, 0x9f, 0x4e, 0xa2, @@ -520,9 +474,9 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) return hsmp_read_acpi_dsd(sock); } -static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) +ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { struct hsmp_socket *sock = bin_attr->private; struct hsmp_message msg = { 0 }; @@ -581,8 +535,8 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind) return 0; } -static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - struct bin_attribute *battr, int id) +umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) { if (plat_dev.proto_ver == HSMP_PROTO_VER6) return battr->attr.mode; @@ -611,8 +565,8 @@ static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock /* One bin sysfs for metrics table */ #define NUM_HSMP_ATTRS 1 -static int hsmp_create_attr_list(struct attribute_group *attr_grp, - struct device *dev, u16 sock_ind) +int hsmp_create_attr_list(struct attribute_group *attr_grp, + struct device *dev, u16 sock_ind) { struct bin_attribute **hsmp_bin_attrs; @@ -628,37 +582,7 @@ static int hsmp_create_attr_list(struct attribute_group *attr_grp, return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind); } -static int hsmp_create_non_acpi_sysfs_if(struct device *dev) -{ - const struct attribute_group **hsmp_attr_grps; - struct attribute_group *attr_grp; - u16 i; - - hsmp_attr_grps = devm_kcalloc(dev, plat_dev.num_sockets + 1, - sizeof(*hsmp_attr_grps), - GFP_KERNEL); - if (!hsmp_attr_grps) - return -ENOMEM; - - /* Create a sysfs directory for each socket */ - for (i = 0; i < plat_dev.num_sockets; i++) { - attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), - GFP_KERNEL); - if (!attr_grp) - return -ENOMEM; - - snprintf(plat_dev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); - attr_grp->name = plat_dev.sock[i].name; - attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; - hsmp_attr_grps[i] = attr_grp; - - hsmp_create_attr_list(attr_grp, dev, i); - } - - return device_add_groups(dev, hsmp_attr_grps); -} - -static int hsmp_create_acpi_sysfs_if(struct device *dev) +int hsmp_create_acpi_sysfs_if(struct device *dev) { struct attribute_group *attr_grp; u16 sock_ind; @@ -681,7 +605,7 @@ static int hsmp_create_acpi_sysfs_if(struct device *dev) return devm_device_add_group(dev, attr_grp); } -static int hsmp_cache_proto_ver(u16 sock_ind) +int hsmp_cache_proto_ver(u16 sock_ind) { struct hsmp_message msg = { 0 }; int ret; @@ -697,76 +621,7 @@ static int hsmp_cache_proto_ver(u16 sock_ind) return ret; } -static inline bool is_f1a_m0h(void) -{ - if (boot_cpu_data.x86 == 0x1A && boot_cpu_data.x86_model <= 0x0F) - return true; - - return false; -} - -static int init_platform_device(struct device *dev) -{ - struct hsmp_socket *sock; - int ret, i; - - for (i = 0; i < plat_dev.num_sockets; i++) { - if (!node_to_amd_nb(i)) - return -ENODEV; - sock = &plat_dev.sock[i]; - sock->root = node_to_amd_nb(i)->root; - sock->sock_ind = i; - sock->dev = dev; - sock->mbinfo.base_addr = SMN_HSMP_BASE; - - /* - * This is a transitional change from non-ACPI to ACPI, only - * family 0x1A, model 0x00 platform is supported for both ACPI and non-ACPI. - */ - if (is_f1a_m0h()) - sock->mbinfo.msg_id_off = SMN_HSMP_MSG_ID_F1A_M0H; - else - sock->mbinfo.msg_id_off = SMN_HSMP_MSG_ID; - - sock->mbinfo.msg_resp_off = SMN_HSMP_MSG_RESP; - sock->mbinfo.msg_arg_off = SMN_HSMP_MSG_DATA; - sema_init(&sock->hsmp_sem, 1); - - /* Test the hsmp interface on each socket */ - ret = hsmp_test(i, 0xDEADBEEF); - if (ret) { - dev_err(dev, "HSMP test message failed on Fam:%x model:%x\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - dev_err(dev, "Is HSMP disabled in BIOS ?\n"); - return ret; - } - ret = hsmp_cache_proto_ver(i); - if (ret) { - dev_err(dev, "Failed to read HSMP protocol version\n"); - return ret; - } - } - - return 0; -} - -static const struct acpi_device_id amd_hsmp_acpi_ids[] = { - {ACPI_HSMP_DEVICE_HID, 0}, - {} -}; -MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); - -static bool check_acpi_support(struct device *dev) -{ - struct acpi_device *adev = ACPI_COMPANION(dev); - - if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) - return true; - - return false; -} - -static int init_acpi(struct device *dev) +int init_acpi(struct device *dev) { u16 sock_ind; int ret; @@ -800,178 +655,3 @@ static int init_acpi(struct device *dev) return ret; } - -static int hsmp_pltdrv_probe(struct platform_device *pdev) -{ - int ret; - - /* - * On ACPI supported BIOS, there is an ACPI HSMP device added for - * each socket, so the per socket probing, but the memory allocated for - * sockets should be contiguous to access it as an array, - * Hence allocate memory for all the sockets at once instead of allocating - * on each probe. - */ - if (!plat_dev.is_probed) { - plat_dev.sock = devm_kcalloc(&pdev->dev, plat_dev.num_sockets, - sizeof(*plat_dev.sock), - GFP_KERNEL); - if (!plat_dev.sock) - return -ENOMEM; - } - if (check_acpi_support(&pdev->dev)) { - ret = init_acpi(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); - return ret; - } - ret = hsmp_create_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - } else { - ret = init_platform_device(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); - return ret; - } - ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - } - - if (!plat_dev.is_probed) { - plat_dev.hsmp_device.name = HSMP_CDEV_NAME; - plat_dev.hsmp_device.minor = MISC_DYNAMIC_MINOR; - plat_dev.hsmp_device.fops = &hsmp_fops; - plat_dev.hsmp_device.parent = &pdev->dev; - plat_dev.hsmp_device.nodename = HSMP_DEVNODE_NAME; - plat_dev.hsmp_device.mode = 0644; - - ret = misc_register(&plat_dev.hsmp_device); - if (ret) - return ret; - - plat_dev.is_probed = true; - } - - return 0; - -} - -static void hsmp_pltdrv_remove(struct platform_device *pdev) -{ - /* - * We register only one misc_device even on multi socket system. - * So, deregister should happen only once. - */ - if (plat_dev.is_probed) { - misc_deregister(&plat_dev.hsmp_device); - plat_dev.is_probed = false; - } -} - -static struct platform_driver amd_hsmp_driver = { - .probe = hsmp_pltdrv_probe, - .remove_new = hsmp_pltdrv_remove, - .driver = { - .name = DRIVER_NAME, - .acpi_match_table = amd_hsmp_acpi_ids, - }, -}; - -static struct platform_device *amd_hsmp_platdev; - -static int hsmp_plat_dev_register(void) -{ - int ret; - - amd_hsmp_platdev = platform_device_alloc(DRIVER_NAME, PLATFORM_DEVID_NONE); - if (!amd_hsmp_platdev) - return -ENOMEM; - - ret = platform_device_add(amd_hsmp_platdev); - if (ret) - platform_device_put(amd_hsmp_platdev); - - return ret; -} - -/* - * This check is only needed for backward compatibility of previous platforms. - * All new platforms are expected to support ACPI based probing. - */ -static bool legacy_hsmp_support(void) -{ - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) - return false; - - switch (boot_cpu_data.x86) { - case 0x19: - switch (boot_cpu_data.x86_model) { - case 0x00 ... 0x1F: - case 0x30 ... 0x3F: - case 0x90 ... 0x9F: - case 0xA0 ... 0xAF: - return true; - default: - return false; - } - case 0x1A: - switch (boot_cpu_data.x86_model) { - case 0x00 ... 0x1F: - return true; - default: - return false; - } - default: - return false; - } - - return false; -} - -static int __init hsmp_plt_init(void) -{ - int ret = -ENODEV; - - /* - * amd_nb_num() returns number of SMN/DF interfaces present in the system - * if we have N SMN/DF interfaces that ideally means N sockets - */ - plat_dev.num_sockets = amd_nb_num(); - if (plat_dev.num_sockets == 0 || plat_dev.num_sockets > MAX_AMD_SOCKETS) - return ret; - - ret = platform_driver_register(&amd_hsmp_driver); - if (ret) - return ret; - - if (!plat_dev.is_acpi_device) { - if (legacy_hsmp_support()) { - /* Not ACPI device, but supports HSMP, register a plat_dev */ - ret = hsmp_plat_dev_register(); - } else { - /* Not ACPI, Does not support HSMP */ - pr_info("HSMP is not supported on Family:%x model:%x\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - ret = -ENODEV; - } - if (ret) - platform_driver_unregister(&amd_hsmp_driver); - } - - return ret; -} - -static void __exit hsmp_plt_exit(void) -{ - platform_device_unregister(amd_hsmp_platdev); - platform_driver_unregister(&amd_hsmp_driver); -} - -device_initcall(hsmp_plt_init); -module_exit(hsmp_plt_exit); - -MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); -MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 5afc7167fac1..1aa33c5633d0 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -51,4 +51,21 @@ struct hsmp_plat_device { bool is_acpi_device; bool is_probed; }; + +extern struct hsmp_plat_device plat_dev; + +int init_acpi(struct device *dev); +ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count); +int hsmp_create_acpi_sysfs_if(struct device *dev); +int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, + u32 *value, bool write); +int hsmp_cache_proto_ver(u16 sock_ind); +long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); +umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id); +int hsmp_create_attr_list(struct attribute_group *attr_grp, + struct device *dev, u16 sock_ind); +int hsmp_test(u16 sock_ind, u32 value); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c new file mode 100644 index 000000000000..2ed5a9452244 --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -0,0 +1,338 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD HSMP Platform Driver + * Copyright (c) 2024, AMD. + * All Rights Reserved. + * + * This file provides platform device implementations. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include "hsmp.h" + +#include + +#include +#include +#include +#include +#include + +#define DRIVER_NAME "amd_hsmp" +#define DRIVER_VERSION "2.2" +#define ACPI_HSMP_DEVICE_HID "AMDI0097" + +/* + * To access specific HSMP mailbox register, s/w writes the SMN address of HSMP mailbox + * register into the SMN_INDEX register, and reads/writes the SMN_DATA reg. + * Below are required SMN address for HSMP Mailbox register offsets in SMU address space + */ +#define SMN_HSMP_BASE 0x3B00000 +#define SMN_HSMP_MSG_ID 0x0010534 +#define SMN_HSMP_MSG_ID_F1A_M0H 0x0010934 +#define SMN_HSMP_MSG_RESP 0x0010980 +#define SMN_HSMP_MSG_DATA 0x00109E0 + +#define HSMP_INDEX_REG 0xc4 +#define HSMP_DATA_REG 0xc8 + +int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, + u32 *value, bool write) +{ + int ret; + + if (!sock->root) + return -ENODEV; + + ret = pci_write_config_dword(sock->root, HSMP_INDEX_REG, + sock->mbinfo.base_addr + offset); + if (ret) + return ret; + + ret = (write ? pci_write_config_dword(sock->root, HSMP_DATA_REG, *value) + : pci_read_config_dword(sock->root, HSMP_DATA_REG, value)); + + return ret; +} + +static const struct file_operations hsmp_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = hsmp_ioctl, + .compat_ioctl = hsmp_ioctl, +}; + +static int hsmp_create_non_acpi_sysfs_if(struct device *dev) +{ + const struct attribute_group **hsmp_attr_grps; + struct attribute_group *attr_grp; + u16 i; + + hsmp_attr_grps = devm_kcalloc(dev, plat_dev.num_sockets + 1, + sizeof(*hsmp_attr_grps), + GFP_KERNEL); + if (!hsmp_attr_grps) + return -ENOMEM; + + /* Create a sysfs directory for each socket */ + for (i = 0; i < plat_dev.num_sockets; i++) { + attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), + GFP_KERNEL); + if (!attr_grp) + return -ENOMEM; + + snprintf(plat_dev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); + attr_grp->name = plat_dev.sock[i].name; + attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; + hsmp_attr_grps[i] = attr_grp; + + hsmp_create_attr_list(attr_grp, dev, i); + } + + return device_add_groups(dev, hsmp_attr_grps); +} + +static inline bool is_f1a_m0h(void) +{ + if (boot_cpu_data.x86 == 0x1A && boot_cpu_data.x86_model <= 0x0F) + return true; + + return false; +} + +static int init_platform_device(struct device *dev) +{ + struct hsmp_socket *sock; + int ret, i; + + for (i = 0; i < plat_dev.num_sockets; i++) { + if (!node_to_amd_nb(i)) + return -ENODEV; + sock = &plat_dev.sock[i]; + sock->root = node_to_amd_nb(i)->root; + sock->sock_ind = i; + sock->dev = dev; + sock->mbinfo.base_addr = SMN_HSMP_BASE; + + /* + * This is a transitional change from non-ACPI to ACPI, only + * family 0x1A, model 0x00 platform is supported for both ACPI and non-ACPI. + */ + if (is_f1a_m0h()) + sock->mbinfo.msg_id_off = SMN_HSMP_MSG_ID_F1A_M0H; + else + sock->mbinfo.msg_id_off = SMN_HSMP_MSG_ID; + + sock->mbinfo.msg_resp_off = SMN_HSMP_MSG_RESP; + sock->mbinfo.msg_arg_off = SMN_HSMP_MSG_DATA; + sema_init(&sock->hsmp_sem, 1); + + /* Test the hsmp interface on each socket */ + ret = hsmp_test(i, 0xDEADBEEF); + if (ret) { + dev_err(dev, "HSMP test message failed on Fam:%x model:%x\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + dev_err(dev, "Is HSMP disabled in BIOS ?\n"); + return ret; + } + + ret = hsmp_cache_proto_ver(i); + if (ret) { + dev_err(dev, "Failed to read HSMP protocol version\n"); + return ret; + } + } + + return 0; +} + +static const struct acpi_device_id amd_hsmp_acpi_ids[] = { + {ACPI_HSMP_DEVICE_HID, 0}, + {} +}; +MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); + +static bool check_acpi_support(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) + return true; + + return false; +} + +static int hsmp_pltdrv_probe(struct platform_device *pdev) +{ + int ret; + + /* + * On ACPI supported BIOS, there is an ACPI HSMP device added for + * each socket, so the per socket probing, but the memory allocated for + * sockets should be contiguous to access it as an array, + * Hence allocate memory for all the sockets at once instead of allocating + * on each probe. + */ + if (!plat_dev.is_probed) { + plat_dev.sock = devm_kcalloc(&pdev->dev, plat_dev.num_sockets, + sizeof(*plat_dev.sock), + GFP_KERNEL); + if (!plat_dev.sock) + return -ENOMEM; + } + + if (check_acpi_support(&pdev->dev)) { + ret = init_acpi(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); + return ret; + } + ret = hsmp_create_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + } else { + ret = init_platform_device(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); + return ret; + } + ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + } + + if (!plat_dev.is_probed) { + plat_dev.hsmp_device.name = HSMP_CDEV_NAME; + plat_dev.hsmp_device.minor = MISC_DYNAMIC_MINOR; + plat_dev.hsmp_device.fops = &hsmp_fops; + plat_dev.hsmp_device.parent = &pdev->dev; + plat_dev.hsmp_device.nodename = HSMP_DEVNODE_NAME; + plat_dev.hsmp_device.mode = 0644; + + ret = misc_register(&plat_dev.hsmp_device); + if (ret) + return ret; + + plat_dev.is_probed = true; + } + + return 0; +} + +static void hsmp_pltdrv_remove(struct platform_device *pdev) +{ + /* + * We register only one misc_device even on multi socket system. + * So, deregister should happen only once. + */ + if (plat_dev.is_probed) { + misc_deregister(&plat_dev.hsmp_device); + plat_dev.is_probed = false; + } +} + +static struct platform_driver amd_hsmp_driver = { + .probe = hsmp_pltdrv_probe, + .remove_new = hsmp_pltdrv_remove, + .driver = { + .name = DRIVER_NAME, + .acpi_match_table = amd_hsmp_acpi_ids, + }, +}; + +static struct platform_device *amd_hsmp_platdev; + +static int hsmp_plat_dev_register(void) +{ + int ret; + + amd_hsmp_platdev = platform_device_alloc(DRIVER_NAME, PLATFORM_DEVID_NONE); + if (!amd_hsmp_platdev) + return -ENOMEM; + + ret = platform_device_add(amd_hsmp_platdev); + if (ret) + platform_device_put(amd_hsmp_platdev); + + return ret; +} + +/* + * This check is only needed for backward compatibility of previous platforms. + * All new platforms are expected to support ACPI based probing. + */ +static bool legacy_hsmp_support(void) +{ + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + return false; + + switch (boot_cpu_data.x86) { + case 0x19: + switch (boot_cpu_data.x86_model) { + case 0x00 ... 0x1F: + case 0x30 ... 0x3F: + case 0x90 ... 0x9F: + case 0xA0 ... 0xAF: + return true; + default: + return false; + } + case 0x1A: + switch (boot_cpu_data.x86_model) { + case 0x00 ... 0x1F: + return true; + default: + return false; + } + default: + return false; + } + + return false; +} + +static int __init hsmp_plt_init(void) +{ + int ret = -ENODEV; + + /* + * amd_nb_num() returns number of SMN/DF interfaces present in the system + * if we have N SMN/DF interfaces that ideally means N sockets + */ + plat_dev.num_sockets = amd_nb_num(); + if (plat_dev.num_sockets == 0 || plat_dev.num_sockets > MAX_AMD_SOCKETS) + return ret; + + ret = platform_driver_register(&amd_hsmp_driver); + if (ret) + return ret; + + if (!plat_dev.is_acpi_device) { + if (legacy_hsmp_support()) { + /* Not ACPI device, but supports HSMP, register a plat_dev */ + ret = hsmp_plat_dev_register(); + } else { + /* Not ACPI, Does not support HSMP */ + pr_info("HSMP is not supported on Family:%x model:%x\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + ret = -ENODEV; + } + if (ret) + platform_driver_unregister(&amd_hsmp_driver); + } + + return ret; +} + +static void __exit hsmp_plt_exit(void) +{ + platform_device_unregister(amd_hsmp_platdev); + platform_driver_unregister(&amd_hsmp_driver); +} + +device_initcall(hsmp_plt_init); +module_exit(hsmp_plt_exit); + +MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL v2"); From patchwork Sat Jul 20 17:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737869 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2081.outbound.protection.outlook.com [40.107.237.81]) (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 2648C146A8D for ; Sat, 20 Jul 2024 17:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497600; cv=fail; b=Hl5qeDGPn6Om5TzvBF4dXY+j9MBke/5g10sPKHAXUg9ZCk95SCQXph4mjrp+m7VcrvDlK9IiUGYHOg46Iue/Cj8RVn+TvSHxYGHCS5Ix6ESHEO6yXVVcr3EoxGkESuxbr8KVvp9SQvsxfw1Ev34eNYpahEs93LFjCwIMeUITH0s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497600; c=relaxed/simple; bh=diP7N+Y4LMwDc1hwS69XyW9XXmvzJO6ixFJ9mrgdn/w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gagbV0MTy/WPiNAAcCs3oLBn54gf8R0F1I7eaV35+wnAuuXMzCh5kKQmwuhrRqRLp22qI/fdvr4B04CSU0TNgZdHUlMDevMidpzb3R8eGC85/M4VmXJNdUtnuxs6bAnWCHNjBQkhvc4xPeQI8I5R8tSxdPsVl7/JTZSLy+4TPMo= 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=e2mAj20u; arc=fail smtp.client-ip=40.107.237.81 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="e2mAj20u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=obuX0YRzTEJM/fhxhGYRbobOCrtfoqZmiK8lsPgWZstoGVHXLclmpvXYUwa99snsyOUZWP1qF6iCQlz8m9r7TwDbnR6vDk4Igi34q81eGCPYG8yWdg8O5YroQUp/9CPwgNx1+RdjOUnh/3ZeO33lwaSmzzyOTNg2ll1L3EF1M8vDMMcIWOOiizvX8HUe7rxzGMXCqvC7/IQXqYgLN7n57yiKG5l3xh//U+R88dkww7xCGf4bqwWV8MwgFcDYw97VTfxTMYDAHFqsZsn7JmSJ5h3hhR90SMiiGsVP0n2fZ9tF9LWjXzPGnCajvv3hEZaiJb9hrLDoBu9PJyEGmMJ8LQ== 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=WXSCaRWcOOlhd12EMz7YcQkDbG0YlJi9KnFiBiIeThs=; b=bo+ZG6eB3oDCQ19ywbEbu+osV0j7pgUiywxVGbMPSNV8UaQ+bAG/zJuDOw2b667/PgqfS4fXI5Hok+LFZoO13Nn+oD01mZnmzdkCQQo9oyzhPI0J+klo836x6BsPNlb1Wnz2QZth0EN7020z8ubqMdTti3WiRFkOwp3LmrRTnvgREt31rFqQrmq2EUXQchigtFOfGeCR50m71TNaO5iePJBVoUAS72Clzf5yCsli8pQkjiG/Yk3vkRF+u9onryXoZTfXpFS1S2pWBWAjXQQ0Tal1pVms7nMdH6yuVayW8ayeS/Z4t+L58nNh2wJcGvMFdvMA7ofJht10PJLl2ZEIlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=WXSCaRWcOOlhd12EMz7YcQkDbG0YlJi9KnFiBiIeThs=; b=e2mAj20unmyUABLRgF1P93khaPMRCy8m2sSPIwvcMDhy6q8WTkf1snUXlIserW9DJPR8HooBWAjKATPmLR85WuQT/SrcY26kdEHBVy2eByAyDRvv7OQNoq5cOn4eitbOVe47Zzz4QzbDcIJr6MlnX04lFdKWDgFPPa8nty24u5g= Received: from DM6PR03CA0097.namprd03.prod.outlook.com (2603:10b6:5:333::30) by PH7PR12MB8780.namprd12.prod.outlook.com (2603:10b6:510:26b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Sat, 20 Jul 2024 17:46:33 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:333:cafe::40) by DM6PR03CA0097.outlook.office365.com (2603:10b6:5:333::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46:32 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:32 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:30 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 05/11] platform/x86/amd/hsmp: Move ACPI code to acpi.c Date: Sat, 20 Jul 2024 17:45:46 +0000 Message-ID: <20240720174552.946255-5-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017095:EE_|PH7PR12MB8780:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b6d3503-cde4-4aff-c7f7-08dca8e3e4ba 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: qNvM1twlbOZ6vbppxqY8+RMtrY5alG7kIvIAtlgIFSF6lwQ8xCVlV8sAaRiSFLPheOmLvxHa54QrHqvp73Im0fiNiksMOZBb1gSp/uKUI6CxFf2vexlDilE7M/nwvpdrYBUS8bAyfFEo+GfLBYgO/ONH4dVg6s1Vm1RccsjVYDcng2Q2JkdAANpuTXQF8Toi+Gn5xMOj89fCMn6E6tA6DQYwjWhZIz34N5myi7QpuKx9mBLhKsluitMOne2GMFUNt1puE+PXwbsXXyZPHSySMmLr/rrapwpnae27oGQzyO2lg6NjDWJXg8OeStExUBFEbghts3T0Gzg37JFkS8dDXxIp6TI6L3hd705+dYe9L+aTPhTmn6i4b2CKja63+oD46pSdqjCOlGpnYhqr2UYeNCINulqryEviw8GVeaN1slt6GgHkSNIDx7APdsHnr/Si5j8f+PF48JMC4Rc2CBP+NmkP+jCIOUdttAmZfHi2Ey2QMOKypJfnKpUspUyps78TmWLgBJ4LZbD5kYJWO2elfzqP9EqeI1/Mhz6fOFvZAuzEJEPwv/Wx22C3a3AsqvpM2AJSpkK5AR4PhxMUz7PlhuQcKsfptVmu1H7/RU1GjSx/n/aaxSu+3Hx9a5QdLhlOPefkH+VSeuGqRnUKUU43MR6G3GoFUIHXw4PcxDq/0S7oWQA8hUEbXK2tTOIzY1+NcFweWHjheDSummnuoBsGMe6rcZ57GqCr+/1BLXOILUcr7lwNSFuhIWTzRNco1rGRRZ5+fFCjDqLWq4zrMa7WoNaLMhSEzsUYV1AHlKY04ky5vg6M2ZDaOjr3aHDNYjPuOFroXzk3v+f28qyeYlxkrVT8QjPM5bvB8TAA5bAEgCns4Kqno8DGqRf63u3o0SfXFYf/NQyq9D1HYqg76n87C8MzYXP7OgC+PfgPx3XVlUVcJLuFIZGipcmIN8APGNpcIG1avr7t682p1NPNr/SAnvOvp8TdrAZbTBpMrtnqGG+qVOii7ZS8Rsew/EvaXF8QxWBiGOrInOsXa2iEHp41CnK8aiAL6kfbKR6YEo+y8E8gwYFrqe7bGAOsvWLcTOIOed7xRMDmYwiy9mVeQJx1fpVesAduVFIQ0JZ05XEevrY5Hc8ZaJyMlYRcm7A6c5PYi8LLaYAGiu1zdWx9ZrdvklqCOQGmIT4bCTSk/YzO05CkvZzrnKJc8ZxyjmUpPAxB4w965aqhZ4iOV6dEkbFxDuNZ7bnqovzyITlaJhGLAMSStjM0ysNWSpdMPN6eT+PMqja/KvupKW+i/o1/Z9wSmyeXccL/pWTDQzadWeC2mGi6DDReJ5E26fOU/LIbCVtAaOjSNDYV5t9IXYj0yjyy4YVCUzHWG1GK4aKtsA2ZIVemRcUSE2HhLcOsRxgPxvKusdGVobiKHxR2u5jUUjmqKZ7RM+y8IVmEj4m0O0lwGRfvsLg7G1xmYiQY71F8T7iE 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: 20 Jul 2024 17:46:32.6537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b6d3503-cde4-4aff-c7f7-08dca8e3e4ba 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8780 Move ACPI related code to acpi.c from hsmp.c. We still have one driver, the driver probe will be split in the next patch. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: None Changes since v1: 1. Add following headers in acpi.c #include #include #include #include #include #include drivers/platform/x86/amd/hsmp/Makefile | 2 +- drivers/platform/x86/amd/hsmp/acpi.c | 268 +++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 247 ----------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 2 + 4 files changed, 271 insertions(+), 248 deletions(-) create mode 100644 drivers/platform/x86/amd/hsmp/acpi.c diff --git a/drivers/platform/x86/amd/hsmp/Makefile b/drivers/platform/x86/amd/hsmp/Makefile index fb8ba04b2f0d..0cc92865c0a2 100644 --- a/drivers/platform/x86/amd/hsmp/Makefile +++ b/drivers/platform/x86/amd/hsmp/Makefile @@ -5,4 +5,4 @@ # obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o -amd_hsmp-objs := hsmp.o plat.o +amd_hsmp-objs := hsmp.o plat.o acpi.o diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c new file mode 100644 index 000000000000..eca324774141 --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD HSMP Platform Driver + * Copyright (c) 2024, AMD. + * All Rights Reserved. + * + * This file provides a device implementation for HSMP interface + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include "hsmp.h" + +#include +#include +#include +#include +#include +#include + +#include + +/* These are the strings specified in ACPI table */ +#define MSG_IDOFF_STR "MsgIdOffset" +#define MSG_ARGOFF_STR "MsgArgOffset" +#define MSG_RESPOFF_STR "MsgRspOffset" + +void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, + u32 *value, bool write) +{ + if (write) + iowrite32(*value, sock->virt_base_addr + offset); + else + *value = ioread32(sock->virt_base_addr + offset); +} + +/* This is the UUID used for HSMP */ +static const guid_t acpi_hsmp_uuid = GUID_INIT(0xb74d619d, 0x5707, 0x48bd, + 0xa6, 0x9f, 0x4e, 0xa2, + 0x87, 0x1f, 0xc2, 0xf6); + +static inline bool is_acpi_hsmp_uuid(union acpi_object *obj) +{ + if (obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == UUID_SIZE) + return guid_equal((guid_t *)obj->buffer.pointer, &acpi_hsmp_uuid); + + return false; +} + +static inline int hsmp_get_uid(struct device *dev, u16 *sock_ind) +{ + char *uid; + + /* + * UID (ID00, ID01..IDXX) is used for differentiating sockets, + * read it and strip the "ID" part of it and convert the remaining + * bytes to integer. + */ + uid = acpi_device_uid(ACPI_COMPANION(dev)); + + return kstrtou16(uid + 2, 10, sock_ind); +} + +static acpi_status hsmp_resource(struct acpi_resource *res, void *data) +{ + struct hsmp_socket *sock = data; + struct resource r; + + switch (res->type) { + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + if (!acpi_dev_resource_memory(res, &r)) + return AE_ERROR; + if (!r.start || r.end < r.start || !(r.flags & IORESOURCE_MEM_WRITEABLE)) + return AE_ERROR; + sock->mbinfo.base_addr = r.start; + sock->mbinfo.size = resource_size(&r); + break; + case ACPI_RESOURCE_TYPE_END_TAG: + break; + default: + return AE_ERROR; + } + + return AE_OK; +} + +static int hsmp_read_acpi_dsd(struct hsmp_socket *sock) +{ + struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *guid, *mailbox_package; + union acpi_object *dsd; + acpi_status status; + int ret = 0; + int j; + + status = acpi_evaluate_object_typed(ACPI_HANDLE(sock->dev), "_DSD", NULL, + &buf, ACPI_TYPE_PACKAGE); + if (ACPI_FAILURE(status)) { + dev_err(sock->dev, "Failed to read mailbox reg offsets from DSD table, err: %s\n", + acpi_format_exception(status)); + return -ENODEV; + } + + dsd = buf.pointer; + + /* HSMP _DSD property should contain 2 objects. + * 1. guid which is an acpi object of type ACPI_TYPE_BUFFER + * 2. mailbox which is an acpi object of type ACPI_TYPE_PACKAGE + * This mailbox object contains 3 more acpi objects of type + * ACPI_TYPE_PACKAGE for holding msgid, msgresp, msgarg offsets + * these packages inturn contain 2 acpi objects of type + * ACPI_TYPE_STRING and ACPI_TYPE_INTEGER + */ + if (!dsd || dsd->type != ACPI_TYPE_PACKAGE || dsd->package.count != 2) { + ret = -EINVAL; + goto free_buf; + } + + guid = &dsd->package.elements[0]; + mailbox_package = &dsd->package.elements[1]; + if (!is_acpi_hsmp_uuid(guid) || mailbox_package->type != ACPI_TYPE_PACKAGE) { + dev_err(sock->dev, "Invalid hsmp _DSD table data\n"); + ret = -EINVAL; + goto free_buf; + } + + for (j = 0; j < mailbox_package->package.count; j++) { + union acpi_object *msgobj, *msgstr, *msgint; + + msgobj = &mailbox_package->package.elements[j]; + msgstr = &msgobj->package.elements[0]; + msgint = &msgobj->package.elements[1]; + + /* package should have 1 string and 1 integer object */ + if (msgobj->type != ACPI_TYPE_PACKAGE || + msgstr->type != ACPI_TYPE_STRING || + msgint->type != ACPI_TYPE_INTEGER) { + ret = -EINVAL; + goto free_buf; + } + + if (!strncmp(msgstr->string.pointer, MSG_IDOFF_STR, + msgstr->string.length)) { + sock->mbinfo.msg_id_off = msgint->integer.value; + } else if (!strncmp(msgstr->string.pointer, MSG_RESPOFF_STR, + msgstr->string.length)) { + sock->mbinfo.msg_resp_off = msgint->integer.value; + } else if (!strncmp(msgstr->string.pointer, MSG_ARGOFF_STR, + msgstr->string.length)) { + sock->mbinfo.msg_arg_off = msgint->integer.value; + } else { + ret = -ENOENT; + goto free_buf; + } + } + + if (!sock->mbinfo.msg_id_off || !sock->mbinfo.msg_resp_off || + !sock->mbinfo.msg_arg_off) + ret = -EINVAL; + +free_buf: + ACPI_FREE(buf.pointer); + return ret; +} + +static int hsmp_read_acpi_crs(struct hsmp_socket *sock) +{ + acpi_status status; + + status = acpi_walk_resources(ACPI_HANDLE(sock->dev), METHOD_NAME__CRS, + hsmp_resource, sock); + if (ACPI_FAILURE(status)) { + dev_err(sock->dev, "Failed to look up MP1 base address from CRS method, err: %s\n", + acpi_format_exception(status)); + return -EINVAL; + } + if (!sock->mbinfo.base_addr || !sock->mbinfo.size) + return -EINVAL; + + /* The mapped region should be un-cached */ + sock->virt_base_addr = devm_ioremap_uc(sock->dev, sock->mbinfo.base_addr, + sock->mbinfo.size); + if (!sock->virt_base_addr) { + dev_err(sock->dev, "Failed to ioremap MP1 base address\n"); + return -ENOMEM; + } + + return 0; +} + +/* Parse the ACPI table to read the data */ +static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) +{ + struct hsmp_socket *sock = &plat_dev.sock[sock_ind]; + int ret; + + sock->sock_ind = sock_ind; + sock->dev = dev; + plat_dev.is_acpi_device = true; + + sema_init(&sock->hsmp_sem, 1); + + /* Read MP1 base address from CRS method */ + ret = hsmp_read_acpi_crs(sock); + if (ret) + return ret; + + /* Read mailbox offsets from DSD table */ + return hsmp_read_acpi_dsd(sock); +} + +int hsmp_create_acpi_sysfs_if(struct device *dev) +{ + struct attribute_group *attr_grp; + u16 sock_ind; + int ret; + + attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), GFP_KERNEL); + if (!attr_grp) + return -ENOMEM; + + attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; + + ret = hsmp_get_uid(dev, &sock_ind); + if (ret) + return ret; + + ret = hsmp_create_attr_list(attr_grp, dev, sock_ind); + if (ret) + return ret; + + return devm_device_add_group(dev, attr_grp); +} + +int init_acpi(struct device *dev) +{ + u16 sock_ind; + int ret; + + ret = hsmp_get_uid(dev, &sock_ind); + if (ret) + return ret; + if (sock_ind >= plat_dev.num_sockets) + return -EINVAL; + + ret = hsmp_parse_acpi_table(dev, sock_ind); + if (ret) { + dev_err(dev, "Failed to parse ACPI table\n"); + return ret; + } + + /* Test the hsmp interface */ + ret = hsmp_test(sock_ind, 0xDEADBEEF); + if (ret) { + dev_err(dev, "HSMP test message failed on Fam:%x model:%x\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + dev_err(dev, "Is HSMP disabled in BIOS ?\n"); + return ret; + } + + ret = hsmp_cache_proto_ver(sock_ind); + if (ret) { + dev_err(dev, "Failed to read HSMP protocol version\n"); + return ret; + } + + return ret; +} diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index d15a978ff71e..8473c2d1258b 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -29,22 +29,8 @@ #define HSMP_WR true #define HSMP_RD false -/* These are the strings specified in ACPI table */ -#define MSG_IDOFF_STR "MsgIdOffset" -#define MSG_ARGOFF_STR "MsgArgOffset" -#define MSG_RESPOFF_STR "MsgRspOffset" - struct hsmp_plat_device plat_dev; -static void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write) -{ - if (write) - iowrite32(*value, sock->virt_base_addr + offset); - else - *value = ioread32(sock->virt_base_addr + offset); -} - static int amd_hsmp_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) { @@ -299,181 +285,6 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return 0; } -/* This is the UUID used for HSMP */ -static const guid_t acpi_hsmp_uuid = GUID_INIT(0xb74d619d, 0x5707, 0x48bd, - 0xa6, 0x9f, 0x4e, 0xa2, - 0x87, 0x1f, 0xc2, 0xf6); - -static inline bool is_acpi_hsmp_uuid(union acpi_object *obj) -{ - if (obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == UUID_SIZE) - return guid_equal((guid_t *)obj->buffer.pointer, &acpi_hsmp_uuid); - - return false; -} - -static inline int hsmp_get_uid(struct device *dev, u16 *sock_ind) -{ - char *uid; - - /* - * UID (ID00, ID01..IDXX) is used for differentiating sockets, - * read it and strip the "ID" part of it and convert the remaining - * bytes to integer. - */ - uid = acpi_device_uid(ACPI_COMPANION(dev)); - - return kstrtou16(uid + 2, 10, sock_ind); -} - -static acpi_status hsmp_resource(struct acpi_resource *res, void *data) -{ - struct hsmp_socket *sock = data; - struct resource r; - - switch (res->type) { - case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: - if (!acpi_dev_resource_memory(res, &r)) - return AE_ERROR; - if (!r.start || r.end < r.start || !(r.flags & IORESOURCE_MEM_WRITEABLE)) - return AE_ERROR; - sock->mbinfo.base_addr = r.start; - sock->mbinfo.size = resource_size(&r); - break; - case ACPI_RESOURCE_TYPE_END_TAG: - break; - default: - return AE_ERROR; - } - - return AE_OK; -} - -static int hsmp_read_acpi_dsd(struct hsmp_socket *sock) -{ - struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *guid, *mailbox_package; - union acpi_object *dsd; - acpi_status status; - int ret = 0; - int j; - - status = acpi_evaluate_object_typed(ACPI_HANDLE(sock->dev), "_DSD", NULL, - &buf, ACPI_TYPE_PACKAGE); - if (ACPI_FAILURE(status)) { - dev_err(sock->dev, "Failed to read mailbox reg offsets from DSD table, err: %s\n", - acpi_format_exception(status)); - return -ENODEV; - } - - dsd = buf.pointer; - - /* HSMP _DSD property should contain 2 objects. - * 1. guid which is an acpi object of type ACPI_TYPE_BUFFER - * 2. mailbox which is an acpi object of type ACPI_TYPE_PACKAGE - * This mailbox object contains 3 more acpi objects of type - * ACPI_TYPE_PACKAGE for holding msgid, msgresp, msgarg offsets - * these packages inturn contain 2 acpi objects of type - * ACPI_TYPE_STRING and ACPI_TYPE_INTEGER - */ - if (!dsd || dsd->type != ACPI_TYPE_PACKAGE || dsd->package.count != 2) { - ret = -EINVAL; - goto free_buf; - } - - guid = &dsd->package.elements[0]; - mailbox_package = &dsd->package.elements[1]; - if (!is_acpi_hsmp_uuid(guid) || mailbox_package->type != ACPI_TYPE_PACKAGE) { - dev_err(sock->dev, "Invalid hsmp _DSD table data\n"); - ret = -EINVAL; - goto free_buf; - } - - for (j = 0; j < mailbox_package->package.count; j++) { - union acpi_object *msgobj, *msgstr, *msgint; - - msgobj = &mailbox_package->package.elements[j]; - msgstr = &msgobj->package.elements[0]; - msgint = &msgobj->package.elements[1]; - - /* package should have 1 string and 1 integer object */ - if (msgobj->type != ACPI_TYPE_PACKAGE || - msgstr->type != ACPI_TYPE_STRING || - msgint->type != ACPI_TYPE_INTEGER) { - ret = -EINVAL; - goto free_buf; - } - - if (!strncmp(msgstr->string.pointer, MSG_IDOFF_STR, - msgstr->string.length)) { - sock->mbinfo.msg_id_off = msgint->integer.value; - } else if (!strncmp(msgstr->string.pointer, MSG_RESPOFF_STR, - msgstr->string.length)) { - sock->mbinfo.msg_resp_off = msgint->integer.value; - } else if (!strncmp(msgstr->string.pointer, MSG_ARGOFF_STR, - msgstr->string.length)) { - sock->mbinfo.msg_arg_off = msgint->integer.value; - } else { - ret = -ENOENT; - goto free_buf; - } - } - - if (!sock->mbinfo.msg_id_off || !sock->mbinfo.msg_resp_off || - !sock->mbinfo.msg_arg_off) - ret = -EINVAL; - -free_buf: - ACPI_FREE(buf.pointer); - return ret; -} - -static int hsmp_read_acpi_crs(struct hsmp_socket *sock) -{ - acpi_status status; - - status = acpi_walk_resources(ACPI_HANDLE(sock->dev), METHOD_NAME__CRS, - hsmp_resource, sock); - if (ACPI_FAILURE(status)) { - dev_err(sock->dev, "Failed to look up MP1 base address from CRS method, err: %s\n", - acpi_format_exception(status)); - return -EINVAL; - } - if (!sock->mbinfo.base_addr || !sock->mbinfo.size) - return -EINVAL; - - /* The mapped region should be un cached */ - sock->virt_base_addr = devm_ioremap_uc(sock->dev, sock->mbinfo.base_addr, - sock->mbinfo.size); - if (!sock->virt_base_addr) { - dev_err(sock->dev, "Failed to ioremap MP1 base address\n"); - return -ENOMEM; - } - - return 0; -} - -/* Parse the ACPI table to read the data */ -static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) -{ - struct hsmp_socket *sock = &plat_dev.sock[sock_ind]; - int ret; - - sock->sock_ind = sock_ind; - sock->dev = dev; - plat_dev.is_acpi_device = true; - - sema_init(&sock->hsmp_sem, 1); - - /* Read MP1 base address from CRS method */ - ret = hsmp_read_acpi_crs(sock); - if (ret) - return ret; - - /* Read mailbox offsets from DSD table */ - return hsmp_read_acpi_dsd(sock); -} - ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) @@ -582,29 +393,6 @@ int hsmp_create_attr_list(struct attribute_group *attr_grp, return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind); } -int hsmp_create_acpi_sysfs_if(struct device *dev) -{ - struct attribute_group *attr_grp; - u16 sock_ind; - int ret; - - attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), GFP_KERNEL); - if (!attr_grp) - return -ENOMEM; - - attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; - - ret = hsmp_get_uid(dev, &sock_ind); - if (ret) - return ret; - - ret = hsmp_create_attr_list(attr_grp, dev, sock_ind); - if (ret) - return ret; - - return devm_device_add_group(dev, attr_grp); -} - int hsmp_cache_proto_ver(u16 sock_ind) { struct hsmp_message msg = { 0 }; @@ -620,38 +408,3 @@ int hsmp_cache_proto_ver(u16 sock_ind) return ret; } - -int init_acpi(struct device *dev) -{ - u16 sock_ind; - int ret; - - ret = hsmp_get_uid(dev, &sock_ind); - if (ret) - return ret; - if (sock_ind >= plat_dev.num_sockets) - return -EINVAL; - - ret = hsmp_parse_acpi_table(dev, sock_ind); - if (ret) { - dev_err(dev, "Failed to parse ACPI table\n"); - return ret; - } - - /* Test the hsmp interface */ - ret = hsmp_test(sock_ind, 0xDEADBEEF); - if (ret) { - dev_err(dev, "HSMP test message failed on Fam:%x model:%x\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - dev_err(dev, "Is HSMP disabled in BIOS ?\n"); - return ret; - } - - ret = hsmp_cache_proto_ver(sock_ind); - if (ret) { - dev_err(dev, "Failed to read HSMP protocol version\n"); - return ret; - } - - return ret; -} diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 1aa33c5633d0..1ff652dc0ef0 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -68,4 +68,6 @@ umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, int hsmp_create_attr_list(struct attribute_group *attr_grp, struct device *dev, u16 sock_ind); int hsmp_test(u16 sock_ind, u32 value); +void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, + u32 *value, bool write); #endif /* HSMP_H */ From patchwork Sat Jul 20 17:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737870 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2048.outbound.protection.outlook.com [40.107.244.48]) (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 AD47E1EB40 for ; Sat, 20 Jul 2024 17:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497601; cv=fail; b=g5huZl2qacKqeIpfNt6oowg8IAFrlpNl1ufTs4Jlv210eRjg2V3S0/uqmUl03WiLe0achIdFRNMztOsdxwZheN+kH6GKStMDc3ckS/TI+suAdHGcNUEVT3ewtsbCtpdwglpCjqQNIQ7XtoAdKfmNjU0Kzc/XePolocSWbq88cik= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497601; c=relaxed/simple; bh=x3LngRlDLsEVv4ykbWPNVAAJc7+YvysQLL83QXYYBvg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bBFoWYkNNTD/tNQhYPxdshS3KQU+EkA314McvXI6Jln/GnpQqIAW8gis9V+xq+jR/vXOwCpxrUYMZFE7X5m5fmmoCC04EVtzv7uwBhlnGeN61xVEM15+Kxx+v+gB4QWv2L1UtiqO3jicRqfADCjXZvXUrP3xbpwI5955uv0IzFU= 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=Ya63fxrO; arc=fail smtp.client-ip=40.107.244.48 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="Ya63fxrO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o98QhgqDTNxwXu015zB5x7xLXdN9x8e9KyBuP0dyDcOnhX5/wctP0+OJCgyhNTMV+q5nWeUtx4Wfee/WsP9kl5H9m4gqIyYJ1xVAIlnPmIqtBOAR9AyEVuf6uLcTG8LtO3aTwLJt11nQb7DGaWEFGrXF68fPD3MAXJzdFRzMpYrQMWiD4DEwKvgwh7qjlhqNHhqm9DGz6ZTbqxkY+9aUDiCcb+3jlfPxu0xk/lMLOXPi0SJdXP3VCpMFQQdN8GtqC5I3Cj0UEtryJmhLaVeY8WpjzBpi68kzjOPkN+qNeJ2O2IdikCLx39veAMC+/KftrCilqCd6bGFeYTrOY1khjA== 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=IOYiw15y3pIaQ1i12n0z6nAGb1v3WDssTT6qCbN9XwA=; b=ViaVWVvWXyYpLICdWRbMdKm90zR6XykiX62uWS/lcSeQPY2woUQeMqfb/YDAGRsdDl8eXhQ5AK8X7bSzqTywYXhd4FTDKVGXeyUeqH3NjOE+qn+yv+OUNS1lOWNGhF8/UuYFEjH18Vi1AfqvzowxXibnEqpat8vsu3eiLoachIw5SicEBb3rrcvBbFpT0zKgDIIic/SGw5fsv4u5BnWNez0+hEkhKH6zxm6N1bdSPZXA+ilttVMPp7A4OabtJ2s1+5C8vwGbF0QCLWkoFnOYPnUoW7znTW4bkwoImx0rhVJN7vlq/3UAq6K+AY70WYCIYVTNMEC946EjyTWjgIKlqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=IOYiw15y3pIaQ1i12n0z6nAGb1v3WDssTT6qCbN9XwA=; b=Ya63fxrOIUOPVOYdL+k5G1HHVji99Xz+NAX++f+hgv1fYUNxio+ROvXWo/Tn5CVoMi3qhXtQyPa50w9TNY2IIFmXjpqztLsxH1gtU32Y9vqIiwlRvDCoOkkzqjaS7eUO42wWKGmBul6+fMSQJW2KOFOsznsuh4zpeTJnKQDy0zs= Received: from DM6PR01CA0016.prod.exchangelabs.com (2603:10b6:5:296::21) by DM6PR12MB4185.namprd12.prod.outlook.com (2603:10b6:5:216::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Sat, 20 Jul 2024 17:46:34 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:296:cafe::9f) by DM6PR01CA0016.outlook.office365.com (2603:10b6:5:296::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46:34 +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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:34 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:32 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 06/11] platform/x86/amd/hsmp: Change generic plat_dev name to hsmp_pdev Date: Sat, 20 Jul 2024 17:45:47 +0000 Message-ID: <20240720174552.946255-6-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017091:EE_|DM6PR12MB4185:EE_ X-MS-Office365-Filtering-Correlation-Id: f28e0586-7a11-4f89-f480-08dca8e3e5ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: aISDWfOrIgPBCyen9nTnUPSIfqbRFPDjWM0XhQw7b5Zdg0zye+HrPskVdD8gtDpVO8/EFhQOPFoy6BHcCoNIxMz0ytvwFgrL2XGnWXNQW6vSuo5gQfCSjpfbOm2ZVCtITzKR0h0UQCJYr6gr2h0Y5hI8A5aGjtADGD73Y940mc7ptVrWL26WciAbFnD2maxBFoveOINCLUU1ha8H5fD5EKWxsF74ZroYB22gwOf2mtS5a/MuSyFLerjpjllfJXla8uNPVRum4qzEoWWNYcB+biJpQ/dje7lkofCLzgPc2Pgz+DrOBvg8gSFpmcRFkx0gz2mNBa/Fr6ummaTrLJRCJSRfiHfdvYsu5e03CWUaoapxTC06VPc3aSp33gfpOCmFqT65D9Y5Zub1R/rO85/QIIAGDRPUP4CSZuBhlbL74xg0k65ui6g54o7be1/Ewg4jk+HTlg1HAE5mfZfAyor1+TlE5IzxjEAXS0U/no+BCJRKg7zLB7po5B+ISd4u4QlZtnisIMEeY22LxGk3nnyIBpt7zTc+lgQOJ8RgcpTOT2ET8siuKWJIrkCxNFkfHHbl02WQWwTE+YgOP80YVaFYa1j2Jo6oM5yMz9lecB0KK9LDelk3H9FVahtcTNo3cLQreDvXDjpoJYzMQNCuY5Dn1FF6A53VzxREjyv007SKYIGA5BXkhX0y6yKmimlx7jJ4sTGSMYJG0JGujKlC5KZp7oG5Ngr9uPmH0mJsvDEGJtDXPrqMl2k1TsHjzzNyE/KGXUssmO/CtmB27/VbEExHBx6RgAIvwsDOPid4OxlnNy78JXeVmC1dTEU5wECcw8czlsSDyDUgE2wFjDZvpL+Qej0sf49J5L5xmkdRKA943QlxGgdovL7lVHKDia/5V4tNvGizmCf15wn6DlGJS/+nliXrhhfyiEcBGopOCa1OKv8i0h5dS1uxzdpovhN1PacjyZwlMiMFYBiDRRyBoy2uDFdwIayQtt6IMfFqMeMYb5Mh2QJEc3bIc4nh2GkfXrHb+rzwemOE55VXfLUkFhb8IjE7XwpMAKYN8PYh5jpVgDrzCZW5nYBowGQ2k88/HDqkkJHiXOPCRJC+/EWUrRM30VZKlRFA61nrAJiB4VYlSV9ngWHo7ptSEtSb8akw/BNTzpNderIcTeg7rTNC73YpDqtyt466eyhV5/X8gKWoiwyB3KbykqFM7WxaHKctM5xIHZk1zc+L0nZJZJIxK4FAb7PPcsSQlyBSAVhJEyqZ7hshvvAMcGWQjCTWCo9Lbg9OiT5c/1Lvn8R+CsHGUNSrmKlzzlOZLXtlp7K/EQOPfgxOG9yX+G0B6FKasEe+WKxIAzNpc6IgEko7Sk4HRHMxgSq/OfBm6AjKM3gfM0UbxBOmqpIs0TrmiU+/gJO0JkQPDQo2XQiDApzl4h+4XDkid5WotllhlPt1GRb63Ruz660Dq2WYwSCpIefkcXxXZ+q+ 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:34.7228 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f28e0586-7a11-4f89-f480-08dca8e3e5ec 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4185 plat_dev is a commonly used variable name, since its made as extern now, change it to more specific name. Also change miscdevice hsmp_device to mdev. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v2: None Changes since v1: 1. This is a new patch to rename generic name "plat_dev" in hsmp.h, hsmp.c, plat.c and acpi.c to more specific name "hsmp_pdev" 2. Rename miscdevice hsmp_device to mdev. drivers/platform/x86/amd/hsmp/acpi.c | 10 +++--- drivers/platform/x86/amd/hsmp/hsmp.c | 22 ++++++------ drivers/platform/x86/amd/hsmp/hsmp.h | 4 +-- drivers/platform/x86/amd/hsmp/plat.c | 52 ++++++++++++++-------------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index eca324774141..46cb86d5d550 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -191,12 +191,12 @@ static int hsmp_read_acpi_crs(struct hsmp_socket *sock) /* Parse the ACPI table to read the data */ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) { - struct hsmp_socket *sock = &plat_dev.sock[sock_ind]; + struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; int ret; - sock->sock_ind = sock_ind; - sock->dev = dev; - plat_dev.is_acpi_device = true; + sock->sock_ind = sock_ind; + sock->dev = dev; + hsmp_pdev.is_acpi_device = true; sema_init(&sock->hsmp_sem, 1); @@ -240,7 +240,7 @@ int init_acpi(struct device *dev) ret = hsmp_get_uid(dev, &sock_ind); if (ret) return ret; - if (sock_ind >= plat_dev.num_sockets) + if (sock_ind >= hsmp_pdev.num_sockets) return -EINVAL; ret = hsmp_parse_acpi_table(dev, sock_ind); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 8473c2d1258b..14edaace4379 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -29,12 +29,12 @@ #define HSMP_WR true #define HSMP_RD false -struct hsmp_plat_device plat_dev; +struct hsmp_plat_device hsmp_pdev; static int amd_hsmp_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) { - if (plat_dev.is_acpi_device) + if (hsmp_pdev.is_acpi_device) amd_hsmp_acpi_rdwr(sock, offset, value, write); else return amd_hsmp_pci_rdwr(sock, offset, value, write); @@ -177,9 +177,9 @@ int hsmp_send_message(struct hsmp_message *msg) if (ret) return ret; - if (!plat_dev.sock || msg->sock_ind >= plat_dev.num_sockets) + if (!hsmp_pdev.sock || msg->sock_ind >= hsmp_pdev.num_sockets) return -ENODEV; - sock = &plat_dev.sock[msg->sock_ind]; + sock = &hsmp_pdev.sock[msg->sock_ind]; /* * The time taken by smu operation to complete is between @@ -220,7 +220,7 @@ int hsmp_test(u16 sock_ind, u32 value) /* Check the response value */ if (msg.args[0] != (value + 1)) { - dev_err(plat_dev.sock[sock_ind].dev, + dev_err(hsmp_pdev.sock[sock_ind].dev, "Socket %d test message failed, Expected 0x%08X, received 0x%08X\n", sock_ind, (value + 1), msg.args[0]); return -EBADE; @@ -315,7 +315,7 @@ ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, static int hsmp_get_tbl_dram_base(u16 sock_ind) { - struct hsmp_socket *sock = &plat_dev.sock[sock_ind]; + struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; struct hsmp_message msg = { 0 }; phys_addr_t dram_addr; int ret; @@ -349,7 +349,7 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind) umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, struct bin_attribute *battr, int id) { - if (plat_dev.proto_ver == HSMP_PROTO_VER6) + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) return battr->attr.mode; else return 0; @@ -357,17 +357,17 @@ umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock_ind) { - struct bin_attribute *hattr = &plat_dev.sock[sock_ind].hsmp_attr; + struct bin_attribute *hattr = &hsmp_pdev.sock[sock_ind].hsmp_attr; sysfs_bin_attr_init(hattr); hattr->attr.name = HSMP_METRICS_TABLE_NAME; hattr->attr.mode = 0444; hattr->read = hsmp_metric_tbl_read; hattr->size = sizeof(struct hsmp_metric_table); - hattr->private = &plat_dev.sock[sock_ind]; + hattr->private = &hsmp_pdev.sock[sock_ind]; hattrs[0] = hattr; - if (plat_dev.proto_ver == HSMP_PROTO_VER6) + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) return hsmp_get_tbl_dram_base(sock_ind); else return 0; @@ -404,7 +404,7 @@ int hsmp_cache_proto_ver(u16 sock_ind) ret = hsmp_send_message(&msg); if (!ret) - plat_dev.proto_ver = msg.args[0]; + hsmp_pdev.proto_ver = msg.args[0]; return ret; } diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 1ff652dc0ef0..a77887d298b6 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -44,7 +44,7 @@ struct hsmp_socket { }; struct hsmp_plat_device { - struct miscdevice hsmp_device; + struct miscdevice mdev; struct hsmp_socket *sock; u32 proto_ver; u16 num_sockets; @@ -52,7 +52,7 @@ struct hsmp_plat_device { bool is_probed; }; -extern struct hsmp_plat_device plat_dev; +extern struct hsmp_plat_device hsmp_pdev; int init_acpi(struct device *dev); ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index 2ed5a9452244..c297540bb64c 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -68,21 +68,21 @@ static int hsmp_create_non_acpi_sysfs_if(struct device *dev) struct attribute_group *attr_grp; u16 i; - hsmp_attr_grps = devm_kcalloc(dev, plat_dev.num_sockets + 1, + hsmp_attr_grps = devm_kcalloc(dev, hsmp_pdev.num_sockets + 1, sizeof(*hsmp_attr_grps), GFP_KERNEL); if (!hsmp_attr_grps) return -ENOMEM; /* Create a sysfs directory for each socket */ - for (i = 0; i < plat_dev.num_sockets; i++) { + for (i = 0; i < hsmp_pdev.num_sockets; i++) { attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), GFP_KERNEL); if (!attr_grp) return -ENOMEM; - snprintf(plat_dev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); - attr_grp->name = plat_dev.sock[i].name; + snprintf(hsmp_pdev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); + attr_grp->name = hsmp_pdev.sock[i].name; attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; hsmp_attr_grps[i] = attr_grp; @@ -105,10 +105,10 @@ static int init_platform_device(struct device *dev) struct hsmp_socket *sock; int ret, i; - for (i = 0; i < plat_dev.num_sockets; i++) { + for (i = 0; i < hsmp_pdev.num_sockets; i++) { if (!node_to_amd_nb(i)) return -ENODEV; - sock = &plat_dev.sock[i]; + sock = &hsmp_pdev.sock[i]; sock->root = node_to_amd_nb(i)->root; sock->sock_ind = i; sock->dev = dev; @@ -173,11 +173,11 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev) * Hence allocate memory for all the sockets at once instead of allocating * on each probe. */ - if (!plat_dev.is_probed) { - plat_dev.sock = devm_kcalloc(&pdev->dev, plat_dev.num_sockets, - sizeof(*plat_dev.sock), - GFP_KERNEL); - if (!plat_dev.sock) + if (!hsmp_pdev.is_probed) { + hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, + sizeof(*hsmp_pdev.sock), + GFP_KERNEL); + if (!hsmp_pdev.sock) return -ENOMEM; } @@ -201,19 +201,19 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); } - if (!plat_dev.is_probed) { - plat_dev.hsmp_device.name = HSMP_CDEV_NAME; - plat_dev.hsmp_device.minor = MISC_DYNAMIC_MINOR; - plat_dev.hsmp_device.fops = &hsmp_fops; - plat_dev.hsmp_device.parent = &pdev->dev; - plat_dev.hsmp_device.nodename = HSMP_DEVNODE_NAME; - plat_dev.hsmp_device.mode = 0644; + if (!hsmp_pdev.is_probed) { + hsmp_pdev.mdev.name = HSMP_CDEV_NAME; + hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; + hsmp_pdev.mdev.fops = &hsmp_fops; + hsmp_pdev.mdev.parent = &pdev->dev; + hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; + hsmp_pdev.mdev.mode = 0644; - ret = misc_register(&plat_dev.hsmp_device); + ret = misc_register(&hsmp_pdev.mdev); if (ret) return ret; - plat_dev.is_probed = true; + hsmp_pdev.is_probed = true; } return 0; @@ -225,9 +225,9 @@ static void hsmp_pltdrv_remove(struct platform_device *pdev) * We register only one misc_device even on multi socket system. * So, deregister should happen only once. */ - if (plat_dev.is_probed) { - misc_deregister(&plat_dev.hsmp_device); - plat_dev.is_probed = false; + if (hsmp_pdev.is_probed) { + misc_deregister(&hsmp_pdev.mdev); + hsmp_pdev.is_probed = false; } } @@ -299,15 +299,15 @@ static int __init hsmp_plt_init(void) * amd_nb_num() returns number of SMN/DF interfaces present in the system * if we have N SMN/DF interfaces that ideally means N sockets */ - plat_dev.num_sockets = amd_nb_num(); - if (plat_dev.num_sockets == 0 || plat_dev.num_sockets > MAX_AMD_SOCKETS) + hsmp_pdev.num_sockets = amd_nb_num(); + if (hsmp_pdev.num_sockets == 0 || hsmp_pdev.num_sockets > MAX_AMD_SOCKETS) return ret; ret = platform_driver_register(&amd_hsmp_driver); if (ret) return ret; - if (!plat_dev.is_acpi_device) { + if (!hsmp_pdev.is_acpi_device) { if (legacy_hsmp_support()) { /* Not ACPI device, but supports HSMP, register a plat_dev */ ret = hsmp_plat_dev_register(); From patchwork Sat Jul 20 17:45:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737871 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2056.outbound.protection.outlook.com [40.107.93.56]) (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 2F8ED1482FC for ; Sat, 20 Jul 2024 17:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497602; cv=fail; b=MyxJDEufq0Z8i8ckvk+usAinwsa1vqnJWEyuoVCC1G1yP+VDiza8avVR1Bosf+WsRvS7OfUA1IxVPo7i7cwYZ9PGbdoREinbh0okPGMF9H4IE6EUYfl4v9bVAtrwnGMk5YMcdR2JCzrs9rhiRB7xVbLqwMtZFlzUblnYFmJZPVE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497602; c=relaxed/simple; bh=1yzb33XkZzx1SmLSECJ33NL1GzVlEJZ4FbucUJMc3To=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sO8/60wxtPacmrfWVFmptm5Y10WLJEOPrcnBplCmBfxizzaIboBtQ5ZnqS6BoDByH08PUnJFb1fW0ljA6OlRizaFB7xknQzdZTPpEVV90E5ua8ZLpjzFabRgAmcRd2LroUAP95AMIY4rx1jg1lcljRGWRRIjV9cnCVb0HR3/ZPg= 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=rM26EyV6; arc=fail smtp.client-ip=40.107.93.56 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="rM26EyV6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eYF/582xEPDAjbQvAxggygHZlxFv4Qj8zeCCX7MbsYyrqdgSFW+FhVBUphTsBAGHVwUH6+7GtLTswyNkPRteLlzIbwcxCj8DQX/JyBJwkYHnfhViefhDkURYjeIvJeK+/L1jkVYLwcYzpfVXCC8Rr90XMJHnw3myd8+V2M98DOCz3wXvCeZInNr0ZL6cgoJiykg4xDIqHRAZTtxzq6wVQPNZHTRObzfj+ciodRq8+WDCdNiSMalAnowY82DTy84wfIFoWDsPofWH1oKP5ilAE6wjw+oi8KK0VEPg4x1A2Ruc9KISTAHpTtWud6dziTNEGU/qIUCS7ZyXHVuiduCnpQ== 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=H+xe9D4t811G/5isRd1qxPewwAPX+axOdXgNQJQn1lk=; b=rt3Ud5JLt4ITwwiNpszDZ2UrrCEkFxrgNyIxY4IiPrONyTzwrWc3ZghzzfRs3oRsUe95fCueV9Gmx6UDYUWkLo4293ba1PO3aQRCLb/vR4Dr+UhKvJGOcbAMo3ZiS//Xrzc8di3ZfncUbyI0Wje6HiUx8yJNZl3BYutDvg9q8dgxs/kjP80U1IgULBnjk1OxvaknEhK25E4i7CvXjMjgzrsAKqg/bAhkn97DTHRFOh3Za1Evo306SKpf3wePcGzRsVSoDydyfSlBcE6rPaABiyrJsm/1wdMdoR5ZGcsa53zbEaB3ua+8NlsjiExbvm1OnHmGSCu5cb5yUJDktJWYtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=H+xe9D4t811G/5isRd1qxPewwAPX+axOdXgNQJQn1lk=; b=rM26EyV6VBqEOS0pYeLiqWBROpJsWX6DAvNHThZQKaT+Acd2yTChxPTnRTy4cWjBIAmHNwV4wkj/QlbKKIBmISTjlEK+aFWXaBofvGMucWbxlullmDA0a21XxVd2gNcMYgn3/3oKocQfqHS77zb57kZb2R6Ea04c/h1lQe4VULA= Received: from DM5PR07CA0074.namprd07.prod.outlook.com (2603:10b6:4:ad::39) by MN0PR12MB6054.namprd12.prod.outlook.com (2603:10b6:208:3ce::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.33; Sat, 20 Jul 2024 17:46:36 +0000 Received: from DS1PEPF00017090.namprd03.prod.outlook.com (2603:10b6:4:ad:cafe::8) by DM5PR07CA0074.outlook.office365.com (2603:10b6:4:ad::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017090.mail.protection.outlook.com (10.167.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:36 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:34 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 07/11] platform/x86/amd/hsmp: Create mutually exclusive ACPI and plat drivers Date: Sat, 20 Jul 2024 17:45:48 +0000 Message-ID: <20240720174552.946255-7-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017090:EE_|MN0PR12MB6054:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ba1d2e6-487a-49af-7d71-08dca8e3e70a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 3uWf6rBZyBrXttGgeU4QoeIZWEo10SZXE1GaurRepKMYj91+VqOHi3XRM8K3GqVZUNzWbXMwvhYbvehVPuBKl1DbIV2Bpzmv8s4p2Rxe3nGdAXbT9318TDfACfeIwj15RnIyIg7ToGEmCRl2WD1pzuupNjzeqouSbzcDklP8jIm6yP9Ilx1zXRlUdfRjnhw1acFiQ2XQgPrnYOxbtq3RSyyjDsirRtus7cdkD/v9whCIJyFUrefzSPM6vdH8gJdBdWPohGiOtLzqLkHRC54adnZMo0lbFwyxCdxDQP0s+3/WNKbhxwTHdGKnp7trmgq5TVQFRfZZI9EcCFVnqmgtrIMvzEpjzShPoysiuZnXJMvGGRmZxaBqAayFRHn/OlTJIsHgO+/iVMm7sH980+ZLvkidzoOu4ckdbz9KRl62zr7FjK+vTe+KQ8WWkmHlr5SiQC220fyFxWKuDprpwny5wOOTRuymGW1SF8mYpCsgCDsI3VwZCKQep5DnH94pyVdEbZqsqvEsIo2EfS6trtlrRGEmVAThxQTE/jvZz0wkO/8xPgCxobodmCiFiRukfyfF/irHryb/zkf3xD0jWcKUk4Mn0YeYIqu7y4T0xWSkVr9WvtKqDKM/hhlX9A4MEfbYWwSLVl/YmxqIkwJ8ewOCzOftppPfaPjAY3kAn3LAuidZXhdyv4BYp03kqILsuUjUQJOtw0E3dHdzolideS2wyEGXXbJlc+OW1lyCgc0K1klkBMLyzi3kthR9DB53E6EyWTLaMhxggKTzFmerqUU+LTfRICAiXXcKk1ZQNFZXY8uRhJTbXVul/7HGbUU/OmglfVI6dnWFh2fo2aoNfikH3NX0DxZ/E2gP1n4SI5C1YwszIoOJox36ZJrKL+v7N17M1AlAQD5I4/nPkkFq+exJ3f5+VucHrmgEUDIH9x9coojkMdHWKC3XB00AEs0I/jv5lQ933rdwHMYL0HXkE7A0ED6z2h/23NItY5MOb56Y7qBA55KiD+boZWSxa/tAnITGek+IuK0uaqIVngmFsfiWMOQDXnWE8DWnVU5hq9oESgX5KyMGSkygwG5TXVp/h/GUctUAfcbCbt/9kY+ezw/gRWD3U3NIFh2lMW9dsnVVR8yqIBUMRymsDDXJa3fk554qNePxL+H3GKsRnzUjDzNwhGx9JAAz6Ksn/wMS7fA7618TEVTzoXDFHFAivb2UmcBYp+GABP8S4Ht4O9lDLn+Z5nKyUDA8y55P1HKZxpfkpd48G4QOk6Rl4NtRU3Saep+lqeM1unydhDsSmWI1KIf7A8A/bhs1BJBML+qkJPM64MWdBPkUN6DyxtGXCfpqr1mW1nG3J5JR9yhaltoYuaxpRemJPNUdfkn78oOedlOaoWtYmxrUnklFp8xCSW31wQF76p7s/3fuoGOmkgcfKiY5QGyi2SeUFa/BJUvYLIZuWxzQPc9owvgSQPgOTz4/lhYM 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)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:36.6097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ba1d2e6-487a-49af-7d71-08dca8e3e70a 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: DS1PEPF00017090.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6054 Separate the probes for ACPI and platform device drivers. Provide a Kconfig option to select either the ACPI or the platform device based driver. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: Following files are modified to add new symbol - drivers/platform/x86/amd/hsmp/Kconfig, - drivers/platform/x86/amd/hsmp/Makefile - drivers/platform/x86/amd/Makefile AMD_HSMP is used as common symbol and new AMD_HSMP_PLAT symbol is added Changes since v1: Rename "plat_dev" to "hsmp_pdev" arch/x86/include/asm/amd_hsmp.h | 2 +- drivers/platform/x86/amd/Makefile | 2 +- drivers/platform/x86/amd/hsmp/Kconfig | 33 ++++++- drivers/platform/x86/amd/hsmp/Makefile | 6 +- drivers/platform/x86/amd/hsmp/acpi.c | 119 ++++++++++++++++++++++-- drivers/platform/x86/amd/hsmp/hsmp.c | 25 ++--- drivers/platform/x86/amd/hsmp/hsmp.h | 8 +- drivers/platform/x86/amd/hsmp/plat.c | 122 +++++++------------------ 8 files changed, 188 insertions(+), 129 deletions(-) diff --git a/arch/x86/include/asm/amd_hsmp.h b/arch/x86/include/asm/amd_hsmp.h index 03c2ce3edaf5..ada14e55f9f4 100644 --- a/arch/x86/include/asm/amd_hsmp.h +++ b/arch/x86/include/asm/amd_hsmp.h @@ -5,7 +5,7 @@ #include -#if IS_ENABLED(CONFIG_AMD_HSMP) +#if IS_ENABLED(CONFIG_AMD_HSMP) || IS_ENABLED(CONFIG_AMD_HSMP_ACPI) int hsmp_send_message(struct hsmp_message *msg); #else static inline int hsmp_send_message(struct hsmp_message *msg) diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile index 96ec24c8701b..f0b2fe81c685 100644 --- a/drivers/platform/x86/amd/Makefile +++ b/drivers/platform/x86/amd/Makefile @@ -5,6 +5,6 @@ # obj-$(CONFIG_AMD_PMC) += pmc/ -obj-y += hsmp/ +obj-$(CONFIG_AMD_HSMP) += hsmp/ obj-$(CONFIG_AMD_PMF) += pmf/ obj-$(CONFIG_AMD_WBRF) += wbrf.o diff --git a/drivers/platform/x86/amd/hsmp/Kconfig b/drivers/platform/x86/amd/hsmp/Kconfig index b55d4ed9bceb..23fb98066225 100644 --- a/drivers/platform/x86/amd/hsmp/Kconfig +++ b/drivers/platform/x86/amd/hsmp/Kconfig @@ -4,14 +4,39 @@ # config AMD_HSMP - tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 && ACPI + tristate "AMD Host System Management Port driver" + depends on AMD_NB help + Host System Management Port (HSMP) interface is a mailbox interface + between the x86 core and the System Management Unit (SMU) firmware. The driver provides a way for user space tools to monitor and manage system management functionality on EPYC server CPUs from AMD. - Host System Management Port (HSMP) interface is a mailbox interface - between the x86 core and the System Management Unit (SMU) firmware. +menu "AMD HSMP Probe" + depends on AMD_HSMP + +config AMD_HSMP_ACPI + tristate "ACPI based probe" + depends on ACPI + help + This driver supports ACPI based probing. + + You may enable this, if your platform bios provides an ACPI object + as described in the documentation. If you choose to compile this driver as a module the module will be called amd_hsmp. + +config AMD_HSMP_PLAT + tristate "Platform device based probe" + depends on AMD_HSMP_ACPI=n + help + This driver supports platform device based probing. + + You may enable this, if your platform bios does not provide + HSMP ACPI object. + + If you choose to compile this driver as a module the module will be + called amd_hsmp. + +endmenu diff --git a/drivers/platform/x86/amd/hsmp/Makefile b/drivers/platform/x86/amd/hsmp/Makefile index 0cc92865c0a2..18d9a0d1e8c5 100644 --- a/drivers/platform/x86/amd/hsmp/Makefile +++ b/drivers/platform/x86/amd/hsmp/Makefile @@ -4,5 +4,7 @@ # AMD HSMP Driver # -obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o -amd_hsmp-objs := hsmp.o plat.o acpi.o +obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o +amd_hsmp-objs := hsmp.o +amd_hsmp-$(CONFIG_AMD_HSMP_PLAT) += plat.o +amd_hsmp-$(CONFIG_AMD_HSMP_ACPI) += acpi.o diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 46cb86d5d550..86100943aadc 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -11,29 +11,43 @@ #include "hsmp.h" +#include + #include #include #include #include #include +#include #include #include +#define DRIVER_NAME "amd_hsmp" +#define DRIVER_VERSION "2.3" +#define ACPI_HSMP_DEVICE_HID "AMDI0097" + /* These are the strings specified in ACPI table */ #define MSG_IDOFF_STR "MsgIdOffset" #define MSG_ARGOFF_STR "MsgArgOffset" #define MSG_RESPOFF_STR "MsgRspOffset" -void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write) +static int amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, + u32 *value, bool write) { if (write) iowrite32(*value, sock->virt_base_addr + offset); else *value = ioread32(sock->virt_base_addr + offset); + return 0; } +static const struct file_operations hsmp_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = hsmp_ioctl, + .compat_ioctl = hsmp_ioctl, +}; + /* This is the UUID used for HSMP */ static const guid_t acpi_hsmp_uuid = GUID_INIT(0xb74d619d, 0x5707, 0x48bd, 0xa6, 0x9f, 0x4e, 0xa2, @@ -194,9 +208,9 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; int ret; - sock->sock_ind = sock_ind; - sock->dev = dev; - hsmp_pdev.is_acpi_device = true; + sock->sock_ind = sock_ind; + sock->dev = dev; + sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; sema_init(&sock->hsmp_sem, 1); @@ -209,7 +223,7 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) return hsmp_read_acpi_dsd(sock); } -int hsmp_create_acpi_sysfs_if(struct device *dev) +static int hsmp_create_acpi_sysfs_if(struct device *dev) { struct attribute_group *attr_grp; u16 sock_ind; @@ -232,7 +246,7 @@ int hsmp_create_acpi_sysfs_if(struct device *dev) return devm_device_add_group(dev, attr_grp); } -int init_acpi(struct device *dev) +static int init_acpi(struct device *dev) { u16 sock_ind; int ret; @@ -266,3 +280,94 @@ int init_acpi(struct device *dev) return ret; } + +static const struct acpi_device_id amd_hsmp_acpi_ids[] = { + {ACPI_HSMP_DEVICE_HID, 0}, + {} +}; +MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); + +static bool check_acpi_support(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) + return true; + + return false; +} + +static int hsmp_acpi_probe(struct platform_device *pdev) +{ + int ret; + + if (!hsmp_pdev.is_probed) { + hsmp_pdev.num_sockets = amd_nb_num(); + if (hsmp_pdev.num_sockets == 0 || hsmp_pdev.num_sockets > MAX_AMD_SOCKETS) + return -ENODEV; + + hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, + sizeof(*hsmp_pdev.sock), + GFP_KERNEL); + if (!hsmp_pdev.sock) + return -ENOMEM; + } + + if (!check_acpi_support(&pdev->dev)) { + dev_err(&pdev->dev, "Not ACPI device?\n"); + return -ENODEV; + } + + ret = init_acpi(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to initialize HSMP interface.\n"); + return ret; + } + + ret = hsmp_create_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + + if (!hsmp_pdev.is_probed) { + hsmp_pdev.mdev.name = HSMP_CDEV_NAME; + hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; + hsmp_pdev.mdev.fops = &hsmp_fops; + hsmp_pdev.mdev.parent = &pdev->dev; + hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; + hsmp_pdev.mdev.mode = 0644; + + ret = misc_register(&hsmp_pdev.mdev); + if (ret) + return ret; + hsmp_pdev.is_probed = true; + } + + return 0; +} + +static void hsmp_acpi_remove(struct platform_device *pdev) +{ + /* + * We register only one misc_device even on multi-socket system. + * So, deregister should happen only once. + */ + if (hsmp_pdev.is_probed) { + misc_deregister(&hsmp_pdev.mdev); + hsmp_pdev.is_probed = false; + } +} + +static struct platform_driver amd_hsmp_driver = { + .probe = hsmp_acpi_probe, + .remove_new = hsmp_acpi_remove, + .driver = { + .name = DRIVER_NAME, + .acpi_match_table = amd_hsmp_acpi_ids, + }, +}; + +module_platform_driver(amd_hsmp_driver); + +MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 14edaace4379..759ec1d4d60d 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -31,17 +31,6 @@ struct hsmp_plat_device hsmp_pdev; -static int amd_hsmp_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write) -{ - if (hsmp_pdev.is_acpi_device) - amd_hsmp_acpi_rdwr(sock, offset, value, write); - else - return amd_hsmp_pci_rdwr(sock, offset, value, write); - - return 0; -} - /* * Send a message to the HSMP port via PCI-e config space registers * or by writing to MMIO space. @@ -64,7 +53,7 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms /* Clear the status register */ mbox_status = HSMP_STATUS_NOT_READY; - ret = amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_WR); + ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_WR); if (ret) { pr_err("Error %d clearing mailbox status register\n", ret); return ret; @@ -73,8 +62,8 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms index = 0; /* Write any message arguments */ while (index < msg->num_args) { - ret = amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2), - &msg->args[index], HSMP_WR); + ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2), + &msg->args[index], HSMP_WR); if (ret) { pr_err("Error %d writing message argument %d\n", ret, index); return ret; @@ -83,7 +72,7 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms } /* Write the message ID which starts the operation */ - ret = amd_hsmp_rdwr(sock, mbinfo->msg_id_off, &msg->msg_id, HSMP_WR); + ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_id_off, &msg->msg_id, HSMP_WR); if (ret) { pr_err("Error %d writing message ID %u\n", ret, msg->msg_id); return ret; @@ -100,7 +89,7 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms timeout = jiffies + msecs_to_jiffies(HSMP_MSG_TIMEOUT); while (time_before(jiffies, timeout)) { - ret = amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_RD); + ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_RD); if (ret) { pr_err("Error %d reading mailbox status\n", ret); return ret; @@ -135,8 +124,8 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms */ index = 0; while (index < msg->response_sz) { - ret = amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2), - &msg->args[index], HSMP_RD); + ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2), + &msg->args[index], HSMP_RD); if (ret) { pr_err("Error %d reading response %u for message ID:%u\n", ret, index, msg->msg_id); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index a77887d298b6..5d4fc7735a87 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -41,6 +41,7 @@ struct hsmp_socket { struct pci_dev *root; struct device *dev; u16 sock_ind; + int (*amd_hsmp_rdwr)(struct hsmp_socket *sock, u32 off, u32 *val, bool rw); }; struct hsmp_plat_device { @@ -48,19 +49,14 @@ struct hsmp_plat_device { struct hsmp_socket *sock; u32 proto_ver; u16 num_sockets; - bool is_acpi_device; bool is_probed; }; extern struct hsmp_plat_device hsmp_pdev; -int init_acpi(struct device *dev); ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count); -int hsmp_create_acpi_sysfs_if(struct device *dev); -int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write); int hsmp_cache_proto_ver(u16 sock_ind); long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, @@ -68,6 +64,4 @@ umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, int hsmp_create_attr_list(struct attribute_group *attr_grp, struct device *dev, u16 sock_ind); int hsmp_test(u16 sock_ind, u32 value); -void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index c297540bb64c..3bce2c570f2b 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -13,15 +13,13 @@ #include -#include #include #include #include #include #define DRIVER_NAME "amd_hsmp" -#define DRIVER_VERSION "2.2" -#define ACPI_HSMP_DEVICE_HID "AMDI0097" +#define DRIVER_VERSION "2.3" /* * To access specific HSMP mailbox register, s/w writes the SMN address of HSMP mailbox @@ -37,8 +35,8 @@ #define HSMP_INDEX_REG 0xc4 #define HSMP_DATA_REG 0xc8 -int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write) +static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, + u32 *value, bool write) { int ret; @@ -113,6 +111,7 @@ static int init_platform_device(struct device *dev) sock->sock_ind = i; sock->dev = dev; sock->mbinfo.base_addr = SMN_HSMP_BASE; + sock->amd_hsmp_rdwr = amd_hsmp_pci_rdwr; /* * This is a transitional change from non-ACPI to ACPI, only @@ -146,89 +145,39 @@ static int init_platform_device(struct device *dev) return 0; } -static const struct acpi_device_id amd_hsmp_acpi_ids[] = { - {ACPI_HSMP_DEVICE_HID, 0}, - {} -}; -MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); - -static bool check_acpi_support(struct device *dev) -{ - struct acpi_device *adev = ACPI_COMPANION(dev); - - if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) - return true; - - return false; -} - static int hsmp_pltdrv_probe(struct platform_device *pdev) { int ret; - /* - * On ACPI supported BIOS, there is an ACPI HSMP device added for - * each socket, so the per socket probing, but the memory allocated for - * sockets should be contiguous to access it as an array, - * Hence allocate memory for all the sockets at once instead of allocating - * on each probe. - */ - if (!hsmp_pdev.is_probed) { - hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, - sizeof(*hsmp_pdev.sock), - GFP_KERNEL); - if (!hsmp_pdev.sock) - return -ENOMEM; - } + hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, + sizeof(*hsmp_pdev.sock), + GFP_KERNEL); + if (!hsmp_pdev.sock) + return -ENOMEM; - if (check_acpi_support(&pdev->dev)) { - ret = init_acpi(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); - return ret; - } - ret = hsmp_create_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - } else { - ret = init_platform_device(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); - return ret; - } - ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + ret = init_platform_device(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); + return ret; } - if (!hsmp_pdev.is_probed) { - hsmp_pdev.mdev.name = HSMP_CDEV_NAME; - hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; - hsmp_pdev.mdev.fops = &hsmp_fops; - hsmp_pdev.mdev.parent = &pdev->dev; - hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; - hsmp_pdev.mdev.mode = 0644; - - ret = misc_register(&hsmp_pdev.mdev); - if (ret) - return ret; + ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - hsmp_pdev.is_probed = true; - } + hsmp_pdev.mdev.name = HSMP_CDEV_NAME; + hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; + hsmp_pdev.mdev.fops = &hsmp_fops; + hsmp_pdev.mdev.parent = &pdev->dev; + hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; + hsmp_pdev.mdev.mode = 0644; - return 0; + return misc_register(&hsmp_pdev.mdev); } static void hsmp_pltdrv_remove(struct platform_device *pdev) { - /* - * We register only one misc_device even on multi socket system. - * So, deregister should happen only once. - */ - if (hsmp_pdev.is_probed) { - misc_deregister(&hsmp_pdev.mdev); - hsmp_pdev.is_probed = false; - } + misc_deregister(&hsmp_pdev.mdev); } static struct platform_driver amd_hsmp_driver = { @@ -236,7 +185,6 @@ static struct platform_driver amd_hsmp_driver = { .remove_new = hsmp_pltdrv_remove, .driver = { .name = DRIVER_NAME, - .acpi_match_table = amd_hsmp_acpi_ids, }, }; @@ -295,6 +243,12 @@ static int __init hsmp_plt_init(void) { int ret = -ENODEV; + if (!legacy_hsmp_support()) { + pr_info("HSMP is not supported on Family:%x model:%x\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + return ret; + } + /* * amd_nb_num() returns number of SMN/DF interfaces present in the system * if we have N SMN/DF interfaces that ideally means N sockets @@ -307,19 +261,9 @@ static int __init hsmp_plt_init(void) if (ret) return ret; - if (!hsmp_pdev.is_acpi_device) { - if (legacy_hsmp_support()) { - /* Not ACPI device, but supports HSMP, register a plat_dev */ - ret = hsmp_plat_dev_register(); - } else { - /* Not ACPI, Does not support HSMP */ - pr_info("HSMP is not supported on Family:%x model:%x\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - ret = -ENODEV; - } - if (ret) - platform_driver_unregister(&amd_hsmp_driver); - } + ret = hsmp_plat_dev_register(); + if (ret) + platform_driver_unregister(&amd_hsmp_driver); return ret; } From patchwork Sat Jul 20 17:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737872 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2076.outbound.protection.outlook.com [40.107.237.76]) (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 76382146A8D for ; Sat, 20 Jul 2024 17:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497603; cv=fail; b=D0xShTb/Avd1xoIatx7I24nzc4hzJ1LlCxxZCTBmChm5Rhxqac4Ero/OeXPyMfM9AtFjEANnodm6UiqRoyTJHiRbOaDiggJiFf+Ea9H6Sg7WCm8fU2AY+/8mXsWOWHP3fDqsQxrghPAld8mtKQ91IOnAyAcbssYj63PrcKCJYxg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497603; c=relaxed/simple; bh=HSBCvPnXh2EoHVDb1dWdcKKsosO9PHpvViJ/R0z4rJA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OO5do7ORcwOl1LZZFa33wXMTXN/0U1aYFdhVTsWrIV5ZjWzAX8XEtAEBVGxXYmdNxMb92MTqnAyCCc6Mpfgq1qJbaaNu25UBW0QYKsLzPj4aV381eisO526VClVf7jQNgR+lqvK9e3VjvNDecixmIbG73qUy1eOMJDlPL1+XvYQ= 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=JppfK3ta; arc=fail smtp.client-ip=40.107.237.76 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="JppfK3ta" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b2LSZW0rigXadFqJGWTExLWvnAdb9RHyzCPA5EBLeJsjkvXz0O1lep4YObX5d6pie4wSfpBMCKNe8xGAHkp31mcZ/zbSYlZN6gM0f8vi4iqv+2CGDo70B3KxAozdLfHTJ9t7C3h02TXFXVrgd7yUuMHz3s6AGIeF7CpEmzoEhSgJC8Tz/VyVd2PfaWGiEP3Gl7tBFh7az+mRT+1pYpmW1CDBGV3caIb5CP7I3MllOJ59T1cYFkrPtyQhoSC5dXXV+TrDyxGoGWYUQgPW81tQRV1iozWx6Z9UISrafPsr8u2wcMiqefEIGQQIAjDlQX585FSBn4csqbGuVIg9HRwWBQ== 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=SN+2dmDZqdPSac36SNSg35RhKDtYUt3CdztZ+HIeUDc=; b=BjDr8/1V9Q7TMxE19tx6GXXufQUaaoD//1veFrZMrbQznSlM1vD1lJ768IuRuX/Qe/LGur7bbvIgFBiFxpD3vHfPdqYb1VmSh8gbQkMG119jWjIx/aqeq2ejnCGKhorxScQGHdqG+xPI5kV9EXjTpSM6kgJQ7Xy5wHART40wHT+kmE6mwB9quRJ6QvV4IdKhDGveeuYWPMn+nXYD3LOORmG8apPiAUs5QFd8M1ZT9CAtF6tFOoRaO1MHAu7AiStaVCVND7F7ZZqK+Ft5x2XXhwBSimZ7ll4pL7Um7qHuaZQ9Y5/xE3nPq6c/NgzmFo1iLY/EO6SM4zJC+MqqhIO2Jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=SN+2dmDZqdPSac36SNSg35RhKDtYUt3CdztZ+HIeUDc=; b=JppfK3tamnK/wY7dANSwwKQvfR9w/KW0s3HszbcOD9flTZf5y2/M3ZsFbLAK3E04MXR1jxC3mGAMhvMGceh530ZeJaAk72uoU3xI1XgcvYXi1EV1sFQH6dJSt/dwmB1wO8fbv6M2x0tbgJ31/Xc2yOehScKy6xrC7f3ItcLT9+c= Received: from DS7PR03CA0326.namprd03.prod.outlook.com (2603:10b6:8:2b::28) by CY5PR12MB6250.namprd12.prod.outlook.com (2603:10b6:930:22::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.17; Sat, 20 Jul 2024 17:46:38 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:8:2b:cafe::bd) by DS7PR03CA0326.outlook.office365.com (2603:10b6:8:2b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.19 via Frontend Transport; Sat, 20 Jul 2024 17:46:38 +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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:38 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:36 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 08/11] platform/x86/amd/hsmp: Use name space while exporting module symbols Date: Sat, 20 Jul 2024 17:45:49 +0000 Message-ID: <20240720174552.946255-8-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF0001708E:EE_|CY5PR12MB6250:EE_ X-MS-Office365-Filtering-Correlation-Id: 457dda5f-3280-4af2-4c06-08dca8e3e83f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: fjkaj8zVd0UyoWy+4dYYdFI+kQ3L8sAI8zBt+7UWZnInNH+l/mEVptAG0mxqYLjf5yKuQbkmhFMY2xmBIAUXc3PjBtLCTmOibDNCJIw85cWH7Co+lR/KofFrq8/IR1mV0oTnVaO2Ur8sfZkUQMV3ug6vzNtGRSDUca/eX/exUKXL0w6Nk0EAAWtLCgU/4oJ8VzrVH/E4uEq0NkNEMMeVTS2C5g2h2SJSGdmkiQtcfuaQUg9KT4fBdtFvpqbicG3RHzh5Du2bziOYYlxbn/EMxKvC0NsEAv0dgr1LJqO7oWkDJOqDupfquZgCJLVq/kOy4+zSeovgV4qA+T7Wb/6zarwXFoNd9o28Xi3fY55qSWj6h4z55vaZyDTkPwkQknkeHlmspjN6avlvsSqF6OL5CILeKxrzUFpAXP6I/osFqxTuZjZd43bDG1vobgUbjyYwHPIIEDvNFNGCiUZNPxpDdA7sDtExwFYPEZ/+ilS6QOncLGJt+R4iXPW1cfzriGRGaTio70AbK2RwnDBb2etL/NZPk/kldomLm3smjDWnUiySdafFwzRtJZwcvXeDT9qPnP2usTThHy2Hso80LihkN6m2j3pn0tMDziUsDfeV/N+mqXfggyEvQ+N4ciyLhIzGhkPWyGSeDppBBQ4z9EchJN6LusrIXfBU1/jNNlqtMYw1bR0+qLS8bth4HhIuT78MORJKjoKKdvPP1C7sSG2e8OdfaJDbRvhXS+iZmw9HBCi/Rrp5UkTKtN+GIjjfCr3RIBXqwRStX4uw3h+ufwnGUKkhLBZevCrn2ujkOukyWcfdYR6KSeg/Vh/3tqRducP0C5eGAlx0HVLlBsABuWwvPkfyalY43jdTN/lMZ24PO440G9wOZnbBzR7Hi6GBvugo/EtKNcH/vudWC+mxJuc998aMUEb7AkwBsToGYRJ9YOuYRVhOTpMz31v9tT9QY3UU1r8n4gomNuslLKtNmaY6OS1pVrBx5Ls5BtgULhPhvFY5AtLl9QLDwWTB33/GfmgM0PNbNI4fYUqjEKwYo/KHtHkbLmJiJ/rD6XUwHzkjSHO2Fl5YYdKx3WJHeRMLTuzmFErhwHj/FJ4SXJM/pEe1rc/3Rq5AkLeUFWrt5XiCQwY7gT8wEyNKsLgpQRnrJ4w7l2vOy+4efJcVZYXHZSaciULyH/Yhf5g1RSX9zo9suyX18VUVol/52mbsNjU/JGbRtZIU6q9IQ1AStOqmUlh1CT13gGGCTbLxxvHVY67hE9oGMt/E2jx6PDJtl68DGsCP8+euwD3RQ95Xr1bIDCWU6L77HZ/EKHMs1vmwQNi8t/XD2w9k2YulXizx+OvMtnjdGDTtGRPB4iSN2RkN3tyIlXu1x50rM3GV/24Q3f7rGaUvRuaZ7GwFjXvsfKzi5G3/ADdSoP38+PEwzGAqtPqluCiCW49tsPy1l7WTpwws2+1sXWQR2Kw8ijXx722xmIAR 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:38.6022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 457dda5f-3280-4af2-4c06-08dca8e3e83f 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6250 hsmp_send_message() is exported with AMD_HSMP name space. The other modules who would like to use this symbol, need to import AMD_HSMP namespace using MODULE_IMPORT_NS() to get away with warning. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: None Changes since v1: None drivers/platform/x86/amd/hsmp/hsmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 759ec1d4d60d..119a1f8895ca 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -186,7 +186,7 @@ int hsmp_send_message(struct hsmp_message *msg) return ret; } -EXPORT_SYMBOL_GPL(hsmp_send_message); +EXPORT_SYMBOL_NS_GPL(hsmp_send_message, AMD_HSMP); int hsmp_test(u16 sock_ind, u32 value) { From patchwork Sat Jul 20 17:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737873 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) (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 339E5146A8D for ; Sat, 20 Jul 2024 17:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497607; cv=fail; b=LpCkkMdp4Lz0y8lkTv1oMx8hIVZbT87u1q6hlwKs7F3kab0p/U75tFmfTqkesBXf4XCAzO/Sj+Nj8NPOLzcmPBm5eXfT31wbUuEfmB8aAkwjGqpUWPEMtCCzXuJtLFN8ryhJhzJGmnErSlAoSR85wJoUd9iUb55rV1/bnyyQbZA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497607; c=relaxed/simple; bh=V1atZGi9gg5EZSwO8s8VbLOZuX86+NYQutuWxuoIFNE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AGmpK1B/F08AMnl5GvqpWNKZ3AfqThM7ofqNFzqcX2c4tsyKUDp5S/CyA7brMqg2Dx3kIwUHQU9Au3DI/KtHrZVz4HK5zD6+/qeAWCi7eou1cA8lcdp0MHsHuFbAJlrnqWIQOqGsWGZd2IgmUxxzbq5m30yYqrUHzbC29eHyaBk= 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=u305X1y0; arc=fail smtp.client-ip=40.107.92.52 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="u305X1y0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GMByCyD/2TxsK6VEmYn56PyxA50k/hvBjaSlEqOYmF36AOP3N1PaY/gDI2u56bAHpOnNtp4XXeX0IbSE0oJDDhYC0kWICDOQWTVYsbLvy7/nr+hix2dOprBi+j3Vm2TyITMhK9psHTqNld38MKmp6kc7lyOut/MX0d33B7O2rqeQRw8tBeGRWCIPCgztVkHniwpc+Yp+grEWtPBaTVNS1GBOHPhZrdWNFutmWo9NilFO702zBOCwo0C6CTwIOq065SNDhUpLoiZ9bq/GUsdmEk2AR1p4PCHG55JWszFLeuOlptJVu0C2Q7S8jaTVzoCg49Jy19vqHNazTay3dqLnWA== 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=ubH0sVXjEg9a9Chq9GizBuBEaahpQGGvYJxoE4FsiNo=; b=dlhjIbIvkyU4mD4ER6ljc008ZrfKQzA+cy7mklWyzKplV+U6/eQvgC1QEXBzW9MP0oxemOe/IV1/sv3PqMTBlgJGVyh+ecqjGTOpJ1S0Mi5Z9SFtxAFpFp6PBNjS39mdvF7SofDVEgz1lk5NlRvKxokxfPvI00/Tsm6ofGIW6TDbQLs3NuK7q7CMpuus9tfB5GoT7+xe3mC9PWZ1fT8OxBNl26HMQdgyWgwePGibsCE8/YJfb4OWMgtBZ2WfabITVEC0AJZO5Ufvbw/Fvs5yCL6RF0BmXH/EaxLqRDiu3rh9XkdVETB6KrF3roB0evL0PaabbmrtpdcBZF+QOwsw+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=ubH0sVXjEg9a9Chq9GizBuBEaahpQGGvYJxoE4FsiNo=; b=u305X1y0eT9ipAM+Rfb5cC+I5jO9tCZm5t5ziJaDYCSnTe+Jke6kTcv4D3jJZXgJWLShG2qnf1Jnf1tjajBQcKHeDw2eGALigfk+rdr5gthxt4U8U/8VEuj38Qf33sFjIcuCTgfO4ZptUM/xE99kLSPUubOtPnX9L1Lbs/GchY0= Received: from DM5PR07CA0075.namprd07.prod.outlook.com (2603:10b6:4:ad::40) by CH3PR12MB8849.namprd12.prod.outlook.com (2603:10b6:610:178::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Sat, 20 Jul 2024 17:46:40 +0000 Received: from DS1PEPF00017090.namprd03.prod.outlook.com (2603:10b6:4:ad:cafe::4e) by DM5PR07CA0075.outlook.office365.com (2603:10b6:4:ad::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017090.mail.protection.outlook.com (10.167.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:40 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:38 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 09/11] platform/x86/amd/hsmp: Move read() and is_bin_visible() to respective files Date: Sat, 20 Jul 2024 17:45:50 +0000 Message-ID: <20240720174552.946255-9-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017090:EE_|CH3PR12MB8849:EE_ X-MS-Office365-Filtering-Correlation-Id: b57c7c57-4c3a-4d61-12db-08dca8e3e968 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: uAkLGvkG/oIJDpFP2PRTwnYRpPMyHE3i02HJkHbk+BY0I+8Tx3zcFKzFaClgCqjnRxN0GSHUfbxd8nUw8ziWSX7vUxqDbUTDnnXZGwsXsRbJUcxJFeWsQFjeO/ZPN+kAvdKHziqa+ECPdDo5pHr7oWqx6GS4VJJsOaOo0q499xeJYVWtbCtVKNL3MrmAVzJ5WpWD8ZViQJKuqnLUkeWQbBtbEIOKYosZLOGytukKAkEr6PpEctGPrr8npkkrgZWomnFoGzS+tSbIdHfJ8NbdOtrd+WmTk8Ni1X8mCuzYNUj3frk8FY98mLwEe/rlEfsdeY6g/G25dfMi7s2XYBRe121FBruvc79PWolt86BAQYmyRnzElZu3LjjRJAsoPO/DNsl6vR48wEGk46/bM5jI/zzJXUNNJ7RnBNImqEZ2TOPGojFl9PhVjKASslOmNQJTg7vXs+xAGDsCJ5vZXrqmA1jgITSgBVAZ3BlVPxwHC6gn8Z79GnVbiIzsbF4fbMJ9w+m5YmAm/9E2QtSwmQcvW71eodiWKV0CYuylR0I7xBH3BAIfLBW/BLpOVAIsfNhbDBgekBeyCn92oTgya+mQIEV3PQChE+u1/KPBH3YaMAXKKDzMo0JUiZh4pH57haBTp6a6lNkcATglDOfJ5sgtT3Fzahk+3qDLKk6zbl6neZU/51b8fvhJ1w8dBYGE97/IZPgxO2ZiAFk8nPS5ONNiBlHvWaO21dt2PHJ2OSipzYsnLsCO/1lZEZzMZG4lhRrS5v+puvyZhkYPNRrIxvxfzdJ595hpMyQfFQpCkbsoSkNQQxJg8xLt1fe4r7fm8KWsZhF7MJBCzZgzoLmmvAM0VWnreYLIYYyZZHBYuf0cK8HXPK0K7ITi0UszVJXxFob5lfT0N/JOCzZhYexTyT2TkInleKdQLam68Ftk4GKn4dIDFZ2rLhirx04+2bky5M6SBx5OEDnIRXjK1g4JA+E3vCnV61Id3SEFHM0PKX8BaYeuccLLGXNzK0ii3guI5EmskbqK+YVjIoJxrCJVP4S5Yi1jpVcIlhtqG3pcLWGrBjdhxVPjReMHK1Ftd5PrXyzTzDRJSkTgVRRLohkSpqpSkU5a/M1eSOw3HFWXhyRqMNoLXxEQRBHEIBro81OZQZdoy1IhddddVTf0rDbWlbLky0ERWvalHmuxRFZZkADs6dbxbGnUDJ+WnsHdmKetimfbNgUbI4mNMjJ29QsfClaokcMFcSOLCvzpr2rDWCUS145ffgEOzss+drWlnVep8cMiF0vbptJ9hxL+ZZga7Fw7MpM293YSgYg3WMiEPH2pp09Cf8dt2l/l0B6lUczGi6GjA2ihKo6YXYNo5L3jYBg4nLbaWKUKvqI0VlT4kt8Yod6cbClRn+8OKhh0XQuPHpvulk1zNVtet8PD38XaivPyRLVYtVSMlOiOz+zgsbLEI8JChjtRpuz+itUTnal1vjhj 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)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:40.5628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b57c7c57-4c3a-4d61-12db-08dca8e3e968 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: DS1PEPF00017090.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8849 The .read() and .is_bin_visibile() need to be handled differently in acpi and platform drivers, due to the way the sysfs files are created. This is in preparation to using .dev_groups instead of dynamic sysfs creation. The sysfs at this point is not functional, it will be enabled in the next patch. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: None Changes since v1: 1. Change is_visible to is_bin_visible in commit message 1. Add parenthesis around read and is_bin_visible in commit message 2. Change plat_dev to hsmp_pdev, hsmp_device to mdev 3. Remove unnecessary if, else conditions in hsmp_is_sock_attr_visible 4. Change un cached to un-cached drivers/platform/x86/amd/hsmp/acpi.c | 41 ++++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 37 ------------------ drivers/platform/x86/amd/hsmp/plat.c | 57 ++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 37 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 86100943aadc..7cb38c8dc627 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -11,6 +11,7 @@ #include "hsmp.h" +#include #include #include @@ -214,6 +215,8 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) sema_init(&sock->hsmp_sem, 1); + dev_set_drvdata(dev, sock); + /* Read MP1 base address from CRS method */ ret = hsmp_read_acpi_crs(sock); if (ret) @@ -246,6 +249,44 @@ static int hsmp_create_acpi_sysfs_if(struct device *dev) return devm_device_add_group(dev, attr_grp); } +ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct hsmp_socket *sock = dev_get_drvdata(dev); + struct hsmp_message msg = { 0 }; + int ret; + + if (!sock) + return -EINVAL; + + /* Do not support lseek(), reads entire metric table */ + if (count < bin_attr->size) { + dev_err(sock->dev, "Wrong buffer size\n"); + return -EINVAL; + } + + msg.msg_id = HSMP_GET_METRIC_TABLE; + msg.sock_ind = sock->sock_ind; + + ret = hsmp_send_message(&msg); + if (ret) + return ret; + memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size); + + return bin_attr->size; +} + +umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) +{ + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) + return battr->attr.mode; + + return 0; +} + static int init_acpi(struct device *dev) { u16 sock_ind; diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 119a1f8895ca..c906723ae2f2 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -274,34 +274,6 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return 0; } -ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) -{ - struct hsmp_socket *sock = bin_attr->private; - struct hsmp_message msg = { 0 }; - int ret; - - if (!sock) - return -EINVAL; - - /* Do not support lseek(), reads entire metric table */ - if (count < bin_attr->size) { - dev_err(sock->dev, "Wrong buffer size\n"); - return -EINVAL; - } - - msg.msg_id = HSMP_GET_METRIC_TABLE; - msg.sock_ind = sock->sock_ind; - - ret = hsmp_send_message(&msg); - if (ret) - return ret; - memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size); - - return bin_attr->size; -} - static int hsmp_get_tbl_dram_base(u16 sock_ind) { struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; @@ -335,15 +307,6 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind) return 0; } -umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - struct bin_attribute *battr, int id) -{ - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) - return battr->attr.mode; - else - return 0; -} - static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock_ind) { struct bin_attribute *hattr = &hsmp_pdev.sock[sock_ind].hsmp_attr; diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index 3bce2c570f2b..c2b83363713f 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -11,6 +11,7 @@ #include "hsmp.h" +#include #include #include @@ -90,6 +91,62 @@ static int hsmp_create_non_acpi_sysfs_if(struct device *dev) return device_add_groups(dev, hsmp_attr_grps); } +ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) +{ + struct hsmp_message msg = { 0 }; + struct hsmp_socket *sock; + u8 sock_ind; + int ret; + + ret = kstrtou8(bin_attr->private, 10, &sock_ind); + if (ret) + return ret; + + if (sock_ind >= hsmp_pdev.num_sockets) + return -EINVAL; + + sock = &hsmp_pdev.sock[sock_ind]; + if (!sock) + return -EINVAL; + + /* Do not support lseek(), reads entire metric table */ + if (count < bin_attr->size) { + dev_err(sock->dev, "Wrong buffer size\n"); + return -EINVAL; + } + + msg.msg_id = HSMP_GET_METRIC_TABLE; + msg.sock_ind = sock_ind; + + ret = hsmp_send_message(&msg); + if (ret) + return ret; + memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size); + + return bin_attr->size; +} + +umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) +{ + u8 sock_ind; + int ret; + + ret = kstrtou8(battr->private, 10, &sock_ind); + if (ret) + return ret; + + if (id == 0 && sock_ind >= hsmp_pdev.num_sockets) + return SYSFS_GROUP_INVISIBLE; + + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) + return battr->attr.mode; + + return 0; +} + static inline bool is_f1a_m0h(void) { if (boot_cpu_data.x86 == 0x1A && boot_cpu_data.x86_model <= 0x0F) From patchwork Sat Jul 20 17:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737874 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2052.outbound.protection.outlook.com [40.107.243.52]) (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 A95CC147C80 for ; Sat, 20 Jul 2024 17:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497608; cv=fail; b=nTyGGt2tknuX/dW6IvIj4KvZq2Nmx3idgApEOWuhFByc/YN6tV1qe56cF4DUr7Lt+I58AloTPVph2Iyj5SrtaDjEuLj+Vo+321kXf+PzQ68yOKIBwFK7oXv4RojjJaiRmGA2Y/uaVIHDQJwVHS9gqlWTS8fgLJ+61R7kRZw115Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497608; c=relaxed/simple; bh=xL0o4Z8F4eXMXRhm60AsIRpUdNHXypQd+YE2rshj3cM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FKKTXmb9gkOKVhpC5hCeLx0kbzsmrR96cdzvQLHlQyFOIYjHbSKG18d7ZxiJZ2KV6v5WBNwoqKsU00aghqrlxTqOCGiAEHO7j4V6VIxc9n2OI6b4m0qVuZE2X/DscTO0rl1bd6he+c3myBF+cYv/YQc1k5KMwr/refU3J8HsEX0= 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=R3aGNJ56; arc=fail smtp.client-ip=40.107.243.52 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="R3aGNJ56" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bBZAJVPgL/pCpslcDO0qJSJSvB/qCzKneuwviO7i9X9tdhGHMpMNY4aRClEL3RoyHtvkKOpYKDo7twMd3DLRl+MXRRtcpHY7d4XNe1krbio6Oap/Tu5pIw+qcDWP/bRLFMG9xyvdgYvx9W/Ask2dPSDj+Cf4DEJA40Hw80r7dwlNxBQcX9TuV6E6y8o0jkOrLZNGYuDPnxmLL3F+ZgT3IbtBpPacn8RlWiA69V77hcXKMvOXlbcFQxC1gOTNY1ZxqCt4FbKE+XRxWPu0AGQU6E1zLVVzPc7AqQTeqUyg5QGn2H4yEEw6JOAK5/XVsexgHjLnOgarvVw2cFBI1ESG3w== 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=v/qUZOYVEJ7YVj9yIxSL9whPjninKP3eLKerwMYMWVc=; b=fj+QsvqzQuptrEFkUGex0nD10Y9O3+z/OkKR7RZTK5VbwMjcswn3FFywxNhNdp/3JjBRFH+1cp5tkKVPO6WBdBXNEbyX/bMpxN/3GEuA9sI8K6/f2xqdPsFV4jx8DJroofJ0PJrRMg2HDbCBvQy9EyxjryWGaHVKkqprjKOK06ZqSXx3xb+val2mlNCBOfQpl/t6ckRs/4gc6H3Uj2M9MVZkfIyh8Ilb1WZVA8pXP4swUnnx4KInz1kvrSjNos9kvdDU/2geRPZY9nnbBfpDRKK40sF4CVesL5e9c6yz1QIF5tD/FEZVPsuxjse4rY9BbrmJ7y5SSOy20oVydL9pAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=v/qUZOYVEJ7YVj9yIxSL9whPjninKP3eLKerwMYMWVc=; b=R3aGNJ56DaILMCS57G2IbGXTOrrbP6uM86bUdCPozeQskk5eRiixFYnV9Oh2p2qZsnanQ3X50HmosYV4DBOcs5V2yU5Ua+dPakZUvaOASxNhl71CSS+FsA7FYCLsmEUsilB4czwwgwmbSh9o7h/GE2db2K9bVgy+6azgRhJEgjc= Received: from DM6PR07CA0100.namprd07.prod.outlook.com (2603:10b6:5:337::33) by CY5PR12MB6453.namprd12.prod.outlook.com (2603:10b6:930:37::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Sat, 20 Jul 2024 17:46:42 +0000 Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:5:337:cafe::66) by DM6PR07CA0100.outlook.office365.com (2603:10b6:5:337::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46:42 +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 DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:42 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:40 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 10/11] platform/x86/amd/hsmp: Use dev_groups in the driver structure Date: Sat, 20 Jul 2024 17:45:51 +0000 Message-ID: <20240720174552.946255-10-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017094:EE_|CY5PR12MB6453:EE_ X-MS-Office365-Filtering-Correlation-Id: 48b30b46-9c33-42f5-4694-08dca8e3ea94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: 2f6mGhWx6e8Xy6sNmgXyTTuTUU0NCWxaHSO+osru6v8rORG7Fo2VfhEavcOT+9iUAlzbsvDBhZfQ7shjp6Bv0fFLhJZ0uQSlsO6uNeOessc3Xcs6ZhI1ijKoea39ajNJrRSOluvofoRY4Fr/VKjDjK5FM0BGTygpISyE5QzxIK5/7i0QBTaXeUw4CRuKMo/QsAiAJzSL7Htnua8xdPu7EeONLpsFbv7P+T+EdgXEsnzK6/DyiUfZswlhVsN/xO8aP1T/GIUGRXeb7nocFAAheA7tu0sXXWk+SYnvUTx1JuAb0/FkvoPt+g5VBJWIr4pnyy4FvIooTu+nmWZuJPBoIOkrPgmFvJEhees5Eopfj8gr5BMvNCtviJKZqz2820AQRoSp0IXX02SCTkKO8BpxCilzqsQz0k+Xyc5fyVKjiYUwdfgIe3hJIcvtrgBNku00XEspsOIt9CVpLNnkerDmimAOIvruotJ0QHQHrT8J311+U+77yu9l7Kna/CTVjjIulRlO0/x+MazJFl12sHZJ2DeO1kHWRl6A1joFmhHm7DXi9prTmZkYL2bLcz4ThOlCACjcVajXrLQ8Ym8mt4oYtBeogrJq/xrCuBLlng1WMoQFAoXErG8Rb7wGkn9QndBI+yFT6s2xCWvGoxIckvW5rNUuLqZOd/HHfftB9XIEPiV8geUlHvfVf0BQDpMDtdfReUzVEvKn2bD5e+SFLEBAB2C0lhVvfxggz5x3JEVAB2OryNO3UyA+EScesiMYHuQAS7JVNAM5dIiMOmcQOLwhashZHX9ugcSxBp+xqPkhVKcUC/PHGiMwH+m6fAX3NYXSltkZbp84iy79vlKa3qTEl3qYnX42kHj3wzJXtwqTi/c80sct93afZEZl9pN4Jh9DbNADcvNQY0HWoVvleHfcGtkGP3E5MWixjYruURTsLOxt9h1HSVul25qqlQ7+Iqisn5A69VxT0ZlLdFFbJ8ycNoh0Y79NNXwjf1ornIIGnK3Ch7lG6PftpbIu4Gh3QBpkklgubGcjDEdN5ravvEeDI9vggEKohGy2RTKFO/dzGB6cukA0OQT68aP3W2c1hxW7hrRYkFZ2vTqYpA/wGlFgA29NFq0FOBVq+UUlkSvSiYd48cGDWDAZI7rjvncQRZle5yLCQGGuxFdvL1dImUo8RX7GNXGzkKMjY7z1ulalVQDAmp5M9P0SzK/Wo9RyVBp5OSMRMiG0EQePYdpzGA9lutwjfThnC2U3KFxBu4AzMuyDKUaFRw5JDUb+oCAZcD8PaKiNQxs89OC29yugOteIxAN7adUaZgELyxfuMyZxqe8aZG3o589jXFniYYHrrgiPp5D8JgxunZHAmk+qTaALCXcME2wL6afdfA/7ipMHEGFz9dve70i5BYZ10sd9XHAC+dSBY/4ecCLcf4iajXxaQuiH+nR6u89uakmWMD0REDI+aqyM/NnLLu8P3g0ZNGWj 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:42.5302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48b30b46-9c33-42f5-4694-08dca8e3ea94 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: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6453 Move out of device_add_group() variants, instead assign static array of attribute groups to .dev_groups in platform_driver structure. Then use is_visible to enable only the necessary files on the platform. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: None Changes since v1: Change plat_dev to hsmp_pdev drivers/platform/x86/amd/hsmp/acpi.c | 65 ++++++++-------- drivers/platform/x86/amd/hsmp/hsmp.c | 40 +--------- drivers/platform/x86/amd/hsmp/hsmp.h | 8 +- drivers/platform/x86/amd/hsmp/plat.c | 106 +++++++++++++++++---------- 4 files changed, 102 insertions(+), 117 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 7cb38c8dc627..4b1470ca8675 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -226,32 +226,9 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) return hsmp_read_acpi_dsd(sock); } -static int hsmp_create_acpi_sysfs_if(struct device *dev) -{ - struct attribute_group *attr_grp; - u16 sock_ind; - int ret; - - attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), GFP_KERNEL); - if (!attr_grp) - return -ENOMEM; - - attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; - - ret = hsmp_get_uid(dev, &sock_ind); - if (ret) - return ret; - - ret = hsmp_create_attr_list(attr_grp, dev, sock_ind); - if (ret) - return ret; - - return devm_device_add_group(dev, attr_grp); -} - -ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) +static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { struct device *dev = container_of(kobj, struct device, kobj); struct hsmp_socket *sock = dev_get_drvdata(dev); @@ -278,8 +255,8 @@ ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, return bin_attr->size; } -umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - struct bin_attribute *battr, int id) +static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) { if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) return battr->attr.mode; @@ -319,9 +296,36 @@ static int init_acpi(struct device *dev) return ret; } + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) { + ret = hsmp_get_tbl_dram_base(sock_ind); + if (ret) + dev_err(dev, "Failed to init metric table\n"); + } + return ret; } +static struct bin_attribute hsmp_metric_tbl_attr = { + .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444}, + .read = hsmp_metric_tbl_read, + .size = sizeof(struct hsmp_metric_table), +}; + +static struct bin_attribute *hsmp_attr_list[] = { + &hsmp_metric_tbl_attr, + NULL +}; + +static struct attribute_group hsmp_attr_grp = { + .bin_attrs = hsmp_attr_list, + .is_bin_visible = hsmp_is_sock_attr_visible, +}; + +static const struct attribute_group *hsmp_groups[] = { + &hsmp_attr_grp, + NULL +}; + static const struct acpi_device_id amd_hsmp_acpi_ids[] = { {ACPI_HSMP_DEVICE_HID, 0}, {} @@ -365,10 +369,6 @@ static int hsmp_acpi_probe(struct platform_device *pdev) return ret; } - ret = hsmp_create_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - if (!hsmp_pdev.is_probed) { hsmp_pdev.mdev.name = HSMP_CDEV_NAME; hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; @@ -404,6 +404,7 @@ static struct platform_driver amd_hsmp_driver = { .driver = { .name = DRIVER_NAME, .acpi_match_table = amd_hsmp_acpi_ids, + .dev_groups = hsmp_groups, }, }; diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index c906723ae2f2..c382b494b9c7 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -274,7 +274,7 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return 0; } -static int hsmp_get_tbl_dram_base(u16 sock_ind) +int hsmp_get_tbl_dram_base(u16 sock_ind) { struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; struct hsmp_message msg = { 0 }; @@ -307,44 +307,6 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind) return 0; } -static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock_ind) -{ - struct bin_attribute *hattr = &hsmp_pdev.sock[sock_ind].hsmp_attr; - - sysfs_bin_attr_init(hattr); - hattr->attr.name = HSMP_METRICS_TABLE_NAME; - hattr->attr.mode = 0444; - hattr->read = hsmp_metric_tbl_read; - hattr->size = sizeof(struct hsmp_metric_table); - hattr->private = &hsmp_pdev.sock[sock_ind]; - hattrs[0] = hattr; - - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) - return hsmp_get_tbl_dram_base(sock_ind); - else - return 0; -} - -/* One bin sysfs for metrics table */ -#define NUM_HSMP_ATTRS 1 - -int hsmp_create_attr_list(struct attribute_group *attr_grp, - struct device *dev, u16 sock_ind) -{ - struct bin_attribute **hsmp_bin_attrs; - - /* Null terminated list of attributes */ - hsmp_bin_attrs = devm_kcalloc(dev, NUM_HSMP_ATTRS + 1, - sizeof(*hsmp_bin_attrs), - GFP_KERNEL); - if (!hsmp_bin_attrs) - return -ENOMEM; - - attr_grp->bin_attrs = hsmp_bin_attrs; - - return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind); -} - int hsmp_cache_proto_ver(u16 sock_ind) { struct hsmp_message msg = { 0 }; diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 5d4fc7735a87..b70f40c2726c 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -54,14 +54,8 @@ struct hsmp_plat_device { extern struct hsmp_plat_device hsmp_pdev; -ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count); int hsmp_cache_proto_ver(u16 sock_ind); long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); -umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - struct bin_attribute *battr, int id); -int hsmp_create_attr_list(struct attribute_group *attr_grp, - struct device *dev, u16 sock_ind); int hsmp_test(u16 sock_ind, u32 value); +int hsmp_get_tbl_dram_base(u16 sock_ind); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index c2b83363713f..33868346b5a0 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -61,39 +61,9 @@ static const struct file_operations hsmp_fops = { .compat_ioctl = hsmp_ioctl, }; -static int hsmp_create_non_acpi_sysfs_if(struct device *dev) -{ - const struct attribute_group **hsmp_attr_grps; - struct attribute_group *attr_grp; - u16 i; - - hsmp_attr_grps = devm_kcalloc(dev, hsmp_pdev.num_sockets + 1, - sizeof(*hsmp_attr_grps), - GFP_KERNEL); - if (!hsmp_attr_grps) - return -ENOMEM; - - /* Create a sysfs directory for each socket */ - for (i = 0; i < hsmp_pdev.num_sockets; i++) { - attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), - GFP_KERNEL); - if (!attr_grp) - return -ENOMEM; - - snprintf(hsmp_pdev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); - attr_grp->name = hsmp_pdev.sock[i].name; - attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; - hsmp_attr_grps[i] = attr_grp; - - hsmp_create_attr_list(attr_grp, dev, i); - } - - return device_add_groups(dev, hsmp_attr_grps); -} - -ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) +static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { struct hsmp_message msg = { 0 }; struct hsmp_socket *sock; @@ -128,8 +98,8 @@ ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, return bin_attr->size; } -umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - struct bin_attribute *battr, int id) +static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) { u8 sock_ind; int ret; @@ -147,6 +117,61 @@ umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, return 0; } +/* + * AMD supports maximum of 8 sockets in a system. + * Static array of 8 + 1(for NULL) elements is created below + * to create sysfs groups for sockets. + * is_bin_visible function is used to show / hide the necessary groups. + */ +#define HSMP_BIN_ATTR(index, _list) \ +static struct bin_attribute attr##index = { \ + .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444}, \ + .private = #index, \ + .read = hsmp_metric_tbl_read, \ + .size = sizeof(struct hsmp_metric_table), \ +}; \ +static struct bin_attribute _list[] = { \ + &attr##index, \ + NULL \ +} + +HSMP_BIN_ATTR(0, *sock0_attr_list); +HSMP_BIN_ATTR(1, *sock1_attr_list); +HSMP_BIN_ATTR(2, *sock2_attr_list); +HSMP_BIN_ATTR(3, *sock3_attr_list); +HSMP_BIN_ATTR(4, *sock4_attr_list); +HSMP_BIN_ATTR(5, *sock5_attr_list); +HSMP_BIN_ATTR(6, *sock6_attr_list); +HSMP_BIN_ATTR(7, *sock7_attr_list); + +#define HSMP_BIN_ATTR_GRP(index, _list, _name) \ +static struct attribute_group sock##index##_attr_grp = { \ + .bin_attrs = _list, \ + .is_bin_visible = hsmp_is_sock_attr_visible, \ + .name = #_name, \ +} + +HSMP_BIN_ATTR_GRP(0, sock0_attr_list, socket0); +HSMP_BIN_ATTR_GRP(1, sock1_attr_list, socket1); +HSMP_BIN_ATTR_GRP(2, sock2_attr_list, socket2); +HSMP_BIN_ATTR_GRP(3, sock3_attr_list, socket3); +HSMP_BIN_ATTR_GRP(4, sock4_attr_list, socket4); +HSMP_BIN_ATTR_GRP(5, sock5_attr_list, socket5); +HSMP_BIN_ATTR_GRP(6, sock6_attr_list, socket6); +HSMP_BIN_ATTR_GRP(7, sock7_attr_list, socket7); + +static const struct attribute_group *hsmp_groups[] = { + &sock0_attr_grp, + &sock1_attr_grp, + &sock2_attr_grp, + &sock3_attr_grp, + &sock4_attr_grp, + &sock5_attr_grp, + &sock6_attr_grp, + &sock7_attr_grp, + NULL +}; + static inline bool is_f1a_m0h(void) { if (boot_cpu_data.x86 == 0x1A && boot_cpu_data.x86_model <= 0x0F) @@ -197,6 +222,12 @@ static int init_platform_device(struct device *dev) dev_err(dev, "Failed to read HSMP protocol version\n"); return ret; } + + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) { + ret = hsmp_get_tbl_dram_base(i); + if (ret) + dev_err(dev, "Failed to init metric table\n"); + } } return 0; @@ -218,10 +249,6 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev) return ret; } - ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - hsmp_pdev.mdev.name = HSMP_CDEV_NAME; hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; hsmp_pdev.mdev.fops = &hsmp_fops; @@ -242,6 +269,7 @@ static struct platform_driver amd_hsmp_driver = { .remove_new = hsmp_pltdrv_remove, .driver = { .name = DRIVER_NAME, + .dev_groups = hsmp_groups, }, }; From patchwork Sat Jul 20 17:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13737875 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.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 E958D148311 for ; Sat, 20 Jul 2024 17:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497608; cv=fail; b=jkWyom4waxL+DWUqKJ78k17K218WkjBeC9xjTZ+hJwHc3z89euk9fZIVXnL4zcIHMVjcpdz9E4HyIp1r1oqo5ANsHDSZvKaDGGaonIJxjlFgIL75hrcsFmpRsx6tNYBhxbTglpZ6PivLqrLDkiAxRMFolMatSnD+d0sfJKJ7H40= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721497608; c=relaxed/simple; bh=mfU7ixi0isfXEJLUE+LKvtPFr1oTZm05L5SZiosfAy0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QJJeJZAupcV5RdzItvZJ9xyli5UVy/nEGLRRXmukWHFOrSxd1Il8uWbVzCZHAo7rLuIxs2Z3ZrK/4a73jpR1aT/zOTXtf27rUPJ3galtGPIBb9xEGxXuSA8jJz7H+1WjIP4bxWCpq3DfW9ClT2HyWsDTvb6vs6jgGFONPIes3+Q= 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=anMiinT9; arc=fail smtp.client-ip=40.107.94.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="anMiinT9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vTzVa3TFaECbEl3Cx20GxdBdaFLyYoVTgnHHQDvLcZuImYFA8HL2UPp2E3PXQJMUDbBcLwvbOsnmq8W/iEGhRs0gOg9XZnBSHy3TEGDLhWNzZjdjUiRyCr8DahoQhmzU/KFWM4nlqeNQ7GBdK1LTMiyJZy4Mp/8zdqCSYy2KqaXtKfDjc/Wem+1jKcu7zjloZzyTBSBN8K+SrIYrV2JKmPyWa/gndxA1coROqn+lMv2Bc/C/3gZvShJbs8FIpM9C5TP91GuKZb+huechaz99agu7ommBQAxhokj/kejEgrgvs8QCle/M4qg2QN77E4dYoKHEYKTR1ZBowPzmtqxepA== 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=RZNIBw9I5v4lJWd+QrIko9Lrwwz1WPAaHiiRMcnA1y4=; b=n4d6zHwUV/GAYsd1Dlt6YKl+dusESMY/jocNooyItKh8UL1ntxRvopKGQPxd2xZuJe0C/zvE9ehu4cpcEPN77mZGyUHF0pocyDfmTaH6FTS78iABmWb/2xNhlhpwjWUoks6yWguPybLvDWpJ+VKhs0L9Pa5ZiVVRFsj5IasKGmdIb/f71lj2Zo8bmgHngX+zO39cvXfnNZVZ6UGLPlq+lrhxDxyTyknGIGE1LFQwZj+Kl1twvK1rY3nIFYgw40xRGfRCHOpAFdaPFuVFP1LELmDOcYfRHs7M0IFV/T3itpb+gEa1of1BoPB6EcSsSS4DLR8/09L9BXNc2OcfDo/Auw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=RZNIBw9I5v4lJWd+QrIko9Lrwwz1WPAaHiiRMcnA1y4=; b=anMiinT93mT5j+yhS/oDBzYFOmLF0HA5TYhOKMVP8GQUf0wOEbu+Bg5OkPm5QlmYxVvirNNGHwj0a9GEfT/7lPlklm2D3BkJJ0RPTIPcSAygo6SK1Adohia+SA0UU8NDyXTtf+AT7iaD1zlB7WIFyGe+i+yVLB4kl3tCI5snprI= Received: from DM6PR01CA0019.prod.exchangelabs.com (2603:10b6:5:296::24) by LV2PR12MB5894.namprd12.prod.outlook.com (2603:10b6:408:174::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.18; Sat, 20 Jul 2024 17:46:44 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:296:cafe::93) by DM6PR01CA0019.outlook.office365.com (2603:10b6:5:296::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Sat, 20 Jul 2024 17:46: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Sat, 20 Jul 2024 17:46:44 +0000 Received: from amd.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; Sat, 20 Jul 2024 12:46:42 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v3 11/11] platform/x86/amd/hsmp: Fix potential spectre issue Date: Sat, 20 Jul 2024 17:45:52 +0000 Message-ID: <20240720174552.946255-11-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240720174552.946255-1-suma.hegde@amd.com> References: <20240720174552.946255-1-suma.hegde@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: DS1PEPF00017091:EE_|LV2PR12MB5894:EE_ X-MS-Office365-Filtering-Correlation-Id: 872aff71-8d94-48e4-3cd5-08dca8e3ebc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: +EY99bZUwZjmpVqzd9uUX8KWL4NcdAs3+nu4b3cCzODARqDGS/cHvl+58qeE7qrPmWNBCOrdBEIhnwWWwuVT21a4oHTXZCuS/bfq6UvJ3TnENFZNUO0jkiOqyPmOkOSvohA1ba7P2PGxjRYRH13X0TTYdZC1OZQlm28QB9Sp+A0Fte9AhqQEv/nRJ3lZGOWB69SEVrQVCqw2UxGC6ffiyZrwoo9SX+7v2ztmvPtN/GtnqkuU1pQZaaqMOZpJEq3g9HIfCwAV8ZzvTasWi2mp8wC8r04bbEDkP3oiwr5mwjxnZhe725p36F5AhBZfy/wsjy3lWkhM4HZVSHufBndztTbbqesAHcn/s3zjZoLBfKfS2V+TLBUvIvjRdNc8uIBUINrRzmaoA+IlI9x3YirXG2KBOtWSRFs4tLfhenqTGhnEf/9/FzZjD59UqtuuQLPPevHE6tK9CWfXgZfAaGMpZ8H2XRKPn+Z5b/cjptVGbsUG13fOcVGDLx59T0ji9GUg0SHGegCIoJmvlxRFIsOvwnKkcW59jxt8/gAGrSwHBcmEYh5GDoD5gXWKFE+LRpniXipsxCarKSTLK7DMdFzqajtdEQThptsAixiqq9/UChmgG5dUFWr0LELKLWV3Q+D+K+keI+FsZ0SPuWcl8ze8YpoulqcFPzREoKULgPxXDq5OxqLB2w1L/F7uC1nLpfiO50vJLOZilgXLAIy4qFdov0qXcrs8LDabGPUNSC1oXpwaVOxb+P2p4N1ZDLbQGRQI2dx3AaON+7jASsZNGJ+oFmB7KQdfQ07Qi81dGjG+xqLpa//Ldi1gxUvysKtebLORYdnUObZMLsNr8auUVm+cL/N5OEUQFFlli52eF5Sed0Rtx/qD9tLZgSPo3dsc2mucuVjNzz+xCcw0767CRo5Lzhumv2DdMktQnruYuGlZc/SIqUTbFh0/9jFF//T+gHCzgxU0qsNIQXhK68u81TMnai/S0M761BjKR3I/fytzqetKtzC7/N7UNuVGNCjdWj8JxLej2yP1pFOD/b2jun3jmraDgC5mJypXPxHQj5EJpt47RvN+tHJw8yiEVLjtddZR2WIfWQBvMUYHZ0rBh9ZRg1ET39zQIN0QkG7X6Z6otGIPeEJp2ofTWvPkPQRzMV41FOWwANyKxnA2n9OBa7/xlIKlYMhU1/hlOfyFvZiDIffRn/CpjlkJ4V6GtaQ66XievZYJsuB4/Vq340515xb5d43RfH1qfxsNHThqYbWIbGa6hhaHEoW1DSXSBLGq2g5V+0+3zDxiyztfK3w0vI2RYCYkD9ZYovtJBTKttQaPnn+7KxAwVkFOX4CsJc4nArf8j5omeXP5fhv5Urzk6KHKO3kSTjeNTmTUj4IuqzrIXSBkOTmxtmBxD72PtgHGxGT6cDy2mAbEspzgvYtcXCF284keeQABUBRMKKeIPW+7iKBXgpxzJv2uycNDQ6URT05O 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 17:46:44.5197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 872aff71-8d94-48e4-3cd5-08dca8e3ebc6 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5894 Fix below warning caused by smatch by using array_index_nospec() to clamp the index within the range. "warn: potential spectre issue 'plat_dev.sock' [r] (local cap)" Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v2: None Changes since v1: Change plat_dev to hsmp_pdev drivers/platform/x86/amd/hsmp/acpi.c | 3 +++ drivers/platform/x86/amd/hsmp/plat.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 4b1470ca8675..cc859c9fe2dd 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -275,6 +276,8 @@ static int init_acpi(struct device *dev) if (sock_ind >= hsmp_pdev.num_sockets) return -EINVAL; + sock_ind = array_index_nospec(sock_ind, hsmp_pdev.num_sockets); + ret = hsmp_parse_acpi_table(dev, sock_ind); if (ret) { dev_err(dev, "Failed to parse ACPI table\n"); diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index 33868346b5a0..00dc7a0d358d 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #define DRIVER_NAME "amd_hsmp" @@ -77,6 +78,8 @@ static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, if (sock_ind >= hsmp_pdev.num_sockets) return -EINVAL; + sock_ind = array_index_nospec(sock_ind, hsmp_pdev.num_sockets); + sock = &hsmp_pdev.sock[sock_ind]; if (!sock) return -EINVAL;