MdeModulePkg: Fix redundant call to RestoreTpl()

Comments out a redundant call to RestoreTpl(). While this does not
technically violate spec on raise/restore TPL, TPL should already be at
the specified level. This extra call introduces an asymmetry between
RaiseTpl and RestoreTpl calls, which makes analysis of TPL correctness
more difficult and hampers certain non-standard TPL usages that some
platforms require.  Additionally, the two TPL variables were renamed to
provide context for each of them.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
This commit is contained in:
Ken Lautner 2024-08-23 15:39:53 -07:00 committed by mergify[bot]
parent b17ac09cc4
commit 559affab2e
2 changed files with 9 additions and 7 deletions

View File

@ -1725,7 +1725,9 @@ CoreStartImage (
// Image has completed. Verify the tpl is the same
//
ASSERT (Image->Tpl == gEfiCurrentTpl);
CoreRestoreTpl (Image->Tpl);
if (Image->Tpl != gEfiCurrentTpl) {
CoreRestoreTpl (Image->Tpl);
}
CoreFreePool (Image->JumpBuffer);

View File

@ -846,8 +846,8 @@ DiskIo2ReadWriteDisk (
LIST_ENTRY Subtasks;
DISK_IO_SUBTASK *Subtask;
DISK_IO2_TASK *Task;
EFI_TPL OldTpl;
EFI_TPL OldTpl1;
EFI_TPL SubtaskPerformTpl;
EFI_TPL SubtaskLockTpl;
BOOLEAN Blocking;
BOOLEAN SubtaskBlocking;
LIST_ENTRY *SubtasksPtr;
@ -897,7 +897,7 @@ DiskIo2ReadWriteDisk (
ASSERT (!IsListEmpty (SubtasksPtr));
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
SubtaskPerformTpl = gBS->RaiseTPL (TPL_CALLBACK);
for ( Link = GetFirstNode (SubtasksPtr), NextLink = GetNextNode (SubtasksPtr, Link)
; !IsNull (SubtasksPtr, Link)
; Link = NextLink, NextLink = GetNextNode (SubtasksPtr, NextLink)
@ -978,7 +978,7 @@ DiskIo2ReadWriteDisk (
}
}
OldTpl1 = gBS->RaiseTPL (TPL_NOTIFY);
SubtaskLockTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// Remove all the remaining subtasks when failure.
@ -1013,8 +1013,8 @@ DiskIo2ReadWriteDisk (
FreePool (Task);
}
gBS->RestoreTPL (OldTpl1);
gBS->RestoreTPL (OldTpl);
gBS->RestoreTPL (SubtaskLockTpl);
gBS->RestoreTPL (SubtaskPerformTpl);
return Status;
}