Fix 3 bugs in DiskIoDxe and PartitionDxe drivers introduced in DiskIo2 implementation.
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 17 Sep 2013 05:11:30 +0000 (05:11 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 17 Sep 2013 05:11:30 +0000 (05:11 +0000)
1. DiskIo2 shouldn't signal the event when the *Ex interface returns failure status per the UEFI spec.
2. PartitionDxe should close DiskIo2 protocol when error happens in DriverBindingStart() otherwise Fat driver cannot open the DiskIo2 BY_DRIVER.
3. PartitionDxe should create event using TPL_NOTIFY instead of TPL_CALLBACK otherwise asynchronous FileIo may be blocked.

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14680 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c

index ba61300911fdaed12ca10d2ae9e1f31f6605940e..f53c3d91d030b64bed1e0437f1786d90e7a0aaf5 100644 (file)
@@ -403,8 +403,6 @@ DiskIo2OnReadWriteComplete (
   EFI_STATUS            TransactionStatus;\r
   DISK_IO_PRIVATE_DATA  *Instance;\r
 \r
-  gBS->CloseEvent (Event);\r
-\r
   Subtask           = (DISK_IO_SUBTASK *) Context;\r
   TransactionStatus = Subtask->BlockIo2Token.TransactionStatus;\r
   Task              = Subtask->Task;\r
@@ -414,26 +412,13 @@ DiskIo2OnReadWriteComplete (
   ASSERT (Instance->Signature == DISK_IO_PRIVATE_DATA_SIGNATURE);\r
   ASSERT (Task->Signature     == DISK_IO2_TASK_SIGNATURE);\r
 \r
-  if (Subtask->WorkingBuffer != NULL) {\r
-    if (!EFI_ERROR (TransactionStatus) && (Task->Token != NULL) && !Subtask->Write) {\r
-      CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);\r
-    }\r
-\r
-    //\r
-    // The WorkingBuffer of blocking subtask either points to SharedWorkingBuffer\r
-    // or will be used by non-blocking subtask which will be freed below.\r
-    //\r
-    if (!Subtask->Blocking) {\r
-      FreeAlignedPages (\r
-        Subtask->WorkingBuffer, \r
-        Subtask->Length < Instance->BlockIo->Media->BlockSize\r
-        ? EFI_SIZE_TO_PAGES (Instance->BlockIo->Media->BlockSize)\r
-        : EFI_SIZE_TO_PAGES (Subtask->Length)\r
-        );\r
-    }\r
+  if ((Subtask->WorkingBuffer != NULL) && !EFI_ERROR (TransactionStatus) && \r
+      (Task->Token != NULL) && !Subtask->Write\r
+     ) {\r
+    CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);\r
   }\r
-  RemoveEntryList (&Subtask->Link);\r
-  FreePool (Subtask);\r
+\r
+  DiskIoDestroySubtask (Instance, Subtask);\r
 \r
   if (EFI_ERROR (TransactionStatus) || IsListEmpty (&Task->Subtasks)) {\r
     if (Task->Token != NULL) {\r
@@ -961,7 +946,7 @@ DiskIo2ReadWriteDisk (
     RemoveEntryList (&Task->Link);\r
     EfiReleaseLock (&Instance->TaskQueueLock);\r
 \r
-    if (Task->Token != NULL) {\r
+    if (!EFI_ERROR (Status) && (Task->Token != NULL)) {\r
       //\r
       // Task->Token should be set to NULL by the DiskIo2OnReadWriteComplete\r
       // It it's not, that means the non-blocking request was downgraded to blocking request.\r
index 5cc1397e7c0776e0e03a1c25004a4635cc7d8222..7fb2c0dfe09dcfde76fb463b87d90b186ddb9f60 100644 (file)
@@ -352,11 +352,11 @@ PartitionDriverBindingStart (
           ControllerHandle\r
           );\r
     //\r
-    // Close Parent BlockIO2 if has.\r
+    // Close Parent DiskIo2 if has.\r
     //    \r
     gBS->CloseProtocol (\r
            ControllerHandle,\r
-           &gEfiBlockIo2ProtocolGuid,\r
+           &gEfiDiskIo2ProtocolGuid,\r
            This->DriverBindingHandle,\r
            ControllerHandle\r
            );\r
@@ -822,7 +822,7 @@ PartitionCreateAccessTask (
 \r
   Status = gBS->CreateEvent (\r
                   EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
+                  TPL_NOTIFY,\r
                   PartitionOnAccessComplete,\r
                   Task,\r
                   &Task->DiskIo2Token.Event\r