* [PATCH 1/3] firmware: turris-mox-rwtm: Do not complete if there are no waiters
2024-07-15 11:59 [PATCH 0/3] Fixes for turris-mox-rwtm driver Marek Behún
@ 2024-07-15 11:59 ` Marek Behún
2024-07-15 11:59 ` [PATCH 2/3] firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout() Marek Behún
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Marek Behún @ 2024-07-15 11:59 UTC (permalink / raw)
To: Arnd Bergmann, soc, arm; +Cc: Marek Behún, Andy Shevchenko
Do not complete the "command done" completion if there are no waiters.
This can happen if a wait_for_completion() timed out or was interrupted.
Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
---
drivers/firmware/turris-mox-rwtm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 31d962cdd6eb..f1f9160c4195 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -2,7 +2,7 @@
/*
* Turris Mox rWTM firmware driver
*
- * Copyright (C) 2019 Marek Behún <kabel@kernel.org>
+ * Copyright (C) 2019, 2024 Marek Behún <kabel@kernel.org>
*/
#include <linux/armada-37xx-rwtm-mailbox.h>
@@ -174,6 +174,9 @@ static void mox_rwtm_rx_callback(struct mbox_client *cl, void *data)
struct mox_rwtm *rwtm = dev_get_drvdata(cl->dev);
struct armada_37xx_rwtm_rx_msg *msg = data;
+ if (completion_done(&rwtm->cmd_done))
+ return;
+
rwtm->reply = *msg;
complete(&rwtm->cmd_done);
}
--
2.44.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout()
2024-07-15 11:59 [PATCH 0/3] Fixes for turris-mox-rwtm driver Marek Behún
2024-07-15 11:59 ` [PATCH 1/3] firmware: turris-mox-rwtm: Do not complete if there are no waiters Marek Behún
@ 2024-07-15 11:59 ` Marek Behún
2024-07-15 11:59 ` [PATCH 3/3] firmware: turris-mox-rwtm: Initialize completion before mailbox Marek Behún
2024-08-06 20:08 ` [PATCH 0/3] Fixes for turris-mox-rwtm driver patchwork-bot+linux-soc
3 siblings, 0 replies; 5+ messages in thread
From: Marek Behún @ 2024-07-15 11:59 UTC (permalink / raw)
To: Arnd Bergmann, soc, arm
Cc: Marek Behún, Ilpo Järvinen, Andy Shevchenko
The wait_for_completion_timeout() function returns 0 if timed out, and a
positive value if completed. Fix the usage of this function.
Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
Fixes: 2eab59cf0d20 ("firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
---
drivers/firmware/turris-mox-rwtm.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index f1f9160c4195..3f4758e03c81 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -202,9 +202,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
if (ret < 0)
return ret;
- ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
- if (ret < 0)
- return ret;
+ if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2))
+ return -ETIMEDOUT;
ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval);
if (ret == -ENODATA) {
@@ -238,9 +237,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
if (ret < 0)
return ret;
- ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
- if (ret < 0)
- return ret;
+ if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2))
+ return -ETIMEDOUT;
ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval);
if (ret == -ENODATA) {
@@ -277,9 +275,8 @@ static int check_get_random_support(struct mox_rwtm *rwtm)
if (ret < 0)
return ret;
- ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
- if (ret < 0)
- return ret;
+ if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2))
+ return -ETIMEDOUT;
return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
}
--
2.44.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/3] firmware: turris-mox-rwtm: Initialize completion before mailbox
2024-07-15 11:59 [PATCH 0/3] Fixes for turris-mox-rwtm driver Marek Behún
2024-07-15 11:59 ` [PATCH 1/3] firmware: turris-mox-rwtm: Do not complete if there are no waiters Marek Behún
2024-07-15 11:59 ` [PATCH 2/3] firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout() Marek Behún
@ 2024-07-15 11:59 ` Marek Behún
2024-08-06 20:08 ` [PATCH 0/3] Fixes for turris-mox-rwtm driver patchwork-bot+linux-soc
3 siblings, 0 replies; 5+ messages in thread
From: Marek Behún @ 2024-07-15 11:59 UTC (permalink / raw)
To: Arnd Bergmann, soc, arm; +Cc: Marek Behún, Andy Shevchenko
Initialize the completion before the mailbox channel is requested.
Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
---
drivers/firmware/turris-mox-rwtm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 3f4758e03c81..3e7f186d239a 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -499,6 +499,7 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rwtm);
mutex_init(&rwtm->busy);
+ init_completion(&rwtm->cmd_done);
rwtm->mbox_client.dev = dev;
rwtm->mbox_client.rx_callback = mox_rwtm_rx_callback;
@@ -512,8 +513,6 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
goto remove_files;
}
- init_completion(&rwtm->cmd_done);
-
ret = mox_get_board_info(rwtm);
if (ret < 0)
dev_warn(dev, "Cannot read board information: %i\n", ret);
--
2.44.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/3] Fixes for turris-mox-rwtm driver
2024-07-15 11:59 [PATCH 0/3] Fixes for turris-mox-rwtm driver Marek Behún
` (2 preceding siblings ...)
2024-07-15 11:59 ` [PATCH 3/3] firmware: turris-mox-rwtm: Initialize completion before mailbox Marek Behún
@ 2024-08-06 20:08 ` patchwork-bot+linux-soc
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-soc @ 2024-08-06 20:08 UTC (permalink / raw)
To: =?utf-8?q?Marek_Beh=C3=BAn_=3Ckabel=40kernel=2Eorg=3E?=; +Cc: soc
Hello:
This series was applied to soc/soc.git (arm/fixes)
by Arnd Bergmann <arnd@arndb.de>:
On Mon, 15 Jul 2024 13:59:09 +0200 you wrote:
> Hello Arnd,
>
> as you requested I've split the 3 fix patches from the
> Updates for turris-mox-rwtm driver
> series. I will send the rest once the merge window is closed.
>
> Marek
>
> [...]
Here is the summary with links:
- [1/3] firmware: turris-mox-rwtm: Do not complete if there are no waiters
https://git.kernel.org/soc/soc/c/0bafb172b111
- [2/3] firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout()
https://git.kernel.org/soc/soc/c/8467cfe821ac
- [3/3] firmware: turris-mox-rwtm: Initialize completion before mailbox
https://git.kernel.org/soc/soc/c/49e24c80d3c8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread