From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 A727021167478 for ; Fri, 26 Oct 2018 00:56:20 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 00:56:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,427,1534834800"; d="scan'208";a="81069386" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga007.fm.intel.com with ESMTP; 26 Oct 2018 00:56:19 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 26 Oct 2018 00:56:19 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.161]) with mapi id 14.03.0415.000; Fri, 26 Oct 2018 15:54:23 +0800 From: "Wu, Hao A" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [edk2] [PATCH V2 2/4] MdeModulePkg EhciDxe: Extract new EhciInsertAsyncIntTransfer function Thread-Index: AQHUbO61j8xlnj1OKUypj0vNJARg7qUxKFSQ Date: Fri, 26 Oct 2018 07:54:22 +0000 Message-ID: References: <1540532541-115032-1-git-send-email-star.zeng@intel.com> <1540532541-115032-3-git-send-email-star.zeng@intel.com> In-Reply-To: <1540532541-115032-3-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH V2 2/4] MdeModulePkg EhciDxe: Extract new EhciInsertAsyncIntTransfer function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Oct 2018 07:56:20 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Star Zeng > Sent: Friday, October 26, 2018 1:42 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu; Wu, Hao A; Yao, Jiewen; Zeng, Star > Subject: [edk2] [PATCH V2 2/4] MdeModulePkg EhciDxe: Extract new > EhciInsertAsyncIntTransfer function >=20 > V2: > Add the missing "gBS->FreePool (Data);". >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1274 >=20 > Extract new EhciInsertAsyncIntTransfer function from > EhcAsyncInterruptTransfer. >=20 > It is code preparation for following patch, > no essential functional change. >=20 > Cc: Ruiyu Ni > Cc: Hao Wu > Cc: Jian J Wang > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c | 25 +---------- > MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c | 77 > ++++++++++++++++++++++++++++++++ > MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.h | 36 ++++++++++++++- > 3 files changed, 113 insertions(+), 25 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c > b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c > index 50b5598df4fb..5569f4f9618b 100644 > --- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c > +++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c > @@ -997,7 +997,6 @@ EhcAsyncInterruptTransfer ( > URB *Urb; > EFI_TPL OldTpl; > EFI_STATUS Status; > - UINT8 *Data; >=20 > // > // Validate parameters > @@ -1046,16 +1045,7 @@ EhcAsyncInterruptTransfer ( >=20 > EhcAckAllInterrupt (Ehc); >=20 > - Data =3D AllocatePool (DataLength); > - > - if (Data =3D=3D NULL) { > - DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to allocate > buffer\n")); > - > - Status =3D EFI_OUT_OF_RESOURCES; > - goto ON_EXIT; > - } > - > - Urb =3D EhcCreateUrb ( > + Urb =3D EhciInsertAsyncIntTransfer ( > Ehc, > DeviceAddress, > EndPointAddress, > @@ -1063,9 +1053,6 @@ EhcAsyncInterruptTransfer ( > *DataToggle, > MaximumPacketLength, > Translator, > - EHC_INT_TRANSFER_ASYNC, > - NULL, > - Data, > DataLength, > CallBackFunction, > Context, > @@ -1073,20 +1060,10 @@ EhcAsyncInterruptTransfer ( > ); >=20 > if (Urb =3D=3D NULL) { > - DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to create > URB\n")); > - > - gBS->FreePool (Data); > Status =3D EFI_OUT_OF_RESOURCES; > goto ON_EXIT; > } >=20 > - // > - // New asynchronous transfer must inserted to the head. > - // Check the comments in EhcMoniteAsyncRequests > - // > - EhcLinkQhToPeriod (Ehc, Urb->Qh); > - InsertHeadList (&Ehc->AsyncIntTransfers, &Urb->UrbList); > - > ON_EXIT: > Ehc->PciIo->Flush (Ehc->PciIo); > gBS->RestoreTPL (OldTpl); > diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > index 168280be81d7..2d202d439d1c 100644 > --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > @@ -814,6 +814,83 @@ EhciDelAllAsyncIntTransfers ( > } > } >=20 > +/** > + Insert a single asynchronous interrupt transfer for > + the device and endpoint. > + > + @param Ehc The EHCI device. > + @param DevAddr The device address. > + @param EpAddr Endpoint addrress & its direction. > + @param DevSpeed The device speed. > + @param Toggle Initial data toggle to use. > + @param MaxPacket The max packet length of the endpoint. > + @param Hub The transaction translator to use. > + @param Data The user data to transfer. > + @param DataLen The length of data buffer. > + @param Callback The function to call when data is transferre= d. > + @param Context The context to the callback. > + @param Interval The interval for interrupt transfer. > + > + @return Created URB or NULL. > + > +**/ > +URB * > +EhciInsertAsyncIntTransfer ( > + IN USB2_HC_DEV *Ehc, > + IN UINT8 DevAddr, > + IN UINT8 EpAddr, > + IN UINT8 DevSpeed, > + IN UINT8 Toggle, > + IN UINTN MaxPacket, > + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub, > + IN UINTN DataLen, > + IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, > + IN VOID *Context, > + IN UINTN Interval > + ) > +{ > + VOID *Data; > + URB *Urb; > + > + Data =3D AllocatePool (DataLen); > + > + if (Data =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: failed to allocate buffer\n", > __FUNCTION__)); > + return NULL; > + } > + > + Urb =3D EhcCreateUrb ( > + Ehc, > + DevAddr, > + EpAddr, > + DevSpeed, > + Toggle, > + MaxPacket, > + Hub, > + EHC_INT_TRANSFER_ASYNC, > + NULL, > + Data, > + DataLen, > + Callback, > + Context, > + Interval > + ); > + > + if (Urb =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: failed to create URB\n", __FUNCTION__)); > + gBS->FreePool (Data); > + return NULL; > + } > + > + // > + // New asynchronous transfer must inserted to the head. > + // Check the comments in EhcMoniteAsyncRequests > + // > + EhcLinkQhToPeriod (Ehc, Urb->Qh); > + InsertHeadList (&Ehc->AsyncIntTransfers, &Urb->UrbList); > + > + return Urb; > +} >=20 > /** > Flush data from PCI controller specific address to mapped system > diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.h > b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.h > index c03bd619d7e8..b852e6327f37 100644 > --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.h > +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.h > @@ -2,7 +2,7 @@ >=20 > This file contains the definination for host controller schedule routi= nes. >=20 > -Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.
> +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at > @@ -162,6 +162,40 @@ EhciDelAllAsyncIntTransfers ( > IN USB2_HC_DEV *Ehc > ); >=20 > +/** > + Insert a single asynchronous interrupt transfer for > + the device and endpoint. > + > + @param Ehc The EHCI device. > + @param DevAddr The device address. > + @param EpAddr Endpoint addrress & its direction. > + @param DevSpeed The device speed. > + @param Toggle Initial data toggle to use. > + @param MaxPacket The max packet length of the endpoint. > + @param Hub The transaction translator to use. > + @param Data The user data to transfer. > + @param DataLen The length of data buffer. > + @param Callback The function to call when data is transferre= d. > + @param Context The context to the callback. > + @param Interval The interval for interrupt transfer. > + > + @return Created URB or NULL. > + > +**/ > +URB * > +EhciInsertAsyncIntTransfer ( > + IN USB2_HC_DEV *Ehc, > + IN UINT8 BusAddr, > + IN UINT8 EpAddr, > + IN UINT8 DevSpeed, > + IN UINT8 Toggle, > + IN UINTN MaxPacket, > + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub, > + IN UINTN DataLen, > + IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, > + IN VOID *Context, > + IN UINTN Interval > + ); >=20 > /** > Interrupt transfer periodic check handler. > -- > 2.7.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel