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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iam3pwOHyCjOUL/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