All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] mmc: tmio: fix reset operation
@ 2018-11-26 17:02 Niklas Söderlund
  2018-11-26 17:02 ` [PATCH v4 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Niklas Söderlund @ 2018-11-26 17:02 UTC (permalink / raw)
  To: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund

Hi,

While looking at the Renesas BSP kernel I found patches which improves
the state of the hardware at probe and after runtime resume.

Patch 1/3 make sure the module clock is enabled after resuming before
register are accessed. Patch 2/3 is the real change in this series and
brings in reset of the vendor specific callback when resetting (SCC in
the Renesas case). While 3/3 simply make sure that the IRQ mask for
Renesas boards (Gen2 and later) are in a good shape after probe (and
reset).

In addition to addressing the state after resuming it helped unbreak a
SD card I have which are very problematic on Koelsch. Without this
series inserting the card results in:

sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
sh_mobile_sdhi ee100000.sd: Tuning procedure failed
mmc0: tuning execution failed: -5
mmc0: error -5 whilst initialising SD card
sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)

While with this series applied (patch 2/3):

sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
mmc0: new ultra high speed SDR50 SDHC card at address aaaa
mmcblk0: mmc0:aaaa SU04G 3.69 GiB
 mmcblk0: p1 p2

Patch 1/3 was previously part of 2/3 but as it deals with a unrelated
issue it's here broken out to a separate patch. Patch 3/3 have once been
posted outside this series bit after comments from Wolfram it's brought
back as it now deepens on 2/3.

Most changes in this series are based on similar work from Masaharu
Hayakawa but for this version all changes now differ quiet a lot from
his work.  All mails sent to him bounce with a "Undelivered Mail
Returned to Sender" error. I therefor felt the need to claim authorship
as I don't want to post blame of my (potential) mistakes on some else.

Niklas Söderlund (3):
  mmc: tmio: enable module clock before resetting when resuming
  mmc: tmio: fix reset operation
  mmc: renesas_sdhi: add initial setting of interrupt mask register

 drivers/mmc/host/renesas_sdhi_core.c |  4 ++++
 drivers/mmc/host/tmio_mmc.h          |  1 +
 drivers/mmc/host/tmio_mmc_core.c     | 27 +++++++++++++++------------
 3 files changed, 20 insertions(+), 12 deletions(-)

-- 
2.19.1

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

* [PATCH v4 1/3] mmc: tmio: enable module clock before resetting when resuming
  2018-11-26 17:02 [PATCH v4 0/3] mmc: tmio: fix reset operation Niklas Söderlund
@ 2018-11-26 17:02 ` Niklas Söderlund
  2018-11-26 17:02 ` [PATCH v4 2/3] mmc: tmio: fix reset operation Niklas Söderlund
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Niklas Söderlund @ 2018-11-26 17:02 UTC (permalink / raw)
  To: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund

On runtime power management resume, the host clock needs to be
enabled before calling tmio_mmc_reset. If the mmc device has a power
domain entry, the host clock is enabled via genpd_runtime_resume,
running before tmio_mmc_host_runtime_resume. If the mmc device has no
power domain entry, however, genpd_runtime_resume is not called. This
patch changes tmio_mmc_host_runtime_resume to enable the host clock
before calling tmio_mmc_reset.

Based on work from Masaharu Hayakawa.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/mmc/host/tmio_mmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index a8f917f744fb9f63..35acfa4f40b2ef57 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1326,8 +1326,8 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
 {
 	struct tmio_mmc_host *host = dev_get_drvdata(dev);
 
-	host->reset(host);
 	tmio_mmc_clk_enable(host);
+	host->reset(host);
 
 	if (host->clk_cache)
 		host->set_clock(host, host->clk_cache);
-- 
2.19.1

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

* [PATCH v4 2/3] mmc: tmio: fix reset operation
  2018-11-26 17:02 [PATCH v4 0/3] mmc: tmio: fix reset operation Niklas Söderlund
  2018-11-26 17:02 ` [PATCH v4 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
@ 2018-11-26 17:02 ` Niklas Söderlund
  2018-11-28 13:21   ` Simon Horman
  2018-11-30 11:33   ` Wolfram Sang
  2018-11-26 17:02 ` [PATCH v4 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
  2018-12-05 14:23 ` [PATCH v4 0/3] mmc: tmio: fix reset operation Ulf Hansson
  3 siblings, 2 replies; 7+ messages in thread
From: Niklas Söderlund @ 2018-11-26 17:02 UTC (permalink / raw)
  To: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund

SD / MMC did not operate properly when suspend transition failed.
Because the SCC was not reset at resume, issue of the command failed.
Call the host specific reset function and reset the hardware in order to
add reset of SCC. This change also fixes tuning on some stubborn cards
on Gen2.

Based on work from Masaharu Hayakawa.

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

---
* Changes sine v1
- Merge tmio_mmc_reset() into tmio_mmc_hw_reset() as it's now the only
  caller.

* Changes since v2
- Rebased on mmc/next caused small refactoring of the code.

* Changes since v3
- Remove call to tmio_mmc_abort_dma() in tmio_mmc_reset_work() as it
  already calls tmio_mmc_hw_reset() which with this change already
  aborts the DMA. Thanks Yamada-san for pointing this out.
---
 drivers/mmc/host/tmio_mmc_core.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 35acfa4f40b2ef57..d396c5156053e410 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -171,6 +171,18 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 	}
 }
 
+static void tmio_mmc_hw_reset(struct mmc_host *mmc)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+
+	host->reset(host);
+
+	tmio_mmc_abort_dma(host);
+
+	if (host->hw_reset)
+		host->hw_reset(host);
+}
+
 static void tmio_mmc_reset_work(struct work_struct *work)
 {
 	struct tmio_mmc_host *host = container_of(work, struct tmio_mmc_host,
@@ -209,12 +221,11 @@ static void tmio_mmc_reset_work(struct work_struct *work)
 
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	host->reset(host);
+	tmio_mmc_hw_reset(host->mmc);
 
 	/* Ready for new calls */
 	host->mrq = NULL;
 
-	tmio_mmc_abort_dma(host);
 	mmc_request_done(host->mmc, mrq);
 }
 
@@ -696,14 +707,6 @@ static int tmio_mmc_start_data(struct tmio_mmc_host *host,
 	return 0;
 }
 
-static void tmio_mmc_hw_reset(struct mmc_host *mmc)
-{
-	struct tmio_mmc_host *host = mmc_priv(mmc);
-
-	if (host->hw_reset)
-		host->hw_reset(host);
-}
-
 static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
 {
 	struct tmio_mmc_host *host = mmc_priv(mmc);
@@ -1226,7 +1229,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 		_host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
 
 	_host->set_clock(_host, 0);
-	_host->reset(_host);
+	tmio_mmc_hw_reset(mmc);
 
 	_host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
 	tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
@@ -1327,7 +1330,7 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
 	struct tmio_mmc_host *host = dev_get_drvdata(dev);
 
 	tmio_mmc_clk_enable(host);
-	host->reset(host);
+	tmio_mmc_hw_reset(host->mmc);
 
 	if (host->clk_cache)
 		host->set_clock(host, host->clk_cache);
-- 
2.19.1

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

* [PATCH v4 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register
  2018-11-26 17:02 [PATCH v4 0/3] mmc: tmio: fix reset operation Niklas Söderlund
  2018-11-26 17:02 ` [PATCH v4 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
  2018-11-26 17:02 ` [PATCH v4 2/3] mmc: tmio: fix reset operation Niklas Söderlund
@ 2018-11-26 17:02 ` Niklas Söderlund
  2018-12-05 14:23 ` [PATCH v4 0/3] mmc: tmio: fix reset operation Ulf Hansson
  3 siblings, 0 replies; 7+ messages in thread
From: Niklas Söderlund @ 2018-11-26 17:02 UTC (permalink / raw)
  To: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund

The initial value of the interrupt mask register may be different from
the H/W manual at the startup of the kernel by setting from the
bootloader. Since the error interrupts may be unmasked, the driver sets
initial value.

The initial value is only known for R-Car Gen2 and Gen3 platforms so
limit the initialization to those platforms.

Based on work from Masaharu Hayakawa.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

---

* Changes since v1
- Limit the initialization to Gen2+ platforms by checking the
  TMIO_MMC_MIN_RCAR2 flag.
- Rename the constant for the initialization value to reflect it's only
  for R-Car Gen2+ platforms.
- Move setting of the initial mask to renesas_sdhi.
---
 drivers/mmc/host/renesas_sdhi_core.c | 4 ++++
 drivers/mmc/host/tmio_mmc.h          | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 78bd117bbe65de46..26da095f8ad5a56c 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -523,6 +523,10 @@ static void renesas_sdhi_hw_reset(struct tmio_mmc_host *host)
 	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
 		       ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
 		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
+
+	if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
+		sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK,
+					     TMIO_MASK_INIT_RCAR2);
 }
 
 static int renesas_sdhi_wait_idle(struct tmio_mmc_host *host, u32 bit)
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 1e317027bf534612..5f6dfb86e43e8208 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -96,6 +96,7 @@
 
 /* Define some IRQ masks */
 /* This is the mask used at reset by the chip */
+#define TMIO_MASK_INIT_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */
 #define TMIO_MASK_ALL           0x837f031d
 #define TMIO_MASK_READOP  (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
 #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
-- 
2.19.1

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

* Re: [PATCH v4 2/3] mmc: tmio: fix reset operation
  2018-11-26 17:02 ` [PATCH v4 2/3] mmc: tmio: fix reset operation Niklas Söderlund
@ 2018-11-28 13:21   ` Simon Horman
  2018-11-30 11:33   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Horman @ 2018-11-28 13:21 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc, linux-renesas-soc

On Mon, Nov 26, 2018 at 06:02:46PM +0100, Niklas Söderlund wrote:
> SD / MMC did not operate properly when suspend transition failed.
> Because the SCC was not reset at resume, issue of the command failed.
> Call the host specific reset function and reset the hardware in order to
> add reset of SCC. This change also fixes tuning on some stubborn cards
> on Gen2.
> 
> Based on work from Masaharu Hayakawa.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

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

* Re: [PATCH v4 2/3] mmc: tmio: fix reset operation
  2018-11-26 17:02 ` [PATCH v4 2/3] mmc: tmio: fix reset operation Niklas Söderlund
  2018-11-28 13:21   ` Simon Horman
@ 2018-11-30 11:33   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2018-11-30 11:33 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

On Mon, Nov 26, 2018 at 06:02:46PM +0100, Niklas Söderlund wrote:
> SD / MMC did not operate properly when suspend transition failed.
> Because the SCC was not reset at resume, issue of the command failed.
> Call the host specific reset function and reset the hardware in order to
> add reset of SCC. This change also fixes tuning on some stubborn cards
> on Gen2.
> 
> Based on work from Masaharu Hayakawa.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Tested on M3-N and H3 ES2.0. eMMC cards were succesfully probed and
transfer speeds were satisfying.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v4 0/3] mmc: tmio: fix reset operation
  2018-11-26 17:02 [PATCH v4 0/3] mmc: tmio: fix reset operation Niklas Söderlund
                   ` (2 preceding siblings ...)
  2018-11-26 17:02 ` [PATCH v4 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
@ 2018-12-05 14:23 ` Ulf Hansson
  3 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2018-12-05 14:23 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, linux-mmc, Linux-Renesas

On Mon, 26 Nov 2018 at 18:03, Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
>
> Hi,
>
> While looking at the Renesas BSP kernel I found patches which improves
> the state of the hardware at probe and after runtime resume.
>
> Patch 1/3 make sure the module clock is enabled after resuming before
> register are accessed. Patch 2/3 is the real change in this series and
> brings in reset of the vendor specific callback when resetting (SCC in
> the Renesas case). While 3/3 simply make sure that the IRQ mask for
> Renesas boards (Gen2 and later) are in a good shape after probe (and
> reset).
>
> In addition to addressing the state after resuming it helped unbreak a
> SD card I have which are very problematic on Koelsch. Without this
> series inserting the card results in:
>
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> sh_mobile_sdhi ee100000.sd: Tuning procedure failed
> mmc0: tuning execution failed: -5
> mmc0: error -5 whilst initialising SD card
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
>
> While with this series applied (patch 2/3):
>
> sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
> mmc0: new ultra high speed SDR50 SDHC card at address aaaa
> mmcblk0: mmc0:aaaa SU04G 3.69 GiB
>  mmcblk0: p1 p2
>
> Patch 1/3 was previously part of 2/3 but as it deals with a unrelated
> issue it's here broken out to a separate patch. Patch 3/3 have once been
> posted outside this series bit after comments from Wolfram it's brought
> back as it now deepens on 2/3.
>
> Most changes in this series are based on similar work from Masaharu
> Hayakawa but for this version all changes now differ quiet a lot from
> his work.  All mails sent to him bounce with a "Undelivered Mail
> Returned to Sender" error. I therefor felt the need to claim authorship
> as I don't want to post blame of my (potential) mistakes on some else.
>
> Niklas Söderlund (3):
>   mmc: tmio: enable module clock before resetting when resuming
>   mmc: tmio: fix reset operation
>   mmc: renesas_sdhi: add initial setting of interrupt mask register
>
>  drivers/mmc/host/renesas_sdhi_core.c |  4 ++++
>  drivers/mmc/host/tmio_mmc.h          |  1 +
>  drivers/mmc/host/tmio_mmc_core.c     | 27 +++++++++++++++------------
>  3 files changed, 20 insertions(+), 12 deletions(-)
>
> --
> 2.19.1
>

Applied for next, thanks!

Kind regards
Uffe

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

end of thread, other threads:[~2018-12-05 14:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 17:02 [PATCH v4 0/3] mmc: tmio: fix reset operation Niklas Söderlund
2018-11-26 17:02 ` [PATCH v4 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
2018-11-26 17:02 ` [PATCH v4 2/3] mmc: tmio: fix reset operation Niklas Söderlund
2018-11-28 13:21   ` Simon Horman
2018-11-30 11:33   ` Wolfram Sang
2018-11-26 17:02 ` [PATCH v4 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
2018-12-05 14:23 ` [PATCH v4 0/3] mmc: tmio: fix reset operation Ulf Hansson

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.