[U-Boot] [RESEND PATCH] common: add blkcache init

From: Angelo Durgehello angelo.dureghello@timesys.com
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.
Signed-off-by: Angelo Durgehello angelo.dureghello@timesys.com --- common/board_r.c | 12 ++++++++++++ drivers/block/blkcache.c | 7 ++++++- include/blk.h | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/common/board_r.c b/common/board_r.c index 65720849cd..13e70a5ffb 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -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, }; diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c index 1fa64989d3..bf0fa1ea6f 100644 --- a/drivers/block/blkcache.c +++ b/drivers/block/blkcache.c @@ -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) diff --git a/include/blk.h b/include/blk.h index d0c033aece..7070fd6af3 100644 --- a/include/blk.h +++ b/include/blk.h @@ -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 *

On Sat, Nov 23, 2019 at 11:51:11PM +0100, Angelo Dureghello wrote:
From: Angelo Durgehello angelo.dureghello@timesys.com
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.
Signed-off-by: Angelo Durgehello angelo.dureghello@timesys.com
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!

Hi Tom and Eric,
ack, sure, will do. v2 in short.
Regards, Angelo
On Wed, Jan 15, 2020 at 9:47 PM Tom Rini trini@konsulko.com wrote:
On Sat, Nov 23, 2019 at 11:51:11PM +0100, Angelo Dureghello wrote:
From: Angelo Durgehello angelo.dureghello@timesys.com
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.
Signed-off-by: Angelo Durgehello angelo.dureghello@timesys.com
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
participants (2)
-
Angelo Dureghello
-
Tom Rini