From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.121043.1671063969338418736 for ; Wed, 14 Dec 2022 16:26:09 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bRZxbbEu; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: hao.a.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671063969; x=1702599969; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=p9r1tzNiMlCPtNbT58rgoxCDjkTWZqhKM1XXzgQgG+g=; b=bRZxbbEu68q76yiaWXByd4ATewRsCcF/LG4vSQK37mdOIAuCV5stDmC1 A2joimw2fJI/GdtgACzO4pKQAtcMnZqT45+pLGaQIc+2ewe25bvXiOUZx 6AtugeRh8Cd3r4npa+Aq3HaN5Sl9/NlfJAykY9I4Emax/e8Na21k25Py9 HTl3tKtOmtnCwBiC+HOR3ELnGdD5huiHRnJtAbOVSYDcscQj2nrZCmMMc edjVxxbTm1GDSqhDCft6cp5q/EBeLuaKjoye4gdb8SzKJaqEOrnfUTvY4 yjsSoOcZ2QZaK+7mcYVPj6J/+blQbNLIV2CX0kEki6B35sNsRWQjeYgf5 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10561"; a="317260341" X-IronPort-AV: E=Sophos;i="5.96,245,1665471600"; d="scan'208";a="317260341" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2022 16:26:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10561"; a="791436994" X-IronPort-AV: E=Sophos;i="5.96,245,1665471600"; d="scan'208";a="791436994" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga001.fm.intel.com with ESMTP; 14 Dec 2022 16:26:08 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 14 Dec 2022 16:26:08 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 14 Dec 2022 16:26:07 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Wed, 14 Dec 2022 16:26:07 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Wed, 14 Dec 2022 16:26:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cUJMK2Ov/K19xXv8rdQR1/QAUTE2M17RKWN8GKodm4AU7TU7Lg8H6Cs5GuoFXDS0fG0lIpldNm1qGpLus0Ujr9fELy3n9zJHqNcnkok6d3D+PWjlkoUdKN/ibPBRxJmATDAMYYdWaX4skkKE44aw5UwHqQQk+cV3Rttd6bb5RA/D1AYNnixrNTPVaMQh1wWYFZZ1k4hjHiTXhMFHpgh/JP3J7A83vPznDgb+d0xTDEByUAUavneUvxy1Yl9eHWWQO+i0XJjEhZ237e5LXTtQYIJ598xOP/lOXYPaI/PuU04zPgBhKrJ5H0KoctQGCl2QCFDLGFyVjHb/jtD0glPyxA== 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=mBBJQhw3z1hMnocoivNV/LJXbGlRVHHGHJiCnAn2q+0=; b=UhBgPIT8OyCE+wKN1c8Yd5ks6628PiKVWONwdi7WgOOo6txBBxxxjN6I2zeKlzHU6tK/QKZOOwyEej+VQliF1Ai34VTQhWyS8kbwTqobtBzyCjSUZEl5h/ONjMABp4Ss2/J5thKnKrr4vpC4FX5Li2tyNS/2dO8r1cZrYVkPJ+N0DNjJ9rVFUZWyp/So+0TVjXHLc5cmuh5aFx5iWBY/l1oNC/2Q9Fxx8weop1DEUXrSKAH10+EPszug4jgNtJMzxzMzsiDZlMiKdDLyrB5RcVu+sBgSLMCNzhmOA/SVqFkhZHKAku9CY0beyKBQcRVbbCA5ijka0FSN1fLwmjxqew== 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 Received: from MN2PR11MB4031.namprd11.prod.outlook.com (2603:10b6:208:150::18) by MN2PR11MB4712.namprd11.prod.outlook.com (2603:10b6:208:264::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11; Thu, 15 Dec 2022 00:26:01 +0000 Received: from MN2PR11MB4031.namprd11.prod.outlook.com ([fe80::6c89:9cdb:3201:97ce]) by MN2PR11MB4031.namprd11.prod.outlook.com ([fe80::6c89:9cdb:3201:97ce%5]) with mapi id 15.20.5880.019; Thu, 15 Dec 2022 00:26:01 +0000 From: "Wu, Hao A" To: "Rhodes, Sean" , "devel@edk2.groups.io" CC: Matt DeVillier , "Ni, Ray" , "Rhodes, Sean" , "Chiu, Ian" Subject: Re: [PATCH 2/3] MdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV Thread-Topic: [PATCH 2/3] MdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV Thread-Index: AQHZDA9Bxv8/EY85vU+pRXzBCBYJw65uHnMQ Date: Thu, 15 Dec 2022 00:26:01 +0000 Message-ID: References: <618cba614165100a6834c7fd4760bfe328ae7d80.1670618740.git.sean@starlabs.systems> In-Reply-To: <618cba614165100a6834c7fd4760bfe328ae7d80.1670618740.git.sean@starlabs.systems> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR11MB4031:EE_|MN2PR11MB4712:EE_ x-ms-office365-filtering-correlation-id: 9304c73a-3bd6-4685-9cc4-08dade32f1a9 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jfBIgYyrEfYWciTSwHbzYgxs31tkvek6Ol0mAaptVugtp6G2xvBGKiy8adeig/EAD2iWMdgVScNAJ8atG3LhPtKs7THhwuAULnW4EXPh+X1Tz1NwcpU7vrzT3xtiLs8C5SpGIpao7+mWF7pfD0F3UaXpLB9+jW8LaxFp2wzBB5XTo9B6V8cI7DZadu0KVFbhLL8PRS44I7yiToLrdKYV7bIkxL63i9JjLZdXFgK+Y/RnOMt6O+DOoB7Sg8bG1rc17Yhsqe46x+2o1ZSTQ+EgkUca8vatPlllpozAu4qlML9qYXKTp83/e7JBaSGEGKvJHvPCD334tN/4Jw3LIXyM2TymPXFhFsrSwkBn+1MGp1viQqRTcDz7CivhQsuQ3Ej4sBIZYo+6+3vOheKdtQWCTszNypKsfqdDZJykIZ97W3s8msNfFI7LXZvqs29zbokhBdDKbRV8/mKb1jB6WFa6Q1ZHCQUOgO0LQI9SQ4rJTo0yVY6IOetID99qtVAknPr/f+bTw9USz+PiZsK+7RKJ6/ZJriynmhRx5gcD7d2+O0B83qmhgVCshQ1LYrEfzcBsutmhdEJVH0XyTLpN1qXQliYuo64LdAGtIAzGbFtBqtpwyE8FSM5lbs1Xp2tO/6tyX7y+tvqLTK7N0vJVIQjpuYEWHiW0orF0pMuA6yuccy6E/2/Wmpg45yU0wa1sMZKDEeW+2lrty9cgJ7r6rix/AQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR11MB4031.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199015)(71200400001)(55016003)(33656002)(41300700001)(64756008)(86362001)(76116006)(66556008)(66446008)(66946007)(9686003)(8676002)(26005)(186003)(52536014)(66476007)(4326008)(478600001)(53546011)(110136005)(6506007)(7696005)(316002)(54906003)(107886003)(122000001)(38100700002)(38070700005)(82960400001)(5660300002)(2906002)(83380400001)(8936002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?PPnGGhfDgVB1RxADBbKxQT3WP39waqvFyfcifyy9k5YFQXimXMTKjCiT3S0D?= =?us-ascii?Q?EeUcI013oxwXm1iqoD0aGSpfP3HI0iXCefgvots0GRok6QOajFCaGrmEFpsr?= =?us-ascii?Q?t3XSEkmE3V7dm5XUnGLg/NSnTKBp/7dSjPn0mexVdPBS7+6DEYYCCRFNKeF5?= =?us-ascii?Q?bPvj6BOQRiLCHbZTla+2xIpvRM+sm1u0aX4Tsk7lN8EhAEM5c/sULRQOuZJO?= =?us-ascii?Q?fXxXpZ6NXSceILAzIHTa6LBbJ55+1WBTa+r6Sb6PerAKj9IYm6c3aSrTPmiL?= =?us-ascii?Q?lUtyMzgsbZVA6wb7oEz4QziGxGCEqVMFVgiPdz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WCISJWnkx5pejFRd72Ua/pkJx9NwXaImOcV8QVpIfJKM?= =?us-ascii?Q?8bRluETF7ZfzdVP/2TMmCzSq7dOoDI72WWrOfknl6+tpcchXf7OeqsX16XLs?= =?us-ascii?Q?D7YAn40iz1o9gdZybjjF3eBSlPSY2ePV3koL4VxiACTpsSXHV2PLHX7ev3WQ?= =?us-ascii?Q?a/z4tzUFvPZZyhEFUtw8CENYRB9joAfq8Y9BgwrNWVF54RhNjCeJ6L3wdFvx?= =?us-ascii?Q?NwYStXp/P4GWOiN5buzCZBgm4MOsRPBFY2G4nx++B+nyQgB4C05n353zt7l4?= =?us-ascii?Q?wLR1kAHSDcNFVl6ghUKiP4vxKG0CYrPWObx1mwQbQjpjeWjDo99YDJGZDjXC?= =?us-ascii?Q?OnhTZJwr7OjPR+kkAB1HpfKVEM4EkrvkGN0Xg46R?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR11MB4031.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9304c73a-3bd6-4685-9cc4-08dade32f1a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Dec 2022 00:26:01.0189 (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: ODEAlJ8HBgYDivDSeVSx6OrVEwpvjgv6SyCnOwblAfmuETbtNbC4O8suZMX1jFqQftWfRfYPjbB/BdxPOfQ8Sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4712 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao A Wu Best Regards, Hao Wu > -----Original Message----- > From: Sean Rhodes > Sent: Saturday, December 10, 2022 4:46 AM > To: devel@edk2.groups.io > Cc: Matt DeVillier ; Wu, Hao A > ; Ni, Ray ; Rhodes, Sean > > Subject: [PATCH 2/3] MdeModulePkg/XhciDxe/Xhci: Don't check for invalid > PSIV >=20 > From: Matt DeVillier >=20 > PSID matching relies on comparing the PSIV against the PortSpeed > value. This patch stops edk2 from checking for a PSIV of 0, as it > is not valid; this reduces the number of register access by > approximately 6 per second. >=20 > Cc: Hao A Wu > Cc: Ray Ni > Reviewed-by: Sean Rhodes > Signed-off-by: Matt DeVillier > Change-Id: If15c55ab66d2e7faa832ce8576d2e5b47157cc9a > --- > MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 44 ++++++++++++++++------------- > 1 file changed, 25 insertions(+), 19 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > index 15fb49f28f..8dd7a8fbb7 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > @@ -371,6 +371,7 @@ XhcGetRootHubPortStatus ( > UINT32 TotalPort; >=20 > UINTN Index; >=20 > UINTN MapSize; >=20 > + UINT8 PortSpeed; >=20 > EFI_STATUS Status; >=20 > USB_DEV_ROUTE ParentRouteChart; >=20 > EFI_TPL OldTpl; >=20 > @@ -397,32 +398,37 @@ XhcGetRootHubPortStatus ( >=20 >=20 > State =3D XhcReadOpReg (Xhc, Offset); >=20 >=20 >=20 > + PortSpeed =3D (State & XHC_PORTSC_PS) >> 10; >=20 > + >=20 > // >=20 > // According to XHCI 1.1 spec November 2017, >=20 > // Section 7.2 xHCI Support Protocol Capability >=20 > // >=20 > - PortStatus->PortStatus =3D XhcCheckUsbPortSpeedUsedPsic (Xhc, ((State = & > XHC_PORTSC_PS) >> 10)); >=20 > - if (PortStatus->PortStatus =3D=3D 0) { >=20 > - // >=20 > - // According to XHCI 1.1 spec November 2017, >=20 > - // bit 10~13 of the root port status register identifies the speed o= f the > attached device. >=20 > - // >=20 > - switch ((State & XHC_PORTSC_PS) >> 10) { >=20 > - case 2: >=20 > - PortStatus->PortStatus |=3D USB_PORT_STAT_LOW_SPEED; >=20 > - break; >=20 > + if (PortSpeed > 0) { >=20 > + PortStatus->PortStatus =3D XhcCheckUsbPortSpeedUsedPsic (Xhc, > PortSpeed); >=20 > + // If no match found in ext cap reg, fall back to PORTSC >=20 > + if (PortStatus->PortStatus =3D=3D 0) { >=20 > + // >=20 > + // According to XHCI 1.1 spec November 2017, >=20 > + // bit 10~13 of the root port status register identifies the speed= of the > attached device. >=20 > + // >=20 > + switch (PortSpeed) { >=20 > + case 2: >=20 > + PortStatus->PortStatus |=3D USB_PORT_STAT_LOW_SPEED; >=20 > + break; >=20 >=20 >=20 > - case 3: >=20 > - PortStatus->PortStatus |=3D USB_PORT_STAT_HIGH_SPEED; >=20 > - break; >=20 > + case 3: >=20 > + PortStatus->PortStatus |=3D USB_PORT_STAT_HIGH_SPEED; >=20 > + break; >=20 >=20 >=20 > - case 4: >=20 > - case 5: >=20 > - PortStatus->PortStatus |=3D USB_PORT_STAT_SUPER_SPEED; >=20 > - break; >=20 > + case 4: >=20 > + case 5: >=20 > + PortStatus->PortStatus |=3D USB_PORT_STAT_SUPER_SPEED; >=20 > + break; >=20 >=20 >=20 > - default: >=20 > - break; >=20 > + default: >=20 > + break; >=20 > + } >=20 > } >=20 > } >=20 >=20 >=20 > -- > 2.37.2