linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFT 0/2] mmc: tmio: make resets more robust
@ 2021-03-16  8:57 Wolfram Sang
  2021-03-16  8:57 ` [PATCH RFT 1/2] mmc: tmio: restore bus width when resetting Wolfram Sang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Wolfram Sang @ 2021-03-16  8:57 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Yoshihiro Shimoda, Wolfram Sang

Here are two more patches improving the robustness of resetting the IP
core. Patches are on top of mmc/next and this series "[PATCH v2 0/3]
mmc: renesas_sdhi: reset via reset controller", especially "[PATCH v2
1/3] mmc: tmio: abort DMA before reset".

Tested on Salvator-XS with H3 ES2.0 and M3-N. A branch for testing can
be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/sdhi/for-5.13

Some additional testing by Shimoda-san or the BSP team would be much
appreciated!

   Wolfram


Takeshi Saito (1):
  mmc: tmio: restore bus width when resetting

Wolfram Sang (1):
  mmc: tmio: always flag retune when resetting and a card is present

 drivers/mmc/host/tmio_mmc_core.c | 37 +++++++++++++++++---------------
 1 file changed, 20 insertions(+), 17 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH RFT 1/2] mmc: tmio: restore bus width when resetting
  2021-03-16  8:57 [PATCH RFT 0/2] mmc: tmio: make resets more robust Wolfram Sang
@ 2021-03-16  8:57 ` Wolfram Sang
  2021-03-16  8:57 ` [PATCH RFT 2/2] mmc: tmio: always flag retune when resetting and a card is present Wolfram Sang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2021-03-16  8:57 UTC (permalink / raw)
  To: linux-mmc
  Cc: linux-renesas-soc, Yoshihiro Shimoda, Takeshi Saito, Wolfram Sang

From: Takeshi Saito <takeshi.saito.xv@renesas.com>

Resetting the IP core will lose the bus width information and not all
code paths recover it. So, make sure the latest bus width gets restored
in the reset routine. For that, tmio_mmc_set_bus_width() is moved, but
not modified.

Signed-off-by: Takeshi Saito <takeshi.saito.xv@renesas.com>
[wsa: reworded commit message]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_core.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index eca767dcabba..3755f606b8db 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -164,6 +164,21 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 	}
 }
 
+static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,
+				   unsigned char bus_width)
+{
+	u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT)
+				& ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8);
+
+	/* reg now applies to MMC_BUS_WIDTH_4 */
+	if (bus_width == MMC_BUS_WIDTH_1)
+		reg |= CARD_OPT_WIDTH;
+	else if (bus_width == MMC_BUS_WIDTH_8)
+		reg |= CARD_OPT_WIDTH8;
+
+	sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg);
+}
+
 static void tmio_mmc_reset(struct tmio_mmc_host *host)
 {
 	/* FIXME - should we set stop clock reg here */
@@ -177,6 +192,8 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 	if (host->reset)
 		host->reset(host);
 
+	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
+
 	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
 		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
 		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
@@ -874,21 +891,6 @@ static void tmio_mmc_power_off(struct tmio_mmc_host *host)
 		host->set_pwr(host->pdev, 0);
 }
 
-static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,
-				   unsigned char bus_width)
-{
-	u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT)
-				& ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8);
-
-	/* reg now applies to MMC_BUS_WIDTH_4 */
-	if (bus_width == MMC_BUS_WIDTH_1)
-		reg |= CARD_OPT_WIDTH;
-	else if (bus_width == MMC_BUS_WIDTH_8)
-		reg |= CARD_OPT_WIDTH8;
-
-	sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg);
-}
-
 static unsigned int tmio_mmc_get_timeout_cycles(struct tmio_mmc_host *host)
 {
 	u16 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH RFT 2/2] mmc: tmio: always flag retune when resetting and a card is present
  2021-03-16  8:57 [PATCH RFT 0/2] mmc: tmio: make resets more robust Wolfram Sang
  2021-03-16  8:57 ` [PATCH RFT 1/2] mmc: tmio: restore bus width when resetting Wolfram Sang
@ 2021-03-16  8:57 ` Wolfram Sang
  2021-03-23 13:09 ` [PATCH RFT 0/2] mmc: tmio: make resets more robust Yoshihiro Shimoda
  2021-03-24 10:20 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2021-03-16  8:57 UTC (permalink / raw)
  To: linux-mmc
  Cc: linux-renesas-soc, Yoshihiro Shimoda, Wolfram Sang, Takeshi Saito

After reset, we manually flagged retune in runtime resume, but missed it
in the workqueue. To fix that and avoid the problem in the future, let's
flag retune in the reset handler directly whenever a card is present.

Reported-by: Takeshi Saito <takeshi.saito.xv@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 3755f606b8db..2e85e40f50f9 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -198,6 +198,9 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
 		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
 	}
+
+	if (host->mmc->card)
+		mmc_retune_needed(host->mmc);
 }
 
 static void tmio_mmc_reset_work(struct work_struct *work)
@@ -1290,8 +1293,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
 
 	tmio_mmc_enable_dma(host, true);
 
-	mmc_retune_needed(host->mmc);
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_runtime_resume);
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH RFT 0/2] mmc: tmio: make resets more robust
  2021-03-16  8:57 [PATCH RFT 0/2] mmc: tmio: make resets more robust Wolfram Sang
  2021-03-16  8:57 ` [PATCH RFT 1/2] mmc: tmio: restore bus width when resetting Wolfram Sang
  2021-03-16  8:57 ` [PATCH RFT 2/2] mmc: tmio: always flag retune when resetting and a card is present Wolfram Sang
@ 2021-03-23 13:09 ` Yoshihiro Shimoda
  2021-03-24 10:20 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Yoshihiro Shimoda @ 2021-03-23 13:09 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-renesas-soc, linux-mmc

Hi Wolfram-san,

> From: Wolfram Sang, Sent: Tuesday, March 16, 2021 5:57 PM
> 
> Here are two more patches improving the robustness of resetting the IP
> core. Patches are on top of mmc/next and this series "[PATCH v2 0/3]
> mmc: renesas_sdhi: reset via reset controller", especially "[PATCH v2
> 1/3] mmc: tmio: abort DMA before reset".
> 
> Tested on Salvator-XS with H3 ES2.0 and M3-N. A branch for testing can
> be found here:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/sdhi/for-5.13
> 
> Some additional testing by Shimoda-san or the BSP team would be much
> appreciated!

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

And, I tested on H3 ES3.0 and then I didn't observe any regression.
So,

Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Best regards,
Yoshihiro Shimoda


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH RFT 0/2] mmc: tmio: make resets more robust
  2021-03-16  8:57 [PATCH RFT 0/2] mmc: tmio: make resets more robust Wolfram Sang
                   ` (2 preceding siblings ...)
  2021-03-23 13:09 ` [PATCH RFT 0/2] mmc: tmio: make resets more robust Yoshihiro Shimoda
@ 2021-03-24 10:20 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2021-03-24 10:20 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc, Linux-Renesas, Yoshihiro Shimoda

On Tue, 16 Mar 2021 at 09:58, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> Here are two more patches improving the robustness of resetting the IP
> core. Patches are on top of mmc/next and this series "[PATCH v2 0/3]
> mmc: renesas_sdhi: reset via reset controller", especially "[PATCH v2
> 1/3] mmc: tmio: abort DMA before reset".
>
> Tested on Salvator-XS with H3 ES2.0 and M3-N. A branch for testing can
> be found here:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/sdhi/for-5.13
>
> Some additional testing by Shimoda-san or the BSP team would be much
> appreciated!
>
>    Wolfram
>
>
> Takeshi Saito (1):
>   mmc: tmio: restore bus width when resetting
>
> Wolfram Sang (1):
>   mmc: tmio: always flag retune when resetting and a card is present
>
>  drivers/mmc/host/tmio_mmc_core.c | 37 +++++++++++++++++---------------
>  1 file changed, 20 insertions(+), 17 deletions(-)
>

Applied for next, thanks!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-24 10:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16  8:57 [PATCH RFT 0/2] mmc: tmio: make resets more robust Wolfram Sang
2021-03-16  8:57 ` [PATCH RFT 1/2] mmc: tmio: restore bus width when resetting Wolfram Sang
2021-03-16  8:57 ` [PATCH RFT 2/2] mmc: tmio: always flag retune when resetting and a card is present Wolfram Sang
2021-03-23 13:09 ` [PATCH RFT 0/2] mmc: tmio: make resets more robust Yoshihiro Shimoda
2021-03-24 10:20 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).