From patchwork Fri Sep 27 11:59:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814167 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2055.outbound.protection.outlook.com [40.107.223.55]) (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 107CE188CBE for ; Fri, 27 Sep 2024 12:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438407; cv=fail; b=LbuRQm7sdrOjzOuaLiqp0I5uDBX8u9I1IympfzzRq69LVjnIxQMMabVCW5yzxU0CUL/W2HXxCPfplazA4EcMMxpRxjVFg6d3vKEMyxTcqwEATWF83FZQJieSw9vlOXw3mqhl3ZjLYejzEji7GbaAAg/E2WHggChPEY/yr9VVK10= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438407; c=relaxed/simple; bh=OC5Q59uorKx1lD4buZ9b2PitZBO6N+cXD3bK3hk/BfU=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=seGsifewl4qcxZnHmp91hxka5LxQz6Ut+cZ/TNDHjXbI0p/3/DlC33ohI6C6Qdu3R9hSA0laqaGpWMHE5UBUeGeUgJ7HbdHd+hXF6gAj9ilbjp5aneTp9LndWIfnPpVKRHd4wAzyIG6eKBEI0d4i6xFdLWmyc5jIExFK2ZGJI9A= 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=wT3wW/Cg; arc=fail smtp.client-ip=40.107.223.55 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="wT3wW/Cg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PrKgmur7dNKB2twfwJLeQ5lkXyQNU2bBMFesasaOyDNAk9qAA+k5BCKsR3yzhkG5vXGqxNcwY5Gtqro/vw992p3oSikczcG3WRHsUFHluWLxVTtxf7yaDtkF7xDZpHpLp5ikiMsA9+KPfoZ8mQ1E67K1mOZMnbJwza7zuHGCRHdKRsAaFi7F0Qz96OSEY5P9oBMIfXJ9uUgxS51XHom1uvBMJIpQEXKB66lU8Wmka7l3hDJD5Ipq8y3MUZ5qlDBWJK3TG0wXINf/MktgSSM0nqcnvqdimB8CuENuc627IhwQ+JCUEj0bomOWq317ml3YADBF6G4+zrH3yGglJN+IfQ== 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=ZFUzUJjIHuyRNou7WPVm4t1vjJwPUYuu//+rcdrSLZs=; b=OtBzLcNYF/b1cnN8avnU4+nkcnX2lA9ALV0zK0fdCYoGYy46qVvWkaPN9bLouVfa3SUoZYUcI9R1hEsrJeHSnoQRu1mhxL4JKYtL4OcRjzTI4W6YaSraj+FwRwJ0V6L9O6HcO+ADVJg1tUcqD9SwrWTRdAZ8WEnzZEby6x0yLnev1km+iPUyOHHWyhdxoAIhaILrOYH8XKp22RrNVVaF2bAsLff+fpqWTEu5L/ZggsyNtFi6a7vJ9N7Z4Ly5pqCgAs+0RKvnXYJ9ooU0e9w5uIM0oYL83AEAE0m2r1eC8BE08ZufrfyLe5SR7f2e0f0KSMsYmwJRd7KbL2CXWDihTg== 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=ZFUzUJjIHuyRNou7WPVm4t1vjJwPUYuu//+rcdrSLZs=; b=wT3wW/CgwhLYXZAXMMoyY4DfpV7oqqicOi0zSNu0zS9dzg9ZRqThE9mVqbp1IVR2ZBRrYZSim4Yg263rZc3DkJw44j1hbD1t1dDPYIb0+6L3QyU5RZiv5vROgV8b6nTEbmzeMRAbLmPbn3gOxAshTfqkTXQI0QLsIWttDABe+cI= Received: from SN7PR04CA0044.namprd04.prod.outlook.com (2603:10b6:806:120::19) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Fri, 27 Sep 2024 11:59:57 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:806:120:cafe::85) by SN7PR04CA0044.outlook.office365.com (2603:10b6:806:120::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22 via Frontend Transport; Fri, 27 Sep 2024 11:59:57 +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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 11:59:57 +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, 27 Sep 2024 06:59:55 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 01/11] platform/x86/amd/hsmp: Create hsmp/ directory Date: Fri, 27 Sep 2024 11:59:11 +0000 Message-ID: <20240927115921.10909-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: SN1PEPF0002BA4C:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: e30f005e-d890-4bfe-7531-08dcdeebe826 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?xWWUO5Ue2BQML7HPczBJdUg+oSUekei?= =?utf-8?q?yEPA4M1BjeM2qoC4V5eOGfGjqJXAGeep44BCYXFJKxNQ8vClwr+hgxj4AYCzW3iRz?= =?utf-8?q?SzFa95xZ2BHlYVYdElgITowE4j8I9EV7/3WciJSUukDhYewMkkkiiNz+nhmn8YJbl?= =?utf-8?q?WF9Q5edjAxBQqvjQJ1SochKWHmgxgePQUxe1so+78jZ+nQZt+4CT/gSMKZgUTQhpl?= =?utf-8?q?TdPX58vz9I3g1nI+tD2HfwZemclzOF4RQal2ADPdxM1K9quz+HpOTd1aA/flBytdT?= =?utf-8?q?8WrTuVpwHPLXGaxTxUT5Yr7n4sLtE6QW3P53/w2kmpVtyCl4E8a+xttAMaYDzAiMt?= =?utf-8?q?zo6//fpez5IYZoBCFw8zOSaU3XQteWj1xP/P0H6vFhsqnJiszgwEg6Nqc9ykH7Roa?= =?utf-8?q?nc8aLUHuoq0+ADlRBgextKYV7wFbnDdasMh4szDQx/Of0Ta0xY4258Yv0WlkYSxKV?= =?utf-8?q?m7FCj5BjKUJNjDO5w+5XMjT8ORqCTuuSLn+4sChYlTycP2Cxsq+kbRGPpfIIWvP0V?= =?utf-8?q?vPD7nJEgdUN8cAT9g1jWSKg3avan1bMuydzdd44DgXav5pnuZTgCKgi7/RIjUbnoK?= =?utf-8?q?wdgCtKnpRQwooV7Sc3zco5sq5Tqo3yeS5WKGQcXDoYewDUumerPjD8BIUmI4PTPTV?= =?utf-8?q?Cm5L/P7mCj+p4k9SewZshWEuLgrXqjT1QTEVsl0fYUAkgNXG41aM1AS6GlUXAYd9K?= =?utf-8?q?Ep0nonH6sy/oZjYiCptNiyiCrw6mUT8TFYg0jwdTyEgh7ZtotQ4IQNdBfCN8hryDq?= =?utf-8?q?SF7WqGqjHfgTz6evoYRGG4Z4klRjky+YnmCBoCHPpHgF3+RE0+TGSJV/AIluHNmT0?= =?utf-8?q?9EakIY0DdcpS1SOVp3LiPwNqpv5JeRiW2P1FuFZIKpPXkQb6nvsvUt+dFiFlN1YlR?= =?utf-8?q?ZO0fP+MruNRFWbLutCf1DsGJ6MHypm3mMGPwKWhSUaTAYf8cGyW5sRQliOz58RIiD?= =?utf-8?q?I38Kr9RGtlpWT5zXECiXOKswX32WDEv8+5X+P7w5ZsqEcWWRqTjD/+S8zytGxvmfL?= =?utf-8?q?Da/un/qK2eNbAD6cuqwSfUIpWmqGmCtQw2hO8NLhcMh9RJRjcZsBVN845KnDcFHjq?= =?utf-8?q?6fFao/6UOW7qIQoy2cjJQMhvhDK9cnm2sE0WVa/o0v7CjjUVsoA28nhRZUQMLvBTd?= =?utf-8?q?2iKjecuakhpMv6Tbp0qdUE8F+h4TfHSN8psyAfhOPw+he0C1HtJ2KUSXhfOZseV7d?= =?utf-8?q?rbzTUOKqtKu0qNi2dQmHeSEOohPuI4jpaPIMlhtOwGA7fAHohLT6zdBD/xIygWsH3?= =?utf-8?q?EbJTo2CoVfXKN15UI1FS3TTkCXSy9OyddwUylpPIucgJ84A8CKZNILlU/ODZJ6+lk?= =?utf-8?q?wHhcFuNGL/I+0MVqammID4pT/9Lm8oShyxUqnqNQNEMK67m3aS0XMmlfmqowoqbDy?= =?utf-8?q?NSDCFZ3Tvj6?= 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: 27 Sep 2024 11:59:57.2345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e30f005e-d890-4bfe-7531-08dcdeebe826 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814166 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2068.outbound.protection.outlook.com [40.107.93.68]) (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 6B8A8189BB5 for ; Fri, 27 Sep 2024 12:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438403; cv=fail; b=Nh8UGZclgLNlPPB7b/c7RJAwJb3ieUZfLy+YwGUs7tdNXUJ39/eAxEcHmVOLItmP0Td9XFqFs74ZP02a/yH2QijtLRPbRj0xNrlMiRZJi1AfaihdGuW6eGY2JKpspmjjgcFURNsYlw5zct6RsubG6YLxHmNHi2j0xb6TvPO0ncw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438403; c=relaxed/simple; bh=ZqsJ7i/QjXnnT12h/kyiU273tXfv6rGm2fZiSHQDoJQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E52YN+/0170sLsGUyy1d5RPkT9+dfMOMWiHfQYycuJciMfq7uD+BKHv95gI/YwVO4i8LG+4fz8AOwVy3ksOH/fuVTTm6iTjMo6F9eEOIHdWiwxvmIr1FO+e2QrOOUpu360fhwlwIpIjEFzBC6cPVsCVcwcAqbbyBUeWFTn3BaVY= 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=AGVFZMeP; arc=fail smtp.client-ip=40.107.93.68 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="AGVFZMeP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WKSxlgXp9qRsCO4ADF8PKSTPvl52rhOQrW+J+NmSt6gIQHdCzS7fXt3pkb2riwoAqRdyJDzne0SqP4Yj7PyUXmsFahVVuGdQsUKK/AeijOWaC4cMTEiTQhWDjxTUDC8rTA6XTxgUUbxgC7IQG6RjD8UyVO/GjAkbBWMHKkZ623IvfaYcu8VMS0/UksKJzNGLcbmhMdu9QP45XqbA0/7+ZrNpv2rI1JuQkgmCrfGVuKzDmJ6TvR0ntoIio2doiYyjZLA03iHSgj/NMU9oFRK+eE1Ynun6xc3W29JJctEM4yf+J5lnP1AAvNeb8bVOfny2Dr3qpsk/NB1Py3B4ozhuLw== 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=X/HYUVVz4MX4Zx0zd9bhQ4ivDNI6s56AULszRNJ9zL8=; b=Q4yY0vRxGKdC0c8gaXM3MbKJCr4JxU1T7yvJCfEuBGMJ8U5zkIRYspj8azXSZCMqrfJskYQmAs+6/tlXYr+zp/hNEx+IgeauAN6q1YJCs6XdSllHWfeJLuwMD+AtcmwprrblGCF1OXoFQhZUqLQ0ByvnxV1b/rKsSlVZGRstFdSDbby1oE7rC7/0Gdx1aIpXtb2R/2sunDTXmlwxu2s/FeAkVGtHjFuXKwlGSNsCxIrBOs8iNwp3WVXEzbw8AspYoPV4GDqyLjQJAhARfoYQbR0q29khZaKvU0tl5P/sgzgVl/hRGvgOrqcUDD7AYtX43YO2CrUXGMMn16oOTb0hdA== 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=X/HYUVVz4MX4Zx0zd9bhQ4ivDNI6s56AULszRNJ9zL8=; b=AGVFZMePH7KClSb6wRnuKTxLh0RbV4B8mB8fw1JZHiGg9aeaR0VULFvABr1BgSaAtdFtTtBNYXDJkTx/PS9MMvnvVuE+a+GoBx6tBLC98d44BJeauiYpG1d14KFlz7pcS5hwQsuVunm+U3+FZURzwGlhQMU32y70H1eDMyVja0U= Received: from SA9P223CA0016.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::21) by SN7PR12MB7935.namprd12.prod.outlook.com (2603:10b6:806:349::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.22; Fri, 27 Sep 2024 11:59:59 +0000 Received: from SN1PEPF0002BA4E.namprd03.prod.outlook.com (2603:10b6:806:26:cafe::8b) by SA9P223CA0016.outlook.office365.com (2603:10b6:806:26::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.17 via Frontend Transport; Fri, 27 Sep 2024 11:59:59 +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 SN1PEPF0002BA4E.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 11:59:59 +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, 27 Sep 2024 06:59:56 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 02/11] platform/x86/amd/hsmp: Create wrapper function init_acpi() Date: Fri, 27 Sep 2024 11:59:12 +0000 Message-ID: <20240927115921.10909-2-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4E:EE_|SN7PR12MB7935:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d996c99-1da3-4032-9d35-08dcdeebe94b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?kskvGWt3FMjfDjtRsufnCIa6GJAAq/F?= =?utf-8?q?TxM24EPeWlz+8a4E/1/OhUE0GJYkYi5jRFBW/UK4nHPKYxhthM+LtNyf0rcTy98Ml?= =?utf-8?q?agHgjJETpUzJ5DduBLRblusmpycD32lj8tg4ABVdWQAWyW67hxC65dUKbof8tYKPJ?= =?utf-8?q?IwSKklbFZCYPuZ4p03KHNOTVKhJ/iaAQ2hEqbwTieZoLpdGIWjcIKLPfZYG0Xfnkx?= =?utf-8?q?ek2wxSJxP6hWQEOA/1j7U0KoDh4cPIh9POs8FkJ0rqNXhszh58tvQsA67pkzmWM5/?= =?utf-8?q?kFSgmAl+pzm0eIi2ViWMMrKeTUC4AckJ2XFfs7VDrqmgKApnnlpD3E5040twJEMsa?= =?utf-8?q?T4tljnwi9WNIflDadB+xIK33AmN1I8ZvAlN5QSiwlsbAwEL/8okd9pWZ4xpbn9joi?= =?utf-8?q?iUnNU3q2UEPj/IIGpdQlJRtYK3XPN3+dsQ3eFlrzwl3SoGw03ImAetoLo3+h2Zv2h?= =?utf-8?q?mS5vWqCkEijxETwR9b11FaeP9uUojzb7mgKN59BfqrNATOWPJy3UUiV58eXAhqHDC?= =?utf-8?q?0i7cYVUe6CcYBcr+Grt8VMF1dKXYpbES+IX2cvjDKKJ6UyQ5Q5QG9tEd4dfcqWXm2?= =?utf-8?q?FvTUGdnECAqFted87Fy0YDRw3J3keITsPzmEJYhn/QmCY3molIECjjJwSLC9QEbcP?= =?utf-8?q?Q0jS7qveurSSy+9PmQwuT/eKXqbka23Y1mur/bvUUy45KFGyrz+OruvEodUi0O+xW?= =?utf-8?q?/pBS40S1KBWzt8y9nhz/BcqgxDoc43f3ZgjYk1ntzawsQtJzd2mvakiy4Bvdj73QR?= =?utf-8?q?JVTMLSGeAs/KSnuFgsQPOcca/SbgipkzCgtkdmLhnyJJlD5Q+5JDsnz8hgl/c3JCI?= =?utf-8?q?pjpX0uvpPVnERRJ5ulp5dKVm735py02XaA0BWrM0d8TR1CHK8AbXk6T/A6iXvdSAQ?= =?utf-8?q?1I53ClUlivOQhMh1RRt5axCgzvpIhRnphtekGfCqq+e9+3Q4U8fRIMRF52skZAoyB?= =?utf-8?q?KU3IgEJc4z1rmHojlnfThHQ7xEIlU3tMXzr9ER/BLS0zC0HMtJKzP7Ph4vX/+qTyE?= =?utf-8?q?UysU5lCEMli+tYzmf+8W7FQ+5Wv387mUmjyjw3hn+3vXjhMsGGXwZhz5VA7w0MOWF?= =?utf-8?q?bM8FouFT3NRiYpTJ80DwaG/TfMBQVdOQxk7SKB3gWHEIakl0jSJZnm5Y5LbyEqnUv?= =?utf-8?q?HbTz+lhsZ06J5lE6HsL7KBO0TXu2q4s8BFQCUslajakhsfgXoQRHUZ3qudQHcCyfk?= =?utf-8?q?N9pJ3qOq7e016Sc7tpWmlnriZFsTYYRKEucZdCBbgdaUpeobo6ootWbhoj0BbTB4y?= =?utf-8?q?eiu7sAekZLSZShl1vXDqe8k74TvRKqh8d+MJjlm1O6UhmMdR3QaTD3k9sTVdquUQN?= =?utf-8?q?L4zQOmmd+TteKWgGtKFzJY6fiw6yW/zh1awHVcWYka/HWBtSlMBQ4aK5TuvV1u3Po?= =?utf-8?q?9CfrCRxQb+P?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 11:59:59.1557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d996c99-1da3-4032-9d35-08dcdeebe94b 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: SN1PEPF0002BA4E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7935 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814168 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2064.outbound.protection.outlook.com [40.107.237.64]) (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 B16A718BB87 for ; Fri, 27 Sep 2024 12:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438408; cv=fail; b=GOOsPnRWSspOQQeAU+aTSipe2GVFRmIX8RQ4I+Y5kU8pi0qYKR9tbMGs6s5HnzczGEyuCp+Epvi+eQkB/QyGeY60m4/pc7t7avHUGGpKENbklfXvzdDSlOkv/phT+fhonEBTv7OK7DO866bGE4PuhVgn6FcRqGV0UozCOIltf38= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438408; c=relaxed/simple; bh=wl49sau62lKnL98xNwkeU3GztwYjNcn9By68nH0PILE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ATI3pGgJmZPDp0dA9COkt8OMwjljwJAyg122ngLCH1XaagjS+Mw8TRquGqRenRhNOgQniaJwWJe7ZAg30vkM+J9Mx4Gm36dbQE5daGNFOAJNlE8kQozxofd0CVAH8LOq1idnpWoEm+h7VG4Cj/B832LTpC8L2Z8xbfnGQe9ht1w= 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=gvEeUNmf; arc=fail smtp.client-ip=40.107.237.64 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="gvEeUNmf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LPs8uAL9FYxkhuSJ3RJdDdidWyumR4J2boqdmDHO+Xo0BqCFwch8u4L1f7GJ0co/nwhu/EN+FRc1Ad+lKIDAEaIAx40gYpYF4hVub9iXFeUkNmSZ9/DTTSjPh13WVqMSB8JpDE79+bblmgQHYMpN67YOHirhDJcilCFyPGkQ5otNph0Lqwl9x05HgehHvsNwk9nv18wFsq5p3Zt5WuREwWpnwaSw4EECIUdZWc7yBy92aVgl0q5WDFXwpHwHh7w713vsIYcpTVgjxr4Bt0ww+VCBHINRkIifpDX/ZcIorjeJ2eVVJ8V95Hza6T/6+4W7cYOJgAxboNWroaZwLXOvtQ== 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=AN3bv09awG72973P8O4PAsrTuIIqYDyOGk2aKlcvWEs=; b=GtoAn0g3gLq/RJWcQ2TD//lmXhQLnPheMvMLzp0guxOee7W8x8rmMudkin2Ie1ZpAhst69Gf2MNkTTjvM8i7wVDQT6H8w+B/UCzUyJP7Jd3U0+S56awNkwziBrq61376HtIgfR4LJ6n/3Krh9hvHEXzwxLHZ0xPxPRK2Ysiy9oRLCSRiI/lAEwtdtVu8DC08SNmhzOW+uMX89ZsPMaoHgNCYigFcW8SOBgIFjG54Lni73TaYnB2IUd9+zTk92Gveom6QMtKhEjfydltWxSgucb1OvmJytKOPf9qZuiQnBu78l/H5imo4rePxamJ41rjCWFbWfLUbTUdBaXhwMTr0HA== 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=AN3bv09awG72973P8O4PAsrTuIIqYDyOGk2aKlcvWEs=; b=gvEeUNmfkNt2snuk96RUhhbEWjTFSxSq0lFj5vYeN3OTamvVt6C01gK6ZdAj1RGs55SM+StyvqLPo0U2EK81Q6C6uEvVRAn/KXgFomeEIBg8G3oy4H4UWZZd0NKl5dBbNDs7ylJy2ov9zqEQi0cRAzJD9+Y9BOVefztvSo+LhRY= Received: from SN7P220CA0025.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::30) by PH7PR12MB7281.namprd12.prod.outlook.com (2603:10b6:510:208::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.21; Fri, 27 Sep 2024 12:00:01 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:123:cafe::8d) by SN7P220CA0025.outlook.office365.com (2603:10b6:806:123::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.20 via Frontend Transport; Fri, 27 Sep 2024 12:00:01 +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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00:01 +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, 27 Sep 2024 06:59:58 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 03/11] platform/x86/amd/hsmp: Convert amd_hsmp_rdwr() to a function pointer Date: Fri, 27 Sep 2024 11:59:13 +0000 Message-ID: <20240927115921.10909-3-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4F:EE_|PH7PR12MB7281:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e63931c-3ad1-4718-261f-08dcdeebeaa0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?oFsdA71gcKjqWpGLtNftL42/NsxQ/xf?= =?utf-8?q?0rQjcSJtmBTB31BrTHirYzak6vfJutJO7UpWZiKJTuF3cJtqNxqz4l/a7j4Hnn/5F?= =?utf-8?q?hAytqZFM5FimcinweGXI6fgsizt65lEAXn9ZkNmgbLHwfrCQQd91+uNUUmYgRpTpK?= =?utf-8?q?VBDLzLtiYgGLP+y0q6S/kToZ1eZJd2WaEq8ChanSbRt9v1IgE2pEJW1a7q8RwPf2m?= =?utf-8?q?cPx1H+UUaXj47fE6DjXDiHBaOhebOt5KAgl2bNmbTBTA6/FZXRAbVAxAc1aP+fedN?= =?utf-8?q?gUKg5TQJbBPufaHnzpsAIaoZCxuqPxXbmj8w0ggIolGKSoAf8m7GMNE6qZR9GooHW?= =?utf-8?q?npiYQNhkfHHivqmGgbt9MgQ/cVTVIzA0vU+61zjiZSKhEKLmPMXegRt+Iesq2O8tM?= =?utf-8?q?XURnCX9l3LVZ7Y1Ib93upk+Wb/vSSjGljb1EysSfnmk0K2dbHoqXTjXL/YCgyEPAJ?= =?utf-8?q?09MkrP06fOz1SHAx/4RwnOj0ZcZBuPxgcDhUr3p2Mf+6I9Ntn/4HAkUAsD/VNgp5s?= =?utf-8?q?bReQlyh4WqMveuovGO53UC/wbjWozz/B0s3RrdCMG8z9wdfI0AQ8BTggvl9NpvlB0?= =?utf-8?q?9PYdddWdMW9dU8X1CwhMa+XOmhDn7yKV6E7kLnSgWTG5kiefqV7MlyQPCQpQxhVkj?= =?utf-8?q?kURwvRYlPVUHFqy5BRKskTspGDTBfXNXJrLI4fmSDIlI9sLYyPwNe1REcQKyzo8NC?= =?utf-8?q?aDXFmwNLsyxX8uM8d56oANOdOpvOk7chHb0pXh41XIMQkNKdBy4W5E4A9UCjRIgc1?= =?utf-8?q?Hd14qvfPgvwJrJRMtppiFx8Qqt8oggPaOHK+lfap7EC6/F1TJoQgvDvZ4DOUWMrpT?= =?utf-8?q?/D0huUFjnd42DdmhdjvNTl0LwJ/Ij83bfHwDxYx2vJTVvyzoVtLahMCePwnZMm4pk?= =?utf-8?q?yxgyA9LE3hMWIeajWkXLkrDYw6IpQSx4NkTcNG6m6oB5WIdXSLjNGrQVEZVdxQDLP?= =?utf-8?q?dEDdEAzhs8wMi/G/sCmtmSvm98GFVQCWSrAzu2Lvr/zIaTvND/v+/sMovRdxNCvx5?= =?utf-8?q?RFotrgyFyXTfHuKmFBNwCHOAfHnqbEBPWLoXCYZas3lBzph6Hx64p86pvSr8Rmud+?= =?utf-8?q?scvAUezLeRY88YetG1Xr6WKTv7NU+KfPpLo0kbIH1PMO1xACrdQDgDd6I43wC1w+K?= =?utf-8?q?9v5HbLENkPi+BQr6/pcDqGD+uwoIIwBEwnImmsovaGQEuYFBNeaHa2DRAYQrYrNWA?= =?utf-8?q?ozRPKw/POosQoHr9APPd5ti8XEUudVnmRn+0CuY2fSdsXvr8LhoprRMHl7dIk7WCU?= =?utf-8?q?oAVRmvW/12bKwVG/wUMURfQogEjPmMG53RmJv9v9JM8d43dev2EaecVH/4tOi7tRs?= =?utf-8?q?KtGkYL29l5dhNX2rvBuC2RDoSIawJEyyDp4a8XmUDXZEhtIUFWbO7QTkBl8q9Dp7C?= =?utf-8?q?P2M91nmOjNq?= 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 12:00:01.3875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e63931c-3ad1-4718-261f-08dcdeebeaa0 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7281 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814169 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2083.outbound.protection.outlook.com [40.107.237.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F62118BB9E for ; Fri, 27 Sep 2024 12:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438409; cv=fail; b=FWcMfBjcree8JQqP5ySDh/OBwN/m9tNA9/f5pjvsIk6qkQ6qZ2VguSxhGe0f5mqDt7X1h/Shv4lMwRwi77jQN9ZoqsBu0IyvGYT72qqtwV4gIFLQwreNlwhWX13UJCHVREWNrPeLOhaA0A8cyX/aVNokC1tHQ7x+XQIqWVqK2g4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438409; c=relaxed/simple; bh=KdN/1WXsgo3Ad098n9kkTJSit8gIabTugQwWQbufJ/I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VHIowfwGnkMOcp1jE5I8u2KX5ghWeaVVuMwMZFra2mk66eCYYpZ/snHM7BxTXCxvLkFFG/HoP5+JcNZTGjjzdqCHwLM7OmYLrrrhZ4vlqEGdcbiJlRj6S//d2FwbSfuJ2PfPRoMl0BF+B8gvhnDw5dOdxMCVyYov1p91lUCCDBs= 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=Rlu6S8Qv; arc=fail smtp.client-ip=40.107.237.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Rlu6S8Qv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y1nUgb2EFznoQSR3ntpPj4lfzGE0tb9QIsGN7N8WrF6pauZngHmIz/ZzKA1wpDHKV/fZ92vPPPzhLGl5MY+V4S+ikygvCzeUlCmH+zzzl1fpQJNYb5dkD0TfKcWINRLQC030nbL2Bt7AkjcbnYklwczT4ZfVja3sc2zocYY1YH1C0CQZI7ZL4A1OTaEtJDCWFbpB7r5B5t55kAqWAsWoxHyGieFW5PI7+Hnc/2foI9bUEKonIDDuEja+p89Z6eVo2VbWiqcHG5m7R0JeT0OG7zUkQeYg2FpP43veyYztbfZjcrvAhOlqNguUuPjeQyH6nb1WJihCigJKlmP9N3gSYQ== 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=dHgx1vVdjCRlbYqHu8fUu7/dw7rAXYt55lzQC5AQFcw=; b=rT1YgSPbVAerE0/wva6+M0qYdLQzFQ4nG0o43EQfjJ3YnO79H5TPuZb7wizHpHVrwPxSbYkf8jV1SlwG4aYO2oc2eb9k0Cm0ueoxSXkZA2VpPufiOP2K6XZl4vH76ofiWK8Y4+qU3SBvRJ9NpItlhb6m1c/dOxzJNLhRp+SAeQ4LosMHfNBGaeAsO77v3xPUF1/sd/NxjfspzfAizrSqqk3pRn0y0pw5lkP38Pqp+JRPypUyw7xcFwdwIe/AfDTYAWA87FuCDep/8J/kJSVJbQECBy8uqSIBwMEy6c92brYTkJMS4KPXz7fNgLsmFQO4Wv52fNsdRJRWYLy/cMMwLA== 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=dHgx1vVdjCRlbYqHu8fUu7/dw7rAXYt55lzQC5AQFcw=; b=Rlu6S8QvVkXboySk4KRFvFG6aibNN9B7V/5mrelt7+OeWXgP9UdDBj/qVoVqOVdgQC7UM9utQdOpFGEZFE5EYqN0Vu4ZNdUEqLyhRMzqMmA125Fk/pzSYpJnol5HkkazEclIubTZuc4SJLR6XaYhBQgqXJGSrCxe6ma5Icira44= Received: from SN7P220CA0005.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::10) by SJ0PR12MB7068.namprd12.prod.outlook.com (2603:10b6:a03:4ae::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.21; Fri, 27 Sep 2024 12:00:04 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:123:cafe::57) by SN7P220CA0005.outlook.office365.com (2603:10b6:806:123::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22 via Frontend Transport; Fri, 27 Sep 2024 12:00: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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00: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, 27 Sep 2024 07:00:00 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 04/11] platform/x86/amd/hsmp: Move structure and macros to header file Date: Fri, 27 Sep 2024 11:59:14 +0000 Message-ID: <20240927115921.10909-4-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4F:EE_|SJ0PR12MB7068:EE_ X-MS-Office365-Filtering-Correlation-Id: 4578ddd6-a3da-418e-7484-08dcdeebec73 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: =?utf-8?q?T8YZi3rGIwvXupTh9p6AqQ0A1qmKJF0?= =?utf-8?q?LPqRTqmmmWSM4GzBeLHygkDxttK5P6TGMBediKpMEZ2zaPOP4+fhceJ7HUhl8G1ha?= =?utf-8?q?f5pAe/FZP+gqx2t9/GAB1DwPuQx9mGeUFW5yY8MzD4w7Fr1nlR2dkkJya5sJldJb8?= =?utf-8?q?ywuOiIXRxJXYGOtfWhZnGLSUWCTfdRE0/cpHuLsmsUQBA4HPXNWGsP5ZAGU62NEQ3?= =?utf-8?q?5fIVB+NisLrvB6w9ZPBE8aXhUN3VMBlPMJDthkc3uo7U0z4DkdZR2d3g8qjJbtF92?= =?utf-8?q?1SZqWRBqvr/0W/8534862zyRY5CZQfvU/73Xem/vVB4q6RytP/ZT2FWYWuEGEt2wJ?= =?utf-8?q?kRCeMbgLR7DZ98DJjFDhvd8TCC9E3CdLc6IuTOEFBNcPHBxlkTejTM5CPzj/+4BiB?= =?utf-8?q?2qYv4GNAOFfTzla7eqp8zS4qF0KNMDPLVES/rnUoYcSJYi8FvBNGuhtj0mhRL4IaM?= =?utf-8?q?rHjv3Lsepebhvwc6XdE+O8DZkYs3TYWXs4oinn5r9BHEzUQlXJRdOUNJIhLLCH7G6?= =?utf-8?q?lso10odyvv4A1mNQ4XWrnbByepGqIX06DqSGoq9QhYRT+Xy1/JYbMYJISZbfIulGV?= =?utf-8?q?mrIL9UCS+2rYMX1xPZKQC3GPnI8/JdsKU0iV6edvhnrnT438vDBdqo02H927LlKw3?= =?utf-8?q?lSqtJZ+Nzj8+6mslEXxmfbV8z9kyKoWDl7N/Zq3WXk1I8gdcWXb9e28WrFtrN/1FP?= =?utf-8?q?pWqOsvyg3lzLRmEJ8QeMJQzXBiV+6IWYxx9J/eJHkuc/m02/jbaL4oO5ln5J5y2KF?= =?utf-8?q?sCANshqftIfNgqGfH3muexNrrnwsfPJFlk2IT1oKoFHDihuSTb/mk9zcoN3TGNPvj?= =?utf-8?q?V3SpbAldcj9KzVH8jtw8prXSvJzr+/Xff0MW9TI8S+0v3SgR4+H5QaTxaz7OelD/H?= =?utf-8?q?RoSf5WHfrtRHJNzsVWr/UKvLZQh1OW4jGpWLfbSCCsgCqkrT6ELIMwev/f0O1q8xh?= =?utf-8?q?Sj0ve69EwRVKvqM3+AN3GjH5eHdYkYmUHoO4+G6+q6oCjpPa99PSh2lgw/TipUSfg?= =?utf-8?q?a2Hs5QkRrjNQozYKNp9gf1Zdd5JI/mnXq34j1cTMD/azD1kHTLwYJcvyVXRZnawH8?= =?utf-8?q?/BPZDPyayyiL+PeXQ3R6/LnXOP/fN34HpYSzw1ol9mUflMHlsve8bP4xua7DIQEEx?= =?utf-8?q?qfNBC9KBPXikEVVeg6Jc16IXMpxCLXFo6qTwoFWdgzsXexxE1JMIzqzCV8LSQAszc?= =?utf-8?q?QsK58ZERIsL7QXRWrSu81yBTeWhrelz9Pf1u3s+x7JCj2FQ8MfLHkQ5r/vVf1oAMV?= =?utf-8?q?1XxHFFTdJwlJtwjxpGtiaJ6Nt+2DeH1ZLFlrB83YTJjWrUgJvULTloPB73b7hr240?= =?utf-8?q?OqwVdrdQa8MIJx7Trpg8JmfqdsfajcpFofowmN/LOHwuSt090OpCMCMfGnaSAV3yE?= =?utf-8?q?0cBteEGWtei?= 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: 27 Sep 2024 12:00:04.4500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4578ddd6-a3da-418e-7484-08dcdeebec73 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7068 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814170 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.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 17E77188CBE for ; Fri, 27 Sep 2024 12:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438412; cv=fail; b=YVPtCP70FbPJaWjGHkWW5rhJjF38jWH9sxlZrC6UVsMaZ6o+XguZ6YRDgwFwLpnEWrmN2+mSjGFNmK9PHw3gANJU2L9Vdi7ImKphCMnLTuedEo4VNMbEOaP/Ilkn1pUV2D++rvD7lVxbqhGMKWvsTdoa53xoENzbyvCpN+RXeX4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438412; c=relaxed/simple; bh=h/tBkvly/m2lSb6nCx5ZTmKltqfW0kGcXlBXnuqp6jU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KD/XcatjDO/9vqvVzsMPL0oVz4C9jfQav5AfvMH0PMwM0pcHvJRO5sn2MsNZ+0TsrjrzVZK1fGszBXL0AoGkNHyn/Pabdcxuox2n2Dc/zaStO2QpBr35Yjt3QmfGe4sm3oSiZQ2uKD6e8Mx/isFwqSM41HWIEBguKyU/vFCpBdg= 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=cDV2CTow; arc=fail smtp.client-ip=40.107.220.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="cDV2CTow" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p7zA+pz7IFWt0yy5YxGUgZSgsBhcDFgoOMqwr6glWfh/OKQTOPdCw8KjmAC59yJP2SZT3RnbBDowD9r22MQTzsWJvHbTW5Su/FZ+Z32DuXKtHeHduHGZogWFTVA0hPgOFr0KYjO8u57pn1qCZUd+ixiIYl5tTTpyDghqSlro6ZLSDDQIrnsrDvVLqd4MjQK5VR3+lJFlYl7/Fx99AnvJeiFrTQBd8dfNvPIgUDFTlfJ3CviL/FwvNkHdipkxezV7Qbwh5TF03Ki0tKj2pt9sqBHS41qW5bjGWSt6HzznR+URq3G8jySGP2QBx1bpmhLFC04zMwrzI2zdoIYCDyFvFg== 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=hyanLgOaNZonVZ/U3YfiJLj9lpjN0a96PYnpfo4ypN0=; b=GiP+32xWi66cyUtCD8AABT8T56Rj7YI3QzB0rcetcYjIGZVQQueWkt700K/6kz+3VM0gPdtSRHpM3XH1zzQi/jHUw+kjn7mTh6D5KZeXBhRCO9SwjG1AkLIr+Ffb+rXqV4xvDBotCEW6+jJyERVsnotmSqgBDgtAD9O2UcHaI5QSwfyH82HCVHDo0b7r5Kpqy0RCle1cIGPYIdDkoBDjdkHX3sEXNbvFoLZ6s3PbxvM/Bqy2NH3bMw5ziUiFTJprA3WQ1qWLMVwtoN4mkqZxaXH9kanbv4sVClLP4UZQG7zh286t6k+XOH43Vb9qtM6bAQvgAXgnQ19SRax6DQ2xng== 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=hyanLgOaNZonVZ/U3YfiJLj9lpjN0a96PYnpfo4ypN0=; b=cDV2CTow018AHpI5BfxraerrEwLS4G3ikB9H+zxw43lWeba/ZmqDHym2UsmA68mzPrS6ppRfOFzRyIqAAPW3catUhUh7B6rX4OWqanc8DDRiNKphSoMXFfso1cw0QrKV0UdfMGnp12pRlPDV62WbM9jhucowYaelGfw95bfw9Tc= Received: from SN7P220CA0027.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::32) by PH0PR12MB7838.namprd12.prod.outlook.com (2603:10b6:510:287::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22; Fri, 27 Sep 2024 12:00:06 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:123:cafe::41) by SN7P220CA0027.outlook.office365.com (2603:10b6:806:123::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.17 via Frontend Transport; Fri, 27 Sep 2024 12:00: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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00: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, 27 Sep 2024 07:00:02 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 05/11] platform/x86/amd/hsmp: Move platform device specific code to plat.c Date: Fri, 27 Sep 2024 11:59:15 +0000 Message-ID: <20240927115921.10909-5-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4F:EE_|PH0PR12MB7838:EE_ X-MS-Office365-Filtering-Correlation-Id: 586170db-8817-411f-1a6c-08dcdeebed7c 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: =?utf-8?q?c9tv+1Ai53EGFeKsPGSfzx9RZZrW7Jk?= =?utf-8?q?XoI1fjOZOK8kB4S9DNWw6IDNSQmNrQsJ8T9c92Dhnft2YoHqtCut7VwA2gN60uNRe?= =?utf-8?q?/16vyjURJzHFnAm8XYzsGibZ2dtlxG49o7bnl5/gQPLsKnTdL4IGHpIuvhUR9ILlY?= =?utf-8?q?YoFf7G3oZ7ONQi1ezRbc1/TVmrO3YF5fvzThnk7+ahnK3gFP8/RnXNID4cYeD/isT?= =?utf-8?q?LN03AV8HLOG/CGQiI8PKHHbqmU1/bfYCU28HZ96qS5eBTI/XYtkzpO64SiY0IK+az?= =?utf-8?q?Odh8XRWbDrMUFusf5G1ftjWnf4wCd36U7J23hGK2xoh5ecnFyYjysKF6lhqb6wdaT?= =?utf-8?q?KtoxTosupB5XYGzpS9DvoGkZClDakFSmAM5dwuqThXcVg7owGUHjQ4F8WDSVoFyZH?= =?utf-8?q?9pUJWNFIWzYry0wt32ft1pBpPreUkume9LIW1omsjWHG2Ejj4X0W+fVxr21dFI+kd?= =?utf-8?q?GuX4k3uwUGUCX/vzFxpKZG3CU5+f/i5wG6F+4inAGcfSPnp8sebdAlAKz+SrWl0+z?= =?utf-8?q?YCjVcDZZrtp1GBD8fFunGFh4u1lWwE/am9+2TY+ZZHxYz1dBo+8h+sFlQSzW/AzvC?= =?utf-8?q?/0yfQf3DfoJO0RTggRRMk/eqBN0E5LsNxYoJwueaC4VOaqQSMZDdmehhA8lUjSGmA?= =?utf-8?q?rQnchXTep4uFdicXVcqZWY+mOX0MMj+bRKAuBO7/K4rggamlOHgkkInh89oqKT2eW?= =?utf-8?q?I6s3kHFEuyKW+VjB0YOXrwvdrudaXCy9KbQsWWh/L2yrb6SR7hHqSlXwrxmGdvHo9?= =?utf-8?q?wpIF+h/WK6NQIRtZxWeHHfKLk1uhw8HZe6ejOnrpG30BgKTOV8VFzXB5gq3xQE1WV?= =?utf-8?q?0PritLVBNAe0zC0URJx186vKT99yVUZSZceK+nX2InVAUoQIAiVhywELSId0gWCZW?= =?utf-8?q?BYxkx6cGQ3vQCywZAqwTdeBZPZyC0KPVvTTMmucl7Va/1kjxYlIG2tkwRFfvbk+Gt?= =?utf-8?q?Fznp3J5I88OGjRPhUCg1YhJMbvOMwly2msXR+75IZ9uioPlb8No3sQhG3Du3Zl4FP?= =?utf-8?q?SZ+loDGXz1n+QyVxzPkED4UkSP/MMe7EqWUs0PRx6sbBU4lLeQ1VrJN86/YhBn5DB?= =?utf-8?q?7nTVJVopTEuXjKkUrtzBctR83ASFKzN/c1X+jpyZ3R8BkLEzQDNs7uPtpQZh6bl9T?= =?utf-8?q?/ZqMvqEa0gUdh6xs0Ctq8P8wvpxeyBtBcQflmC+Orp4aB6MosdqKMU4+bXtLknMzP?= =?utf-8?q?OrnDQcleLUh3cK+d0qVgagBNRC9JrLHuCSSkxkNSeelDXR5IpPBzXvqEqtwOhQJmd?= =?utf-8?q?4yN69atBdMlHuuLo4RU++52TJNqNOQWPeTF8v/TrnZxsKr491CBIKDYs=3D?= 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: 27 Sep 2024 12:00:06.1844 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 586170db-8817-411f-1a6c-08dcdeebed7c 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7838 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814171 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) (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 A371118BC00 for ; Fri, 27 Sep 2024 12:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438413; cv=fail; b=nIKTvUjdEcWiArjJC522c2kG/ETXgIeW6MI3JcWk2uQa+wVngRpLgpD5df6yX1DMFAZwE6B7vLw068IJfXEi1YaYm8sGpWxFKBHxWgqtvw9sK4lHvhq+vMXCX9ewH4n3rV09ph00YaDlj2ohJ2G2C7Z3K09D87/SMAWI66feR+4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438413; c=relaxed/simple; bh=ZpOSIXqAdYycM1fCZPYY1vZ4Dsae9OA1+c6Q9fZDmV8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YcKpVaNW/RpKNiS+2Lc00hhZCWUz811bCuDpUQRXEs4rfZ7tymYyOg543+VHRzHbD7aDmljBtXtxC0Ti6Shx5eNPRYyHADymuiaC0LViEcYgs4eztmc0PwfKMCeRN2vX3iK5zojWZEUOH0ykBQfKxSkNZNMwPITYe1GWGcZj5gk= 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=sBhij7XN; arc=fail smtp.client-ip=40.107.223.73 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="sBhij7XN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xo48y4JZ55EXQjhbMl8LtdFigUBb99W+GxPwFdr4qV5gBfLxhUkPNLrkqruxeVxCvzsGtkGGxjMWeIVoey3fA4ftmbITptI8oPt7V4Ku6jYVnwYkjDqd9RqfKzIDebFNlA9vLmOQ9GcUdEjrBevWRdNgtXl+LuqBu/q8uCj3WnxDfVwohwexSrCKYrvf2M32ccURTXoh3QWCrQ4Lpmpttl7foabUkUsMI0JfE0Vh7Oq7IAN1qfAJTrmtNXA0DLQEhgtaG+g+jkEBxhw2d4r+DSfB/wtQGCiYF9qw8XXyafckS2sTUu6HSj9AsYiMW77pd2rKlP5isC0Q/6jLtjtPzQ== 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=U5OwxnqLpVLAhvI0TJqEv72hUWg8MKZe1cFuYumlbI0=; b=tJzzuoKgg7kgSPxiNDIfgnqAbQkxYurD5IJtLLQQXlGGVGbE81Vb4zUBwffhirTsSl4F+mVuEQwk2m0/gnjMpeEhcD1hxPK8c7hIO50bcQGC8ujUvPZCV5/kUgb8P0j1HU+e40b5BpmH42sjcbfZ0CUho1nEgi2btucfsnIBSt1o/xqkBKvpIDMfh7fXywD4irsDiE/CVQFcaX8s3/2QbqHb6Y6jVXItVFrpUqCeIPaTG8SkYsEOHVTkZrKsJu6cMQo3BiEKW7xGn/0R0TZkYT1saBBw7STZuODzLf16HOE4pgwD4IpjaNrM+qgaMFPFPPIbZrqa3JaFQ75lqs01Xw== 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=U5OwxnqLpVLAhvI0TJqEv72hUWg8MKZe1cFuYumlbI0=; b=sBhij7XN7QM25XnOEvhjCtqqBGdbaoZxJK0Uej2hA0DEEUtyWW8KsW+79ISTpI2MZTRMeZ34n6Dxh5Uz9DCn1+JNZfVIm/t06veMCvGG9EeUpnHwnkn56rq9tvXEtcgoe8J6OxHt41VdLPjcd0lCT/TdNdwbUUSRimmSLTXS8MA= Received: from SN7P220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::19) by SJ0PR12MB8165.namprd12.prod.outlook.com (2603:10b6:a03:4e4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.24; Fri, 27 Sep 2024 12:00:07 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:123:cafe::a3) by SN7P220CA0014.outlook.office365.com (2603:10b6:806:123::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.23 via Frontend Transport; Fri, 27 Sep 2024 12:00:07 +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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00:07 +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, 27 Sep 2024 07:00:05 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 06/11] platform/x86/amd/hsmp: Move ACPI code to acpi.c Date: Fri, 27 Sep 2024 11:59:16 +0000 Message-ID: <20240927115921.10909-6-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4F:EE_|SJ0PR12MB8165:EE_ X-MS-Office365-Filtering-Correlation-Id: c03f8409-0da9-4f04-d727-08dcdeebee3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?jhzC1WCh+xbmxYJhamihyOk5p6bcrKb?= =?utf-8?q?aGNXgE+UhTZieu0hGJBOB4MMFd+xcL5A9xOoJnyFj2OrpWK4e7I+AoxCLVtMMf8IR?= =?utf-8?q?mKYAQu1cLWN5NYcm6fiJoJKlNHXcdbZVANCyUt9WKDaJcfEsBsYNOrx2scmthf7Hs?= =?utf-8?q?HpgFujY4xwW9paXd3g07NHP1kDcepOLfe7qml6oZ3lUZpj7cxuzB2cYxWTvh+Fz0R?= =?utf-8?q?4pF5Rm2CIbg34tUtBot3WMljfk2i97LT6XYlp4voqEWX43AyAmvl//VGWfrgWexB/?= =?utf-8?q?2LFogsRkCjAOEPVuT6GT/9z4h5HV73Ai7zYf7cewm4CaiCPpaWdfuhbC4eVnXoA06?= =?utf-8?q?Gt/W3WcrPmBl7fz41eYgSKY17tFll2lLf9xJLt2l4b0qASYskhq7ZKc+05uxJw4YD?= =?utf-8?q?Iz+OOxqSnAdKna6SLvr45/X0Y3WVkC4appVezxIto3vSRyprM0LbQO63lDfk3vXxA?= =?utf-8?q?f1eoWFgMZcWvO1COWAz1YZ40ECbcxXuomAy2nWhNgAZ4vO86/eVn4stI9ayxnQnCg?= =?utf-8?q?f7q/hilUPNxXH0b6P47sp/8CYDnm6oQVY9j0AKQ2dtoLfuWjE6j0MettHJu3xBE/1?= =?utf-8?q?PKLfp34n/OiDOTnfLhjDnN7xUjVUWoywcp352HAPyvW/GP4HQXWJR56u/E2Mmalil?= =?utf-8?q?UyQ3HOlMOcMPmtGJw0g7D3TYtCKBFJWH0ySSqubDZNzkJVun+u6M/9Pc2ZO/Hugch?= =?utf-8?q?rjjMXOG67w2ae0Im+s1bAsxr6dRkk0InbUj+cBhfc0sBY3hanlxzwVvMMO1GJBhWi?= =?utf-8?q?1sVRyZavCKgtJO8kXKFu48LxzwbCO6TUbGFTNXEEuSfgfWZvG+4PDdtpqSlk8uTsT?= =?utf-8?q?b4dcJcs1JT81iUNhPHDHQk/t74ZzTIhEsJWJQiePBXfBCJ/krHR7HCH4xrtcJcSha?= =?utf-8?q?rmXiBaxEposNO7Gb6oM+gpjN+RB0XEkeD5c5s3imdFqxGHExz9O7i3I1jHFi5VZg5?= =?utf-8?q?rr8AHfA4zvHFcAi7fdvNjmvXb4gFXUZgF/13FcxIom4Vq2zJWj0LXLyloWQK9cU8A?= =?utf-8?q?+yunixBKh4M+qFGPlq0lWJnvXRyRJzfkp0Q7YoD1Ky7pVDeyt7YfBpTCPj3rQCZHp?= =?utf-8?q?9tZ/6mmNQ/bNsNz0esuY2fAEOD2ltz6VZ4iY69ClcZiea9lg4scFuq3Q0D0OX1q1U?= =?utf-8?q?8bcc+P3ApfSSx4CR1coPrDUUTPxgfG7q1OPeb0HvHT+UWq33VWckE6httCdZS+kAB?= =?utf-8?q?iRtIW2EpDcpaqmZatzVI+ld3+K59RVTmTQ3w/ylw/AcHECA6bk+DD9p2ziQkfwP6i?= =?utf-8?q?P2vaLcqNkHOtOQBLHXNL6GlFwJZg6ADGoliyRw+FGsapg605zkHPBEyo8bx34hMHB?= =?utf-8?q?UqohNNQWJcPO+tKZXJNHAAtwLLLj/S+QuZbHdoyAgGtZOWhzUR3W72Arimt2H7DP3?= =?utf-8?q?2B05g0/57Pp?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 12:00:07.4344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c03f8409-0da9-4f04-d727-08dcdeebee3a 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8165 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814172 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2041.outbound.protection.outlook.com [40.107.94.41]) (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 51BCC189F59 for ; Fri, 27 Sep 2024 12:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438417; cv=fail; b=tBRzErOEaX8wrUgvQyv7IPvR1r1Y3oL3IyiM7bjZFl12BRw1ACta2PnAA0Hm3CmkI+bsZKOLBb6KJF1VgzfN5Dmk+j5zvHQ2N7Slu2crTu8IFNtve8Y0OhB/BdHFVJ+AbCJU74wqfXjY+Wr1ueKZFvwqTX5CUmPkfEfryJ5nLqc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438417; c=relaxed/simple; bh=q7IerrsjUbn6D/B7nZueK5Wuk74Y8ZAdO4nWuQDl6kw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C+dXWVqMbMJZh39616qL7WNPJLUsdUGmKzrjUiIZDKsQbpGPBJkvMOrTDsnAaoNt+nCgXRGWMEhKCuEw4mZccGGrdDn5y0Ro+V0B4GjYRFocHoh7z4/6rHTxbb6sUxlDeJUj6zGmJUKvSgSJI8yP8PU02T7k4Ux0rMZGNi0Eyqk= 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=cMHbJgjs; arc=fail smtp.client-ip=40.107.94.41 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="cMHbJgjs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nv6a43M6xkgWsg3+02ANPph1KbvePSOXKo7zzGy79wzP+ZEarXWt1mM2SxDrDJMJGPLz15EjQw1oGgVjtFeY+fHj+kXWeHWCj37bA0c273Yov2ocsOFYp52XeoovvA1SgjneSqhm/xcedYehKeIoShRDmsUiqxi33dxH/2YF1ynn1rinToomdUfNkMm6nIftpx4T71cPhRiPVfMu6x+vtKJIiINsJTsYY4PAla+++3+3rUaEZsEtHTeaIASGRXFZ6XFnCO5Awp0pV4Aag9w7X6H7W0THnm2Mn4M3h5sZ5owKUO1m/Svf0uqr92zhlwaBW4HNyAfyr1lRUwlJb7ps4w== 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=ETa5iBkJgYHnnfRPEMk/XFNwJpiVGeYwqelOHmvv3jo=; b=fz+ahp6HOCPBPDKYTAMDa1RwhOMomvNhu1512ugq8T5cjxCDgYndfkRWTqTYKGSbs//NW1zfpcRy9M5bBAp8ECoHVfSSiMzH4ueOb5eF1fNmNsQquKb3f21BZ9HScDkxyhcmxEjmk6wcd6LTJs3npJfDVEGXh5f5ZAa9vtgfcPOA3mW6bsU2iF4gnF5Dg3w7E6WWI1dpv4XSEtPYPISIj/1ie2lJ93KETOqinA6ayvp6MNNlPPNOSrre7NpBlfEVF60MlITTJSrbxe5WSl4J/bUkIfcktlWPn9Hnkf4J2VZmVQWcAmVWvrcfZBJbp0P/CFuU4NCpNU+cTzx8Bw+SIw== 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=ETa5iBkJgYHnnfRPEMk/XFNwJpiVGeYwqelOHmvv3jo=; b=cMHbJgjs1LUZs9kaWOz1rk9pXhODD6fEoI8iDPf+akYXuk+WFL+IFbWJMq3h9PB7KpjzdhpHsHScwKaOg9TU+DHb6OZye1yhIkK3mSRc9tQj5ykXISZYAjygRHtq7qL3gIubnbpxGuhOmU08xdFvQjjkyAOOMcDnw3TvNAjcA9U= Received: from SN7PR18CA0024.namprd18.prod.outlook.com (2603:10b6:806:f3::33) by IA0PR12MB8973.namprd12.prod.outlook.com (2603:10b6:208:48e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22; Fri, 27 Sep 2024 12:00:09 +0000 Received: from SN1PEPF0002BA4D.namprd03.prod.outlook.com (2603:10b6:806:f3::4) by SN7PR18CA0024.outlook.office365.com (2603:10b6:806:f3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.28 via Frontend Transport; Fri, 27 Sep 2024 12:00:09 +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 SN1PEPF0002BA4D.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00:09 +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, 27 Sep 2024 07:00:07 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 07/11] platform/x86/amd/hsmp: Change generic plat_dev name to hsmp_pdev Date: Fri, 27 Sep 2024 11:59:17 +0000 Message-ID: <20240927115921.10909-7-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4D:EE_|IA0PR12MB8973:EE_ X-MS-Office365-Filtering-Correlation-Id: 80c604cb-dd88-4250-6a50-08dcdeebef39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?IeqIGMxMp99N6vjhH2nrQySTGM8TP7Q?= =?utf-8?q?vX5CMZbAFjBJUr2evENtLDNj/2fyBdwReTgBQqy1mkEAXEPhrH8ca/Nk/AYhvSYKF?= =?utf-8?q?zKsjwbbqB33u5xipyCDO9XgImP1D1vlTsCk/kzjy087ZjIW6JbC0daP2bU6vTOfJa?= =?utf-8?q?1kXsPYTVMVZb0bWuneBSghV/s+6rtw9/YnW4ZE9PAswlAWl8ky15pzgDtWsbU2o5O?= =?utf-8?q?2RNG7xwDVdg0lw5TMLKY3Eve+GU1fnjIRahto7lC3dktiQaUzDhfyWw1Kc1xe5eKt?= =?utf-8?q?fzIzc/8HtwgXidEAq1iuqKwrzxlAG01BM4g+LsOL9t8Lj6IDHwhmORsO2+ARgHOnh?= =?utf-8?q?QvK4sp4EO8iJJ6R+XF8m94uN0cDKah36kBmWrZC717pioQHZr1PMVpEq/aFf9cZ7h?= =?utf-8?q?h+7cVObaeg2zbqPpETXFbIFhnjl3e8WE/NKEWaizKrtsDtLfOLqWHHqdD+6SqRnVw?= =?utf-8?q?UukmcXjEXAPG2UhS/ymrv9vpps63QaKxQ/XSk3r5L8QDxDgF3uqqkTOjcZwCCUG2/?= =?utf-8?q?MmeoszBwDr/qBafC1utNsR5/2YHmaLPWVANcvsC3f8ywlDmWqDoVfZLsqlbWuqXmc?= =?utf-8?q?7FkrYW+bSM70yiovR5kcWnFxVWuMxwbHnp1WK4FpTKtWJYrJhTZVhPDuGtIN8W25C?= =?utf-8?q?xd462OjSzxjPUcPA7a8EpPRwn0jPjXl86uHCnjurI5SO3qnd4pEzQaKJX9SLsuV+4?= =?utf-8?q?mov2gari7MuEtwUHuakEXZkAmHnvt53jao2E+nxSLXH5Uvi6Vze/GlBOcJCa28z+K?= =?utf-8?q?ndTOkQmmz3uWDGtGA7DfL6R8ciirlGTjogm3MUrmk7abIZZGlxqfqJ39KeLXwbg0+?= =?utf-8?q?5YZQfrNVg/Va9VzqMpnPp4LOdl8zIOUI0cI8malY/kHSQaKDZry2sbea821FOG8CS?= =?utf-8?q?lqtGsimoGOGEyvBz6NbEzAVWTcWNI3tCMlTawcNB3Fr4+UMom7TcM+ij7sg0W2Ia8?= =?utf-8?q?jbaDLRKkR1if5tAhSkX+YuuIiIr0y3gcrfkzDFsrmiEnvmMccj7xhdx840KV5TpOb?= =?utf-8?q?E2H+BQn0AJ+iSFT6XdPwW8f15MpR3o224yevy4UnRRsyJQGyfW3+/xr5ZeMIl2sMG?= =?utf-8?q?KsgZ1ZiwzqvXgx2uyS2xmmYW+qWNKqgUFXtQTPO4R4v38H+jg4VTx8vaVLBaOitgW?= =?utf-8?q?fY3guFe3+lY5BaXDf0QbO0ljO0K4sNynd+aX4TyaBM/TWfEokUWDajRSRRW2kcxon?= =?utf-8?q?SSgKAJZJ0vj0JgDVIjqzUiFsVqxRPw8z/wb2iJLS4FVo2P3Nw8UfsnRVBauOXUKE9?= =?utf-8?q?gPcZfZ/ppwT6zmPe7KsJnX1O40j/WCQySDnU8d+kORMh8rlLSu29UdPo=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 12:00:09.1340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80c604cb-dd88-4250-6a50-08dcdeebef39 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: SN1PEPF0002BA4D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8973 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 v7: None Changes since v6: None Changes since v5: None 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 Sep 27 11:59:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814174 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) (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 A490418C012 for ; Fri, 27 Sep 2024 12:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438421; cv=fail; b=tiFbA9MCc1rXiy/DwExPWG76QTED5vCTgjjsaslooj/KTkwb888qiPyo85kIwWHNMXD3QXhhgyueTGMoHiTRUlJdi3hzHkmNZQ5OHGsiI64dMSVf3iiy1OoC6agWb3LFq16bZY7I5xmiW3Mkg+PPfpHcCsSmuwd3YzEJb5X9OVk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438421; c=relaxed/simple; bh=XUDem1CkTAA9no8JGItQIFmTfrf3f5IR7YfSqRtQz1w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ea8ks/jH1J5Xpi3sLVE3SXV7VR6q3Rq7IW6VhyxUoiQ+xzp/QNhpKq/jVRpu0cC2jNl5jaLGQNOlIlD1I4EIov5T6K6XQqGlFWkTbJPM0d6DSTOhnXELETMFtE8QwxFlA45hw9zisGNlVagjZK6fonFDOQ/nJQZSueIYSE0E870= 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=5cRQic8X; arc=fail smtp.client-ip=40.107.243.66 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="5cRQic8X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V26gxDkn3B7YrUZTOExyTXfxJKLfe8nmkskaVfGQyUZy31TWFsm3UFP8gGyKJsKkdMoCrpqkBoQuFmBks1TpAUJ8G7cf7Z6ruEkyqLWh067IjeqAqVXtXgjxgKDSDmBh5wgmHwA/1gejM/MA0KU/uaFEyM+9z3l7lDM/HLkGyyPnIiE6HxR9IRzhhXN/lY8F/gkHuAAM23JJBmj48c6/1Q8btOj3+KuxceDqZFzlAz6FIbTSfRU+R72TgYH+Le/yJG0eX0Wyqn9X9Vau9qL2Osy7F6BfE56zElQQd+koOHWoG7lmRXnSTLumRdV0O9lW8X7q9jaWWfS17u5n+LURLQ== 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=Bobpo8zJTFHepaqkIfoLqyr2A18P+qDCb0vS5xk6eIk=; b=xRJJM57dHmkfX8nr9g6C/39N9ZrjGWPyjJqYh2Sw2prP4DfrOaWe4wwd4BPiB1tFpPo8BVAYCW97mGF7KwKNgvsSanWtFY8kA+NdjOH4PpU7/wh602R85ui90eT6CQT9nQWgQp53I8kzl1wHLxePkTm14gN2S8rVUOvModEH9Y22TNxuGIaSWGZ3MS0z5cpz4f6+MK7STYaMCw5uC0hVqNqYD6l9bZ8ubhsafrPjLb4yhnhr9nZE/2VR/ZEN/yhE7ZSdQvT/BjsldaykRm1Fo5Md5dCF1FT6s8/92/rt2J2Gx1jF3V5gUhEHoagwoyaq5zohsE0l6sx3Fa7rmFjauw== 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=Bobpo8zJTFHepaqkIfoLqyr2A18P+qDCb0vS5xk6eIk=; b=5cRQic8XWpXSMoaIl7vozshWzaz6UoB+NjjVXHYoaB1CUHWsHMmP/kfJMBINQ6YwwxvUXxtIFVHyFGgEY6/Muf7WRv+QzoIl9x9+yW9EWU+gTJcUydIB7i4H/I2yOQifHH1WE/wRxp3rrP7DC7lbhlt6qObNrtKBYc0Jk8t2nmc= Received: from SN7PR18CA0007.namprd18.prod.outlook.com (2603:10b6:806:f3::27) by LV2PR12MB5725.namprd12.prod.outlook.com (2603:10b6:408:14c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Fri, 27 Sep 2024 12:00:12 +0000 Received: from SN1PEPF0002BA4D.namprd03.prod.outlook.com (2603:10b6:806:f3:cafe::d9) by SN7PR18CA0007.outlook.office365.com (2603:10b6:806:f3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22 via Frontend Transport; Fri, 27 Sep 2024 12:00: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 SN1PEPF0002BA4D.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00: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, 27 Sep 2024 07:00:09 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 08/11] platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers Date: Fri, 27 Sep 2024 11:59:18 +0000 Message-ID: <20240927115921.10909-8-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4D:EE_|LV2PR12MB5725:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b7ea531-68df-4429-55bc-08dcdeebf129 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: ZynyU1aKxN3eqlnN0hXMRrB7RIJyUrMGu9TOu5qRKh2hQM7gR4by8V9+ps4ONwEBNEVs26Ytnsg3VquPjvNRT9znXa6lBdW4Z7a94IeFKIsDDQ/AmR2f8oTwvRgSv0KpDT/+NMQ7hnyateRaVy/VXqe1VQVHq/DJ1kyLTp3n4KOuzJ/C7SRv243PETaaysr3em6zpLuQI5M9OYTFF5/2NLamNu9DEt8yu6EUDG/VowtHiHdAdye0Gzy6Mqp5zpXwYGLqADb6E/jUH7cLoe0mjqWZZ//RGIJkYZ9u/tTP7yDwsgQngFhQdq+QASVQO+WKa7nLa768qdSVNXlVH990HNzD3FWNp71iWVyGG4USMk9iYz/NQrLTUdoXyx85Yp/5KryOgsW86A+kwlmrzzq7njnwBwNbfLBny5i0zQ1/Ew576njvK+J5uNKRS3jLesnFD9Yc13NYq8PUjiA91+80ud9IK8rF0mDZPsjB3sgm0LM3qmzeudCE/triz69sgn8bQew6gUd5eVav6Zcc8xg6eo2XwBP5HU5X5XbuPGJGjU71ql3lZexWYde2gS6N6hiOpnR/w1IiWVPzuxQ+wHGtjVEdCyMiNxSQqMisQLdnrZ1g3XN8ugdqi3AHKktOyDVggEwLn9qDMckrSCfQKWMD7hv5ZYBynLPH6hV+6lwczAC5be8UY2GF7OkkhxKbr/NEdAhK1SO8tENWicNhjG0zPTe7zgC4PbvX+Ov5C+S+sCG3VI58XAKqB5cqCg0aBtLnOmURNLdQ13rWewydzNPN0bo0/nUo0ChV3wujmdfuKc4Y7MBHtbZUGuKHCzq/85DJ1yH/p3iiPO7l2V0Su/Ky5d1TpT5b8u0I7W8cEPUnnr/rxZc6fHkjPH5sjHPDoTNSnd1aE9ihzMjMQXH6boXF5kXGTo9vf+ERW3lN/S5usjPZAQsHQo7Z+nt534ZjareeEOYsazkBfJGNJcAgIDfb/TxZEaRjHxWFUTQOw28gkAJAq2R93J1APBB8fYOrBFzaop1s9lH9glwTvD17wvi2i6OLcPWvF5DfUxkYf+RWPjTPgQm2UKHTsLQfOT2pyxG5bsXhKMOZVvzsTaoVZA/0qFuN0lIW+Jcmpzc68lzrahLXbUbTL0YMuU4lUt0g9yw+SUtrQGrg3BaRS6ECg4OO2z7hILvJGh62AZsBIaxw6ctxqsPaYSGeRAVM8+riXZ5h/1gxYtIC6lS6i15KWDKgV86NrJ4vQKvPiKaSJig9BP3T1t6843nuOaTfJo+C01TqELW/y/2lcZtc4kgP2GBsUs/Rsbyjw9snF6orOIRKRknq7zRhctsKyS5VCM/VgISthlJ5AU2NT8HNZaFErORog9xuYyQiAnk4JVTeyQWd+vwH0xyeirtV7XsupBw90c/bv5tcvb3+izlRilTVh6L7Kpn/lmlDsxLXV+7NaOmEK0w48Slp2DzMaYzO7Vm2z8QW X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 12:00:12.3841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b7ea531-68df-4429-55bc-08dcdeebf129 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: SN1PEPF0002BA4D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5725 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. This will be built into separate hsmp_common.ko module and acpi as hsmp_acpi and plat as amd_hsmp respectively. 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 v7: 1. Commit description is updated. 2. Makefile is updated to create 3 modules, hsmp_common, hsmp_acpi, amd_hsmp. 3. hsmp.c is modified to make it as a module and functions used by acpi.c and plat.c are made as export symbols (hsmp_test(), hsmp_cache_proto_ver() etc). 4. "depends on AMD_HSMP_ACPI=n" is removed from Kconfig. 5. Documentation is updated to reflect new changes. 6. amd_hsmp.h is modified to remove IS_ENABLED(CONFIG_AMD_HSMP_ACPI). Changes since v6: 1. Keep the SPDX license line same as original hsmp.c file. 2. Reflow the paragraph in amd_hsmp.rst. Changes since v5: 1. Update documentation to reduce line length, update SPDK line and update the wordings. 2. Change module license from GPL v2 to GPL and update SPDX license line in plat.c and acpi.c. 3. Update Kconfig with amd_hsmp.rst document name. 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 | 67 +++++++- drivers/platform/x86/amd/Makefile | 2 +- drivers/platform/x86/amd/hsmp/Kconfig | 36 +++- drivers/platform/x86/amd/hsmp/Makefile | 8 +- drivers/platform/x86/amd/hsmp/acpi.c | 82 ++++++++- drivers/platform/x86/amd/hsmp/hsmp.c | 222 ++++--------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 8 +- drivers/platform/x86/amd/hsmp/plat.c | 144 +++++++++++++++- 8 files changed, 354 insertions(+), 215 deletions(-) diff --git a/Documentation/arch/x86/amd_hsmp.rst b/Documentation/arch/x86/amd_hsmp.rst index 1e499ecf5f4e..abf1fa3230d9 100644 --- a/Documentation/arch/x86/amd_hsmp.rst +++ b/Documentation/arch/x86/amd_hsmp.rst @@ -4,8 +4,9 @@ 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 +17,25 @@ 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 drivers/platforms/x86/amd/hsmp/ has separate driver files +for ACPI object based probing, platform device based probing and for the common +code for these two drivers. + +Kconfig option CONFIG_AMD_HSMP_PLAT compiles plat.c and creates amd_hsmp.ko. +Kconfig option CONFIG_AMD_HSMP_ACPI compiles acpi.c and creates hsmp_acpi.ko. +Selecting any of these two configs automatically selects CONFIG_AMD_HSMP. This +compiles common code hsmp.c and creates hsmp_common.ko module. + +Both the ACPI and plat drivers 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. $ ls -al /dev/hsmp crw-r--r-- 1 root root 10, 123 Jan 21 21:41 /dev/hsmp @@ -59,6 +71,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/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..dc64b5b1165c 100644 --- a/drivers/platform/x86/amd/hsmp/Kconfig +++ b/drivers/platform/x86/amd/hsmp/Kconfig @@ -4,14 +4,44 @@ # 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 amd_hsmp.rst document. + + 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" + 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..3175d8885e87 100644 --- a/drivers/platform/x86/amd/hsmp/Makefile +++ b/drivers/platform/x86/amd/hsmp/Makefile @@ -4,5 +4,9 @@ # AMD HSMP Driver # -obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o -amd_hsmp-objs := hsmp.o plat.o acpi.o +obj-$(CONFIG_AMD_HSMP) += hsmp_common.o +hsmp_common-objs := hsmp.o +obj-$(CONFIG_AMD_HSMP_PLAT) += amd_hsmp.o +amd_hsmp-objs := plat.o +obj-$(CONFIG_AMD_HSMP_ACPI) += hsmp_acpi.o +hsmp_acpi-objs := acpi.o diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 6f8e7962266a..766617e6adc7 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"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 78945750d590..4fa0850c7824 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 @@ -39,7 +33,10 @@ #define HSMP_WR true #define HSMP_RD false +#define DRIVER_VERSION "2.3" + struct hsmp_plat_device hsmp_pdev; +EXPORT_SYMBOL_GPL(hsmp_pdev); /* * Send a message to the HSMP port via PCI-e config space registers @@ -227,8 +224,9 @@ int hsmp_test(u16 sock_ind, u32 value) return ret; } +EXPORT_SYMBOL_GPL(hsmp_test); -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 +282,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) @@ -317,6 +309,7 @@ ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, return bin_attr->size; } +EXPORT_SYMBOL_GPL(hsmp_metric_tbl_read); static int hsmp_get_tbl_dram_base(u16 sock_ind) { @@ -359,6 +352,7 @@ umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, else return 0; } +EXPORT_SYMBOL_GPL(hsmp_is_sock_attr_visible); static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock_ind) { @@ -397,6 +391,7 @@ int hsmp_create_attr_list(struct attribute_group *attr_grp, return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind); } +EXPORT_SYMBOL_GPL(hsmp_create_attr_list); int hsmp_cache_proto_ver(u16 sock_ind) { @@ -413,194 +408,33 @@ int hsmp_cache_proto_ver(u16 sock_ind) return ret; } +EXPORT_SYMBOL_GPL(hsmp_cache_proto_ver); -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); } +EXPORT_SYMBOL_GPL(hsmp_misc_register); -/* - * 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; -} - -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; + misc_deregister(&hsmp_pdev.mdev); } +EXPORT_SYMBOL_GPL(hsmp_misc_deregister); -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_DESCRIPTION("AMD HSMP Common driver"); MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); +MODULE_LICENSE("GPL"); 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..e49b53f8c5e3 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"); From patchwork Fri Sep 27 11:59:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814173 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2055.outbound.protection.outlook.com [40.107.236.55]) (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 754EF18C00E for ; Fri, 27 Sep 2024 12:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438418; cv=fail; b=MwZeOFZP3c+en1ArQzf2Og8Bhg7I/Dx1MVmhWiYRCayBcFV78o/ajuy7gHvKJlfMso0yDuTEhPogiDgl9dNKlkHkOu58TmJPCX2zTY8hRiV82mTXLjuqB2rfHr2lH/DWlLRC8CTdtk7dvVYJ9vw81jSZ6JjQOwX/k1fOz72Oixs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438418; c=relaxed/simple; bh=R6IEF9gdF2BrP26N6eBuDmlljwlq0Og8uiRNScQ3B9w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qLLXTpiOnCn+aqok+taV8VrCfM8tLQMa6gfwk1c6NOB8DvJYpRQ9stGOJ3PyPtbxcP/aZFTj0ZXv81pGMsLAsGRPRHAeGDjrPas0vZFMlg2Qk8YshhegySMUSPzEQkVWk5KrWA0P0cqzPP6DdVNwt7s5NLQcTYh1vilrNCudkxI= 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=oiz918PO; arc=fail smtp.client-ip=40.107.236.55 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="oiz918PO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ekWzWmPZtO4DkK+NWuc0Whzzli20Mj61MZjJwdw0T4JQjD79APYgzETgtL00vsezeGcqeBIhY/M0lX0dxYqqXFpXD/aINEfoDMqqb6WqI2jvZyxBFxnJ9x6Oq04CCqEhd4OpH8qHfPIZJXpfPHOH8lGM+iHBoXgmTD9xizcmUYLlZRiC+5TRZv9/dIq7gGG3CfAEqgTuIWP1GOCpZ+K3BWXJ57WPMAwXSUF3J0HZibaAo0jAf1aoscrzryHzOb8i3PvPDSxvVVsMcYRqeoUMz1XnwYR0k6XRIrQOdrty+aA+vOFco51YLFqa+BSX2gX6Eug+UuxSSHgg5ydNR2Lqog== 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=cASPamzJ1Kl8U8FvH9z+RplpIX25E9lWaufxtaMktYw=; b=Sd52VXKjiMYy/fWehcx3tQiB2K/ngWCD6eNc2RUs0bdmAIH9x9qhl4qrlyXLssN3JgYhvGfBpjvEZZBLsBbiAWH8sfU3VXV+f+NJMi3L2CrYhP/S9baf+5o5vUHhP37/ZT/XsvSSe5kaMZQrYcSgp7FwAtlmvMxLGBk3IUAFTJiwAcQFN2KncIcXP4zgxF67ntFgoRiG5wpDEMtdDGbcfsq9gR5Jmd7co9AbB1UxD73DIYLuLJKysdPa+tdT45ALm9Tq+FQ+V0BRKQ++RbfE4ubnDHvFmI16XTXkOhVNHFCstzcqOAIjKq7NDik5NVR3SGFJ66PDncickn7L5u6Pjw== 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=cASPamzJ1Kl8U8FvH9z+RplpIX25E9lWaufxtaMktYw=; b=oiz918PO/fKYPGYsE5vTiuNhtO+LMlmcg9tCj9gvuFFwnWOi87nko3dmkoau/nB/LnDrtzDlcjAiXQRr7TMKpBM7px0/Y90yd8R/e3BX320U5wyZFpL+6pow4PY+GPrnHEUth8qKk2YCABhvaLLG9zhJOqC7g6tUwgO9Qm//52I= Received: from SN7PR04CA0053.namprd04.prod.outlook.com (2603:10b6:806:120::28) by PH7PR12MB6418.namprd12.prod.outlook.com (2603:10b6:510:1fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Fri, 27 Sep 2024 12:00:13 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:806:120:cafe::51) by SN7PR04CA0053.outlook.office365.com (2603:10b6:806:120::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.21 via Frontend Transport; Fri, 27 Sep 2024 12:00:13 +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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00:13 +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, 27 Sep 2024 07:00:11 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 09/11] platform/x86/amd/hsmp: Use name space while exporting module symbols Date: Fri, 27 Sep 2024 11:59:19 +0000 Message-ID: <20240927115921.10909-9-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4C:EE_|PH7PR12MB6418:EE_ X-MS-Office365-Filtering-Correlation-Id: 7dc8981d-adbf-48c2-f72b-08dcdeebf1e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: JP1wo4rtX5qfKTmZfsaDzrgp63LD2PjoejuPjB9yMBrA2h7IyBbIgoGtc+4aEETg3htO3ZTVd2Y/9AJrXDx4NVEZnF2upqrwKFqNwMAYRA1ZmHjc+GqRhwqBx84XSrxX2wB9h0QNKmt/lpwtUg5+uVYuI35h/wcxYwG/IyBSgjn4QDvaD3HLkofpAqz5r4Rt2KSek/eE7yo9J/v09kcpIfk8kAgsNsb/QIlYf5XOh0ARd8LdZlWZpEDnblvdTXsV98hMm4ln4kOFY/lGct4jOjkhqvnbRWknO4DESz13mASJfSIecNiuEWmfqX/n/onlGF4BvfVeJ9GVUDhrlstCKZas8mXqZeMBanfulmyQ03l7/GtDRH4p7y5lKOuodMv04mhZ0sdKirhlwEzou1iMJtzonPkx92dVTdDWaNZ/TrTyjmzK/I75UHKKMJeC6lMqPC0dKwX39t+wYhPYrf5F8RQrMvbr8Bka7o/jN39UjslzsxDQY8B/NJf8U3D7C0ufFpNphBMjg/2b/Y53iN26jWD/b5teDfPVOSael81EzUD2VGs+EmCITtBGyTurjfcyWriGN2GF9UhyJgFmqGiABK1cckLYs3qJ281x1i5Q9yyk7P6LgLaTbg16JzUABDz4YokWHthKBEY4cgefVmWekATLXISr51Z6sE/erAXRkN/1QKDQAM2ADqB3l4OOMn+JVwwiceU2D41aHLbtjUabXtxQwhfo4EFD3AevTC8ueEEA7EtNCbLpczWqyb0fjFg1vyhJ76O2+awOcMZ06hVImmf90tn6aBX9D2jloeqlZKIbkZUdlNfE2LNQQ4LbQAv+Cc33QJcy9W4NfrVhyZzCDhG+Wn0mMzUK4ky07r19zgSrZGuA8f8XmUAhR/RMfjk2pnrN1Rqu20M9l0v6w6cncge0f68IntuwMncYDRxL7kqeSkDQf1pzAeBjW3/u54U5Qb+MwU35AqzzVXBgyTbTxa96BRVpV3s7HQ5ljP/uTtgSiy4v3cwEpU20KWZF9BF4+FakkbBfQjhZ0Ag0mLKa0GX7lZ4ZkCIHWW1jLaHVbY2E5fPobr8Ew5FVd9OhN7saENPPIMvNWTag/dwigXucHEsr0lnZe2K5GWznTUsKYZWSIf5mYz5BZ7nBloj7H0OtkerfyMVLjsQOBI2fDwRB2k6OvJXc5zstB5QwiRYApngg4oF0SxMIHuYkTlC6o31j0MYS5BTcfk2/u4gWwROHNHNKksFfFjtV6Ffx6AljJK1YcsejdeRd4Bilgt5csRqcSCZg17grKbn+jJssjmnpZPwkyOSTjOnWDCGbUy+EfxfM5sAVMGYOkofc1DIlwDUrsD/s4xj3O4zqapsUgWhOVqz3pfbQhgBLEjLV810nKRU5OvybX4/gHuaOyKNlVHbUDmOcTOOvRq06EGDMYSjtt1/n6S2xtLcckfzE+J4PygDwfMWibWw1rjl9MPN+uuC+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 12:00:13.5785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7dc8981d-adbf-48c2-f72b-08dcdeebf1e1 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6418 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 v7: 1. Changed from EXPORT_SYMBOL_GPL() to EXPORT_SYMBOL_NS_GPL() for the newly exported symbols in hsmp.c. 2. MODULE_IMPORT_NS(AMD_HSMP) is added in hsmp.c and acpi.c. Changes since v6: None Changes since v5: None Changes since v4: None Changes since v3: None Changes since v2: None Changes since v1: None drivers/platform/x86/amd/hsmp/acpi.c | 1 + drivers/platform/x86/amd/hsmp/hsmp.c | 18 +++++++++--------- drivers/platform/x86/amd/hsmp/plat.c | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 766617e6adc7..53deee86f456 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -343,6 +343,7 @@ static struct platform_driver amd_hsmp_driver = { module_platform_driver(amd_hsmp_driver); +MODULE_IMPORT_NS(AMD_HSMP); MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 4fa0850c7824..6fd08f16933a 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -36,7 +36,7 @@ #define DRIVER_VERSION "2.3" struct hsmp_plat_device hsmp_pdev; -EXPORT_SYMBOL_GPL(hsmp_pdev); +EXPORT_SYMBOL_NS_GPL(hsmp_pdev, AMD_HSMP); /* * Send a message to the HSMP port via PCI-e config space registers @@ -193,7 +193,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) { @@ -224,7 +224,7 @@ int hsmp_test(u16 sock_ind, u32 value) return ret; } -EXPORT_SYMBOL_GPL(hsmp_test); +EXPORT_SYMBOL_NS_GPL(hsmp_test, AMD_HSMP); long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { @@ -309,7 +309,7 @@ ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, return bin_attr->size; } -EXPORT_SYMBOL_GPL(hsmp_metric_tbl_read); +EXPORT_SYMBOL_NS_GPL(hsmp_metric_tbl_read, AMD_HSMP); static int hsmp_get_tbl_dram_base(u16 sock_ind) { @@ -352,7 +352,7 @@ umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, else return 0; } -EXPORT_SYMBOL_GPL(hsmp_is_sock_attr_visible); +EXPORT_SYMBOL_NS_GPL(hsmp_is_sock_attr_visible, AMD_HSMP); static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock_ind) { @@ -391,7 +391,7 @@ int hsmp_create_attr_list(struct attribute_group *attr_grp, return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind); } -EXPORT_SYMBOL_GPL(hsmp_create_attr_list); +EXPORT_SYMBOL_NS_GPL(hsmp_create_attr_list, AMD_HSMP); int hsmp_cache_proto_ver(u16 sock_ind) { @@ -408,7 +408,7 @@ int hsmp_cache_proto_ver(u16 sock_ind) return ret; } -EXPORT_SYMBOL_GPL(hsmp_cache_proto_ver); +EXPORT_SYMBOL_NS_GPL(hsmp_cache_proto_ver, AMD_HSMP); static const struct file_operations hsmp_fops = { .owner = THIS_MODULE, @@ -427,13 +427,13 @@ int hsmp_misc_register(struct device *dev) return misc_register(&hsmp_pdev.mdev); } -EXPORT_SYMBOL_GPL(hsmp_misc_register); +EXPORT_SYMBOL_NS_GPL(hsmp_misc_register, AMD_HSMP); void hsmp_misc_deregister(void) { misc_deregister(&hsmp_pdev.mdev); } -EXPORT_SYMBOL_GPL(hsmp_misc_deregister); +EXPORT_SYMBOL_NS_GPL(hsmp_misc_deregister, AMD_HSMP); MODULE_DESCRIPTION("AMD HSMP Common driver"); MODULE_VERSION(DRIVER_VERSION); diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index e49b53f8c5e3..0c34312d1a50 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -271,6 +271,7 @@ static void __exit hsmp_plt_exit(void) device_initcall(hsmp_plt_init); module_exit(hsmp_plt_exit); +MODULE_IMPORT_NS(AMD_HSMP); MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); From patchwork Fri Sep 27 11:59:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814175 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.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 6CA4518C32E for ; Fri, 27 Sep 2024 12:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438422; cv=fail; b=oDcsgj/QbDsLogwboDXuor/6y7bjoEF4HE+a1L1SMuEA5whWwFNWh7LWeIiLJ4JYjGBEeCkmC6baZtgV5UQenFSBaM+yl8nb/+UznABYDDNv803PbCe9JU1FU1Axpdgntm8qxbZltnauNqq1wCmA5U/mjfoZXxe7a8Wf/0Qclf4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438422; c=relaxed/simple; bh=2m7YpLlvzkGtnV1zrnt27dO8PnOv/ERBVX7oZ2r+ckU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GWzU4JnczGZlLWC+9KUipdB0n2ovUkDVy5VOJydcOOcBeyDMrq5ThivdlcYasBL4aWunhxb2rYexNz8RNPVT5sFeJJ5S9POw8IYC0B/h/whPquYxGaJwTf4DDHe7LUlpXEySJcfecPXJ6Z9JfapHZKG4fZ53nJenRDQznoGD1OE= 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=hZ2ueeMK; arc=fail smtp.client-ip=40.107.92.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="hZ2ueeMK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CuIBfDTwQsqd/W/VY6pEv50/vymFP7fM+wcUvlL3yTXIUE49KLajIW6TWqJXjU3tsRqtdrMlyHJ42BAO4uQJZRoa23dbDbSVanqhnA+aQZVUJPl4bM403NcQaVzgJoAw6zo+GiKpivrqONKYOLHmIHX26dr+agyekdm7V0t/tpnQd2FKMzFaoPoyRKlcG/tYr/REeknZYvkVV3Bk8PbgRvw2/NjS70HptCQ9pxtiPJ5tBlPqx/CfAW5xKFgvMHfiTLUPp01Jtv5Op14LVaatQzh1etwHNKJGe2OhiquLE2cw+fwObRmLl496GewbknkVZRGRwd7WHEyKjIL+w9tzMw== 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=j1SWnGNVsDcDUAsUQLeVLuaW/KaQemi9MZCJjnoZr2M=; b=UmZUiWprek0aJBKmToCdf0C06cFtxRQQ8L9UrCaAo5uODPz0yMSt+yt9EL0uQ/eOzla5JMoM08nFSfjGT3DZq/XomixvigWyyLC6jqP5nkNSLcFezyr1tV7LX+IncSji9xDb1wus/aLGcCLe+yIEHVoQNBkvawi/q3m4M3s+yYIpSp/Kg1CxveKZrBJZ0rGBAzwqq3DnZ4GhNGCjhidmfn6Vp2E5p4wiS5oU8uVQEwg7MfIFg06+8IYlGC3LODQMQmKpUWD6rhKtv12W2KaZI2EyNAYItTrfYcIewBk+x3l1rlvwRuQIyYRLayPBgUKDacy5W2XUKPGVnAUWBsVcjQ== 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=j1SWnGNVsDcDUAsUQLeVLuaW/KaQemi9MZCJjnoZr2M=; b=hZ2ueeMKDJ3CvDtPvLRu/gvJVhuetgwb+0fZ8KxaU75m8DcAZ9oDNS+gaE1kOCtO1R2Iug74LKWExaZ28z/mIDjUapoM02SIcbcj/rirz26Ng0fe20SDWq2wZtYMgJLx93Ri+BXPptKk/jOoZWhXNUtiZDK11m1rFLPzRwiSXqA= Received: from SN7PR18CA0029.namprd18.prod.outlook.com (2603:10b6:806:f3::28) by MN2PR12MB4471.namprd12.prod.outlook.com (2603:10b6:208:26f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.24; Fri, 27 Sep 2024 12:00:15 +0000 Received: from SN1PEPF0002BA4D.namprd03.prod.outlook.com (2603:10b6:806:f3:cafe::88) by SN7PR18CA0029.outlook.office365.com (2603:10b6:806:f3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.17 via Frontend Transport; Fri, 27 Sep 2024 12:00: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 SN1PEPF0002BA4D.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00:15 +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, 27 Sep 2024 07:00:13 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 10/11] platform/x86/amd/hsmp: Use dev_groups in the driver structure Date: Fri, 27 Sep 2024 11:59:20 +0000 Message-ID: <20240927115921.10909-10-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA4D:EE_|MN2PR12MB4471:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fa0db6b-d3df-4511-b74d-08dcdeebf30f 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: u083XbIev57ilCtk7OALW6OA59GSQ22AFeFrYtenBQvx6tpvdMmg/lxam4Amz16ZruIXw6E3PUPTUoVGb0v9wXipd5PitHC4o9j9vE8L8ihBzzILBj55oZyY5j1bCmzsY6s8mBo+z0WZpjq90QHpatu19szSLYhSCanKv+E2O5jH2ybTOLbV+2Fg5kdf4ddvfy3SSjLn23E3DRX/DRggAw1SrA+CwhZZAdArfwrGjJZxZAWgyrNOnfWk7Nvl0K8shWnyG59HGmy6LJ7Lxkid/Y4gEMl5i1GowU+lV0I3rf6o49v1nAFWzmHNK8wtj0qBmT0iazz1tX8ct0/98tQsUVO1kSBTRcrqnulAjwcb/STItEYtD/5jBuvn+QM3cLDqkYPDEzKORs4rRjxCfpaXL3cVyzpyUBy6/egHkwiGkE3nWyed28rNklIzFpQiKU4Ikah333cdXqkgqMsicjV0DYch1QIcV9DqdQSLIgMsDHQYlwQKe5IXDw7fNIsIHWcLIEpmFIDqQ/uFVUVPZLOmTPv9PaiinZWYKHm4VT3c1pofD7dNawU2CfI4JMNyeiUem09vQFsSEww6smuwmyfKr15z7OrSr+dshU86jH6yfDcU8ZhjyoEe2JzBCtxJI/OjTsgV3w0EL2edYggO++29tapS8/dCYCzG3/eRkLkP0+o6X+qiKr19DXsP7iKnwwdBjglj3ZKdNXO+wgfT4JWABlmzcZQGxEpyWncNR7wYs8XMqzaRfQjC5X9hrn8dGfY/8gt5NES2AI9hLmzNosyaw8puSKSwKhVTqnSjiFudvbbuWtqviEvEbSJoEdYB0nQ3lNgmsaQulYaJ5jWGBzxTgb7vM1IhFcXOge7so9TbOCpf93aX+sdgpLa6clSDi39Sk6teETtYhoCUvPR8v75yFK9BGAONsbOafuM8Nmtiy6EnY0b4EmYer4H2eGgqMEtEsUsVuaJvCuZ7ximk0DDkWdK1xFJzFfmFbK/sFfHbmpwq+Go/q8qAzU7JYhi1RfMpGn1H5BIdWgG3wRXPb9zbURzjiqjHH1S28Xv98G25dJeKyWReyKsBRjsrzfCoX1qHVzUrzYruaGE/hz+hd3sNWzxgxCzT7b9z8R6pJ7ylitQZAQF0iRYddbaaErgCnqQLXx/2Vh2BOjvJe8li8a2TZueDoptWptjmBxvg6mzIA0oppR5TKx1kpwNvyJcx5+qjj9olVyShijCOF2yHHHvQzppqLzgsYk0M6alK1o4no8VRi4tQ93UyA+ZUCCEsPhojaYKyydDj7IJVZXMR8bO/EYtjKGlb1K7oadBF0TVSzii4eTidI90K/5SbQCu9vlImCGGhXWp+H+hJS0LLKmLkwfz4afsHyZOmIWn1ywhrcSA= 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: 27 Sep 2024 12:00:15.5560 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fa0db6b-d3df-4511-b74d-08dcdeebf30f 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: SN1PEPF0002BA4D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4471 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 v7: hsmp_get_tbl_dram_base() is exported as a module symbol. Changes since v6: 1. Move common code of hsmp_metric_tbl_read() of plat.c and acpi.c to hsmp.c with the same function name. 2. Rename hsmp_metric_tbl_read() to hsmp_metric_tbl_plat_read() and hsmp_metric_tbl_acpi_read() in plat.c acpi.c respectively. 3. Add tabe space in macros definition in plat.c 4. Keep only one cast for sock_ind. Changes since v5: Assign integer directly to .private. 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 | 65 ++++++++++----- drivers/platform/x86/amd/hsmp/hsmp.c | 67 ++-------------- drivers/platform/x86/amd/hsmp/hsmp.h | 9 +-- drivers/platform/x86/amd/hsmp/plat.c | 113 +++++++++++++++++++++------ 4 files changed, 141 insertions(+), 113 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 53deee86f456..9435e40bbf25 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,23 @@ 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_acpi_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; - int ret; + struct device *dev = container_of(kobj, struct device, kobj); + struct hsmp_socket *sock = dev_get_drvdata(dev); - 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; + return hsmp_metric_tbl_read(sock, buf, count); +} - ret = hsmp_create_attr_list(attr_grp, dev, sock_ind); - if (ret) - return ret; +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 devm_device_add_group(dev, attr_grp); + return 0; } static int init_acpi(struct device *dev) @@ -275,9 +274,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_acpi_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 +332,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 +360,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 6fd08f16933a..7c3fb090684f 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -282,19 +282,16 @@ 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) +ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size) { - struct hsmp_socket *sock = bin_attr->private; struct hsmp_message msg = { 0 }; int ret; - if (!sock) + if (!sock || !buf) return -EINVAL; - /* Do not support lseek(), reads entire metric table */ - if (count < bin_attr->size) { + /* Do not support lseek(), also don't allow more than the size of metric table */ + if (size != sizeof(struct hsmp_metric_table)) { dev_err(sock->dev, "Wrong buffer size\n"); return -EINVAL; } @@ -305,13 +302,13 @@ ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, ret = hsmp_send_message(&msg); if (ret) return ret; - memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size); + memcpy_fromio(buf, sock->metric_tbl_addr, size); - return bin_attr->size; + return size; } EXPORT_SYMBOL_NS_GPL(hsmp_metric_tbl_read, AMD_HSMP); -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 }; @@ -343,55 +340,7 @@ 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; -} -EXPORT_SYMBOL_NS_GPL(hsmp_is_sock_attr_visible, AMD_HSMP); - -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); -} -EXPORT_SYMBOL_NS_GPL(hsmp_create_attr_list, AMD_HSMP); +EXPORT_SYMBOL_NS_GPL(hsmp_get_tbl_dram_base, AMD_HSMP); int hsmp_cache_proto_ver(u16 sock_ind) { diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 9ab50bc74676..9b4ab6a3598c 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -57,16 +57,11 @@ 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); +ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index 0c34312d1a50..c1ddd8957f19 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 @@ -61,36 +62,93 @@ 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_plat_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; + struct hsmp_socket *sock; + u16 sock_ind; - hsmp_attr_grps = devm_kcalloc(dev, hsmp_pdev.num_sockets + 1, - sizeof(*hsmp_attr_grps), - GFP_KERNEL); - if (!hsmp_attr_grps) - return -ENOMEM; + sock_ind = (uintptr_t)bin_attr->private; + if (sock_ind >= hsmp_pdev.num_sockets) + return -EINVAL; - /* 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; + sock = &hsmp_pdev.sock[sock_ind]; - 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; + return hsmp_metric_tbl_read(sock, buf, count); +} - hsmp_create_attr_list(attr_grp, dev, i); - } +static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) +{ + u16 sock_ind; + + sock_ind = (uintptr_t)battr->private; + + if (id == 0 && sock_ind >= hsmp_pdev.num_sockets) + return SYSFS_GROUP_INVISIBLE; - return device_add_groups(dev, hsmp_attr_grps); + 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 = (void *)index, \ + .read = hsmp_metric_tbl_plat_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 +199,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 +226,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 +239,7 @@ static struct platform_driver amd_hsmp_driver = { .remove_new = hsmp_pltdrv_remove, .driver = { .name = DRIVER_NAME, + .dev_groups = hsmp_groups, }, }; From patchwork Fri Sep 27 11:59:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13814176 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2071.outbound.protection.outlook.com [40.107.236.71]) (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 0A37318C919 for ; Fri, 27 Sep 2024 12:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438428; cv=fail; b=KQrzG3uTfVkr+SPFQaVc2ba364rvF4d7XJwUdgqVyzNE0wTFuSYm4IHUTFo0Xq6hDfDeC2TyiYASLTLUivXydAbhBzNh280KlT/QwiDAF8aN4FvnpvZN9WvybfBk1ZKa8x1990/USQA2gIyoulXeGS33AqRnJ30l5K7shsRp/dc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727438428; c=relaxed/simple; bh=5oBKjabA2YdytiFu5wEDB4lxNiHBiES2qrXvztj16AI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pCTUNDoDsk7gUR7R4iWt3mfIv3xpre7NgU0uUxOhZ0TrmTh5NEFiM3S2kddBGvTtFTGzYm7ViovLrrt25MaTsuxkyrjn0OimiVnlmyxS2iqBO3X10AOMRcO9OenRyXxIj37pM9dLMy31uKNn5N4QMOcP1B96JHSiuizHJUddmS4= 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=HDN7pTHe; arc=fail smtp.client-ip=40.107.236.71 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="HDN7pTHe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sB9H3Ak+JpG+SeM+MO/hp7/0WFUUZljA8T+6fEab8F4BrPqiCAv8OJ9pcCFt85stjy7trC2GcGJV7lv7AqknZtWYZ8fND4zAlD8shGE8XBmlIUXfX3Kk1B4lUoIrOs5Lr9z1NfAyfo7BM6H1QjRUtj7k5uJrgQ5KNrpE29udWZrKQg9dATm7jyJHAARy2L7dXEv3wuHSj27sZCDeSQKsii+1WHqGDlO2BzpYIjCajBRn3GL1P4U6Hov2lyMQt96VESFz+3hZuhlt2en+Cj43FbHNU17Dam1iMsceQd2/P5c3usj14L7rMoi5JmsuOq/oC+JIqRYano/2hObTcthuRA== 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=qdUPzNSAjpC/zSuhS/WkNl/Dbxeep8bxj1VA6jiwEqI=; b=LXdnmiYezXYFkQ0OQpA73zh9WZ5xgAxAaoMcdS162fKUQ0geD0m2n+URq9B4fMcUVOfuIT7wQG4P9atF8OCNpjoaM0XAzlhDw1aCHqVl3+M0wVbpmesmkQ/AQc9MZ8axklcuiXu4HQiSCcKIGX9PEko9dSJrjdzuQijMgQX4Kp9E+O9z8ydRcBhBhPYEl9GehIimPEOcwXQhdvOshmaFXwioUZtNoxStdtxDoZW9TcJ1n7oEBSaTtFtu/gWa6+5MrhzGiMAJA2fGNlzzWzo2OK7wvXh5MDV2gf83qPvCfl/RboDUlWhCtdXo0IZECzCLaxy4a3NRu6vN8F3UoVOMWg== 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=qdUPzNSAjpC/zSuhS/WkNl/Dbxeep8bxj1VA6jiwEqI=; b=HDN7pTHeU5tLsGxJYInOqKxQ0xVRvuVLs6reBRiRXJApKVO5ielrBN0LClVN0bvb20Y9jC6dz689LLu0r7E3Iw6rgmlqdcC7fkRnMEon+hdFKqsENXACrjCew4y5FNxYH62bnvSLs2EzQ4J7Dw9dkyaNolwqCNfVBpzHQFhshtg= Received: from PH2PEPF0000385C.namprd17.prod.outlook.com (2603:10b6:518:1::6a) by PH7PR12MB6491.namprd12.prod.outlook.com (2603:10b6:510:1f4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.25; Fri, 27 Sep 2024 12:00:17 +0000 Received: from SN1PEPF0002BA50.namprd03.prod.outlook.com (2a01:111:f403:f90e::3) by PH2PEPF0000385C.outlook.office365.com (2603:1036:903:48::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.22 via Frontend Transport; Fri, 27 Sep 2024 12:00: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 SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 12:00: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, 27 Sep 2024 07:00:15 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v8 11/11] platform/x86/amd/hsmp: Make hsmp_pdev static instead of global Date: Fri, 27 Sep 2024 11:59:21 +0000 Message-ID: <20240927115921.10909-11-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240927115921.10909-1-suma.hegde@amd.com> References: <20240927115921.10909-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: SN1PEPF0002BA50:EE_|PH7PR12MB6491:EE_ X-MS-Office365-Filtering-Correlation-Id: f2aedb5a-b7e0-461c-bd39-08dcdeebf44f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: 6u8m09aYl78y0vJh+Mf9cF6NFZJ7Zj0SzRgDI9XNxURjS3V8FCwAB4hUwWJRL+UbhWA4JYelKIkp8yvcbtDTL5X1IZ5ITrL4bpvnQHjWoGyJdj3/50EE5l7AgFt3kegTfa4fag4hNyAYKyQ/5zWHXf6EumJACgR782QBwx1kD6+YTrc+0EZ9Xo0FGbGVnOVChlc9RZdHprp5YTla0slTIAmjOYx8A/oub8HDrzWlBVxcBP2qNLDOSGd5ZizYi8X5/8sBCDDc8t1lwpempKHaIVgLd9yju5Tb+XuMyYDSZH5TvCiK73jYNnCK8nLearq7g0Ql1tkDsV8ifAU9SLSKbue91Cr4pVdptlCd6ZOd2iGdmAjjAxVuMgOBDvBvMtcYc5cMezSjYLGsLoUgIsPGdr8V5gTJsEcMnN36lGMzkpa+VJUGQrIcRSWGomj+iWYLmhwkf9rFpiHGojqKB8UtfJ48Ea796TfMAJmabk5lCwRnZu23Wozu11LUvztPZz9BhxGV4tCFKKg6GehragjE08vgZ347AYYAQYtwjdkpz4K0p0mSRq1NjRePd0dJ3Z8Ze9IL+sjkx0h8ToT1U4KmzEjsdvNSy7KeQY1rcTllsRyklWcmdwfRTNH2gtXvWry8hXPrRuV4Pc0EalBF4MKtDblfQEeVqxRZEq29OJjp4ucY1cnac1c7/AkQml6VTP8BpjLLbode80MhLJA8WwIM6a0FvmdFNvekADrLPjH19zKbcnXdscsyKlOwDUApuoMruyM3U3Bj4GgaO+J1+FVXBPpTf6Z+dBfLF9cDvblGd8sE/Iidcw/ucnOwq+i55D7KwAtC44itoOnu25VsXQ31hihSaMlcgG2GZ8qI6YJSsKUCm60Rl/+O9TpGc8qSdjKfXYv7lUacAsMxfMkgzK2IxS8SoIjVp8lk9/LY4QlzIiWGgMqp0iCVH9Q2mBGiWV+soMCFqWxw9CQGGlfVhTu9qM7BY/wb92uOOOvXDYp5+/iVDRdIpHewbULH1aQ86Hw6D5d7FdhKXEgnf4x+cOz1mbJbKD5h1Q+XNDxGsMfRhojZKf1wnIa4yocV26Ecsc/ZfRQ2Nsje3bZgb3SJRT8tkGEyW/LQY9mXbxETlc5EHO4d2SqUlqJxdhfBy+ioeytAhjQgYPPPLmTv/nxhc8Dk0HV7D6ZXZ1ie+kxIdgqvXirQDWBiHPL+hBwtF2iKXTuuYZ/NrjHH8c8mHd1+IllTEXJTHPAx2RBhbwLglQvWOa8qVBlN4cUJ5pXLQjlZ1UF+kqQVWSz4lL1WPWS192OCL2numf+2NX5Id2L1EQYV1vfu8ZXzJupgMBX5O3Hztkpfk6jyQ9zdR6PAQxD5IV8H8QbUsb/hpDTfUvvlU0rACOsuYttLE4eZimTBweTkq38cqDVJf1YFvp0LKOmEprOSSnfSAUDzGMy8ontDp5R8PxrK235fMe7A9b9Qx/at7ls+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 12:00:17.6377 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2aedb5a-b7e0-461c-bd39-08dcdeebf44f 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: SN1PEPF0002BA50.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6491 Instead of making hsmp_pdev global and exporting this symbol from hsmp.c, make it static and create a wrapper function get_hsmp_pdev() to access hsmp_pdev from plat.c and acpi.c. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi --- Changes since v7 New patch drivers/platform/x86/amd/hsmp/acpi.c | 36 ++++++++++++++++------------ drivers/platform/x86/amd/hsmp/hsmp.c | 9 +++++-- drivers/platform/x86/amd/hsmp/hsmp.h | 3 +-- drivers/platform/x86/amd/hsmp/plat.c | 32 +++++++++++++++---------- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 9435e40bbf25..360b7789b192 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -35,6 +35,8 @@ #define MSG_ARGOFF_STR "MsgArgOffset" #define MSG_RESPOFF_STR "MsgRspOffset" +static struct hsmp_plat_device *hsmp_pdev; + static int amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) { @@ -203,7 +205,7 @@ 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 = &hsmp_pdev.sock[sock_ind]; + struct hsmp_socket *sock = &hsmp_pdev->sock[sock_ind]; int ret; sock->sock_ind = sock_ind; @@ -236,7 +238,7 @@ static ssize_t hsmp_metric_tbl_acpi_read(struct file *filp, struct kobject *kobj 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) + if (hsmp_pdev->proto_ver == HSMP_PROTO_VER6) return battr->attr.mode; return 0; @@ -250,7 +252,7 @@ static int init_acpi(struct device *dev) ret = hsmp_get_uid(dev, &sock_ind); if (ret) return ret; - if (sock_ind >= hsmp_pdev.num_sockets) + if (sock_ind >= hsmp_pdev->num_sockets) return -EINVAL; ret = hsmp_parse_acpi_table(dev, sock_ind); @@ -274,7 +276,7 @@ static int init_acpi(struct device *dev) return ret; } - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) { + 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"); @@ -314,15 +316,19 @@ 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) + hsmp_pdev = get_hsmp_pdev(); + if (!hsmp_pdev) + return -ENOMEM; + + 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) + hsmp_pdev->sock = devm_kcalloc(&pdev->dev, hsmp_pdev->num_sockets, + sizeof(*hsmp_pdev->sock), + GFP_KERNEL); + if (!hsmp_pdev->sock) return -ENOMEM; } @@ -332,11 +338,11 @@ static int hsmp_acpi_probe(struct platform_device *pdev) return ret; } - if (!hsmp_pdev.is_probed) { + if (!hsmp_pdev->is_probed) { ret = hsmp_misc_register(&pdev->dev); if (ret) return ret; - hsmp_pdev.is_probed = true; + hsmp_pdev->is_probed = true; } return 0; @@ -348,9 +354,9 @@ 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) { + if (hsmp_pdev->is_probed) { hsmp_misc_deregister(); - hsmp_pdev.is_probed = false; + hsmp_pdev->is_probed = false; } } diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 7c3fb090684f..82d8ba2e1204 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -35,8 +35,7 @@ #define DRIVER_VERSION "2.3" -struct hsmp_plat_device hsmp_pdev; -EXPORT_SYMBOL_NS_GPL(hsmp_pdev, AMD_HSMP); +static struct hsmp_plat_device hsmp_pdev; /* * Send a message to the HSMP port via PCI-e config space registers @@ -384,6 +383,12 @@ void hsmp_misc_deregister(void) } EXPORT_SYMBOL_NS_GPL(hsmp_misc_deregister, AMD_HSMP); +struct hsmp_plat_device *get_hsmp_pdev(void) +{ + return &hsmp_pdev; +} +EXPORT_SYMBOL_NS_GPL(get_hsmp_pdev, AMD_HSMP); + MODULE_DESCRIPTION("AMD HSMP Common driver"); MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 9b4ab6a3598c..e852f0a947e4 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -55,8 +55,6 @@ struct hsmp_plat_device { bool is_probed; }; -extern struct hsmp_plat_device hsmp_pdev; - int hsmp_cache_proto_ver(u16 sock_ind); int hsmp_test(u16 sock_ind, u32 value); long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); @@ -64,4 +62,5 @@ void hsmp_misc_deregister(void); int hsmp_misc_register(struct device *dev); int hsmp_get_tbl_dram_base(u16 sock_ind); ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size); +struct hsmp_plat_device *get_hsmp_pdev(void); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index c1ddd8957f19..37bf75d5c43b 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -37,6 +37,8 @@ #define HSMP_INDEX_REG 0xc4 #define HSMP_DATA_REG 0xc8 +static struct hsmp_plat_device *hsmp_pdev; + static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) { @@ -70,10 +72,10 @@ static ssize_t hsmp_metric_tbl_plat_read(struct file *filp, struct kobject *kobj u16 sock_ind; sock_ind = (uintptr_t)bin_attr->private; - if (sock_ind >= hsmp_pdev.num_sockets) + if (sock_ind >= hsmp_pdev->num_sockets) return -EINVAL; - sock = &hsmp_pdev.sock[sock_ind]; + sock = &hsmp_pdev->sock[sock_ind]; return hsmp_metric_tbl_read(sock, buf, count); } @@ -85,10 +87,10 @@ static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, sock_ind = (uintptr_t)battr->private; - if (id == 0 && sock_ind >= hsmp_pdev.num_sockets) + if (id == 0 && sock_ind >= hsmp_pdev->num_sockets) return SYSFS_GROUP_INVISIBLE; - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) + if (hsmp_pdev->proto_ver == HSMP_PROTO_VER6) return battr->attr.mode; return 0; @@ -162,10 +164,10 @@ static int init_platform_device(struct device *dev) struct hsmp_socket *sock; int ret, i; - for (i = 0; i < hsmp_pdev.num_sockets; i++) { + for (i = 0; i < hsmp_pdev->num_sockets; i++) { if (!node_to_amd_nb(i)) return -ENODEV; - sock = &hsmp_pdev.sock[i]; + sock = &hsmp_pdev->sock[i]; sock->root = node_to_amd_nb(i)->root; sock->sock_ind = i; sock->dev = dev; @@ -200,7 +202,7 @@ static int init_platform_device(struct device *dev) return ret; } - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) { + 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"); @@ -214,10 +216,10 @@ 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) + 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); @@ -304,12 +306,16 @@ static int __init hsmp_plt_init(void) return ret; } + hsmp_pdev = get_hsmp_pdev(); + if (!hsmp_pdev) + return -ENOMEM; + /* * 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) + 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);