Skip to contentSkip to conversation

firmware: arm_scmi: Fix return error code in smc_send_message

PATCH Applied Sudeep Holla 3 participants 7 messages Apr 17, 2020 – Apr 20, 2020 System control & power/management interface (SCPI/SCMI) Message Protocol drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/firmware/arm_scmi/smc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/smc.c +5 -1
index 833e793b5391..a8b5ecb8927a 100644
@@ -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,
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines

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.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
In reply to Sudeep Holla

Hello Sudeep,

Quoted 5 lines · 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.

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.

Quoted 13 lines
---
 drivers/firmware/arm_scmi/smc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/smc.c +0 -0
index 833e793b5391..a8b5ecb8927a 100644

drivers/firmware/arm_scmi/smc.c static int smc_send_message(struct scmi_chan_info *cinfo, · line 120

Quoted 8 lines
drivers/firmware/arm_scmi/smc.c +4 -1
@@ -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

Quoted 7 lines
drivers/firmware/arm_scmi/smc.c +1 -1
+       return 0;
 }
 
 static void smc_fetch_response(struct scmi_chan_info *cinfo,
--

2.17.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 9 lines · Etienne Carriere

Hello Sudeep,

Quoted 5 lines · 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.

Quoted 9 lines

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.

Quoted 27 lines
Quoted 13 lines
---
 drivers/firmware/arm_scmi/smc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/smc.c +0 -0
index 833e793b5391..a8b5ecb8927a 100644

drivers/firmware/arm_scmi/smc.c static int smc_send_message(struct scmi_chan_info *cinfo, · line 120

Quoted 8 lines
drivers/firmware/arm_scmi/smc.c +4 -1
@@ -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.

Quoted 2 lines

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 ?

Signature · 7 lines
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
Quoted 51 lines · Sudeep Holla
Quoted 9 lines · Etienne Carriere

Hello Sudeep,

Quoted 5 lines · 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.

Quoted 9 lines

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.

Quoted 27 lines
Quoted 13 lines
---
 drivers/firmware/arm_scmi/smc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/smc.c +0 -0
index 833e793b5391..a8b5ecb8927a 100644

drivers/firmware/arm_scmi/smc.c static int smc_send_message(struct scmi_chan_info *cinfo, · line 120

Quoted 8 lines
drivers/firmware/arm_scmi/smc.c +4 -1
@@ -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.

Quoted 4 lines
Quoted 2 lines

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

Quoted 4 lines

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

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

Quoted 1 line

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

Thanks.

Quoted 3 lines

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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author Applied
#6 lore raw
In reply to Sudeep Holla
Quoted 5 lines · 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.

Quoted 7 lines

[...]

Applied!

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

      commit: f7199cf489027ae38a9a82312d13025f7aefa0b8

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel