From nobody Wed May 15 23:52:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94512+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94512+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1664441392; cv=none; d=zohomail.com; s=zohoarc; b=LC0Y9zsEVbXbOaYjwb7TDc/waZ26zjYf1Wv+l44hqVFhLJ4z2t3R/lTlCDzR4wRBH+JZxyS7bxG76LovPmZXIL7++cPlWIZR9Svpk8jSK/VHsaodFkjJxrIwUCOoZu67zuaNwceLzu2hKNJuE1tlTZFYfRIeefRqFWS0TsreAXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664441392; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ELXiOChPkIQF3TwF5ajhwykA9TuuCwCh2MN7lHG0eJ8=; b=OCOiGdlfSPvQQn3bZLQ7dOc3lkEWFLGGHSu+/FlmwXmRA2/wEfMsr+NUAJNOEADW2bOfBayuTZUjWysVFwEWqOarV/UPjA9Xnn9AODb3OeLAZ6WG9qVdb9nLI7u/t1rRRvJzd+w5tqZOEz90Rfi2GHFP/uPCbGMoRapRY9KHiGU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94512+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664441392109629.4382000608638; Thu, 29 Sep 2022 01:49:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id j3IVYY1788612xWENx07tu5G; Thu, 29 Sep 2022 01:49:50 -0700 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web10.7924.1664441389908235125 for ; Thu, 29 Sep 2022 01:49:50 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="282201715" X-IronPort-AV: E=Sophos;i="5.93,354,1654585200"; d="scan'208";a="282201715" X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 01:49:48 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="622273171" X-IronPort-AV: E=Sophos;i="5.93,354,1654585200"; d="scan'208";a="622273171" X-Received: from bfeng1-mobl.ccr.corp.intel.com ([10.238.5.140]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 01:49:47 -0700 From: "Bob Feng" To: devel@edk2.groups.io Cc: Foster Nong Subject: [edk2-devel] [PATCH] MdeModulePkg: Handle InitialVFs=0 case for SR-IOV Date: Thu, 29 Sep 2022 16:49:40 +0800 Message-Id: <14266957051500e82d927d794b07e44954db06c3.1664416117.git.foster.nong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,bob.c.feng@intel.com X-Gm-Message-State: Y4s4yYYgKYTuoE8oZ2iCCCR0x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664441390; bh=t4f88H26c+IffhZ6ItZRJTDbqoTALFOUzbUqdHw+fpk=; h=Cc:Date:From:Reply-To:Subject:To; b=kS4HwVQW4a29o84DcWS5oDGErHd2rYiDSjKwEI+tg+6qBdXQLiLgI08G9ss+t5iQ+Q5 DdRqgCEYNGnMEYzCYapRHsdVeiiw5oEKv3TY4KHpDv7/jAwpvGPELyvsMZY5McHuefzdR ifdai1XkFcOTbr875xhcFJlOuvTUr1TAB98= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664441393592100002 Content-Type: text/plain; charset="utf-8" From: Foster Nong Per SR-IOV spec,InitialVFs minimum is 0. Below code which use to calculate = SR-IOV bus number, if InitialVFs =3D0, it maybe calculate the wrong bus number. LastVF =3D PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride we can fix it with below code: if (PciIoDevice->InitialVFs =3D=3D 0) { PciIoDevice->ReservedBusNum =3D 0; } else { PFRid =3D EFI_PCI_RID (Bus, Device, Func); LastVF =3D PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStrid= e; // // Calculate ReservedBusNum for this PF // PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus = + 1); // // Calculate ReservedBusNum for this PF // PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus= + 1); } https://bugzilla.tianocore.org/show_bug.cgi?id=3D4069 Signed-off-by: Foster Nong --- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeMod= ulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index 509f828b62..eb250f6f7b 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -2416,13 +2416,17 @@ CreatePciIoDevice ( // // Calculate LastVF // - PFRid =3D EFI_PCI_RID (Bus, Device, Func); - LastVF =3D PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * V= FStride; + if (PciIoDevice->InitialVFs =3D=3D 0) { + PciIoDevice->ReservedBusNum =3D 0; + } else { + PFRid =3D EFI_PCI_RID (Bus, Device, Func); + LastVF =3D PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) *= VFStride; =20 - // - // Calculate ReservedBusNum for this PF - // - PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastVF)= - Bus + 1); + // + // Calculate ReservedBusNum for this PF + // + PciIoDevice->ReservedBusNum =3D (UINT16)(EFI_PCI_BUS_OF_RID (LastV= F) - Bus + 1); + } =20 DEBUG (( DEBUG_INFO, --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94512): https://edk2.groups.io/g/devel/message/94512 Mute This Topic: https://groups.io/mt/93990439/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-