public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "zhoucheng" <zhoucheng@phytium.com.cn>
To: devel@edk2.groups.io
Cc: Ray Ni <ray.ni@intel.com>, Liming Gao <gaoliming@byosoft.com.cn>,
	Wang Jian J <jian.j.wang@intel.com>
Subject: [PATCH v1 1/1] MdeModulePkg:Avoid Xhc cross 64K boundary
Date: Thu,  3 Mar 2022 11:35:05 +0800	[thread overview]
Message-ID: <20220303033505.26773-2-zhoucheng@phytium.com.cn> (raw)
In-Reply-To: <20220303033505.26773-1-zhoucheng@phytium.com.cn>

The current xhc implementation may exceed the 64K boundary,
so must restrictions need to be added.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Wang Jian J <jian.j.wang@intel.com>
Reviewed-by: Wu Hao A <hao.a.wu@intel.com>
Signed-off-by: Cheng Zhou <zhoucheng@phytium.com.cn>
---
 MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index c2906e06fd84..0fedc8cfced5 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -891,8 +891,14 @@ CreateTransferRing (
   VOID                  *Buf;
   LINK_TRB              *EndTrb;
   EFI_PHYSICAL_ADDRESS  PhyAddr;
+  VOID                  *NewBuf;
 
   Buf = UsbHcAllocateMem (Xhc->MemPool, sizeof (TRB_TEMPLATE) * TrbNum);
+  if((((UINTN)Buf & ((1<<16)-1)) + sizeof (TRB_TEMPLATE) * TrbNum) & (1<<16)) {
+    NewBuf = UsbHcAllocateMem (Xhc->MemPool,sizeof(TRB_TEMPLATE) * TrbNum);
+    UsbHcFreeMem(Xhc->MemPool,Buf,sizeof(TRB_TEMPLATE)*TrbNum);
+    Buf = NewBuf;
+  }
   ASSERT (Buf != NULL);
   ASSERT (((UINTN)Buf & 0x3F) == 0);
   ZeroMem (Buf, sizeof (TRB_TEMPLATE) * TrbNum);
-- 
2.17.1


      reply	other threads:[~2022-03-03  3:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  3:35 [PATCH v1 0/1] MdeModulePkg:Avoid Xhc cross 64K boundary zhoucheng
2022-03-03  3:35 ` zhoucheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220303033505.26773-2-zhoucheng@phytium.com.cn \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox