From nobody Tue Feb 10 02:49:00 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1499145639328387.09128109355527; Mon, 3 Jul 2017 22:20:39 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 138482095D205; Mon, 3 Jul 2017 22:18:57 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F46021A00AC2 for ; Mon, 3 Jul 2017 22:18:56 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2017 22:20:34 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.12]) by fmsmga004.fm.intel.com with ESMTP; 03 Jul 2017 22:20:32 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,307,1496127600"; d="scan'208";a="281840462" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 4 Jul 2017 13:20:27 +0800 Message-Id: <20170704052030.226408-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20170704052030.226408-1-ruiyu.ni@intel.com> References: <20170704052030.226408-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH v2 1/4] MdeModulePkg/XhciDxe: Refine IsTransferRingTrb and IsAsyncIntTrb X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao A Wu , Feng Tian , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Current implementation of IsTransferRingTrb only checks whether the TRB is in the RING of the URB. The patch enhanced the logic to check that whether the TRB belongs to the transaction of URB. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Hao A Wu Cc: Star Zeng Cc: Feng Tian --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 90 ++++++++++++++++------------= ---- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 457344051b..a72a104b80 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -977,45 +977,42 @@ XhcFreeSched ( } =20 /** - Check if the Trb is a transaction of the URBs in XHCI's asynchronous tra= nsfer list. + Check if the Trb is a transaction of the URB. =20 - @param Xhc The XHCI Instance. - @param Trb The TRB to be checked. - @param Urb The pointer to the matched Urb. + @param Trb The TRB to be checked + @param Urb The URB to be checked. =20 - @retval TRUE The Trb is matched with a transaction of the URBs in the a= sync list. - @retval FALSE The Trb is not matched with any URBs in the async list. + @retval TRUE It is a transaction of the URB. + @retval FALSE It is not any transaction of the URB. =20 **/ BOOLEAN -IsAsyncIntTrb ( +IsTransferRingTrb ( IN USB_XHCI_INSTANCE *Xhc, IN TRB_TEMPLATE *Trb, - OUT URB **Urb + IN URB *Urb ) { - LIST_ENTRY *Entry; - LIST_ENTRY *Next; - TRB_TEMPLATE *CheckedTrb; - URB *CheckedUrb; - UINTN Index; + LINK_TRB *LinkTrb; + TRB_TEMPLATE *CheckedTrb; + UINTN Index; + EFI_PHYSICAL_ADDRESS PhyAddr; =20 - EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) { - CheckedUrb =3D EFI_LIST_CONTAINER (Entry, URB, UrbList); - CheckedTrb =3D CheckedUrb->TrbStart; - for (Index =3D 0; Index < CheckedUrb->TrbNum; Index++) { - if (Trb =3D=3D CheckedTrb) { - *Urb =3D CheckedUrb; - return TRUE; - } - CheckedTrb++; - // - // If the checked TRB is the link TRB at the end of the transfer rin= g, - // recircle it to the head of the ring. - // - if (CheckedTrb->Type =3D=3D TRB_TYPE_LINK) { - CheckedTrb =3D (TRB_TEMPLATE*) CheckedUrb->Ring->RingSeg0; - } + CheckedTrb =3D Urb->TrbStart; + for (Index =3D 0; Index < Urb->TrbNum; Index++) { + if (Trb =3D=3D CheckedTrb) { + return TRUE; + } + CheckedTrb++; + // + // If the checked TRB is the link TRB at the end of the transfer ring, + // recircle it to the head of the ring. + // + if (CheckedTrb->Type =3D=3D TRB_TYPE_LINK) { + LinkTrb =3D (LINK_TRB *) CheckedTrb; + PhyAddr =3D (EFI_PHYSICAL_ADDRESS)(LinkTrb->PtrLo | LShiftU64 ((UINT= 64) LinkTrb->PtrHi, 32)); + CheckedTrb =3D (TRB_TEMPLATE *)(UINTN) UsbHcGetHostAddrForPciAddr (X= hc->MemPool, (VOID *)(UINTN) PhyAddr, sizeof (TRB_TEMPLATE)); + ASSERT (CheckedTrb =3D=3D Urb->Ring->RingSeg0); } } =20 @@ -1023,38 +1020,39 @@ IsAsyncIntTrb ( } =20 /** - Check if the Trb is a transaction of the URB. + Check if the Trb is a transaction of the URBs in XHCI's asynchronous tra= nsfer list. =20 - @param Trb The TRB to be checked - @param Urb The transfer ring to be checked. + @param Xhc The XHCI Instance. + @param Trb The TRB to be checked. + @param Urb The pointer to the matched Urb. =20 - @retval TRUE It is a transaction of the URB. - @retval FALSE It is not any transaction of the URB. + @retval TRUE The Trb is matched with a transaction of the URBs in the a= sync list. + @retval FALSE The Trb is not matched with any URBs in the async list. =20 **/ BOOLEAN -IsTransferRingTrb ( +IsAsyncIntTrb ( + IN USB_XHCI_INSTANCE *Xhc, IN TRB_TEMPLATE *Trb, - IN URB *Urb + OUT URB **Urb ) { - TRB_TEMPLATE *CheckedTrb; - UINTN Index; - - CheckedTrb =3D Urb->Ring->RingSeg0; - - ASSERT (Urb->Ring->TrbNumber =3D=3D CMD_RING_TRB_NUMBER || Urb->Ring->Tr= bNumber =3D=3D TR_RING_TRB_NUMBER); + LIST_ENTRY *Entry; + LIST_ENTRY *Next; + URB *CheckedUrb; =20 - for (Index =3D 0; Index < Urb->Ring->TrbNumber; Index++) { - if (Trb =3D=3D CheckedTrb) { + EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) { + CheckedUrb =3D EFI_LIST_CONTAINER (Entry, URB, UrbList); + if (IsTransferRingTrb (Xhc, Trb, CheckedUrb)) { + *Urb =3D CheckedUrb; return TRUE; } - CheckedTrb++; } =20 return FALSE; } =20 + /** Check the URB's execution result and update the URB's result accordingly. @@ -1131,7 +1129,7 @@ XhcCheckUrbResult ( // This way is used to avoid that those completed async transfer event= s don't get // handled in time and are flushed by newer coming events. // - if (IsTransferRingTrb (TRBPtr, Urb)) { + if (IsTransferRingTrb (Xhc, TRBPtr, Urb)) { CheckedUrb =3D Urb; } else if (IsAsyncIntTrb (Xhc, TRBPtr, &AsyncUrb)) { =20 CheckedUrb =3D AsyncUrb; --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel