From 559affab2e82aba4e0819d299d5a8de03e276af6 Mon Sep 17 00:00:00 2001 From: Ken Lautner Date: Fri, 23 Aug 2024 15:39:53 -0700 Subject: 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 --- MdeModulePkg/Core/Dxe/Image/Image.c | 4 +++- MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 37fc74d5d1..8d12f93d7f 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -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); diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c index 15dfa3699f..54b634afe3 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c @@ -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; } -- cgit