All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue
@ 2017-02-23  1:59 Eddie Cai
  2017-02-23  1:59 ` [U-Boot] [U-Boot 1/2] spl: add spl_early_init Eddie Cai
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Eddie Cai @ 2017-02-23  1:59 UTC (permalink / raw)
  To: u-boot

Andrew F. Davis's below patch broke rk3288 based board. that is because we call
spl_init in board_init_f which is at very early stage. What Andrew want to fix
is calling spl_init very late. That patch will make malloc_base, limit, ptr not
initualized in spl_init when we call spl_init in board_init_f. This patch set 
add spl_early_init. it can be called in board_init_f. So we can fix this issue 
by using spl_early_init.

	commit b3d2861eb20a795b99292b823c923935df26dfc6
	Author: Andrew F. Davis <afd@ti.com>
	Date:   Fri Jan 27 10:39:19 2017 -0600

	    spl: Remove overwrite of relocated malloc limit

Eddie Cai (2):
  spl: add spl_early_init
  rockchip: use spl_early_init instead of spl_init

 arch/arm/mach-rockchip/rk3288-board-spl.c |  2 +-
 common/spl/spl.c                          | 54 ++++++++++++++++++++++++++-----
 include/asm-generic/global_data.h         |  1 +
 include/spl.h                             | 12 ++++++-
 4 files changed, 59 insertions(+), 10 deletions(-)

-- 
2.7.4

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

* [U-Boot] [U-Boot 1/2] spl: add spl_early_init
  2017-02-23  1:59 [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
@ 2017-02-23  1:59 ` Eddie Cai
  2017-02-23  1:59 ` [U-Boot] [U-Boot 2/2] rockchip: use spl_early_init instead of spl_init Eddie Cai
  2017-03-06  7:03 ` [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
  2 siblings, 0 replies; 6+ messages in thread
From: Eddie Cai @ 2017-02-23  1:59 UTC (permalink / raw)
  To: u-boot

Andrew F. Davis's below patch will make malloc_base, limit, ptr not initualized
in spl_init when we call spl_init in board_init_f. Add spl_early_init which can
be called in board_init_f to fix this issue.

commit b3d2861eb20a795b99292b823c923935df26dfc6
Author: Andrew F. Davis <afd@ti.com>
Date:   Fri Jan 27 10:39:19 2017 -0600

    spl: Remove overwrite of relocated malloc limit

Signed-off-by: Eddie Cai <eddie.cai.linux@gmail.com>
---
 common/spl/spl.c                  | 54 +++++++++++++++++++++++++++++++++------
 include/asm-generic/global_data.h |  1 +
 include/spl.h                     | 12 ++++++++-
 3 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 766fb3d..26bc9ef 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -170,21 +170,19 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 	image_entry();
 }
 
-int spl_init(void)
+int spl_early_init(void)
 {
 	int ret;
 
-	debug("spl_init()\n");
-/*
- * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
- * malloc_limit in spl_relocate_stack_gd
- */
-#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
-	!defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
+	debug("spl_early_init()\n");
+
+#if defined(CONFIG_SYS_MALLOC_F_LEN)
 #ifdef CONFIG_MALLOC_F_ADDR
 	gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
+#ifdef CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN
 	gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
+#endif
 	gd->malloc_ptr = 0;
 #endif
 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
@@ -202,6 +200,46 @@ int spl_init(void)
 			return ret;
 		}
 	}
+	gd->flags |= GD_FLG_SPL_EARLY_INIT;
+
+	return 0;
+}
+
+int spl_init(void)
+{
+	int ret;
+
+	debug("spl_init()\n");
+/*
+ * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
+ * malloc_limit in spl_relocate_stack_gd
+ */
+	if (!(gd->flags & GD_FLG_SPL_EARLY_INIT)) {
+#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
+		!defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
+#ifdef CONFIG_MALLOC_F_ADDR
+		gd->malloc_base = CONFIG_MALLOC_F_ADDR;
+#endif
+		gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
+		gd->malloc_ptr = 0;
+#endif
+
+		if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
+			ret = fdtdec_setup();
+			if (ret) {
+				debug("fdtdec_setup() returned error %d\n", ret);
+				return ret;
+			}
+		}
+		if (IS_ENABLED(CONFIG_SPL_DM)) {
+			/* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
+			ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
+			if (ret) {
+				debug("dm_init_and_scan() returned error %d\n", ret);
+				return ret;
+			}
+		}
+	}
 	gd->flags |= GD_FLG_SPL_INIT;
 
 	return 0;
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index e02863d..17ed3dc 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -127,5 +127,6 @@ typedef struct global_data {
 #define GD_FLG_SKIP_RELOC	0x00800	/* Don't relocate		   */
 #define GD_FLG_RECORD		0x01000	/* Record console		   */
 #define GD_FLG_ENV_DEFAULT	0x02000 /* Default variable flag	   */
+#define GD_FLG_SPL_EARLY_INIT	0x04000 /* Default variable flag	   */
 
 #endif /* __ASM_GENERIC_GBL_DATA_H */
diff --git a/include/spl.h b/include/spl.h
index bde4437..a89ac00 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -213,7 +213,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
 			  struct blk_desc *block_dev, int partition);
 
 /**
- * spl_init() - Set up device tree and driver model in SPL if enabled
+ * spl_early_init() - Set up device tree and driver model in SPL if enabled
  *
  * Call this function in board_init_f() if you want to use device tree and
  * driver model early, before board_init_r() is called. This function will
@@ -222,6 +222,16 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
  * If this is not called, then driver model will be inactive in SPL's
  * board_init_f(), and no device tree will be available.
  */
+int spl_early_init(void);
+
+/**
+ * spl_init() - Set up device tree and driver model in SPL if enabled
+ *
+ * This function will be called from board_init_r() if not called earlier.
+ *
+ * If this is not called, then driver model will be inactive in SPL's
+ * board_init_f(), and no device tree will be available.
+ */
 int spl_init(void);
 
 #ifdef CONFIG_SPL_BOARD_INIT
-- 
2.7.4

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

* [U-Boot] [U-Boot 2/2] rockchip: use spl_early_init instead of spl_init
  2017-02-23  1:59 [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
  2017-02-23  1:59 ` [U-Boot] [U-Boot 1/2] spl: add spl_early_init Eddie Cai
@ 2017-02-23  1:59 ` Eddie Cai
  2017-03-06  7:03 ` [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
  2 siblings, 0 replies; 6+ messages in thread
From: Eddie Cai @ 2017-02-23  1:59 UTC (permalink / raw)
  To: u-boot

use spl_early_init to avoid malloc_base, limit, ptr not initualized.

Signed-off-by: Eddie Cai <eddie.cai.linux@gmail.com>
---
 arch/arm/mach-rockchip/rk3288-board-spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c b/arch/arm/mach-rockchip/rk3288-board-spl.c
index 930939a..02ab5a4 100644
--- a/arch/arm/mach-rockchip/rk3288-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3288-board-spl.c
@@ -184,7 +184,7 @@ void board_init_f(ulong dummy)
 	debug_uart_init();
 #endif
 
-	ret = spl_init();
+	ret = spl_early_init();
 	if (ret) {
 		debug("spl_init() failed: %d\n", ret);
 		hang();
-- 
2.7.4

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

* [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue
  2017-02-23  1:59 [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
  2017-02-23  1:59 ` [U-Boot] [U-Boot 1/2] spl: add spl_early_init Eddie Cai
  2017-02-23  1:59 ` [U-Boot] [U-Boot 2/2] rockchip: use spl_early_init instead of spl_init Eddie Cai
@ 2017-03-06  7:03 ` Eddie Cai
  2017-03-16  1:39   ` Simon Glass
  2 siblings, 1 reply; 6+ messages in thread
From: Eddie Cai @ 2017-03-06  7:03 UTC (permalink / raw)
  To: u-boot

Hi Simon
I guess you may lost this patch. So a friendly ping.

2017-02-23 9:59 GMT+08:00 Eddie Cai <eddie.cai.linux@gmail.com>:

> Andrew F. Davis's below patch broke rk3288 based board. that is because we
> call
> spl_init in board_init_f which is at very early stage. What Andrew want to
> fix
> is calling spl_init very late. That patch will make malloc_base, limit,
> ptr not
> initualized in spl_init when we call spl_init in board_init_f. This patch
> set
> add spl_early_init. it can be called in board_init_f. So we can fix this
> issue
> by using spl_early_init.
>
>         commit b3d2861eb20a795b99292b823c923935df26dfc6
>         Author: Andrew F. Davis <afd@ti.com>
>         Date:   Fri Jan 27 10:39:19 2017 -0600
>
>             spl: Remove overwrite of relocated malloc limit
>
> Eddie Cai (2):
>   spl: add spl_early_init
>   rockchip: use spl_early_init instead of spl_init
>
>  arch/arm/mach-rockchip/rk3288-board-spl.c |  2 +-
>  common/spl/spl.c                          | 54
> ++++++++++++++++++++++++++-----
>  include/asm-generic/global_data.h         |  1 +
>  include/spl.h                             | 12 ++++++-
>  4 files changed, 59 insertions(+), 10 deletions(-)
>
> --
> 2.7.4
>
>

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

* [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue
  2017-03-06  7:03 ` [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
@ 2017-03-16  1:39   ` Simon Glass
  2017-03-16 15:02     ` Eddie Cai
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2017-03-16  1:39 UTC (permalink / raw)
  To: u-boot

Hi Eddie,

On 6 March 2017 at 00:03, Eddie Cai <eddie.cai.linux@gmail.com> wrote:
> Hi Simon
> I guess you may lost this patch. So a friendly ping.

I did not lose it, but I thought I commented on it, that we needed to
remove the duplicate code. Perhaps I imagined it sorry.

Anyway I have sent out an updated version (now at v4) so please take a
look. I think your approach is the right way to solve it, but I just wanted
to unified the code a bit.

>
> 2017-02-23 9:59 GMT+08:00 Eddie Cai <eddie.cai.linux@gmail.com>:
>>
>> Andrew F. Davis's below patch broke rk3288 based board. that is because
we
>> call
>> spl_init in board_init_f which is at very early stage. What Andrew want
to
>> fix
>> is calling spl_init very late. That patch will make malloc_base, limit,
>> ptr not
>> initualized in spl_init when we call spl_init in board_init_f. This patch
>> set
>> add spl_early_init. it can be called in board_init_f. So we can fix this
>> issue
>> by using spl_early_init.
>>
>> commit b3d2861eb20a795b99292b823c923935df26dfc6
>> Author: Andrew F. Davis <afd@ti.com>
>> Date: Fri Jan 27 10:39:19 2017 -0600
>>
>> spl: Remove overwrite of relocated malloc limit
>>
>> Eddie Cai (2):
>> spl: add spl_early_init
>> rockchip: use spl_early_init instead of spl_init
>>
>> arch/arm/mach-rockchip/rk3288-board-spl.c | 2 +-
>> common/spl/spl.c | 54
>> ++++++++++++++++++++++++++-----
>> include/asm-generic/global_data.h | 1 +
>> include/spl.h | 12 ++++++-
>> 4 files changed, 59 insertions(+), 10 deletions(-)
>>
>> --
>> 2.7.4
>>
>

Regards,
Simon

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

* [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue
  2017-03-16  1:39   ` Simon Glass
@ 2017-03-16 15:02     ` Eddie Cai
  0 siblings, 0 replies; 6+ messages in thread
From: Eddie Cai @ 2017-03-16 15:02 UTC (permalink / raw)
  To: u-boot

2017-03-16 9:39 GMT+08:00 Simon Glass <sjg@chromium.org>:

> Hi Eddie,
>
> On 6 March 2017 at 00:03, Eddie Cai <eddie.cai.linux@gmail.com> wrote:
> > Hi Simon
> > I guess you may lost this patch. So a friendly ping.
>
> I did not lose it, but I thought I commented on it, that we needed to
> remove the duplicate code. Perhaps I imagined it sorry.
>
I checked but didn't find that mail.

>
> Anyway I have sent out an updated version (now at v4) so please take a
> look. I think your approach is the right way to solve it, but I just wanted
> to unified the code a bit.
>
Sure, i will review it.

>
>
> >
> > 2017-02-23 9:59 GMT+08:00 Eddie Cai <eddie.cai.linux@gmail.com>:
> >>
> >> Andrew F. Davis's below patch broke rk3288 based board. that is because
> we
> >> call
> >> spl_init in board_init_f which is at very early stage. What Andrew want
> to
> >> fix
> >> is calling spl_init very late. That patch will make malloc_base, limit,
> >> ptr not
> >> initualized in spl_init when we call spl_init in board_init_f. This
> patch
> >> set
> >> add spl_early_init. it can be called in board_init_f. So we can fix this
> >> issue
> >> by using spl_early_init.
> >>
> >> commit b3d2861eb20a795b99292b823c923935df26dfc6
> >> Author: Andrew F. Davis <afd@ti.com>
> >> Date: Fri Jan 27 10:39:19 2017 -0600
> >>
> >> spl: Remove overwrite of relocated malloc limit
> >>
> >> Eddie Cai (2):
> >> spl: add spl_early_init
> >> rockchip: use spl_early_init instead of spl_init
> >>
> >> arch/arm/mach-rockchip/rk3288-board-spl.c | 2 +-
> >> common/spl/spl.c | 54
> >> ++++++++++++++++++++++++++-----
> >> include/asm-generic/global_data.h | 1 +
> >> include/spl.h | 12 ++++++-
> >> 4 files changed, 59 insertions(+), 10 deletions(-)
> >>
> >> --
> >> 2.7.4
> >>
> >
>
> Regards,
> Simon
>

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

end of thread, other threads:[~2017-03-16 15:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23  1:59 [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
2017-02-23  1:59 ` [U-Boot] [U-Boot 1/2] spl: add spl_early_init Eddie Cai
2017-02-23  1:59 ` [U-Boot] [U-Boot 2/2] rockchip: use spl_early_init instead of spl_init Eddie Cai
2017-03-06  7:03 ` [U-Boot] [U-Boot 0/2] add spl_early_init to fix rk3288 board broken issue Eddie Cai
2017-03-16  1:39   ` Simon Glass
2017-03-16 15:02     ` Eddie Cai

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.