All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart"
@ 2019-08-27  7:32 Weijie Gao
  2019-08-27  7:32 ` [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully Weijie Gao
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Weijie Gao @ 2019-08-27  7:32 UTC (permalink / raw)
  To: u-boot

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().

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
 drivers/block/blk-uclass.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index c23b6682a6..baaf431e5e 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -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)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully
  2019-08-27  7:32 [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Weijie Gao
@ 2019-08-27  7:32 ` Weijie Gao
  2019-08-27  8:22   ` Felix Brack
  2019-09-02 14:13   ` Tom Rini
  2019-08-27  7:32 ` [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2 Weijie Gao
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 8+ messages in thread
From: Weijie Gao @ 2019-08-27  7:32 UTC (permalink / raw)
  To: u-boot

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>
---
 drivers/mmc/mmc-uclass.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 551007905c..2b146ea43c 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -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)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2
  2019-08-27  7:32 [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Weijie Gao
  2019-08-27  7:32 ` [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully Weijie Gao
@ 2019-08-27  7:32 ` Weijie Gao
  2019-09-02 14:13   ` Tom Rini
  2019-08-27  8:21 ` [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Felix Brack
  2019-09-02 14:13 ` Tom Rini
  3 siblings, 1 reply; 8+ messages in thread
From: Weijie Gao @ 2019-08-27  7:32 UTC (permalink / raw)
  To: u-boot

This patch enables CONFIG_BLOCK_CACHE for mt7623n_bpir2.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
This patch must be merged after patch 1 & 2.
---
 configs/mt7623n_bpir2_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig
index ae8209831b..f79850f849 100644
--- a/configs/mt7623n_bpir2_defconfig
+++ b/configs/mt7623n_bpir2_defconfig
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart"
  2019-08-27  7:32 [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Weijie Gao
  2019-08-27  7:32 ` [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully Weijie Gao
  2019-08-27  7:32 ` [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2 Weijie Gao
@ 2019-08-27  8:21 ` Felix Brack
  2019-09-02 14:13 ` Tom Rini
  3 siblings, 0 replies; 8+ messages in thread
From: Felix Brack @ 2019-08-27  8:21 UTC (permalink / raw)
  To: u-boot

On 27.08.19 09:32, Weijie Gao wrote:
> 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().
> 
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> ---
For the PDU001 board:

Tested-by: Felix Brack <fb@ltec.ch>

regards, Felix

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully
  2019-08-27  7:32 ` [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully Weijie Gao
@ 2019-08-27  8:22   ` Felix Brack
  2019-09-02 14:13   ` Tom Rini
  1 sibling, 0 replies; 8+ messages in thread
From: Felix Brack @ 2019-08-27  8:22 UTC (permalink / raw)
  To: u-boot

On 27.08.19 09:32, Weijie Gao wrote:
> 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>
> ---
For the PDU001 board:

Tested-by: Felix Brack <fb@ltec.ch>

regards, Felix

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart"
  2019-08-27  7:32 [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Weijie Gao
                   ` (2 preceding siblings ...)
  2019-08-27  8:21 ` [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Felix Brack
@ 2019-09-02 14:13 ` Tom Rini
  3 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2019-09-02 14:13 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 27, 2019 at 03:32:18PM +0800, Weijie Gao wrote:

> 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().
> 
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> Tested-by: Felix Brack <fb@ltec.ch>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully
  2019-08-27  7:32 ` [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully Weijie Gao
  2019-08-27  8:22   ` Felix Brack
@ 2019-09-02 14:13   ` Tom Rini
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Rini @ 2019-09-02 14:13 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 27, 2019 at 03:32:19PM +0800, Weijie Gao wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2
  2019-08-27  7:32 ` [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2 Weijie Gao
@ 2019-09-02 14:13   ` Tom Rini
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2019-09-02 14:13 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 27, 2019 at 03:32:20PM +0800, Weijie Gao wrote:

> This patch enables CONFIG_BLOCK_CACHE for mt7623n_bpir2.
> 
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-02 14:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  7:32 [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Weijie Gao
2019-08-27  7:32 ` [U-Boot] [PATCH 2/3] mmc: invalidate block cache after hwpart switched successfully Weijie Gao
2019-08-27  8:22   ` Felix Brack
2019-09-02 14:13   ` Tom Rini
2019-08-27  7:32 ` [U-Boot] [PATCH 3/3] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2 Weijie Gao
2019-09-02 14:13   ` Tom Rini
2019-08-27  8:21 ` [U-Boot] [PATCH 1/3] Revert "blk: Invalidate block cache when switching hwpart" Felix Brack
2019-09-02 14:13 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.