From nobody Sun Apr 28 22:21:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97227+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670685067110977.5505374972746; Sat, 10 Dec 2022 07:11:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id wQBUYY1788612xeXcqEoaRuo; Sat, 10 Dec 2022 07:11:06 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.54]) by mx.groups.io with SMTP id smtpd.web10.17153.1670685065565288177 for ; Sat, 10 Dec 2022 07:11:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VglUxDg5I0miN5mfC8VPOKaqZadC6mBBg9BtabKTmkWPqeZoiqTI8HAnUnbnlLX8L+qzH6vOvZdcrsZ5d38tCqO5tPDxHqysB4JcjNpmFmIFO3vNa+edpfAOH1DZQHH7JjUecLHup9yB0/T87DvEp4mUF1tTqIQJQccFsHWkg1+ZGErA6r9LYh4Oq1mmOOUT0fxwcotojbtvUk1iLmjZgc6X9+byEXd543NfAP0OucdNd5L4ln+9k/pyayWaTsjAUhJBHi6Iqfzl/3jSuQwEudnQjqyg0gQDq2YvM7NF3PO9QcaqgxqBbCwf1mjOcEyxTHNKFJKcsDP/atR+1ZJJ5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NQp/Hq9YqEjknErYQn0K7fdVpdEZ9Y/9COHJS4Wgdcs=; b=FjsvRQQ0cRvIAK/PPb9cdCchZDIsNj2Spb4JtluVeyTNo+floPntzE445VZxlZP9bPyN6BH2jqQDDCb6AmzNx+sJYEhRIluXrikdAMTKHwdfHe+VgYFaDjHuWQ45XyIqiWC3wrygmW6bWSMu+FH+B6sFtAotgpOF3gu3DG9YEpF8PcfjV961WY4WrQXFhHLzqU97dvhUD6viCM1vOB6+tnbfSwPlFxT3pnQMit0G5cviz4OVbe1SEVSkED6CUOQAZRPUQT6xtXsZ5iY09cvUBb+RGVL/l1APYXUdeq2jgr3lALejPB53PeyPStZDCj4SysZLUtNgFMjoV0v+KwiBag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none X-Received: from BL1PR13CA0399.namprd13.prod.outlook.com (2603:10b6:208:2c2::14) by MN2PR12MB4304.namprd12.prod.outlook.com (2603:10b6:208:1d0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 15:11:00 +0000 X-Received: from BL02EPF00010206.namprd05.prod.outlook.com (2603:10b6:208:2c2:cafe::4b) by BL1PR13CA0399.outlook.office365.com (2603:10b6:208:2c2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.7 via Frontend Transport; Sat, 10 Dec 2022 15:11:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97227+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00010206.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Sat, 10 Dec 2022 15:11:00 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sat, 10 Dec 2022 09:10:55 -0600 From: "Chang, Abner via groups.io" To: CC: , Hao A Wu , Ray Ni , Garrett Kirkendall , "Abner Chang" Subject: [edk2-devel] [PATCH V2] MdeModulePkg/Usb: Read a large number of blocks Date: Sat, 10 Dec 2022 23:10:32 +0800 Message-ID: <20221210151032.1312-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00010206:EE_|MN2PR12MB4304:EE_ X-MS-Office365-Filtering-Correlation-Id: d0007eaa-2ba7-4477-c7fd-08dadac0bf7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: Xr+C6LzlvpaHVIlyylauHpUX7psEulm8rFC9OPN7NA/gJjDZt7SZEMTUAgqTgiH3cZAttnp1PADVXBt8Qlvxt6blFF96RbhT1DYqsbW6k2I8IRbIGzCbm5osdVb8Qc9y40hrhVz2D1gPEmhqxlg7rZWMZvPu4F+KQ3oD1Zev+ErAYcR8QkbSEA0vP60urbl4t0Y7JxWizcyQitTwG0xbI39uiaaNyB30wgJMpHlW1SSSew83NQ2GWqeB58f/K42D/1vbCK1uv4F8QZ6rxDgng1WtPk/XUbnAoZeRFY0u41aF/+Iu/0eMt7aGSDKeW/6RQn4U7xnFvbHtL+HrAEjC4KAGMD2o9GJeysUHIbnn2HjuyVNoABx+FFEbRcGUzoAErlkwJbEVYJOTDafVdAdaTkUWKfq8sb3jV6xH/icCNjM8wnY4fmtkYPO3ILuWn6TztOEmvwqL4/bPSBrY5KynCityhBe1x3bcY5xBdbh0ARAPz55YpGLncTAzfy9j2W034C98s6xpBo+GkOCAdRSh0c+ckSOt7eqkawBntLIlyksvSk43Fms97mfpLhcy0A2y4t2Tt4M5ozRiec6vxmfAYkC6S10Wxr9kYDx5ZubyJrckX29HV5RQb1Sc8vY47TXsOGVTSjT38e9keUd2aNt8wbizcQHO72so5v+BZPpG4OuyO2pbEJVq+aMKy4K+6sw/1VbaPud2o3wtKIaNDexCvzwjdPFzJxHaaWGEQOsmUdg= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 15:11:00.7170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0007eaa-2ba7-4477-c7fd-08dadac0bf7b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00010206.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4304 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com X-Gm-Message-State: ydHI2sie0Jk5eTkg5LvY9fITx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670685066; bh=+3sDiK8CYVaq/VeH36Ozxw0+pzlxP/uTQmHfg5kIeOo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=F6/yvGm7xUGtvIUZz/IlCT2562fU85rJJt+lP4OBUErkaBYH5xGos6PW0g9AMNNMrSr mpqSSHrVSXxB2lcTSaiegEoCY/nSFSIsihul54SsQTtx0gvy82oXREtk0p3ppX0fDqlHL BX4KfPw4UeQ5hOVCQrLHoZyD/50q1ooMrOM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670685068364100001 Content-Type: text/plain; charset="utf-8" From: Abner Chang In V2: Add AMD copyright. Changes to allow reading blocks that greater than 65535 sectors. Signed-off-by: Kuei-Hung Lin Cc: Hao A Wu Cc: Ray Ni Cc: Garrett Kirkendall Cc: Abner Chang --- MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c b/MdeModulePkg/Bus/U= sb/UsbBotPei/PeiAtapi.c index 422ac5fec99..f85c7258abc 100644 --- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c +++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c @@ -2,6 +2,7 @@ Pei USB ATAPI command implementations. =20 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
+Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -382,14 +383,14 @@ PeiUsbRead10 ( ATAPI_PACKET_COMMAND Packet; ATAPI_READ10_CMD *Read10Packet; UINT16 MaxBlock; - UINT16 BlocksRemaining; - UINT16 SectorCount; + UINT32 BlocksRemaining; + UINT32 SectorCount; UINT32 Lba32; UINT32 BlockSize; UINT32 ByteCount; VOID *PtrBuffer; EFI_STATUS Status; - UINT16 TimeOut; + UINT32 TimeOut; =20 // // prepare command packet for the Inquiry Packet Command. @@ -401,16 +402,13 @@ PeiUsbRead10 ( =20 BlockSize =3D (UINT32)PeiBotDevice->Media.BlockSize; =20 - MaxBlock =3D (UINT16)(65535 / BlockSize); - BlocksRemaining =3D (UINT16)NumberOfBlocks; + MaxBlock =3D (UINT16)(MAX_UINT16 / BlockSize); + ASSERT (NumberOfBlocks < MAX_UINT32); + BlocksRemaining =3D (UINT32)NumberOfBlocks; =20 Status =3D EFI_SUCCESS; while (BlocksRemaining > 0) { - if (BlocksRemaining <=3D MaxBlock) { - SectorCount =3D BlocksRemaining; - } else { - SectorCount =3D MaxBlock; - } + SectorCount =3D MIN (BlocksRemaining, MaxBlock); =20 // // fill the Packet data structure @@ -435,7 +433,7 @@ PeiUsbRead10 ( =20 ByteCount =3D SectorCount * BlockSize; =20 - TimeOut =3D (UINT16)(SectorCount * 2000); + TimeOut =3D SectorCount * 2000; =20 // // send command packet @@ -448,16 +446,17 @@ PeiUsbRead10 ( (VOID *)PtrBuffer, ByteCount, EfiUsbDataIn, - TimeOut + (UINT16)MIN (TimeOut, MAX_UINT16) ); =20 if (Status !=3D EFI_SUCCESS) { return Status; } =20 + ASSERT (Lba32 <=3D (MAX_UINT32-SectorCount)); Lba32 +=3D SectorCount; PtrBuffer =3D (UINT8 *)PtrBuffer + SectorCount * BlockSize; - BlocksRemaining =3D (UINT16)(BlocksRemaining - SectorCount); + BlocksRemaining =3D BlocksRemaining - SectorCount; } =20 return Status; --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97227): https://edk2.groups.io/g/devel/message/97227 Mute This Topic: https://groups.io/mt/95582705/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-