From patchwork Thu Mar 15 12:29:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 131777 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp1051609ljb; Thu, 15 Mar 2018 05:29:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELt/jirSUCqICqzrFfpdVPMkxkc2Nhz4YMMZI4cV4pkBk4iGwUU8921JRBG0KrfzN4+szRJa X-Received: by 2002:a17:902:8d87:: with SMTP id v7-v6mr7900095plo.146.1521116994904; Thu, 15 Mar 2018 05:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521116994; cv=none; d=google.com; s=arc-20160816; b=VI6LUIi3Re+phxvqqOccnCG0v6L0Hy7hNrDIafWcXR/0mdtzNx4GwSqR9iilQdpWDG hNYayHL/qO2StYXRAgF8j4I6CcFhkWQxGc5+FVuFWONwaR76h96m0AOWcAgJllloNEum Cmrhn6bdTKfqRzhXSdpSiWAdfBkcGHAbBKHWy2SkMmRX8ePJ5zS7nyOlmvb2WOAzGv0h WnYqLq3kixeRDlEBJ4L8R+Oy6OjhAO4CHUZzs0BYgauCssLw+I/DdMErkVZJWQ2Y4OEG M3wB7Xj/W428LIiZEcwQz5bgTVwMejiRhH0LM0tg2CjqsohDxnPJF/dMsElbw9lB/MRl MjRQ== 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=ZQyxzi7/NqvvZCEfOvKrVSmx4P4R+eE0SCTWnewAJWI=; b=GyqODu8O/Y+C1v1GpbPVLhEAbqEDOXkJOnBo6yeEEZb4YoWI6CFotpSmGfzG8Fo7SG YgUNn4YgJHJIrcRi2Ef4AsMKftdAsytdfE8mEoULbx/6Mm5Q/ZeWBzST1MmLi0rb46Cn FkuMCzLMR3lC1IAlPoc81bdFW0FXAmeflPxU4fVXp4kEam9w76x1o0k9QfUBUg+UQr5L WN1XHv2L7RmIEgjhJeKfSi2nMGQjiWXbFIQRpuRAGsDjnLyVzZLpeb+K648EpbzOJn2O FO9XWNhBYjBfQ1SXtEC4EJzWEhYvMOUugfsEcQt3HHHMwUc6+anK+HiN5Kpt1XfuTnoP mH0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CcO6P5JG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id bg2-v6si3941440plb.30.2018.03.15.05.29.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 05:29:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CcO6P5JG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 5460A21E082A4; Thu, 15 Mar 2018 05:23:30 -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:c05::242; helo=mail-pg0-x242.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (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 E42AA20954B8F for ; Thu, 15 Mar 2018 05:23:28 -0700 (PDT) Received: by mail-pg0-x242.google.com with SMTP id i14so2693751pgv.3 for ; Thu, 15 Mar 2018 05:29:52 -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=46wpwXmSI9Y4ZeKXbTxuJea4UEuiVolRKmunNGg2gCc=; b=CcO6P5JG0Bg+BLJwAqaPd+mBJ0mMuLi0HLBvo4D9FVMqMyEglqVNXgSB7L9bR2tZRF dp3BIPSDZUNHMDLG5EbnvcC8OUigvG9SrvNuTnrjjQkQPxoJt9yTHWyk2OriHs3omG+n 7DyUSiUenjsznAmUNWdBBZ6QXd77PgXz9YPNM= 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=46wpwXmSI9Y4ZeKXbTxuJea4UEuiVolRKmunNGg2gCc=; b=p4C6Zi6PpqhjSsZO3Ni1DZrwjcReRI7HhEGTCedrt82udQLDa9wpTpivFrJY1XIbsR BisqrCSMvKaznYkjAzwahXJfk0/frDhvyMBl37hMSPXiZqMCd1ATZUCp29IKy0NFfOnb 7onDXWdeT4RUAw0RHcsWE2KR2LSvHKxNMyWDGDHlxRPCPHlDyycIiljPAYz6qqmBVMqd VvVcXffAwTo9pQB5ICkClzfq97qeRRMnP9PI9ScYUcrIFsGogofgnoPRFdDOmsNGNEZV kBwOlOoJdvY7ws5HKZil3L3ukfg7yXAU/l5Ns4Ii2Yp2mChEEerSwq4cSXl5lp2xC9SM XPzg== X-Gm-Message-State: AElRT7EgpG2IDbJS3r3FIA9971qzjLEie9xQVliVz0MqpnJlcrRoRvIK pq//mNEmPi2fIfHTFKMSpTBFWQ== X-Received: by 10.101.97.139 with SMTP id c11mr6745695pgv.447.1521116992620; Thu, 15 Mar 2018 05:29:52 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id h80sm10378689pfj.181.2018.03.15.05.29.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Mar 2018 05:29:52 -0700 (PDT) From: Ming Huang To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, star.zeng@intel.com, eric.dong@intel.com Date: Thu, 15 Mar 2018 20:29:40 +0800 Message-Id: <1521116980-120594-2-git-send-email-ming.huang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521116980-120594-1-git-send-email-ming.huang@linaro.org> References: <1521116980-120594-1-git-send-email-ming.huang@linaro.org> Subject: [edk2] [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: , Cc: huangming23@huawei.com, ard.biesheuvel@linaro.org, Ming Huang , liming.gao@intel.com, mengfanrong@huawei.com, guoheyi@huawei.com, zhangjinsong2@huawei.com, michael.d.kinney@intel.com, waip23@126.com, wanghuiqiang@huawei.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. 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 Signed-off-by: Ming Huang diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/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; BlockSize = UsbMass->BlockIoMedia.BlockSize; + CountMax = 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 = 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 = 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 = 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..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 // -// 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 0x10000 // // Retry mass command times, set by experience