* [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion
@ 2021-09-16 9:36 Uwe Kleine-König
2021-09-16 9:36 ` [PATCH 2/2] mci-bcm2835: Fix return type handling of bcm2835_mci_wait_command_done() Uwe Kleine-König
2021-10-02 9:14 ` [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-09-16 9:36 UTC (permalink / raw)
To: barebox
Instead abort with a timeout error. This prevents getting a hung barebox
when a command doesn't complete.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mci/mci-bcm2835.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index 0450f899c60a..12f7cb6ea398 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -87,13 +87,17 @@ static u32 bcm2835_sdhci_read32(struct sdhci *sdhci, int reg)
static u32 bcm2835_mci_wait_command_done(struct bcm2835_mci_host *host)
{
u32 interrupt = 0;
+ uint64_t start;
+ start = get_time_ns();
while (true) {
interrupt = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
if (interrupt & SDHCI_INT_INDEX)
return -EPERM;
if (interrupt & SDHCI_INT_CMD_COMPLETE)
break;
+ if (is_timeout(start, SECOND))
+ return -ETIMEDOUT;
}
return 0;
}
base-commit: c945d24ec5dad6910b02697e4d1df09f89d2b950
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] mci-bcm2835: Fix return type handling of bcm2835_mci_wait_command_done()
2021-09-16 9:36 [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion Uwe Kleine-König
@ 2021-09-16 9:36 ` Uwe Kleine-König
2021-10-02 9:14 ` [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-09-16 9:36 UTC (permalink / raw)
To: barebox
The function returns a negative value in a code path and the return value
is used as a return value for another functions returning int, too. So
change the value to int (and the variable holding the return value, too).
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mci/mci-bcm2835.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index 12f7cb6ea398..f2cb65231e99 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -84,7 +84,7 @@ static u32 bcm2835_sdhci_read32(struct sdhci *sdhci, int reg)
return readl(host->regs + reg);
}
-static u32 bcm2835_mci_wait_command_done(struct bcm2835_mci_host *host)
+static int bcm2835_mci_wait_command_done(struct bcm2835_mci_host *host)
{
u32 interrupt = 0;
uint64_t start;
@@ -131,7 +131,8 @@ static void bcm2835_mci_reset_emmc(struct bcm2835_mci_host *host, u32 reset,
*/
static int bcm2835_mci_request(struct mci_host *mci, struct mci_cmd *cmd,
struct mci_data *data) {
- u32 command, block_data = 0, ret = 0, transfer_mode = 0;
+ u32 command, block_data = 0, transfer_mode = 0;
+ int ret;
u32 wait_inhibit_mask = SDHCI_CMD_INHIBIT_CMD | SDHCI_CMD_INHIBIT_DATA;
struct bcm2835_mci_host *host = to_bcm2835_host(mci);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion
2021-09-16 9:36 [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion Uwe Kleine-König
2021-09-16 9:36 ` [PATCH 2/2] mci-bcm2835: Fix return type handling of bcm2835_mci_wait_command_done() Uwe Kleine-König
@ 2021-10-02 9:14 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-10-02 9:14 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: barebox
On Thu, Sep 16, 2021 at 11:36:26AM +0200, Uwe Kleine-König wrote:
> Instead abort with a timeout error. This prevents getting a hung barebox
> when a command doesn't complete.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mci/mci-bcm2835.c | 4 ++++
> 1 file changed, 4 insertions(+)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-02 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 9:36 [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion Uwe Kleine-König
2021-09-16 9:36 ` [PATCH 2/2] mci-bcm2835: Fix return type handling of bcm2835_mci_wait_command_done() Uwe Kleine-König
2021-10-02 9:14 ` [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox