From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.62212.1671757219639592616 for ; Thu, 22 Dec 2022 17:00:19 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BMZ4rSGP; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: hao.a.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671757219; x=1703293219; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=md23Jhf1ZCUig2xGqX8e4FyeIOr/i4DjPiY2JI+H8ks=; b=BMZ4rSGPaVX/eqQIiyMLtp8v5yEZnLtdGZef2LcBBCO6dX1HBV3NcNWd YdK5hJKl1LusFF0w6kojnx2S1m8TGML5Dh/RAwfeHEzIIG/OzAzASb3t6 QPhSoCf2KHSF0b2dovproGSPgfdB+iPNWs1Ez5bXEWJqXOE8tVysRkSGC jDBBaqFqzpE8u+22bShy00cur8GuesjmEClIiU0RlDikyE59eNntX8nv2 k1XfYcADIGEQSyxKUcf9AssuOuyzxvYzpZCGTFMNinGMxslqkfR6W9L/Y XV4bEsuhtbqXIESHjcLsnv5gxZc5x8r13cp7rCOr8UlKIuyEZ7FJBv92s Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="317892971" X-IronPort-AV: E=Sophos;i="5.96,267,1665471600"; d="scan'208";a="317892971" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2022 17:00:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="602044411" X-IronPort-AV: E=Sophos;i="5.96,267,1665471600"; d="scan'208";a="602044411" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga003.jf.intel.com with ESMTP; 22 Dec 2022 17:00:18 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 22 Dec 2022 17:00:17 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Thu, 22 Dec 2022 17:00:17 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.47) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Thu, 22 Dec 2022 17:00:17 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ax5ZDJTSejDFS3IXZq76jpY641jRwwaijx0ePISK4Rxa+B5pdfqJKZzCYipY2RZ5sRgUTbicTxbGSI5Xyll+PtlC6p+7P+dQ0ZZUe6Ibdz8zvl4y9PLq9pOhFsSRAESiqYvtuFeSxBSDgm/MiMk59V+J4UurjVrhZ6IdKH/SeNatF+/0F1COWvPQfhVVxSn6Jsj1lx2obdrkQUpmHWcq0D+cp4/QIcLBoOj2jgxkEF11yh6v2YPIQzC2H6H4U+RIWKId8dUQOH+Y0KJEck5KP8SICpT1oVTfWuICNO03fi2O0xKKw5aH6Wfg0USB0KWrHf9Unmqk5/x9Hx0SqYBerA== 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=ablY/S/8ow1xFoEXK18+CI+r4LEZ2vqavnLA4cyabW4=; b=L8hENjjog5cLowcS0lzjKEtN9VcGtr4+aourohdvCD9/2SNeNcWzzXzCX/kiZCC7aBW1ce7QLzMGlilwtauLppKgWnGJykwFZ8m9rOnqUkrN0yoxIRDIMjYOFIbBEH8pN3ge2Ar7EnnvzOmcDXM8DEp8hYLOasXSwPyerMh003YM1bUYAF6etkAK1F/c+5bTnaomeUo48TcteajMpQLQFMNdI0zwlZ6ogqJv3EReZmBlYUl+McSlnA8uRrVCTUDa+OtGPpC7TxHKMo+Ltpb+uaCNxyqJknd55UYzteOvvBMhPuKNfaUJKr6OzejvnWGq/V6zH3Bm6RVOvyzsq/JvbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB4025.namprd11.prod.outlook.com (2603:10b6:5:197::31) by MW4PR11MB6617.namprd11.prod.outlook.com (2603:10b6:303:1ed::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.12; Fri, 23 Dec 2022 01:00:15 +0000 Received: from DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::6129:7158:18dd:761c]) by DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::6129:7158:18dd:761c%3]) with mapi id 15.20.5924.016; Fri, 23 Dec 2022 01:00:15 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "abner.chang@amd.com" CC: "Ni, Ray" , Garrett Kirkendall , Kuei-Hung Lin Subject: Re: [edk2-devel] [PATCH 2/3] MdeModulePkg/Usb: Read a large number of blocks Thread-Topic: [edk2-devel] [PATCH 2/3] MdeModulePkg/Usb: Read a large number of blocks Thread-Index: AQHZFVLa7+xnm7t8QUKjiznNkUx+O656pc0w Date: Fri, 23 Dec 2022 01:00:15 +0000 Message-ID: References: <20221221154144.623-1-abner.chang@amd.com> In-Reply-To: <20221221154144.623-1-abner.chang@amd.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB4025:EE_|MW4PR11MB6617:EE_ x-ms-office365-filtering-correlation-id: ec3845c5-f9b1-43b1-e0fe-08dae4810d9e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PwOfJs3eJtxrXhnjx2ZM0sptgIM5e1d6AlvsdQD2N6SbUUJc8fNijrD7DTnaLzTB7lOp6XsZOo86496QT1fEw2NFEhNyr4m84yyUNCmeiq6Ydaw1UYorMCoYIMrrIdribVxNLWwkhYr9g5k4PqDYVgnk4lGKtbnEj3QL92L9G1JqSRsGDoBFPm7yQqe8rFCQclT2zryj4j3H1mlFIvXdbceSBNTemciDd4p3nIZ0fsml/kTEJmQTYwXJe1oJDkJk42EIWD8m23TadH8BbrgelYWmRCgACj3pDR7Cr8RvtG6h0TSW/QwwCvJ6MGb9uAUwtwtNyAHq8gxySa7Yq1foFOoUZRP8yIgNrzvSXXT9/fUyOGHvNodsa6AUUlacyOOUB5q+KL3etRRcxLIFmUt4e7Wzqt3O5ktzO3loODBEFnvHYF9D5eL5Rcclb2l1mM7SP8ES7BU8Tmja3gOhjORNiC+s4g3RuIzZQdTNOR7uUbE9WDILmgq/FfcyGThT5LrTW22mHYclvZjYmk0I13m7yh9bM9Aq/KSLTe0kDZ/JxM5TJRnLs3SoF/XeG/nia1ioqJongKlas/9yz83E9MJp3q6R7n3E2B3ZknajqcuLnRnasn7trZ9ykVplWHUtjRQIWRC6u3c70rLN4wczHxaSl2ez8Dq//3JwV2jVoXTiW/5iHQZfS/lhjOJQe1xNmb7uGxuGpVB+kW0wdPbysCjmYgeJ0IK33H4UIg7BfE/cdfFeE297W5uXHlirPRh+tMQ3 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4025.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(376002)(346002)(136003)(366004)(396003)(451199015)(82960400001)(2906002)(38100700002)(122000001)(33656002)(55016003)(38070700005)(86362001)(71200400001)(54906003)(110136005)(66899015)(7696005)(6506007)(53546011)(26005)(186003)(9686003)(966005)(478600001)(5660300002)(76116006)(83380400001)(66946007)(66446008)(41300700001)(66556008)(66476007)(64756008)(8676002)(8936002)(52536014)(4326008)(316002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?poIj8jrF0Ax+qu8uUUJiGfkNLgp85ddtLakpAGrlYAhpr2/q97usgR59rIRk?= =?us-ascii?Q?ACVwhGS6nPE+pzm6FPS+wArJbkxKTQG/tXAc7y0nj9bl2GSX6TFEHcmBLnPj?= =?us-ascii?Q?jIwiTKsyk98+Q5luS+v0jjw7vZ4yCTSqRsYeSEdL9ILR24zzjcwYy2HGnCHD?= =?us-ascii?Q?MkNzbpFDrXubTy2ZP37ox8BXTRHUH8oleplD4eT052A4kdVPGYRTetXxy+e+?= =?us-ascii?Q?ULeJrrhE8ymVUhTTpBdQD7fNl4nzxVSRzoiXdkorD0vqJ+cU/FbHJzc/cPoE?= =?us-ascii?Q?ykf6xso/81L8piCnbj190+Na4wTEGaWjBuAs2UFzpbir0WRVNbICq1Qls90d?= =?us-ascii?Q?4MedNRv1F4koHoSh5sk7wxsp+IEYgAoYYwWjHD5o+MCZjdplVE+/h8WkmXD+?= =?us-ascii?Q?+oBtjZB3Nal7LtUOOR53QLisSIfXkQpRoQs5183CFYWLnoVzzuSXqnQcdO/7?= =?us-ascii?Q?N6gu2F//S3dCrfGltvhoPLiaX8M1uDAx8IcPxkjuYnZM3OoaYmQFZ+HnXMx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tACUk8ECSpU5y/gDFTJ?= =?us-ascii?Q?jkn9oOXRoUGu2k0sgT4dXcA+BIsjUXP90lWlKYYEJEMv2YL6rSyN2OS6tmG6?= =?us-ascii?Q?lhSokOMK/wB/k3sLkugbA6wF23dg4Md+Us1/V3bHG8tQ+McpqmNvo9bveJ2K?= =?us-ascii?Q?FjjKQRBfibdXjr5BdeMlKk9QFDaT44FJRj+oGOPA?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4025.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec3845c5-f9b1-43b1-e0fe-08dae4810d9e X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Dec 2022 01:00:15.6620 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /SnUV66t2X0/jweTJs0qWrbqFbvrhsKuZitd8tjq0ZybPHx1N/k0W54oB9t4SiYkwjwFzMlEJONXFWPWpu5CYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6617 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao A Wu Best Regards, Hao Wu > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Chang, > Abner via groups.io > Sent: Wednesday, December 21, 2022 11:42 PM > To: devel@edk2.groups.io > Cc: Wu, Hao A ; Ni, Ray ; Garrett > Kirkendall ; Abner Chang > ; Kuei-Hung Lin > Subject: [edk2-devel] [PATCH 2/3] MdeModulePkg/Usb: Read a large number > of blocks >=20 > From: Abner Chang >=20 > Changes to allow reading blocks that greater than 65535 sectors. >=20 > Signed-off-by: Jiangang He > Cc: Hao A Wu > Cc: Ray Ni > Cc: Garrett Kirkendall > Cc: Abner Chang > Cc: Kuei-Hung Lin > --- > MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c | 25 +++++++++++------------ > 1 file changed, 12 insertions(+), 13 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c > b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c > index 422ac5fec99..5111e4579e2 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; > -- > 2.37.1.windows.1 >=20 >=20 >=20 >=20 >=20