[PATCH v2] powerpc/machdep: warn when machine_is() used too early

2023-02-13 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch machine_is() can't provide correct results before probe_machine() has run. Warn when it's used too early in boot, placing the WARN_ON() in a helper function so the reported file:line indicates exactly what went wrong. checkpatch complains about __attribute__((weak)) in the

[PATCH] powerpc/machdep: warn when machine_is() used too early

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch machine_is() can't provide correct results before probe_machine() has run. Warn when it's used too early in boot. Signed-off-by: Nathan Lynch --- Prompted by my attempts to do some pseries-specific setup during rtas_initialize() and being puzzled for a while that it wasn't

[PATCH v3 12/20] powerpc/pseries: add RTAS work area allocator

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Various pseries-specific RTAS functions take a temporary "work area" parameter - a buffer in memory accessible to RTAS. Typically such functions are passed the statically allocated rtas_data_buf buffer as the argument. This buffer is protected by a global spinlock. So users of

[PATCH v3 18/20] powerpc/pseries/lpar: convert to papr_sysparm API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Convert the TLB block invalidate characteristics discovery to the new papr_sysparm API. This occurs too early in boot to use papr_sysparm_buf_alloc(), so use a static buffer. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/lpar.c | 37

[PATCH v3 15/20] powerpc/pseries: convert CMO probe to papr_sysparm API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Convert the direct invocation of the ibm,get-system-parameter RTAS function to papr_sysparm_get(). Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/setup.c | 23 ++- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git

[PATCH v3 10/20] powerpc/tracing: tracepoints for RTAS entry and exit

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Add two sets of tracepoints to be used around RTAS entry: * rtas_input/rtas_output, which emit the function name, its inputs, the returned status, and any other outputs. These produce an API-level record of OS<->RTAS activity. * rtas_ll_entry/rtas_ll_exit, which are

[PATCH v3 09/20] powerpc/rtas: strengthen do_enter_rtas() type safety, drop inline

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Make do_enter_rtas() take a pointer to struct rtas_args and do the __pa() conversion in one place instead of leaving it to callers. This also makes it possible to introduce enter/exit tracepoints that access the rtas_args struct fields. There's no apparent reason to force

[PATCH v3 14/20] powerpc/pseries: PAPR system parameter API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Introduce a set of APIs for retrieving and updating PAPR system parameters. This encapsulates the toil of temporary RTAS work area management, RTAS function call retries, and translation of RTAS call statuses to conventional error values. There are several places in the

[PATCH v3 13/20] powerpc/pseries/dlpar: use RTAS work area API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Hold a work area object for the duration of the RTAS ibm,configure-connector sequence, eliminating locking and copying around each RTAS call. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/dlpar.c | 27 +-- 1 file changed, 9

[PATCH v3 19/20] powerpc/rtas: introduce rtas_function_token() API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Users of rtas_token() supply a string argument that can't be validated at build time. A typo or misspelling has to be caught by inspection or by observing wrong behavior at runtime. Since the core RTAS code now has consolidated the names of all possible RTAS functions and

[PATCH v3 11/20] powerpc/rtas: add tracepoints around RTAS entry

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Decompose the RTAS entry C code into tracing and non-tracing variants, calling the just-added tracepoints in the tracing-enabled path. Skip tracing in contexts known to be unsafe (real mode, CPU offline). Signed-off-by: Nathan Lynch --- arch/powerpc/kernel/rtas.c | 59

[PATCH v3 20/20] powerpc/rtas: arch-wide function token lookup conversions

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch With the tokens for all implemented RTAS functions now available via rtas_function_token(), which is optimal and safe for arbitrary contexts, there is no need to use rtas_token() or cache its result. Most conversions are trivial, but a few are worth describing in more detail:

[PATCH v3 17/20] powerpc/pseries/hv-24x7: convert to papr_sysparm API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The new papr_sysparm API handles the details of system parameter retrieval. Use that instead of open-coding the RTAS call, work area management, and retries. Signed-off-by: Nathan Lynch --- arch/powerpc/perf/hv-24x7.c | 37 +++-- 1 file

[PATCH v3 08/20] powerpc/rtas: improve function information lookups

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The core RTAS support code and its clients perform two types of lookup for RTAS firmware function information. First, mapping a known function name to a token. The typical use case invokes rtas_token() to retrieve the token value to pass to rtas_call(). rtas_token() relies on

[PATCH v3 16/20] powerpc/pseries/lparcfg: convert to papr_sysparm API

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch /proc/powerpc/lparcfg derives the LPAR name and SPLPAR characteristics it reports using bare calls to the RTAS ibm,get-system-parameter function. Convert these to the higher-level papr_sysparm API, which handles the tedious details. While the SPLPAR string parsing code could

[PATCH v3 06/20] powerpc/rtas: ensure 4KB alignment for rtas_data_buf

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Some RTAS functions that have work area parameters impose alignment requirements on the work area passed to them by the OS. Examples include: - ibm,configure-connector - ibm,update-nodes - ibm,update-properties 4KB is the greatest alignment required by PAPR for such buffers.

[PATCH v3 05/20] powerpc/pseries/setup: add missing RTAS retry status handling

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. pSeries_cmo_feature_init() ignores this, making it possible to fail to detect cooperative memory overcommit capabilities during boot. Move the RTAS call into a

[PATCH v3 07/20] powerpc/pseries: drop RTAS-based timebase synchronization

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The pseries platform has been LPAR-only for several generations, and the PAPR spec: * Guarantees that timebase synchronization is performed by the platform ("The timebase registers are synchronized by the platform before CPUs are given to the OS" - 7.3.8 SMP Support). *

[PATCH v3 02/20] powerpc/perf/hv-24x7: add missing RTAS retry status handling

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. read_24x7_sys_info() ignores this, allowing transient failures in reporting processor module information. Move the RTAS call into a coventional

[PATCH v3 01/20] powerpc/rtas: handle extended delays safely in early boot

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Some code that runs early in boot calls RTAS functions that can return -2 or 990x statuses, which mean the caller should retry. An example is pSeries_cmo_feature_init(), which invokes ibm,get-system-parameter but treats these benign statuses as errors instead of retrying.

[PATCH v3 03/20] powerpc/pseries/lpar: add missing RTAS retry status handling

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. pseries_lpar_read_hblkrm_characteristics() ignores this, making it possible to incorrectly detect TLB block invalidation characteristics at boot. Move the RTAS

[PATCH v3 04/20] powerpc/pseries/lparcfg: add missing RTAS retry status handling

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. lparcfg's parse_system_parameter_string() ignores this, making it possible to intermittently report incorrect SPLPAR characteristics. Move the RTAS call into a

[PATCH v3 00/20] RTAS maintenance

2023-02-10 Thread Nathan Lynch via B4 Submission Endpoint
Proposed changes for the RTAS subsystem and client code. Fixes that are subject to backporting are at the front of the queue. The rest of the queue is roughly ordered with respect to maturity: i.e. patches that have already garnered some review and discussion precede newer, more experimental

[PATCH v2 19/19] powerpc/rtas: arch-wide function token lookup conversions

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch With the tokens for all implemented RTAS functions now available via rtas_function_token(), which is optimal and safe for arbitrary contexts, there is no need to use rtas_token() or cache its result. Most conversions are trivial, but a few are worth describing in more detail:

[PATCH v2 17/19] powerpc/pseries/lpar: convert to papr_sysparm API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Convert the TLB block invalidate characteristics discovery to the new papr_sysparm API. This occurs too early in boot to use papr_sysparm_buf_alloc(), so use a static buffer. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/lpar.c | 37

[PATCH v2 13/19] powerpc/pseries: PAPR system parameter API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Introduce a set of APIs for retrieving and updating PAPR system parameters. This encapsulates the toil of temporary RTAS work area management, RTAS function call retries, and translation of RTAS call statuses to conventional error values. There are several places in the

[PATCH v2 15/19] powerpc/pseries/lparcfg: convert to papr_sysparm API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch /proc/powerpc/lparcfg derives the LPAR name and SPLPAR characteristics it reports using bare calls to the RTAS ibm,get-system-parameter function. Convert these to the higher-level papr_sysparm API, which handles the tedious details. While the SPLPAR string parsing code could

[PATCH v2 11/19] powerpc/rtas: add work area allocator

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Most callers of RTAS functions that take a temporary "work area" parameter use the statically allocated rtas_data_buf buffer as the argument. This buffer is protected by a global spinlock. So users of rtas_data_buf cannot perform sleeping operations while accessing the buffer.

[PATCH v2 06/19] powerpc/pseries: drop RTAS-based timebase synchronization

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The pseries platform has been LPAR-only for several generations, and the PAPR spec: * Guarantees that timebase synchronization is performed by the platform ("The timebase registers are synchronized by the platform before CPUs are given to the OS" - 7.3.8 SMP Support). *

[PATCH v2 14/19] powerpc/pseries: convert CMO probe to papr_sysparm API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Convert the direct invocation of the ibm,get-system-parameter RTAS function to papr_sysparm_get(). Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/setup.c | 23 ++- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git

[PATCH v2 18/19] powerpc/rtas: introduce rtas_function_token() API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Users of rtas_token() supply a string argument that can't be validated at build time. A typo or misspelling has to be caught by inspection or by observing wrong behavior at runtime. Since the core RTAS code now has consolidated the names of all possible RTAS functions and

[PATCH v2 10/19] powerpc/rtas: add tracepoints around RTAS entry

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Decompose the RTAS entry C code into tracing and non-tracing variants, calling the just-added tracepoints in the tracing-enabled path. Skip tracing in contexts known to be unsafe (real mode, CPU offline). Signed-off-by: Nathan Lynch --- arch/powerpc/kernel/rtas.c | 59

[PATCH v2 09/19] powerpc/tracing: tracepoints for RTAS entry and exit

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Add two sets of tracepoints to be used around RTAS entry: * rtas_input/rtas_output, which emit the function name, its inputs, the returned status, and any other outputs. These produce an API-level record of OS<->RTAS activity. * rtas_ll_entry/rtas_ll_exit, which are

[PATCH v2 00/19] RTAS maintenance

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
Proposed changes for the RTAS subsystem and client code. Fixes that are subject to backporting are at the front of the queue. The rest of the queue is roughly ordered with respect to maturity: i.e. patches that have already garnered some review and discussion precede newer, more experimental

[PATCH v2 01/19] powerpc/rtas: handle extended delays safely in early boot

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Some code that runs early in boot calls RTAS functions that can return -2 or 990x statuses, which mean the caller should retry. An example is pSeries_cmo_feature_init(), which invokes ibm,get-system-parameter but treats these benign statuses as errors instead of retrying.

[PATCH v2 03/19] powerpc/pseries/lpar: add missing RTAS retry status handling

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. pseries_lpar_read_hblkrm_characteristics() ignores this, making it possible to incorrectly detect TLB block invalidation characteristics at boot. Move the RTAS

[PATCH v2 05/19] powerpc/pseries/setup: add missing RTAS retry status handling

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. pSeries_cmo_feature_init() ignores this, making it possible to fail to detect cooperative memory overcommit capabilities during boot. Move the RTAS call into a

[PATCH v2 12/19] powerpc/pseries/dlpar: use RTAS work area API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Hold a work area object for the duration of the RTAS ibm,configure-connector sequence, eliminating locking and copying around each RTAS call. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/dlpar.c | 27 +-- 1 file changed, 9

[PATCH v2 08/19] powerpc/rtas: strengthen do_enter_rtas() type safety, drop inline

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch Make do_enter_rtas() take a pointer to struct rtas_args and do the __pa() conversion in one place instead of leaving it to callers. This also makes it possible to introduce enter/exit tracepoints that access the rtas_args struct fields. There's no apparent reason to force

[PATCH v2 07/19] powerpc/rtas: improve function information lookups

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The core RTAS support code and its clients perform two types of lookup for RTAS firmware function information. First, mapping a known function name to a token. The typical use case invokes rtas_token() to retrieve the token value to pass to rtas_call(). rtas_token() relies on

[PATCH v2 04/19] powerpc/pseries/lparcfg: add missing RTAS retry status handling

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. lparcfg's parse_system_parameter_string() ignores this, making it possible to intermittently report incorrect SPLPAR characteristics. Move the RTAS call into a

[PATCH v2 16/19] powerpc/pseries/hv-24x7: convert to papr_sysparm API

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The new papr_sysparm API handles the details of system parameter retrieval. Use that instead of open-coding the RTAS call, work area management, and retries. Signed-off-by: Nathan Lynch --- arch/powerpc/perf/hv-24x7.c | 37 +++-- 1 file

[PATCH v2 02/19] powerpc/perf/hv-24x7: add missing RTAS retry status handling

2023-02-06 Thread Nathan Lynch via B4 Submission Endpoint
From: Nathan Lynch The ibm,get-system-parameter RTAS function may return -2 or 990x, which indicate that the caller should try again. read_24x7_sys_info() ignores this, allowing transient failures in reporting processor module information. Move the RTAS call into a coventional