]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.5.1/mmc-sdhci-fix-incorrect-command-used-in-tuning.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.5.1 / mmc-sdhci-fix-incorrect-command-used-in-tuning.patch
1 From 473b095a72a95ba719905b1f2e82cd18d099a427 Mon Sep 17 00:00:00 2001
2 From: Aaron Lu <aaron.lu@amd.com>
3 Date: Tue, 3 Jul 2012 17:27:49 +0800
4 Subject: mmc: sdhci: fix incorrect command used in tuning
5
6 From: Aaron Lu <aaron.lu@amd.com>
7
8 commit 473b095a72a95ba719905b1f2e82cd18d099a427 upstream.
9
10 For SD hosts using retuning mode 1, when retuning timer expired, it will
11 need to do retuning in sdhci_request before processing the actual
12 request. But the retuning command is fixed: cmd19 for SD card and cmd21
13 for eMMC card, so we can't use the original request's command to do the
14 tuning.
15
16 And since the tuning command depends on the card type attached to the
17 host, we will need to know the card type to use the correct tuning
18 command.
19
20 Signed-off-by: Aaron Lu <aaron.lu@amd.com>
21 Reviewed-by: Philip Rakity <prakity@marvell.com>
22 Signed-off-by: Chris Ball <cjb@laptop.org>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 drivers/mmc/host/sdhci.c | 8 +++++++-
27 1 file changed, 7 insertions(+), 1 deletion(-)
28
29 --- a/drivers/mmc/host/sdhci.c
30 +++ b/drivers/mmc/host/sdhci.c
31 @@ -27,6 +27,7 @@
32
33 #include <linux/mmc/mmc.h>
34 #include <linux/mmc/host.h>
35 +#include <linux/mmc/card.h>
36
37 #include "sdhci.h"
38
39 @@ -1245,6 +1246,7 @@ static void sdhci_request(struct mmc_hos
40 struct sdhci_host *host;
41 bool present;
42 unsigned long flags;
43 + u32 tuning_opcode;
44
45 host = mmc_priv(mmc);
46
47 @@ -1292,8 +1294,12 @@ static void sdhci_request(struct mmc_hos
48 */
49 if ((host->flags & SDHCI_NEEDS_RETUNING) &&
50 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
51 + /* eMMC uses cmd21 while sd and sdio use cmd19 */
52 + tuning_opcode = mmc->card->type == MMC_TYPE_MMC ?
53 + MMC_SEND_TUNING_BLOCK_HS200 :
54 + MMC_SEND_TUNING_BLOCK;
55 spin_unlock_irqrestore(&host->lock, flags);
56 - sdhci_execute_tuning(mmc, mrq->cmd->opcode);
57 + sdhci_execute_tuning(mmc, tuning_opcode);
58 spin_lock_irqsave(&host->lock, flags);
59
60 /* Restore original mmc_request structure */