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.31; helo=mga06.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 6065420954BA5 for ; Sun, 25 Mar 2018 19:48:38 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Mar 2018 19:55:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,363,1517904000"; d="scan'208";a="185945755" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 25 Mar 2018 19:55:12 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 25 Mar 2018 19:55:12 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 25 Mar 2018 19:55:12 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.226]) by shsmsx102.ccr.corp.intel.com ([169.254.2.80]) with mapi id 14.03.0319.002; Mon, 26 Mar 2018 10:55:06 +0800 From: "Ni, Ruiyu" To: "Zeng, Star" , Ming Huang , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "huangming23@huawei.com" , "Dong, Eric" , "ard.biesheuvel@linaro.org" , "zhangjinsong2@huawei.com" , "leif.lindholm@linaro.org" , "mengfanrong@huawei.com" , "guoheyi@huawei.com" , "Gao, Liming" , "Kinney, Michael D" , "waip23@126.com" , "wanghuiqiang@huawei.com" , "huangdaode@hisilicon.com" Thread-Topic: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Thread-Index: AQHTwblYdi/XX8FW6EGkDhpDGqBW/qPh2DFg Date: Mon, 26 Mar 2018 02:55:06 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BC0CEC3@SHSMSX104.ccr.corp.intel.com> References: <1521704666-54009-1-git-send-email-ming.huang@linaro.org> <1521704666-54009-2-git-send-email-ming.huang@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103BA72588@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BA72588@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzYxZDJiNGItNjdlYy00MDM3LTlhYWEtNzEyNGNkYmRmM2ZhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJZNVY5VW1WXC9oT09EQkZjTGhaVmFsRUFiRGt0aFA1NkY2QUtYMWoydHJiNjZBTUFNOGlGRWZrMmN2N2hxZnhnVSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2018 02:48:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ze= ng, > Star > Sent: Thursday, March 22, 2018 4:39 PM > To: Ming Huang ; linaro-uefi@lists.linaro.org; edk= 2- > devel@lists.01.org > Cc: Zeng, Star ; huangming23@huawei.com; Dong, Eric > ; ard.biesheuvel@linaro.org; > zhangjinsong2@huawei.com; leif.lindholm@linaro.org; > mengfanrong@huawei.com; guoheyi@huawei.com; Gao, Liming > ; Kinney, Michael D ; > waip23@126.com; wanghuiqiang@huawei.com; huangdaode@hisilicon.com > Subject: Re: [edk2] [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace > macro USB_BOOT_IO_BLOCKS >=20 > Reviewed-by: Star Zeng >=20 > Thanks, > Star > -----Original Message----- > From: Ming Huang [mailto:ming.huang@linaro.org] > Sent: Thursday, March 22, 2018 3:44 PM > To: linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org > Cc: Zeng, Star ; Dong, Eric ; > Kinney, Michael D ; Gao, Liming > ; leif.lindholm@linaro.org; ard.biesheuvel@linaro.o= rg; > guoheyi@huawei.com; wanghuiqiang@huawei.com; > huangming23@huawei.com; zhangjinsong2@huawei.com; > mengfanrong@huawei.com; huangdaode@hisilicon.com; waip23@126.com; > Ming Huang > Subject: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro > USB_BOOT_IO_BLOCKS >=20 > Booting from USB may fail while the macro USB_BOOT_IO_BLOCKS set to 128 > because the block size of some USB devices are exceeded 512, like some vi= rtual > CD-ROM from BMC, the block size is 2048. > So,the count blocks to transfer should be calculated by block size of the= USB > devices. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ming Huang > --- > MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 16 > ++++++++++++---- > MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h | 4 ++-- > 2 files changed, 14 insertions(+), 6 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c > b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c > index b84bfd2d7290..3bf6e6a81f3c 100644 > --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c > +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c > @@ -814,11 +814,13 @@ UsbBootReadBlocks ( > USB_BOOT_READ10_CMD ReadCmd; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; >=20 > BlockSize =3D UsbMass->BlockIoMedia.BlockSize; > + CountMax =3D (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status =3D EFI_SUCCESS; >=20 > while (TotalBlock > 0) { > @@ -827,7 +829,7 @@ UsbBootReadBlocks ( > // on the device. We must split the total block because the READ10 > // command only has 16 bit transfer length (in the unit of block). > // > - Count =3D (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBloc= k : > USB_BOOT_IO_BLOCKS); > + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountM= ax); > ByteSize =3D (UINT32)Count * BlockSize; >=20 > // > @@ -890,11 +892,13 @@ UsbBootWriteBlocks ( > USB_BOOT_WRITE10_CMD WriteCmd; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; >=20 > BlockSize =3D UsbMass->BlockIoMedia.BlockSize; > + CountMax =3D (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status =3D EFI_SUCCESS; >=20 > while (TotalBlock > 0) { > @@ -903,7 +907,7 @@ UsbBootWriteBlocks ( > // on the device. We must split the total block because the WRITE10 > // command only has 16 bit transfer length (in the unit of block). > // > - Count =3D (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBloc= k : > USB_BOOT_IO_BLOCKS); > + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountM= ax); > ByteSize =3D (UINT32)Count * BlockSize; >=20 > // > @@ -966,18 +970,20 @@ UsbBootReadBlocks16 ( > UINT8 ReadCmd[16]; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; >=20 > BlockSize =3D UsbMass->BlockIoMedia.BlockSize; > + CountMax =3D (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status =3D EFI_SUCCESS; >=20 > while (TotalBlock > 0) { > // > // Split the total blocks into smaller pieces. > // > - Count =3D (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBloc= k : > USB_BOOT_IO_BLOCKS); > + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountM= ax); > ByteSize =3D (UINT32)Count * BlockSize; >=20 > // > @@ -1040,18 +1046,20 @@ UsbBootWriteBlocks16 ( > UINT8 WriteCmd[16]; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; >=20 > BlockSize =3D UsbMass->BlockIoMedia.BlockSize; > + CountMax =3D (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status =3D EFI_SUCCESS; >=20 > while (TotalBlock > 0) { > // > // Split the total blocks into smaller pieces. > // > - Count =3D (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBloc= k : > USB_BOOT_IO_BLOCKS); > + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountM= ax); > ByteSize =3D (UINT32)Count * BlockSize; >=20 > // > diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h > b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h > index 13a926035ceb..f8a0708350c7 100644 > --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h > +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h > @@ -65,9 +65,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direc= t access > device >=20 > // > -// Other parameters, Max carried size is 512B * 128 =3D 64KB > +// Other parameters, Max carried size is 64KB. > // > -#define USB_BOOT_IO_BLOCKS 128 > +#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB >=20 > // > // Retry mass command times, set by experience > -- > 1.9.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel