]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuVideoDxe: child handles should have open parent protocol BY_CHILD_CONTROLLER
authorChris Ruffin <chris.ruffin@intel.com>
Sun, 15 Dec 2013 20:47:39 +0000 (20:47 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 15 Dec 2013 20:47:39 +0000 (20:47 +0000)
The QemuVideoDxe driver creates child controller handles, so it is acting
as a hybrid bus driver. The child handles should open the parent's bus
protocol BY_CHILD_CONTROLLER to properly maintain the protocol usage count.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Ruffin <chris.ruffin@intel.com>
Reviewed-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@14987 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/QemuVideoDxe/Driver.c

index 53718e1aea538367e9b5aa02f9bac6ecc66370dc..b253ec734edf9e214a916ad58930622f6a81124e 100644 (file)
@@ -209,6 +209,7 @@ QemuVideoControllerDriverStart (
   PCI_TYPE00                        Pci;\r
   QEMU_VIDEO_CARD                   *Card;\r
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *MmioDesc;\r
+  EFI_PCI_IO_PROTOCOL               *ChildPciIo;\r
 \r
   PciAttributesSaved = FALSE;\r
   //\r
@@ -419,6 +420,22 @@ QemuVideoControllerDriverStart (
                     &Private->GraphicsOutput,\r
                     NULL\r
                     );\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
+\r
+    Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  (VOID **) &ChildPciIo,\r
+                  This->DriverBindingHandle,\r
+                  Private->Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                  );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
   }\r
 \r
 Error:\r
@@ -440,7 +457,14 @@ Error:
         // Close the PCI I/O Protocol\r
         //\r
         gBS->CloseProtocol (\r
-              Private->Handle,\r
+              Controller,\r
+              &gEfiPciIoProtocolGuid,\r
+              This->DriverBindingHandle,\r
+              Controller\r
+              );\r
+\r
+        gBS->CloseProtocol (\r
+              Controller,\r
               &gEfiPciIoProtocolGuid,\r
               This->DriverBindingHandle,\r
               Private->Handle\r
@@ -533,6 +557,13 @@ QemuVideoControllerDriverStop (
         Controller\r
         );\r
 \r
+  gBS->CloseProtocol (\r
+        Controller,\r
+        &gEfiPciIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Private->Handle\r
+        );\r
+\r
   //\r
   // Free our instance data\r
   //\r