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.15924.1665542226696379833 for ; Tue, 11 Oct 2022 19:37:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=VrP1MRiL; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: foster.nong@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665542226; x=1697078226; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nYK3l1M7pInY9h7fZ+ujqkzb1AA2oYoA4/f5QQxuVEU=; b=VrP1MRiLfA7BSrDg5GIe4nfLsrQiWHxZVlTqZIuB/ZAQ7FJ+yVEapyXp oWvQsR/w3JmhRS2yybXcWowNOwNN7n9bVfzlGhDm0WNai+jywJQW3KLGO ehp071HwWLVEqx7nNx9zlqRRaeFAerD/cRISw8u48eKVh+JzOL24zl2af ZE8lWFf8Wrc080L5vQ8t0mbi9ka/l82TiaVC4+31L4c5vjG7E47uNkU8U wRQ8BFzK/5OcvN5vxwIds61gq9GWnQuopy3/ZX8hvTzNsDYqLR2h4oqTc MqntSiNGiM5vYw+9hGmMvNeLv5Z+jKIbBpdyRhY0vs4NPF52qLxArec43 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10497"; a="366679147" X-IronPort-AV: E=Sophos;i="5.95,177,1661842800"; d="scan'208";a="366679147" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2022 19:37:06 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10497"; a="715751484" X-IronPort-AV: E=Sophos;i="5.95,177,1661842800"; d="scan'208";a="715751484" Received: from shwdeopenlab108.ccr.corp.intel.com ([10.239.56.147]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2022 19:37:05 -0700 From: Foster Nong To: devel@edk2.groups.io Cc: Foster Nong Subject: [PATCH v2 1/2] MdeModulePkg: Fixed extra 1 SR-IOV reserved bus Date: Wed, 12 Oct 2022 10:36:55 +0800 Message-Id: <20221012023656.1565-1-foster.nong@intel.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Below code will calculate the reserved bus number for the each PF. Based on the VF routing ID algorithm, PFRid and LastVF in below code already sure that "All VFs and PFs must have distinct Routing IDs". PF will be assigned Routing ID based on secBusNumber, ReservedBusNum will add into SubBusNumber directly. So the SR-IOV device will be assigned bus range as SecBusNumber ~ (SubBusNumber=3D(SecBusNumber + ReservedBusNum)). Thus "+1" in below code will cause extra 1 bus, and introduce a bus hole. PFRid =3D EFI_PCI_RID (Bus, Device, Func); LastVF =3D PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStrid= e; PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus + 1); In SR-IOV spec, there is a note in section 2.1.2: Note: Bus Numbers are a constrained resource. Devices are strongly encouraged to avoid leaving =E2=80=9Choles=E2=80=9D in their Bus Number usa= ge to avoid wasting Bus Numbers So the issue can be fixed with below code change. PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus); https://bugzilla.tianocore.org/show_bug.cgi?id=3D4069 Signed-off-by: Foster Nong --- MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeMod= ulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index eb250f6f7b..bc20da1f38 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -2425,7 +2425,7 @@ CreatePciIoDevice ( //=0D // Calculate ReservedBusNum for this PF=0D //=0D - PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastV= F) - Bus + 1);=0D + PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastV= F) - Bus);=0D }=0D =0D DEBUG ((=0D --=20 2.37.1.windows.1