From patchwork Thu Jun 18 08:06:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 486135 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6932814016A for ; Thu, 18 Jun 2015 18:19:50 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4FB631A2D85 for ; Thu, 18 Jun 2015 18:19:50 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id AD2011A0F12 for ; Thu, 18 Jun 2015 18:09:08 +1000 (AEST) Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Jun 2015 18:09:08 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 18 Jun 2015 18:09:05 +1000 X-Helo: d23dlp02.au.ibm.com X-MailFrom: weiyang@linux.vnet.ibm.com X-RcptTo: linuxppc-dev@lists.ozlabs.org Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 37CAB2BB0052 for ; Thu, 18 Jun 2015 18:09:05 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t5I88vt643909352 for ; Thu, 18 Jun 2015 18:09:05 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t5I88WOB005057 for ; Thu, 18 Jun 2015 18:08:32 +1000 Received: from localhost ([9.123.251.122]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t5I88VtF004675; Thu, 18 Jun 2015 18:08:32 +1000 From: Wei Yang To: gwshan@linux.vnet.ibm.com, bhelgaas@google.com Subject: [PATCH V8 10/10] powerpc/powernv: compound PE for VFs Date: Thu, 18 Jun 2015 16:06:45 +0800 Message-Id: <1434614805-19002-11-git-send-email-weiyang@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1434614805-19002-1-git-send-email-weiyang@linux.vnet.ibm.com> References: <1434614805-19002-1-git-send-email-weiyang@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15061808-0033-0000-0000-000001A853D8 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, Wei Yang , linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When VF BAR size is larger than 64MB, we group VFs in terms of M64 BAR, which means those VFs in a group should form a compound PE. This patch links those VF PEs into compound PE in this case. [gwshan: code refactoring for a bit] Signed-off-by: Wei Yang Acked-by: Gavin Shan --- arch/powerpc/platforms/powernv/pci-ioda.c | 46 +++++++++++++++++++++++++---- arch/powerpc/platforms/powernv/pci.c | 17 +++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index f8bc950..56e7b65 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1363,9 +1363,20 @@ static void pnv_ioda_release_vf_PE(struct pci_dev *pdev, u16 num_vfs) } list_for_each_entry_safe(pe, pe_n, &phb->ioda.pe_list, list) { + struct pnv_ioda_pe *s, *sn; if (pe->parent_dev != pdev) continue; + if ((pe->flags & PNV_IODA_PE_MASTER) && + (pe->flags & PNV_IODA_PE_VF)) { + list_for_each_entry_safe(s, sn, &pe->slaves, list) { + pnv_pci_ioda2_release_dma_pe(pdev, s); + list_del(&s->list); + pnv_ioda_deconfigure_pe(phb, s); + pnv_ioda_free_pe(phb, s->pe_number); + } + } + pnv_pci_ioda2_release_dma_pe(pdev, pe); /* Remove from list */ @@ -1418,7 +1429,7 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) struct pci_bus *bus; struct pci_controller *hose; struct pnv_phb *phb; - struct pnv_ioda_pe *pe; + struct pnv_ioda_pe *pe, *master_pe; int pe_num; u16 vf_index; struct pci_dn *pdn; @@ -1464,10 +1475,13 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) GFP_KERNEL, hose->node); pe->tce32_table->data = pe; - /* Put PE to the list */ - mutex_lock(&phb->ioda.pe_list_mutex); - list_add_tail(&pe->list, &phb->ioda.pe_list); - mutex_unlock(&phb->ioda.pe_list_mutex); + /* Put PE to the list, or postpone it for compound PEs */ + if ((pdn->m64_per_iov != M64_PER_IOV) || + (num_vfs <= M64_PER_IOV)) { + mutex_lock(&phb->ioda.pe_list_mutex); + list_add_tail(&pe->list, &phb->ioda.pe_list); + mutex_unlock(&phb->ioda.pe_list_mutex); + } pnv_pci_ioda2_setup_dma_pe(phb, pe); } @@ -1480,10 +1494,32 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) vf_per_group = roundup_pow_of_two(num_vfs) / pdn->m64_per_iov; for (vf_group = 0; vf_group < M64_PER_IOV; vf_group++) { + master_pe = NULL; + for (vf_index = vf_group * vf_per_group; vf_index < (vf_group + 1) * vf_per_group && vf_index < num_vfs; vf_index++) { + + /* + * Figure out the master PE and put all slave + * PEs to master PE's list. + */ + pe = &phb->ioda.pe_array[pdn->offset + vf_index]; + if (!master_pe) { + pe->flags |= PNV_IODA_PE_MASTER; + INIT_LIST_HEAD(&pe->slaves); + master_pe = pe; + mutex_lock(&phb->ioda.pe_list_mutex); + list_add_tail(&pe->list, &phb->ioda.pe_list); + mutex_unlock(&phb->ioda.pe_list_mutex); + } else { + pe->flags |= PNV_IODA_PE_SLAVE; + pe->master = master_pe; + list_add_tail(&pe->list, + &master_pe->slaves); + } + for (vf_index1 = vf_group * vf_per_group; vf_index1 < (vf_group + 1) * vf_per_group && vf_index1 < num_vfs; diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 10bc8c3..717a58e 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c @@ -667,7 +667,7 @@ static void pnv_pci_dma_dev_setup(struct pci_dev *pdev) struct pci_controller *hose = pci_bus_to_host(pdev->bus); struct pnv_phb *phb = hose->private_data; #ifdef CONFIG_PCI_IOV - struct pnv_ioda_pe *pe; + struct pnv_ioda_pe *pe, *slave; struct pci_dn *pdn; /* Fix the VF pdn PE number */ @@ -679,10 +679,23 @@ static void pnv_pci_dma_dev_setup(struct pci_dev *pdev) (pdev->devfn & 0xff))) { pdn->pe_number = pe->pe_number; pe->pdev = pdev; - break; + goto found; + } + + if ((pe->flags & PNV_IODA_PE_MASTER) && + (pe->flags & PNV_IODA_PE_VF)) { + list_for_each_entry(slave, &pe->slaves, list) { + if (slave->rid == ((pdev->bus->number << 8) + | (pdev->devfn & 0xff))) { + pdn->pe_number = slave->pe_number; + slave->pdev = pdev; + goto found; + } + } } } } +found: #endif /* CONFIG_PCI_IOV */ if (phb && phb->dma_dev_setup)