2018-11-21 11:31:07

by Faiz Abbas

[permalink] [raw]
Subject: [PATCH v2 0/3] 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(-)

--
2.19.1



2018-11-21 10:44:18

by Faiz Abbas

[permalink] [raw]
Subject: [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")
Cc: <[email protected]>
Signed-off-by: Faiz Abbas <[email protected]>
---
drivers/mmc/host/sdhci-omap.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 88347ce78f23..d264391616f9 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -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;
--
2.19.1


2018-11-21 11:31:07

by Faiz Abbas

[permalink] [raw]
Subject: [PATCH v2 2/3] mmc: sdhci-omap: Add platform specific reset callback

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

Acked-by: Kishon Vijay Abraham I <[email protected]>
Signed-off-by: Faiz Abbas <[email protected]>
---
drivers/mmc/host/sdhci-omap.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index d264391616f9..4fad47926743 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -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,
};

--
2.19.1


2018-11-21 11:32:06

by Faiz Abbas

[permalink] [raw]
Subject: [PATCH v2 3/3] mmc: sdhci-omap: Remove redundant structure assignments

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

Acked-by: Kishon Vijay Abraham I <[email protected]>
Signed-off-by: Faiz Abbas <[email protected]>
---
drivers/mmc/host/sdhci-omap.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 4fad47926743..f588ab679cb0 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -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;
--
2.19.1


2018-11-21 11:45:11

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Tuning Fixes for sdhci-omap

On 21/11/18 12:33 PM, Faiz Abbas wrote:
> 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(-)
>

Acked-by: Adrian Hunter <[email protected]>

2018-12-04 08:26:39

by Faiz Abbas

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Tuning Fixes for sdhci-omap

Hi,

On 21/11/18 4:53 PM, Adrian Hunter wrote:
> On 21/11/18 12:33 PM, Faiz Abbas wrote:
>> 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(-)
>>
>
> Acked-by: Adrian Hunter <[email protected]>

Gentle ping.

Thanks,
Faiz


2018-12-05 14:25:32

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Tuning Fixes for sdhci-omap

On Wed, 21 Nov 2018 at 11:31, Faiz Abbas <[email protected]> wrote:
>
> 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(-)
>
> --
> 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