File: prm.c

package info (click to toggle)
linux 6.19.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,760,000 kB
  • sloc: ansic: 27,013,505; asm: 273,421; sh: 151,386; python: 81,301; makefile: 58,566; perl: 34,311; xml: 21,064; cpp: 5,986; yacc: 4,841; lex: 2,901; awk: 1,707; sed: 30; ruby: 25
file content (53 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * AMD Address Translation Library
 *
 * prm.c : Plumbing code for ACPI Platform Runtime Mechanism (PRM)
 *
 * Information on AMD PRM modules and handlers including the GUIDs and buffer
 * structures used here are defined in the AMD ACPI Porting Guide in the
 * chapter "Platform Runtime Mechanism Table (PRMT)"
 *
 * Copyright (c) 2024, Advanced Micro Devices, Inc.
 * All Rights Reserved.
 *
 * Author: John Allen <john.allen@amd.com>
 */

#include "internal.h"

#include <linux/prmt.h>

/*
 * PRM parameter buffer - normalized to system physical address, as described
 * in the "PRM Parameter Buffer" section of the AMD ACPI Porting Guide.
 */
struct norm_to_sys_param_buf {
	u64 norm_addr;
	u8 socket;
	u64 bank_id;
	void *out_buf;
} __packed;

unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
{
	struct norm_to_sys_param_buf p_buf;
	unsigned long ret_addr;
	int ret;

	p_buf.norm_addr = addr;
	p_buf.socket    = socket_id;
	p_buf.bank_id   = bank_id;
	p_buf.out_buf   = &ret_addr;

	ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf);
	if (!ret)
		return ret_addr;

	if (ret == -ENODEV)
		pr_debug("PRM module/handler not available\n");
	else
		pr_notice_once("PRM address translation failed\n");

	return ret;
}