All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@amd.com>
To: Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org, Aaron Lu <aaron.lwe@gmail.com>,
	Aaron Lu <aaron.lu@amd.com>
Subject: [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed
Date: Fri, 29 Jun 2012 16:17:31 +0800	[thread overview]
Message-ID: <1340957852-28936-2-git-send-email-aaron.lu@amd.com> (raw)
In-Reply-To: <1340957852-28936-1-git-send-email-aaron.lu@amd.com>

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



  reply	other threads:[~2012-06-29  8:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29  8:17 [PATCH v2 0/2] Fixes for tuning stuffs Aaron Lu
2012-06-29  8:17 ` Aaron Lu [this message]
2012-07-04  0:40   ` [PATCH v2 1/2] mmc: sdhci: restore host settings when card is removed 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340957852-28936-2-git-send-email-aaron.lu@amd.com \
    --to=aaron.lu@amd.com \
    --cc=aaron.lwe@gmail.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.