]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
20 months agodrivers: tee: sandbox: Fix SCP03 control emulator
Jorge Ramirez-Ortiz [Sat, 8 Apr 2023 15:35:31 +0000 (17:35 +0200)]
drivers: tee: sandbox: Fix SCP03 control emulator

Fix and document the Secure Channel Protocol03 emulator.

Fixes: 5a8783c80c39 ("drivers: tee: sandbox: SCP03 control emulator")
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agosandbox: fix return type of os_filesize()
Heinrich Schuchardt [Wed, 5 Apr 2023 09:34:15 +0000 (11:34 +0200)]
sandbox: fix return type of os_filesize()

Given a file ../img of size 4294967296 with GPT partition table and
partitions:

=> host bind 0 ../img
=> part list host 0
Disk host-0.blk not ready

The cause is os_filesize() returning int. File sizes must use off_t.

Correct all uses of os_filesize() too.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoMAINTAINERS: assign include/os.h
Heinrich Schuchardt [Wed, 5 Apr 2023 09:26:38 +0000 (11:26 +0200)]
MAINTAINERS: assign include/os.h

os.h is only used by the sandbox.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agobinman: Use unsigned long over typedef ulong
Andrew Davis [Tue, 4 Apr 2023 18:45:41 +0000 (13:45 -0500)]
binman: Use unsigned long over typedef ulong

The header binman_sym.h depends on ulong typedef but does not include
types.h. This means the header must be included after including types.h
or a header that includes it.

We could include types.h but instead let's just switch from ulong
to directly using unsigned long. This removes the need for typedef'ing
it in some of the tests, so also remove those.

Signed-off-by: Andrew Davis <afd@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agocommon: static fdt_simplefb_enable_existing_node()
Heinrich Schuchardt [Mon, 3 Apr 2023 18:46:50 +0000 (20:46 +0200)]
common: static fdt_simplefb_enable_existing_node()

Function fdt_simplefb_enable_existing_node() should be static as it is not
used outside common/fdt_simplefb.c.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoboot: vbe_simple: Fix vbe_simple_read_bootflow() dependency
Bin Meng [Mon, 3 Apr 2023 03:40:26 +0000 (11:40 +0800)]
boot: vbe_simple: Fix vbe_simple_read_bootflow() dependency

vbe_simple_read_bootflow() calls vbe_simple_read_bootflow_fw()
which is only available when BOOTMETH_VBE_SIMPLE_FW is on.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: mark sandbox_exit() as no return.
Heinrich Schuchardt [Sat, 1 Apr 2023 07:54:25 +0000 (09:54 +0200)]
sandbox: mark sandbox_exit() as no return.

Fix a -Wimplicit-fallthrough warning in sandbox_sysreset_request().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: spi: sandbox_sf_process_cmd() missing fallthrough
Heinrich Schuchardt [Sat, 1 Apr 2023 07:38:05 +0000 (09:38 +0200)]
sandbox: spi: sandbox_sf_process_cmd() missing fallthrough

Add a missing fallthrough macro to avoid a -Wimplicit-fallthrough warning.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: fix sandbox_hub_submit_control_msg()
Heinrich Schuchardt [Sat, 1 Apr 2023 06:57:33 +0000 (08:57 +0200)]
sandbox: fix sandbox_hub_submit_control_msg()

Avoid incorrect fall through:
A USB_RT_HUB request should not be treated as USB_RT_PORT.

Simplify the coding:
Avoid duplicate debug() statements.

This fixes all -Wimplicit-fallthrough warnings.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: fix fall through in sandbox_flash_bulk()
Heinrich Schuchardt [Sat, 1 Apr 2023 06:24:52 +0000 (08:24 +0200)]
sandbox: fix fall through in sandbox_flash_bulk()

Handling of SANDBOX_FLASH_EP_OUT should never fall through to
SANDBOX_FLASH_EP_IN.

This addresses a warning shown when compiling with
-Wimplicit-fallthrough.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoMerge branch '2023-04-27-introduce-nvm-xip-block-storage-emulation'
Tom Rini [Thu, 27 Apr 2023 23:22:38 +0000 (19:22 -0400)]
Merge branch '2023-04-27-introduce-nvm-xip-block-storage-emulation'

To quote the author:
Adding block storage emulation for NVM XIP flash devices.

Some paltforms such as Corstone-1000 need to see NVM XIP raw flash
as a block storage device with read only capability.

Here NVM flash devices are devices with addressable
memory (e.g: QSPI NOR flash).

The NVM XIP block storage emulation provides the following features:

- Emulate NVM XIP raw flash as a block storage device with read only capability
- Being generic by design and can be used by any platform
- Device tree node
- Platforms can use multiple NVM XIP devices at the same time by defining a
  DT node for each one of them
- A generic NVMXIP block driver allowing to read from the XIP flash
- A generic NVMXIP Uclass driver for binding the block device
- A generic NVMXIP QSPI driver
- Implemented on top of memory-mapped IO (using readq macro)
- Enabling NVMXIP in sandbox64
- A sandbox test case
- Enabling NVMXIP in Corstone1000 platform as a use case

For more details please refer to doc/develop/driver-model/nvmxip.rst

20 months agosandbox64: add a test case for UCLASS_NVMXIP
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:58 +0000 (10:11 +0100)]
sandbox64: add a test case for UCLASS_NVMXIP

provide a test for NVM XIP devices

The test case allows to make sure of the following:

- The NVM XIP QSPI devices are probed
- The DT entries are read correctly
- the data read from the flash by the NVMXIP block driver is correct

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agocorstone1000: enable NVM XIP QSPI flash
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:57 +0000 (10:11 +0100)]
corstone1000: enable NVM XIP QSPI flash

add the QSPI flash device with block storage capability

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agocorstone1000: add NVM XIP QSPI device tree node
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:56 +0000 (10:11 +0100)]
corstone1000: add NVM XIP QSPI device tree node

add QSPI flash device node for block storage access

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agosandbox64: add support for NVMXIP QSPI
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:55 +0000 (10:11 +0100)]
sandbox64: add support for NVMXIP QSPI

enable NVMXIP QSPI for sandbox 64-bit

Adding two NVM XIP QSPI storage devices.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox64: fix: return unsigned long in readq()
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:54 +0000 (10:11 +0100)]
sandbox64: fix: return unsigned long in readq()

make readq return unsigned long

readq should return 64-bit data

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agodrivers/mtd/nvmxip: introduce QSPI XIP driver
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:53 +0000 (10:11 +0100)]
drivers/mtd/nvmxip: introduce QSPI XIP driver

add nvmxip_qspi driver under UCLASS_NVMXIP

The device associated with this driver is the parent of the blk#<id> device
nvmxip_qspi can be reused by other platforms. If the platform
has custom settings to apply before using the flash, then the platform
can provide its own parent driver belonging to UCLASS_NVMXIP and reuse
nvmxip-blk driver. The custom driver can be implemented like nvmxip_qspi in
addition to the platform custom settings.

Platforms can use multiple NVM XIP devices at the same time by defining a
DT node for each one of them.

For more details please refer to doc/develop/driver-model/nvmxip_qspi.rst

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agodrivers/mtd/nvmxip: introduce NVM XIP block storage emulation
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:52 +0000 (10:11 +0100)]
drivers/mtd/nvmxip: introduce NVM XIP block storage emulation

add block storage emulation for NVM XIP flash devices

Some paltforms such as Corstone-1000 need to see NVM XIP raw flash
as a block storage device with read only capability.

Here NVM flash devices are devices with addressable
memory (e.g: QSPI NOR flash).

The implementation is generic and can be used by different platforms.

Two drivers are provided as follows.

  nvmxip-blk :

    a generic block driver allowing to read from the XIP flash

  nvmxip Uclass driver :

        When a device is described in the DT and associated with
        UCLASS_NVMXIP, the Uclass creates a block device and binds it with
 the nvmxip-blk.

Platforms can use multiple NVM XIP devices at the same time by defining a
DT node for each one of them.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agoMerge branch '2023-04-27-IDE-code-cleanups'
Tom Rini [Thu, 27 Apr 2023 20:33:58 +0000 (16:33 -0400)]
Merge branch '2023-04-27-IDE-code-cleanups'

To quote the author:
This code was converted to driver model a long time again but it was a
pretty rough conversion. It introduced a few minor bugs, e.g. the device
capacity is incorrect and some flags are lost (such as lba48).

This series tidies up the code and fixes these bugs. This involves quite
a bit of refactoring, so it is done one patch at a time for easier
review.

20 months agoide: Make use of U-Boot types
Simon Glass [Tue, 25 Apr 2023 16:54:55 +0000 (10:54 -0600)]
ide: Make use of U-Boot types

Use standard U-Boot types in the file to make the code less verbose.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Simplify expressions and hex values
Simon Glass [Tue, 25 Apr 2023 16:54:54 +0000 (10:54 -0600)]
ide: Simplify expressions and hex values

The code has quite a few unnecessary brackets and comparisons to zero,
etc. Fix these up as well as some upper-case hex values and use of 0x in
printf() strings.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Convert to use log_debug()
Simon Glass [Tue, 25 Apr 2023 16:54:53 +0000 (10:54 -0600)]
ide: Convert to use log_debug()

Avoid the use of the function name in a few of the debug() calls, since
this causes a checkpatch warning. Convert all other calls too.

Use lower-case hex consistently.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Tidy up ide_reset()
Simon Glass [Tue, 25 Apr 2023 16:54:52 +0000 (10:54 -0600)]
ide: Tidy up ide_reset()

Avoid using #ifdef and use a single function declaration, so it is easier
to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Correct LBA setting
Simon Glass [Tue, 25 Apr 2023 16:54:51 +0000 (10:54 -0600)]
ide: Correct LBA setting

Fix a longstanding bug where the LBA is calculated as the size of the
media instead of the number of blocks. This was perhaps not noticed
earlier since it prints the correct value first, before setting the wrong
value.

Drop the unnecessary blksz variable while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model")
20 months agoide: Use a single local blk_desc for ide_ident()
Simon Glass [Tue, 25 Apr 2023 16:54:50 +0000 (10:54 -0600)]
ide: Use a single local blk_desc for ide_ident()

We only use one member of the ide_dev_desc[] array at a time and it does
not stick around outside ide_probe(). Use a single element instead.

Copy over the missing members of blk_desc at the same, since this was
missing from the previous code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model")
20 months agoide: Move all blk_desc init into ide_ident()
Simon Glass [Tue, 25 Apr 2023 16:54:49 +0000 (10:54 -0600)]
ide: Move all blk_desc init into ide_ident()

Rather than having the caller fill some of this in, do it all in the
ide_ident() function, since it knows all the values.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Make ide_ident() return an error code
Simon Glass [Tue, 25 Apr 2023 16:54:48 +0000 (10:54 -0600)]
ide: Make ide_ident() return an error code

Update ide_ident() to indicate whether it finds a device or not. Use
that to decide whether to create a block device for it, rather than
looking DEV_TYPE_UNKNOWN.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Use desc consistently for struct blk_desc
Simon Glass [Tue, 25 Apr 2023 16:54:47 +0000 (10:54 -0600)]
ide: Use desc consistently for struct blk_desc

Most of the code uses 'desc' as the variable name for a blk descriptor.
Change ide to do the same.

Tidy up some extra brackets and types while we are here.

Leave the code in ide_probe() alone since it is about to be refactored.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Combine the two loops in ide_probe()
Simon Glass [Tue, 25 Apr 2023 16:54:46 +0000 (10:54 -0600)]
ide: Combine the two loops in ide_probe()

The two loops in this function operate on the same ide_dev_desc[] array.
Combine them to reduce duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move ide_init() entirely within ide_probe()
Simon Glass [Tue, 25 Apr 2023 16:54:45 +0000 (10:54 -0600)]
ide: Move ide_init() entirely within ide_probe()

Now that ide_probe() is the only caller of ide_init(), move all the code
into the probe function, so it is easier to refactor it.

Move ide_dev_desc[] into ide_probe() to, since it is the only user.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move setting of vendor strings into ide_probe()
Simon Glass [Tue, 25 Apr 2023 16:54:44 +0000 (10:54 -0600)]
ide: Move setting of vendor strings into ide_probe()

The current implementation adds this information in the block device's
probe() function, which is called in the blk_probe_or_unbind() in
ide_probe().

It is simpler to do this in ide_probe() itself, since the effect is the
same. This helps to consolidate use of ide_dev_desc[] which we would like
to remove.

Use strlcpy() to keep checkpatch happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Make ide_bus_ok a local variable
Simon Glass [Tue, 25 Apr 2023 16:54:43 +0000 (10:54 -0600)]
ide: Make ide_bus_ok a local variable

This is only used in one place now, so make it a local variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move bus init into a function
Simon Glass [Tue, 25 Apr 2023 16:54:42 +0000 (10:54 -0600)]
ide: Move bus init into a function

Move this code into a separate function which returns whether the bus was
found, or not.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Avoid preprocessor for CONFIG_LBA48
Simon Glass [Tue, 25 Apr 2023 16:54:41 +0000 (10:54 -0600)]
ide: Avoid preprocessor for CONFIG_LBA48

Use IS_ENABLED() instead for all conditions. Add the 'lba48' flag into
struct blk_desc always, since it uses very little space. Use a bool so
the meaning is clearer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
20 months agoide: Avoid preprocessor for CONFIG_ATAPI
Simon Glass [Tue, 25 Apr 2023 16:54:40 +0000 (10:54 -0600)]
ide: Avoid preprocessor for CONFIG_ATAPI

Use IS_ENABLED() instead for all conditions.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Simplify success condition
Simon Glass [Tue, 25 Apr 2023 16:54:39 +0000 (10:54 -0600)]
ide: Simplify success condition

Change the if() to remove extra brackets and check for the positive case
first, i.e. when a device is found. Exit the loop in that case, with the
retry logic in the 'else' part.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Refactor confusing loop code
Simon Glass [Tue, 25 Apr 2023 16:54:38 +0000 (10:54 -0600)]
ide: Refactor confusing loop code

This code is hard to follow as it uses #ifdef in a strange way. Adjust
it to avoid the preprocessor. Drop the special return for the non-ATAPI
case since we can rely on tries becoming 0 and exiting the loop.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Change the retries variable
Simon Glass [Tue, 25 Apr 2023 16:54:37 +0000 (10:54 -0600)]
ide: Change the retries variable

Use a 'tries' variable which starts at the number of tries we want to do,
rather than a 'retries' one that stops at either 1 or 2. This will make it
easier to refactor the code to avoid the horrible #ifdefs

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Make function static
Simon Glass [Tue, 25 Apr 2023 16:54:36 +0000 (10:54 -0600)]
ide: Make function static

Only one function is called from outside this file. Make all the others
static.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Correct use of ATAPI
Simon Glass [Tue, 25 Apr 2023 16:54:35 +0000 (10:54 -0600)]
ide: Correct use of ATAPI

The use of atapi_read() was incorrect dropped. Fix this so that it will
be used when needed. Use a udevice for the first argument of atapi_read()
so it is consistent with ide_read().

This requires much of the ATAPI code to be brought out from behind the
existing #ifdef. It will still be removed by the compiler if it is not
needed.

Add an atapi flag to struct blk_desc so the information can be retained.

Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices")
Fixes: d0075059e4d ("ide: Drop non-DM code for BLK")
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Create a prototype for ide_set_reset()
Simon Glass [Tue, 25 Apr 2023 16:54:34 +0000 (10:54 -0600)]
ide: Create a prototype for ide_set_reset()

This is used by a board so should be in the header file. Add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Drop weak functions
Simon Glass [Tue, 25 Apr 2023 16:54:33 +0000 (10:54 -0600)]
ide: Drop weak functions

These are not used from outside this file anymore. Make them static and
remove them from the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move a few functions further up the file
Simon Glass [Tue, 25 Apr 2023 16:54:32 +0000 (10:54 -0600)]
ide: Move a few functions further up the file

Move these functions so they appear before they are used.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Drop ide_device_present()
Simon Glass [Tue, 25 Apr 2023 16:54:31 +0000 (10:54 -0600)]
ide: Drop ide_device_present()

This function is not used anymore. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move ide_init() into probing
Simon Glass [Tue, 25 Apr 2023 16:54:30 +0000 (10:54 -0600)]
ide: Move ide_init() into probing

At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Drop init for not using BLK
Simon Glass [Tue, 25 Apr 2023 16:54:29 +0000 (10:54 -0600)]
ide: Drop init for not using BLK

ALl boards use CONFIG_BLK now so this code is not used. Drop it and the
header-file #ifdef

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Drop CONFIG_START_IDE
Simon Glass [Tue, 25 Apr 2023 16:54:28 +0000 (10:54 -0600)]
ide: Drop CONFIG_START_IDE

This is not used by any board. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Use mdelay() for long delays
Simon Glass [Tue, 25 Apr 2023 16:54:27 +0000 (10:54 -0600)]
ide: Use mdelay() for long delays

Rather than using very large numbers with udelay(), use mdelay(), which
is easier to follow.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move ATA_CURR_BASE to C file
Simon Glass [Tue, 25 Apr 2023 16:54:26 +0000 (10:54 -0600)]
ide: Move ATA_CURR_BASE to C file

This is not used outside one C file. Move it out of the header to
reduce its visbility.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoMerge branch '2023-04-26-enable-bootstd-for-all-rockchip'
Tom Rini [Wed, 26 Apr 2023 17:29:49 +0000 (13:29 -0400)]
Merge branch '2023-04-26-enable-bootstd-for-all-rockchip'

- Merge Simon's series that enables bootstd and the distro bootmeth
  there for all of Rockchip.

20 months agorockchip: Use the same boot_targets for all boards
Simon Glass [Mon, 24 Apr 2023 01:49:52 +0000 (13:49 +1200)]
rockchip: Use the same boot_targets for all boards

It doesn't really matter if we mention things which are not present. For
example, if 'nvme' is included but the board does not support it, it just
continues with the next item in the list.

It is simpler to use the same target list for all boards, so drop the
different one for rk3399.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agorockchip: Move to standard boot
Simon Glass [Mon, 24 Apr 2023 01:49:51 +0000 (13:49 +1200)]
rockchip: Move to standard boot

Drop the distro-boot scripts and use standard boot instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
20 months agobootstd: Use blk uclass device numbers to set efi bootdev
Mathew McBride [Mon, 24 Apr 2023 01:49:50 +0000 (13:49 +1200)]
bootstd: Use blk uclass device numbers to set efi bootdev

When loading a file from a block device, efiload_read_file
was using the seq_num of the device (e.g "35" of virtio_blk#35)
instead of the block device id (e.g what you get from running
the corresponding device scan command, like "virtio 0")

This cause EFI booting from these devices to fail as an
invalid device number is passed to blk_get_device_part_str:

  Scanning bootdev 'virtio-blk#35.bootdev':
  distro_efi_read_bootflow_file start (efi,fname=<NULL>)
  distro_efi_read_bootflow_file start (efi,fname=<NULL>)
  setting bootdev virtio, 35, efi/boot/bootaa64.efi, 00000000beef9a40, 170800
  efi_dp_from_name calling blk_get_device_part_str
  dev=virtio devnr=35 path=efi/boot/bootaa64.efi
  blk_get_device_part_str (virtio,35)
  blk_get_device_by_str (virtio, 35)
  ** Bad device specification virtio 35 **
  Using default device tree: dtb/qemu-arm.dtb
  No device tree available
  0  efi          ready   virtio       1  virtio-blk#35.bootdev.par efi/boot/bootaa64.efi
  ** Booting bootflow 'virtio-blk#35.bootdev.part_1' with efi
  blk_get_device_part_str (virtio,0:1)
  blk_get_device_by_str (virtio, 0)
  No UEFI binary known at beef9a40 (image buf=00000000beef9a40,addr=0000000000000000)
  Boot failed (err=-22)

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agobootstd: Adjust code ordering to work around compiler quirk
Simon Glass [Mon, 24 Apr 2023 01:49:49 +0000 (13:49 +1200)]
bootstd: Adjust code ordering to work around compiler quirk

At present when debugging is off, bootdev_find_in_blk() sometimes fails
to find a valid bootflow, e.g. with virtio. Accessing the 'blk' variable
later in the function seems to correct it.

Move the 'ret' check before the debug statement and set the block device
again aftewards, to work around this.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agobootstd: Show a message sometimes if no bootflows are found
Simon Glass [Mon, 24 Apr 2023 01:49:48 +0000 (13:49 +1200)]
bootstd: Show a message sometimes if no bootflows are found

Enable some messages that might provide hints, but only for
CMD_BOOTFLOW_FULL since otherwise the -l flag is not available.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
20 months agobootstd: Report missing labels only when asked
Simon Glass [Mon, 24 Apr 2023 01:49:47 +0000 (13:49 +1200)]
bootstd: Report missing labels only when asked

Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agobootstd: Support booting EFI where multiple options exist
Simon Glass [Mon, 24 Apr 2023 01:49:46 +0000 (13:49 +1200)]
bootstd: Support booting EFI where multiple options exist

The current EFI implementation has a strange quirk where it watches
loaded files and uses the last-loaded file to determine the device that
is being booted from.

This is confusing with bootstd, where multiple options may exist. Even
loading a device tree will cause it to go wrong. There is no API for
passing this information, since the only entry into booting an EFI image
is the 'bootefi' command.

To work around this, call efi_set_bootdev() for EFI images, if possible,
just before booting.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agovirtio: Ensure PCI is set up first
Simon Glass [Mon, 24 Apr 2023 01:49:45 +0000 (13:49 +1200)]
virtio: Ensure PCI is set up first

Sometimes virtio may rely on PCI, or at least that is what the
distro_bootcmd script suggests. Add this in.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agobootstd: Tweak bootflow logic for device tree
Simon Glass [Mon, 24 Apr 2023 01:49:44 +0000 (13:49 +1200)]
bootstd: Tweak bootflow logic for device tree

We should only store the FDT filename if we were able to determine one.
Adjust the logic for this.

This corrects the case where no FDT is needed to boot, such as with EFI
using ACPI.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoMerge branch '2023-04-25-assorted-updates-and-fixes'
Tom Rini [Wed, 26 Apr 2023 12:24:34 +0000 (08:24 -0400)]
Merge branch '2023-04-25-assorted-updates-and-fixes'

- A few TI, mpc8379erdb and vexpress64 updates, some arm64 core updates,
  test cleanups, Xen cleanups, assorted code and Kconfig cleanups (many
  in preparation for using clang on ARM), psci pre-reloc fixes, enable
  PCI bus mastering for ATA devices, and a gpio-uclass bugfix

20 months agogpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()
Rasmus Villemoes [Wed, 19 Apr 2023 10:10:13 +0000 (12:10 +0200)]
gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()

By the time we jump to the err label, count represents the number of
gpios we've successfully requested. So by subtracting one, we fail to
free the most recently requested.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoxen: Limit execution to EL1 only
Michal Simek [Tue, 18 Apr 2023 12:51:56 +0000 (14:51 +0200)]
xen: Limit execution to EL1 only

Xen core_init() is calling HVC which should be called from EL1 level that's
why do Xen initialization only when U-Boot runs in EL1.

Signed-off-by: Michal Simek <michal.simek@amd.com>
20 months agoxen: Add dependency on armv8
Michal Simek [Tue, 18 Apr 2023 12:51:55 +0000 (14:51 +0200)]
xen: Add dependency on armv8

U-Boot currently implements hypervisor calls only for ARM64 that's why add
dependency on ARM64. The hardware functionality is also available on
ARMv7a, but currently not supported by U-Boot, hence it is not added to the
list of dependencies here.

Signed-off-by: Michal Simek <michal.simek@amd.com>
20 months agoarm: omap3: Directly use SMC #1 in lowlevel_init.S
Pali Rohár [Thu, 13 Apr 2023 20:34:43 +0000 (22:34 +0200)]
arm: omap3: Directly use SMC #1 in lowlevel_init.S

Since commit de39dc71625d ("arm: armv7-a: Compile and tune for armv7-a
instead of armv5") is used -march=armv7-a option for Omap3 platforms.

With directive ".arch_extension sec" it is possible for -march=armv7-a to
directly use ARM SMC instruction.

So enable ".arch_extension sec" in Omap3 lowlevel_init.S and replace hand
assembled ".word 0xe1600071" by "SMC #1".

Since commit 51d063865064 ("arm: omap-common: add secure smc entry") same
pattern is already used in arch/arm/cpu/armv7/omap-common/lowlevel_init.S.

Signed-off-by: Pali Rohár <pali@kernel.org>
20 months agotools: env: update lock path in README
John Keeping [Wed, 12 Apr 2023 11:24:26 +0000 (12:24 +0100)]
tools: env: update lock path in README

Commit aeb40f1166e0 ("tools: env: use /run to store lockfile") updated the
path to the lockfile but did not update the documentation to match.

Use the new path in the documentation.

Fixes: aeb40f1166 ("tools: env: use /run to store lockfile")
Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoata: pci: enable bus mastering
Christian Gmeiner [Tue, 11 Apr 2023 15:07:02 +0000 (17:07 +0200)]
ata: pci: enable bus mastering

The non DM code path already would enable pci bus mastering. Do the
same for the DM code path.

Fixes AHCI problems I am seeing on an Intel Apollolake device.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[trini: Use ahci_dev not dev in the calls]
Signed-off-by: Tom Rini <trini@konsulko.com>
20 months agompc8379erdb: Convert to using DM_SERIAL
Sinan Akman [Fri, 7 Apr 2023 22:03:44 +0000 (18:03 -0400)]
mpc8379erdb: Convert to using DM_SERIAL

  Convert to DM_SERIAL for mpc8379erdb.

Signed-off-by: Sinan Akman <sinan@writeme.com>
20 months agoqemu: dfu: Correct memset call in set_dfu_alt_info
Tom Rini [Thu, 6 Apr 2023 13:58:40 +0000 (09:58 -0400)]
qemu: dfu: Correct memset call in set_dfu_alt_info

When building with clang, we see:
board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess]

As we're calling memset with the length set to the size of the pointer
and not the size of the buffer. Correct this with a call of the size of
the buffer itself.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
20 months agoapi: Rework menu, and make it depend on CC_IS_GCC
Tom Rini [Thu, 6 Apr 2023 13:48:58 +0000 (09:48 -0400)]
api: Rework menu, and make it depend on CC_IS_GCC

We can only use the old U-Boot API for standalone applications when
building U-Boot with GCC as it relies upon the "gd is a register" trick
that only GCC supports. Further, rework the rest of the options so that
they are in the API menu and only visible if API support is enabled.

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosysreset: psci: add psci_sysreset_get_status
Peng Fan [Thu, 6 Apr 2023 10:23:19 +0000 (18:23 +0800)]
sysreset: psci: add psci_sysreset_get_status

Add weak function psci_sysreset_get_status for platform to define
their own reset status with CONFIG_SYSRESET enabled.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
20 months agosysreset: psci: enable DM_FLAG_PRE_RELOC
Peng Fan [Thu, 6 Apr 2023 10:23:18 +0000 (18:23 +0800)]
sysreset: psci: enable DM_FLAG_PRE_RELOC

It is possible that cpu core may reset before relocation with PSCI reset

Signed-off-by: Peng Fan <peng.fan@nxp.com>
20 months agofirmware: psci: enable DM_FLAG_PRE_RELOC
Peng Fan [Thu, 6 Apr 2023 10:23:17 +0000 (18:23 +0800)]
firmware: psci: enable DM_FLAG_PRE_RELOC

It is possible that cpu core may reset before relocation with PSCI reset

Signed-off-by: Peng Fan <peng.fan@nxp.com>
20 months agoxen: Fix Kconfig dependencies
Michal Simek [Thu, 6 Apr 2023 08:04:15 +0000 (10:04 +0200)]
xen: Fix Kconfig dependencies

XEN config can be enabled by other platforms (even it doesn't need to make
sense) that's why fix dependencies. XEN (xenbus.c) requires sscanf (also
pvblock needs it). And PVBLOCK is inside drivers/xen folder which requires
XEN to be enabled.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agopytest: Use --lazy with umount
Tom Rini [Thu, 6 Apr 2023 02:19:39 +0000 (22:19 -0400)]
pytest: Use --lazy with umount

Sometimes when doing tests on real hardware we sometimes run in to the
case where some of these mounts haven't been fully flushed.  Using the
--lazy option with umount will allow us to continue while letting the OS
handle flushing the data out still.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agousb: gadget: f_mass_storage: Rework do_request_sense slightly
Tom Rini [Wed, 5 Apr 2023 23:48:57 +0000 (19:48 -0400)]
usb: gadget: f_mass_storage: Rework do_request_sense slightly

When building with clang, it notes that sdinfo may be unused
uninitialized in some cases. This appears to be true from reading the
code, and we can simply set the variable to zero to start with and be as
correct as before.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Marek Vasut <marex@denx.de>
20 months agoboot/image-board.c: Silence warning in select_ramdisk
Tom Rini [Wed, 5 Apr 2023 23:48:56 +0000 (19:48 -0400)]
boot/image-board.c: Silence warning in select_ramdisk

When building with clang we get a warning that rdaddr could be
uninitialized in one case. While this cannot functionally happen, we can
easily silence the warning.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoarmv7: Use isb/dsb directly in start.S
Tom Rini [Wed, 5 Apr 2023 23:48:55 +0000 (19:48 -0400)]
armv7: Use isb/dsb directly in start.S

Toolchains which do not directly support using "isb" and "dsb" directly
are no longer functionally supported in U-Boot. Furthermore, clang has
for a long time warned about using the alternate form that we were.
Update the code.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoarm: Centralize fixed register logic
Tom Rini [Wed, 5 Apr 2023 23:48:54 +0000 (19:48 -0400)]
arm: Centralize fixed register logic

When building for ARM64, we need to pass -ffixed-x18 and otherwise pass
-ffixed-r9. Rather than having this logic in two places, we can do this
once in arch/arm/config.mk. Further, while gcc will ignore being passed
both -ffixed-r9 and -ffixed-x18 and simply use -ffixed-x18, clang will
note that -ffixed-r9 is not used. Remove this duplication to also remove
the warning.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoclang: Don't look for libgcc
Tom Rini [Wed, 5 Apr 2023 23:48:53 +0000 (19:48 -0400)]
clang: Don't look for libgcc

In the case of using clang to build, and having not already enabled the
private libgcc, do not look for it, as it will not be found nor
required.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoclang: Add $(CLANG_TARGET) to LDPPFLAGS
Tom Rini [Wed, 5 Apr 2023 23:48:52 +0000 (19:48 -0400)]
clang: Add $(CLANG_TARGET) to LDPPFLAGS

When we invoke $(CPP) to make u-boot.lds we have LDPPFLAGS available to
set other required flags here. As this file is for the target and not
the host, we must ensure that CPP knows what the target architecture is.
For this, pass in $(CLANG_TARGET).

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoarm: Only support ARM64_CRC32 when using GCC
Tom Rini [Wed, 5 Apr 2023 23:48:51 +0000 (19:48 -0400)]
arm: Only support ARM64_CRC32 when using GCC

Today, only gcc has __builtin_aarch64_crc32b (clang-16 does not, for
example). Make this option depend on CC_IS_GCC.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agofs: yaffs2: Make yaffsfs_deviceList static
Bin Meng [Wed, 5 Apr 2023 14:40:22 +0000 (22:40 +0800)]
fs: yaffs2: Make yaffsfs_deviceList static

yaffsfs_deviceList is only referenced in yaffsfs.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
20 months agotest: move unit tests into a sub-menu
Heinrich Schuchardt [Mon, 3 Apr 2023 18:27:43 +0000 (20:27 +0200)]
test: move unit tests into a sub-menu

The main configuration menu should not contain detail settings.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agotest: improve configuration for Kconfig test options
Heinrich Schuchardt [Mon, 3 Apr 2023 10:04:39 +0000 (12:04 +0200)]
test: improve configuration for Kconfig test options

* Fix dependencies
* Provide labels that are easier to grasp.
* Fix typo %s/whgch/which/
* Fix type %s/Is/is/

Fixes: 29784d62eded ("test: Add some tests for kconfig.h")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoarm64: interrupts: print FAR_ELx on sync exceptions
Pavel Skripkin [Sun, 2 Apr 2023 16:27:34 +0000 (19:27 +0300)]
arm64: interrupts: print FAR_ELx on sync exceptions

Default synchronous exceptions handler prints only esr and register
dump. Sometimes it requiers to see an address which caused exceptions
to understand what's going on

ARM ARM in section D13.2.41 states that FAR_EL2 will contain meanfull
value in case of ESR.EC holds 0x20, 0x21, 0x24, 0x25, 0x22, 0x34 or
0x35. Same applies for EL1.

This patch adds function whivh determine current EL, gets correct FAR
register and prints it on panic.

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
20 months agoconfigs: Create minimal vexpress_fvp_defconfig
Peter Hoyes [Fri, 31 Mar 2023 08:58:13 +0000 (09:58 +0100)]
configs: Create minimal vexpress_fvp_defconfig

The vexpress64 board family now relies on OF_CONTROL and
OF_HAS_PRIOR_STAGE, so platform-specific configuration requirements
are minimal.

The vexpress_aemv8a_semi_defconfig file defines many flags that are not
needed for a minimal boot, such as flash memory configuration.

Therefore create vexpress_fvp_defconfig which contains the minimum
configuration required to boot on an Arm v8a FVP.

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
20 months agovexpress64: Enable VIRTIO_MMIO and RTC_PL031 in the base model
Peter Hoyes [Fri, 31 Mar 2023 08:58:12 +0000 (09:58 +0100)]
vexpress64: Enable VIRTIO_MMIO and RTC_PL031 in the base model

The Arm EBBR (Embedded Base Boot Requirements) require that the time
and basic networking EFI interfaces are available and working, so long
as the hardware has an RTC and network interface.

Arm FVPs typically have a memory-mapped PL031 RTC and a VIRTIO_NET
device defined in the device tree, so "imply" these in the Kconfig for
the FVP base model to simplify creating EBBR-compliant firmware.

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
20 months agovexpress64: Use OF_HAS_PRIOR_STAGE for BASE_FVP variant
Peter Hoyes [Fri, 31 Mar 2023 08:58:11 +0000 (09:58 +0100)]
vexpress64: Use OF_HAS_PRIOR_STAGE for BASE_FVP variant

BASE_FVP now typically uses a devicetree provided by a prior boot stage
(typically Arm TF-A), so imply this option by default when
TARGET_VEXPRESS64_BASE_FVP is selected.

OF_HAS_PRIOR_STAGE selects OF_BOARD so this change is minor, but aligns
TARGET_VEXPRESS64_BASE_FVP with TARGET_VEXPRESS64_BASER_FVP.

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
20 months agoinclude: configs: am64x_evm: Change to using .env
Nikhil M Jain [Thu, 30 Mar 2023 08:54:09 +0000 (14:24 +0530)]
include: configs: am64x_evm: Change to using .env

Move to using .env file for setting up environment variables for am64x.

Signed-off-by: Nikhil M Jain <n-jain1@ti.com>
Reviewed-by: Devarsh Thakkar <devarsht@ti.com>
20 months agoarch: mach-k3: j721s2_init: Disable the firewalls
Jayesh Choudhary [Tue, 28 Mar 2023 13:02:01 +0000 (18:32 +0530)]
arch: mach-k3: j721s2_init: Disable the firewalls

Some firewalls enabled by ROM are still left on. So some
address space is inaccessible to the bootloader. For example,
in OSPI boot mode we get an exception and the system hangs.
Therefore, disable all the firewalls left on by the ROM.

Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
Reviewed-by: Andrew Davis <afd@ti.com>
Reviewed-by: Manorit Chawdhry <m-chawdhry@ti.com>
20 months agosoc: soc_ti_k3: fix revision array bounds checks
Rasmus Villemoes [Fri, 24 Mar 2023 07:44:29 +0000 (08:44 +0100)]
soc: soc_ti_k3: fix revision array bounds checks

If rev is equal to the array size, we'll access the array
one-past-the-end.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Bryan Brattlof <bb@ti.com>
20 months agoarmv8: enable HAFDBS for other ELx when FEAT_HAFDBS is present
meitao [Fri, 17 Mar 2023 16:22:53 +0000 (00:22 +0800)]
armv8: enable HAFDBS for other ELx when FEAT_HAFDBS is present

u-boot could be run at EL1/EL2/EL3. so we set it as same as EL1 does.
otherwise it will hang when enable mmu, that is what we encounter
in our SOC.

Signed-off-by: meitao <meitaogao@asrmicro.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3bf38943aeab4700c2319bff2a1477d99c6afd2f
20 months agoarm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present
Marc Zyngier [Fri, 17 Mar 2023 16:22:52 +0000 (00:22 +0800)]
arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8
20 months agoarm64: Use FEAT_HAFDBS to track dirty pages when available
Marc Zyngier [Fri, 17 Mar 2023 16:22:51 +0000 (00:22 +0800)]
arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263
20 months agoMerge branch '2023-04-25-use-bounce-buffers-for-VIRTIO_F_IOMMU_PLATFORM'
Tom Rini [Tue, 25 Apr 2023 18:22:40 +0000 (14:22 -0400)]
Merge branch '2023-04-25-use-bounce-buffers-for-VIRTIO_F_IOMMU_PLATFORM'

To quote the author:
These patches will use bounce buffers when VIRTIO_F_IOMMU_PLATFORM
feature is in a virtio device.

This feature can be tested with qemu with -device virtio-iommu-pci.  So
that when a -device virtio-blk-pci with iommu_platform=true, it will
uses the bounce buffer instead.

20 months agovirtio: Use bounce buffers when VIRTIO_F_IOMMU_PLATFORM is set
Will Deacon [Wed, 29 Mar 2023 14:25:00 +0000 (22:25 +0800)]
virtio: Use bounce buffers when VIRTIO_F_IOMMU_PLATFORM is set

Devices advertising the VIRTIO_F_IOMMU_PLATFORM feature require
platform-specific handling to configure their DMA transactions.

When handling virtio descriptors for such a device, use bounce
buffers to ensure that the underlying buffers are always aligned
to and padded to PAGE_SIZE in preparation for platform specific
handling at page granularity.

Signed-off-by: Will Deacon <willdeacon@google.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/1eff171e613ee67dca71dbe97be7282e2db17011
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agovirtio: Allocate bounce buffers for devices with VIRTIO_F_IOMMU_PLATFORM
Will Deacon [Wed, 29 Mar 2023 14:24:59 +0000 (22:24 +0800)]
virtio: Allocate bounce buffers for devices with VIRTIO_F_IOMMU_PLATFORM

In preparation for bouncing virtio data for devices advertising the
VIRTIO_F_IOMMU_PLATFORM feature, allocate an array of bounce buffer
structures in the vring, one per descriptor.

Signed-off-by: Will Deacon <willdeacon@google.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3e052749e7c50c4c1a6014e645ae3b9be3710c07
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agovirtio: Add helper functions to attach/detach vring descriptors
Will Deacon [Wed, 29 Mar 2023 14:24:58 +0000 (22:24 +0800)]
virtio: Add helper functions to attach/detach vring descriptors

Move the attach and detach logic for manipulating vring descriptors
out into their own functions so that we can later extend these to
bounce the data for devices with VIRTIO_F_IOMMU_PLATFORM set.

Signed-off-by: Will Deacon <willdeacon@google.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/f73258a4bfe968c5f935db45f2ec5cc0104ee796
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agovirtio: Allocate virtqueue in page-size units
Will Deacon [Wed, 29 Mar 2023 14:24:57 +0000 (22:24 +0800)]
virtio: Allocate virtqueue in page-size units

In preparation for explicit bouncing of virtqueue pages for devices
advertising the VIRTIO_F_IOMMU_PLATFORM feature, introduce a couple
of wrappers around virtqueue allocation and freeing operations,
ensuring that buffers are handled in terms of page-size units.

Signed-off-by: Will Deacon <willdeacon@google.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/b4bb5227d4cf4fdfcd8b4e1ff2692d3a54d1482a
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agovirtio: pci: Tear down VQs in virtio_pci_reset()
Will Deacon [Wed, 29 Mar 2023 14:24:56 +0000 (22:24 +0800)]
virtio: pci: Tear down VQs in virtio_pci_reset()

The pages backing the virtqueues for virtio PCI devices are not freed
on reset, despite the virtqueue structure being freed as part of the
driver '->priv_auto' destruction at ->remove() time.

Call virtio_pci_del_vqs() from virtio_pci_reset() to free the virtqueue
pages before freeing the virtqueue structure itself.

Signed-off-by: Will Deacon <willdeacon@google.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/5ed54ccd83cbffd0d8719ce650604b4e44b5b0d8
Reviewed-by: Simon Glass <sjg@chromium.org>