From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 4825E21DFC895 for ; Thu, 24 Aug 2017 19:00:19 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Aug 2017 19:02:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,423,1498546800"; d="scan'208";a="893902578" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 24 Aug 2017 19:02:54 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 Aug 2017 19:02:54 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 Aug 2017 19:02:54 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.219]) with mapi id 14.03.0319.002; Fri, 25 Aug 2017 10:02:52 +0800 From: "Ni, Ruiyu" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [PATCH] MdeModulePkg XhciDxe: Fix Map and Unmap inconsistency Thread-Index: AQHTHL4QvtAvF9mhOkO1us6Kp/yWMKKUUslA Date: Fri, 25 Aug 2017 02:02:51 +0000 Deferred-Delivery: Fri, 25 Aug 2017 02:02:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA0E763@SHSMSX104.ccr.corp.intel.com> References: <1503568048-157864-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1503568048-157864-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg XhciDxe: Fix Map and Unmap inconsistency 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: , X-List-Received-Date: Fri, 25 Aug 2017 02:00:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni Thanks/Ray > -----Original Message----- > From: Zeng, Star > Sent: Thursday, August 24, 2017 5:47 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Ni, Ruiyu ; Yao= , > Jiewen > Subject: [PATCH] MdeModulePkg XhciDxe: Fix Map and Unmap > inconsistency >=20 > We found there are loops of *2* Maps and only *1* Unmap and the DMA > buffer address is decreasing. >=20 > It is caused by the below code flow. > XhcAsyncInterruptTransfer -> > XhcCreateUrb -> > XhcCreateTransferTrb -> > Map Urb->DataMap (1) >=20 > Timer: loops of *2* Maps and only *1* Unmap XhcMonitorAsyncRequests -> > XhcFlushAsyncIntMap -> > Unmap and Map Urb->DataMap (2) > XhcUpdateAsyncRequest -> > XhcCreateTransferTrb -> > Map Urb->DataMap (3) >=20 > This patch is to eliminate (3). >=20 > Cc: Ruiyu Ni > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > index 6013d7620fe5..21fdcf130a50 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > @@ -259,8 +259,11 @@ XhcCreateTransferTrb ( > } else { > EPType =3D (UINT8) ((DEVICE_CONTEXT_64 *)OutputContext)->EP[Dci- > 1].EPType; > } > - > - if (Urb->Data !=3D NULL) { > + > + // > + // No need to remap. > + // > + if ((Urb->Data !=3D NULL) && (Urb->DataMap =3D=3D NULL)) { > if (((UINT8) (Urb->Ep.Direction)) =3D=3D EfiUsbDataIn) { > MapOp =3D EfiPciIoOperationBusMasterWrite; > } else { > -- > 2.7.0.windows.1