]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: invalidate block cache after hwpart switched successfully
authorWeijie Gao <weijie.gao@mediatek.com>
Tue, 27 Aug 2019 07:32:19 +0000 (15:32 +0800)
committerTom Rini <trini@konsulko.com>
Fri, 30 Aug 2019 18:17:11 +0000 (14:17 -0400)
eMMC device has multiple hw partitions both address from zero. However the
mmc driver lacks block cache invalidation for switch hwpart. This causes a
problem that data of current hw partition is cached before switching to
another hw partition. And the following read operation of the latter hw
partition will get wrong data when reading from the addresses that have
been cached previously.

To solve this problem, invalidate block cache after a successful
mmc_switch_part() operation.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Tested-by: Felix Brack <fb@ltec.ch>
drivers/mmc/mmc-uclass.c

index 551007905c3b8c777d6abf45e90adbd52929bbba..2b146ea43c59dcab49d75a8ad8ab338db63e9556 100644 (file)
@@ -360,6 +360,7 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
        struct udevice *mmc_dev = dev_get_parent(bdev);
        struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
        struct blk_desc *desc = dev_get_uclass_platdata(bdev);
+       int ret;
 
        if (desc->hwpart == hwpart)
                return 0;
@@ -367,7 +368,11 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
        if (mmc->part_config == MMCPART_NOAVAILABLE)
                return -EMEDIUMTYPE;
 
-       return mmc_switch_part(mmc, hwpart);
+       ret = mmc_switch_part(mmc, hwpart);
+       if (!ret)
+               blkcache_invalidate(desc->if_type, desc->devnum);
+
+       return ret;
 }
 
 static int mmc_blk_probe(struct udevice *dev)