[U-Boot] Microblaze fixes

Hi Wolfgang,
I am sending two patches for review. I don't expect that someone will have any compains about that's why I have create fix branch in my custodian repo and you can pull them.
Both patches are fixes and if possible, I would like to add them to your branch. I have looked at schedule and if you don't want to merge it, I will ask for merging in upcomming merge window.
Thanks, Michal
The following changes since commit 71aab09b2c1edd1b6e00819abd1e31c04db04f36: Wolfgang Denk (1): Merge branch 'master' of /home/wd/git/u-boot/custodians
are available in the git repository at:
git://www.denx.de/git/u-boot-microblaze.git fix
Michal Simek (2): microblaze: Disabling interrupt should return 1 if implemented microblaze: Fix bdiinfo pointer
arch/microblaze/cpu/interrupts.c | 2 +- arch/microblaze/lib/board.c | 2 +- include/configs/microblaze-generic.h | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-)

Microblaze implement enable/disable interrupts through MSR that's why disable_interrupts function should return 1.
Signed-off-by: John Linn john.linn@xilinx.com Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/cpu/interrupts.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c index e9d53c1..331746c 100644 --- a/arch/microblaze/cpu/interrupts.c +++ b/arch/microblaze/cpu/interrupts.c @@ -42,7 +42,7 @@ void enable_interrupts (void) int disable_interrupts (void) { MSRCLR(0x2); - return 0; + return 1; }
#ifdef CONFIG_SYS_INTC_0

Patch "Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value" (sha1: 25ddd1fb0a2281b182529afbc8fda5de2dc16d96) introduce GENERATED_GBL_DATA_SIZE which is sizeof aligned gd_t (currently 0x40). Microblaze configs used 0x40(128) because this place also contained board info structure which lies on the top of ram.
This patch is fixing this scheme by extending CONFIG_SYS_GBL_DATA_OFFSET value. Doubled GENERATED_GBL_DATA_SIZE size is enough to store gd_t and bd_t structures.
U-Boot is placed to the top of the ram (for example 0xd7ffffff) and bd structure was moved out of ram.
For example: Current: gd 0xd7ffffc0, bd 0xd8000000 Fixed: gd 0xd7ffff80, bd 0xd7ffffc0
Signed-off-by: Michal Simek monstr@monstr.eu --- arch/microblaze/lib/board.c | 2 +- include/configs/microblaze-generic.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c index eeef579..e215684 100644 --- a/arch/microblaze/lib/board.c +++ b/arch/microblaze/lib/board.c @@ -96,7 +96,7 @@ void board_init (void) ulong flash_size = 0; #endif asm ("nop"); /* FIXME gd is not initialize - wait */ - memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE); + memset ((void *)gd, 0, 2 * GENERATED_GBL_DATA_SIZE); /* gd/bd space */ gd->bd = (bd_t *) (gd + 1); /* At end of global data */ gd->baudrate = CONFIG_BAUDRATE; bd = gd->bd; diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 75e4e07..ec152bf 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -135,14 +135,17 @@ #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_SDRAM_BASE + 0x1000)
/* global pointer */ +/* Allocate 2 * GENERATED_GBL_DATA_SIZE (0x40) size for global data and + * board info structure(size 0x24). Would be better to use sizeof but + * this requires more changes to asm code */ /* start of global data */ #define CONFIG_SYS_GBL_DATA_OFFSET \ (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE \ - - GENERATED_GBL_DATA_SIZE) + - 2 * GENERATED_GBL_DATA_SIZE)
/* monitor code */ #define SIZE 0x40000 -#define CONFIG_SYS_MONITOR_LEN (SIZE - GENERATED_GBL_DATA_SIZE) +#define CONFIG_SYS_MONITOR_LEN SIZE #define CONFIG_SYS_MONITOR_BASE \ (CONFIG_SYS_GBL_DATA_OFFSET - CONFIG_SYS_MONITOR_LEN) #define CONFIG_SYS_MONITOR_END \

Dear Michal Simek,
In message 1292933384-3032-3-git-send-email-monstr@monstr.eu you wrote:
Patch "Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value" (sha1: 25ddd1fb0a2281b182529afbc8fda5de2dc16d96) introduce GENERATED_GBL_DATA_SIZE which is sizeof aligned gd_t (currently 0x40). Microblaze configs used 0x40(128) because this place also contained board info structure which lies on the top of ram.
This patch is fixing this scheme by extending CONFIG_SYS_GBL_DATA_OFFSET value. Doubled GENERATED_GBL_DATA_SIZE size is enough to store gd_t and bd_t structures.
No, I will not accept this.
Please do not make assumptions abouth the size of bd_t compared to GENERATED_GBL_DATA_SIZE. Use the correct size instead, as you can easily get using the sizeof() operator (plus some padding eventually to guarantee alignment, if needed).
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Dear Michal Simek,
In message 1292933384-3032-3-git-send-email-monstr@monstr.eu you wrote:
Patch "Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value" (sha1: 25ddd1fb0a2281b182529afbc8fda5de2dc16d96) introduce GENERATED_GBL_DATA_SIZE which is sizeof aligned gd_t (currently 0x40). Microblaze configs used 0x40(128) because this place also contained board info structure which lies on the top of ram.
This patch is fixing this scheme by extending CONFIG_SYS_GBL_DATA_OFFSET value. Doubled GENERATED_GBL_DATA_SIZE size is enough to store gd_t and bd_t structures.
No, I will not accept this.
Please do not make assumptions abouth the size of bd_t compared to GENERATED_GBL_DATA_SIZE. Use the correct size instead, as you can easily get using the sizeof() operator (plus some padding eventually to guarantee alignment, if needed).
I would like to do it but it is not easy to use sizeof because there are some dependencies in macros in common.h(lines 193-201) because I am using CONFIG_SYS_GBL_DATA_OFFSET for monitor/malloc areas.
The best will be to be able to generate this value in lib/asm-offsets.c
Not sure if you are ok with it.
diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 2209561..36fc198 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -24,6 +24,8 @@ int main(void) /* Round up to make sure size gives nice stack alignment */ DEFINE(GENERATED_GBL_DATA_SIZE, (sizeof(struct global_data)+15) & ~15); + DEFINE(GENERATED_BD_INFO_SIZE, + (sizeof(struct bd_info)+15) & ~15);
return 0; }
Michal

Dear Michal Simek,
In message 4D10A473.2030202@monstr.eu you wrote:
I would like to do it but it is not easy to use sizeof because there are some dependencies in macros in common.h(lines 193-201) because I am using CONFIG_SYS_GBL_DATA_OFFSET for monitor/malloc areas.
The best will be to be able to generate this value in lib/asm-offsets.c
Not sure if you are ok with it.
Yes, this is OK.
diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 2209561..36fc198 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -24,6 +24,8 @@ int main(void) /* Round up to make sure size gives nice stack alignment */ DEFINE(GENERATED_GBL_DATA_SIZE, (sizeof(struct global_data)+15) & ~15);
DEFINE(GENERATED_BD_INFO_SIZE,
(sizeof(struct bd_info)+15) & ~15); return 0;
}
This patch is white-space corrupted, though.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Dear Michal Simek,
In message 4D10A473.2030202@monstr.eu you wrote:
I would like to do it but it is not easy to use sizeof because there are some dependencies in macros in common.h(lines 193-201) because I am using CONFIG_SYS_GBL_DATA_OFFSET for monitor/malloc areas.
The best will be to be able to generate this value in lib/asm-offsets.c
Not sure if you are ok with it.
Yes, this is OK.
diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 2209561..36fc198 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -24,6 +24,8 @@ int main(void) /* Round up to make sure size gives nice stack alignment */ DEFINE(GENERATED_GBL_DATA_SIZE, (sizeof(struct global_data)+15) & ~15);
DEFINE(GENERATED_BD_INFO_SIZE,
(sizeof(struct bd_info)+15) & ~15); return 0;
}
This patch is white-space corrupted, though.
It wasn't intended as a patch just show if this approach will be acceptable.
I will generate patches based on this.
Thanks, Michal

Dear Michal Simek,
In message 1292933384-3032-2-git-send-email-monstr@monstr.eu you wrote:
Microblaze implement enable/disable interrupts through MSR that's why disable_interrupts function should return 1.
Signed-off-by: John Linn john.linn@xilinx.com Signed-off-by: Michal Simek monstr@monstr.eu
arch/microblaze/cpu/interrupts.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c index e9d53c1..331746c 100644 --- a/arch/microblaze/cpu/interrupts.c +++ b/arch/microblaze/cpu/interrupts.c @@ -42,7 +42,7 @@ void enable_interrupts (void) int disable_interrupts (void) { MSRCLR(0x2);
- return 0;
- return 1;
}
I think this is wrong. disable_interrupts() should return 1 only if interrupts were enabled before, so code like this can make sure that some parts are run with interrupts disabled, but then restore the previous state, no matter if this had interrupts on or off:
int flag = disable_interrupts(); ... do something ... if (flag) enable_interrupts();
With your code, we would ALWAYS enable interrupts, even if these were off before.
For reference, see for example arch/powerpc/lib/interrupts.c
Best regards,
Wolfgang Denk
participants (2)
-
Michal Simek
-
Wolfgang Denk