Skip to contentSkip to conversation

microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE

PATCH In review Ovidiu Panait 3 participants 6 messages Aug 29, 2022 – Aug 31, 2022 Microblaze architecture

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE

These macros are not used anymore in microblaze code since commit f113d7d303467 ("Convert CONFIG_SPL_STACK to Kconfig"), so remove them.

Fixes f113d7d303467 ("Convert CONFIG_SPL_STACK to Kconfig")

---

Changes in v2:
Improved commit message, added "Fixes" tag.

 include/configs/microblaze-generic.h | 6 ------
 1 file changed, 6 deletions(-)
include/configs/microblaze-generic.h +0 -6
index 8eaac4f8bc..dfae8cea7b 100644
@@ -97,10 +97,4 @@
 
 #define CONFIG_SYS_UBOOT_BASE		CONFIG_SYS_TEXT_BASE
 
-/* SP location before relocation, must use scratch RAM */
-/* BRAM start */
-#define CONFIG_SYS_INIT_RAM_ADDR	0x0
-/* BRAM size - will be generated */
-#define CONFIG_SYS_INIT_RAM_SIZE	0x100000
-
 #endif	/* __CONFIG_H */
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/4 cpu: microblaze: add error handling in microblaze_cpu_get_desc()

Check snprintf() return value for errors.

Make microblaze_cpu_get_desc() directly return snprintf() error code if ret < 0. Otherwise, if the return value is greater than or equal to size, the resulting string is truncated, so return -ENOSPC.

Fixes 816226d27e ("cpu: add CPU driver for microblaze")

---

Changes in v2:
New patch.

 drivers/cpu/microblaze_cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpu/microblaze_cpu.c +3 -1
index 969a1047e5..b9d0792822 100644
@@ -97,8 +97,10 @@ static int microblaze_cpu_get_desc(const struct udevice *dev, char *buf,
 	ret = snprintf(buf, size,
 		       "MicroBlaze @ %uMHz, Rev: %s, FPGA family: %s",
 		       cpu_freq_mhz, cpu_ver, fpga_family);
+	if (ret < 0)
+		return ret;
 
-	return 0;
+	return (ret >= size) ? -ENOSPC : 0;
 }
 
 static int microblaze_cpu_get_info(const struct udevice *dev,
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 3/4 cmd: bdinfo: introduce bdinfo_print_size() helper

In reply to Ovidiu Panait

Add bdinfo_print_size() helper to display size variables (such as cache sizes) in bdinfo format. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB", "xxx GiB", etc as needed;

---

Changes in v2:
Added "Reviewed-by" tag from Simon.

 cmd/bdinfo.c   |  7 +++++++
 include/init.h | 13 +++++++++++++
 2 files changed, 20 insertions(+)
cmd/bdinfo.c +7 -0
index 37cd8a57eb..9e23c4dd8f 100644
@@ -16,9 +16,16 @@
 #include <vsprintf.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
+#include <display_options.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void bdinfo_print_size(const char *name, uint64_t size)
+{
+	printf("%-12s= ", name);
+	print_size(size, "\n");
+}
+
 void bdinfo_print_num_l(const char *name, ulong value)
 {
 	printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
include/init.h +13 -0
index 7b8f62c121..02bb4ce13e 100644
@@ -343,6 +343,19 @@ void bdinfo_print_num_ll(const char *name, unsigned long long value);
 /* Print a clock speed in MHz */
 void bdinfo_print_mhz(const char *name, unsigned long hz);
 
+/**
+ * bdinfo_print_size - print size variables in bdinfo format
+ * @name:	string to print before the size
+ * @size:	size to print
+ *
+ * Helper function for displaying size variables as properly formatted bdinfo
+ * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
+ * "xxx GiB", etc. as needed;
+ *
+ * For use in arch_print_bdinfo().
+ */
+void bdinfo_print_size(const char *name, uint64_t size);
+
 /* Show arch-specific information for the 'bd' command */
 void arch_print_bdinfo(void);
 
Signature · 1 line
2.25.1
Reviewed-by on v2 3/4
#3 lore raw

RE: [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper

Quoted 12 lines

-----Original Message-----
From: Ovidiu Panait <[email protected]>
Sent: 2022年8月30日 1:02
To: [email protected]
Cc: Ovidiu Panait <[email protected]>; Simon Glass <[email protected]>; Andy Shevchenko <[email protected]>; Dzmitry Sankouski <[email protected]>; Heinrich Schuchardt <[email protected]>; Jason Liu <[email protected]>
Subject: [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper

Quoted 2 lines

Add bdinfo_print_size() helper to display size variables (such as cache sizes) in bdinfo format. The size is printed as "xxx Bytes", "xxx KiB",

"xxx MiB",

Quoted 4 lines

"xxx GiB", etc as needed;

Quoted 9 lines

---

Changes in v2:
Added "Reviewed-by" tag from Simon.

 cmd/bdinfo.c   |  7 +++++++
 include/init.h | 13 +++++++++++++
 2 files changed, 20 insertions(+)

The patch looks good to me.

Quoted 9 lines
cmd/bdinfo.c index 37cd8a57eb..9e23c4dd8f renamed from cmd/bdinfo.c +0 -0

100644

cmd/bdinfo.c +1 -0
@@ -16,9 +16,16 @@
 #include <vsprintf.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
+#include <display_options.h>

cmd/bdinfo.c line 29

Quoted 10 lines
cmd/bdinfo.c +5 -0
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void bdinfo_print_size(const char *name, uint64_t size) {
+	printf("%-12s= ", name);
+	print_size(size, "\n");
+}
+
 void bdinfo_print_num_l(const char *name, ulong value)  {
 	printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);

diff --git

Quoted 27 lines

a/include/init.h b/include/init.h index 7b8f62c121..02bb4ce13e 100644

include/init.h +14 -0
@@ -343,6 +343,19 @@ void bdinfo_print_num_ll(const char *name,
 unsigned long long value);
 /* Print a clock speed in MHz */
 void bdinfo_print_mhz(const char *name, unsigned long hz);
 
+/**
+ * bdinfo_print_size - print size variables in bdinfo format
+ * @name:	string to print before the size
+ * @size:	size to print
+ *
+ * Helper function for displaying size variables as properly formatted
+bdinfo
+ * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
+ * "xxx GiB", etc. as needed;
+ *
+ * For use in arch_print_bdinfo().
+ */
+void bdinfo_print_size(const char *name, uint64_t size);
+
 /* Show arch-specific information for the 'bd' command */  void

arch_print_bdinfo(void);

--
2.25.1

#4 lore raw

PATCH v2 4/4 microblaze: add arch_print_bdinfo() implementation

In reply to Ovidiu Panait

Allow bdinfo command to print icache/dcache information:
U-Boot-mONStR> bdinfo
boot_params = 0x00000000

DRAM bank   = 0x00000000
-> start    = 0x04000000
-> size     = 0x04000000
flashstart  = 0x00000000
flashsize   = 0x00000000
flashoffset = 0x00000000
baudrate    = 9600 bps
relocaddr   = 0x07f76000
reloc off   = 0x02f76000
Build       = 32-bit
current eth = unknown
ethaddr     = (not set)
IP addr     = <NULL>
fdt_blob    = 0x07fec7e0
new_fdt     = 0x00000000
fdt_size    = 0x00000000

lmb_dump_all:
memory.cnt = 0x1
memory[0] [0x4000000-0x7ffffff], 0x04000000 bytes flags: 0
reserved.cnt = 0x1
reserved[0] [0x7e94b8c-0x7ffffff], 0x0016b474 bytes flags: 0
devicetree = embed
icache = 32 KiB
icache line = 4 Bytes
dcache = 32 KiB
dcache line = 4 Bytes

---

(no changes since v1)

 arch/microblaze/lib/Makefile |  1 +
 arch/microblaze/lib/bdinfo.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 arch/microblaze/lib/bdinfo.c
arch/microblaze/lib/Makefile +1 -0
index 05f447abba..dfd8135f4f 100644
@@ -4,4 +4,5 @@
 # Wolfgang Denk, DENX Software Engineering, [email protected].
 
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_BDI) += bdinfo.o
 obj-y	+= muldi3.o
arch/microblaze/lib/bdinfo.c new file +24 -0
new file mode 100644
index 0000000000..41b7a216a4
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022, Ovidiu Panait <[email protected]>
+ */
+#include <init.h>
+#include <asm/cpuinfo.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_print_bdinfo(void)
+{
+	struct microblaze_cpuinfo *ci = gd_cpuinfo();
+
+	if (ci->icache_size) {
+		bdinfo_print_size("icache", ci->icache_size);
+		bdinfo_print_size("icache line", ci->icache_line_length);
+	}
+
+	if (ci->dcache_size) {
+		bdinfo_print_size("dcache", ci->dcache_size);
+		bdinfo_print_size("dcache line", ci->dcache_line_length);
+	}
+}
Signature · 1 line
2.25.1
#5 lore raw
In reply to Ovidiu Panait
Quoted 18 lines · Ovidiu Panait

These macros are not used anymore in microblaze code since commit f113d7d303467 ("Convert CONFIG_SPL_STACK to Kconfig"), so remove them.

Fixes f113d7d303467 ("Convert CONFIG_SPL_STACK to Kconfig")

---

Changes in v2:
Improved commit message, added "Fixes" tag.

  include/configs/microblaze-generic.h | 6 ------
  1 file changed, 6 deletions(-)
include/configs/microblaze-generic.h +0 -0
index 8eaac4f8bc..dfae8cea7b 100644

include/configs/microblaze-generic.h line 100

Quoted 10 lines
include/configs/microblaze-generic.h +0 -6
@@ -97,10 +97,4 @@
 
  #define CONFIG_SYS_UBOOT_BASE		CONFIG_SYS_TEXT_BASE
 
-/* SP location before relocation, must use scratch RAM */
-/* BRAM start */
-#define CONFIG_SYS_INIT_RAM_ADDR	0x0
-/* BRAM size - will be generated */
-#define CONFIG_SYS_INIT_RAM_SIZE	0x100000
-
  #endif	/* __CONFIG_H */

Applied all.
M