From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.83]) by mx.groups.io with SMTP id smtpd.web11.38806.1671496068571395939 for ; Mon, 19 Dec 2022 16:27:49 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=ZYgdm+MS; 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.92.83, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfxXl5z0akFRJacR/TTLrODqvoqvQgKFROXr5HQZW7mWnnj+dm0wOVeoOqXLwFz99FeGWLoNmc6BI5kqKknodHZnnwlvRx0LFiW+TbF7kQ51oHNwRsw02Yatv4Z/SFmGos3IgotzdpFza2eJNdZqMqUiB7mV0xmiB6oCXtl7MkBp3dwrFPMEOm2Fwl+rjKnDIcsEbCxvmKCLpOwoqVtokmgRqeCzrJtGx4lq4zFH2HNzEDgFIikyVlBPQ++SCtlt/rYOgLdJ9WpYIXXeLlsVrhSl2R+0mMBkfNS7PLNgrtr9pctPpScDGOsK/vzj4e5VSYUTa3Xa/SznMvg3ZPFlww== 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=yiIz39zTePlk42AyZsH2kHPte43ITwIgax/IkvXqFrA=; b=dGVGD/9VBvziUDtElZW3qxPbnCrmkklLvD75Spg9YF4LmblmjVMHfISZpGGEvmFJq3g6jD8wWZDmKgl9sEyFtsVrv/XElSWcrHQs3HWF7n4l1sGrjD8t9yVvQGVEQXta5hs4gSSuaIqQbUD2EzNiBUy2BciwfP65Jv6YlWjkoHqBem7xcqK5kkBVpwp+TXDvSM3AJ3ETCTZKM3EQK0cQedNV3ZQbk+Jx0Ee/JjXEkgAZhRqAB4kE49uWFpREd1Gz9aaMmYIsiNbUgHRcotyUJonXBTITN1W/ukdkvfJ4tOyGeD8TLP4gEQ1oqiCDP58nXYjjkp3REI88gDZ2JZp0EA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=yiIz39zTePlk42AyZsH2kHPte43ITwIgax/IkvXqFrA=; b=ZYgdm+MSwtQ2nA3xMLm90594okp50HExvhKxwegk489EyEC/N0kwIcgR/94BH4ftp5ijSWBxGr0MNAReqMqkLFpKfayXYR9iFdsZdHZYneDWQSQpcalS87Q4ddf0vXdQ3zTB0sX6twXEYTml70UoZePOxsI3FnpNChjfGBtkBfY= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by MN2PR12MB4552.namprd12.prod.outlook.com (2603:10b6:208:24f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Tue, 20 Dec 2022 00:27:46 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::cddb:3de9:cd1d:26e4]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::cddb:3de9:cd1d:26e4%5]) with mapi id 15.20.5924.016; Tue, 20 Dec 2022 00:27:46 +0000 From: "Chang, Abner" To: "Wu, Hao A" , "He, Jiangang" , "devel@edk2.groups.io" CC: "Lin, Kuei-Hung (Timothy)" , "Ni, Ray" , "Zeng, Star" , "Sun, Zhikai" , "Kirkendall, Garrett" Subject: Re: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block Thread-Topic: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block Thread-Index: AQHZDKno0DYnXuJIl0m31zK+lceR8a5pmfcAgASf6dCAAPSyIIAFoY+AgAEJJdCAACDegIAAACVw Date: Tue, 20 Dec 2022 00:27:45 +0000 Message-ID: References: <20221210151240.1548-1-abner.chang@amd.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-12-20T00:27:43Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=13f395c6-8b4a-4a08-a765-b6541ce91967; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|MN2PR12MB4552:EE_ x-ms-office365-filtering-correlation-id: f62f4145-370f-4f10-3b8f-08dae221044f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: syXBaJyYNboLYY9CrbyFewpx+Q3HyNEG8VPJ8hQ1scZ00CN4l5g/anjIbjNqInPed4R4Fgtb6rHmAv0uOwqTu+BVg2sYx3xw0a19cqw22IBBcmJsyPydDLYHKq6bOs2Iy8tY6ptAlk/Q8o7AHtUjsarGivMrC9qF11SpLOk2xDptqDzyIjQtaYgoD6hDY5KyAzIBHwB1uwSnK/qiAYylBaoxD+zhqhBE+HB0UR2001kFyJ41QWWoa5Xf9/VhgAy0tCBhU15zZdReuYP1WNlDMd6JZidIABcDQDoq/hvUzGPYmfW7+mvQ95C6oAh9zUmok4749d99iNOS6OOcU1vdLdVZ/Cu/IfsKbPvtoBypwn/HOlEKh6Qg0O8pmRYWcn1JMYFl9HbOMYKvkrdT5EgCxBeNz1j5v8J6CvKAaPthO5HVAoYtDYgqB3b85nVk3LbJb8abnEeIrEkFZBpPvV/K6f03p5aHFDQ0mPOB6y6KE8XBDGjZB/3Gj0VTswD1dmeD3P0VX8oFXZzpq2L2Wn9fN9rH6ZrKuPvSyMvs+uihQ9XluEnOMSrDrBmx1M0fMcPU2+bVYr8QdABcXH0yKehBGzZpZmCau3cwF8e95rfYmeU5nVB2pFxunaEQAcy7d5AK5Xn9vc17amtuPW1M6SJNr5TTzUOYfCjqpJhSfcH+2zS3+ijHHzHHgE3nj2uCdlTE/uxxrPC6zgBDWyycNFVnnA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(396003)(376002)(346002)(39860400002)(136003)(451199015)(66476007)(9686003)(26005)(478600001)(186003)(4326008)(71200400001)(45080400002)(33656002)(8676002)(52536014)(41300700001)(2906002)(86362001)(55016003)(66946007)(30864003)(5660300002)(8936002)(76116006)(64756008)(66556008)(66446008)(316002)(6506007)(966005)(53546011)(19627235002)(122000001)(110136005)(83380400001)(54906003)(7696005)(38100700002)(38070700005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?4AeZh+O9hf2hFwWrYtaCn1T6kG8nvSHoaBx2C07On52covlqGryGqXM+Ocox?= =?us-ascii?Q?u0csYQu5xvNjZgGPEm/nJhCSjBa2LKtOBlAwld2vNRN7/oAd15n//zSxuve7?= =?us-ascii?Q?a+XC1cdZINcPJPWvPGWAuEYD9IFyANqr/ZV/dgCk3GhjG8dMfymKOyieIsw5?= =?us-ascii?Q?7PWKTu2Gd6xMoGUDS8wCqFKAkKPCc6Bh+e5Q4fYfs0IH+r+ilM86ob+j4NUG?= =?us-ascii?Q?qZmdSqCMrJBrJHiKUp2d3YOFPh2A+dJywY17VzwqpWoDsxamq0cf/GXEcmJi?= =?us-ascii?Q?lkFuIuwSRwZUoahYa1tL7qZS/4uDvUTMiAyWkKMLAXjmrwOHNkotXb4Ej01L?= =?us-ascii?Q?MDvXpbFd3MUAHkj+FmRPmS3OxELfA9cWPZXNwpaoP9tpIdSpUSOzvkq81vwi?= =?us-ascii?Q?CF+2sh8Epbj+ZuyDUsD4gnVtFIRO+mNHDoM9LoD6rd0iOQ9Ig50Mt/jBStZP?= =?us-ascii?Q?pbEpBdQCLMlwaWIVmXn7od4O8vXOb0FLK7BrF7VvdeNO/s6r8mRGUGG2f3bC?= =?us-ascii?Q?H3D29ROGNgPvuiXP5O570k9wsEC7nOnWjU4lzTgNq2is0Wj7W0Q+y1b7s06e?= =?us-ascii?Q?9OF0BKY8vun9MuIQxTSISECepc04sOhYrsnB50qbMpaFP7BtomVgq7pXg+Wa?= =?us-ascii?Q?cDFxCKtM2RYHXovdYJ6TsZU99Ne/57XdwreMJrqxVGWKlsvH/4e7JLgYhvHS?= =?us-ascii?Q?BNXyk+MZtQ42ov/guNLMWBu4DG/ON056yhgApBNcx8R5s0MjIu0/5/lKDEvM?= =?us-ascii?Q?hphZOhsjCra0ptodx50S8VJjWPmoAqLapb4v7ifzhp5HOMBbqy3M7nGl5VY4?= =?us-ascii?Q?bEgvoidI7tJGevqrXhsnYJcsaJvf/zKSsJvdB+hg6EHT/wdCXbsKRhGk3QRG?= =?us-ascii?Q?d8PV847yY4SMwWMrkvKiyUXf3HHu7tJ6rP63uFfVdom58d9pp8vhafWxTBUs?= =?us-ascii?Q?3kE8IAXZHiretXI4Vxv118mzXRQlfel/NHIVf6+cvyrKcm4l8aw7q/q8yG8r?= =?us-ascii?Q?IYtWS7toSe+vMpysf0sGJMmyXApx7sx4XjVKK8NyVfISm5rTxTqcam/5UHFk?= =?us-ascii?Q?W8ibmRMGYVe2QO/Gfg8H61BEzJEEn3CBehCrfPnhlhFZB+2E4jvbZk0h/+13?= =?us-ascii?Q?r+UxtVhcA74dZyzB6WxIfTho5wDv1+FWvLQEPwuGdymha7XetjDOcvw3X8n7?= =?us-ascii?Q?Dx8OGZtGhgLLXKZkfX0VJZNy3fLIal5PafWRudUcfbCBPHpB3R/GKkXuC47j?= =?us-ascii?Q?hXch/Cn0dsVV3jYzYL006SXAHM/CCJp/CXNpgQKVEo/yvR+fQG+Owx78o0RB?= =?us-ascii?Q?2RGC6cKjKKoK7YwIP2m9LgT2w3rgg7LMui5xQbG5wTxm7ftURRAoJmzO4fub?= =?us-ascii?Q?2tNmM6JJoHCKEy/lmzS8KPxm/lSLDYfj3iffnk5vRKIMAxK5zABbAqMwRgcv?= =?us-ascii?Q?ZT8ZOvhSFlevE+L+XhG+YtkBB4805jIMkCGW7cxk7EtCwjzrOxLQwej1sLoJ?= =?us-ascii?Q?dpFoNq6ZAE0kqz0qya5bt48uykXngUc9+7Ibpw3ppC3juHHO1ry9KlT8MiEA?= =?us-ascii?Q?jrnS3QcgYYc2HtAXOYZUmqF9IDe0CXH/oC0Lq7Vc?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f62f4145-370f-4f10-3b8f-08dae221044f X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2022 00:27:46.0133 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jvJQ+CYyNJ7or6u0fb1jbkBbgDPxjOwZ9/XpZturpF36q+CN/FoFiN8Gm/Yw4PCPJLmcabkoxiYC3BA5P9hPwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4552 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] I will send the update according to the discussion. Thanks Abner > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, December 20, 2022 8:27 AM > To: He, Jiangang ; Chang, Abner > ; devel@edk2.groups.io > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > ; Zeng, Star ; Sun, Zhikai > ; Kirkendall, Garrett > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory > block >=20 > [AMD Official Use Only - General] >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > Thanks. > You are right. I agree with you that aligning with XhciDxe is a better re= solution. >=20 > Best Regards, > Hao Wu >=20 > > -----Original Message----- > > From: He, Jiangang > > Sent: Tuesday, December 20, 2022 6:54 AM > > To: Wu, Hao A ; Chang, Abner > > ; devel@edk2.groups.io > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > > ; Zeng, Star ; Sun, Zhikai > > ; Kirkendall, Garrett > > > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei > memory > > block > > > > [AMD Official Use Only - General] > > > > UsbHcFreeMemBlock()->IoMmuFreeBuffer()->mIoMmu->FreeBuffer(), > which > > may end up calling PeiFreePages() depending on gEdkiiIoMmuPpiGuid > > implementation. Surely both will work since UsbHcFreeMemPool() can't > > be interrupted by any service call to use the memory just freed. Just > > for good coding practice reason, I pick the one aligning with XhciDxe. > > > > Thanks, > > Jiangang > > -----Original Message----- > > From: Wu, Hao A > > Sent: Monday, December 19, 2022 12:40 AM > > To: He, Jiangang ; Chang, Abner > > ; devel@edk2.groups.io > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > > ; Zeng, Star ; Sun, Zhikai > > ; Kirkendall, Garrett > > > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei > memory > > block > > > > [AMD Official Use Only - General] > > > > Caution: This message originated from an External Source. Use proper > > caution when opening attachments, clicking links, or responding. > > > > > > Hello, > > > > My take is that unlike in DXE, the UsbHcFreeMemBlock() implementation > > in PEI phase does not perform freeing the memory. > > > > So I think both the solution: > > * Provided at > > > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fedk > 2 > > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165&data=3D05%7C01% > 7 > > CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3d > > d8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126779782%7C > > > Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB > T > > > iI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3DuJMNyYXMU22 > > UZNjrKtDetyD2BqrvkualuorPZHAV3wg%3D&reserved=3D0, which aligns with > > EhciPei > > * Mentioned at the end of your previous reply, which aligns with > > XhciDxe should work fine. > > > > I will leave it to you for the final decision. > > > > Best Regards, > > Hao Wu > > > > > -----Original Message----- > > > From: He, Jiangang > > > Sent: Friday, December 16, 2022 12:48 AM > > > To: Chang, Abner ; Wu, Hao A > > > ; devel@edk2.groups.io > > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > > > ; Zeng, Star ; Sun, Zhikai > > > ; Kirkendall, Garrett > > > > > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei > > > memory block > > > > > > [AMD Official Use Only - General] > > > > > > Yes, it is the same issue discussed in > > > > > > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fedk > 2 > > > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165&data=3D05%7C01 > > %7CJiang > > > > > ang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3dd8961f > > e4884e60 > > > > > 8e11a82d994e183d%7C0%7C0%7C638070288126936018%7CUnknown%7CT > > WFpbGZsb3d8 > > > > > > eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3 > > D%7C3 > > > > > > 000%7C%7C%7C&sdata=3D58j41QJxKbrQenhyZKYO4dxYj3Sat2kJejQGioZhtu4% > 3 > > D&rese > > > rved=3D0 > > > > > > MdeModulePkg\Bus\Pci\XhciPei\UsbHcMem.c > > > > > > for (Block =3D Pool->Head->Next; Block !=3D NULL; Block =3D Pool->H= ead- > >Next) { > > > // UsbHcUnlinkMemBlock (Pool->Head, Block); > > > UsbHcFreeMemBlock (Pool, Block); > > > } > > > Block =3D Pool->Head->Next never change without calling > > > UsbHcUnlinkMemBlock (Pool->Head, Block), therefore dead loop. > > > > > > Our proposed fix came from dxe version of the equivalent file > > > MdeModulePkg\Bus\Pci\XhciDxe\UsbHcMem.c but swapped two > routine > > call > > > order (Now I think it is incorrect as clarified below). > > > for (Block =3D Pool->Head->Next; Block !=3D NULL; Block =3D Pool->H= ead- > >Next) { > > > UsbHcFreeMemBlock (Pool, Block); > > > UsbHcUnlinkMemBlock (Pool->Head, Block); > > > } > > > > > > > > > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fedk > 2 > > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165&data=3D05%7C01% > 7 > > CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3d > > d8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126936018%7C > > > Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB > T > > > iI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3D58j41QJxKbrQen > > hyZKYO4dxYj3Sat2kJejQGioZhtu4%3D&reserved=3D0 proposed fix: > > > > > > for (Block =3D Pool->Head->Next; Block !=3D NULL; Block =3D Block -= >Next) { > > > // UsbHcUnlinkMemBlock (Pool->Head, Block); > > > UsbHcFreeMemBlock (Pool, Block); > > > } > > > > > > I think it again, both proposals have problem of reading memory > > > content in the buffer that has just been freed. > > > > > > for (Block =3D Pool->Head->Next; Block !=3D NULL; Block =3D Pool->H= ead- > >Next) { > > > UsbHcUnlinkMemBlock (Pool->Head, Block); > > > UsbHcFreeMemBlock (Pool, Block); > > > } > > > is right solution and matches dxe version of UsbHcMem.c. > > > > > > Thanks, > > > Jiangang > > > > > > -----Original Message----- > > > From: Chang, Abner > > > Sent: Wednesday, December 14, 2022 8:12 PM > > > To: Wu, Hao A ; devel@edk2.groups.io > > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > > > ; Zeng, Star ; Sun, Zhikai > > > ; Kirkendall, Garrett > > > ; He, Jiangang > > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei > > > memory block > > > > > > [AMD Official Use Only - General] > > > > > > Hi Jiangang, > > > Could you please provide the context of this patch? > > > > > > Thanks > > > Abner > > > > > > > -----Original Message----- > > > > From: Wu, Hao A > > > > Sent: Monday, December 12, 2022 11:27 AM > > > > To: Chang, Abner ; devel@edk2.groups.io > > > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > > > > ; Zeng, Star ; Sun, Zhikai > > > > ; Kirkendall, Garrett > > > > > > > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei > > > > memory block > > > > > > > > Caution: This message originated from an External Source. Use > > > > proper caution when opening attachments, clicking links, or respond= ing. > > > > > > > > > > > > Sorry for a question, may I know what issue was met that leads to > > > > the proposed patch? > > > > Could you help to check if it is related with the topic discussed > > > > in > > > > > > > > > > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fedk > 2 > > > > .gr > > > > > > > > oups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165&data=3D05%7C0 > > > 1%7 > > > > > > > > > Cabner.chang%40amd.com%7Ccac49c2820e741b8c48a08dadbf0cc24%7C3d > > > d8 > > > > > > > 961fe4884e608e11a82d994e183d%7C0%7C0%7C638064124512265992%7C > > > Unk > > > > > > > > > > nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6I > > > k1h > > > > > > > > > > aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3Dz1Q7NRxN4GMA > > > %2 > > > > FBxYd2D7Gnkc3aTD23mRnwNF3H5wE0k%3D&reserved=3D0? Thanks > > in > > > advance. > > > > > > > > Best Regards, > > > > Hao Wu > > > > > > > > > -----Original Message----- > > > > > From: abner.chang@amd.com > > > > > Sent: Saturday, December 10, 2022 11:13 PM > > > > > To: devel@edk2.groups.io > > > > > Cc: Kuei-Hung.Lin@amd.com; Wu, Hao A ; Ni, > > Ray > > > > > ; Garrett Kirkendall > > > > > ; Abner Chang > > > > > > Subject: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei > > > > > memory block > > > > > > > > > > From: Abner Chang > > > > > > > > > > In V2: Add AMD copyright. > > > > > > > > > > Unlink the XhciPei memory block when it has been freed. > > > > > > > > > > Signed-off-by: Kuei-Hung Lin > > > > > Cc: Hao A Wu > > > > > Cc: Ray Ni > > > > > Cc: Garrett Kirkendall > > > > > Cc: Abner Chang > > > > > --- > > > > > MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 29 > > > > > ++++++++++++++++++++++++- > > > > > 1 file changed, 28 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > > > > > b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > > > > > index c64b38fcfc8..39ba31b0913 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 gPeiUsbControllerPpiGuid which is used to enable recovery > > > > > function from USB Drivers. > > > > > > > > > > Copyright (c) 2014 - 2016, Intel Corporation. All rights > > > > > reserved.
> > > > > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights > > > > > +reserved.
> > > > > > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > @@ -365,6 +366,32 @@ UsbHcInitMemPool ( > > > > > return Pool; > > > > > } > > > > > > > > > > +/** > > > > > + Unlink the memory block from the pool's list. > > > > > + > > > > > + @param Head The block list head of the memory's poo= l. > > > > > + @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. > > > > > > > > > > @@ -386,8 +413,8 @@ UsbHcFreeMemPool ( > > > > > // first block. > > > > > // > > > > > for (Block =3D Pool->Head->Next; Block !=3D NULL; Block =3D > > > > > Pool->Head->Next) { > > > > > - // UsbHcUnlinkMemBlock (Pool->Head, Block); > > > > > UsbHcFreeMemBlock (Pool, Block); > > > > > + UsbHcUnlinkMemBlock (Pool->Head, Block); > > > > > } > > > > > > > > > > UsbHcFreeMemBlock (Pool, Pool->Head); > > > > > -- > > > > > 2.37.1.windows.1