From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.80]) by mx.groups.io with SMTP id smtpd.web10.14506.1673406640648026004 for ; Tue, 10 Jan 2023 19:10:40 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=0ATbaMNv; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.244.80, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nUmee3WTzMvgfHomN1FT7cpb0l48wzVm+YUtcU+qdjk8PEFjqb+5q+okASZZZ1t+ZLz1+0TZgnpTKmDqJBiXhBObFZITx9zcPfKWHmSLxci3CL1X/OSbCHVSFj6ZyBZunMrpPIM9IUUyjkRawaqqgte/x6MZR2LFJZXkJR6Tn5P9sXs8A65F6q5oKBxvNVGBr/sHwwSZ9Omq65oa4oBY3yEA6ZC8mbstcaHtxHI9pyEVAhqNg5Vu4Bq0ZVh7lsjXIgc+KJPjObQurhDOqOxP5MCJhAN4gwalaaxmQ6Y8kdIlf1SlNrSJoGnOW7b/s9FTJkWKzSLJMZxTFuLHf+PVOA== 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=2l+SBVu4Yw1wPK/GWI5EmqDixlBCvjLIeuEFyPkIvxY=; b=YvCSTAaBRw5aJKmXhJsCN58MpZhLk7PWiHej6bG/6CHKWrIIbvZZnbbnRNWG/cfm+rsk9RMWCNxRN9UNLHOMYQSnXc26m1vxJh3HHFlB6SVClGZJij7vkDDW93D0t1div5jXhhliVg8ClUgQmwQsQg3fRPS7eS9ZE5rn9a/67KJMNLgb4Jiu5BqtTCnQ+vdipTlW65UAbVu/uanQww4BLI6QY/KMlrBZNX9nwWj8aAHbdmgFBLPvUDFbFDOcHK/sN+b799jnsxLGj3AoINv23nj4QdA64FK5fIOxIqvmEnF3GMxpnABxWK6bM3eKt4ZWvB+LTbBrnke43MYgCHhXEg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2l+SBVu4Yw1wPK/GWI5EmqDixlBCvjLIeuEFyPkIvxY=; b=0ATbaMNvRc6yTnNZbCKaLYIPwQJkXjFzeukcpWwLVl6edjGILzJC8skplaAfafxqZG2RWXejZDksUd7Id8rY6cMpgK46+9XkSXuyyqRguUIHF6m1qTxMyswCKCs+B0Aj9IC35BtNpshfc+Pe2WanmF+DR5KUT1RO6NAza7/zgj8= Received: from MW4PR03CA0038.namprd03.prod.outlook.com (2603:10b6:303:8e::13) by DM4PR12MB7503.namprd12.prod.outlook.com (2603:10b6:8:111::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 03:10:33 +0000 Received: from CO1NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::82) by MW4PR03CA0038.outlook.office365.com (2603:10b6:303:8e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 03:10:32 +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 (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 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT017.mail.protection.outlook.com (10.13.175.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 03:10:32 +0000 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; Tue, 10 Jan 2023 21:10:30 -0600 From: "Chang, Abner" To: CC: Hao A Wu , Ray Ni , "Garrett Kirkendall" , Abner Chang , Kuei-Hung Lin Subject: [PATCH V2 3/3] MdeModulePkg/XhciPei: Unlinked XhciPei memory block Date: Wed, 11 Jan 2023 11:10:08 +0800 Message-ID: <20230111031008.1476-3-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230111031008.1476-1-abner.chang@amd.com> References: <20230111031008.1476-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com 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: CO1NAM11FT017:EE_|DM4PR12MB7503:EE_ X-MS-Office365-Filtering-Correlation-Id: f9d3266e-13b3-4ac2-12ab-08daf38166c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T4c8VEP2kKU2oQf02EU9F1Yl8hJnfyoxRrD0EqjEBXqIiXEjtmw5FhDL+b2bMTKd8Ei0+8DgxixCNoQRXjHHqPbKQDggb6OiJK8p4lNbs/P6VjffnqU/0cZXqkkANYdLlx9OFTgirPxWlJ7K30zy7EtYyyLCBFgx27AkkXN9gOlvuqMyVS8LTHASuLukMq4mGX5clVaXw4tEVF/4izHGCzqKDoofm5EBhIpuFQuaZ8RY78nTqw1O6hT69ZmE2Ws4JatZx3kHBFxpNiSTclewAqTCmFMsu8I6wPp2xJeQkR+dieW+9l9/JW8Mer19kRu6rAhFGzH/XBreMlPvArM7v1N0zaLpdQF3HXP0vTYGwHw5deNt0YWupzA/IVYbk3BCyo26wVpuwYuBqjaY57ASKc8q0h4Up0AIizO4oeu0NlvcdtHk7yrKgCnD9tLqpCJdbidc5RNFF7r3hTCqcRef+WU/gdPuvJ9dlj+zxTsnxqikNma9yxg5a78WMuxDUPMjCokWmcv9MBTnKuIc0U5WGffwgMKFitlXf6N6S3kPqKgyZEnKlitzMPk13f5vo7Ux79PSflhXrFiiSYZ+HY0SICB+V27Q5p7JjZmKx1lDSRtsUQDMfUgpDGTjJL23txfjRB3xClba2JqNacWZCG4q0ds6T1OepkEmMsX9BoL6qkbhFbmG7VrqlC7MWiw51E9VFgthfBqrcgiLvyyPhNb6JAkbN64E/mSc0X/Gbcc6PRE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199015)(36840700001)(46966006)(40470700004)(426003)(36860700001)(86362001)(47076005)(83380400001)(2876002)(2906002)(81166007)(41300700001)(356005)(8936002)(5660300002)(82310400005)(82740400003)(316002)(40460700003)(40480700001)(6666004)(26005)(16526019)(2616005)(336012)(478600001)(70586007)(8676002)(19627235002)(70206006)(186003)(4326008)(7696005)(1076003)(54906003)(6916009)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 03:10:32.5109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9d3266e-13b3-4ac2-12ab-08daf38166c2 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: CO1NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7503 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang Unlink the XhciPei memory block when it has been freed. Signed-off-by: Jiangang He Cc: Hao A Wu Cc: Ray Ni Cc: Garrett Kirkendall Cc: Abner Chang Cc: Kuei-Hung Lin --- MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 31 +++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c b/MdeModulePkg/Bus/Pci= /XhciPei/UsbHcMem.c index c64b38fcfc8..e779a311388 100644 --- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c +++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPei= UsbControllerPpiGuid which is used to enable recovery function from USB Drivers. =20 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -365,6 +366,32 @@ UsbHcInitMemPool ( return Pool; } =20 +/** + Unlink the memory block from the pool's list. + + @param Head The block list head of the memory's pool. + @param BlockToUnlink The memory block to unlink. + +**/ +VOID +UsbHcUnlinkMemBlock ( + IN USBHC_MEM_BLOCK *Head, + IN USBHC_MEM_BLOCK *BlockToUnlink + ) +{ + USBHC_MEM_BLOCK *Block; + + ASSERT ((Head !=3D NULL) && (BlockToUnlink !=3D NULL)); + + for (Block =3D Head; Block !=3D NULL; Block =3D Block->Next) { + if (Block->Next =3D=3D BlockToUnlink) { + Block->Next =3D BlockToUnlink->Next; + BlockToUnlink->Next =3D NULL; + break; + } + } +} + /** Release the memory management pool. =20 @@ -386,7 +413,7 @@ UsbHcFreeMemPool ( // first block. // for (Block =3D Pool->Head->Next; Block !=3D NULL; Block =3D Pool->Head->= Next) { - // UsbHcUnlinkMemBlock (Pool->Head, Block); + UsbHcUnlinkMemBlock (Pool->Head, Block); UsbHcFreeMemBlock (Pool, Block); } =20 @@ -532,7 +559,7 @@ UsbHcFreeMem ( // Release the current memory block if it is empty and not the head // if ((Block !=3D Head) && UsbHcIsMemBlockEmpty (Block)) { - // UsbHcUnlinkMemBlock (Head, Block); + UsbHcUnlinkMemBlock (Head, Block); UsbHcFreeMemBlock (Pool, Block); } } --=20 2.37.1.windows.1