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...@intel.com>
---
 MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c | 44 ++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c 
b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
index 3e49ffb..c443c1c 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
@@ -986,13 +986,34 @@ ScsiExecuteSCSICommand (
 
   if (ScsiIoDevice->ExtScsiSupport) {
     ExtRequestPacket = (EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *) Packet;
-    Status = ScsiIoDevice->ExtScsiPassThru->PassThru (
-                                          ScsiIoDevice->ExtScsiPassThru,
-                                          Target,
-                                          ScsiIoDevice->Lun,
-                                          ExtRequestPacket,
-                                          Event
-                                          );
+
+    if (((ScsiIoDevice->ExtScsiPassThru->Mode->Attributes & 
EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO) != 0) && (Event !=  NULL)) {
+      Status = ScsiIoDevice->ExtScsiPassThru->PassThru (
+                                                ScsiIoDevice->ExtScsiPassThru,
+                                                Target,
+                                                ScsiIoDevice->Lun,
+                                                ExtRequestPacket,
+                                                Event
+                                                );
+    } else {
+      //
+      // If there's no event or the SCSI Device doesn't support NON-BLOCKING,
+      // let the 'Event' parameter for PassThru() be NULL.
+      //
+      Status = ScsiIoDevice->ExtScsiPassThru->PassThru (
+                                                ScsiIoDevice->ExtScsiPassThru,
+                                                Target,
+                                                ScsiIoDevice->Lun,
+                                                ExtRequestPacket,
+                                                NULL
+                                                );
+      if (Event != NULL) {
+        //
+        // Signal Event to tell caller to pick up the SCSI IO Packet.
+        //
+        gBS->SignalEvent (Event);
+      }
+    }
   } else {
 
     mWorkingBuffer = AllocatePool 
(sizeof(EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET));
@@ -1052,7 +1073,7 @@ ScsiExecuteSCSICommand (
                                           ScsiIoDevice->Pun.ScsiId.Scsi,
                                           ScsiIoDevice->Lun,
                                           mWorkingBuffer,
-                                          Event
+                                          NULL
                                           );
       if (EFI_ERROR(Status)) {
         FreePool(mWorkingBuffer);
@@ -1065,6 +1086,13 @@ ScsiExecuteSCSICommand (
       // free mWorkingBuffer.
       //
       FreePool(mWorkingBuffer);
+
+      //
+      // Signal Event to tell caller to pick up the SCSI IO Packet.
+      //
+      if (Event != NULL) {
+        gBS->SignalEvent (Event);
+      }
     }
   }
   return Status;
-- 
1.9.5.msysgit.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to