From patchwork Tue Jan 21 09:37:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 239855 List-Id: U-Boot discussion From: angelo.dureghello at timesys.com (Angelo Dureghello) Date: Tue, 21 Jan 2020 10:37:27 +0100 Subject: [PATCH] common: add blkcache init Message-ID: <20200121093727.33758-1-angelo.dureghello@timesys.com> From: Angelo Durgehello 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 Reviewed-by: Eric Nelson --- Changes for v2: - call blkcache_init directly --- common/board_r.c | 3 +++ drivers/block/blkcache.c | 9 ++++++++- include/blk.h | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/board_r.c b/common/board_r.c index 8a0c1114e7..4f56c19fcc 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -864,6 +864,9 @@ static init_fnc_t init_sequence_r[] = { #endif #if defined(CONFIG_PRAM) initr_mem, +#endif +#ifdef CONFIG_BLOCK_CACHE + blkcache_init, #endif run_main_loop, }; diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c index 1fa64989d3..f603aa129d 100644 --- a/drivers/block/blkcache.c +++ b/drivers/block/blkcache.c @@ -21,13 +21,20 @@ 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 }; +int blkcache_init(void) +{ + INIT_LIST_HEAD(&block_cache); + + return 0; +} + 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..65db69f5d9 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 + */ +int blkcache_init(void); + /** * blkcache_read() - attempt to read a set of blocks from cache *