From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.2694.1588036505903704948 for ; Mon, 27 Apr 2020 18:15:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=xmNODuMW; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: guomin.jiang@intel.com) IronPort-SDR: LUGVyW7Z52PWZV+ItE/batJH7z65LMaYCeOAW+Y1O9+FyDS81mhFzzAnZY4u2gm0nDjnELkJ9x AP5PlbBqeqsg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 18:15:04 -0700 IronPort-SDR: zGgagcBk2FetujUPYfT2W8zJ2DFXlcsqgid1pFfVRa3fdaUoQjwOR+6QEb7MVzcPYBlmRrlRgY vdYqJrOMQnag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,325,1583222400"; d="scan'208";a="336478699" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 27 Apr 2020 18:15:02 -0700 Received: from fmsmsx162.amr.corp.intel.com (10.18.125.71) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Apr 2020 18:14:46 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx162.amr.corp.intel.com (10.18.125.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Apr 2020 18:14:46 -0700 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.52) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Apr 2020 18:14:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BLCl5+s9JL9Lvz547TXpnDrn9fC3Y1FP8avguUoV6YHoav2tFihGtdA92i8G5JW05gzi4lwNBvXHW3WbmAlpx3lYl1g1C3iv3mxXedrY3J2xjRwDAQx/Tq9voBJOf5RyZNe/RkMAUXR1n8buyM8l0uVtZGqbWcEJsI9R7Fzjh5VjDY/ag/PBeXYKW6+pNly4ehG9qQxWON8qN/ZThavpJBMMBFQ13b9lOEejK65OkRY3pOJAZS7BPc7+deubfT1qN8Zsfgpr5OR8inpUlUTYd5+s8qHyRzy/Lr9qNuFBM9qXGF/RNGuW5J6gsNRec/snxLpNVUiu8zP4UxqvgpA7EA== 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=vhnsYpgDjFMCH+qKTGshgGswftOnQ7kSMvXbWaYaIZY=; b=cEphkGKz70YBHkXNfvc1cCyEHNU+V4xJjbBsxM0yzvSwOF6W8uD/JBuo5s6lUunpi32HRTHqzEwgekzargN3F/la7lBcLNSfCf1r58zHNliZK82xS5DeWX5P/sMA3H1mc/VoPVdikQj35sPjxMu7jyuf3i4F3kC3n2PMuc0PMhW7Fso+/w+1L80g64S/Vd3cvflrLAAtsOLyoT4DjvTUcaTzxnn9uMrjcIr9bZdh9aNxnAmcnAGdxJ/NWAgVQLTFUiDf1v+vkDO8deN60HtcaF4wh0fqrZlbKbC+tElgyiblHOgcqKDSyoKLJr7hf+AzTfQsx5AhF8HsOzsA64cWiA== 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=vhnsYpgDjFMCH+qKTGshgGswftOnQ7kSMvXbWaYaIZY=; b=xmNODuMW9fmS5PCQ8yoQTyLP/1ZiSbMBeQzlsAhQlLzENDpmA/qycAE7USt8WWpPaOjOvuTm97hGUjOndKagGy8YwNX1nY6I5CMCnofaSnRZfjFdfg0QJxd7lIcw7AqMRu4bvE5LLNqyWgp76exg1/j5jzAg8XT4bldfW5z/qnY= Received: from DM6PR11MB2955.namprd11.prod.outlook.com (2603:10b6:5:65::31) by DM6PR11MB4459.namprd11.prod.outlook.com (2603:10b6:5:1de::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13; Tue, 28 Apr 2020 01:14:11 +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.2937.023; Tue, 28 Apr 2020 01:14:11 +0000 From: "Guomin Jiang" To: "Wu, Hao A" , "devel@edk2.groups.io" , Jeremy Linton CC: "Wang, Jian J" , "Ni, Ray" , "ard.biesheuvel@arm.com" , "Tian, Feng" , "Kinney, Michael D" 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+6oJcz8EY40K8DVzwoZo6F6iK2sQggAACMZCAAA8QEIAAHB0QgABHW8CAAOJngIABirAg Date: Tue, 28 Apr 2020 01:14:11 +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: 1e3a2aba-513c-4edf-373f-08d7eb117586 x-ms-traffictypediagnostic: DM6PR11MB4459: 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: 0387D64A71 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:(396003)(39860400002)(346002)(376002)(136003)(366004)(55016002)(76116006)(30864003)(52536014)(66556008)(9686003)(66476007)(66946007)(2906002)(4326008)(66446008)(64756008)(107886003)(478600001)(110136005)(71200400001)(54906003)(316002)(19627235002)(81156014)(6506007)(86362001)(8676002)(33656002)(26005)(966005)(53546011)(7696005)(5660300002)(8936002)(186003);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TippmV09Rn3ChUN68Uj3v/8a/FDKYdJ/p5+NA8ZI0i+S45DBy3ZG6oLoqN5V6ckjU3G8fQATOcoSPlrfEvbzY8fmWIxCfibiJTF8pag2i7XeuxJBOgIco9waGvmk/rtiOxuN9jr4A+WOzwe5nogqG1XhjljXDRWdebuf80bBfrYsvJ4yWweAJfNiyqJu5W5Kl0XLuyhfQXX5hVcGq3TIE3VFsw5GvYv/Pv+3EWCExHCj42zeK2Q+mvD8JOAXRW0iRJ/jSZFjEngKPYT2udH/X00lybYZDdUOfAe3syh3vfq9Xb4wOTg3DhSIXxnhvGoVl4h5JTdbUqbPYBpwQP6AG4YzAiSOcknQwCg3oVL5g/TnMXI2w+5/Xnl+AvkMUz3rAolaguF0erGCSZ9zJltXDiyaRY9RQ04KxlKJBzahDrH+Y3dx5pAdk7eGlIUQbOjCx5uu4Lzs2mGnZjXGaqm1tI0vGEYGrkC9GJ/zTblU5qqakJ0j5iKT3/93YI8jMQqbf1Kod27fl2S0Q3mJr0kGAg== x-ms-exchange-antispam-messagedata: 1WjHZSBMuGaPWZ/IB1ybRlnjdWLSyUWQDPCery6SD+6e8iUFWBpStOKARsewdzqDLaLbHJFbNm66tUz+oaMZoY4xtVwUunLyTbQN+hkh+DOyIKPurBgf2mYsCE/9lGmJyPGP8Td5BwEgJckhvzV54lBQgf1GA78e5JRwxBbL7atGzKjzIhHcFr/pYhF8JB0qSwVAsH9P5XEO/BSAXE2e5DBn2NjSjf+oQx6KDenJRmHJCuTRz1lFPEh+50br2dY3RihB30c82oe/fIQxLlzhN4F4o0o0YX8OPCshXUvq9Ce7wWNN42Qrcy9xcoarXqPT/qLe9KrNSIOSwQBmXo8ZK9xKtepG1tumejDXg1qhPnfEBBRCl4zYWJGM6rqVVuN/TvDdRNtPxBzZqw/1kA/ZisXdWE8hSF30OhDpI5HMhG6aGW9bCFs/zFgIUidqCKOmrx4PsdoCY3BoIDOOcmB0QSrUnQlF9Y+7TFZRluDC/0lZcEISt2PrpNkMTQdA1COVcsmYuudIfmXXv4r0ktF9Wua0R5PPQGX2chHdPegzv/GxsZjwDc/iakHfqWu5UV96u66trtwjKhnLAUYBOxQ/jQf7n+agQiR90qrny9OJe7sqtxN4bKtayegrtyaSWk6MCC/Svm7lGj6ZkC0s1+ikGDRx4prV8vc/To5lIo/wFZmqXoVXZIXi2ZVw9F1+CZm/v1cHghJVUFqVSio2/k8h2XdmH/OdwKs9ukYOA+MIrsDnuVeSviRhXeM81JSlDxAO1NWmOerxpSYlsSjYAGqpV452DzN5n87I028ZY+C0EbVUxDU0DgpRzM/wHhorcJV2 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1e3a2aba-513c-4edf-373f-08d7eb117586 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2020 01:14:11.3916 (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: hta1YgpNczmM44clLMjWXdMGHGCz0o4v8ju4RLDp4GHzilbtZM/SzB99ImnDDcJpg3XAmS7IrfyQ3ypefvGf4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4459 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 Add stakeholder and link https://edk2.groups.io/g/devel/message/58193 Add discussion history and add comment. > > Hi Jeremy, > > > > You can refer https://edk2.groups.io/g/devel/message/58125 for discuss= ion > about this solution. >=20 > Oh fun, odd how a bug can exist in a code base for years and then this > happens.. I will move the discussion there. >=20 > Thanks, >=20 > > > > Two issue I found: > > 1. Memory leakage may occur if doing so and I am investigating it. >=20 > It seems our solutions differ a bit? The memory leakage may occur when invoke UsbBuildDescTable(), because you = allocate new buffer but haven't freed the old allocated buffer ye. >=20 > > 2. It test pass with OVMF but fail in real platform, and I am figuring= out the > flow. >=20 > Hmm, I've been seeing this on a RPI with an attached USB3 hub and 5 bay = USB > JBOD. (there is another problem but the reset crash is keeps the machine > from booting). Can you share detail information with us.=20 > -----Original Message----- > From: Wu, Hao A > Sent: Monday, April 27, 2020 9:36 AM > 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 >=20 > > -----Original Message----- > > From: Jiang, Guomin > > Sent: Sunday, April 26, 2020 9:05 PM > > 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 > > > > Add comment inline. > > > > > -----Original Message----- > > > From: Wu, Hao A > > > Sent: Sunday, April 26, 2020 4:04 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: Sunday, April 26, 2020 2:44 PM > > > > 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 > > > > > > > > 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 > > > > > > > > > > > -----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 > > description. > > > > > > > > > > > > > > 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 UsbMassReset, the corresponding slot transfer ring is > > > > normal and invalid after UsbMassReset. > > > > 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 0= 0 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: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 > > > > 00000400: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 > > > > 00000410: 01 00 00 00 00 00 00 00-00 00 00 00 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 > > > e > > > > d.c(1909): TrsRing !=3D ((void *) 0) > > > > > > > > The EndpointTranferRing should be initialized by > > > > UsbBuildDescTable() but seem that it is omitted in Reset branch, s= o I add > it. > > > > > > > > > Sorry Guomin, I still do not fully understand the link between > > > calling the > > > UsbBuildDescTable() in UsbBusDxe and the re-initialization of the > > > 'EndpointTranferRing' in the XhciDxe. Could you help to provide more > detail? > > > > I am sorry that make confusion to you, I will explain it in detail now= . > > 1. The critical call flow as below > > UsbMassReset() > > --> UsbMass->Transport->Reset() =3D=3D UsbBotResetDevice() > > --> UsbBot->UsbIo->UsbPortReset() =3D=3D UsbIoPortReset() > > --> UsbIf->Device->ParentIf->HubApi->ResetPort() =3D=3D > > UsbRootHubResetPort() > > --> UsbHcGetRootHubPortStatus() > > --> UsbBus->Usb2Hc-GetRootHubPortStatus() =3D= =3D > > XhcGetRootHubPortStatus() > > --> XhcPollPortStatusChange() > > --> XhcDisableSlotCmd() or > > XhcDisableSlotCmd64() [Very very critical routine 1] > > --> XhcInitializeDeviceSlot() or > > XhcInitializeDeviceSlot64() [Very very critical routine 2] > > --> UsbSetAddress() > > --> UsbSetConfig() > > --> UsbBus->Usb2Hc->ControlTransfer() =3D=3D XhcCont= rolTransfer() > > --> XhcSetConfigCmd() or XhcSetConfigCmd64() > > [Very very critical routine 3] > > > > There are three very very critical routine, 1. XhcDisableSlotCmd() or > > XhcDisableSlotCmd64() will disable the slot context and free the > > allocated memory. > > 2. XhcInitializeDeviceSlot() or XhcInitializeDeviceSlot() will > > initialize the basic control and slot endpoint transfer ring. > > 3. XhcSetConfigCmd() or XhcSetConfigCmd64() will configure the other > > transfer ring. It depend on Xhc- > > >UsbDevContext[Slot].DevDesc.NumConfigurations, unfortunately, the > > DevDesc haven't benn initialized by UsbBuildDescTable and it is 0. So > > XhcSetConfigCmd() or XhcSetConfigCmd64() haven't run. > > > > After run below 3 critical routine, the device is initialize but > > EndpointTransferRing of Input and Output haven't been initialized and > > still keep NULL. > > > > When UsbMassReadBlocks, it will use uninitialized EndpointTransferRing > > and will ASSERT. >=20 >=20 > Thanks a lot Guomin, >=20 > Now I understand the reason behind for the proposed fix. >=20 > I would suggest to add an abstract of the above analysis in the commit > message, such information will be helpful for others who might work on > USB/Xhci in the future. >=20 >=20 > > > > > Another thing I found (if current proposed fix is a proper solution) > > > is that in > > > UsbBuildDescTable() , several memory allocations will be made to > > > store the device descriptor/config descriptor. Could you help to > > > double check if their old values are properly freed in order to avoi= d > memory leak? > > > > > > > I will investigate it and give you feedback. >=20 >=20 > Thanks for this. >=20 > Best Regards, > Hao Wu >=20 >=20 > > > > > Best Regards, > > > Hao Wu > > > > > > > > > > > > > > > > > > > > > > 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 pac= ket > > > > > > |> 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. > > > > > > > > > > > > > > > > > > > One more thing, could you help to add the information for what > > > > > tests have been done for the proposed patch as well? > > > > > > > > > > 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 > > > > environment, the procedure as below 1. Import the test patch from > > > > https://bugzilla.tianocore.org/attachment.cgi?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,file=3Dfile.img -device nec-usb-xhci,id=3Dxhc= i, > > > > -device > > > > usb- storage,bus=3Dxhci.0,drive=3Dstick -global > > > > isa-debugcon.iobase=3D0x402 > > > > - debugcon file:xhci.log``` 5. you will see hang currently and > > > > will see ASSERT when check xhci.log. > > > > 6. import proposal patch, the symptom disappear. > > > > > > > > > > > > > > > > > > > > > Best Regards, > > > > > > Hao Wu > > > > > > > > > > > > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > // > > > > > > > > > > > > > > // Reset the current active configure, after this device > > > > > > > > > > > > > > // is in CONFIGURED state. > > > > > > > > > > > > > > -- > > > > > > > 2.25.1.windows.1 > > > > > > > > > > > > > > > > > >=20 > > > > > > > > > > > > > > >=20