All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Wahren <stefan.wahren@i2se.com>
To: Eric Anholt <eric@anholt.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: Stefan Wahren <stefan.wahren@i2se.com>,
	Phil Elwell <phil@raspberrypi.org>,
	linux-mmc@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
	Michal Suchanek <msuchanek@suse.de>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 2/7] mmc: bcm2835: Recover from MMC_SEND_EXT_CSD
Date: Sun, 11 Nov 2018 21:23:54 +0100	[thread overview]
Message-ID: <1541967839-2847-3-git-send-email-stefan.wahren@i2se.com> (raw)
In-Reply-To: <1541967839-2847-1-git-send-email-stefan.wahren@i2se.com>

From: Phil Elwell <phil@raspberrypi.org>

If the user issues an "mmc extcsd read", the SD controller receives
what it thinks is a SEND_IF_COND command with an unexpected data block.
The resulting operations leave the FSM stuck in READWAIT, a state which
persists until the MMC framework resets the controller, by which point
the root filesystem is likely to have been unmounted.

A less heavyweight solution is to detect the condition and nudge the
FSM by asserting the (self-clearing) FORCE_DATA_MODE bit.

Link: https://github.com/raspberrypi/linux/issues/2728
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mmc/host/bcm2835.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index f1712df..a251be2 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -773,6 +773,8 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
 
 		if (!(sdhsts & SDHSTS_CRC7_ERROR) ||
 		    (host->cmd->opcode != MMC_SEND_OP_COND)) {
+			u32 edm, fsm;
+
 			if (sdhsts & SDHSTS_CMD_TIME_OUT) {
 				host->cmd->error = -ETIMEDOUT;
 			} else {
@@ -781,6 +783,13 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
 				bcm2835_dumpregs(host);
 				host->cmd->error = -EILSEQ;
 			}
+			edm = readl(host->ioaddr + SDEDM);
+			fsm = edm & SDEDM_FSM_MASK;
+			if (fsm == SDEDM_FSM_READWAIT ||
+			    fsm == SDEDM_FSM_WRITESTART1)
+				/* Kick the FSM out of its wait */
+				writel(edm | SDEDM_FORCE_DATA_MODE,
+				       host->ioaddr + SDEDM);
 			bcm2835_finish_request(host);
 			return;
 		}
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: stefan.wahren@i2se.com (Stefan Wahren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 2/7] mmc: bcm2835: Recover from MMC_SEND_EXT_CSD
Date: Sun, 11 Nov 2018 21:23:54 +0100	[thread overview]
Message-ID: <1541967839-2847-3-git-send-email-stefan.wahren@i2se.com> (raw)
In-Reply-To: <1541967839-2847-1-git-send-email-stefan.wahren@i2se.com>

From: Phil Elwell <phil@raspberrypi.org>

If the user issues an "mmc extcsd read", the SD controller receives
what it thinks is a SEND_IF_COND command with an unexpected data block.
The resulting operations leave the FSM stuck in READWAIT, a state which
persists until the MMC framework resets the controller, by which point
the root filesystem is likely to have been unmounted.

A less heavyweight solution is to detect the condition and nudge the
FSM by asserting the (self-clearing) FORCE_DATA_MODE bit.

Link: https://github.com/raspberrypi/linux/issues/2728
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mmc/host/bcm2835.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index f1712df..a251be2 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -773,6 +773,8 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
 
 		if (!(sdhsts & SDHSTS_CRC7_ERROR) ||
 		    (host->cmd->opcode != MMC_SEND_OP_COND)) {
+			u32 edm, fsm;
+
 			if (sdhsts & SDHSTS_CMD_TIME_OUT) {
 				host->cmd->error = -ETIMEDOUT;
 			} else {
@@ -781,6 +783,13 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
 				bcm2835_dumpregs(host);
 				host->cmd->error = -EILSEQ;
 			}
+			edm = readl(host->ioaddr + SDEDM);
+			fsm = edm & SDEDM_FSM_MASK;
+			if (fsm == SDEDM_FSM_READWAIT ||
+			    fsm == SDEDM_FSM_WRITESTART1)
+				/* Kick the FSM out of its wait */
+				writel(edm | SDEDM_FORCE_DATA_MODE,
+				       host->ioaddr + SDEDM);
 			bcm2835_finish_request(host);
 			return;
 		}
-- 
2.7.4

  parent reply	other threads:[~2018-11-11 20:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-11 20:23 [PATCH V2 0/7] mmc: Several fixes for bcm2835 driver Stefan Wahren
2018-11-11 20:23 ` Stefan Wahren
2018-11-11 20:23 ` [PATCH V2 1/7] mmc: bcm2835: reset host on timeout Stefan Wahren
2018-11-11 20:23   ` Stefan Wahren
2018-11-11 20:23 ` Stefan Wahren [this message]
2018-11-11 20:23   ` [PATCH V2 2/7] mmc: bcm2835: Recover from MMC_SEND_EXT_CSD Stefan Wahren
2018-11-11 20:23 ` [PATCH V2 4/7] mmc: bcm2835: Avoid possible races on data requests Stefan Wahren
2018-11-11 20:23   ` Stefan Wahren
     [not found] ` <1541967839-2847-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org>
2018-11-11 20:23   ` [PATCH V2 3/7] mmc: bcm2835: Release DMA channel on driver unload Stefan Wahren
2018-11-11 20:23     ` Stefan Wahren
2018-11-11 20:23   ` [PATCH V2 5/7] mmc: bcm2835: Terminate timeout work synchronously Stefan Wahren
2018-11-11 20:23     ` Stefan Wahren
2018-12-05 14:23   ` [PATCH V2 0/7] mmc: Several fixes for bcm2835 driver Ulf Hansson
2018-12-05 14:23     ` Ulf Hansson
2018-11-11 20:23 ` [PATCH V2 6/7] mmc: bcm2835: Refactor dma_map_sg handling Stefan Wahren
2018-11-11 20:23   ` Stefan Wahren
2018-11-11 20:23 ` [PATCH V2 7/7] mmc: bcm2835: Properly handle dmaengine_prep_slave_sg Stefan Wahren
2018-11-11 20:23   ` Stefan Wahren
2018-11-28 17:27   ` Eric Anholt
2018-11-28 17:27     ` Eric Anholt
2018-12-04 18:20     ` Stefan Wahren
2018-12-04 18:20       ` Stefan Wahren
2019-03-21 20:03 ` [PATCH V2 0/7] mmc: Several fixes for bcm2835 driver Michal Suchánek
2019-03-21 20:03   ` Michal Suchánek
2019-03-22 14:45   ` Stefan Wahren
2019-03-22 16:06     ` Michal Suchánek
     [not found]       ` <20190322170643.2e56d220-yQW5Ri8AFK4NMLpHRKhSow@public.gmane.org>
2019-03-22 17:10         ` Stefan Wahren
2019-03-22 17:10           ` Stefan Wahren
2019-03-28 20:43           ` Michal Suchánek
2019-03-30 15:15             ` Stefan Wahren
     [not found]               ` <1920951985.237156.1553958914902-uEpKuDZ350hmhno068Nerg@public.gmane.org>
2019-04-02 18:58                 ` Michal Suchánek
2019-04-02 18:58                   ` Michal Suchánek
2019-04-08 14:55               ` Michal Suchánek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1541967839-2847-3-git-send-email-stefan.wahren@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=msuchanek@suse.de \
    --cc=phil@raspberrypi.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.