Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / ras / amd / atl / prm.c
blob0931a20d213b61be748007659e6de28745c0105a
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * AMD Address Translation Library
5 * prm.c : Plumbing code for ACPI Platform Runtime Mechanism (PRM)
7 * Information on AMD PRM modules and handlers including the GUIDs and buffer
8 * structures used here are defined in the AMD ACPI Porting Guide in the
9 * chapter "Platform Runtime Mechanism Table (PRMT)"
11 * Copyright (c) 2024, Advanced Micro Devices, Inc.
12 * All Rights Reserved.
14 * Author: John Allen <john.allen@amd.com>
17 #include "internal.h"
19 #include <linux/prmt.h>
22 * PRM parameter buffer - normalized to system physical address, as described
23 * in the "PRM Parameter Buffer" section of the AMD ACPI Porting Guide.
25 struct norm_to_sys_param_buf {
26 u64 norm_addr;
27 u8 socket;
28 u64 bank_id;
29 void *out_buf;
30 } __packed;
32 static const guid_t norm_to_sys_guid = GUID_INIT(0xE7180659, 0xA65D, 0x451D,
33 0x92, 0xCD, 0x2B, 0x56, 0xF1,
34 0x2B, 0xEB, 0xA6);
36 unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
38 struct norm_to_sys_param_buf p_buf;
39 unsigned long ret_addr;
40 int ret;
42 p_buf.norm_addr = addr;
43 p_buf.socket = socket_id;
44 p_buf.bank_id = bank_id;
45 p_buf.out_buf = &ret_addr;
47 ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf);
48 if (!ret)
49 return ret_addr;
51 if (ret == -ENODEV)
52 pr_debug("PRM module/handler not available\n");
53 else
54 pr_notice_once("PRM address translation failed\n");
56 return ret;