From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e23smtp07.au.ibm.com ([202.81.31.140]:49813 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752045AbaKBPmR (ORCPT ); Sun, 2 Nov 2014 10:42:17 -0500 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Nov 2014 01:42:16 +1000 Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id EE8CB2CE8047 for ; Mon, 3 Nov 2014 02:42:13 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sA2FiC9539846132 for ; Mon, 3 Nov 2014 02:44:12 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sA2FgCL6028470 for ; Mon, 3 Nov 2014 02:42:13 +1100 From: Wei Yang To: bhelgaas@google.com, benh@au1.ibm.com, gwshan@linux.vnet.ibm.com, linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: Wei Yang Subject: [PATCH V9 15/18] powerpc/powernv: Shift VF resource with an offset Date: Sun, 2 Nov 2014 23:41:31 +0800 Message-Id: <1414942894-17034-16-git-send-email-weiyang@linux.vnet.ibm.com> In-Reply-To: <1414942894-17034-1-git-send-email-weiyang@linux.vnet.ibm.com> References: <1414942894-17034-1-git-send-email-weiyang@linux.vnet.ibm.com> Sender: linux-pci-owner@vger.kernel.org List-ID: On PowrNV platform, resource position in M64 implies the PE# the resource belongs to. In some particular case, adjustment of a resource is necessary to locate it to a correct position in M64. This patch introduces a function to shift the 'real' PF IOV BAR address according to an offset. Signed-off-by: Wei Yang --- arch/powerpc/platforms/powernv/pci-ioda.c | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index f7abba3..5034a3c 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -644,6 +645,36 @@ static unsigned int pnv_ioda_dma_weight(struct pci_dev *dev) return 10; } +#ifdef CONFIG_PCI_IOV +static void pnv_pci_vf_resource_shift(struct pci_dev *dev, int offset) +{ + struct pci_dn *pdn = pci_get_pdn(dev); + int i; + struct resource *res; + resource_size_t size; + + if (!dev->is_physfn) + return; + + for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { + res = &dev->resource[i]; + if (!res->flags || !res->parent) + continue; + + if (!pnv_pci_is_mem_pref_64(res->flags)) + continue; + + dev_info(&dev->dev, " Shifting VF BAR %pR to\n", res); + size = pci_iov_resource_size(dev, i); + res->start += size*offset; + + dev_info(&dev->dev, " %pR\n", res); + pci_update_resource(dev, i); + } + pdn->max_vfs -= offset; +} +#endif /* CONFIG_PCI_IOV */ + #if 0 static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev) { -- 1.7.9.5