Skip to content

Commit e2411a3

Browse files
authored
[CHERRY-PICK] MdeModulePkg: Add PcdDelayedDispatchMaxEntries (#1534)
## Description The current fixed value of 8 for `DELAYED_DISPATCH_MAX_ENTRIES` is not large enough to accommodate platform usage. This change replaces the macro with a PCD that can be configured by platforms. In the case the default PCD value is too small, an error message explaining that the PCD should be updated will be printed followed by an assert. (cherry picked from commit 8a07311710acba244a1b44910324b3b4afd5889a) - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested - Tested on a a physical Intel platform that uses delayed dispatch ## Integration Instructions - Adjust `gEfiMdeModulePkgTokenSpaceGuid.PcdDelayedDispatchMaxEntries` as needed to accommodate the number of delayed dispatch entries used by a platform. Signed-off-by: Michael Kubacki <[email protected]>
1 parent 7448e5c commit e2411a3

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,15 @@ PeiDelayedDispatchRegister (
134134
}
135135

136136
// Check for available entry slots
137-
ASSERT (DelayedDispatchTable->Count <= DELAYED_DISPATCH_MAX_ENTRIES);
138-
if (DelayedDispatchTable->Count == DELAYED_DISPATCH_MAX_ENTRIES) {
139-
DEBUG ((DEBUG_ERROR, "%a Too many entries requested\n", __func__));
137+
if (DelayedDispatchTable->Count >= PcdGet32 (PcdDelayedDispatchMaxEntries)) {
138+
DEBUG ((
139+
DEBUG_ERROR,
140+
"%a DelayedDispatchTable->Count = %d. PcdDelayedDispatchMaxEntries (%d) is too small.\n",
141+
__func__,
142+
DelayedDispatchTable->Count,
143+
PcdGet32 (PcdDelayedDispatchMaxEntries)
144+
));
145+
ASSERT (DelayedDispatchTable->Count < PcdGet32 (PcdDelayedDispatchMaxEntries));
140146
Status = EFI_OUT_OF_RESOURCES;
141147
goto Exit;
142148
}
@@ -1833,7 +1839,7 @@ PeiDispatcher (
18331839
if (GuidHob != NULL) {
18341840
Private->DelayedDispatchTable = (DELAYED_DISPATCH_TABLE *)(GET_GUID_HOB_DATA (GuidHob));
18351841
} else {
1836-
TableSize = sizeof (DELAYED_DISPATCH_TABLE) + ((DELAYED_DISPATCH_MAX_ENTRIES - 1) * sizeof (DELAYED_DISPATCH_ENTRY));
1842+
TableSize = sizeof (DELAYED_DISPATCH_TABLE) + (PcdGet32 (PcdDelayedDispatchMaxEntries) * sizeof (DELAYED_DISPATCH_ENTRY));
18371843
Private->DelayedDispatchTable = BuildGuidHob (&gEfiDelayedDispatchTableGuid, TableSize);
18381844
if (Private->DelayedDispatchTable != NULL) {
18391845
ZeroMem (Private->DelayedDispatchTable, TableSize);

MdeModulePkg/Core/Pei/PeiMain.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes ## CONSUMES
124124
gEfiMdeModulePkgTokenSpaceGuid.PcdDelayedDispatchMaxDelayUs ## CONSUMES
125125
gEfiMdeModulePkgTokenSpaceGuid.PcdDelayedDispatchCompletionTimeoutUs ## CONSUMES
126+
gEfiMdeModulePkgTokenSpaceGuid.PcdDelayedDispatchMaxEntries ## CONSUMES
126127

127128
# [BootMode]
128129
# S3_RESUME ## SOMETIMES_CONSUMES

MdeModulePkg/Include/Guid/DelayedDispatch.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @file
22
Definition for structure & defines exported by Delayed Dispatch PPI
33
4-
Copyright (c), Microsoft Corporation.
4+
Copyright (c) Microsoft Corporation.
55
66
SPDX-License-Identifier: BSD-2-Clause-Patent
77
@@ -15,11 +15,6 @@
1515
0x4b733449, 0x8eff, 0x488c, { 0x92, 0x1a, 0x15, 0x4a, 0xda, 0x25, 0x18, 0x07 } \
1616
}
1717

18-
//
19-
// Maximal number of Delayed Dispatch entries supported
20-
//
21-
#define DELAYED_DISPATCH_MAX_ENTRIES 32 // MU_CHANGE: Set max delayed dispatch entries to 32
22-
2318
//
2419
// Internal structure for delayed dispatch entries.
2520
// Packing the structures here to save space as they will be stored as HOBs.
@@ -37,7 +32,7 @@ typedef struct {
3732
typedef struct {
3833
UINT32 Count;
3934
UINT32 DispCount;
40-
DELAYED_DISPATCH_ENTRY Entry[DELAYED_DISPATCH_MAX_ENTRIES];
35+
DELAYED_DISPATCH_ENTRY Entry[]; // Number of entries is based on PcdDelayedDispatchMaxEntries
4136
} DELAYED_DISPATCH_TABLE;
4237

4338
#pragma pack (pop)

MdeModulePkg/MdeModulePkg.dec

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
## @libraryclass This library is used to report memory type information change
204204
## across a reboot.
205205
MemoryTypeInformationChangeLib|Include/Library/MemoryTypeInformationChangeLib.h
206-
206+
207207
## MU_CHANGE
208208
## @libraryclass A public library interface for persisting Capsules across reset.
209209
# This provides platform-defined support for persistence on architectures
@@ -484,7 +484,7 @@
484484

485485
## Include/Guid/EndofS3Resume.h
486486
gEdkiiEndOfS3ResumeGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } }
487-
487+
488488

489489
#
490490
# Guids for NVMe Timeout Events
@@ -718,7 +718,7 @@
718718
# MU_CHANGE
719719
# This protocol provides access to Internal Event services that do not need TPL_APPLICATION
720720
gInternalEventServicesProtocolGuid = {0x7ecd162a, 0xc664, 0x11ec, { 0x9d, 0x64, 0x02, 0x42, 0xac, 0x12, 0x00, 0x02 } }
721-
721+
722722
## This protocol defines the generic memory test interfaces in Dxe phase.
723723
# Include/Protocol/GenericMemoryTest.h
724724
gEfiGenericMemTestProtocolGuid = { 0x309DE7F1, 0x7F5E, 0x4ACE, { 0xB4, 0x9C, 0x53, 0x1B, 0xE5, 0xAA, 0x95, 0xEF }}
@@ -1385,7 +1385,7 @@
13851385
# Default is 2000, it represent delay is 2 ms.
13861386
# @Prompt Delay access XHCI register after it issues HCRST (us)
13871387
gEfiMdeModulePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000|UINT16|0x30001060
1388-
1388+
13891389
# MU_CHANGE [BEGIN] - Support alternative hardware queue sizes in NVME driver
13901390
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportAlternativeQueueSize|FALSE|BOOLEAN|0x40000151
13911391
# MU_CHANGE [END]
@@ -1399,9 +1399,9 @@
13991399
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaTxRxPageCount|1|UINT64|0x30001062
14001400

14011401
# MU_CHANGE [BEGIN] - Support indefinite boot retries
1402-
# # Some platforms require that all EfiLoadOptions are retried until one of the options
1403-
# # succeeds. When True, this Pcd will force Bds to retry all the valid EfiLoadOptions
1404-
# # indefinitely until one of the options succeeds.
1402+
# # Some platforms require that all EfiLoadOptions are retried until one of the options
1403+
# # succeeds. When True, this Pcd will force Bds to retry all the valid EfiLoadOptions
1404+
# # indefinitely until one of the options succeeds.
14051405
# # TRUE - Efi boot options will be retried indefinitely.
14061406
# # FALSE - Efi boot options will not be retried.
14071407
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries|FALSE|BOOLEAN|0x40000152
@@ -1938,6 +1938,10 @@
19381938
# @Prompt UFS device initial completion timoeout (us), default value is 600ms.
19391939
gEfiMdeModulePkgTokenSpaceGuid.PcdUfsInitialCompletionTimeout|600000|UINT32|0x00000036
19401940

1941+
## Delayed Dispatch Max Entries
1942+
# @Prompt Maximum number of delayed dispatch entries. Default value is 8.
1943+
gEfiMdeModulePkgTokenSpaceGuid.PcdDelayedDispatchMaxEntries|8|UINT32|0x00000037
1944+
19411945
## MU_CHANGE [BEGIN]
19421946
## This PCD holds the background color of progress bar.
19431947
# Bit fields:
@@ -1948,7 +1952,6 @@
19481952
# @Prompt Describes background color of progress bar.
19491953
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressBarBackgroundColor|0x00808080|UINT32|0x0000010B
19501954
## MU_CHANGE [END]
1951-
19521955
[PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
19531956
## This PCD defines the Console output row. The default value is 25 according to UEFI spec.
19541957
# This PCD could be set to 0 then console output would be at max column and max row.
@@ -2516,7 +2519,7 @@
25162519
## The value of rate limiter event for timeout check. Default value is 100(unit 1ms).
25172520
# @Prompt The value is use for Usb Network rate limiting supported.
25182521
gEfiMdeModulePkgTokenSpaceGuid.PcdUsbNetworkRateLimitingFactor|100|UINT32|0x10000028
2519-
2522+
25202523
## MU_CHANGE - Configuring timer interval in terminal DXE driver
25212524
## This PCD determines the timer interval to be set when using serial console.
25222525
# @Prompt Sets the serial console timer interval, in the unit of 100ns.

0 commit comments

Comments
 (0)