u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE
@ 2022-08-29 17:02 Ovidiu Panait
  2022-08-29 17:02 ` [PATCH v2 2/4] cpu: microblaze: add error handling in microblaze_cpu_get_desc() Ovidiu Panait
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ovidiu Panait @ 2022-08-29 17:02 UTC (permalink / raw)
  To: u-boot; +Cc: Ovidiu Panait, Michal Simek, Michal Simek

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")
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---

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

 include/configs/microblaze-generic.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 8eaac4f8bc..dfae8cea7b 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -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 */
-- 
2.25.1


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

* [PATCH v2 2/4] cpu: microblaze: add error handling in microblaze_cpu_get_desc()
  2022-08-29 17:02 [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Ovidiu Panait
@ 2022-08-29 17:02 ` Ovidiu Panait
  2022-08-29 17:02 ` [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper Ovidiu Panait
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ovidiu Panait @ 2022-08-29 17:02 UTC (permalink / raw)
  To: u-boot; +Cc: Ovidiu Panait, Michal Simek, Michal Simek

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")
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---

Changes in v2:
New patch.

 drivers/cpu/microblaze_cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cpu/microblaze_cpu.c b/drivers/cpu/microblaze_cpu.c
index 969a1047e5..b9d0792822 100644
--- a/drivers/cpu/microblaze_cpu.c
+++ b/drivers/cpu/microblaze_cpu.c
@@ -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,
-- 
2.25.1


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

* [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper
  2022-08-29 17:02 [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Ovidiu Panait
  2022-08-29 17:02 ` [PATCH v2 2/4] cpu: microblaze: add error handling in microblaze_cpu_get_desc() Ovidiu Panait
@ 2022-08-29 17:02 ` Ovidiu Panait
  2022-08-30  1:50   ` Jason Liu
  2022-08-29 17:02 ` [PATCH v2 4/4] microblaze: add arch_print_bdinfo() implementation Ovidiu Panait
  2022-08-31  8:21 ` [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Michal Simek
  3 siblings, 1 reply; 6+ messages in thread
From: Ovidiu Panait @ 2022-08-29 17:02 UTC (permalink / raw)
  To: u-boot
  Cc: Ovidiu Panait, Simon Glass, Andy Shevchenko, Dzmitry Sankouski,
	Heinrich Schuchardt, Jason Liu

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;

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---

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

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

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 37cd8a57eb..9e23c4dd8f 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -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);
diff --git a/include/init.h b/include/init.h
index 7b8f62c121..02bb4ce13e 100644
--- a/include/init.h
+++ b/include/init.h
@@ -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


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

* [PATCH v2 4/4] microblaze: add arch_print_bdinfo() implementation
  2022-08-29 17:02 [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Ovidiu Panait
  2022-08-29 17:02 ` [PATCH v2 2/4] cpu: microblaze: add error handling in microblaze_cpu_get_desc() Ovidiu Panait
  2022-08-29 17:02 ` [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper Ovidiu Panait
@ 2022-08-29 17:02 ` Ovidiu Panait
  2022-08-31  8:21 ` [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Michal Simek
  3 siblings, 0 replies; 6+ messages in thread
From: Ovidiu Panait @ 2022-08-29 17:02 UTC (permalink / raw)
  To: u-boot; +Cc: Ovidiu Panait, Michal Simek, Michal Simek

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

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---

(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

diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile
index 05f447abba..dfd8135f4f 100644
--- a/arch/microblaze/lib/Makefile
+++ b/arch/microblaze/lib/Makefile
@@ -4,4 +4,5 @@
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_BDI) += bdinfo.o
 obj-y	+= muldi3.o
diff --git a/arch/microblaze/lib/bdinfo.c b/arch/microblaze/lib/bdinfo.c
new file mode 100644
index 0000000000..41b7a216a4
--- /dev/null
+++ b/arch/microblaze/lib/bdinfo.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com>
+ */
+#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);
+	}
+}
-- 
2.25.1


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

* RE: [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper
  2022-08-29 17:02 ` [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper Ovidiu Panait
@ 2022-08-30  1:50   ` Jason Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Liu @ 2022-08-30  1:50 UTC (permalink / raw)
  To: Ovidiu Panait, u-boot
  Cc: Simon Glass, Andy Shevchenko, Dzmitry Sankouski, Heinrich Schuchardt

[-- Attachment #1: Type: text/plain, Size: 2519 bytes --]



> -----Original Message-----
> From: Ovidiu Panait <ovpanait@gmail.com>
> Sent: 2022年8月30日 1:02
> To: u-boot@lists.denx.de
> Cc: Ovidiu Panait <ovpanait@gmail.com>; Simon Glass <sjg@chromium.org>;
> Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Dzmitry Sankouski
> <dsankouski@gmail.com>; Heinrich Schuchardt <xypron.glpk@gmx.de>; Jason
> Liu <jason.hui.liu@nxp.com>
> Subject: [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper
> 
> 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;
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
> ---
> 
> 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.

Reviewed-by: Jason Liu <jason.hui.liu@nxp.com>

> diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 37cd8a57eb..9e23c4dd8f
> 100644
> --- a/cmd/bdinfo.c
> +++ b/cmd/bdinfo.c
> @@ -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);
diff --git
> a/include/init.h b/include/init.h index 7b8f62c121..02bb4ce13e 100644
> --- a/include/init.h
> +++ b/include/init.h
> @@ -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


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 9583 bytes --]

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

* Re: [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE
  2022-08-29 17:02 [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Ovidiu Panait
                   ` (2 preceding siblings ...)
  2022-08-29 17:02 ` [PATCH v2 4/4] microblaze: add arch_print_bdinfo() implementation Ovidiu Panait
@ 2022-08-31  8:21 ` Michal Simek
  3 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2022-08-31  8:21 UTC (permalink / raw)
  To: Ovidiu Panait, u-boot; +Cc: Michal Simek



On 8/29/22 19:02, Ovidiu Panait wrote:
> 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")
> Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
> ---
> 
> Changes in v2:
> Improved commit message, added "Fixes" tag.
> 
>   include/configs/microblaze-generic.h | 6 ------
>   1 file changed, 6 deletions(-)
> 
> diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
> index 8eaac4f8bc..dfae8cea7b 100644
> --- a/include/configs/microblaze-generic.h
> +++ b/include/configs/microblaze-generic.h
> @@ -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

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

end of thread, other threads:[~2022-08-31  8:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 17:02 [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Ovidiu Panait
2022-08-29 17:02 ` [PATCH v2 2/4] cpu: microblaze: add error handling in microblaze_cpu_get_desc() Ovidiu Panait
2022-08-29 17:02 ` [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper Ovidiu Panait
2022-08-30  1:50   ` Jason Liu
2022-08-29 17:02 ` [PATCH v2 4/4] microblaze: add arch_print_bdinfo() implementation Ovidiu Panait
2022-08-31  8:21 ` [PATCH v2 1/4] microblaze: drop CONFIG_SYS_INIT_RAM_ADDR and CONFIG_SYS_INIT_RAM_SIZE Michal Simek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).