From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.49]) by mx.groups.io with SMTP id smtpd.web11.626.1688749650932129752 for ; Fri, 07 Jul 2023 10:07:31 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=4V/XYYDD; 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.243.49, mailfrom: brit.chesley@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3zMeT3c8MEWzZ1LndBxS7+DIiMcAuziGdPxvZCD3zqdAubDqm81xGA2d/0Wm2ikBnLLMdM0S11Q7eV13OeiPUWoz4fHfw210tqoMhmgW63XCy4P1HG80QZN/0epNNtSX6VUplGinA8Eok/lltEfE6t0ceEmm4Yb7qMdmOLtQfdbv5IRd6VxOzmo42se8QFje0HQvLFvZOobH+OFRiDSuzq3QNr5dhlKCCPef/r7DI4+Bx1EyPIqEJtKZvVF6oNYFNj72+/DwWCn8+Y/ftI5Z7MSRb9H7LiXm9GUFkPm835B6OxUTFsekJQfsmDqHW/nZFjAiBf1am54Usdx398/Pw== 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=AFPr+1TuWnSoNkLRhmR8V7qxzu2qhND4tH8iwBLAins=; b=TDJKndAeaGzl2rMdaRa2f0WXRs68hgb90c/6+0Uqpuj92msWRNIHRIeVA38PLte/c+BQQl46ew+D75/2mL8zIBl/u3GRQPsN0vcwEO8VO6Vb9PdwOb31fUxuvxxTKFmEw1wICf/XyWePcev7tu7X0N0TzKITFbubfVinjc8t/8XPYwx9lXtZXVihDc8ChauHtgy1G3PwcsOIa/4imA5L5oTjthL/Wtq6bPcuX8JFLTo1ER8KgfmbTvJdXOqw1SaHgLYwlkd3MftJ+GpoWOVxdSZRMxVE3QwCujiYvcwCU7ZnTu3vjOREKXa/uxKtaySgBctZWFDQjP5FmQIYOMxISg== 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=AFPr+1TuWnSoNkLRhmR8V7qxzu2qhND4tH8iwBLAins=; b=4V/XYYDDowfBwiQUeXhQ5kKTcWtXbhfcHmv3soLTHLcF3E/NxJuooYBg0ljIp5GcHp+WuMjwwjE1IADeRhLPeZ/OKq2GjURAkmEZFQ+svPS63J05SoP+PnTihlymgY1hjpCTBBY1CcXcsDhXU6qPbjuIUPkEvVmsE91w+83iDmI= Received: from BYAPR05CA0047.namprd05.prod.outlook.com (2603:10b6:a03:74::24) by IA0PR12MB8893.namprd12.prod.outlook.com (2603:10b6:208:484::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 7 Jul 2023 17:07:28 +0000 Received: from CO1NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:74:cafe::fc) by BYAPR05CA0047.outlook.office365.com (2603:10b6:a03:74::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.13 via Frontend Transport; Fri, 7 Jul 2023 17:07:28 +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 CO1NAM11FT029.mail.protection.outlook.com (10.13.174.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.45 via Frontend Transport; Fri, 7 Jul 2023 17:07:27 +0000 Received: from aus-g8-bchesley.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.2507.23; Fri, 7 Jul 2023 12:07:25 -0500 From: brit.chesley@amd.com To: CC: Jian J Wang , Liming Gao , Hao A Wu , Ray Ni , Abner Chang Subject: [PATCH v2 1/1] MdeModulePkg: UsbBusDxe: Rebuild Descriptor Table Date: Fri, 7 Jul 2023 12:07:09 -0500 Message-ID: <20230707170709.45-1-brit.chesley@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Return-Path: Brit.Chesley@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT029:EE_|IA0PR12MB8893:EE_ X-MS-Office365-Filtering-Correlation-Id: 77bba211-54e1-4917-1cb8-08db7f0ca49a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CtyXxKqPftaVegXIoS3LZ52m9OqWi/WhpuHPLK04O2y0MxenMXi3NAjd12t2qyM88UFC1u76aOBgMpXWlDa6g981f1LNHUfkfT3I3+gZMqxdLxOj/D98uoWS+BWkC6O/k3s8EAUwSEHZG+iW1DpiJrzpqCEsYcxcjUr6dV4rPo5NBlB/9CNBuyuU90h2oiDTci4rO3Lbjc8gFJk9pWjEhRFIH6ZjIndOJdQF3st3+O/G4yylH4oIYn6G6JeONTMuJS1FF1rZbXyWuNoiMQVx6r4nPCq+pmtrA9x05Ci4AtzbsI2+OmhlPtP+nGSQJMB5YolKEO6nb4gQQ4ZvPquAGjThdSKUpCjDhRhjffyQJ4nkkAbl8fzaNcNGVc3iMhw1B6qNJ83ulc30iTpdc2IycBvnnvHTGWgjsACC3g/ebGFTif7cJGdNh2OBDaoNqxBC9jAPfnbbfei0BJNfwSs4IRbHYHhode6mnIrAjvhl7C3jCUxo4XZ4bHPE1A97K+HlOD1KsnljmmHxag9rPbdRW372y6fyQ22UqdNYLSMZjBGkZyU0AcW3dTS/OH+1Cdm/HHvfDjmuBPawF6DVtwv3a5Hb+z+RDurJpzo0mAUxXuDQ+zsbtgBnUYNRDUpoP8uEEXGVeUZiIzuUjiIicVPXF21AYw1/27zJhywb/C/IJhp75Pi9JTytYdnW6Mul4YNuTz2+Nm6cqMZv37Jzrt2cRUhlmKo6ScfIKlT5SDXC5S2cIZ3hSclWHLqaDKDvXwxDiKXmAzfmu7Crf09UC01KaA== 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:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(36756003)(40480700001)(40460700003)(7696005)(356005)(81166007)(82740400003)(1076003)(16526019)(186003)(26005)(19627235002)(316002)(4326008)(70206006)(70586007)(6916009)(478600001)(6666004)(54906003)(47076005)(36860700001)(2616005)(426003)(336012)(2876002)(2906002)(83380400001)(86362001)(8936002)(8676002)(5660300002)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2023 17:07:27.9549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77bba211-54e1-4917-1cb8-08db7f0ca49a 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: CO1NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8893 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Britton Chesley Fixed a bug which led to an ASSERT due to the USB device context being maintained after a port reset, but the underlying XHCI context was uninitialized. Specifically, Xhc->UsbDevContext is freed after a reset and only re-allocates the default [0] enpoint transfer ring. Added build de= scriptor table call in UsbIoPortReset. BZ 4456 Cc: Jian J Wang Cc: Liming Gao Cc: Hao A Wu Cc: Ray Ni Cc: Abner Chang Signed-off-by: Britton Chesley --- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb= /UsbBusDxe/UsbBus.c index c25f3cc2f279..a5b798bd8d6c 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c @@ -821,6 +821,7 @@ UsbIoPortReset ( EFI_TPL OldTpl; EFI_STATUS Status; UINT8 DevAddress; + UINT8 Config; =20 OldTpl =3D gBS->RaiseTPL (USB_BUS_TPL); =20 @@ -882,8 +883,26 @@ UsbIoPortReset ( // is in CONFIGURED state. // if (Dev->ActiveConfig !=3D NULL) { - Status =3D UsbSetConfig (Dev, Dev->ActiveConfig->Desc.ConfigurationVal= ue); + UsbFreeDevDesc (Dev->DevDesc); =20 + Status =3D UsbRemoveConfig (Dev); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to remove configuration= - %r\n", Status)); + } + + Status =3D UsbGetMaxPacketSize0 (Dev); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to get max packet size = - %r\n", Status)); + } + + Status =3D UsbBuildDescTable (Dev); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to build descriptor tab= le - %r\n", Status)); + } + + Config =3D Dev->DevDesc->Configs[0]->Desc.ConfigurationValue; + + Status =3D UsbSetConfig (Dev, Config); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -892,6 +911,11 @@ UsbIoPortReset ( Status )); } + + Status =3D UsbSelectConfig (Dev, Config); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to set configuration - = %r\n", Status)); + } } =20 ON_EXIT: --=20 2.36.1