IntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation
[mirror_edk2.git] / IntelSiliconPkg / Feature / VTd / IntelVTdDxe / IntelVTdDxe.c
index 89d9bea..570b47c 100644 (file)
 \r
 **/\r
 \r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/IoMmu.h>\r
-#include <Protocol/PciIo.h>\r
-\r
-#include <Library/IoLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
 #include "DmaProtection.h"\r
 \r
 /**\r
@@ -306,18 +296,22 @@ IoMmuSetAttribute (
   EFI_STATUS            Status;\r
   EFI_PHYSICAL_ADDRESS  DeviceAddress;\r
   UINTN                 NumberOfPages;\r
+  EFI_TPL               OriginalTpl;\r
+\r
+  OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);\r
 \r
   Status = GetDeviceInfoFromMapping (Mapping, &DeviceAddress, &NumberOfPages);\r
-  if (EFI_ERROR(Status)) {\r
-    return Status;\r
+  if (!EFI_ERROR(Status)) {\r
+    Status = VTdSetAttribute (\r
+               This,\r
+               DeviceHandle,\r
+               DeviceAddress,\r
+               EFI_PAGES_TO_SIZE(NumberOfPages),\r
+               IoMmuAccess\r
+               );\r
   }\r
-  Status = VTdSetAttribute (\r
-             This,\r
-             DeviceHandle,\r
-             DeviceAddress,\r
-             EFI_PAGES_TO_SIZE(NumberOfPages),\r
-             IoMmuAccess\r
-             );\r
+\r
+  gBS->RestoreTPL (OriginalTpl);\r
 \r
   return Status;\r
 }\r