diff mbox series

[RFC,1/1] efi_loader: fix open protocol information for block device

Message ID 20221004193105.19323-1-heinrich.schuchardt@canonical.com
State Not Applicable, archived
Delegated to: Heinrich Schuchardt
Headers show
Series [RFC,1/1] efi_loader: fix open protocol information for block device | expand

Commit Message

Heinrich Schuchardt Oct. 4, 2022, 7:31 p.m. UTC
If OpenProtocol() is called without an agent handle, no open protocol
information is generated. With the patch we actually see the link between
partition an its block device when printing the open protocol information:

  000000001b2452f0 (host0)
    protocol: 964e5b21-6459-11d2-8e39-00a0c969723b - Block IO
      AgentHandle - 000000001b027eb0 - /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
      ControllerHandle - 000000001b245460 (host0:1)
      Attributes - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
      OpenCount - 1

Fixes: 264485131c59 ("efi_loader: link partition to block device")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
The EFI/DM integration needs some rework. In future efi_disk_add_dev() will
have to use a real driver handle as agent handle.

So this change is more for demonstration than actually required now.
---
 lib/efi_loader/efi_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heinrich Schuchardt Oct. 5, 2022, 7:48 a.m. UTC | #1
On 10/4/22 21:31, Heinrich Schuchardt wrote:
> If OpenProtocol() is called without an agent handle, no open protocol
> information is generated. With the patch we actually see the link between
> partition an its block device when printing the open protocol information:
> 
>    000000001b2452f0 (host0)
>      protocol: 964e5b21-6459-11d2-8e39-00a0c969723b - Block IO
>        AgentHandle - 000000001b027eb0 - /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
>        ControllerHandle - 000000001b245460 (host0:1)
>        Attributes - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
>        OpenCount - 1
> 
> Fixes: 264485131c59 ("efi_loader: link partition to block device")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> The EFI/DM integration needs some rework. In future efi_disk_add_dev() will
> have to use a real driver handle as agent handle.
> 
> So this change is more for demonstration than actually required now.
> ---
>   lib/efi_loader/efi_disk.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index 39ea1a68a6..5f1717eda4 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -424,7 +424,7 @@ static efi_status_t efi_disk_add_dev(
>   		 * Link the partition (child controller) to the block device
>   		 * (controller).
>   		 */
> -		ret = efi_protocol_open(handler, &protocol_interface, NULL,
> +		ret = efi_protocol_open(handler, &protocol_interface, efi_root,
>   					&diskobj->header,
>   					EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
>   		if (ret != EFI_SUCCESS)

This patch is not compatible with the teardown function in 
efi_selftest_block_device.c as we have not implemented a driver binding 
protocol on the root handle.

So this is nice for testing. But we shall not merge the patch.

Best regards

Heinrich
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 39ea1a68a6..5f1717eda4 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -424,7 +424,7 @@  static efi_status_t efi_disk_add_dev(
 		 * Link the partition (child controller) to the block device
 		 * (controller).
 		 */
-		ret = efi_protocol_open(handler, &protocol_interface, NULL,
+		ret = efi_protocol_open(handler, &protocol_interface, efi_root,
 					&diskobj->header,
 					EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
 		if (ret != EFI_SUCCESS)