From patchwork Mon Oct 21 11:14:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843918 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) (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 484E739FD6 for ; Mon, 21 Oct 2024 11:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509296; cv=fail; b=R10C6wfiWoMPDch/c70n+V50XIi3YhHs9vqG6bIChG7fvJQQySzbw2EWXnenRNNbnp8ACY3L3XvcbTfJ5uAZSfRsHYEx6KZu1JkVvQQjl4NUKhq4IG16wM3tKwdrMpBPzGx+7a5RaSHNxT/wUo+4QUhEdcwH3HMhJI+sgpuDEr0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509296; c=relaxed/simple; bh=aVIj5GB0nMzm+XwLKjrkYTCFDaiRXvsTOFwizuNJmIA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=odzUJBzgee1Y5Lc3ELNYs35a77/iUz5MP09TpQMkQRVZNwMti9QEF9qbzF0rKqbHSNwsE8M/XQRzhBVGkoJOzd2Y7JOW36KpCDHFVET4wIOZpLhx+dtbP/rEzJIzO7ifPgAJpxln7Ue0QUMd2WnhezmnwvbEQV+P0iX8vrHlgPg= 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=sv67LDfN; arc=fail smtp.client-ip=40.107.237.44 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="sv67LDfN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AP80UMuLtzPs6zO2PJg5haPnKEiUImxfpSqcmDyMQsyLZrp0JbDkqKCgMmJB4lcRLoqEKvC0N11JaZZqF5hdicnwgzbyK6jQaQA9NUv+6xpmq8zEWwoATuV+9hNn22VCW1/nWOwLG3JFue5Orrs8Zm2bjviVxf27cVOYAF1BAZcb2/Sv/e9jyeNcUf1ZLlUp3siF+yhn4WmPcnrfBq7lAUT7VUwCL/eUgsfXqAcO3vVYRApZsbgEuoRmwpExRf91fQ3yIz627ybeI0EcRwdAmqon6A5lgdSGgWxpwQC4SevndLF6Qmhx4/3fi6phgdIVLFfF5t441yU++IbbrJwwjw== 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=S0DUcd0CWz7rpzAVovnpxB/2DNYMIzcyM3Y1u8Qp9V8=; b=SQLjAjvI9M9EiDgjcaLPK2gTdr53mkUBANmX1Qa203GoSCR/YDe6HxKTG/pMfRGRSLGRWDECZzw5u8I5MFCgsq6VylU4VhjHK8d/5iO9kNXSGam/NeKZKqKMssWVoZ4iUK+MIRTJd5dTOYPAXPxSAfyPb+8F4O6/hsnhxGfTsKDkaFA/xtt3a1indXyfvpsflE9vkG+7BzHKdiWl9MYE8+nxePeOuEWUvt4I0TGjcH5kF8hUI4QP5Ke4DzAsm9LCUzCXlpwpHLT3hopeaDqw56zH5jgKtmXna9Ch2Q9Pq+dXcXS9ouDUEnYdskYF2mOmLeOx8QpKgtQOpyG52pr69w== 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=S0DUcd0CWz7rpzAVovnpxB/2DNYMIzcyM3Y1u8Qp9V8=; b=sv67LDfNZFuEbCkU4pUBk0YAP558MKn5rMWWCBRDtXFmmM2Cn3kwqwhcaJ1nNYDKy4S+2+Aj1KdKr74eUOQebpb9fM/XSJtCr8nCxjLlT17Wvl6q12xUYIIIIqbdXO/cKwwfKMHLkbhaEsJKIJTG68e+KOfarOgmPQCNiKkHOx4= Received: from BN0PR03CA0014.namprd03.prod.outlook.com (2603:10b6:408:e6::19) by PH7PR12MB7965.namprd12.prod.outlook.com (2603:10b6:510:270::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 11:14:50 +0000 Received: from BL02EPF0002992E.namprd02.prod.outlook.com (2603:10b6:408:e6:cafe::41) by BN0PR03CA0014.outlook.office365.com (2603:10b6:408:e6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:14:50 +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 BL02EPF0002992E.mail.protection.outlook.com (10.167.249.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:14:50 +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; Mon, 21 Oct 2024 06:14:48 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 01/11] platform/x86/amd/hsmp: Create hsmp/ directory Date: Mon, 21 Oct 2024 11:14:18 +0000 Message-ID: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992E:EE_|PH7PR12MB7965:EE_ X-MS-Office365-Filtering-Correlation-Id: 107ce563-74d8-4cc5-093b-08dcf1c194c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Rz7Pw9X2WLy/CkQq9NVycXblMjU3qhh?= =?utf-8?q?TN2dy0lwv7IWHVe5hDPyI40OdsbbKQlvfLlgRePkCwG22uP4+vnaMF/4jGtwDlxqw?= =?utf-8?q?akfbbh5P3YoDJI1QHGpv/54HaKFhL0SYNNm56c5w/gi0Df0a5+ekcNC0WsgB7gyRp?= =?utf-8?q?MVqlyolkR5ippJ/wQAbTWsEF1yv2ZULkazY9KhIxuUQAWy87AFihImVGD3vCPPNT7?= =?utf-8?q?WnIiLPVvFxGafGmzcbb06NulZWD4s+PLRSb2KDsY9AzbDTcekWGyXr/m/ga13Mc/n?= =?utf-8?q?qKpPxfiPZhFTRE3A9TIVPyxI8JF6ywrYpWh73f93/hNp8gJNU5dlbzLW2UkQugK01?= =?utf-8?q?n3AQWV8IPccVIMk1vGqjGaxS9CN+v16THFQLDpDovnE1EGzs36SPkpLe85CKoOtHu?= =?utf-8?q?B3zxJDECag8TidU1FItDG2FQFuviSNWcOVmUbVUVxfXtkgekDg9r62o0vNhGAMFec?= =?utf-8?q?VXKGd2N46csvSt2OyCJtZ9xiIZRI7c0lTlvAvWwhubAyBNq5tFihTF97NSOH513dZ?= =?utf-8?q?RUIEZdfUhV4ipcA7x92Gqhvm3GFnQBTjwwQR6dg0wPJRjdd+AW8SCe6QomGx3CYRT?= =?utf-8?q?987sumFPlAQ9HqOFlIhVUa6YUd3ElNn6rRMt8N8YXzQrz3kiUfROiKOa1TOVEIICC?= =?utf-8?q?epv6+I0oEy77wv7sUw6AyP6A/olS28HMb+KcGSqB8Lt+UkCb6QGViv7TEAm+EOCZn?= =?utf-8?q?VaKo3udK2taxG0Pm/auQXhsvo0W+g0EziWaIJw9qI+1nZN5i9fCKncwFMVb8p2tE3?= =?utf-8?q?50nmeUlYGgpPHAtqAn19AGYZkD3h3TCM3vDGk2IVXGY7g0t9inSie8N+6rwq+jZCY?= =?utf-8?q?f1t/a6CjAm3Qq7wkEstVImLQk0vykRJvo6xeHd8s53JddxV979GppcdluqDesDogp?= =?utf-8?q?6MJwXZE+ftRXWDNcZ2qmlr8wVNBzYgmSXSFalZn1au3RvCiWyhD5RJ7J8rHPX8RcP?= =?utf-8?q?M/9RHQlU2yEvOhzdhhCpsEGAekuzLBCvYxUI28SpAGD1w3ACosVBHtlUxQQRgObNm?= =?utf-8?q?aLn3OI4+lHUJCTxIktxnuhAoBN7KH9rRHliHyjhXuNBMBB6rfIBiXld3DL+scHYmR?= =?utf-8?q?FMw5pYAy3NMhpIyix4PbbtRI8Uxgty2pXyf1648DbX3gtWh4juMiLRvDf9EYUi1bF?= =?utf-8?q?Zxj/2L94XDCd9105/mIlOOl5gOfWEeRtnNi5MWjJsM3S642ua7yJekgI62lG8EdZJ?= =?utf-8?q?Ln2qjiFPcOV/oEDg8Ep2/WIfpy9OhUfm1t5BzEwIkSBDLLV+BwoucQXryz1FbHJLd?= =?utf-8?q?IgA/1eZRdqQzfgWkAFlFu6quOkoPiHGFClnNrAaLdCTUoJUGejZpimF4brh2eYA8H?= =?utf-8?q?M4g7OpVypsg+vRtIvFSYoo0jsQYlDjWarw=3D=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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:14:50.6106 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 107ce563-74d8-4cc5-093b-08dcf1c194c8 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: BL02EPF0002992E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7965 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843919 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2042.outbound.protection.outlook.com [40.107.94.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 584A41E377E for ; Mon, 21 Oct 2024 11:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509297; cv=fail; b=OCAL06/w/VCgyB3O7zhBv7zY2g6tQR9I05gCtZ1KFGS+O3uTJCj4AIi3pzvJ0qeHAJzG5W7NkiZNETM4q/SIO7dq/HwMVS/FaI+g8rSELmw+g1L++Zzx1AUxdd1oKwbWRIbb2s97IsNiLd82dhifOLC/+RWV4TSXNg9GySgbvSU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509297; c=relaxed/simple; bh=kNx80jrqgEOg6dtHXtDLyYbsQubemlWf9yqPtB4BMWk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cmOjkERaatEFeaNvx9KEMuf9WZh8ecW95OUyvMyS9giWEmvZ7GgUa2TaQ5+QNPD20jrpasTJ0v2/mINyIpp1gc0elPoVPUDbYU2dIjCPliE6S/PalIDBFnBvB+ZA6sYXKOnaaU4n4gjetZRqnOJAhbdtopyCPiTYIIrvyhbUJFg= 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=ldF0qDHg; arc=fail smtp.client-ip=40.107.94.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ldF0qDHg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g3jBslXdz5BjR5SS5CiVQccji9vHvZKiUdLhhGwC37m52fskjlrPMo5bpvVhwEsTtonsfYGdCyoDuHv0cTDIIczJUpPKjOd3Wn27pOmlsqT6pS1ilJpH+8GGPZNEjxKt8iaqrzUF3c/03Yi11SYTiFtWr/c44+NAeF7+XjIoarlOWXJywbUYf7rr7oRWEE46qfko6wXIoWJt+KxsCaQ7v3ZffJQ9fKEj8QXyJlBRaeMmvNF5pQh4Q8QVKDHvzX6M6dfZWH0Fnkli1+N5ClOeHc04Fi+SGJqoonhwqz3dHuRS3ARTulN5IYbXxu4bbhxTr+W4xBe8KCSS0NQIrr+CCg== 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=OmzU24QLpcoFku5jQrH+hpYpljKjKZVk737BDUHby1Y=; b=oLBlETC0j45hhWwKTbD4atxgZEaU5aph+hSfOLdG8W6/2pdIEEdTGL8qCRYC8r+P5Ik/EiBPZjkPHxLOYOC1grCe6cUAqBKdFYYqh3kOll4RlIhrgdJMUHLQPFci1FN3p4Astb8XHhjkXioaeSnRkw/mbLupW/SvUso8e9DtucTGdofBQGsxo7iFjSXk/uz8UPz8sLYHERUvT9v3zP/ZtQIR663S9IPj08PXlgAKeBMhKqooxz9Fb279o3WRk8XYpa9E+rBzBvvGr0ar7BspCW1B+e+qdHPLf1ZZ1V2CEO+nnSHrA+ff0m5A9PThSlwY4+i0QMhyUHCCEI0qcj3QoQ== 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=OmzU24QLpcoFku5jQrH+hpYpljKjKZVk737BDUHby1Y=; b=ldF0qDHgFlN4GM5sCJLrEfy+zL3zwtyuXIiM/8dv5E4XFWHUvo6GRHDObNKfxS5Be9Un4VWTJD8J82ATMmjLFWH1bjqOIOsODl4n8ba/r1w3x4UPTHjZOIFE1pAB37QxcJZ5k+mz4onApjjH/ZxYshnXkvqz87eJq5vIHYiOAp4= Received: from BN9PR03CA0475.namprd03.prod.outlook.com (2603:10b6:408:139::30) by SJ1PR12MB6243.namprd12.prod.outlook.com (2603:10b6:a03:456::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Mon, 21 Oct 2024 11:14:53 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:139:cafe::20) by BN9PR03CA0475.outlook.office365.com (2603:10b6:408:139::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:14:52 +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 BL02EPF0002992B.mail.protection.outlook.com (10.167.249.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:14:52 +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; Mon, 21 Oct 2024 06:14:50 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 02/11] platform/x86/amd/hsmp: Create wrapper function init_acpi() Date: Mon, 21 Oct 2024 11:14:19 +0000 Message-ID: <20241021111428.2676884-2-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|SJ1PR12MB6243:EE_ X-MS-Office365-Filtering-Correlation-Id: 9de5999f-5345-483b-217a-08dcf1c195e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?skkA0i2NJspney0AKcsp5g2HK1kDWJV?= =?utf-8?q?l6Yk1PWtjeKt1l8ccUpB6966Fj+/tP8beusAhZdqVWtWHd1d+vbX5yI0euKhrVhKa?= =?utf-8?q?ulvf0BjVe1hfxTQeKVGgkDGfuAySMP7ezjA8JvHEKR+27wLn9cAjpAHDXgJ3Ss1IV?= =?utf-8?q?cYjPBaIJD56qB/9GCvI1LkQlzhYtysF69QUX8c1sBjkO+8VZRVx2Mg21LwEG09J3H?= =?utf-8?q?DxIj+3ZtaL3I90GhAGZgvxUJTU2mHyZy7lF9afQd/Gabt5BhBHdm75Csn9ihAer9F?= =?utf-8?q?YXJl0ZF/qDYsRJIr2dYzvZ0o/uulmUXB7R1gThnoB2zd554MwWa0Q1Krwx2wE2p+u?= =?utf-8?q?Dffjlc8RhecoO73BZVtT9KQzJADe23taqhNsR1/nrYwoU/VmX4FSKpBdPWLfkYkaM?= =?utf-8?q?anxoceWyR9lBAP9EdC+fQ5ioB9CBvWxtVuU0PXlPMmHZ24ATF6OLeWJxupQLhuIvd?= =?utf-8?q?GxZkzY2cJg/opGf9hDqdvJb3wZcPftr1sYi14vtRsoUtmXM6TcpsT9z4t8p7yyGth?= =?utf-8?q?TG1Uj/RerJBw225FT3Wo8FKuLPUT64rGwduaiBSK1kXUo5AVdUTOMTN5Ghs/7yGO9?= =?utf-8?q?+QkkIklD0xBJaHdfORgHiGKkY74JYZ8slwbfW18EhzJ9YpB0qu7oM8zU5JByWLxRi?= =?utf-8?q?LdQRrvDakbyrmYiicOewIjTW7rVmVY0G1iyraxzkhoKmgFYPoLWkqsV+bY/eZIkzj?= =?utf-8?q?UAYhbJqikpJQVVtv7He9lwYyo7bfk+ZdHbkdALIrrzSXGstvu5NAsSvpwiSPHnIWp?= =?utf-8?q?QAygV47CPFz+Buc7W2wXYlSwlxlzcMSaCE2PnDdxYric1E5C3Zw1axDKuY5JGGXAT?= =?utf-8?q?IjX0NItdFISKQxuBrZrOpSaWW8UBETYpd8/H1JatN0lX8h9I/xq0qIddddcYXqCNz?= =?utf-8?q?A/FNIjNr0ktiZfffU42HYz7bEBn9/zPVzWKJJutzqZ6rgd3Yt5Ung211fQqF57abL?= =?utf-8?q?Doffqapq3s5epksHb0w1Rynxurb2kZVc9gFAnRWnVMmqWYXeEfP3ZA83WbuQAnwG8?= =?utf-8?q?iJPpOxiqVKl3fwfCG+ffjeB0ekvPuOgWunqLhVn6vW+dhGr0DYehf6/zP40P5z71V?= =?utf-8?q?KXiAxYtEUENNN9xFdshVVqpxVww//UtA0kc2FBdTwV/0TLXYohlGE0RXepWMITpws?= =?utf-8?q?Ld8uEtoNhuLG4SxuUdHGsQZCPC4gIGzLVkdYNkdQg8+ZqOvxB29MyDdw/dH0+LvqU?= =?utf-8?q?OPGQNJnpdLqamjS2YEw8jLE217xr0oDUai1HTWM5KT+gtl88xqFhU56EjmbROfmD8?= =?utf-8?q?/hihygkgwI6rHbiMqlLI+lJhxYLk+2RDdgWy5dbcOh/ZpJMwEDXv880en+Txe3auk?= =?utf-8?q?R3C/a7A5SILnMccA8otJfPut9Jjr9U5X0g=3D=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)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:14:52.4855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9de5999f-5345-483b-217a-08dcf1c195e6 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: BL02EPF0002992B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6243 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843920 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 974C71E377E for ; Mon, 21 Oct 2024 11:14:57 +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=1729509299; cv=fail; b=X9p2qE6IE0qLETgPzrgsBm2bSayYg4Kbg0biNapMsdKDZI5OjgHkdomeGF3bih39Pv/YPIx89COSYLGOCUVsg9/fkgHYdBGgM5psvggGQpAC29fN8xlJM/B6iFzbOXr2qs3GVfeSPI+5NUaHOov0wJtfqGiN9XFv0mCyL7l/3UU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509299; c=relaxed/simple; bh=DY4dgIg5107+/uThHD1JX/4C6lf52SafeobeIAxjlxw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BmYMMQ8HvL9eUvP3x0voYwwLvEa3AKZ3va46VTouwDFGaJCmLpECOAYgJ2oAbaqmnQlQmQOlzXYk18nm3fM6x78iy2dJ2tGDRvqniqd/J93B+MTzGLl9ieCPLCDn3t1cLbe7y1pdkXbSBJ3ZCm5wPOjIp1KbkFrsMS9sFwkdyBs= 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=VPlUtNEf; 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="VPlUtNEf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oFvmbiKX/2c1Hh/gZX1KFKww1xmFDinLnp2vaSeiJr8eA+9uCRbKhCS9cp1Sk99cVW4F8IoPWixBIc2Br1M7lHfv+shxSS5Jl7wKN9iC2II5fT+NK/n46FJCeP1ceoHLFqSFufREPZpcTqo2G9EkdZSvyPzPcoiijdYFtWR/h9WK7ZwJJTbQJL+kj1uxlHBTQft8UsfPmncAiUx57cImzYXplmCCqLYTppqs+koN7uxbC6Jh9PdrFqoE34ezdhf9SLDlhjrC6TBXfG1xKzoNhIzrbNp88jBqCmg2lmJH6rvCtT3pG02cVfiDCDPwwNL2xvkHrU2dyipReuzSZ4sV7w== 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=IVk16Bo6M/bhsfwUoMnUXlmLz2YIJhkjHrFr2Ys7+ck=; b=mc5uEJkhg0uSpEorP3y7Xioyo/yofvtNzct7sFx9JuLdHnG2cDQvnEYkTdtb2xMyFbxfbSFhlbWuJfUqDd5sibf2D1wj/M3CiMyrmO9AvMaXXb8rhBAr8R++M9S1ZCSK1Uks7NfybgxHWn9cdkj7H4aIYX8fIApZShtB3o7emijlHkiGIA4pC78FhbkPfVD5U0PJpr2/OZCEjfQ03xTz2+HI9D2cPMNeoGBaOVUdTlfHGSmmptXHDzZ15YThSjQzzKNS1LTDenKj4out6TWrCgi0sRg9mBPnUBJgNZUVq/xxjgdjCzUvp5iB0zK8mu49q1Plro1bDcPqPJPDZBjdEg== 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=IVk16Bo6M/bhsfwUoMnUXlmLz2YIJhkjHrFr2Ys7+ck=; b=VPlUtNEfz2tzAdQe/cdkxQJMvRSGbCFCzq0DT9q5AbnSlj5APQkwF1JqfRJdKa7BWIzesiNdF3FYUMsX4cr/uR8vOMfWfe96gtXIxZe/DANKF9M1SmBnkToqIjvuzzvGTUafAG22s1Umkux9MELI8M+7MNt883dxPWHDCdSn+BM= Received: from MN2PR10CA0013.namprd10.prod.outlook.com (2603:10b6:208:120::26) by CY8PR12MB7657.namprd12.prod.outlook.com (2603:10b6:930:9d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 11:14:55 +0000 Received: from BL02EPF00029927.namprd02.prod.outlook.com (2603:10b6:208:120:cafe::8e) by MN2PR10CA0013.outlook.office365.com (2603:10b6:208:120::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:14:54 +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 BL02EPF00029927.mail.protection.outlook.com (10.167.249.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:14:54 +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; Mon, 21 Oct 2024 06:14:52 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 03/11] platform/x86/amd/hsmp: Convert amd_hsmp_rdwr() to a function pointer Date: Mon, 21 Oct 2024 11:14:20 +0000 Message-ID: <20241021111428.2676884-3-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029927:EE_|CY8PR12MB7657:EE_ X-MS-Office365-Filtering-Correlation-Id: 152d8d16-3c60-465c-47fd-08dcf1c19711 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WdooP2GLME0WeggKtjSfL2URFkyqUtc?= =?utf-8?q?PQvPYFFrLsuG4lolu0IK0HX4WTERgDMG30P8njQtqNAok2VqmVXleuqCKtzrpZzgG?= =?utf-8?q?6EjypA1YdQM3/y+enEU8aWkKUOEcQgSlha/E6yAGzU6cDAhtz1DepsHjrVXdi7nzS?= =?utf-8?q?8QRrrCyvDNpaUjhGiiSKf4jJaD0AELgkqeP4t/EFTvzmQ8UGcXQQHxk9GwvgBQ3oS?= =?utf-8?q?DxdCW216BXcj2+w91G8/aWo+jfa/c1YpJ0Liqm7yFdVbKf1wX78VMxeR5bw3bzyb3?= =?utf-8?q?mRAqy3zT9AGrmG0Y8npN4VsnD9tOmJ3ujkaMK+dRP77/dJ4AaVKQuGhjC/JNLuz6g?= =?utf-8?q?RHvpbV2KdSXfJu1YHf1p7movGlWgnXfVpcCGqxWBn/ZdhLLBeBPIhRTcx0ew43a+P?= =?utf-8?q?1mmFTASslVuk8H5l7oxuF8mW3S5A4Xe9NabGgiA4c/40U1V63ymd8H9YHy/SLU38I?= =?utf-8?q?spxzNV9jf20wqzqsXGtt1iR2FJMpp4d6bumFo449HNaZHoUD6IeaVR7qt7JJnO+UB?= =?utf-8?q?ZKBneTKhgfC9KyCQ+N428Ab8JunGwQIq11LmlEDjdLBGMpZBtrFYEX27AfWbEeWxp?= =?utf-8?q?ih272SXQRTDVhPWIRY2+nEcMWCKWSevNqqaSnBN1esKO5Rh+3irWrdsMid9xPSwnl?= =?utf-8?q?YyizrBKn1H/KppCBiOoIEsRthsD2N/23X0Cld3d4OI6+xaDkVBbJKIostEDZU6Npa?= =?utf-8?q?9YVXFTVzkAxgDSq/46OuWAKooZU/mh5YVyVLHBfzFy1WM79V25anneEcxuC4M7roN?= =?utf-8?q?+OO/oZChf2F938xVpMRTewN+0jPFhrx7e+3tcu23NqdSFfV0ldGwVOk4yOGCQ4uz0?= =?utf-8?q?T+RZD7g+GCX+V8F4zcb3yicd/Sj3gsRGY1Pl6hA1o38JRCSWmiuwasGWIfjKaft1H?= =?utf-8?q?vP2kpP9Zc2TOp5amrPt+efwIsp/AFZ9C2igSiBpxV0naDIFfv+8CIJXiUSuRv7GUH?= =?utf-8?q?fgk9b5WxuNuYdNB5q4PzX9dzmvziIvoCxOVZ04bUtWTCTCBjhjvwZt0dyi5pZ1bl/?= =?utf-8?q?2j0X16MdnlOzOEQekafH+ahHGDBaN6aMhiqDCS9gMrObbEYGuV5U91/vnP+9CgiXv?= =?utf-8?q?gTQZSZG9wmGSlQhuBHJcR7h8QRiMcu5NHCPaTslWB2nUrj/cWf1mv0FTGKe5ds0BA?= =?utf-8?q?MUC1nUV3sE/KCc+yw4XnPp3WOscLjb0QUJJjPU8k1Y15WU7OkbCC4VzfcQYmA1avM?= =?utf-8?q?+rIMOmzrJU+ZWklqr3fGBRHE3DMbFpbFdE1Qrvst7IV7aVDwweyANY+Ev11s/Hzsa?= =?utf-8?q?9zH+5G9C/FQglgVT1SfznGBGCeLxxN538u8Evw+lrBt22DOZyZ2MEXfYzElqN/hLq?= =?utf-8?q?LF9Mh0iKjR/qog4HDl471A1mQddmkrbySA=3D=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)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:14:54.4460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 152d8d16-3c60-465c-47fd-08dcf1c19711 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: BL02EPF00029927.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7657 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843921 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2041.outbound.protection.outlook.com [40.107.223.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 3A53B1E377E for ; Mon, 21 Oct 2024 11:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509302; cv=fail; b=XW+H4wWkwzb68B+pNEPiRIKVSkOoUejLZgUSSP8ycu0p4N9DB5+SLgZfktlwl8SpDu+GKHsH6f3bRlvrZ2hvS5zr71mGd2zHqYwA2vL/bNpLTEnCeAnzXuy+QqCkuJ705+A0uJGLQo4bMNGEkCzWlxIhVO3IxHfezK8hkvpOrWg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509302; c=relaxed/simple; bh=KQRqQqIkuSUE9ycY5qUxlw64ZPkZLMhYU2UIckjsms8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lqFAgHCvIsSQAu3AJF8mwQYD/okDxyFx2Al9g3RwaCWkOtgdmve12GFN2qc82v5SplSdCW+V5vauzPSdyHQoOOG+PvhYfNAlxWVoQ9bGG+H3+BELhPPpfLJ+Tzpi9veiW9QBB0D5DHZDOUHBi7hB6Wts/g/6Mc1sroUylWELNkk= 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=Dy8tUrLI; arc=fail smtp.client-ip=40.107.223.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="Dy8tUrLI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eOOQ8kS1p6TAYmvXExZASmiL/pqjSbj+xC/17m3qlbETpo4w8cRsgV8C5eNVv/pK7KgZQ7L9EVJVi31+vKbU3IhDVEi7CUH7d+AWZ3GaQdC3C1+bJs3gC/btBgZsajOyGgFBis6S7dxWkVx7xY58G7xxvagt5AyAWziudQHdAKhN+6Zf3J6BfOj5BjI4SkhGqChuF3vzdTEOklMJ1RB+7WjqgZ9e6nanlv/1XM6SkSrrHEPC/WZxzdDJ2d2Y/DKrs6lJbnNyU/mugqSeiuTD2mGIyBzsHRv18KBSHkFbPmMCuRXp0biSNuLDnht28KfREqnNtd8lHDVxbXD4vVCKfg== 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=sKeTdaHEWPRT2Gla7efXO5YbupwCzedIFy61cmhs+fU=; b=xgj2gv3qRE2ezsiAPXX3/OPdTGb+7FYSeHyPoJqt+E5Ct+J2C6EikZsEq8lPdhxOivW1WEWD79QFZ5EXXga0SnuDQGBn5uSC9ZrlTSsqqe7enF8yM4ZhfQ/Pz7/z3bX5Hc8luYBwd4U4zZyOo44yO8imeodQHpQKzG/MopI/iFxahV4AQqDbTO01ZvX4bQRtSYOPT4LsN+JG+3irnonIwXGDQWHSgr27IwY2EJb6bfH8XL44HvTWLzUTeVmICxMFiyjSHFwfcG/T3ZzavSDDNrfE4dn8itxv3HE6qo7SfOTeprEfqVK/38Ya5vpKvl/RAvric0WeKFyfH88zaZhc2Q== 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=sKeTdaHEWPRT2Gla7efXO5YbupwCzedIFy61cmhs+fU=; b=Dy8tUrLIi6bymNJVhum+vzFsR6xrVNTMf6+mZTXUY1s+Xzd/IkqWDb1wQhUjV1JBv49lKvCDAEnSnNc1EWwVgf4OgPL9RjlLTsCDAmhNqmjWfN+Jkr5Sw9ReOe/b95/e9c0kUs2D9a3RqYBYbLuoq79WE7UDf1ExvgTR+KPrdxI= Received: from BN9PR03CA0461.namprd03.prod.outlook.com (2603:10b6:408:139::16) by IA0PR12MB8905.namprd12.prod.outlook.com (2603:10b6:208:484::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 11:14:56 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:139:cafe::52) by BN9PR03CA0461.outlook.office365.com (2603:10b6:408:139::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26 via Frontend Transport; Mon, 21 Oct 2024 11:14:56 +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 BL02EPF0002992B.mail.protection.outlook.com (10.167.249.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:14:56 +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; Mon, 21 Oct 2024 06:14:54 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 04/11] platform/x86/amd/hsmp: Move structure and macros to header file Date: Mon, 21 Oct 2024 11:14:21 +0000 Message-ID: <20241021111428.2676884-4-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|IA0PR12MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f377841-85f9-4bd1-f14b-08dcf1c1985d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6SiSYh3AxPhPjlIf5cWabBCOyXgU2Cq?= =?utf-8?q?re/H9ZRjFJyJiVHcv2EOI82nPZpVWX7jCXENSdhVno/V6+YqXRvHNyu3oVredMj6m?= =?utf-8?q?GhP8B+XR8wvYLBi/rILRb8AgMfvUhFCGB6OEVG0aid22u1t4rrIzoJlgLkr8bw0Pa?= =?utf-8?q?9gz2q4Wg3kNipRqiTiZO5onyNeEB3+TjqO2l0TBauYwpalHiUYwpq87QApdXcBa8c?= =?utf-8?q?ZyVGK//hG9ujldN/Ri1nSb0ZhEqmDUjEpQAUWYO8ZfInkvlGrXGPSEVxhVYCEm9P3?= =?utf-8?q?NQElVVoiTuRmr9WxbSiJg5z7ytdhB0M0mpD2LkzFtCOBbFvY8haYWClFIMNN2Pm04?= =?utf-8?q?VfalNjawAfbaKW9IPz7tksw2wKsi9y3LpaVzEo2LUTqFwSdjQgrZIguTDgEz0qf6q?= =?utf-8?q?x+2jNh+QyKDe5Z3pgX70ZMKpzJ7+WxaXCT4jB8LTwcXILClAMsLohJ+Pb4rdRsvUB?= =?utf-8?q?6tpne/tGO2yTUq36LKlfgarAZhqv5kzzAgQ9WjI3XW8/jOgN0ciRbwU2/bhLJUpz8?= =?utf-8?q?Q+W26nej/te16xL9IylSapYe4FAsDAZWF5XIARgJIVDWtfnYOb0GFSzRdzJJsDzkZ?= =?utf-8?q?6wzuQBe0pETOaIYLX9KJ/DSUb2+E5IAoCcOXK7I/qixTSjXnFKM0Bx95WzKIfGU6W?= =?utf-8?q?YsEzXFXF9MOH4PLA4BV4yM7sMv2SBB4Fvf/2I8gaPyQp5Zuo+gAxnXmUkZJQSM4Xx?= =?utf-8?q?UmSktqTaJ2osOxkdbhiPiFo+XYd2+tel6wOZXJ/WsWTG2BCrQqZlBG6Mve5X387DE?= =?utf-8?q?QROkpJ0VcVWZDwyrmeyA065aXMlzs0r3wgJcWpR8IJIhOYLgS4OFfjGdTz6t9Acbm?= =?utf-8?q?ciBU9oPzRvQO6YEX9DJVvGnkFYCIpe1d+IgI+78HsQdub4tI+aW1Lte2f/bK7RkK0?= =?utf-8?q?WF9HFVLTxyaT6Fha3YrBWRFkxqROA2MTSdKKufte/gF1G+vdFVApXDQFxt0XJKoYM?= =?utf-8?q?oRWZXwoBJImIE9vMM5PQHLqRcDOQhL5XSfVawVqt4LqZYbpyBM5f0E503/5f++4w6?= =?utf-8?q?Tl1nNWJ3VxlPxbyJT1q1r7Q1z9ifnnqAfNKWV49H3YcUIom03R+/3PJTfvmq2rQUv?= =?utf-8?q?NSvLmBMZ0KCvh9kpL+6TfK7cV3Sw9TtwOOV13tQ9gpU9W4IlD7QusE0KQMLRVDfkd?= =?utf-8?q?Yet6pPH/5akKI2m4Wq360UjY7p1PhUb7vpgnaESE9o3jXwoHUnsTar/ZzRpXMtlZo?= =?utf-8?q?O34Ui5hDsE8KduphVeZ4P2k+N1O7Tgc4C+QYWuAGqVFyQmGEpfoN6gIm/r0jrrZOq?= =?utf-8?q?3Zv0uFYifo3HuXsIhstfn33scF6oBCyFb6VJPvQ4VuW1E0RysTSCQQLe+tyYjUOe4?= =?utf-8?q?xqbG/cDJxrQOTXVfqPZ9J10bHf7c/Ey0vw=3D=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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:14:56.6105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f377841-85f9-4bd1-f14b-08dcf1c1985d 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: BL02EPF0002992B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8905 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843922 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.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 3610A1E4929 for ; Mon, 21 Oct 2024 11:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509304; cv=fail; b=E4JwhNmc4PXkF5vIaSdbLGFI0vcEbHRuhYWzOmn9D4unGHTJYPihcXVAGP6W0S6yLrxAV8vhIAU2MU3Q8zRHS+4CmC+wz5PVSrCevcyHsJgAiC/YO9EMTbAzZMXdh93zNnBPNUIxZ3MTwf7BLn4GKFc1HMJHMvcoizQoSW8fm78= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509304; c=relaxed/simple; bh=Mo67JuSMpWk9mdekEhsUXschXmjlKQEiSUmH0qn+H0A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o2E0JiSl36Zzv2ChEXzsa8Vgd3IAePvsWsS4IbWrkcoAFnD3UPMa6ZzhYCeWQ9Hm+Fx3769F9F0467pN5GsDTSyQT67ndbCqwieg7Rt+X58UlsR0jCHHQ4F4fvWvNOkrGTFJmhhoDJClK9NCr39EcukwS8Nw0ELVxfuecSKWx04= 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=kL4Fi3n/; arc=fail smtp.client-ip=40.107.220.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="kL4Fi3n/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lUGr8dbEkcF/uBM2P7lU9thywn4eikYLuq1ics02qqUI12Sl4Z+R8+W5gT3rlVBDl7CRau7t62P8ViTd6DfxXVYPUJrQ3BCUhPobSzS/IErzSYlfBMB5MFa0h38tMitroerxWqoncX4xGYMhaG1lkQgVrw8Kw1+OI3IlkCrOcZdZhAUF7GtgHbuZcA23Z05aillTZuLPpcgJOfD3sDdlv6M4c8OE0AeKbjf+uNfy2ec0zheFtMCTJk4SUf+cXqy3/c/rebyA6+//v6kcmBacGZruYGYw+XLFc8WHM6oys9i9jHCXgiLmuOtsaXx2tYnIwg74zBhOshVVMK9y/Ac6iw== 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=QLVtCSBAMiRPcxbBWBfdFr56Waf4Bx56hNkwPJVl02c=; b=whPVpqc4SXwDXscWLMvv87AYV7C3DW3fNiTVOyyEjn5uyBjeOhGR9tK61JbhZpvHjyK8Mkua0cLmBM7xPVbwmiOxTT8XGSic7XkLhbs/OOdmvqUMUKXqJzo8nC/sg8n2yTX+p2iWIdiMYR9fJc5ktCCqP+O66D85VKqFJPTZ0/HO8mE1Qp0RnaW6D2yddk4S2JrjTZLfAkXiO1KyV3omrdQVhhfPzfWxuOC6Yqm6AwFzVZ9SDG7yw6IRsIMqhfn0tlejgSATahTFDJW2Lc5CWcbjXC46mVX8QABYTsoHBrAr6iA2lfwr4SNEY/+UDU/V+Wzei09rc4wzzw04sH08Fg== 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=QLVtCSBAMiRPcxbBWBfdFr56Waf4Bx56hNkwPJVl02c=; b=kL4Fi3n/ENnRV+4J7z/VRkctIGJtSmAA02Bs5D1aN6YnkEoWXOK5YgS6g1qdd6GTQIIZAzg9lKQavrkGRz6wS0XSUZLq+PlMzBEScMbMz4crSNXnZYH2wRrjF9Q5k9Z1cb9Zd4ovisUmIZnBc0yLXYIFKRe64zqa/J8OdXFVUgw= Received: from MN0P223CA0029.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:52b::18) by SA1PR12MB9471.namprd12.prod.outlook.com (2603:10b6:806:458::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 11:14:59 +0000 Received: from BL02EPF0002992A.namprd02.prod.outlook.com (2603:10b6:208:52b:cafe::88) by MN0P223CA0029.outlook.office365.com (2603:10b6:208:52b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 11:14:58 +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 BL02EPF0002992A.mail.protection.outlook.com (10.167.249.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:14:58 +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; Mon, 21 Oct 2024 06:14:56 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 05/11] platform/x86/amd/hsmp: Move platform device specific code to plat.c Date: Mon, 21 Oct 2024 11:14:22 +0000 Message-ID: <20241021111428.2676884-5-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992A:EE_|SA1PR12MB9471:EE_ X-MS-Office365-Filtering-Correlation-Id: b8584963-106e-451c-5e23-08dcf1c1998c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4E06UfmPJtzCHMdkhCQWDf1Acm47geQ?= =?utf-8?q?pvSutYCQPkKdlLLOB23KwG0V4n13BEqXih8j3nADsPRsKGm3ah1SonMOWXID+6I6n?= =?utf-8?q?O59Fgwb8+Z6wKK1XYJXCB5xQU3ksbxsm8JkwVzDx0ieVOGSKx25EJLm3Z2pF7VjIP?= =?utf-8?q?e16tjdG4T8kty8vErHoP15lOvK4ykk0yw/mRki+nGZPP0gJO9ccbqacNxoP6lyQ5A?= =?utf-8?q?/al1Xp8dq4loxRG8CXATL5R42lQ+gyeCtMkVpfPZJxoVNopAZbKC/z0ydnpoqjs2W?= =?utf-8?q?wFrmpXKxe13I/PTjbsqN3WHQRiayAYsDSt1RcaivuSd4EqRhUV7HG65aLAKOXt+2e?= =?utf-8?q?XJr/yOKZNWP6G7GpLDCm5zPRzeMQEsCLf4UUn4TH00j1cxK/M+a73dB1+eWFpp/Nn?= =?utf-8?q?n0kzlScK225epx1kV7zBXhiVKbnTipTsCCubSuYZftxLrmkA2lkq4OPf0ptYasZAk?= =?utf-8?q?1nGjk8gQcPQIemWacSfEL28JziEY8BuDlG+JgiiZmDUDB5iiCHIdp8aWty0dbEm2Y?= =?utf-8?q?ioAvdicJvDKGa/HP0PCsJArzjem4B75QN8+Deh8y93XnkpHsPcAm5F366z33AxnxX?= =?utf-8?q?YXOoR9Yf9bXtEPgIza8i0NhRQ8D/sW2LNVKapxDfgKDOElgp6Pzk8BTAiUsXTXvNG?= =?utf-8?q?a3hiCUvTkekJovS5eYT01Rkk+tjzZ84d6x9BYg4KCIBTbNAD8hNKyU54u44ffGZDq?= =?utf-8?q?xycDbpCEisoQR+33TIklKacZvwCByRRh3GGh+vvoXfZ/mUP03jT79VpItjlEB/vc1?= =?utf-8?q?0LPcxSLsDk+DHJbPS0dKn5gUUv/B5YouhYnJHthfhl4yFncN3Gf40gyXwfomvEZXv?= =?utf-8?q?dl84V6qD2lzZyf7fgT9ig+DtEvIcyaxEu9Xa/L61JswBkdAPt9Si+clE1oa8f5myz?= =?utf-8?q?dh7zplRVRfAVjG2VuYhH2ZTqxGdyGbqZWeoim45GfZ0hqmDVA/9usCdBY6eXdShC6?= =?utf-8?q?710YTjOP7Agq4Dx+zThhpqo6SfilX7Rajq2IYJC+fpeHtykumluxSekmbLS4RTjAp?= =?utf-8?q?aojjz2m+q4QqhNsOh3+exl2mw7n7Z5srIMqgL/NeBpw2GT363jxtST7x4TlyoIFtU?= =?utf-8?q?Pvmp07qaPVLMthEcLyhu9QJ74wb2o8iJgH4y7S3Jvszid8prp6yNuJsZSxTPZMX0i?= =?utf-8?q?hs//tB3iKYuqoG5FldWmqoAqN6OuBkhwuuFTO23uTG403e0FGtKOwAIIKi1fPkFrV?= =?utf-8?q?JQTlRzJoehfq3eGmdGsfFSA8+P1y+DUyZHAbZ3WSKIyQtIr4cFHIUiRmvuPwxiWzf?= =?utf-8?q?lhZUcybeSiZvPqhvHdYaRxR4rcEtIw6oUTBQfdUpLr6MQ0rr5cCBL04SF6N93NgUU?= =?utf-8?q?w+GVoH2LeYf3Df9rVxYMAF4XyB5sbrALiw=3D=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)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:14:58.6238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8584963-106e-451c-5e23-08dcf1c1998c 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: BL02EPF0002992A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB9471 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843923 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2083.outbound.protection.outlook.com [40.107.93.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 6F7341E5731 for ; Mon, 21 Oct 2024 11:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509308; cv=fail; b=CgfD8lg9QaNVxhZQmxwjj1XJIZXPRo9UdaEQHBux2h9BlVuSI60+u9wXQC4IbkPP/2a0hQOuQ2JC0kaQlX0qlREdzuf23o46wfROJPIt24FTmse/0UamNhvV3zMGkWcs0RovyzJ5o2lRdB2j8Fl/zuQZxWiuhWlz1VmCL+wJIX8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509308; c=relaxed/simple; bh=w8eIhX7q8aB1AP6XugwKYvlBOCgGJRpBG3Xhm7sI8ko=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=guWf0obGZTWspuvofgAK+TcCnBnxHiyh0lPJ16L3N5hQNH1zkgLHRverrAEhLlmUSdN/97s+xs11UIKL10/7VxuilJk4G4IoU5nojyRWRERcRWzjE+ns+46JgA/N+iaQxmh/cUzNjTLQ2B3NYriqET8MzwfMe0Dpwg+SFTOFMOU= 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=4pG+BVAh; arc=fail smtp.client-ip=40.107.93.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="4pG+BVAh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aRHx4mz5nHqy038/TLmIHCyyH3beg10rps6O13OZXkltlCXg8XH3gA/0oYQG6N4wNdqgecURZPnF9hO6k3od/rLyEcs/eEQtnZwBOhJAi2PU4XX90L6QoUc5HkR4ye7aXZE8XJRR+gB9yKHNVVRxfChRX09Neq50rIP+R+8BCZleZkMF1Vh0HhmBhMozeAd0ptbEDJHa8OkCTEu6vTEV9KeQGCzLf+28mLB3NJuwqyIq097Ii/DFwI9RyPfqcFFyRHfioawqNK9XFCkMcvi6Az9snyfSUfAdZ/sw7UXprUl+OyMdcmlNfV4JviI1UVYBnX81WE6RGrUbRpAUo8fzxg== 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=1tdGOf2/Sp1WRbQo9tog+SVZOqz86an92iw7dBVfZ6Q=; b=sY7e1cAzA5t8F8q7lUQNcTiGLyEJYe8T2hGu+fwjzsjHWiFMkyTDenNGD7xyGtCfHmZH7xQxOW58RUP8dCrAibIB1R3YbSNFsmd5GiGPtDJSLFkxwVF0u1YvsYOdna8h8LvbW4OJWrw97fm0cke2dPwgk3O2y1ZgIR4H7BwBLhajdgxqs8kRWXWUhPcSb53b2U9Gv/FWAQYg3fxV79c5Jt6G9JB9MOt7i37KApPmdblZ52K1mnJOdbZXBYxYn7lzSQGIy5YbUWlE/8n/X8Jn7QzoKK+gd4W1MLqtwteRaIf1WFWuiu5syU0cPRe5f+ENaVO3J+McyXL1wvQL3ALFkQ== 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=1tdGOf2/Sp1WRbQo9tog+SVZOqz86an92iw7dBVfZ6Q=; b=4pG+BVAhY+qZ0v8eof2n4LjF0XzN6lsKyQenkOyx4PQLBJ1Puvytzgb9lWFDv+5nqC7Kvs1zyYcqB3R/0fLuDap61CCC1xmfBi2At/TG5xPgM58qha7NC3afURZTwpinySbtbPTB/XTlP5+fX1yOhKQK4Y+UXsWubljf2+aikDs= Received: from BN0PR03CA0012.namprd03.prod.outlook.com (2603:10b6:408:e6::17) by MW4PR12MB7120.namprd12.prod.outlook.com (2603:10b6:303:222::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Mon, 21 Oct 2024 11:15:01 +0000 Received: from BL02EPF0002992E.namprd02.prod.outlook.com (2603:10b6:408:e6:cafe::b9) by BN0PR03CA0012.outlook.office365.com (2603:10b6:408:e6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:15:00 +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 BL02EPF0002992E.mail.protection.outlook.com (10.167.249.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:15:00 +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; Mon, 21 Oct 2024 06:14:58 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 06/11] platform/x86/amd/hsmp: Move ACPI code to acpi.c Date: Mon, 21 Oct 2024 11:14:23 +0000 Message-ID: <20241021111428.2676884-6-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992E:EE_|MW4PR12MB7120:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a800211-343d-4cc7-003c-08dcf1c19ad1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?saKuN5yfWyLLMGERIb5nkrktYNPcQ78?= =?utf-8?q?MdMl1GruA+XXfh7gaxZSR6gsxWFnmEyYpkZHw/yu8m5vKqWsd+W5pY2MVHBfi1XX5?= =?utf-8?q?+d84XiGpelzFA1sEFe1YWuHm7nLKoo0uzwa08wb7NImcrLBHHDP+3xMn2jpWp60cA?= =?utf-8?q?k7ODlx1d2GnB4E4/TUxGVZUN6Zc5mHPgMS1P2EErszTWXoFdE8/EbALO/BZIW2Olw?= =?utf-8?q?W3jOokpKyzi0tDHOuUQG7xQ9QloVhysQjZM5bswK84q6jPJSm92SIdRKHdjNKZMN6?= =?utf-8?q?iK/UcjisgCqDZNu4H0xC/Bj97asUD4wEmcdkwmgIO+foztj+uxZXLYdWSE+MBl6jb?= =?utf-8?q?3C85pPObVhP/DPzNG1Fvo+03uye/AEaIc+kM8Ov+GHi1CAYioZJWr/zlTPzBiYBvM?= =?utf-8?q?hBInPDx5CCBCmI8/SjuuT276TDBFPvH7Z6K74oWNa/Apvphytv8VmSzPhmw7wJTpz?= =?utf-8?q?fw2wvxyXTQByQaAyxNJoqp6XFVOE3y+abT+mNXlIMgcEsN44HOwIXmY+CnQXYvqmg?= =?utf-8?q?7r9fOCRS2RUERsmAWCG5gpmSEGblCenl/FKdXgNbHrbGFSfgdE4vH8ISharq8yYI5?= =?utf-8?q?rMylz69yZPZGBIoVYbCtWlGZHNpUdRkDsnnbqDPCBUCyTHWaPisxnMCTmZ3f8g1iD?= =?utf-8?q?CQrQW8NhRS4CJezGxc7yQdfrk7tijoxnhk6AYTN/HIZXktCgpMcQcM9uE281Bg4EB?= =?utf-8?q?AQT0k+UbINBlzVRD7Guj0oTrk6j/5Ha+XEly5vku9KVeNKfocj0HqcNuIukv98ZqY?= =?utf-8?q?Goh3vb/PttFVwz759ejf2x1ftrq7gYxxWhP0Byorjevaavd/PZcx1EQyznwrX8RlJ?= =?utf-8?q?ioXVoujdgPAX6h3NMWQb5p897Xb2KYwAsFZpMAzw1AB7NGAcaqirj6taIDjVOXxOz?= =?utf-8?q?7kgzu4UGkMqBhLZTJ1W7P/exVhx3u/GYRePjp/2iKMBuBqUSbeVVRKJnT14ZshSaD?= =?utf-8?q?3BZLXIj8zHOiPXe0yPnTRBEO/g176ldfI8D3bDusWYghSbtNxk/fCzEqEgxZowr9F?= =?utf-8?q?GDtUbkIS6vdo8ROetfPZmEQMc0moUOyMC9bT/eugd4pZYSSkNrHzg6+MZo0ae8VoZ?= =?utf-8?q?Lcrp+1IIqQ8qa9lKA+eHhJAI4Wgzvk8lmoRHVbXrQqKTiBhgzCge0BDV06Z1Gqg24?= =?utf-8?q?9B6PG6ytB5iFxuJqpbmqhhqnEqLz6l34D085PDtYfrJ+KhU0eitsy+CEEPzdU+Ndh?= =?utf-8?q?bqqPTWhn1TFXwoKA8XcZ/uGWc+jLOTlGRXpxjeo479nUFXhSUtCh2tGC8J9ji+ySh?= =?utf-8?q?jRWQT8ptozUJMUwux1JpaeaYM9ZgY2gvqQQMLOL4sbuhyewTcSIstWzBrNYM0GgPS?= =?utf-8?q?czI3esicNXoOYXQBzCvuz1aLq/UeBHIf5A=3D=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)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:15:00.7356 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a800211-343d-4cc7-003c-08dcf1c19ad1 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: BL02EPF0002992E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7120 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843924 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 D88C11E47BC for ; Mon, 21 Oct 2024 11:15: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=1729509309; cv=fail; b=PiuCup/Ea0zOUnvxs39ntgZkWQHZ2OppmW6LnM6OflpXaFxBv/ZpQytZWHoP8Oav3ISiuGPJs85Bqs4MBJKu6g5oGgKOuavT2zHJr7GPNiq2VBb8YMDRbUrVltJkxmGE5Css3g3uYYoC7TqdbB0igXFIeoA0F7Y2ncnq4QzcITI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509309; c=relaxed/simple; bh=OmNtKg1RJQTtD7m5UZisWQpYPjm41W6XY6NWVxV+qSA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tCtrrk92pOlJo//+hBIQFa/QWVXnL5WUOQhH+DvJIn3Zq2Y+4AljOem5vwRtgN5CQmKYBxRQhygKEq6uXtchKP4kyt5Io6KxyLriTUzBexCMv84uKNqg3TtXaPwNIj+vfOTmnh/QGFovSsddewVe2LXi+q+6TD8uvpDqTnmuwto= 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=10kAtRLk; 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="10kAtRLk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EtWmvTxEDrhbkZqcW64Zp6qcoXjLBV+LepxTXnYPaE+EBWoqHxJW2+ggVcwH1Yp1beWoG3NUFnyAsCMRHUoOiSbj/NA5Z8h3a95LK3E34VhZaxQkVzbZq5/z5mpGBTE17BfklB+Itzm/abxg5NN3TFqWBLVn5iNc6gBMTnLy5rUwzHcYibjhigyIuoUI0gTZ9MwqbTPGtaUHX1xnNuFhEJbw+A0KcYvdPvVOc45wKBDPZlKCZfo+CIrqUOA21Gnq4o6s3F6wnymZk+bu/hkIqx5CCSrT0Ik7cLlfmqUQ/LIVfrh6vG7DyEGvhdjN+E+1Guz5496yU+AFbvq26CsS+A== 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=praEVRLiXdL2PSHfRmd6+wGMKt3DCbMfifIcqkwkXTs=; b=XDAVHWHc9ls3c96k8VyqzUDoKKDlSp4kzPNyM32AF0rVG6sP2lQrNyLnIlnR7giQ9145xop7/kf7UUa33GdKlV0iGqCVFXo2hsI17jPuWl5fBT8O328qxiLH6c9R5mgATMoptNwOEnCAvuNdAYYwTI64QnDZuF55mChM0ePMCNkYH6ddI6JJNQqEBmGuf/MRA1T2VEj0Rc//Bl01stomuqVQH+lj2FtumQDXnFGRP5IRD/iisp6vKRo1zU35wtrHw6xi1azkTrojNV5p0cbO7+vzEg2k9G+qW79xcFXsnvCDmY4UDat0zKRo1IB/TURRIZQ5vtOQdX2Jf7bbE4XX/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=praEVRLiXdL2PSHfRmd6+wGMKt3DCbMfifIcqkwkXTs=; b=10kAtRLkgJiMEnS2SN2taaOQAeae1VESfMAFx9FIXJaNYFXtoF4EXTnEeCVn1arCCGsUVyWQR69fGNWndpbnPrRYPh5i2Kpx0iFTfiW9B1JPWDYYEaJQtS1f93lAeorzf4d/wez9APRa62+q94MmYgdLXhvuEItpnaC5L540lvU= Received: from MN2PR02CA0025.namprd02.prod.outlook.com (2603:10b6:208:fc::38) by SJ2PR12MB8782.namprd12.prod.outlook.com (2603:10b6:a03:4d0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 11:15:03 +0000 Received: from BL02EPF00029928.namprd02.prod.outlook.com (2603:10b6:208:fc:cafe::1f) by MN2PR02CA0025.outlook.office365.com (2603:10b6:208:fc::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:15:02 +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 BL02EPF00029928.mail.protection.outlook.com (10.167.249.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:15:02 +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; Mon, 21 Oct 2024 06:15:00 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 07/11] platform/x86/amd/hsmp: Change generic plat_dev name to hsmp_pdev Date: Mon, 21 Oct 2024 11:14:24 +0000 Message-ID: <20241021111428.2676884-7-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029928:EE_|SJ2PR12MB8782:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ec349dc-1253-4812-871e-08dcf1c19bfd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?qdQvjkoOA47QLIusihfkl/3xEfQJnLm?= =?utf-8?q?km02cGIh21xp47YDZi7zdV3IjnLIe/eVZje8VJTsiKH3BaMsvp22abh0jaPR+/QhI?= =?utf-8?q?U54Mo5554LG/zQTcAiP5KaLF2+7QldUAgDKWusoORo1XwU8Zvc+IGslR6iLmYsuzd?= =?utf-8?q?wgQZ5RloMiiHC/Jm4gZBJH0NhF1SK6vBECEH/5U09S3NhGS7PmCJUHDP85YZuIo96?= =?utf-8?q?YN3V1IpOQl8D/50dXQ99BlAHgi/GwLgf5RsdYn1KI3kJcb6JyBc5iTcwGVBTS98EV?= =?utf-8?q?Ir0MyVaIMHgqb8t907u4xZen6kALGBozakLOYu2neh0hkWII3fKK8k1QI6RrmMPFJ?= =?utf-8?q?Qk+2/8mYsxTdm7Fzmh7N7JTiJTmxm/yQr0t5T+A1IGTCZ7SkSNjOqmY3C1KBiQt0U?= =?utf-8?q?PqQ1NSnXimAX+kVVhw4PfMqdfqQoJWrj+Exny8KWB2SEHlHA6bppii1w8d7OS74os?= =?utf-8?q?xYAdLFw1VlbbPro7zKF+q1nj53dgye/5y+EHwVzjQzIzG5JNeguh3b9yw0MoqPpSz?= =?utf-8?q?sacZtxpiF1tG7JBRv10tgn7Y7P4VQbqNJ++A+AoHuDd7noP/bqBzB2aJNu5LtrdSg?= =?utf-8?q?ETqqIjLx5h4Xhu9HT5NGMGP2/4gsHsxxgdvHozcFPGkXgZzBI5BczfiYtJddIQBrC?= =?utf-8?q?W1AJRJHrQMazYaD+tH58G4fLvsKPYYpFXq3DGEvmmu7qM9Gn0PPNMQOC+bDspQk9R?= =?utf-8?q?xk+Uos6TyVIjY6CLF84NcAiNFiUJu2hkvWbNWBc/jKLcK01hA7jYG7CMFXBNCsqQM?= =?utf-8?q?C4yEhxd1snkW04q/Ax5Cz/pecTPs3zpCaujRJJN0Hh4COk3h1bzmDipdmgFMqYkC/?= =?utf-8?q?StL/t0oFKdOCFVRhcJHTPtfK34TG1zfWf2ytFNP8BoQqQf+qy4ilYZEibJaNLCQdF?= =?utf-8?q?VlyVnJFI9eJaMutGrCMClVfjXxv4pjU2/hHxU+t3TC9qpB+bwMiOHQwXrMEv6QtOp?= =?utf-8?q?LqQqtdyC3a0wwps8ycpa+XEeKdErmUqQcQkmaAGaYcbB++6gEA+Bl5rKhvkhHxBHy?= =?utf-8?q?wsLeA2OtjimQtyBfgTRZojkZiVJzxO0vpmx5sj3bAQ33xyI3qlz3Pn8G+rGMGXDzp?= =?utf-8?q?uYUYQD3ZroFBSYR83Vm3n99pwyHgC2KTWF+c4ZQsnv2ZYGiPZjs8WQRZxR1FZFme8?= =?utf-8?q?57yuXIN7toYqZxvEhjnilshmiWXhItXUYo4JlR/4ue720okLVvYVPzAQciJ0BNg/q?= =?utf-8?q?zecyLhS2mHwV5qIDCnKhQYMmiHAxWAfVumqgVJMtBZxbZvzsyXFwrbX0676/V1fs6?= =?utf-8?q?nuS3cUWfoR4RaIXcusz2WMTNszyyCKGy/fEJVzxD6O1YFogCOwD+W8tIX3cT1auec?= =?utf-8?q?A7CmGH+IMPGN9gyLebY5Vj9V9Vv+KulfEg=3D=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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:15:02.7208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ec349dc-1253-4812-871e-08dcf1c19bfd 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: BL02EPF00029928.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8782 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 v9: None Changes since v8: None 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 Mon Oct 21 11:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843925 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF4F11E6DD4 for ; Mon, 21 Oct 2024 11:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509313; cv=fail; b=pxD82v9lgVu3vAHbGFAgI+bzZSfnmsadNftHJRmOc2HAHMYQzKoD0qOQXAqPDqTHQFrcK4xXraXeFmsAuz3LBufUPIGR/FjZKLj0IlJDVwXqDAoDniASf32hMdwFCKolhZEnqvRH9HCsQutrzC4uc6KG8GRUlltD6kwu4sfp8FQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509313; c=relaxed/simple; bh=HFufW/Ale6gSx5L03huu+KIo3f3MIlMsQrnnrxoW1yA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p8YF3uHpllnOsbg26lJ0xDB1x35f/6jrQNyhS6JCXLByrCuyZkeD5ikjDLAWklju1Pker/pDFV6DIdBSFSBWM/fN2+aDG/p2GTNeLPsdNP8dGNu05x9cCVJUwqAYON2lwAuj86xey+1IFyHnAHeyhn8WxePyr10EoC0/iWvlvqE= 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=K0444CF2; arc=fail smtp.client-ip=40.107.93.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="K0444CF2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Jq3I+o5uS7Iur2A3cPj8QWTxOWzK2H02esBd+hAQgeJPZF3deuHXhD7MtFDQDYNnjGDs+uRkn/ZvWGIS3EOzDuCY+mixT2i6agP0nZu9lSrD71HFY/0SbMtd+FZfnVNwo5KiDWgbHPmUvKf4oUtT5N97FslYltTU7APN+TPLThLkBYayZzT0pAiXgYcspTVDCMF3YgjoQbESYDm2dAiT/BcKjG2n2h7qpFnvPcK8rFFqVdJQqj2r6iTwOsl2UwDKTwmUu+WgzKuE19CoybGp+KVx+ybv+2XjrU7sN/z+PcH6xj9bfEGI/r1BoNQ7A/3MiCKiQuxcdD2L1MoFkD9JUQ== 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=n0sWNzd29tpF+b1A0NLQzX3y6TzLQX3b7wkOq5JkMX8=; b=WcoKQsCGBva5duVxuCtTUgbKjabFqa6RVlG31M36ypFoyUlWNLqLMXudPtSkxiC57Cp8ZV6EBJ9izCR3/L1oP0M0Pfmrhapyp+/ym1oTdibZjHJPgX1cXH1oxFA+peYI5lYRfyelmzFgSRzAm/SSlgXooD9gFDZNK/IV/SrivDBSPrrbMoUske0I0jcaqpv3p3bOsKtLoWUqws8abQdv0ViAJK+ZpGKGSy5puGUrU3k/vGxH8V+RXfpu/482JH0CWyAS6Wy9kqPjjpg/1C7NdcqZ086Dl70I1/56U+YnmMNvuPSFn1OI4mLfkrLAcPt+mA0RkhQ5+TdWdbDfD1nDYQ== 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=n0sWNzd29tpF+b1A0NLQzX3y6TzLQX3b7wkOq5JkMX8=; b=K0444CF2/XFGEor23/qkTO0V/6HXh7e7rdYCa9V0lKfpC9wbtVs4BPNt2bFX9h2UVKFbmNzJ85VLDoHhB++NS16vm5eGpFkfjwBeKV2lFauljfkf2K6ectAI+i2pCV8vPGOIR1XCO3nBDUl74f1bplSS8NUGUZa66WfTMqiyTMA= Received: from BN9PR03CA0461.namprd03.prod.outlook.com (2603:10b6:408:139::16) by BY5PR12MB4306.namprd12.prod.outlook.com (2603:10b6:a03:206::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Mon, 21 Oct 2024 11:15:04 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:139:cafe::30) by BN9PR03CA0461.outlook.office365.com (2603:10b6:408:139::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26 via Frontend Transport; Mon, 21 Oct 2024 11:15: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 BL02EPF0002992B.mail.protection.outlook.com (10.167.249.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:15: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; Mon, 21 Oct 2024 06:15:02 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 08/11] platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers Date: Mon, 21 Oct 2024 11:14:25 +0000 Message-ID: <20241021111428.2676884-8-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|BY5PR12MB4306:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b5ceae4-104e-4cba-925b-08dcf1c19d2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: ZWaBmx7hhokYlzJBAdNoTTLYn4EbR2PLqu4zx+DLP7ZRFNjy63mCu+N+kUQuLveRTjc1nNnP+RGBjH8Glf+w0WhDEXfbIN5rRH5vzPtNGtKEo8WiBxOQ3UdpNyxsuM5RP2t6vYXqpV8gecb1yDZrbgxwfXrWnxlesvGEKiaBdHo2+WQTPW+qm/i61LG20KGz/EOlYshmsP46FxQSdwc1lkNAWoGNW81dEACRpf2ldHoCFClKWlRul7+oJ2yE45HR+FvnBlZaVut8ByG8SkzNCexUQUipaGobUAn9WWvr2e+9mYL2lWlK4/sn4Hrn2pCIiLzeYhEv/3rhoDN5uwEQc3PxEUnNEWfUpXrCfw65yyX8gdNq9zE4e1flejkZsu58Cz7+01Rsl21d0Llrr5Em9e3zLILUJgxagwW+Z4nlI8Gjy7BX70FuywnRNlTO8muYUdAdjpxlIRbvFOdKmNgQbD675jPXrOO3G+tgdwY/cZceLbzXgK2Wb7Fz94VqXi6I6hk/9oB+xiCk9j+1wzk9sxMxK17csutJHuCM8JIlujruv3hErJj20k2vWa22DDGi+kT4exfmghh7ApFT7ylwB2/mtwq+4ixhvIAc3jT/XwIdlf//0edYLjCUOTXCCLCaJVrnPJnmRJLE0Nj8Q7B9ZIro5gyvffuvvoATh3L58AooGtCxE2km9uqa/h8RhBdiXSvWW2Spk4lDWrw1C7hgH2CYCp2QLicDLTXrJ5LvkU4gMtMzffPI0L6+czH4+kuR1f2NM8CzAPKlbyMFMHsiQ8aH8Zu6mFfshoHEAjLSE0ANoyOnRM/nimDRNYHVvjDYxYqr8bDthxzMRiph67kjA2qV5pocfrod4XCxBZxXoQC6csDhBeaNiR8RzJX6WwSJyC6kNsQgVI7OSbfGPFKnSyn/pqkTZ1IudDV3yzuIyuDFUJQC4jt+hU/LDIvMaZKGQA/3tPZuQ5IT3z+dXUt28XvFr2e9NHjakXsd2kMz+YK4zok/uHE22tdAJcEOQBNVAUmftBJL+2+eWNYBGy4sQXSm8jioVJQbhj6XGHUuexfGmsgn9wQ6GrZEyq3jSfg4I6PP2YLMJm24MHuY7c7jaPQLq1gUYYqqG7Pv4Fm1bK0d5P6cZQVRNtnNl06McaCffAObsqJZS0kCyFSpxSMnFa6otxF/qqfpJTeXjfHK0qtA0E2IMH4/v2IA1Wl9n1363O+eT7o0wdYubIIS29DG+xf3a8BSG7AnlIW5TzkqwCuLG9EXDbdQQGkOZL1oVyIElFBXlFUL1SPxgkuAvrKkha9dFDbM1yOxqXyG14xXoI1usEP7Hn9BhZivIQjyi3vxXROOPiLIce33pUj8HGzyaO9nePGTLMfDxo/pHDGQvfhIjznbrI2CziSoY2PR/3NnbQfzyF0+ZJQYfYGTwCNE+CMssmG1fSi3zY3Za5lOYEI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:15:04.7043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b5ceae4-104e-4cba-925b-08dcf1c19d2e 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: BL02EPF0002992B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4306 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 v9: 1. Change "remove_new" assignment to "remove" as per 0edb555a65d1. 2. Change "called amd_hsmp" to "called hsmp_acpi" in Kconfig. Changes since v8: Removed unused hsmp_fops structure definition. | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202410021345.okdVjjGy-lkp@intel.com/ 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 | 138 ++++++++++++++- 8 files changed, 348 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..7d10d4462a45 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 hsmp_acpi. + +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..098c879798e7 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 = 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..ce6cab23dce8 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,7 @@ 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 int hsmp_create_non_acpi_sysfs_if(struct device *dev) { const struct attribute_group **hsmp_attr_grps; struct attribute_group *attr_grp; @@ -88,7 +93,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 +139,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 = 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 Mon Oct 21 11:14:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843926 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2068.outbound.protection.outlook.com [40.107.92.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 BE3CF1E7657 for ; Mon, 21 Oct 2024 11:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509313; cv=fail; b=jaCqNhYnf3ITcJcm/9zoSF5oR152/Voe28LhHUkWldRtlC/eJ7CayJz4tnGqDIgqcUG+OHdhvSeVLJaKmKLy0VPka+gYqpXsVqOX6T8agXYcmyJrpkNv/xNMYrmxuoWvDREUKuBpKzQfcOOCCuOWxHCtZoV8RcufVwvzozxofZw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509313; c=relaxed/simple; bh=cDT4wx4xlEexHnFVR8A35jf0NfzQCMFqRQwgzsHjo8g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O0X4vVVF6qCYVhMzIlC1O7ko7HSGz+3ZZxyUVuBZDfoMM1heaZDLYlBf7EoPvkcdp8tR773+j71S1RcMLiSg6dBKP8g3+xiAKf/KPQ52+ObFY4badI5DKPxl+OVausi85AC8plyPGa0jM8pbAzrXfdfTqaahhjlMMLtrJDlQDgg= 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=KSTVaAQx; arc=fail smtp.client-ip=40.107.92.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="KSTVaAQx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KOv/cDsCci/6FJ6rkmgTyLAPS7UP+KHgeIgB3GLCqQwwn5vTkfYh/x+Icd5sLvzCkv9CBE3Ff+4m5i3zW32nB0FMfSjPkaKgMuL7/Gp5UCJa+ev0udBvOqaDO8NvCXFftRYUJ86gWNvZ9c+c6SLvuIGpJj1pNsPRgYkgAhOQXrXfw3rHtKBfOoTrDVCD1LZRsXqt6AciYIzh5l0rt9JT4KjTV33queKFHY3mOVWtEaTGNk3kbaVEwyEiAd6yV0fqeuGXdn/Vdh1u/yLJTivSoVjLqoGEzYarOKi+HH6AfL5uZL5s6txXbEc1qLSB0Dhosp6nvy8WaC4SrglhZr+MJw== 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=t7FL2Wu7sXmPOl356pDKIA4bj6t24fMtDFZnFfjz+dU=; b=hTexACSq2PzzCaxbTZ87D4LseCMKIuVGr6UyvckPm2cInKes44jrqvQvnFLJndxek/kzBwhqtsIbT6VRShNKgfygIACcBPTRQam5TQMbQS+vRUxgvPVuDHsaVMPUmDB9zLWZSQpAz/7GS7cRP8s8oTUhcwdbnDTNJiXPH0CyV0gjCe6UX8MLLhwXWVzFEo7fI3RwiIokCLUt+kf3Xg5dBkBXUIfX9oo+T5AOUWCZ8lMLxCbnF0fBt0njS8B9ODW4pnP7ajfattICQE5fUb2/nWT4T7yWwIAOqSu9xC5IJc4jEmKDfVrb86NGNqi+VsdpZB3k4JS80lfyIRK02V+cDQ== 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=t7FL2Wu7sXmPOl356pDKIA4bj6t24fMtDFZnFfjz+dU=; b=KSTVaAQxXiZe15GwTxfHApyIwVdPJRjkJ0j5LMaRI0HzgWTsJflovmkFwi5CzhHF2zoKlHrLsX72dkKn02OGbsWfcVYdpORtlPMaOTsMiabKExuCMJ5JlPm35/IxoFlxkNaxD3XGP3d89BBZJBSfxXMiR0Y1gqboGBFlnWtbcfQ= Received: from BN9PR03CA0078.namprd03.prod.outlook.com (2603:10b6:408:fc::23) by DS0PR12MB8502.namprd12.prod.outlook.com (2603:10b6:8:15b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Mon, 21 Oct 2024 11:15:06 +0000 Received: from BL02EPF0002992D.namprd02.prod.outlook.com (2603:10b6:408:fc:cafe::95) by BN9PR03CA0078.outlook.office365.com (2603:10b6:408:fc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:15: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 BL02EPF0002992D.mail.protection.outlook.com (10.167.249.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:15: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; Mon, 21 Oct 2024 06:15:04 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 09/11] platform/x86/amd/hsmp: Use name space while exporting module symbols Date: Mon, 21 Oct 2024 11:14:26 +0000 Message-ID: <20241021111428.2676884-9-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992D:EE_|DS0PR12MB8502:EE_ X-MS-Office365-Filtering-Correlation-Id: ebb5fd6b-8885-4455-d454-08dcf1c19e54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: nyziwD64/xpV4PW6WPlhQ3/1mXNVlYx/HPXa1h4L9arMlXs9d5U20kTQMdnnONS+/j7WA6s0WYInYzsrgP8vUuoUFY282MD8fYKQLE5D+gCfFx12KOFp1s635F5UBjZAt0MFP3+OmJLIOKxDEJzq4t0CYvXJeC2v1XHb7a1sWpdYpM7TGh63gzHdxxyE2mZUrbbrd+wJ8ZQYt3xwvrRpD85knPfivM9XBXoT1HswUzpQPpFehjhxJfHIU3tGAWQEvzyDivv+EkMNLHVk4RDZtoZ7YJgvNe1dsdx6l9aHLp/umAkezBn8GIYthGOb3Qwd5NcZZ/7E33aony5Mc2kSa2zVPt+8Gy0X5j8bguag6qqsqu1mU/KPzCVw3Lsk5QY0raW6W/US5gKYFjsb/xKSoyctkKEIPwqzZNwNhuuLXsfJunCuxgs3nyBWN8ibuInN0mlPlfRTGcdu7iM3mA18J4MulQIFZGs+dEOB+y+HCm2hJ47MKX6RenTHKwq9iXFjlcD8TucLyMb42YALWLCDHhQcxIYLLxD7ZhhcnN1yD9iECrNAeoSZfzpLfK6D6CAUbTTq11U+qbnlPzR1c7LWzPI0Gk3/IFBS40ElR4FxyMUWkO6DWaxjfRrbDdxFYI+cEl/hrwEE6NnXaqRyGxBEP0v/okTgQ5eRjRjo3+h0PLOGmM6V8UmoJpL8wQYj8fnFzTYJXzvIXy3c6XiG8bYaX0rSKc1PvzQgUXVUV4TU6pSx65SYG8RH24HBABn0vYoZU9b24KjD7ODaYxwjynd9WApghUqNXnpbPlwWhdGEWNrsPTzPv1jfk8mFdlca88d18u5dNazN6ehERnhA1J8kw0j1U+mPDrpxzMHsjnuxB+YCSJYjT/s8MSKzhhgK2onnGw94uf68J/l7h/IRjvxR3b9vNF6HAAZCpjyK91fXnKcujXmEBwcBLcYjgYt8oectMsQI9zZefVOkrNY1fwQWVJF5+BvSezd23AptXl/miNDaP4jQr3WezUA9pxnQEbcAKK3n2Kwgc4ER5I8fW2pbDh4+jGRJhFFFHK48XryibKEZSVRlczlraBPF381tdBN5SknnPfVOG7elDSNBYuD+Bfl7r2OKS4gTvNSjtjr3E661t89DD9+/+7KeO07BMDHEfMlh3MpgRII0E5zGIqmOqZNnpGkym7jeHWVofprWI34sav/QCNgtuOorcp06pLXtvjSG2mopwZ9dRarOlXPiH2NH4kCjT/717OlXKzqlFW0JQKnPZjhL0dyW9O8M0yt8Wpz7f9fk7glMORazNxSrzTEbbiTGuDju+WtQ1BpcDdoXpvSEORP2kMrZI7uyMkJWt9g5r6nC7zPorKtWbBZI5E/CePxteMc+X2aed+gOjSj36Z/7wlrHkv5lb0unaDJHEUVjbdgd4d6GqyqRF+jCKw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:15:06.6328 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebb5fd6b-8885-4455-d454-08dcf1c19e54 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: BL02EPF0002992D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8502 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 v9: None Changes since v8: None 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 098c879798e7..06315ecf0b5f 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 ce6cab23dce8..a41aa0979da5 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -265,6 +265,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 Mon Oct 21 11:14:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843928 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2C951E7C05 for ; Mon, 21 Oct 2024 11:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509316; cv=fail; b=leH5taNuRqw/TavTZAcFEuyeWB0GXqikUHBe6YfoMg+yUPmwJHbEeziOS+928qXEcHSjhw36M7+NiBlCo1TVo8jJS3YrJLvohhSe3Rjqk45ABffx6Em2ANM1b+/rwjljrQAbGrA+epqrexwkyHhWjO3A9Y1Mw4ZjMj7JAWwzj/8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509316; c=relaxed/simple; bh=kEbdAvP9LPsUIgBHUMbrklkzRAKvWgoyUZD9Ts/Xuuo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YYm8tRG4Y06udvw2iOKd/seYrhMXP580iuN5L2J11VXYRG2TGmgeQp8Fmo4x+hO83c9hMUbVYR9r+fJ9NLtDzEpJa/770IvPquBP47g/KfPeFw2yHO0QuPHY8mwlImZWVrJsddiwGf+a53/MmfFiqMGRrlWBNLGAlWhzNV0ZnFI= 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=uUmWaqI9; arc=fail smtp.client-ip=40.107.223.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uUmWaqI9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ud0GEOE6CLWvrK2CFc1/x2fTWflLo4khwxk+IqAlumn8khlNTk95ajnheip9RysfhqKSIYtiOY/GZZBa4M99uYCRiNPmoILGsmzfxqKj+/4U/m6JdfXo8XR6DFnEWFznQGHjQY4ua8+rKwigibU3y9A76wPXnn9fHQx4l3cFwq5HS+dSHiWfLaz9/cIjkCR72Lj2E65kTpjCryjtuJSrAEQwCtNQICN3QI+n1fN7K3S2uiorv8pBHZ0T7SpefUsNZ2Ub1P51MvWE9k4uLrAD0n/P1al85IMv1qbHWQvIudmJD9TOU5kyJEERkdZV2gUZvKEyGxgl4q6oUpOIL7IaJQ== 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=pVGBJtXyqPkL+gVB6DqxfmlAsGwF9l4Xd8Wfd81hsFg=; b=o94Y/suqsMrNjbpwY1GYX5R0jBDt1p3oIJrFBG5AKHHDR9L/dE0+8vp5jCna4HbbbvVhmtENtwLO6Pbb9h2cb7rh5cWzxvT0yXcV2bq77srk+T6KRYC5YbgVj38qAQN6Ldthm0mT0NKVKVHFv4JiCxTuEiJer3K0v1YTOpepHGAAAGNkxNIi+UQx1Y3pSC7yHK67r6lxN/404gDzzKEySBW7sR84BSF4cocLKCrhtdq+A+lhBw/80WCUCpVapHr24u/C7P6rkVF2et5se5/iGEzYbjQCFRL2BXCZtjm4Mh/eggrWdfHxqllReIGTC6dMZ/CyAWnxRLc9TZ7LqINSQA== 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=pVGBJtXyqPkL+gVB6DqxfmlAsGwF9l4Xd8Wfd81hsFg=; b=uUmWaqI9wuOYe+8LbvWxf0H5Uyn3owHY/5nQ/Qlvu3ftbKolmdjJu34VkxcGxUVtxq5KS/gY9cQhZJwjFyrj5O1+/UwlFnFV4c6Qb4xqMHUQsBX0lhU6uF/Ekw2rvmizVbzCdAvk8Gyk6/zZKQByH/JuI8GBnPZzpuSLsqzBGc8= Received: from BN9PR03CA0671.namprd03.prod.outlook.com (2603:10b6:408:10e::16) by SJ0PR12MB6832.namprd12.prod.outlook.com (2603:10b6:a03:47e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 11:15:08 +0000 Received: from BL02EPF0002992C.namprd02.prod.outlook.com (2603:10b6:408:10e:cafe::a5) by BN9PR03CA0671.outlook.office365.com (2603:10b6:408:10e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 11:15:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0002992C.mail.protection.outlook.com (10.167.249.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:15:08 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 21 Oct 2024 06:15:06 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 10/11] platform/x86/amd/hsmp: Use dev_groups in the driver structure Date: Mon, 21 Oct 2024 11:14:27 +0000 Message-ID: <20241021111428.2676884-10-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992C:EE_|SJ0PR12MB6832:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f4bf046-6cb1-4d07-96cc-08dcf1c19f80 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: j+9my88l1o+uPaaSzl9j1MiBoV2/kPHXnlqaD1vJs3iV8QnsAGcQ6JvGBGt7Mo5bw1kJHnW5uuH3G5jV1BroQB/gXbSFyucJtEFS503+m1qyXlI0mCWVmfGE0vRcLpeYwSTuHA9iSIpQ+wf2Lr2IlB8XYVWBkiv+56/7BgN03w4Qhxy26tvB4/V12LQOjDSgEkQKX1wJr6B82Qw6QHOosoNvkVvc++e8dYzQJ7CBmNpvPtSGGD7feYm6C3HfKFLP0KB7vXCdWvOvhhgVxni1kfPolgDsX+c47/XDn6jT+m1BrQAfYEPgveIcTVi0+8ZIiWw4sLfxzDcHhpAyby/NAbb7ytKKJfSrxT/IzEugDqXyjRBUFfJAU9dxlwp5u6wFwB1rrk7PL0ljj8sJMvsG3sc87M5yVcgUg4VCTwys0Zd+T8551/6qa+6PAsxTpsWiXPbjO2t0YjGD6q2uLBl2kLjl8xjotnQvkC3IlhoU4OBSGNH1x3X9ebUJVo2moLDOPNjcO6dZP+MLvp5o61wRdWJgviuE7J7os36MbxfmVIHX4hMRMdczwIG7mEjsQxnd33tQ3tnC9kzQhB6a4hZaf6pbWuv4MXNR4cG0t3zhrvoTT0PK513QBKmuawnKVBnjiYCNQT8NpSAJjGcwhe1ASTQXsHwRRE96ou6rWpbe4/EZmDcWrsbcpwT6pnHXgfBVkQc4YMtKEhehuIuWkYGS0kl5D+vE6X2snGYG7n79V6U2iUqhta9XLqc2fM+OedQY3j7CyWKrsmpNLOLkEA43IPY8vLr6n8P9bbDWNzMsh+TWym1xS7JCWx8uxaNhNNXTukbHri/ZqkJwZcLRJQ00xMgVNvficYMVi2UwjAW6cEEyz6Pfkj5feEPFdA1p+7kl0QzCKQfPZipb30ZHFoKv9Qt1IhhqDG9konTC7bLfrfBmyK/Kg81Ll4qBM4VeTdBwV1BQIYz2ZvFxuqTR0J64UuQLbcGxEUMXtWbZG5YdMohIRXSe1Cn8MPpyXwhHgx0qapPVx9dRTD+PBI4EA+WcBlWbIFguELyVkO0+zjBZ9YTripioSVQbluQbJZuj+VokWys43+uVTBOlpGLnaXF1Oq0LNAugOXmT08QVF+Oz3NJ2IfpuCGxaEyMYuu3KEzscuD0vmyd+2vEtEL5tnv/k8MEYPZ8YrLuw0dIeQLHJZ+sAnToPU2xFWVxloDvXTYUUU2YenV8McrrBLlis2Vf9UQrJS/b15QUU7ChU/p9b6RWZ+qcVKt7RhTKHITsAhuSSh5tO4ygcZ3Aa0xWl8SpLNzuF8GZZgVF1R0I21yBQMr5GHdGPQIzYxDmMd2MP/O5Iv9heNaYpmeXCJ7tm+FlJosZOSADUjc+ez3oLe21uEnwdEAAl8KNw8LkolJAVqrGrPhYw+jVxcItdWljPC4A+Uw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:15:08.5973 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f4bf046-6cb1-4d07-96cc-08dcf1c19f80 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: BL02EPF0002992C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6832 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 v9: None Changes since v8: Resolved conflict caused due to change in plat.c. 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 06315ecf0b5f..b953959c9adb 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 a41aa0979da5..905607b5cba5 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 @@ -55,36 +56,93 @@ static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, return ret; } -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) @@ -135,6 +193,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; @@ -156,10 +220,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); } @@ -173,6 +233,7 @@ static struct platform_driver amd_hsmp_driver = { .remove = hsmp_pltdrv_remove, .driver = { .name = DRIVER_NAME, + .dev_groups = hsmp_groups, }, }; From patchwork Mon Oct 21 11:14:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13843927 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90E411E7C01 for ; Mon, 21 Oct 2024 11:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509315; cv=fail; b=ebrwv6ybm1PXcm+7igfh4SDtj2NC2f8O6TutdjOW7YLJrEajjMq/DG3EKdtbAyLOQQ3Br584ObG1XTeSbJInXfZoD3kVhLnlbPRSC6/5RbgxoG8559GzyIrL7r8AUaOpxjDWTRD85fyiqkSd7S+422e2fCABtquF8+Pju5Yr4Eo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509315; c=relaxed/simple; bh=isxAJJhHuVVmWAWWfQsTbI5qEuiZ6SkvXbNvJg2dcr8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FzgHleQtiCLi1LRlxkIhxIW5UIK1W1FmENZgr3s4lr868cGdmMVOyCPufkES7hvq6ZTlnfMUSqsujiXdQjl/1+/dze9rPZ8nIyk3PA9D5Wr8tpZJ491LyNmzcmKGs+RbBoTTheQcu2LebS105i1tJtgZZfJUjzSPX9nL8cmzGJY= 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=IVDw2yBC; arc=fail smtp.client-ip=40.107.243.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="IVDw2yBC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TfBcZICh0+ZMxAaBOvx2iGzMumoljJRW3iBgTVU2k3yDN2WSWDAeg4PYXOnPfpIW85TMlLVuw2wGMlKBgV9eJiwjJY4Mxr5JgPrv9E5Zn7cDNs5yK2vWNguhrEl40ghTFYsNWAIK+bWcijcnsRLcV1WVjKHBBInj0dpx6WFkxmW782rfPObpf6pAjqOn0IyJXOmjgIOS2DX5+3jSCrWIdT/T52ODlPjxbYSb13lfx1UhFXRPVfPqlUVv7/1GxMQFS4GrXHnjd+NuWIG9nFDg9KcLfGlORQTIqKjY/4H/6ihQAa3bK/Z5L3aChsYyh7MHiZC0Z9AtHfwCGz4TyqtG1w== 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=RUrwkdA1/zqpbYHYWlwm7Qn3jSSdsi5Veh+1M+z1Xyo=; b=wNTIZZ86kj/5pYSER2EXLdMVgpXTpV6FF/eXnjZBCq6eEGXJJ0OzLR0o1Erv81pA4tK8UrnYkJYCinCX0tzgrcneVo7X7KrbcboyNWe9UkX6jN7iu6xPwGQVxYyNCWC1c2l5f8xN9v12LbWBdTfcwtG9sV3rIvHo30YBiAqn5BYvQ0Fr92NA53H3w4Uptx+AOEJH06peu01UQA+6EwwJwgpMXPqwLHJN95QNE8MVYsSS6bgYpwTyLPtUfTNvtXFBYMh/vbGsPYGZaymu0clME217NTbeR6cma+tPRXMVcAICY7Qdbo+ZjNwePJhwvXW8XIY3GO/ZUyOcZSmcsNg/1A== 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=RUrwkdA1/zqpbYHYWlwm7Qn3jSSdsi5Veh+1M+z1Xyo=; b=IVDw2yBCG4KIbQ1VudFAl+7JLYy/s2Fclf0JZVfZt2y3DSbrRMj09XAK+VohjYrIPTRaUUueXPBlRi3C8kwiGk7LjOOdPtgl/Qhy4DKrOA47XN9FgQinwlBWFGoRLPsIhcXLVbu07F5XGfrPx+wiFInhwYuQzoCzjbpssKpinh0= Received: from BN9PR03CA0459.namprd03.prod.outlook.com (2603:10b6:408:139::14) by DM4PR12MB6470.namprd12.prod.outlook.com (2603:10b6:8:b8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 11:15:10 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:139:cafe::3e) by BN9PR03CA0459.outlook.office365.com (2603:10b6:408:139::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 11:15:10 +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 BL02EPF0002992B.mail.protection.outlook.com (10.167.249.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 11:15:10 +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; Mon, 21 Oct 2024 06:15:08 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v10 11/11] platform/x86/amd/hsmp: Make hsmp_pdev static instead of global Date: Mon, 21 Oct 2024 11:14:28 +0000 Message-ID: <20241021111428.2676884-11-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021111428.2676884-1-suma.hegde@amd.com> References: <20241021111428.2676884-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|DM4PR12MB6470:EE_ X-MS-Office365-Filtering-Correlation-Id: 76ca65e9-bd92-415f-b95f-08dcf1c1a0a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: xGXcsghjmmnlJ82+8C01Z39jn3p7gSkZTggronq6ZkiDYbMbYH09CpQQJX5wrBKnw1fnyBl209JUMQ91JNSbl7AdsUUbnn3it/C+j4fxjMcxdX4MOrGv/d3JBCcVb0oIm8MFhp48xPFVR0+8fmlL4YbI3zagPWMtVKTv1ywMHlDIjIXLelE0B1UVJTf2E2cAnlBLxNlwBDm6TI9sv1RqNttx15jXmT4tkIM/oDVe09VEBoVnC++jtetVqmhMZ+bn84wEcCxAkuCNqxwgIVao0c4x/tre1HSILiwK8SqYmhUtYyW0NX+u75HAJxN5rvtZcDjarqb7xZRqIXPrH4YHdF8aiBiqgmk2Cea1R9PYQUfH3vxkKhfLUU5gic4ZEndOVIYVjhD9LIfwpSFZ0k5Chnygr0LiZlVUaK2k7b9QOdl9k7URpPH4VbUPjBoIQoSMwOOUwZ0VTni2cOuzbbgthclIsAHplntbEo39jQ5YjAeoeuhcZpw2N58l13AX94jxFbswrfC+h+5fcKk6yslNkvwEoE1eIGRYfoiBSmASArSaW14qchN0rTr+gWzwNBvswhh+AQvTSOV1fMEdXcd/sySSZSQOV092RZnjrrty9ER9iBtIXRaGF6QTYv0Z4NOZ48wIpc6HWttAuK7MWHe03dtbhMYi40a7SIUqtThffo9KjkPxz4XWsoaV0ND/oIlxK0HE7Cq2+Ctld5HpLGzqFbQsIDoj5a526VzIJaw/1IYDjcqoBFy7avJlBNYNXO+u0LtEUsBu6jhDInJXDGrPnXmuTYSE7kZc+hzMKRHlG5rd1zrYJWENh245/ITmv+1a19DZ8Dm9lMjxsq7f+/x5ELSGFXfkZ2Tyoc8FMUoGjwcp9tITEMQvJMKKitNnITUddMb+Uz2PhdyeJg8DsHcbmtssU1tl8L0iuXYFQ6jb51nw2KPCnV1JaCBAPbIQuThsPmLqBGSO85JqZ6i9KwZGoT0bZhahz24aLOY4D7WHhevDE+Arvf4HBZVCInWSu+HsGLlXxxDcmBheMLb72DJ6WY0MDHvLy5eOGrebOUO58RM6/UeKwjyvS33yYUMc1DRg4nhxPHTCLa5gulqpxHIik2Ix17Ya/HSwu85dvEezW2eHqUC5NvjpIGmuISfoXGgQVaUV2n1FYitiRTqWU/Hh8Bi/k65Edjs8YReCrDCPNkUxWzn7fORla6J0xPnluHmoZN7/d5KmX/TWuwDrTk+Z2MlWKoNSfBKCy1lBQSHEbYNz7LvAskIlIZmIpkmF935R4t468gxrVRsG4uJfWYl2zZwyTXCo5LclwkGNUYjbZW7kj596TVBqx6TCFEPhlKGu1ONR1Av3LM7voPoFqV740Da/w+l2YHAqu6pIezFDxizqgGy0cftnPT9jHKPaM3V8TJgxcKjYh12zx4FUP4a8Hg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 11:15:10.4856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76ca65e9-bd92-415f-b95f-08dcf1c1a0a0 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: BL02EPF0002992B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6470 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 v9 None Changes since v8 None 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 b953959c9adb..4aa4d66f491a 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 905607b5cba5..f8e74c0392ba 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) { @@ -64,10 +66,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); } @@ -79,10 +81,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; @@ -156,10 +158,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; @@ -194,7 +196,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"); @@ -208,10 +210,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); @@ -298,12 +300,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);