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

From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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     | 26 +++++++++++++++-----------
 3 files changed, 20 insertions(+), 11 deletions(-)

-- 
2.19.1

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

* [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming
  2018-10-31 23:05 [PATCH v3 0/3] mmc: tmio: fix reset operation Niklas Söderlund
@ 2018-10-31 23:05 ` Niklas Söderlund
  2018-11-01 19:01   ` Wolfram Sang
                     ` (2 more replies)
  2018-10-31 23:05 ` [PATCH v3 2/3] mmc: tmio: fix reset operation Niklas Söderlund
                   ` (4 subsequent siblings)
  5 siblings, 3 replies; 19+ messages in thread
From: Niklas Söderlund @ 2018-10-31 23:05 UTC (permalink / raw)
  To: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund

From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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>
---
 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 8d64f6196f33e882..953562a12a0d6ebc 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1328,8 +1328,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] 19+ messages in thread

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

From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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.
---
 drivers/mmc/host/tmio_mmc_core.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 953562a12a0d6ebc..662161be03b6d52e 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,7 +221,7 @@ 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;
@@ -696,14 +708,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);
@@ -1228,7 +1232,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);
@@ -1329,7 +1333,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] 19+ messages in thread

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

From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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>

---

* 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 d3ac43c3d0b655dc..f2162f2b7de3ae05 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -532,6 +532,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] 19+ messages in thread

* Re: [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming
  2018-10-31 23:05 ` [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
@ 2018-11-01 19:01   ` Wolfram Sang
  2018-11-02  6:51   ` Masahiro Yamada
  2018-11-02 11:58   ` Simon Horman
  2 siblings, 0 replies; 19+ messages in thread
From: Wolfram Sang @ 2018-11-01 19:01 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

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

On Thu, Nov 01, 2018 at 12:05:52AM +0100, Niklas Söderlund wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> 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>

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


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

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

* Re: [PATCH v3 2/3] mmc: tmio: fix reset operation
  2018-10-31 23:05 ` [PATCH v3 2/3] mmc: tmio: fix reset operation Niklas Söderlund
@ 2018-11-01 19:02   ` Wolfram Sang
  2018-11-02  6:54   ` Masahiro Yamada
  1 sibling, 0 replies; 19+ messages in thread
From: Wolfram Sang @ 2018-11-01 19:02 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

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

On Thu, Nov 01, 2018 at 12:05:53AM +0100, Niklas Söderlund wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> 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: Wolfram Sang <wsa+renesas@sang-engineering.com>


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

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

* Re: [PATCH v3 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register
  2018-10-31 23:05 ` [PATCH v3 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
@ 2018-11-01 19:02   ` Wolfram Sang
  2018-11-02 12:02   ` Simon Horman
  1 sibling, 0 replies; 19+ messages in thread
From: Wolfram Sang @ 2018-11-01 19:02 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

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

On Thu, Nov 01, 2018 at 12:05:54AM +0100, Niklas Söderlund wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> 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>
> 

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


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

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-10-31 23:05 [PATCH v3 0/3] mmc: tmio: fix reset operation Niklas Söderlund
                   ` (2 preceding siblings ...)
  2018-10-31 23:05 ` [PATCH v3 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
@ 2018-11-01 19:04 ` Wolfram Sang
  2018-11-01 19:35 ` Wolfram Sang
  2018-11-19 12:08 ` Ulf Hansson
  5 siblings, 0 replies; 19+ messages in thread
From: Wolfram Sang @ 2018-11-01 19:04 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

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


So, we agreed on this series during our Renesas SDHI hackathon.
Comments / testing from Yamada-san would be very welcome because we
really don't want to cause regressions on his hardware.


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

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-10-31 23:05 [PATCH v3 0/3] mmc: tmio: fix reset operation Niklas Söderlund
                   ` (3 preceding siblings ...)
  2018-11-01 19:04 ` [PATCH v3 0/3] mmc: tmio: fix reset operation Wolfram Sang
@ 2018-11-01 19:35 ` Wolfram Sang
  2018-11-19 12:08 ` Ulf Hansson
  5 siblings, 0 replies; 19+ messages in thread
From: Wolfram Sang @ 2018-11-01 19:35 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

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


All patches tested on M3N, H2, and E2.

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] 19+ messages in thread

* Re: [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming
  2018-10-31 23:05 ` [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
  2018-11-01 19:01   ` Wolfram Sang
@ 2018-11-02  6:51   ` Masahiro Yamada
  2018-11-02 11:58   ` Simon Horman
  2 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2018-11-02  6:51 UTC (permalink / raw)
  To: niklas.soderlund
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, Linux-Renesas,
	Niklas Söderlund

On Thu, Nov 1, 2018 at 8:52 AM Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
>
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> 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>


Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>




> ---
>  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 8d64f6196f33e882..953562a12a0d6ebc 100644
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -1328,8 +1328,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
>


--
Best Regards
Masahiro Yamada

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

* Re: [PATCH v3 2/3] mmc: tmio: fix reset operation
  2018-10-31 23:05 ` [PATCH v3 2/3] mmc: tmio: fix reset operation Niklas Söderlund
  2018-11-01 19:02   ` Wolfram Sang
@ 2018-11-02  6:54   ` Masahiro Yamada
  2018-11-26 16:53     ` Niklas Söderlund
  1 sibling, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2018-11-02  6:54 UTC (permalink / raw)
  To: niklas.soderlund
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, Linux-Renesas,
	Niklas Söderlund

On Thu, Nov 1, 2018 at 8:53 AM Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
>
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> 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.
> ---
>  drivers/mmc/host/tmio_mmc_core.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
> index 953562a12a0d6ebc..662161be03b6d52e 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,7 +221,7 @@ 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;



I see tmio_mmc_abort_dma() a few lines below.

If you add tmio_mmc_abort_dma() into tmio_mmc_hw_reset(),
you do not need to abort DMA twice, don't you?




        tmio_mmc_hw_reset(host->mmc);

        /* Ready for new calls */
        host->mrq = NULL;

        tmio_mmc_abort_dma(host);              /* <-- abort DMA again? */
        mmc_request_done(host->mmc, mrq);
}







> @@ -696,14 +708,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);
> @@ -1228,7 +1232,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);


I think it is weird to call tmio_mmc_abort_dma()
before tmio_mmc_request_dma().





>         _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
>         tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
> @@ -1329,7 +1333,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
>


--
Best Regards
Masahiro Yamada

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

* Re: [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming
  2018-10-31 23:05 ` [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
  2018-11-01 19:01   ` Wolfram Sang
  2018-11-02  6:51   ` Masahiro Yamada
@ 2018-11-02 11:58   ` Simon Horman
  2 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2018-11-02 11:58 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

On Thu, Nov 01, 2018 at 12:05:52AM +0100, Niklas Söderlund wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> 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>

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

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

* Re: [PATCH v3 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register
  2018-10-31 23:05 ` [PATCH v3 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
  2018-11-01 19:02   ` Wolfram Sang
@ 2018-11-02 12:02   ` Simon Horman
  1 sibling, 0 replies; 19+ messages in thread
From: Simon Horman @ 2018-11-02 12:02 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, Ulf Hansson, linux-mmc,
	linux-renesas-soc, Niklas Söderlund

On Thu, Nov 01, 2018 at 12:05:54AM +0100, Niklas Söderlund wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> 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>

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

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-10-31 23:05 [PATCH v3 0/3] mmc: tmio: fix reset operation Niklas Söderlund
                   ` (4 preceding siblings ...)
  2018-11-01 19:35 ` Wolfram Sang
@ 2018-11-19 12:08 ` Ulf Hansson
  2018-11-19 12:14   ` Wolfram Sang
  5 siblings, 1 reply; 19+ messages in thread
From: Ulf Hansson @ 2018-11-19 12:08 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Masahiro Yamada, linux-mmc, Linux-Renesas,
	Niklas Söderlund

On 1 November 2018 at 00:05, Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> 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     | 26 +++++++++++++++-----------
>  3 files changed, 20 insertions(+), 11 deletions(-)
>
> --
> 2.19.1
>

Applied for next, thanks!

I noticed there were a minor comment from Yamada-san, however I
decided to pick this as is and leave further improvements to be made
on top.

Kind regards
Uffe

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-11-19 12:08 ` Ulf Hansson
@ 2018-11-19 12:14   ` Wolfram Sang
  2018-11-19 13:08     ` Ulf Hansson
  0 siblings, 1 reply; 19+ messages in thread
From: Wolfram Sang @ 2018-11-19 12:14 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Niklas Söderlund, Wolfram Sang, Masahiro Yamada, linux-mmc,
	Linux-Renesas, Niklas Söderlund

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


> I noticed there were a minor comment from Yamada-san, however I
> decided to pick this as is and leave further improvements to be made
> on top.

Can I vote for waiting until Niklas comes back from Plumbers and have a
proper V2 applied instead? Makes backporting easier.


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

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-11-19 12:14   ` Wolfram Sang
@ 2018-11-19 13:08     ` Ulf Hansson
  2018-11-19 13:33       ` Wolfram Sang
  0 siblings, 1 reply; 19+ messages in thread
From: Ulf Hansson @ 2018-11-19 13:08 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Niklas Söderlund, Wolfram Sang, Masahiro Yamada, linux-mmc,
	Linux-Renesas, Niklas Söderlund

On 19 November 2018 at 13:14, Wolfram Sang <wsa@the-dreams.de> wrote:
>
>> I noticed there were a minor comment from Yamada-san, however I
>> decided to pick this as is and leave further improvements to be made
>> on top.
>
> Can I vote for waiting until Niklas comes back from Plumbers and have a
> proper V2 applied instead? Makes backporting easier.
>

Sure, no problem. I drop this and the other series then.

Kind regards
Uffe

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-11-19 13:08     ` Ulf Hansson
@ 2018-11-19 13:33       ` Wolfram Sang
  2018-11-19 17:28         ` Niklas Söderlund
  0 siblings, 1 reply; 19+ messages in thread
From: Wolfram Sang @ 2018-11-19 13:33 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Niklas Söderlund, Wolfram Sang, Masahiro Yamada, linux-mmc,
	Linux-Renesas, Niklas Söderlund

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


> Sure, no problem. I drop this and the other series then.

Thanks, Ulf!


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

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

* Re: [PATCH v3 0/3] mmc: tmio: fix reset operation
  2018-11-19 13:33       ` Wolfram Sang
@ 2018-11-19 17:28         ` Niklas Söderlund
  0 siblings, 0 replies; 19+ messages in thread
From: Niklas Söderlund @ 2018-11-19 17:28 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Wolfram Sang, Masahiro Yamada, linux-mmc, Linux-Renesas

Hi Ulf, Wolfram

On 2018-11-19 14:33:58 +0100, Wolfram Sang wrote:
> 
> > Sure, no problem. I drop this and the other series then.
> 
> Thanks, Ulf!
> 

Thanks for looking out for me here, I will fly home tomorrow so I hope 
to get a new versions of these series out late this week.

-- 
Regards,
Niklas S�derlund

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

* Re: [PATCH v3 2/3] mmc: tmio: fix reset operation
  2018-11-02  6:54   ` Masahiro Yamada
@ 2018-11-26 16:53     ` Niklas Söderlund
  0 siblings, 0 replies; 19+ messages in thread
From: Niklas Söderlund @ 2018-11-26 16:53 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Wolfram Sang, Ulf Hansson, linux-mmc, Linux-Renesas

Hi Yamada-san,

Thanks for your feedback.

On 2018-11-02 15:54:17 +0900, Masahiro Yamada wrote:
> On Thu, Nov 1, 2018 at 8:53 AM Niklas S�derlund
> <niklas.soderlund@ragnatech.se> wrote:
> >
> > From: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>
> >
> > 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.
> > ---
> >  drivers/mmc/host/tmio_mmc_core.c | 26 +++++++++++++++-----------
> >  1 file changed, 15 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
> > index 953562a12a0d6ebc..662161be03b6d52e 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,7 +221,7 @@ 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;
> 
> 
> 
> I see tmio_mmc_abort_dma() a few lines below.
> 
> If you add tmio_mmc_abort_dma() into tmio_mmc_hw_reset(),
> you do not need to abort DMA twice, don't you?
> 
> 
> 
> 
>         tmio_mmc_hw_reset(host->mmc);
> 
>         /* Ready for new calls */
>         host->mrq = NULL;
> 
>         tmio_mmc_abort_dma(host);              /* <-- abort DMA again? */
>         mmc_request_done(host->mmc, mrq);
> }
> 

You are correct with this change the call to tmio_mmc_abort_dma() can be 
dropped here. Will do so and send out a new version. Thanks for pointing 
this out!

> 
> > @@ -696,14 +708,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);
> > @@ -1228,7 +1232,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);
> 
> 
> I think it is weird to call tmio_mmc_abort_dma()
> before tmio_mmc_request_dma().
> 
> 
> 
> 
> 
> >         _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
> >         tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
> > @@ -1329,7 +1333,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
> >
> 
> 
> --
> Best Regards
> Masahiro Yamada

-- 
Regards,
Niklas S�derlund

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

end of thread, other threads:[~2018-11-27  3:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 23:05 [PATCH v3 0/3] mmc: tmio: fix reset operation Niklas Söderlund
2018-10-31 23:05 ` [PATCH v3 1/3] mmc: tmio: enable module clock before resetting when resuming Niklas Söderlund
2018-11-01 19:01   ` Wolfram Sang
2018-11-02  6:51   ` Masahiro Yamada
2018-11-02 11:58   ` Simon Horman
2018-10-31 23:05 ` [PATCH v3 2/3] mmc: tmio: fix reset operation Niklas Söderlund
2018-11-01 19:02   ` Wolfram Sang
2018-11-02  6:54   ` Masahiro Yamada
2018-11-26 16:53     ` Niklas Söderlund
2018-10-31 23:05 ` [PATCH v3 3/3] mmc: renesas_sdhi: add initial setting of interrupt mask register Niklas Söderlund
2018-11-01 19:02   ` Wolfram Sang
2018-11-02 12:02   ` Simon Horman
2018-11-01 19:04 ` [PATCH v3 0/3] mmc: tmio: fix reset operation Wolfram Sang
2018-11-01 19:35 ` Wolfram Sang
2018-11-19 12:08 ` Ulf Hansson
2018-11-19 12:14   ` Wolfram Sang
2018-11-19 13:08     ` Ulf Hansson
2018-11-19 13:33       ` Wolfram Sang
2018-11-19 17:28         ` Niklas Söderlund

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.