From patchwork Wed May 27 19:51:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 6493801 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 A3F139F399 for ; Wed, 27 May 2015 19:52:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67ED620705 for ; Wed, 27 May 2015 19:52:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FFA820702 for ; Wed, 27 May 2015 19:52:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866AbbE0TwZ (ORCPT ); Wed, 27 May 2015 15:52:25 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:58994 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752059AbbE0TwY (ORCPT ); Wed, 27 May 2015 15:52:24 -0400 Received: from wuerfel.localnet ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue104) with ESMTPSA (Nemesis) id 0MAeNv-1Yqnkg3qtX-00Bs8K; Wed, 27 May 2015 21:51:56 +0200 From: Arnd Bergmann To: Fabrice Gasnier Cc: linux-arm-kernel@lists.infradead.org, Zhou Wang , zhudacai@hisilicon.com, devicetree@vger.kernel.org, 'Zhang Jukuo' , 'Gabriele Paoloni' , Jingoo Han , 'Pratyush Anand' , 'Richard Zhu' , 'Zhichang Yuan' , 'Kishon Vijay Abraham I' , qiuzhenfa@hisilicon.com, linux-pci@vger.kernel.org, 'Bjorn Helgaas' , 'Liviu Dudau' , 'Liguozhu' , 'Lucas Stach' Subject: Re: [RFC PATCH v1 1/3] PCI: designware: Add ARM64 support Date: Wed, 27 May 2015 21:51:52 +0200 Message-ID: <16371687.jmfn381VuV@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <5565EEAD.9070003@st.com> References: <000001d096a9$27bf43f0$773dcbd0$@com> <2095085.CuXXeGT0Wg@wuerfel> <5565EEAD.9070003@st.com> MIME-Version: 1.0 X-Provags-ID: V03:K0:c90xAWQQYKZGSvGvBhrvTbCWjuA9Mo2voit0ABoQEQZPz5+1zQ9 GYVmDY48+s4hbhLLuZbdYHHc+cR0t8BG0aJ6Ym5TuZQP49FPI664h+ZwHH22RlFz1opI2UN 2SIlq7jdN+Pd0fGrzGgfmu2WFdfkAAwsN6+0trcd9fJ3Sqeg/D7SPBAgznsnFQ2tXdL1jgu siEP2JXm8sL5RQtzcmCfg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qUuPf9kwLJ8=:PUBgu1D35+kjASvwnEa76k a6Wh04ZdMpt/nhIXQRh5GdXAhUBjv/JXh6wQBoUPTar+I/3NeAta3A6j6sRdnrGLVG75FNQ8g aqY+T2ldPzqTxVNylpXbLWy5vlawyaQfQ8khmQCpUQQevqPLamoNfXPLe+FvpTqpeWPOUYFzg pp1QyailS3NS3ie7dxVdvP7ae1QhL1U3cQyplk3UTYE/kWomd+KJcVBfa5MhvtGxur269xTNO Q3PQf2dtGy8vsp8j4SdCgz7ceMo+uqdK7+T3tWtyzjAsTOoMtyrUrokVi0S1JsFaGAc5qv+aK VjX0awDQvT5atolRUAnx8Tso9tE07UouhAJetY7MJL3KPbx5zEu9UCC7urthb7FKIOiJ4o7FZ jhUohEqo1EdV9Z1tW2p9GI8Zr5EpNTE7Mu7rNkuM9r4vlppk0LOskn0zObskmM2nRwA5HCiQy EVcc8/eniFO5EtxH86tH7QvHZ4xKXwDxKxGPfc9ixSxZrXzIYhz+TcXcHxSxXxX8tVivmxVJN EVHazimj93oC1so/s1jjcOm94HCFlPiJ5G6rsjsbOpImoRKbxwdH1Umk6/xZT3NU9rSJsXIwN SOLjlVEtGLfV6msl+lhc41xfwJFdNO8JQNcjDzoXT9KpF5neyqSCgyPV8yPxRKw2h9FQy0Dxm u9MPKeC6jA+61ohB/nm8o1/oHvT82o9aEowWK9s8cggf59g== 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 On Wednesday 27 May 2015 18:19:57 Fabrice Gasnier wrote: > On 05/27/2015 05:43 PM, Arnd Bergmann wrote: > > On Wednesday 27 May 2015 17:31:46 Arnd Bergmann wrote: > >> Yes, that works. However there are two problems with the approach: > >> > >> - we have to change all PCI host drivers on ARM to do this in order to remove > >> the ARM-specific pcibios_msi_controller() function > >> - it's possible that there are dw_pcie implementations that do not include > >> an MSI controller, so that pointer would be NULL, which leads to the > >> core code to still call the ARM-specific pcibios_msi_controller() function > >> unless we remove it. > > I wonder if this simple patch would be sufficient to kill off > > pcibios_msi_controller(). > > > > Can one of you try it? > > > > Arnd > > Hi Arnd, > I tested it quickly on my platform, with and without CONFIG_PCI_MSI. > In both case it seems to run fine with dw pcie. > Awesome. Now we just need to find a way to move the align_resource callback. I wonder if the approach below would be acceptable. Arnd --- 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/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index fcbbbb1b9e95..20839d26a490 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -597,9 +588,6 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, start = (start + align - 1) & ~(align - 1); - if (sys->align_resource) - return sys->align_resource(dev, res, start, size, align); - return start; } diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 1ab863551920..74216c9c2822 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -751,27 +751,20 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys) return 1; } -static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) +static resource_size_t mvebu_pcie_align_resource(void *data, + const struct resource *res, + resource_size_t size, + resource_size_t align) { - struct mvebu_pcie *pcie = sys_to_pcie(sys); - struct pci_bus *bus; + struct device *dev = data; - bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr, - &mvebu_pcie_ops, sys, &sys->resources); - if (!bus) - return NULL; + resource_size_t start = res->start; - pci_scan_child_bus(bus); + if (res->flags & IORESOURCE_IO && start & 0x300) + start = (start + 0x3ff) & ~0x3ff; - return bus; -} + start = (start + align - 1) & ~(align - 1); -static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, - const struct resource *res, - resource_size_t start, - resource_size_t size, - resource_size_t align) -{ if (dev->bus->number != 0) return start; @@ -796,6 +789,25 @@ static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, return start; } +static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) +{ + struct mvebu_pcie *pcie = sys_to_pcie(sys); + struct pci_host_bridge *phb; + struct pci_bus *bus; + + bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr, + &mvebu_pcie_ops, sys, &sys->resources); + if (!bus) + return NULL; + + phb = pci_find_host_bridge(bus); + phb->align_resource = mvebu_pcie_align_resource; + + pci_scan_child_bus(bus); + + return bus; +} + static void mvebu_pcie_enable(struct mvebu_pcie *pcie) { struct hw_pci hw; @@ -812,7 +824,6 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) hw.scan = mvebu_pcie_scan_bus; hw.map_irq = of_irq_parse_and_map_pci; hw.ops = &mvebu_pcie_ops; - hw.align_resource = mvebu_pcie_align_resource; pci_common_init(&hw); } diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 232f9254c11a..e1f5e13c4636 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -200,7 +200,11 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev, } static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, - int resno, resource_size_t size, resource_size_t align) + int resno, resource_size_t size, resource_size_t align, + resource_size_t (*alignf)(void *, + const struct resource *, + resource_size_t, + resource_size_t)) { struct resource *res = dev->resource + resno; resource_size_t min; @@ -217,7 +221,7 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, */ ret = pci_bus_alloc_resource(bus, res, size, align, min, IORESOURCE_PREFETCH | IORESOURCE_MEM_64, - pcibios_align_resource, dev); + alignf, dev); if (ret == 0) return 0; @@ -229,7 +233,7 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) { ret = pci_bus_alloc_resource(bus, res, size, align, min, IORESOURCE_PREFETCH, - pcibios_align_resource, dev); + alignf, dev); if (ret == 0) return 0; } @@ -242,7 +246,7 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, */ if (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) ret = pci_bus_alloc_resource(bus, res, size, align, min, 0, - pcibios_align_resource, dev); + alignf, dev); return ret; } @@ -251,10 +255,19 @@ static int _pci_assign_resource(struct pci_dev *dev, int resno, resource_size_t size, resource_size_t min_align) { struct pci_bus *bus; + struct pci_host_bridge *phb; int ret; bus = dev->bus; - while ((ret = __pci_assign_resource(bus, dev, resno, size, min_align))) { + phb = pci_find_host_bridge(bus); + + if (phb->align_resource) + alignf = phb->align_resource; + else + alignf = pcibios_align_resource; + + while ((ret = __pci_assign_resource(bus, dev, resno, size, + min_align, alignf))) { if (!bus->parent || !bus->self->transparent) break; bus = bus->parent;