All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
@ 2021-10-06 17:16 Biju Das
  2021-10-19 10:42 ` Ulf Hansson
  2021-10-22 13:22 ` Wolfram Sang
  0 siblings, 2 replies; 10+ messages in thread
From: Biju Das @ 2021-10-06 17:16 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Biju Das, Wolfram Sang, Yoshihiro Shimoda, linux-mmc,
	Geert Uytterhoeven, Chris Paterson, Biju Das,
	Prabhakar Mahadev Lad, linux-renesas-soc


This patch fixes internal cd irq miss after hard reset by enabling
internal card insertion/removal interrupts.

Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Hi All,

On RZ/G2M board, if i enable internal cd, then it is missing irq after hard reset.
Please find my test logs with card inserted during boot,

case 1:- current case (no internal cd interrupt)
root@hihope-rzg2m:~# cat /proc/interrupts | grep mmc
162:          0          0          0          0          0          0     GIC-0 197 Level     ee100000.mmc
163:        151          0          0          0          0          0     GIC-0 199 Level     ee140000.mmc
164:       1500          0          0          0          0          0     GIC-0 200 Level     ee160000.mmc
root@hihope-rzg2m:~#


case 2:- current case + patch
root@hihope-rzg2m:~# cat /proc/interrupts | grep mmc
162:       1107          0          0          0          0          0     GIC-0 197 Level     ee100000.mmc
163:        151          0          0          0          0          0     GIC-0 199 Level     ee140000.mmc
164:       1106          0          0          0          0          0     GIC-0 200 Level     ee160000.mmc
root@hihope-rzg2m:~#

case 3:- with cd nterrupt as gpio
root@hihope-rzg2m:~# cat /proc/interrupts | grep mmc
162:        796          0          0          0          0          0     GIC-0 197 Level     ee100000.mmc
163:        151          0          0          0          0          0     GIC-0 199 Level     ee140000.mmc
164:       1010          0          0          0          0          0     GIC-0 200 Level     ee160000.mmc
197:          0          0          0          0          0          0  gpio-rcar  12 Edge      ee100000.mmc cd
root@hihope-rzg2m:~# 
---
 drivers/mmc/host/renesas_sdhi.h      | 1 +
 drivers/mmc/host/renesas_sdhi_core.c | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index 0c45e82ff0de..1199693690da 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -68,6 +68,7 @@ struct renesas_sdhi {
 	u32 scc_tappos_hs400;
 	const u8 *adjust_hs400_calib_table;
 	bool needs_adjust_hs400;
+	bool internal_cd;
 
 	/* Tuning values: 1 for success, 0 for failure */
 	DECLARE_BITMAP(taps, BITS_PER_LONG);
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index a4407f391f66..9d828094169a 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -561,6 +561,11 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host)
 		/* Unknown why but without polling reset status, it will hang */
 		read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100,
 				  false, priv->rstc);
+
+		if (priv->internal_cd)
+			tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_CARD_REMOVE |
+						 TMIO_STAT_CARD_INSERT);
+
 		/* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */
 		sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
 		priv->needs_adjust_hs400 = false;
@@ -1017,6 +1022,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 	if (IS_ERR(priv->rstc))
 		return PTR_ERR(priv->rstc);
 
+	if (priv->rstc && !(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
+	    !mmc_can_gpio_cd(host->mmc))
+		priv->internal_cd = true;
+
 	ver = sd_ctrl_read16(host, CTL_VERSION);
 	/* GEN2_SDR104 is first known SDHI to use 32bit block count */
 	if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX)
-- 
2.17.1


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

* Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-06 17:16 [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset Biju Das
@ 2021-10-19 10:42 ` Ulf Hansson
  2021-10-22 13:22 ` Wolfram Sang
  1 sibling, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-10-19 10:42 UTC (permalink / raw)
  To: Biju Das, Wolfram Sang
  Cc: Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven, Chris Paterson,
	Biju Das, Prabhakar Mahadev Lad, Linux-Renesas

On Wed, 6 Oct 2021 at 19:16, Biju Das <biju.das.jz@bp.renesas.com> wrote:
>
>
> This patch fixes internal cd irq miss after hard reset by enabling
> internal card insertion/removal interrupts.
>
> Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Wolfram, would you mind having a look at this?

Kind regards
Uffe

> ---
> Hi All,
>
> On RZ/G2M board, if i enable internal cd, then it is missing irq after hard reset.
> Please find my test logs with card inserted during boot,
>
> case 1:- current case (no internal cd interrupt)
> root@hihope-rzg2m:~# cat /proc/interrupts | grep mmc
> 162:          0          0          0          0          0          0     GIC-0 197 Level     ee100000.mmc
> 163:        151          0          0          0          0          0     GIC-0 199 Level     ee140000.mmc
> 164:       1500          0          0          0          0          0     GIC-0 200 Level     ee160000.mmc
> root@hihope-rzg2m:~#
>
>
> case 2:- current case + patch
> root@hihope-rzg2m:~# cat /proc/interrupts | grep mmc
> 162:       1107          0          0          0          0          0     GIC-0 197 Level     ee100000.mmc
> 163:        151          0          0          0          0          0     GIC-0 199 Level     ee140000.mmc
> 164:       1106          0          0          0          0          0     GIC-0 200 Level     ee160000.mmc
> root@hihope-rzg2m:~#
>
> case 3:- with cd nterrupt as gpio
> root@hihope-rzg2m:~# cat /proc/interrupts | grep mmc
> 162:        796          0          0          0          0          0     GIC-0 197 Level     ee100000.mmc
> 163:        151          0          0          0          0          0     GIC-0 199 Level     ee140000.mmc
> 164:       1010          0          0          0          0          0     GIC-0 200 Level     ee160000.mmc
> 197:          0          0          0          0          0          0  gpio-rcar  12 Edge      ee100000.mmc cd
> root@hihope-rzg2m:~#
> ---
>  drivers/mmc/host/renesas_sdhi.h      | 1 +
>  drivers/mmc/host/renesas_sdhi_core.c | 9 +++++++++
>  2 files changed, 10 insertions(+)
>
> diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
> index 0c45e82ff0de..1199693690da 100644
> --- a/drivers/mmc/host/renesas_sdhi.h
> +++ b/drivers/mmc/host/renesas_sdhi.h
> @@ -68,6 +68,7 @@ struct renesas_sdhi {
>         u32 scc_tappos_hs400;
>         const u8 *adjust_hs400_calib_table;
>         bool needs_adjust_hs400;
> +       bool internal_cd;
>
>         /* Tuning values: 1 for success, 0 for failure */
>         DECLARE_BITMAP(taps, BITS_PER_LONG);
> diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> index a4407f391f66..9d828094169a 100644
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -561,6 +561,11 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host)
>                 /* Unknown why but without polling reset status, it will hang */
>                 read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100,
>                                   false, priv->rstc);
> +
> +               if (priv->internal_cd)
> +                       tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_CARD_REMOVE |
> +                                                TMIO_STAT_CARD_INSERT);
> +
>                 /* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */
>                 sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
>                 priv->needs_adjust_hs400 = false;
> @@ -1017,6 +1022,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
>         if (IS_ERR(priv->rstc))
>                 return PTR_ERR(priv->rstc);
>
> +       if (priv->rstc && !(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
> +           !mmc_can_gpio_cd(host->mmc))
> +               priv->internal_cd = true;
> +
>         ver = sd_ctrl_read16(host, CTL_VERSION);
>         /* GEN2_SDR104 is first known SDHI to use 32bit block count */
>         if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX)
> --
> 2.17.1
>

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

* Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-06 17:16 [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset Biju Das
  2021-10-19 10:42 ` Ulf Hansson
@ 2021-10-22 13:22 ` Wolfram Sang
  2021-10-22 13:26   ` Biju Das
  2021-10-22 16:01   ` Biju Das
  1 sibling, 2 replies; 10+ messages in thread
From: Wolfram Sang @ 2021-10-22 13:22 UTC (permalink / raw)
  To: Biju Das
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

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

On Wed, Oct 06, 2021 at 06:16:05PM +0100, Biju Das wrote:
> 
> This patch fixes internal cd irq miss after hard reset by enabling
> internal card insertion/removal interrupts.
> 
> Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

IIUC, the following should be the apropriate fix. Can you please test
it? If it works, then I'll make a proper patch out of it.

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 7dfc26f48c18..9416245a7b56 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -195,6 +195,10 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask_all);
 	host->sdcard_irq_mask = host->sdcard_irq_mask_all;
 
+	if (host->native_hotplug)
+		tmio_mmc_enable_mmc_irqs(host,
+				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
+
 	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
 
 	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
@@ -1185,10 +1189,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 	_host->set_clock(_host, 0);
 	tmio_mmc_reset(_host);
 
-	if (_host->native_hotplug)
-		tmio_mmc_enable_mmc_irqs(_host,
-				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
-
 	spin_lock_init(&_host->lock);
 	mutex_init(&_host->ios_lock);
 


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

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

* RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-22 13:22 ` Wolfram Sang
@ 2021-10-22 13:26   ` Biju Das
  2021-10-22 16:01   ` Biju Das
  1 sibling, 0 replies; 10+ messages in thread
From: Biju Das @ 2021-10-22 13:26 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

Hi Wolfram,

Thanks for the patch.

> -----Original Message-----
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Sent: 22 October 2021 14:22
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>; Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com>; linux-mmc@vger.kernel.org; Geert
> Uytterhoeven <geert+renesas@glider.be>; Chris Paterson
> <Chris.Paterson2@renesas.com>; Biju Das <biju.das@bp.renesas.com>;
> Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>; linux-
> renesas-soc@vger.kernel.org
> Subject: Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard
> reset
> 
> On Wed, Oct 06, 2021 at 06:16:05PM +0100, Biju Das wrote:
> >
> > This patch fixes internal cd irq miss after hard reset by enabling
> > internal card insertion/removal interrupts.
> >
> > Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> IIUC, the following should be the apropriate fix. Can you please test it?
> If it works, then I'll make a proper patch out of it.

It is much better. I will test and let you know the results.

Regards,
Biju

> 
> diff --git a/drivers/mmc/host/tmio_mmc_core.c
> b/drivers/mmc/host/tmio_mmc_core.c
> index 7dfc26f48c18..9416245a7b56 100644
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -195,6 +195,10 @@ static void tmio_mmc_reset(struct tmio_mmc_host
> *host)
>  	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host-
> >sdcard_irq_mask_all);
>  	host->sdcard_irq_mask = host->sdcard_irq_mask_all;
> 
> +	if (host->native_hotplug)
> +		tmio_mmc_enable_mmc_irqs(host,
> +				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> +
>  	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
> 
>  	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { @@ -1185,10 +1189,6 @@
> int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
>  	_host->set_clock(_host, 0);
>  	tmio_mmc_reset(_host);
> 
> -	if (_host->native_hotplug)
> -		tmio_mmc_enable_mmc_irqs(_host,
> -				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> -
>  	spin_lock_init(&_host->lock);
>  	mutex_init(&_host->ios_lock);
> 


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

* RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-22 13:22 ` Wolfram Sang
  2021-10-22 13:26   ` Biju Das
@ 2021-10-22 16:01   ` Biju Das
  2021-10-22 16:05     ` Biju Das
  1 sibling, 1 reply; 10+ messages in thread
From: Biju Das @ 2021-10-22 16:01 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

Hi Wolfram,

> Subject: Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard
> reset
> 
> On Wed, Oct 06, 2021 at 06:16:05PM +0100, Biju Das wrote:
> >
> > This patch fixes internal cd irq miss after hard reset by enabling
> > internal card insertion/removal interrupts.
> >
> > Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> IIUC, the following should be the apropriate fix. Can you please test it?
> If it works, then I'll make a proper patch out of it.

I have tested and it doesn't work. This addresses issue from tmio_mmc_reset call
from tmio_mmc_core.

But  tmio_mmc_reset is called from multiple places in renesas sdhi core driver. 
I guess that could be the reason this patch didn't work.

Regards,
Biju

> 
> diff --git a/drivers/mmc/host/tmio_mmc_core.c
> b/drivers/mmc/host/tmio_mmc_core.c
> index 7dfc26f48c18..9416245a7b56 100644
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -195,6 +195,10 @@ static void tmio_mmc_reset(struct tmio_mmc_host
> *host)
>  	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host-
> >sdcard_irq_mask_all);
>  	host->sdcard_irq_mask = host->sdcard_irq_mask_all;
> 
> +	if (host->native_hotplug)
> +		tmio_mmc_enable_mmc_irqs(host,
> +				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> +
>  	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
> 
>  	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { @@ -1185,10 +1189,6 @@
> int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
>  	_host->set_clock(_host, 0);
>  	tmio_mmc_reset(_host);
> 
> -	if (_host->native_hotplug)
> -		tmio_mmc_enable_mmc_irqs(_host,
> -				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> -
>  	spin_lock_init(&_host->lock);
>  	mutex_init(&_host->ios_lock);
> 


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

* RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-22 16:01   ` Biju Das
@ 2021-10-22 16:05     ` Biju Das
  2021-10-23  7:38       ` Biju Das
  0 siblings, 1 reply; 10+ messages in thread
From: Biju Das @ 2021-10-22 16:05 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

Hi Wolfram,

> Subject: RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard
> reset
> 
> Hi Wolfram,
> 
> > Subject: Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with
> > hard reset
> >
> > On Wed, Oct 06, 2021 at 06:16:05PM +0100, Biju Das wrote:
> > >
> > > This patch fixes internal cd irq miss after hard reset by enabling
> > > internal card insertion/removal interrupts.
> > >
> > > Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if possible")
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > IIUC, the following should be the apropriate fix. Can you please test
> it?
> > If it works, then I'll make a proper patch out of it.
> 
> I have tested and it doesn't work. This addresses issue from
> tmio_mmc_reset call from tmio_mmc_core.
> 

Just to add, It could be related to timing issue, with your patch, if I put some print message,
It works.

Regards,
Biju

> 
> Regards,
> Biju
> 
> >
> > diff --git a/drivers/mmc/host/tmio_mmc_core.c
> > b/drivers/mmc/host/tmio_mmc_core.c
> > index 7dfc26f48c18..9416245a7b56 100644
> > --- a/drivers/mmc/host/tmio_mmc_core.c
> > +++ b/drivers/mmc/host/tmio_mmc_core.c
> > @@ -195,6 +195,10 @@ static void tmio_mmc_reset(struct tmio_mmc_host
> > *host)
> >  	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host-
> > >sdcard_irq_mask_all);
> >  	host->sdcard_irq_mask = host->sdcard_irq_mask_all;
> >
> > +	if (host->native_hotplug)
> > +		tmio_mmc_enable_mmc_irqs(host,
> > +				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> > +
> >  	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
> >
> >  	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { @@ -1185,10 +1189,6 @@
> > int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
> >  	_host->set_clock(_host, 0);
> >  	tmio_mmc_reset(_host);
> >
> > -	if (_host->native_hotplug)
> > -		tmio_mmc_enable_mmc_irqs(_host,
> > -				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> > -
> >  	spin_lock_init(&_host->lock);
> >  	mutex_init(&_host->ios_lock);
> >


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

* RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-22 16:05     ` Biju Das
@ 2021-10-23  7:38       ` Biju Das
  2021-10-28 19:45         ` Wolfram Sang
  0 siblings, 1 reply; 10+ messages in thread
From: Biju Das @ 2021-10-23  7:38 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

Hi Wolfram,

> Subject: RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard
> reset
> 
> Hi Wolfram,
> 
> > Subject: RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with
> > hard reset
> >
> > Hi Wolfram,
> >
> > > Subject: Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss
> > > with hard reset
> > >
> > > On Wed, Oct 06, 2021 at 06:16:05PM +0100, Biju Das wrote:
> > > >
> > > > This patch fixes internal cd irq miss after hard reset by enabling
> > > > internal card insertion/removal interrupts.
> > > >
> > > > Fixes: b4d86f37eacb ("mmc: renesas_sdhi: do hard reset if
> > > > possible")
> > > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > >
> > > IIUC, the following should be the apropriate fix. Can you please
> > > test
> > it?
> > > If it works, then I'll make a proper patch out of it.
> >
> > I have tested and it doesn't work. This addresses issue from
> > tmio_mmc_reset call from tmio_mmc_core.
> >
> 
> Just to add, It could be related to timing issue, with your patch, if I
> put some print message, It works.

Finally found the issue. There is one more patch for host->reset in tmio_mmc_core.c. please see below.
If you add this code, then it works.

Can you please add this as well in your proper patch?

@ -958,6 +963,11 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                /* For R-Car Gen2+, we need to reset SDHI specific SCC */
                if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
                        host->reset(host);
+
+               if (host->native_hotplug)
+                       tmio_mmc_enable_mmc_irqs(host,
+                               TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
+

Regards,
Biju

> >
> > >
> > > diff --git a/drivers/mmc/host/tmio_mmc_core.c
> > > b/drivers/mmc/host/tmio_mmc_core.c
> > > index 7dfc26f48c18..9416245a7b56 100644
> > > --- a/drivers/mmc/host/tmio_mmc_core.c
> > > +++ b/drivers/mmc/host/tmio_mmc_core.c
> > > @@ -195,6 +195,10 @@ static void tmio_mmc_reset(struct tmio_mmc_host
> > > *host)
> > >  	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host-
> > > >sdcard_irq_mask_all);
> > >  	host->sdcard_irq_mask = host->sdcard_irq_mask_all;
> > >
> > > +	if (host->native_hotplug)
> > > +		tmio_mmc_enable_mmc_irqs(host,
> > > +				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> > > +
> > >  	tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
> > >
> > >  	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { @@ -1185,10 +1189,6
> > > @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
> > >  	_host->set_clock(_host, 0);
> > >  	tmio_mmc_reset(_host);
> > >
> > > -	if (_host->native_hotplug)
> > > -		tmio_mmc_enable_mmc_irqs(_host,
> > > -				TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
> > > -
> > >  	spin_lock_init(&_host->lock);
> > >  	mutex_init(&_host->ios_lock);
> > >


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

* Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-23  7:38       ` Biju Das
@ 2021-10-28 19:45         ` Wolfram Sang
  2021-10-29  6:55           ` Biju Das
  0 siblings, 1 reply; 10+ messages in thread
From: Wolfram Sang @ 2021-10-28 19:45 UTC (permalink / raw)
  To: Biju Das
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

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

Hi Biju,

> Finally found the issue. There is one more patch for host->reset in tmio_mmc_core.c. please see below.
> If you add this code, then it works.

Thanks for finding the culprit! To get this hopefully into v5.15 still,
I will simply add this chunk like you suggested. However, I really
wonder if we shouldn't just replace this:

>                 /* For R-Car Gen2+, we need to reset SDHI specific SCC */
>                 if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
>                         host->reset(host);
>  
>                 if (host->native_hotplug)
>                         tmio_mmc_enable_mmc_irqs(host,
>                                 TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
>  

with a simple call to

	tmio_mmc_reset(host)

(with tmio_mmc_reset() still updated to set the card interrupts, of
course)? I have to admit I haven't checked all paths for side-effects
yet, but maybe you can already test if this change also works (instead
of adding the second chunk)? If so, we could change it incrementally for
5.16.

Anyhow, will send the patch for 5.15 in some minutes.

Thanks and all the best,

   Wolfram


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

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

* RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-28 19:45         ` Wolfram Sang
@ 2021-10-29  6:55           ` Biju Das
  2021-11-02 15:28             ` Biju Das
  0 siblings, 1 reply; 10+ messages in thread
From: Biju Das @ 2021-10-29  6:55 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

Hi Wolfram,

Thanks for the feedback.

> Subject: Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard
> reset
> 
> Hi Biju,
> 
> > Finally found the issue. There is one more patch for host->reset in
> tmio_mmc_core.c. please see below.
> > If you add this code, then it works.
> 
> Thanks for finding the culprit! To get this hopefully into v5.15 still, I
> will simply add this chunk like you suggested. However, I really wonder if
> we shouldn't just replace this:
> 
> >                 /* For R-Car Gen2+, we need to reset SDHI specific SCC
> */
> >                 if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
> >                         host->reset(host);
> >
> >                 if (host->native_hotplug)
> >                         tmio_mmc_enable_mmc_irqs(host,
> >                                 TMIO_STAT_CARD_REMOVE |
> > TMIO_STAT_CARD_INSERT);
> >
> 
> with a simple call to
> 
> 	tmio_mmc_reset(host)
> 
> (with tmio_mmc_reset() still updated to set the card interrupts, of
> course)? I have to admit I haven't checked all paths for side-effects yet,
> but maybe you can already test if this change also works (instead of
> adding the second chunk)? If so, we could change it incrementally for
> 5.16.

Agreed. Will test and provide you feedback.

Regards,
Biju

> 
> Anyhow, will send the patch for 5.15 in some minutes.
> 
> Thanks and all the best,
> 
>    Wolfram


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

* RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset
  2021-10-29  6:55           ` Biju Das
@ 2021-11-02 15:28             ` Biju Das
  0 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2021-11-02 15:28 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Yoshihiro Shimoda, linux-mmc, Geert Uytterhoeven,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad,
	linux-renesas-soc

Hi Wolfram,

> Subject: RE: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard
> reset
> 
> Hi Wolfram,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with
> > hard reset
> >
> > Hi Biju,
> >
> > > Finally found the issue. There is one more patch for host->reset in
> > tmio_mmc_core.c. please see below.
> > > If you add this code, then it works.
> >
> > Thanks for finding the culprit! To get this hopefully into v5.15
> > still, I will simply add this chunk like you suggested. However, I
> > really wonder if we shouldn't just replace this:
> >
> > >                 /* For R-Car Gen2+, we need to reset SDHI specific
> > > SCC
> > */
> > >                 if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
> > >                         host->reset(host);
> > >
> > >                 if (host->native_hotplug)
> > >                         tmio_mmc_enable_mmc_irqs(host,
> > >                                 TMIO_STAT_CARD_REMOVE |
> > > TMIO_STAT_CARD_INSERT);
> > >
> >
> > with a simple call to
> >
> > 	tmio_mmc_reset(host)
> >
> > (with tmio_mmc_reset() still updated to set the card interrupts, of
> > course)? I have to admit I haven't checked all paths for side-effects
> > yet, but maybe you can already test if this change also works (instead
> > of adding the second chunk)? If so, we could change it incrementally
> > for 5.16.
> 
> Agreed. Will test and provide you feedback.

I have tested and it works ok on RZ/G2L platform. 

Looking at the code, further optimization is possible. Can you please check below and
If it is ok, please add to the new patch for 5.16.

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index e2affa52ef46..e8add010bd7d 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -960,14 +960,8 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        case MMC_POWER_OFF:
                tmio_mmc_power_off(host);
                /* For R-Car Gen2+, we need to reset SDHI specific SCC */
-               if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) {
-                       host->reset(host);
-
-                       if (host->native_hotplug)
-                               tmio_mmc_enable_mmc_irqs(host,
-                                               TMIO_STAT_CARD_REMOVE |
-                                               TMIO_STAT_CARD_INSERT);
-               }
+               if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
+                       tmio_mmc_reset(host);
 
                host->set_clock(host, 0);
                break;
@@ -1295,10 +1289,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
        if (host->clk_cache)
                host->set_clock(host, host->clk_cache);
 
-       if (host->native_hotplug)
-               tmio_mmc_enable_mmc_irqs(host,
-                               TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
-
        tmio_mmc_enable_dma(host, true);
 
        return 0;

Regards,
Biju

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

end of thread, other threads:[~2021-11-02 15:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 17:16 [PATCH] mmc: renesas_sdhi: Fix internal cd irq miss with hard reset Biju Das
2021-10-19 10:42 ` Ulf Hansson
2021-10-22 13:22 ` Wolfram Sang
2021-10-22 13:26   ` Biju Das
2021-10-22 16:01   ` Biju Das
2021-10-22 16:05     ` Biju Das
2021-10-23  7:38       ` Biju Das
2021-10-28 19:45         ` Wolfram Sang
2021-10-29  6:55           ` Biju Das
2021-11-02 15:28             ` Biju Das

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.