Skip to contentSkip to conversation

mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish

PATCH Applied Aaron Lu 5 participants 11 messages Jul 11, 2011 – Jul 28, 2011

Subsystems (2)
lore
Share & tools
lore

Aaron Lu

author
#0 lore raw

PATCH 1/1 mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish

Currently, the retuning timer for retuning mode 1 will be deleted in function sdhci_tasklet_finish after a mmc request done, which will make retuning timing never trigger again. This patch fixed this problem.

---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long param)
 
 	del_timer(&host->timer);
 
-	if (host->version >= SDHCI_SPEC_300)
-		del_timer(&host->tuning_timer);
-
 	mrq = host->mrq;
 
 	/*
Signature · 1 line
1.7.1
#1 lore raw

Hi Philip, Zhangfei

Do you have any comments on this patch?

Thanks,
Arindam

Quoted 34 lines

-----Original Message-----
From: Aaron Lu [mailto:[email protected]]
Sent: Monday, July 11, 2011 10:57 AM
To: Chris Ball
Cc: Nath, Arindam; [email protected]; Lu, Aaron
Subject: [PATCH] mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish

Currently, the retuning timer for retuning mode 1 will be deleted in function sdhci_tasklet_finish after a mmc request done, which will make retuning timing never trigger again. This patch fixed this problem.

---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
 	del_timer(&host->timer);
 
-	if (host->version >= SDHCI_SPEC_300)
-		del_timer(&host->tuning_timer);
-
 	mrq = host->mrq;
 

/*
--
1.7.1

author
#2 lore raw
Quoted 4 lines · Arindam

Hi Philip, Zhangfei

Do you have any comments on this patch?

Hi all,

This patch is sent for a while now and didn't seem to receive any notice yet...So, can you please take a look and give your comments?

This is a bug fix for exsting code, if the re-tuning timer is deleted, the re-tuning will not happen again, that will cause problems for SDHC 3.0 hosts which utilize re-tuning mode 1.

Thanks.

Quoted 38 lines
Quoted 11 lines

-----Original Message-----
From: Aaron Lu [mailto:[email protected]]
Sent: Monday, July 11, 2011 10:57 AM
To: Chris Ball
Cc: Nath, Arindam; [email protected]; Lu, Aaron
Subject: [PATCH] mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish

Currently, the retuning timer for retuning mode 1 will be deleted in function sdhci_tasklet_finish after a mmc request done, which will

make

Quoted 24 lines

retuning timing never trigger again. This patch fixed this problem.

---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
 	del_timer(&host->timer);
 
-	if (host->version >= SDHCI_SPEC_300)
-		del_timer(&host->tuning_timer);
-
 	mrq = host->mrq;
 

/*
--
1.7.1

#3 lore raw
Quoted 4 lines

This is a bug fix for exsting code, if the re-tuning timer is deleted, the re-tuning will not happen again, that will cause problems for SDHC 3.0 hosts which utilize re-tuning mode 1.

Quoted 15 lines

Thanks.

Quoted 13 lines
Quoted 11 lines

-----Original Message-----
From: Aaron Lu [mailto:[email protected]]
Sent: Monday, July 11, 2011 10:57 AM
To: Chris Ball
Cc: Nath, Arindam; [email protected]; Lu, Aaron
Subject: [PATCH] mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish

Currently, the retuning timer for retuning mode 1 will be deleted in function sdhci_tasklet_finish after a mmc request done, which will

make

Quoted 1 line

retuning timing never trigger again. This patch fixed this problem.

Does the execute_tuning is called again?
del_timer is not delete timer really, but deactivate the timer, which could be re-activated by mod_timer.
So if execute_tuning is called, the mod_timer will tigger the tuning timer again.

Quoted 27 lines
Quoted 25 lines
Quoted 23 lines

---
 drivers/mmc/host/sdhci.c |    3 ---

 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
     del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
     mrq = host->mrq;
 

    /*
--
1.7.1

author
#4 lore raw
Quoted 7 lines · zhangfei gao

Does the execute_tuning is called again?
del_timer is not delete timer really, but deactivate the timer, which could be re-activated by mod_timer.
So if execute_tuning is called, the mod_timer will tigger the tuning timer again.

Hi zhangfei,

Thanks for the comment.

The execute_tuning will be called at two places:
1 In mmc_sd_init_uhs_card, when host is initializing an UHS card, and the re-tuning timer will be activated for the first time; 2 When re-tuning timer expired

So if the re-tuning timer is deactivated in sdhci_tasklet_finish, execute_tuning will have no chance of getting called again, and the host will not be able to do the re-tuning anymore.

Quoted 28 lines
Quoted 27 lines
Quoted 25 lines
Quoted 23 lines

---
 drivers/mmc/host/sdhci.c |    3 ---

 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
     del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
     mrq = host->mrq;
 

    /*
--
1.7.1

#5 lore raw

Aaron,

Code is fine. Do you want to also fix the problem with suspend or should I do the patch ?

When we are suspending we should kill the tuning timer.

drivers/mmc/host/sdhci.c +4 -8
index 4da6a4d..88c25e8 100644
@@ -2289,18 +2289,14 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
 
 	sdhci_disable_card_detection(host);
 
-	/* Disable tuning since we are suspending */
-	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
-		host->flags &= ~SDHCI_NEEDS_RETUNING;
-		mod_timer(&host->tuning_timer, jiffies +
-			host->tuning_count * HZ);
-	}
-
 	ret = mmc_suspend_host(host->mmc);
 	if (ret)
 		return ret;
 
+	/* Disable tuning since we are suspending */
+	if (host->version >= SDHCI_SPEC_300)
+		del_timer_sync(&host->tuning_timer);
+
 	free_irq(host->irq, host);
 
 	if (host->vmmc)

Philip

Quoted 51 lines · Aaron Lu
Quoted 7 lines · zhangfei gao

Does the execute_tuning is called again?
del_timer is not delete timer really, but deactivate the timer, which could be re-activated by mod_timer.
So if execute_tuning is called, the mod_timer will tigger the tuning timer again.

Hi zhangfei,

Thanks for the comment.

The execute_tuning will be called at two places:
1 In mmc_sd_init_uhs_card, when host is initializing an UHS card, and the re-tuning timer will be activated for the first time; 2 When re-tuning timer expired

So if the re-tuning timer is deactivated in sdhci_tasklet_finish, execute_tuning will have no chance of getting called again, and the host will not be able to do the re-tuning anymore.

Quoted 28 lines
Quoted 27 lines
Quoted 25 lines
Quoted 23 lines
---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
    del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
    mrq = host->mrq;
 
    /*

--
1.7.1

author
#6 lore raw

Hi Philip,

Quoted 4 lines · Philip Rakity

Aaron,

Code is fine.

Thanks.

Quoted 2 lines

Do you want to also fix the problem with suspend or should I do the patch ? When we are suspending we should kill the tuning timer.

Yes, that is a problem.

I've another patch to add support for re-tuning mode 2 queued for submit which should have fixed this problem, but I didn't touch anything if mmc_suspend_host failed, so when I submit the other patch, please take you time to review it and let's see how we can fix the problem altogether :-)

Quoted 88 lines
drivers/mmc/host/sdhci.c +4 -8
index 4da6a4d..88c25e8 100644
@@ -2289,18 +2289,14 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
 
 	sdhci_disable_card_detection(host);
 
-	/* Disable tuning since we are suspending */
-	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
-		host->flags &= ~SDHCI_NEEDS_RETUNING;
-		mod_timer(&host->tuning_timer, jiffies +
-			host->tuning_count * HZ);
-	}
-
 	ret = mmc_suspend_host(host->mmc);
 	if (ret)
 		return ret;
 
+	/* Disable tuning since we are suspending */
+	if (host->version >= SDHCI_SPEC_300)
+		del_timer_sync(&host->tuning_timer);
+
 	free_irq(host->irq, host);
 
 	if (host->vmmc)

Philip

Quoted 51 lines · Aaron Lu
Quoted 7 lines · zhangfei gao

Does the execute_tuning is called again?
del_timer is not delete timer really, but deactivate the timer, which could be re-activated by mod_timer.
So if execute_tuning is called, the mod_timer will tigger the tuning timer again.

Hi zhangfei,

Thanks for the comment.

The execute_tuning will be called at two places:
1 In mmc_sd_init_uhs_card, when host is initializing an UHS card, and the re-tuning timer will be activated for the first time; 2 When re-tuning timer expired

So if the re-tuning timer is deactivated in sdhci_tasklet_finish, execute_tuning will have no chance of getting called again, and the host will not be able to do the re-tuning anymore.

Quoted 28 lines
Quoted 27 lines
Quoted 25 lines
Quoted 23 lines
---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
    del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
    mrq = host->mrq;
 
    /*

--
1.7.1

#7 lore raw
In reply to Aaron Lu
Quoted 13 lines · Aaron Lu
Quoted 7 lines · zhangfei gao

Does the execute_tuning is called again?
del_timer is not delete timer really, but deactivate the timer, which could be re-activated by mod_timer.
So if execute_tuning is called, the mod_timer will tigger the tuning timer again.

Hi zhangfei,

Thanks for the comment.

Quoted 8 lines

The execute_tuning will be called at two places:
1 In mmc_sd_init_uhs_card, when host is initializing an UHS card, and the re-tuning timer will be activated for the first time; 2 When re-tuning timer expired

So if the re-tuning timer is deactivated in sdhci_tasklet_finish, execute_tuning will have no chance of getting called again, and the host will not be able to do the re-tuning anymore.

Thanks for explanation, looks good to me.

Quoted 31 lines
Quoted 29 lines
Quoted 28 lines
Quoted 26 lines
Quoted 24 lines

---
 drivers/mmc/host/sdhci.c |    3 ---

 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
     del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
     mrq = host->mrq;
 

    /*
--
1.7.1

author
#8 lore raw
Quoted 3 lines · zhangfei gao

Thanks for explanation, looks good to me.

Hi Philip & Zhangfei,

Can I have your reviewed-by tag in the patch?

Thanks,
Aaron

Quoted 31 lines
Quoted 30 lines
Quoted 28 lines
Quoted 27 lines
Quoted 25 lines
Quoted 23 lines

---
 drivers/mmc/host/sdhci.c |    3 ---

 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
     del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
     mrq = host->mrq;
 

    /*
--
1.7.1

Reviewed-by
#9 lore raw

________________________________________
From: Aaron Lu [[email protected]]
Sent: Wednesday, July 27, 2011 2:15 AM
To: zhangfei gao; Philip Rakity
Cc: Nath, Arindam; Chris Ball; [email protected]
Subject: Re: [PATCH] mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish

Quoted 3 lines · zhangfei gao

Thanks for explanation, looks good to me.

Hi Philip & Zhangfei,

Can I have your reviewed-by tag in the patch?

Thanks,
Aaron

Quoted 31 lines
Quoted 30 lines
Quoted 28 lines
Quoted 27 lines
Quoted 25 lines
Quoted 23 lines
---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -3
index 91d9892..6250bac 100644
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long
 param)
 
    del_timer(&host->timer);
 
-   if (host->version >= SDHCI_SPEC_300)
-           del_timer(&host->tuning_timer);
-
    mrq = host->mrq;
 
    /*

--
1.7.1

Applied
#10 lore raw
In reply to Aaron Lu

Hi Aaron,

Quoted 14 lines · Aaron Lu

Currently, the retuning timer for retuning mode 1 will be deleted in function sdhci_tasklet_finish after a mmc request done, which will make retuning timing never trigger again. This patch fixed this problem.

---
 drivers/mmc/host/sdhci.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +0 -0
index 91d9892..6250bac 100644

drivers/mmc/host/sdhci.c static void sdhci_tasklet_finish(unsigned long param) · line 1868

Quoted 9 lines
drivers/mmc/host/sdhci.c +0 -3
@@ -1863,9 +1863,6 @@ static void sdhci_tasklet_finish(unsigned long param)
 
 	del_timer(&host->timer);
 
-	if (host->version >= SDHCI_SPEC_300)
-		del_timer(&host->tuning_timer);
-
 	mrq = host->mrq;
 
 	/*

Pushed to mmc-next for 3.1 with Philip's Reviewed-by, thanks.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child