From patchwork Thu Jul 9 08:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 241095 List-Id: U-Boot discussion From: ovidiu.panait at windriver.com (Ovidiu Panait) Date: Thu, 9 Jul 2020 11:04:56 +0300 Subject: [PATCH 09/10] blkcache: Extend blkcache_init to cover CONFIG_NEEDS_MANUAL_RELOC In-Reply-To: <20200709080457.26850-1-ovidiu.panait@windriver.com> References: <20200709080457.26850-1-ovidiu.panait@windriver.com> Message-ID: <20200709080457.26850-9-ovidiu.panait@windriver.com> Extend manual relocation of block_cache list pointers to all platforms that enable CONFIG_NEEDS_MANUAL_RELOC. Remove m68k-specific checks and provide a single implementation that adds gd->reloc_off to the pre-relocation pointers. Cc: Angelo Durgehello Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- common/board_r.c | 2 +- drivers/block/blkcache.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 522059c5a5..29d831d5eb 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -836,7 +836,7 @@ static init_fnc_t init_sequence_r[] = { #if defined(CONFIG_PRAM) initr_mem, #endif -#if defined(CONFIG_M68K) && defined(CONFIG_BLOCK_CACHE) +#if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_BLOCK_CACHE) blkcache_init, #endif run_main_loop, diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c index b6fc72fe98..d97ee99cf4 100644 --- a/drivers/block/blkcache.c +++ b/drivers/block/blkcache.c @@ -12,6 +12,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + struct block_cache_node { struct list_head lh; int iftype; @@ -22,21 +24,20 @@ struct block_cache_node { char *cache; }; -#ifndef CONFIG_M68K static LIST_HEAD(block_cache); -#else -static struct list_head block_cache; -#endif static struct block_cache_stats _stats = { .max_blocks_per_entry = 8, .max_entries = 32 }; -#ifdef CONFIG_M68K +#ifdef CONFIG_NEEDS_MANUAL_RELOC int blkcache_init(void) { - INIT_LIST_HEAD(&block_cache); + struct list_head *head = &block_cache; + + head->next = (uintptr_t)head->next + gd->reloc_off; + head->prev = (uintptr_t)head->prev + gd->reloc_off; return 0; }