On Thu, Feb 03, 2022 at 05:34:49PM +0530, Naveen Krishna Chatradhi wrote: > From: Suma Hegde <suma.hegde@xxxxxxx> > [...] > > .../userspace-api/ioctl/ioctl-number.rst | 2 + > arch/x86/include/asm/amd_hsmp.h | 16 + > arch/x86/include/uapi/asm/amd_hsmp.h | 56 +++ > drivers/platform/x86/Kconfig | 13 + > drivers/platform/x86/Makefile | 1 + > drivers/platform/x86/amd_hsmp.c | 450 ++++++++++++++++++ We added new files. Shall we update MAINTAINERS? > 6 files changed, 538 insertions(+) > create mode 100644 arch/x86/include/asm/amd_hsmp.h > create mode 100644 arch/x86/include/uapi/asm/amd_hsmp.h > create mode 100644 drivers/platform/x86/amd_hsmp.c > > diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst > index 687efcf245c1..663e316d320c 100644 > --- a/Documentation/userspace-api/ioctl/ioctl-number.rst > +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst > @@ -372,6 +372,8 @@ Code Seq# Include File Comments [...] > diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/asm/amd_hsmp.h > new file mode 100644 > index 000000000000..42cdac8a331d > --- /dev/null > +++ b/arch/x86/include/uapi/asm/amd_hsmp.h > @@ -0,0 +1,56 @@ > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > + > +#ifndef _UAPI_ASM_X86_AMD_HSMP_H_ > +#define _UAPI_ASM_X86_AMD_HSMP_H_ > + > +#include <linux/types.h> > + > +#pragma pack(4) > + > +#define HSMP_MAX_MSG_LEN 8 > + > +/* > + * HSMP Messages supported > + */ > +enum hsmp_message_ids { > + HSMP_TEST = 1, /* 01h Increments input value by 1 */ > + HSMP_GET_SMU_VER, /* 02h SMU FW version */ > + HSMP_GET_PROTO_VER, /* 03h HSMP interface version */ > + HSMP_GET_SOCKET_POWER, /* 04h average package power consumption */ > + HSMP_SET_SOCKET_POWER_LIMIT, /* 05h Set the socket power limit */ > + HSMP_GET_SOCKET_POWER_LIMIT, /* 06h Get current socket power limit */ > + HSMP_GET_SOCKET_POWER_LIMIT_MAX,/* 07h Get maximum socket power value */ > + HSMP_SET_BOOST_LIMIT, /* 08h Set a core maximum frequency limit */ > + HSMP_SET_BOOST_LIMIT_SOCKET, /* 09h Set socket maximum frequency level */ > + HSMP_GET_BOOST_LIMIT, /* 0Ah Get current frequency limit */ > + HSMP_GET_PROC_HOT, /* 0Bh Get PROCHOT status */ > + HSMP_SET_XGMI_LINK_WIDTH, /* 0Ch Set max and min width of xGMI Link */ > + HSMP_SET_DF_PSTATE, /* 0Dh Alter APEnable/Disable messages behavior */ > + HSMP_SET_AUTO_DF_PSTATE, /* 0Eh Enable DF P-State Performance Boost algorithm */ > + HSMP_GET_FCLK_MCLK, /* 0Fh Get FCLK and MEMCLK for current socket */ > + HSMP_GET_CCLK_THROTTLE_LIMIT, /* 10h Get CCLK frequency limit in socket */ > + HSMP_GET_C0_PERCENT, /* 11h Get average C0 residency in socket */ > + HSMP_SET_NBIO_DPM_LEVEL, /* 12h Set max/min LCLK DPM Level for a given NBIO */ > + HSMP_RESERVED, /* 13h Reserved */ > + HSMP_GET_DDR_BANDWIDTH, /* 14h Get theoretical maximum and current DDR Bandwidth */ > + HSMP_GET_TEMP_MONITOR, /* 15h Get per-DIMM temperature and refresh rates */ > + HSMP_MSG_ID_MAX, > +}; > + > +struct hsmp_message { > + __u32 msg_id; /* Message ID */ > + __u16 num_args; /* Number of arguments in message */ > + __u16 response_sz; /* Number of expected response words */ > + __u32 args[HSMP_MAX_MSG_LEN]; /* Argument(s) */ > + __u32 response[HSMP_MAX_MSG_LEN]; /* Response word(s) */ > + __u16 sock_ind; /* socket number */ > +}; IIUC, we rely on user space to know (from other sources) the proper num_args and response_sz for each message_id. The only check applied by the kernel is "num_args <= HSMP_MAX_MSG_LEN && response_sz <= HSMP_MAX_MSG_LEN". How about we explicitly call out those constraints in amd_hsmp.h? Maybe something like: struct hsmp_msg_format { int msg_id; int num_args; int response_sz; }; struct hsmp_msg_format hsmp_msg_format_table = { { HSMP_TEST, 1, 1}, /* more */ }; Thanks, Song [...]