* [MdeModulePkg/Usb v2 0/1] Calculating the count of blocks to transfer @ 2018-03-22 7:44 Ming Huang 2018-03-22 7:44 ` [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Ming Huang 0 siblings, 1 reply; 5+ messages in thread From: Ming Huang @ 2018-03-22 7:44 UTC (permalink / raw) To: linaro-uefi, edk2-devel Cc: star.zeng, eric.dong, michael.d.kinney, liming.gao, leif.lindholm, ard.biesheuvel, guoheyi, wanghuiqiang, huangming23, zhangjinsong2, mengfanrong, huangdaode, waip23, Ming Huang Calculating the count of blocks to transfer by Evaluating block size to fix booting failed from USB issue in some platforms. Ming Huang (1): MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 16 ++++++++++++---- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS 2018-03-22 7:44 [MdeModulePkg/Usb v2 0/1] Calculating the count of blocks to transfer Ming Huang @ 2018-03-22 7:44 ` Ming Huang 2018-03-22 8:39 ` Zeng, Star 0 siblings, 1 reply; 5+ messages in thread From: Ming Huang @ 2018-03-22 7:44 UTC (permalink / raw) To: linaro-uefi, edk2-devel Cc: star.zeng, eric.dong, michael.d.kinney, liming.gao, leif.lindholm, ard.biesheuvel, guoheyi, wanghuiqiang, huangming23, zhangjinsong2, mengfanrong, huangdaode, waip23, Ming Huang 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 <ming.huang@linaro.org> --- 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/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; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // @@ -890,11 +892,13 @@ UsbBootWriteBlocks ( USB_BOOT_WRITE10_CMD WriteCmd; EFI_STATUS Status; UINT16 Count; + UINT16 CountMax; UINT32 BlockSize; UINT32 ByteSize; UINT32 Timeout; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // @@ -966,18 +970,20 @@ UsbBootReadBlocks16 ( UINT8 ReadCmd[16]; EFI_STATUS Status; UINT16 Count; + UINT16 CountMax; UINT32 BlockSize; UINT32 ByteSize; UINT32 Timeout; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; while (TotalBlock > 0) { // // Split the total blocks into smaller pieces. // - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // @@ -1040,18 +1046,20 @@ UsbBootWriteBlocks16 ( UINT8 WriteCmd[16]; EFI_STATUS Status; UINT16 Count; + UINT16 CountMax; UINT32 BlockSize; UINT32 ByteSize; UINT32 Timeout; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; while (TotalBlock > 0) { // // Split the total blocks into smaller pieces. // - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // 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 direct access device // -// Other parameters, Max carried size is 512B * 128 = 64KB +// Other parameters, Max carried size is 64KB. // -#define USB_BOOT_IO_BLOCKS 128 +#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB // // Retry mass command times, set by experience -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS 2018-03-22 7:44 ` [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Ming Huang @ 2018-03-22 8:39 ` Zeng, Star 2018-03-26 2:55 ` Ni, Ruiyu 0 siblings, 1 reply; 5+ messages in thread From: Zeng, Star @ 2018-03-22 8:39 UTC (permalink / raw) 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 Reviewed-by: Star Zeng <star.zeng@intel.com> 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 <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; 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; Ming Huang <ming.huang@linaro.org> 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 <ming.huang@linaro.org> --- 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/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; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // @@ -890,11 +892,13 @@ UsbBootWriteBlocks ( USB_BOOT_WRITE10_CMD WriteCmd; EFI_STATUS Status; UINT16 Count; + UINT16 CountMax; UINT32 BlockSize; UINT32 ByteSize; UINT32 Timeout; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // @@ -966,18 +970,20 @@ UsbBootReadBlocks16 ( UINT8 ReadCmd[16]; EFI_STATUS Status; UINT16 Count; + UINT16 CountMax; UINT32 BlockSize; UINT32 ByteSize; UINT32 Timeout; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; while (TotalBlock > 0) { // // Split the total blocks into smaller pieces. // - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // @@ -1040,18 +1046,20 @@ UsbBootWriteBlocks16 ( UINT8 WriteCmd[16]; EFI_STATUS Status; UINT16 Count; + UINT16 CountMax; UINT32 BlockSize; UINT32 ByteSize; UINT32 Timeout; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); Status = EFI_SUCCESS; while (TotalBlock > 0) { // // Split the total blocks into smaller pieces. // - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS); + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); ByteSize = (UINT32)Count * BlockSize; // 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 direct access device // -// Other parameters, Max carried size is 512B * 128 = 64KB +// Other parameters, Max carried size is 64KB. // -#define USB_BOOT_IO_BLOCKS 128 +#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB // // Retry mass command times, set by experience -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS 2018-03-22 8:39 ` Zeng, Star @ 2018-03-26 2:55 ` Ni, Ruiyu 2018-03-26 3:05 ` Zeng, Star 0 siblings, 1 reply; 5+ messages in thread From: Ni, Ruiyu @ 2018-03-26 2:55 UTC (permalink / raw) 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 Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Zeng, > Star > Sent: Thursday, March 22, 2018 4:39 PM > To: Ming Huang <ming.huang@linaro.org>; linaro-uefi@lists.linaro.org; edk2- > devel@lists.01.org > Cc: Zeng, Star <star.zeng@intel.com>; huangming23@huawei.com; Dong, Eric > <eric.dong@intel.com>; ard.biesheuvel@linaro.org; > zhangjinsong2@huawei.com; leif.lindholm@linaro.org; > mengfanrong@huawei.com; guoheyi@huawei.com; Gao, Liming > <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; > 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 > > Reviewed-by: Star Zeng <star.zeng@intel.com> > > 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 <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; > Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming > <liming.gao@intel.com>; 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; > Ming Huang <ming.huang@linaro.org> > 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 <ming.huang@linaro.org> > --- > 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/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; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > @@ -890,11 +892,13 @@ UsbBootWriteBlocks ( > USB_BOOT_WRITE10_CMD WriteCmd; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > @@ -966,18 +970,20 @@ UsbBootReadBlocks16 ( > UINT8 ReadCmd[16]; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > while (TotalBlock > 0) { > // > // Split the total blocks into smaller pieces. > // > - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > @@ -1040,18 +1046,20 @@ UsbBootWriteBlocks16 ( > UINT8 WriteCmd[16]; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > while (TotalBlock > 0) { > // > // Split the total blocks into smaller pieces. > // > - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > 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 direct access > device > > // > -// Other parameters, Max carried size is 512B * 128 = 64KB > +// Other parameters, Max carried size is 64KB. > // > -#define USB_BOOT_IO_BLOCKS 128 > +#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB > > // > // Retry mass command times, set by experience > -- > 1.9.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS 2018-03-26 2:55 ` Ni, Ruiyu @ 2018-03-26 3:05 ` Zeng, Star 0 siblings, 0 replies; 5+ messages in thread From: Zeng, Star @ 2018-03-26 3:05 UTC (permalink / raw) To: Ming Huang, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org Cc: 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, Ni, Ruiyu, Zeng, Star Patch has been pushed at https://github.com/tianocore/edk2/commit/824b6e3b5fa080df36626db3eb8465c25a12c053. Thanks for the contribution. Star -----Original Message----- From: Ni, Ruiyu Sent: Monday, March 26, 2018 10:55 AM To: Zeng, Star <star.zeng@intel.com>; Ming Huang <ming.huang@linaro.org>; linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org Cc: Zeng, Star <star.zeng@intel.com>; huangming23@huawei.com; Dong, Eric <eric.dong@intel.com>; ard.biesheuvel@linaro.org; zhangjinsong2@huawei.com; leif.lindholm@linaro.org; mengfanrong@huawei.com; guoheyi@huawei.com; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; waip23@126.com; wanghuiqiang@huawei.com; huangdaode@hisilicon.com Subject: RE: [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Zeng, Star > Sent: Thursday, March 22, 2018 4:39 PM > To: Ming Huang <ming.huang@linaro.org>; linaro-uefi@lists.linaro.org; > edk2- devel@lists.01.org > Cc: Zeng, Star <star.zeng@intel.com>; huangming23@huawei.com; Dong, > Eric <eric.dong@intel.com>; ard.biesheuvel@linaro.org; > zhangjinsong2@huawei.com; leif.lindholm@linaro.org; > mengfanrong@huawei.com; guoheyi@huawei.com; Gao, Liming > <liming.gao@intel.com>; Kinney, Michael D > <michael.d.kinney@intel.com>; 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 > > Reviewed-by: Star Zeng <star.zeng@intel.com> > > 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 <star.zeng@intel.com>; Dong, Eric > <eric.dong@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; > Gao, Liming <liming.gao@intel.com>; 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; Ming Huang > <ming.huang@linaro.org> > 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 <ming.huang@linaro.org> > --- > 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/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; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > @@ -890,11 +892,13 @@ UsbBootWriteBlocks ( > USB_BOOT_WRITE10_CMD WriteCmd; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > 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 = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > @@ -966,18 +970,20 @@ UsbBootReadBlocks16 ( > UINT8 ReadCmd[16]; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > while (TotalBlock > 0) { > // > // Split the total blocks into smaller pieces. > // > - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > @@ -1040,18 +1046,20 @@ UsbBootWriteBlocks16 ( > UINT8 WriteCmd[16]; > EFI_STATUS Status; > UINT16 Count; > + UINT16 CountMax; > UINT32 BlockSize; > UINT32 ByteSize; > UINT32 Timeout; > > BlockSize = UsbMass->BlockIoMedia.BlockSize; > + CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize); > Status = EFI_SUCCESS; > > while (TotalBlock > 0) { > // > // Split the total blocks into smaller pieces. > // > - Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : > USB_BOOT_IO_BLOCKS); > + Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax); > ByteSize = (UINT32)Count * BlockSize; > > // > 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 direct access > device > > // > -// Other parameters, Max carried size is 512B * 128 = 64KB > +// Other parameters, Max carried size is 64KB. > // > -#define USB_BOOT_IO_BLOCKS 128 > +#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB > > // > // Retry mass command times, set by experience > -- > 1.9.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-26 2:59 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-03-22 7:44 [MdeModulePkg/Usb v2 0/1] Calculating the count of blocks to transfer Ming Huang 2018-03-22 7:44 ` [MdeModulePkg/Usb v2 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Ming Huang 2018-03-22 8:39 ` Zeng, Star 2018-03-26 2:55 ` Ni, Ruiyu 2018-03-26 3:05 ` Zeng, Star
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox