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.24; helo=mga09.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 6EFA422551BB9 for ; Thu, 22 Mar 2018 01:33:00 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2018 01:39:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,343,1517904000"; d="scan'208";a="26576489" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 22 Mar 2018 01:39:31 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 22 Mar 2018 01:39:31 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 22 Mar 2018 01:39:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.80]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.226]) with mapi id 14.03.0319.002; Thu, 22 Mar 2018 16:39:29 +0800 From: "Zeng, Star" To: Ming Huang , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Kinney, Michael D" , "Gao, Liming" , "leif.lindholm@linaro.org" , "ard.biesheuvel@linaro.org" , "guoheyi@huawei.com" , "wanghuiqiang@huawei.com" , "huangming23@huawei.com" , "zhangjinsong2@huawei.com" , "mengfanrong@huawei.com" , "huangdaode@hisilicon.com" , "waip23@126.com" , "Zeng, Star" Thread-Topic: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Thread-Index: AQHTwbGmnhWt1PURhECHPMDpLR5F86Pb7w4w Date: Thu, 22 Mar 2018 08:39:28 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BA72588@shsmsx102.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> In-Reply-To: <1521704666-54009-2-git-send-email-ming.huang@linaro.org> 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: [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: Thu, 22 Mar 2018 08:33:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Ming Huang [mailto:ming.huang@linaro.org]=20 Sent: Thursday, March 22, 2018 3:44 PM To: linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org Cc: Zeng, Star ; Dong, Eric ; Kin= ney, Michael D ; Gao, Liming ; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org; guoheyi@huawei.c= om; wanghuiqiang@huawei.com; huangming23@huawei.com; zhangjinsong2@huawei.c= om; 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 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 virtual 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. 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(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/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) ? TotalBlock = : USB_BOOT_IO_BLOCKS); + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax= ); 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) ? TotalBlock = : USB_BOOT_IO_BLOCKS); + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax= ); 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) ? TotalBlock = : USB_BOOT_IO_BLOCKS); + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax= ); 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) ? TotalBlock = : USB_BOOT_IO_BLOCKS); + Count =3D (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax= ); ByteSize =3D (UINT32)Count * BlockSize; =20 // diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h b/MdeModu= lePkg/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 direct = 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 --=20 1.9.1