All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
To: Nathan Lynch via B4 Relay
	<devnull+nathanl.linux.ibm.com@kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>
Cc: "Nathan Lynch" <nathanl@linux.ibm.com>,
	tyreld@linux.ibm.com, "Michal Suchánek" <msuchanek@suse.de>,
	linuxppc-dev@lists.ozlabs.org, gcwilson@linux.ibm.com
Subject: Re: [PATCH v4 04/13] powerpc/rtas: Factor out function descriptor lookup
Date: Mon, 20 Nov 2023 13:38:41 +0530	[thread overview]
Message-ID: <87cyw4lud2.fsf@kernel.org> (raw)
In-Reply-To: <20231117-papr-sys_rtas-vs-lockdown-v4-4-b794d8cb8502@linux.ibm.com>

Nathan Lynch via B4 Relay <devnull+nathanl.linux.ibm.com@kernel.org>
writes:

> From: Nathan Lynch <nathanl@linux.ibm.com>
>
> Move the function descriptor table lookup out of rtas_function_token()
> into a separate routine for use in new code to follow. No functional
> change.
>

Reviewed-by: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>

> Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
> ---
>  arch/powerpc/kernel/rtas.c | 31 +++++++++++++++++++------------
>  1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
> index f0051881348a..1fc0b3fffdd1 100644
> --- a/arch/powerpc/kernel/rtas.c
> +++ b/arch/powerpc/kernel/rtas.c
> @@ -469,29 +469,36 @@ static struct rtas_function rtas_function_table[] __ro_after_init = {
>  static DEFINE_RAW_SPINLOCK(rtas_lock);
>  static struct rtas_args rtas_args;
>  
> -/**
> - * rtas_function_token() - RTAS function token lookup.
> - * @handle: Function handle, e.g. RTAS_FN_EVENT_SCAN.
> - *
> - * Context: Any context.
> - * Return: the token value for the function if implemented by this platform,
> - *         otherwise RTAS_UNKNOWN_SERVICE.
> - */
> -s32 rtas_function_token(const rtas_fn_handle_t handle)
> +static struct rtas_function *rtas_function_lookup(const rtas_fn_handle_t handle)
>  {
>  	const size_t index = handle.index;
>  	const bool out_of_bounds = index >= ARRAY_SIZE(rtas_function_table);
>  
>  	if (WARN_ONCE(out_of_bounds, "invalid function index %zu", index))
> -		return RTAS_UNKNOWN_SERVICE;
> +		return NULL;
>  	/*
>  	 * Various drivers attempt token lookups on non-RTAS
>  	 * platforms.
>  	 */
>  	if (!rtas.dev)
> -		return RTAS_UNKNOWN_SERVICE;
> +		return NULL;
> +
> +	return &rtas_function_table[index];
> +}
> +
> +/**
> + * rtas_function_token() - RTAS function token lookup.
> + * @handle: Function handle, e.g. RTAS_FN_EVENT_SCAN.
> + *
> + * Context: Any context.
> + * Return: the token value for the function if implemented by this platform,
> + *         otherwise RTAS_UNKNOWN_SERVICE.
> + */
> +s32 rtas_function_token(const rtas_fn_handle_t handle)
> +{
> +	const struct rtas_function *func = rtas_function_lookup(handle);
>  
> -	return rtas_function_table[index].token;
> +	return func ? func->token : RTAS_UNKNOWN_SERVICE;
>  }
>  EXPORT_SYMBOL_GPL(rtas_function_token);
>  
>
> -- 
> 2.41.0

  reply	other threads:[~2023-11-20 20:21 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-18  5:14 [PATCH v4 00/13] powerpc/pseries: New character devices for system parameters and VPD Nathan Lynch
2023-11-18  5:14 ` Nathan Lynch via B4 Relay
2023-11-18  5:14 ` [PATCH v4 01/13] powerpc/rtas: Add for_each_rtas_function() iterator Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:07   ` Aneesh Kumar K.V
2023-11-18  5:14 ` [PATCH v4 02/13] powerpc/rtas: Fall back to linear search on failed token->function lookup Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:07   ` Aneesh Kumar K.V
2023-11-18  5:14 ` [PATCH v4 03/13] powerpc/rtas: Add function return status constants Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:08   ` Aneesh Kumar K.V
2023-11-18  5:14 ` [PATCH v4 04/13] powerpc/rtas: Factor out function descriptor lookup Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:08   ` Aneesh Kumar K.V [this message]
2023-11-18  5:14 ` [PATCH v4 05/13] powerpc/rtas: Facilitate high-level call sequences Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:10   ` Aneesh Kumar K.V
2023-11-28 15:35     ` Nathan Lynch
2023-11-28 22:30   ` Michael Ellerman
2023-11-28 23:05     ` Nathan Lynch
2023-11-29 13:20       ` Michael Ellerman
2023-11-30 18:26         ` Nathan Lynch
2023-11-30 21:41           ` Nathan Lynch
2023-11-30 22:46           ` Michael Ellerman
2023-11-30 23:53             ` Nathan Lynch
2023-12-05 16:51               ` Nathan Lynch
2023-12-07  1:02                 ` Michael Ellerman
2023-11-29  2:11   ` Michael Ellerman
2023-11-29  2:37     ` Nathan Lynch
2023-11-29  3:16       ` Michael Ellerman
2023-11-18  5:14 ` [PATCH v4 06/13] powerpc/rtas: Serialize firmware activation sequences Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:12   ` Aneesh Kumar K.V
2023-11-28 15:32     ` Nathan Lynch
2023-11-28 15:46       ` Aneesh Kumar K.V
2023-11-28 16:16         ` Nathan Lynch
2023-11-28 16:41           ` Nathan Lynch
2023-11-18  5:14 ` [PATCH v4 07/13] powerpc/rtas: Warn if per-function lock isn't held Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-20  8:13   ` Aneesh Kumar K.V
2023-11-18  5:14 ` [PATCH v4 08/13] powerpc/uapi: Export papr-miscdev.h header Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-18  5:14 ` [PATCH v4 09/13] powerpc/pseries: Add papr-vpd character driver for VPD retrieval Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-21  8:31   ` Michal Suchánek
2023-11-28 15:38     ` Nathan Lynch
2023-11-29  2:07   ` Michael Ellerman
2023-11-29  2:41     ` Nathan Lynch
2023-11-29  3:13       ` Michael Ellerman
2023-11-18  5:14 ` [PATCH v4 10/13] powerpc/pseries/papr-sysparm: Validate buffer object lengths Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-18  5:14 ` [PATCH v4 11/13] powerpc/pseries/papr-sysparm: Expose character device to user space Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-18  5:14 ` [PATCH v4 12/13] powerpc/selftests: Add test for papr-vpd Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-18  5:14 ` [PATCH v4 13/13] powerpc/selftests: Add test for papr-sysparm Nathan Lynch
2023-11-18  5:14   ` Nathan Lynch via B4 Relay
2023-11-29  1:08   ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cyw4lud2.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=devnull+nathanl.linux.ibm.com@kernel.org \
    --cc=gcwilson@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=msuchanek@suse.de \
    --cc=nathanl@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=tyreld@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.