]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuVideoDxe: disentangle UEFI driver model use in Stop()
authorLaszlo Ersek <lersek@redhat.com>
Mon, 3 Mar 2014 08:40:35 +0000 (08:40 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 3 Mar 2014 08:40:35 +0000 (08:40 +0000)
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 <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15284 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/QemuVideoDxe/Driver.c

index 508e1acb1018becf6715400f0677857c0c1b8e2f..48a788f6f835ac8bfa1dee3ae392eab4d0388617 100644 (file)
@@ -454,8 +454,26 @@ QemuVideoControllerDriverStop (
   EFI_STATUS                      Status;\r
   QEMU_VIDEO_PRIVATE_DATA  *Private;\r
 \r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the PCI I/O Protocol\r
+    //\r
+    gBS->CloseProtocol (\r
+          Controller,\r
+          &gEfiPciIoProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Controller\r
+          );\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // free all resources for whose access we need the child handle, because the\r
+  // child handle is going away\r
+  //\r
+  ASSERT (NumberOfChildren == 1);\r
   Status = gBS->OpenProtocol (\r
-                  Controller,\r
+                  ChildHandleBuffer[0],\r
                   &gEfiGraphicsOutputProtocolGuid,\r
                   (VOID **) &GraphicsOutput,\r
                   This->DriverBindingHandle,\r
@@ -470,6 +488,7 @@ QemuVideoControllerDriverStop (
   // Get our private context information\r
   //\r
   Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);\r
+  ASSERT (Private->Handle == ChildHandleBuffer[0]);\r
 \r
   QemuVideoGraphicsOutputDestructor (Private);\r
   //\r
@@ -496,16 +515,6 @@ QemuVideoControllerDriverStop (
                   NULL\r
                   );\r
 \r
-  //\r
-  // Close the PCI I/O Protocol\r
-  //\r
-  gBS->CloseProtocol (\r
-        Controller,\r
-        &gEfiPciIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
   gBS->CloseProtocol (\r
         Controller,\r
         &gEfiPciIoProtocolGuid,\r