Skip to contentSkip to conversation

cmd: mmc: Force mmc reinit when no card present

PATCH New Marek Vasut 2 participants 4 messages Jan 3, 2019 – Jan 16, 2019

lore
Share & tools
lore
#0 lore raw

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.

---
 cmd/mmc.c | 3 +++
 1 file changed, 3 insertions(+)
cmd/mmc.c +3 -0
index 3920a1836a..ca8f982f53 100644
@@ -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))
Signature · 1 line
2.19.2
#1 lore raw

PATCH 2/2 cmd: mmc: Invalidate MMC block cache after init

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.

---
 cmd/mmc.c | 6 ++++++
 1 file changed, 6 insertions(+)
cmd/mmc.c +6 -0
index ca8f982f53..9951315f91 100644
@@ -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[])
Signature · 1 line
2.19.2
#2 lore raw

PATCH 2/2 cmd: mmc: Invalidate MMC block cache after init

Quoted 6 lines · Marek Vasut

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190115/a8196b39/attachment.sig>
#3 lore raw

PATCH 1/2 cmd: mmc: Force mmc reinit when no card present

In reply to Marek Vasut
Quoted 5 lines · Marek Vasut

In case the card is removed, force-init the MMC to start the internal machinery which deregisters and invalidate the MMC device.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190115/169d9220/attachment.sig>