public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
@ 2022-12-21 15:42 Chang, Abner
  2022-12-23  1:00 ` [edk2-devel] " Wu, Hao A
  0 siblings, 1 reply; 4+ messages in thread
From: Chang, Abner @ 2022-12-21 15:42 UTC (permalink / raw)
  To: devel; +Cc: Hao A Wu, Ray Ni, Garrett Kirkendall, Abner Chang, Kuei-Hung Lin

From: Abner Chang <abner.chang@amd.com>

Unlink the XhciPei memory block when it has been freed.

Signed-off-by: Jiangang He <jiangang.he@amd.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Kuei-Hung Lin <Kuei-Hung.Lin@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
  2022-12-21 15:42 [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block Chang, Abner
@ 2022-12-23  1:00 ` Wu, Hao A
  2022-12-26 15:33   ` Chang, Abner
  0 siblings, 1 reply; 4+ messages in thread
From: Wu, Hao A @ 2022-12-23  1:00 UTC (permalink / raw)
  To: devel@edk2.groups.io, abner.chang@amd.com
  Cc: Ni, Ray, Garrett Kirkendall, Kuei-Hung Lin

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.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Garrett
> Kirkendall <garrett.kirkendall@amd.com>; Abner Chang
> <abner.chang@amd.com>; Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
> Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei
> memory block
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> Unlink the XhciPei memory block when it has been freed.
> 
> Signed-off-by: Jiangang He <jiangang.he@amd.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Kuei-Hung Lin <Kuei-Hung.Lin@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
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
  2022-12-23  1:00 ` [edk2-devel] " Wu, Hao A
@ 2022-12-26 15:33   ` Chang, Abner
  2023-01-09 15:35     ` He, Jiangang
  0 siblings, 1 reply; 4+ messages in thread
From: Chang, Abner @ 2022-12-26 15:33 UTC (permalink / raw)
  To: Wu, Hao A, devel@edk2.groups.io
  Cc: Ni, Ray, Kirkendall, Garrett, Lin, Kuei-Hung (Timothy),
	He, Jiangang

[AMD Official Use Only - General]

Hi Hao,
Yes, I think we also have to uncomment it and change the order as well. However, I would like to have Jiangang's confirmation. Lets wait until they come back from holidays.

Thanks
Abner


> -----Original Message-----
> From: Wu, Hao A <hao.a.wu@intel.com>
> Sent: Friday, December 23, 2022 9:00 AM
> To: devel@edk2.groups.io; Chang, Abner <Abner.Chang@amd.com>
> Cc: Ni, Ray <ray.ni@intel.com>; Kirkendall, Garrett
> <Garrett.Kirkendall@amd.com>; Lin, Kuei-Hung (Timothy) <Kuei-
> Hung.Lin@amd.com>
> Subject: RE: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked
> XhciPei memory block
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> 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.wu@intel.com>; Ni, Ray <ray.ni@intel.com>;
> > Garrett Kirkendall <garrett.kirkendall@amd.com>; Abner Chang
> > <abner.chang@amd.com>; Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
> > Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked
> > XhciPei memory block
> >
> > From: Abner Chang <abner.chang@amd.com>
> >
> > Unlink the XhciPei memory block when it has been freed.
> >
> > Signed-off-by: Jiangang He <jiangang.he@amd.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
> > Cc: Abner Chang <abner.chang@amd.com>
> > Cc: Kuei-Hung Lin <Kuei-Hung.Lin@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
> >
> >
> >
> > 
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
  2022-12-26 15:33   ` Chang, Abner
@ 2023-01-09 15:35     ` He, Jiangang
  0 siblings, 0 replies; 4+ messages in thread
From: He, Jiangang @ 2023-01-09 15:35 UTC (permalink / raw)
  To: Chang, Abner, Wu, Hao A, devel@edk2.groups.io
  Cc: Ni, Ray, Kirkendall, Garrett, Lin, Kuei-Hung (Timothy)

[AMD Official Use Only - General]

Hi Hao,

Yes UsbHcUnlinkMemBlock() call should be uncommented.

----------------------
  for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
     UsbHcUnlinkMemBlock (Pool->Head, Block);
     UsbHcFreeMemBlock (Pool, Block);
  }
----------------------
Thanks,
Jiangang

-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Monday, December 26, 2022 9:33 AM
To: Wu, Hao A <hao.a.wu@intel.com>; devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>; Kirkendall, Garrett <Garrett.Kirkendall@amd.com>; Lin, Kuei-Hung (Timothy) <Kuei-Hung.Lin@amd.com>; He, Jiangang <Jiangang.He@amd.com>
Subject: RE: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

[AMD Official Use Only - General]

Hi Hao,
Yes, I think we also have to uncomment it and change the order as well. However, I would like to have Jiangang's confirmation. Lets wait until they come back from holidays.

Thanks
Abner


> -----Original Message-----
> From: Wu, Hao A <hao.a.wu@intel.com>
> Sent: Friday, December 23, 2022 9:00 AM
> To: devel@edk2.groups.io; Chang, Abner <Abner.Chang@amd.com>
> Cc: Ni, Ray <ray.ni@intel.com>; Kirkendall, Garrett
> <Garrett.Kirkendall@amd.com>; Lin, Kuei-Hung (Timothy) <Kuei-
> Hung.Lin@amd.com>
> Subject: RE: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked
> XhciPei memory block
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> 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.wu@intel.com>; Ni, Ray <ray.ni@intel.com>;
> > Garrett Kirkendall <garrett.kirkendall@amd.com>; Abner Chang
> > <abner.chang@amd.com>; Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
> > Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked
> > XhciPei memory block
> >
> > From: Abner Chang <abner.chang@amd.com>
> >
> > Unlink the XhciPei memory block when it has been freed.
> >
> > Signed-off-by: Jiangang He <jiangang.he@amd.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
> > Cc: Abner Chang <abner.chang@amd.com>
> > Cc: Kuei-Hung Lin <Kuei-Hung.Lin@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
> >
> >
> >
> > 
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-09 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-21 15:42 [PATCH 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block Chang, Abner
2022-12-23  1:00 ` [edk2-devel] " Wu, Hao A
2022-12-26 15:33   ` Chang, Abner
2023-01-09 15:35     ` He, Jiangang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox