]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mmc: core: Allow mmc_start_host() synchronously detect a card
authorDennis Zhou <dennis@kernel.org>
Wed, 29 Mar 2023 23:48:01 +0000 (16:48 -0700)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 13 Jun 2023 14:08:16 +0000 (16:08 +0200)
When using dm-verity with a data partition on an emmc device, dm-verity
races with the initialization of the (e)MMC/SD cards. This is because the
card detection procedure is being managed from a workqueue, rather than
synchronously from the mmc host's ->probe() routine.

To allow the card detect to be synchronous, let's simply skip using the
workqueue at the first initialization attempt from mmc_start_host().

Signed-off-by: Dennis Zhou <dennis@kernel.org>
Link: https://lore.kernel.org/r/ZCTOMVjW+pnZVGsQ@snowbird
[Ulf: Re-wrote the commit message to clarify the change]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/core.c

index 3d3e0ca5261481a86069e38261678924524448b6..ec4108a3e5b93e0748428ecc254884954f6b0501 100644 (file)
@@ -2199,10 +2199,8 @@ int mmc_card_alternative_gpt_sector(struct mmc_card *card, sector_t *gpt_sector)
 }
 EXPORT_SYMBOL(mmc_card_alternative_gpt_sector);
 
-void mmc_rescan(struct work_struct *work)
+static void __mmc_rescan(struct mmc_host *host)
 {
-       struct mmc_host *host =
-               container_of(work, struct mmc_host, detect.work);
        int i;
 
        if (host->rescan_disable)
@@ -2274,6 +2272,14 @@ void mmc_rescan(struct work_struct *work)
                mmc_schedule_delayed_work(&host->detect, HZ);
 }
 
+void mmc_rescan(struct work_struct *work)
+{
+       struct mmc_host *host =
+               container_of(work, struct mmc_host, detect.work);
+
+       __mmc_rescan(host);
+}
+
 void mmc_start_host(struct mmc_host *host)
 {
        host->f_init = max(min(freqs[0], host->f_max), host->f_min);
@@ -2286,7 +2292,8 @@ void mmc_start_host(struct mmc_host *host)
        }
 
        mmc_gpiod_request_cd_irq(host);
-       _mmc_detect_change(host, 0, false);
+       host->detect_change = 1;
+       __mmc_rescan(host);
 }
 
 void __mmc_stop_host(struct mmc_host *host)