From patchwork Thu Mar 22 07:44:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 132254 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp512485ljb; Thu, 22 Mar 2018 00:44:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELsi9pX0MvT0lG9PZYe7PsYUCSUpt3GMpsuQ34JTpSOesAOw9T3hH/nOLULku1Hb0Dv7ntAK X-Received: by 10.99.185.77 with SMTP id v13mr17575556pgo.112.1521704685896; Thu, 22 Mar 2018 00:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521704685; cv=none; d=google.com; s=arc-20160816; b=jzeSnjXqW8IJdE0adK2clynqnLaCRfrSX8vZpmCMNCdIWXmSeTXeFwmBfhesEFCFzp z6hDeQpSrrWwRcIJKAheC8QqLpsKzZjrLaoAo9oHmvkmxf8WoqRwn3lsSfR7OMjQaywq bggmuu23PqfW3FudOV0I93A6oLklbyZUEf7DGzocjsj6F2DjtJ3MXh1Y9a9YSxR7BhIw 338ZmLUmEpXjROPTKVneYy3/T4HP1ybe4z2Nl4RBALYmuWEHbSpQrTnCxuVt8Wz7llax THcFq8jVsJjJNxYmP+jx3iqbNCKGzVRgey3WTommchP/guWSha+fRFADLKWLwyB2RunC V3cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=pjz0njAzlz2OwYXAm30R8src7MYdRnBUpxiQ25OWjPs=; b=BROLSom8uWNAc1yCIoq6eFGSTkM6M7EtfHE2C7itIlEaeTSQhZL/Jkyh4FMaXS70TY ag3DYEirQOZvtz9QDzPd77U65PmORDqNrI9d80XqXDbx3GtUm7+h2nQ/tGTOJXFqt1es 8kZ98ckSfOTmm3nIcITN3CGVrWccIQCrChmiykK0aMnCw79UuKpzwlWWEfT4cdtCbx2e XFdMu57ev5JWsV2v4hBI8le/MpEoF+RWXH7WK3aBFmpOelsGBCsu381fOeAx3JaAyUOW jhgvUhOlXrtRqaemH8SnZJLL3Sw4bqKYAdZAy0w3x1f10ux5BiznY2qaH1f4yw3TAPXn /GeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HtsUMgmA; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 97-v6si5615792plm.149.2018.03.22.00.44.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 00:44:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HtsUMgmA; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B239122551BB8; Thu, 22 Mar 2018 00:38:13 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4602522551BB7 for ; Thu, 22 Mar 2018 00:38:12 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id p9-v6so4797450pls.2 for ; Thu, 22 Mar 2018 00:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s8/Vj22VyOTG6urdS0DT4p6jQClfz45FS78KTj3a85o=; b=HtsUMgmA7WOTW5FHp5+cYqc2zfC0Xe1By8tPiqxxfp8izpjwNFE3WqDzzAdZB7JseC h6J7phn4Tpr1JuOqJJII632w0q3ZIpWHqBhxSEqUbrt0TZSCOZM5N3Mz08IN6ONxNBFb dZaCTRdU++x0u2h2sdO2frQLUIDyQv7U+U3iU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s8/Vj22VyOTG6urdS0DT4p6jQClfz45FS78KTj3a85o=; b=CRAmFsIBdf2bDnwuOdbmIPqL0dPAVCotDfC9q5d34VZg5DgTVZK6j2UWKF7hsCOrKx 1szM5MP4MprwiJpS+MpxsXE8jnpAWNvZ7tG318M+fUbrHsrwZK/dnfJ4lmspevqx1EiP SlL6H3I8uhdpQkGmz4bZrhRMHYxVxuOTTDrNzp/isgNKusrcIIM1YVSNZMrpuVQZFQy6 VZjZgZ4ug16dwc+5oVVHOcpZYxtvvUbhWFWkYZaMosz6PXVcRxBnJwKYFsJBJf9FbFNu y5i2ZjAWEATVhsbjU2+oj4AXvGjyjnvesdiOmO9iTzXQyEjZwhvpBzjg9rrAHy9UJgvM zfYg== X-Gm-Message-State: AElRT7G60Q1sFk7QgJ+I9Bd6TGfRCCE1lT8FdQO6wDGn9LvjokVWmubd U7JmXvqd0ySKZyb9fdm2iIPX7a+31oA= X-Received: by 2002:a17:902:b2c6:: with SMTP id x6-v6mr24426459plw.298.1521704683576; Thu, 22 Mar 2018 00:44:43 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id c15sm12483456pfm.114.2018.03.22.00.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Mar 2018 00:44:43 -0700 (PDT) From: Ming Huang To: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org Date: Thu, 22 Mar 2018 15:44:26 +0800 Message-Id: <1521704666-54009-2-git-send-email-ming.huang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521704666-54009-1-git-send-email-ming.huang@linaro.org> References: <1521704666-54009-1-git-send-email-ming.huang@linaro.org> Subject: [edk2] [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: , Cc: huangming23@huawei.com, wanghuiqiang@huawei.com, eric.dong@intel.com, ard.biesheuvel@linaro.org, zhangjinsong2@huawei.com, Ming Huang , leif.lindholm@linaro.org, mengfanrong@huawei.com, guoheyi@huawei.com, liming.gao@intel.com, michael.d.kinney@intel.com, waip23@126.com, star.zeng@intel.com, huangdaode@hisilicon.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Star Zeng Signed-off-by: Ming Huang Reviewed-by: Ruiyu Ni Reviewed-by: Ruiyu Ni 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