From: Leonardo Bras <leobras.c@gmail.com>
To: Nathan Lynch <nathanl@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Allison Randal <allison@lohutok.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Nicholas Piggin <npiggin@gmail.com>,
"Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
Nadav Amit <namit@vmware.com>
Subject: Re: [PATCH v3 2/2] powerpc/rtas: Implement reentrant rtas call
Date: Thu, 14 May 2020 20:28:15 -0300 [thread overview]
Message-ID: <fc13b26ff3d2ea2e84049eabda0c60a60d851b40.camel@gmail.com> (raw)
In-Reply-To: <878shu2vjp.fsf@linux.ibm.com>
Hello Nathan,
On Thu, 2020-05-14 at 13:58 -0500, Nathan Lynch wrote:
> Hi,
>
> Leonardo Bras <leobras.c@gmail.com> writes:
> > +/**
> > + * rtas_call_reentrant() - Used for reentrant rtas calls
> > + * @token: Token for desired reentrant RTAS call
> > + * @nargs: Number of Input Parameters
> > + * @nret: Number of Output Parameters
> > + * @outputs: Array of outputs
> > + * @...: Inputs for desired RTAS call
> > + *
> > + * According to LoPAR documentation, only "ibm,int-on", "ibm,int-off",
> > + * "ibm,get-xive" and "ibm,set-xive" are currently reentrant.
> > + * Reentrant calls need their own rtas_args buffer, so not using rtas.args, but
> > + * PACA one instead.
> > + *
> > + * Return: -1 on error,
> > + * First output value of RTAS call if (nret > 0),
> > + * 0 otherwise,
> > + */
> > +
> > +int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
> > +{
> > + va_list list;
> > + struct rtas_args *args;
> > + int i;
> > +
> > + if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
> > + return -1;
> > +
> > + /* We use the per-cpu (PACA) rtas args buffer */
> > + args = &local_paca->reentrant_args;
> > +
> > + va_start(list, outputs);
> > + va_rtas_call_unlocked(args, token, nargs, nret, list);
> > + va_end(list);
> > +
> > + if (nret > 1 && outputs)
> > + for (i = 0; i < nret - 1; ++i)
> > + outputs[i] = be32_to_cpu(args->rets[i + 1]);
>
> Doesn't this need to be more careful about preemption and exceptions?
> I.e. the args structure in the paca needs to be protected from
> concurrent use somehow, like any per-cpu data structure.
>
> local_irq_save/restore while accessing local_paca->reentrant_args here
> would be sufficient I think?
Yes, you are right.
I will also add preempt_{dis,en}able, which in most kernels will
compile out, but it will be kind of 'ready' if we ever decide to
support PREEMPT.
Thanks for the feedback!
next prev parent reply other threads:[~2020-05-14 23:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 1:12 [PATCH v3 0/2] Implement reentrant rtas call Leonardo Bras
2020-05-14 1:12 ` [PATCH v3 1/2] powerpc/rtas: Move type/struct definitions from rtas.h into rtas-types.h Leonardo Bras
2020-05-14 1:12 ` [PATCH v3 2/2] powerpc/rtas: Implement reentrant rtas call Leonardo Bras
2020-05-14 18:58 ` Nathan Lynch
2020-05-14 23:28 ` Leonardo Bras [this message]
2020-05-15 0:00 ` Leonardo Bras
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=fc13b26ff3d2ea2e84049eabda0c60a60d851b40.camel@gmail.com \
--to=leobras.c@gmail.com \
--cc=allison@lohutok.net \
--cc=benh@kernel.crashing.org \
--cc=ego@linux.vnet.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=namit@vmware.com \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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).