2023-07-05 02:56:34

by Lee, Kah Jing

[permalink] [raw]
Subject: [PATCH] firmware: stratix10-rsu: prevent io block when sending RSU messages

From: Kah Jing Lee <[email protected]>

Fix the issue for preventing recursive rsu mutex lock
issue in RSU update command.

Signed-off-by: Kah Jing Lee <[email protected]>
---
drivers/firmware/stratix10-rsu.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
index e51c95f8d445..0a7542e9bb6f 100644
--- a/drivers/firmware/stratix10-rsu.c
+++ b/drivers/firmware/stratix10-rsu.c
@@ -280,7 +280,9 @@ static int rsu_send_msg(struct stratix10_rsu_priv *priv,
struct stratix10_svc_client_msg msg;
int ret;

- mutex_lock(&priv->lock);
+ if (!mutex_trylock(&priv->lock))
+ return -EAGAIN;
+
reinit_completion(&priv->completion);
priv->client.receive_cb = callback;

@@ -525,7 +527,9 @@ static ssize_t reboot_image_store(struct device *dev,

ret = rsu_send_msg(priv, COMMAND_RSU_UPDATE,
address, rsu_command_callback);
- if (ret) {
+ if (ret == -EAGAIN)
+ return 0;
+ else if (ret) {
dev_err(dev, "Error, RSU update returned %i\n", ret);
return ret;
}
--
2.25.1



2023-07-11 00:44:42

by Dinh Nguyen

[permalink] [raw]
Subject: Re: [PATCH] firmware: stratix10-rsu: prevent io block when sending RSU messages



On 7/4/23 21:18, [email protected] wrote:
> From: Kah Jing Lee <[email protected]>
>
> Fix the issue for preventing recursive rsu mutex lock
> issue in RSU update command.

This message is a bit confusing. What "issue" is preventing a lock issue?

>
> Signed-off-by: Kah Jing Lee <[email protected]>
> ---
> drivers/firmware/stratix10-rsu.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
> index e51c95f8d445..0a7542e9bb6f 100644
> --- a/drivers/firmware/stratix10-rsu.c
> +++ b/drivers/firmware/stratix10-rsu.c
> @@ -280,7 +280,9 @@ static int rsu_send_msg(struct stratix10_rsu_priv *priv,
> struct stratix10_svc_client_msg msg;
> int ret;
>
> - mutex_lock(&priv->lock);
> + if (!mutex_trylock(&priv->lock))
> + return -EAGAIN;
> +
> reinit_completion(&priv->completion);
> priv->client.receive_cb = callback;
>
> @@ -525,7 +527,9 @@ static ssize_t reboot_image_store(struct device *dev,
>
> ret = rsu_send_msg(priv, COMMAND_RSU_UPDATE,
> address, rsu_command_callback);
> - if (ret) {
> + if (ret == -EAGAIN)
> + return 0;
> + else if (ret) {
> dev_err(dev, "Error, RSU update returned %i\n", ret);
> return ret;
> }