linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
@ 2013-12-17  8:16 Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 1/5] mmc: sdhci: add platfrom get_max_timeout_count hook Dong Aisheng
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Dong Aisheng @ 2013-12-17  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

Patch 1~4 mainly fixes the issue that the max timeout counter for uSDHC is
1 << 28 rather than 1 << 27. 1~2 fix getting the max timeout counter
while 3~4 fix setting the max timeout.
Thus it introduces two new platform hook: get_max_timeout_count and set_timeout
for those platform which have different timeout setting.

This issue is firstly reported here by Ed Sutter:
http://www.spinics.net/lists/linux-mmc/msg23375.html
The root cause is the max_discard_to got from uSDHC is too small, only 677ms,
which cause the max_discard_bytes for eMMC is only 512, then the discard operation
of mkfs.ext3 for an eMMC card is too slow, just like dead.
With above patches, the issue can be fixed.

Patch 5 adds the capability to calcalute the max_discard_to dynamically
for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.

Originally the max_discard_to for a high speed sdhc card may be:
mmc1: new high speed SDHC card at address aaaa
mmc1: calculated max. discard sectors 49152 for timeout 1355 ms
After fix:
mmc1: new high speed SDHC card@address aaaa
mmc1: calculated max. discard sectors 712704 for timeout 5422 ms

It also improves the card discard performance a lot due to max_discard_sectors
increase a lot.

There's also discussion about remove max_discard_to limit here:
http://www.spinics.net/lists/linux-mmc/msg23395.html
But it does not help for uSDHC since we can observe data timeout
on a Toshiba SD3.0 cards if we do not disable data timeout interrupt.

ChangeLog:
v1->v2:
 1. change .get_max_timeout to .get_max_timeout_count to reuse some code
 2. some other minor changes based on Shawn's comment.
 3. patch 6 in v1 is dropped since not need anymore after change 1



Dong Aisheng (5):
  mmc: sdhci: add platfrom get_max_timeout_count hook
  mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
  mmc: sdhci: add platform set_timeout hook
  mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
  mmc: sdhci: calculate max_discard_to dynamically for
    SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK

 drivers/mmc/host/sdhci-esdhc-imx.c |   20 +++++++++++
 drivers/mmc/host/sdhci.c           |   66 +++++++++++++++++++++++------------
 drivers/mmc/host/sdhci.h           |    3 ++
 3 files changed, 66 insertions(+), 23 deletions(-)

-- 
1.7.2.rc3

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

* [PATCH v2 1/5] mmc: sdhci: add platfrom get_max_timeout_count hook
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
@ 2013-12-17  8:16 ` Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 2/5] mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC Dong Aisheng
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2013-12-17  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

Currently the max_discard_to is simply got by (1 << 27) / host->timeout_clk
which is assumed to be the maximum timeout value, however, some platforms
maximum timeout counter may not be 1 << 27, e.g. i.MX uSDHC is 1 << 28.
Thus 1 << 27 may not be correct for such platforms.

It is also possible that other platforms may have different problems.
To be flexible, we add a get_max_timeout_count hook to get the correct
maximum timeout value for these platforms.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
 drivers/mmc/host/sdhci.c |    4 +++-
 drivers/mmc/host/sdhci.h |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index cc00bed..7fef3bb 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2942,7 +2942,9 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
 		host->timeout_clk = mmc->f_max / 1000;
 
-	mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+	mmc->max_discard_to = host->ops->get_max_timeout_count ?
+			host->ops->get_max_timeout_count(host) : 1 << 27;
+	mmc->max_discard_to /= host->timeout_clk;
 
 	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0a3ed01..acba9a7 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -281,6 +281,7 @@ struct sdhci_ops {
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
+	unsigned int	(*get_max_timeout_count)(struct sdhci_host *host);
 	int		(*platform_bus_width)(struct sdhci_host *host,
 					       int width);
 	void (*platform_send_init_74_clocks)(struct sdhci_host *host,
-- 
1.7.2.rc3

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

* [PATCH v2 2/5] mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 1/5] mmc: sdhci: add platfrom get_max_timeout_count hook Dong Aisheng
@ 2013-12-17  8:16 ` Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 3/5] mmc: sdhci: add platform set_timeout hook Dong Aisheng
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2013-12-17  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

The default sdhci code use the 1 << 27 as the max timeout counter to
to calculate the max_discard_to, however it's not correct for uSDHC
since its the max counter is 1 << 28.
Implement esdhc_get_max_timeout to handle it correctly.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index de2655e..5d9b56d 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -880,6 +880,14 @@ static int esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
 	return esdhc_change_pinstate(host, uhs);
 }
 
+static unsigned int esdhc_get_max_timeout_count(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct pltfm_imx_data *imx_data = pltfm_host->priv;
+
+	return esdhc_is_usdhc(imx_data) ? 1 << 28 : 1 << 27;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = esdhc_readl_le,
 	.read_w = esdhc_readw_le,
@@ -892,6 +900,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 	.get_ro = esdhc_pltfm_get_ro,
 	.platform_bus_width = esdhc_pltfm_bus_width,
 	.set_uhs_signaling = esdhc_set_uhs_signaling,
+	.get_max_timeout_count = esdhc_get_max_timeout_count,
 };
 
 static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
-- 
1.7.2.rc3

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

* [PATCH v2 3/5] mmc: sdhci: add platform set_timeout hook
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 1/5] mmc: sdhci: add platfrom get_max_timeout_count hook Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 2/5] mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC Dong Aisheng
@ 2013-12-17  8:16 ` Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 4/5] mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC Dong Aisheng
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2013-12-17  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

Currently the common code assume 0xE is the maximum timeout counter
value and use it to write into the timeout counter register.
However, it's fairly possible that some other SoCs may have different
max timeout register value. That means 0xE may be incorrect and
becomes meaningless.

It's also possible that other platforms has different timeout
calculation algorithm. To be flexible, this patch provides a .set_timeout
hook for those platforms to set the timeout on their way if they need.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
 drivers/mmc/host/sdhci.c |   19 ++++++++++++++-----
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7fef3bb..47ecf50 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -726,19 +726,28 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host)
 		sdhci_clear_set_irqs(host, dma_irqs, pio_irqs);
 }
 
-static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
+static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 {
 	u8 count;
+
+	if (host->ops->set_timeout) {
+		host->ops->set_timeout(host, cmd);
+	} else {
+		count = sdhci_calc_timeout(host, cmd);
+		sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
+	}
+}
+
+static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
+{
 	u8 ctrl;
 	struct mmc_data *data = cmd->data;
 	int ret;
 
 	WARN_ON(host->data);
 
-	if (data || (cmd->flags & MMC_RSP_BUSY)) {
-		count = sdhci_calc_timeout(host, cmd);
-		sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
-	}
+	if (data || (cmd->flags & MMC_RSP_BUSY))
+		sdhci_set_timeout(host, cmd);
 
 	if (!data)
 		return;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index acba9a7..25c1572 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -282,6 +282,8 @@ struct sdhci_ops {
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
 	unsigned int	(*get_max_timeout_count)(struct sdhci_host *host);
+	void		(*set_timeout)(struct sdhci_host *host,
+						struct mmc_command *cmd);
 	int		(*platform_bus_width)(struct sdhci_host *host,
 					       int width);
 	void (*platform_send_init_74_clocks)(struct sdhci_host *host,
-- 
1.7.2.rc3

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

* [PATCH v2 4/5] mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
                   ` (2 preceding siblings ...)
  2013-12-17  8:16 ` [PATCH v2 3/5] mmc: sdhci: add platform set_timeout hook Dong Aisheng
@ 2013-12-17  8:16 ` Dong Aisheng
  2013-12-17  8:16 ` [PATCH v2 5/5] mmc: sdhci: calculate max_discard_to dynamically for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK Dong Aisheng
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2013-12-17  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

The default sdhci driver write 0xE into timeout counter register to
set the maximum timeout. The value is not correct for uSDHC since the
max counter value for uSDHC is 0xF.
Instead of using common timeout code in sdhci, we implement esdhc_set_timeout
to handle the difference between eSDHC and uSDHC.

Currently we simply set the max timeout value as before.
But in the future, we probably may implement IMX specific timeout
setting algorithm and use suitable timeout for different CMDs.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 5d9b56d..2a04847 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -888,6 +888,16 @@ static unsigned int esdhc_get_max_timeout_count(struct sdhci_host *host)
 	return esdhc_is_usdhc(imx_data) ? 1 << 28 : 1 << 27;
 }
 
+static void esdhc_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct pltfm_imx_data *imx_data = pltfm_host->priv;
+
+	/* use maximum timeout counter */
+	sdhci_writeb(host, esdhc_is_usdhc(imx_data) ? 0xF : 0xE,
+			SDHCI_TIMEOUT_CONTROL);
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = esdhc_readl_le,
 	.read_w = esdhc_readw_le,
@@ -901,6 +911,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 	.platform_bus_width = esdhc_pltfm_bus_width,
 	.set_uhs_signaling = esdhc_set_uhs_signaling,
 	.get_max_timeout_count = esdhc_get_max_timeout_count,
+	.set_timeout = esdhc_set_timeout,
 };
 
 static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
-- 
1.7.2.rc3

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

* [PATCH v2 5/5] mmc: sdhci: calculate max_discard_to dynamically for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
                   ` (3 preceding siblings ...)
  2013-12-17  8:16 ` [PATCH v2 4/5] mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC Dong Aisheng
@ 2013-12-17  8:16 ` Dong Aisheng
  2013-12-17 14:30 ` [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Shawn Guo
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2013-12-17  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

For host controllers using SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK, since the card
clock is changed dynamically for different cards, it does not make sense
to use the maximum host clock to calculate max_discard_to which may lead
the max_discard_to to be much smaller than its capbility and affect the card
discard performance a lot.
e.g. the host clock is 200Mhz, but the card is working on 50Mhz. Then the
max_discard_to is only 1/4 of its real capbility.

In this patch, it uses the actual_clock to calculate the max_discard_to
dynamically as long as a new clock speed is set.

Tested with a high speed SDHC card shows:
Originally:
mmc1: new high speed SDHC card at address aaaa
mmc1: calculated max. discard sectors 49152 for timeout 1355 ms
Now:
mmc1: new high speed SDHC card at address aaaa
mmc1: calculated max. discard sectors 712704 for timeout 5422 ms
The max_discard_sectors will increase a lot which will also improve discard
performance a lot.

The one known limitation of this approach is that it does not cover the special
case for user changes the clock via sysfs, since the max_discard_to is only
initialised for one time during the mmc queue init.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
 drivers/mmc/host/sdhci.c |   47 +++++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 47ecf50..a104bb1 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1155,7 +1155,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 	if (host->ops->set_clock) {
 		host->ops->set_clock(host, clock);
 		if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK)
-			return;
+			goto out;
 	}
 
 	sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
@@ -1254,6 +1254,16 @@ clock_set:
 
 out:
 	host->clock = clock;
+
+	/* update timeout_clk and max_discard_to once the SDCLK is changed */
+	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK && clock) {
+		host->timeout_clk = host->mmc->actual_clock ?
+					host->mmc->actual_clock / 1000 :
+					host->clock / 1000;
+		host->mmc->max_discard_to = host->ops->get_max_timeout_count ?
+			host->ops->get_max_timeout_count(host) : 1 << 27;
+		host->mmc->max_discard_to /= host->timeout_clk;
+	}
 }
 
 static inline void sdhci_update_clock(struct sdhci_host *host)
@@ -2933,27 +2943,26 @@ int sdhci_add_host(struct sdhci_host *host)
 	} else
 		mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
-	host->timeout_clk =
-		(caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
-	if (host->timeout_clk == 0) {
-		if (host->ops->get_timeout_clock) {
-			host->timeout_clk = host->ops->get_timeout_clock(host);
-		} else if (!(host->quirks &
-				SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
-			pr_err("%s: Hardware doesn't specify timeout clock "
-			       "frequency.\n", mmc_hostname(mmc));
-			return -ENODEV;
+	if (!(host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
+		host->timeout_clk = (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >>
+				SDHCI_TIMEOUT_CLK_SHIFT;
+		if (host->timeout_clk == 0) {
+			if (host->ops->get_timeout_clock) {
+				host->timeout_clk =
+					host->ops->get_timeout_clock(host);
+			} else {
+				pr_err("%s: Hardware doesn't specify timeout"
+				       "clock frequency.\n", mmc_hostname(mmc));
+				return -ENODEV;
+			}
 		}
-	}
-	if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
-		host->timeout_clk *= 1000;
-
-	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
-		host->timeout_clk = mmc->f_max / 1000;
+		if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
+			host->timeout_clk *= 1000;
 
-	mmc->max_discard_to = host->ops->get_max_timeout_count ?
+		mmc->max_discard_to = host->ops->get_max_timeout_count ?
 			host->ops->get_max_timeout_count(host) : 1 << 27;
-	mmc->max_discard_to /= host->timeout_clk;
+		mmc->max_discard_to /= host->timeout_clk;
+	}
 
 	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
 
-- 
1.7.2.rc3

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
                   ` (4 preceding siblings ...)
  2013-12-17  8:16 ` [PATCH v2 5/5] mmc: sdhci: calculate max_discard_to dynamically for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK Dong Aisheng
@ 2013-12-17 14:30 ` Shawn Guo
  2014-01-13 10:55   ` Dong Aisheng
  2014-01-13 13:01 ` Ulf Hansson
  2014-05-17 14:09 ` Shawn Guo
  7 siblings, 1 reply; 13+ messages in thread
From: Shawn Guo @ 2013-12-17 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 17, 2013 at 04:16:26PM +0800, Dong Aisheng wrote:
> Dong Aisheng (5):
>   mmc: sdhci: add platfrom get_max_timeout_count hook
>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>   mmc: sdhci: add platform set_timeout hook
>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>   mmc: sdhci: calculate max_discard_to dynamically for
>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK

For all,

Reviewed-by: Shawn Guo <shawn.guo@linaro.org>

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2013-12-17 14:30 ` [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Shawn Guo
@ 2014-01-13 10:55   ` Dong Aisheng
  2014-01-20  2:42     ` Dong Aisheng
  0 siblings, 1 reply; 13+ messages in thread
From: Dong Aisheng @ 2014-01-13 10:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Chris,

On Tue, Dec 17, 2013 at 10:30 PM, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Tue, Dec 17, 2013 at 04:16:26PM +0800, Dong Aisheng wrote:
>> Dong Aisheng (5):
>>   mmc: sdhci: add platfrom get_max_timeout_count hook
>>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>>   mmc: sdhci: add platform set_timeout hook
>>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>>   mmc: sdhci: calculate max_discard_to dynamically for
>>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
>
> For all,
>
> Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
>

Can you pick this series?

Regards
Dong Aisheng

> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
                   ` (5 preceding siblings ...)
  2013-12-17 14:30 ` [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Shawn Guo
@ 2014-01-13 13:01 ` Ulf Hansson
  2014-01-15  6:53   ` Dong Aisheng
  2014-05-17 14:09 ` Shawn Guo
  7 siblings, 1 reply; 13+ messages in thread
From: Ulf Hansson @ 2014-01-13 13:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 17 December 2013 09:16, Dong Aisheng <b29396@freescale.com> wrote:
> Patch 1~4 mainly fixes the issue that the max timeout counter for uSDHC is
> 1 << 28 rather than 1 << 27. 1~2 fix getting the max timeout counter
> while 3~4 fix setting the max timeout.
> Thus it introduces two new platform hook: get_max_timeout_count and set_timeout
> for those platform which have different timeout setting.
>
> This issue is firstly reported here by Ed Sutter:
> http://www.spinics.net/lists/linux-mmc/msg23375.html
> The root cause is the max_discard_to got from uSDHC is too small, only 677ms,
> which cause the max_discard_bytes for eMMC is only 512, then the discard operation
> of mkfs.ext3 for an eMMC card is too slow, just like dead.
> With above patches, the issue can be fixed.
>
> Patch 5 adds the capability to calcalute the max_discard_to dynamically
> for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.
>
> Originally the max_discard_to for a high speed sdhc card may be:
> mmc1: new high speed SDHC card at address aaaa
> mmc1: calculated max. discard sectors 49152 for timeout 1355 ms
> After fix:
> mmc1: new high speed SDHC card at address aaaa
> mmc1: calculated max. discard sectors 712704 for timeout 5422 ms
>
> It also improves the card discard performance a lot due to max_discard_sectors
> increase a lot.
>
> There's also discussion about remove max_discard_to limit here:
> http://www.spinics.net/lists/linux-mmc/msg23395.html
> But it does not help for uSDHC since we can observe data timeout
> on a Toshiba SD3.0 cards if we do not disable data timeout interrupt.

Just some more input to this discussion.

As you probably know, I am working on a solution which in principle
means we will fall back to use R1 responses instead of R1B.
Particularly in those cases were the host driver supports
MMC_CAP_WAIT_WHILE_BUSY and when it can't support the requested busy
detection timeout. In other words, we will fall back to use poll with
CMD13 instead, which is what happens already for those not supporting
MMC_CAP_WAIT_WHILE_BUSY.

Kind regards
Ulf Hansson

>
> ChangeLog:
> v1->v2:
>  1. change .get_max_timeout to .get_max_timeout_count to reuse some code
>  2. some other minor changes based on Shawn's comment.
>  3. patch 6 in v1 is dropped since not need anymore after change 1
>
>
>
> Dong Aisheng (5):
>   mmc: sdhci: add platfrom get_max_timeout_count hook
>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>   mmc: sdhci: add platform set_timeout hook
>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>   mmc: sdhci: calculate max_discard_to dynamically for
>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
>
>  drivers/mmc/host/sdhci-esdhc-imx.c |   20 +++++++++++
>  drivers/mmc/host/sdhci.c           |   66 +++++++++++++++++++++++------------
>  drivers/mmc/host/sdhci.h           |    3 ++
>  3 files changed, 66 insertions(+), 23 deletions(-)
>
> --
> 1.7.2.rc3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2014-01-13 13:01 ` Ulf Hansson
@ 2014-01-15  6:53   ` Dong Aisheng
  0 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2014-01-15  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ulf,

On Mon, Jan 13, 2014 at 9:01 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 17 December 2013 09:16, Dong Aisheng <b29396@freescale.com> wrote:
>> Patch 1~4 mainly fixes the issue that the max timeout counter for uSDHC is
>> 1 << 28 rather than 1 << 27. 1~2 fix getting the max timeout counter
>> while 3~4 fix setting the max timeout.
>> Thus it introduces two new platform hook: get_max_timeout_count and set_timeout
>> for those platform which have different timeout setting.
>>
>> This issue is firstly reported here by Ed Sutter:
>> http://www.spinics.net/lists/linux-mmc/msg23375.html
>> The root cause is the max_discard_to got from uSDHC is too small, only 677ms,
>> which cause the max_discard_bytes for eMMC is only 512, then the discard operation
>> of mkfs.ext3 for an eMMC card is too slow, just like dead.
>> With above patches, the issue can be fixed.
>>
>> Patch 5 adds the capability to calcalute the max_discard_to dynamically
>> for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.
>>
>> Originally the max_discard_to for a high speed sdhc card may be:
>> mmc1: new high speed SDHC card at address aaaa
>> mmc1: calculated max. discard sectors 49152 for timeout 1355 ms
>> After fix:
>> mmc1: new high speed SDHC card at address aaaa
>> mmc1: calculated max. discard sectors 712704 for timeout 5422 ms
>>
>> It also improves the card discard performance a lot due to max_discard_sectors
>> increase a lot.
>>
>> There's also discussion about remove max_discard_to limit here:
>> http://www.spinics.net/lists/linux-mmc/msg23395.html
>> But it does not help for uSDHC since we can observe data timeout
>> on a Toshiba SD3.0 cards if we do not disable data timeout interrupt.
>
> Just some more input to this discussion.
>
> As you probably know, I am working on a solution which in principle
> means we will fall back to use R1 responses instead of R1B.
> Particularly in those cases were the host driver supports
> MMC_CAP_WAIT_WHILE_BUSY and when it can't support the requested busy
> detection timeout. In other words, we will fall back to use poll with
> CMD13 instead, which is what happens already for those not supporting
> MMC_CAP_WAIT_WHILE_BUSY.
>

Will be glad to see your patches for that feature.

This patch series is intend to fix different issues, it does not
depend on your work.
Patch 1~4 is totally for fixing imx timeout issues.
Patch 5 is to add the capability to calcalute the max_discard_to dynamically.
This is also a fix of calculating max_discard_to for controllers using
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.
It's especially useful for controllers using hw timeout with big
timeout capability.
They should be needed no matter whether polling way is used or not.

Regards
Dong Aisheng

> Kind regards
> Ulf Hansson
>
>>
>> ChangeLog:
>> v1->v2:
>>  1. change .get_max_timeout to .get_max_timeout_count to reuse some code
>>  2. some other minor changes based on Shawn's comment.
>>  3. patch 6 in v1 is dropped since not need anymore after change 1
>>
>>
>>
>> Dong Aisheng (5):
>>   mmc: sdhci: add platfrom get_max_timeout_count hook
>>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>>   mmc: sdhci: add platform set_timeout hook
>>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>>   mmc: sdhci: calculate max_discard_to dynamically for
>>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
>>
>>  drivers/mmc/host/sdhci-esdhc-imx.c |   20 +++++++++++
>>  drivers/mmc/host/sdhci.c           |   66 +++++++++++++++++++++++------------
>>  drivers/mmc/host/sdhci.h           |    3 ++
>>  3 files changed, 66 insertions(+), 23 deletions(-)
>>
>> --
>> 1.7.2.rc3
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2014-01-13 10:55   ` Dong Aisheng
@ 2014-01-20  2:42     ` Dong Aisheng
  0 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2014-01-20  2:42 UTC (permalink / raw)
  To: linux-arm-kernel

Ping...

On Mon, Jan 13, 2014 at 6:55 PM, Dong Aisheng <dongas86@gmail.com> wrote:
> Hi Chris,
>
> On Tue, Dec 17, 2013 at 10:30 PM, Shawn Guo <shawn.guo@linaro.org> wrote:
>> On Tue, Dec 17, 2013 at 04:16:26PM +0800, Dong Aisheng wrote:
>>> Dong Aisheng (5):
>>>   mmc: sdhci: add platfrom get_max_timeout_count hook
>>>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>>>   mmc: sdhci: add platform set_timeout hook
>>>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>>>   mmc: sdhci: calculate max_discard_to dynamically for
>>>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
>>
>> For all,
>>
>> Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
>>
>
> Can you pick this series?
>
> Regards
> Dong Aisheng
>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
                   ` (6 preceding siblings ...)
  2014-01-13 13:01 ` Ulf Hansson
@ 2014-05-17 14:09 ` Shawn Guo
  2014-05-19  2:43   ` Dong Aisheng
  7 siblings, 1 reply; 13+ messages in thread
From: Shawn Guo @ 2014-05-17 14:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 17, 2013 at 04:16:26PM +0800, Dong Aisheng wrote:
> Patch 1~4 mainly fixes the issue that the max timeout counter for uSDHC is
> 1 << 28 rather than 1 << 27. 1~2 fix getting the max timeout counter
> while 3~4 fix setting the max timeout.
> Thus it introduces two new platform hook: get_max_timeout_count and set_timeout
> for those platform which have different timeout setting.
> 
> This issue is firstly reported here by Ed Sutter:
> http://www.spinics.net/lists/linux-mmc/msg23375.html
> The root cause is the max_discard_to got from uSDHC is too small, only 677ms,
> which cause the max_discard_bytes for eMMC is only 512, then the discard operation
> of mkfs.ext3 for an eMMC card is too slow, just like dead.
> With above patches, the issue can be fixed.

It seems the series got lost?  The issue reported by Ed Sutter is still
there with the latest kernel.

Dong, you may need to rebase it a little bit and resend.

Shawn

> 
> Patch 5 adds the capability to calcalute the max_discard_to dynamically
> for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.
> 
> Originally the max_discard_to for a high speed sdhc card may be:
> mmc1: new high speed SDHC card at address aaaa
> mmc1: calculated max. discard sectors 49152 for timeout 1355 ms
> After fix:
> mmc1: new high speed SDHC card at address aaaa
> mmc1: calculated max. discard sectors 712704 for timeout 5422 ms
> 
> It also improves the card discard performance a lot due to max_discard_sectors
> increase a lot.
> 
> There's also discussion about remove max_discard_to limit here:
> http://www.spinics.net/lists/linux-mmc/msg23395.html
> But it does not help for uSDHC since we can observe data timeout
> on a Toshiba SD3.0 cards if we do not disable data timeout interrupt.
> 
> ChangeLog:
> v1->v2:
>  1. change .get_max_timeout to .get_max_timeout_count to reuse some code
>  2. some other minor changes based on Shawn's comment.
>  3. patch 6 in v1 is dropped since not need anymore after change 1
> 
> 
> 
> Dong Aisheng (5):
>   mmc: sdhci: add platfrom get_max_timeout_count hook
>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>   mmc: sdhci: add platform set_timeout hook
>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>   mmc: sdhci: calculate max_discard_to dynamically for
>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
> 
>  drivers/mmc/host/sdhci-esdhc-imx.c |   20 +++++++++++
>  drivers/mmc/host/sdhci.c           |   66 +++++++++++++++++++++++------------
>  drivers/mmc/host/sdhci.h           |    3 ++
>  3 files changed, 66 insertions(+), 23 deletions(-)
> 
> -- 
> 1.7.2.rc3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to
  2014-05-17 14:09 ` Shawn Guo
@ 2014-05-19  2:43   ` Dong Aisheng
  0 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2014-05-19  2:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, May 17, 2014 at 10:09 PM, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Tue, Dec 17, 2013 at 04:16:26PM +0800, Dong Aisheng wrote:
>> Patch 1~4 mainly fixes the issue that the max timeout counter for uSDHC is
>> 1 << 28 rather than 1 << 27. 1~2 fix getting the max timeout counter
>> while 3~4 fix setting the max timeout.
>> Thus it introduces two new platform hook: get_max_timeout_count and set_timeout
>> for those platform which have different timeout setting.
>>
>> This issue is firstly reported here by Ed Sutter:
>> http://www.spinics.net/lists/linux-mmc/msg23375.html
>> The root cause is the max_discard_to got from uSDHC is too small, only 677ms,
>> which cause the max_discard_bytes for eMMC is only 512, then the discard operation
>> of mkfs.ext3 for an eMMC card is too slow, just like dead.
>> With above patches, the issue can be fixed.
>
> It seems the series got lost?  The issue reported by Ed Sutter is still
> there with the latest kernel.
>
> Dong, you may need to rebase it a little bit and resend.
>

Yes, it's lost.
I will rebase and resend it.

Regards
Dong Aisheng

> Shawn
>
>>
>> Patch 5 adds the capability to calcalute the max_discard_to dynamically
>> for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.
>>
>> Originally the max_discard_to for a high speed sdhc card may be:
>> mmc1: new high speed SDHC card at address aaaa
>> mmc1: calculated max. discard sectors 49152 for timeout 1355 ms
>> After fix:
>> mmc1: new high speed SDHC card at address aaaa
>> mmc1: calculated max. discard sectors 712704 for timeout 5422 ms
>>
>> It also improves the card discard performance a lot due to max_discard_sectors
>> increase a lot.
>>
>> There's also discussion about remove max_discard_to limit here:
>> http://www.spinics.net/lists/linux-mmc/msg23395.html
>> But it does not help for uSDHC since we can observe data timeout
>> on a Toshiba SD3.0 cards if we do not disable data timeout interrupt.
>>
>> ChangeLog:
>> v1->v2:
>>  1. change .get_max_timeout to .get_max_timeout_count to reuse some code
>>  2. some other minor changes based on Shawn's comment.
>>  3. patch 6 in v1 is dropped since not need anymore after change 1
>>
>>
>>
>> Dong Aisheng (5):
>>   mmc: sdhci: add platfrom get_max_timeout_count hook
>>   mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC
>>   mmc: sdhci: add platform set_timeout hook
>>   mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC
>>   mmc: sdhci: calculate max_discard_to dynamically for
>>     SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
>>
>>  drivers/mmc/host/sdhci-esdhc-imx.c |   20 +++++++++++
>>  drivers/mmc/host/sdhci.c           |   66 +++++++++++++++++++++++------------
>>  drivers/mmc/host/sdhci.h           |    3 ++
>>  3 files changed, 66 insertions(+), 23 deletions(-)
>>
>> --
>> 1.7.2.rc3
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2014-05-19  2:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-17  8:16 [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Dong Aisheng
2013-12-17  8:16 ` [PATCH v2 1/5] mmc: sdhci: add platfrom get_max_timeout_count hook Dong Aisheng
2013-12-17  8:16 ` [PATCH v2 2/5] mmc: sdhci-esdhc-imx: fix incorrect max_discard_to for uSDHC Dong Aisheng
2013-12-17  8:16 ` [PATCH v2 3/5] mmc: sdhci: add platform set_timeout hook Dong Aisheng
2013-12-17  8:16 ` [PATCH v2 4/5] mmc: sdhci-esdhc-imx: set the correct max timeout value for uSDHC Dong Aisheng
2013-12-17  8:16 ` [PATCH v2 5/5] mmc: sdhci: calculate max_discard_to dynamically for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK Dong Aisheng
2013-12-17 14:30 ` [PATCH v2 0/5] mmc: sdhci: a few fixes on timeout and max_discard_to Shawn Guo
2014-01-13 10:55   ` Dong Aisheng
2014-01-20  2:42     ` Dong Aisheng
2014-01-13 13:01 ` Ulf Hansson
2014-01-15  6:53   ` Dong Aisheng
2014-05-17 14:09 ` Shawn Guo
2014-05-19  2:43   ` Dong Aisheng

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).