All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] mmc: sh_mmcif: Various minor improvements
@ 2016-06-21 13:12 Ulf Hansson
  2016-06-21 13:12 ` [PATCH 1/5] mmc: core: Allow hosts to specify non-support for SD commands Ulf Hansson
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-21 13:12 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

When looking for mmc drivers that has special treatmeant of the ERASE command,
the sh_mmcif driver is one of them, I took the opportunity to improve some of
that related code.

This is not tested on HW, so I would appreciate if someone that still cares
about this driver can do a quick test of these changes.

Ulf Hansson (5):
  mmc: core: Allow hosts to specify non-support for SD commands
  mmc: sh_mmcif: Enable MMC_CAP2_NO_SD and MMC_CAP2_NO_SDIO
  mmc: sh_mmcif: Use response type to know when to enable busy detection
  mmc: sh_mmcif: Inform the mmc core about the max busy timeout
  mmc: sh_mmcif: Use a 10s timeout in the error recovery path

 drivers/mmc/core/core.c     |  9 +++++---
 drivers/mmc/host/sh_mmcif.c | 53 ++++++++++-----------------------------------
 include/linux/mmc/host.h    |  1 +
 3 files changed, 18 insertions(+), 45 deletions(-)

-- 
1.9.1


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

* [PATCH 1/5] mmc: core: Allow hosts to specify non-support for SD commands
  2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
@ 2016-06-21 13:12 ` Ulf Hansson
  2016-06-21 13:12 ` [PATCH 2/5] mmc: sh_mmcif: Enable MMC_CAP2_NO_SD and MMC_CAP2_NO_SDIO Ulf Hansson
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-21 13:12 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

There are host drivers which needs to valdiate for non-supported SD
commands and returnn error code for such requests.

To improve and simplify the behaviour, let's invent MMC_CAP2_NO_SD
which these host drivers can set to tell the mmc core to skip sending SD
commands during card initialization.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/core.c  | 9 ++++++---
 include/linux/mmc/host.h | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index e864187..8b11028 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2500,15 +2500,18 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 
 	mmc_go_idle(host);
 
-	mmc_send_if_cond(host, host->ocr_avail);
+	if (!(host->caps2 & MMC_CAP2_NO_SD))
+		mmc_send_if_cond(host, host->ocr_avail);
 
 	/* Order's important: probe SDIO, then SD, then MMC */
 	if (!(host->caps2 & MMC_CAP2_NO_SDIO))
 		if (!mmc_attach_sdio(host))
 			return 0;
 
-	if (!mmc_attach_sd(host))
-		return 0;
+	if (!(host->caps2 & MMC_CAP2_NO_SD))
+		if (!mmc_attach_sd(host))
+			return 0;
+
 	if (!mmc_attach_mmc(host))
 		return 0;
 
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index d72c0c3..c22476d 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -309,6 +309,7 @@ struct mmc_host {
 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18)	/* No physical write protect pin, assume that card is always read-write */
 #define MMC_CAP2_NO_SDIO	(1 << 19)	/* Do not send SDIO commands during initialization */
 #define MMC_CAP2_HS400_ES	(1 << 20)	/* Host supports enhanced strobe */
+#define MMC_CAP2_NO_SD		(1 << 21)	/* Do not send SD commands during initialization */
 
 	mmc_pm_flag_t		pm_caps;	/* supported pm features */
 
-- 
1.9.1


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

* [PATCH 2/5] mmc: sh_mmcif: Enable MMC_CAP2_NO_SD and MMC_CAP2_NO_SDIO
  2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
  2016-06-21 13:12 ` [PATCH 1/5] mmc: core: Allow hosts to specify non-support for SD commands Ulf Hansson
@ 2016-06-21 13:12 ` Ulf Hansson
  2016-06-21 13:12 ` [PATCH 3/5] mmc: sh_mmcif: Use response type to know when to enable busy detection Ulf Hansson
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-21 13:12 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

Enable the capabilities which tells the mmc core to prevent sending SD and
SDIO commands during card initialization. In this way, we can also remove
the validation of non-supported commands in the ->request() callback.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/sh_mmcif.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index dd64b86..4d6c59f 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1009,22 +1009,6 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	host->state = STATE_REQUEST;
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	switch (mrq->cmd->opcode) {
-	/* MMCIF does not support SD/SDIO command */
-	case MMC_SLEEP_AWAKE: /* = SD_IO_SEND_OP_COND (5) */
-	case MMC_SEND_EXT_CSD: /* = SD_SEND_IF_COND (8) */
-		if ((mrq->cmd->flags & MMC_CMD_MASK) != MMC_CMD_BCR)
-			break;
-	case MMC_APP_CMD:
-	case SD_IO_RW_DIRECT:
-		host->state = STATE_IDLE;
-		mrq->cmd->error = -ETIMEDOUT;
-		mmc_request_done(mmc, mrq);
-		return;
-	default:
-		break;
-	}
-
 	host->mrq = mrq;
 
 	sh_mmcif_start_cmd(host, mrq);
@@ -1488,6 +1472,8 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 	sh_mmcif_init_ocr(host);
 
 	mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_WAIT_WHILE_BUSY;
+	mmc->caps2 |= MMC_CAP2_NO_SD | MMC_CAP2_NO_SDIO;
+
 	if (pd && pd->caps)
 		mmc->caps |= pd->caps;
 	mmc->max_segs = 32;
-- 
1.9.1


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

* [PATCH 3/5] mmc: sh_mmcif: Use response type to know when to enable busy detection
  2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
  2016-06-21 13:12 ` [PATCH 1/5] mmc: core: Allow hosts to specify non-support for SD commands Ulf Hansson
  2016-06-21 13:12 ` [PATCH 2/5] mmc: sh_mmcif: Enable MMC_CAP2_NO_SD and MMC_CAP2_NO_SDIO Ulf Hansson
@ 2016-06-21 13:12 ` Ulf Hansson
  2016-06-21 13:12 ` [PATCH 4/5] mmc: sh_mmcif: Inform the mmc core about the max busy timeout Ulf Hansson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-21 13:12 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

The sh_mmcif explicity checks for certain commands to decide when to
enable HW busy detection. Instead, it should only check the response type
as it tells if busy detection is needed.

In this way, the mmc core also gets full control whether it thinks busy
detection should be done or not. In some specific scenarios, like for
ERASE and STOP commands it may decide to fall back to use a CMD13 to poll
the card status instead.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/sh_mmcif.c | 32 +++++++-------------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 4d6c59f..96a45d8 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -819,10 +819,12 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
 		tmp |= CMD_SET_RTYP_NO;
 		break;
 	case MMC_RSP_R1:
-	case MMC_RSP_R1B:
 	case MMC_RSP_R3:
 		tmp |= CMD_SET_RTYP_6B;
 		break;
+	case MMC_RSP_R1B:
+		tmp |= CMD_SET_RBSY | CMD_SET_RTYP_6B;
+		break;
 	case MMC_RSP_R2:
 		tmp |= CMD_SET_RTYP_17B;
 		break;
@@ -830,17 +832,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
 		dev_err(dev, "Unsupported response type.\n");
 		break;
 	}
-	switch (opc) {
-	/* RBSY */
-	case MMC_SLEEP_AWAKE:
-	case MMC_SWITCH:
-	case MMC_STOP_TRANSMISSION:
-	case MMC_SET_WRITE_PROT:
-	case MMC_CLR_WRITE_PROT:
-	case MMC_ERASE:
-		tmp |= CMD_SET_RBSY;
-		break;
-	}
+
 	/* WDAT / DATW */
 	if (data) {
 		tmp |= CMD_SET_WDAT;
@@ -925,23 +917,13 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host,
 {
 	struct mmc_command *cmd = mrq->cmd;
 	u32 opc = cmd->opcode;
-	u32 mask;
+	u32 mask = 0;
 	unsigned long flags;
 
-	switch (opc) {
-	/* response busy check */
-	case MMC_SLEEP_AWAKE:
-	case MMC_SWITCH:
-	case MMC_STOP_TRANSMISSION:
-	case MMC_SET_WRITE_PROT:
-	case MMC_CLR_WRITE_PROT:
-	case MMC_ERASE:
+	if (cmd->flags & MMC_RSP_BUSY)
 		mask = MASK_START_CMD | MASK_MRBSYE;
-		break;
-	default:
+	else
 		mask = MASK_START_CMD | MASK_MCRSPE;
-		break;
-	}
 
 	if (host->ccs_enable)
 		mask |= MASK_MCCSTO;
-- 
1.9.1


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

* [PATCH 4/5] mmc: sh_mmcif: Inform the mmc core about the max busy timeout
  2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
                   ` (2 preceding siblings ...)
  2016-06-21 13:12 ` [PATCH 3/5] mmc: sh_mmcif: Use response type to know when to enable busy detection Ulf Hansson
@ 2016-06-21 13:12 ` Ulf Hansson
  2016-06-21 13:12 ` [PATCH 5/5] mmc: sh_mmcif: Use a 10s timeout in the error recovery path Ulf Hansson
  2016-06-27  9:22 ` [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
  5 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-21 13:12 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

The sh_mmcif driver is already using a 10s request timeout. Let's also
inform the mmc core about this value, as there are situations when it
needs to know about it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/sh_mmcif.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 96a45d8..bab971b 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1455,6 +1455,7 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 
 	mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_WAIT_WHILE_BUSY;
 	mmc->caps2 |= MMC_CAP2_NO_SD | MMC_CAP2_NO_SDIO;
+	mmc->max_busy_timeout = 10000;
 
 	if (pd && pd->caps)
 		mmc->caps |= pd->caps;
-- 
1.9.1


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

* [PATCH 5/5] mmc: sh_mmcif: Use a 10s timeout in the error recovery path
  2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
                   ` (3 preceding siblings ...)
  2016-06-21 13:12 ` [PATCH 4/5] mmc: sh_mmcif: Inform the mmc core about the max busy timeout Ulf Hansson
@ 2016-06-21 13:12 ` Ulf Hansson
  2016-06-27  9:22 ` [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
  5 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-21 13:12 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

The current value means an mdelay(1) may execute up to 10000000 times,
which translates to around ~2.8 hours. This is probably not what the
orignal author had in mind. Let's instead use 10s, which is the same value
sh_mmcif is using for other timeouts.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/sh_mmcif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index bab971b..9007784 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -574,7 +574,7 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host)
 	if (state1 & STS1_CMDSEQ) {
 		sh_mmcif_bitset(host, MMCIF_CE_CMD_CTRL, CMD_CTRL_BREAK);
 		sh_mmcif_bitset(host, MMCIF_CE_CMD_CTRL, ~CMD_CTRL_BREAK);
-		for (timeout = 10000000; timeout; timeout--) {
+		for (timeout = 10000; timeout; timeout--) {
 			if (!(sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1)
 			      & STS1_CMDSEQ))
 				break;
-- 
1.9.1


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

* Re: [PATCH 0/5] mmc: sh_mmcif: Various minor improvements
  2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
                   ` (4 preceding siblings ...)
  2016-06-21 13:12 ` [PATCH 5/5] mmc: sh_mmcif: Use a 10s timeout in the error recovery path Ulf Hansson
@ 2016-06-27  9:22 ` Ulf Hansson
  5 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2016-06-27  9:22 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson
  Cc: Kuninori Morimoto, Geert Uytterhoeven, Nguyen Viet Dung,
	Magnus Damm, Simon Horman, Baolin Wang

On 21 June 2016 at 15:12, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> When looking for mmc drivers that has special treatmeant of the ERASE command,
> the sh_mmcif driver is one of them, I took the opportunity to improve some of
> that related code.
>
> This is not tested on HW, so I would appreciate if someone that still cares
> about this driver can do a quick test of these changes.
>
> Ulf Hansson (5):
>   mmc: core: Allow hosts to specify non-support for SD commands
>   mmc: sh_mmcif: Enable MMC_CAP2_NO_SD and MMC_CAP2_NO_SDIO
>   mmc: sh_mmcif: Use response type to know when to enable busy detection
>   mmc: sh_mmcif: Inform the mmc core about the max busy timeout
>   mmc: sh_mmcif: Use a 10s timeout in the error recovery path
>
>  drivers/mmc/core/core.c     |  9 +++++---
>  drivers/mmc/host/sh_mmcif.c | 53 ++++++++++-----------------------------------
>  include/linux/mmc/host.h    |  1 +
>  3 files changed, 18 insertions(+), 45 deletions(-)
>
> --
> 1.9.1
>

I decided to queue up this series to get it tested in next/kernelci.

If any objections, please let me know!

Kind regards
Uffe

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

end of thread, other threads:[~2016-06-27  9:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 13:12 [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson
2016-06-21 13:12 ` [PATCH 1/5] mmc: core: Allow hosts to specify non-support for SD commands Ulf Hansson
2016-06-21 13:12 ` [PATCH 2/5] mmc: sh_mmcif: Enable MMC_CAP2_NO_SD and MMC_CAP2_NO_SDIO Ulf Hansson
2016-06-21 13:12 ` [PATCH 3/5] mmc: sh_mmcif: Use response type to know when to enable busy detection Ulf Hansson
2016-06-21 13:12 ` [PATCH 4/5] mmc: sh_mmcif: Inform the mmc core about the max busy timeout Ulf Hansson
2016-06-21 13:12 ` [PATCH 5/5] mmc: sh_mmcif: Use a 10s timeout in the error recovery path Ulf Hansson
2016-06-27  9:22 ` [PATCH 0/5] mmc: sh_mmcif: Various minor improvements Ulf Hansson

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.