linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value
@ 2012-11-29  4:48 Haijun Zhang
  2012-11-29  5:09 ` Zhang Haijun-B42677
  2012-11-29  5:29 ` Anton Vorontsov
  0 siblings, 2 replies; 5+ messages in thread
From: Haijun Zhang @ 2012-11-29  4:48 UTC (permalink / raw)
  To: linux-mmc; +Cc: Haijun Zhang, Jerry Huang, Anton Vorontsov

As large area erase needs long time usually a few minutes,
So we use max_discard_to to limit the size one request can
issue to avoid timeout. As our controller had the quirk
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK so we need to assign the
timeout_clk and max_discard_to according to the max_dtr which
can be read after the card had setup and decoded, As esdhc-imx
also use this func and this quirk so this patch will also work
on esdhci-imx, but this patch only test on powerpc platform, if
there are any negative impact on esdhc-imx please let me know.

Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Anton Vorontsov <cbouatmailru@gmail.com>
---
changes for v5:
	- Split two variable in their own line
changes for v4:
	- Apply the timeout clk after the card setup and reuse quirk
changes for v3:
	- Add an empty line

 drivers/mmc/host/sdhci-esdhc.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index d25f9ab..a9968e3 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -47,6 +47,7 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 	int pre_div = 2;
 	int div = 1;
 	u32 temp;
+	u32 actual_clk;
 
 	if (clock == 0)
 		goto out;
@@ -65,6 +66,8 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
 		clock, host->max_clk / pre_div / div);
 
+	actual_clk = host->max_clk / pre_div / div;
+
 	pre_div >>= 1;
 	div--;
 
@@ -74,6 +77,12 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 		| (pre_div << ESDHC_PREDIV_SHIFT));
 	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
 	mdelay(1);
+
+	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
+		host->timeout_clk = actual_clk / 1000;
+		host->mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+	}
+
 out:
 	host->clock = clock;
 }
-- 
1.7.0.4



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

* RE: [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value
  2012-11-29  4:48 [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value Haijun Zhang
@ 2012-11-29  5:09 ` Zhang Haijun-B42677
  2012-11-29  5:29 ` Anton Vorontsov
  1 sibling, 0 replies; 5+ messages in thread
From: Zhang Haijun-B42677 @ 2012-11-29  5:09 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Huang Changming-R66093, Zhang Haijun-B42677,
	linux-mmc@vger.kernel.org

Thanks Anton

Please review.


Regards
Haijun.


> -----Original Message-----
> From: Zhang Haijun-B42677
> Sent: Thursday, November 29, 2012 12:48 PM
> To: linux-mmc@vger.kernel.org
> Cc: Zhang Haijun-B42677; Huang Changming-R66093; Anton Vorontsov
> Subject: [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase
> timeout value
> 
> As large area erase needs long time usually a few minutes, So we use
> max_discard_to to limit the size one request can issue to avoid timeout.
> As our controller had the quirk SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK so we
> need to assign the timeout_clk and max_discard_to according to the
> max_dtr which can be read after the card had setup and decoded, As esdhc-
> imx also use this func and this quirk so this patch will also work on
> esdhci-imx, but this patch only test on powerpc platform, if there are
> any negative impact on esdhc-imx please let me know.
> 
> Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> ---
> changes for v5:
> 	- Split two variable in their own line
> changes for v4:
> 	- Apply the timeout clk after the card setup and reuse quirk
> changes for v3:
> 	- Add an empty line
> 
>  drivers/mmc/host/sdhci-esdhc.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-
> esdhc.h index d25f9ab..a9968e3 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -47,6 +47,7 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  	int pre_div = 2;
>  	int div = 1;
>  	u32 temp;
> +	u32 actual_clk;
> 
>  	if (clock == 0)
>  		goto out;
> @@ -65,6 +66,8 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
>  		clock, host->max_clk / pre_div / div);
> 
> +	actual_clk = host->max_clk / pre_div / div;
> +
>  	pre_div >>= 1;
>  	div--;
> 
> @@ -74,6 +77,12 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  		| (pre_div << ESDHC_PREDIV_SHIFT));
>  	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
>  	mdelay(1);
> +
> +	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
> +		host->timeout_clk = actual_clk / 1000;
> +		host->mmc->max_discard_to = (1 << 27) / host->timeout_clk;
> +	}
> +
>  out:
>  	host->clock = clock;
>  }
> --
> 1.7.0.4



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

* [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value
  2012-11-29  5:22 [PATCH V4] Powerpc eSDHC Recover from the ADMA error Haijun Zhang
@ 2012-11-29  5:22 ` Haijun Zhang
  2012-11-29  5:46   ` Zhang Haijun-B42677
  0 siblings, 1 reply; 5+ messages in thread
From: Haijun Zhang @ 2012-11-29  5:22 UTC (permalink / raw)
  To: linux-mmc; +Cc: Haijun Zhang, Jerry Huang, Chris Ball

As large area erase needs long time usually a few minutes,
So we use max_discard_to to limit the size one request can
issue to avoid timeout. As our controller had the quirk
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK so we need to assign the
timeout_clk and max_discard_to according to the max_dtr which
can be read after the card had setup and decoded, As esdhc-imx
also use this func and this quirk so this patch will also work
on esdhci-imx, but this patch only test on powerpc platform, if
there are any negative impact on esdhc-imx please let me know.

Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v5:
	- Split two variable in their own line
changes for v4:
	- Apply the timeout clk after the card setup and reuse quirk
changes for v3:
	- Add an empty line

 drivers/mmc/host/sdhci-esdhc.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index d25f9ab..a9968e3 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -47,6 +47,7 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 	int pre_div = 2;
 	int div = 1;
 	u32 temp;
+	u32 actual_clk;
 
 	if (clock == 0)
 		goto out;
@@ -65,6 +66,8 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
 		clock, host->max_clk / pre_div / div);
 
+	actual_clk = host->max_clk / pre_div / div;
+
 	pre_div >>= 1;
 	div--;
 
@@ -74,6 +77,12 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 		| (pre_div << ESDHC_PREDIV_SHIFT));
 	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
 	mdelay(1);
+
+	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
+		host->timeout_clk = actual_clk / 1000;
+		host->mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+	}
+
 out:
 	host->clock = clock;
 }
-- 
1.7.0.4



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

* Re: [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value
  2012-11-29  4:48 [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value Haijun Zhang
  2012-11-29  5:09 ` Zhang Haijun-B42677
@ 2012-11-29  5:29 ` Anton Vorontsov
  1 sibling, 0 replies; 5+ messages in thread
From: Anton Vorontsov @ 2012-11-29  5:29 UTC (permalink / raw)
  To: Haijun Zhang; +Cc: linux-mmc, Jerry Huang

On Thu, Nov 29, 2012 at 12:48:22PM +0800, Haijun Zhang wrote:
> As large area erase needs long time usually a few minutes,
> So we use max_discard_to to limit the size one request can
> issue to avoid timeout. As our controller had the quirk
> SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK so we need to assign the
> timeout_clk and max_discard_to according to the max_dtr which
> can be read after the card had setup and decoded, As esdhc-imx
> also use this func and this quirk so this patch will also work
> on esdhci-imx, but this patch only test on powerpc platform, if
> there are any negative impact on esdhc-imx please let me know.
> 
> Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>

Looks good, thanks.

Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>

> ---
> changes for v5:
> 	- Split two variable in their own line
> changes for v4:
> 	- Apply the timeout clk after the card setup and reuse quirk
> changes for v3:
> 	- Add an empty line
> 
>  drivers/mmc/host/sdhci-esdhc.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
> index d25f9ab..a9968e3 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -47,6 +47,7 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
>  	int pre_div = 2;
>  	int div = 1;
>  	u32 temp;
> +	u32 actual_clk;
>  
>  	if (clock == 0)
>  		goto out;
> @@ -65,6 +66,8 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
>  	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
>  		clock, host->max_clk / pre_div / div);
>  
> +	actual_clk = host->max_clk / pre_div / div;
> +
>  	pre_div >>= 1;
>  	div--;
>  
> @@ -74,6 +77,12 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
>  		| (pre_div << ESDHC_PREDIV_SHIFT));
>  	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
>  	mdelay(1);
> +
> +	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
> +		host->timeout_clk = actual_clk / 1000;
> +		host->mmc->max_discard_to = (1 << 27) / host->timeout_clk;
> +	}
> +
>  out:
>  	host->clock = clock;
>  }
> -- 
> 1.7.0.4

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

* RE: [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value
  2012-11-29  5:22 ` [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value Haijun Zhang
@ 2012-11-29  5:46   ` Zhang Haijun-B42677
  0 siblings, 0 replies; 5+ messages in thread
From: Zhang Haijun-B42677 @ 2012-11-29  5:46 UTC (permalink / raw)
  To: Zhang Haijun-B42677, linux-mmc@vger.kernel.org
  Cc: Huang Changming-R66093, Chris Ball

Sorry, I forget to add patch version.
Discard this patch. Another had send.


Regards
Haijun.


> -----Original Message-----
> From: Zhang Haijun-B42677
> Sent: Thursday, November 29, 2012 1:22 PM
> To: linux-mmc@vger.kernel.org
> Cc: Zhang Haijun-B42677; Huang Changming-R66093; Chris Ball
> Subject: [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase
> timeout value
> 
> As large area erase needs long time usually a few minutes, So we use
> max_discard_to to limit the size one request can issue to avoid timeout.
> As our controller had the quirk SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK so we
> need to assign the timeout_clk and max_discard_to according to the
> max_dtr which can be read after the card had setup and decoded, As esdhc-
> imx also use this func and this quirk so this patch will also work on
> esdhci-imx, but this patch only test on powerpc platform, if there are
> any negative impact on esdhc-imx please let me know.
> 
> Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v5:
> 	- Split two variable in their own line
> changes for v4:
> 	- Apply the timeout clk after the card setup and reuse quirk
> changes for v3:
> 	- Add an empty line
> 
>  drivers/mmc/host/sdhci-esdhc.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-
> esdhc.h index d25f9ab..a9968e3 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -47,6 +47,7 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  	int pre_div = 2;
>  	int div = 1;
>  	u32 temp;
> +	u32 actual_clk;
> 
>  	if (clock == 0)
>  		goto out;
> @@ -65,6 +66,8 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  	dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
>  		clock, host->max_clk / pre_div / div);
> 
> +	actual_clk = host->max_clk / pre_div / div;
> +
>  	pre_div >>= 1;
>  	div--;
> 
> @@ -74,6 +77,12 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  		| (pre_div << ESDHC_PREDIV_SHIFT));
>  	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
>  	mdelay(1);
> +
> +	if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
> +		host->timeout_clk = actual_clk / 1000;
> +		host->mmc->max_discard_to = (1 << 27) / host->timeout_clk;
> +	}
> +
>  out:
>  	host->clock = clock;
>  }
> --
> 1.7.0.4



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

end of thread, other threads:[~2012-11-29  5:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-29  4:48 [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value Haijun Zhang
2012-11-29  5:09 ` Zhang Haijun-B42677
2012-11-29  5:29 ` Anton Vorontsov
  -- strict thread matches above, loose matches on Subject: below --
2012-11-29  5:22 [PATCH V4] Powerpc eSDHC Recover from the ADMA error Haijun Zhang
2012-11-29  5:22 ` [PATCH] Powerpc/eSDHC: Calculate the applicable mmc erase timeout value Haijun Zhang
2012-11-29  5:46   ` Zhang Haijun-B42677

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