platform/kernel/u-boot.git
3 years agoARM: stm32: Update dhelectronics/dh_stm32mp1/MAINTAINERS file
Christoph Niedermaier [Wed, 5 May 2021 16:23:51 +0000 (18:23 +0200)]
ARM: stm32: Update dhelectronics/dh_stm32mp1/MAINTAINERS file

Adding new DH electronics mailing list.

Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoreset: stm32: Fix bank and offset computation
Patrice Chotard [Wed, 28 Apr 2021 11:42:45 +0000 (13:42 +0200)]
reset: stm32: Fix bank and offset computation

BITS_PER_LONG is used to represent register's size which is 32.
But when compiled on arch64, BITS_PER_LONG is then equal to 64.

Fix bank and offset computation to make it work on arch32 and
arch64 and ensure that register's size is always equal to 32.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agodfu: dfu_mtd: remove the mtd_block_op error when mtd_lock is not supported
Patrick Delaunay [Wed, 10 Mar 2021 09:27:22 +0000 (10:27 +0100)]
dfu: dfu_mtd: remove the mtd_block_op error when mtd_lock is not supported

Fix the result of DFU_OP_WRITE operation in mtd_block_op function
when mtd_lock is not supported (-EOPNOTSUPP) to avoid DFU stack
error on the DFU manifestation of the MTD device, when
dfu_flush_medium_mtd is called.

Without this patch, dfu-util failed on dfuERROR state at the end
of the write operation on the alternate even if MTD write
opeartion is correctly performed.

$> dfu-util -a 3 -D test.bin
....
DFU mode device DFU version 0110
Device returned transfer size 4096
Copying data from PC to DFU device
....
Download [=========================] 100%       225469 bytes
Download done.
state(10) = dfuERROR, status(14) = Something went wrong,
  but the device does not know what it was Done!

Fixes: 65f3fc18fc1e ("dfu_mtd: Add provision to unlock mtd device")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
3 years agoMerge tag 'ti-v2021.07-rc4' of https://source.denx.de/u-boot/custodians/u-boot-ti
Tom Rini [Thu, 27 May 2021 11:42:49 +0000 (07:42 -0400)]
Merge tag 'ti-v2021.07-rc4' of https://source.denx.de/u-boot/custodians/u-boot-ti

- Fix reset for AM64 platforms
- Enable networking PHY driver for AM64
- Fix default R5F cluster setting in J7

3 years agoMerge branch '2021-05-26-assorted-bugfixes'
Tom Rini [Thu, 27 May 2021 11:41:25 +0000 (07:41 -0400)]
Merge branch '2021-05-26-assorted-bugfixes'

3 years agoARM: ti: Increase the allocated size for MLO.raw
Faiz Abbas [Mon, 19 Apr 2021 06:50:27 +0000 (12:20 +0530)]
ARM: ti: Increase the allocated size for MLO.raw

MLO has increased to a size greater than the allocated
128 kB in dfu_alt_info_emmc and _mmc.

Therefore, double the allocated size for MLO.raw in
the default environment.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Link: https://lore.kernel.org/r/20210419065027.5834-1-a-govindraju@ti.com
3 years agoarm: dts: k3-am642-sk: Add sysreset controller node
Suman Anna [Fri, 14 May 2021 01:10:57 +0000 (20:10 -0500)]
arm: dts: k3-am642-sk: Add sysreset controller node

The AM64x SoC uses a central Device Management and Security Controller
(DMSC) processor that manages all the low-level device controls
including the system-wide SoC reset. The system-wide reset is managed
through the system reset driver.

Add a sysreset controller node as a child of the dmsc node to enable
the "reset" command from U-Boot prompt for the K3 AM642 SK.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
3 years agoarm: dts: k3-am642-evm: Add sysreset controller node
Suman Anna [Fri, 14 May 2021 01:10:56 +0000 (20:10 -0500)]
arm: dts: k3-am642-evm: Add sysreset controller node

The AM64x SoC uses a central Device Management and Security Controller
(DMSC) processor that manages all the low-level device controls
including the system-wide SoC reset. The system-wide reset is managed
through the system reset driver.

Add a sysreset controller node as a child of the dmsc node to enable
the "reset" command from U-Boot prompt for the K3 AM642 EVM.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
3 years agofirmware: ti_sci: Update ti_sci_msg_req_reboot to include domain
Dave Gerlach [Fri, 14 May 2021 01:10:55 +0000 (20:10 -0500)]
firmware: ti_sci: Update ti_sci_msg_req_reboot to include domain

The ti_sci_msg_req_reboot message payload has been extended to include a
domain field, but for the purposes of u-boot this should be zero to
reset the entire SoC as it did before. Include domain for completeness
and set to zero to ensure proper operation.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
3 years agoarm: dts: k3-j721e: Fix up MAIN R5FSS cluster mode back to Split-mode
Suman Anna [Tue, 18 May 2021 21:38:25 +0000 (16:38 -0500)]
arm: dts: k3-j721e: Fix up MAIN R5FSS cluster mode back to Split-mode

The default U-Boot environment variables and design are all set up for
both the MAIN R5FSS clusters to be in Split-mode. This is the setting
in v2021.01 U-Boot and the dt nodes are synched with the kernel binding
property names in commit 468ec2f3ef8f ("remoteproc: k3_r5: Sync to
upstreamed kernel DT property names") merged in v2021.04-rc2.

The modes for both the clusters got switched back to LockStep mode by
mistake in commit 70e167495ab2 ("arm: dts: k3-j721e: Sync Linux v5.11-rc6
dts into U-Boot") also in v2021.04-rc2. This throws the following warning
messages when early-booting the cores using default env variables,

  k3_r5f_rproc r5f at 5d00000: Invalid op: Trying to start secondary core 7 in lockstep mode
  Load Remote Processor 3 with data at addr=0x82000000 98484 bytes: Failed!
  k3_r5f_rproc r5f at 5f00000: Invalid op: Trying to start secondary core 9 in lockstep mode
  Load Remote Processor 5 with data at addr=0x82000000 98484 bytes: Failed!

Fix this by switching back both the clusters to the expected Split-mode.
Make this mode change in the u-boot specific dtsi file to avoid such
sync overrides in the future until the kernel dts is also switched to
Split-mode by default.

Fixes: 70e167495ab2 ("arm: dts: k3-j721e: Sync Linux v5.11-rc6 dts into U-Boot")
Reported-by: Minas Hambardzumyan <minas@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
3 years agoconfigs: am64x_evm_a53_defconfig: Enable DP83867 PHY driver
Vignesh Raghavendra [Wed, 12 May 2021 14:38:25 +0000 (20:08 +0530)]
configs: am64x_evm_a53_defconfig: Enable DP83867 PHY driver

AM64x GP and SK EVM have DP83867 PHY connected to CPSW external port0.
Enable the driver in order to use ethernet at U-Boot prompt.
CONFIG_PHY_TI is selected by CONFIG_PHY_TI_DP83867 and thus can be dropped.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
3 years agotest: Remove duplicate macro
Sean Anderson [Sun, 23 May 2021 17:00:56 +0000 (13:00 -0400)]
test: Remove duplicate macro

ut_asserteq_strn is defined twice. Remove one definition.

Fixes: 33d7edfd5f ("test: Add a way to check part of a console line or skip it")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoGitLab: Remove tags for sandbox_noinst tests
Harm Berntsen [Fri, 21 May 2021 19:59:45 +0000 (21:59 +0200)]
GitLab: Remove tags for sandbox_noinst tests

Commit 712cc962b70d ("GitLab: Remove "tags" stanzas") removed the 'all'
tag from all the jobs. The sandbox_noinst_test.py test was added in
between the author date and commit date (commit 6c914e4232cd
("azure/gitlab: Add tests for sandbox_noinst")) which is probably why it
still contains the tags. This commit fixes that so all jobs now don't
require tags on the GitLab runners.

Signed-off-by: Harm Berntsen <harm.berntsen@nedap.com>
CC: Simon Glass <sjg@chromium.org>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
3 years agotest: Fix filesystem tests always being skipped
Alper Nebi Yasak [Thu, 20 May 2021 19:09:46 +0000 (22:09 +0300)]
test: Fix filesystem tests always being skipped

Commit 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system")
fixes an issue in the filesystem tests where the test setup may fail
to mount an image and still attempt to unmount it. However, the commit
unintentionally breaks the test setups in two ways.

The newly created unmounted filesystem images are being immediately
deleted due to some cleanup steps being misplaced into finally blocks,
which makes them always run instead of only on failures. The mount calls
always fail since the images never exist, causing the tests to be always
skipped. This patch moves these cleanup calls into the except blocks to
fix this and makes the tests run again.

There are also unmount calls misplaced into finally blocks, making them
run after the tests instead of before the tests. These unmount calls
make the filesystem image file consistent with the changes made to it as
part of the test setup, and this misplacement is making a number of
tests fail unexpectedly.

The unmount calls must be run before the tests use the image, meaning
before the yield call and not in the finally block. They must also be
run as a cleanup step when the filesystem setup fails, so they can't be
placed as the final call in the try blocks since they would be skipped
on such failures. For these reasons, this patch places the unmount calls
both in the except blocks and the else blocks of the final setup step.
This makes the unexpectedly failing tests to succeed again.

Furthermore, this isolates the mount calls to their own try-except
statement to avoid reintroducing the original issue of unmounting a
not-mounted image while fixing the unmount misplacement.

After these fixes, running "make tests" with guestmount available results
in two test failures not related to the mentioned commit. If the
guestmount executables are unavailable, the mounts fallback to using
sudo and result in no failures.

Fixes: 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system")
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agospl: Kconfig: Use tabs instead of space for alignment
Michal Simek [Thu, 20 May 2021 11:08:44 +0000 (13:08 +0200)]
spl: Kconfig: Use tabs instead of space for alignment

A lot of entries were using spaces instead of tab for alignment that's why
it is good to fix it to use the same style everywhere.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofs: btrfs: Add missing cache aligned allocation
Marek Vasut [Mon, 17 May 2021 22:39:39 +0000 (00:39 +0200)]
fs: btrfs: Add missing cache aligned allocation

The superblock buffer must be cache aligned, since it might be used
in DMA context, allocate it using ALLOC_CACHE_ALIGN_BUFFER() just
like it was done in btrfs_read_superblock() and read_tree_node().

This fixes this output on boot and non-working btrfs on iMX53:
CACHE: Misaligned operation at range [ced299d0ced2a9d0]

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Marek Behún <marek.behun@nic.cz>
Cc: Qu Wenruo <wqu@suse.com>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
3 years agofs/squashfs: zero out unused fields in fs_dirent
Heinrich Schuchardt [Mon, 17 May 2021 06:21:39 +0000 (08:21 +0200)]
fs/squashfs: zero out unused fields in fs_dirent

When reading directories the UEFI sub-system must supply file attributes
and timestamps. These fields will have to be added to struct fs_dirent.
SquashFS should not fill these fields with random data. Ensure that they
are zeroed out.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
3 years agopowerpc: fix regression in arch_initr_trap()
Matt Merhar [Mon, 17 May 2021 17:32:48 +0000 (17:32 +0000)]
powerpc: fix regression in arch_initr_trap()

The assembly output of the arch_initr_trap() function differed by a
single byte after common.h was removed from traps.c:

 fff49a18 <arch_initr_trap>:
 fff49a18:      94 21 ff f0     stwu    r1,-16(r1)
 fff49a1c:      7c 08 02 a6     mflr    r0
 fff49a20:      90 01 00 14     stw     r0,20(r1)
-fff49a24:      80 62 00 44     lwz     r3,68(r2)
+fff49a24:      80 62 00 38     lwz     r3,56(r2)
 fff49a28:      4b ff 76 19     bl      fff41040 <trap_init>
 fff49a2c:      80 01 00 14     lwz     r0,20(r1)
 fff49a30:      38 60 00 00     li      r3,0
 fff49a34:      38 21 00 10     addi    r1,r1,16
 fff49a38:      7c 08 03 a6     mtlr    r0

This was causing a consistent hard lockup during the MMC read / loading
of the QoriQ FMan firmware on a P2041RDB board.

Re-adding the header causes identical assembly to be emitted and allows
the firmware loading and subsequent boot to succeed.

Fixes: 401d1c4f5d ("common: Drop asm/global_data.h from common header")
Signed-off-by: Matt Merhar <mattmerhar@protonmail.com>
3 years agopart: Add check for NULL dev_part_str
Sean Anderson [Sat, 15 May 2021 18:13:54 +0000 (14:13 -0400)]
part: Add check for NULL dev_part_str

Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str.
While blk_get_device_part_str handles this fine,
part_get_info_by_dev_and_name does not. This fixes commands crashing when
implicitly using bootdevice.

The unit test has also been updated to set bootdevice to a known value and
to restore it after we are done.

Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions")
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agopinctrl: single: Fix probe failure getting register area size
Vignesh Raghavendra [Fri, 7 May 2021 09:10:34 +0000 (14:40 +0530)]
pinctrl: single: Fix probe failure getting register area size

If reg property of pinctrl-single node requires address translation then
probe fails with following message:

single-pinctrl pinctrl@4301c000: failed to get base register size

This is because driver uses dev_read_addr_size() to get size which also
tries to fetch untranslated addr and fails.
Fix this by using dev_read_addr_size_index() which takes care of address
translation and also makes following dev_read_addr() call redundant.

This fixes Ethernet failures on TI's AM654 based EVMs due to lack of
pinmux configuration.

Fixes: 9fd8a430f3 ("pinctrl: single: get register area size by device API")
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
3 years agoconfigs: Resync with savedefconfig
Tom Rini [Tue, 25 May 2021 15:58:50 +0000 (11:58 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agonet: Remove ne2000 driver
Tom Rini [Tue, 25 May 2021 15:54:12 +0000 (11:54 -0400)]
net: Remove ne2000 driver

With the last user of this driver removed, remove the driver.

Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge tag 'efi-2021-07-rc4' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Tue, 25 May 2021 15:48:55 +0000 (11:48 -0400)]
Merge tag 'efi-2021-07-rc4' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2021-07-rc4

Documentation:

* correct mmc man-page

Bug fixes:

* reduce code size of efidebug command
* remove 31 character limit for file paths in efidebug command
* fix build warning in the TCG2 protocol implementation

3 years agoMerge tag 'mips-pull-2021-05-25' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 25 May 2021 15:48:37 +0000 (11:48 -0400)]
Merge tag 'mips-pull-2021-05-25' of https://source.denx.de/u-boot/custodians/u-boot-mips

- MIPS: octeon: fix CFI flash setup
- MIPS: remove qemu_mips boards

3 years agodoc: update and fix Qemu MIPS documentation
Daniel Schwierzeck [Wed, 21 Apr 2021 19:13:14 +0000 (21:13 +0200)]
doc: update and fix Qemu MIPS documentation

Update description to use the MIPS Malta board for Qemu.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 years agoMIPS: remove deprecated qemu_mips board
Daniel Schwierzeck [Wed, 21 Apr 2021 19:13:13 +0000 (21:13 +0200)]
MIPS: remove deprecated qemu_mips board

Remove qemu_mips boards because DM migration doesn't make sense.
The board support for qemu_mips is already marked as deprecated
in Qemu in favour of the Malta board. Also qemu_mips support
has been removed from Linux a long time ago.

The official replacement is the Malta board. The same Malta U-Boot
image can be used with Qemu and on physical hardware.
All combinations of Big Endian and Little Endian as well as 32 bit
and 64 bit are supported.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 years agomips: octeon: octeon_ebb7304_defconfig: Fix CFI flash setup
Stefan Roese [Mon, 26 Apr 2021 14:43:18 +0000 (16:43 +0200)]
mips: octeon: octeon_ebb7304_defconfig: Fix CFI flash setup

This patch makes the necessary adjustments in the defconfig to fully
support the CFI flash on the Octeon EBB7304.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Aaron Williams <awilliams@marvell.com>
Cc: Chandrakala Chavva <cchavva@marvell.com>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 years agoefi_loader: Fix -Wextra warning for EFI TCG2
Ilias Apalodimas [Tue, 25 May 2021 11:35:31 +0000 (14:35 +0300)]
efi_loader: Fix -Wextra warning for EFI TCG2

Compiling with -Wextra produces a number of (harmless) warnings for the EFI
TCG2 protocol.  Let's fix those in case we ever enable the flag on the EFI
subsystem

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: simplify accessing variables
Heinrich Schuchardt [Mon, 24 May 2021 09:10:59 +0000 (11:10 +0200)]
efi_loader: simplify accessing variables

Use efi_get_variable_int() instead of EFI_CALL(RT->get_variable()).
Use efi_set_variable_int() instead of EFI_CALL(efi_set_variable()).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: use efi_create_indexed_name()
Heinrich Schuchardt [Mon, 24 May 2021 08:57:03 +0000 (10:57 +0200)]
efi_loader: use efi_create_indexed_name()

Simplify the creation of indexed variable names like 'Boot0000' by using
function efi_create_indexed_name().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: simplify show_efi_boot_order()
Heinrich Schuchardt [Mon, 24 May 2021 08:48:45 +0000 (10:48 +0200)]
efi_loader: simplify show_efi_boot_order()

To print a UTF-16 string use %ls instead of converting string to UTF-8.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: simplify show_efi_boot_opt_data()
Heinrich Schuchardt [Mon, 24 May 2021 08:35:25 +0000 (10:35 +0200)]
efi_loader: simplify show_efi_boot_opt_data()

To print a UTF-16 string use %ls instead of converting string to UTF-8.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: path length in efi_dp_from_name()
Heinrich Schuchardt [Tue, 25 May 2021 10:07:30 +0000 (12:07 +0200)]
efi_loader: path length in efi_dp_from_name()

Before this patch efi_dp_from_name() only accommodated a maximum file path
length of 31 characters. This leads to boot failures due to file name
truncation.

Allow arbitrary path lengths.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled
Masahisa Kojima [Fri, 14 May 2021 00:53:36 +0000 (09:53 +0900)]
efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled

This is preparation for PE/COFF measurement support.
PE/COFF image hash calculation is same in both
UEFI Secure Boot image verification and measurement in
measured boot. PE/COFF image parsing functions are
gathered into efi_image_loader.c, and exposed even if
UEFI Secure Boot is not enabled.

This commit also adds the EFI_SIGNATURE_SUPPORT option
to decide if efi_signature.c shall be compiled.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: remove weak efi_get_public_key_data()
Heinrich Schuchardt [Thu, 20 May 2021 02:08:11 +0000 (04:08 +0200)]
efi_loader: remove weak efi_get_public_key_data()

Configuring a system with CONFIG_EFI_CAPSULE_AUTHENTICATE=y but without a
method to retrieve the public key data is a misconfiguration. We should get
a build failure for it. Therefore remove the weak efi_get_public_key_data()
implementation.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodoc: usage: modify mmc man-page
Jaehoon Chung [Mon, 10 May 2021 07:04:02 +0000 (16:04 +0900)]
doc: usage: modify mmc man-page

Modify mmc man-page.
- Change a description about mmc erase command.
- Add whitespace to distinguish.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agoPrepare v2021.07-rc3
Tom Rini [Tue, 25 May 2021 00:53:13 +0000 (20:53 -0400)]
Prepare v2021.07-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge branch '2021-05-24-add-lto-support'
Tom Rini [Mon, 24 May 2021 20:12:31 +0000 (16:12 -0400)]
Merge branch '2021-05-24-add-lto-support'

- Add LTO (link time optimization) support to the build system and
  enable it on a few boards.  This is an alternative to using
  -ffunction-sections/-fdata-sections and --gc-sections at link time to
  remove unused code.  This can result in notable savings, but needs
  testing on each platform before use as it can expose problems by
  optimizing away various functionally necessary calls.

3 years agostackprot: Make our test a bit more complex
Tom Rini [Mon, 24 May 2021 18:19:05 +0000 (14:19 -0400)]
stackprot: Make our test a bit more complex

With better compiler optimizations available, a compiler may see we do
nothing with our buffer after calling memset and omit the call, thus
causing us to not smash the stack.  Add a comment to explain why we now
also have a printf call, so that the test will pass as the memset will
not be omitted.

Reported-by: Marek Behún <marek.behun@nic.cz>
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoARM: enable LTO for some boards
Marek Behún [Thu, 20 May 2021 11:24:25 +0000 (13:24 +0200)]
ARM: enable LTO for some boards

Enable LTO for some boards that were tested by people on U-Boot Mailing
List.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Tested-by: Adam Ford <aford173@gmail.com>
Tested-by: Pali Rohár <pali@kernel.org>
Tested-by: Tim Harvey <tharvey@gateworks.com>
3 years agoARM: don't use --gc-sections with LTO when using private libgcc
Marek Behún [Thu, 20 May 2021 11:24:24 +0000 (13:24 +0200)]
ARM: don't use --gc-sections with LTO when using private libgcc

When using LTO, we can throw away the --gc-sections flag, but only if
using private libgcc.

When using system's libgcc, --gc-sections is still needed, otherwise
linking will fail due to undefined references to libc's symbols.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: don't use -ffunction-sections/-fdata-sections with LTO build
Marek Behún [Thu, 20 May 2021 11:24:23 +0000 (13:24 +0200)]
ARM: don't use -ffunction-sections/-fdata-sections with LTO build

When building with LTO, using -ffunction-sections/-fdata-sections is not
useful anymore.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: make LTO available
Marek Behún [Thu, 20 May 2021 11:24:22 +0000 (13:24 +0200)]
ARM: make LTO available

Make LTO available for ARM architecture.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoata: ahci: fix ahci_link_up() type mismatch for LTO
Marek Behún [Thu, 20 May 2021 11:24:21 +0000 (13:24 +0200)]
ata: ahci: fix ahci_link_up() type mismatch for LTO

When building highbank_defconfig with LTO, the compiler complains about
type mismatch of function ahci_link_up().

The third parameter of this function is of type u8 in
drivers/ata/ahci.c, but of type int in board/highbank/ahci.c.

There is no reason in using u8, and the code using this function
actually passes an int variable into the function (so it is implicitly
converted to u8).

Change the type of this parameter to int in drivers/ata/ahci.c.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agoarmv8: SPL: discard relocation information
Marek Behún [Thu, 20 May 2021 11:24:20 +0000 (13:24 +0200)]
armv8: SPL: discard relocation information

For some reason when building SPL for ARMv8 with LTO, the relocation
information is not discarded.

Discard it explicitly in the linker script.

This fixes LTO build for imx8mm_venice_defconfig.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: omap3: fix LTO for DM3730 (and possibly other omap3 boards)
Marek Behún [Thu, 20 May 2021 11:24:19 +0000 (13:24 +0200)]
ARM: omap3: fix LTO for DM3730 (and possibly other omap3 boards)

Adam Ford says that DM3730 needs board.c compiled without LTO flags.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Tested-by: Adam Ford <aford173@gmail.com>
3 years agoARM: fix LTO for rockchip and samsung
Marek Behún [Thu, 20 May 2021 11:24:18 +0000 (13:24 +0200)]
ARM: fix LTO for rockchip and samsung

When building with LTO, the compiler complains about type mismatch of
function usb_gadget_handle_interrupts(). This function is defined
without parameters in files
  arch/arm/mach-rockchip/board.c
  board/samsung/common/exynos5-dt.c
but it should have one parameter, int index.

Fix this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agoARM: fix LTO for seaboard
Marek Behún [Thu, 20 May 2021 11:24:17 +0000 (13:24 +0200)]
ARM: fix LTO for seaboard

When seaboard_defconfig is compiled with LTO, the compiler complains
about some instructions not being supported in ARM mode.

This is caused by arch/arm/mach-tegra/tegra20/warmboot_avp.c having
different CFLAGS declared in Makefile. This file needs to be compiled
without LTO.

Fix this by removing -flto for this file.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: imx8m: fix imx_eqos_txclk_set_rate() type mismatch for LTO
Marek Behún [Thu, 20 May 2021 11:24:16 +0000 (13:24 +0200)]
ARM: imx8m: fix imx_eqos_txclk_set_rate() type mismatch for LTO

When building imx8mp_evk_defconfig with LTO, the compiler complains
about type mismatch of function imx_eqos_txclk_set_rate() in file
  drivers/net/dwc_eth_qos.c:845:12
which contains a weak definition of this function, vs file
  arch/arm/mach-imx/imx8m/clock_imx8mm.c
which contains an implementation.

Change the type of this function in the implementation to fix this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agoARM: kona: fix clk_bsc_enable() type mismatch for LTO
Marek Behún [Thu, 20 May 2021 11:24:15 +0000 (13:24 +0200)]
ARM: kona: fix clk_bsc_enable() type mismatch for LTO

When building with LTO, the compiler complains about type mismatch of
function clk_bsc_enable() in file:
  arch/arm/cpu/armv7/kona-common/clk-stubs.c
vs other files that define or use this function:
  warning: type of ‘clk_bsc_enable’ does not match original declaration.

Change the type of this function to that of the other usages.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agoARM: fix LTO for keystone
Marek Behún [Thu, 20 May 2021 11:24:14 +0000 (13:24 +0200)]
ARM: fix LTO for keystone

When building keystone with LTO the compiler complains:
  Error: selected processor does not support `smc #0' in Thumb mode

Fix this by removing -flto for the file implementing these SMC calls.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
3 years agoARM: fix LTO for apf27
Marek Behún [Thu, 20 May 2021 11:24:13 +0000 (13:24 +0200)]
ARM: fix LTO for apf27

When apf27_defconfig is built with LTO, linking complains about
undefined reference to `nand_boot`. This is because it is referenced
from inline assembly. Make it visible.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
3 years agoARM: fix LTO for imx28_xea
Marek Behún [Thu, 20 May 2021 11:24:12 +0000 (13:24 +0200)]
ARM: fix LTO for imx28_xea

When imx28_xea_defconfig is built with LTO, the compiler complains about
the two different declarations of _start:
   include/asm-generic/sections.h    as  extern void _start(void);
   arch/arm/cpu/arm926ejs/mxs/mxs.c  as  extern uint32_t _start;

Fix this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agoARM: fix LTO build for some thumb-interwork cases
Marek Behún [Thu, 20 May 2021 11:24:11 +0000 (13:24 +0200)]
ARM: fix LTO build for some thumb-interwork cases

Fix LTO build for some thumb-interwork usecases (such as for
da850evm_defconfig), where inline assmebly such as
  mrc p15,0,r2,c1,c0,0
causes the compiler to fail during LTO linking with
  Error: selected processor does not support `mrc p15,0,r2,c1,c0,0'
         in Thumb mode

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: make gd a function call for LTO and set via set_gd()
Marek Behún [Thu, 20 May 2021 11:24:10 +0000 (13:24 +0200)]
ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
  Note that global register vars shouldn't be used with LTO and if they
  are restricted to just a few compilation units the recommended fix is
  to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: global_data: make set_gd() work for armv5 and armv6
Marek Behún [Thu, 20 May 2021 11:24:09 +0000 (13:24 +0200)]
ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: enable LTO by default
Marek Behún [Thu, 20 May 2021 11:24:08 +0000 (13:24 +0200)]
sandbox: enable LTO by default

Build sandbox targets with LTO by default.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agosandbox: make LTO available
Marek Behún [Thu, 20 May 2021 11:24:07 +0000 (13:24 +0200)]
sandbox: make LTO available

Make LTO available for sandbox architecture.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agosandbox: use sections instead of symbols for getopt array boundaries
Marek Behún [Thu, 20 May 2021 11:24:06 +0000 (13:24 +0200)]
sandbox: use sections instead of symbols for getopt array boundaries

In style of linked lists, instead of declaring symbols for boundaries
of getopt options array in the linker script, declare corresponding
sections and retrieve the boundaries via static inline functions.

Without this clang's LTO produces binary without any getopt options,
because for some reason it thinks that array is empty (start and end
symbols are at the same address).

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: errno: avoid conflict with libc's errno
Marek Behún [Thu, 20 May 2021 11:24:05 +0000 (13:24 +0200)]
sandbox: errno: avoid conflict with libc's errno

When building with LTO, the system libc's `errno` variable used in
arch/sandbox/cpu/os.c conflicts with U-Boot's `errno` (defined in
lib/errno.c) with the following error:
 .../ld: errno@@GLIBC_PRIVATE: TLS definition in /lib64/libc.so.6
         section .tbss mismatches non-TLS reference in
 /tmp/u-boot.EQlEXz.ltrans0.ltrans.o

To avoid this conflict use different asm label for this variable when
CONFIG_SANDBOX is enabled.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agobuild: link with --build-id=none
Marek Behún [Thu, 20 May 2021 11:24:04 +0000 (13:24 +0200)]
build: link with --build-id=none

Some toolchains are compiled so that they pass a --build-id=something
parameter to the linker implicitly.

This causes U-Boot LTO linking to fail with something like:
  ld: section .note.gnu.build-id LMA ... overlaps section .text LMA ...
because U-Boot's link scripts do not currently handle .note.gnu.build-id
section.

Fix this by explicitly disabling build-id.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agobuild: support building with Link Time Optimizations
Marek Behún [Thu, 20 May 2021 11:24:03 +0000 (13:24 +0200)]
build: support building with Link Time Optimizations

Add plumbing for building U-Boot with Link Time Optimizations.

When building with LTO, $(PLATFORM_LIBS) has to be in --whole-archive /
--no-whole-archive group, otherwise some functions declared in assembly
may not be resolved and linking may fail.

Note: clang may throw away linker list symbols it thinks are unused when
compiling with LTO. To force these symbols to be included, we refer to
them via the __ADDRESSABLE macro in a C file generated from compiled
built-in.o files before linking.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agobuild: use thin archives instead of incremental linking
Marek Behún [Thu, 20 May 2021 11:24:02 +0000 (13:24 +0200)]
build: use thin archives instead of incremental linking

Currently we use incremental linking (ld -r) to link several object
files from one directory into one built-in.o object file containing the
linked code from that directory (and its subdirectories).

Linux has, some time ago, moved to thin archives instead.

Thin archives are archives (.a) that do not really contain the object
files, only references to them.

Using thin archives instead of incremental linking
- saves disk space
- apparently works better with dead code elimination
- makes things easier for LTO

The third point is the important one for us. With incremental linking
there are several options how to do LTO, and that would unnecessarily
complicate things.

We have to use the --whole-archive/--no-whole-archive linking option
instead of --start-group/--end-group, otherwise linking may fail because
of unresolved symbols, or the resulting binary will be unusable.

We also need to use the P flag for ar, otherwise final linking may fail.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile, Makefile.spl: cosmetic change
Marek Behún [Thu, 20 May 2021 11:24:01 +0000 (13:24 +0200)]
Makefile, Makefile.spl: cosmetic change

Indent the linking commands so that they look cosmetically better.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agolib: crc32: put the crc_table variable into efi_runtime_rodata section
Marek Behún [Thu, 20 May 2021 11:24:00 +0000 (13:24 +0200)]
lib: crc32: put the crc_table variable into efi_runtime_rodata section

When compiling with LTO, the compiler fails with an error saying that
`crc_table` causes a section type conflict with `efi_var_buf`.

This is because both are declared to be in the same section (via macro
`__efi_runtime_data`), but one is const while the other is not.

Put this variable into the section .rodata.efi_runtime, instead of
.data.efi_runtime, via macro __efi_runtime_rodata.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Heinrich Schuchardt <xypron.gpk@gmx.de>
3 years agoefi_selftest: compiler flags for efi_selftest_miniapp_exception.o
Marek Behún [Thu, 20 May 2021 11:23:59 +0000 (13:23 +0200)]
efi_selftest: compiler flags for efi_selftest_miniapp_exception.o

Add $(CFLAGS_EFI) and remove $(CFLAGS_NON_EFI) for
efi_selftest_miniapp_exception.o.

The removal is needed when compiling with LTO - this object file needs
to be compiled without -flto.

The adding is for consistency with other miniapps.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: add macro for const EFI runtime data
Marek Behún [Thu, 20 May 2021 11:23:58 +0000 (13:23 +0200)]
efi_loader: add macro for const EFI runtime data

Add macro __efi_runtime_rodata, for const variables with similar purpose
as those using __efi_runtime_data.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: add Sphinx doc for __efi_runtime and __efi_runtime_data
Marek Behún [Thu, 20 May 2021 11:23:57 +0000 (13:23 +0200)]
efi_loader: add Sphinx doc for __efi_runtime and __efi_runtime_data

Document the macros __efi_runtime and __efi_runtime_data in Sphinx
style.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: fix warning when linking with LTO
Marek Behún [Thu, 20 May 2021 11:23:56 +0000 (13:23 +0200)]
efi_loader: fix warning when linking with LTO

When linking with LTO, the compiler complains about type mismatch of
variables `__efi_runtime_start`, `__efi_runtime_stop`,
`__efi_runtime_rel_start` and `__efi_runtime_rel_stop`:

 include/efi_loader.h:218:21: warning: type of ‘__efi_runtime_start’
                                       does not match original
                                       declaration [-Wlto-type-mismatch]
    218 | extern unsigned int __efi_runtime_start, __efi_runtime_stop;
        |                     ^
  arch/sandbox/lib/sections.c:7:6: note: ‘__efi_runtime_start’ was
                                         previously declared here
      7 | char __efi_runtime_start[0] __attribute__((section(".__efi_run
        |      ^

Change the type to char[] in include/efi_loader.h.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agostring: make memcpy(), memset(), memcmp() and memmove() visible for LTO
Marek Behún [Thu, 20 May 2021 11:23:55 +0000 (13:23 +0200)]
string: make memcpy(), memset(), memcmp() and memmove() visible for LTO

It seems that sometimes (happening on ARM64, for example with
turris_mox_defconfig) GCC, when linking with LTO, changes the symbol
names of some functions, for example lib/string.c's memcpy() function to
memcpy.isra.0.

This is a problem however when GCC for a code such as this:
struct some_struct *info = get_some_struct();
struct some struct tmpinfo;
tmpinfo = *info;
emits a call to memcpy() by builtin behaviour, to copy *info to tmpinfo.

This then results in the following linking error:
  .../lz4.c:93: undefined reference to `memcpy'
  .../uuid.c:206: more undefined references to `memcpy' follow

GCC's documentation says this about -nodefaultlibs option:
  The compiler may generate calls to "memcmp", "memset", "memcpy" and
  "memmove".  These entries are usually resolved by entries in libc.
  These entry points should be supplied through some other mechanism
  when this option is specified.

Make these functions visible by using the __used macro to avoid this
error.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest/py: improve regular expression for ut subtest symbol matcher
Marek Behún [Thu, 20 May 2021 11:23:54 +0000 (13:23 +0200)]
test/py: improve regular expression for ut subtest symbol matcher

Improve the regular expression that matches unittest symbols in
u-boot.sym.

Currently we do not enforce no prefix in symbol string, but with the
soon to come change in linker lists declaring lists and entries with the
__ADDRESSABLE macro (because of LTO), the symbol file will contain for
every symbol of the form
  _u_boot_list_2_ut_X_2_Y
also symbol
  __UNIQUE_ID___addressable__u_boot_list_2_ut_X_2_YN,
(where N at the end is some number).

In order to avoid matching these additional symbols, ensure that the
character before "_u_boot_list_2_ut" is not a symbol name character.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocompiler.h: align the __ADDRESSABLE macro with Linux' version
Marek Behún [Thu, 20 May 2021 11:23:53 +0000 (13:23 +0200)]
compiler.h: align the __ADDRESSABLE macro with Linux' version

Use UNIQUE_ID in the __ADDRESSABLE macro.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agotreewide: Convert macro and uses of __section(foo) to __section("foo")
Marek Behún [Thu, 20 May 2021 11:23:52 +0000 (13:23 +0200)]
treewide: Convert macro and uses of __section(foo) to __section("foo")

This commit does the same thing as Linux commit 33def8498fdd.

Use a more generic form for __section that requires quotes to avoid
complications with clang and gcc differences.

Remove the quote operator # from compiler_attributes.h __section macro.

Convert all unquoted __section(foo) uses to quoted __section("foo").
Also convert __attribute__((section("foo"))) uses to __section("foo")
even if the __attribute__ has multiple list entry forms.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocheckpatch: require quotes around section name in the __section() macro
Marek Behún [Thu, 20 May 2021 11:23:51 +0000 (13:23 +0200)]
checkpatch: require quotes around section name in the __section() macro

This is how Linux does this now, see Linux commit 339f29d91acf.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoregmap: fix a serious pointer casting bug
Marek Behún [Thu, 20 May 2021 11:23:50 +0000 (13:23 +0200)]
regmap: fix a serious pointer casting bug

There is a serious bug in regmap_read() and regmap_write() functions
where an uint pointer is cast to (void *) which is then cast to (u8 *),
(u16 *), (u32 *) or (u64 *), depending on register width of the map.

For example given a regmap with 16-bit register width the code
int val = 0x12340000;
regmap_read(map, 0, &val);
only changes the lower 16 bits of val on little-endian machines.
The upper 16 bits will remain 0x1234.

Nobody noticed this probably because this bug can be triggered with
regmap_write() only on big-endian architectures (which are not used by
many people anymore), and on little endian this bug has consequences
only if register width is 8 or 16 bits and also the memory place to
which regmap_read() should store it's result has non-zero upper bits,
which it seems doesn't happen anywhere in U-Boot normally. CI managed to
trigger this bug in unit test of dm_test_devm_regmap_field when compiled
for sandbox_defconfig using LTO.

Fix this by utilizing an union { u8; u16; u32; u64; } and reading data
into this union / writing data from this union.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heiko Schocher <hs@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Pratyush Yadav <p.yadav@ti.com>
3 years agotest: Avoid random numbers in dm_test_devm_regmap()
Simon Glass [Fri, 14 May 2021 01:39:23 +0000 (19:39 -0600)]
test: Avoid random numbers in dm_test_devm_regmap()

There is no good reason to use a sequence from rand() here. We may as well
invent our own sequence.

This should molify Coverity which does not use rand() being used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 312949)
3 years agopylibfdt: Rework "avoid unused variable warning" lines
Tom Rini [Mon, 24 May 2021 15:47:01 +0000 (11:47 -0400)]
pylibfdt: Rework "avoid unused variable warning" lines

Clang has -Wself-assign enabled by default under -Wall and so when
building with -Werror we would get an error here.  Inspired by Linux
kernel git commit a21151b9d81a ("tools/build: tweak unused value
workaround") make use of the fact that both Clang and GCC support
casting to `void` as the method to note that something is intentionally
unused.

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-sh
Tom Rini [Sun, 23 May 2021 14:15:15 +0000 (10:15 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-sh

- Various clk/pinctrl updates to re-sync with Linux and other fixes

3 years agopinctrl: renesas: Implement unlock register masks
Marek Vasut [Tue, 27 Apr 2021 20:03:38 +0000 (22:03 +0200)]
pinctrl: renesas: Implement unlock register masks

The V3U SoC has several unlock registers, one per register group. They
reside at offset zero in each 0x200 bytes-sized block.

To avoid adding yet another table to the PFC implementation, this
patch adds the option to specify an address mask instead of the fixed
address in sh_pfc_soc_info::unlock_reg.

This is a direct port of Linux 5.12 commit e127ef2ed0a6
("pinctrl: renesas: Implement unlock register masks") by
Ulrich Hecht <uli+renesas@fpond.eu>

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agopinctrl: renesas: Fix R-Car Gen2 help text
Marek Vasut [Tue, 27 Apr 2021 00:03:33 +0000 (02:03 +0200)]
pinctrl: renesas: Fix R-Car Gen2 help text

The help text for Gen2 entries had a copy paste error, still containing
the Gen3 string, while the description was correctly listing Gen2. Fix
the help text.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agopinctrl: renesas: Deduplicate Kconfig
Marek Vasut [Tue, 27 Apr 2021 00:01:50 +0000 (02:01 +0200)]
pinctrl: renesas: Deduplicate Kconfig

The help text in the Kconfig file was always a copy of the same thing.
Move single copy into the common PFC driver entry instead. Also fix a
copy-paste error in the PFC help text, which identified PFC as clock.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agogpio: renesas: Pass struct udevice to rcar_gpio_set_direction()
Marek Vasut [Tue, 27 Apr 2021 19:17:43 +0000 (21:17 +0200)]
gpio: renesas: Pass struct udevice to rcar_gpio_set_direction()

Pass struct udevice to rcar_gpio_set_direction() in preparation of
quirk handling in rcar_gpio_set_direction(). No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Deduplicate gen3_clk_get_rate64() PLL handling
Marek Vasut [Tue, 27 Apr 2021 17:36:39 +0000 (19:36 +0200)]
clk: renesas: Deduplicate gen3_clk_get_rate64() PLL handling

Most of the PLLx, MAIN, FIXED clock handlers are calling very similar
code, which determines parent rate and then applies multiplication and
division. The only difference is whether multiplication is fixed factor
or coming from CRx register. Deduplicate the code into a single function.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Add register pointers into struct cpg_mssr_info
Hai Pham [Thu, 5 Nov 2020 15:30:37 +0000 (22:30 +0700)]
clk: renesas: Add register pointers into struct cpg_mssr_info

Base on Linux v5.10-rc2, commit 8b652aa8a1fb by Yoshihiro Shimoda
To support other register layouts in the future, add register pointers
of {control,status,reset,reset_clear}_regs into struct cpg_mssr_info

Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Introduce enum clk_reg_layout
Hai Pham [Thu, 5 Nov 2020 14:32:38 +0000 (21:32 +0700)]
clk: renesas: Introduce enum clk_reg_layout

From Linux v5.10-rc2, commit ffbf9cf3f946 by Yoshihiro Shimoda
Introduce enum clk_reg_layout to support multiple register layout variants

Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Pass struct cpg_mssr_info to renesas_clk_endisable()
Hai Pham [Fri, 22 May 2020 03:39:04 +0000 (10:39 +0700)]
clk: renesas: Pass struct cpg_mssr_info to renesas_clk_endisable()

CPG IP in some specific Renesas SoCs (i.e. new R8A779A0 V3U SoC)
requires a different setting procedure. Make struct cpg_mssr_info
accessible to handle the clock setting in that case.

Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Make reset controller modemr register offset configurable
Marek Vasut [Sun, 25 Apr 2021 19:53:05 +0000 (21:53 +0200)]
clk: renesas: Make reset controller modemr register offset configurable

The MODEMR register offset changed on R8A779A0, make the MODEMR offset
configurable. Fill the offset in on all clock drivers. No functional
change.

Based off "clk: renesas: Make CPG Reset MODEMR offset accessible from
struct cpg_mssr_info" by Hai Pham <hai.pham.ud@renesas.com>

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Add support for RPCD2 clock
Hai Pham [Tue, 11 Aug 2020 03:25:28 +0000 (10:25 +0700)]
clk: renesas: Add support for RPCD2 clock

This supports RPCD2 clock handling. While at it, add the check point
for RPC-IF clock RPCD2 Frequency Division Ratio, since it must be odd
number

Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Fix Realtime Module Stop Control Register offsets
Hai Pham [Tue, 19 May 2020 10:42:05 +0000 (17:42 +0700)]
clk: renesas: Fix Realtime Module Stop Control Register offsets

This patch fixes Realtime Module Stop Control Register (RMSTPCR) offsets
based on R-Car Gen3, H2/M2/M2N/E2/E2X hardware user's manual.
The r8a73a4 only has RMSTPCR0 - RMSTPCR5 so this calculation change
doesn't affect it.

Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Fix incorrect return RPC clk_get_rate
Hai Pham [Sat, 5 Dec 2020 02:35:40 +0000 (09:35 +0700)]
clk: renesas: Fix incorrect return RPC clk_get_rate

RPC clk_get_rate will return error code instead of expected clock rate.
Fix this.

Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Reinstate RPC clock on R-Car D3/E3
Marek Vasut [Sun, 25 Apr 2021 19:26:22 +0000 (21:26 +0200)]
clk: renesas: Reinstate RPC clock on R-Car D3/E3

Reinstate RPC clock on D3/E3 after Linux 5.12 synchronization.
The D3 and E3 clock drivers do not contain RPC clock entries
mainline Linux yet.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Synchronize R-Car Gen3 tables with Linux 5.12
Marek Vasut [Sun, 25 Apr 2021 19:10:40 +0000 (21:10 +0200)]
clk: renesas: Synchronize R-Car Gen3 tables with Linux 5.12

Synchronize R-Car Gen3 clock tables with Linux 5.12,
commit 9f4ad9e425a1 ("Linux 5.12") .

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Synchronize R-Car Gen2 tables with Linux 5.12
Marek Vasut [Sun, 25 Apr 2021 19:09:10 +0000 (21:09 +0200)]
clk: renesas: Synchronize R-Car Gen2 tables with Linux 5.12

Synchronize R-Car Gen2 clock tables with Linux 5.12,
commit 9f4ad9e425a1 ("Linux 5.12") .

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoclk: renesas: Synchronize RZ/G2 tables with Linux 5.12
Marek Vasut [Sun, 25 Apr 2021 19:08:18 +0000 (21:08 +0200)]
clk: renesas: Synchronize RZ/G2 tables with Linux 5.12

Synchronize RZ/G2 clock tables with Linux 5.12,
commit 9f4ad9e425a1 ("Linux 5.12") .

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Thu, 20 May 2021 15:06:56 +0000 (11:06 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- Sync Armada mvpp2 ethernet driver with Marvell version (misc Marvell
  authors)

3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Thu, 20 May 2021 15:06:33 +0000 (11:06 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-riscv

3 years agoarm: mvebu: armada-3720-uDPU.dts: Change back to phy-mode "2500base-x"
Stefan Roese [Tue, 27 Apr 2021 09:48:28 +0000 (11:48 +0200)]
arm: mvebu: armada-3720-uDPU.dts: Change back to phy-mode "2500base-x"

With commit 8678776df6f5 (arm: mvebu: armada-3720-uDPU: fix PHY mode
definition to sgmii-2500) the PHY mode was switch to "sgmii-2500", even
when this is functionally incorrect since "2500base-x" was not supported
in U-Boot at that time. As this mode is now supported (at least present
in the headers), this patch moves back to the orinal version.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jakov Petrina <jakov.petrina@sartura.hr>
Cc: Vladimir Vid <vladimir.vid@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
3 years agonet: mvpp2: add explicit sgmii-2500 support
Marcin Wojtas [Mon, 3 May 2021 06:08:53 +0000 (08:08 +0200)]
net: mvpp2: add explicit sgmii-2500 support

Until now the mvpp2 driver used an extra 'phy-speed'
DT property in order to differentiate between the
SGMII and SGMII @2.5GHz. As there is a dedicated
PHY_INTERFACE_MODE_SGMII_2500 flag to mark the latter
start using it and drop the custom flag.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Stefan Chulski <stefanc@marvell.com>
Reviewed-by: Nadav Haklai <nadavh@marvell.com>
Tested-by: Nadav Haklai <nadavh@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
3 years agonet: mvpp2: allow MDIO registration for fixed links
Stefan Chulski [Mon, 3 May 2021 06:08:52 +0000 (08:08 +0200)]
net: mvpp2: allow MDIO registration for fixed links

Currently, there are 2 valid cases for interface, PHY
and mdio relation:
  - If an interface has PHY handler, it'll call
    mdio_mii_bus_get_from_phy(), which will register
    MDIO bus.
  - If we want to use fixed-link for an interface,
    PHY handle is not defined in the DTS, and no
    MDIO is registered.

There is a third case, for some boards (with switch),
the MDIO is used for switch configuration, but the interface
itself uses fixed link. This patch allows this option by
checking if fixed-link subnode is defined, in this case,
MDIO bus is registers, but the PHY address is set to
PHY_MAX_ADDR for this interface, so this interface will
not try to access the PHY later on.

Signed-off-by: Stefan Chulski <stefanc@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
3 years agonet: mvpp2: fix missing switch case break
Ben Peled [Mon, 3 May 2021 06:08:51 +0000 (08:08 +0200)]
net: mvpp2: fix missing switch case break

Signed-off-by: Ben Peled <bpeled@marvell.com>
Reviewed-by: Stefan Chulski <stefanc@marvell.com>
Reviewed-by: Kostya Porotchkin <kostap@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>