diff mbox series

[RFT] mmc: renesas_sdhi: register irqs before registering controller

Message ID 20230710140825.47793-1-wsa+renesas@sang-engineering.com
State New
Headers show
Series [RFT] mmc: renesas_sdhi: register irqs before registering controller | expand

Commit Message

Wolfram Sang July 10, 2023, 2:08 p.m. UTC
IRQs should be ready to serve when we call mmc_add_host() via
tmio_mmc_host_probe(). To achieve that, ensure that all irqs are masked
before registering the handlers.

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

Based on 6.5-rc1 with bf54dec9e953 ("Revert "mmc: Revert "mmc: core:
Allow mmc_start_host() synchronously detect a card") reverted. That base
alone shows the regression. This patch works fine on a Salvator-X with a
M3-W. I'll test more boards. Yet, I send it out so people can tests with
boards I don't have.

 drivers/mmc/host/renesas_sdhi_core.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Biju Das July 10, 2023, 2:35 p.m. UTC | #1
Hi Wolfram Sang,

Thanks for the patch.

> -----Original Message-----
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Sent: Monday, July 10, 2023 3:08 PM
> To: linux-renesas-soc@vger.kernel.org; linux-mmc@vger.kernel.org
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>; Ulf Hansson
> <ulf.hansson@linaro.org>; linux-kernel@vger.kernel.org
> Subject: [PATCH RFT] mmc: renesas_sdhi: register irqs before registering
> controller
> 
> IRQs should be ready to serve when we call mmc_add_host() via
> tmio_mmc_host_probe(). To achieve that, ensure that all irqs are masked
> before registering the handlers.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> 
> Based on 6.5-rc1 with bf54dec9e953 ("Revert "mmc: Revert "mmc: core:
> Allow mmc_start_host() synchronously detect a card") reverted. That base
> alone shows the regression. This patch works fine on a Salvator-X with a
> M3-W. I'll test more boards. Yet, I send it out so people can tests with
> boards I don't have.

Tested on RZ/V2L SMARC EVK, after Revert "mmc: Revert "mmc: core: Allow mmc_start_host() synchronously detect a card""

Cheers,
Biju

> 
>  drivers/mmc/host/renesas_sdhi_core.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/renesas_sdhi_core.c
> b/drivers/mmc/host/renesas_sdhi_core.c
> index 345934e4f59e..499d043f034f 100644
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -1004,10 +1004,11 @@ int renesas_sdhi_probe(struct platform_device
> *pdev,
>  		host->ops.start_signal_voltage_switch =
>  			renesas_sdhi_start_signal_voltage_switch;
>  		host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
> -		host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2;
>  		host->reset = renesas_sdhi_reset;
>  	}
> 
> +	host->sdcard_irq_mask_all = TMIO_MMC_MIN_RCAR2 ?
> TMIO_MASK_ALL_RCAR2 :
> +TMIO_MASK_ALL;
> +
>  	/* Orginally registers were 16 bit apart, could be 32 or 64
> nowadays */
>  	if (!host->bus_shift && resource_size(res) > 0x100) /* old way to
> determine the shift */
>  		host->bus_shift = 1;
> @@ -1100,9 +1101,7 @@ int renesas_sdhi_probe(struct platform_device
> *pdev,
>  		host->ops.hs400_complete = renesas_sdhi_hs400_complete;
>  	}
> 
> -	ret = tmio_mmc_host_probe(host);
> -	if (ret < 0)
> -		goto edisclk;
> +	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK,
> +host->sdcard_irq_mask_all);
> 
>  	num_irqs = platform_irq_count(pdev);
>  	if (num_irqs < 0) {
> @@ -1129,6 +1128,10 @@ int renesas_sdhi_probe(struct platform_device
> *pdev,
>  			goto eirq;
>  	}
> 
> +	ret = tmio_mmc_host_probe(host);
> +	if (ret < 0)
> +		goto edisclk;
> +
>  	dev_info(&pdev->dev, "%s base at %pa, max clock rate %u MHz\n",
>  		 mmc_hostname(host->mmc), &res->start, host->mmc->f_max /
> 1000000);
> 
> --
> 2.35.1
Geert Uytterhoeven July 10, 2023, 2:54 p.m. UTC | #2
Hi Wolfram,

On Mon, Jul 10, 2023 at 4:10 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> IRQs should be ready to serve when we call mmc_add_host() via
> tmio_mmc_host_probe(). To achieve that, ensure that all irqs are masked
> before registering the handlers.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks for your patch!

> Based on 6.5-rc1 with bf54dec9e953 ("Revert "mmc: Revert "mmc: core:
> Allow mmc_start_host() synchronously detect a card") reverted. That base
> alone shows the regression. This patch works fine on a Salvator-X with a
> M3-W. I'll test more boards. Yet, I send it out so people can tests with
> boards I don't have.

I guess bf54dec9e953 is your local commit that reverts commit
fa700d73494abbd3 ("mmc: Revert "mmc: core: Allow mmc_start_host()
synchronously detect a card"") in v6.5-rc1?

> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -1004,10 +1004,11 @@ int renesas_sdhi_probe(struct platform_device *pdev,
>                 host->ops.start_signal_voltage_switch =
>                         renesas_sdhi_start_signal_voltage_switch;
>                 host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
> -               host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2;
>                 host->reset = renesas_sdhi_reset;
>         }
>
> +       host->sdcard_irq_mask_all = TMIO_MMC_MIN_RCAR2 ? TMIO_MASK_ALL_RCAR2 : TMIO_MASK_ALL;

The condition above is always true. I assume you wanted to test
"mmc_data->flags & TMIO_MMC_MIN_RCAR2" instead?

> +
>         /* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */
>         if (!host->bus_shift && resource_size(res) > 0x100) /* old way to determine the shift */
>                 host->bus_shift = 1;

Gr{oetje,eeting}s,

                        Geert
Wolfram Sang July 12, 2023, 12:26 p.m. UTC | #3
> No issues seen after reverting fa700d73494abbd3 and applying your patch
> (plus the fix below) on top of today's renesas-drivers release.

Thanks! I would have fixed it differently but I agree this is probably
the best version when backporting is also considered.
diff mbox series

Patch

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 345934e4f59e..499d043f034f 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -1004,10 +1004,11 @@  int renesas_sdhi_probe(struct platform_device *pdev,
 		host->ops.start_signal_voltage_switch =
 			renesas_sdhi_start_signal_voltage_switch;
 		host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
-		host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2;
 		host->reset = renesas_sdhi_reset;
 	}
 
+	host->sdcard_irq_mask_all = TMIO_MMC_MIN_RCAR2 ? TMIO_MASK_ALL_RCAR2 : TMIO_MASK_ALL;
+
 	/* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */
 	if (!host->bus_shift && resource_size(res) > 0x100) /* old way to determine the shift */
 		host->bus_shift = 1;
@@ -1100,9 +1101,7 @@  int renesas_sdhi_probe(struct platform_device *pdev,
 		host->ops.hs400_complete = renesas_sdhi_hs400_complete;
 	}
 
-	ret = tmio_mmc_host_probe(host);
-	if (ret < 0)
-		goto edisclk;
+	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask_all);
 
 	num_irqs = platform_irq_count(pdev);
 	if (num_irqs < 0) {
@@ -1129,6 +1128,10 @@  int renesas_sdhi_probe(struct platform_device *pdev,
 			goto eirq;
 	}
 
+	ret = tmio_mmc_host_probe(host);
+	if (ret < 0)
+		goto edisclk;
+
 	dev_info(&pdev->dev, "%s base at %pa, max clock rate %u MHz\n",
 		 mmc_hostname(host->mmc), &res->start, host->mmc->f_max / 1000000);