u-boot/common
Rasmus Villemoes 50128aeb0f cyclic: get rid of cyclic_init()
Currently, we must call cyclic_init() at some point before
cyclic_register() becomes possible. That turns out to be somewhat
awkward, especially with SPL, and has resulted in a watchdog callback
not being registered, thus causing the board to prematurely reset.

We already rely on gd->cyclic reliably being set to NULL by the asm
code that clears all of gd. Now that the cyclic list is a hlist, and
thus an empty list is represented by a NULL head pointer, and struct
cyclic_drv has no other members, we can just as well drop a level of
indirection and put the hlist_head directly in struct
global_data. This doesn't increase the size of struct global_data,
gets rid of an early malloc(), and generates slightly smaller code.

But primarily, this avoids having to call cyclic_init() early; the cyclic
infrastructure is simply ready to register callbacks as soon as we
enter C code.

We can still end up with schedule() being called from asm very early,
so we still need to check that gd itself has been properly initialized
[*], but once it has, gd->cyclic_list is perfectly fine to access, and
will just be an empty list.

As for cyclic_uninit(), it was never really the opposite of
cyclic_init() since it didn't free the struct cyclic_drv nor set
gd->cyclic to NULL. Rename it to cyclic_unregister_all() and use that
in test/, and also insert a call at the end of the board_init_f
sequence so that gd->cyclic_list is a fresh empty list before we enter
board_init_r().

A small piece of ugliness is that I had to add a cast in
cyclic_get_list() to silence a "discards 'volatile' qualifier"
warning, but that is completely equivalent to the existing handling of
the uclass_root_s list_head member.

[*] I'm not really sure where we guarantee that the register used for
gd contains 0 until it gets explicitly initialized, but that must be
the case, otherwise testing gd for being NULL would not make much sense.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
2022-11-02 08:42:03 +01:00
..
eeprom SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
init board_init: Do not reserve MALLOC_F area on stack if non-zero MALLOC_F_ADDR 2022-07-08 12:20:28 -04:00
spl vbe: Add Kconfig options for VPL 2022-10-31 11:03:59 -04:00
autoboot.c Rename CONFIG_SYS_TEXT_BASE to CONFIG_TEXT_BASE 2022-10-31 11:01:31 -04:00
avb_verify.c avb: Fix error when partition not found 2021-03-17 12:50:19 -04:00
bloblist.c bloblist: Drop debugging 2022-10-31 11:02:44 -04:00
board_f.c cyclic: get rid of cyclic_init() 2022-11-02 08:42:03 +01:00
board_info.c board-info: Call sysinfo_detect() before sysinfo_get_str() 2021-07-14 16:48:00 -04:00
board_r.c cyclic: get rid of cyclic_init() 2022-11-02 08:42:03 +01:00
bootstage.c bootstage: Show func name for bootstage_mark/error 2022-08-20 18:07:32 -06:00
bouncebuf.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
cli_hush.c cli: slighly more clear error messages 2021-05-17 17:06:42 -04:00
cli_readline.c cyclic: Use schedule() instead of WATCHDOG_RESET() 2022-09-18 10:26:33 +02:00
cli_simple.c cli: Support macro processing with a fixed-size buffer 2020-12-04 16:10:01 -05:00
cli.c fdt: Start a test for the fdt command 2022-07-26 02:30:56 -06:00
command.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
console.c serial: Implement serial_flush() function for console flush() fallback 2022-09-24 11:34:37 -04:00
cros_ec.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
cyclic.c cyclic: get rid of cyclic_init() 2022-11-02 08:42:03 +01:00
ddr_spd.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
dfu.c cyclic: Use schedule() instead of WATCHDOG_RESET() 2022-09-18 10:26:33 +02:00
dlmalloc.c test: Support testing malloc() failures 2022-09-29 16:07:58 -04:00
dlmalloc.src Consolidate bool type 2013-04-01 16:33:52 -04:00
edid.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
event.c event: Add an event for main_loop 2022-10-31 14:47:32 -04:00
exports.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
fdt_simplefb.c video: Rename CONFIG_DM_VIDEO to CONFIG_VIDEO 2022-10-30 20:07:17 +01:00
fdt_support.c video: cmd: Drop old LCD code 2022-10-30 20:07:17 +01:00
flash.c Audit <flash.h> inclusion 2022-08-04 16:18:47 -04:00
hash.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
hwconfig.c hwconfig: Allow to use restricted env 2022-08-20 18:12:51 -04:00
iomux.c IOMUX: Fix buffer overflow in iomux_replace_device() 2021-04-27 08:05:30 -04:00
iotrace.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
kallsyms.c global: Convert simple_strtoul() with hex to hextoul() 2021-08-02 13:32:14 -04:00
Kconfig vpl: Allow signature verification 2022-10-31 11:04:00 -04:00
kgdb_stubs.c common: Drop asm/ptrace.h from common header 2020-05-18 21:19:23 -04:00
kgdb.c common: board_r: drop initr_kgdb wrapper 2022-01-18 08:31:02 -05:00
log_console.c log: Allow padding of the function name 2021-07-21 10:27:35 -06:00
log_syslog.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
log.c common: Drop display_options.h from common header 2022-08-10 13:46:55 -04:00
main.c efi_loader: split efi_init_obj_list() into two stages 2022-04-23 22:05:41 +02:00
Makefile video: Drop common LCD implementation 2022-10-30 20:07:17 +01:00
malloc_simple.c malloc: Annotate allocator for valgrind 2022-04-11 10:00:30 -04:00
memsize.c common/memsize.c: Fix get_effective_memsize() to check for overflow 2022-09-23 15:11:13 -04:00
menu.c cyclic: Use schedule() instead of WATCHDOG_RESET() 2022-09-18 10:26:33 +02:00
miiphyutil.c Convert CONFIG_PHY_RESET_DELAY to Kconfig 2022-03-25 12:01:15 +00:00
qfw.c x86: qemu: move QFW to its own uclass 2021-04-12 17:44:55 -04:00
s_record.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
scp03.c common: SCP03 control (enable and provision of keys) 2021-03-13 13:14:52 -05:00
splash_source.c splash: get devpart from environment variable 2022-10-30 20:01:40 +01:00
splash.c video: Rename CONFIG_DM_VIDEO to CONFIG_VIDEO 2022-10-30 20:07:17 +01:00
stackprot.c Add support for stack-protector 2021-04-20 07:31:12 -04:00
stdio.c video: Rename CONFIG_DM_VIDEO to CONFIG_VIDEO 2022-10-30 20:07:17 +01:00
system_map.c
update.c Audit <flash.h> inclusion 2022-08-04 16:18:47 -04:00
usb_hub.c usb: Add missing guard around env_get() in usb_hub 2022-10-10 18:08:18 +02:00
usb_kbd.c cyclic: Use schedule() instead of WATCHDOG_RESET() 2022-09-18 10:26:33 +02:00
usb_storage.c blk: Rename if_type to uclass_id 2022-09-25 08:30:05 -06:00
usb.c Convert CONFIG_USB_MAX_CONTROLLER_COUNT to Kconfig 2022-06-28 17:11:48 -04:00
xyzModem.c cyclic: Use schedule() instead of WATCHDOG_RESET() 2022-09-18 10:26:33 +02:00