From: Andrew Donnellan <ajd@linux.ibm.com>
To: Nathan Lynch <nathanl@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: tyreld@linux.ibm.com, nnac123@linux.ibm.com,
ldufour@linux.ibm.com, npiggin@gmail.com
Subject: Re: [PATCH 10/13] powerpc/rtas: improve function information lookups
Date: Tue, 29 Nov 2022 18:23:09 +1100 [thread overview]
Message-ID: <099d99683c12b137ec2a4b0158ae3fd390fc1cd3.camel@linux.ibm.com> (raw)
In-Reply-To: <87r0xm8vvy.fsf@linux.ibm.com>
On Mon, 2022-11-28 at 18:08 -0600, Nathan Lynch wrote:
> Andrew Donnellan <ajd@linux.ibm.com> writes:
> > On Fri, 2022-11-18 at 09:07 -0600, Nathan Lynch wrote:
> > > Convert rtas_token() to use a lockless binary search on the
> > > function
> > > table. Fall back to the old behavior for lookups against names
> > > that
> > > are not known to be RTAS functions, but issue a warning.
> > > rtas_token()
> > > is for function names; it is not a general facility for accessing
> > > arbitrary properties of the /rtas node. All known misuses of
> > > rtas_token() have been converted to more appropriate of_ APIs in
> > > preceding changes.
> >
> > For in-kernel users, why not go all the way: make rtas_token()
> > static
> > and use it purely for the userspace API,
>
> Not sure what userspace API refers to here, can you be more specific?
> I
> don't think rtas_token() is exposed to user space.
Right, what I actually meant to refer to here is the fact that sys_rtas
takes a token, but when I wrote this I forgot that userspace doesn't
pass a string, rather librtas implements rtas_token itself using the
/proc interface to the device tree.
>
> > and switch kernel users over
> > to using rtas_function_index directly?
>
> Well, I have work in progress to transition all rtas_token() users to
> a
> different API, but using opaque symbolic handles rather than exposing
> the indexes. Something like:
>
> /*
> * Opaque handle for client code to refer to RTAS functions. All
> valid
> * function handles are build-time constants prefixed with RTAS_FN_.
> */
> typedef struct {
> enum rtas_function_index index;
> } rtas_fn_handle_t;
>
> #define rtas_fn_handle(x_) (const rtas_fn_handle_t) { .index =
> rtas_fnidx(x_), }
>
> #define RTAS_FN_CHECK_EXCEPTION
> rtas_fn_handle(CHECK_EXCEPTION)
> #define RTAS_FN_DISPLAY_CHARACTER
> rtas_fn_handle(DISPLAY_CHARACTER)
> #define RTAS_FN_EVENT_SCAN
> rtas_fn_handle(EVENT_SCAN)
>
> ...
>
> /**
> * 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 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 rtas_function_table[index].token;
> }
>
> But that's a tree-wide change that would touch various drivers, and I
> feel like the current series is what I can reasonably hope to get
> applied right now.
It's not clear to me what the benefit of adding this additional layer
of indirection would be.
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
next prev parent reply other threads:[~2022-11-29 7:24 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 15:07 [PATCH 00/13] RTAS maintenance Nathan Lynch
2022-11-18 15:07 ` [PATCH 01/13] powerpc/rtas: document rtas_call() Nathan Lynch
2022-11-22 2:46 ` Andrew Donnellan
2022-11-18 15:07 ` [PATCH 02/13] powerpc/rtasd: use correct OF API for event scan rate Nathan Lynch
2022-11-22 2:39 ` Andrew Donnellan
2022-11-18 15:07 ` [PATCH 03/13] powerpc/rtas: avoid device tree lookups in rtas_os_term() Nathan Lynch
2022-11-22 3:03 ` Andrew Donnellan
2022-11-28 18:08 ` Nathan Lynch
2022-11-28 2:29 ` Nicholas Piggin
2022-11-28 18:26 ` Nathan Lynch
2022-11-29 6:45 ` Nicholas Piggin
2022-11-29 15:37 ` Nathan Lynch
2022-11-18 15:07 ` [PATCH 04/13] powerpc/rtas: avoid scheduling " Nathan Lynch
2022-11-22 3:17 ` Andrew Donnellan
2022-11-28 2:34 ` Nicholas Piggin
2022-11-18 15:07 ` [PATCH 05/13] powerpc/pseries/eeh: use correct API for error log size Nathan Lynch
2022-11-22 3:21 ` Andrew Donnellan
2022-11-28 20:22 ` Nathan Lynch
2022-11-18 15:07 ` [PATCH 06/13] powerpc/rtas: clean up rtas_error_log_max initialization Nathan Lynch
2022-11-22 3:40 ` Andrew Donnellan
2022-11-18 15:07 ` [PATCH 07/13] powerpc/rtas: clean up includes Nathan Lynch
2022-11-22 4:45 ` Andrew Donnellan
2022-11-18 15:07 ` [PATCH 08/13] powerpc/rtas: define pr_fmt and convert printk call sites Nathan Lynch
2022-11-22 4:07 ` Andrew Donnellan
2022-11-18 15:07 ` [PATCH 09/13] powerpc/rtas: mandate RTAS syscall filtering Nathan Lynch
2022-11-22 4:20 ` Andrew Donnellan
2022-11-18 15:07 ` [PATCH 10/13] powerpc/rtas: improve function information lookups Nathan Lynch
2022-11-23 2:51 ` Andrew Donnellan
2022-11-23 19:32 ` Nick Child
2022-11-24 3:28 ` Andrew Donnellan
2022-11-28 21:19 ` Nathan Lynch
2022-11-29 0:08 ` Nathan Lynch
2022-11-29 7:23 ` Andrew Donnellan [this message]
2022-11-29 15:33 ` Nathan Lynch
2022-11-23 20:06 ` Nick Child
2022-11-28 21:57 ` Nathan Lynch
2022-11-18 15:07 ` [PATCH 11/13] powerpc/rtas: strengthen do_enter_rtas() type safety, drop inline Nathan Lynch
2022-11-23 3:23 ` Andrew Donnellan
2022-11-28 2:37 ` Nicholas Piggin
2022-11-18 15:07 ` [PATCH 12/13] powerpc/tracing: tracepoints for RTAS entry and exit Nathan Lynch
2022-11-28 2:54 ` Nicholas Piggin
2022-11-18 15:07 ` [PATCH 13/13] powerpc/rtas: place tracepoints in do_enter_rtas() Nathan Lynch
2022-11-28 3:07 ` Nicholas Piggin
2022-11-28 23:44 ` Nathan Lynch
2022-11-29 0:49 ` Michael Ellerman
2022-11-29 20:24 ` Nathan Lynch
2022-11-30 7:43 ` Michael Ellerman
2022-11-29 6:47 ` Nicholas Piggin
2022-12-08 12:40 ` [PATCH 00/13] RTAS maintenance 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=099d99683c12b137ec2a4b0158ae3fd390fc1cd3.camel@linux.ibm.com \
--to=ajd@linux.ibm.com \
--cc=ldufour@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nathanl@linux.ibm.com \
--cc=nnac123@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).