forked from ibm-power-utilities/librtas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
librtas/sysparm: prefer /dev/papr-sysparm when available
Change rtas_get_sysparm() and rtas_set_sysparm() to prefer the /dev/papr-sysparm character device expected in Linux v6.8. On the first invocation of either function, probe for the new ABI and initialize internal function pointers according to the result. Use pthread_once() to ensure that this initialization step is performed atomically and only once. When /dev/papr-sysparm is available, use its PAPR_SYSPARM_IOC_GET and PAPR_SYSPARM_IOC_SET ioctl commands to retrieve and update system parameters. Most of the complexity of calling RTAS is handled internally to the kernel and the ioctl follows Linux conventions, returning 0 on success or -1 w/errno on failure. On failure, back-convert the errno to an RTAS status value that callers will recognize. For now, carry a copy of the kernel uapi header. Signed-off-by: Nathan Lynch <[email protected]>
- Loading branch information
1 parent
b7f0932
commit 7af7d7f
Showing
3 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note | ||
#ifndef _UAPI_PAPR_SYSPARM_H_ | ||
#define _UAPI_PAPR_SYSPARM_H_ | ||
|
||
#include <linux/types.h> | ||
#include <asm/ioctl.h> | ||
#include "papr-miscdev.h" | ||
|
||
enum { | ||
PAPR_SYSPARM_MAX_INPUT = 1024, | ||
PAPR_SYSPARM_MAX_OUTPUT = 4000, | ||
}; | ||
|
||
struct papr_sysparm_io_block { | ||
__u32 parameter; | ||
__u16 length; | ||
char data[PAPR_SYSPARM_MAX_OUTPUT]; | ||
}; | ||
|
||
/** | ||
* PAPR_SYSPARM_IOC_GET - Retrieve the value of a PAPR system parameter. | ||
* | ||
* Uses _IOWR because of one corner case: Retrieving the value of the | ||
* "OS Service Entitlement Status" parameter (60) requires the caller | ||
* to supply input data (a date string) in the buffer passed to | ||
* firmware. So the @length and @data of the incoming | ||
* papr_sysparm_io_block are always used to initialize the work area | ||
* supplied to ibm,get-system-parameter. No other parameters are known | ||
* to parameterize the result this way, and callers are encouraged | ||
* (but not required) to zero-initialize @length and @data in the | ||
* common case. | ||
* | ||
* On error the contents of the ioblock are indeterminate. | ||
* | ||
* Return: | ||
* 0: Success; @length is the length of valid data in @data, not to exceed @PAPR_SYSPARM_MAX_OUTPUT. | ||
* -EIO: Platform error. (-1) | ||
* -EINVAL: Incorrect data length or format. (-9999) | ||
* -EPERM: The calling partition is not allowed to access this parameter. (-9002) | ||
* -EOPNOTSUPP: Parameter not supported on this platform (-3) | ||
*/ | ||
#define PAPR_SYSPARM_IOC_GET _IOWR(PAPR_MISCDEV_IOC_ID, 1, struct papr_sysparm_io_block) | ||
|
||
/** | ||
* PAPR_SYSPARM_IOC_SET - Update the value of a PAPR system parameter. | ||
* | ||
* The contents of the ioblock are unchanged regardless of success. | ||
* | ||
* Return: | ||
* 0: Success; the parameter has been updated. | ||
* -EIO: Platform error. (-1) | ||
* -EINVAL: Incorrect data length or format. (-9999) | ||
* -EPERM: The calling partition is not allowed to access this parameter. (-9002) | ||
* -EOPNOTSUPP: Parameter not supported on this platform (-3) | ||
*/ | ||
#define PAPR_SYSPARM_IOC_SET _IOW(PAPR_MISCDEV_IOC_ID, 2, struct papr_sysparm_io_block) | ||
|
||
#endif /* _UAPI_PAPR_SYSPARM_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters