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=star.zeng@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 877B2225E9646 for ; Wed, 21 Mar 2018 05:34:24 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2018 05:40:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,340,1517904000"; d="scan'208";a="39344023" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 21 Mar 2018 05:40:54 -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; Wed, 21 Mar 2018 05:40:54 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 21 Mar 2018 05:40:53 -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; Wed, 21 Mar 2018 20:40:51 +0800 From: "Zeng, Star" To: Ming Huang , "Ni, Ruiyu" , "leif.lindholm@linaro.org" , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" , "Dong, Eric" CC: "ard.biesheuvel@linaro.org" , "Kinney, Michael D" , "Gao, Liming" , "guoheyi@huawei.com" , "wanghuiqiang@huawei.com" , "huangming23@huawei.com" , "zhangjinsong2@huawei.com" , "mengfanrong@huawei.com" , "huangdaode@hisilicon.com" , "waip23@126.com" Thread-Topic: [edk2 UsbMassStorageDxe v1 1/1] MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS Thread-Index: AQHTvFlVWNlJ/wzmFE2C5kTU4KKIkKPaqb7Q Date: Wed, 21 Mar 2018 12:40:50 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BA71F3C@shsmsx102.ccr.corp.intel.com> References: <1521116980-120594-1-git-send-email-ming.huang@linaro.org> <1521116980-120594-2-git-send-email-ming.huang@linaro.org> In-Reply-To: <1521116980-120594-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: [edk2 UsbMassStorageDxe v1 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: Wed, 21 Mar 2018 12:34:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ming, Basically, I am ok with the change in this patch. There are two comments. 1. Please add more background information about the specific device in the = commit log. For example, you mentioned " like some virtual CD-ROM from BMC = " in previous patch. 2. Please make sure building pass with the patch on different tool chains. = I tried to build with the patch on VS2015, but met building failure like be= low. warning C4244: '=3D': conversion from 'UINT32' to 'UINT16', possible loss o= f data Ray, Do you have other concern? Thanks, Star -----Original Message----- From: Ming Huang [mailto:ming.huang@linaro.org]=20 Sent: Thursday, March 15, 2018 8:30 PM To: leif.lindholm@linaro.org; linaro-uefi@lists.linaro.org; edk2-devel@list= s.01.org; Zeng, Star ; Dong, Eric Cc: ard.biesheuvel@linaro.org; Kinney, Michael D ; Gao, Liming ; guoheyi@huawei.com; wanghuiqiang@hu= awei.com; huangming23@huawei.com; zhangjinsong2@huawei.com; mengfanrong@hua= wei.com; huangdaode@hisilicon.com; waip23@126.com; Ming Huang Subject: [edk2 UsbMassStorageDxe v1 1/1] MdeModulePkg/Usb: Replace macro US= B_BOOT_IO_BLOCKS Booting from USB may fail while the macro USB_BOOT_IO_BLOCKS set to 128 bec= ause the block size of some USB devices are exceeded 512. So,the count bloc= ks 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..b38cb6116bf4 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 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 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 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 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..fc5449bde21e 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 0x10000 =20 // // Retry mass command times, set by experience -- 1.9.1