[U-Boot] [PATCH] MMC HW partition switching must also invalidate the cache
Jan Sedivy
jans at zhinst.com
Thu Apr 11 13:23:54 UTC 2019
Signed-off-by: Jan Šedivý <jans at zhinst.com>
---
drivers/mmc/mmc.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 456c1b4..3d9a68e 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -954,8 +954,13 @@ int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
* to return to representing the raw device.
*/
if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0))) {
+ struct blk_desc *desc = mmc_get_blk_desc(mmc);
+
ret = mmc_set_capacity(mmc, part_num);
- mmc_get_blk_desc(mmc)->hwpart = part_num;
+ if (desc && desc->hwpart != part_num) {
+ desc->hwpart = part_num;
+ blkcache_invalidate(desc->if_type, desc->devnum);
+ }
}
return ret;
@@ -2673,7 +2678,12 @@ retry:
return err;
/* The internal partition reset to user partition(0) at every CMD0*/
- mmc_get_blk_desc(mmc)->hwpart = 0;
+ struct blk_desc *desc = mmc_get_blk_desc(mmc);
+
+ if (desc && desc->hwpart != 0) {
+ desc->hwpart = 0;
+ blkcache_invalidate(desc->if_type, desc->devnum);
+ }
/* Test for SD version 2 */
err = mmc_send_if_cond(mmc);
--
1.7.9.5
More information about the U-Boot
mailing list