mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: jz4740: Remove the host before resetting the controller
@ 2026-10-26  8:33 Olivier Louvignes
  2026-10-26  8:42 ` Paul Cercueil
  2026-10-30 11:00 ` Ulf Hansson
  0 siblings, 2 replies; 4+ messages in thread
From: Olivier Louvignes @ 2026-10-26  8:33 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Paul Cercueil, Lars-Peter Clausen, Matt Fleming, linux-mmc,
	linux-mips, linux-kernel, Olivier Louvignes

jz4740_mmc_remove() masks every interrupt and resets the controller
before mmc_remove_host(), which removes the card and lets the card's
driver send its last commands. Those commands then run on a controller
that was just reset, and can wait out the driver's 5 s request timeout.

With an SDIO card that cost 5 s on every unbind: on a HiBy R1 (Ingenic
X1600, a BCM43430A1 driven by brcmfmac), the CMD52 that
sdio_release_irq() sends from brcmfmac's remove waited 5.1 s. The
command had finished (END_CMD_RES set in MSC_STAT), but MSC_IMASK read
0xffffffff although the request had unmasked END_CMD_RES. MSC_STAT can
still show IS_RESETTING after jz4740_mmc_reset() returns, so the reset
most likely completed after that write and undid it.

Remove the host first, then quiesce the controller, as other host
drivers do. On the R1, unbinding the Wi-Fi's MSC now takes 0.65 s.

Fixes: 61bfbdb85687 ("MMC: Add support for the controller on JZ4740 SoCs.")
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
---
 drivers/mmc/host/jz4740_mmc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 6a3c26b7c82d..923cf1450de5 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -1151,12 +1151,13 @@ static void jz4740_mmc_remove(struct platform_device *pdev)
 {
 	struct jz4740_mmc_host *host = platform_get_drvdata(pdev);
 
+	/* The card's driver may still send commands as it goes */
+	mmc_remove_host(host->mmc);
+
 	timer_delete_sync(&host->timeout_timer);
 	jz4740_mmc_set_irq_enabled(host, 0xff, false);
 	jz4740_mmc_reset(host);
 
-	mmc_remove_host(host->mmc);
-
 	free_irq(host->irq, host);
 
 	if (host->use_dma)

base-commit: fd9af27f6c2319713bb23832066585f8a59a1771
-- 
2.39.5


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

* Re: [PATCH] mmc: jz4740: Remove the host before resetting the controller
  2026-10-26  8:33 [PATCH] mmc: jz4740: Remove the host before resetting the controller Olivier Louvignes
@ 2026-10-26  8:42 ` Paul Cercueil
  2026-10-26 21:04   ` Olivier Louvignes
  2026-10-30 11:00 ` Ulf Hansson
  1 sibling, 1 reply; 4+ messages in thread
From: Paul Cercueil @ 2026-10-26  8:42 UTC (permalink / raw)
  To: Olivier Louvignes, Ulf Hansson
  Cc: Lars-Peter Clausen, Matt Fleming, linux-mmc, linux-mips, linux-kernel

Hi Olivier,

Le lundi 26 octobre 2026 à 09:33 +0100, Olivier Louvignes a écrit :
> jz4740_mmc_remove() masks every interrupt and resets the controller
> before mmc_remove_host(), which removes the card and lets the card's
> driver send its last commands. Those commands then run on a controller
> that was just reset, and can wait out the driver's 5 s request timeout.
> 
> With an SDIO card that cost 5 s on every unbind: on a HiBy R1 (Ingenic
> X1600, a BCM43430A1 driven by brcmfmac), the CMD52 that
> sdio_release_irq() sends from brcmfmac's remove waited 5.1 s. The
> command had finished (END_CMD_RES set in MSC_STAT), but MSC_IMASK read
> 0xffffffff although the request had unmasked END_CMD_RES. MSC_STAT can
> still show IS_RESETTING after jz4740_mmc_reset() returns, so the reset
> most likely completed after that write and undid it.
> 
> Remove the host first, then quiesce the controller, as other host
> drivers do. On the R1, unbinding the Wi-Fi's MSC now takes 0.65 s.
> 
> Fixes: 61bfbdb85687 ("MMC: Add support for the controller on JZ4740 SoCs.")
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>

If you have a Fixes: tag, you need to Cc the stable@vger.kernel.org list.

Cheers,
-Paul

> ---
>  drivers/mmc/host/jz4740_mmc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
> index 6a3c26b7c82d..923cf1450de5 100644
> --- a/drivers/mmc/host/jz4740_mmc.c
> +++ b/drivers/mmc/host/jz4740_mmc.c
> @@ -1151,12 +1151,13 @@ static void jz4740_mmc_remove(struct platform_device
> *pdev)
>  {
>  	struct jz4740_mmc_host *host = platform_get_drvdata(pdev);
>  
> +	/* The card's driver may still send commands as it goes */
> +	mmc_remove_host(host->mmc);
> +
>  	timer_delete_sync(&host->timeout_timer);
>  	jz4740_mmc_set_irq_enabled(host, 0xff, false);
>  	jz4740_mmc_reset(host);
>  
> -	mmc_remove_host(host->mmc);
> -
>  	free_irq(host->irq, host);
>  
>  	if (host->use_dma)
> 
> base-commit: fd9af27f6c2319713bb23832066585f8a59a1771

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

* Re: [PATCH] mmc: jz4740: Remove the host before resetting the controller
  2026-10-26  8:42 ` Paul Cercueil
@ 2026-10-26 21:04   ` Olivier Louvignes
  0 siblings, 0 replies; 4+ messages in thread
From: Olivier Louvignes @ 2026-10-26 21:04 UTC (permalink / raw)
  To: Paul Cercueil, Ulf Hansson
  Cc: Lars-Peter Clausen, Matt Fleming, stable, linux-mmc, linux-mips,
	linux-kernel

Hi Paul,

Right, my miss, adding stable now.

Ulf, could you add

Cc: stable@vger.kernel.org

when applying? Or I can send a v2 with it after -rc1 if you prefer,

Thanks,
Olivier

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

* Re: [PATCH] mmc: jz4740: Remove the host before resetting the controller
  2026-10-26  8:33 [PATCH] mmc: jz4740: Remove the host before resetting the controller Olivier Louvignes
  2026-10-26  8:42 ` Paul Cercueil
@ 2026-10-30 11:00 ` Ulf Hansson
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2026-10-30 11:00 UTC (permalink / raw)
  To: Olivier Louvignes
  Cc: Ulf Hansson, Paul Cercueil, Lars-Peter Clausen, Matt Fleming,
	linux-mmc, linux-mips, linux-kernel

On Mon, Oct 26, 2026 at 9:34 AM Olivier Louvignes <olivier@mgcrea.io> wrote:
>
> jz4740_mmc_remove() masks every interrupt and resets the controller
> before mmc_remove_host(), which removes the card and lets the card's
> driver send its last commands. Those commands then run on a controller
> that was just reset, and can wait out the driver's 5 s request timeout.
>
> With an SDIO card that cost 5 s on every unbind: on a HiBy R1 (Ingenic
> X1600, a BCM43430A1 driven by brcmfmac), the CMD52 that
> sdio_release_irq() sends from brcmfmac's remove waited 5.1 s. The
> command had finished (END_CMD_RES set in MSC_STAT), but MSC_IMASK read
> 0xffffffff although the request had unmasked END_CMD_RES. MSC_STAT can
> still show IS_RESETTING after jz4740_mmc_reset() returns, so the reset
> most likely completed after that write and undid it.
>
> Remove the host first, then quiesce the controller, as other host
> drivers do. On the R1, unbinding the Wi-Fi's MSC now takes 0.65 s.
>
> Fixes: 61bfbdb85687 ("MMC: Add support for the controller on JZ4740 SoCs.")
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/jz4740_mmc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
> index 6a3c26b7c82d..923cf1450de5 100644
> --- a/drivers/mmc/host/jz4740_mmc.c
> +++ b/drivers/mmc/host/jz4740_mmc.c
> @@ -1151,12 +1151,13 @@ static void jz4740_mmc_remove(struct platform_device *pdev)
>  {
>         struct jz4740_mmc_host *host = platform_get_drvdata(pdev);
>
> +       /* The card's driver may still send commands as it goes */
> +       mmc_remove_host(host->mmc);
> +
>         timer_delete_sync(&host->timeout_timer);
>         jz4740_mmc_set_irq_enabled(host, 0xff, false);
>         jz4740_mmc_reset(host);
>
> -       mmc_remove_host(host->mmc);
> -
>         free_irq(host->irq, host);
>
>         if (host->use_dma)
>
> base-commit: fd9af27f6c2319713bb23832066585f8a59a1771
> --
> 2.39.5
>

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

end of thread, other threads:[~2026-10-30 11:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  8:33 [PATCH] mmc: jz4740: Remove the host before resetting the controller Olivier Louvignes
2026-10-26  8:42 ` Paul Cercueil
2026-10-26 21:04   ` Olivier Louvignes
2026-10-30 11:00 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®