All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: inline the first mmc_scan() on mmc_start_host()
@ 2023-03-29 20:21 Dennis Zhou
  2023-03-29 22:56 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Dennis Zhou @ 2023-03-29 20:21 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, linux-kernel, Dennis Zhou

When using dm-verity with a data partition on an emmc device, dm-verity
races with the discovery of attached emmc devices. This is because mmc's
probing code sets up the host data structure then a work item is
scheduled to do discovery afterwards. To prevent this race on init,
let's inline the first call to detection, __mm_scan(), and let
subsequent detect calls be handled via the workqueue.

Signed-off-by: Dennis Zhou <dennis@kernel.org>
---
 drivers/mmc/core/core.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 368f10405e13..c0fdc438c882 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2185,10 +2185,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)
+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)
@@ -2249,6 +2247,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);
@@ -2261,7 +2267,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)
-- 
2.40.0


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

end of thread, other threads:[~2023-06-30 22:09 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 20:21 [PATCH] mmc: inline the first mmc_scan() on mmc_start_host() Dennis Zhou
2023-03-29 22:56 ` kernel test robot
2023-03-29 23:36 ` kernel test robot
2023-03-29 23:48 ` [PATCH v2] " Dennis Zhou
2023-03-31 12:43   ` Ulf Hansson
2023-03-31 18:23     ` Dennis Zhou
2023-04-03  9:50       ` Ulf Hansson
2023-04-07  8:24         ` Dennis Zhou
2023-04-11 20:29           ` Dennis Zhou
2023-04-12 11:05           ` Ulf Hansson
2023-05-12 11:42         ` Ulf Hansson
2023-06-08 20:49           ` Dennis Zhou
2023-06-09  6:19             ` Greg KH
2023-06-09  7:16               ` Dennis Zhou
2023-06-09  8:53                 ` Greg KH
2023-06-09  8:58                   ` Linus Walleij
2023-06-12 14:55                 ` Ulf Hansson
2023-06-27 17:20   ` Geert Uytterhoeven
2023-06-27 18:09     ` Biju Das
2023-06-30 11:26     ` Ulf Hansson
2023-06-30 13:34       ` Wolfram Sang
2023-06-30 22:09       ` Dennis Zhou
2023-06-13 14:25 ` [PATCH] " Ulf Hansson
2023-06-15 16:06   ` Dennis Zhou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.