Sorry, I found that I missed pointing out in the previous discussion that within function UsbHcFreeMem(), below snippet of code should be updated as well:
// // Release the current memory block if it is empty and not the head // if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) { // UsbHcUnlinkMemBlock (Head, Block); UsbHcFreeMemBlock (Pool, Block); } Could you help to double check if the above UsbHcUnlinkMemBlock() call should be uncommented? Thanks in advance. Best Regards, Hao Wu > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, > Abner via groups.io > Sent: Wednesday, December 21, 2022 11:42 PM > To: devel@edk2.groups.io > Cc: Wu, Hao A <hao.a...@intel.com>; Ni, Ray <ray...@intel.com>; Garrett > Kirkendall <garrett.kirkend...@amd.com>; Abner Chang > <abner.ch...@amd.com>; Kuei-Hung Lin <kuei-hung....@amd.com> > Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei > memory block > > From: Abner Chang <abner.ch...@amd.com> > > Unlink the XhciPei memory block when it has been freed. > > Signed-off-by: Jiangang He <jiangang...@amd.com> > Cc: Hao A Wu <hao.a...@intel.com> > Cc: Ray Ni <ray...@intel.com> > Cc: Garrett Kirkendall <garrett.kirkend...@amd.com> > Cc: Abner Chang <abner.ch...@amd.com> > Cc: Kuei-Hung Lin <kuei-hung....@amd.com> > --- > MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 29 > ++++++++++++++++++++++++- > 1 file changed, 28 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > index c64b38fcfc8..7dc014e465d 100644 > --- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > +++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based > on gPeiUsbControllerPpiGuid > which is used to enable recovery function from USB Drivers. > > Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR> > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR> > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -365,6 +366,32 @@ UsbHcInitMemPool ( > return Pool; > } > > +/** > + Unlink the memory block from the pool's list. > + > + @param Head The block list head of the memory's pool. > + @param BlockToUnlink The memory block to unlink. > + > +**/ > +VOID > +UsbHcUnlinkMemBlock ( > + IN USBHC_MEM_BLOCK *Head, > + IN USBHC_MEM_BLOCK *BlockToUnlink > + ) > +{ > + USBHC_MEM_BLOCK *Block; > + > + ASSERT ((Head != NULL) && (BlockToUnlink != NULL)); > + > + for (Block = Head; Block != NULL; Block = Block->Next) { > + if (Block->Next == BlockToUnlink) { > + Block->Next = BlockToUnlink->Next; > + BlockToUnlink->Next = NULL; > + break; > + } > + } > +} > + > /** > Release the memory management pool. > > @@ -386,7 +413,7 @@ UsbHcFreeMemPool ( > // first block. > // > for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) { > - // UsbHcUnlinkMemBlock (Pool->Head, Block); > + UsbHcUnlinkMemBlock (Pool->Head, Block); > UsbHcFreeMemBlock (Pool, Block); > } > > -- > 2.37.1.windows.1 > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97724): https://edk2.groups.io/g/devel/message/97724 Mute This Topic: https://groups.io/mt/95808360/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-