Skip to contentSkip to conversation

arm: Correct cpu_reset function prototype on some platforms

PATCH In review Tom Rini 3 participants 13 messages Mar 9, 2023 – Mar 23, 2023

Subsystems (4)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/6 arm: Correct cpu_reset function prototype on some platforms

Some platforms were not including <cpu_func.h> which sets the prototype for reset_cpu, and in turn had it set wrong. Correct these cases.

---
 arch/arm/mach-hpe/gxp/reset.c            | 3 ++-
 arch/arm/mach-mediatek/mt7981/init.c     | 3 ++-
 arch/arm/mach-mediatek/mt7986/init.c     | 3 ++-
 board/armltd/corstone1000/corstone1000.c | 3 ++-
 board/bosch/acc/acc.c                    | 3 ++-
 5 files changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-hpe/gxp/reset.c +2 -1
index ce018a35d94d..a147bcac18bd 100644
@@ -7,6 +7,7 @@
  * Author: Jean-Marie Verdun <[email protected]>
  */
 
+#include <cpu_func.h>
 #include <asm/io.h>
 
 #define GXP_CCR	0xc0000000
@@ -16,7 +17,7 @@ void lowlevel_init(void)
 {
 }
 
-void reset_cpu(ulong ignored)
+void reset_cpu(void)
 {
 	writel(1, GXP_CCR);
 
arch/arm/mach-mediatek/mt7981/init.c +2 -1
index d8b10f035808..3c921d6ad5cc 100644
@@ -4,6 +4,7 @@
  * Author: Sam Shih <[email protected]>
  */
 
+#include <cpu_func.h>
 #include <init.h>
 #include <asm/armv8/mmu.h>
 #include <asm/system.h>
@@ -19,7 +20,7 @@ int dram_init(void)
 	return 0;
 }
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 	psci_system_reset();
 }
arch/arm/mach-mediatek/mt7986/init.c +2 -1
index fb74b2f34d7b..9d0c0cdcd08f 100644
@@ -4,6 +4,7 @@
  * Author: Sam Shih <[email protected]>
  */
 
+#include <cpu_func.h>
 #include <init.h>
 #include <asm/armv8/mmu.h>
 #include <asm/system.h>
@@ -19,7 +20,7 @@ int dram_init(void)
 	return 0;
 }
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 	psci_system_reset();
 }
board/armltd/corstone1000/corstone1000.c +2 -1
index 4f4b96a095c2..6ec8e6144fb4 100644
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <dm.h>
 #include <netdev.h>
 #include <dm/platform_data/serial_pl01x.h>
@@ -86,6 +87,6 @@ int dram_init_banksize(void)
 	return 0;
 }
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 }
board/bosch/acc/acc.c +2 -1
index 770ca8b711b0..4a0603d0f3f6 100644
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <bootstage.h>
 #include <dm.h>
 #include <dm/platform_data/serial_mxc.h>
@@ -720,7 +721,7 @@ int board_fit_config_name_match(const char *name)
 	return -1;
 }
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 	puts("Hanging CPU for watchdog reset!\n");
 	hang();
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/6 spl: Add function prototype for spl_mmc_get_uboot_raw_sector

We did not add a prototype for spl_mmc_get_uboot_raw_sector to include/spl.h before, so add and document one now. Correct the incorrect prototype in board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c and ensure that we have spl.h where we define a non-weak spl_mmc_get_uboot_raw_sector as well.

---
 arch/arm/mach-imx/image-container.c                 |  1 +
 board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c |  3 ++-
 include/spl.h                                       | 13 +++++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/mach-imx/image-container.c +1 -0
index 06ee608c4a46..5b059a64292e 100644
@@ -10,6 +10,7 @@
 #include <asm/io.h>
 #include <mmc.h>
 #include <spi_flash.h>
+#include <spl.h>
 #include <nand.h>
 #include <asm/mach-imx/image.h>
 #include <asm/arch/sys_proto.h>
board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +2 -1
index 34109c69ddbd..09e63e052100 100644
@@ -208,7 +208,8 @@ int board_late_init(void)
 
 #ifdef CONFIG_SPL_MMC
 #define UBOOT_RAW_SECTOR_OFFSET 0x40
-unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+					   unsigned long raw_sector)
 {
 	u32 boot_dev = spl_boot_device();
 
include/spl.h +13 -0
index 827bd25c8839..a6cec91f1845 100644
@@ -466,6 +466,19 @@ int spl_mmc_emmc_boot_partition(struct mmc *mmc);
 
 void spl_set_bd(void);
 
+/**
+ * spl_mmc_get_uboot_raw_sector() - Provide raw sector of the start of U-Boot
+ *
+ * This is a weak function which by default will provide the raw sector that is
+ * where the start of the U-Boot image has been written to.
+ *
+ * @mmc: struct mmc that describes the devie where U-Boot resides
+ * @raw_sect: The raw sector number where U-Boot is by default.
+ * Return: The raw sector location that U-Boot resides at
+ */
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+					   unsigned long raw_sect);
+
 /**
  * spl_set_header_raw_uboot() - Set up a standard SPL image structure
  *
Signature · 1 line
2.34.1
author
#2 lore raw

Re: [PATCH 2/6] spl: Add function prototype for spl_mmc_get_uboot_raw_sector

Quoted 7 lines · Tom Rini

We did not add a prototype for spl_mmc_get_uboot_raw_sector to include/spl.h before, so add and document one now. Correct the incorrect prototype in board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c and ensure that we have spl.h where we define a non-weak spl_mmc_get_uboot_raw_sector as well.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
author
#3 lore raw

PATCH 3/6 examples: Don't use LTO for hello_world

In reply to Tom Rini

If we're building U-Boot with LTO, we don't want to use that for examples as it's more work than required.

---
 examples/standalone/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
examples/standalone/Makefile +4 -0
index 5b48a9d43c62..559170dd5c97 100644
@@ -29,6 +29,10 @@ targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y)
 LIBOBJS	:= $(addprefix $(obj)/,$(LIBOBJS-y))
 ELF	:= $(addprefix $(obj)/,$(ELF))
 
+# Disable LTO for these builds
+CFLAGS_REMOVE_hello_world.o := $(LTO_CFLAGS)
+CFLAGS_REMOVE_stubs.o := $(LTO_CFLAGS)
+
 # For PowerPC there's no need to compile standalone applications as a
 # relocatable executable.  The relocation data is not needed, and
 # also causes the entry point of the standalone application to be
Signature · 1 line
2.34.1
Reviewed-by on v1 3/6
#4 lore raw

Re: [PATCH 3/6] examples: Don't use LTO for hello_world

Quoted 8 lines · Tom Rini

If we're building U-Boot with LTO, we don't want to use that for examples as it's more work than required.

---
 examples/standalone/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

BTW linux has a reduced LTO which doesn't take so long to build, but still gets a lot of the benefits.

author
#6 lore raw

PATCH 4/6 compulab: imx8mm-cl-iot-gate: Fix some function declarations in eeprom_spl.c

In reply to Tom Rini

We have a few places here we the function declarations do not match their prototypes in another header, correct them.

---
Cc: "Ying-Chun Liu (PaulLiu)" <[email protected]>

---
 board/compulab/imx8mm-cl-iot-gate/eeprom_spl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
board/compulab/imx8mm-cl-iot-gate/eeprom_spl.c +2 -2
index 90cc33a6e460..b8573aaac283 100644
@@ -101,7 +101,7 @@ u32 cl_eeprom_set_ddrinfo(u32 ddrinfo)
 	return board_ddrinfo;
 };
 
-u8 cl_eeprom_get_subind(void)
+u32 cl_eeprom_get_subind(void)
 {
 	if (cl_eeprom_read(BOARD_DDRSUBIND_OFFSET, (uchar *)&board_ddrsubind, BOARD_DDRSUBIND_SIZE))
 		return 0xff;
@@ -109,7 +109,7 @@ u8 cl_eeprom_get_subind(void)
 	return board_ddrsubind;
 };
 
-u8 cl_eeprom_set_subind(u8 ddrsubind)
+u32 cl_eeprom_set_subind(u32 ddrsubind)
 {
 	if (cl_eeprom_write(BOARD_DDRSUBIND_OFFSET, (uchar *)&ddrsubind, BOARD_DDRSUBIND_SIZE))
 		return 0xff;
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 4/6] compulab: imx8mm-cl-iot-gate: Fix some function declarations in eeprom_spl.c

Hi Tom,

Maybe we should fix the header by changing it to u8? Because the eeprom only returns one byte for the DDRSUBIND value.

Yours,
Paul

Quoted 39 lines · Tom Rini

We have a few places here we the function declarations do not match their prototypes in another header, correct them.

---
Cc: "Ying-Chun Liu (PaulLiu)" <[email protected]>

---
 board/compulab/imx8mm-cl-iot-gate/eeprom_spl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
board/compulab/imx8mm-cl-iot-gate/eeprom_spl.c +1 -1
index 90cc33a6e460..b8573aaac283 100644
@@ -101,7 +101,7 @@ u32 cl_eeprom_set_ddrinfo(u32 ddrinfo)
        return board_ddrinfo;
 };
 
-u8 cl_eeprom_get_subind(void)
+u32 cl_eeprom_get_subind(void)
 {
        if (cl_eeprom_read(BOARD_DDRSUBIND_OFFSET, (uchar
 *)&board_ddrsubind, BOARD_DDRSUBIND_SIZE))
                return 0xff;
board/compulab/imx8mm-cl-iot-gate/eeprom_spl.c +1 -1
@@ -109,7 +109,7 @@ u8 cl_eeprom_get_subind(void)
        return board_ddrsubind;
 };
 
-u8 cl_eeprom_set_subind(u8 ddrsubind)
+u32 cl_eeprom_set_subind(u32 ddrsubind)
 {
        if (cl_eeprom_write(BOARD_DDRSUBIND_OFFSET, (uchar *)&ddrsubind,
 BOARD_DDRSUBIND_SIZE))
                return 0xff;

--
2.34.1

author
#8 lore raw

Re: [PATCH 4/6] compulab: imx8mm-cl-iot-gate: Fix some function declarations in eeprom_spl.c

Quoted 4 lines · Paul Liu

Hi Tom,

Maybe we should fix the header by changing it to u8? Because the eeprom only returns one byte for the DDRSUBIND value.

As the board maintainer, yes, please feel free to submit a new patch to better correct the issue. I hit this as part of enabling LTO for all of ARM, and it errored out here.

Signature · 1 line
Tom
author
#9 lore raw

PATCH 5/6 purism: librem5: Fix a function declaration in spl.c

In reply to Tom Rini

Here we implement usb_gadget_handle_interrupts() but did not include <linux/usb/gadget.h> so did not have the declaration correct. Fix this and add the missing include.

---
Cc: Angus Ainslie <[email protected]>
Cc: [email protected]

---
 board/purism/librem5/spl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/purism/librem5/spl.c +2 -1
index 1a203b459990..90f1fcf415f3 100644
@@ -26,6 +26,7 @@
 #include <usb.h>
 #include <dwc3-uboot.h>
 #include <linux/delay.h>
+#include <linux/usb/gadget.h>
 #include "librem5.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -417,7 +418,7 @@ out:
 	return rv;
 }
 
-int usb_gadget_handle_interrupts(void)
+int usb_gadget_handle_interrupts(int index)
 {
 	dwc3_uboot_handle_interrupt(0);
 	return 0;
Signature · 1 line
2.34.1
author
#10 lore raw

Re: [PATCH 5/6] purism: librem5: Fix a function declaration in spl.c

Quoted 5 lines · Tom Rini

Here we implement usb_gadget_handle_interrupts() but did not include <linux/usb/gadget.h> so did not have the declaration correct. Fix this and add the missing include.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
author
#11 lore raw

PATCH 6/6 RFC: arm: Enable LTO by default

In reply to Tom Rini

At this point, we have had wide enough testing of LTO on ARM platforms that we hope to have covered all of the issues that linking in manner exposes in terms of run-time failures. Note that on 32bit ARM we must use our private libgcc in order to ensure that we do not have a size mismatch over wchar_t, and we're missing some thumb1 assembly functions for LTO to be usable in that case. Enable this by default, on ARM.

---
This is not yet ready to go. As noted in this[0] thread there's some issues with weak functions. In addition, platforms such as socfpga_n5x_vab (and _atf) have their SPL grow and meesc_dataflash grows itself. This seems to be in part due to how the sha1_process_one/sha256_process_one abstractions interact with LTO. There might be more issues like this, but it's harder to spot just due to how LTO will essentially inline a large number of functions.

Further, my pine64_plus fails to boot with LTO and loops on:
U-Boot SPL 2023.04-rc3-00196-gbe79da84c30b-dirty (Mar 08 2023 - 16:10:56 -0500)
DRAM: 1024 MiB
Trying to boot from MMC1
Trying to boot from MMC1 (repeats)

So this very much isn't ready for everyone, just yet.

[0]: https://lore.kernel.org/u-boot/[email protected]/

---
 Kconfig                    | 2 ++
 configs/qemu_arm_defconfig | 1 +
 2 files changed, 3 insertions(+)
Kconfig +2 -0
index a75cce7e28fb..14693a92c1b3 100644
@@ -121,6 +121,8 @@ config ARCH_SUPPORTS_LTO
 config LTO
 	bool "Enable Link Time Optimizations"
 	depends on ARCH_SUPPORTS_LTO
+	select USE_PRIVATE_LIBGCC if ARM && !ARM64
+	default y if ARM && !(SYS_THUMB_BUILD || SPL_SYS_THUMB_BUILD)
 	help
 	  This option enables Link Time Optimization (LTO), a mechanism which
 	  allows the compiler to optimize between different compilation units.
configs/qemu_arm_defconfig +1 -0
index aa6bf931b5fd..820f78e76311 100644
@@ -16,6 +16,7 @@ CONFIG_SYS_LOAD_ADDR=0x40200000
 CONFIG_ENV_ADDR=0x4000000
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
+# CONFIG_LTO is not set
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
Signature · 1 line
2.34.1