]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg ScsiBusDxe: Fix caller event may nerver be signaled
authorHao Wu <hao.a.wu@intel.com>
Fri, 11 Dec 2015 01:59:09 +0000 (01:59 +0000)
committerhwu1225 <hwu1225@Edk2>
Fri, 11 Dec 2015 01:59:09 +0000 (01:59 +0000)
For function ScsiExecuteSCSICommand(), when the 'Event' parameter is not
NULL but the target SCSI device does not support non-blocking I/O, it will
execute a blocking I/O operation instead.

However, after the SCSI operation is done, the 'Event' is not signaled to
inform the caller.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19217 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c

index 3e49ffba688874cd72873d643148eff69b3dd59d..8eb73e7673fab86a3eed6c0839b4a670ba72885a 100644 (file)
@@ -2,7 +2,7 @@
   SCSI Bus driver that layers on every SCSI Pass Thru and\r
   Extended SCSI Pass Thru protocol in the system.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -986,13 +986,34 @@ ScsiExecuteSCSICommand (
 \r
   if (ScsiIoDevice->ExtScsiSupport) {\r
     ExtRequestPacket = (EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *) Packet;\r
-    Status = ScsiIoDevice->ExtScsiPassThru->PassThru (\r
-                                          ScsiIoDevice->ExtScsiPassThru,\r
-                                          Target,\r
-                                          ScsiIoDevice->Lun,\r
-                                          ExtRequestPacket,\r
-                                          Event\r
-                                          );\r
+\r
+    if (((ScsiIoDevice->ExtScsiPassThru->Mode->Attributes & EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO) != 0) && (Event !=  NULL)) {\r
+      Status = ScsiIoDevice->ExtScsiPassThru->PassThru (\r
+                                                ScsiIoDevice->ExtScsiPassThru,\r
+                                                Target,\r
+                                                ScsiIoDevice->Lun,\r
+                                                ExtRequestPacket,\r
+                                                Event\r
+                                                );\r
+    } else {\r
+      //\r
+      // If there's no event or the SCSI Device doesn't support NON-BLOCKING,\r
+      // let the 'Event' parameter for PassThru() be NULL.\r
+      //\r
+      Status = ScsiIoDevice->ExtScsiPassThru->PassThru (\r
+                                                ScsiIoDevice->ExtScsiPassThru,\r
+                                                Target,\r
+                                                ScsiIoDevice->Lun,\r
+                                                ExtRequestPacket,\r
+                                                NULL\r
+                                                );\r
+      if (Event != NULL) {\r
+        //\r
+        // Signal Event to tell caller to pick up the SCSI IO Packet.\r
+        //\r
+        gBS->SignalEvent (Event);\r
+      }\r
+    }\r
   } else {\r
 \r
     mWorkingBuffer = AllocatePool (sizeof(EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET));\r
@@ -1052,7 +1073,7 @@ ScsiExecuteSCSICommand (
                                           ScsiIoDevice->Pun.ScsiId.Scsi,\r
                                           ScsiIoDevice->Lun,\r
                                           mWorkingBuffer,\r
-                                          Event\r
+                                          NULL\r
                                           );\r
       if (EFI_ERROR(Status)) {\r
         FreePool(mWorkingBuffer);\r
@@ -1065,6 +1086,13 @@ ScsiExecuteSCSICommand (
       // free mWorkingBuffer.\r
       //\r
       FreePool(mWorkingBuffer);\r
+\r
+      //\r
+      // Signal Event to tell caller to pick up the SCSI IO Packet.\r
+      //\r
+      if (Event != NULL) {\r
+        gBS->SignalEvent (Event);\r
+      }\r
     }\r
   }\r
   return Status;\r