Skip to contentSkip to conversation

common: add blkcache init

PATCH RESEND Superseded Angelo Dureghello 2 participants 3 messages Nov 23, 2019 – Jan 21, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 common: add blkcache init

From: Angelo Durgehello <[email protected]>

On m68k, block_cache list is relocated, but next and prev list pointers are not adjusted to the relocated struct list_head address, so the first iteration over the block_cache list hangs.

This patch initializes the block_cache list after relocation.

---
 common/board_r.c         | 12 ++++++++++++
 drivers/block/blkcache.c |  7 ++++++-
 include/blk.h            |  6 ++++++
 3 files changed, 24 insertions(+), 1 deletion(-)
common/board_r.c +12 -0
index 65720849cd..13e70a5ffb 100644
@@ -628,6 +628,15 @@ static int initr_bedbug(void)
 }
 #endif
 
+#ifdef CONFIG_BLOCK_CACHE
+static int initr_blkcache(void)
+{
+	blkcache_init();
+
+	return 0;
+}
+#endif
+
 static int run_main_loop(void)
 {
 #ifdef CONFIG_SANDBOX
@@ -832,6 +841,9 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #if defined(CONFIG_PRAM)
 	initr_mem,
+#endif
+#ifdef CONFIG_BLOCK_CACHE
+	initr_blkcache,
 #endif
 	run_main_loop,
 };
drivers/block/blkcache.c +6 -1
index 1fa64989d3..bf0fa1ea6f 100644
@@ -21,13 +21,18 @@ struct block_cache_node {
 	char *cache;
 };
 
-static LIST_HEAD(block_cache);
+static struct list_head block_cache;
 
 static struct block_cache_stats _stats = {
 	.max_blocks_per_entry = 8,
 	.max_entries = 32
 };
 
+void blkcache_init(void)
+{
+	INIT_LIST_HEAD(&block_cache);
+}
+
 static struct block_cache_node *cache_find(int iftype, int devnum,
 					   lbaint_t start, lbaint_t blkcnt,
 					   unsigned long blksz)
include/blk.h +6 -0
index d0c033aece..7070fd6af3 100644
@@ -113,6 +113,12 @@ struct blk_desc {
 	(PAD_SIZE(size, blk_desc->blksz))
 
 #if CONFIG_IS_ENABLED(BLOCK_CACHE)
+
+/**
+ * blkcache_init() - initialize the block cache list pointers
+ */
+void blkcache_init(void);
+
 /**
  * blkcache_read() - attempt to read a set of blocks from cache
  *
Signature · 1 line
2.24.0
#1 lore raw

PATCH RESEND 1/1 common: add blkcache init

Quoted 9 lines · Angelo Dureghello

From: Angelo Durgehello <[email protected]>

On m68k, block_cache list is relocated, but next and prev list pointers are not adjusted to the relocated struct list_head address, so the first iteration over the block_cache list hangs.

This patch initializes the block_cache list after relocation.

As noted by Eric in the original posting, we don't need the indirection just for the name as there's not really a hard rule about names there, please just call the function directly, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200115/609e818e/attachment.sig>
#2 lore raw

PATCH RESEND 1/1 common: add blkcache init

Hi Tom and Eric,

ack, sure, will do. v2 in short.

Regards,
Angelo

Quoted 19 lines · Tom Rini
Quoted 9 lines · Angelo Dureghello

From: Angelo Durgehello <[email protected]>

On m68k, block_cache list is relocated, but next and prev list pointers are not adjusted to the relocated struct list_head address, so the first iteration over the block_cache list hangs.

This patch initializes the block_cache list after relocation.

As noted by Eric in the original posting, we don't need the indirection just for the name as there's not really a hard rule about names there, please just call the function directly, thanks!

--
Tom

Signature · 4 lines
Angelo Dureghello
Timesys
email: angelo.dureghello at timesys.com
cell.:  +39 388 8550663