[U-Boot] [PATCH 1/2] cmd: mmc: Force mmc reinit when no card present

In case the card is removed, force-init the MMC to start the internal machinery which deregisters and invalidate the MMC device.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Jaehoon Chung jh80.chung@samsung.com --- cmd/mmc.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/cmd/mmc.c b/cmd/mmc.c index 3920a1836a..ca8f982f53 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -101,6 +101,9 @@ static struct mmc *init_mmc_device(int dev, bool force_init) return NULL; }
+ if (!mmc_getcd(mmc)) + force_init = true; + if (force_init) mmc->has_init = 0; if (mmc_init(mmc))

Make sure the block cache is cleared for the MMC device after it was reinitialized to avoid having any stale data in the cache, like e.g. partition tables or such.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Jaehoon Chung jh80.chung@samsung.com --- cmd/mmc.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/cmd/mmc.c b/cmd/mmc.c index ca8f982f53..9951315f91 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -108,6 +108,12 @@ static struct mmc *init_mmc_device(int dev, bool force_init) mmc->has_init = 0; if (mmc_init(mmc)) return NULL; + +#ifdef CONFIG_BLOCK_CACHE + struct blk_desc *bd = mmc_get_blk_desc(mmc); + blkcache_invalidate(bd->if_type, bd->devnum); +#endif + return mmc; } static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

On Thu, Jan 03, 2019 at 10:09:44PM +0100, Marek Vasut wrote:
Make sure the block cache is cleared for the MMC device after it was reinitialized to avoid having any stale data in the cache, like e.g. partition tables or such.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Jaehoon Chung jh80.chung@samsung.com
Applied to u-boot/master, thanks!

On Thu, Jan 03, 2019 at 10:09:43PM +0100, Marek Vasut wrote:
In case the card is removed, force-init the MMC to start the internal machinery which deregisters and invalidate the MMC device.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Jaehoon Chung jh80.chung@samsung.com
Applied to u-boot/master, thanks!
participants (2)
-
Marek Vasut
-
Tom Rini