linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: benh@kernel.crashing.org, paulus@samba.org, aik@ozlabs.ru,
	Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [PATCH 2/2] powerpc/powernv: Double VF BAR size for compound PE
Date: Fri, 17 Jul 2015 10:14:43 +1000	[thread overview]
Message-ID: <1437092083-20672-3-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1437092083-20672-1-git-send-email-gwshan@linux.vnet.ibm.com>

When VF BAR size is equal to 128MB or bigger than that, we extend
the corresponding PF's IOV BAR to cover number of total VFs supported
by the PF. Otherwise, we extend the PF's IOV BAR to cover 256 VFs.
For the former case, we have to create compound PE, which includes
4 VFs. Those 4 VFs included in the compound PE can't be passed through
to different guests, which isn't good.

The gate (128MB) was choosen based on the assumption that each PHB
supports 64GB M64 space and one PF's IOV BAR can be extended to be
as huge as 1/4 of that, which is 16GB. However, the IOV BAR can be
extended to half of PHB's M64 window when the PF seats behind the
root port. In that case, the gate can be enlarged to be 256MB to
avoid compound PE as we can.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 6ec62b9..5b2e88f 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2721,6 +2721,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
 	struct resource *res;
 	int i;
 	resource_size_t size;
+	resource_size_t limit;
 	struct pci_dn *pdn;
 	int mul, total_vfs;
 
@@ -2730,6 +2731,18 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
 	hose = pci_bus_to_host(pdev->bus);
 	phb = hose->private_data;
 
+	/*
+	 * When the PF seats behind root port, the IOV BAR can
+	 * consume half of the PHB's M64 window. Otherwise,
+	 * 1/4 of the PHB's M64 window can be consumed to the
+	 * maximal degree.
+	 */
+	if (!pci_is_root_bus(pdev->bus) &&
+	    pci_is_root_bus(pdev->bus->self->bus))
+		limit = 128;
+	else
+		limit = 256;
+
 	pdn = pci_get_pdn(pdev);
 	pdn->vfs_expanded = 0;
 
@@ -2748,11 +2761,9 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
 		}
 
 		size = pci_iov_resource_size(pdev, i + PCI_IOV_RESOURCES);
-
-		/* bigger than 64M */
-		if (size > (1 << 26)) {
-			dev_info(&pdev->dev, "PowerNV: VF BAR%d: %pR IOV size is bigger than 64M, roundup power2\n",
-				 i, res);
+		if (size >= (limit * 0x100000)) {
+			dev_info(&pdev->dev, "PowerNV: VF BAR%d: %pR IOV size is bigger than %lldMB, roundup power2\n",
+				 i, res, limit);
 			pdn->m64_per_iov = M64_PER_IOV;
 			mul = roundup_pow_of_two(total_vfs);
 			break;
-- 
2.1.0

  parent reply	other threads:[~2015-07-17  0:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  0:14 [PATCH 0/2] powerpc/powernv: Avoid compound PE for VF Gavin Shan
2015-07-17  0:14 ` [PATCH 1/2] powerpc/powernv: Fix alignment for IOV BAR Gavin Shan
2015-07-17  0:14 ` Gavin Shan [this message]
2015-07-17  0:28   ` [PATCH 2/2] powerpc/powernv: Double VF BAR size for compound PE Gavin Shan
2015-07-29 23:06 ` [PATCH 0/2] powerpc/powernv: Avoid compound PE for VF Gavin Shan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437092083-20672-3-git-send-email-gwshan@linux.vnet.ibm.com \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=aik@ozlabs.ru \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).