* [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
@ 2021-11-25 3:19 jdzhang
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
* [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
@ 2021-11-25 4:33 jdzhang
0 siblings, 0 replies; 2+ messages in thread
From: jdzhang @ 2021-11-25 4:33 UTC (permalink / raw)
To: devel
[-- Attachment #1: Type: text/plain, Size: 1593 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: 2382 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-25 4:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-25 4:33 [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue jdzhang
-- strict thread matches above, loose matches on Subject: below --
2021-11-25 3:19 jdzhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox