On Thu, 30 Mar 2023 at 01:48, Dennis Zhou <dennis@xxxxxxxxxx> wrote: > > 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. In principle, I don't mind the changes in $subject patch, as long as it doesn't hurt the overall initialization/boot time. Especially, we may have more than one mmc-slot being used, so this needs to be well tested. Although, more importantly, I fail to understand how this is going to solve the race condition. Any I/O request to an eMMC or SD requires the mmc block device driver to be up and running too, which is getting probed from a separate module/driver that's not part of mmc_rescan(). Kind regards Uffe > > Signed-off-by: Dennis Zhou <dennis@xxxxxxxxxx> > --- > Sigh.. fix missing static declaration. > > 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..fda7ee57dee3 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) > +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) > @@ -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 >