All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-mmc@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH v3 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting
Date: Tue, 17 Jul 2018 16:52:15 +0200	[thread overview]
Message-ID: <20180717145216.16840-4-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20180717145216.16840-1-niklas.soderlund+renesas@ragnatech.se>

When tuning each tap is issued CMD19 twice and the result of both runs
recorded in host->taps. If the result is different between the two runs
the wrong sampling clock position was selected. Fix this by merging the
two runs and only keep the result for each tap if it was good in both
sets.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

---

* Changes since v2
- Rewrote the change to use a less clumsy loop.  The patch is now
  completely changed from Hayakawa-sans version and therefor I have also
  claimed authorship.
- Fixed spelling in comment as suggested by Geert.

* Changes since v1
- Updated commit message after discussion with Wolfram.
- Expanded comment in code to better explain why the results are merged.
---
 drivers/mmc/host/renesas_sdhi_core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 384ae6cfa289e22c..777e32b0e410e850 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -384,6 +384,18 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
 	/* Clear SCC_RVSREQ */
 	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ, 0);
 
+	/*
+	 * When tuning CMD19 is issued twice for each tap, merge the
+	 * result requiring the tap to be good in both runs before
+	 * considering it for tuning selection.
+	 */
+	for (i = 0; i < host->tap_num * 2; i++) {
+		int offset = host->tap_num * (i < host->tap_num ? 1 : -1);
+
+		if (!test_bit(i, host->taps))
+			clear_bit(i + offset, host->taps);
+	}
+
 	/*
 	 * Find the longest consecutive run of successful probes.  If that
 	 * is more than SH_MOBILE_SDHI_MAX_TAP probes long then use the
-- 
2.18.0

  parent reply	other threads:[~2018-07-17 15:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 14:52 [PATCH v3 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior Niklas Söderlund
2018-07-17 14:52 ` [PATCH v3 1/4] mmc: tmio: Fix tuning flow Niklas Söderlund
2018-07-18  8:48   ` Simon Horman
2018-07-24 10:42   ` Wolfram Sang
2018-07-24 10:58     ` Simon Horman
2018-07-24 11:19       ` Wolfram Sang
2018-07-17 14:52 ` [PATCH v3 2/4] mmc: tmio: Fix SCC error detection Niklas Söderlund
2018-07-24 10:44   ` Wolfram Sang
2018-07-24 11:03     ` Simon Horman
2018-07-24 11:17       ` Wolfram Sang
2018-07-24 12:17         ` Simon Horman
2018-07-17 14:52 ` Niklas Söderlund [this message]
2018-07-18  8:52   ` [PATCH v3 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting Simon Horman
2018-07-24 11:26   ` Wolfram Sang
2018-07-24 12:19     ` Simon Horman
2018-07-24 14:57     ` Niklas Söderlund
2018-07-17 14:52 ` [PATCH v3 4/4] mmc: renesas_sdhi: skip SCC error check when retuning Niklas Söderlund
2018-07-18  8:54   ` Simon Horman
2018-07-18  9:46     ` Wolfram Sang
2018-07-18 12:23       ` Niklas Söderlund
2018-07-18 12:22     ` Niklas Söderlund
2018-07-19  7:40       ` Simon Horman

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=20180717145216.16840-4-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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.