All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fixes for tuning stuffs
@ 2012-06-29  8:17 Aaron Lu
  2012-06-29  8:17 ` [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed Aaron Lu
  2012-06-29  8:17 ` [PATCH v2 2/2] mmc: sdhci: A new flag SDHCI_NEEDS_RETUNING_TIMER Aaron Lu
  0 siblings, 2 replies; 9+ messages in thread
From: Aaron Lu @ 2012-06-29  8:17 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Aaron Lu, Aaron Lu

v2:
v1 mistakenly removed the line del_timer_sync(&host->timer) in
sdhci_remove_host, fix this by adding back the code.

v1:
The following 2 patches fixed a bug related the tuning stuffs and
refactored the code to make it simpler and easier to read and understand.

-- 
1.7.11.1.3.g4c8a9db



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

* [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed
  2012-06-29  8:17 [PATCH v2 0/2] Fixes for tuning stuffs Aaron Lu
@ 2012-06-29  8:17 ` Aaron Lu
  2012-07-04  0:40   ` Chris Ball
  2012-06-29  8:17 ` [PATCH v2 2/2] mmc: sdhci: A new flag SDHCI_NEEDS_RETUNING_TIMER Aaron Lu
  1 sibling, 1 reply; 9+ messages in thread
From: Aaron Lu @ 2012-06-29  8:17 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Aaron Lu, Aaron Lu

Some of the host settings are affected by different cards inserted, e.g.
when an UHS-I card is inserted, the SDHCI_NEEDS_RETUING flag might be
set when the tuning timer expired and host's max_blk_count will be
reduced to make sure the data transfer for a command does not exceed 4MiB
to meet the retuning mode 1's requirement.

When the card is removed, we should restore the original setting of the
host since we can't be sure the next card being inserted will still be
an UHS-I card that needs tuning. The original setting include its
max_blk_count and no set of the flag of SDHCI_NEEDS_RETUNING.

Signed-off-by: Aaron Lu <aaron.lu@amd.com>
---
 drivers/mmc/host/sdhci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index ff522ec..7e182ad 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -245,6 +245,18 @@ static void sdhci_init(struct sdhci_host *host, int soft)
 static void sdhci_reinit(struct sdhci_host *host)
 {
 	sdhci_init(host, 0);
+	/*
+	 * Retuning stuffs are affected by different cards inserted and only
+	 * applicable to UHS-I cards. So reset these fields to their initial
+	 * value when card is removed.
+	 */
+	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
+			host->tuning_mode == SDHCI_TUNING_MODE_1) {
+		del_timer_sync(&host->tuning_timer);
+		host->flags &= ~SDHCI_NEEDS_RETUNING;
+		host->mmc->max_blk_count =
+			(host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535;
+	}
 	sdhci_enable_card_detection(host);
 }
 
-- 
1.7.11.1



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

* [PATCH v2 2/2] mmc: sdhci: A new flag SDHCI_NEEDS_RETUNING_TIMER
  2012-06-29  8:17 [PATCH v2 0/2] Fixes for tuning stuffs Aaron Lu
  2012-06-29  8:17 ` [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed Aaron Lu
@ 2012-06-29  8:17 ` Aaron Lu
  2012-07-04  0:46   ` Chris Ball
  1 sibling, 1 reply; 9+ messages in thread
From: Aaron Lu @ 2012-06-29  8:17 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Aaron Lu, Aaron Lu

Add a new flag of SDHCI_NEEDS_RETUNING_TIMER to represent if the host
currently needs retuning timer when driving the card inserted.

This flag is set when the host does tuning the first time for the card
and is used afterwards whenever needs to decide if the host is currently
using a retuning timer.

This flag is cleared when the card is removed in sdhci_reinit.

The set/clear of the flag and the start/stop of the retuning timer is
associated with the card's init/remove time, so there is no need to
touch it when the host is to be removed as at that time the card should
have already been removed.

Signed-off-by: Aaron Lu <aaron.lu@amd.com>
---
 drivers/mmc/host/sdhci.c  | 29 +++++++++++------------------
 include/linux/mmc/sdhci.h |  1 +
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7e182ad..a02077a 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -250,8 +250,9 @@ static void sdhci_reinit(struct sdhci_host *host)
 	 * applicable to UHS-I cards. So reset these fields to their initial
 	 * value when card is removed.
 	 */
-	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
-			host->tuning_mode == SDHCI_TUNING_MODE_1) {
+	if (host->flags & SDHCI_NEEDS_RETUNING_TIMER) {
+		host->flags &= ~SDHCI_NEEDS_RETUNING_TIMER;
+
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 		host->mmc->max_blk_count =
@@ -1872,6 +1873,7 @@ out:
 	 */
 	if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count &&
 	    (host->tuning_mode == SDHCI_TUNING_MODE_1)) {
+		host->flags |= SDHCI_NEEDS_RETUNING_TIMER;
 		mod_timer(&host->tuning_timer, jiffies +
 			host->tuning_count * HZ);
 		/* Tuning mode 1 limits the maximum data length to 4MB */
@@ -1889,10 +1891,9 @@ out:
 	 * try tuning again at a later time, when the re-tuning timer expires.
 	 * So for these controllers, we return 0. Since there might be other
 	 * controllers who do not have this capability, we return error for
-	 * them.
+	 * them. SDHCI_NEEDS_RETUNING_TIMER means the host supports re-tuning.
 	 */
-	if (err && host->tuning_count &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1)
+	if (err && (host->flags & SDHCI_NEEDS_RETUNING_TIMER))
 		err = 0;
 
 	sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier);
@@ -2399,7 +2400,6 @@ out:
 int sdhci_suspend_host(struct sdhci_host *host)
 {
 	int ret;
-	bool has_tuning_timer;
 
 	if (host->ops->platform_suspend)
 		host->ops->platform_suspend(host);
@@ -2407,16 +2407,14 @@ int sdhci_suspend_host(struct sdhci_host *host)
 	sdhci_disable_card_detection(host);
 
 	/* Disable tuning since we are suspending */
-	has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
-		host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
-	if (has_tuning_timer) {
+	if (host->flags & SDHCI_NEEDS_RETUNING_TIMER) {
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 	}
 
 	ret = mmc_suspend_host(host->mmc);
 	if (ret) {
-		if (has_tuning_timer) {
+		if (host->flags & SDHCI_NEEDS_RETUNING_TIMER) {
 			host->flags |= SDHCI_NEEDS_RETUNING;
 			mod_timer(&host->tuning_timer, jiffies +
 					host->tuning_count * HZ);
@@ -2467,8 +2465,7 @@ int sdhci_resume_host(struct sdhci_host *host)
 		host->ops->platform_resume(host);
 
 	/* Set the re-tuning expiration flag */
-	if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
-	    (host->tuning_mode == SDHCI_TUNING_MODE_1))
+	if (host->flags & SDHCI_NEEDS_RETUNING_TIMER)
 		host->flags |= SDHCI_NEEDS_RETUNING;
 
 	return ret;
@@ -2507,8 +2504,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
 	int ret = 0;
 
 	/* Disable tuning since we are suspending */
-	if (host->version >= SDHCI_SPEC_300 &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
+	if (host->flags & SDHCI_NEEDS_RETUNING_TIMER) {
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 	}
@@ -2549,8 +2545,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
 		sdhci_do_enable_preset_value(host, true);
 
 	/* Set the re-tuning expiration flag */
-	if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
-	    (host->tuning_mode == SDHCI_TUNING_MODE_1))
+	if (host->flags & SDHCI_NEEDS_RETUNING_TIMER)
 		host->flags |= SDHCI_NEEDS_RETUNING;
 
 	spin_lock_irqsave(&host->lock, flags);
@@ -3098,8 +3093,6 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 	free_irq(host->irq, host);
 
 	del_timer_sync(&host->timer);
-	if (host->version >= SDHCI_SPEC_300)
-		del_timer_sync(&host->tuning_timer);
 
 	tasklet_kill(&host->card_tasklet);
 	tasklet_kill(&host->finish_tasklet);
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index e9051e1..1493bf3 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -122,6 +122,7 @@ struct sdhci_host {
 #define SDHCI_PV_ENABLED	(1<<8)	/* Preset value enabled */
 #define SDHCI_SDIO_IRQ_ENABLED	(1<<9)	/* SDIO irq enabled */
 #define SDHCI_HS200_NEEDS_TUNING (1<<10)	/* HS200 needs tuning */
+#define SDHCI_NEEDS_RETUNING_TIMER (1<<11)	/* Host needs retuning timer */
 
 	unsigned int version;	/* SDHCI spec. version */
 
-- 
1.7.11.1



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

* Re: [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed
  2012-06-29  8:17 ` [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed Aaron Lu
@ 2012-07-04  0:40   ` Chris Ball
  0 siblings, 0 replies; 9+ messages in thread
From: Chris Ball @ 2012-07-04  0:40 UTC (permalink / raw)
  To: Aaron Lu; +Cc: linux-mmc, Aaron Lu

Hi,

On Fri, Jun 29 2012, Aaron Lu wrote:
> Some of the host settings are affected by different cards inserted, e.g.
> when an UHS-I card is inserted, the SDHCI_NEEDS_RETUING flag might be
> set when the tuning timer expired and host's max_blk_count will be
> reduced to make sure the data transfer for a command does not exceed 4MiB
> to meet the retuning mode 1's requirement.
>
> When the card is removed, we should restore the original setting of the
> host since we can't be sure the next card being inserted will still be
> an UHS-I card that needs tuning. The original setting include its
> max_blk_count and no set of the flag of SDHCI_NEEDS_RETUNING.
>
> Signed-off-by: Aaron Lu <aaron.lu@amd.com>
> ---
>  drivers/mmc/host/sdhci.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index ff522ec..7e182ad 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -245,6 +245,18 @@ static void sdhci_init(struct sdhci_host *host, int soft)
>  static void sdhci_reinit(struct sdhci_host *host)
>  {
>  	sdhci_init(host, 0);
> +	/*
> +	 * Retuning stuffs are affected by different cards inserted and only
> +	 * applicable to UHS-I cards. So reset these fields to their initial
> +	 * value when card is removed.
> +	 */
> +	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
> +			host->tuning_mode == SDHCI_TUNING_MODE_1) {
> +		del_timer_sync(&host->tuning_timer);
> +		host->flags &= ~SDHCI_NEEDS_RETUNING;
> +		host->mmc->max_blk_count =
> +			(host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535;
> +	}
>  	sdhci_enable_card_detection(host);
>  }

Thanks, pushed to mmc-next for 3.6.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* Re: [PATCH v2 2/2] mmc: sdhci: A new flag SDHCI_NEEDS_RETUNING_TIMER
  2012-06-29  8:17 ` [PATCH v2 2/2] mmc: sdhci: A new flag SDHCI_NEEDS_RETUNING_TIMER Aaron Lu
@ 2012-07-04  0:46   ` Chris Ball
  2012-07-04  5:29     ` [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER Aaron Lu
  0 siblings, 1 reply; 9+ messages in thread
From: Chris Ball @ 2012-07-04  0:46 UTC (permalink / raw)
  To: Aaron Lu; +Cc: linux-mmc, Aaron Lu

Hi,

On Fri, Jun 29 2012, Aaron Lu wrote:
> Add a new flag of SDHCI_NEEDS_RETUNING_TIMER to represent if the host
> currently needs retuning timer when driving the card inserted.

Minor changes:

Could we call it "SDHCI_USING_RETUNING_TIMER", then?  I don't think
NEEDS makes the use clear enough.

> @@ -1889,10 +1891,9 @@ out:
>  	 * try tuning again at a later time, when the re-tuning timer expires.
>  	 * So for these controllers, we return 0. Since there might be other
>  	 * controllers who do not have this capability, we return error for
> -	 * them.
> +	 * them. SDHCI_NEEDS_RETUNING_TIMER means the host supports re-tuning.

This comment seems wrong, or at least incomplete.  You've just described
in the commit message how the flag's not about whether the host supports
it, but is instead about whether it's currently in use by the card.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER
  2012-07-04  0:46   ` Chris Ball
@ 2012-07-04  5:29     ` Aaron Lu
  2012-07-04  7:14       ` Girish K S
                         ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Aaron Lu @ 2012-07-04  5:29 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Aaron Lu, Philip Rakity

Add a new flag of SDHCI_USING_RETUNING_TIMER to represent if the host
is using a retuning timer for the card inserted.

This flag is set when the host does tuning the first time for the card
and the host's retuning mode is 1. This flag is used afterwards whenever
needs to decide if the host is currently using a retuning timer.

This flag is cleared when the card is removed in sdhci_reinit.

The set/clear of the flag and the start/stop of the retuning timer is
associated with the card's init/remove time, so there is no need to
touch it when the host is to be removed as at that time the card should
have already been removed.

Signed-off-by: Aaron Lu <aaron.lu@amd.com>
---
v3:
Change the macro name from SDHCI_NEEDS_RETUNING_TIMER to
SDHCI_USING_RETUNING_TIMER for better description of the flag as suggested
by Chris Ball.

v2:
v1 mistakenly removed the line del_timer_sync(&host->timer) in
sdhci_remove_host, fix this by adding back the code.

 drivers/mmc/host/sdhci.c  | 30 ++++++++++++------------------
 include/linux/mmc/sdhci.h |  1 +
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b0a5629..3ec4182 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -250,8 +250,9 @@ static void sdhci_reinit(struct sdhci_host *host)
 	 * applicable to UHS-I cards. So reset these fields to their initial
 	 * value when card is removed.
 	 */
-	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
-			host->tuning_mode == SDHCI_TUNING_MODE_1) {
+	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
+		host->flags &= ~SDHCI_USING_RETUNING_TIMER;
+
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 		host->mmc->max_blk_count =
@@ -1873,6 +1874,7 @@ out:
 	 */
 	if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count &&
 	    (host->tuning_mode == SDHCI_TUNING_MODE_1)) {
+		host->flags |= SDHCI_USING_RETUNING_TIMER;
 		mod_timer(&host->tuning_timer, jiffies +
 			host->tuning_count * HZ);
 		/* Tuning mode 1 limits the maximum data length to 4MB */
@@ -1890,10 +1892,10 @@ out:
 	 * try tuning again at a later time, when the re-tuning timer expires.
 	 * So for these controllers, we return 0. Since there might be other
 	 * controllers who do not have this capability, we return error for
-	 * them.
+	 * them. SDHCI_USING_RETUNING_TIMER means the host is currently using
+	 * a retuning timer to do the retuning for the card.
 	 */
-	if (err && host->tuning_count &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1)
+	if (err && (host->flags & SDHCI_USING_RETUNING_TIMER))
 		err = 0;
 
 	sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier);
@@ -2400,7 +2402,6 @@ out:
 int sdhci_suspend_host(struct sdhci_host *host)
 {
 	int ret;
-	bool has_tuning_timer;
 
 	if (host->ops->platform_suspend)
 		host->ops->platform_suspend(host);
@@ -2408,16 +2409,14 @@ int sdhci_suspend_host(struct sdhci_host *host)
 	sdhci_disable_card_detection(host);
 
 	/* Disable tuning since we are suspending */
-	has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
-		host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
-	if (has_tuning_timer) {
+	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 	}
 
 	ret = mmc_suspend_host(host->mmc);
 	if (ret) {
-		if (has_tuning_timer) {
+		if (host->flags & SDHCI_USING_RETUNING_TIMER) {
 			host->flags |= SDHCI_NEEDS_RETUNING;
 			mod_timer(&host->tuning_timer, jiffies +
 					host->tuning_count * HZ);
@@ -2468,8 +2467,7 @@ int sdhci_resume_host(struct sdhci_host *host)
 		host->ops->platform_resume(host);
 
 	/* Set the re-tuning expiration flag */
-	if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
-	    (host->tuning_mode == SDHCI_TUNING_MODE_1))
+	if (host->flags & SDHCI_USING_RETUNING_TIMER)
 		host->flags |= SDHCI_NEEDS_RETUNING;
 
 	return ret;
@@ -2508,8 +2506,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
 	int ret = 0;
 
 	/* Disable tuning since we are suspending */
-	if (host->version >= SDHCI_SPEC_300 &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
+	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 	}
@@ -2550,8 +2547,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
 		sdhci_do_enable_preset_value(host, true);
 
 	/* Set the re-tuning expiration flag */
-	if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
-	    (host->tuning_mode == SDHCI_TUNING_MODE_1))
+	if (host->flags & SDHCI_USING_RETUNING_TIMER)
 		host->flags |= SDHCI_NEEDS_RETUNING;
 
 	spin_lock_irqsave(&host->lock, flags);
@@ -3140,8 +3136,6 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 	free_irq(host->irq, host);
 
 	del_timer_sync(&host->timer);
-	if (host->version >= SDHCI_SPEC_300)
-		del_timer_sync(&host->tuning_timer);
 
 	tasklet_kill(&host->card_tasklet);
 	tasklet_kill(&host->finish_tasklet);
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index d989b51..ac83b10 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -122,6 +122,7 @@ struct sdhci_host {
 #define SDHCI_PV_ENABLED	(1<<8)	/* Preset value enabled */
 #define SDHCI_SDIO_IRQ_ENABLED	(1<<9)	/* SDIO irq enabled */
 #define SDHCI_HS200_NEEDS_TUNING (1<<10)	/* HS200 needs tuning */
+#define SDHCI_USING_RETUNING_TIMER (1<<11)	/* Host is using a retuning timer for the card */
 
 	unsigned int version;	/* SDHCI spec. version */
 
-- 
1.7.11.1.3.g4c8a9db


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

* Re: [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER
  2012-07-04  5:29     ` [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER Aaron Lu
@ 2012-07-04  7:14       ` Girish K S
  2012-07-09  5:10       ` Philip Rakity
  2012-07-10  2:55       ` Chris Ball
  2 siblings, 0 replies; 9+ messages in thread
From: Girish K S @ 2012-07-04  7:14 UTC (permalink / raw)
  To: Aaron Lu; +Cc: Chris Ball, linux-mmc, Aaron Lu, Philip Rakity

On 4 July 2012 10:59, Aaron Lu <aaron.lu@amd.com> wrote:
> Add a new flag of SDHCI_USING_RETUNING_TIMER to represent if the host
> is using a retuning timer for the card inserted.
>
> This flag is set when the host does tuning the first time for the card
> and the host's retuning mode is 1. This flag is used afterwards whenever
> needs to decide if the host is currently using a retuning timer.
>
> This flag is cleared when the card is removed in sdhci_reinit.
>
> The set/clear of the flag and the start/stop of the retuning timer is
> associated with the card's init/remove time, so there is no need to
> touch it when the host is to be removed as at that time the card should
> have already been removed.
>
> Signed-off-by: Aaron Lu <aaron.lu@amd.com>
> ---
> v3:
> Change the macro name from SDHCI_NEEDS_RETUNING_TIMER to
> SDHCI_USING_RETUNING_TIMER for better description of the flag as suggested
> by Chris Ball.
>
> v2:
> v1 mistakenly removed the line del_timer_sync(&host->timer) in
> sdhci_remove_host, fix this by adding back the code.
>
>  drivers/mmc/host/sdhci.c  | 30 ++++++++++++------------------
>  include/linux/mmc/sdhci.h |  1 +
>  2 files changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index b0a5629..3ec4182 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -250,8 +250,9 @@ static void sdhci_reinit(struct sdhci_host *host)
>          * applicable to UHS-I cards. So reset these fields to their initial
>          * value when card is removed.
>          */
> -       if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
> -                       host->tuning_mode == SDHCI_TUNING_MODE_1) {
> +       if (host->flags & SDHCI_USING_RETUNING_TIMER) {
> +               host->flags &= ~SDHCI_USING_RETUNING_TIMER;
> +
>                 del_timer_sync(&host->tuning_timer);
>                 host->flags &= ~SDHCI_NEEDS_RETUNING;
>                 host->mmc->max_blk_count =
> @@ -1873,6 +1874,7 @@ out:
>          */
>         if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count &&
>             (host->tuning_mode == SDHCI_TUNING_MODE_1)) {
> +               host->flags |= SDHCI_USING_RETUNING_TIMER;
>                 mod_timer(&host->tuning_timer, jiffies +
>                         host->tuning_count * HZ);
>                 /* Tuning mode 1 limits the maximum data length to 4MB */
> @@ -1890,10 +1892,10 @@ out:
>          * try tuning again at a later time, when the re-tuning timer expires.
>          * So for these controllers, we return 0. Since there might be other
>          * controllers who do not have this capability, we return error for
> -        * them.
> +        * them. SDHCI_USING_RETUNING_TIMER means the host is currently using
> +        * a retuning timer to do the retuning for the card.
>          */
> -       if (err && host->tuning_count &&
> -           host->tuning_mode == SDHCI_TUNING_MODE_1)
> +       if (err && (host->flags & SDHCI_USING_RETUNING_TIMER))
>                 err = 0;
>
>         sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier);
> @@ -2400,7 +2402,6 @@ out:
>  int sdhci_suspend_host(struct sdhci_host *host)
>  {
>         int ret;
> -       bool has_tuning_timer;
>
>         if (host->ops->platform_suspend)
>                 host->ops->platform_suspend(host);
> @@ -2408,16 +2409,14 @@ int sdhci_suspend_host(struct sdhci_host *host)
>         sdhci_disable_card_detection(host);
>
>         /* Disable tuning since we are suspending */
> -       has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
> -               host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
> -       if (has_tuning_timer) {
> +       if (host->flags & SDHCI_USING_RETUNING_TIMER) {
>                 del_timer_sync(&host->tuning_timer);
>                 host->flags &= ~SDHCI_NEEDS_RETUNING;
>         }
>
>         ret = mmc_suspend_host(host->mmc);
>         if (ret) {
> -               if (has_tuning_timer) {
> +               if (host->flags & SDHCI_USING_RETUNING_TIMER) {
>                         host->flags |= SDHCI_NEEDS_RETUNING;
>                         mod_timer(&host->tuning_timer, jiffies +
>                                         host->tuning_count * HZ);
> @@ -2468,8 +2467,7 @@ int sdhci_resume_host(struct sdhci_host *host)
>                 host->ops->platform_resume(host);
>
>         /* Set the re-tuning expiration flag */
> -       if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
> -           (host->tuning_mode == SDHCI_TUNING_MODE_1))
> +       if (host->flags & SDHCI_USING_RETUNING_TIMER)
>                 host->flags |= SDHCI_NEEDS_RETUNING;
>
>         return ret;
> @@ -2508,8 +2506,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
>         int ret = 0;
>
>         /* Disable tuning since we are suspending */
> -       if (host->version >= SDHCI_SPEC_300 &&
> -           host->tuning_mode == SDHCI_TUNING_MODE_1) {
> +       if (host->flags & SDHCI_USING_RETUNING_TIMER) {
>                 del_timer_sync(&host->tuning_timer);
>                 host->flags &= ~SDHCI_NEEDS_RETUNING;
>         }
> @@ -2550,8 +2547,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
>                 sdhci_do_enable_preset_value(host, true);
>
>         /* Set the re-tuning expiration flag */
> -       if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
> -           (host->tuning_mode == SDHCI_TUNING_MODE_1))
> +       if (host->flags & SDHCI_USING_RETUNING_TIMER)
>                 host->flags |= SDHCI_NEEDS_RETUNING;
>
>         spin_lock_irqsave(&host->lock, flags);
> @@ -3140,8 +3136,6 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
>         free_irq(host->irq, host);
>
>         del_timer_sync(&host->timer);
> -       if (host->version >= SDHCI_SPEC_300)
> -               del_timer_sync(&host->tuning_timer);
>
>         tasklet_kill(&host->card_tasklet);
>         tasklet_kill(&host->finish_tasklet);
> diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
> index d989b51..ac83b10 100644
> --- a/include/linux/mmc/sdhci.h
> +++ b/include/linux/mmc/sdhci.h
> @@ -122,6 +122,7 @@ struct sdhci_host {
>  #define SDHCI_PV_ENABLED       (1<<8)  /* Preset value enabled */
>  #define SDHCI_SDIO_IRQ_ENABLED (1<<9)  /* SDIO irq enabled */
>  #define SDHCI_HS200_NEEDS_TUNING (1<<10)       /* HS200 needs tuning */
> +#define SDHCI_USING_RETUNING_TIMER (1<<11)     /* Host is using a retuning timer for the card */
>
>         unsigned int version;   /* SDHCI spec. version */
Looks good to me
Reviewed By:- Girish K S <girish.shivananjappa@linaro.org>
>
> --
> 1.7.11.1.3.g4c8a9db
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER
  2012-07-04  5:29     ` [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER Aaron Lu
  2012-07-04  7:14       ` Girish K S
@ 2012-07-09  5:10       ` Philip Rakity
  2012-07-10  2:55       ` Chris Ball
  2 siblings, 0 replies; 9+ messages in thread
From: Philip Rakity @ 2012-07-09  5:10 UTC (permalink / raw)
  To: Aaron Lu; +Cc: Chris Ball, linux-mmc, Aaron Lu


Reviewed-by: Philip Rakity <prakity@marvell.com>

On Jul 3, 2012, at 10:29 PM, Aaron Lu wrote:

> Add a new flag of SDHCI_USING_RETUNING_TIMER to represent if the host
> is using a retuning timer for the card inserted.
> 
> This flag is set when the host does tuning the first time for the card
> and the host's retuning mode is 1. This flag is used afterwards whenever
> needs to decide if the host is currently using a retuning timer.
> 
> This flag is cleared when the card is removed in sdhci_reinit.
> 
> The set/clear of the flag and the start/stop of the retuning timer is
> associated with the card's init/remove time, so there is no need to
> touch it when the host is to be removed as at that time the card should
> have already been removed.
> 
> Signed-off-by: Aaron Lu <aaron.lu@amd.com>
> ---
> v3:
> Change the macro name from SDHCI_NEEDS_RETUNING_TIMER to
> SDHCI_USING_RETUNING_TIMER for better description of the flag as suggested
> by Chris Ball.
> 
> v2:
> v1 mistakenly removed the line del_timer_sync(&host->timer) in
> sdhci_remove_host, fix this by adding back the code.
> 
> drivers/mmc/host/sdhci.c  | 30 ++++++++++++------------------
> include/linux/mmc/sdhci.h |  1 +
> 2 files changed, 13 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index b0a5629..3ec4182 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -250,8 +250,9 @@ static void sdhci_reinit(struct sdhci_host *host)
> 	 * applicable to UHS-I cards. So reset these fields to their initial
> 	 * value when card is removed.
> 	 */
> -	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
> -			host->tuning_mode == SDHCI_TUNING_MODE_1) {
> +	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
> +		host->flags &= ~SDHCI_USING_RETUNING_TIMER;
> +
> 		del_timer_sync(&host->tuning_timer);
> 		host->flags &= ~SDHCI_NEEDS_RETUNING;
> 		host->mmc->max_blk_count =
> @@ -1873,6 +1874,7 @@ out:
> 	 */
> 	if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count &&
> 	    (host->tuning_mode == SDHCI_TUNING_MODE_1)) {
> +		host->flags |= SDHCI_USING_RETUNING_TIMER;
> 		mod_timer(&host->tuning_timer, jiffies +
> 			host->tuning_count * HZ);
> 		/* Tuning mode 1 limits the maximum data length to 4MB */
> @@ -1890,10 +1892,10 @@ out:
> 	 * try tuning again at a later time, when the re-tuning timer expires.
> 	 * So for these controllers, we return 0. Since there might be other
> 	 * controllers who do not have this capability, we return error for
> -	 * them.
> +	 * them. SDHCI_USING_RETUNING_TIMER means the host is currently using
> +	 * a retuning timer to do the retuning for the card.
> 	 */
> -	if (err && host->tuning_count &&
> -	    host->tuning_mode == SDHCI_TUNING_MODE_1)
> +	if (err && (host->flags & SDHCI_USING_RETUNING_TIMER))
> 		err = 0;
> 
> 	sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier);
> @@ -2400,7 +2402,6 @@ out:
> int sdhci_suspend_host(struct sdhci_host *host)
> {
> 	int ret;
> -	bool has_tuning_timer;
> 
> 	if (host->ops->platform_suspend)
> 		host->ops->platform_suspend(host);
> @@ -2408,16 +2409,14 @@ int sdhci_suspend_host(struct sdhci_host *host)
> 	sdhci_disable_card_detection(host);
> 
> 	/* Disable tuning since we are suspending */
> -	has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
> -		host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
> -	if (has_tuning_timer) {
> +	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
> 		del_timer_sync(&host->tuning_timer);
> 		host->flags &= ~SDHCI_NEEDS_RETUNING;
> 	}
> 
> 	ret = mmc_suspend_host(host->mmc);
> 	if (ret) {
> -		if (has_tuning_timer) {
> +		if (host->flags & SDHCI_USING_RETUNING_TIMER) {
> 			host->flags |= SDHCI_NEEDS_RETUNING;
> 			mod_timer(&host->tuning_timer, jiffies +
> 					host->tuning_count * HZ);
> @@ -2468,8 +2467,7 @@ int sdhci_resume_host(struct sdhci_host *host)
> 		host->ops->platform_resume(host);
> 
> 	/* Set the re-tuning expiration flag */
> -	if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
> -	    (host->tuning_mode == SDHCI_TUNING_MODE_1))
> +	if (host->flags & SDHCI_USING_RETUNING_TIMER)
> 		host->flags |= SDHCI_NEEDS_RETUNING;
> 
> 	return ret;
> @@ -2508,8 +2506,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
> 	int ret = 0;
> 
> 	/* Disable tuning since we are suspending */
> -	if (host->version >= SDHCI_SPEC_300 &&
> -	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
> +	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
> 		del_timer_sync(&host->tuning_timer);
> 		host->flags &= ~SDHCI_NEEDS_RETUNING;
> 	}
> @@ -2550,8 +2547,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
> 		sdhci_do_enable_preset_value(host, true);
> 
> 	/* Set the re-tuning expiration flag */
> -	if ((host->version >= SDHCI_SPEC_300) && host->tuning_count &&
> -	    (host->tuning_mode == SDHCI_TUNING_MODE_1))
> +	if (host->flags & SDHCI_USING_RETUNING_TIMER)
> 		host->flags |= SDHCI_NEEDS_RETUNING;
> 
> 	spin_lock_irqsave(&host->lock, flags);
> @@ -3140,8 +3136,6 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
> 	free_irq(host->irq, host);
> 
> 	del_timer_sync(&host->timer);
> -	if (host->version >= SDHCI_SPEC_300)
> -		del_timer_sync(&host->tuning_timer);
> 
> 	tasklet_kill(&host->card_tasklet);
> 	tasklet_kill(&host->finish_tasklet);
> diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
> index d989b51..ac83b10 100644
> --- a/include/linux/mmc/sdhci.h
> +++ b/include/linux/mmc/sdhci.h
> @@ -122,6 +122,7 @@ struct sdhci_host {
> #define SDHCI_PV_ENABLED	(1<<8)	/* Preset value enabled */
> #define SDHCI_SDIO_IRQ_ENABLED	(1<<9)	/* SDIO irq enabled */
> #define SDHCI_HS200_NEEDS_TUNING (1<<10)	/* HS200 needs tuning */
> +#define SDHCI_USING_RETUNING_TIMER (1<<11)	/* Host is using a retuning timer for the card */
> 
> 	unsigned int version;	/* SDHCI spec. version */
> 
> -- 
> 1.7.11.1.3.g4c8a9db
> 


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

* Re: [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER
  2012-07-04  5:29     ` [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER Aaron Lu
  2012-07-04  7:14       ` Girish K S
  2012-07-09  5:10       ` Philip Rakity
@ 2012-07-10  2:55       ` Chris Ball
  2 siblings, 0 replies; 9+ messages in thread
From: Chris Ball @ 2012-07-10  2:55 UTC (permalink / raw)
  To: Aaron Lu; +Cc: linux-mmc, Aaron Lu, Philip Rakity

Hi Aaron,

On Wed, Jul 04 2012, Aaron Lu wrote:
> Add a new flag of SDHCI_USING_RETUNING_TIMER to represent if the host
> is using a retuning timer for the card inserted.
>
> This flag is set when the host does tuning the first time for the card
> and the host's retuning mode is 1. This flag is used afterwards whenever
> needs to decide if the host is currently using a retuning timer.
>
> This flag is cleared when the card is removed in sdhci_reinit.
>
> The set/clear of the flag and the start/stop of the retuning timer is
> associated with the card's init/remove time, so there is no need to
> touch it when the host is to be removed as at that time the card should
> have already been removed.
>
> Signed-off-by: Aaron Lu <aaron.lu@amd.com>
> ---
> v3:
> Change the macro name from SDHCI_NEEDS_RETUNING_TIMER to
> SDHCI_USING_RETUNING_TIMER for better description of the flag as suggested
> by Chris Ball.

Thanks, pushed to mmc-next for 3.6.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2012-07-10  2:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29  8:17 [PATCH v2 0/2] Fixes for tuning stuffs Aaron Lu
2012-06-29  8:17 ` [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed Aaron Lu
2012-07-04  0:40   ` Chris Ball
2012-06-29  8:17 ` [PATCH v2 2/2] mmc: sdhci: A new flag SDHCI_NEEDS_RETUNING_TIMER Aaron Lu
2012-07-04  0:46   ` Chris Ball
2012-07-04  5:29     ` [PATCH v3 2/2] mmc: sdhci: A new flag SDHCI_USING_RETUNING_TIMER Aaron Lu
2012-07-04  7:14       ` Girish K S
2012-07-09  5:10       ` Philip Rakity
2012-07-10  2:55       ` Chris Ball

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.