Add character devices for indices and platform-dump RTAS
cover Add character devices for indices and platform-dump RTAS
Several APIs such as rtas_get_indices(), rtas_get_dynamic_sensor(), rtas_set_dynamic_indicator() and rtas_platform_dump() provided by librtas library are implemented in user space using rtas syscall in combination with writable mappings of /dev/mem. But this implementation is not compatible with system lockdown which prohibits /dev/mem access. The current kernel already provides char based driver interfaces for several RTAS calls such as VPD and system parameters to support lockdown feature.
This patch series adds new char based drivers, /dev/papr-indices for ibm,get-indices, ibm,get-dynamic-sensor-state and ibm,set-dynamic-indicator RTAS Calls. and /dev/papr-platform-dump for ibm,platform-dump. Providing the similar open/ioctl/read interfaces to the user space as in the case of VPD and system parameters.
I have made changes to librtas library to use the new kernel interfaces if the corresponding device entry is available.
This patch series has the following patches:
powerpc/pseries: Define common functions for RTAS sequence HCALLs
- For some of sequence based RTAS calls, the OS should not start another sequence with different input until the previous sequence is completed. So the sequence should be completed during ioctl() and expose the entire buffer during read(). ibm,get-indices is sequence based RTAS function similar to ibm,get-vpd and we already have the corresponding implementation for VPD driver. So update papr_rtas_sequence struct for RTAS call specific functions and move the top level sequence functions in to a separate file.
powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
- /dev/papr-indices driver supports ibm,get-indices, ibm,get-dynamic-sensor-state and ibm,set-dynamic-indicator RTAS Calls. papr-indices.h introduces 3 different ioctls for these RTAS calls and the corresponding ioctl input buffer.
powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL
- Introduce /dev/papr-indices char based driver and add support for get-indices RTAS function
powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
- Update /dev/papr-indices for set-dynamic-indicator RTAS function
powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
- Update /dev/papr-indices for get-dynamic-sensor-state RTAS function
powerpc/pseries: Add papr-platform-dump character driver for dump
retrieval
- Introduce /dev/papr-platform-dump char driver and adds support for ibm,platform-dump. Received suggestions from the previous post as a separate patch - Updated the patch with invalidating the dump using a separate ioctl.
Haren Myneni (6):
powerpc/pseries: Define common functions for RTAS sequence HCALLs powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls powerpc/pseries: Add papr-indices char driver for ibm,get-indices
HCALL
powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support powerpc/pseries: Add papr-platform-dump character driver for dump
retrieval
arch/powerpc/include/asm/rtas.h | 3 + arch/powerpc/include/uapi/asm/papr-indices.h | 41 ++ .../include/uapi/asm/papr-platform-dump.h | 15 + arch/powerpc/kernel/rtas.c | 6 +- arch/powerpc/platforms/pseries/Makefile | 3 +- arch/powerpc/platforms/pseries/papr-indices.c | 552 ++++++++++++++++++ .../platforms/pseries/papr-platform-dump.c | 408 +++++++++++++ .../platforms/pseries/papr-rtas-common.c | 243 ++++++++ .../platforms/pseries/papr-rtas-common.h | 45 ++ arch/powerpc/platforms/pseries/papr-vpd.c | 266 ++------- 10 files changed, 1356 insertions(+), 226 deletions(-) create mode 100644 arch/powerpc/include/uapi/asm/papr-indices.h create mode 100644 arch/powerpc/include/uapi/asm/papr-platform-dump.h create mode 100644 arch/powerpc/platforms/pseries/papr-indices.c create mode 100644 arch/powerpc/platforms/pseries/papr-platform-dump.c create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.c create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.h
Signature · 1 line
2.43.5
PATCH 1/6 powerpc/pseries: Define common functions for RTAS sequence HCALLs
The RTAS call can be normal where retrieves the data form the hypervisor with one HCALL or sequence based HCALL which has to issue multiple times until the complete data is obtained. For some of these sequence HCALLs, the OS should not interleave calls with different input until the sequence is completed. The data is collected for each HCALL and copy to the buffer for the entire sequence during ioctl() handle and then expose this buffer to the user space with read() handle.
One such sequence RTAS call is ibm,get-vpd and its support is already included in the current code. To add the similar support for other sequence HCALLs, move the common functions in to separate file and update papr_rtas_sequence struct with the following callbacks so that HCALL specific code will be defined and executed to complete the sequence.
struct papr_rtas_sequence {
int error;
void params;
void (*begin) (struct papr_rtas_sequence *, void *);
void (*end) (struct papr_rtas_sequence *);
const char * (*work) (struct papr_rtas_sequence *, size_t *);
};params: Input parameters used to pass for HCALL.
Begin: HCALL specific function to initialize data including
work area allocation.
End: HCALL specific function to free up resources (free
work area) after the sequence is completed.
Work: The actual HCALL specific function which collects the
data from the hypervisor.
--- arch/powerpc/platforms/pseries/Makefile | 2 +- .../platforms/pseries/papr-rtas-common.c | 243 ++++++++++++++++ .../platforms/pseries/papr-rtas-common.h | 45 +++ arch/powerpc/platforms/pseries/papr-vpd.c | 266 +++--------------- 4 files changed, 333 insertions(+), 223 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.c create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.h
arch/powerpc/platforms/pseries/Makefile +1 -1
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ - papr-vpd.o \ + papr-rtas-common.o papr-vpd.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o \
arch/powerpc/platforms/pseries/papr-rtas-common.c new file +243 -0
243 lines not on this page · raw message
arch/powerpc/platforms/pseries/papr-rtas-common.h new file +45 -0
45 lines not on this page · raw message
arch/powerpc/platforms/pseries/papr-vpd.c +44 -222
384 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH 2/6 powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
In reply to Haren MyneniTo issue ibm,get-indices, ibm,set-dynamic-indicator and ibm,get-dynamic-sensor-state in the user space, the RMO buffer is allocated for the work area which is restricted under system lockdown. So instead of user space execution, the kernel will provide /dev/papr-indices interface to execute these RTAS HCALLs.
The user space assigns data in papr_indices_io_block struct depends on the specific HCALL and passes to the following ioctls:
PAPR_INDICES_IOC_GET: Use for ibm,get-indices. Returns a
get-indices handle fd to read data.PAPR_DYNAMIC_SENSOR_IOC_GET: Use for ibm,get-dynamic-sensor-state.
Updates the sensor state in papr_indices_io_block.dynamic_param.state
PAPR_DYNAMIC_INDICATOR_IOC_SET: Use for ibm,set-dynamic-indicator.
Sets the new state for the input indicator.
--- arch/powerpc/include/uapi/asm/papr-indices.h | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/papr-indices.h
arch/powerpc/include/uapi/asm/papr-indices.h new file +41 -0
@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_PAPR_INDICES_H_ +#define _UAPI_PAPR_INDICES_H_ + +#include <linux/types.h> +#include <asm/ioctl.h> +#include <asm/papr-miscdev.h> + +#define LOC_CODE_SIZE 80 +#define RTAS_GET_INDICES_BUF_SIZE SZ_4K + +struct papr_indices_io_block { +union { +struct { +__u8 is_sensor;/* 0 for indicator and 1 for sensor */ +__u32 indice_type; + } indices; +struct { +__u32 token;/* Sensor or indicator token */ +__u32 state;/* get / set state */ +/* +* PAPR+ 12.3.2.4 Converged Location Code Rules - Length +* Restrictions. 79 characters plus null. +*/ +char location_code_str[LOC_CODE_SIZE ];/* location code */ + } dynamic_param; + }; +}; + +/* +* ioctls for /dev/papr-indices. +* PAPR_INDICES_IOC_GET: Returns a get-indices handle fd to read data +* PAPR_DYNAMIC_SENSOR_IOC_GET: Gets the state of the input sensor +* PAPR_DYNAMIC_INDICATOR_IOC_SET: Sets the new state for the input indicator +*/ +#define PAPR_INDICES_IOC_GET _IOW(PAPR_MISCDEV_IOC_ID, 3, struct papr_indices_io_block) +#define PAPR_DYNAMIC_SENSOR_IOC_GET _IOWR(PAPR_MISCDEV_IOC_ID, 4, struct papr_indices_io_block) +#define PAPR_DYNAMIC_INDICATOR_IOC_SET _IOW(PAPR_MISCDEV_IOC_ID, 5, struct papr_indices_io_block) + + +#endif /* _UAPI_PAPR_INDICES_H_ */
Signature · 1 line
2.43.5
PATCH 3/6 powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL
In reply to Haren MyneniThe RTAS call ibm,get-indices is used to obtain indices and location codes for a specified indicator or sensor token. The current implementation uses rtas_get_indices() API provided by librtas library which allocates RMO buffer and issue this RTAS call in the user space. But writable mapping /dev/mem access by the user space is prohibited under system lockdown.
To overcome the restricted access in the user space, the kernel provide interfaces to collect indices data from the hypervisor. This patch adds papr-indices character driver and expose standard interfaces such as open / ioctl/ read to user space in ways that are compatible with lockdown.
PAPR (2.13 7.3.17 ibm,get-indices RTAS Call) describes the following steps to retrieve all indices data:
- User input parameters to the RTAS call: sensor or indicator, and indice type
- ibm,get-indices is sequence RTAS call which means has to issue multiple times to get the entire list of indicators or sensors of a particular type. The hypervisor expects the first RTAS call with the sequence 1 and the subsequent calls with the sequence number returned from the previous calls.
- The OS may not interleave calls to ibm,get-indices for different indicator or sensor types. Means other RTAS calls with different type should not be issued while the previous type sequence is in progress. So collect the entire list of indices and copied to buffer BLOB during ioctl() and expose this buffer to the user space with the file descriptor.
- The hypervisor fills the work area with a specific format but does not return the number of bytes written to the buffer. Instead of parsing the data for each call to determine the data length, copy the work area size (RTAS_GET_INDICES_BUF_SIZE) to the buffer. Return work-area size of data to the user space for each read() call.
Expose these interfaces to user space with a /dev/papr-indices character device using the following programming model:
int devfd = open("/dev/papr-indices", O_RDONLY);
int fd = ioctl(devfd, PAPR_INDICES_IOC_GET,
struct papr_indices_io_block)
- Collect all indices data for the specified token to the buffer
char *buf = malloc(RTAS_GET_INDICES_BUF_SIZE);
length = read(fd, buf, RTAS_GET_INDICES_BUF_SIZE)
- RTAS_GET_INDICES_BUF_SIZE of data is returned to the user space.
- The user space retrieves the indices and their location codes from the buffer
- Should issue multiple read() calls until reaches the end of BLOB buffer.
The read() should use the file descriptor obtained from ioctl to get the data that is exposed to file descriptor. Implemented support in librtas (rtas_get_indices()) for this new ABI for system lockdown.
--- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/platforms/pseries/Makefile | 2 +- arch/powerpc/platforms/pseries/papr-indices.c | 369 ++++++++++++++++++ 4 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/papr-indices.c
arch/powerpc/include/asm/rtas.h +1 -0
@@ -515,6 +515,7 @@ extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];extern unsigned long rtas_rmo_buf;extern struct mutex rtas_ibm_get_vpd_lock; +extern struct mutex rtas_ibm_get_indices_lock;#define GLOBAL_INTERRUPT_QUEUE 9005
arch/powerpc/kernel/rtas.c +1 -1
@@ -93,11 +93,11 @@ struct rtas_function {*/ static DEFINE_MUTEX (rtas_ibm_activate_firmware_lock);static DEFINE_MUTEX (rtas_ibm_get_dynamic_sensor_state_lock); -static DEFINE_MUTEX (rtas_ibm_get_indices_lock);static DEFINE_MUTEX (rtas_ibm_lpar_perftools_lock);static DEFINE_MUTEX (rtas_ibm_physical_attestation_lock);static DEFINE_MUTEX (rtas_ibm_set_dynamic_indicator_lock);DEFINE_MUTEX (rtas_ibm_get_vpd_lock); +DEFINE_MUTEX (rtas_ibm_get_indices_lock);static struct rtas_function rtas_function_table[]__ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION ] = {
arch/powerpc/platforms/pseries/Makefile +1 -1
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ - papr-rtas-common.o papr-vpd.o \ + papr-rtas-common.o papr-vpd.o papr-indices.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o \
arch/powerpc/platforms/pseries/papr-indices.c new file +369 -0
369 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH 4/6 powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
In reply to Haren MyneniThe RTAS call ibm,set-dynamic-indicator is used to set the new indicator state identified by a location code. The current implementation uses rtas_set_dynamic_indicator() API provided by librtas library which allocates RMO buffer and issue this RTAS call in the user space. But /dev/mem access by the user space is prohibited under system lockdown.
This patch provides an interface with new ioctl PAPR_DYNAMIC_INDICATOR_IOC_SET to the papr-indices character driver and expose this interface to the user space that is compatible with lockdown.
Refer PAPR 7.3.18 ibm,set-dynamic-indicator for more information on this RTAS call.
- User input parameters to the RTAS call: location code string, indicator token and new state
Expose these interfaces to user space with a /dev/papr-indices character device using the following programming model:
int fd = open("/dev/papr-indices", O_RDWR);
int ret = ioctl(fd, PAPR_DYNAMIC_INDICATOR_IOC_SET,
struct papr_indices_io_block)
- The user space passes input parameters in papr_indices_io_block struct
--- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/platforms/pseries/papr-indices.c | 119 ++++++++++++++++++ 3 files changed, 121 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/rtas.h +1 -0
@@ -516,6 +516,7 @@ extern unsigned long rtas_rmo_buf;extern struct mutex rtas_ibm_get_vpd_lock;extern struct mutex rtas_ibm_get_indices_lock; +extern struct mutex rtas_ibm_set_dynamic_indicator_lock;#define GLOBAL_INTERRUPT_QUEUE 9005
arch/powerpc/kernel/rtas.c +1 -1
@@ -95,9 +95,9 @@ static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock);static DEFINE_MUTEX (rtas_ibm_get_dynamic_sensor_state_lock);static DEFINE_MUTEX (rtas_ibm_lpar_perftools_lock);static DEFINE_MUTEX (rtas_ibm_physical_attestation_lock); -static DEFINE_MUTEX (rtas_ibm_set_dynamic_indicator_lock);DEFINE_MUTEX (rtas_ibm_get_vpd_lock);DEFINE_MUTEX (rtas_ibm_get_indices_lock); +DEFINE_MUTEX (rtas_ibm_set_dynamic_indicator_lock);static struct rtas_function rtas_function_table[]__ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION ] = {
arch/powerpc/platforms/pseries/papr-indices.c +119 -0
143 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH 5/6 powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
In reply to Haren MyneniThe RTAS call ibm,get-dynamic-sensor-state is used to get the sensor state identified by the location code and the sensor token. The librtas library provides an API rtas_get_dynamic_sensor() which uses /dev/mem access for work area allocation but is restricted under system lockdown.
This patch provides an interface with new ioctl
PAPR_DYNAMIC_SENSOR_IOC_GET to the papr-indices character
driver which executes this HCALL and copies the sensor state in the user specified ioctl buffer.
Refer PAPR 7.3.19 ibm,get-dynamic-sensor-state for more information on this RTAS call.
- User input parameters to the RTAS call: location code string and the sensor token
Expose these interfaces to user space with a /dev/papr-indices character device using the following programming model:
int fd = open("/dev/papr-indices", O_RDWR);
int ret = ioctl(fd, PAPR_DYNAMIC_SENSOR_IOC_GET,
struct papr_indices_io_block)
- The user space specifies input parameters in papr_indices_io_block struct
- Returned state for the specified sensor is copied to papr_indices_io_block.dynamic_param.state
--- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/platforms/pseries/papr-indices.c | 64 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/rtas.h +1 -0
@@ -517,6 +517,7 @@ extern unsigned long rtas_rmo_buf;extern struct mutex rtas_ibm_get_vpd_lock;extern struct mutex rtas_ibm_get_indices_lock;extern struct mutex rtas_ibm_set_dynamic_indicator_lock; +extern struct mutex rtas_ibm_get_dynamic_sensor_state_lock;#define GLOBAL_INTERRUPT_QUEUE 9005
arch/powerpc/kernel/rtas.c +1 -1
@@ -92,12 +92,12 @@ struct rtas_function {* Per-function locks for sequence-based RTAS functions. */ static DEFINE_MUTEX (rtas_ibm_activate_firmware_lock); -static DEFINE_MUTEX (rtas_ibm_get_dynamic_sensor_state_lock);static DEFINE_MUTEX (rtas_ibm_lpar_perftools_lock);static DEFINE_MUTEX (rtas_ibm_physical_attestation_lock);DEFINE_MUTEX (rtas_ibm_get_vpd_lock);DEFINE_MUTEX (rtas_ibm_get_indices_lock);DEFINE_MUTEX (rtas_ibm_set_dynamic_indicator_lock); +DEFINE_MUTEX (rtas_ibm_get_dynamic_sensor_state_lock);static struct rtas_function rtas_function_table[]__ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION ] = {
arch/powerpc/platforms/pseries/papr-indices.c +64 -0
82 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH 6/6 powerpc/pseries: Add papr-platform-dump character driver for dump retrieval
In reply to Haren Myneniibm,platform-dump RTAS call in combination with writable mapping /dev/mem is issued to collect platform dump from the hypervisor and may need multiple calls to get the complete dump. The current implementation uses rtas_platform_dump() API provided by librtas library to issue these HCALLs. But /dev/mem access by the user space is prohibited under system lockdown.
The solution should be to restrict access to RTAS function in user space and provide kernel interfaces to collect dump. This patch adds papr-platform-dump character driver and expose standard interfaces such as open / ioctl/ read to user space in ways that are compatible with lockdown.
PAPR (7.3.3.4.1 ibm,platform-dump) provides a method to obtain the complete dump:
- Each dump will be identified by ID called dump tag.
- A sequence of RTAS calls have to be issued until retrieve the complete dump. The hypervisor expects the first RTAS call with the sequence 0 and the subsequent calls with the sequence number returned from the previous calls.
- The hypervisor returns "dump complete" status once the complete dump is retrieved. But expects one more RTAS call from the partition with the NULL buffer to invalidate dump which means the dump will be removed in the hypervisor.
- Sequence of calls are allowed with different dump IDs at the same time but not with the same dump ID.
Expose these interfaces to user space with a /dev/papr-platform-dump character device using the following programming model:
int devfd = open("/dev/papr-platform-dump", O_RDONLY); int fd = ioctl(devfd,PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE, &dump_id)
- Restrict user space to access with the same dump ID. Typically we do not expect user space requests the dump again for the same dump ID.
char *buf = malloc(size);
length = read(fd, buf, size);
- size should be minimum 1K based on PAPR and <= 4K based on RTAS work area size. It will be restrict to RTAS work area size. Using 4K work area based on the current implementation in librtas library
- Each read call issue RTAS call to get the data based on the size requirement and returns bytes returned from the hypervisor
- If the previous HCALL returns dump complete status, the next read returns 0 like EOF.
ret = ioctl(PAPR_PLATFORM_DUMP_IOC_INVALIDATE, &dump_id)
- RTAS call with NULL buffer to invalidates the dump.
The read API should use the file descriptor obtained from ioctl based on dump ID so that gets dump contents for the corresponding dump ID. Implemented support in librtas (rtas_platform_dump()) for this new ABI to support system lockdown.
--- .../include/uapi/asm/papr-platform-dump.h | 15 + arch/powerpc/platforms/pseries/Makefile | 1 + .../platforms/pseries/papr-platform-dump.c | 408 ++++++++++++++++++ 3 files changed, 424 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/papr-platform-dump.h create mode 100644 arch/powerpc/platforms/pseries/papr-platform-dump.c
arch/powerpc/include/uapi/asm/papr-platform-dump.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_PAPR_PLATFORM_DUMP_H_ +#define _UAPI_PAPR_PLATFORM_DUMP_H_ + +#include <asm/ioctl.h> +#include <asm/papr-miscdev.h> + +/* +* ioctl for /dev/papr-platform-dump. Returns a VPD handle fd corresponding to +* the location code. +*/ +#define PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE _IOW(PAPR_MISCDEV_IOC_ID, 6, __u64) +#define PAPR_PLATFORM_DUMP_IOC_INVALIDATE _IOW(PAPR_MISCDEV_IOC_ID, 7, __u64) + +#endif /* _UAPI_PAPR_PLATFORM_DUMP_H_ */
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -4,6 +4,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ papr-rtas-common.o papr-vpd.o papr-indices.o \ + papr-platform-dump.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o \
arch/powerpc/platforms/pseries/papr-platform-dump.c new file +408 -0
408 lines not on this page · raw message
Signature · 1 line
2.43.5
kernel test robot
build botRe: [PATCH 1/6] powerpc/pseries: Define common functions for RTAS sequence HCALLs
In reply to Haren Mynenikernel test robot noticed the following build warnings:
Hi Haren,
kernel test robot noticed the following build warnings:
[auto build test WARNING on powerpc/next]
[also build test WARNING on powerpc/fixes linus/master v6.13-rc5 next-20241220] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haren-Myneni/powerpc-pseries-Define-common-functions-for-RTAS-sequence-HCALLs/20250105-045010 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20250104204652.388720-2-haren%40linux.ibm.com patch subject: [PATCH 1/6] powerpc/pseries: Define common functions for RTAS sequence HCALLs config: powerpc64-randconfig-002-20250105 (https://download.01.org/0day-ci/archive/20250105/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250105/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> arch/powerpc/platforms/pseries/papr-vpd.c:141: warning: Function parameter or struct member 'param' not described in 'vpd_sequence_begin' >> arch/powerpc/platforms/pseries/papr-vpd.c:141: warning: Excess function parameter 'loc_code' description in 'vpd_sequence_begin'
vim +141 arch/powerpc/platforms/pseries/papr-vpd.c
514f6ff4369a30 Nathan Lynch 2023-12-12 121
514f6ff4369a30 Nathan Lynch 2023-12-12 122 /*
514f6ff4369a30 Nathan Lynch 2023-12-12 123 * Internal VPD sequence APIs. A VPD sequence is a series of calls to
514f6ff4369a30 Nathan Lynch 2023-12-12 124 * ibm,get-vpd for a given location code. The sequence ends when an
514f6ff4369a30 Nathan Lynch 2023-12-12 125 * error is encountered or all VPD for the location code has been
514f6ff4369a30 Nathan Lynch 2023-12-12 126 * returned.
514f6ff4369a30 Nathan Lynch 2023-12-12 127 */
514f6ff4369a30 Nathan Lynch 2023-12-12 128
514f6ff4369a30 Nathan Lynch 2023-12-12 129 /**
514f6ff4369a30 Nathan Lynch 2023-12-12 130 * vpd_sequence_begin() - Begin a VPD retrieval sequence.
514f6ff4369a30 Nathan Lynch 2023-12-12 131 * @seq: Uninitialized sequence state.
514f6ff4369a30 Nathan Lynch 2023-12-12 132 * @loc_code: Location code that defines the scope of the VPD to return.
514f6ff4369a30 Nathan Lynch 2023-12-12 133 *
514f6ff4369a30 Nathan Lynch 2023-12-12 134 * Initializes @seq with the resources necessary to carry out a VPD
514f6ff4369a30 Nathan Lynch 2023-12-12 135 * sequence. Callers must pass @seq to vpd_sequence_end() regardless
514f6ff4369a30 Nathan Lynch 2023-12-12 136 * of whether the sequence succeeds.
514f6ff4369a30 Nathan Lynch 2023-12-12 137 *
514f6ff4369a30 Nathan Lynch 2023-12-12 138 * Context: May sleep.
514f6ff4369a30 Nathan Lynch 2023-12-12 139 */
5d8b0014124124 Haren Myneni 2025-01-04 140 static void vpd_sequence_begin(struct papr_rtas_sequence *seq, void *param)
514f6ff4369a30 Nathan Lynch 2023-12-12 @141 {
5d8b0014124124 Haren Myneni 2025-01-04 142 struct rtas_ibm_get_vpd_params *vpd_params;
514f6ff4369a30 Nathan Lynch 2023-12-12 143 /*
514f6ff4369a30 Nathan Lynch 2023-12-12 144 * Use a static data structure for the location code passed to
514f6ff4369a30 Nathan Lynch 2023-12-12 145 * RTAS to ensure it's in the RMA and avoid a separate work
514f6ff4369a30 Nathan Lynch 2023-12-12 146 * area allocation. Guarded by the function lock.
514f6ff4369a30 Nathan Lynch 2023-12-12 147 */
514f6ff4369a30 Nathan Lynch 2023-12-12 148 static struct papr_location_code static_loc_code;
514f6ff4369a30 Nathan Lynch 2023-12-12 149
514f6ff4369a30 Nathan Lynch 2023-12-12 150 /*
514f6ff4369a30 Nathan Lynch 2023-12-12 151 * We could allocate the work area before acquiring the
514f6ff4369a30 Nathan Lynch 2023-12-12 152 * function lock, but that would allow concurrent requests to
514f6ff4369a30 Nathan Lynch 2023-12-12 153 * exhaust the limited work area pool for no benefit. So
514f6ff4369a30 Nathan Lynch 2023-12-12 154 * allocate the work area under the lock.
514f6ff4369a30 Nathan Lynch 2023-12-12 155 */
514f6ff4369a30 Nathan Lynch 2023-12-12 156 mutex_lock(&rtas_ibm_get_vpd_lock);
5d8b0014124124 Haren Myneni 2025-01-04 157 static_loc_code = *(struct papr_location_code *)param;
5d8b0014124124 Haren Myneni 2025-01-04 158 vpd_params = (struct rtas_ibm_get_vpd_params *)seq->params;
5d8b0014124124 Haren Myneni 2025-01-04 159 vpd_params->work_area = rtas_work_area_alloc(SZ_4K);
5d8b0014124124 Haren Myneni 2025-01-04 160 vpd_params->loc_code = &static_loc_code;
5d8b0014124124 Haren Myneni 2025-01-04 161 vpd_params->sequence = 1;
5d8b0014124124 Haren Myneni 2025-01-04 162 vpd_params->status = 0;
514f6ff4369a30 Nathan Lynch 2023-12-12 163 }
514f6ff4369a30 Nathan Lynch 2023-12-12 164 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 3/6] powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL
In reply to Haren Mynenikernel test robot noticed the following build warnings:
Hi Haren,
kernel test robot noticed the following build warnings:
[auto build test WARNING on powerpc/next]
[also build test WARNING on powerpc/fixes linus/master v6.13-rc5 next-20241220] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haren-Myneni/powerpc-pseries-Define-common-functions-for-RTAS-sequence-HCALLs/20250105-045010 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20250104204652.388720-4-haren%40linux.ibm.com patch subject: [PATCH 3/6] powerpc/pseries: Add papr-indices char driver for ibm,get-indices HCALL config: powerpc64-randconfig-002-20250105 (https://download.01.org/0day-ci/archive/20250105/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250105/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> arch/powerpc/platforms/pseries/papr-indices.c:45: warning: expecting prototype for struct rtas_ibm_get_indices_params. Prototype was for struct rtas_get_indices_params instead
>> arch/powerpc/platforms/pseries/papr-indices.c:210: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Work function to be passed to papr_rtas_blob_generate().
>> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function parameter or struct member 'file' not described in 'papr_indices_handle_read'
>> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function parameter or struct member 'buf' not described in 'papr_indices_handle_read'
>> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function parameter or struct member 'size' not described in 'papr_indices_handle_read'
>> arch/powerpc/platforms/pseries/papr-indices.c:247: warning: Function parameter or struct member 'off' not described in 'papr_indices_handle_read'vim +45 arch/powerpc/platforms/pseries/papr-indices.c
29
30 /**
31 * struct rtas_ibm_get_indices_params - Parameters (in and out) for
32 * ibm,get-indices.
33 * @is_sensor: In: Caller-provided whether sensor or indicator.
34 * @indice_type:In: Caller-provided indice (sensor or indicator) token
35 * @work_area: In: Caller-provided work area buffer for results.
36 * @next: In: Sequence number. Out: Next sequence number.
37 * @status: Out: RTAS call status.
38 */
39 struct rtas_get_indices_params {
40 u8 is_sensor;
41 u32 indice_type;
42 struct rtas_work_area *work_area;
43 u32 next;
44 s32 status;
> 45 };
46
47 /**
48 * rtas_ibm_get_indices() - Call ibm,get-indices to fill a work area buffer.
49 * @params: See &struct rtas_ibm_get_indices_params.
50 *
51 * Calls ibm,get-indices until it errors or successfully deposits data
52 * into the supplied work area. Handles RTAS retry statuses. Maps RTAS
53 * error statuses to reasonable errno values.
54 *
55 * The caller is expected to invoke rtas_ibm_get_indices() multiple times
56 * to retrieve all indices data for the provided indice type. Only one
57 * sequence should be in progress at any time; starting a new sequence
58 * will disrupt any sequence already in progress. Serialization of
59 * indices retrieval sequences is the responsibility of the caller.
60 *
61 * The caller should inspect @params.status to determine whether more
62 * calls are needed to complete the sequence.
63 *
64 * Context: May sleep.
65 * Return: -ve on error, 0 otherwise.
66 */
67 static int rtas_ibm_get_indices(struct rtas_get_indices_params *params)
68 {
69 struct rtas_work_area *work_area = params->work_area;
70 const s32 token = rtas_function_token(RTAS_FN_IBM_GET_INDICES);
71 u32 rets;
72 s32 fwrc;
73 int ret;
74
75 if (token == RTAS_UNKNOWN_SERVICE)
76 return -ENOENT;
77
78 lockdep_assert_held(&rtas_ibm_get_indices_lock);
79
80 do {
81 fwrc = rtas_call(token, 5, 2, &rets, params->is_sensor,
82 params->indice_type,
83 rtas_work_area_phys(work_area),
84 rtas_work_area_size(work_area),
85 params->next);
86 } while (rtas_busy_delay(fwrc));
87
88 switch (fwrc) {
89 case RTAS_HARDWARE_ERROR:
90 ret = -EIO;
91 break;
92 case RTAS_INVALID_PARAMETER: /* Indicator type is not supported */
93 ret = -EINVAL;
94 break;
95 case RTAS_IBM_GET_INDICES_START_OVER:
96 ret = -EAGAIN;
97 pr_info_ratelimited("Indices changed during retrieval, retrying\n");
98 params->next = 1;
99 break;
100 case RTAS_IBM_GET_INDICES_MORE_DATA:
101 params->next = rets;
102 fallthrough;
103 case RTAS_IBM_GET_INDICES_COMPLETE:
104 params->next = 0;
105 ret = 0;
106 break;
107 default:
108 ret = -EIO;
109 pr_err_ratelimited("unexpected ibm,get-indices status %d\n", fwrc);
110 break;
111 }
112
113 params->status = fwrc;
114 return ret;
115 }
116
117 /*
118 * Internal indices sequence APIs. A sequence is a series of calls to
119 * ibm,get-indices for a given location code. The sequence ends when
120 * an error is encountered or all indices for the input has been
121 * returned.
122 */
123
124 /**
125 * indices_sequence_begin() - Begin a indices retrieval sequence.
126 * @seq: Uninitialized sequence state.
127 * @params: Indices call parameters and initialization
128 *
129 * Initializes @seq with the resources necessary to carry out indices
130 * call sequence. Callers must pass @seq to indices_sequence_end()
131 * regardless of whether the sequence succeeds.
132 *
133 * Context: May sleep.
134 */
135 static void indices_sequence_begin(struct papr_rtas_sequence *seq,
136 void *params)
137 {
138 struct rtas_get_indices_params *param;
139
140 param = (struct rtas_get_indices_params *)params;
141 /*
142 * We could allocate the work area before acquiring the
143 * function lock, but that would allow concurrent requests to
144 * exhaust the limited work area pool for no benefit. So
145 * allocate the work area under the lock.
146 */
147 mutex_lock(&rtas_ibm_get_indices_lock);
148 param->work_area = rtas_work_area_alloc(RTAS_GET_INDICES_BUF_SIZE);
149 param->next = 1;
150 param->status = 0;
151 seq->params = param;
152 }
153
154 /**
155 * indices_sequence_end() - Finalize a indices retrieval sequence.
156 * @seq: indices call parameters from sequence struct
157 *
158 * Releases resources obtained by indices_sequence_begin().
159 */
160 static void indices_sequence_end(struct papr_rtas_sequence *seq)
161 {
162 struct rtas_get_indices_params *param;
163
164 param = (struct rtas_get_indices_params *)seq->params;
165 rtas_work_area_free(param->work_area);
166 mutex_unlock(&rtas_ibm_get_indices_lock);
167 }
168
169 /**
170 * indices_sequence_should_stop() - Determine whether a indices
171 * retrieval sequence should continue.
172 * @seq: indices sequence state.
173 *
174 * Examines the sequence error state and outputs of the last call to
175 * ibm,get-indices to determine whether the sequence in progress should
176 * continue or stop.
177 *
178 * Return: True if the sequence has encountered an error or if all
179 * indices for this sequence has been retrieved. False otherwise.
180 */
181 static bool indices_sequence_should_stop(const struct papr_rtas_sequence *seq)
182 {
183 struct rtas_get_indices_params *param;
184 bool done;
185
186 if (seq->error)
187 return true;
188
189 param = (struct rtas_get_indices_params *)seq->params;
190
191 switch (param->status) {
192 case RTAS_IBM_GET_INDICES_COMPLETE:
193 if (param->next == 1)
194 done = false; /* Initial state. */
195 else
196 done = true; /* All data consumed. */
197 break;
198 case RTAS_IBM_GET_INDICES_MORE_DATA:
199 done = false; /* More data available. */
200 break;
201 default:
202 done = true; /* Error encountered. */
203 break;
204 }
205
206 return done;
207 }
208
209 /**
> 210 * Work function to be passed to papr_rtas_blob_generate(). 211 *
212 * ibm,get-indices RTAS call fills the work area with the certain
213 * format but does not return the bytes written in the buffer. So
214 * instead of kernel parsing this work area to determine the buffer
215 * length, copy the complete work area (RTAS_GET_INDICES_BUF_SIZE)
216 * to the blob and let the user space to obtain the data.
217 * Means RTAS_GET_INDICES_BUF_SIZE data will be returned for each
218 * read().
219 */
220
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 4/6] powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
In reply to Haren MyneniHi Haren,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haren-Myneni/powerpc-pseries-Define-common-functions-for-RTAS-sequence-HCALLs/20250105-045010 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20250104204652.388720-5-haren%40linux.ibm.com patch subject: [PATCH 4/6] powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support config: powerpc64-randconfig-r071-20250108 (https://download.01.org/0day-ci/archive/20250109/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:arch/powerpc/platforms/pseries/papr-indices.c:438 papr_dynamic_indicator_ioc_set() warn: inconsistent returns 'global &rtas_ibm_set_dynamic_indicator_lock'.
vim +438 arch/powerpc/platforms/pseries/papr-indices.c
3f48afd07934e4 Haren Myneni 2025-01-04 397 static long papr_dynamic_indicator_ioc_set(struct papr_indices_io_block __user *ubuf)
3f48afd07934e4 Haren Myneni 2025-01-04 398 {
3f48afd07934e4 Haren Myneni 2025-01-04 399 struct papr_indices_io_block kbuf;
3f48afd07934e4 Haren Myneni 2025-01-04 400 struct rtas_work_area *work_area;
3f48afd07934e4 Haren Myneni 2025-01-04 401 s32 fwrc, token, ret;
3f48afd07934e4 Haren Myneni 2025-01-04 402
3f48afd07934e4 Haren Myneni 2025-01-04 403 token = rtas_function_token(RTAS_FN_IBM_SET_DYNAMIC_INDICATOR);
3f48afd07934e4 Haren Myneni 2025-01-04 404 if (token == RTAS_UNKNOWN_SERVICE)
3f48afd07934e4 Haren Myneni 2025-01-04 405 return -ENOENT;
3f48afd07934e4 Haren Myneni 2025-01-04 406
3f48afd07934e4 Haren Myneni 2025-01-04 407 mutex_lock(&rtas_ibm_set_dynamic_indicator_lock);
3f48afd07934e4 Haren Myneni 2025-01-04 408 work_area = papr_dynamic_indice_buf_from_user(ubuf, &kbuf);
3f48afd07934e4 Haren Myneni 2025-01-04 409 if (IS_ERR(work_area))
3f48afd07934e4 Haren Myneni 2025-01-04 410 return PTR_ERR(work_area);mutex_unlock(&rtas_ibm_set_dynamic_indicator_lock); before returning
3f48afd07934e4 Haren Myneni 2025-01-04 411
3f48afd07934e4 Haren Myneni 2025-01-04 412 do {
3f48afd07934e4 Haren Myneni 2025-01-04 413 fwrc = rtas_call(token, 3, 1, NULL,
3f48afd07934e4 Haren Myneni 2025-01-04 414 kbuf.dynamic_param.token,
3f48afd07934e4 Haren Myneni 2025-01-04 415 kbuf.dynamic_param.state,
3f48afd07934e4 Haren Myneni 2025-01-04 416 rtas_work_area_phys(work_area));
3f48afd07934e4 Haren Myneni 2025-01-04 417 } while (rtas_busy_delay(fwrc));
3f48afd07934e4 Haren Myneni 2025-01-04 418
3f48afd07934e4 Haren Myneni 2025-01-04 419 rtas_work_area_free(work_area);
3f48afd07934e4 Haren Myneni 2025-01-04 420 mutex_unlock(&rtas_ibm_set_dynamic_indicator_lock);
3f48afd07934e4 Haren Myneni 2025-01-04 421
3f48afd07934e4 Haren Myneni 2025-01-04 422 switch (fwrc) {
3f48afd07934e4 Haren Myneni 2025-01-04 423 case RTAS_IBM_DYNAMIC_INDICE_SUCCESS:
3f48afd07934e4 Haren Myneni 2025-01-04 424 ret = 0;
3f48afd07934e4 Haren Myneni 2025-01-04 425 break;
3f48afd07934e4 Haren Myneni 2025-01-04 426 case RTAS_IBM_DYNAMIC_INDICE_NO_INDICATOR: /* No such indicator */
3f48afd07934e4 Haren Myneni 2025-01-04 427 ret = -EOPNOTSUPP;
3f48afd07934e4 Haren Myneni 2025-01-04 428 break;
3f48afd07934e4 Haren Myneni 2025-01-04 429 default:
3f48afd07934e4 Haren Myneni 2025-01-04 430 pr_err("unexpected ibm,set-dynamic-indicator result %d\n",
3f48afd07934e4 Haren Myneni 2025-01-04 431 fwrc);
3f48afd07934e4 Haren Myneni 2025-01-04 432 fallthrough;
3f48afd07934e4 Haren Myneni 2025-01-04 433 case RTAS_IBM_DYNAMIC_INDICE_HW_ERROR: /* Hardware/platform error */
3f48afd07934e4 Haren Myneni 2025-01-04 434 ret = -EIO;
3f48afd07934e4 Haren Myneni 2025-01-04 435 break;
3f48afd07934e4 Haren Myneni 2025-01-04 436 }
3f48afd07934e4 Haren Myneni 2025-01-04 437 3f48afd07934e4 Haren Myneni 2025-01-04 @438 return ret;3f48afd07934e4 Haren Myneni 2025-01-04 439 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 5/6] powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
In reply to Haren MyneniHi Haren,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haren-Myneni/powerpc-pseries-Define-common-functions-for-RTAS-sequence-HCALLs/20250105-045010 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20250104204652.388720-6-haren%40linux.ibm.com patch subject: [PATCH 5/6] powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support config: powerpc64-randconfig-r071-20250108 (https://download.01.org/0day-ci/archive/20250109/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:arch/powerpc/platforms/pseries/papr-indices.c:496 papr_dynamic_sensor_ioc_get() warn: inconsistent returns 'global &rtas_ibm_get_dynamic_sensor_state_lock'.
Old smatch warnings:arch/powerpc/platforms/pseries/papr-indices.c:438 papr_dynamic_indicator_ioc_set() warn: inconsistent returns 'global &rtas_ibm_set_dynamic_indicator_lock'.
vim +496 arch/powerpc/platforms/pseries/papr-indices.c
e44fb25ad9fa03 Haren Myneni 2025-01-04 452 static long papr_dynamic_sensor_ioc_get(struct papr_indices_io_block __user *ubuf)
e44fb25ad9fa03 Haren Myneni 2025-01-04 453 {
e44fb25ad9fa03 Haren Myneni 2025-01-04 454 struct papr_indices_io_block kbuf;
e44fb25ad9fa03 Haren Myneni 2025-01-04 455 struct rtas_work_area *work_area;
e44fb25ad9fa03 Haren Myneni 2025-01-04 456 s32 fwrc, token, ret;
e44fb25ad9fa03 Haren Myneni 2025-01-04 457 u32 rets;
e44fb25ad9fa03 Haren Myneni 2025-01-04 458
e44fb25ad9fa03 Haren Myneni 2025-01-04 459 token = rtas_function_token(RTAS_FN_IBM_GET_DYNAMIC_SENSOR_STATE);
e44fb25ad9fa03 Haren Myneni 2025-01-04 460 if (token == RTAS_UNKNOWN_SERVICE)
e44fb25ad9fa03 Haren Myneni 2025-01-04 461 return -ENOENT;
e44fb25ad9fa03 Haren Myneni 2025-01-04 462
e44fb25ad9fa03 Haren Myneni 2025-01-04 463 mutex_lock(&rtas_ibm_get_dynamic_sensor_state_lock);
e44fb25ad9fa03 Haren Myneni 2025-01-04 464 work_area = papr_dynamic_indice_buf_from_user(ubuf, &kbuf);
e44fb25ad9fa03 Haren Myneni 2025-01-04 465 if (IS_ERR(work_area))
e44fb25ad9fa03 Haren Myneni 2025-01-04 466 return PTR_ERR(work_area);Add an unlock, same as with the _set() function.
e44fb25ad9fa03 Haren Myneni 2025-01-04 467
e44fb25ad9fa03 Haren Myneni 2025-01-04 468 do {
e44fb25ad9fa03 Haren Myneni 2025-01-04 469 fwrc = rtas_call(token, 2, 2, &rets,
e44fb25ad9fa03 Haren Myneni 2025-01-04 470 kbuf.dynamic_param.token,
e44fb25ad9fa03 Haren Myneni 2025-01-04 471 rtas_work_area_phys(work_area));
e44fb25ad9fa03 Haren Myneni 2025-01-04 472 } while (rtas_busy_delay(fwrc));
e44fb25ad9fa03 Haren Myneni 2025-01-04 473
e44fb25ad9fa03 Haren Myneni 2025-01-04 474 rtas_work_area_free(work_area);
e44fb25ad9fa03 Haren Myneni 2025-01-04 475 mutex_unlock(&rtas_ibm_get_dynamic_sensor_state_lock);
e44fb25ad9fa03 Haren Myneni 2025-01-04 476
e44fb25ad9fa03 Haren Myneni 2025-01-04 477 switch (fwrc) {
e44fb25ad9fa03 Haren Myneni 2025-01-04 478 case RTAS_IBM_DYNAMIC_INDICE_SUCCESS:
e44fb25ad9fa03 Haren Myneni 2025-01-04 479 if (put_user(rets, &ubuf->dynamic_param.state))
e44fb25ad9fa03 Haren Myneni 2025-01-04 480 ret = -EFAULT;
e44fb25ad9fa03 Haren Myneni 2025-01-04 481 else
e44fb25ad9fa03 Haren Myneni 2025-01-04 482 ret = 0;
e44fb25ad9fa03 Haren Myneni 2025-01-04 483 break;
e44fb25ad9fa03 Haren Myneni 2025-01-04 484 case RTAS_IBM_DYNAMIC_INDICE_NO_INDICATOR: /* No such indicator */
e44fb25ad9fa03 Haren Myneni 2025-01-04 485 ret = -EOPNOTSUPP;
e44fb25ad9fa03 Haren Myneni 2025-01-04 486 break;
e44fb25ad9fa03 Haren Myneni 2025-01-04 487 default:
e44fb25ad9fa03 Haren Myneni 2025-01-04 488 pr_err("unexpected ibm,get-dynamic-sensor result %d\n",
e44fb25ad9fa03 Haren Myneni 2025-01-04 489 fwrc);
e44fb25ad9fa03 Haren Myneni 2025-01-04 490 fallthrough;
e44fb25ad9fa03 Haren Myneni 2025-01-04 491 case RTAS_IBM_DYNAMIC_INDICE_HW_ERROR: /* Hardware/platform error */
e44fb25ad9fa03 Haren Myneni 2025-01-04 492 ret = -EIO;
e44fb25ad9fa03 Haren Myneni 2025-01-04 493 break;
e44fb25ad9fa03 Haren Myneni 2025-01-04 494 }
e44fb25ad9fa03 Haren Myneni 2025-01-04 495 e44fb25ad9fa03 Haren Myneni 2025-01-04 @496 return ret;e44fb25ad9fa03 Haren Myneni 2025-01-04 497 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki