From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue To: devel@edk2.groups.io From: jdzhang@zd-tech.com.cn X-Originating-Location: Beijing, CN (223.104.41.2) X-Originating-Platform: Windows Chrome 96 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 24 Nov 2021 19:19:33 -0800 Message-ID: Content-Type: multipart/alternative; boundary="MKH1HUWxoDa5r2Q1EGl3" --MKH1HUWxoDa5r2Q1EGl3 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 --- 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); } -=C2=A0 return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT; +=C2=A0 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. // -=C2=A0 =C2=A0 if ((Block->Buf <=3D ToFree) && ((ToFree + AllocSize) <=3D (= Block->Buf + Block->BufLen))) { +=C2=A0 =C2=A0 if ((Block->BufHost <=3D ToFree) && ((ToFree + AllocSize) <= =3D (Block->BufHost + Block->BufLen))) { // // compute the start byte and bit in the bit array // -=C2=A0 =C2=A0 =C2=A0 Byte=C2=A0 =3D ((ToFree - Block->Buf) / USBHC_MEM_UNI= T) / 8; -=C2=A0 =C2=A0 =C2=A0 Bit=C2=A0 =C2=A0=3D ((ToFree - Block->Buf) / USBHC_ME= M_UNIT) % 8; +=C2=A0 =C2=A0 =C2=A0 Byte=C2=A0 =3D ((ToFree - Block->BufHost) / USBHC_MEM= _UNIT) / 8; +=C2=A0 =C2=A0 =C2=A0 Bit=C2=A0 =C2=A0=3D ((ToFree - Block->BufHost) / USBH= C_MEM_UNIT) % 8; // // reset associated bits in bit array -- 2.30.0.windows.1 --MKH1HUWxoDa5r2Q1EGl3 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
When use the UsbHcAllocMemFromBlock() and UsbHcFreeMem() to allocate m= emory and free memory for the UHC, it should use the corresponding host add= ress 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/Bu= s/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 <=3D ToFree) && ((ToFree = + AllocSize) <=3D (Block->Buf + Block->BufLen))) {
+    if ((Block->BufHost <=3D ToFree) && ((ToF= ree + AllocSize) <=3D (Block->BufHost + Block->BufLen))) {
       //
       // compute the start byte and bit in the bi= t array
       //
-      Byte  =3D ((ToFree - Block->Buf) / USBHC= _MEM_UNIT) / 8;
-      Bit   =3D ((ToFree - Block->Buf) / = USBHC_MEM_UNIT) % 8;
+      Byte  =3D ((ToFree - Block->BufHost) / U= SBHC_MEM_UNIT) / 8;
+      Bit   =3D ((ToFree - Block->BufHost= ) / USBHC_MEM_UNIT) % 8;
 
       //
       // reset associated bits in bit array
-- 
2.30.0.windows.1
 
--MKH1HUWxoDa5r2Q1EGl3--