public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] OvmfPkg/XenBusDxe: Don't call DisconnectController in Stop()
@ 2019-07-01 11:14 Anthony PERARD
  2019-07-01 14:39 ` Laszlo Ersek
  2019-07-01 14:56 ` Laszlo Ersek
  0 siblings, 2 replies; 3+ messages in thread
From: Anthony PERARD @ 2019-07-01 11:14 UTC (permalink / raw)
  To: devel
  Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Julien Grall,
	Anthony PERARD

Calling DisconnectController() on children isn't part of the job of
EFI_DRIVER_BINDING_PROTOCOL.Stop() as it only needs to deallocate
resources allocated in Start(). The disconnection will happen when
both DevicePath and XenBus protocols gets uninstalled.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    Please apply this patch after:
    "OvmfPkg/XenBusDxe: Close XenIoProtocol openned by children"

 OvmfPkg/XenBusDxe/XenBusDxe.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
index 7c07a96650..634c7b71eb 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.c
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
@@ -446,12 +446,6 @@ XenBusDxeDriverBindingStop (
       continue;
     }
     ChildData = XENBUS_PRIVATE_DATA_FROM_THIS (XenBusIo);
-    Status = gBS->DisconnectController (ChildData->Handle, NULL, NULL);
-    if (EFI_ERROR (Status)) {
-      DEBUG ((EFI_D_ERROR, "XenBusDxe: error disconnecting child: %r\n",
-              Status));
-      continue;
-    }
 
     Status = gBS->CloseProtocol (Dev->ControllerHandle, &gXenIoProtocolGuid,
                     Dev->This->DriverBindingHandle, ChildData->Handle);
-- 
Anthony PERARD


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] OvmfPkg/XenBusDxe: Don't call DisconnectController in Stop()
  2019-07-01 11:14 [PATCH] OvmfPkg/XenBusDxe: Don't call DisconnectController in Stop() Anthony PERARD
@ 2019-07-01 14:39 ` Laszlo Ersek
  2019-07-01 14:56 ` Laszlo Ersek
  1 sibling, 0 replies; 3+ messages in thread
From: Laszlo Ersek @ 2019-07-01 14:39 UTC (permalink / raw)
  To: Anthony PERARD, devel; +Cc: Jordan Justen, Ard Biesheuvel, Julien Grall

On 07/01/19 13:14, Anthony PERARD wrote:
> Calling DisconnectController() on children isn't part of the job of
> EFI_DRIVER_BINDING_PROTOCOL.Stop() as it only needs to deallocate
> resources allocated in Start(). The disconnection will happen when
> both DevicePath and XenBus protocols gets uninstalled.

Correct. In the spec, UninstallMultipleProtocolInterfaces() refers to
UninstallProtocolInterface(), and the latter says,

    [...] Before the protocol interface is removed, an attempt is made
    to force all the drivers that are consuming the protocol interface
    to stop consuming that protocol interface. This is done by calling
    the boot service EFI_BOOT_SERVICES.DisconnectController() for the
    driver that currently have the protocol interface open with an
    attribute of EFI_OPEN_PROTOCOL_BY_DRIVER or
    EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE. [...]

And, the Driver Writer's Guide states, in a Note,

    When an attempt is made to remove a protocol interface from a handle
    in the handle database, the UEFI core firmware checks to see if any
    other UEFI drivers are currently using the services of the protocol
    to be removed. If UEFI drivers are using that protocol interface,
    the UEFI core firmware attempts to stop those UEFI drivers with a
    call to DisconnectController(). This is a quick, legal, and safe way
    to shut down any protocols associated with this driver's stack.

> 
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> 
> Notes:
>     Please apply this patch after:
>     "OvmfPkg/XenBusDxe: Close XenIoProtocol openned by children"
> 
>  OvmfPkg/XenBusDxe/XenBusDxe.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
> index 7c07a96650..634c7b71eb 100644
> --- a/OvmfPkg/XenBusDxe/XenBusDxe.c
> +++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
> @@ -446,12 +446,6 @@ XenBusDxeDriverBindingStop (
>        continue;
>      }
>      ChildData = XENBUS_PRIVATE_DATA_FROM_THIS (XenBusIo);
> -    Status = gBS->DisconnectController (ChildData->Handle, NULL, NULL);
> -    if (EFI_ERROR (Status)) {
> -      DEBUG ((EFI_D_ERROR, "XenBusDxe: error disconnecting child: %r\n",
> -              Status));
> -      continue;
> -    }
>  
>      Status = gBS->CloseProtocol (Dev->ControllerHandle, &gXenIoProtocolGuid,
>                      Dev->This->DriverBindingHandle, ChildData->Handle);
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] OvmfPkg/XenBusDxe: Don't call DisconnectController in Stop()
  2019-07-01 11:14 [PATCH] OvmfPkg/XenBusDxe: Don't call DisconnectController in Stop() Anthony PERARD
  2019-07-01 14:39 ` Laszlo Ersek
@ 2019-07-01 14:56 ` Laszlo Ersek
  1 sibling, 0 replies; 3+ messages in thread
From: Laszlo Ersek @ 2019-07-01 14:56 UTC (permalink / raw)
  To: Anthony PERARD, devel; +Cc: Jordan Justen, Ard Biesheuvel, Julien Grall

On 07/01/19 13:14, Anthony PERARD wrote:
> Calling DisconnectController() on children isn't part of the job of
> EFI_DRIVER_BINDING_PROTOCOL.Stop() as it only needs to deallocate
> resources allocated in Start(). The disconnection will happen when
> both DevicePath and XenBus protocols gets uninstalled.
> 
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> 
> Notes:
>     Please apply this patch after:
>     "OvmfPkg/XenBusDxe: Close XenIoProtocol openned by children"
> 
>  OvmfPkg/XenBusDxe/XenBusDxe.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
> index 7c07a96650..634c7b71eb 100644
> --- a/OvmfPkg/XenBusDxe/XenBusDxe.c
> +++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
> @@ -446,12 +446,6 @@ XenBusDxeDriverBindingStop (
>        continue;
>      }
>      ChildData = XENBUS_PRIVATE_DATA_FROM_THIS (XenBusIo);
> -    Status = gBS->DisconnectController (ChildData->Handle, NULL, NULL);
> -    if (EFI_ERROR (Status)) {
> -      DEBUG ((EFI_D_ERROR, "XenBusDxe: error disconnecting child: %r\n",
> -              Status));
> -      continue;
> -    }
>  
>      Status = gBS->CloseProtocol (Dev->ControllerHandle, &gXenIoProtocolGuid,
>                      Dev->This->DriverBindingHandle, ChildData->Handle);
> 

Commit 6a1f06fadb26.

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-01 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-01 11:14 [PATCH] OvmfPkg/XenBusDxe: Don't call DisconnectController in Stop() Anthony PERARD
2019-07-01 14:39 ` Laszlo Ersek
2019-07-01 14:56 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox