[PATCH 2/2] efi: remove error in efi_disk_remove

Patrick Delaunay patrick.delaunay at foss.st.com
Wed Mar 8 14:26:48 CET 2023

EFI has no reason to block the driver remove when the associated EFI
resources failed to be released.

This patch avoids DM issue when an EFI resource can't be released,
for example if this resource wasn't created, for duplicated device name

Without this patch, the U-Boot device tree is not updated for "usb stop"
command because EFI stack can't free a resource; in usb_stop(), the
remove operation is stopped on first device_remove() error, including a
device_notify() error on any child.

And this remove error, returned by usb_stop(), is not managed in cmd/usb.c
and the next "usb start" command cause a crash because all the USB devices
need to be released before the next USB scan.

Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>

 lib/efi_loader/efi_disk.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 8d53ba3bd27e..22a0035dcde2 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -767,16 +767,20 @@ int efi_disk_remove(void *ctx, struct event *event)
 	enum uclass_id id;
 	struct udevice *dev;
+	int ret = 0;
 	dev = event->data.dm.dev;
 	id = device_get_uclass_id(dev);
 	if (id == UCLASS_BLK)
-		return efi_disk_delete_raw(dev);
+		ret = efi_disk_delete_raw(dev);
 	else if (id == UCLASS_PARTITION)
-		return efi_disk_delete_part(dev);
-	else
-		return 0;
+		ret = efi_disk_delete_part(dev);
+	if (ret)
+		log_err("%s failed for %s uclass %u (%d)\n", __func__, dev->name, id, ret);
+	return 0;

More information about the U-Boot mailing list