All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RESEND PATCH] common: add blkcache init
@ 2019-11-23 22:51 Angelo Dureghello
  2020-01-15 20:47 ` Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Angelo Dureghello @ 2019-11-23 22:51 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [RESEND PATCH] common: add blkcache init
  2019-11-23 22:51 [U-Boot] [RESEND PATCH] common: add blkcache init Angelo Dureghello
@ 2020-01-15 20:47 ` Tom Rini
  2020-01-21  8:22   ` Angelo Dureghello
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2020-01-15 20:47 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [RESEND PATCH] common: add blkcache init
  2020-01-15 20:47 ` Tom Rini
@ 2020-01-21  8:22   ` Angelo Dureghello
  0 siblings, 0 replies; 3+ messages in thread
From: Angelo Dureghello @ 2020-01-21  8:22 UTC (permalink / raw)
  To: u-boot

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



-- 
Angelo Dureghello
Timesys
email: angelo.dureghello at timesys.com
cell.:  +39 388 8550663

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

end of thread, other threads:[~2020-01-21  8:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-23 22:51 [U-Boot] [RESEND PATCH] common: add blkcache init Angelo Dureghello
2020-01-15 20:47 ` Tom Rini
2020-01-21  8:22   ` Angelo Dureghello

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.