A bus driver needs to pay attention whether its Stop() function is being called on the "main" controller handle (NumberOfChildren == 0) or on the child handles (NumberOfChildren > 0).
In QemuVideoDxe, all our resources are associated with the one child handle (and the Private data structure) *except* the top-level PciIo protocol reference. Be conscious of which mode Stop() is being called for. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <[email protected]> --- OvmfPkg/QemuVideoDxe/Driver.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c index ab3afae..6a2cac1 100644 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ b/OvmfPkg/QemuVideoDxe/Driver.c @@ -464,8 +464,26 @@ QemuVideoControllerDriverStop ( EFI_STATUS Status; QEMU_VIDEO_PRIVATE_DATA *Private; + if (NumberOfChildren == 0) { + // + // Close the PCI I/O Protocol + // + gBS->CloseProtocol ( + Controller, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + Controller + ); + return EFI_SUCCESS; + } + + // + // free all resources for whose access we need the child handle, because the + // child handle is going away + // + ASSERT (NumberOfChildren == 1); Status = gBS->OpenProtocol ( - Controller, + ChildHandleBuffer[0], &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput, This->DriverBindingHandle, @@ -480,6 +498,7 @@ QemuVideoControllerDriverStop ( // Get our private context information // Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput); + ASSERT (Private->Handle == ChildHandleBuffer[0]); QemuVideoGraphicsOutputDestructor (Private); // @@ -506,16 +525,6 @@ QemuVideoControllerDriverStop ( NULL ); - // - // Close the PCI I/O Protocol - // - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - gBS->CloseProtocol ( Controller, &gEfiPciIoProtocolGuid, -- 1.8.3.1 ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
