public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
@ 2021-11-25  3:19 jdzhang
  2021-11-25  5:47 ` [edk2-devel] " Wu, Hao A
  0 siblings, 1 reply; 4+ messages in thread
From: jdzhang @ 2021-11-25  3:19 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]

When use the UsbHcAllocMemFromBlock() and UsbHcFreeMem() to allocate memory and free memory for the UHC, it should use the corresponding host address but not the pci bus address.

Signed-off-by: jdzhang <jdzhang@zd-tech.com.cn>
---
MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
index 9aade19f8e..041638a2de 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
@@ -211,7 +211,7 @@ UsbHcAllocMemFromBlock (
NEXT_BIT (Byte, Bit);
}

-  return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;
+  return Block->BufHost + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;
}

/**
@@ -518,12 +518,12 @@ UsbHcFreeMem (
// scan the memory block list for the memory block that
// completely contains the memory to free.
//
-    if ((Block->Buf <= ToFree) && ((ToFree + AllocSize) <= (Block->Buf + Block->BufLen))) {
+    if ((Block->BufHost <= ToFree) && ((ToFree + AllocSize) <= (Block->BufHost + Block->BufLen))) {
//
// compute the start byte and bit in the bit array
//
-      Byte  = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) / 8;
-      Bit   = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) % 8;
+      Byte  = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) / 8;
+      Bit   = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8;

//
// reset associated bits in bit array
--
2.30.0.windows.1

[-- Attachment #2: Type: text/html, Size: 2431 bytes --]

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

* Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
  2021-11-25  3:19 [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue jdzhang
@ 2021-11-25  5:47 ` Wu, Hao A
  2021-12-09  2:39   ` Wu, Hao A
  0 siblings, 1 reply; 4+ messages in thread
From: Wu, Hao A @ 2021-11-25  5:47 UTC (permalink / raw)
  To: devel@edk2.groups.io, jdzhang@zd-tech.com.cn

[-- Attachment #1: Type: text/plain, Size: 2037 bytes --]

Thanks for the fix.
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Will hold the merging of the patch after the upcoming edk2-stable202111 tag.

Best Regards,
Hao Wu

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of 张家定
Sent: Thursday, November 25, 2021 11:20 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue

When use the UsbHcAllocMemFromBlock() and UsbHcFreeMem() to allocate memory and free memory for the UHC, it should use the corresponding host address but not the pci bus address.

Signed-off-by: jdzhang <jdzhang@zd-tech.com.cn<mailto:jdzhang@zd-tech.com.cn>>
---
 MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
index 9aade19f8e..041638a2de 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
@@ -211,7 +211,7 @@ UsbHcAllocMemFromBlock (
     NEXT_BIT (Byte, Bit);
   }

-  return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;
+  return Block->BufHost + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;
 }

 /**
@@ -518,12 +518,12 @@ UsbHcFreeMem (
     // scan the memory block list for the memory block that
     // completely contains the memory to free.
     //
-    if ((Block->Buf <= ToFree) && ((ToFree + AllocSize) <= (Block->Buf + Block->BufLen))) {
+    if ((Block->BufHost <= ToFree) && ((ToFree + AllocSize) <= (Block->BufHost + Block->BufLen))) {
       //
       // compute the start byte and bit in the bit array
       //
-      Byte  = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) / 8;
-      Bit   = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) % 8;
+      Byte  = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) / 8;
+      Bit   = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8;

       //
       // reset associated bits in bit array
--
2.30.0.windows.1



[-- Attachment #2: Type: text/html, Size: 7182 bytes --]

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

* Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
  2021-11-25  5:47 ` [edk2-devel] " Wu, Hao A
@ 2021-12-09  2:39   ` Wu, Hao A
  2021-12-09  8:52     ` Jordan Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Wu, Hao A @ 2021-12-09  2:39 UTC (permalink / raw)
  To: devel@edk2.groups.io, Wu, Hao A, jdzhang@zd-tech.com.cn

[-- Attachment #1: Type: text/plain, Size: 2612 bytes --]

Pushed via:
PR - https://github.com/tianocore/edk2/pull/2267
Commit - https://github.com/tianocore/edk2/commit/d25b803e514a11a25de91d4174b289d2ae783338

Best Regards,
Hao Wu

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao A
Sent: Thursday, November 25, 2021 1:47 PM
To: devel@edk2.groups.io; jdzhang@zd-tech.com.cn
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue

Thanks for the fix.
Reviewed-by: Hao A Wu <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>

Will hold the merging of the patch after the upcoming edk2-stable202111 tag.

Best Regards,
Hao Wu

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of 张家定
Sent: Thursday, November 25, 2021 11:20 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue

When use the UsbHcAllocMemFromBlock() and UsbHcFreeMem() to allocate memory and free memory for the UHC, it should use the corresponding host address but not the pci bus address.

Signed-off-by: jdzhang <jdzhang@zd-tech.com.cn<mailto:jdzhang@zd-tech.com.cn>>
---
 MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
index 9aade19f8e..041638a2de 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
@@ -211,7 +211,7 @@ UsbHcAllocMemFromBlock (
     NEXT_BIT (Byte, Bit);
   }

-  return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;
+  return Block->BufHost + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;
 }

 /**
@@ -518,12 +518,12 @@ UsbHcFreeMem (
     // scan the memory block list for the memory block that
     // completely contains the memory to free.
     //
-    if ((Block->Buf <= ToFree) && ((ToFree + AllocSize) <= (Block->Buf + Block->BufLen))) {
+    if ((Block->BufHost <= ToFree) && ((ToFree + AllocSize) <= (Block->BufHost + Block->BufLen))) {
       //
       // compute the start byte and bit in the bit array
       //
-      Byte  = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) / 8;
-      Bit   = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) % 8;
+      Byte  = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) / 8;
+      Bit   = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8;

       //
       // reset associated bits in bit array
--
2.30.0.windows.1



[-- Attachment #2: Type: text/html, Size: 8465 bytes --]

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

* Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
  2021-12-09  2:39   ` Wu, Hao A
@ 2021-12-09  8:52     ` Jordan Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Jordan Zhang @ 2021-12-09  8:52 UTC (permalink / raw)
  To: Wu, Hao A; +Cc: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 2854 bytes --]

Thanks! 




---------------------------------------------------- 



发件人:"Wu, Hao A" <hao.a.wu@intel.com>
发送日期:2021-12-09 10:39:58
收件人:"devel@edk2.groups.io" <devel@edk2.groups.io>,"Wu, Hao A" <hao.a.wu@intel.com>,"jdzhang@zd-tech.com.cn" <jdzhang@zd-tech.com.cn>
主题:RE: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue


Pushed via:

PR - https://github.com/tianocore/edk2/pull/2267

Commit - https://github.com/tianocore/edk2/commit/d25b803e514a11a25de91d4174b289d2ae783338

 

Best Regards,

Hao Wu

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao A
Sent: Thursday, November 25, 2021 1:47 PM
To: devel@edk2.groups.io; jdzhang@zd-tech.com.cn
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue

 

Thanks for the fix.

Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

 

Will hold the merging of the patch after the upcoming edk2-stable202111 tag.

 

Best Regards,

Hao Wu

 

From:devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of 张家定
Sent: Thursday, November 25, 2021 11:20 AM
To:devel@edk2.groups.io
Subject: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue

 

When use the UsbHcAllocMemFromBlock() and UsbHcFreeMem() to allocate memory and free memory for the UHC, it should use the corresponding host address but not the pci bus address.

 

Signed-off-by: jdzhang <jdzhang@zd-tech.com.cn>

---

 MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)

 

diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c

index 9aade19f8e..041638a2de 100644

--- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c

+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c

@@ -211,7 +211,7 @@ UsbHcAllocMemFromBlock (

     NEXT_BIT (Byte, Bit);

   }

 

-  return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;

+  return Block->BufHost + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;

 }

 

 /**

@@ -518,12 +518,12 @@ UsbHcFreeMem (

     // scan the memory block list for the memory block that

     // completely contains the memory to free.

     //

-    if ((Block->Buf <= ToFree) && ((ToFree + AllocSize) <= (Block->Buf + Block->BufLen))) {

+    if ((Block->BufHost <= ToFree) && ((ToFree + AllocSize) <= (Block->BufHost + Block->BufLen))) {

       //

       // compute the start byte and bit in the bit array

       //

-      Byte  = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) / 8;

-      Bit   = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) % 8;

+      Byte  = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) / 8;

+      Bit   = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8;

 

       //

       // reset associated bits in bit array

-- 

2.30.0.windows.1

 


[-- Attachment #2: Type: text/html, Size: 7245 bytes --]

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

end of thread, other threads:[~2021-12-09  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-25  3:19 [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue jdzhang
2021-11-25  5:47 ` [edk2-devel] " Wu, Hao A
2021-12-09  2:39   ` Wu, Hao A
2021-12-09  8:52     ` Jordan Zhang

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