History

misc: amd-sbi: Add support for AMD_SBI IOCTL

The present sbrmi module only support reporting power via hwmon. However, AMD data center range of processors support various system management functionality using custom protocols defined in Advanced Platform Management Link (APML) specification. Register a miscdevice, which creates a device /dev/sbrmiX with an IOCTL interface for the user space to invoke the APML Mailbox protocol, which is already defined in sbrmi_mailbox_xfer(). The APML protocols depend on a set of RMI registers. Having an IOCTL as a single entry point will help in providing synchronization among these protocols as multiple transactions on RMI register set may create race condition. Support for other protocols will be added in subsequent patches. APML mailbox protocol returns additional error codes written by SMU firmware in the out-bound register 0x37. These errors include, invalid core, message not supported over platform and others. This additional error codes can be used to provide more details to user space. Open-sourced and widely used https://github.com/amd/esmi_oob_library will continue to provide user-space programmable API.

Akshay Gupta committed 1 year ago

Commit 35ac2031 parent 587d2c67 files · +167 −32Browse files

Showing the changes to include/uapi (1 of 7 files). Show all

Unified · Split

include/uapi/misc/amd-apml.h+51−0
@@ -0,0 +1,51 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+/*
3+ * Copyright (C) 2021-2024 Advanced Micro Devices, Inc.
4+ */
5+#ifndef _AMD_APML_H_
6+#define _AMD_APML_H_
7+
8+#include <linux/types.h>
9+
10+/* Mailbox data size for data_in and data_out */
11+#define AMD_SBI_MB_DATA_SIZE 4
12+
13+struct apml_mbox_msg {
14+ /*
15+ * Mailbox Message ID
16+ */
17+ __u32 cmd;
18+ /*
19+ * [0]...[3] mailbox 32bit input/output data
20+ */
21+ __u32 mb_in_out;
22+ /*
23+ * Error code is returned in case of soft mailbox error
24+ */
25+ __u32 fw_ret_code;
26+};
27+
28+/*
29+ * AMD sideband interface base IOCTL
30+ */
31+#define SB_BASE_IOCTL_NR 0xF9
32+
33+/**
34+ * DOC: SBRMI_IOCTL_MBOX_CMD
35+ *
36+ * @Parameters
37+ *
38+ * @struct apml_mbox_msg
39+ * Pointer to the &struct apml_mbox_msg that will contain the protocol
40+ * information
41+ *
42+ * @Description
43+ * IOCTL command for APML messages using generic _IOWR
44+ * The IOCTL provides userspace access to AMD sideband mailbox protocol
45+ * - Mailbox message read/write(0x0~0xFF)
46+ * - returning "-EFAULT" if none of the above
47+ * "-EPROTOTYPE" error is returned to provide additional error details
48+ */
49+#define SBRMI_IOCTL_MBOX_CMD _IOWR(SB_BASE_IOCTL_NR, 0, struct apml_mbox_msg)
50+
51+#endif /*_AMD_APML_H_*/