linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes
@ 2020-04-16 18:35 Martin Blumenstingl
  2020-04-16 18:35 ` [PATCH v2 1/2] mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY Martin Blumenstingl
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2020-04-16 18:35 UTC (permalink / raw)
  To: ulf.hansson, linux-mmc, linux-amlogic
  Cc: Martin Blumenstingl, linux-kernel, linux-arm-kernel

The following errors were observed with Linux 5.7-rc1 and an SD card
hooked up to the meson-mx-sdio controller:
  mmc1: Card stuck being busy! __mmc_poll_for_busy
  blk_update_request: I/O error, dev mmcblk1, sector 17111080 op
   0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0


At least patch #1 should go to a -fixes branch so it can make it
into v5.7.


Changes since v1 at [0]:
- added correct Fixes tag for patch #1
- added a patch which drops the ->card_busy() implementation from
  the meson-mx-sdio driver because this is not working
- special thanks to Ulf for taking the time to provide debug
  patches, explaining things and answering my questions!


[0] https://patchwork.kernel.org/patch/11483621/


Martin Blumenstingl (2):
  mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY
  mmc: meson-mx-sdio: remove the broken ->card_busy() op

 drivers/mmc/host/meson-mx-sdio.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

-- 
2.26.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY
  2020-04-16 18:35 [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Martin Blumenstingl
@ 2020-04-16 18:35 ` Martin Blumenstingl
  2020-04-16 18:35 ` [PATCH v2 2/2] mmc: meson-mx-sdio: remove the broken ->card_busy() op Martin Blumenstingl
  2020-04-17  9:30 ` [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2020-04-16 18:35 UTC (permalink / raw)
  To: ulf.hansson, linux-mmc, linux-amlogic
  Cc: Martin Blumenstingl, linux-kernel, linux-arm-kernel

The Meson SDIO controller uses the DAT0 lane for hardware busy
detection. Set MMC_CAP_WAIT_WHILE_BUSY accordingly. This fixes
the following error observed with Linux 5.7 (pre-rc-1):
  mmc1: Card stuck being busy! __mmc_poll_for_busy
  blk_update_request: I/O error, dev mmcblk1, sector 17111080 op
   0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0

Fixes: ed80a13bb4c4c9 ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/mmc/host/meson-mx-sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
index 8b038e7b2cd3..fe02130237a8 100644
--- a/drivers/mmc/host/meson-mx-sdio.c
+++ b/drivers/mmc/host/meson-mx-sdio.c
@@ -570,7 +570,7 @@ static int meson_mx_mmc_add_host(struct meson_mx_mmc_host *host)
 	mmc->f_max = clk_round_rate(host->cfg_div_clk,
 				    clk_get_rate(host->parent_clk));
 
-	mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23;
+	mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY;
 	mmc->ops = &meson_mx_mmc_ops;
 
 	ret = mmc_of_parse(mmc);
-- 
2.26.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] mmc: meson-mx-sdio: remove the broken ->card_busy() op
  2020-04-16 18:35 [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Martin Blumenstingl
  2020-04-16 18:35 ` [PATCH v2 1/2] mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY Martin Blumenstingl
@ 2020-04-16 18:35 ` Martin Blumenstingl
  2020-04-17  9:30 ` [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2020-04-16 18:35 UTC (permalink / raw)
  To: ulf.hansson, linux-mmc, linux-amlogic
  Cc: Martin Blumenstingl, linux-kernel, linux-arm-kernel

The recent commit 0d84c3e6a5b2 ("mmc: core: Convert to
mmc_poll_for_busy() for erase/trim/discard") makes use of the
->card_busy() op for SD cards. This uncovered that the ->card_busy() op
in the Meson SDIO driver was never working right:
while polling the busy status with ->card_busy()
meson_mx_mmc_card_busy() reads only one of the two MESON_MX_SDIO_IRQC
register values 0x1f001f10 or 0x1f003f10. This translates to "three out
of four DAT lines are HIGH" and "all four DAT lines are HIGH", which
is interpreted as "the card is busy".

It turns out that no situation can be observed where all four DAT lines
are LOW, meaning the card is not busy anymore. Upon further research the
3.10 vendor driver for this controller does not implement the
->card_busy() op.

Remove the ->card_busy() op from the meson-mx-sdio driver since it is
not working. At the time of writing this patch it is not clear what's
needed to make the ->card_busy() implementation work with this specific
controller hardware. For all use-cases which have previously worked the
MMC_CAP_WAIT_WHILE_BUSY flag is now taking over, even if we don't have
a ->card_busy() op anymore.

Fixes: ed80a13bb4c4c9 ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/mmc/host/meson-mx-sdio.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
index fe02130237a8..2e58743d83bb 100644
--- a/drivers/mmc/host/meson-mx-sdio.c
+++ b/drivers/mmc/host/meson-mx-sdio.c
@@ -357,14 +357,6 @@ static void meson_mx_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		meson_mx_mmc_start_cmd(mmc, mrq->cmd);
 }
 
-static int meson_mx_mmc_card_busy(struct mmc_host *mmc)
-{
-	struct meson_mx_mmc_host *host = mmc_priv(mmc);
-	u32 irqc = readl(host->base + MESON_MX_SDIO_IRQC);
-
-	return !!(irqc & MESON_MX_SDIO_IRQC_FORCE_DATA_DAT_MASK);
-}
-
 static void meson_mx_mmc_read_response(struct mmc_host *mmc,
 				       struct mmc_command *cmd)
 {
@@ -506,7 +498,6 @@ static void meson_mx_mmc_timeout(struct timer_list *t)
 static struct mmc_host_ops meson_mx_mmc_ops = {
 	.request		= meson_mx_mmc_request,
 	.set_ios		= meson_mx_mmc_set_ios,
-	.card_busy		= meson_mx_mmc_card_busy,
 	.get_cd			= mmc_gpio_get_cd,
 	.get_ro			= mmc_gpio_get_ro,
 };
-- 
2.26.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes
  2020-04-16 18:35 [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Martin Blumenstingl
  2020-04-16 18:35 ` [PATCH v2 1/2] mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY Martin Blumenstingl
  2020-04-16 18:35 ` [PATCH v2 2/2] mmc: meson-mx-sdio: remove the broken ->card_busy() op Martin Blumenstingl
@ 2020-04-17  9:30 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-04-17  9:30 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: open list:ARM/Amlogic Meson...,
	linux-mmc, Linux Kernel Mailing List, Linux ARM

On Thu, 16 Apr 2020 at 20:37, Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
>
> The following errors were observed with Linux 5.7-rc1 and an SD card
> hooked up to the meson-mx-sdio controller:
>   mmc1: Card stuck being busy! __mmc_poll_for_busy
>   blk_update_request: I/O error, dev mmcblk1, sector 17111080 op
>    0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0
>
>
> At least patch #1 should go to a -fixes branch so it can make it
> into v5.7.

Applied for both patches for fixes, and adding stable tags, thanks!

Kind regards
Uffe


>
>
> Changes since v1 at [0]:
> - added correct Fixes tag for patch #1
> - added a patch which drops the ->card_busy() implementation from
>   the meson-mx-sdio driver because this is not working
> - special thanks to Ulf for taking the time to provide debug
>   patches, explaining things and answering my questions!
>
>
> [0] https://patchwork.kernel.org/patch/11483621/
>
>
> Martin Blumenstingl (2):
>   mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY
>   mmc: meson-mx-sdio: remove the broken ->card_busy() op
>
>  drivers/mmc/host/meson-mx-sdio.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
>
> --
> 2.26.1
>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-17  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 18:35 [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Martin Blumenstingl
2020-04-16 18:35 ` [PATCH v2 1/2] mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY Martin Blumenstingl
2020-04-16 18:35 ` [PATCH v2 2/2] mmc: meson-mx-sdio: remove the broken ->card_busy() op Martin Blumenstingl
2020-04-17  9:30 ` [PATCH v2 0/2] meson-mx-sdhc card busy detection fixes Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).