mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Further prevent card detect during shutdown
@ 2024-11-25 12:24 Ulf Hansson
  2024-11-26 11:57 ` Adrian Hunter
  2024-12-02 15:23 ` Ulf Hansson
  0 siblings, 2 replies; 4+ messages in thread
From: Ulf Hansson @ 2024-11-25 12:24 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Anthony Pighin
  Cc: Adrian Hunter, linux-kernel, stable

Disabling card detect from the host's ->shutdown_pre() callback turned out
to not be the complete solution. More precisely, beyond the point when the
mmc_bus->shutdown() has been called, to gracefully power off the card, we
need to prevent card detect. Otherwise the mmc_rescan work may poll for the
card with a CMD13, to see if it's still alive, which then will fail and
hang as the card has already been powered off.

To fix this problem, let's disable mmc_rescan prior to power off the card
during shutdown.

Reported-by: Anthony Pighin <anthony.pighin@nokia.com>
Fixes: 66c915d09b94 ("mmc: core: Disable card detect during shutdown")
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/bus.c  | 2 ++
 drivers/mmc/core/core.c | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 9283b28bc69f..1cf64e0952fb 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -149,6 +149,8 @@ static void mmc_bus_shutdown(struct device *dev)
 	if (dev->driver && drv->shutdown)
 		drv->shutdown(card);
 
+	__mmc_stop_host(host);
+
 	if (host->bus_ops->shutdown) {
 		ret = host->bus_ops->shutdown(host);
 		if (ret)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index a499f3c59de5..d996d39c0d6f 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2335,6 +2335,9 @@ void mmc_start_host(struct mmc_host *host)
 
 void __mmc_stop_host(struct mmc_host *host)
 {
+	if (host->rescan_disable)
+		return;
+
 	if (host->slot.cd_irq >= 0) {
 		mmc_gpio_set_cd_wake(host, false);
 		disable_irq(host->slot.cd_irq);
-- 
2.43.0


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

* Re: [PATCH] mmc: core: Further prevent card detect during shutdown
  2024-11-25 12:24 [PATCH] mmc: core: Further prevent card detect during shutdown Ulf Hansson
@ 2024-11-26 11:57 ` Adrian Hunter
  2024-11-26 12:17   ` Ulf Hansson
  2024-12-02 15:23 ` Ulf Hansson
  1 sibling, 1 reply; 4+ messages in thread
From: Adrian Hunter @ 2024-11-26 11:57 UTC (permalink / raw)
  To: Ulf Hansson, linux-mmc, Anthony Pighin; +Cc: linux-kernel, stable

On 25/11/24 14:24, Ulf Hansson wrote:
> Disabling card detect from the host's ->shutdown_pre() callback turned out
> to not be the complete solution. More precisely, beyond the point when the
> mmc_bus->shutdown() has been called, to gracefully power off the card, we
> need to prevent card detect. Otherwise the mmc_rescan work may poll for the
> card with a CMD13, to see if it's still alive, which then will fail and
> hang as the card has already been powered off.
> 
> To fix this problem, let's disable mmc_rescan prior to power off the card
> during shutdown.
> 
> Reported-by: Anthony Pighin <anthony.pighin@nokia.com>

Could add a closes tag here

> Fixes: 66c915d09b94 ("mmc: core: Disable card detect during shutdown")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/core/bus.c  | 2 ++
>  drivers/mmc/core/core.c | 3 +++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 9283b28bc69f..1cf64e0952fb 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -149,6 +149,8 @@ static void mmc_bus_shutdown(struct device *dev)
>  	if (dev->driver && drv->shutdown)
>  		drv->shutdown(card);
>  
> +	__mmc_stop_host(host);
> +
>  	if (host->bus_ops->shutdown) {
>  		ret = host->bus_ops->shutdown(host);
>  		if (ret)
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index a499f3c59de5..d996d39c0d6f 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2335,6 +2335,9 @@ void mmc_start_host(struct mmc_host *host)
>  
>  void __mmc_stop_host(struct mmc_host *host)
>  {
> +	if (host->rescan_disable)
> +		return;
> +
>  	if (host->slot.cd_irq >= 0) {
>  		mmc_gpio_set_cd_wake(host, false);
>  		disable_irq(host->slot.cd_irq);


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

* Re: [PATCH] mmc: core: Further prevent card detect during shutdown
  2024-11-26 11:57 ` Adrian Hunter
@ 2024-11-26 12:17   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2024-11-26 12:17 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: linux-mmc, Anthony Pighin, linux-kernel, stable

On Tue, 26 Nov 2024 at 12:57, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 25/11/24 14:24, Ulf Hansson wrote:
> > Disabling card detect from the host's ->shutdown_pre() callback turned out
> > to not be the complete solution. More precisely, beyond the point when the
> > mmc_bus->shutdown() has been called, to gracefully power off the card, we
> > need to prevent card detect. Otherwise the mmc_rescan work may poll for the
> > card with a CMD13, to see if it's still alive, which then will fail and
> > hang as the card has already been powered off.
> >
> > To fix this problem, let's disable mmc_rescan prior to power off the card
> > during shutdown.
> >
> > Reported-by: Anthony Pighin <anthony.pighin@nokia.com>
>
> Could add a closes tag here

Good point, I will add it when applying!

>
> > Fixes: 66c915d09b94 ("mmc: core: Disable card detect during shutdown")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

Thanks!

Kind regards
Uffe

>
> > ---
> >  drivers/mmc/core/bus.c  | 2 ++
> >  drivers/mmc/core/core.c | 3 +++
> >  2 files changed, 5 insertions(+)
> >
> > diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> > index 9283b28bc69f..1cf64e0952fb 100644
> > --- a/drivers/mmc/core/bus.c
> > +++ b/drivers/mmc/core/bus.c
> > @@ -149,6 +149,8 @@ static void mmc_bus_shutdown(struct device *dev)
> >       if (dev->driver && drv->shutdown)
> >               drv->shutdown(card);
> >
> > +     __mmc_stop_host(host);
> > +
> >       if (host->bus_ops->shutdown) {
> >               ret = host->bus_ops->shutdown(host);
> >               if (ret)
> > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> > index a499f3c59de5..d996d39c0d6f 100644
> > --- a/drivers/mmc/core/core.c
> > +++ b/drivers/mmc/core/core.c
> > @@ -2335,6 +2335,9 @@ void mmc_start_host(struct mmc_host *host)
> >
> >  void __mmc_stop_host(struct mmc_host *host)
> >  {
> > +     if (host->rescan_disable)
> > +             return;
> > +
> >       if (host->slot.cd_irq >= 0) {
> >               mmc_gpio_set_cd_wake(host, false);
> >               disable_irq(host->slot.cd_irq);
>

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

* Re: [PATCH] mmc: core: Further prevent card detect during shutdown
  2024-11-25 12:24 [PATCH] mmc: core: Further prevent card detect during shutdown Ulf Hansson
  2024-11-26 11:57 ` Adrian Hunter
@ 2024-12-02 15:23 ` Ulf Hansson
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2024-12-02 15:23 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Anthony Pighin
  Cc: Adrian Hunter, linux-kernel, stable

On Mon, 25 Nov 2024 at 13:24, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> Disabling card detect from the host's ->shutdown_pre() callback turned out
> to not be the complete solution. More precisely, beyond the point when the
> mmc_bus->shutdown() has been called, to gracefully power off the card, we
> need to prevent card detect. Otherwise the mmc_rescan work may poll for the
> card with a CMD13, to see if it's still alive, which then will fail and
> hang as the card has already been powered off.
>
> To fix this problem, let's disable mmc_rescan prior to power off the card
> during shutdown.
>
> Reported-by: Anthony Pighin <anthony.pighin@nokia.com>
> Fixes: 66c915d09b94 ("mmc: core: Disable card detect during shutdown")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

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

Kind regards
Uffe


> ---
>  drivers/mmc/core/bus.c  | 2 ++
>  drivers/mmc/core/core.c | 3 +++
>  2 files changed, 5 insertions(+)
>
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 9283b28bc69f..1cf64e0952fb 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -149,6 +149,8 @@ static void mmc_bus_shutdown(struct device *dev)
>         if (dev->driver && drv->shutdown)
>                 drv->shutdown(card);
>
> +       __mmc_stop_host(host);
> +
>         if (host->bus_ops->shutdown) {
>                 ret = host->bus_ops->shutdown(host);
>                 if (ret)
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index a499f3c59de5..d996d39c0d6f 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2335,6 +2335,9 @@ void mmc_start_host(struct mmc_host *host)
>
>  void __mmc_stop_host(struct mmc_host *host)
>  {
> +       if (host->rescan_disable)
> +               return;
> +
>         if (host->slot.cd_irq >= 0) {
>                 mmc_gpio_set_cd_wake(host, false);
>                 disable_irq(host->slot.cd_irq);
> --
> 2.43.0
>

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

end of thread, other threads:[~2024-12-02 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 12:24 [PATCH] mmc: core: Further prevent card detect during shutdown Ulf Hansson
2024-11-26 11:57 ` Adrian Hunter
2024-11-26 12:17   ` Ulf Hansson
2024-12-02 15:23 ` 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®