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.web12.4218.1665728815390236702 for ; Thu, 13 Oct 2022 23:26:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=QXJgLOer; spf=pass (domain: intel.com, ip: 134.134.136.126, 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=1665728815; x=1697264815; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=KHgu1QENagHFYtwXyeahikTMo8wqc4WHh87TXl/VoKI=; b=QXJgLOerlkz1XUJ/+UWbaE5HiYnw9N90qDY4uC/DyuRJl8lDvF+VHAf6 c4NLYFiHcjhrRcochUOuZkPtZxVSaagYOyYb2h+D8FopskQAVKmG54dp6 sHoWBF2sqENqJjna5eJ33HfNaM7WlRQmbVOSqGzqDkXZlufEzHOItdQR6 g/OUIVSb9D6nq6lorX8CHq0ynktOz5Aw9CsMI+BjzYjO0F1p64PXy7XsP UfGIfN+U2pSnNRvfHwuhNeGpEaGIKjvBFBRu1UO4eFdk44pR9KMjn1CmS YySlsHoyg4WVfY1aUkKgccNc6TbKIpvPdIQWK4wFDeMAjnFzkw4yV7wQL A==; X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="288583709" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="288583709" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2022 23:26:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="769922640" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="769922640" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga001.fm.intel.com with ESMTP; 13 Oct 2022 23:26:32 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) 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 23:26:32 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) 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 23:26:32 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (134.134.137.102) 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 23:26:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m5BNTtCIyAaJ94bK9JZG3f9l1nvo4eHYwlZmucP6L6YohQp7Gb7OyqxQXdd09RIUcxPnNFzKdW6wwe0qw78kNLRKAfwK2naLTwwiL9FQVkIs9gVFuHVf186zmSRgXQe6tXo3cdw5enX2ow0eZPaRXeo173/x6SS7NKfbGn4PgwZg7eOCU4Gkh1jZNBpH5uDas40Wa5trGW0cVyqSn3777RgViPK8TN4QFfcQIY+WZ30Pg1ar6Au7kqTz3Uu8fnd0dWVilqe8B5HyVVAqwaHqGGW7A7HpTYdaeyJGJXWgr/5RD4Ag67mCLK7aVRcBHqvmjTHTXCMsVEyTouyACA6kSw== 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=UhPcnyzD6BbNjRmSnCEnrpARIrRXWVYt18E51sGBS3Q=; b=FU3a+tzGOgsQcCer/N5ST5OB0Lt6DmEjmURV/H+I54o0FE1UelK4cJUcuJpU8LDe+xz57J6wh1rHpHepRmSrHC5PKghOXDmPJBNWn4Zm2fM7dHe+ZcphC1ynTbF20Zn8YlcMDmWbrlCqQfsXVYllERtSd3qsd2etIWlU1x5YkAsInSz6LdRC7/92oI8F4qFy1wmXhX7iCwJN9+WmB3qO+qFD2YTNpZXhcQA+CvVhKQID3xU9O3azgk3HCN8VNY9zdF6G2TF7eI32L8MtVc0DoYv3wMYguJQj1GJfPeiWl/06h2xecFKlmbRXEOV25Hw8EdeIZKdt36OfRZ8XIB0ziw== 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 SA1PR11MB7040.namprd11.prod.outlook.com (2603:10b6:806:2b7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Fri, 14 Oct 2022 06:26:29 +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 06:26:29 +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: AQHY3kfoQ5jMbMCSXkOso8N2gVBYGa4NbyBg Date: Fri, 14 Oct 2022 06:26:29 +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_|SA1PR11MB7040:EE_ x-ms-office365-filtering-correlation-id: 593a4fcc-dcf7-44d8-c19b-08daadad0775 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VY6h1vJ7n/blJaCx19DX1lOWcWswSsabcMat3hmL6bu5ag5Vl+KhVj8wxK1cNyA/r2vqbR/u1Q//ggWvQuctdT2x8QS2Zmz1p47JLFmrwQSx4bGPfYzqjlPGZxcXF5XGnRaP8b+qf/NFjXsTxgE2iqxSzbg6kiKLF+ootcOBMSzqu+B5CJq1Ue1ThvM0++VJdTYw0xytKcmIe45kVS/jI0qL4GOoWWkfQfIrZBw9sQpLYe2imZ+RBCDro3fSijRiKLQGqbvLHbKwmDLHnbbSqbw60otr9KWWBEa5k6S4bb7pml+L/MJ9gfg+1eX57yJPDk0hCtJYvW6kEqRHibL4dXfXvr+FLLiZA5GZytFd/JWTg/N3OvldyR/qkP9vGFnff209VE6yG/pbPFqsyFni+sfOQY6YR+83nhDsu8ehRQTcmoqcoC8ACSVp6Iwx+nFJilczSUT45HGX7XOTLgQE7Ng/KRrXAo7dr6Cv5Jn75tcvOyi1NHUSFaiVYx+C2gNldb+yUgjG9OykzGKn7OTCoh7/p577+2is51tNffucjSn0naeg0ki0inax+lO5R5EfXUc4alhQ1z/rUrCiLT/71jGDp8rM1QQLt7FaIZcXL0n2eLVx/UYzBhtrJGryio1eXStTW7oboVTflXncF28eR1CWfM8VOnLt7bjrGOXvxs2cbakOdDnmCzWGEprCfiJHt/AuLRmwb+pvQKsCWA/svu6q4SXg51Itzp68ADNLRVHBni4Qd68Wnw1O/a0/ZXGKHTpL2OwdboZjjq4MNWwKx6O1wXf46q5qOTTesqKliRdiqQIDed3KsyT9+gcBSAg64+LLdc1Li3l2D2pnLQgvmQ== 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)(396003)(346002)(39860400002)(136003)(366004)(451199015)(2906002)(83380400001)(66899015)(64756008)(55016003)(53546011)(66446008)(6506007)(86362001)(38100700002)(8676002)(41300700001)(7696005)(38070700005)(6636002)(33656002)(82960400001)(966005)(186003)(8936002)(478600001)(52536014)(26005)(110136005)(66946007)(9686003)(5660300002)(316002)(66476007)(71200400001)(66556008)(122000001)(76116006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DknjQamlD2hmS4rITyD5SGqXwF7Jf4+ZPKrfbXc046ommOrqKY9hj9NM2AFm?= =?us-ascii?Q?6eVqakJg7jwBwdj5nwNOprNyucLPodeiG6w//Kc0PPRqXC7rnYBfj+F2Vevo?= =?us-ascii?Q?gxKUvTDQR+dBEgtBlKS3lCSWe4GSGyxcLhvN0QxFiEE3f/B3tMtK0U3nDdBO?= =?us-ascii?Q?BW8+9F1tdMRjFpS1Kf07ryz8XlNG/BOTzOqDGrhbRPqTVvz5m7mIU9kKPVHw?= =?us-ascii?Q?aEpfzL1kgkG1QA44rr9Uh2WnPhDxcnTWbQhjCEDUKIj+lvcXnO3X4zIiA6bD?= =?us-ascii?Q?t4XQgYchF7It6DPjJRz3Dt98cn36RJ+RyZ4E6zykIhFTnMXBssdzDLkO6E2G?= =?us-ascii?Q?Eo1c5M06Gn2a62SwqhG0MciQkiT1Uy1IfEx62BPtScdpy4tA48HWGl04shKe?= =?us-ascii?Q?0/zamjR4y8C24vBBLpFOPgDSVdfoCfaXR7ybQLboj+hzu4eqIr0BBH2gK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aHgsVkiXjedg8M9PzuqcnjrEYULj3gtGu2pgTR2gzSg+3fj8bMGz?= =?us-ascii?Q?GLpAxo8pCL08KX2+OOUDLRZBDxToKNAnkeylgZDpc/eummErujRYpGPhhYWv?= =?us-ascii?Q?CdIKfgOz13ZI0zVaxgfvdz/5bekZpPCrC3MmyG6QteXlCFq6iw28HpmbF2Jf?= =?us-ascii?Q?iUPmHN/zstQ2iO5VVzrvvkgIBcbZzX48qNH6xPKsCQRf1rg2iCeg0dv1HqY0?= =?us-ascii?Q?pRTrDH8UDNfk95DUji3nN3wlpvv7z4xgo2vp2VzX?= 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: 593a4fcc-dcf7-44d8-c19b-08daadad0775 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2022 06:26:29.2139 (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: 2/d5Q11Z51SHUH++hDmefeBy3veBv6CNUEMm1slaZl0JuRClTdlY4Bo/O8pQbNAQ6aMwbeh2XQk0s1hfZwTR0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB7040 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 PR failed. https://github.com/tianocore/edk2/pull/3475/checks?check_run_id=3D888569372= 3 > -----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