From patchwork Tue Sep 3 12:38: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: 13788645 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2073.outbound.protection.outlook.com [40.107.95.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 742DC1C986E for ; Tue, 3 Sep 2024 12:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367136; cv=fail; b=YcQYjcodEcCiiGNidrr5lSRrOT04KWeVgaBG9rB9y5s6oZvhtXWiDQYoS94191FU6SjIke2hA7sxe+m6gKHypGk4OXXnyp4Y8qdHp8NtLOlEvnRJSH3IlA1plGiJO5bz+n+wk6GE784S7NwtNy9blfJrA+gBmguP63fdC6QaQbg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367136; c=relaxed/simple; bh=0zQB0sC41AEeh4pxd44KTM8BSemWdGTV4VcCtFDTggA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=j1bigUwch/E0Szl35r/oSoOcm8hveDjXXu8mH29DsVtg8kFfc4tE4QNLkvtJ0UIa6yiXZob5dwOf0V/ddQjlaCR+Jbj5tRVhWZoEhe43/NWUySIG+XKS8JCzipEztUxeqeEbMGy4r2xlfljjRyCnyYgPPrpjSL87nLn/QEbj2JA= 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=YSPzi7NX; arc=fail smtp.client-ip=40.107.95.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YSPzi7NX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q3ZcHzi8sGrINCtgKxSPDCS8Nev9Dzdc3xrmJ5tDkHsmN00MHKzxe2Age/2/5Dtnbfhx4lfAUcmm8H3aUy46EEAhC6LTehSaxWgqG6dU4iNl84NVLEOxQ2P4oI81S0uLGijuObL16e61xn+c3ZyYeEK0UiarGHS96VBA6f7xq1da2siUvMPr9mj0fThhG5COrBrKCz3YmC89Z3MyY5ryDiCNZz7rMlftJ0af4qRDc0vIq4pMV+n2116Vt5Uaejh6vepxcuq40cGY7cgteUVrHKX48xEFnKoZJLfy21/D5KlzakDMJ9u5kxsxNCLEqEwHQQBwd8eydVQYJjLJuoG3lg== 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=PuZqnnbSx5XLBP3/Dc7T8tawb9PK0S4u/b+Do08Rjpk=; b=HbZB99/sg8LXcnTsCKA71067RXuCANF8manISUYPBzyaReQsjKffW6ZI7VQWg5Mj3Hr3TtlErQme2Mt2W2p1/beZBCPKEyQEPcgV1GNfJWaHqSdpSs3H2EO4w+K6gjFhbFOViuDKKd9Lv+HFtjqPygb3pkhsD/KFq7QsuhU+5q6DhnzXgUSBaJppNo0pWiBPIvBubqGao6i1jFtkqoqVfKAnrOjSfF+PiY4qWsg5/GOm2J0ItjyePQf9qxbcskNqIkF4CZSAeYkl5SUYIUNb7I5BsKNI3fw+6zL7RrH6YTSrlPSNNB7X/N4RmdssSdqqKRTmCsC/MpeE3iZKca3SAg== 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=PuZqnnbSx5XLBP3/Dc7T8tawb9PK0S4u/b+Do08Rjpk=; b=YSPzi7NXV31iF97QKBWwI0HKfo6vzvF9VbLdJkG/0yiNVAS0tvPIoTKcr9pQZ8yO2zYgCU7xvl51YImbPeYZDuVj/TttirCmVsY8QVA4y4MTZkG44YPgF+kUZJyK0n0lN3D/uHwZJVWAAtzU/8vj7AzNdm2Hpdnrmg4FYUcKPv4= Received: from BN9PR03CA0889.namprd03.prod.outlook.com (2603:10b6:408:13c::24) by LV2PR12MB5943.namprd12.prod.outlook.com (2603:10b6:408:170::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 12:38:48 +0000 Received: from BL02EPF0002992D.namprd02.prod.outlook.com (2603:10b6:408:13c:cafe::2) by BN9PR03CA0889.outlook.office365.com (2603:10b6:408:13c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.26 via Frontend Transport; Tue, 3 Sep 2024 12:38:48 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:38:48 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:38:46 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 01/10] platform/x86/amd/hsmp: Create hsmp/ directory Date: Tue, 3 Sep 2024 12:38:21 +0000 Message-ID: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992D:EE_|LV2PR12MB5943:EE_ X-MS-Office365-Filtering-Correlation-Id: 41542954-b88a-4e5f-388c-08dccc155bdb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?2AQSLgtlpqcZt0Zjy8IVHhX2jpxGVO8?= =?utf-8?q?eblp3ZLWis23n2z7TBlPYQQgWJpvslrS52Nj1m+ghC1F3Q0dFp0DDZEq/NFEo0qbD?= =?utf-8?q?yr7tMLH+VMlf177vLcu5uDIgjEs/i0pSFqdo9RurToECnifMhzDA07IkJUubIRDgq?= =?utf-8?q?CzE321sNMS6U4nQ/MfWPIO5QauSWU8xMfc2B/+XZSvCwk6KiJEwARf+0dpUPOfhY3?= =?utf-8?q?0igzCcOCiguY5roqePWCjuZHJc5iDtMp+SPmwRlzN897EpAhOeJKRmOiqzN/RmQ4D?= =?utf-8?q?yf5C9YJPovxkjViSv4hGLqS2ykncMk66ETwYsh8Ih7NYXPEjwVOJU/TJvKGFElieP?= =?utf-8?q?F++9i/IAfLefvPMuH4X+1+pmvfmuDr1U5WbcCoqxgxSKLKv2/AgyIOm/OMH0pXU4h?= =?utf-8?q?AOJlJVDJb+xm9zzrCL9FmEv+F3/zgnN/2+alGXtm5gJ+F9e6JlU+v0wEMvlvK/R3D?= =?utf-8?q?gZpi1ohjOBjo0EcnftggiP2Vx1Hl054Y4n5p7UUrSXkew82bswkU18/L8UpqoNYkC?= =?utf-8?q?7vHGhxKHoxuIppMtPBNWMsjS9BuDaxO1WrbY6F8HnffhLVYNQjI9gTLiOkN0oS5dL?= =?utf-8?q?uh4ep2Dk3SxaI64IWPyel7kY2bP+AEWsVBMU9R8Tofk/4ILf9YBBG9MM52CgafGIP?= =?utf-8?q?DKDx5ZKeK75zn5RDBQ3mvvJcLm0pmnERdgk6n0kKM8HX5ONHNrb782FGZ3BfXnCQc?= =?utf-8?q?hbtuHrkdUOr6gag7Qe/AvtE/Cgud2p0oGMMRlqShbFVSk63OLTeKiaiFeFB57cnNT?= =?utf-8?q?krCQkBLHsFz1injmz2L5B4ubhKNE7xrlIQvSYicyLVu5OF2fgrsdu2d/hxmKrbs1s?= =?utf-8?q?gkJocsA4TELd8daQPTvilJGQXUt5rymcL5nc4bhXLawF/acKd2hqpLPhPueFObunx?= =?utf-8?q?1+HD4o6ljKK/e8rtQqqrXLBC4A1Hkdn5wbaUmnYN6D42cc+NBpLxMjmxNXaBZi1es?= =?utf-8?q?bU3FDngE2cYu0VTlySJpitzO12MHuJ9o5yxId0rjq1bXVSQXGBiu/5QqhthDPDxV0?= =?utf-8?q?evjuydlTwZeqLloQPfrs1q6d8bVuzN6PDjs0klFQa5loalXafhmsShGRrXn48UVHJ?= =?utf-8?q?UfnG2LPx5OU7ThkyNkdSLOtdBsfFfg+ovhxCiKiuDS2He7GRWt5njfrSvPp6oZBhH?= =?utf-8?q?2mpSufGMYzyq/6d/kyrcyiEN2Rpwv4Sql3mS6DSZrUHixCbcY3b5RSGHskIlX/9Xg?= =?utf-8?q?S+nXmK+AIZV5g6X1x2SgWpSt4l5sFS2TbzjVh6LovMl7JmtaBRQnlPfdMK9dmVcDa?= =?utf-8?q?vOrWcfDK0sTsDMLLNT1zV13wAxLOHfFCeioHT/FyL0NZX6GiCSoxzK9OX7NBxfMRV?= =?utf-8?q?hhSW41yX7msnpjZI5tqBd2EVBMx4hVvy8Zf0bW9pwOwEqLbK8r3P5PrsKsXaYPHjV?= =?utf-8?q?GQeSywtkrRl?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 12:38:48.6459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41542954-b88a-4e5f-388c-08dccc155bdb 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=[SATLEXMB03.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: LV2PR12MB5943 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 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 Tue Sep 3 12:38: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: 13788646 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) (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 F1A911B12F0 for ; Tue, 3 Sep 2024 12:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367138; cv=fail; b=mxKoBBg+9MjUldAERDozsGRSglepVcsE4+NNc3CfI0qVNUZ4+acsnDAB7F1hmtyNvNzmEtOf6pvjAGtK4Ts3CgG4P7GUFl6tudqs0xBW97NqbwbxRy8aLZd23OChEW5RvWisdGUxbnWhOnPe58r5BnTpDAl+DftrHxo2sJVPAJc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367138; c=relaxed/simple; bh=qvdmhoZbkZ9MIHwM9eP40DAREQeem5tH7XoYNWnP4IE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SKFBeYzr3M2SM40RetcWLmcVRhq84ZhNowd7oPnUKne3rDiGv4uk9aPYp4uq4NGDbiWOjWEVZgmmq+YMTp+z4tle1V3mtZUGcRsqoKDuyU+QqjmNEiOrOZ3/vjall23NWQi/e+ivUHLnzSJOgd+ai8Tzdk0A7ezZ3b1e/L3y/84= 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=IglE+Btf; arc=fail smtp.client-ip=40.107.92.63 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="IglE+Btf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iVSYhJcdkRzEcgwLdhLgcNi7NfN+LHV+aqWdTRQg6GxW6jSywufHmtQSO0A4FWKMnt0S3f4qAE3snm7xNaYeV7yIqQ3LBF6ot7/flQTNuLzgdNRe3CDEqC8/KuaSllNn1NIhHe6pMPwcelYGI+DXAWF36MoelfwtjGZr5UG2Illcazq+AOwLkG2m2zpvaQNbw6gchcmZ9TohKVH+ygG3hkOxUI95CJUIFAPtTcpxYiBPUPOawS5iMVUNSQ2ag5QMLJhYF9cliJaWFhB2lKggx7gqFjMAv6l2B328sv4Xl3Mg5awOMo9jTCFr7MOPxENyulBRnhCCdPwYabyt8k25Pw== 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=H3c537tLL9+s+2ZuZzRSIfnwbmdJQE5PvFtAMYfC9jU=; b=m6cgPpTU6RviMYWW7s7cGivEoTPFAnl52V67Mco4Z8frlR34poAiBW+4J58Z6kY9sT3ciYWBMIqIzPlsdcssYbj5NupVlULiAYnDmkjULajxlKDjxr+/KrunOJ4vrVMoj6Ae/XTFXvzMebncUUBEtrtoq0q2HediodU3X4ZkHNncEMCXNpZeFDMCUA88929qoGSTaf9HEL1K6vL8bO70EBpJlJM300p4yMOpSz+yk2N/vLha6Fr9OQJcd1KN3GMbmIEMaBhDJXzsVqBPmHk3XKWW1CXZnZ3UjqqNGHencCDpxzZyhDFNa/Hpz3MWhqAdVh+3X/IWuL6GswrgE9NHSQ== 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=H3c537tLL9+s+2ZuZzRSIfnwbmdJQE5PvFtAMYfC9jU=; b=IglE+BtfR9nRDOkLv00BrkK/rUdrjgkSxdoCb2SwA7ss1aeZzcpOiA/gAvHvKtn8eEjh1jnt9scgcka2JtEwWzZXRmNTtOPu7JxcEOeW+GWV7hmuq/Ow198fNvSN7slXcjo8+xT6fE2ViIliJQRl/HRfmYN9c5wKsJvy9UUqhRM= Received: from BN9PR03CA0342.namprd03.prod.outlook.com (2603:10b6:408:f6::17) by PH7PR12MB7967.namprd12.prod.outlook.com (2603:10b6:510:273::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 12:38:51 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:f6:cafe::53) by BN9PR03CA0342.outlook.office365.com (2603:10b6:408:f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:38:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:38:51 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:38:48 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 02/10] platform/x86/amd/hsmp: Create wrapper function init_acpi() Date: Tue, 3 Sep 2024 12:38:22 +0000 Message-ID: <20240903123830.2717196-2-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|PH7PR12MB7967:EE_ X-MS-Office365-Filtering-Correlation-Id: da51ec18-2c62-4c17-2bfc-08dccc155d43 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: =?utf-8?q?LRWuwmaO3szrLChlrZv6DSti5hoAZY5?= =?utf-8?q?l1YpnE8FgNLW8m8EqUYXGApef0QXNf4ZIFnqSn2nL5j6hb9gY7KSJKPbefO7WOc+3?= =?utf-8?q?HwPOf//7rwctC61dDzzLgYPtyioBrHOawv5aKoj6RmGAaHXXECEgYSxM0LoGyqdk9?= =?utf-8?q?GZrDpwgT/RG+92i+3C+oMeWJBU7MMvC/rssc8IHItwS0QxQLtA70tFPyyznYy/7w0?= =?utf-8?q?fbJsVKHNyNz1qwzeUbeeHah1pTX+1MGiWayL59V1TElCM+4IrIoU6O8Bvb0hL1yVt?= =?utf-8?q?uKu2TNJX9Y6WJu+GK+3syWyPESseB7ZqSe5VKLOInlCgL86faonLsshg7hWl+of3e?= =?utf-8?q?PGaGiZ5U/W5zEwbS5ul5NpDuEnFm17X4oHpsOZT3NpowUyU5fyY1btmpZQurTNXhD?= =?utf-8?q?DJAZ9Z3qw6piDsQA/gTUfqo8dIWYT0hNLgFt6odQ7i8efPZgaBrI/IQA9AokjoOzE?= =?utf-8?q?C8OE5bFEkPI/JV2q7F20L05RPcqzuaI0j8xDRemKxwF2HKBFSpZAV+nZ2y1ueeC66?= =?utf-8?q?HZ8sKMh1e8lP1CAa3DipVMIo0MSjdcSEBYBhlviJSGjnnNrM92KSE1yNOJr4DzHSt?= =?utf-8?q?GvDgzFYrq0QHkSbBkkkUg4VvdZQIevIdE4eTI83/CxnOOH12IQ2xQTTHsK80bcgC3?= =?utf-8?q?VDwe75ra9PwX15a2FLa28mDX80p2Gdtgxw+sOHT75+LOKRS/oyoI6goOa4YLHYVti?= =?utf-8?q?h95HXNhRBorpeiCqUoeKuNo0m7PVw8FtOaR0mcdDUFWE9SPJvhrj19+30vWfc0Omv?= =?utf-8?q?gDMD7YjoeBK/ofcYeEpGCAdjuZ94vCzclszWfyKI7V8HERc0p7hFW37/hGor0rmAV?= =?utf-8?q?d7PHM9k+J86YzpfYUDk4Nt2FDeAgam9EJizR8v+w9b3OGL4PLzG+3GmoCocJOMndW?= =?utf-8?q?GwsgUBZEY5kZoKRNjMocWOFQ8/2JYuHIC+Y4DckHmezxPDcf9lkCdeEbqiNslpKca?= =?utf-8?q?7nEpKpVt7cncyyMKPz1OTUomQnk/pCEVE2uslAGNCYqGTLizB/PLmmsOv8oSSjN4k?= =?utf-8?q?jKEXaJ7du+quy1QXDWexFnBTajg8TFwT+eHaVG51B4FpyhFCZaGHtcpaQlAElksM0?= =?utf-8?q?jSEOX2eaah7OuqjtkL3OPScKsMVePEAqAAEHdcgNaJqD+tmnzPIaTL7zIbHnNKeKF?= =?utf-8?q?pW0D41qV7zf40cJeQCDOikjhRU8c2mzj4H5ZeL9Ba9aR2Ny2FCJnQ83dD6CY42tU4?= =?utf-8?q?jujsgqZ1Qu4mq+OD3MMt6oyptfLIeqLjSEATjd8v6GbNBOU5Vhmh8aXIbDkzP/kMJ?= =?utf-8?q?VOOKitwasmmnSf75XBdPuq48wHtdJHlQfy5c3z9efYW/zy8EYCuWaPYWh+WAyskFT?= =?utf-8?q?XGtkvUdUElB5oDpDfEj5L/oGVOwByJywM5K+LgRgw3MMcTKRzns2kJNnFlwctQ4ha?= =?utf-8?q?hItSop6Q7VY?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.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: 03 Sep 2024 12:38:51.0049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da51ec18-2c62-4c17-2bfc-08dccc155d43 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=[SATLEXMB03.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: PH7PR12MB7967 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 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 Tue Sep 3 12:38: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: 13788647 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 6A6C71AD270 for ; Tue, 3 Sep 2024 12:38:57 +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=1725367141; cv=fail; b=IcBgE0o/cJC1gjPyurzJ65/nkx22nOcFbLVCEBjbd1XQuBQ66DWTFSKzd8hPIVjkWgqTJjsK3cdijYuRCXe7JSsrxzE1QrhE96adICyU8Nho6+dj2iyzaqGLEwD7YTuyazg520wI4GPmkkRFhZ85Ho8hbKufWUbvUcNLSRXFYJw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367141; c=relaxed/simple; bh=LA3n5GRzVRaXPvjCXYLjgxRWr5+Ql1x4rgL1HHq6Xis=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RzuApEHacJ1t/vSe+IUTh5R7uB6PhzKPsvT683qfk/XXOUmw8zPmuS3jcI4ZEi7r/vSRj6d0dkYMuuKSCl9WNbNisi2VaA+Nzzvzi2yPdqBjImIAIX2tzjIUq9owJa8szeclZ/3m5qK/uifch2r9LysMVAHhg+VpS4Lj0SvlLbo= 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=2bjkVrAz; 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="2bjkVrAz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZowYECT2eC408rvypByHdVBZ/XgW3YDlMw4WkoKgu9jCjBKkXvzF7RvJ4sBktke6DG0eVSHkHBuyxB+JjGHlqlqN8/AGafCkclS0Ug++k7YdH7yI8L/uBS44iohcUmxM/hkl2FhdGLf+jGnAZjPcyXnGe6vFnKMKbrRJWtzgcGiO3jWw+OhmsHOuLewMc+PpEk+UrKnx2QCBSWpIvY4wsoJTy9AHSuAsyLM2NBtTIFEVIHK5dl/YIsggq7e67o7u+EtVL+Bb+4oUmYtcVTqlGa5d6NyLMrqGzQ93uD04ohTa8M/K+6lHoNP9+s/W+IUwRTRuMi2wsGvzilTW+QgVpw== 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=HHeTmT1v0JQCzb+Cu24x1njdeIrWyIzEJ2Jo/lFtIkE=; b=l15GFNq+n1wSOEa040CSDRxq17JI2Cs7MhrhL2Rn+HFsSQFNRgYTFs7bD1Paad1+pc8KXlUAFuYoH9Bsvpsd2r/XMxpg1pmEh7WxGFasoRPwfQiJog6NId9F4yn5jUADW8DoeNHxzT0120ApTDoUCHSN7j2zT+NHxoMppzfTUU9BsELcQFm6u+Flzs0QWdVL1sJN9mb1sWBs5GT+RMgxHxyHvCfm+vgF8ZUZfBSB03l1K2ynC2Z4WBrywS2XEazgNvfucs1peU5tIz2YJxr1boQHTD269qIlSMOrxZ2ZC53lLQZAz39L58ZVs9fSFtw+xT4TI6tiJx28Kxmu/Jp/oA== 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=HHeTmT1v0JQCzb+Cu24x1njdeIrWyIzEJ2Jo/lFtIkE=; b=2bjkVrAzkZrFRtGV+F2PAOrATrAr5kK4e3c0CIZzUwd/n0sQjVsHJ7JNqDE0X4VQdb8Xcg2X9oZzQjcysyCMLIt0ZfPrZ7LnNQ5NJoQcJNBubWQMzU3cuS3hXua9BxmWN+pEks9mBavTZTPC42O6/KJaVilWQM+3Up5+OSwRVVs= Received: from BN9PR03CA0874.namprd03.prod.outlook.com (2603:10b6:408:13c::9) by SA1PR12MB6752.namprd12.prod.outlook.com (2603:10b6:806:259::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 12:38:53 +0000 Received: from BL02EPF0002992D.namprd02.prod.outlook.com (2603:10b6:408:13c:cafe::1a) by BN9PR03CA0874.outlook.office365.com (2603:10b6:408:13c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:38:53 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:38:53 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:38:50 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 03/10] platform/x86/amd/hsmp: Convert amd_hsmp_rdwr() to a function pointer Date: Tue, 3 Sep 2024 12:38:23 +0000 Message-ID: <20240903123830.2717196-3-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992D:EE_|SA1PR12MB6752:EE_ X-MS-Office365-Filtering-Correlation-Id: 3890eb8b-8d62-40b6-b841-08dccc155e82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?cJB5XzOlbF/arizIvJKWaczeFvSUpNF?= =?utf-8?q?CT3ewKyVYulQVMsoBuFAfP4Lv4fTn1ujqmHBu7iUJHgJgRn4jLwj4xWdDY2Ibe53h?= =?utf-8?q?kI1lLWmWI/jSOTSM9l0IbEAa0Tb57euYd1Y4aFrPrjefX6Z5++5N5i/YmT142R0BU?= =?utf-8?q?/tAS8/XAZfBDNfYirUk5lAlWLEfrr3afqCDvp7RxyleS+emNlWlE298tWEqJMwsfx?= =?utf-8?q?Hif44RNhpMQFx5y0689thwXDhpSC+OLHsoYiRC8iOoRiGf0Qy24tZ5ntr2ZcAo8xm?= =?utf-8?q?m+EmaHkGeoLFmQ+ExEygJS9Gi3iq1y88AIM6lC2x1hcWmFNxXte8YcaZgkVQY+axj?= =?utf-8?q?FxqVQY0QVSiFz9kezAjyfdXT5CfG89JPdrbcH1Bh4YuRiVKNgCdcTlte2z8PzkHRM?= =?utf-8?q?pbHjkr8mNDIFEPpaoYjcL6P1lubldlNiKZXGFdyB0K2GqfgaP4VPBV2nHVbRsodRn?= =?utf-8?q?1Mny719nLgE4FclZX7CKT009gSf+zpP2had+kZqV/L7YJjwCWZi602K/FLzQyNF17?= =?utf-8?q?3/yxir9hnE/LUfHF/me7YraBNGEORfiERk9NMUBC0OekmC7TQzRfss0D1i6r8G6NC?= =?utf-8?q?e79LE2BXL6xTtA7D/VnmdY/daRHXlopMIuK1as4MV0T5BGyFp0oq98kDH8FLaCwfN?= =?utf-8?q?w3wduFEomxaeHpMjwa5eXY8UE12s9tKY5+xzEGSdOUMr1vPTfiDTQcD4lpNYDD4e9?= =?utf-8?q?4E1B1katprfmeDYIU8mPU878sPFl46mGxTYBzu5PJRO6VhaOUr4CEMnAKn/KhogA9?= =?utf-8?q?2LEGIwuBEUOYkIiXR8ICfrNpBpzd8Dv6v6MbVl7p6UjqW/Fl82O3GuE4R5ALhoz2A?= =?utf-8?q?ySaevAvLIUYnUZRF5Pi6KMGFGCABvCumhhLTmHghjqy++LrAJQbGkVFe5g9omZsEg?= =?utf-8?q?DIIgA4QEAMl8ALUdHiApYT+wxMB2qIb2yE9tf30riujgTsTZ07FVZQwHz0aVVzEQo?= =?utf-8?q?evdvC2Joiam3pwOHyCjOUL/x8bTfr9DqBqfGCIGpKA6q+49luvrmFMPUafP+QVQGb?= =?utf-8?q?wcPALe5qE1i826Qiu02ZY47M/wciRHXud77Q7OtNN9b9mUJ9ONCHK0+u6j4EkqDpW?= =?utf-8?q?86d4p4yKiaW8JIcNPbGP5SgxllfUuFA7ud2Iytig3IGspxAQKG7WKQK2Pksk+UKv7?= =?utf-8?q?zabJbFlgMIF9eDS30lJrxgTgTGhAdTCvQNSNeJPwa/Fh04Fhf2Qi1JnwxmOH3punc?= =?utf-8?q?ZK5lTBRK+v/7Wj8mt+uNGf7h7Wcd9FWJZmH4IhN4vnOZCFSfsuMb2eDj7axVnaNW0?= =?utf-8?q?TbYCrjI7qZWUDaJ46TdDfPmjevxoAdujUcyRYE+S/5zPuhy/A22sZ/jk3vjcOFsiF?= =?utf-8?q?ipI/1CkwOVvmUqmfJFm9yjF8XAXU7rRniBs3pq+oJy1jm10k9cxm8ZgEBqibYk7G1?= =?utf-8?q?V0PUg3z84G5?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 12:38:53.1147 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3890eb8b-8d62-40b6-b841-08dccc155e82 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=[SATLEXMB03.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: SA1PR12MB6752 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 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 Tue Sep 3 12:38: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: 13788648 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EFF01C986E for ; Tue, 3 Sep 2024 12:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367144; cv=fail; b=WZgtKzN7wvynq+nmqfWjzDoY7bd+GsNiJdVY4Dwuc1EWUJDm+JgKcV9THBbrihkUGLQLkrlbk4bg+6z6D6Whul9Fnge5HAaRBBfQVy49uJw+vD6mrz5Hogdsxp2yUvZBrguHObGJHIAAYMgYWh9BRA0whc7uoPa8rRUlpV8Ibeo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367144; c=relaxed/simple; bh=lR7XPT7N57IPPS+U+p24Kx1/h5BUp02uVCSdl0VBoKs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HmMCsUYjCDzmApq8j7YB0Fssc2jYJFvaJ7r4oANzZ2LW9guaczOCa/6e92ii4uy4dxvRDxXsCyI//Ir864eJwMhjKoUqZyUodvdK2YG8sb5/jMSWQ1v1NTs3NSVDEa45n1r6vIC3UDwnzIBZ42h1dlpcCsVIuVkbyO8FD8t1vks= 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=gqOMn+Ii; arc=fail smtp.client-ip=40.107.92.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gqOMn+Ii" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s4RLAev9d7VoULN4qOrBwJuXZqVPvM5dOjOnuU6n6DSI7VSnfe69YoFU/5ZD+DwCrasu6X7s0WEvy5/rsTUkfakFMs65aLJKfczL/xtTUDivtyCAT7I0n15XNJ3xB/WLldcUo2sH7hwz0PKHLv+5zKDjOD6cWMcZK+Ifx0my/gXed87jHzuXtNHincqtWKJ0e7NK502p4AVDbLCZ8caAVCF/YlJ/Gry5INZEW9itoxYlFxEAAk13MbugHziTH9arPCNba+StmeEkULu4DvrwfVFOE7DlQuk6SQ4SlBJLstJ42qc0oIWMkjplVI/vPnYSxKg7X5u58B7TweZj5Y2gNw== 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=Ebfy6iU8k/3HRmeVnhf1pRHfN+Od5BeB49yVLcdNOYw=; b=VdlVDBD26OGJNaMbaHyk5ebZgiVFp7MlSJJBHnr5qrJNk5yQgO6ND8FkpI507YcVdXpIY1E7F/OfHvGqx51cGuKtZDQod67rDa2AIP2eUZobPgAc+LF+nI1pzl+ZEA9KXDqaWSv2ovuzdPX36SznK5RWng+xMmcrIe6mDZwR9paIohRUFS0S31AQy7JhQhHB8xaloo4KdEbXlSnQqZQiZlpp1cspKlHq0l6za3mTDHpdG1sQH1z53vdK9aPd0XrPIfdChJQp0WuHthTomDoPVtJ2jiP9udTM3XH3/1DjmcSKTwOoW0ndVTEEwl9MTv8MhyImVICLtBeFWoHfsSHGPw== 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=Ebfy6iU8k/3HRmeVnhf1pRHfN+Od5BeB49yVLcdNOYw=; b=gqOMn+Iiz02p+2VSlELldhcwNKe5C2Ot0zs56ZlrhjLmDbPNAhGd5GNWzSL2W8YutdzJFNY6VEQheD5qfy4WKjtiY2dJ8Nr+aw0pKWHCU+r+aUXZs0PCrA71Zp+LWGEU1b6jtPt1js+HOXmskSxPlT8RAjUlfo9US9DOyiVqz30= Received: from BLAP220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::7) by SJ2PR12MB8874.namprd12.prod.outlook.com (2603:10b6:a03:540::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 12:38:56 +0000 Received: from BL02EPF00029929.namprd02.prod.outlook.com (2603:10b6:208:32c:cafe::50) by BLAP220CA0002.outlook.office365.com (2603:10b6:208:32c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:38: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF00029929.mail.protection.outlook.com (10.167.249.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:38:55 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:38:52 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 04/10] platform/x86/amd/hsmp: Move structure and macros to header file Date: Tue, 3 Sep 2024 12:38:24 +0000 Message-ID: <20240903123830.2717196-4-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029929:EE_|SJ2PR12MB8874:EE_ X-MS-Office365-Filtering-Correlation-Id: f7c9fc19-8bf1-41b4-989f-08dccc156028 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?MC/8tMWXG3uXCgVF2J6FklbCFYQbFJ/?= =?utf-8?q?Rq/THTJ2QvIJACIljotJZUVqmE1UWw/bHuIQH9u5g3+m3ZO3jfaXbqkHH8dE+ccB6?= =?utf-8?q?4QiAvsAxwSgCdzfguMvzQngnVhG6oM7aouIHWzBUXU2jNKhEKMSNX5P4hVlU3FYd5?= =?utf-8?q?eiSsa/hLoS6WebHsr4TA+8fF9K5Vc9/B+ldvyRxPMI2M/EkODsybjSq4O6i+zunD3?= =?utf-8?q?rfY8gmpghmKyobIumBTvZ1+973M6L9wMDdBputS18ml34ivYsRksdZbMVhDDsxmpV?= =?utf-8?q?NE0Lq6oOQ/jQeY0qzcCp9cTsRIqjuF7ClVatVl/LFz/dcOix2vezOxxOTAFws6V3g?= =?utf-8?q?Pcynz+Ogu6sGTkDPmcKd0Hpry1HMwd+pIfsR07qUqOntcs/RIvuzOlpVU+ErqbjRi?= =?utf-8?q?Jjvqkcp91NWOgsdQkNnxUktbRBOPPwchwNEwKzOcH+p+BsJ9bmtqT5ThtsajyckSP?= =?utf-8?q?mQd0bQaZycBccfZu5DYB7n7AMT4C7ahh244a7a9jG586BV/2dTue6grtF/dwc42El?= =?utf-8?q?jZ13nfZqvZGIKT79ZAbAih/CwgokWQDDAl3OmtD89ZXhlfOG9KD0mtQUqMD/Le4gY?= =?utf-8?q?Ewj0se0/JOi4mMb7ixMuboS34r7SmmwEzz3VAMJ+8G7i5Uq497knRpo/CjVuN/DbS?= =?utf-8?q?VqLK1P84LOlnuVX2foPssclzRZoURxDy+N6jrqj5m1joUDdzJ1IEMWNql4ar1MWOE?= =?utf-8?q?rBEwh+3fTlxvqKf73PVh2YMsj/BbxDRYAqNpEdwJrGBcAYwZaJpCC+m+dHmsU1Whr?= =?utf-8?q?SRvfhAqPyjIfD+1GkgY2WK+mY6m5VVS+Ug530Ptuj+139The88542G9tfBk7cES7p?= =?utf-8?q?fWOqKxM0B3+8DP7L1Vf9mXbH6ma0tdtB1wrZD2UWr8q9KZwzf9VpU0BGKP/b6MuX8?= =?utf-8?q?+fhyNb0P3Nqb32XPC4BUWmtPcgLvfb0Sn8nnpanrbIYoEbS8BXA+ijFwAbciTsNl2?= =?utf-8?q?jUyfmxT1ov47HZDZDWOvd2chMD0eVBAYrhrg47ggqhjCBBwwdO+ghEOQyBHF6ij9c?= =?utf-8?q?MBX6/S22CP3ppVZBJFRPaR7G0jPhS4fiMP6xXK2lCelvRp2va5A9vTfqBAt9exmJE?= =?utf-8?q?Pht1phrJ+70+lMRZhfWSXWngGTpeh0YTX8K1Qz4gQ5tiCBe9CvrSW7TB9drmKnj1t?= =?utf-8?q?lhM/D6yK4fEWm6uLxs45MJhRseXty061ZKCju9uNReX1WPUsm72LpXpF0RyoZvR+E?= =?utf-8?q?VscSm+5ZpWTiRogddRp2MEMckPvN9INMZBirwv92TjSvjKqqe6XGYhAa0D4HTcuHm?= =?utf-8?q?/l9JGzksD3memqkm2AuygSWHIbY5f5Wpg70pbkS1khBIiCrfkLRizeyWSZXmTZ1Bv?= =?utf-8?q?aGCkNUtWWNkBh8QE+6uMPASl8w2vNsBuTPQtYZtzvriL0yk2vMikpFwLLZBWZZzhL?= =?utf-8?q?FJbm+r0DPY9?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 12:38:55.8483 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7c9fc19-8bf1-41b4-989f-08dccc156028 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00029929.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8874 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 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 Tue Sep 3 12:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13788650 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2043.outbound.protection.outlook.com [40.107.237.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 AE0361D0974 for ; Tue, 3 Sep 2024 12:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367148; cv=fail; b=dcdO6/mdMcCjry+dgPj/W/4uYiC2ioUSW/qyQlMi4SOHftT/Thp8jBFxhUjA7ETqhoR4coMpAM2fdlOtc1kqmSMZOR6gnjUqRrlLhUWskiNT/kZClsezW1NVCWHWWpUPw5S+rBY2vd/KFzcQ2siwk94O/wuMSJhWjbO28cR7VPM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367148; c=relaxed/simple; bh=31d16paXPTGy/Bkgbz5vT0gtX2PvlOGJQWw1VbBbrFg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OU8r/CkRq8CpKRuXNKw72sJvHvtvFyzrD8sGkTzkhxSeFaLwgYI21XVLlPNa76+oVuWswPSkGNEhfqC8GR901V74YHhW1CQ7zyYtfzgvz4wsOFmgSw2Mo70nTmnTWXDDefgWuiswepE/06L5hxw7XNUqWYUFOyd2+SjTD3mDC94= 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=Tf1OIJhy; arc=fail smtp.client-ip=40.107.237.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="Tf1OIJhy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Da2iqmH3obX81xmN75lTMeYhS/2AeoAbnn2gfeB6oahH9Zw/1cKp+tVNvvN9//RpXcUny6ABxWhDMo+Bao3u7itqQlj0sTmebC1fmtOU/6XnchZ3ncu40S65fPFQtQxyzkZL8HAMU+5Cfd7rUKfwbDeY/CIsR8ZtVkfAfk0toBdbE/qCtSWXwiScTxc1/JU6nCbvMWXU5Kt8rHMz//aIRvlaYOxXAgYpjgf5KwMDFkkfHZL7b1tqkSIGA/qibjLDis+EK4gKgFqA9ioZ1ouDM1zy83Zy3cG5COeeRJzIAkfQFhIu9qERtgpvK8QyIoTToCEWZapQfBqIjdufOPGVEQ== 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=xkBId9d+NPXnLOiM7mAvKPMSu0QgJSCX/rm78cfz4P0=; b=WL4KPA0NcCUg7LUgE3qOherLABOewF67+4BZ87RwNRWhMsn29Lb4V4fKcrUvMV9mDxhdWI+V65ptE7NOR3DLaHsowFOYTY3pYlHeTIe+elgKnDvumWXHdlbVKubCq4rXXCUqkgNmYfuUcQxOjiwwLHoQpk/lMgZqLChZIDKH99OX1XmwCGldU6y9NoFvEqXIVqZzlsWHmC4eetTVLQEx1ov2JxJIW33NMeI7pssA18cDtefuscC1LRJxEZn2/5MQYsLQRjKBJ08b/E1m+YYTohOL9UjPbcBhln57zalC26YVmZnw4UEKf1ztlhD8ayhaoKWu2bsTvciUp2ShXBY+3Q== 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=xkBId9d+NPXnLOiM7mAvKPMSu0QgJSCX/rm78cfz4P0=; b=Tf1OIJhy+UwmnbeifgrZdeCnZFNIPZo1HNBr/I3PDFZ5edn3ZXB9fQthCD8uMZc2WvOc2wag9sj9DojP5VtfMoyo8VddLLmutng9drst6++jgVXSLaot0gUGGvsu/tvdVOHVN1MQbkweFS6l3L91XVBdN1kX0mfR3gIBfmfeUyE= Received: from BLAP220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::22) by CH3PR12MB8877.namprd12.prod.outlook.com (2603:10b6:610:170::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Tue, 3 Sep 2024 12:38:58 +0000 Received: from BL02EPF00029929.namprd02.prod.outlook.com (2603:10b6:208:32c:cafe::29) by BLAP220CA0017.outlook.office365.com (2603:10b6:208:32c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:38: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF00029929.mail.protection.outlook.com (10.167.249.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:38:58 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:38:55 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 05/10] platform/x86/amd/hsmp: Move platform device specific code to plat.c Date: Tue, 3 Sep 2024 12:38:25 +0000 Message-ID: <20240903123830.2717196-5-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029929:EE_|CH3PR12MB8877:EE_ X-MS-Office365-Filtering-Correlation-Id: 950d6ebe-bb23-4998-107a-08dccc1561a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?mZwg4kpzdPSNcRvxH3v07ywUI66ultq?= =?utf-8?q?IaZQ5dUQ4lf2S0FFU6TBlNAs+fqmZ8VaXx9z8R/q91gx7nDDp9dptgtktDd2dkdcT?= =?utf-8?q?ARsNfMbGcDRFT3BfCBeoo2RUwlmJDqqPdBUI13U6V/SOdjkVm6QxHLCoDEVAuMt1M?= =?utf-8?q?VwK9XIMX7s3xohlY/i4n4ZHsW0Rn9a+i0HD52R5zEXUcQIyLIrkwc4Fy/tVxILpon?= =?utf-8?q?ky/qcgdKW4qu064qqAmovS3dc59ZA8XFErcLIxzLeH315vp1thFKQaA0iDoSeqz55?= =?utf-8?q?v7i5WYeg6d2kYUXh2/vEUT3gQRzWTDp3pQ7gdRgvqFe5PxM3znob+18u9ifxKJnvQ?= =?utf-8?q?VsFrlDh13JFKzzceKuXUJf+keWusQhR3ldyYkuwRmId5fSt0Ul3jAcdd0e0Pxt2xs?= =?utf-8?q?wSQKAdp26kQWwEDpYdj8jrtHHkrUyQW5BHwMvub9juSvaKBChHtoA8K5E8/Ph3tcm?= =?utf-8?q?P56guf6OjIlM4Mp6Sl7sDf+xTkboTPQuhdXJhzYuxwOJpV9hdbzDb36Rog7OBIGat?= =?utf-8?q?1a6MACLLZ+TyhalKniTtbmSS2k57q/6dyH+0Ojv/eryR1UH1R54qnwveVDYcm1WEY?= =?utf-8?q?VtyQgwmkaT72EyelGVaLchebWKcMROslhayJ2v7Kdwhg5qEUO6NukGGvYB2/5o1Zk?= =?utf-8?q?joDyf/4qKuVnLeYJDLNq/N66lV6QxQ+2OScMuRRW/I2spalNBck4skk1zq4I3gl+t?= =?utf-8?q?nUeTqJ4rgJp3d6TsJHndGjb0LEgQthqAmgRb6BWk6ztVwzCNiJ/AtelwuByvib9tr?= =?utf-8?q?B8eKbHRQeGI9A8HcF4x6bx0WqwnT4U2kKR36JelTC63OaSQtXwy94/8EmPioK1Em4?= =?utf-8?q?mlxRNwfVb+H22fPjNu+w0dNJ0AYO1uwKO0/HDHcrlat+YfPcDc4ePaDvP3IF65a4z?= =?utf-8?q?dhPq/gR/MhgDPRfrU2Qvjc+w7Fe5lBFu9nVuCcmSTJAcJ/hLau0SW6VzBwkS6vOuh?= =?utf-8?q?/m/naMUB610rI6ARUoxpdNpP+9o+z5eiMJZqKp+7MC0E6f/NZOhR+j1Qb8r2SC/v2?= =?utf-8?q?Gg/GC89H/my/zwwX64PsW+5pq0UxqeMgMrd2kU1WQcUnrsTEnHriNJqlmDAZzErY5?= =?utf-8?q?EUyOOzji5xUWNjnXuriPRH0mDd03Ets3/FhGYbVMrOhFUukJWk9UVr+yhSfXOvYF1?= =?utf-8?q?NDv+uHNXkUZzfef/KssgjoZK53SPRapdg7oLetwKq6WUt1HGaIf140k7o19/srcYo?= =?utf-8?q?SjY85LSb420ElHy1uKPHHxZNml9BDF/wdtgGwQsuhw34FxZ+uAn3uRh8J6yRMb0Ve?= =?utf-8?q?Vc0uAxO0/Z49qeH2xGoFMHVXFw75HkjZySb8cRiI2Na9x2g5J24yjGrSbp4pStOub?= =?utf-8?q?NnC1MScvF1k1KvhtxQ7hO+qZrVjv0Ucu8vEDs7QvtOb+3TAxUxOs8n3r9MROwIzvF?= =?utf-8?q?bE/RcC9vTEm?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 12:38:58.3170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 950d6ebe-bb23-4998-107a-08dccc1561a6 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00029929.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8877 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 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 Tue Sep 3 12:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13788649 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) (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 247961D0965 for ; Tue, 3 Sep 2024 12:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367148; cv=fail; b=rZfbF0btmfR6BEshGhbrQGGQQ1yumlv9zFFEewKHmwtAU6LqglIfhO9i7TgyxiapjXM3MiLwsR9hoAj18YArWGlGtSkARD73uC2tLFm4LLwfSYJmyThq3FrFU0K8lp2ndgs2KFGdo9iqr39PAgTQOlRsjptSW/C2+IwBU4w/pBk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367148; c=relaxed/simple; bh=L6VMRVeCQnKT/cz9wG06bd4tqOemZR5OGSJ55hvhtz0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WS6GChIdqizGIzxn7IGVM8AjeMJEfmJAyTPmFmQU2lZij5QwKTiyK24+ntPD1GF9+eNizLSMsMw2Xetw7e0+FoQ61okpvYmK3pkO0gAY7oZ0OU64pA7HOAfqnjEm3l3LAbvSDLZjdBs22HPHyKHErYQiQScYXc/zmEu9H07HWog= 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=AbyTlmH3; arc=fail smtp.client-ip=40.107.244.87 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="AbyTlmH3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oNAmMsHljPrPCVSeWVdx+zYyywihe4mNY0fmz4hnHnsFib9fU9EkpcO3BLAzu9kubKILo1GN5UgvHJvSUr1WZ/hOpzoRZUxHntUh1zITgJsdehtwJU7HpmepBSW5h+1UIJsfwlwjAPLOqaGMiGcGxQbpS3hUMaEgX+gQ2Da91jEKyCjsB03cISCd7yL6+Q0xzGskaqwKBKynnOjzh+jxuDiW8i8Arr8Au2Njgh+60kOBQULHj+jeWALm56ZN3cEjQAOTLJHoGRV8qjtWhh+CYAUdq2q3W+YrLs1pXVqRviRxDjTJnEBd3S0fBD6rjlqC1F1iWq/YBJuFPlRCzmZOkQ== 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=7JbuVOL3b1fjAb0U6FQPG8Ydv9Z4TUWAnkzegGb5bOM=; b=cSTGMaz+rpFHJ3lVgwuf+lJhv1CK53eRuh1vkk8UplatKAnUClZKGxIcslvIs1UMMVppw+Wm4D8EcffqG+kra1teFR2SrfNWb3N2qvWmiKw8RqJqB6tpJFNh4MdzNXpA8bvN9y7IlcC0Eo9Aq3CStgfZOJUpnCBCj/cFUtbOSbpGLINM69+iPMOrFDeAIfpgeaTjWsX9sV62CRqAFg6hL8NP425/BGcIMY25pgH3rgsGRkBdb/V/+XbAfIZmFOV8MFSEiH1+Q2xjoCXO7YCYKxgSz9GYEeshC7jRDnGN6aSX59UqB/ZyVy1xH6+BYZJSwd1IlGvnRBBjR7quh8YCZg== 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=7JbuVOL3b1fjAb0U6FQPG8Ydv9Z4TUWAnkzegGb5bOM=; b=AbyTlmH3xqk+wGw5CCcyE6lg8Qqrmw2T6hfKyplK2JAk3/tOu4T7vMf8x69A9CyCnUzkLlAQNZEw9Lo5wBiUeRkSqWwLv3wwWQSeulav2mDPN9adTrljYBWRWLYXt7FYlcMJ2jsfD+I/GiM9doWCQ54e/FYzk8pl6R+R1n7rLKU= Received: from BN9PR03CA0358.namprd03.prod.outlook.com (2603:10b6:408:f6::33) by CH3PR12MB9454.namprd12.prod.outlook.com (2603:10b6:610:1c7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 12:39:00 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:f6:cafe::10) by BN9PR03CA0358.outlook.office365.com (2603:10b6:408:f6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:39: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:39:00 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:38:58 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 06/10] platform/x86/amd/hsmp: Move ACPI code to acpi.c Date: Tue, 3 Sep 2024 12:38:26 +0000 Message-ID: <20240903123830.2717196-6-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|CH3PR12MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 39334aa9-0dd5-41fd-fe91-08dccc156306 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: =?utf-8?q?TtHgXqPMAsbiHwafPc7pawMfaRhSO4F?= =?utf-8?q?87xy/OOFV+jMlX18GgTBnk1SlBaQrM6M+PEmQ2qatEHKHlqMoLGmI5FBVSg6DWYuJ?= =?utf-8?q?bxt3g7MNO+3WD/uT1y2K8XR2yGZ3fD6HwzaCjyvuRNRI5CEcK8/M928ZYRqIAadPN?= =?utf-8?q?832ODhYFEOnp8P0Cdqg5Yfu8IGh58R1tilYWVdrgz2ytHy6Ms+te89xQFi2bVh3A3?= =?utf-8?q?UDF2hX+umAWo+F3xq3iFHaDEiGd+doAse+Gjclp9KlZEK98hBAgmQ2c55EtSmNToX?= =?utf-8?q?lEh4s446dDyqnEaFFlTc2+/CGktYIAIv9JBmjiMrW02pq2E4UY4/JFU1SSPTtuJB2?= =?utf-8?q?uLNRi1L4KxeuRG609qr73JIvKnDMMtGj0+hyduLXVfqof9WfdXlDCeTH3iY6WQ3k/?= =?utf-8?q?CmGcRlGjN6qFCSt+Eg7abuAlmVebWhaL+DIG0eXgO+2ZgfSwwAtK8gCgYiYDOuKMG?= =?utf-8?q?dR/NPP4qPDYuYTjEZTdN9s9j9YRRmPnFF9LtaslH/+j2Q/ckwVGQfwqF8g3hW/Myh?= =?utf-8?q?uDKWYPEjbsjcTY6/l/nxANyEnAP5A3mHtVwuaNiuT4sOSMVgTrbsMFjQv99hAoCM9?= =?utf-8?q?6hoB9FcbfunB+32v/mCxf4qUIzk4BrEezAkxg+DrJyuUP9uCxN2rRSxp9X3In5sDg?= =?utf-8?q?ytJFcMerkywUMN9fuYJpWIv+XWT3j23ZkFx7yb+RifpOSgJy9R1HZEnF4KR4H2H/z?= =?utf-8?q?csfVjdsXSMrOtFh2TXPXgk4zvelgStPn+KEFXn053OHx6VW9TGJow1EnvGfPse62Z?= =?utf-8?q?W798VE/upx5+7RhLILuL6ik6nqz415FH6hgF7/Skqn31AqiFcFs/CLX7N6vcwSTpA?= =?utf-8?q?Mb8m9kxJxsyP4wbWivcqQ8ULS4dK7OwlLNRV1955wPRsjRqT0KB0LmhBcAjPWTGHg?= =?utf-8?q?ukqqKe9jTjFzlyYrxR8TYUxi9mkA4PSk0IIH7Flq8BuL1I2Gn228FltZFeIjHYZPp?= =?utf-8?q?Zgr33T4ZkwJRCQiaOOlREdbET3yVmDXJYrErl9uKqrxT6FfhWiCqXx1K8aLB4YP1b?= =?utf-8?q?LEEYjjYhGpLJo4g655Lb6dPOdZe4nZL5JHvhjSdhyNjmiXRU211v5+xaMs8eDv9Gf?= =?utf-8?q?o6Xh9gZvQdmSGKenqAc9LTM0TIW5REQrAM17kF/crpZB5wOgFB/OwXW5FkSBWnkyN?= =?utf-8?q?YVQQhZShYU3A2Y5035+w5XG04MH6czoD1UM/4Gl0ISjdo0FKEUJheNTIsoQpi4O3Y?= =?utf-8?q?mQ+tA5Btu9Xs+aB8Ug5/1ADQueeK5cTUm5q6F1VJWwDJsC9a4maNhD+9O2wQfo6U1?= =?utf-8?q?Tqb6UBdkgliFix6dbR+yvfAEyHffPaGw1c88d32Mc9FRj92+uJ9+uE/KqcLv6S7UV?= =?utf-8?q?mJvR+WvroPrHyWkFj7ii1nDvv64bZkOMI8iMOOmF+G0di+6diiK0BANASFluU353y?= =?utf-8?q?xG+yxpqIpOr?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.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: 03 Sep 2024 12:39:00.6925 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39334aa9-0dd5-41fd-fe91-08dccc156306 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=[SATLEXMB03.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: CH3PR12MB9454 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 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 Tue Sep 3 12:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13788651 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2067.outbound.protection.outlook.com [40.107.244.67]) (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 4ECD21CE6F5 for ; Tue, 3 Sep 2024 12:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367150; cv=fail; b=LDemYk8jIlPkW6VzEe839Ymxjl/8fP+GJab11E+K0SfgMbJExGFsSy9JjINjNleBB+EQS0CxBoFIGFdl5F1QsfUSY+PO9ZPEnw524q7MMVVsdrY3yuHn8KWAEp6VNVLI8vwaogob7Hxs/LzWuroBsPKgsb0ElnJ3Go2sosJirSk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367150; c=relaxed/simple; bh=dSKNd7V0rbBEQnkWFIQurqqa2+vjQNrstGwSsI4Mspo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DxSPL4ARxznxsPuV26HkR5zeFcm7iErCm+LRqHSYrt6dRT7jy+86Rv24z5Elff/PILqWmPk/XYHAaDy6VLj23tnEFvTNU6qAuOPrnXPmQTkYXsXXMFHkwre1AdDdfPG64czMAbnSknvirC34/frYBlitndveCgN28x/RTyIEvoY= 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=vrg52K7D; arc=fail smtp.client-ip=40.107.244.67 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="vrg52K7D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L6n12ENvVy8efgt1HoTCoaRKbMsmrP90gNjCg5B/rA4hGYk30h5E/ha7qxHxHCLuy/qWuxibpnfrhVpYnXoKkerA8mOgk4CkMdZMBqO5sBYtHBloXttObbL9jfrN8JB1pukvVm18ZIxsHSMdSYtlN/wihdxDIeaQtfxovC8EvO3zgFKJdCjm6E/Mxu1dMcPE/WHOSMnA7xFLfGzWQToOlxpu15L4ujvCoAjuOR+TTjPczdZeJbMotHZO7WKpoQvHmTqCWb7sAHHZI0XIrV2XneYd+2Lc8NYgGePFXphnI8D3kIobt3Am05Y4ynf2DJ4tYIwubBcHrEiWoyMeEy0t4A== 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=LNazj1u7/aJ9Durh8mptior5dwLufRAmYpGxNbnZdk8=; b=rF7AM9gBbYBHbFeu+88h5tpKbflxaSX7IAVvoMghGL8aHLx2FgchH7q+qIq9acbubZhkNNQT0ePFQK9o3I6HyQj0jgRKPLva9xktEFRIkH1zbaVYn7nnwh45EEpbuVK796BOoIO8XxClYnzHBnz0J/QwueKprqxl2Pjkb+TRpUM3jplx87IFSo8dELq/7Z/QzLSb85PfOJ0Jk2FiTDu2XXvZdI90wfkYUOJt5BaEY5HEEi336ElixJtm3+lVAWRspkWz2ZHGYYetmwsmG9u5ofyym8JeJeSLe/AgUKSruPCM/yMvyVf2JXYJ+6kYVlvNFdpkvKLgoOmdONYgPKA6/Q== 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=LNazj1u7/aJ9Durh8mptior5dwLufRAmYpGxNbnZdk8=; b=vrg52K7D6epxq7kFgOSULZGsSAPFG8CJse6I4DvaAO8anOXihnjE8a0Mt6kALJ24zTNzd1t+1M4jUa6MWdwPFacAIyd0212AJcXpi/hpsqJAseGiCehZvsdLWHn9Mhk+UXqbXJp2iBWawcKq85bjO4UY8QKyGr+NHA6eZPNo6uw= Received: from MN2PR05CA0055.namprd05.prod.outlook.com (2603:10b6:208:236::24) by DS7PR12MB8420.namprd12.prod.outlook.com (2603:10b6:8:e9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 12:39:03 +0000 Received: from BL02EPF00029927.namprd02.prod.outlook.com (2603:10b6:208:236:cafe::55) by MN2PR05CA0055.outlook.office365.com (2603:10b6:208:236::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.14 via Frontend Transport; Tue, 3 Sep 2024 12:39: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:39:02 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:39:00 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 07/10] platform/x86/amd/hsmp: Change generic plat_dev name to hsmp_pdev Date: Tue, 3 Sep 2024 12:38:27 +0000 Message-ID: <20240903123830.2717196-7-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029927:EE_|DS7PR12MB8420:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b900af3-ebef-45ef-2ff0-08dccc156455 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: =?utf-8?q?jBl8pLwwYoiE5MPlDhj9FkgDM22H1TF?= =?utf-8?q?gPu3S1H307OXVabxh/TxYhSw8RcFeL2dtLUiHGCy024DlbCKyLRoJo/8X+HUeQvJU?= =?utf-8?q?fOd7gpeAOKE4/EL42bMQdnf24Xzg88kf+TkM/6mIekXzlUd4U9FwWjzZDxoPcuHlk?= =?utf-8?q?v8xaQbm/miiftVdU7nCDZsSAWfN1mwDGV1tmzp42hkURVpJifvMHBkbpqn4VxIvEC?= =?utf-8?q?58m9X/grrJhK0uO9dcdPMdSlno43JgBxw0qTFfF2Bo13nPUzV46Z9cdD+6QyRJSPZ?= =?utf-8?q?ijmgMnwyQ7t4c+t5LNL8aBFIcgkwjGccPnywL4VFjsrAhdTyV3mFo37/v31vG71L4?= =?utf-8?q?+FYrVKygYrLnbh2TXzyQpZDAlj13QYl2AxWIBeGMCi8NdkYVfD1cCVSPbgG2KPSdp?= =?utf-8?q?yBC2PcP/ycObzHjc1QuyFg7d+HdLI1R7us79LbG6IMX362WL+PXe+gUQ0p4whcMTF?= =?utf-8?q?ZmHuuBYSa+SqxpOtbrs6t9u/LaXzGRYf9fmX0YQJz4oblVQdSYP8JfRydwJyXPgZd?= =?utf-8?q?zyJwYftIN268ALXABU9mtzlzlG7omgaDiSdVkTqVhV/byel8masC5bj/KmVmkLbhh?= =?utf-8?q?zFQU1//EcPSrus7xdIXK21z0Qw7nGaNZCaT32Wsl+6aq0TuaEPiJ/vGmzmFGOh9D/?= =?utf-8?q?oSW2bKMbAkrQAiTtil/VUgrLx4hCWLRN3Ih8TBZtnWoTDGpyblNgPpSyI+o4zBC4G?= =?utf-8?q?xkFzeAX1taaueluDbpCPLs67HdVu+tai95xhLag+wD9xCVI68RP3q24N9f8vmBWcf?= =?utf-8?q?HKsMvOt5XpXWJ6ccVMqs+LoMDc+je0pyGJVVh5QfAqSZyYZxUoYQsQhdl4pINtn0X?= =?utf-8?q?F3aaQfbSmk32/V88uNVagVd6cgC3kmsVIAQMW7CAuueD5f26ZX55Bx/B9DO52ed4b?= =?utf-8?q?ZUQPUwWbWFcwkTuruZ10b7fBGHNHK9mLbJMnWKN9rr/CyksR+H0eFgb8L0y0dAAQQ?= =?utf-8?q?T3inTKP0uzz/Rnzc7rpB+eS2mrpxW3grgm8Y2J4B5vQ+urex8bD73ADL6ZilPPnxA?= =?utf-8?q?u56knRCCl21qbhpUxGAaYc2jrh1YVrfFM1Ao4UoIR6RK957I+V6NYUDWCmgRjVxN9?= =?utf-8?q?8e1Kw2pki4WFWGdDcZs2tkasNxnS4ulQhqyfdwklKny+Bxw+Bkgu2F/qe8NBC19L4?= =?utf-8?q?20FsiZ3fTR5LX/kJOtr2Jk6uXbnGJcgd/qdZ83BYO+FU0jbvLP9QbUjSdksiqi5Us?= =?utf-8?q?yAytLGlJ/f0/ZfdnVVpriU/vnYeOdCoxudos6sAf6N46HGXuywF7If4UJdQgDFhiS?= =?utf-8?q?qS+QVWLWEs3lSryq9/IqJKC+EPTFAM/bXA3D8E8gCff15R5BOnnNfN8GoQhX3pZxf?= =?utf-8?q?1C0IA8bn0r5Dpq89ynrJofXyckmwE7x4rZppe/GqHJmj5lYlrM2pNoN0XEsM9Igud?= =?utf-8?q?vxDkUw3V7sI?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.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: 03 Sep 2024 12:39:02.8670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b900af3-ebef-45ef-2ff0-08dccc156455 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=[SATLEXMB03.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: DS7PR12MB8420 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 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 Tue Sep 3 12:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13788653 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2080.outbound.protection.outlook.com [40.107.236.80]) (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 826511CE6F5 for ; Tue, 3 Sep 2024 12:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367152; cv=fail; b=vELT0q1VaJMWKJ9uYFGHt6IWhDMU/V/kzIpI5WvRHtPXzw4NdCxAlsR5TC7rKwelsIMDacILq5Hpps6dDBzuGyGyJ64PJnq82M9m25W/f//W8a20PwUlqgN3XDjfJSlQNkFpKdM1bkHvF7/jPWoRrxNixi0lS98XJYtQDy4Xgw8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367152; c=relaxed/simple; bh=4dUDWuq9zno2fSubecIwY4Zj417YXfeNifgFbdGmLtI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oaTSpq6w5IQ34hksRvq9eRev238fwu6+zKS4lprSqbCwIhB9ROQjY/F++6viCrYxPZENoPP+LkYrOVueSllmgDyMqzTbsguSf33FGr7P4E32tkS4BgbYmdV67N4BBK6PlMQEZFM/1WO5RiDbhAPqqEdQ/6zFNA+MyxqsETc+HSw= 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=3AvWPfN+; arc=fail smtp.client-ip=40.107.236.80 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="3AvWPfN+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b6nHzFZ4Jk8D+gtwPAOtNgnxWxjX/H8GKDFlhEBjGfwiRkuEsuvSNygdKKzegm+DK6erkzwjNEW+t85cpLahWMub72seYlUW62vO7L5CwTlt8WKAz6OHpZ8BOvwB25tXNaps/r8v+oUr8Pij8rIfXkVXJzJ47ebGEeB2Wap6ubvuDgoL1184I6ATPcsygcxn5emIfR6jMztne3CvgMXrCjP2QWL38GnNED/bEhiCIPaqz95wS1OMeOADfjigocLJp4mSS1zQTW3KCl8RxyzCjJwXJZnEWqp5Aj8rIfHhvhyxb8d1VmTMtrJBSSj2utYEtK0EUSFkllhHF5UCkp0vng== 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=o6JYZFykt/wEZecREyeVCT87LRiFgmSKn7+piIloYy4=; b=KxLr+mgEC5c4rLxXQlSeglomw5aFqSDMDEvLsIXUyDKMcJdhj3uBfUt13lJHLFiqfQNqdYWoWXS6BiIWxNV0R3aU0sJpFZH2JrFYGLxay10j5BAGl2X7zmTdCoEaP8vh8cpKalIUzMXmIUlUSQRnw4XJHJXqpYkaP1RfcIpG84e4GnEtBonu8Nnwdtzf3ZkNG8zC9gSO+/yeujk0sMH66URqsMx1Fb6Jedy2Tv6D9B9mVv59Nv5h5lS1rQys88yIMFW+FGFlSekmh5FeONmIezRsAMEXQ5/oq3sGNCSaLEnHKzR6NRbfWHmSirkc1y7gt6lcUlPjQqPWn6TtSfD+CQ== 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=o6JYZFykt/wEZecREyeVCT87LRiFgmSKn7+piIloYy4=; b=3AvWPfN+nUd3F/ThmDuUr4SJdN+OomABOcwgzGAy9G7PPl4EP77aaBOLZLh4t+4EVhMe1O/dvOjadRKbKVOmJonmJkIDVg4bEdypIDdq8Gy938Rjt0ky3jvgXu0nmNtpgrni7Cx+PWejxO9LMsXSh22flwtzfOa7VhKhlPrNyF8= Received: from BL1PR13CA0380.namprd13.prod.outlook.com (2603:10b6:208:2c0::25) by SJ0PR12MB6992.namprd12.prod.outlook.com (2603:10b6:a03:483::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 12:39:05 +0000 Received: from BL02EPF0002992E.namprd02.prod.outlook.com (2603:10b6:208:2c0:cafe::bf) by BL1PR13CA0380.outlook.office365.com (2603:10b6:208:2c0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.12 via Frontend Transport; Tue, 3 Sep 2024 12:39:05 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:39:04 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:39:02 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 08/10] platform/x86/amd/hsmp: Create mutually exclusive ACPI and plat drivers Date: Tue, 3 Sep 2024 12:38:28 +0000 Message-ID: <20240903123830.2717196-8-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992E:EE_|SJ0PR12MB6992:EE_ X-MS-Office365-Filtering-Correlation-Id: f0b5e53c-7afb-4e1c-1a95-08dccc15659b 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: at9z11ptMpHKrrQMOzGh0IESGV+GzwrH1yWMRuv0ZannLCxvgNRLBeqvfSb98gTfEqp1IfH8je5E2Qev6MouecQm5WIzRLAcJGhYjpDcDD7MptNU8uVu2ucwEUTlJ6sWLfvGarQxn2/C+z60LYiY7oCx75RvC0Q7h6xQ8RiM1hAS/RJw1vpEISq9JxXyh3HC5jynmMr0pAglTAqgb4aP0BB3KVuE1+hRHdXAFigumH1/V+51TKNLiY2mN3aOk/4FhKbL2Oi9zfg9LB4Mi+q18R2MjdVrr4/Eb86ZBuA+VUWG+KypO9xFJYOPQjfI2BWE1ki4Ohgi/ZzQZ3gLlq7bTypYc+h6ErnaIVMyI4ccRMhlSAoqOZil88xAqg8Vh/MVaDxVKEoDShtKDdGsos2r/IU2nv+mYMNAaH7c+ShsNk487B8UmbIYmS1uoqsmlvc77DoBEiwx61QfF/rSMZpHuqmj40Meo0wHmsAfiK/1NAx+PX8Fp1aoBRU2unmxlqHr1KQeKijo9MbxSZqM2ajC/MFj/9eSoS71GS8+O+QUkYBYnxST0vherwedGHUBWelFjAobDGwLSbEm0pIqjt7GaVcOah7Qt1ghj8Ef2DC8Lsl34JIrRTMDJilMPX4ZWNDYO9Wlb1MyuEzAdFkVbwV6Oc17E4XBtsX/SASdz3DTvfpnJlldifELaQACKtizsjJkqlTi71FS2RxKXZlQZXmTLp27OEI6efxddfef5u0n42p9s6m5334Bkki3JfaE+osCUtH6CJf6p2ecl1V9ZJe1Rb1LD7Becq7mYm41FaWRT9BaZbNnInXYH5VmhQ6yJCrTX40W+96xT+pl9Bg5rVOtB9pu2muJzA/QDTq8sgIll0zh1hEC4KGQu9573qvUTvyoAzEVNj1aKyDmiTV8MC7oMj0PyqQdgi99fTtpaGq3RS5LRXohDw5xl+F/XWhQSlVk6USomKziev4x0lfEIxtMX6/vkNoUh39BuwUzv7ZT0gwU543Si/n+jUrlxnp0y0v2bhxIlqj0kip8sf2OV8wQqDgub98tyta6BaUCtolwCutd4ab7Tdn7oGvtF8sNDZRRXVI5urLYGWgojnLlWuWtVWC3q+2B1uAVLTMKN8X13503tyxjnl7SutGw3Of+isrvsmvldBCkvE/od0rP3ImkSyBsUqEFxQxuLrgcsKynrTdiq6/a6a0zs0nUPlcSCQHX5BFE+Ko8WpF3hY3xj7iI0zH2mgLz/W5tUGKopreUmiGD1upfXLoPhUzgV2SET5Te4sMZgunaaYvjfcCcUkpUPEriAmPFlGs5rhD7fWnqZmEyuDO1rKeLJ+E64lWCi7GN+IgB1XwuQEOhqT88OWCRTjHnRWsugg5b+j7mSrFsxKwafM524tRcTwtn5f4ETEn90mLuAomsFk/eZruvMi7EKZ4akgC/F7Oab5RUUjZ2/n7yfsrifMseaLeQPYgYoIcX X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.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: 03 Sep 2024 12:39:04.9873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0b5e53c-7afb-4e1c-1a95-08dccc15659b 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=[SATLEXMB03.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: SJ0PR12MB6992 Separate the probes for HSMP ACPI and platform device drivers. Provide a Kconfig option to choose between ACPI or the platform device based driver. The common code which is the core part of the HSMP driver maintained at hsmp.c is guarded by AMD_HSMP config and is selected by these two driver configs. Also add "|| COMPILE_TEST" clause in Kconfig to get build coverage for HSMP. Signed-off-by: Suma Hegde Reviewed-by: Naveen Krishna Chatradhi Reviewed-by: Ilpo Järvinen --- 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 | 66 +++++++- arch/x86/include/asm/amd_hsmp.h | 2 +- drivers/platform/x86/amd/Makefile | 2 +- drivers/platform/x86/amd/hsmp/Kconfig | 37 ++++- drivers/platform/x86/amd/hsmp/Makefile | 6 +- drivers/platform/x86/amd/hsmp/acpi.c | 82 +++++++++- drivers/platform/x86/amd/hsmp/hsmp.c | 212 ++----------------------- drivers/platform/x86/amd/hsmp/hsmp.h | 8 +- drivers/platform/x86/amd/hsmp/plat.c | 144 ++++++++++++++++- 9 files changed, 341 insertions(+), 218 deletions(-) diff --git a/Documentation/arch/x86/amd_hsmp.rst b/Documentation/arch/x86/amd_hsmp.rst index 1e499ecf5f4e..e4b4bbeed643 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,24 @@ 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 and platform device based probing. These two +drivers are mutually exclusive drivers with compile time Kconfig options to +choose between them. Both the 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. + +Kconfig option CONFIG_AMD_HSMP compiles plat.c + hsmp.c +for platform device based probing. +Kconfig option CONFIG_AMD_HSMP_ACPI compiles acpi.c + hsmp.c +for ACPI object based probing. $ ls -al /dev/hsmp crw-r--r-- 1 root root 10, 123 Jan 21 21:41 /dev/hsmp @@ -59,6 +70,51 @@ Note: lseek() is not supported as entire metrics table is read. Metrics table definitions will be documented as part of Public PPR. The same is defined in the amd_hsmp.h header. +ACPI device object format +========================= +The ACPI object format expected from the amd_hsmp driver +for socket with ID00 is given below. + +Device(HSMP) + { + Name(_HID, "AMDI0097") + Name(_UID, "ID00") + Name(HSE0, 0x00000001) + Name(RBF0, ResourceTemplate() + { + Memory32Fixed(ReadWrite, 0xxxxxxx, 0x00100000) + }) + Method(_CRS, 0, NotSerialized) + { + Return(RBF0) + } + Method(_STA, 0, NotSerialized) + { + If(LEqual(HSE0, One)) + { + Return(0x0F) + } + Else + { + Return(Zero) + } + } + Name(_DSD, Package(2) + { + Buffer(0x10) + { + 0x9D, 0x61, 0x4D, 0xB7, 0x07, 0x57, 0xBD, 0x48, + 0xA6, 0x9F, 0x4E, 0xA2, 0x87, 0x1F, 0xC2, 0xF6 + }, + Package(3) + { + Package(2) {"MsgIdOffset", 0x00010934}, + Package(2) {"MsgRspOffset", 0x00010980}, + Package(2) {"MsgArgOffset", 0x000109E0} + } + }) + } + An example ========== diff --git a/arch/x86/include/asm/amd_hsmp.h b/arch/x86/include/asm/amd_hsmp.h index 03c2ce3edaf5..ada14e55f9f4 100644 --- a/arch/x86/include/asm/amd_hsmp.h +++ b/arch/x86/include/asm/amd_hsmp.h @@ -5,7 +5,7 @@ #include -#if IS_ENABLED(CONFIG_AMD_HSMP) +#if IS_ENABLED(CONFIG_AMD_HSMP) || IS_ENABLED(CONFIG_AMD_HSMP_ACPI) int hsmp_send_message(struct hsmp_message *msg); #else static inline int hsmp_send_message(struct hsmp_message *msg) diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile index 96ec24c8701b..f0b2fe81c685 100644 --- a/drivers/platform/x86/amd/Makefile +++ b/drivers/platform/x86/amd/Makefile @@ -5,6 +5,6 @@ # obj-$(CONFIG_AMD_PMC) += pmc/ -obj-y += hsmp/ +obj-$(CONFIG_AMD_HSMP) += hsmp/ obj-$(CONFIG_AMD_PMF) += pmf/ obj-$(CONFIG_AMD_WBRF) += wbrf.o diff --git a/drivers/platform/x86/amd/hsmp/Kconfig b/drivers/platform/x86/amd/hsmp/Kconfig index b55d4ed9bceb..b10ff91e9f5a 100644 --- a/drivers/platform/x86/amd/hsmp/Kconfig +++ b/drivers/platform/x86/amd/hsmp/Kconfig @@ -4,14 +4,45 @@ # config AMD_HSMP - tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 && ACPI + tristate + +menu "AMD HSMP Driver" + depends on AMD_NB || COMPILE_TEST + +config AMD_HSMP_ACPI + tristate "AMD HSMP ACPI device driver" + depends on ACPI + select AMD_HSMP help + Host System Management Port (HSMP) interface is a mailbox interface + between the x86 core and the System Management Unit (SMU) firmware. The driver provides a way for user space tools to monitor and manage - system management functionality on EPYC server CPUs from AMD. + system management functionality on EPYC and MI300A server CPUs + from AMD. + + This option supports ACPI based probing. + You may enable this, if your platform BIOS provides an ACPI object + as described in amd_hsmp.rst document. + + If you choose to compile this driver as a module the module will be + called amd_hsmp. +config AMD_HSMP_PLAT + tristate "AMD HSMP platform device driver" + depends on AMD_HSMP_ACPI=n + select AMD_HSMP + help Host System Management Port (HSMP) interface is a mailbox interface between the x86 core and the System Management Unit (SMU) firmware. + The driver provides a way for user space tools to monitor and manage + system management functionality on EPYC and MI300A server CPUs + from AMD. + + This option supports platform device based probing. + You may enable this, if your platform BIOS does not provide + HSMP ACPI object. If you choose to compile this driver as a module the module will be called amd_hsmp. + +endmenu diff --git a/drivers/platform/x86/amd/hsmp/Makefile b/drivers/platform/x86/amd/hsmp/Makefile index 0cc92865c0a2..18d9a0d1e8c5 100644 --- a/drivers/platform/x86/amd/hsmp/Makefile +++ b/drivers/platform/x86/amd/hsmp/Makefile @@ -4,5 +4,7 @@ # AMD HSMP Driver # -obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o -amd_hsmp-objs := hsmp.o plat.o acpi.o +obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o +amd_hsmp-objs := hsmp.o +amd_hsmp-$(CONFIG_AMD_HSMP_PLAT) += plat.o +amd_hsmp-$(CONFIG_AMD_HSMP_ACPI) += acpi.o diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 6f8e7962266a..766617e6adc7 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -9,11 +9,15 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include + #include #include #include #include #include +#include +#include #include #include @@ -21,6 +25,10 @@ #include "hsmp.h" +#define DRIVER_NAME "amd_hsmp" +#define DRIVER_VERSION "2.3" +#define ACPI_HSMP_DEVICE_HID "AMDI0097" + /* These are the strings specified in ACPI table */ #define MSG_IDOFF_STR "MsgIdOffset" #define MSG_ARGOFF_STR "MsgArgOffset" @@ -200,7 +208,6 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) sock->sock_ind = sock_ind; sock->dev = dev; sock->amd_hsmp_rdwr = amd_hsmp_acpi_rdwr; - hsmp_pdev.is_acpi_device = true; sema_init(&sock->hsmp_sem, 1); @@ -213,7 +220,7 @@ static int hsmp_parse_acpi_table(struct device *dev, u16 sock_ind) return hsmp_read_acpi_dsd(sock); } -int hsmp_create_acpi_sysfs_if(struct device *dev) +static int hsmp_create_acpi_sysfs_if(struct device *dev) { struct attribute_group *attr_grp; u16 sock_ind; @@ -236,7 +243,7 @@ int hsmp_create_acpi_sysfs_if(struct device *dev) return devm_device_add_group(dev, attr_grp); } -int init_acpi(struct device *dev) +static int init_acpi(struct device *dev) { u16 sock_ind; int ret; @@ -270,3 +277,72 @@ int init_acpi(struct device *dev) return ret; } + +static const struct acpi_device_id amd_hsmp_acpi_ids[] = { + {ACPI_HSMP_DEVICE_HID, 0}, + {} +}; +MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); + +static int hsmp_acpi_probe(struct platform_device *pdev) +{ + int ret; + + if (!hsmp_pdev.is_probed) { + hsmp_pdev.num_sockets = amd_nb_num(); + if (hsmp_pdev.num_sockets == 0 || hsmp_pdev.num_sockets > MAX_AMD_SOCKETS) + return -ENODEV; + + hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, + sizeof(*hsmp_pdev.sock), + GFP_KERNEL); + if (!hsmp_pdev.sock) + return -ENOMEM; + } + + ret = init_acpi(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to initialize HSMP interface.\n"); + return ret; + } + + ret = hsmp_create_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + + if (!hsmp_pdev.is_probed) { + ret = hsmp_misc_register(&pdev->dev); + if (ret) + return ret; + hsmp_pdev.is_probed = true; + } + + return 0; +} + +static void hsmp_acpi_remove(struct platform_device *pdev) +{ + /* + * We register only one misc_device even on multi-socket system. + * So, deregister should happen only once. + */ + if (hsmp_pdev.is_probed) { + hsmp_misc_deregister(); + hsmp_pdev.is_probed = false; + } +} + +static struct platform_driver amd_hsmp_driver = { + .probe = hsmp_acpi_probe, + .remove_new = hsmp_acpi_remove, + .driver = { + .name = DRIVER_NAME, + .acpi_match_table = amd_hsmp_acpi_ids, + }, +}; + +module_platform_driver(amd_hsmp_driver); + +MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 78945750d590..5e0c9c36f435 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -15,17 +15,11 @@ #include #include #include -#include -#include #include #include #include "hsmp.h" -#define DRIVER_NAME "amd_hsmp" -#define DRIVER_VERSION "2.2" -#define ACPI_HSMP_DEVICE_HID "AMDI0097" - /* HSMP Status / Error codes */ #define HSMP_STATUS_NOT_READY 0x00 #define HSMP_STATUS_OK 0x01 @@ -228,7 +222,7 @@ int hsmp_test(u16 sock_ind, u32 value) return ret; } -static long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { int __user *arguser = (int __user *)arg; struct hsmp_message msg = { 0 }; @@ -284,12 +278,6 @@ static long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return 0; } -static const struct file_operations hsmp_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = hsmp_ioctl, - .compat_ioctl = hsmp_ioctl, -}; - ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) @@ -414,193 +402,25 @@ int hsmp_cache_proto_ver(u16 sock_ind) return ret; } -static const struct acpi_device_id amd_hsmp_acpi_ids[] = { - {ACPI_HSMP_DEVICE_HID, 0}, - {} -}; -MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids); - -static bool check_acpi_support(struct device *dev) -{ - struct acpi_device *adev = ACPI_COMPANION(dev); - - if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) - return true; - - return false; -} - -static int hsmp_pltdrv_probe(struct platform_device *pdev) -{ - int ret; - - /* - * On ACPI supported BIOS, there is an ACPI HSMP device added for - * each socket, so the per socket probing, but the memory allocated for - * sockets should be contiguous to access it as an array, - * Hence allocate memory for all the sockets at once instead of allocating - * on each probe. - */ - if (!hsmp_pdev.is_probed) { - hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, - sizeof(*hsmp_pdev.sock), - GFP_KERNEL); - if (!hsmp_pdev.sock) - return -ENOMEM; - } - if (check_acpi_support(&pdev->dev)) { - ret = init_acpi(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); - return ret; - } - ret = hsmp_create_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - } else { - ret = init_platform_device(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); - return ret; - } - ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - } - - if (!hsmp_pdev.is_probed) { - hsmp_pdev.mdev.name = HSMP_CDEV_NAME; - hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; - hsmp_pdev.mdev.fops = &hsmp_fops; - hsmp_pdev.mdev.parent = &pdev->dev; - hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; - hsmp_pdev.mdev.mode = 0644; - - ret = misc_register(&hsmp_pdev.mdev); - if (ret) - return ret; - - hsmp_pdev.is_probed = true; - } - - return 0; - -} - -static void hsmp_pltdrv_remove(struct platform_device *pdev) -{ - /* - * We register only one misc_device even on multi socket system. - * So, deregister should happen only once. - */ - if (hsmp_pdev.is_probed) { - misc_deregister(&hsmp_pdev.mdev); - hsmp_pdev.is_probed = false; - } -} - -static struct platform_driver amd_hsmp_driver = { - .probe = hsmp_pltdrv_probe, - .remove_new = hsmp_pltdrv_remove, - .driver = { - .name = DRIVER_NAME, - .acpi_match_table = amd_hsmp_acpi_ids, - }, +static const struct file_operations hsmp_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = hsmp_ioctl, + .compat_ioctl = hsmp_ioctl, }; -static struct platform_device *amd_hsmp_platdev; - -static int hsmp_plat_dev_register(void) +int hsmp_misc_register(struct device *dev) { - int ret; - - amd_hsmp_platdev = platform_device_alloc(DRIVER_NAME, PLATFORM_DEVID_NONE); - if (!amd_hsmp_platdev) - return -ENOMEM; - - ret = platform_device_add(amd_hsmp_platdev); - if (ret) - platform_device_put(amd_hsmp_platdev); - - return ret; + hsmp_pdev.mdev.name = HSMP_CDEV_NAME; + hsmp_pdev.mdev.minor = MISC_DYNAMIC_MINOR; + hsmp_pdev.mdev.fops = &hsmp_fops; + hsmp_pdev.mdev.parent = dev; + hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME; + hsmp_pdev.mdev.mode = 0644; + + return misc_register(&hsmp_pdev.mdev); } -/* - * This check is only needed for backward compatibility of previous platforms. - * All new platforms are expected to support ACPI based probing. - */ -static bool legacy_hsmp_support(void) +void hsmp_misc_deregister(void) { - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) - return false; - - switch (boot_cpu_data.x86) { - case 0x19: - switch (boot_cpu_data.x86_model) { - case 0x00 ... 0x1F: - case 0x30 ... 0x3F: - case 0x90 ... 0x9F: - case 0xA0 ... 0xAF: - return true; - default: - return false; - } - case 0x1A: - switch (boot_cpu_data.x86_model) { - case 0x00 ... 0x1F: - return true; - default: - return false; - } - default: - return false; - } - - return false; + misc_deregister(&hsmp_pdev.mdev); } - -static int __init hsmp_plt_init(void) -{ - int ret = -ENODEV; - - /* - * amd_nb_num() returns number of SMN/DF interfaces present in the system - * if we have N SMN/DF interfaces that ideally means N sockets - */ - hsmp_pdev.num_sockets = amd_nb_num(); - if (hsmp_pdev.num_sockets == 0 || hsmp_pdev.num_sockets > MAX_AMD_SOCKETS) - return ret; - - ret = platform_driver_register(&amd_hsmp_driver); - if (ret) - return ret; - - if (!hsmp_pdev.is_acpi_device) { - if (legacy_hsmp_support()) { - /* Not ACPI device, but supports HSMP, register a plat_dev */ - ret = hsmp_plat_dev_register(); - } else { - /* Not ACPI, Does not support HSMP */ - pr_info("HSMP is not supported on Family:%x model:%x\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - ret = -ENODEV; - } - if (ret) - platform_driver_unregister(&amd_hsmp_driver); - } - - return ret; -} - -static void __exit hsmp_plt_exit(void) -{ - platform_device_unregister(amd_hsmp_platdev); - platform_driver_unregister(&amd_hsmp_driver); -} - -device_initcall(hsmp_plt_init); -module_exit(hsmp_plt_exit); - -MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); -MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 9c5b9c263fc1..9ab50bc74676 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -52,7 +52,6 @@ struct hsmp_plat_device { struct hsmp_socket *sock; u32 proto_ver; u16 num_sockets; - bool is_acpi_device; bool is_probed; }; @@ -61,14 +60,13 @@ extern struct hsmp_plat_device hsmp_pdev; ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count); -int hsmp_create_non_acpi_sysfs_if(struct device *dev); -int hsmp_create_acpi_sysfs_if(struct device *dev); int hsmp_cache_proto_ver(u16 sock_ind); umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, struct bin_attribute *battr, int id); int hsmp_create_attr_list(struct attribute_group *attr_grp, struct device *dev, u16 sock_ind); int hsmp_test(u16 sock_ind, u32 value); -int init_platform_device(struct device *dev); -int init_acpi(struct device *dev); +long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); +void hsmp_misc_deregister(void); +int hsmp_misc_register(struct device *dev); #endif /* HSMP_H */ diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index e18cf82478a0..e49b53f8c5e3 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -12,11 +12,16 @@ #include #include +#include #include +#include #include #include "hsmp.h" +#define DRIVER_NAME "amd_hsmp" +#define DRIVER_VERSION "2.3" + /* * To access specific HSMP mailbox register, s/w writes the SMN address of HSMP mailbox * register into the SMN_INDEX register, and reads/writes the SMN_DATA reg. @@ -50,7 +55,13 @@ static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, return ret; } -int hsmp_create_non_acpi_sysfs_if(struct device *dev) +static const struct file_operations hsmp_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = hsmp_ioctl, + .compat_ioctl = hsmp_ioctl, +}; + +static int hsmp_create_non_acpi_sysfs_if(struct device *dev) { const struct attribute_group **hsmp_attr_grps; struct attribute_group *attr_grp; @@ -88,7 +99,7 @@ static inline bool is_f1a_m0h(void) return false; } -int init_platform_device(struct device *dev) +static int init_platform_device(struct device *dev) { struct hsmp_socket *sock; int ret, i; @@ -134,3 +145,132 @@ int init_platform_device(struct device *dev) return 0; } + +static int hsmp_pltdrv_probe(struct platform_device *pdev) +{ + int ret; + + hsmp_pdev.sock = devm_kcalloc(&pdev->dev, hsmp_pdev.num_sockets, + sizeof(*hsmp_pdev.sock), + GFP_KERNEL); + if (!hsmp_pdev.sock) + return -ENOMEM; + + ret = init_platform_device(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to init HSMP mailbox\n"); + return ret; + } + + ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); + + return hsmp_misc_register(&pdev->dev); +} + +static void hsmp_pltdrv_remove(struct platform_device *pdev) +{ + hsmp_misc_deregister(); +} + +static struct platform_driver amd_hsmp_driver = { + .probe = hsmp_pltdrv_probe, + .remove_new = hsmp_pltdrv_remove, + .driver = { + .name = DRIVER_NAME, + }, +}; + +static struct platform_device *amd_hsmp_platdev; + +static int hsmp_plat_dev_register(void) +{ + int ret; + + amd_hsmp_platdev = platform_device_alloc(DRIVER_NAME, PLATFORM_DEVID_NONE); + if (!amd_hsmp_platdev) + return -ENOMEM; + + ret = platform_device_add(amd_hsmp_platdev); + if (ret) + platform_device_put(amd_hsmp_platdev); + + return ret; +} + +/* + * This check is only needed for backward compatibility of previous platforms. + * All new platforms are expected to support ACPI based probing. + */ +static bool legacy_hsmp_support(void) +{ + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + return false; + + switch (boot_cpu_data.x86) { + case 0x19: + switch (boot_cpu_data.x86_model) { + case 0x00 ... 0x1F: + case 0x30 ... 0x3F: + case 0x90 ... 0x9F: + case 0xA0 ... 0xAF: + return true; + default: + return false; + } + case 0x1A: + switch (boot_cpu_data.x86_model) { + case 0x00 ... 0x1F: + return true; + default: + return false; + } + default: + return false; + } + + return false; +} + +static int __init hsmp_plt_init(void) +{ + int ret = -ENODEV; + + if (!legacy_hsmp_support()) { + pr_info("HSMP is not supported on Family:%x model:%x\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + return ret; + } + + /* + * amd_nb_num() returns number of SMN/DF interfaces present in the system + * if we have N SMN/DF interfaces that ideally means N sockets + */ + hsmp_pdev.num_sockets = amd_nb_num(); + if (hsmp_pdev.num_sockets == 0 || hsmp_pdev.num_sockets > MAX_AMD_SOCKETS) + return ret; + + ret = platform_driver_register(&amd_hsmp_driver); + if (ret) + return ret; + + ret = hsmp_plat_dev_register(); + if (ret) + platform_driver_unregister(&amd_hsmp_driver); + + return ret; +} + +static void __exit hsmp_plt_exit(void) +{ + platform_device_unregister(amd_hsmp_platdev); + platform_driver_unregister(&amd_hsmp_driver); +} + +device_initcall(hsmp_plt_init); +module_exit(hsmp_plt_exit); + +MODULE_DESCRIPTION("AMD HSMP Platform Interface Driver"); +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL"); From patchwork Tue Sep 3 12:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13788652 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2085.outbound.protection.outlook.com [40.107.244.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86CA61D61A8 for ; Tue, 3 Sep 2024 12:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367151; cv=fail; b=og6zdzjrKn87O/INPgBXk4muH1x2eYi6TvGDhZLPsEIJ5ALGVZesz6Cqx8jacRWmWlMrUcWy7pSsldpUdojExAd8n9BdlWPK/UXbRKfJimAoUr1iezO+fJLn/ZHU4moI48JDnJ7QQWwk50wqq0KTdnK8B+NG3DwH93nqrVdddUg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367151; c=relaxed/simple; bh=02gxiEnTghQn2MqVLTL9mPoirX9ox/CRt3sT0ErmD+w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZanyWH3IqJkIEaBm5JxHz3Q7O9x2ThRgaAOz0Ocx1QDDHTemay/6gLz9aRQhGokZpg2EnfdUozF7NKXyZMaMDkThP05H6EcCtYocG2GbwWhFylsb5DvbrXae956zcZV8y+hFqx3O1K9XvZmavIX2iahgAYkkgbhiOBn/KNOxLEI= 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=Ho5un63V; arc=fail smtp.client-ip=40.107.244.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Ho5un63V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VMt9YiiGtn3uFjakhHWbj0qwCgJkqoETSAGbGrACYtZ77r8flK/mf6hX4Nb4cN7B/4ASq92pyppHBD28lMgc7XJwi9L7dwyv4KRVbkegMthGfFusyDTKdqapy6NXA8aA9Oq7KzD8xysroTg2Gnl4u4Ptdt7mdMMY+kO3ZudDXy4Yvj5C/buByKIGfcmDYtfLjRBkMA4VByNcxsWqnzH8KnBesw7nXwJdwCEfHD67vxi6zMtD5OhOupiy6CDmYAcLH+B/ydg1ZaFV73wUj+6H7VzHpXlxJOplsNi5JqI5TrmEX2Cl/vKnYECw4qFrSitWCAJpkMZ6mdpq/T2Ak42OWw== 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=nOY++L07b+vooMmv7+uuHkUo2kfkWwJMbYh1TI+Gykw=; b=OWxtWIb/iNbI7nxD0/yeAzYFuzNIxS2R6DPTLDwTNIgl5SNxRfEWXaWs9x7/Q2P9sCtw7rx/zuS0U7i5glU7iZ849rhmBN5B2PHud92tM2SCYs3AHIV5Woepf/yU3FOm2ZfTcR+LmAW1VxZhktwNQGYQO5d5TxX3CeuzJo2feE96BTfZrbJuWw5xZoy9m3KW2xZle5SuyZypWc+ujPe3ekVysaSMiWcbXE4Hl2R2pnNmK9M2E48sqktjlHBBTm1spAzIVQbu+NJY+K9pkTzxTzM6myboyMXL+tbn+38R2URkBzJ09F3/wKqAhDgjIPiwmKwOKaFH73Zv8bl+9e7J4w== 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=nOY++L07b+vooMmv7+uuHkUo2kfkWwJMbYh1TI+Gykw=; b=Ho5un63VK+7z4RB2xYJjeiXoyj9SMDPl/pa16hiDOZQWsALT8qyaUS6xUd/K9Fgljm1OSWyXOiBGLBxp8aqHq3b805k6wFOgtHso4PSDNl4p0ihWXTmAXDwl5t4q6CFOjDAjAunOXuEbEjXHJ+TN3gYsXad28/bF8V0jm4twGdU= Received: from BN9PR03CA0332.namprd03.prod.outlook.com (2603:10b6:408:f6::7) by LV3PR12MB9188.namprd12.prod.outlook.com (2603:10b6:408:19b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Tue, 3 Sep 2024 12:39:07 +0000 Received: from BL02EPF0002992B.namprd02.prod.outlook.com (2603:10b6:408:f6:cafe::39) by BN9PR03CA0332.outlook.office365.com (2603:10b6:408:f6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:39:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:39:07 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:39:04 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 09/10] platform/x86/amd/hsmp: Use name space while exporting module symbols Date: Tue, 3 Sep 2024 12:38:29 +0000 Message-ID: <20240903123830.2717196-9-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992B:EE_|LV3PR12MB9188:EE_ X-MS-Office365-Filtering-Correlation-Id: eef39271-277a-4d16-e711-08dccc1566da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: TR18qbPT3xbj+B0UOoWhDwXOV0sRFHX0VbE/GecY1kqiJDivZi3jNL0SW+zbLDwuXjIxry/9TsBnqJEon4NcwzPClgRnyhxSiHnO3bLt6Yz3zTevsJARFyA0RzHMV+VBVUC4QAHSxo5OTywgDoaXxsh94IVAbi9gxbBLrD13O1h037kCPfV7adC08CCh6SwslY9gUDyqerJDPBHtM5UqmhBVdE28KUmNTxfGVyfuY34snSVVRAgsb3u7mkj+OksGDP1X5MYDHl6/aTB9ksCIE80gk3jd6YisHXhmiAcgq6NRk3JQl8epGx4/IAJ1sbt72MdUxHgEqvG3PLbxi02nWytNJELwPwjEMkAliQQGRT7zxL/HXxyEjBNb9WdRJg1ItsrT0xP/gq7JAvXfuIPavTlLXj3pV0wd/TN/AXl8kgLM16Xwqsk/iFk5UO49HGYHwYuKhjos5KMMqJsayhbkyYFm/NFZ3EUVDN1ZA5nkWvMojS3cwOiOlnRelRPQzTtd12l3hJ+0wyutKne8AXwOK42YN23nbIHDdmK57CI2m/IclvNUuRyivf0mzTRFzSp5109Zwyo7sFckA6ioNTHDZ9ycG/YvHbCNQxEyFKPsozTPfYOnJ+KknN2OS+rNkm3dzXz4dGdvvhjzEC+VmdvF1jYGvBkM+b9y5PKCdGmCdljVcJOvj3dD0Ecnyh5/vNRLK6jtoKjKlwFyK6/HjjekmhjrqDwFI9Ox6aLTAxipsjCK21HrTQv6jV8GHrBQDcVVxKLDKsCOMRJ2vYbM258O9uCIztwkKgN/8J0a0tkMe7Wz1nLrh7VRAxVDp9LnOA4NuYOkaFlQBnWLjSnQn8mEQz695wIL8ixNgn5IfAyi8TUpRoJdFMi+FH2XFh0MgRpCeN7/9xuIk+9yTLlC0wRKhf5M9xbY8bceAKBCUqfZ99p9DBsEAxorth4z0sddF67pPIcItpvZo3uHShyO/BjR9KA6tDkq9v0iMU2ct+l7mWFMCVLnsw5evozZY740IanALiJpzk/KxA7y1pr7Kh06ZnLiP8syPDtEp3sZyzYNBOkOwQclcRi52VYo4Hj920kVbGoa0vzz6GglNN7thVh6zsSgqpN7DkdfA2ld7dbYiTeowkavrKLVnyzRYcWMwIijc85HjWJB87N3a3dtr824U+e8z8jlnTWK1MoCbZXBdimVzITNXOnmGLaT2N7KbvW8tERbaGKCfL7eSn1RlVKUWZ6btzYgN24jq8N2j4mf3mDpL2UhCnSTI+AdKgHA0GYlKbgcyW8j97ec6bmrL8J46EIwzdpAaORDWibmdmfls6xalzTcOUQEeDDqrkyrJpPrOkYE8GTfe4UVdNt4WR1g4ENNsTfeG0yHXzyicdwOTgTXuivHceLSDYXREa0kn+bipVefHnEng6/kdqLG8+gv4gXnoFyCMH0CultAgrocqBhApc05r4lo+bzdwZJwJPA0 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 12:39:07.0988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eef39271-277a-4d16-e711-08dccc1566da 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=[SATLEXMB03.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: LV3PR12MB9188 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 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/hsmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 5e0c9c36f435..8c8e361b1feb 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -190,7 +190,7 @@ int hsmp_send_message(struct hsmp_message *msg) return ret; } -EXPORT_SYMBOL_GPL(hsmp_send_message); +EXPORT_SYMBOL_NS_GPL(hsmp_send_message, AMD_HSMP); int hsmp_test(u16 sock_ind, u32 value) { From patchwork Tue Sep 3 12:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suma Hegde X-Patchwork-Id: 13788654 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2046.outbound.protection.outlook.com [40.107.96.46]) (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 17A441DA0E1 for ; Tue, 3 Sep 2024 12:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367157; cv=fail; b=tu8D7BIoFQcS4KceaapEr3J5YTGOJcw2rZizzYRSLUBo30TkSpi4tURkyy/1NWK/AmGGK1JKQCB18YN8LgjHjXX/aZTjwaGqBnH7mhJ9aU+PEVZtK72OU99I8YlbmDz5wPyvI4DGa78liChpu0bF9MAoJ1gEAWkT6BCXwT2V7pk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725367157; c=relaxed/simple; bh=OWgn1IfN9a3Hyc5TZZVw3gbJVE0C170X2OK3QBk7X2Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XmDB9D7WCeyhQtec7RA+to3HcPAE2ldL725010qbTTFQs9D9Vl0EzKXn0FR2OXoNfR9T94csgw9xmGkELZXYEnsQNR4dZosssnQiEbZGnqnBBOwiQx94hil8szTFPsrZ/T//Incyy1LbynXY9wLBamcmccSkLuvo+G72JyRgN4Y= 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=TCKu1bzq; arc=fail smtp.client-ip=40.107.96.46 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="TCKu1bzq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VI9qVKaNW0FHqqKfByoSW49oIfpoB0B6L7KjlCiuSveBr33Nag5TyP71WTa+72bwfnrsuoSvN0scSsXPlLndUbr1jyM15o7jhkw6JTLY2FVcIQ3gvEn1xHskl9Cd1Sh7/TR2hB0D1Ghtb7wJIicVsP1mL+iA7uWR0go2FA6sADsOyZhwG03cBD+yaOvdePPRkLqVElfSH++cau7rvZkgO5eie2tlNqD8XE12dSTbpe6bWJipShPCIZPj0y+aU17ufao8dNW2B/FMR8jgxaultK5MwS5xDBHHA51zhNX03YPQ7I2zXR4Ryk3TabCUVjD9gMWMEjVGwOCxVR2UEsTomw== 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=z0SgSDiwhSbFXZNk7knaao3OQx7iEeTGQoD1TxcEGlQ=; b=tpI7XFUbK3rVFkkJwRr3C6CQh4ij8EDNfdiEPI6BaXJmE/77bjqwZfQ6nnGC4k9ArJjkKdFehyDW/WiatHn6zCgxoz5u/Gc7YUncgLZxbax3BtD90oGiFffhEzQ0APd7wC9n2URY5wXpPoa2zRiPjGJY46m4jYo0yY0O5RgrWMzliamoc5xuGRqZi71/iEL6I9LxJehbra0ZoM2kqcHjg4UiWU9rXAg584Z+ok7AkibDjQlXUOeBl+Wqy23QnWsXVgTA6n0GeXS6o4c7sL3vEAjTCwY0gxhV9VMZycd+i57TwDVQNj8qDWMZ403N1mmblLxGxbSbMShiuaerMt83ag== 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=z0SgSDiwhSbFXZNk7knaao3OQx7iEeTGQoD1TxcEGlQ=; b=TCKu1bzq4t9QXorJWrlK/yig91UfWxlsF2DGvE0+c2u5vrBniNn8QzXcGZXpUkgo7pnzIuMP/caq5cxd6eJG2bIARVY9OOAh3CHXiJwBpO3gVzrj5PbqlVbj3zknpOezfj7R5Sq2Tr7qTIxjtQuCh1VfUAqBABtMwhSqXx2LSEU= Received: from MN2PR12CA0005.namprd12.prod.outlook.com (2603:10b6:208:a8::18) by SJ1PR12MB6025.namprd12.prod.outlook.com (2603:10b6:a03:48c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Tue, 3 Sep 2024 12:39:09 +0000 Received: from BL02EPF0002992C.namprd02.prod.outlook.com (2603:10b6:208:a8:cafe::50) by MN2PR12CA0005.outlook.office365.com (2603:10b6:208:a8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Tue, 3 Sep 2024 12:39:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.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.7918.13 via Frontend Transport; Tue, 3 Sep 2024 12:39:09 +0000 Received: from amd.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 07:39:06 -0500 From: Suma Hegde To: CC: , , Suma Hegde , Naveen Krishna Chatradhi Subject: [v7 10/10] platform/x86/amd/hsmp: Use dev_groups in the driver structure Date: Tue, 3 Sep 2024 12:38:30 +0000 Message-ID: <20240903123830.2717196-10-suma.hegde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903123830.2717196-1-suma.hegde@amd.com> References: <20240903123830.2717196-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 SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992C:EE_|SJ1PR12MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: a3e6ff99-f889-46ad-fa17-08dccc156823 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: edAEZ4q+lkO3v7GChuh+Nn0/QyPTd8+sE7YRtZHkplhmOAwNjCgGreIYBs+IbX1LxIoKIeQm7j0CFz3VJyGmIciFuF4wHlccL14IbVRRcF0ZsUWjju6+YsFTpTAJGdHrz/Hq+7wmkmePlucN3Bv6URRXXSuXxcIOMOvMUHF0ww5YKBTW5iH29C6dhQV2GT88GWMMI6di50/CuNgOq5/gBNx9+HptuigRRDtBLBl5gAsIHtHebl0yBf4xBhdYEci2mAkg5FbIofRV49alGl1alJfvUvT7+o4hwAW2U88jFlJvyxajD9XC5kC8+Wpk7HAR8mSNiEe4beCHazxFWFaOGivTjSywzWeymEalsbdcxBCJ4AvBIegZ3BAcTTD/bZ7ngvJSx/OfnlJi4pZMDx6A7QJB81EI2Zl6rPh0xuVbKL0Qv2vU6gvAukziglvgTWvBBaSuqiEpAH6LKN9xro0Aq0kJ6O8v7F1/3QVG4VRtO2lT/zqsnYcBaKUrjNV2dAZ0BEv8cgk2tslyFDyKsyZX1R7CwTLpFshcXe8Am1lHmawyO5otaVArc42J8Yf4Q/g2u48le3RplY/K9UXwwd07fClnN9wSQ7CqI4GJApLZgDNGj+vQmxHUz1M3eE7NwyeL4+YlsHuq4nodI6lDclVrIOyp6UMglZfF0s1eNp5gDNn91aFwN70Bqe4UQViIuxZ2IE8GJ/1hOSdbzgnDWARxQRsQUajKX7xQ/SCeGesgIexshbJLNHD8DGSVv/891/6r/ALTftHlH2Cm8bWWxih3baDwk99qhFGCRAMqWxsd7tRFRpYac3o86cKgfqKlLzic+D+At595K1IgRFhQd4833jgQ/7L9NKCcxNHedYDOQnnVFsdoKg36ca4qd10vuFhOINBEgYcRS3wRon8Qf5b9+9UlD6ML7zHu2Pc6hAHlUL2zDCbXT+zD7/7G+U5vc2r2GlOHuqEFDAL6T8t3zQDps15EvNkdCBJq6Wy/hOV73+piA+jQfeStPVGfPaUTFofwBu1gao5zzbFQpzomIcgYEmBC9uhFa4tV1rAzQay758NNw3qLRQzSGWKJeeSx3gDQUdtvTu80vt/MriOjmLXAkotCtniBHR0zoW+63FqJ4xaA6xY+BincOUKP7yXFE2SZ6U8b5yVcf1buZpvmY7U4DYzAu+UhCPXw9l992U56aEgoMpmN0516x/PbKXwwwKk3hGhsOaBnH1TL9Iha7uC/+xEMKcR3GEXXLOujCkcnVvl2jLKFDizOnY0K/ifIbum2tFRDgDsaaYpndZwaNy7YgJAHVgzRHBxT1btlogd5qWHUgl+mhTmVG0+BAQTG5F83xDzKS/3HpQX3ZvsTFnwoZIPO7xHzUrUXJO02yoummqtWi9taDEB3lpaTSf2rLIy8zDy8KRoveVjDrUjkPDZYdcj45UpNs0+YmrK3+tH3wzStls2if0a5tgINeKOPwAw9 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 12:39:09.2554 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3e6ff99-f889-46ad-fa17-08dccc156823 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=[SATLEXMB03.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: SJ1PR12MB6025 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 Reviewed-by: Ilpo Järvinen --- 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 | 64 ++------------- drivers/platform/x86/amd/hsmp/hsmp.h | 9 +-- drivers/platform/x86/amd/hsmp/plat.c | 113 +++++++++++++++++++++------ 4 files changed, 140 insertions(+), 111 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index 766617e6adc7..d226f7deb49b 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 8c8e361b1feb..e7df514c699c 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -278,19 +278,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; } @@ -301,12 +298,12 @@ 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; } -static int hsmp_get_tbl_dram_base(u16 sock_ind) +int hsmp_get_tbl_dram_base(u16 sock_ind) { struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind]; struct hsmp_message msg = { 0 }; @@ -339,53 +336,6 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind) return 0; } -umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, - struct bin_attribute *battr, int id) -{ - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) - return battr->attr.mode; - else - return 0; -} - -static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock_ind) -{ - struct bin_attribute *hattr = &hsmp_pdev.sock[sock_ind].hsmp_attr; - - sysfs_bin_attr_init(hattr); - hattr->attr.name = HSMP_METRICS_TABLE_NAME; - hattr->attr.mode = 0444; - hattr->read = hsmp_metric_tbl_read; - hattr->size = sizeof(struct hsmp_metric_table); - hattr->private = &hsmp_pdev.sock[sock_ind]; - hattrs[0] = hattr; - - if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) - return hsmp_get_tbl_dram_base(sock_ind); - else - return 0; -} - -/* One bin sysfs for metrics table */ -#define NUM_HSMP_ATTRS 1 - -int hsmp_create_attr_list(struct attribute_group *attr_grp, - struct device *dev, u16 sock_ind) -{ - struct bin_attribute **hsmp_bin_attrs; - - /* Null terminated list of attributes */ - hsmp_bin_attrs = devm_kcalloc(dev, NUM_HSMP_ATTRS + 1, - sizeof(*hsmp_bin_attrs), - GFP_KERNEL); - if (!hsmp_bin_attrs) - return -ENOMEM; - - attr_grp->bin_attrs = hsmp_bin_attrs; - - return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind); -} - int hsmp_cache_proto_ver(u16 sock_ind) { struct hsmp_message msg = { 0 }; diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 9ab50bc74676..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 e49b53f8c5e3..a1f42163db57 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include @@ -61,36 +62,93 @@ static const struct file_operations hsmp_fops = { .compat_ioctl = hsmp_ioctl, }; -static int hsmp_create_non_acpi_sysfs_if(struct device *dev) +static ssize_t hsmp_metric_tbl_plat_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { - const struct attribute_group **hsmp_attr_grps; - struct attribute_group *attr_grp; - u16 i; + struct hsmp_socket *sock; + u16 sock_ind; - hsmp_attr_grps = devm_kcalloc(dev, hsmp_pdev.num_sockets + 1, - sizeof(*hsmp_attr_grps), - GFP_KERNEL); - if (!hsmp_attr_grps) - return -ENOMEM; + sock_ind = (uintptr_t)bin_attr->private; + if (sock_ind >= hsmp_pdev.num_sockets) + return -EINVAL; - /* Create a sysfs directory for each socket */ - for (i = 0; i < hsmp_pdev.num_sockets; i++) { - attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), - GFP_KERNEL); - if (!attr_grp) - return -ENOMEM; + sock = &hsmp_pdev.sock[sock_ind]; - snprintf(hsmp_pdev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); - attr_grp->name = hsmp_pdev.sock[i].name; - attr_grp->is_bin_visible = hsmp_is_sock_attr_visible; - hsmp_attr_grps[i] = attr_grp; + return hsmp_metric_tbl_read(sock, buf, count); +} - hsmp_create_attr_list(attr_grp, dev, i); - } +static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, + struct bin_attribute *battr, int id) +{ + u16 sock_ind; + + sock_ind = (uintptr_t)battr->private; + + if (id == 0 && sock_ind >= hsmp_pdev.num_sockets) + return SYSFS_GROUP_INVISIBLE; - return device_add_groups(dev, hsmp_attr_grps); + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) + return battr->attr.mode; + + return 0; } +/* + * AMD supports maximum of 8 sockets in a system. + * Static array of 8 + 1(for NULL) elements is created below + * to create sysfs groups for sockets. + * is_bin_visible function is used to show / hide the necessary groups. + */ +#define HSMP_BIN_ATTR(index, _list) \ +static struct bin_attribute attr##index = { \ + .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444}, \ + .private = (void *)index, \ + .read = hsmp_metric_tbl_plat_read, \ + .size = sizeof(struct hsmp_metric_table), \ +}; \ +static struct bin_attribute _list[] = { \ + &attr##index, \ + NULL \ +} + +HSMP_BIN_ATTR(0, *sock0_attr_list); +HSMP_BIN_ATTR(1, *sock1_attr_list); +HSMP_BIN_ATTR(2, *sock2_attr_list); +HSMP_BIN_ATTR(3, *sock3_attr_list); +HSMP_BIN_ATTR(4, *sock4_attr_list); +HSMP_BIN_ATTR(5, *sock5_attr_list); +HSMP_BIN_ATTR(6, *sock6_attr_list); +HSMP_BIN_ATTR(7, *sock7_attr_list); + +#define HSMP_BIN_ATTR_GRP(index, _list, _name) \ +static struct attribute_group sock##index##_attr_grp = { \ + .bin_attrs = _list, \ + .is_bin_visible = hsmp_is_sock_attr_visible, \ + .name = #_name, \ +} + +HSMP_BIN_ATTR_GRP(0, sock0_attr_list, socket0); +HSMP_BIN_ATTR_GRP(1, sock1_attr_list, socket1); +HSMP_BIN_ATTR_GRP(2, sock2_attr_list, socket2); +HSMP_BIN_ATTR_GRP(3, sock3_attr_list, socket3); +HSMP_BIN_ATTR_GRP(4, sock4_attr_list, socket4); +HSMP_BIN_ATTR_GRP(5, sock5_attr_list, socket5); +HSMP_BIN_ATTR_GRP(6, sock6_attr_list, socket6); +HSMP_BIN_ATTR_GRP(7, sock7_attr_list, socket7); + +static const struct attribute_group *hsmp_groups[] = { + &sock0_attr_grp, + &sock1_attr_grp, + &sock2_attr_grp, + &sock3_attr_grp, + &sock4_attr_grp, + &sock5_attr_grp, + &sock6_attr_grp, + &sock7_attr_grp, + NULL +}; + static inline bool is_f1a_m0h(void) { if (boot_cpu_data.x86 == 0x1A && boot_cpu_data.x86_model <= 0x0F) @@ -141,6 +199,12 @@ static int init_platform_device(struct device *dev) dev_err(dev, "Failed to read HSMP protocol version\n"); return ret; } + + if (hsmp_pdev.proto_ver == HSMP_PROTO_VER6) { + ret = hsmp_get_tbl_dram_base(i); + if (ret) + dev_err(dev, "Failed to init metric table\n"); + } } return 0; @@ -162,10 +226,6 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev) return ret; } - ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev); - if (ret) - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n"); - return hsmp_misc_register(&pdev->dev); } @@ -179,6 +239,7 @@ static struct platform_driver amd_hsmp_driver = { .remove_new = hsmp_pltdrv_remove, .driver = { .name = DRIVER_NAME, + .dev_groups = hsmp_groups, }, };