MdeModulePkg/Xhci: Skip size round up for TRB during address translation

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4560

TRB Template is 16 bytes. When boundary checking is 64 bytes for xHCI
device/host memory address, it may exceed xHCI host memory pool and
cause unwanted DXE_ASSERT. Introduce a new input parameter to indicate
whether to enforce 64byte size alignment and round up. For TRB case,
should set it to FALSE to skip the size round up.

Signed-off-by: Gao Cheng <gao.cheng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Gao Cheng
2023-09-13 14:16:16 +08:00
committed by mergify[bot]
parent ad1c0394b1
commit f36e1ec1f0
6 changed files with 103 additions and 63 deletions

View File

@@ -226,6 +226,7 @@ UsbHcAllocMemFromBlock (
@param Pool The memory pool of the host controller.
@param Mem The pointer to host memory.
@param Size The size of the memory region.
@param Alignment Alignment the size to USBHC_MEM_UNIT bytes.
@return The pci memory address
@@ -234,7 +235,8 @@ EFI_PHYSICAL_ADDRESS
UsbHcGetPciAddrForHostAddr (
IN USBHC_MEM_POOL *Pool,
IN VOID *Mem,
IN UINTN Size
IN UINTN Size,
IN BOOLEAN Alignment
)
{
USBHC_MEM_BLOCK *Head;
@@ -243,8 +245,12 @@ UsbHcGetPciAddrForHostAddr (
EFI_PHYSICAL_ADDRESS PhyAddr;
UINTN Offset;
Head = Pool->Head;
AllocSize = USBHC_MEM_ROUND (Size);
Head = Pool->Head;
if (Alignment) {
AllocSize = USBHC_MEM_ROUND (Size);
} else {
AllocSize = Size;
}
if (Mem == NULL) {
return 0;
@@ -275,6 +281,7 @@ UsbHcGetPciAddrForHostAddr (
@param Pool The memory pool of the host controller.
@param Mem The pointer to pci memory.
@param Size The size of the memory region.
@param Alignment Alignment the size to USBHC_MEM_UNIT bytes.
@return The host memory address
@@ -283,7 +290,8 @@ EFI_PHYSICAL_ADDRESS
UsbHcGetHostAddrForPciAddr (
IN USBHC_MEM_POOL *Pool,
IN VOID *Mem,
IN UINTN Size
IN UINTN Size,
IN BOOLEAN Alignment
)
{
USBHC_MEM_BLOCK *Head;
@@ -292,8 +300,12 @@ UsbHcGetHostAddrForPciAddr (
EFI_PHYSICAL_ADDRESS HostAddr;
UINTN Offset;
Head = Pool->Head;
AllocSize = USBHC_MEM_ROUND (Size);
Head = Pool->Head;
if (Alignment) {
AllocSize = USBHC_MEM_ROUND (Size);
} else {
AllocSize = Size;
}
if (Mem == NULL) {
return 0;