summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-07-05 11:28:55 -0400
committerTom Rini <trini@konsulko.com>2023-07-05 11:28:55 -0400
commite80f4079b3a3db0961b73fa7a96e6c90242d8d25 (patch)
tree5352d65d18b44e0982152654dc9f8018047e65ae /lib
parent45f77b807c2f6b8da88ae897b7eb2238e25df36b (diff)
parente1bebc16e1d9aa0ddd56c53c0b781f7186dce557 (diff)
downloadu-boot-e80f4079b3a3db0961b73fa7a96e6c90242d8d25.tar.gz
u-boot-e80f4079b3a3db0961b73fa7a96e6c90242d8d25.tar.bz2
u-boot-e80f4079b3a3db0961b73fa7a96e6c90242d8d25.zip
Merge tag 'v2023.07-rc6' into next
Prepare v2023.07-rc6
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_disk.c91
-rw-r--r--lib/efi_selftest/efi_selftest_controllers.c26
-rw-r--r--lib/efi_selftest/efi_selftest_manageprotocols.c2
-rw-r--r--lib/efi_selftest/efi_selftest_register_notify.c25
4 files changed, 78 insertions, 66 deletions
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index d2256713a8..28c8cdf710 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -690,91 +690,52 @@ int efi_disk_probe(void *ctx, struct event *event)
return 0;
}
-/*
- * Delete an efi_disk object for a whole raw disk
+/**
+ * efi_disk_remove - delete an efi_disk object for a block device or partition
*
- * @dev uclass device (UCLASS_BLK)
+ * @ctx: event context: driver binding protocol
+ * @event: EV_PM_PRE_REMOVE event
*
- * Delete an efi_disk object which is associated with @dev.
- * The type of @dev must be UCLASS_BLK.
+ * Delete an efi_disk object which is associated with the UCLASS_BLK or
+ * UCLASS_PARTITION device for which the EV_PM_PRE_REMOVE event is raised.
*
- * @return 0 on success, -1 otherwise
+ * Return: 0 on success, -1 otherwise
*/
-static int efi_disk_delete_raw(struct udevice *dev)
+int efi_disk_remove(void *ctx, struct event *event)
{
+ enum uclass_id id;
+ struct udevice *dev = event->data.dm.dev;
efi_handle_t handle;
struct blk_desc *desc;
- struct efi_disk_obj *diskobj;
+ struct efi_disk_obj *diskobj = NULL;
if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle))
- return -1;
+ return 0;
- desc = dev_get_uclass_plat(dev);
- if (desc->uclass_id != UCLASS_EFI_LOADER) {
+ id = device_get_uclass_id(dev);
+ switch (id) {
+ case UCLASS_BLK:
+ desc = dev_get_uclass_plat(dev);
+ if (desc && desc->uclass_id != UCLASS_EFI_LOADER)
+ diskobj = container_of(handle, struct efi_disk_obj,
+ header);
+ break;
+ case UCLASS_PARTITION:
diskobj = container_of(handle, struct efi_disk_obj, header);
- efi_free_pool(diskobj->dp);
+ break;
+ default:
+ return 0;
}
- efi_delete_handle(handle);
- dev_tag_del(dev, DM_TAG_EFI);
-
- return 0;
-}
-
-/*
- * Delete an efi_disk object for a disk partition
- *
- * @dev uclass device (UCLASS_PARTITION)
- *
- * Delete an efi_disk object which is associated with @dev.
- * The type of @dev must be UCLASS_PARTITION.
- *
- * @return 0 on success, -1 otherwise
- */
-static int efi_disk_delete_part(struct udevice *dev)
-{
- efi_handle_t handle;
- struct efi_disk_obj *diskobj;
-
- if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle))
- return -1;
-
- diskobj = container_of(handle, struct efi_disk_obj, header);
+ if (diskobj)
+ efi_free_pool(diskobj->dp);
- efi_free_pool(diskobj->dp);
efi_delete_handle(handle);
dev_tag_del(dev, DM_TAG_EFI);
return 0;
}
-/*
- * Delete an efi_disk object for a block device
- *
- * @dev uclass device (UCLASS_BLK or UCLASS_PARTITION)
- *
- * Delete an efi_disk object which is associated with @dev.
- * The type of @dev must be either UCLASS_BLK or UCLASS_PARTITION.
- * This function is expected to be called at EV_PM_PRE_REMOVE.
- *
- * @return 0 on success, -1 otherwise
- */
-int efi_disk_remove(void *ctx, struct event *event)
-{
- enum uclass_id id;
- struct udevice *dev;
-
- dev = event->data.dm.dev;
- id = device_get_uclass_id(dev);
-
- if (id == UCLASS_BLK)
- return efi_disk_delete_raw(dev);
- else if (id == UCLASS_PARTITION)
- return efi_disk_delete_part(dev);
- else
- return 0;
-}
-
/**
* efi_disk_get_device_name() - get U-Boot device name associated with EFI handle
*
diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c
index d2bbd1c4f6..63e674bedc 100644
--- a/lib/efi_selftest/efi_selftest_controllers.c
+++ b/lib/efi_selftest/efi_selftest_controllers.c
@@ -271,6 +271,8 @@ static int setup(const efi_handle_t img_handle,
efi_status_t ret;
boottime = systable->boottime;
+ handle_controller = NULL;
+ handle_driver = NULL;
/* Create controller handle */
ret = boottime->install_protocol_interface(
@@ -402,14 +404,36 @@ static int execute(void)
/* Check number of child controllers */
ret = count_child_controllers(handle_controller, &guid_controller,
&count);
- if (ret == EFI_SUCCESS)
+ if (ret == EFI_SUCCESS || count) {
efi_st_error("Uninstall failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+
return EFI_ST_SUCCESS;
}
+ /*
+ * Tear down unit test.
+ *
+ */
+static int teardown(void)
+{
+ efi_status_t ret;
+ /* Uninstall binding protocol */
+ ret = boottime->uninstall_protocol_interface(handle_driver,
+ &guid_driver_binding_protocol,
+ &binding_interface);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("Failed to uninstall protocols\n");
+
+ return ret;
+}
+
EFI_UNIT_TEST(controllers) = {
.name = "controllers",
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
.setup = setup,
.execute = execute,
+ .teardown = teardown,
};
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index 8edb1e4d46..097b2ae354 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -79,6 +79,8 @@ static int setup(const efi_handle_t img_handle,
efi_status_t ret;
efi_handle_t handle;
+ handle1 = NULL;
+ handle2 = NULL;
boottime = systable->boottime;
ret = boottime->install_protocol_interface(&handle1, &guid3,
diff --git a/lib/efi_selftest/efi_selftest_register_notify.c b/lib/efi_selftest/efi_selftest_register_notify.c
index ad4bcce1a1..adf5dd00a1 100644
--- a/lib/efi_selftest/efi_selftest_register_notify.c
+++ b/lib/efi_selftest/efi_selftest_register_notify.c
@@ -124,6 +124,7 @@ static int execute(void)
{
efi_status_t ret;
efi_handle_t handle1 = NULL, handle2 = NULL;
+ struct interface *interface;
struct interface interface1, interface2;
ret = boottime->install_protocol_interface(&handle1, &guid1,
@@ -145,6 +146,18 @@ static int execute(void)
efi_st_error("LocateHandle failed\n");
return EFI_ST_FAILURE;
}
+ interface = NULL;
+ ret = boottime->open_protocol(handle1, &guid1, (void**)&interface,
+ NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Cannot find installed protocol on handle\n");
+ return EFI_ST_FAILURE;
+ }
+ if (interface != &interface1) {
+ efi_st_error("Wrong interface after install\n");
+ return EFI_ST_FAILURE;
+ }
ret = boottime->free_pool(context.handles);
if (ret != EFI_SUCCESS) {
efi_st_error("FreePool failed\n");
@@ -186,6 +199,18 @@ static int execute(void)
efi_st_error("FreePool failed\n");
return EFI_ST_FAILURE;
}
+ interface = NULL;
+ ret = boottime->open_protocol(handle1, &guid1, (void**)&interface,
+ NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Cannot find reinstalled protocol on handle\n");
+ return EFI_ST_FAILURE;
+ }
+ if (interface != &interface2) {
+ efi_st_error("Wrong interface after reinstall\n");
+ return EFI_ST_FAILURE;
+ }
context.notify_count = 0;
ret = boottime->install_protocol_interface(&handle2, &guid1,
EFI_NATIVE_INTERFACE,