Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelwell/265baccf92ea4f2d8e47c4f9e1655714 to your computer and use it in GitHub Desktop.
Save pelwell/265baccf92ea4f2d8e47c4f9e1655714 to your computer and use it in GitHub Desktop.
Potential patch to work around occasional SDHOST timeouts
From 84b0474a86349d36a943db70acdde4729f66478e Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Thu, 22 Feb 2018 17:18:32 +0000
Subject: [PATCH] bcm2835-sdhost: Reset controller & DMA on timeout
Under some circumstances the SDHOST controller has been observed to
lock up, leading to a timeout. When this happens, give the system a
chance of recovering by resetting the controller and terminating any
DMA transfer.
Largely copied from a patch to the upstream bcm2835 driver by
Michal Suchanek <msuchanek@suse.de>.
See: https://github.com/raspberrypi/issues/2392
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---
drivers/mmc/host/bcm2835-sdhost.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/mmc/host/bcm2835-sdhost.c b/drivers/mmc/host/bcm2835-sdhost.c
index 273b1be..6b6bcc0 100644
--- a/drivers/mmc/host/bcm2835-sdhost.c
+++ b/drivers/mmc/host/bcm2835-sdhost.c
@@ -416,6 +416,10 @@ static void bcm2835_sdhost_reset_internal(struct bcm2835_host *host)
if (host->debug)
pr_info("%s: reset\n", mmc_hostname(host->mmc));
+ if (host->dma_chan)
+ dmaengine_terminate_sync(host->dma_chan);
+ host->dma_chan = NULL;
+
bcm2835_sdhost_set_power(host, false);
bcm2835_sdhost_write(host, 0, SDCMD);
@@ -1320,6 +1324,8 @@ static void bcm2835_sdhost_timeout(unsigned long data)
log_dump();
bcm2835_sdhost_dumpregs(host);
+ bcm2835_sdhost_reset_internal(host);
+
if (host->data) {
host->data->error = -ETIMEDOUT;
bcm2835_sdhost_finish_data(host);
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment