From 7556927fc0a7e9df0cbf9f85e056569ecffead98 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Aug 2022 16:13:49 +0200 Subject: [PATCH 1/4] doc: qemu-riscv: describe booting with QEMU and KVM The ELF U-Boot image produced by qemu-riscv64_smode_defconfig can be used to boot with QEMU and KVM. Signed-off-by: Heinrich Schuchardt --- doc/board/emulation/qemu-riscv.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 782f37251c3..509bf7c4a6c 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -133,6 +133,19 @@ An attached disk can be emulated in RISC-V virt machine by adding:: You will have to run 'scsi scan' to use it. +Running with KVM +---------------- + +Running with QEMU using KVM requires an S-mode U-Boot binary as created by +qemu-riscv64_smode_defconfig. + +Provide the U-Boot S-mode ELF image as *-kernel* parameter and do not add a +*-bios* parameter, e.g. + +.. code-block:: bash + + qemu-system-riscv64 -accel kvm -nographic -machine virt -kernel u-boot + Debug UART ---------- From 8f666cbb75bb0290fa7987def29e751a670a04ce Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Thu, 4 Aug 2022 19:57:45 +0200 Subject: [PATCH 2/4] doc: dm: clarify activation. Explain when devices should get activated. Signed-off-by: Michal Suchanek Reviewed-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- doc/develop/driver-model/design.rst | 47 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst index a75d637ec33..20611e85e34 100644 --- a/doc/develop/driver-model/design.rst +++ b/doc/develop/driver-model/design.rst @@ -794,34 +794,53 @@ fall afoul of this rule. Activation/probe ^^^^^^^^^^^^^^^^ -When a device needs to be used, U-Boot activates it, by first reading ofdata -as above and then following these steps (see device_probe()): +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader, +not an operating system. Many devices are never used during an U-Boot run, and +probing them takes time, requires memory, may add delays to the main loop, etc. + +The device should be probed by the uclass code or generic device code (e.g. +device_find_global_by_ofnode()). Uclasses differ but two common use cases can be +seen: + + 1. The uclass is asked to look up a specific device, such as SPI bus 0, + first chip select - in this case the returned device should be + activated. + + 2. The uclass is asked to perform a specific function on any device that + supports it, eg. reset the board using any sysreset that can be found - + for this case the core uclass code provides iterators that activate + each device before returning it, and the uclass typically implements a + walk function that iterates over all devices of the uclass and tries + to perform the requested function on each in turn until succesful. + +To activate a device U-Boot first reads ofdata as above and then follows these +steps (see device_probe()): 1. All parent devices are probed. It is not possible to activate a device - unless its predecessors (all the way up to the root device) are activated. - This means (for example) that an I2C driver will require that its bus - be activated. + unless its predecessors (all the way up to the root device) are activated. + This means (for example) that an I2C driver will require that its bus + be activated. 2. The device's probe() method is called. This should do anything that - is required by the device to get it going. This could include checking - that the hardware is actually present, setting up clocks for the - hardware and setting up hardware registers to initial values. The code - in probe() can access: + is required by the device to get it going. This could include checking + that the hardware is actually present, setting up clocks for the + hardware and setting up hardware registers to initial values. The code + in probe() can access: - platform data in dev->plat (for configuration) - private data in dev->priv (for run-time state) - uclass data in dev->uclass_priv (for things the uclass stores about this device) - Note: If you don't use priv_auto then you will need to - allocate the priv space here yourself. The same applies also to - plat_auto. Remember to free them in the remove() method. + Note: If you don't use priv_auto then you will need to + allocate the priv space here yourself. The same applies also to + plat_auto. Remember to free them in the remove() method. 3. The device is marked 'activated' 4. The uclass's post_probe() method is called, if one exists. This may - cause the uclass to do some housekeeping to record the device as - activated and 'known' by the uclass. + cause the uclass to do some housekeeping to record the device as + activated and 'known' by the uclass. Running stage ^^^^^^^^^^^^^ From ab31c8a158715abe4bceadb8eb78aa3e281d0bdc Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Fri, 19 Aug 2022 09:48:30 +0900 Subject: [PATCH 3/4] efi_loader: disk: remove unused field The field, ifname, in efi_disk_obj is set but never used anywhere. Just remove it. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_disk.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 16d14b04297..f269abf1354 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -29,7 +29,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * * @header: EFI object header * @ops: EFI disk I/O protocol interface - * @ifname: interface name for block device * @dev_index: device index of block device * @media: block I/O media information * @dp: device path to the block device @@ -40,7 +39,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; struct efi_disk_obj { struct efi_object header; struct efi_block_io ops; - const char *ifname; int dev_index; struct efi_block_io_media media; struct efi_device_path *dp; @@ -379,7 +377,6 @@ static int efi_fs_exists(struct blk_desc *desc, int part) * * @parent: parent handle * @dp_parent: parent device path - * @if_typename: interface name for block device * @desc: internal block device * @dev_index: device index for block device * @part_info: partition info @@ -390,7 +387,6 @@ static int efi_fs_exists(struct blk_desc *desc, int part) static efi_status_t efi_disk_add_dev( efi_handle_t parent, struct efi_device_path *dp_parent, - const char *if_typename, struct blk_desc *desc, int dev_index, struct disk_partition *part_info, @@ -475,7 +471,6 @@ static efi_status_t efi_disk_add_dev( return ret; } diskobj->ops = block_io_disk_template; - diskobj->ifname = if_typename; diskobj->dev_index = dev_index; /* Fill in EFI IO Media info (for read/write callbacks) */ @@ -533,15 +528,13 @@ static int efi_disk_create_raw(struct udevice *dev) { struct efi_disk_obj *disk; struct blk_desc *desc; - const char *if_typename; int diskid; efi_status_t ret; desc = dev_get_uclass_plat(dev); - if_typename = blk_get_if_type_name(desc->if_type); diskid = desc->devnum; - ret = efi_disk_add_dev(NULL, NULL, if_typename, desc, + ret = efi_disk_add_dev(NULL, NULL, desc, diskid, NULL, 0, &disk); if (ret != EFI_SUCCESS) { if (ret == EFI_NOT_READY) @@ -575,7 +568,6 @@ static int efi_disk_create_part(struct udevice *dev) { efi_handle_t parent; struct blk_desc *desc; - const char *if_typename; struct disk_part *part_data; struct disk_partition *info; unsigned int part; @@ -589,7 +581,6 @@ static int efi_disk_create_part(struct udevice *dev) return -1; desc = dev_get_uclass_plat(dev_get_parent(dev)); - if_typename = blk_get_if_type_name(desc->if_type); diskid = desc->devnum; part_data = dev_get_uclass_plat(dev); @@ -601,7 +592,7 @@ static int efi_disk_create_part(struct udevice *dev) return -1; dp_parent = (struct efi_device_path *)handler->protocol_interface; - ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid, + ret = efi_disk_add_dev(parent, dp_parent, desc, diskid, info, part, &disk); if (ret != EFI_SUCCESS) { log_err("Adding partition for %s failed\n", dev->name); From 2a4fb47533318f26702a8e8a38a002433e75202b Mon Sep 17 00:00:00 2001 From: Heiko Thiery Date: Sat, 6 Aug 2022 13:22:53 +0200 Subject: [PATCH 4/4] tools: mkeficapsule: use pkg-config for each lib separat Call pkg-config for each library individually. This improves fallback handling. Suggested-by: AKASHI Takahiro Fixes: 31a7688cbe0e ("tools: mkeficapsule: use pkg-config to get -luuid and -lgnutls") Signed-off-by: Heiko Thiery Reviewed-by: Heinrich Schuchardt --- tools/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 005e7362a31..3626919633a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -245,9 +245,13 @@ hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include HOSTCFLAGS_mkeficapsule.o += \ - $(shell pkg-config --cflags gnutls uuid 2> /dev/null || echo "") + $(shell pkg-config --cflags gnutls 2> /dev/null || echo "") +HOSTCFLAGS_mkeficapsule.o += \ + $(shell pkg-config --cflags uuid 2> /dev/null || echo "") HOSTLDLIBS_mkeficapsule += \ - $(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid") + $(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls") +HOSTLDLIBS_mkeficapsule += \ + $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule # We build some files with extra pedantic flags to try to minimize things