firmware: imx: Skip return value check for some special SCU firmware APIs
PATCH v2 1/1 firmware: imx: Skip return value check for some special SCU firmware APIs
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on https://patchwork.kernel.org/patch/11129553/
--- drivers/firmware/imx/imx-scu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/firmware/imx/imx-scu.c +15 -1
@@ -162,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)*/ int imx_scu_call_rpc (struct imx_sc_ipc *sc_ipc,void *msg,bool have_resp) { +uint8_t saved_svc, saved_func;struct imx_sc_rpc_msg *hdr;int ret;
@@ -171,8 +172,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)mutex_lock (&sc_ipc->lock);reinit_completion (&sc_ipc->done); -if (have_resp) +if (have_resp) { sc_ipc->msg = msg; + saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc; + saved_func = ((struct imx_sc_rpc_msg *)msg)->func; + } sc_ipc->count =0 ; ret =imx_scu_ipc_write (sc_ipc, msg);if (ret <0 ) {
@@ -191,6 +195,16 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)/* response status is stored in hdr->func field */ hdr = msg; ret = hdr->func; +/* +* Some special SCU firmware APIs do NOT have return value +* in hdr->func, but they do have response data, those special +* APIs are defined as void function in SCU firmware, so they +* should be treated as return success always. +*/ +if ((saved_svc ==IMX_SC_RPC_SVC_MISC ) && + (saved_func ==IMX_SC_MISC_FUNC_UNIQUE_ID || + saved_func ==IMX_SC_MISC_FUNC_GET_BUTTON_STATUS )) + ret =0 ; } out:
Signature · 1 line
2.7.4
Hi Anson,
Quoted 10 lines · Anson Huang
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on https://patchwork.kernel.org/patch/11129553/
Thanks for this v2. It would be good to change the callers within this series.
Regards,
Marco
Quoted 51 lines
--- drivers/firmware/imx/imx-scu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/firmware/imx/imx-scu.c +15
-1@@ -162,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)*/ int imx_scu_call_rpc (struct imx_sc_ipc *sc_ipc,void *msg,bool have_resp) { +uint8_t saved_svc, saved_func;struct imx_sc_rpc_msg *hdr;int ret;@@ -171,8 +172,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)mutex_lock (&sc_ipc->lock);reinit_completion (&sc_ipc->done); -if (have_resp) +if (have_resp) { sc_ipc->msg = msg; + saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc; + saved_func = ((struct imx_sc_rpc_msg *)msg)->func; + } sc_ipc->count =0 ; ret =imx_scu_ipc_write (sc_ipc, msg);if (ret <0 ) {@@ -191,6 +195,16 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)/* response status is stored in hdr->func field */ hdr = msg; ret = hdr->func; +/* +* Some special SCU firmware APIs do NOT have return value +* in hdr->func, but they do have response data, those special +* APIs are defined as void function in SCU firmware, so they +* should be treated as return success always. +*/ +if ((saved_svc ==IMX_SC_RPC_SVC_MISC ) && + (saved_func ==IMX_SC_MISC_FUNC_UNIQUE_ID || + saved_func ==IMX_SC_MISC_FUNC_GET_BUTTON_STATUS )) + ret =0 ; } out:Signature · 1 line
2.7.4
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi, Marco
Quoted 16 lines · Anson Huang
Quoted 5 lines
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Quoted 7 lines
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11129553%2F&data=02%7C01%7Canson. huang%
Quoted 1 line
Quoted 8 lines
40nxp.com%7C2de0a6be69b74cc249ad08d74afc9730%7C686ea1d3bc2b4c6f a92cd99
Quoted 1 line
c5c301635%7C0%7C0%7C637060321046247040&sdata=RMFAdLKGKb6 mEdhycrzHX
Quoted 1 line
R03E6Qr5pWyRc8Zk6ErlBc%3D&reserved=0
Thanks for this v2. It would be good to change the callers within this series.
NOT quite understand your point, the callers does NOT need to be changed, those 2 special APIs callers are already following the right way of calling the APIs.
Anson
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Anson,
Quoted 21 lines · Anson Huang
Hi, Marco
Quoted 19 lines · Anson Huang
Quoted 5 lines
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Quoted 7 lines
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11129553%2F&data=02%7C01%7Canson. huang%
Quoted 1 line
40nxp.com%7C2de0a6be69b74cc249ad08d74afc9730%7C686ea1d3bc2b4c6f a92cd99
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
c5c301635%7C0%7C0%7C637060321046247040&sdata=RMFAdLKGKb6 mEdhycrzHX
Quoted 1 line
R03E6Qr5pWyRc8Zk6ErlBc%3D&reserved=0
Thanks for this v2. It would be good to change the callers within this series.
NOT quite understand your point, the callers does NOT need to be changed, those 2 special APIs callers are already following the right way of calling the APIs.
Ah okay. I searched the 5.4-rc2 tag and found the soc_uid_show() as only user but this user sets the have_resp field to false. Is this intended?
Regards,
Marco
Quoted 1 line
Anson
Hi, Marco
Quoted 31 lines · Anson Huang
Quoted 17 lines
Hi, Marco
Quoted 15 lines · Anson Huang
Quoted 13 lines
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
patchwork.kernel.org%2Fpatch%2F11129553%2F&data=02%7C01%7Canson.
Quoted 3 lines
Quoted 3 lines
huang%
Quoted 1 line
40nxp.com%7C2de0a6be69b74cc249ad08d74afc9730%7C686ea1d3bc2b4c6f
Quoted 3 lines
Quoted 3 lines
a92cd99
Quoted 1 line
c5c301635%7C0%7C0%7C637060321046247040&sdata=RMFAdLKGKb6
Quoted 4 lines
Quoted 4 lines
mEdhycrzHX
Quoted 1 line
R03E6Qr5pWyRc8Zk6ErlBc%3D&reserved=0
Thanks for this v2. It would be good to change the callers within this
Quoted 8 lines
series.
Quoted 4 lines
NOT quite understand your point, the callers does NOT need to be changed, those
2 special APIs callers are already following the right way of calling the APIs.Ah okay. I searched the 5.4-rc2 tag and found the
soc_uid_show()as only user but this user sets thehave_respfield to false. Is this intended?
I already fixed it and patch applied by Shawn, see below:
https://patchwork.kernel.org/patch/11129497/
Anson
Quoted 39 lines · Anson Huang
Hi, Marco
Quoted 37 lines · Anson Huang
Quoted 17 lines
Hi, Marco
Quoted 15 lines · Anson Huang
Quoted 13 lines
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
patchwork.kernel.org%2Fpatch%2F11129553%2F&data=02%7C01%7Canson.
Quoted 3 lines
Quoted 3 lines
huang%
Quoted 1 line
40nxp.com%7C2de0a6be69b74cc249ad08d74afc9730%7C686ea1d3bc2b4c6f
Quoted 3 lines
Quoted 3 lines
a92cd99
Quoted 1 line
c5c301635%7C0%7C0%7C637060321046247040&sdata=RMFAdLKGKb6
Quoted 4 lines
Quoted 4 lines
mEdhycrzHX
Quoted 1 line
R03E6Qr5pWyRc8Zk6ErlBc%3D&reserved=0
Thanks for this v2. It would be good to change the callers within this
series.
Quoted 4 lines
NOT quite understand your point, the callers does NOT need to be changed, those
2 special APIs callers are already following the right way of calling the APIs.
Quoted 6 lines
Quoted 2 lines
Ah okay. I searched the 5.4-rc2 tag and found the
soc_uid_show()as only user but this user sets thehave_respfield to false. Is this intended?I already fixed it and patch applied by Shawn, see below:
I see :) So one last question, please check the other thread.
Regards,
Marco
Quoted 3 lines
Anson
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Anson,
Quoted 27 lines · Anson Huang
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on https://patchwork.kernel.org/patch/11129553/--- drivers/firmware/imx/imx-scu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/firmware/imx/imx-scu.c +1
-0@@ -162,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)*/ int imx_scu_call_rpc (struct imx_sc_ipc *sc_ipc,void *msg,bool have_resp) { +uint8_t saved_svc, saved_func;struct imx_sc_rpc_msg *hdr;int ret;
drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) · line 177
Quoted 7 lines
drivers/firmware/imx/imx-scu.c +2
-1@@ -171,8 +172,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)mutex_lock (&sc_ipc->lock);reinit_completion (&sc_ipc->done); -if (have_resp) +if (have_resp) { sc_ipc->msg = msg; + saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc;
Why do we need to check the svc too?
drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) · line 178
Quoted 1 line
drivers/firmware/imx/imx-scu.c +1
-0+ saved_func = ((struct imx_sc_rpc_msg *)msg)->func;
Nitpick, should we call it requested_func/req_func?
Regards,
Marco
Quoted 26 lines
drivers/firmware/imx/imx-scu.c +11
-0+ } sc_ipc->count =0 ; ret =imx_scu_ipc_write (sc_ipc, msg);if (ret <0 ) {@@ -191,6 +195,16 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)/* response status is stored in hdr->func field */ hdr = msg; ret = hdr->func; +/* +* Some special SCU firmware APIs do NOT have return value +* in hdr->func, but they do have response data, those special +* APIs are defined as void function in SCU firmware, so they +* should be treated as return success always. +*/ +if ((saved_svc ==IMX_SC_RPC_SVC_MISC ) && + (saved_func ==IMX_SC_MISC_FUNC_UNIQUE_ID || + saved_func ==IMX_SC_MISC_FUNC_GET_BUTTON_STATUS )) + ret =0 ; } out:Signature · 1 line
2.7.4
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi, Marco
Quoted 44 lines · Anson Huang
Quoted 5 lines
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Quoted 7 lines
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11129553%2F&data=02%7C01%7Canson. huang%
Quoted 1 line
40nxp.com%7Cbefd2849a124462caa4a08d74c972dc9%7C686ea1d3bc2b4c6f a92cd99
Quoted 1 line
c5c301635%7C0%7C0%7C637062084506889431&sdata=7fW8hZB4AaUK 9QTKTJQR7
drivers/firmware/imx/imx-scu.c static int imx_scu_ipc_write(struct imx_sc_ipc
Quoted 10 lines
LuV2nGo6e%2Fqb%2Fqmn4ykquk%3D&reserved=0
--- drivers/firmware/imx/imx-scu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/firmware/imx/imx-scu.cindex 869be7a..03b43b7 100644drivers/firmware/imx/imx-scu.c +0
-0@@ -162,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc
*sc_ipc, void *msg)drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc,
Quoted 8 lines
drivers/firmware/imx/imx-scu.c +1
-0*/ int imx_scu_call_rpc (struct imx_sc_ipc *sc_ipc,void *msg,bool have_resp) { +uint8_t saved_svc, saved_func;struct imx_sc_rpc_msg *hdr;int ret;@@ -171,8 +172,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc,void *msg, bool
have_resp)Quoted 3 lines
drivers/firmware/imx/imx-scu.c +0
-0mutex_lock (&sc_ipc->lock);reinit_completion (&sc_ipc->done);
Quoted 6 lines
drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) · line 177
Quoted 4 lines
drivers/firmware/imx/imx-scu.c +2
-1-if (have_resp) +if (have_resp) { sc_ipc->msg = msg; + saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc;Why do we need to check the svc too?
It is because the SCU firmware API has many different category called SVC, each category has many different function, and the function value could be same in each category, for example, there are IRQ, PM, MISC etc. SVC category, and each of them could have function type defined as 0, 1, 2 .... That is why I need to save both SVC and FUNC to identify the SCU FW API. See below:
PM SVC:
#define PM_FUNC_SET_PARTITION_POWER_MODE 1U /* Index for pm_set_partition_power_mode() RPC call */ #define PM_FUNC_GET_SYS_POWER_MODE 2U /* Index for pm_get_sys_power_mode() RPC call */ #define PM_FUNC_SET_RESOURCE_POWER_MODE 3U /* Index for pm_set_resource_power_mode() RPC call */
MISC SVC:
#define MISC_FUNC_SET_CONTROL 1U /* Index for misc_set_control() RPC call */ #define MISC_FUNC_GET_CONTROL 2U /* Index for misc_get_control() RPC call */ #define MISC_FUNC_SET_MAX_DMA_GROUP 4U /* Index for misc_set_max_dma_group() RPC call */
Quoted 4 lines
drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) · line 178
Quoted 2 lines
drivers/firmware/imx/imx-scu.c +1
-0+ saved_func = ((struct imx_sc_rpc_msg *)msg)->func;Nitpick, should we call it requested_func/req_func?
OK, I will change them If I have to sent out a new version, otherwise, I think the saved_func and saved_svc should also be fine.
Thanks,
Anson
Marco Felsch
Reviewed-byHi Anson,
Quoted 64 lines · Anson Huang
Hi, Marco
Quoted 44 lines · Anson Huang
Quoted 5 lines
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Quoted 7 lines
Signed-off-by Anson Huang <[email protected]>---
Changes since V1:
- Use direct API check instead of calling another function to check.
- This patch is based on
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11129553%2F&data=02%7C01%7Canson. huang%
Quoted 1 line
40nxp.com%7Cbefd2849a124462caa4a08d74c972dc9%7C686ea1d3bc2b4c6f a92cd99
Quoted 1 line
c5c301635%7C0%7C0%7C637062084506889431&sdata=7fW8hZB4AaUK 9QTKTJQR7
drivers/firmware/imx/imx-scu.c static int imx_scu_ipc_write(struct imx_sc_ipc
Quoted 10 lines
LuV2nGo6e%2Fqb%2Fqmn4ykquk%3D&reserved=0
--- drivers/firmware/imx/imx-scu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/firmware/imx/imx-scu.cindex 869be7a..03b43b7 100644drivers/firmware/imx/imx-scu.c +0
-0@@ -162,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc
*sc_ipc, void *msg)drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc,
Quoted 8 lines
drivers/firmware/imx/imx-scu.c +1
-0*/ int imx_scu_call_rpc (struct imx_sc_ipc *sc_ipc,void *msg,bool have_resp) { +uint8_t saved_svc, saved_func;struct imx_sc_rpc_msg *hdr;int ret;@@ -171,8 +172,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc,void *msg, bool
have_resp)Quoted 3 lines
drivers/firmware/imx/imx-scu.c +0
-0mutex_lock (&sc_ipc->lock);reinit_completion (&sc_ipc->done);Quoted 6 lines
drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) · line 177
Quoted 4 lines
drivers/firmware/imx/imx-scu.c +2
-1-if (have_resp) +if (have_resp) { sc_ipc->msg = msg; + saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc;Why do we need to check the svc too?
It is because the SCU firmware API has many different category called SVC, each category has many different function, and the function value could be same in each category, for example, there are IRQ, PM, MISC etc. SVC category, and each of them could have function type defined as 0, 1, 2 .... That is why I need to save both SVC and FUNC to identify the SCU FW API. See below:
PM SVC:
#definePM_FUNC_SET_PARTITION_POWER_MODE1U /* Index forpm_set_partition_power_mode()RPC call */ #definePM_FUNC_GET_SYS_POWER_MODE2U /* Index forpm_get_sys_power_mode()RPC call */ #definePM_FUNC_SET_RESOURCE_POWER_MODE3U /* Index forpm_set_resource_power_mode()RPC call */
Quoted 4 lines
MISC SVC:
#defineMISC_FUNC_SET_CONTROL1U /* Index formisc_set_control()RPC call */ #defineMISC_FUNC_GET_CONTROL2U /* Index formisc_get_control()RPC call */ #defineMISC_FUNC_SET_MAX_DMA_GROUP4U /* Index formisc_set_max_dma_group()RPC call */
Ahh, okay get it. Thanks for the explanation.
Quoted 7 lines
Quoted 4 lines
drivers/firmware/imx/imx-scu.c int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) · line 178
Quoted 2 lines
drivers/firmware/imx/imx-scu.c +1
-0+ saved_func = ((struct imx_sc_rpc_msg *)msg)->func;Nitpick, should we call it requested_func/req_func?
OK, I will change them If I have to sent out a new version, otherwise, I think the
saved_funcandsaved_svcshould also be fine.
Just a nitpick ;)
Feel free to add my
Regards,
Marco
Quoted 3 lines
Thanks,
Anson
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Shawn Guo
AppliedQuoted 6 lines · Anson Huang
The SCU firmware does NOT always have return value stored in message header's function element even the API has response data, those special APIs are defined as void function in SCU firmware, so they should be treated as return success always.
Signed-off-by Anson Huang <[email protected]>
Applied, thanks.