summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/rockchip'Sascha Hauer2021-11-151-0/+27
|\
| * cdev: Add function to get unallocated space at start of deviceSascha Hauer2021-10-121-0/+27
| | | | | | | | | | | | | | | | | | | | | | On several SoCs barebox is written to the raw device in front of the first partition. So far we blindly trust that there is enough space available for the barebox image. Start changing this by adding a function that retrieves the available space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20211012073352.4071559-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-11-156-74/+6
|\ \
| * | include: add dedicated header for printf/printkAhmad Fatoum2021-11-015-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Including <stdio.h> for printf is a bit problematic, because it pulls in other headers for <console.h>, which includes quite a few more headers as well. To make it easier to share code between barebox and host tools make <printk.h> the new minimal header for printf and move the extra logging stuff into <linux/printk.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | devfs: Do not create overlapping partitionsSascha Hauer2021-10-121-69/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now it has been possible to create overlapping partitions. Go away from that and allow to create partitions only in unallocated areas of a device. This lowers the risk of having inconsistent partitioning and increases the chance that inconsistent partitioning is recognized by the user. We had explicit overlap checking for the environment partition which becomes unnecessary with this change and is removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20211011073025.4187545-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/imx'Sascha Hauer2021-11-151-1/+1
|\ \ \
| * | | imd: reuse imd_is_crc32()Antony Pavlov2021-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Link: https://lore.barebox.org/20211028012816.929611-3-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | efi: efi-iomem: fix erroneous use of IS_ENABLED()Ahmad Fatoum2021-11-151-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IS_ENABLED() is supposed to be used for CONFIG_ macros, which a local #define DEBUG isn't. Fix by using __is_defined instead. The reason, we have this as a compile time switch is that the memory map can be very extensive (> 100 entries) and is usually only interesting during development. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211115090023.4192546-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | efi: efi-iomem: don't add EFI loader code/data as memory banksAhmad Fatoum2021-11-151-2/+6
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The loader code and data memory descriptors describe code used by the currently running barebox instance. This is already used memory, so registering it as available SDRAM is wrong. Instead, just reserve the IO MEM region for informational purposes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211115090023.4192546-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | common: Kconfig: fix indentationUlrich Ölmann2021-10-121-3/+3
| | | | | | | | | | | | | | | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Link: https://lore.barebox.org/20211012083920.14092-2-u.oelmann@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | common: Kconfig: fix typosUlrich Ölmann2021-10-121-13/+13
| |/ |/| | | | | | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Link: https://lore.barebox.org/20211012083920.14092-1-u.oelmann@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | console: fixup add new CONFIG_CONSOLE_DISABLE_INPUT optionAhmad Fatoum2021-10-111-1/+1
|/ | | | | | | | Fix typo in CONFIG_CONSOLE_DISABLE_INPUT case for simple console. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211002174417.27020-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/targettools'Sascha Hauer2021-10-071-29/+0
|\
| * common: add new menu for target toolsAhmad Fatoum2021-10-021-26/+0
| | | | | | | | | | | | | | | | | | | | We have four target tools and will add 3 more in a follow up commit. Add a new menu to collect them. Acked-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210917174127.23345-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: remove !SANDBOX dependency for target toolsAhmad Fatoum2021-10-021-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | d4aa01503348 ("common: add dependency !SANDBOX on target tools") and later commits disabled building the target tools with sandbox, because the build failed when they were enabled. This has been fixed since then. Remove the limitation, so target tools can be cross-compiled when using the ARCH=sandbox. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210917174127.23345-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/riscv'Sascha Hauer2021-10-072-4/+10
|\ \
| * | RISC-V: add LiteX SoC and linux-on-litex-vexriscv supportAntony Pavlov2021-10-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LiteX is a Migen-based System on Chip, supporting softcore VexRiscv CPU, a 32-bits Linux Capable RISC-V CPU. See https://github.com/enjoy-digital/litex and https://github.com/litex-hub/linux-on-litex-vexriscv for details. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Acked-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210817101104.114945-8-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | console: support set baudrate for fixed baudrate driversAntony Pavlov2021-10-041-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are console drivers (linux, virtio, litex) that don't support baud rate setting and has no setbrg (set baudrate) callback, so console_set_baudrate() returns -ENOSYS. At the other hand console_set_baudrate() SUCCESS return value is needed for the loadx/loady commands correct work. See discussion here: http://lists.infradead.org/pipermail/barebox/2021-May/036237.html Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210817101104.114945-4-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc'Sascha Hauer2021-10-079-29/+98
|\ \ \ | |/ / |/| |
| * | state: backend_raw: fix ignoring unpack failuresMarco Felsch2021-10-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is required to inform the state framework that the state variable set have changed and we need to write the new variable set. Without this fix the new variable set is never written since the state never sets dirty=1 and so state_save() will return early without saving the new variable set. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20210825144904.4929-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: Select CRC32 dependency for DEFAULT_ENVIRONMENTJules Maselbas2021-10-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The DEFAULT_ENVIRONMENT config enable the compilation of envfs-core.c which depends on CRC32. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20210907124520.24581-1-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | console: add new CONFIG_CONSOLE_DISABLE_INPUT optionRouven Czerwinski2021-10-054-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add CONFIG_CONSOLE_DISABLE_INPUT to initialize the consoles without input support, making default bootup effectively non-interactive. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Christian Melki <christian.melki@t2data.com> Link: https://lore.barebox.org/20210915123644.1292607-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | kbuild: dtc: Allow adding device tree fragments via configTrent Piepho2021-10-051-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a config variable that allows adding additional fragments to the Barebox device tree(s). Example uses are adjusting the flash partition layout, adding barebox state variables, or adding an I2C device. These can be now be done with build configuration only, without needing to patch the existing dts files in the Barebox source. The advantage is greater when an external build system, such as Yocto or Buildroot, is being used to build Barebox. The build system can drop in a dts fragment to partition flash and build from unaltered Barebox source. This avoids the need for cumbersome maintenance of patch files to modify Barebox's source for each flash partition layout. Preprocessing the dts file gains another layer, where a generated dts source consisting of an include directive for the original dts source is followed by more includes for each fragment. This is piped to the existing preprocessor call on stdin to avoid another temporary file. cpp/dtc will correctly identify errors in the source files they occur in. The -MT option is used so the cpp auto-dependencies reference the original dts source and not the generated code passed on stdin. A preprocessor macro named after the base dts file, e.g. foo-bar.dts will define foo_bar_dts, will be defined so that the fragments can possibly operate differently based on which image's dts is being built. Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com> Link: https://lore.barebox.org/20210922181336.1350460-1-trent.piepho@igorinstitute.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fastboot: use file_list_parse_null()Rouven Czerwinski2021-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case an invalid file list is passed to file_list_parse(), it will return an error, i.e. by passing "/dev/mmc1(emmc) /dev/mmc1.1(root)", the error here being that the entries are not comma separated and file_list_parse will try to parse ' ' as a flag. The fastboot code didn't handle this, leading to the following error: ERROR: file_list: Unknown flag ' ' ERROR: file_list: parse error unable to handle paging request at address 0xfffffff2 pc : [<8fe26a20>] lr : [<8fe0f965>] sp : 8ffeff50 ip : 8ffef714 fp : 00079bda r10: 001b9ff8 r9 : 8fea7eec r8 : 00000001 r7 : 00000000 r6 : 00000001 r5 : 00000000 r4 : 8813eab0 r3 : ffffffea r2 : 00020000 r1 : 00000001 r0 : 8813eab0 Flags: nzCv IRQs off FIQs off Mode SVC_32 WARNING: [<8fe26a20>] (usb_multi_count_functions+0xc/0x2a) from [<8fe0f965>] (usbgadget_register+0x79/0xf4) WARNING: [<8fe0f965>] (usbgadget_register+0x79/0xf4) from [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) WARNING: [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) from [<8fe4d437>] (param_int_set+0x4b/0xb0) WARNING: [<8fe4d437>] (param_int_set+0x4b/0xb0) from [<8fe4d899>] (dev_set_param+0x4d/0x64) WARNING: [<8fe4d899>] (dev_set_param+0x4d/0x64) from [<8fe066f1>] (globalvar_add_bool+0x49/0x54) WARNING: [<8fe066f1>] (globalvar_add_bool+0x49/0x54) from [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) WARNING: [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) from [<8fe01081>] (start_barebox+0x35/0x6c) WARNING: [<8fe01081>] (start_barebox+0x35/0x6c) from [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) WARNING: [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) from [<8fe00005>] (__bare_init_start+0x1/0xc) WARNING: [<8fe64e3d>] (unwind_backtrace+0x1/0x78) from [<8fe01385>] (panic+0x1d/0x34) WARNING: [<8fe01385>] (panic+0x1d/0x34) from [<8fe62723>] (do_exception+0xf/0x14) WARNING: [<8fe62723>] (do_exception+0xf/0x14) from [<8fe62791>] (do_data_abort+0x21/0x34) WARNING: [<8fe62791>] (do_data_abort+0x21/0x34) from [<8fe624d4>] (do_abort_6+0x48/0x54) Use file_list_parse_null instead of file_list_parse to get a NULL pointer if there is a parse error. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210810052928.101783-2-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | file_list: add file_list_parse_null()Rouven Czerwinski2021-10-052-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the usbgadget parse() function to file_list and rename it to file_list_parse_null() which will return a NULL pointer instead of an error. Also adjust the callers in the usbgadget code. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210810052928.101783-1-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | hush: fix conditional statements exit codeAndrej Picej2021-10-051-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix conditional statements ("if" , "elif", "while" and "until") exit code when used in scripts. Before the change, when conditional statement evaluated false just before the end of the script, script's exit code would have been 1 (instead of 0), which implies error condition. This is not expected nor desired behavior, so correct it by handling such cases and passing exit code 0 (SUCCESS) instead in such situations. Signed-off-by: Andrej Picej <andrej.picej@norik.com> Link: https://lore.barebox.org/20210810054712.1547433-1-andrej.picej@norik.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | blspec: fix use-after-free of firmware search pathAhmad Fatoum2021-10-042-4/+4
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | firmware_set_searchpath() is used to temporarily extend firmware search path when parsing boot spec files. It does so by first freeing the original firmware pointer and then storing a pointer to a copy of the new search path. firmware_get_searchpath() returns this pointer without copying meaning that following sequence causes a use-after-free: old_fws = firmware_get_searchpath(); firmware_set_searchpath(fws); /* calls free(old_fws) */ firmware_set_searchpath(old_fws); Fix this by keeping around a copy of the search path. Fixes: dfebbb0a5944 ("blspec: Set firmware searchpath") Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210913082957.364440-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: fat: pbl: support >32M alignment for first partitionAhmad Fatoum2021-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LBA of the first absolute sector in a partition is a 32-bit field at offset 0x8 of a partition entry. The first such partition entry is at offset 446 of the MBR. The DOS partition parser adheres to this scheme, but the FAT code contains a very basic partition parser as well that kicks in when a disk couldn't be mounted as FAT: It will seek to the first FAT partition in a MBR and mount that. This only happens with FAT PBL, because in barebox proper, we use the actual partition parser. The partition parser in FAT assumed starting LBA to be a 16-bit value and thus failed to load a first FAT partition located more than 0x10000 sectors into the image. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922065000.20970-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: menutree: prevent read of uninitialized memory in error pathAhmad Fatoum2021-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | globfree() is a no-op if glob_t::gl_pathv is NULL. A failed glob may not always initialize this member however, leading to potential memory corruption. Fix this by initializing glob_t. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922071440.31949-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | startup: don't read glob_t if glob("/env/init/*") failsAhmad Fatoum2021-10-011-2/+2
|/ | | | | | | | | | | | globfree() is a no-op if glob_t::gl_pathv is NULL. A failed glob may not always initialize this member however, leading to potential memory corruption. Fix this by only freeing the glob_t if glob() had succeeded. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922071440.31949-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fit: Use digest_verify() to verify hashesSascha Hauer2021-07-301-7/+1
| | | | | | | Use digest_verify() to verify hashes rather than open code it. This simplifies the code a bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* password: Use crypto_memneq() to compare hashesSascha Hauer2021-07-301-2/+3
| | | | | | | | Cryptographic verifications should be time-constant so that an attacker cannot get information about the secrets used by observing the system, so use crypto_memneq() rather than memcmp() to compare password hashes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: support deep probeAhmad Fatoum2021-07-181-0/+4
| | | | | | | | | | | | With deep probe, drivers registered before of_populate_initcall must themselves take care to ensure their dependencies had a chance to probe. For barebox-state, this means the backend partition provider must be probed. Do so by calling of_partition_ensure_probed on it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628064517.28636-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2021-07-186-43/+107
|\
| * bthread: replace blocking bthread_stop with nonblocking bthread_cancelAhmad Fatoum2021-06-281-11/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When bthread were first merged, they could be scheduled in any context and bthread_stop could just keep rescheduling until the bthread in question exits after which it would return the exit code. Now that bthreads are only scheduled in command context, bthread_stop also can only be scheduled in command context, making it much less useful and easier to shoot yourself in the foot with. Avoid this by introducing a bthread_cancel function instead that will asynchronously terminate the thread. For most purposes that should be fine, because bthread_stop is used to synchronize cleanup and we can move the cleanup into the thread instead. The only exception is the bthread command, which relies on being able to wait on bthreads to complete. For these __bthread_stop remains available, but should not be used in new code. This fixes a hang that is encountered when the usb mass storage gadget unbind is called from a poller leading barebox to wait indefinitely. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628070732.16812-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bthread: remove thread exit codesAhmad Fatoum2021-06-281-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up commit will replace blocking bthread_stop with non-blocking bthread_cancel. Prepare for this by dropping exit codes. This is not much of a loss, because most users of bthreads will only call bthread_stop at cleanup time. bthread command is an exception, so have it take manual care of passing around exit codes. As we touch the bthread_stop prototype anyway, rename it to __bthread_stop. This will make it clearer in the future, that it's not meant for driver use. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628070732.16812-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: add support for USB mass storage gadgetAhmad Fatoum2021-06-251-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver is based on the f_mass_storage drivers in Linux v5.11 and U-Boot v2021.01. Unlike the U-Boot version, it runs asynchronously without blocking the bootloader from doing other tasks, like exporting other USB gadgets at the same time or enabling shell access. With pollers and workqueues, enabling this would need a large rework of the code to be completely callback based, whenever the original Linux code sleeps waiting for events. With the new bthread support, we can actually sleep and handover control to other bthreads until there is actual work to do. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: refactor usbgadget_register to accept arrayAhmad Fatoum2021-06-251-11/+17
| | | | | | | | | | | | | | | | | | | | usbgadget_register currently takes 6 arguments. Instead of increasing them to 8 to support the new usb mass storage gadget, rewrite it to accept a pointer to a struct with all the options instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: bthread: schedule only in command contextAhmad Fatoum2021-06-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally, I envisioned bthreads as replacement for pollers and workqueues. But even without preemption, having functions you call possibly accessing structures you are iterating over can corrupt memory. This problem exists with pollers as well, but because of their limited scope, it's harder to shoot your foot with them, as you don't keep implicit state between poller activations unlike bthreads, which maintain their stack across context switches. Limit bthread scope instead to be a replacement for workqueues. This still allows us to port some classes of state-machine-in-kthread kernel code, while avoding the aforementioned pitfalls. Cc: Jan Luebbe <j.luebbe@pengutronix.de> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: move workqueue handling from poller_call() to sched()Ahmad Fatoum2021-06-254-15/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Workqueues are run out of poller_call, not because of a dependency, but because when they were added, poller_call was directly called from is_timeout. With the addition of bthreads, there is now a general resched() function that runs pollers and switches between bthreads. It makes sense to move workqueue handling there as well to keep scheduling matter contained in a single function. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bthread: add debug print for scheduler context switchesAhmad Fatoum2021-06-251-1/+4
| | | | | | | | | | | | | | | | | | | | When debugging around bthreads, it's often useful to log context switches. Make this easier by adding a ready-to-use pr_debug at the correct location. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/rockchip'Sascha Hauer2021-07-182-1/+12
|\ \
| * | ARM: Rockchip: Add rk3568 supportSascha Hauer2021-06-281-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds basic support for the Rockchip rk3568 SoC. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615141641.31577-8-s.hauer@pengutronix.de Link: https://lore.barebox.org/20210621092802.27275-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | filetype: Add Rockchip boot image typeSascha Hauer2021-06-211-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | Newer Rockchip SoCs boot images starting with the magic "RKNS". There are older image formats currently not supported, this one is at least supported on the RK3568. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615141641.31577-4-s.hauer@pengutronix.de Link: https://lore.barebox.org/20210621092802.27275-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/riscv'Sascha Hauer2021-07-183-1/+50
|\ \
| * | RISC-V: StarFive: add board support for BeagleV StarlightAhmad Fatoum2021-06-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | With the different drivers now in place, we have everything to start a barebox image. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-30-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | RISC-V: erizo: make it easier to reuse ns16550 debug_llAhmad Fatoum2021-06-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incoming StarFive support also uses ns16550 compatibles as UART IP. Make reuse easier by making the two most likely parameters to change SoC-specific (base address and baud clock frequency) and move the rest behind the new CONFIG_DEBUG_LL_NS16550. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | RISC-V: S-Mode: propagate Hart IDAhmad Fatoum2021-06-242-1/+39
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike other architectures we support, Linux must apparently be booted on all cores by the bootloader. To achieve this, the bootloaders running on the multiple cores synchronize via IPIs. We will get there eventually, but for now, let's restrict barebox to boot Linux on a single core. S-Mode firmware is passed hart (core) id in a0. This is propagated via the thread pointer register, which is unused by GCC and made available as: - cpuinfo output when running in S-Mode - $global.hartid - a0 when booting via bootm - /chosen/boot-hartid fixup: will come in handy when we gain EFI loading support - single /cpus/*/reg: All other CPU nodes are deleted via fixup For M-Mode, we can query hart id via CSR. It's unknown whether erizo supports it and we don't yet have exception support to handle it not being available, so changes are only done for S-Mode for now. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-07-181-2/+25
|\ \
| * | common: bbu: add pr_fmtRouven Czerwinski2021-06-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to identify where messages are coming from. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210618120557.2192098-2-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>