From patchwork Tue Feb 24 08:34:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 5870591 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 3754CBF440 for ; Tue, 24 Feb 2015 08:34:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A03002064F for ; Tue, 24 Feb 2015 08:34:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 976C220658 for ; Tue, 24 Feb 2015 08:34:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750850AbbBXIey (ORCPT ); Tue, 24 Feb 2015 03:34:54 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34750 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751253AbbBXIew (ORCPT ); Tue, 24 Feb 2015 03:34:52 -0500 Received: by pabrd3 with SMTP id rd3so34440757pab.1 for ; Tue, 24 Feb 2015 00:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=9yHmkk6uZVAEtfQaeHVa27cQdi6oMO7jJXWdI4+gc6w=; b=KdvfWm+A9874ysJVL62/OpaZGSLKjb2ssveC3aFhSzUNV6ozjcCv5NAYBvjBkH/mVo upHwO0f5IHrDFBLXFgQ43lF77Rm6W2AoOz2EpWHtXOMOpciqa7Uc4C2C2mUu3PvSrahF xtxHFI/GqDnlbRzUl/0cYKY0eF9gdF+0Ej6JRX48EYutL70eKDlrn4iSMfuw3guUPdyy eNbyu1GhYy2iRo5jqQR14MdWCIk0wOYdHflaFTAjIRYn30YqS2SydtQY8Kr92TUZFeSg +pnvxB2P80DI2KeE5XQ+B0wBmSMqthrWCvzutO+SiNgCSjpIPJZSmQGTDVMjkbsqvIp3 +mnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=9yHmkk6uZVAEtfQaeHVa27cQdi6oMO7jJXWdI4+gc6w=; b=BGtaURADaf27fak0KXeSFkKE/q7ElGLFzpdq/0YIS1leK9OhOMkGIVTeqBy9sDsuu0 Ps6gTb72hSuL7DXidEuU8SgUAxcMtWuZ/NJYp8bbELE1O3+w1Y3RmEcdhpvQRTjFHOss HSLOekMt5k78sn9iF4jbSCMJjyO0eUFmCKW9lej4MDsdE4cqNnCOa9oIQg6qMow2EYyX FYpGLqDoALPv2vlH8y1/FvyuG1M5tdCmr14293kRl0GLm97mnafIrj3sfmqYchj4VgQf jRQYWhy++qvbYk9lm+qYF5ugb1XCMW95Jo/CLqzFr0t4UUdEgiEwP8sIS9nDaofT5iqf ESfw== X-Gm-Message-State: ALoCoQkHnIQXz36viwoX2QzYzkeFgJdWCsVCK8dPyKcSXFWRzX0LCgy9S2qyfH8Bs7cn4c8FIpJY X-Received: by 10.70.23.69 with SMTP id k5mr26407660pdf.68.1424766892464; Tue, 24 Feb 2015 00:34:52 -0800 (PST) Received: from localhost ([12.23.74.29]) by mx.google.com with ESMTPSA id w16sm26828222pbs.35.2015.02.24.00.34.50 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 00:34:50 -0800 (PST) Subject: [PATCH v12 16/21] powerpc/powernv: Implement pcibios_iov_resource_alignment() on powernv To: Wei Yang , benh@au1.ibm.com, gwshan@linux.vnet.ibm.com From: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 24 Feb 2015 02:34:49 -0600 Message-ID: <20150224083449.32124.68975.stgit@bhelgaas-glaptop2.roam.corp.google.com> In-Reply-To: <20150224082939.32124.45744.stgit@bhelgaas-glaptop2.roam.corp.google.com> References: <20150224082939.32124.45744.stgit@bhelgaas-glaptop2.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Wei Yang Implement pcibios_iov_resource_alignment() on powernv platform. On PowerNV platform, there are 3 cases for the IOV BAR: 1. initial state, the IOV BAR size is multiple times of VF BAR size 2. after expanded, the IOV BAR size is expanded to meet the M64 segment size 3. sizing stage, the IOV BAR is truncated to 0 pnv_pci_iov_resource_alignment() handle these three cases respectively. [bhelgaas: adjust to drop "align" parameter, return pci_iov_resource_size() if no ppc_md machdep_call version] Signed-off-by: Wei Yang Signed-off-by: Bjorn Helgaas --- arch/powerpc/include/asm/machdep.h | 1 + arch/powerpc/kernel/pci-common.c | 10 ++++++++++ arch/powerpc/platforms/powernv/pci-ioda.c | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index 965547c58497..045448f9e8b2 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -252,6 +252,7 @@ struct machdep_calls { #ifdef CONFIG_PCI_IOV void (*pcibios_fixup_sriov)(struct pci_bus *bus); + resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno); #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 022e9feeb1f2..2f1ad9ef4402 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -130,6 +130,16 @@ void pcibios_reset_secondary_bus(struct pci_dev *dev) pci_reset_secondary_bus(dev); } +#ifdef CONFIG_PCI_IOV +resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno) +{ + if (ppc_md.pcibios_iov_resource_alignment) + return ppc_md.pcibios_iov_resource_alignment(pdev, resno); + + return pci_iov_resource_size(dev, resno); +} +#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 36c533da5ccb..6a86690bb8de 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1980,6 +1980,25 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus, return phb->ioda.io_segsize; } +#ifdef CONFIG_PCI_IOV +static resource_size_t pnv_pci_iov_resource_alignment(struct pci_dev *pdev, + int resno) +{ + struct pci_dn *pdn = pci_get_pdn(pdev); + resource_size_t align, iov_align; + + iov_align = resource_size(&pdev->resource[resno]); + if (iov_align) + return iov_align; + + align = pci_iov_resource_size(pdev, resno); + if (pdn->max_vfs) + return pdn->max_vfs * align; + + return align; +} +#endif /* CONFIG_PCI_IOV */ + /* Prevent enabling devices for which we couldn't properly * assign a PE */ @@ -2182,6 +2201,7 @@ static 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_iov_resource_alignment = pnv_pci_iov_resource_alignment; #endif /* CONFIG_PCI_IOV */ pci_add_flags(PCI_REASSIGN_ALL_RSRC);