From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.7201.1587883434116040241 for ; Sat, 25 Apr 2020 23:43:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=sxJBIO2G; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: guomin.jiang@intel.com) IronPort-SDR: sun5VJSl9Q/I6uDh3KECg9IL2DvDLHD+WcdrURNBQMh93wlcUpq35iXQE3s4oxC11Gwj8b8kOJ bphDr61VJnkg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 23:43:53 -0700 IronPort-SDR: P1lictXyJ+jZFl724phuJPlnc0nlY7hvJeqKPsAPfznQFQnQintOceHR+fYsrpl/ipGi8O77Bb UYMHVcfWdr+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,319,1583222400"; d="scan'208";a="302029055" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by FMSMGA003.fm.intel.com with ESMTP; 25 Apr 2020 23:43:53 -0700 Received: from orsmsx126.amr.corp.intel.com (10.22.240.126) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 25 Apr 2020 23:43:53 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX126.amr.corp.intel.com (10.22.240.126) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 25 Apr 2020 23:43:53 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.175) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 25 Apr 2020 23:43:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kHlKy2tNegZi/qJG6R/TxihO8VTD6nfank4v9CLbfzelUlev3fzbbthSuA85gBjpIX6dthRXade0AFf+i5Guc7vO+sjK/jZr6/JHEaKJBs1j5pbzWLGUgQxiL3l0XD88hoSZgXvI7GhKqDV+NfCY5mYcZa2nsagt4Xj8TZQvpWWOIQ69R7nIK4BZ2ORHmRyq55fsebLhAixoZUUjwyhL0chRWp1FqTywVnIV7C2jhytdzmwU6xMMUYLdNGQHWFvRPo/LkyxNW1XQWuVJOcmJw5Ep816j/2kUw4VVMGuJn6gvkKWdxjKWHI6IPPLaQWNb1zBZDGNUj6IY59rlUG+DWg== 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-SenderADCheck; bh=uCOeV4oOtTqk0cDwZ8XKcczBGvfzPfK9r3FQpFL7ypI=; b=DGorfAQumQt2V+mLonfGPHAbTgrEq6v3IdxrO8309wHxzEaQYhPyxS/9wVBUL184i8ylt0rmlumlqx5TYWXSW4QGaJb/bVRAS5wlxeiZzXg2EnID064lr5tEB8Ia4bFdCCAQsPSzAZk0FQ04KTCFa/J64yE+bJCsmaxOruORdgSLfTEfW9PuUuQ6uICJ+knyE7fWAzJ4PfZPfr1/VIgE4I+RG57mH1q8Y2LMEqNQahF91ul1RQeQI0UqAMPYNH461r8quZjOrc2TuVXI0/oO/HaQiOrFNfecbgpnn2ull3WDV65xDqFfdbnt7OoqIdo8rLc6lZlii1UEfydggThIcA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uCOeV4oOtTqk0cDwZ8XKcczBGvfzPfK9r3FQpFL7ypI=; b=sxJBIO2GRos/DQROlmYbPqLIYJQyXfP+krhCA4VKsQQFJ+vapPg58tnc0PGE6zxJtg/uRtDrJ6M3M9v80IQCNeeJEyOoPnCCpq/d7S57so6vuZ31ZVJIbjtLA2S8odW7/ajt4etyV/w/6F06CqlkPTBgJJF8XaWI5bCe1/uKjQs= Received: from DM6PR11MB2955.namprd11.prod.outlook.com (20.177.217.95) by DM6PR11MB4489.namprd11.prod.outlook.com (52.132.251.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Sun, 26 Apr 2020 06:43:50 +0000 Received: from DM6PR11MB2955.namprd11.prod.outlook.com ([fe80::ccd4:4b0d:535a:58be]) by DM6PR11MB2955.namprd11.prod.outlook.com ([fe80::ccd4:4b0d:535a:58be%7]) with mapi id 15.20.2921.030; Sun, 26 Apr 2020 06:43:50 +0000 From: "Guomin Jiang" To: "Wu, Hao A" , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: Rebuild the description table after Reset Device Thread-Topic: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: Rebuild the description table after Reset Device Thread-Index: AQHWGqH+6oJcz8EY40K8DVzwoZo6F6iK2sQggAACMZCAAA8QEA== Date: Sun, 26 Apr 2020 06:43:50 +0000 Message-ID: References: <20200425013620.1159-1-guomin.jiang@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: spf=none (sender IP is ) smtp.mailfrom=guomin.jiang@intel.com; x-originating-ip: [134.191.221.109] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: acaa2ab6-7a03-453f-7e4a-08d7e9ad2dda x-ms-traffictypediagnostic: DM6PR11MB4489: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 03853D523D x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB2955.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(376002)(136003)(396003)(39850400004)(346002)(366004)(66476007)(66556008)(26005)(53546011)(64756008)(66946007)(6506007)(316002)(33656002)(71200400001)(110136005)(66446008)(52536014)(54906003)(966005)(76116006)(81156014)(9686003)(186003)(5660300002)(4326008)(8936002)(107886003)(8676002)(2906002)(7696005)(478600001)(55016002)(86362001)(19627235002);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Fp32ee76uT/0W+kpC1Ty4q9e0/LFsGQqh17jcoj6Xz3gqTNFGwJIBjohHS7NTHaseKPEYRN1OTLemhA86gFLMbGnETWDJKtkLoUmX+6vGOgWctwXGaZvBqsZRalfSyEbMlGG2NvkzNoITrEANx1BrXcZU0ISbKEqx1EHTB5RwG7e9FM8DLtQ5+BYFkqSbFxGnxvXUpQxakbDfvIqpeSWd5lISKepJhC2IcM+QsiifmZbAD9bffGIcStm09qtE3iIIWsCKtnKRuoanxQNBCRI8eGBw264YSc8EFr6DEn38SLNVzKRQFZjapJhMm9z6J7TXYQCKrdB7e2yLjqrGK6NuPihTURy5BJ/Ok5lDp7e62r+sqd4S+hNEtjcHvKEsKcumBwhqX97N2GuTo/DSGGEo4oIziP4u8ek5oP1iQY4JQ5gIqml0i8rM47B9rjCHU7OrRAHr2piT8CVUwEPsJv1tkNX9LobggJboqa5WvbxtFiu7bK2jgP+cp/svFPibHBfSAarXOlX1OnKIUyxSYzI/A== x-ms-exchange-antispam-messagedata: SFAtnZl+cuvGTjU7T0c5ktOSgU6XApHjUa4788ZnHNGAAvmDDWvA0KJcTk5B44JhIhaVX5z/taB0z2nq5h+63cXlDRTvzHTJ1ssJEc46AuDCiiSAjK7Q3omrSdMWqtf+FstjI9UGd2AGFYFrjcP+5TqPgqfCIZBAa1HPjQH5/VpAfzz19AHDayDUUmoPu4NJwGqOCiWT/Z2Y8plh6HONTFH2Her0Jun+GWpRhYCpfgMtAI2vzY2ELk4TuItQmMEj02Hw6QNJk3B9JkrnZXPJYdd8/+0P0Y7fn/MJ/pnGxVpDgWiHkJ8UcvfJ8EogvnhiMpGiUeHg6JNgDGO9UNGWXUKFEfRd/rv51jGeLCx1n5Qfs9Gy8OZGm+TGF/2MKK+amSXvhJ6MsqQevj4+S4cbQEZEEOPtdh++J/A2HRl4qsqTj724zYAxxoKPiz+qPVxF3GTOysILLvbR++SkXBv9j0ceQ+ih2S2awZu0i8hWi85qdRYU+5DVWjoqNiW/vMZfp8q+mfjp8skCJlrQPwUovKPt7ckE2Qagq5QhGfwiQy/7y2ELHZQ4WFVdLI2skBmu8hif/MJ4g8FYqwfPl9GKFUZHPETt27yi0EwtlYikRiXrcHKSMOdt7+md8MCQhRJ4ZVLuD+swanxsqSh1zhHIlPHFQJzNzbwXLlJjq0Q6S7dmE6KzkOa8BFd1ATQbvDLKaqXTMEf65ZmrDBpO91InCf5XAUFdthUYnUVCzJ7oZTkAx9u/beldygPVFqQy7uDrkWDV1pPl8RDjStQedhTJKrZkkk474P4780vVN9sh9gtY6sw+/Fs9TO2ZOvL+7CHe MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: acaa2ab6-7a03-453f-7e4a-08d7e9ad2dda X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2020 06:43:50.2203 (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: bXioHCaC9Nks88qgWn4xsOGM8y6vP4sX8OtfwsgH8BsmmbM8BZby6vRvxzl1KWT/uFDDmdj8wmQ1jiPMKrdxJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4489 Return-Path: guomin.jiang@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Hao, Add comments inline. > -----Original Message----- > From: Wu, Hao A > Sent: Sunday, April 26, 2020 1:12 PM > To: devel@edk2.groups.io; Wu, Hao A ; Jiang, Guomin > > Cc: Wang, Jian J ; Ni, Ray > Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: Rebuild the > description table after Reset Device >=20 > > -----Original Message----- > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > > Wu, Hao A > > Sent: Sunday, April 26, 2020 1:10 PM > > To: Jiang, Guomin; devel@edk2.groups.io > > Cc: Wang, Jian J; Ni, Ray > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: Rebuild > the > > description table after Reset Device > > > > > -----Original Message----- > > > From: Jiang, Guomin > > > Sent: Saturday, April 25, 2020 9:36 AM > > > To: devel@edk2.groups.io > > > Cc: Wang, Jian J; Wu, Hao A; Ni, Ray > > > Subject: [PATCH] MdeModulePkg/UsbBusDxe: Rebuild the description > > > table after Reset Device > > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2694 > > > > > > When the USB fail and then Reset Device, it should rebuild descripti= on. > > > > > > Signed-off-by: Guomin Jiang > > > Cc: Jian J Wang > > > Cc: Hao A Wu > > > Cc: Ray Ni > > > --- > > > MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c > > > b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c > > > index 4b4915c019..9f2d2cc87f 100644 > > > --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c > > > +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c > > > @@ -869,6 +869,11 @@ UsbIoPortReset ( > > > > > > > > > DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at > > > %d\n", Dev->Address)); > > > > > > > > > > > > + // > > > > > > + // The description will be invalid after reset, should rebuild it= as well. > > > > > > + // > > > > > > + UsbBuildDescTable (Dev); > > > > > > Hello Guomin, > > > > Thanks for the proposed patch. > > > > Could you help to explain in more detail for the above fix with regard > > to the transfer ring not being set properly in the XHCI driver? Thanks= . When I debug, I dump the below data structure and found that before UsbMas= sReset, the corresponding slot transfer ring is normal and invalid after Us= bMassReset. USB_DEV_CONTEXT =3D 0x148 +0x0 Enabled +0x1 SlotId +0x4 RouteString +0x8 ParentRouteString +0xC XhciDevAddr +0xD BusDevAddr +0x10 InputContext +0x18 OutputContext +0x20 EndpointTransferRing[31] +0x118 DevDesc +0x130 ConfDesc +0x138 ActiveConfiguration +0x140 ActiveAlternateSetting Before UsbMassReset 000002D0: -01 01 00 00 00 00 10= 10 000002E0: 00 00 00 00 01 01 00 00-80 02 FA 06 00 00 00 00 000002F0: C0 16 FA 06 00 00 00 00-98 27 FC 06 00 00 00 00 00000300: 00 00 00 00 00 00 00 00-98 26 FC 06 00 00 00 00 00000310: 98 BE F9 06 00 00 00 00-00 00 00 00 00 00 00 00 00000320: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000330: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000340: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000350: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000360: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000370: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000380: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000390: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003A0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003B0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003C0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003D0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003E0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003F0: 12 01 00 03 00 00 00 09-F4 46 01 00 00 00 01 02 00000400: 03 01 00 00 00 00 00 00-98 CD F9 06 00 00 00 00 00000410: 01 00 00 00 00 00 00 00-18 24 FC 06 00 00 00 00 After UsbMassReset 000002D0: -01 01 00 00 00 00 10 = 10 000002E0: 00 00 00 00 01 01 00 00-80 02 FA 06 00 00 00 00 000002F0: C0 16 FA 06 00 00 00 00-00 00 00 00 00 00 00 00 00000300: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000310: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000320: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000330: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000340: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000350: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000360: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000370: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000380: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00000390: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003A0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003B0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003C0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003D0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003E0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 000003F0: 12 01 00 03 00 00 00 09-F4 46 01 00 00 00 01 02 00000400: 03 01 00 00 00 00 00 00-98 CD F9 06 00 00 00 00 00000410: 01 00 00 00 00 00 00 00-18 24 FC 06 00 00 00 00 After Reset Finished, it will try to get data again by sending command to = Usb Mass Device and it will use USB_DEV_CONTEXT. EndpointTransferRing[4]. But it haven't been initialized after reset, and ASSERT will trigger when = access the USB_DEV_CONTEXT. EndpointTransferRing and will show ASSERT c:\users\guominji\dcg10nm\edk2\MdeModulePkg\Bus\Pci\XhciDxe\XhciSch= ed.c(1909): TrsRing !=3D ((void *) 0) The EndpointTranferRing should be initialized by UsbBuildDescTable() but s= eem that it is omitted in Reset branch, so I add it. > > > > Also, judging from the function description comments in > UsbBuildDescTable(): > > |> /** > > |> Build the whole array of descriptors. This function must > > |> be called after UsbGetMaxPacketSize0 returns the max packet > > |> size correctly for endpoint 0. > > |> ... > > |> **/ > > |> EFI_STATUS > > |> UsbBuildDescTable ( > > |> IN USB_DEVICE *UsbDev > > |> ) > > > > Does function UsbGetMaxPacketSize0() need to be called before > > UsbBuildDescTable() in the proposed fix? I ignored it and will double check it. >=20 >=20 > One more thing, could you help to add the information for what tests hav= e > been done for the proposed patch as well? >=20 > Thanks in advance. > Have test OVMF and test pass, detail as below I use qemu-w64-2020020, you should install it first and add it to PATH env= ironment, the procedure as below 1. Import the test patch from https://bugzilla.tianocore.org/attachment.cg= i?id=3D508 2. type ```build -p OvmfPkg\OvmfPkgX64.dsc -b DEBUG -a X64``` to generate = OVMF.fd 3. type ```qemu-img create file.img 1G``` to create test image. 4. type ```qemu-system-x86_64 -bios OVMF.fd -drive if=3Dnone,id=3Dstick,fi= le=3Dfile.img -device nec-usb-xhci,id=3Dxhci, -device usb-storage,bus=3Dxhc= i.0,drive=3Dstick -global isa-debugcon.iobase=3D0x402 -debugcon file:xhci.l= og``` 5. you will see hang currently and will see ASSERT when check xhci.log. 6. import proposal patch, the symptom disappear. =20 >=20 > > > > Best Regards, > > Hao Wu > > > > > > > > > > + > > > > > > // > > > > > > // Reset the current active configure, after this device > > > > > > // is in CONFIGURED state. > > > > > > -- > > > 2.25.1.windows.1 > > > > > >=20 >=20