From patchwork Fri May 15 13:37:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 6414241 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 77B329F1C1 for ; Fri, 15 May 2015 13:41:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8134D2040F for ; Fri, 15 May 2015 13:41:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6820D2039E for ; Fri, 15 May 2015 13:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422996AbbEONlu (ORCPT ); Fri, 15 May 2015 09:41:50 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:47955 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422697AbbEONlu (ORCPT ); Fri, 15 May 2015 09:41:50 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 May 2015 23:41:48 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 May 2015 23:41:45 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id A87032CE8040 for ; Fri, 15 May 2015 23:41:45 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4FDfb6u27787350 for ; Fri, 15 May 2015 23:41:45 +1000 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 t4FDfC1Z013153 for ; Fri, 15 May 2015 23:41:13 +1000 Received: from localhost ([9.123.251.150]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t4FDfCCu012917; Fri, 15 May 2015 23:41:12 +1000 From: Wei Yang To: gwshan@linux.vnet.ibm.com, bhelgaas@google.com Cc: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, Wei Yang Subject: [PATCH V5 10/10] powerpc/powernv: compound PE for VFs Date: Fri, 15 May 2015 21:37:04 +0800 Message-Id: <1431697024-5710-11-git-send-email-weiyang@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1431697024-5710-1-git-send-email-weiyang@linux.vnet.ibm.com> References: <1431697024-5710-1-git-send-email-weiyang@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15051513-0025-0000-0000-0000017D9397 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Wei Yang --- arch/powerpc/platforms/powernv/pci-ioda.c | 50 ++++++++++++++++++++++++++--- arch/powerpc/platforms/powernv/pci.c | 17 ++++++++-- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 920c252..23fe8aa 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1345,6 +1345,7 @@ static void pnv_ioda_release_vf_PE(struct pci_dev *pdev, u16 num_vfs) vf_index < (vf_group + 1) * vf_per_group && vf_index < num_vfs; vf_index++) + for (vf_index1 = vf_group * vf_per_group; vf_index1 < (vf_group + 1) * vf_per_group && vf_index1 < num_vfs; @@ -1363,9 +1364,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 +1430,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 +1476,16 @@ 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 this if we have Compound PE + */ + 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 +1498,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 31d0258..073caec 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)