linux/arch/powerpc/platforms
Nathan Lynch 514f6ff436 powerpc/pseries: Add papr-vpd character driver for VPD retrieval
PowerVM LPARs may retrieve Vital Product Data (VPD) for system
components using the ibm,get-vpd RTAS function.

We can expose this to user space with a /dev/papr-vpd character
device, where the programming model is:

  struct papr_location_code plc = { .str = "", }; /* obtain all VPD */
  int devfd = open("/dev/papr-vpd", O_RDONLY);
  int vpdfd = ioctl(devfd, PAPR_VPD_CREATE_HANDLE, &plc);
  size_t size = lseek(vpdfd, 0, SEEK_END);
  char *buf = malloc(size);
  pread(devfd, buf, size, 0);

When a file descriptor is obtained from ioctl(PAPR_VPD_CREATE_HANDLE),
the file contains the result of a complete ibm,get-vpd sequence. The
file contents are immutable from the POV of user space. To get a new
view of the VPD, the client must create a new handle.

This design choice insulates user space from most of the complexities
that ibm,get-vpd brings:

* ibm,get-vpd must be called more than once to obtain complete
  results.

* Only one ibm,get-vpd call sequence should be in progress at a time;
  interleaved sequences will disrupt each other. Callers must have a
  protocol for serializing their use of the function.

* A call sequence in progress may receive a "VPD changed, try again"
  status, requiring the client to abandon the sequence and start
  over.

The memory required for the VPD buffers seems acceptable, around 20KB
for all VPD on one of my systems. And the value of the
/rtas/ibm,vpd-size DT property (the estimated maximum size of VPD) is
consistently 300KB across various systems I've checked.

I've implemented support for this new ABI in the rtas_get_vpd()
function in librtas, which the vpdupdate command currently uses to
populate its VPD database. I've verified that an unmodified vpdupdate
binary generates an identical database when using a librtas.so that
prefers the new ABI.

Along with the papr-vpd.h header exposed to user space, this
introduces a common papr-miscdev.h uapi header to share a base ioctl
ID with similar drivers to come.

Tested-by: Michal Suchánek <msuchanek@suse.de>
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-9-e9eafd0c8c6c@linux.ibm.com
2023-12-13 21:38:21 +11:00
..
4xx powerpc: Use NULL instead of 0 for null pointers 2023-10-19 17:12:47 +11:00
8xx powerpc: Untangle fixmap.h and pgtable.h and mmu.h 2023-10-19 17:12:44 +11:00
40x powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
44x powerpc/44x: select I2C for CURRITUCK 2023-12-01 21:15:33 +11:00
52xx powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
82xx powerpc/82xx: Select FSL_SOC 2023-09-18 12:23:48 +10:00
83xx powerpc: Untangle fixmap.h and pgtable.h and mmu.h 2023-10-19 17:12:44 +11:00
85xx powerpc/85xx: Fix typo in code comment 2023-12-01 21:15:33 +11:00
86xx powerpc: address missing-prototypes warnings 2023-08-02 22:22:19 +10:00
512x powerpc/512x: Fix missing prototype warnings 2023-11-30 13:25:27 +11:00
amigaone powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
book3s powerpc/vas: Limit open window failure messages in log bufffer 2023-10-20 17:10:03 +11:00
cell vfs-6.7.ctime 2023-10-30 09:47:13 -10:00
chrp powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
embedded6xx powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
maple powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
microwatt powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
pasemi powerpc/pasemi: mark pas_shutdown() static 2023-11-21 12:06:50 +11:00
powermac powerpc/powermac: mark smp_psurge_{give,take}_timebase static 2023-11-21 12:06:50 +11:00
powernv powerpc: Add PVN support for HeXin C2000 processor 2023-12-01 21:15:33 +11:00
ps3 powerpc/ps3: move udbg_shutdown_ps3gelic prototype 2023-11-21 12:06:50 +11:00
pseries powerpc/pseries: Add papr-vpd character driver for VPD retrieval 2023-12-13 21:38:21 +11:00
fsl_uli1575.c powerpc/fsl_uli1575: Mark uli_exclude_device() as static 2023-04-20 10:20:50 +10:00
Kconfig powerpc/82xx: Remove CONFIG_8260 and CONFIG_8272 2023-08-18 17:03:14 +10:00
Kconfig.cputype powerpc updates for 6.6 2023-08-31 12:43:10 -07:00
Makefile powerpc: Add Microwatt platform 2021-06-21 21:15:26 +10:00