From patchwork Thu Jul 24 06:22:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 4614661 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3E9C49F37C for ; Thu, 24 Jul 2014 06:23:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C1FB201D3 for ; Thu, 24 Jul 2014 06:23:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C671201DD for ; Thu, 24 Jul 2014 06:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758723AbaGXGXD (ORCPT ); Thu, 24 Jul 2014 02:23:03 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:32867 "EHLO e28smtp01.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758699AbaGXGXB (ORCPT ); Thu, 24 Jul 2014 02:23:01 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 Jul 2014 11:52:58 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 Jul 2014 11:52:56 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id D51EB394005C for ; Thu, 24 Jul 2014 11:52:54 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6O6NElo1048924 for ; Thu, 24 Jul 2014 11:53:14 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s6O6MrXW007977 for ; Thu, 24 Jul 2014 11:52:53 +0530 Received: from localhost (richard.cn.ibm.com [9.111.17.69]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s6O6MqDk007951; Thu, 24 Jul 2014 11:52:53 +0530 From: Wei Yang To: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, bhelgaas@google.com, benh@au1.ibm.com, gwshan@linux.vnet.ibm.com, yan@linux.vnet.ibm.com, qiudayu@linux.vnet.ibm.com Cc: Wei Yang Subject: [PATCH V7 13/17] powerpc/powernv: Implement pcibios_sriov_resource_alignment on powernv Date: Thu, 24 Jul 2014 14:22:23 +0800 Message-Id: <1406182947-11302-14-git-send-email-weiyang@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1406182947-11302-1-git-send-email-weiyang@linux.vnet.ibm.com> References: <1406182947-11302-1-git-send-email-weiyang@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14072406-4790-0000-0000-000002DCA1C5 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, 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 This patch implements the pcibios_sriov_resource_alignment() on powernv platform. Signed-off-by: Wei Yang --- arch/powerpc/include/asm/machdep.h | 3 +++ arch/powerpc/kernel/pci-common.c | 14 ++++++++++++++ arch/powerpc/platforms/powernv/pci-ioda.c | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index fabb8016..5c023be 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -254,6 +254,9 @@ struct machdep_calls { #ifdef CONFIG_PCI_IOV void (*pcibios_fixup_sriov)(struct pci_bus *bus); + resource_size_t (*pcibios_sriov_resource_alignment)(struct pci_dev *, + int resno, + resource_size_t align); #endif /* CONFIG_PCI_IOV */ /* Called to shutdown machine specific hardware not already controlled diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index c2b7930..942a3e5 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -140,6 +140,20 @@ void pcibios_reset_secondary_bus(struct pci_dev *dev) ssleep(1); } +#ifdef CONFIG_PCI_IOV +resource_size_t pcibios_sriov_resource_alignment(struct pci_dev *pdev, + int resno, + resource_size_t align) +{ + if (ppc_md.pcibios_sriov_resource_alignment) + return ppc_md.pcibios_sriov_resource_alignment(pdev, + resno, + align); + + return 0; +} +#endif /* CONFIG_PCI_IOV */ + static resource_size_t pcibios_io_size(const struct pci_controller *hose) { #ifdef CONFIG_PPC64 diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 6fd2377..3aeb87b 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1767,6 +1767,23 @@ resource_size_t pnv_pci_sriov_resource_size(struct pci_dev *pdev, int resno) return size; } + +static resource_size_t pnv_pcibios_sriov_resource_alignment(struct pci_dev *pdev, + int resno, + resource_size_t align) +{ + struct pci_dn *pdn = pci_get_pdn(pdev); + resource_size_t iov_align; + + iov_align = resource_size(&pdev->resource[resno]); + if (iov_align) + return iov_align; + + if (pdn->vfs) + return pdn->vfs * align; + + return align; +} #endif /* CONFIG_PCI_IOV */ /* Prevent enabling devices for which we couldn't properly @@ -1976,6 +1993,7 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, ppc_md.pcibios_reset_secondary_bus = pnv_pci_reset_secondary_bus; #ifdef CONFIG_PCI_IOV ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_sriov; + ppc_md.pcibios_sriov_resource_alignment = pnv_pcibios_sriov_resource_alignment; #endif /* CONFIG_PCI_IOV */ pci_add_flags(PCI_REASSIGN_ALL_RSRC);