]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mmc: core: Prevent processing SDIO IRQs when the card is suspended
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 18 Jun 2019 12:05:17 +0000 (14:05 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838824
commit 83293386bc95cf5e9f0c0175794455835bd1cb4a upstream.

Processing of SDIO IRQs must obviously be prevented while the card is
system suspended, otherwise we may end up trying to communicate with an
uninitialized SDIO card.

Reports throughout the years shows that this is not only a theoretical
problem, but a real issue. So, let's finally fix this problem, by keeping
track of the state for the card and bail out before processing the SDIO
IRQ, in case the card is suspended.

Cc: stable@vger.kernel.org
Reported-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/mmc/core/sdio.c
drivers/mmc/core/sdio_irq.c

index cc43687ca241918fe40d8511eab5fe6ecb848d52..7ee8c90820211050fe1b3b64197a6e1684e3a2a1 100644 (file)
@@ -907,6 +907,10 @@ static int mmc_sdio_pre_suspend(struct mmc_host *host)
  */
 static int mmc_sdio_suspend(struct mmc_host *host)
 {
+       /* Prevent processing of SDIO IRQs in suspended state. */
+       mmc_card_set_suspended(host->card);
+       cancel_delayed_work_sync(&host->sdio_irq_work);
+
        mmc_claim_host(host);
 
        if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host))
@@ -962,13 +966,20 @@ static int mmc_sdio_resume(struct mmc_host *host)
                err = sdio_enable_4bit_bus(host->card);
        }
 
-       if (!err && host->sdio_irqs) {
+       if (err)
+               goto out;
+
+       /* Allow SDIO IRQs to be processed again. */
+       mmc_card_clr_suspended(host->card);
+
+       if (host->sdio_irqs) {
                if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD))
                        wake_up_process(host->sdio_irq_thread);
                else if (host->caps & MMC_CAP_SDIO_IRQ)
                        host->ops->enable_sdio_irq(host, 1);
        }
 
+out:
        mmc_release_host(host);
 
        host->pm_flags &= ~MMC_PM_KEEP_POWER;
index 7a2eaf8410a3b36297b2bc1192fb2249a1859cb5..5eb4d5c6a8cd962a567e8f16b08e7f437b21a70a 100644 (file)
@@ -38,6 +38,10 @@ static int process_sdio_pending_irqs(struct mmc_host *host)
        unsigned char pending;
        struct sdio_func *func;
 
+       /* Don't process SDIO IRQs if the card is suspended. */
+       if (mmc_card_suspended(card))
+               return 0;
+
        /*
         * Optimization, if there is only 1 function interrupt registered
         * and we know an IRQ was signaled then call irq handler directly.