From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.3178.1665716642515584244 for ; Thu, 13 Oct 2022 20:04:02 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=aiCb4K4X; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665716642; x=1697252642; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=yn7iQQKhxJ9oFn2vbq2Ncen/5po1tsA6cHC/c199ANc=; b=aiCb4K4XAyTd5N0Hd93o3NrNQL3ao1am8GeNXQVWG6hE1qMQeNze/6j+ DZLSLsEeFMS6qWPRJzDeFoXW25gLIJJ4JDUqazsKF58L/olszE7/JqxPH SjUUJVNhg1F3tYcieozwKffYSKe2hqNO99skW9/KIkSrUjGtoAzPsJUu2 aa3UXw7R7yG7OzsS3ktt0nVBU+VuO816OHarq0+++iTlY9lp0z4rJglVC wcP5uSnHgaUQugyPnJdqdBS+/neUCtNcuQ+TL9xXiMT3W78LojISWsuBZ yHCjr66btrBLIdP4qH9HY/CNdKb07A+wSNLB/SK1MowZICRu9Y3abiHQf g==; X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="367283454" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="367283454" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2022 20:04:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="716586898" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="716586898" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by FMSMGA003.fm.intel.com with ESMTP; 13 Oct 2022 20:04:01 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 13 Oct 2022 20:04:01 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Thu, 13 Oct 2022 20:04:01 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) 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.2375.31; Thu, 13 Oct 2022 20:04:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zb49Sv3LfUGPGd1HCw4e4UrzWAJgrimpuB1uKb/GDWtrdl9KyfmT33e+6u606p1rSIZPKU5LwcP0CwJ3V68HoqevFAJJbUIAG/Z99FiI9t2A9P+sjklzNo4rbt8zDGlGg1SIr35qji/l3V2GtVnbfUWms8Wj4zyEdEuSrFQ2ps/yBfVIQJuem0zvsPGBX9k4PmoDJZNv8+cb9fn0PIxJ35vg8m4vIAFtuHcPZPmb8dF4mIvXEECqBMzlM+GB6DyTNZjAMPViqCzdHGTn6vgx9mJCqMHpgw7YvGuJZtMCWs6BFFuhC9YH2nV4V/ppgZpPnEARXscaevrHAm9V1Er7jg== 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=T7WY4R6Vufs0udX2lkB7fN5bApZ09SG9D32BOggb0aQ=; b=NFPZ8aWK3u7jrd0B5DSBJvl6rvSGKX6ja1xqcN3hL+8wCkMvopfCu+5eK68Sq5om+Zn+92If+MobbXXsO6Ve1xV/hIg54o/ma4/PfAMZhjtLqkI8/R8DC32Tor5Z4HpLqyT/wxKGgdru3NKAvUMZ+04rbKc1hTr67IajHrcIQMvWn/vvYA+Rk30P8Sl0t7FJ3OpBAPvDCiKZVN4uuNm/KSnSkGhhdO0vswyK0s7LMfBL68RtIlhp/mNfOjj2X5ik3te0wV3WOuxuDURTvok/mVNIxKI4Hdlam8iF7jCUBeV35vKZxtBxvM5tSnmT0NHhznj4+sXrXmnLwn07ATAqsg== 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 MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by PH8PR11MB6802.namprd11.prod.outlook.com (2603:10b6:510:1ca::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Fri, 14 Oct 2022 03:03:59 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::483f:4bb5:a15f:f571]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::483f:4bb5:a15f:f571%11]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:03:59 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Nong, Foster" Subject: Re: [edk2-devel] [PATCH v2 2/2] Fix bug on SRIOV ReservedBusNum when ARI enable. Thread-Topic: [edk2-devel] [PATCH v2 2/2] Fix bug on SRIOV ReservedBusNum when ARI enable. Thread-Index: AQHY3kfoQ5jMbMCSXkOso8N2gVBYGa4NNprA Date: Fri, 14 Oct 2022 03:03:59 +0000 Message-ID: References: <20221012023656.1565-1-foster.nong@intel.com> <20221012023656.1565-2-foster.nong@intel.com> In-Reply-To: <20221012023656.1565-2-foster.nong@intel.com> Accept-Language: en-US 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: MWHPR11MB1631:EE_|PH8PR11MB6802:EE_ x-ms-office365-filtering-correlation-id: afab1951-1a86-43b7-f77d-08daad90bdb2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kC8GcgwDdVtwKToRwfJVKxik8jwjG+TrgtZ7AnGs1VAn7v2i/VqVfxxqDvT9ex9la6jRMMMpKZuYwgmZ9ptQRzWwLlRUPQPOTyNyi3XICWAkv0AUptmNlLo2paPsgW4TEfXhHyHR01VSuBpv9krNIGL2yFfVTgyTZOiEE6geAsrVNZ3+PvsHr5wgkTlrQ8xPNDSQGXK/PPqmMkdsCRnrldge4Xgg+UxF07eIHDk6JItONUvSL4ds9pw+HhuZPtzpX8c7DJwqZivlNZWuf1hdJ4uLYy2bPrEyKukmXXo3WPjZ2q5ZvLSJPxYkbNBlVnQ1IH7JKevUjN0NxNQMxtQKWIRy6+HQqoe//K8j0vPdXImFy5NeXQ/NgiGmwiaV1ty4h0ASkHH5V9VEtM5dsRCtIYxCWtRYY7u4fCAA/H0TkhWiEFP5zk4vO2MsPt+2dEE4w/NjBHKR/hf5vD7NH9G/D1dJmWX2tY/a0mTUHCR93waMwwd+h09sCT5SysRkxHw3OAvRAAcvtvMc6UqOkWjK7HteoTxnhvTkSlnf1JbPFq1kIv2/f9JcfwI90NS9D1oWEs4qyGR53GzJG9Q1N903iN1cguJOwbby8N8dtvXwDijhvFrnb/zYL2y7qkrI6wBENQ96SXF3Q/8LQY396js9J9saV3kaTu9KKck1ZZvdFLfUdiWejzRy1HQ77d1OhILEyi2uSHCiA0E3XxLRjHhlLXola4go6oXS0AjgWnr0Bma5rggV2Q39SmPv2F/xjbqSY8kL4eop+YsSiD1NaS1nVdnUIplJBNgv2tTbJ0tiy6FCuV6rIeNEf40Lg/7pSM6nQYN3Yns+s/ofcdzak8+7sQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(39860400002)(346002)(366004)(396003)(136003)(451199015)(33656002)(66899015)(86362001)(2906002)(38100700002)(82960400001)(5660300002)(122000001)(186003)(83380400001)(7696005)(6506007)(38070700005)(966005)(9686003)(478600001)(76116006)(66446008)(66556008)(66946007)(71200400001)(66476007)(53546011)(6636002)(26005)(52536014)(41300700001)(8936002)(8676002)(64756008)(110136005)(316002)(55016003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7C1XiC3ld4XIBxydaLO5sJk3ZgwM2EL83OmcVvNEElSmJuwtfJxjzrqWY9TR?= =?us-ascii?Q?Ff2BvO+1J1YSrhqQQ0O7s/Mo9pced/kLt1epPFk9AXQHr/86BU0MWPiow9aN?= =?us-ascii?Q?O9LpjM+nIwpK8lBag6TVXwkDpL1ThKb+u/isejaeyg6E1x6MP13OMDefz1Rw?= =?us-ascii?Q?/ECbrEwRhAMKnE2ZETR/g5PHGS1G4JD3QOs5iMi4ydej/6l1afR+01d2Ttfz?= =?us-ascii?Q?nzpIMU3DB/pk92cJgVs8Rh08+gxkMG8GWpPfXd3jPH2L0X4zIi/IoGaO/wpw?= =?us-ascii?Q?Y/VDEnLBvpMqEMqzeDD1crVfrZTCge32GnVnY7iLggtLKorppNCjRzSgDQRL?= =?us-ascii?Q?ZkjtlYGU02l0F5bh4fE/RG3QUXZJIxmV3tAuFE8u1SYHj1oeKsUyZopdc++V?= =?us-ascii?Q?qcrAQcjvqH+D4zI4k1aYMC/IcKE/o1UzC5zTVNn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eB6FTjlpB3kG/dga3uX4XKLR9aaTtj7l85ez1Uw+8GD?= =?us-ascii?Q?/q8uC2y31mhPDq35IDxRV6RsuciGE+JoxwclR7obbItMNg6IoTBoJQdtEveH?= =?us-ascii?Q?pRa7OJhalXJd+yDhW5pGWtyA2jdGC6kaAdYBrK1+L3x0mpsz2/WJA3QI9zrt?= =?us-ascii?Q?Lg7oZ6qaoe63ruA7ypXRhYAofGk6R/LElKw98hizFo73LO3O1RsRftq+s+8a?= =?us-ascii?Q?ostjvYKakdl+0PE1tcBK9flFmsUBzKl/c3bhh0wW?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afab1951-1a86-43b7-f77d-08daad90bdb2 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2022 03:03:59.5240 (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: TqNqCNZiheinNIcf+EmSfl+sBB8uZjPS/LuNa/8d2un6biy1UZkwB7RHxlCOKx8fjv2lcgi0cA649W4ov4U1Tw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB6802 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Foster Non= g > Sent: Wednesday, October 12, 2022 10:37 AM > To: devel@edk2.groups.io > Cc: Nong, Foster > Subject: [edk2-devel] [PATCH v2 2/2] Fix bug on SRIOV ReservedBusNum when= ARI enable. >=20 > If a device which support both features SR-IOV/ARI has multi > functions, which maybe support 8-255. After enable ARI forwarding in > the root port and ARI Capable Hierarchy in the SR-IOV PF0. > The device will support and expose multi functions(0-255) with ARI ID rou= ting. > In next device loop in below for() code, actually it still be in the > same SR-IOV device, and just some PF which is over 8 or higher > one(n*8), PciAllocateBusNumber() will allocate bus > number(ReservedBusNum - TempReservedBusNum)) for this PF. if reset > TempReservedBusNum as 0 in this case,it will allocate wrong bus number > for this PF because TempReservedBusNum should be total previous PF's > reserved bus numbers. >=20 > code: > for (Device =3D 0; Device <=3D PCI_MAX_DEVICE; Device++) { > TempReservedBusNum =3D 0; > for (Func =3D 0; Func <=3D PCI_MAX_FUNC; Func++) { > // > // Check to see whether a pci device is present > // > Status =3D PciDevicePresent ( > PciRootBridgeIo, > &Pci, > StartBusNumber, > Device, > Func > ); > ... > Status =3D PciAllocateBusNumber (PciDevice, *SubBusNumber, > (UINT8)(PciDevice->ReservedBusNum - TempReservedBusNum), SubBusNumber= ); >=20 > The solution is add a new flag IsAriEnabled to help handle this case. > if ARI is enabled, then TempReservedBusNum will not be reset again > during all functions(1-255) scan with checking flag IsAriEnabled. >=20 > Signed-off-by: Foster Nong > --- > MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 19 +++++++++++++= +++++- > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 1 + > 3 files changed, 20 insertions(+), 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c > index bc20da1f38..8eca859695 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c > @@ -2286,6 +2286,7 @@ CreatePciIoDevice ( > &Data32 >=20 > ); >=20 > if ((Data32 & EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWAR= DING) !=3D 0) { >=20 > + PciIoDevice->IsAriEnabled =3D TRUE; >=20 > // >=20 > // ARI forward support in bridge, so enable it. >=20 > // >=20 > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/P= ci/PciBusDxe/PciLib.c > index d5e3ef4d3f..3a57c05755 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c > @@ -1106,6 +1106,7 @@ PciScanBus ( > EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; >=20 > BOOLEAN BusPadding; >=20 > UINT32 TempReservedBusNum; >=20 > + BOOLEAN IsAriEnabled; >=20 >=20 >=20 > PciRootBridgeIo =3D Bridge->PciRootBridgeIo; >=20 > SecondBus =3D 0; >=20 > @@ -1116,9 +1117,12 @@ PciScanBus ( > BusPadding =3D FALSE; >=20 > PciDevice =3D NULL; >=20 > PciAddress =3D 0; >=20 > + IsAriEnabled =3D FALSE; >=20 >=20 >=20 > for (Device =3D 0; Device <=3D PCI_MAX_DEVICE; Device++) { >=20 > - TempReservedBusNum =3D 0; >=20 > + if (!IsAriEnabled) { >=20 > + TempReservedBusNum =3D 0; >=20 > + } >=20 > for (Func =3D 0; Func <=3D PCI_MAX_FUNC; Func++) { >=20 > // >=20 > // Check to see whether a pci device is present >=20 > @@ -1157,6 +1161,19 @@ PciScanBus ( > if (EFI_ERROR (Status)) { >=20 > continue; >=20 > } >=20 > + // >=20 > + // Per Pcie spec ARI Extended Capability >=20 > + // This capability must be implemented by each function in an ARI = device. >=20 > + // It is not applicable to a Root Port, a Switch Downstream Port, = an RCiEP, or a Root Complex Event Collector >=20 > + // >=20 > + if (((Device =3D=3D 0) && (Func =3D=3D 0)) && (PciDevice->IsAriEna= bled)) { >=20 > + IsAriEnabled =3D TRUE; >=20 > + } >=20 > + if (PciDevice->IsAriEnabled !=3D IsAriEnabled) { >=20 > + DEBUG ((DEBUG_ERROR, "ERROR: %02x:%02x:%02x device ARI Feature(%= x) is not consistent with others Function\n", >=20 > + StartBusNumber, Device, Func, PciDevice->IsAriEnabled)); >=20 > + return EFI_DEVICE_ERROR; >=20 > + } >=20 >=20 >=20 > PciAddress =3D EFI_PCI_ADDRESS (StartBusNumber, Device, Func, 0); >=20 >=20 >=20 > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h b/MdeModulePkg/Bus/P= ci/PciBusDxe/PciBus.h > index 4b58c3ea9b..ca5c06204d 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h > @@ -262,6 +262,7 @@ struct _PCI_IO_DEVICE { > EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BusNumberRanges; >=20 >=20 >=20 > BOOLEAN IsPciExp; >=20 > + BOOLEAN IsAriEnabled; >=20 > // >=20 > // For SR-IOV >=20 > // >=20 > -- > 2.37.1.windows.1 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#95106): https://edk2.groups.io/g/devel/message/95106 > Mute This Topic: https://groups.io/mt/94282086/1712937 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D >=20