From patchwork Thu Jun 4 06:41:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 6544021 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB8EAC0020 for ; Thu, 4 Jun 2015 06:43:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D724320752 for ; Thu, 4 Jun 2015 06:43:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8FD020762 for ; Thu, 4 Jun 2015 06:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752485AbbFDGno (ORCPT ); Thu, 4 Jun 2015 02:43:44 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:42051 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752457AbbFDGnk (ORCPT ); Thu, 4 Jun 2015 02:43:40 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Jun 2015 16:43:39 +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, 4 Jun 2015 16:43:36 +1000 Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id A6BFB2BB0075; Thu, 4 Jun 2015 16:43:35 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t546hQ1239059552; Thu, 4 Jun 2015 16:43:34 +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 t546h17i005391; Thu, 4 Jun 2015 16:43:03 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t546h1TV004583; Thu, 4 Jun 2015 16:43:01 +1000 Received: from bran.ozlabs.ibm.com (unknown [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 88278A03FE; Thu, 4 Jun 2015 16:42:32 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 9289BE387C; Thu, 4 Jun 2015 16:42:32 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 81DFE9422B2; Thu, 4 Jun 2015 16:42:32 +1000 (AEST) From: Gavin Shan To: linuxppc-dev@lists.ozlabs.org Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, benh@kernel.crashing.org, bhelgaas@google.com, aik@ozlabs.ru, panto@antoniou-consulting.com, robherring2@gmail.com, grant.likely@linaro.org, Gavin Shan Subject: [PATCH v5 23/42] powerpc/powernv: Cleanup on pnv_pci_ioda2_release_dma_pe() Date: Thu, 4 Jun 2015 16:41:52 +1000 Message-Id: <1433400131-18429-24-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433400131-18429-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1433400131-18429-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15060406-0033-0000-0000-0000019AC96C 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 The patch applies cleanup on pnv_pci_ioda2_release_dma_pe(): * Rename it to pnv_pci_ioda2_release_pe_dma() to match the function names used to release resources for one PE in the subsequent patches. * Remove the parameter of PCI device, which is used to figure out device node. VFs don't have associated device nodes in SRIOV case. For other cases, the device node can be figured out from the PCI bus or device the PE was allocated for. Signed-off-by: Gavin Shan --- v5: * Newly introduced --- arch/powerpc/platforms/powernv/pci-ioda.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 3d5aec8d..2e31472 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -197,11 +197,11 @@ static void pnv_pci_ioda2_set_bypass(struct pnv_ioda_pe *pe, bool enable) pe->tce_bypass_enabled = enable; } -static void pnv_pci_ioda2_release_dma_pe(struct pci_dev *dev, - struct pnv_ioda_pe *pe) +static void pnv_pci_ioda2_release_pe_dma(struct pnv_ioda_pe *pe) { - struct iommu_table *tbl; - int64_t rc; + struct iommu_table *tbl; + struct device_node *dn; + int64_t rc; tbl = pe->table_group.tables[0]; rc = pnv_pci_ioda2_unset_window(&pe->table_group, 0); @@ -213,8 +213,20 @@ static void pnv_pci_ioda2_release_dma_pe(struct pci_dev *dev, iommu_group_put(pe->table_group.group); BUG_ON(pe->table_group.group); } + + if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)) + dn = pci_bus_to_OF_node(pe->pbus); + else if (pe->flags & PNV_IODA_PE_DEV) + dn = pci_device_to_OF_node(pe->pdev); +#ifdef CONFIG_PCI_IOV + else if (pe->flags & PNV_IODA_PE_VF) + dn = pci_device_to_OF_node(pe->parent_dev); +#endif + else + dn = NULL; + pnv_pci_ioda2_table_free_pages(tbl); - iommu_free_table(tbl, of_node_full_name(dev->dev.of_node)); + iommu_free_table(tbl, of_node_full_name(dn)); } static int pnv_ioda_set_one_peltv(struct pnv_phb *phb, @@ -1495,14 +1507,14 @@ static void pnv_ioda_release_vf_PE(struct pci_dev *pdev, u16 num_vfs) 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); + pnv_pci_ioda2_release_pe_dma(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); + pnv_pci_ioda2_release_pe_dma(pe); /* Remove from list */ mutex_lock(&phb->ioda.pe_list_mutex);