summaryrefslogtreecommitdiff
path: root/drivers/block/blk-uclass.c
diff options
context:
space:
mode:
authorWeijie Gao <weijie.gao@mediatek.com>2019-07-11 10:10:23 +0300
committerTom Rini <trini@konsulko.com>2019-07-18 18:31:31 +0300
commit0ebe112d09b48230ba4be833cd3504b06997d9a4 (patch)
tree6ef07a51f392f9d84bd2082550486b6f38cd13be /drivers/block/blk-uclass.c
parent5490d6ad3b9f38aa26df36c37a1ffccad77bff7d (diff)
downloadu-boot-0ebe112d09b48230ba4be833cd3504b06997d9a4.tar.xz
blk: Invalidate block cache when switching hwpart
Some storage devices have multiple hw partitions and both address from zero, for example eMMC. However currently block cache invalidation only applies to block write/erase. This can cause 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 select_hwpart operation. Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Diffstat (limited to 'drivers/block/blk-uclass.c')
-rw-r--r--drivers/block/blk-uclass.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index baaf431e5e..c23b6682a6 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -208,7 +208,11 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
if (ret)
return ret;
- return blk_select_hwpart(dev, hwpart);
+ ret = blk_select_hwpart(dev, hwpart);
+ if (!ret)
+ blkcache_invalidate(if_type, devnum);
+
+ return ret;
}
int blk_list_part(enum if_type if_type)
@@ -348,7 +352,13 @@ int blk_select_hwpart(struct udevice *dev, int hwpart)
int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
{
- return blk_select_hwpart(desc->bdev, hwpart);
+ int ret;
+
+ ret = blk_select_hwpart(desc->bdev, hwpart);
+ if (!ret)
+ blkcache_invalidate(desc->if_type, desc->devnum);
+
+ return ret;
}
int blk_first_device(int if_type, struct udevice **devp)