All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
@ 2020-04-17 10:32 Sudeep Holla
  2020-04-18  9:02 ` Peng Fan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sudeep Holla @ 2020-04-17 10:32 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Peng Fan, Etienne Carriere, Sudeep Holla

SMCCC can return one of the 2 return error code here: NOT_SUPPORTED(-1)
and INVALID_PARAMETER(-3). Map them to appropriate Linux error codes
namely -EOPNOTSUPP and -EINVAL respectively. -EINVAL is also returned
for any other return values.

Cc: Peng Fan <peng.fan@nxp.com>
Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/firmware/arm_scmi/smc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index 833e793b5391..a8b5ecb8927a 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -114,7 +114,11 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
 
 	mutex_unlock(&scmi_info->shmem_lock);
 
-	return res.a0;
+	if (res.a0 == SMCCC_RET_NOT_SUPPORTED)
+		return -EOPNOTSUPP;
+	else if (res.a0)
+		return -EINVAL;
+	return 0;
 }
 
 static void smc_fetch_response(struct scmi_chan_info *cinfo,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
  2020-04-17 10:32 [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message Sudeep Holla
@ 2020-04-18  9:02 ` Peng Fan
  2020-04-19 10:04 ` Etienne Carriere
  2020-04-20 18:13 ` Sudeep Holla
  2 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2020-04-18  9:02 UTC (permalink / raw)
  To: Sudeep Holla, linux-arm-kernel; +Cc: Etienne Carriere

> Subject: [PATCH] firmware: arm_scmi: Fix return error code in
> smc_send_message
> 
> SMCCC can return one of the 2 return error code here: NOT_SUPPORTED(-1)
> and INVALID_PARAMETER(-3). Map them to appropriate Linux error codes
> namely -EOPNOTSUPP and -EINVAL respectively. -EINVAL is also returned for
> any other return values.
> 
> Cc: Peng Fan <peng.fan@nxp.com>
> Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
  2020-04-17 10:32 [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message Sudeep Holla
  2020-04-18  9:02 ` Peng Fan
@ 2020-04-19 10:04 ` Etienne Carriere
  2020-04-20 15:35   ` Sudeep Holla
  2020-04-20 18:13 ` Sudeep Holla
  2 siblings, 1 reply; 7+ messages in thread
From: Etienne Carriere @ 2020-04-19 10:04 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: Peng Fan, linux-arm-kernel

Hello Sudeep,

On Fri, 17 Apr 2020 at 12:32, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> SMCCC can return one of the 2 return error code here: NOT_SUPPORTED(-1)
> and INVALID_PARAMETER(-3). Map them to appropriate Linux error codes
> namely -EOPNOTSUPP and -EINVAL respectively. -EINVAL is also returned
> for any other return values.

Reading back the SMCCC spec, I see that INVALID_PARAMETER(-3) and
SUCCESS(0) are Arm Architecture Calls specific return values.
The only generic return value that applies to any SMCCC call is
NOT_SUPPORTED(-1).

As for an SCMI SMCCC transport layer, any other value than -1 means
the call is supported and one should rely on the statuses provided in
the shared memory buffer related to the function ID.

>
> Cc: Peng Fan <peng.fan@nxp.com>
> Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/firmware/arm_scmi/smc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index 833e793b5391..a8b5ecb8927a 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -114,7 +114,11 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>
>         mutex_unlock(&scmi_info->shmem_lock);
>
> -       return res.a0;
> +       if (res.a0 == SMCCC_RET_NOT_SUPPORTED)
> +               return -EOPNOTSUPP;
> +       else if (res.a0)
> +               return -EINVAL;

Related to my comment above:
I have no strong opinion on that as I guess SCMI SMCCC transport layer
in secure world firmware could ensure output argument a0 is set not 0.
That said, I might be nitpicking but I still think th 2 lines could be removed.

Is there any strong reason for testing finer return status from res.a0?

Regards,
Etienne

> +       return 0;
>  }
>
>  static void smc_fetch_response(struct scmi_chan_info *cinfo,
> --
> 2.17.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
  2020-04-19 10:04 ` Etienne Carriere
@ 2020-04-20 15:35   ` Sudeep Holla
  2020-04-20 16:25     ` Etienne Carriere
  0 siblings, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2020-04-20 15:35 UTC (permalink / raw)
  To: Etienne Carriere; +Cc: Peng Fan, linux-arm-kernel, Sudeep Holla

On Sun, Apr 19, 2020 at 12:04:27PM +0200, Etienne Carriere wrote:
> Hello Sudeep,
> 
> On Fri, 17 Apr 2020 at 12:32, Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > SMCCC can return one of the 2 return error code here: NOT_SUPPORTED(-1)
> > and INVALID_PARAMETER(-3). Map them to appropriate Linux error codes
> > namely -EOPNOTSUPP and -EINVAL respectively. -EINVAL is also returned
> > for any other return values.
> 
> Reading back the SMCCC spec, I see that INVALID_PARAMETER(-3) and
> SUCCESS(0) are Arm Architecture Calls specific return values.
> The only generic return value that applies to any SMCCC call is
> NOT_SUPPORTED(-1).
>
> As for an SCMI SMCCC transport layer, any other value than -1 means
> the call is supported and one should rely on the statuses provided in
> the shared memory buffer related to the function ID.
>

Yes I agree, I had the change to reflect above initially and for some reason
I decided to extend.

> >
> > Cc: Peng Fan <peng.fan@nxp.com>
> > Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> >  drivers/firmware/arm_scmi/smc.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> > index 833e793b5391..a8b5ecb8927a 100644
> > --- a/drivers/firmware/arm_scmi/smc.c
> > +++ b/drivers/firmware/arm_scmi/smc.c
> > @@ -114,7 +114,11 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
> >
> >         mutex_unlock(&scmi_info->shmem_lock);
> >
> > -       return res.a0;
> > +       if (res.a0 == SMCCC_RET_NOT_SUPPORTED)
> > +               return -EOPNOTSUPP;
> > +       else if (res.a0)
> > +               return -EINVAL;
> 
> Related to my comment above:
> I have no strong opinion on that as I guess SCMI SMCCC transport layer
> in secure world firmware could ensure output argument a0 is set not 0.
> That said, I might be nitpicking but I still think th 2 lines could be removed.
> 
> Is there any strong reason for testing finer return status from res.a0?
>

No, I will drop. With that can I have you Ack/Reviewed-by ?

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
  2020-04-20 15:35   ` Sudeep Holla
@ 2020-04-20 16:25     ` Etienne Carriere
  2020-04-20 16:52       ` Sudeep Holla
  0 siblings, 1 reply; 7+ messages in thread
From: Etienne Carriere @ 2020-04-20 16:25 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: Peng Fan, linux-arm-kernel

On Mon, 20 Apr 2020 at 17:35, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> On Sun, Apr 19, 2020 at 12:04:27PM +0200, Etienne Carriere wrote:
> > Hello Sudeep,
> >
> > On Fri, 17 Apr 2020 at 12:32, Sudeep Holla <sudeep.holla@arm.com> wrote:
> > >
> > > SMCCC can return one of the 2 return error code here: NOT_SUPPORTED(-1)
> > > and INVALID_PARAMETER(-3). Map them to appropriate Linux error codes
> > > namely -EOPNOTSUPP and -EINVAL respectively. -EINVAL is also returned
> > > for any other return values.
> >
> > Reading back the SMCCC spec, I see that INVALID_PARAMETER(-3) and
> > SUCCESS(0) are Arm Architecture Calls specific return values.
> > The only generic return value that applies to any SMCCC call is
> > NOT_SUPPORTED(-1).
> >
> > As for an SCMI SMCCC transport layer, any other value than -1 means
> > the call is supported and one should rely on the statuses provided in
> > the shared memory buffer related to the function ID.
> >
>
> Yes I agree, I had the change to reflect above initially and for some reason
> I decided to extend.
>
> > >
> > > Cc: Peng Fan <peng.fan@nxp.com>
> > > Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
> > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > > ---
> > >  drivers/firmware/arm_scmi/smc.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> > > index 833e793b5391..a8b5ecb8927a 100644
> > > --- a/drivers/firmware/arm_scmi/smc.c
> > > +++ b/drivers/firmware/arm_scmi/smc.c
> > > @@ -114,7 +114,11 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
> > >
> > >         mutex_unlock(&scmi_info->shmem_lock);
> > >
> > > -       return res.a0;
> > > +       if (res.a0 == SMCCC_RET_NOT_SUPPORTED)
> > > +               return -EOPNOTSUPP;
> > > +       else if (res.a0)
> > > +               return -EINVAL;
> >
> > Related to my comment above:
> > I have no strong opinion on that as I guess SCMI SMCCC transport layer
> > in secure world firmware could ensure output argument a0 is set not 0.
> > That said, I might be nitpicking but I still think th 2 lines could be removed.
> >
> > Is there any strong reason for testing finer return status from res.a0?
> >
>
> No, I will drop. With that can I have you Ack/Reviewed-by ?

Ok.
Sure you can add my Reviewed-by as well as my Tested-by, assuming I
tested this change over the right version.
I used your branch for-next/scmi, from commit a2fe6324.

Regards,
Etienne

>
> --
> Regards,
> Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
  2020-04-20 16:25     ` Etienne Carriere
@ 2020-04-20 16:52       ` Sudeep Holla
  0 siblings, 0 replies; 7+ messages in thread
From: Sudeep Holla @ 2020-04-20 16:52 UTC (permalink / raw)
  To: Etienne Carriere; +Cc: Peng Fan, linux-arm-kernel, Sudeep Holla

On Mon, Apr 20, 2020 at 06:25:31PM +0200, Etienne Carriere wrote:
[...]

> Sure you can add my Reviewed-by as well as my Tested-by, assuming I

Thanks.

> tested this change over the right version.
> I used your branch for-next/scmi, from commit a2fe6324.
>

That's correct.


--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message
  2020-04-17 10:32 [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message Sudeep Holla
  2020-04-18  9:02 ` Peng Fan
  2020-04-19 10:04 ` Etienne Carriere
@ 2020-04-20 18:13 ` Sudeep Holla
  2 siblings, 0 replies; 7+ messages in thread
From: Sudeep Holla @ 2020-04-20 18:13 UTC (permalink / raw)
  To: linux-arm-kernel, Sudeep Holla; +Cc: Peng Fan, Etienne Carriere

On Fri, 17 Apr 2020 11:32:32 +0100, Sudeep Holla wrote:
> SMCCC can return one of the 2 return error code here: NOT_SUPPORTED(-1)
> and INVALID_PARAMETER(-3). Map them to appropriate Linux error codes
> namely -EOPNOTSUPP and -EINVAL respectively. -EINVAL is also returned
> for any other return values.
> 
> Link: https://lore.kernel.org/r/20200417103232.6896-1-sudeep.holla@arm.com
> Cc: Peng Fan <peng.fan@nxp.com>
> Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> 
> [...]

Applied!

[1/1] firmware: arm_scmi: Fix return error code in smc_send_message
      commit: f7199cf489027ae38a9a82312d13025f7aefa0b8

--
Regards,
Sudeep


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-20 18:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17 10:32 [PATCH] firmware: arm_scmi: Fix return error code in smc_send_message Sudeep Holla
2020-04-18  9:02 ` Peng Fan
2020-04-19 10:04 ` Etienne Carriere
2020-04-20 15:35   ` Sudeep Holla
2020-04-20 16:25     ` Etienne Carriere
2020-04-20 16:52       ` Sudeep Holla
2020-04-20 18:13 ` Sudeep Holla

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.