From patchwork Fri Aug 23 07:55:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774732 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2084.outbound.protection.outlook.com [40.107.94.84]) (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 4F66313C80A for ; Fri, 23 Aug 2024 07:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399770; cv=fail; b=sqciGcnCCb5TaxdDjuXrAbUEuQieRqRChHTQCrBJGkVsSDLb2ZRYq+d80b2c4HK+KXJbOxJTGsjW1gNkywZysor+9KoEhmPbpZhbDNq46FUex3qBmPWVcFkuej0r23HSt96vrPVxSlhko0Yw0zEeTB37JFCe574lY3vixZInp1o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399770; c=relaxed/simple; bh=5ncR3NATvIIsLzvieQHERKQwzIGD2SnI/BhHXDUuESs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=PwelggFKaJ35qiNJGwU++m8zUPM2Vzw5TSdnkNfppjo2vOz2m4Adsftr+Nzh5SVnmgvg8LXrKFKCYYpwJ0jZEqo7M/bOF/k43L5Mnsi6LXXunBCRKnObAorZ2B4CKfozcb4zxzQ2lvhmslJTlfWQsGZ9Cp0o8nJpPiD87nMegaw= 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=OgpNfn2C; arc=fail smtp.client-ip=40.107.94.84 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="OgpNfn2C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=edOHkEaVJVWUVfKqN1FYmhmVTCzWixe5yvgDa05oG/Y1Iihp1wQ4dm8ppIXAWAM1pvAEEWWwj5lsnkuzRvPaHtvEsG+WfXRmvpUAEymF5sgwA+s9pA94n+QRzw+0xjCvPvmBtge+FqkkgqSLwDULWIRHW2wcD7KWamvO1xoaqZCA1Yq0X7Z0OobWn/P1tu6KGmDxYQ5jGWlZ0UZiawWxNoJaCb6rVBkQ7E5m4KkExQJ+H+biJuUUzQ52mn1TTduR3qVkmeX6I28fHhgWoBgDQDjHDbC44rR+BFBBXH8TPto5zLGPVn9vFRGD6xlcipqiZrwdpKn0qHxmtF+itQGASQ== 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=LcTEiHPxyQL/ghIBjUNQnWUQ501pgs59m52tCirS7sM=; b=ncnGwMSReuqTVTvi6dhtNjyDqUfiROgA7hZU5dPFuzMNYC8MkiGWUYfojXtpzNz70VFK412Pw/l9BV5FX1jnb8LsIUEIAqcJrT8Gkxe49Vjh5PvGE6c3s2dUPA95cKE+jJTEQuXcPagMrUG0DqTmH07kJ2fhQb4VLNN7i51DEFH73TkTxZMElgk0D53sGuCwtfGBL+3iv8hcJ9rR4dH5m3qehbZnNShAJcSw1aqPpyvVXIoxcqTdf/1791pP7Ajz23PLY1HWHHC5oLk9aIl3BAnYO9E2w6J/Es7lfgudOWARl4YQqdB7Md2Q6NqMWJpIAJ9/rXhm1ZchjkHvbsqRAg== 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=LcTEiHPxyQL/ghIBjUNQnWUQ501pgs59m52tCirS7sM=; b=OgpNfn2CE6JS29wy+hIJDLeHvaRshcAGvamItS+/vPYrC1+bkXoy1YY8bRfPlMk/tzjpP9njChO5oQa8rFgUAiuKOui/+EH/kXHOrReNEkBKYZaMBRXQ0wmrkgFE4oCT5EgsrwYGkV9/KXilEeKeB7gl5QffvTTuYalyWGALeRg= Received: from PH3PEPF000040AA.namprd05.prod.outlook.com (2603:10b6:518:1::4c) by CH0PR12MB8532.namprd12.prod.outlook.com (2603:10b6:610:191::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 07:56:04 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2a01:111:f403:f90d::1) by PH3PEPF000040AA.outlook.office365.com (2603:1036:903:49::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13 via Frontend Transport; Fri, 23 Aug 2024 07:56:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:04 +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; Fri, 23 Aug 2024 02:56:01 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 01/11] platform/x86/amd/hsmp: Create hsmp/ directory Date: Fri, 23 Aug 2024 07:55:33 +0000 Message-ID: <20240823075543.884265-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: SN1PEPF000397B2:EE_|CH0PR12MB8532:EE_ X-MS-Office365-Filtering-Correlation-Id: 617882d9-97c0-43a1-4809-08dcc34909ae 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: =?utf-8?q?JkSuRShaohZF/vN+T1U+UmBU83XjHws?= =?utf-8?q?BFpGiXY3VIu4pLheddDQFo6gPRm6MY+6EhwQijiO5WwbIMwowUlWwB0/UIqx7HYf1?= =?utf-8?q?odwvFJSJKQ9ll9zi4SvDHL9eFPPPlAU88BDwOd3wV+reBGM3V5155vyfZ8mtaB/Hr?= =?utf-8?q?CSFzi74UguwJmJ0xZqxhr23PR07yDe6MkkqiriqHQPJByqGJfrtmSFE8kJOBtE/hp?= =?utf-8?q?0/93dlG96OWICJ581jIGbdWm48vLkeZzWG+RdONL4nMLuLU/W+3OhYCSGMyOmXHku?= =?utf-8?q?RqUtdejWVt80ssHwIIXBYWPb6pdEhYjjPi0dFj74i9UwbMRCI5LOXdNsLteG4FQ1I?= =?utf-8?q?iLswxMxUx+i8815byf/LReBj7aEmo1X0ffQokF0Wi5xFMNfEacVplr9KaBgGdIxEy?= =?utf-8?q?p3vTbDVWFvv/Svb4qoebCbaTTn3XObj/3Ufr8vuaQ8ab5Gs1c6e6O/hfWPO1un5IA?= =?utf-8?q?ooe3jqRqUDym0MLN+g3SA4/srIjJu3a++QWyaQZR3mPhZiPe8hX3X7+WwdiWqRXLy?= =?utf-8?q?cAlrpdg6FvY2UT7AqxsaIbVG6N85HX+OAvQsTiWSimJ9PUTHpKstibJ0mrVbnbKTI?= =?utf-8?q?JSt7/6ZL4MK2xYTS0B6ENdLsyPXgS8zdEgfQXy+W8SdY9qa/wAYep6b905ff7ouXY?= =?utf-8?q?I20A+N+05ifeeSY9KtxNSN43spYWXj9n9Dsq61TNOPzynmih5FyPYW7oROmeU+oUJ?= =?utf-8?q?/KBmDHuvO0RsoxaaVKVAMoeWQrr6W+vEwnCCivgP9qwuQw0HeLrNNM2JXwPe5Ndk9?= =?utf-8?q?qeCL2xh06VmAeekVi3iXTSN1skHYJaiOAJ68I71myv2wcoNx7r0OicnJG/5VTKyF5?= =?utf-8?q?AvgQRKmS2QY43F2R3bgCuKW8aI7HBTy+7cx3GqMPBWbOGEoxLxGnYWlcLrkIlFEPA?= =?utf-8?q?uP+PSCGgyx1biFwLRV9L9hoDOpbXjxPxY2v0TE+9unQvdm9vgQJUWb7EYN2IBDF4s?= =?utf-8?q?SH55QXcs2ky4bmtBOz33DKItn90Hm9qJx3pOA2w3PGnAVrWuRhnkYf/P0kQb8ubMh?= =?utf-8?q?kSAQ7SgSIpU0dmmjAwydxlLhE/YoWydxBJK2RsxTv+y2s5smHvUhkgV/bFdbeh0he?= =?utf-8?q?n2+w3e2HjZ1kY7t3VYtgGk34C+fDor0mxP1aoK8108PjwymbG35mMrMfJ8Jpw7D4P?= =?utf-8?q?wUPJE1W/2MRk2Z+mNYgo4p7ZSNGbazJBsBSeIHXh7vhAUbVtVdUW+bVpLlfTjxSmc?= =?utf-8?q?E8zgEPu2zc9rY0/Mr2ay5MhL6LeL68tU75L3TFM1V/epkc4mdFioM/MX6WUtXsNux?= =?utf-8?q?0w+MkOsJvoMXlwQZnt5coYsF/lPuX+rsJXWez7IFvCH8qaJRHX55mP6wPy3wCovOx?= =?utf-8?q?9LxfvRTHNnmTi3/+6NGOUsDHDuKEjunQld19ueeE7pkZTJM1zqhNRmKQJLc4WAMdD?= =?utf-8?q?423pJ/Bh9Ow?= 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: 23 Aug 2024 07:56:04.1275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 617882d9-97c0-43a1-4809-08dcc34909ae 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8532 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 v4: None Changes since v3: Added "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 Fri Aug 23 07:55:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774733 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) (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 ACCD513C810 for ; Fri, 23 Aug 2024 07:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399771; cv=fail; b=JW5KVRwGwa5ol/OLUWRPxMXmrf0zUo3pnd4c8ib0ljC28yJxUfNOFtqqRqpJQrlkkHjhFFL7vDQbUhCpY90jDIRkxrRG/6KU3Wcmm80HSZ4n3w8AgcsPQLP+U/f73B5bY+xMt10spY7EUBfCJ2P0PNFodOVYcCKFE7mmM46mUA4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399771; c=relaxed/simple; bh=sDNqHyqZ+QbswgOrbYMf/BVyseHmDGAl8kjjQNDBOLY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rgr67tfgUGso+5ws0fcKl52cct+Vr150A8PS/4GzscXnwS2trQxih+zvqJZKPIyWEPWxmwGlNtdQgFJ6c5E8DzuH1KvvyVHryDwMYhHHAr+tZJwkORtWJ0txx1Vi8T6mxX7XUw+bkABQl0GzJkw4T8BsUHdTy3pwqlClag4wVJY= 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=rryHXydA; arc=fail smtp.client-ip=40.107.220.85 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="rryHXydA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JKtxfwynp6Iv+KMMwXBdvMX1SPkoSCyoquJyMn1Qh571fs80qI48TbgL5u6DvBaib1U5lv+165UmKSLg+lkbw6XR3pOdEgulnofBuBHFm6yM7wbc1nlH++EVrYM7SSiboHCUjo1eP6KitjVn212+smjL1ry9ZbndrEVzYdU2DHo3Hzwgf1k9O95UIoDu2EMHTFba9oTCtooiIsGpX0Q5vxSDBV2ECMUxKtiPfXy2ew4ZwaZ/x2dB/HTAEh4elwlnJODc0brCrBV5Itvo23lXqnyoFkjyrMGtiYZxqM71DRMAajY+QPgJaUcjb9UV7cblcvyLlMMZsiEADmdpjtYRdw== 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=dMR4uJjdkN7pA3afr5j342LYsf4CTkhz9C0lJdjW3LY=; b=hIYPn8cE0vLnijdLwf0QpngWiQepGPiFJSXl7pz0zaOaK0z3mV+MMnzHBQXJ2jy1R5fcDYEW1mrSyI7HknkSQ4IZBW8qedfsXWBbLNkIddDfAOKw8EkN6tZ3Hud2xxpXCHBfss1tvUfy4zsuFk8PUilaDhvXe6r2jTRC1Y+VArV/Y5w5hTMSbN1+nzAZhe19lUreHIUaikpnpqMsXeNOqF8k2bbPM1ZqecyMMI8+eeqTTs60bx+HqmGZ6G9OAOcnosHI3rdsLSfPOOf5lDLkHfk+OpWVWRqDz3C9YL1jNKTj8g8neoXO9X6rRyx0Zi8Q5jOZK//JmAlWTP6q811bQQ== 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=dMR4uJjdkN7pA3afr5j342LYsf4CTkhz9C0lJdjW3LY=; b=rryHXydA55vvZmRURrd904oNE2Iq3prTKS96Rave4ihr5CS6vqIPTZZ5d/fchNHWnxsohVGs7g3Wr8dyZY4f8iOhIY1NoAJNg+Huzj6w1u0DfMBm+GZNVIIdIJ44D2a3NubUAMKv5lqq9oftX2mF2u18uNNugp6gTDLzSZlCDos= Received: from SN6PR2101CA0026.namprd21.prod.outlook.com (2603:10b6:805:106::36) by SJ2PR12MB9006.namprd12.prod.outlook.com (2603:10b6:a03:540::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.19; Fri, 23 Aug 2024 07:56:06 +0000 Received: from SN1PEPF000397AE.namprd05.prod.outlook.com (2603:10b6:805:106:cafe::2e) by SN6PR2101CA0026.outlook.office365.com (2603:10b6:805:106::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13 via Frontend Transport; Fri, 23 Aug 2024 07:56:06 +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 SN1PEPF000397AE.mail.protection.outlook.com (10.167.248.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:06 +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; Fri, 23 Aug 2024 02:56:03 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 02/11] platform/x86/amd/hsmp: Create wrapper function init_acpi() Date: Fri, 23 Aug 2024 07:55:34 +0000 Message-ID: <20240823075543.884265-2-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397AE:EE_|SJ2PR12MB9006:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d532c1a-7e03-4cdd-a567-08dcc3490adf 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?R6Miv3OTm/JU4cWVta4IjXoxpsITOpz?= =?utf-8?q?+sFDXPNQtvc+d5MW3Ew20TvgOUc4PRlE68gPDhm0m3nfHbw3TPjIcBJF2Dfey+CU2?= =?utf-8?q?rQpqafYyXzbWzVTuQFktqEVjFIEQIrky9ATIEHsPucA8LqeY6XVrIOygFeQlinx+w?= =?utf-8?q?JUxzumZotLoUWJ4Uxd1Oh5XaEOSmmRRJlr/fHJxIktqOe2VL6Obn0OWslVr3JosbK?= =?utf-8?q?EbtBB76smQ3bDiQ2n2tOSWQcx9G9/bzm0Jk3vGgf8+cDkQfYxASLye2+6y6odFPjS?= =?utf-8?q?MfsT30HXWZaX1Ri+ny1/OJCPDbUzc3vEmaK1vONph1sXJMYgEZw6G6zaXG2xcK1FZ?= =?utf-8?q?aQXbj0cn6s5FrMo68KuYZDaNQ+VFZWUq3pgoXENeFxpw4dHeWV9wqbzuiOmThqG4y?= =?utf-8?q?OxyFdkT8PxiUXyyBC79FAELR/ddDC8yCjcVDG5wqS2V7BGEDB5F7n5Ii6ESagIoCA?= =?utf-8?q?WUS+3KQ/EfKyV1vnCA+OSnMDqTl0GiIgXUJE1mKCL7nniooaLS+vG537xiuOqstgY?= =?utf-8?q?buiakxD1BsisuKd721zDy5rIhBXZB4FDeruJWVT5blvl0xXfgbICSjjen+0Dg+0L2?= =?utf-8?q?ZElNMvMj2ZSFf12suaUKQ5c/Yc5xkY4lmL8OwkpNzbEui9tSxOuHtKFPE6e/FxiV6?= =?utf-8?q?rc3YHE94MiHf7NwhAEmVxZsptft+dG8sMEjkTK4vk9YNjlGJhkiDd0SGipApb/Ou4?= =?utf-8?q?RMISJDO+Hjjq3t9J/8Lf73Pl+m8QP7PgHfguYOTdINWv/KPi7D0uZnFcYWJWN1tpw?= =?utf-8?q?hBpRn1lwgRRIdrJMF441ZONBGqIBB1MVXhH+7984QX1dNxIfQ6gReIHKd5AOxt2gd?= =?utf-8?q?PUctY64+M77vopfj62g9gg4g1emLKo7inurYahtJINtSFuQfbmUQpXAAxNj8H+W/q?= =?utf-8?q?PLPF8aTWyx7yLvVwXCSSMlCgIhn+TiQpGTz1GHoZvAmzvhHOpTZ3PfWJmGcOrDYcO?= =?utf-8?q?bRrzJpPMkVCU3QwFpqZu2GA75/6cFwWzPiL2yMl25fO490sp2D/Hf1xFoE/u6Y8AH?= =?utf-8?q?szzjliqNSdCpNyqJdvxp2VxIJ2PTme/tfa+zy+IFDyBTLcXIxFqEah9Yuh1aZ8Ost?= =?utf-8?q?Bu97q01pQ1ygsNoQbmGw7D5ABQFD/d3cNkxOuBPOxeCw7tK3V2cXqItITMHnyPR5t?= =?utf-8?q?Ld7FXvXLxDlKGe0BpKY66rMvPDaNQn1exYXh6jJN6XKCgUPSCFWY7D7ev1niIIN/s?= =?utf-8?q?n+OVyLAYVQ5lDBeE5PlS1SxTBjOS7NFJAdiFVWFJceXSXTRL8xYSAOw0MveIgq1vp?= =?utf-8?q?malCHlLdbB6KiekFIzwJ6CqVgGjTSX7gb+5ZuQ/HK4H7gnCzeeO2u450Wlui4HU5y?= =?utf-8?q?tLfA2OdoAV3Uj7/im9+cWpyFQy6LI4m58JHobRgAch6asUzfHsQLvbt+3sYxbdjI1?= =?utf-8?q?9QGi5eUtKF+?= 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: 23 Aug 2024 07:56:06.1288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d532c1a-7e03-4cdd-a567-08dcc3490adf 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: SN1PEPF000397AE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9006 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 v4: None Changes since v3: None 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 Fri Aug 23 07:55:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774734 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) (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 3C8CD13C9B3 for ; Fri, 23 Aug 2024 07:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399772; cv=fail; b=gcg0tdIVFYv2H754O3m3YuSNbRauOh7VyleLbKX+Ihf+2wbCLU6+eRuAhdBU9iNH/UYd8mszrFzRcovpVeQ2lUHVOhnCddmHruDm08kweg7AoWcQP8CfWouAPnJKp+HW6o7qzvncuJ+6OiIvxW1LVJ1tjf1+cDfKKGqATkkYwuM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399772; c=relaxed/simple; bh=cq559UkfbGO3dt5S8H+p8tJdnMJQ7VfHOKr4LG+90RU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZEI1cmIBSFmKb3UlHhOiLoRoYbnEKIIxnEEUtfVW+9K17J9bAVQWtncex1IYXC0qWBO0EgsVyXnlOGVggWQ+oZHCPjXTiiGCCeDQb2ppBzfrI+sYvZBymlqDE2tosv0LU/gqG6J9IaTPBpvxevS7e0rR8FUyWCud2HrHB6BSI9E= 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=XGGzc+6a; arc=fail smtp.client-ip=40.107.94.88 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="XGGzc+6a" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iT0B7Oez/UgvPFAI9E+GOHjST5ABBkpPbzk5dOkiQ4WI2DsZqt/cqYpyiLwk29pR8DeIVe8niVcd4eo6PvOb9U5/n2bgqLX50P/uTTufHzj6ndIfKT89s0gEWXE0DfhbiIcbU/Qc0T4VOe9sn9TH3zuSth2Xo/VKI59FFLPuV345XSzXU2h7cqRzOdJ5EE4ocXXjvXcA3iOSrluteDv10ujtUb9I1uz2AMeKnzwVXUneTAQVDtv8mQ981qm8ybeLUpqsJCbIfEpbn7qm9RGfzdVum3J4fba7xDHHzA+wjyaIdadZNEuh5ka9a8/Tm38ZKUsQG09O1E1Ya+769ktzIw== 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=OVhH4RXrWroCyXRh934MxgKr5kTTBzb3rjTk4D4OXfI=; b=XrzkL9b0uvP1fMCFJZSKESa2yIWKz8SFvUESKxSlKRzrvPMcLjOifY4a9PMBhbDKFcLJabtXKy3tXMcFQjx27/6vjPWfMopEKSOU0tWNdrOCL0El5PMGmDdBFzcG8FDwQmEzahLDofyU3VKPNuGUFiamWi6nTgQs62xrrTj7kvJ2mg7FXJMzv8uR1+yT/HaaGUjYYXmlCZ81zGF8lkPiH2HshltriY039PGJfJHy8krfyVvfQAwdgylvnyABldtpq12C/AApAz1FDEj5qs6xwcEuFgaYqFZjOL2rTs/3KHdCdaSp8ed0eU0xX1CvDQBflCV8GIfA27FjogQudBZjag== 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=OVhH4RXrWroCyXRh934MxgKr5kTTBzb3rjTk4D4OXfI=; b=XGGzc+6aVgDuExEQ2hM3errbippiGqbugQex0uMw2ERWMmgOghAR7NLRrQnxlRHGjKUFFcwmCiBMIaJUqwqK49ri8ezqA5fmpM/Sb7fElsZzCtEUz0KaBce7ajzoskSWcaIlUe3IULrrOaTVhoyuNxzQb4NyCT15BTU+Ms02oC4= Received: from SA9PR13CA0014.namprd13.prod.outlook.com (2603:10b6:806:21::19) by DS0PR12MB8413.namprd12.prod.outlook.com (2603:10b6:8:f9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Fri, 23 Aug 2024 07:56:08 +0000 Received: from SN1PEPF000397B3.namprd05.prod.outlook.com (2603:10b6:806:21:cafe::eb) by SA9PR13CA0014.outlook.office365.com (2603:10b6:806:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B3.mail.protection.outlook.com (10.167.248.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:08 +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; Fri, 23 Aug 2024 02:56:05 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 03/11] platform/x86/amd/hsmp: Convert amd_hsmp_rdwr() to a function pointer Date: Fri, 23 Aug 2024 07:55:35 +0000 Message-ID: <20240823075543.884265-3-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397B3:EE_|DS0PR12MB8413:EE_ X-MS-Office365-Filtering-Correlation-Id: 20058067-ff79-4099-7f0b-08dcc3490c0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?F8OV7tMbUh+7Vu5NimqDJajF+7B7K9W?= =?utf-8?q?tqeEUARtk8Jzn14wm7YB3gMfIpkPUeTR+hqhL/ErfRPmmPmM5tbFg2eaq85sTgpDP?= =?utf-8?q?6dMfPomfpcFTSZrmZy4SIYOV2rbMJJN+GMJWzi2nRYcICwkJPnMYqNYzaR38EMqu6?= =?utf-8?q?YZWYkhzjFeFOHUujx6RDmZLT2w9TMeJjMbF/CKvMOx9uV5/v5tIBy7CP+y1ulCDmH?= =?utf-8?q?pV1dKAriEmNu3wI9I4s1hZqRYGXYM0S637zwLk5pkg9mIVgLa2+5mXEC0okt/s4cv?= =?utf-8?q?+3BnThV0hL0nJBQ7hQyP7ZlPyiUVgNtmdMOLuFu1K2akN6MJmZ4MCW1kYh/UMfQa1?= =?utf-8?q?/ARb1knGWJ+soXZToh9c1Uf7e0BBW6exETlOHOnVJNzyHM6JNy2vV2seRhjkZj7YH?= =?utf-8?q?gU0UtxssYmR/1Rvt3sxS/UB4SwqTQbhVTbuA4Dwa4aOdYtvzYf1utcG2Fz5wartLK?= =?utf-8?q?9KJW/iB/Np0aMcP63YcgAc2Pah8k0/Ns2hEWPgMgIjruBi0XXQg4Yme6OfgyK3/JV?= =?utf-8?q?fPpYdL2R+VzJRFhnt2UHiAaMpJ4329iHBG6/nXnAOTsxnYI3bpC87FlLl6IsOHjgP?= =?utf-8?q?bF/ohB76f2M5c0glJPtAU3h4G9V8lUnIr1QoTyIqAHCua/H8+N1c2T3nFn1CctW1F?= =?utf-8?q?Xbq90AxVzCd+UksgvlacdeJQ8e/qSXS2SYgJ5fMwodE0C+OzikBr0AvDFku4s2M8T?= =?utf-8?q?XeD1TOHQ5cmvkSOW/N2Decq1m9LxiRp0FfQu1CSSVq8pe4lN+f/iTzx58qdw8htky?= =?utf-8?q?ET5EKXkmuh+C456kc3LvOXF5Gmbw8mi21WRjIysUFF07SL9Yro8QjrDqcAx7rLKL3?= =?utf-8?q?CWEUFiUSFjJZU0bFSMJTLWDM4JQJE1cJMnu2ypZTOjRjAHJRm2q+1EI6Z13D1GPN7?= =?utf-8?q?pQ4P2oU2v5Zvdfo++/4rIecr+5KRbqoQrJBrjIi52psnuT7YXqiAexw/k+Z2NNWKW?= =?utf-8?q?fN4aSRLlaf61Mbk3BZJehoAu3zRMmiWPg7LbkbS8cVe1CEIMOnMxd2o/WqbEvn6Tu?= =?utf-8?q?orHuGu91QLnSk7JoLkGe3eMjnggxqFv70E30gzg9GIvMhCIi+EGTeB7DeV8ycjnrR?= =?utf-8?q?8OrSC1MHYt/pn2BFsvvfy72OudNkFPYvHKanvLW58MKEPI7ZTB3YYHML/BfjLvQa/?= =?utf-8?q?wtlC4LXrADsAYN6FXFlzxzvP3mA2cU6rJLlbKQtfbw47S91vFSATsX2c19FLsCPAh?= =?utf-8?q?wjFEgTD3E0zzt1Kq4uOosvUGtoRmi2IptEIjNxrujhbKBXwa8lZFkhPQdhyMvI2HU?= =?utf-8?q?0raPUEKj1mHi1kzgJGyuXdUfN5JkScBPjftfBgBcWDZLXXi7EQ2ydtJ6bdr59BSp9?= =?utf-8?q?yA8a9pVREC1oeB+59yARnjS3Gdl0CR/3Ai+9SkcIfUBPWdA5J7LNRG+2weJZpFS76?= =?utf-8?q?xihZX4muC4g?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:08.1135 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20058067-ff79-4099-7f0b-08dcc3490c0e 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: SN1PEPF000397B3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8413 This is in preparation to ACPI, Non-ACPI split. amd_hsmp_rdwr() is used to access HSMP protocol registers. ACPI and Non-ACPI use different methods to access these registers. Now that code is split and common functionality is kept in hsmp.c we need to define a function pointer to handle these functions separately. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v4: Add "Reviewed-by: Ilpo Järvinen ". Changes since v3: New patch created out of 7th patch in v3 series, to address the review comment. drivers/platform/x86/amd/hsmp/hsmp.c | 30 +++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 10ab9b2437f1..6d0c58c6a82f 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -82,6 +82,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 { @@ -114,22 +115,13 @@ static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, return ret; } -static 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); -} - -static int amd_hsmp_rdwr(struct hsmp_socket *sock, u32 offset, - u32 *value, bool write) -{ - if (plat_dev.is_acpi_device) - amd_hsmp_acpi_rdwr(sock, offset, value, write); - else - return amd_hsmp_pci_rdwr(sock, offset, value, write); return 0; } @@ -156,7 +148,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; @@ -165,8 +157,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; @@ -175,7 +167,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; @@ -192,7 +184,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; @@ -227,8 +219,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); @@ -545,6 +537,7 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) sock->sock_ind = sock_ind; sock->dev = dev; + sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; plat_dev.is_acpi_device = true; sema_init(&sock->hsmp_sem, 1); @@ -756,6 +749,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 From patchwork Fri Aug 23 07:55:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774735 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2070.outbound.protection.outlook.com [40.107.94.70]) (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 1CB3813C9B3 for ; Fri, 23 Aug 2024 07:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399776; cv=fail; b=Y2D0Rtc+CmF8mlNmN2HwNJLzm2+xxEpNBCpw1x4FThGGOMDbiSx1YWTxsYtKd7TOeKOANdVXVQA9JOLHiQodiX5zvQTVc0/MJI8zkmCxTrFCQUM2XExJFRFW6c3M/avRvVHVgTSgn+OEvccFoL1I2wxT9PKONRPkdlgtDjA9DKY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399776; c=relaxed/simple; bh=wfHJZ3Ghea2SOqAxUwocbf3NHTKlNmTpOTiq7JKWFVk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Hi3ZRZrWF0Uf/IN3CVDdqnRzKFXlfdbn2qC0IngQgnG7xeyX44AhSlHO3E9ltn5u/f5taVWX3jThC9mgHyj7tUMPfHNvi0ZPxQ+RtiUDW0YI2ugn/xMTWoOrMFaRPMGD/AewRbid4pESWC+yO5tmwn175LryBxIJRv/FWjR+W4w= 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=IPnul39N; arc=fail smtp.client-ip=40.107.94.70 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="IPnul39N" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rMhvc3PyqEokpWwbm5N69ToaVD4+kTrfCGPVAHHdADT1l1shRIRLlEY+IWw8KSI2o9wcPNyEfAmJsZUPocbgPRgv9A2yWEA6mjvC/KK3xznTNuzv/QhGELZMhFg83RZPjcYKTYphtwVEUwDpHM0euQneAVJ942PYFzkaawdfTfKxe00P8vcl/7Wg7+iXKCoDIxRODE4Di6+xIFeHS7RBdyEGWh4nYYk2hbp0/4FgesBW+/qgRNfQ/P6GV9NYlEE5i/Bwz8v4ZxmgTsj3ZdPIaXpwf1oFc39DzwWslQxnqLmnDlYF2eSXia+fXu6jfXgooSnyF/YVbZ0P6IDEmtuNtA== 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=PTL3M5VA67a/NtxJTfY9/+5Zy/oMWAybg788/phPags=; b=R9MCSW2sm8h9bSIG7I0Y4LFEaKLGspIIbcalJNvQ3yjBPGyb/wuni8mHOFR5Z3qlXWYaTOWL3StWbnw+Q3EdNjHum8j7vp/Y7tiOtWclD/b56kD9Yy7KBAGCQfehO4JjvazDqPTJE4jjZTLxDfAmiN64QCHqSkGKv+Q3QiArPU1otjlVjAro9qvkEp6uQqjcj9J9R7h6upzC4rVdKkDtt/2uQvVPXq++9igEXFVQoMA4iedNQF/p2/h2jJLVOwAnhz1EvVhjWn4mAvLm4v4UJBao8i0fL6XVBVzk10EoAdGmJu/g3cv+EPfPjwR4qiY55T/z4H7HkKbBED8Qie3bQg== 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=PTL3M5VA67a/NtxJTfY9/+5Zy/oMWAybg788/phPags=; b=IPnul39NeEE+aEcn+J81J9C8iR/T+Jvs9DH0PiUnpV0IV7UHvLRltv8GUa/xQC823RXTOiUYgEI8SyEsx3/t0jJNPqeg4nAMhXT2FJip0YxPXFUbOTU+XMNqJgu3+T1JDI3ByDIcRGntOq4PNR39FlqWyGDoRCYAJgNZL8VdgYw= Received: from SN6PR2101CA0027.namprd21.prod.outlook.com (2603:10b6:805:106::37) by SJ2PR12MB7918.namprd12.prod.outlook.com (2603:10b6:a03:4cc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 07:56:11 +0000 Received: from SN1PEPF000397AE.namprd05.prod.outlook.com (2603:10b6:805:106:cafe::2a) by SN6PR2101CA0027.outlook.office365.com (2603:10b6:805:106::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13 via Frontend Transport; Fri, 23 Aug 2024 07:56:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397AE.mail.protection.outlook.com (10.167.248.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:11 +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; Fri, 23 Aug 2024 02:56:07 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 04/11] platform/x86/amd/hsmp: Move structure and macros to header file Date: Fri, 23 Aug 2024 07:55:36 +0000 Message-ID: <20240823075543.884265-4-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397AE:EE_|SJ2PR12MB7918:EE_ X-MS-Office365-Filtering-Correlation-Id: a7352fb2-8071-4b1c-d131-08dcc3490e13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?tyFddTlaI3FloiDDUZF/Nj+Ab/UhxMe?= =?utf-8?q?Ett9HgeP8IPTCH7qKFi8GxFRe/poo/7mLJ60Z9L+3Ochtmeg8s4BGzGhZtLK9tOO+?= =?utf-8?q?FA/QvFiDIadRY7vbqD7Z5PxmaLGku1r3G6q49CvI/pAErrIIhiVPfEwo7+Iw+53cc?= =?utf-8?q?Fuqf+kf9gMduFZtmaroPlHtwOaS6ZRvZSi9ZYz2xtbs8jumYu3RTRPrsqQlPYIH9W?= =?utf-8?q?1w9WeikQ3F9S2HnlXo3jWvTxLjHKlbm6JPRIcZHwIWWUT++hV4aHQvnPz/C4NnWvz?= =?utf-8?q?wY4zDd28N8hjtrhon800mUoLNjY1RYmXQORzOY637lBGgD8Sj0KzooZ9yavlCKJW8?= =?utf-8?q?cDIogLVtg8sRe/6qY7uu9edgqiDQwpnwlVxhut8PXcA9Oi2G0Pde2wt9iQcp6kpAn?= =?utf-8?q?UUni9y+TaRLJDOBn6WTvY/8q6uKvvrOGPHOsUa1SsS+1R1hmT4JZTQpj4Ro85vnxC?= =?utf-8?q?7jz4OEh+FH007EuiU2nc5MOgI1gJI775OHVbXTKLnKMoKGZUz6R+hW1VEB7M37xSv?= =?utf-8?q?FMVD5QUYiT04bHwPTV3ESjcWSUfos0kvqJJo0fkaNPeLpzaek73NQFjWymRu7awZH?= =?utf-8?q?ZcB8X67CjTSmbUaHBNYOOp6beLpG1MSVp+7KfdurAfQpG/RFw2pq0SMqxoBxKlAlD?= =?utf-8?q?dVjdldSVTndESV58WskFA8VIKV3667fwTbRVmOz/nhvjcGmh3JUY4huWK/G/7/4Ym?= =?utf-8?q?ExAEPaS1DKZWbSRNwxRgds2ODXboiuTlMjndRnNWWQyJyBbmelJjsKxGmQ6EAhzXY?= =?utf-8?q?+jt5y8V3x3GfNail6Qesw11G4EfgUDJK5sE/J2rwKP8pEFn7J8pRKXEr8RB8jxuCm?= =?utf-8?q?sCO9cHK0h+aVRonvfxi+U05FunWgdLDKH140M6efFotAuF7TM91682Pm8+JCdGbZo?= =?utf-8?q?uZzoYHO0utfJvtoGGAM2klAOx2vC9p2rixG9rKmvmqJiB2Wi8x6S2xPs1e/N6G+5m?= =?utf-8?q?y9DOTLaSFHh2rFr5Cq2l2yCs5qdMe+3u7iagWiIRWy7s0EvVHc8CnMJnEs9fiPImm?= =?utf-8?q?ohiL1rpvEaQLyzpaPgxeMnwalToFm2g7I4M2FeVwDv2W2akBkHbuBe2ykppxdSFGm?= =?utf-8?q?xNOP3Iri1xxdditDjL9NYOtBmk6ggZtyExDOzGhJRLNbImTkd8xNLMbKGKKKItsvx?= =?utf-8?q?JZmJi7tsqXbcHhCzwPYVSx1HbAP092dKPyoCszOwOe6GV6LBkES2xoC8beFqm2zzS?= =?utf-8?q?wEIVo+Uv8VztS/rTblM4t2gnz2GpQIq3Z4mskROoeaQpyMuxu6GhqENQndgaTRn33?= =?utf-8?q?ldzOJfKOb5+F5HQGjXmROMbsETfvDb7YV/9Wnti33J8jsiGsHFeJmGefvhA5KMjXq?= =?utf-8?q?CV5OYh3SDhAj80Vdk9/FHnmMZ9qe+JfeNBn6aQMAI4edgkzjq9DvWnH1IpJw05lEo?= =?utf-8?q?kBndDZC3Sf7?= 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)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:11.5038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7352fb2-8071-4b1c-d131-08dcc3490e13 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: SN1PEPF000397AE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7918 This is in preparation to splitting ACPI and platform device drivers. No logical change, move common structures, macros to hsmp.h, add missed header files, remove unwanted header inclusions, and re-order the header file in hsmp.c file. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v4: None Changes since v3: 1. linux/sysfs.h, linux/device.h are included newly in hsmp.c file. 2. Header file inclusion order is changed in hsmp.c. 3. linux/compiler_types.h, linux/sysfs.h are newly included in hsmp.h. 4. io.h and device.h removed from hsmp.h. 5. commit description is changed to reflect the new changes. 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 | 47 +++------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 58 ++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 41 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 6d0c58c6a82f..9ed1fc0aeb00 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -11,14 +11,17 @@ #include #include + +#include #include -#include -#include +#include #include #include #include #include -#include +#include + +#include "hsmp.h" #define DRIVER_NAME "amd_hsmp" #define DRIVER_VERSION "2.2" @@ -51,49 +54,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; - int (*amd_hsmp_rdwr)(struct hsmp_socket *sock, u32 off, u32 *val, bool rw); -}; - -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..d54b9681d514 --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -0,0 +1,58 @@ +/* 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 +#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; + int (*amd_hsmp_rdwr)(struct hsmp_socket *sock, u32 off, u32 *val, bool rw); +}; + +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 Fri Aug 23 07:55:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774736 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) (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 6E35013DB88 for ; Fri, 23 Aug 2024 07:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399780; cv=fail; b=hVPW2yPTb8ur5+PXFyEX3Hf+kzM0MIlNG7d0I/3ccc0rQV514j1NvyZG33R8i4BLJ4oGLWX7c5nbeX02hO/xShRtH3dl8rIFEvwFim5pR7SiiEuws4DGX6MYemQA9d4JQX3uujHgzkfqqx3UjJ440kACgPLysTJJSs+2UaekQTI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399780; c=relaxed/simple; bh=bWfL2/Wz1z4RwfPTenf4IFQS7BVxqRNyPchrTcB7TI4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D147o5WxAp3swjC9ddm3TQMBLOZ8qpNIuLD8jbNf0KyXrsXL3TeTdHOYZP8mTSDaX5OjC6TKDffhl0TngULRiVVkh+JNCC52ZN3wKkTtXH7kwJGu2+STN7uPdUzbjpKUkByUKC7ivKUPpa8iFKj98Lji26OMvSfg9Rj2ZhQVuDc= 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=LiAwZ5Qz; arc=fail smtp.client-ip=40.107.93.43 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="LiAwZ5Qz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gm8FZY/dAQB+be7Xz3fK4SMwDNUb7eWz/Y8/mbedCdynXiNye/Pq67aq/gx3+gPYd48hPv01LxPl0xunW4m9tmnMhTdz/2n8gajT7nBchjHZDgDp6hqcpTFkTmIbzvmKCR67AGBtI8+60cS4OHC2FqRK2UGyuxMqxO+S8qPSkPUo9rS56s9Aqhhv4KEKZBRsBfnnoU8bnzLwWq/Svj4i06JWCELIg/aohitwb4Hk+LitXRTPHUPZOlDji6H+Vqtvr0NqxD9mtltQD6NgQSnsjyaOJmb0QA/6O3ln/l10pnpKoSfyCyPyR9mIltpxRFXMzp2qt11iHuSTjxKUE7I5Tw== 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=vwv9H4mFaU7KEl0Hy/mCkoFe99RtBzV8yBC/e54b43E=; b=ZfAqjQmqRFJj+4V2DC6z7PbeLEAQW4zKATO6SZXK+9Ishf1lXwVUyxxjLbA3CmtTyy6IUpuodsS+cRMZKVha/lGUUKTtQiQ9n3i2v/otJvzsOIL4phF6npDgvNKukrlFa62vVsX93bYfjpYpMzYzueo2jpPXhD9j0nMzF3iCXpd+stBbVWCU1k/9rmXZuD/R7G64VZEY6W3tC344mzF+LRIqQ33xC16u4bERX7mlfmrIl+qRDbY4/SdCq16QWEeryN7EAON2g0LHiEtf8fzftbJ90MNNPQCouXzRpxp92ym0SUeWFxDRfX6PImnOe00NyutYhk5lF0pb0xvoIPOp0A== 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=vwv9H4mFaU7KEl0Hy/mCkoFe99RtBzV8yBC/e54b43E=; b=LiAwZ5QzXqnRQjcNDZ0kGpv45B08HGp6wD0xUBCODZAaEfB+4KSoNw87i3sM0tCqYgX2wZyGPwhU5eYZEZgKhMGr05csIDbCxG6FJ812whZ3QibhS2WOKJAIEL0XzR08QzNHHpPVcFT2pu+P7rMWah4LIk0onIclVfhyypfwoCA= Received: from SN6PR2101CA0015.namprd21.prod.outlook.com (2603:10b6:805:106::25) by CH3PR12MB9194.namprd12.prod.outlook.com (2603:10b6:610:19f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17; Fri, 23 Aug 2024 07:56:13 +0000 Received: from SN1PEPF000397AE.namprd05.prod.outlook.com (2603:10b6:805:106:cafe::44) by SN6PR2101CA0015.outlook.office365.com (2603:10b6:805:106::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.9 via Frontend Transport; Fri, 23 Aug 2024 07:56:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397AE.mail.protection.outlook.com (10.167.248.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:12 +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; Fri, 23 Aug 2024 02:56:09 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 05/11] platform/x86/amd/hsmp: Move platform device specific code to plat.c Date: Fri, 23 Aug 2024 07:55:37 +0000 Message-ID: <20240823075543.884265-5-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397AE:EE_|CH3PR12MB9194:EE_ X-MS-Office365-Filtering-Correlation-Id: fd208bee-6d55-484a-a0ed-08dcc3490ee5 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?pHN1+TDi1AljJ+ecnPdp+jcltNFlGJW?= =?utf-8?q?NuhjwFvKJtJWyuOoqvI1bPZsFs3qIW1TXHuO3NCWh8Gnz1tG1F9QaJvjQjQQIjEOU?= =?utf-8?q?MOXVxDL/ryxK67tuntvEafz/tiuNRjZQawMOcWd1AOEbSauQjFIWxC3YGCABDbigH?= =?utf-8?q?6t2XSaiIFPw4hhoM8xAKgomq2FntgEkmytr4NBz3lT4XnvMyoN49FFsD926QmcsHQ?= =?utf-8?q?sNz4iM3NYBkFFHK19NUHc/BnpisomM8qbaalDFeLygQP4+GxPVecyCnP99jduTXof?= =?utf-8?q?dHceZ55STmEK2B/t02vpzSEYLZ20rjJET9NY2AqW3enGvX//H8cUVYW15240GzPT4?= =?utf-8?q?tgcAYwb58KTd6xg8h/iY91S088WT8mTaW7cmJlqT1MGEDArUKPNPwHkL2G5vyO7Cu?= =?utf-8?q?rzQqotocyoAf+7vX4kG9cU5t3nAwAqaMJeYnHUbJnPBDjdUayQGZOWh+vhyWC905I?= =?utf-8?q?pI4EPkKC6/BKXl9ej/ylh8jDU4szAnzadlBZ/99MGTgpS8dWKkFLDsCgT5ER410zi?= =?utf-8?q?ElSN3TUS2pNPQgzKy3XibdaQwNTJ9EMGxzwWohGOiHEOiG2RkgYg0jF84kD5kH5f3?= =?utf-8?q?AJwvoLhfubRWafxLzjVO91Y8bJUIRvxlC9mdx39mCsM3ol46fG5BEozihKbTAhX6X?= =?utf-8?q?t08wDy+/Oy21golkARHWCcZgnNxoYlUC5EkseiyrYo/zN7PmuRUm0CHEEe5yaZ+q8?= =?utf-8?q?X9XE3ldI5s3KJP0Pim5Epv8JUvTNAWYkEaxfrsa3sV6tCmFV2RVvg9EagFKYVZiCI?= =?utf-8?q?zYmZvmrlVhSWoVQW14enez+yGTw7NGGKxRjrlpgDusPHrGHCk5QvLha2AgNOTg7i3?= =?utf-8?q?BfHq0Puz9dV//JJ1h4wj4H8gWXKLe+lnF8uncFRlGV1ik/VHQWeU9C1LN+z+EfU3Y?= =?utf-8?q?ZvVPnDKVpeNgaJ+o0uPYHfqhcEyT+XUJUgati58uyDF2FN6cqSyzQafNdEWS/LCCy?= =?utf-8?q?xluCbGIp764A4n9JopI0cXfHh7pLbfmmDh3AwD51TxshWUFgx+xLzRa5DLGWaMQ7t?= =?utf-8?q?g3Kd2sdhbXNWaMHGHT2B1anGvggN9cditm08IYgXEL0d/LZhpKQ7JUzWhHI4RlP22?= =?utf-8?q?MFHTgfSsYrKaU+62DdQrk0So2d89sIFJSbRusUNTk7lFhVJvMznB2c1k7O3K45ZOg?= =?utf-8?q?E5x+JR9lcE2nXSLC/YMBTjBCUcX+gaz5vweJybRBSRlU9mdE4NiVPyhX3zHIUztIE?= =?utf-8?q?9MI2muhZiGLND4QOnPUUHu4mFKQZrLHBKlePUQkna9jK1pdL++YjBud439BW7hU1a?= =?utf-8?q?rkuNA67G87lg92ym/ayJLj22moeE3mX/T8c29gzBBqJutNybj1wKAVeZqjYlu/rei?= =?utf-8?q?mj9URKjjREsyU7NsUGdAOR36N38mOLTX109j+ZWQVy5EysDdh9EQYxtAz/Ml0DOFD?= =?utf-8?q?UO4q58CHt69?= 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: 23 Aug 2024 07:56:12.9101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd208bee-6d55-484a-a0ed-08dcc3490ee5 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: SN1PEPF000397AE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9194 An upcoming change splits HSMP driver into ACPI and platform device variants. Prepare for the split by moving 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 Reviewed-by: Ilpo Järvinen --- Changes since v4: 1. Update commit description. 2. Add "Reviewed-by: Ilpo Järvinen " Changes since v3: 1. module init, exit code, probe, remove functions are kept back in hsmp.c not added to plat.c in this patch, as per review comment. 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 | 138 ++----------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 14 +++ drivers/platform/x86/amd/hsmp/plat.c | 136 ++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 129 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 9ed1fc0aeb00..6da7c6189020 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -40,45 +39,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 int amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) @@ -248,7 +214,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; @@ -516,9 +482,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 }; @@ -577,8 +543,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; @@ -607,8 +573,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; @@ -624,36 +590,6 @@ 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) { struct attribute_group *attr_grp; @@ -677,7 +613,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; @@ -693,60 +629,6 @@ 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; - sock->amd_hsmp_rdwr = amd_hsmp_pci_rdwr; - - /* - * 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}, {} diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index d54b9681d514..d59a9efb4799 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -55,4 +55,18 @@ struct hsmp_plat_device { bool is_acpi_device; bool is_probed; }; + +extern struct hsmp_plat_device plat_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_non_acpi_sysfs_if(struct device *dev); +int hsmp_cache_proto_ver(u16 sock_ind); +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 init_platform_device(struct device *dev); #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..85a104859acd --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -0,0 +1,136 @@ +// 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 + +#include +#include +#include + +#include "hsmp.h" + +/* + * 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 + +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; +} + +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; +} + +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; + sock->amd_hsmp_rdwr = amd_hsmp_pci_rdwr; + + /* + * 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; +} From patchwork Fri Aug 23 07:55:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774737 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) (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 DD5E213DB88 for ; Fri, 23 Aug 2024 07:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399783; cv=fail; b=fzLS85QRoXnLT6s+8qHJvT2YughabCYmjsZjY3eT7hm9QZuiFNFMit6yCcRb/BNXHiOgYTLKaoLFncPtpcusAixV1MldrN3vx3tgDEVxIi8bdVUhjXJSgGJBWExG3tIOtUJkmvIfS+nXjVij4MAW8RczkHP0niFqXh+0Tr+MtMg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399783; c=relaxed/simple; bh=y3CqlUwL4IwleZVeabaoIbWhVJxgteNaz6lUALgW0gw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PrrJ3ajGJiZDhCeU9KkZeMKLSiZcGV29fZf07Jk3FbQrw+n9AOkzqJ6BfZIqtBkZk/8HqNIVDlCyrkytgApG1HeoSIMzJM/7sFNMKQ9FwBJQmF4goZ3NQTKvuM12mroWShZLYCAha8Dvlmvhg1t2ImX6wla0W1AeI7YlwH30n5Q= 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=BranNvS1; arc=fail smtp.client-ip=40.107.93.85 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="BranNvS1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DJeSJenMFWDr4znU+9xvgn+ZOXIIVSr+J5vAFYGts7QhOZg2aVYciaKpfBa1znAd6M0xw6uoMK62rCqI0yprxwFWieop+hc283hV1dRRPZFptpQEWxmuLGq7/TyZISjWeTl36+zG0sS0Q3Rg2AJVla8aMtj/cQDby+kDN4CkMvY1/MXbxQllfRAle786liasYhdF7Cki/loasX4aYTMATqeOWGuxwgq0yt8T8khVBJ4/883yZgilVlBdtR3K/slp/JstsNPS4HMndZJFSybKzsbCzALwSMkjDqZ42BjZXA7OaD6iiMBynOo6isgLBY9hkdeKSXtx7A9zhaaJ79OCJw== 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=R0je3L/N2wl4rn1QvZ8dwhWrJeIwpbN4AD9PMXioBrU=; b=B2cVH8cE8JwGRQcxTX/Vcc1JGMmWcGwTPWtk4W6e+q3x/EPd3dVE5u/Z0k5nv7ELmgkbSy4r6fXfgrdGUhJdamhGOuLumACDnfO2Uy7e+0yI6eiA7s/McWD4X4KldF3+b9oS/jEqwpgihDCALsUFVAQ8AN1mplZ07sNp60YEfChjgb6/e5B/kqfburfPYYlsf6FLMc4/LlcAE+BolO3gwWY1Ap+SlUouysZfdDX//xQEsuBrwBlk1xPrasWESAOe9+QuMeMbtw0kIrR4+OnUC5Oz2IQuO+CVTEXalpZyEvUECfj42SMHZ3YKeysGnRkVPw4Eo7uVFT1sbDlDg30T+A== 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=R0je3L/N2wl4rn1QvZ8dwhWrJeIwpbN4AD9PMXioBrU=; b=BranNvS1FR6vew17AInsqcYUUk2Rm1yDaZT9OFNTm98b3auJyGDLB2uaSQgyNkaZUY2/nKU/IKd7bg0VvgJhwIeLab8nB2o1QHLHExo8IPGURIiwxZFP7vnR1BZB5lM/Baio/TlsS07BabmgBTfsf+cEdoffIoPmIMECdD1gyxU= Received: from SA1P222CA0035.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::10) by PH7PR12MB9068.namprd12.prod.outlook.com (2603:10b6:510:1f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 07:56:15 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:806:2d0:cafe::d9) by SA1P222CA0035.outlook.office365.com (2603:10b6:806:2d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:14 +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; Fri, 23 Aug 2024 02:56:12 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 06/11] platform/x86/amd/hsmp: Move ACPI code to acpi.c Date: Fri, 23 Aug 2024 07:55:38 +0000 Message-ID: <20240823075543.884265-6-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397B1:EE_|PH7PR12MB9068:EE_ X-MS-Office365-Filtering-Correlation-Id: 08dfbaf0-2340-41e6-c0aa-08dcc3491026 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HxoXsbM4Bf40J4Sc5I55dxXf+JLx3iY?= =?utf-8?q?WsOWB08KngkR1T/YhNBzbAR5ZDEpNQkjTSzRqU53SCuSYrcG6ajygoNo1Os+/k5dM?= =?utf-8?q?Is1ApsuwLrLngIQS+0djb3CptlYN0X5yVGhN5di0KQNxXV/ZTuVQL/mlJyrw4exgG?= =?utf-8?q?oDsdVKFWe5nMaqH35BAVLzPECARkd7h0aSrD8kk9e8Hw7/Ae8mBJ/Evd/ro1afv3E?= =?utf-8?q?lZCOTpEleg8RC7w6/z9TPwRCiZzr4zifeJwBNYE0vmgFQYZi1ilz4Hi2jFkG7GnOP?= =?utf-8?q?qQleQVKCrzgRrCISflgXBErbVyNxSMOAIfqrkXMwfQd0dndB/MNaXARjP1D4PeR41?= =?utf-8?q?ZcvgtmT9CEundr/HAUHraRdFPEY7cqi0z81JBTKnsgLTqCVLt9xpS6LJP9aE069xS?= =?utf-8?q?PjMsz3AoPLcoi+Ux6C5S7KW3xJxID2w0+MMvPdYmstg0/BJhRzp5kniXGVosUT/ei?= =?utf-8?q?JV9Ny4qhDL3b4hYDelg8DxoxJrNGDoOZw2p1q3KhvhEiLruPTqzTdkms2GLVvhEDi?= =?utf-8?q?ZB+XuQ7Fw8wiuKqkjz5qnsKERr5lQEkSNSgPbRvwew0dkxisuacGrEJFHEfCP4qsz?= =?utf-8?q?l76z68x1OB/uMZwkwNayCqKC/thI0+EX3GHLY3QlE99MyHacNg3YT9Cm+rS/M0DuS?= =?utf-8?q?xie6QkuVPSXZAuQKcrmeFkdHuLjik3pf+qkGAA+Yq0k4haNtra6OoLixufDWezNlW?= =?utf-8?q?WigLr5yZf+YhUWKrOTXXAHqSfaNdbEhgmPJCGafZg7eBaTMgV73bG19e95yiXOUPR?= =?utf-8?q?fQa2ajAN+BVYTlNJpwEhS7t23aEGU3TonQI07ntutcqcdSPcEgrBIiNl1sEpYR3/3?= =?utf-8?q?uGhn2RE3QEqeG5hWZk1WYxEEqdqKpfWUxWYF4XgA8PDzgqlGiQK5gEyFxpWHjAUrC?= =?utf-8?q?/Nuwtw2y8YgMBo++F7T9FDePFChxAEXn/M+q9ZaizuLOAH9SXtJvuV8wc+SaTvx53?= =?utf-8?q?4LLG2kSOikqvG8IE0GEnbGyfFK4FxXvCWjcSJBPWusZ0QHuNExklOJkJSV0E/QRVn?= =?utf-8?q?yHf6inz8gZHYvecye6+dXKPzCwRv27SXdqStpfFhVu8oBBZ1UYjAEmKoWhdDgiXbx?= =?utf-8?q?07m/EHpepgx3cO+0XF2jz1D+9YOJaH+pzfnmWM8BTDrk87Ae1UZPcOrP2yQ0nwYEw?= =?utf-8?q?TMMwowh87t7jw6hXQ9X67eCC+JbY+RiP2KQgNNIJSfq6hZjI+nkGfd6AW2oZjR2dw?= =?utf-8?q?1NB12FMbK7ADOSg/rO8dWTlbvjmM716MD9DXsf9HhTIX4bDAaxdgzQkHHPnoaFtjr?= =?utf-8?q?cD74xTUJPhPZjWQ4xZBcfIASZYNptFiMKoUss3kQBdVrUY9D89VTA0KOPmzmuNm4h?= =?utf-8?q?M2qbYPa1rkwdZoW2mpdCefyzMmdUheqZotXHGmp71YpmYrhK/zjm5ySl2uZ0tgcYw?= =?utf-8?q?OSBpKNZiI90?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:14.9990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08dfbaf0-2340-41e6-c0aa-08dcc3491026 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: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9068 An upcoming change splits HSMP driver into ACPI and platform device variants. Prepare for the split by moving ACPI related code to acpi.c from hsmp.c. Common code is kept in hsmp.c. No logical/functional change. We still have one driver at this point, the driver probe will be split in the next patch. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- Changes since v4: 1. Update commit description. 2. Add "Reviewed-by: Ilpo Järvinen " Changes since v3: 1. File header content is modified. 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 | 272 +++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 250 ----------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 2 + 4 files changed, 275 insertions(+), 251 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..61c072216fb7 --- /dev/null +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD HSMP Platform Driver + * Copyright (c) 2024, AMD. + * All Rights Reserved. + * + * This file provides an ACPI based driver implementation for HSMP interface. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "hsmp.h" + +/* These are the strings specified in ACPI table */ +#define MSG_IDOFF_STR "MsgIdOffset" +#define MSG_ARGOFF_STR "MsgArgOffset" +#define MSG_RESPOFF_STR "MsgRspOffset" + +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; +} + +/* 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; + sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; + 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 6da7c6189020..573867c17fd5 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -39,24 +39,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 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; -} - /* * Send a message to the HSMP port via PCI-e config space registers * or by writing to MMIO space. @@ -306,182 +290,6 @@ static const struct file_operations hsmp_fops = { .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, - 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; - sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; - 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) @@ -590,29 +398,6 @@ 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_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 }; @@ -645,41 +430,6 @@ static bool check_acpi_support(struct device *dev) 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) { int ret; diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index d59a9efb4799..f465600cb843 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -62,6 +62,7 @@ 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_non_acpi_sysfs_if(struct device *dev); +int hsmp_create_acpi_sysfs_if(struct device *dev); int hsmp_cache_proto_ver(u16 sock_ind); umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, struct bin_attribute *battr, int id); @@ -69,4 +70,5 @@ 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 init_platform_device(struct device *dev); +int init_acpi(struct device *dev); #endif /* HSMP_H */ From patchwork Fri Aug 23 07:55:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774738 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061.outbound.protection.outlook.com [40.107.223.61]) (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 8729E13D539 for ; Fri, 23 Aug 2024 07:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399785; cv=fail; b=lMk8ft/+T4dAe0QmniVL2iDWbW22EDRFO+meup9coK8Hcw2LhlX2hrK/UGf3KXEAwegFwq9dzlugZ4K/W30ZGgTERfHm9ELPCCXmQoyKj5JAsZAih7kQaaiTAdGv5DzlF17M+5rqWFxm28+7fzunubl3sSn4moLBPi/Xqs1j9yY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399785; c=relaxed/simple; bh=MXf8mRZ0bmHwni3Zs3EdHexSOT0wvdLeRwuDr/Azxkk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GrDqOYunBMP7dahvaFvMykvuJclkmCDFoRL9mG1ut4W7sNvuI0bPR+T2MKHzqg4F4cPRqDF9WQRXsoYUf8oddpCGWRJO2S1vXHjiDsq0CQ1LXzma5/TYvJAukudDoj0+1VeDg7QVc1vXyQldDdGR9jRkZpgqYUW/Dru6GcrMde8= 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=gCgcJUpj; arc=fail smtp.client-ip=40.107.223.61 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="gCgcJUpj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oNApOd7ocvkxNFSic33RqlLyCPwNR91i6vWVH0MgybNmniQGQ0iSXku1kQdtKMi6+IuiSOEU2YYaP6G/ctfOEC3Dy3nk6LlA3pKbEtA/xuR+ZCMoEnOc9RHVGvZkijDCnpWWMBqp+P1tdyhnqBeiF7boi4/5W6BBoloqJaOo26Qc3j85F8Q3/I8xaY7kzkKKfovauiGTyXEPQ+a04DW0Fwb3hX2Zgh93QuKFRWf01dXouW/RQf3PIwsNI7RvLqmsqMb8AiCxB1HIYb8IHR0XNNPVu8UQnsEubWX3AhQzjs3pmdj8lGHuxtGDfaeMHNVRAQe9vGfh7HDDM96/P9SlSg== 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=JGExhTN+4yGdFXYoBw+k7dSUcCZpVnC7fAOHoLVBbPo=; b=iLx45tS+hIJnVKkWyvb121mivSrX6CkFl6uH49qhmleJX40dRrzGntVIY4f20D5XKwVQtw/kAeZt/9R962M/RZXl5+Cn30m/7g9sosU1aqh0G45+BRbXMR73kZz7x+Xs6wFn6JeHGA5lUyWNdK6006tOkk+m+qZW2+U4OHJYPVLoSrzUcTZLuolbyYS4BunjUuzwBIkrWrgiP171epJsomLVyOn+Nvsv33SQLoOsOcmoGM1KzLhILKZRq/7qfqEFOqq6lEzqBXKhY6U2zNKn+qwvYVUykhVe4hen9oo+0k+WhrPd9RDm0SAv7CdGXdccl5Br7OVEdan6/0y8lAqamg== 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=JGExhTN+4yGdFXYoBw+k7dSUcCZpVnC7fAOHoLVBbPo=; b=gCgcJUpjmGffiaIwFjoDIMFuONbFN6jTAkUC12Q+CfGsuzx3ybfd1bsEnr414e+zHBjTo4K5z/Gr5MPu3SBagcKKeMhx5uOxK7YVgUZs5UjL9amgpUwsvNP0rH29j+axNIgA876MLEY6PQ6STG4B/ME+KqnMF5rz2pTqwbs/7/M= Received: from SA9PR13CA0096.namprd13.prod.outlook.com (2603:10b6:806:24::11) by SJ0PR12MB6942.namprd12.prod.outlook.com (2603:10b6:a03:449::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 07:56:17 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2603:10b6:806:24:cafe::8d) by SA9PR13CA0096.outlook.office365.com (2603:10b6:806:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:17 +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; Fri, 23 Aug 2024 02:56:14 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 07/11] platform/x86/amd/hsmp: Change generic plat_dev name to hsmp_pdev Date: Fri, 23 Aug 2024 07:55:39 +0000 Message-ID: <20240823075543.884265-7-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397B2:EE_|SJ0PR12MB6942:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e20e419-f56b-4064-9aab-08dcc349115f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?0tzfOfHQIClKoNFCzTdV7XU5jBagC2d?= =?utf-8?q?5EGnT/NcJn1H0MaISuZ/q/ZfHOISWPfADYIJfa1DjBNCKOL8TJAqPv0UWqYpIdJKv?= =?utf-8?q?uWfqJhHGHm5IanOQikuH6gXih/krfmDfyuinRZT9l317l9lCv6aYlbthhEdm1N8sY?= =?utf-8?q?k4efC2m/ICVSB3SiqeUN3a3ugCwbzW16Z/diDTmjbF4rxNFTLyCijxJ0k/gjmhfCz?= =?utf-8?q?UczN+tqqYjci2+prM/qrptW+LpxiDP5ZqXO3n/0H+tc5eTb7EAorQfA7rN4KAhFct?= =?utf-8?q?q9QxPRfXK/KvvfseXLmRCsfIw7dfDgdE4o98mrZnMbwi/8/wWLndgM/uoH21cabh3?= =?utf-8?q?GPFclUplGR2GoZKzNlx4xdEbsteMt7PrLnpJSl7W7ZQQsycbJPojyzcIUWaKavoF5?= =?utf-8?q?itYkXAr6hwe9ncsPZJIJgHmYB+mkyBJCEpR3Rs3zwwaPFVZKPn2aRUp1Sbr2ejxS4?= =?utf-8?q?YUoOrR7b6f5Q5X//IPrCOCHPE2sThWL9EREd2xHz+uuKWmyQC/Ql8K545AI/X7VQC?= =?utf-8?q?iO6PyonELh0esfO4FUueD0Y14ajIZ0wHaUcLwvdO8/xZ/dkI5Jd9hb4lVO5UL5m+4?= =?utf-8?q?aVLdD6t/mdEr7OAr8BAjlNmOB05aNMGqFq2Sqo8uAF/HiefXZjbmLXmqCA+Pumbxz?= =?utf-8?q?F3c6DfO3C7MNo28HtHWwpMeIT27eBbmmH23oY+JA8IsPGsya9CAVadecIqC1FdnBi?= =?utf-8?q?LiY0U8N6f/4bt2MiJO07W8gT+DGfBEKS3uEspqEY2aMEwGnminQ4n2JaC8hbwBfIR?= =?utf-8?q?tSKGzoyVCvjRShHjXPZR/nKgrM2b1r3BUU0kNa3omuBjAYkiPaRynhRMboy5ttk4c?= =?utf-8?q?LbLva0VsBnTGnqi0DN8gBeRtiI4X4G5eU5j5I5+UKjYyVQI/RMU6rq3IeP1yepM2Z?= =?utf-8?q?nPKQWzJFnbAVNzPb/P9apm+qFQ0+KXc9TbVirSLFrC8xu+Ercvq5fyDhTNdJDD8MU?= =?utf-8?q?aGk9hM633ZBMeJTQTOhan1ln2FrEXRQvCttIfTEis9pqo3MntJqAZxy9MXPM3DGyl?= =?utf-8?q?5DiUNlogS9W/csqp8MUzcpF13tdyT4gwMOrFPb+n5bL08Or7QmgviXTP0vDX2tkwv?= =?utf-8?q?BVXfMwqmtRI7NHpQEAVTofr61XtNn4kwlKZ3OYHarwP4p2E5p6AvbUh5Hz6BmmCbw?= =?utf-8?q?jf/URMS92t1jwEvee9CNplo/UTM2azKv9DPMajB0H2dz7FQGcgnhXGzbZ8xNWpLQE?= =?utf-8?q?sJZGzoLdbSDFMMjnxE18ZQ6NtEVJyO6Btpc9QyKmoepnqxe8yc8b7hvhGQOVoYCkr?= =?utf-8?q?dpSxAfQ2GIEQp0eaQeNWvXCDhhXLE9KulPb9dIvqfieSG4ZcIXGeJ0Ak80k7YgxMT?= =?utf-8?q?vUYLUQI7NI418IP31wiHSOY1mcfNltCcTrr17EuCCqgW2nly4knjaZ/hk0I/Sc7rE?= =?utf-8?q?O9cgEAmnxnq?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:17.0493 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e20e419-f56b-4064-9aab-08dcc349115f 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6942 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 v4: Add Reviewed-by: Ilpo Järvinen Changes since v3: code indentation is removed in hsmp_parse_acpi_table(). 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 | 6 +-- drivers/platform/x86/amd/hsmp/hsmp.c | 60 ++++++++++++++-------------- drivers/platform/x86/amd/hsmp/hsmp.h | 4 +- drivers/platform/x86/amd/hsmp/plat.c | 12 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 61c072216fb7..6f8e7962266a 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -194,13 +194,13 @@ 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; sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; - plat_dev.is_acpi_device = true; + hsmp_pdev.is_acpi_device = true; sema_init(&sock->hsmp_sem, 1); @@ -244,7 +244,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 573867c17fd5..78945750d590 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -39,7 +39,7 @@ #define HSMP_WR true #define HSMP_RD false -struct hsmp_plat_device plat_dev; +struct hsmp_plat_device hsmp_pdev; /* * Send a message to the HSMP port via PCI-e config space registers @@ -176,9 +176,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 @@ -219,7 +219,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; @@ -320,7 +320,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; @@ -354,7 +354,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; @@ -362,17 +362,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; @@ -409,7 +409,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; } @@ -441,11 +441,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; } if (check_acpi_support(&pdev->dev)) { @@ -468,19 +468,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; @@ -493,9 +493,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; } } @@ -567,15 +567,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(); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index f465600cb843..9c5b9c263fc1 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -48,7 +48,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; @@ -56,7 +56,7 @@ struct hsmp_plat_device { bool is_probed; }; -extern struct hsmp_plat_device plat_dev; +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, diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index 85a104859acd..e18cf82478a0 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -56,21 +56,21 @@ 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; @@ -93,10 +93,10 @@ 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; From patchwork Fri Aug 23 07:55:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774740 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2082.outbound.protection.outlook.com [40.107.212.82]) (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 A17B013D601 for ; Fri, 23 Aug 2024 07:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399788; cv=fail; b=JzN6fYeHsWO5KFlAJ2dliU0OE9NPzvYTJfqcEXnaDxa5OD/Xzq/H0Tc7HCFHlCr5TP2EYUvd66avRvG1kYriCCpTtPqr0HtIcaRRSlUBBSKw88ym4F2dxfKOZ2Lq76vwWaTDVufAYY/FzuEAFkMEzIr7pPBDidGVSkmbRdCiXeM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399788; c=relaxed/simple; bh=eIDIsH4uhkICQP/YapjBxtU37JtALZQP/PNzk+RQrYM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=plMdJsxl5+IKXVWp5MPr3D1s0//Bc4Y1iHvDKjGpHzeQuAgl2iMh9O2X+8GUACqr3i6HYaiQ6BUMcWy7B/po4wcPUfCYdoCYHhUYu4tsT9AgvrguLcWrng9Dph8K5kG+aKv9JsaP1d8ZzINrABi1N5JDQWANrN/2GJgMe/Di0SQ= 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=45uAuWrH; arc=fail smtp.client-ip=40.107.212.82 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="45uAuWrH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O4Zto+HVPBcTvOjqSxmKnDEYl9i2gqMTZXv+XE49qBxVImCC0XOyPvNBc0T9kOBVRUBfDgbOvknIgBjSGLx8cuwwjaV5ZD5oW+/LhRdJl9VNYV0egWgahmM8c+T8/xSzGx63JcjG5fNP/xJwo63vEJkxBq1vzqZWb4FAnP93BuJ7shYgo4xFzgRdKI9OE/x+Gel+NBYkAASMcxK7iTCAekthzIhzX9KeIA7HTREfJVBvHBZW6YOJxhB2C+1LLY1B09QG3XO7NJ8nvwcPYKFOvujHFYdf81jOeL6DhOX7NXN6l5lJ04GegQ6xw/xSgBTU1koH4c9EA/CyA81NA1oouA== 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=k2eB8bEt+CJ/CX1R5pFuEP4VwRWb2Vu9elblxWux7Bo=; b=p57n3DsOiy0GE7esNt0OxtJ/ADkSPrV6+ezJfPEvmii6EatpKhCF5ynzVpK1GkUm0w9DVc3BZRo7GJ63KrB/9r3V3E7f7wqXw3gTpVoeT8r7lTI2wEus6zP8SjAmkFa4LHCkPw3i1X2CWBFYWsrfLcyZ79GMkUBgFYfRKjDsVDoFNdj/D8zFSmoy+qYR4p2pozWhtbIlC4dUCz07xfJeLGoxEweRQVdOBqWs3eS8wamJ0afeHfL1iB5BQvxKI5876/zPZc4IoRtErS+h8C67JVeNRmPdXFQs0vgye329LZHmrkgQ5Q1xo51pMRK9vvNyvvGm7fHC7jG2Gz1wM7Z4Ig== 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=k2eB8bEt+CJ/CX1R5pFuEP4VwRWb2Vu9elblxWux7Bo=; b=45uAuWrHbEyOM/FTM81YQmA9A7BiyXVOfwJG846SLNQosdmj1GaHatwFO+/KfpjaYe/k6wSreyvwALgLxLc8KwLKzKj2smUEyv89UCPNlH4UszqDTQ44PCo+E/RkFROhHbpRaD1/MmGzh7qPE+zWHibUe3t/CULr6rMipjrnN9c= Received: from PH0PR07CA0092.namprd07.prod.outlook.com (2603:10b6:510:4::7) by CY8PR12MB7610.namprd12.prod.outlook.com (2603:10b6:930:9a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.27; Fri, 23 Aug 2024 07:56:19 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:4:cafe::37) by PH0PR07CA0092.outlook.office365.com (2603:10b6:510:4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:19 +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 SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:19 +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; Fri, 23 Aug 2024 02:56:16 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 08/11] platform/x86/amd/hsmp: Create mutually exclusive ACPI and plat drivers Date: Fri, 23 Aug 2024 07:55:40 +0000 Message-ID: <20240823075543.884265-8-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397B4:EE_|CY8PR12MB7610:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bb493f0-37d9-44a4-a097-08dcc3491299 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: ir9r0Osdt0msEkRHdJoMCOqM9bt8MF3uPwzpCrPE1+lN7iMbJjrFFyciTJcS/x5Jn7ZKtQoW0RuDR+evs7VbIb4EA/nTdnEqefR10VXG7+F1YGb34ORUuxaWFNCeLtKAi6uz9U4h7DdTHy2gDvtffk/isNFnSd7k1GRdW2N/D9BM5QCSg83RPSAt9jSHMS3tKrB70lBUh1iToJ4tcQ1Y1T3JYngoTfmrc88iZadv8YDQRqTwhbHggMhA+cO6x4I2Be6l8plzJi/UlA9Rj8AkWQRBq0XQTcQ+SuvX9lhzERmtCLHPE1/gDua/g84iM9rofTmM4db+3/yE4bOWWUM1m4kxSZalElwSmV3p5uKgKdJmQaRhsJ8I4rxeLtinrj4wd+qVo9DSCpJ0zSndMHzOvI1DSF2WQJTzNxjH3k72JHbIsN0S6afTZuH+wWnf258TrB1wRwLgIW+LZnfwooZhAVVVzC/1xiTzpP7uZDpYU22JMBVJqsARkuDPC6lWCUFR3LX/EIh7hD/Ek382V3h5fp9teVOddiOUw00hzbHSSi+mz8u/vv+N/AJRtnPSbAQEOucuDMJGz9VUN11mUJTRixXSGm0ts0BYjSNbVbuiFj+bbynmEXWxxhk2Nf9YWw/o4EsAk/+PCJG7X/g8b5azCiKiCQFk9Mw+uyzX+FI/bofCKGYEDpXpKDoNIzZp+sqsyECV/t5Ekn1dEUC1szvtZMmscY1vWeiZkX+DBGbfUlm2Y16rnsQZBqgxkmTc82jMgVmr5u9/6EsBdTwzhX2Y4ysoQK4ttYMoOM6ODWY3a00kEXI0GMGODMZ4rcZK2+wb5WWcUPJ7P1k66gWmlnwakk9KcM5LUYXJBF6IMj66dVR87eslc15vxBbLHJI8U9RM1KqjikVYnDgzSCCNVTdhjNUl3jG/Ey4dvCPFWaAMtoXcdk9h0XhxzdBE5XAY5s99LnKWj2rj+QyXE1YJJXU+jiKU4csQZPNXfYSCJd0cpklkdXxDnXOXCGwEj7v3RFfo3Qtt0YxjKwFut++W6IlA4+awWqC7XrgNLVB4xtQBT+fZKXMD13WkZSem37Q1sT7nFUuQ433cOemlojW0YPd/aCgcRnJ7LkecimFD4GrnMHK/3S3i4XgnjRzLCWPDFTJVVZT7q6S/CRyx0AtMFHstmSYcBW8FuWjo/K9poS7Xu6hB8u2kAmHUPYCHrC9z4MXumGhCGfvAg4tbQVoOjSMwkJBN/V/AkAAQw2w0UhKTrRdrQbNVFf2Exz8q+AApSVoXTqB1Px/3CkLX6vp2pCel5Aim7CWlSt3K2/VqCOb76/xCiyaMf9ZZji0f81fY8hNDjxANq+VrZc26PQoF1XETr0Kw3fbxD9Mv5mXr3qFKPAJGWUWsYEr2x53zoEZ6yqbpJ1dgUHCvM2xAqyaGqNg9pQ== 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: 23 Aug 2024 07:56:19.0917 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9bb493f0-37d9-44a4-a097-08dcc3491299 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: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7610 Separate the probes for HSMP ACPI and platform device drivers. Provide a Kconfig option to choose between ACPI or the platform device based driver. The common code which is the core part of the HSMP driver maintained at hsmp.c is guarded by AMD_HSMP config and is selected by these two driver configs. Also add "|| COMPILE_TEST" clause in Kconfig to get build coverage for HSMP. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v4: 1. Update commit description. 2. Move common code from plat.c and acpi.c to hsmp.c and name it as hsmp_misc_register() and hsmp_misc_deregister(). 3. Reduce line size in documentation. 4. Remove check_acpi_support() related code. Changes since v3: 1. Added documentation for ACPI object. 2. Kconfig is updated. 3. Added COMPILE_TEST clause in Kconfig. 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" Documentation/arch/x86/amd_hsmp.rst | 62 +++++++- arch/x86/include/asm/amd_hsmp.h | 2 +- drivers/platform/x86/amd/Makefile | 2 +- drivers/platform/x86/amd/hsmp/Kconfig | 37 ++++- drivers/platform/x86/amd/hsmp/Makefile | 6 +- drivers/platform/x86/amd/hsmp/acpi.c | 82 +++++++++- drivers/platform/x86/amd/hsmp/hsmp.c | 212 ++----------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 8 +- drivers/platform/x86/amd/hsmp/plat.c | 144 ++++++++++++++++- 9 files changed, 337 insertions(+), 218 deletions(-) diff --git a/Documentation/arch/x86/amd_hsmp.rst b/Documentation/arch/x86/amd_hsmp.rst index 1e499ecf5f4e..2e5802783da4 100644 --- a/Documentation/arch/x86/amd_hsmp.rst +++ b/Documentation/arch/x86/amd_hsmp.rst @@ -4,8 +4,8 @@ AMD HSMP interface ============================================ -Newer Fam19h EPYC server line of processors from AMD support system -management functionality via HSMP (Host System Management Port). +Newer Fam19h(model 0x00-0x1f, 0x30-0x3f, 0x90-0x9f, 0xa0-0xaf), Fam1Ah(model 0x00-0x1f) EPYC server line of processors +from AMD support system management functionality via HSMP (Host System Management Port). The Host System Management Port (HSMP) is an interface to provide OS-level software with access to system management functions via a @@ -16,14 +16,21 @@ More details on the interface can be found in chapter Eg: https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/55898_B1_pub_0_50.zip -HSMP interface is supported on EPYC server CPU models only. +HSMP interface is supported on EPYC line of server CPUs and MI300A (APU). HSMP device ============================================ -amd_hsmp driver under the drivers/platforms/x86/ creates miscdevice -/dev/hsmp to let user space programs run hsmp mailbox commands. +amd_hsmp driver under the drivers/platforms/x86/amd/hsmp/ is now split into separate driver files +with mutually exclusive compile time Kconfig options to choose between ACPI object based probing +or as a platform device which continues to create the miscdevice /dev/hsmp to let user +space programs run hsmp mailbox commands. + +The ACPI object format supported by the driver is defined below. + +Kconfig option CONFIG_AMD_HSMP compiles plat.c + hsmp.c for platform probing. +Kconfig option CONFIG_AMD_HSMP_ACPI compiles acpi.c + hsmp.c for ACPI probing. $ ls -al /dev/hsmp crw-r--r-- 1 root root 10, 123 Jan 21 21:41 /dev/hsmp @@ -59,6 +66,51 @@ Note: lseek() is not supported as entire metrics table is read. Metrics table definitions will be documented as part of Public PPR. The same is defined in the amd_hsmp.h header. +ACPI device object format +========================= +The ACPI object format expected from the amd_hsmp driver +for socket with ID00 is given below. + +Device(HSMP) + { + Name(_HID, "AMDI0097") + Name(_UID, "ID00") + Name(HSE0, 0x00000001) + Name(RBF0, ResourceTemplate() + { + Memory32Fixed(ReadWrite, 0xxxxxxx, 0x00100000) + }) + Method(_CRS, 0, NotSerialized) + { + Return(RBF0) + } + Method(_STA, 0, NotSerialized) + { + If(LEqual(HSE0, One)) + { + Return(0x0F) + } + Else + { + Return(Zero) + } + } + Name(_DSD, Package(2) + { + Buffer(0x10) + { + 0x9D, 0x61, 0x4D, 0xB7, 0x07, 0x57, 0xBD, 0x48, + 0xA6, 0x9F, 0x4E, 0xA2, 0x87, 0x1F, 0xC2, 0xF6 + }, + Package(3) + { + Package(2) {"MsgIdOffset", 0x00010934}, + Package(2) {"MsgRspOffset", 0x00010980}, + Package(2) {"MsgArgOffset", 0x000109E0} + } + }) + } + An example ========== 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..6740f68243d7 100644 --- a/drivers/platform/x86/amd/hsmp/Kconfig +++ b/drivers/platform/x86/amd/hsmp/Kconfig @@ -4,14 +4,45 @@ # config AMD_HSMP - tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 && ACPI + tristate + +menu "AMD HSMP Driver" + depends on AMD_NB || COMPILE_TEST + +config AMD_HSMP_ACPI + tristate "AMD HSMP ACPI device driver" + depends on ACPI + select AMD_HSMP 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. + system management functionality on EPYC and MI300A server CPUs + from AMD. + + This option 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 "AMD HSMP platform device driver" + depends on AMD_HSMP_ACPI=n + select AMD_HSMP + 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 and MI300A server CPUs + from AMD. + + This option 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 6f8e7962266a..0fb730177ea1 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -9,11 +9,15 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include + #include #include #include #include #include +#include +#include #include #include @@ -21,6 +25,10 @@ #include "hsmp.h" +#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" @@ -200,7 +208,6 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) sock->sock_ind = sock_ind; sock->dev = dev; sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; - hsmp_pdev.is_acpi_device = true; sema_init(&sock->hsmp_sem, 1); @@ -213,7 +220,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; @@ -236,7 +243,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; @@ -270,3 +277,72 @@ 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 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; + } + + 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) { + ret = hsmp_misc_register(&pdev->dev); + 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) { + hsmp_misc_deregister(); + 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 78945750d590..5e0c9c36f435 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -15,17 +15,11 @@ #include #include #include -#include -#include #include #include #include "hsmp.h" -#define DRIVER_NAME "amd_hsmp" -#define DRIVER_VERSION "2.2" -#define ACPI_HSMP_DEVICE_HID "AMDI0097" - /* HSMP Status / Error codes */ #define HSMP_STATUS_NOT_READY 0x00 #define HSMP_STATUS_OK 0x01 @@ -228,7 +222,7 @@ 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 }; @@ -284,12 +278,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, -}; - 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) @@ -414,193 +402,25 @@ int hsmp_cache_proto_ver(u16 sock_ind) 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_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; - } - 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 (!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_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; - } -} - -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 const struct file_operations hsmp_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = hsmp_ioctl, + .compat_ioctl = hsmp_ioctl, }; -static struct platform_device *amd_hsmp_platdev; - -static int hsmp_plat_dev_register(void) +int hsmp_misc_register(struct device *dev) { - 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; + hsmp_pdev.mdev.name = HSMP_CDEV_NAME; + hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; + hsmp_pdev.mdev.fops = &hsmp_fops; + hsmp_pdev.mdev.parent = dev; + hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; + hsmp_pdev.mdev.mode = 0644; + + return misc_register(&hsmp_pdev.mdev); } -/* - * 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) +void hsmp_misc_deregister(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; + misc_deregister(&hsmp_pdev.mdev); } - -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 - */ - 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 (!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); - } - - 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 9c5b9c263fc1..9ab50bc74676 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -52,7 +52,6 @@ struct hsmp_plat_device { struct hsmp_socket *sock; u32 proto_ver; u16 num_sockets; - bool is_acpi_device; bool is_probed; }; @@ -61,14 +60,13 @@ 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_create_non_acpi_sysfs_if(struct device *dev); -int hsmp_create_acpi_sysfs_if(struct device *dev); int hsmp_cache_proto_ver(u16 sock_ind); 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 init_platform_device(struct device *dev); -int init_acpi(struct device *dev); +long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); +void hsmp_misc_deregister(void); +int hsmp_misc_register(struct device *dev); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index e18cf82478a0..74be46a64c05 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -12,11 +12,16 @@ #include #include +#include #include +#include #include #include "hsmp.h" +#define DRIVER_NAME "amd_hsmp" +#define DRIVER_VERSION "2.3" + /* * 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. @@ -50,7 +55,13 @@ static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, return ret; } -int hsmp_create_non_acpi_sysfs_if(struct device *dev) +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; @@ -88,7 +99,7 @@ static inline bool is_f1a_m0h(void) return false; } -int init_platform_device(struct device *dev) +static int init_platform_device(struct device *dev) { struct hsmp_socket *sock; int ret, i; @@ -134,3 +145,132 @@ int init_platform_device(struct device *dev) return 0; } + +static int hsmp_pltdrv_probe(struct platform_device *pdev) +{ + int ret; + + hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, + sizeof(*hsmp_pdev.sock), + GFP_KERNEL); + if (!hsmp_pdev.sock) + return -ENOMEM; + + 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"); + + return hsmp_misc_register(&pdev->dev); +} + +static void hsmp_pltdrv_remove(struct platform_device *pdev) +{ + hsmp_misc_deregister(); +} + +static struct platform_driver amd_hsmp_driver = { + .probe = hsmp_pltdrv_probe, + .remove_new = hsmp_pltdrv_remove, + .driver = { + .name = DRIVER_NAME, + }, +}; + +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; + + 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 + */ + 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; + + ret = hsmp_plat_dev_register(); + 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 Fri Aug 23 07:55:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774739 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2089.outbound.protection.outlook.com [40.107.212.89]) (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 EA79913D606 for ; Fri, 23 Aug 2024 07:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399786; cv=fail; b=dN6EDnSLBGQhHg8UqzcpTLSdAVPRuRMxil/+Vp4s3enHSVV32iiHsu3qsB2rFPv6MPAlH9/UQ08m5EH/a1oZOUmy1CcQAz4adTrF1nGrPHe/UNwpnYdEOMIN6WjYWLrnnBgn2on7HJmSKYryHhRGkzBi2NvAhQKP1pBOoiche4s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399786; c=relaxed/simple; bh=sgnmehs5XSxSUGy73WNxXoNWZnuk64iwITrFeLCE4zI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AYAGj1l/MTmZJX7LERL2GXhQU//W04rbSrzuagEy5pZYlT0ZW6eMCVS16/+IpOAkX5URgfibpyQPxV4gk03CS4yk3Q0avrBn19NCfMoAA1IzQ+8dYDnrOmHIfWF9oSPbkOyvlEcQPWVQU2pXqogoNWejis0Pd30uDJZeIBPZXKs= 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=f7PraHfF; arc=fail smtp.client-ip=40.107.212.89 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="f7PraHfF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v4qOduRvFKtl72imBqQUBDtgMSHwMMAXMi3t0D9srriDhhBNtPDfBU6PMG85smrTEvKmGbcRgtZYUOjZdA1lBZlKGpJvGmD+ChXGuXmxLsJeCb2kRwhozWY2zqTcf1M0GCwSwigU+8j8RgnIgE+1nc158EDhA1GUv1ARYLVrjJ2uqfJfgpJvr34LPv32keM8a3Ly3kCqhqzjQ6WkdS+XcbI507nv1IDrvMh2uqLkb6i6TmkkAaak8tgOpj4iy6XN1gXnLWlGmkTd9cCgScf9plIWQWy35Vo2Adjs0PuaSSLnh974XZeDalZrW/PiDgt5G3hYHr59MEvS6wRtJ7VzrA== 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=z6gi+7YyuxZtNgz19A2WhP6E9c8cSl81xo95PJku5sE=; b=dAQOGUuUZnkUrC6xDd9sbs8H+q0qsEMZIoWF9yAJZ/4KkQTJzXt2iL3tqK1N/oEd7mDiaQkemUdNLUpAHacYQDGojOaZhcbIz2ZSFsCHOHKXOr8TNmMVo2o7t2/AHJoGP0zHlVYVnHe8N62FL6rudBq5+6zU8Hy+4NNeYbD466nOkdT9JMtbYZyUg43V6vNRCy+QOAQ74mP9h0vXO1cjY0R6IEnIRWk1j7L74xsvjjUKAKaoYmnuFhgfer+vlUS5nW9DzQ9cmfj1mYHqyoQjAGouf+6o92k3tGmbCgeQxIe3BNKmEUcDXV1KtykuFwqxXrs5BH6D+SPi8fL8Mlw+XQ== 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=z6gi+7YyuxZtNgz19A2WhP6E9c8cSl81xo95PJku5sE=; b=f7PraHfFB+dH3ldh04zf2JjNBGfASmp39c3oU4VnM8TSVHyqZCcBqOM2ZdWJmkK0Rnm6R6R5oOQ5IkmpL+NdJiHZ+Bkc0a7Ed4VUo7okHQBHNXtEiGC95XddkTyg+F0JZ4rFxcL47jMoWqP95fjb76Mrt1U7xvQvcxSiM4UPK8o= Received: from SN7P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::13) by MW4PR12MB6899.namprd12.prod.outlook.com (2603:10b6:303:208::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Fri, 23 Aug 2024 07:56:22 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:806:124:cafe::56) by SN7P222CA0019.outlook.office365.com (2603:10b6:806:124::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:21 +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; Fri, 23 Aug 2024 02:56:18 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 09/11] platform/x86/amd/hsmp: Use name space while exporting module symbols Date: Fri, 23 Aug 2024 07:55:41 +0000 Message-ID: <20240823075543.884265-9-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397AF:EE_|MW4PR12MB6899:EE_ X-MS-Office365-Filtering-Correlation-Id: 364dc322-8c09-431c-363b-08dcc3491414 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 9FaEdzNfPeP9g2cAFTqSoUL09Y20lKY+AnvJt0VR6Da3xFRbBOEi+OIQwg5eE9h9W3W378gaETstShYGSTqqAbYvt7FFNroRqEDZ041u5/kd5n4Eu5WvtUKbb1VCXpeFAkYMQmLgiwrze7GjigVS4EPF5bPH11TQVVPfxHh7PfPzshvHqNt0A06fsjktmQ3YjE9uRM4qFakTcfELfL5gbgt0AOv7TXk2FoP0ppTAsAgosltJceLCmfFTYK8eNgrQXBwqOACPYxvYiuBmES7ruiGFEDpjdAeeSvSl3L6CJvOf6hTsPHXSMp+HMto7bawZFWWeqHpqZ4Z9/gqtxNSW/8v833ZUq7j4s/G2YuXeLIn85B2gJa8pupfEtOqNT9R8NG3jwtnPIpAMOyCkJZ0vlYoJHr27eLFCcns3fM4AumaeRPKbE55eMYSyWD/ZDv3fY2/D3SAn0LsF7NDeuBp5IwOsP1qE6chKHiNlEvZ2tp01qfVckrdr5K2s40hYS5ix1V7xoG3t4rr8Tktz19dCYhh4wNqDIB3NMAiDAPmCI+aaX+3IKmqCO2A7b5P4zanuJAMl6KY0zZJkfDcUJVgolGo2XPOgOYK7rUA9bZhs2j4kLJtw4U7WvRyYbm5tZB2n4SbFpDSjgHZ2Jo/7NvT6h5RzlN8OsaRRZABz3eQDyQB/2ekAAGN3oJEyym3nQcI7sffZPZa29IB1cpoKH5z/+VP47RLQ0zr5HWBbZx0kOeHX3bb7bRTOfnT80C7uK43DGqO/tDQF38h5heJVopwZGrxGpO7KTEtTQN2gAzuwAxKAlko0ZpqhP083+aBkQj2VX6XUUPiplb54lx+tdt/3IUhaBcKJxLZXiRKdSI5L8qZJ4eYZ2H0sLt7BfpmORUpjG0PqNqmaN0rtZNQSI62I5Zqef9tcM8wFWTXKoDLGazse+GbCZSKYwioe2obCNtuPOMdiWyDa5Kr0SUGLwsci2+KdlhnXvxsJ8e/6q3Zd1lyTkFJP0t756u2kvdrAYOLZqNJ+OR5UMyixwab3zYPlDevMH7BVVZUdf/AazQfFMVNL+Vo6y7eGHwGypcAlC45pJgR643373h1LUQ8C4fZA0PD6Uia0uYaBPMOwSXkJ1V8lkPsYuEevsbKNrEm4AtWWtmfjMrK9S+Xi2hfwgV/Omh4zAXHn+oCd0821/Ukwoz8JVjZ/ddDMmNBDTJ7uN6+Et8nC8TRtC3RSVxDIWw4ElZxWOq5IuN9c7yAhFqnOrAUFm0xwqz6k/J79usOBSZoZ6TsQqwqssBDbMeRK2qLzEJg7vSPY2SQg3Hsyyd6hz53bmYDfWQEagzHSqntyuRXhAIWEej3mcT7MzVvwA8vw1EeC3YcP7wyz4OBjCROpPBEmzrGvJnVG3BE/ZyMtKLac7d4WsgvWJY1cKX27v3uIL775rNvr6wPwzicBimOr64s5/eo4PTB/It6coQT4tQvV 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)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:21.5728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 364dc322-8c09-431c-363b-08dcc3491414 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6899 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 v4: None Changes since v3: None 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 5e0c9c36f435..8c8e361b1feb 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -190,7 +190,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 Fri Aug 23 07:55:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774742 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.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 2337C13D8A4 for ; Fri, 23 Aug 2024 07:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399791; cv=fail; b=sOcENH7NwgXp4401DJVmpTbt4xko0dqQMR6dQETvS0Sfy0zPsLh2cifmd+62qwe1djpy5afZYLeQRBSioghi7j1Ds0ji6XNDUyojOYxv/OI6z6ev0nxEqFqHUWPhZzyUrhYUws8VmErFMtnY9bFa0csDWY95d8RfWT4DZnDEetM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399791; c=relaxed/simple; bh=wDTtMhbJMy9Huc7u+uBaGi0q/bvdkN3btMd4Iw71gR0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dIuhirBKYpJP/pAOtgPjWRDAT+XV11QV6gyQ37hei5r17MjHoT/UCPxgVuKz3ooPbUqKkrELCSO4c/wvpmEI4Wl1QG16YEgU5psY7MfXLbMr3RSqkFjZgzxTtuHi13ThNpaPdR/Ezx3mtDhI8GfcoAGklMheZgFEIxJWpRNAOnY= 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=AHH5bKPE; arc=fail smtp.client-ip=40.107.237.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="AHH5bKPE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OQq86jl7wEqr0djTArh1ddUFPgTxfUHLts8DSeC0gCWkVQMwMGiKQgybifMYrqsnPd/z5IvZ87vnsu+dSJLOv4NT+WBvJpjBWlbHbQQB0rijI3KXHfU8b21PiQUrkH57gpKcecF+RXoC2lTkNQoFR+iehvInta+nV0UwWBA4j577qyV/DOoOmSmThnBIfdQ34ZHojtocT1fRpI30/yg2dJZnakRcPQjYNpZ6oCxEuTOVtOMzjBoMZb2YxMeQ3q7MGV7A21JU8dSDVnqQ35KJmdLXXaANRtUGmMB9h3FoO0VK/6XxE9VGjiRiANc/MjL8Xd0NmHs2ic2ZRIv03mg2Ig== 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=OPyyCgAKklKvjlNv8sfQT3TUAACLWYa9TSzMd2RND3U=; b=zVWZa2B/aB5LEClBJtruFALStb0cHWjqy47Klmgl/aROPkoNxXGFQe6HGgkOXaaMAaDnCVgBg5EK7iHFnjyhHdgSZFvP5WklfTfQMm/g/20qrTQEZ1Hnfs4iITUbc8PxUHxIsYiLHiyO52EspdtjauctTolw4e2eTp8sXftFu5n+GfnSxFwjfTatTAGitbNyfz80DzGV1mWge0Ocp7SIp+/AKx0ozrgHm16mpunN3rXQ1VTNBN3xX52FUUN+jDPmmlDIg11I56Am5ZnzvVRQD0gOP5VP7A0dhBt+NKl1IhH9FaJBgNZEK3y0BOIJcfsF7JrSr0KfBwrJsUdpYxd5kw== 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=OPyyCgAKklKvjlNv8sfQT3TUAACLWYa9TSzMd2RND3U=; b=AHH5bKPEKGgiqLv6uYykMSu+Dw4aZ7aPsPqdl/NTYvohC21i06Mcvbr/b+UtaSvnuUVzLmcn8hneIRGa1vkF2RNQejEBwX4447l85CKxqnhcKGhrn+TA78DheUsg4mQqinFx3sZf29/5W5f5lqivukRl8FdyVyq3fg6Scqa8eyI= Received: from SA9PR13CA0096.namprd13.prod.outlook.com (2603:10b6:806:24::11) by MW6PR12MB8736.namprd12.prod.outlook.com (2603:10b6:303:244::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 07:56:23 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2603:10b6:806:24:cafe::8d) by SA9PR13CA0096.outlook.office365.com (2603:10b6:806:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:22 +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; Fri, 23 Aug 2024 02:56:20 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 10/11] platform/x86/amd/hsmp: Use dev_groups in the driver structure Date: Fri, 23 Aug 2024 07:55:42 +0000 Message-ID: <20240823075543.884265-10-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397B2:EE_|MW6PR12MB8736:EE_ X-MS-Office365-Filtering-Correlation-Id: aa4d1678-e093-44bf-f8fa-08dcc34914eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: QM18kdUqHRazLu64RESB8Hc1Wj50ac3zMebHOGt6lhkaSekXQ/GF/Tmw/JnNepQKtT1b1s154w3cKgroIB6yOS3gZ/Z1eglseOpR++DdxTGhHRB0N6fDvvwWIRiz2TGZBz7nC+TMOkzysKurW+ica9UbAR+//XnDgqCuFM9KbGdrRki7cYOTJsTxB7KOKxGIP2uP6VYrSkT3oHQpBkOYD9pL0jlz1dh4P/dd6/wSChRXEfNj2TcHn+hKs/rERLVkcYFDw6jKO+VxhoxEYj8O29P8/5aFV+8YyUkK9Y2tpTIT87wZdy+C0/TdFAQz/I7stgyqLnw31uJxKJsfoSJgoJsZFXItkXUYDDax37qAcJqPsVlH6vfPe3Jw+KsvHachUk8bSBWcWcNxkZXmaDhaRilArooxN+oj6F5L9/nlVeVDYwEB8scsrHtX52d5dl+0weB6u39oXkTA6/kdNFxwQT9mxG5mLn7Lx2q/dwZIXbRkp2wNIhlpTeumN934fwL0RpaXialIOb74t5QMZtzutYp6QeuYIcbsfKbNI0r3JbuywKmgHBG5AfG0OfHsNcy4cO2KSoBpKV/2zsBeDDWDf6ogqiy0NMuXXj9EOLmr2Rlziks59mI9evaarJR/k/6m43t0pu8mYYCJWbkoB0NVEEO0xCayg63ZklxWW23j7srEunJsdBOD3haHISKt+hV8yKHJMfO9/SHizsCqbB1/tokl5xphBgK64EVYyeos6rZSl9bMDECB54zxvOZ46/8asVJ1Q4lsQWZ/y9bTnpXCudFBxpIZt1i3ZTrxhYMUGngBfPpbhG1Uinbz3bnup1g1WSYwwQ1j9ZJ+BCNKskmiViFtJ+QTqGpJ/4TmWenAt7bShBOYCo76ko82aAZGARMOv0X6DGwzKaKwqBojd0V7UXCGYczZo1hKyLTC3gsC5Vye8Wn3s2s6xx6l05RUA+Ec8oIQ1dZSjIyHUIUyZgXg8b/mfU04zy/lVZM4xi4Am19LN1wGke27SSfyvWnGM1sVGleJwtD+8hDczhI5jwGMMHIzO6/sCGzw5iye8rXfny+xhkn+LzxKlie3UnRS0WvSVtOApw3mwZgJ+hjbLVvl148EQtRn1pDh9s3+Nx9NJuA8iHeUzU+6E/hr1Kzpicj/vJWq3KqQGntrvSVObcwAuDEKYnYgTFPUePtFvpOVULhlp6nF29WcLP8ByljeXgfxcotcZvLBDN3g+b3mVpBobRcmSTIT0s+AijoTB0D/baV3NyCnreccLAFC02a/hoUElEpA9s60fI97vtohfbwUCP6bI+Vix9GT38okDgRM/9IQzZDHpZoQH5NExVLUtZuSWu2h0OBMDbnCqSys4wafykSgzx18Ll9+IvSz3Lc3qSwvHC/pyY4fN/hlVUmgDELRi2xY9hXYvakuqM8bf3Cr5f92HxwPhJemUinn6v5Bw9u/I6ATO1Imy2iujOz1dpSf 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)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:22.9868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa4d1678-e093-44bf-f8fa-08dcc34914eb 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8736 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. .read() and .is_bin_visibile() have slightly different implemetations on ACPI and non-ACPI system, so move them to respective files. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v4: Change ->private from string pointer to u16 pointer. Changes since v3: This patch and next patch(9th and 10th patch in v3 series) are merged and commit description is updated. 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 | 74 +++++++++++---- drivers/platform/x86/amd/hsmp/hsmp.c | 77 +-------------- drivers/platform/x86/amd/hsmp/hsmp.h | 8 +- drivers/platform/x86/amd/hsmp/plat.c | 137 ++++++++++++++++++++++----- 4 files changed, 171 insertions(+), 125 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 0fb730177ea1..f2bfc5981590 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include @@ -211,6 +212,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) @@ -220,27 +223,42 @@ 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) +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 attribute_group *attr_grp; - u16 sock_ind; + struct device *dev = container_of(kobj, struct device, kobj); + struct hsmp_socket *sock = dev_get_drvdata(dev); + struct hsmp_message msg = { 0 }; int ret; - attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), GFP_KERNEL); - if (!attr_grp) - return -ENOMEM; + if (!sock) + return -EINVAL; - attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; + /* Do not support lseek(), reads entire metric table */ + if (count < bin_attr->size) { + dev_err(sock->dev, "Wrong buffer size\n"); + return -EINVAL; + } - ret = hsmp_get_uid(dev, &sock_ind); - if (ret) - return ret; + msg.msg_id = HSMP_GET_METRIC_TABLE; + msg.sock_ind = sock->sock_ind; - ret = hsmp_create_attr_list(attr_grp, dev, 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; +} - return devm_device_add_group(dev, attr_grp); +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; + + return 0; } static int init_acpi(struct device *dev) @@ -275,9 +293,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}, {} @@ -306,10 +351,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) { ret = hsmp_misc_register(&pdev->dev); if (ret) @@ -338,6 +379,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 8c8e361b1feb..019802fb3cb4 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -278,35 +278,7 @@ 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) +int hsmp_get_tbl_dram_base(u16 sock_ind) { struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; struct hsmp_message msg = { 0 }; @@ -339,53 +311,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; - - 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 9ab50bc74676..c4148fc2530c 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -57,16 +57,10 @@ 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); -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); long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); void hsmp_misc_deregister(void); int hsmp_misc_register(struct device *dev); +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 74be46a64c05..d55c984a9a5a 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include @@ -22,6 +23,8 @@ #define DRIVER_NAME "amd_hsmp" #define DRIVER_VERSION "2.3" +static u16 sock_numbers[MAX_AMD_SOCKETS] = {0, 1, 2, 3, 4, 5, 6, 7}; + /* * 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. @@ -61,36 +64,115 @@ static const struct file_operations hsmp_fops = { .compat_ioctl = hsmp_ioctl, }; -static int hsmp_create_non_acpi_sysfs_if(struct device *dev) +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) { - 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; + struct hsmp_message msg = { 0 }; + struct hsmp_socket *sock; + u16 sock_ind; + int ret; - /* 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; + if (!bin_attr->private) + return -EINVAL; + sock_ind = *(u16 *)(bin_attr->private); + if (sock_ind >= hsmp_pdev.num_sockets) + return -EINVAL; - 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; + sock = &hsmp_pdev.sock[sock_ind]; + if (!sock) + return -EINVAL; - hsmp_create_attr_list(attr_grp, dev, i); + /* Do not support lseek(), reads entire metric table */ + if (count < bin_attr->size) { + dev_err(sock->dev, "Wrong buffer size\n"); + return -EINVAL; } - return device_add_groups(dev, hsmp_attr_grps); + 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; } +static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) +{ + u16 sock_ind; + + if (!battr->private) + return 0; + sock_ind = *(u16 *)(battr->private); + + 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; +} + +/* + * 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 = &sock_numbers[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) @@ -141,6 +223,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; @@ -162,10 +250,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"); - return hsmp_misc_register(&pdev->dev); } @@ -179,6 +263,7 @@ static struct platform_driver amd_hsmp_driver = { .remove_new = hsmp_pltdrv_remove, .driver = { .name = DRIVER_NAME, + .dev_groups = hsmp_groups, }, }; From patchwork Fri Aug 23 07:55:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13774741 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 ED15E13D51D for ; Fri, 23 Aug 2024 07:56:28 +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=1724399790; cv=fail; b=U9MrHWTJ0+VEZol/eg62dI3xwXaISJWaC2/I2sP+NqcyeRl334WTbQWz/CNB6p5e/YiSLXye4qHB8s/UzUfgYGRwEVy2uZwv2q0KskNmrjaj4JEZRC/khdsDcVs3HLmCi7anIDam2C7GCPwQRGGOiScTeZS9ymImo3LmTPHsd6A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724399790; c=relaxed/simple; bh=Zam9+1l7LWDl141DrbBvL0vxfYKE67xUM/QaBL+sy28=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tUhwC/v8yITzS+6qDeVeeelC0SGwY9Mu3korDvveQGX/7J9FOnnbF12gisPH+3hBisu7hsNAZik4iELArdwez68wltUqY9YMrDGRhpuhzjjqgIZktwDqhsEi78to97E4JnGRD8cLMO7L6K+cH1VwErC4okK2ZNhnpEi/vLiCV6A= 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=gcpEFY9X; 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="gcpEFY9X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cReFcOCDRM3efQ4W2M/Lt7C68XFHwTzwbmiOmJDco4Ei6/b/ol0saU6JOct0oN7fjPq6SIVyFV9p9+4HEs2xBp+W+yt2k5LHdh2FSPNXJBE9P1UqJtNVeHun+eqwb6/DLkFvQQ6x/QEcaPXgNPbuupzftdHgjkCRZIBU8OsjiSWB/lfTRTytnwBOcUHjNoo4wXozA45FhjfrCuvv9bfMHazFLVy/1J9NxstAB2itr23FEyCWfbtD7uIKqod6xdV8v38mGKvfxUzjFeSizu7ECAB9SaUEn6O1WlNLv/wwH1rqjXy9/zOZ0vOd8c1IgTJswwjAMSiXOCDCkCLO6BDKFA== 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=gzQ/f/z5mGMN17BGi/zHxx0wv8UlwvcGwWkVUz50PdY=; b=DK38GG0Rw7f4UGR5BM0N9aZA8nLAN/DWgxKTGUvE0DvPFYBUMH38lKdmliEzscLGLH5qwiemqTShtTZs/PuOZeAI6Pt9SyALUAeqO8JFOl/kBW5bCku6O750F7obWJIgt1JVi8d3rPnCFYVJucJRIFuZsRbHCB4fABsQd9Hi/31Oa13iM1SdSmehs+a2UUx415BEMcb0DgnW0IEZ5EY88O5Krb+UH5H+7/ollIwUyogcBfcJO9rB44GJlEtj4tz0hq4VYLWlKv/5gYizTISo8wdCtw6r/4VTKtfujxhlxHH0vvZpZzcoqycHt1oGBx/4w6lpBx64y5Wj0a/h0bXj1A== 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=gzQ/f/z5mGMN17BGi/zHxx0wv8UlwvcGwWkVUz50PdY=; b=gcpEFY9XPyy8QRUgroph52JpRrxBrBkgxmC2ePZWlDGx8LT8DMihqSMaHsmEB6eMCAkbdtHV61RWaATWGbjovKM8aIYLf31MG/VamoBnUPQC1JoL8z34quNgF68iOMUOiNbuJr8TZfrXLms3A+CkevtQErthTu7dF/g9KhSds/4= Received: from SA9PR13CA0119.namprd13.prod.outlook.com (2603:10b6:806:24::34) by CY5PR12MB6623.namprd12.prod.outlook.com (2603:10b6:930:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 07:56:25 +0000 Received: from SN1PEPF000397B2.namprd05.prod.outlook.com (2603:10b6:806:24:cafe::92) by SA9PR13CA0119.outlook.office365.com (2603:10b6:806:24::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Fri, 23 Aug 2024 07:56:25 +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 SN1PEPF000397B2.mail.protection.outlook.com (10.167.248.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Fri, 23 Aug 2024 07:56:25 +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; Fri, 23 Aug 2024 02:56:22 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v5 11/11] platform/x86/amd/hsmp: Fix potential spectre issue Date: Fri, 23 Aug 2024 07:55:43 +0000 Message-ID: <20240823075543.884265-11-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823075543.884265-1-suma.hegde@amd.com> References: <20240823075543.884265-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: SN1PEPF000397B2:EE_|CY5PR12MB6623:EE_ X-MS-Office365-Filtering-Correlation-Id: 117a6bda-1d3b-4af3-ea26-08dcc3491621 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: L5OXoNe9FrkeK/9zsNPolXkyUfZtbAjTAcJ7f5H7tWhbdf0wzYpfX2t1PiDhUTLRIFFSMNk3a2RyVTXgKeXkLtT9Zx+I8zPCORtXslc6E2LEzFP8x6zBeuTMTOJebUXdMqCq4dh+MWlozOetzrCgAS0lbDzs1fISJdovz1lmKYDXUa//HVZvonNeDo5Rmd2ckXH0nUbP+I+8uZdgr/LIM76N95cC6cZOowTUTIblkEhSp4bAv4ybxYoCt7ep1WnspoGK23nIs9ASuc0yQDTM91Wy3WKIyyIpuJsdugdxLvLuU5bJtbCk0cPkegKLegwjyoNjV7y/krxFdOM64tk9qZMgoZmCuX/ldKDxSLbkf0tjpnZ0n4IGwKtwFy5RO21/M+5GTLgajQdtphtUwTmy3KThsa6FgiHmYp3sNJe/CTJrceKgWYF+xn+upJEEZfQ+qAT1zzSwxgmio+le9kLWyLBqWobkaKKzGVTBztn8E2esPbr3inpUZPB+6blfRVD0XIQdwDNzm3pKVFs0/6FvFejDC1VD2a9OZibTSYr3OM/G84ZNh7yP2pkLrIxXLVRgluv9Ww7CbUkSXqDd6eUCaaUfDJk1/+f8A29pJAbf3hK5JIXdjAEdpCvbSix3tPqo0jHIil+HiC8yG2z/B6GMDnw3wKDNF2cgO56SkEk0GCWgANmDBENXaktojLWWrVY+rU6H7JOq/Y3EehCl42Z+/xl9y+iVr2O8TyP1FNp9mP6mVCtxKx/exEZxQUy/ut0zco6hbPpr8oRwypo9mTn72JGbNsuOaehq08wTU6v8EjeJNvprrCB8xvAisXI7YZ/IErEr3ETH+6n3/Xqak6yW8nSY0ooFuRys9HsstegadYtev0pdzNJwkSxqJxfgkJPFF/OZGci74wJGUW+Td0AxdbLzK1P7mAJm4wJQUoVc7x7Kr5Y6vaDN+Fj5U/n0t+98Q1poZAPvOg7wYqy0K/4Srs5T2NS4tYfrMdF1xi5aYq37ZoW6/AEUBCemjHXFyySyV/aN+rGMdITrt920RAxlURT1fkU+vH36pmFENGCkpOqPzo5SqL30GBpO1vMTINABGv1KCLFsOTcoj1wJKulO6U6G1pdXDH/+Lfn/S6iGFrQnsG9E2KvN3L6otTv16h/gBDglouheRTQFoaEpv+k4CKg5cMSEvCuOKW/siRVWIOouCScl4IEmVFGiVRAUKyqnL6bwfnZEU6EM1qqIfA4sU1Lb5cJ5rjR6HCdSLLizpLU5r9D6UHtj1BZieZ38H1aMiI7ysU/mqGjigZroGEsfv2ux/J5AW9fME8RJdO3LX+M37LEUS8iBAtI4u21eL7w7iAPe56/o39q7YmuRqLL5m5xWk86l+P0lD7sKG7GmAH/Bs3lqUuw2IRMLY0qNprgrOH6pq4dwebGwazuOuXWrabLhsCOJvPzQx9xWPugtcQI42x20RnHXdJDt1EOUx7zq X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:56:25.0336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 117a6bda-1d3b-4af3-ea26-08dcc3491621 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: SN1PEPF000397B2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6623 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 v4: None Changes since v3: None 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 f2bfc5981590..16a82b8bce28 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -272,6 +273,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 d55c984a9a5a..8fb395e91806 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -79,6 +80,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;