From nobody Sat Apr 27 04:10:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+84077+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84077+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=zd-tech.com.cn ARC-Seal: i=1; a=rsa-sha256; t=1637816860; cv=none; d=zohomail.com; s=zohoarc; b=Oi7J7KTfBa0DedfKAPbMsuYxbdXD5OF/C+dNBGgyEtFeRIzbPbwdfXNH63BOzQPc+9vR2RDNII3xYiHRBuhmAMZkjO/uut06vIKh1yggeNB/qXb6MMyPNQvxtQwO0dYFb42YyNHj18DHu6aJM2V058bQy1yPQX3OKiqb7gMqcBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637816860; h=Content-Type:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=UihNbHY2fLENVB4n4NjtBq4R4nfcKd7a+VPYTByIsow=; b=dayiC5tQyHeGmambySgtX9DOYMTeRUM4HoFBxvmfgfR4XCNsk2+b4RanClPUAiXTlZLtLV1gNA4xMQZpj5npC9SEVrARilYoctpqq/s0Eg+pddyVwdj/ghxeR0I2Bqe2ybl+AQKARp1TRdO+N8IUXqqH8U4z2IVTgUVx4c1HzB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84077+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637816860061949.1283964744661; Wed, 24 Nov 2021 21:07:40 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id RDPPYY1788612xBl43PerKBB; Wed, 24 Nov 2021 21:07:39 -0800 Subject: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue To: devel@edk2.groups.io From: =?UTF-8?B?5byg5a625a6a?= 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: Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jdzhang@zd-tech.com.cn X-Gm-Message-State: sQEMkMLtUMsHjNH0yvOeiKDnx1787277AA= Content-Type: multipart/alternative; boundary="MKH1HUWxoDa5r2Q1EGl3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637816859; bh=GgYvymk6s0VZIQgP7KPO9quo4QWFzUWaPUiqUQZPZUA=; h=Content-Type:Date:From:Reply-To:Subject:To; b=T0uvVO0tsEm6tg7FRtZNsZeUqlTw/9idRGgKsK5RgOrIFJm8YwlrJUJZDOMWUjk25F2 8qESslZp/ipZ6Vd6ZRMZZfBnXkc+N/Isuys8WtKYHbdHC9RI/TB8hhxdEKV8plepX7n+l 6Mip+p3WOolr8sZf0bbEdrswetJ6qA2TvU8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637816860890100007 --MKH1HUWxoDa5r2Q1EGl3 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 Reviewed-by: Hao A Wu > Reviewed-by: Hao A Wu --- 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#84077): https://edk2.groups.io/g/devel/message/84077 Mute This Topic: https://groups.io/mt/87296862/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --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
 
_._,_._,_

G= roups.io Links:

You receive all messages sent to this group.

Vi= ew/Reply Online (#84077) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [importer@patchew.org]
_._,_._,_=20 --MKH1HUWxoDa5r2Q1EGl3--