Skip to contentSkip to conversation

Tuning Fixes for sdhci-omap

PATCH In review Faiz Abbas 3 participants 7 messages Nov 21, 2018 – Dec 5, 2018

Subsystems (3)
lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

v2 cover Tuning Fixes for sdhci-omap

The following patches fix tuning related errors in the sdhci-omap driver.

v2:
Added Fixes and stable tags for patch 1. Re-enable DCRC in patch 1 only if it was enabled before Squashed patches 2 & 3

Faiz Abbas (3):
mmc: sdhci-omap: Fix DCRC error handling during tuning
mmc: sdhci-omap: Add platform specific reset callback
mmc: sdhci-omap: Remove redundant structure assignments

 drivers/mmc/host/sdhci-omap.c | 36 ++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)
Signature · 1 line
2.19.1
author
#1 lore raw

PATCH v2 1/3 mmc: sdhci-omap: Fix DCRC error handling during tuning

Commit 7d33c3581536 ("mmc: sdhci-omap: Workaround for Errata i802") disabled DCRC interrupts during tuning. This write to the interrupt enable register gets overwritten in sdhci_prepare_data() and the interrupt is not in fact disabled. Fix this by disabling the interrupt in the host->ier variable.

Fixes 7d33c3581536 ("mmc: sdhci-omap: Workaround for Errata i802")
---
 drivers/mmc/host/sdhci-omap.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-omap.c +8 -4
index 88347ce78f23..d264391616f9 100644
@@ -288,9 +288,9 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	struct device *dev = omap_host->dev;
 	struct mmc_ios *ios = &mmc->ios;
 	u32 start_window = 0, max_window = 0;
+	bool dcrc_was_enabled = false;
 	u8 cur_match, prev_match = 0;
 	u32 length = 0, max_len = 0;
-	u32 ier = host->ier;
 	u32 phase_delay = 0;
 	int ret = 0;
 	u32 reg;
@@ -317,9 +317,10 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	 * during the tuning procedure. So disable it during the
 	 * tuning procedure.
 	 */
-	ier &= ~SDHCI_INT_DATA_CRC;
-	sdhci_writel(host, ier, SDHCI_INT_ENABLE);
-	sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE);
+	if (host->ier & SDHCI_INT_DATA_CRC) {
+		host->ier &= ~SDHCI_INT_DATA_CRC;
+		dcrc_was_enabled = true;
+	}
 
 	while (phase_delay <= MAX_PHASE_DELAY) {
 		sdhci_omap_set_dll(omap_host, phase_delay);
@@ -366,6 +367,9 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode)
 
 ret:
 	sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
+	/* Reenable forbidden interrupt */
+	if (dcrc_was_enabled)
+		host->ier |= SDHCI_INT_DATA_CRC;
 	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
 	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
 	return ret;
Signature · 1 line
2.19.1
author
#2 lore raw

PATCH v2 2/3 mmc: sdhci-omap: Add platform specific reset callback

In reply to Faiz Abbas

The TRM (SPRUIC2C - January 2017 - Revised May 2018 [1]) forbids assertion of data reset while tuning is happening. Implement a platform specific callback that takes care of this condition.

[1] http://www.ti.com/lit/pdf/spruic2 Section 25.5.1.2.4

---
 drivers/mmc/host/sdhci-omap.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-omap.c +19 -1
index d264391616f9..4fad47926743 100644
@@ -115,6 +115,7 @@ struct sdhci_omap_host {
 
 	struct pinctrl		*pinctrl;
 	struct pinctrl_state	**pinctrl_state;
+	bool			is_tuning;
 };
 
 static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host);
@@ -322,6 +323,8 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode)
 		dcrc_was_enabled = true;
 	}
 
+	omap_host->is_tuning = true;
+
 	while (phase_delay <= MAX_PHASE_DELAY) {
 		sdhci_omap_set_dll(omap_host, phase_delay);
 
@@ -359,9 +362,12 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	phase_delay = max_window + 4 * (max_len >> 1);
 	sdhci_omap_set_dll(omap_host, phase_delay);
 
+	omap_host->is_tuning = false;
+
 	goto ret;
 
 tuning_error:
+	omap_host->is_tuning = false;
 	dev_err(dev, "Tuning failed\n");
 	sdhci_omap_disable_tuning(omap_host);
 
@@ -687,6 +693,18 @@ static void sdhci_omap_set_uhs_signaling(struct sdhci_host *host,
 	sdhci_omap_start_clock(omap_host);
 }
 
+void sdhci_omap_reset(struct sdhci_host *host, u8 mask)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
+
+	/* Don't reset data lines during tuning operation */
+	if (omap_host->is_tuning)
+		mask &= ~SDHCI_RESET_DATA;
+
+	sdhci_reset(host, mask);
+}
+
 static struct sdhci_ops sdhci_omap_ops = {
 	.set_clock = sdhci_omap_set_clock,
 	.set_power = sdhci_omap_set_power,
@@ -695,7 +713,7 @@ static struct sdhci_ops sdhci_omap_ops = {
 	.get_min_clock = sdhci_omap_get_min_clock,
 	.set_bus_width = sdhci_omap_set_bus_width,
 	.platform_send_init_74_clocks = sdhci_omap_init_74_clocks,
-	.reset = sdhci_reset,
+	.reset = sdhci_omap_reset,
 	.set_uhs_signaling = sdhci_omap_set_uhs_signaling,
 };
 
Signature · 1 line
2.19.1
author
#3 lore raw

PATCH v2 3/3 mmc: sdhci-omap: Remove redundant structure assignments

In reply to Faiz Abbas

The sdhci_execute_tuning() function has assignment of private pointers multiple times. Remove the redundant assignment.

---
 drivers/mmc/host/sdhci-omap.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/mmc/host/sdhci-omap.c +0 -4
index 4fad47926743..f588ab679cb0 100644
@@ -296,10 +296,6 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	int ret = 0;
 	u32 reg;
 
-	pltfm_host = sdhci_priv(host);
-	omap_host = sdhci_pltfm_priv(pltfm_host);
-	dev = omap_host->dev;
-
 	/* clock tuning is not needed for upto 52MHz */
 	if (ios->clock <= 52000000)
 		return 0;
Signature · 1 line
2.19.1
maintainer Acked-by on the v2 series
#4 lore raw
In reply to Faiz Abbas
Quoted 8 lines · Faiz Abbas

The following patches fix tuning related errors in the sdhci-omap driver.

v2:
Added Fixes and stable tags for patch 1. Re-enable DCRC in patch 1 only if it was enabled before Squashed patches 2 & 3

Quoted 8 lines

Faiz Abbas (3):
mmc: sdhci-omap: Fix DCRC error handling during tuning
mmc: sdhci-omap: Add platform specific reset callback
mmc: sdhci-omap: Remove redundant structure assignments

 drivers/mmc/host/sdhci-omap.c | 36 ++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)
author
#5 lore raw

Hi,

Quoted 14 lines · Adrian Hunter
Quoted 13 lines · Faiz Abbas

The following patches fix tuning related errors in the sdhci-omap driver.

v2:
Added Fixes and stable tags for patch 1. Re-enable DCRC in patch 1 only if it was enabled before Squashed patches 2 & 3

Faiz Abbas (3):
mmc: sdhci-omap: Fix DCRC error handling during tuning
mmc: sdhci-omap: Add platform specific reset callback
mmc: sdhci-omap: Remove redundant structure assignments

Quoted 5 lines
Quoted 3 lines
 drivers/mmc/host/sdhci-omap.c | 36 ++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

Gentle ping.

Thanks,
Faiz

#6 lore raw
In reply to Faiz Abbas
Quoted 14 lines · Faiz Abbas

The following patches fix tuning related errors in the sdhci-omap driver.

v2:
Added Fixes and stable tags for patch 1. Re-enable DCRC in patch 1 only if it was enabled before Squashed patches 2 & 3

Faiz Abbas (3):
mmc: sdhci-omap: Fix DCRC error handling during tuning
mmc: sdhci-omap: Add platform specific reset callback
mmc: sdhci-omap: Remove redundant structure assignments

Quoted 6 lines
 drivers/mmc/host/sdhci-omap.c | 36 ++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

--
2.19.1

Sorry for the delay!

Picked patch 1/3 for fixes, patch 2/3 and 3/3 for next, thanks!

Kind regards
Uffe