From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: Narayana Murty N <nnmlinux@linux.ibm.com>,
mahesh@linux.ibm.com, maddy@linux.ibm.com, mpe@ellerman.id.au,
christophe.leroy@csgroup.eu, gregkh@linuxfoundation.org,
oohall@gmail.com, npiggin@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
tyreld@linux.ibm.com, vaibhav@linux.ibm.com, sbhat@linux.ibm.com,
ganeshgr@linux.ibm.com
Subject: Re: [PATCH 1/4] powerpc/rtas: Handle special return format for RTAS_FN_IBM_OPEN_ERRINJCT
Date: Fri, 12 Dec 2025 14:39:22 +0530 [thread overview]
Message-ID: <b071cc87-18de-41ad-a142-63a8e852cc25@linux.ibm.com> (raw)
In-Reply-To: <20251205094510.4671-2-nnmlinux@linux.ibm.com>
On 05/12/25 15:15, Narayana Murty N wrote:
> RTAS_FN_IBM_OPEN_ERRINJCT returns results in special format:
> rets[0] = session token (output)
> rets[1] = status code
> rets[2..] = additional outputs (if any)
>
> Unlike standard RTAS calls where:
> rets[0] = status code
> rets[1..] = outputs
>
> This patch adds special handling for OPEN_ERRINJCT to:
> 1. Check correct status position (rets[1]) for __fetch_rtas_last_error()
> 2. Copy all rets[0..nret-1] to outputs[] (including token at rets[0])
> 3. Return status from rets[1] instead of rets[0]
>
> Reference: OpenPOWER PAPR documentation
> https://files.openpower.foundation/s/XFgfMaqLMD5Bcm8
> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
> ---
> arch/powerpc/kernel/rtas.c | 30 ++++++++++++++++++++++++------
> 1 file changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
> index 8d81c1e7a8db..04c8438aadda 100644
> --- a/arch/powerpc/kernel/rtas.c
> +++ b/arch/powerpc/kernel/rtas.c
> @@ -1183,7 +1183,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
> unsigned long flags;
> struct rtas_args *args;
> char *buff_copy = NULL;
> - int ret;
> + int ret = 0;
>
> if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
> return -1;
> @@ -1213,15 +1213,33 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
> va_rtas_call_unlocked(args, token, nargs, nret, list);
> va_end(list);
>
> + /* Special handling for RTAS_FN_IBM_OPEN_ERRINJCT for error fetching */
It would be more helpful if we explain why special handling is needed.
> /* A -1 return code indicates that the last command couldn't
> be completed due to a hardware error. */
> - if (be32_to_cpu(args->rets[0]) == -1)
> +
The above empty line can be avoided.
> + if (token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT) && nret > 1)
> + ret = be32_to_cpu(args->rets[1]);
> + else if (nret > 0)
> + ret = be32_to_cpu(args->rets[0]);
> +
> + if (ret == -1)It would be more helpful if we explain why special handling is needed.
>
> buff_copy = __fetch_rtas_last_error(NULL);
>
> - if (nret > 1 && outputs != NULL)
> - for (i = 0; i < nret-1; ++i)
> - outputs[i] = be32_to_cpu(args->rets[i + 1]);
> - ret = (nret > 0) ? be32_to_cpu(args->rets[0]) : 0;
> + /* Handle outputs and return status */
Return status is already handled above, isn't it?
> + if (nret > 1 && outputs != NULL) {
> + if (token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT)) {
> + /* Special case: rets[0]=token, rets[1]=status, rets[2..]=outputs */
> + for (i = 0; i < nret; ++i)
> + outputs[i] = be32_to_cpu(args->rets[i]);
> + } else {
> + /* Normal case: rets[0]=status, rets[1..]=outputs */
> + for (i = 0; i < nret - 1; ++i)
> + outputs[i] = be32_to_cpu(args->rets[i + 1]);
> + }
> + } else {
> + /* No outputs: just ret is status */
> + ret = (nret > 0) ? be32_to_cpu(args->rets[0]) : 0;
> + }
Do we really need to calculated the ret again here?
>
> lockdep_unpin_lock(&rtas_lock, cookie);
> raw_spin_unlock_irqrestore(&rtas_lock, flags);
- Sourabh Jain
next prev parent reply other threads:[~2025-12-12 9:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 9:45 [PATCH 0/4] powerpc/pseries: Add full RTAS-based error injection support Narayana Murty N
2025-12-05 9:45 ` [PATCH 1/4] powerpc/rtas: Handle special return format for RTAS_FN_IBM_OPEN_ERRINJCT Narayana Murty N
2025-12-12 9:09 ` Sourabh Jain [this message]
2025-12-05 9:45 ` [PATCH 2/4] powerpc/pseries: Add RTAS error injection buffer infrastructure Narayana Murty N
2025-12-05 9:45 ` [PATCH 3/4] powerpc/pseries: Add RTAS error injection validation helpers Narayana Murty N
2025-12-06 5:30 ` kernel test robot
2025-12-10 4:02 ` kernel test robot
2025-12-05 9:45 ` [PATCH 4/4] powerpc/pseries: Implement RTAS error injection via pseries_eeh_err_inject Narayana Murty N
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=b071cc87-18de-41ad-a142-63a8e852cc25@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=ganeshgr@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=nnmlinux@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=oohall@gmail.com \
--cc=sbhat@linux.ibm.com \
--cc=tyreld@linux.ibm.com \
--cc=vaibhav@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
all inboxes | Powered by JetHome®