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 <[email protected]>
---

This patch consolidates and implements review feedback for the following two 
uncomitted patches:
[PATCH] OvmfPkg/QemuVideoDxe: use child handle to open parent protocols
[PATCH] OvmfPkg/QemuVideoDxe: close the appropriate protocol


 OvmfPkg/QemuVideoDxe/Driver.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c
index 1dd8899..ca67c30 100644
--- a/OvmfPkg/QemuVideoDxe/Driver.c
+++ b/OvmfPkg/QemuVideoDxe/Driver.c
@@ -415,6 +415,22 @@ QemuVideoControllerDriverStart (
                     &Private->GraphicsOutput,
                     NULL
                     );
+    if (EFI_ERROR (Status)) {
+      goto Error;
+    }
+
+    Status = gBS->OpenProtocol (
+                  Controller,
+                  &gEfiPciIoProtocolGuid,
+                  &Private->Handle,
+                  This->DriverBindingHandle,
+                  Private->Handle,
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+                  );
+
+    if (EFI_ERROR (Status)) {
+      goto Error;
+    }
   }
 
 Error:
@@ -439,6 +455,13 @@ Error:
               Private->Handle,
               &gEfiPciIoProtocolGuid,
               This->DriverBindingHandle,
+              Controller
+              );
+
+        gBS->CloseProtocol (
+              Controller,
+              &gEfiPciIoProtocolGuid,
+              This->DriverBindingHandle,
               Private->Handle
               );
       }
@@ -529,6 +552,13 @@ QemuVideoControllerDriverStop (
         Controller
         );
 
+  gBS->CloseProtocol (
+        Controller,
+        &gEfiPciIoProtocolGuid,
+        This->DriverBindingHandle,
+        Private->Handle
+        );
+
   //
   // Free our instance data
   //
-- 
1.8.4.msysgit.0


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to