]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mmc: core: Further prevent card detect during shutdown
authorUlf Hansson <ulf.hansson@linaro.org>
Mon, 25 Nov 2024 12:24:46 +0000 (13:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:48:24 +0000 (19:48 +0100)
commit 87a0d90fcd31c0f36da0332428c9e1a1e0f97432 upstream.

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>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Closes: https://lore.kernel.org/all/BN0PR08MB695133000AF116F04C3A9FFE83212@BN0PR08MB6951.namprd08.prod.outlook.com/
Tested-by: Anthony Pighin <anthony.pighin@nokia.com>
Message-ID: <20241125122446.18684-1-ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mmc/core/bus.c
drivers/mmc/core/core.c

index 4383c262b3f5a383a95a56cdf115571ae838118d..6676f8883c9cec7d17843fea08b756d76600adcf 100644 (file)
@@ -160,6 +160,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)
index d5ca59bd1c99557fce6c5e169c8287ba77a80acc..0f73ee841574a4a758f8c9360590c7550b4807fc 100644 (file)
@@ -2345,6 +2345,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);