Skip to contentSkip to conversation

Revert "blk: Invalidate block cache when switching hwpart"

PATCH New Weijie Gao 3 participants 8 messages Aug 27, 2019 – Sep 2, 2019

Subsystems (3)
lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

PATCH 1/3 Revert "blk: Invalidate block cache when switching hwpart"

This reverts commit 0ebe112d09b48230ba4be833cd3504b06997d9a4.

Most block devices have only one hwpart. Multiple hwparts only found used by eMMC devices in u-boot. The mmc driver do blk_dselect_hwpart() at the beginning of mmc_bread() which causes block cache being invalidated too frequently and makes block cache useless.

So it's not a good idea to put blkcache_invalidate() in the common functions. It should be called inside mmc_select_hwpart().

---
 drivers/block/blk-uclass.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/block/blk-uclass.c +2 -12
index c23b6682a6..baaf431e5e 100644
@@ -208,11 +208,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
 	if (ret)
 		return ret;
 
-	ret = blk_select_hwpart(dev, hwpart);
-	if (!ret)
-		blkcache_invalidate(if_type, devnum);
-
-	return ret;
+	return blk_select_hwpart(dev, hwpart);
 }
 
 int blk_list_part(enum if_type if_type)
@@ -352,13 +348,7 @@ int blk_select_hwpart(struct udevice *dev, int hwpart)
 
 int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
 {
-	int ret;
-
-	ret = blk_select_hwpart(desc->bdev, hwpart);
-	if (!ret)
-		blkcache_invalidate(desc->if_type, desc->devnum);
-
-	return ret;
+	return blk_select_hwpart(desc->bdev, hwpart);
 }
 
 int blk_first_device(int if_type, struct udevice **devp)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 mmc: invalidate block cache after hwpart switched successfully

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.

---
 drivers/mmc/mmc-uclass.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/mmc-uclass.c +6 -1
index 551007905c..2b146ea43c 100644
@@ -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)
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 mmc: invalidate block cache after hwpart switched successfully

Quoted 7 lines · Weijie Gao

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.

Quoted 5 lines

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

---

For the PDU001 board:

regards, Felix

#3 lore raw

PATCH 2/3 mmc: invalidate block cache after hwpart switched successfully

In reply to Weijie Gao
Quoted 7 lines · Weijie Gao

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.

Quoted 5 lines

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

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/20190902/bb87ebd5/attachment.sig>
author
#4 lore raw

PATCH 3/3 configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2

In reply to Weijie Gao

This patch enables CONFIG_BLOCK_CACHE for mt7623n_bpir2.

---
This patch must be merged after patch 1 & 2.

---
 configs/mt7623n_bpir2_defconfig | 1 -
 1 file changed, 1 deletion(-)
configs/mt7623n_bpir2_defconfig +0 -1
index ae8209831b..f79850f849 100644
@@ -31,7 +31,6 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
-# CONFIG_BLOCK_CACHE is not set
 CONFIG_CLK=y
 CONFIG_DM_MMC=y
 # CONFIG_MMC_QUIRKS is not set
Signature · 1 line
2.17.1
#5 lore raw

PATCH 3/3 configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2

Quoted 3 lines · Weijie Gao

This patch enables CONFIG_BLOCK_CACHE for mt7623n_bpir2.

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/20190902/4c34e4ae/attachment.sig>
#6 lore raw

PATCH 1/3 Revert "blk: Invalidate block cache when switching hwpart"

In reply to Weijie Gao
Quoted 7 lines · Weijie Gao

This reverts commit 0ebe112d09b48230ba4be833cd3504b06997d9a4.

Most block devices have only one hwpart. Multiple hwparts only found used by eMMC devices in u-boot. The mmc driver do blk_dselect_hwpart() at the beginning of mmc_bread() which causes block cache being invalidated too frequently and makes block cache useless.

Quoted 5 lines

So it's not a good idea to put blkcache_invalidate() in the common functions. It should be called inside mmc_select_hwpart().

---

For the PDU001 board:

regards, Felix

#7 lore raw

PATCH 1/3 Revert "blk: Invalidate block cache when switching hwpart"

In reply to Weijie Gao
Quoted 7 lines · Weijie Gao

This reverts commit 0ebe112d09b48230ba4be833cd3504b06997d9a4.

Most block devices have only one hwpart. Multiple hwparts only found used by eMMC devices in u-boot. The mmc driver do blk_dselect_hwpart() at the beginning of mmc_bread() which causes block cache being invalidated too frequently and makes block cache useless.

Quoted 5 lines

So it's not a good idea to put blkcache_invalidate() in the common functions. It should be called inside mmc_select_hwpart().

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/20190902/c2ecafd1/attachment.sig>