From patchwork Wed Aug 16 16:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9904165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BCC31600CA for ; Wed, 16 Aug 2017 16:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD8F428A1B for ; Wed, 16 Aug 2017 16:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A289F28A4A; Wed, 16 Aug 2017 16:53:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BA6828A1B for ; Wed, 16 Aug 2017 16:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751782AbdHPQx0 (ORCPT ); Wed, 16 Aug 2017 12:53:26 -0400 Received: from mout.gmx.net ([212.227.17.22]:62118 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751772AbdHPQx0 (ORCPT ); Wed, 16 Aug 2017 12:53:26 -0400 Received: from ls3530.fritz.box ([193.159.28.120]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LejNC-1dExaz07As-00qUrQ; Wed, 16 Aug 2017 18:53:19 +0200 Date: Wed, 16 Aug 2017 18:53:16 +0200 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc: Fix up devices below a PCI-PCI MegaRAID controller bridge Message-ID: <20170816165316.GA11396@ls3530.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) X-Provags-ID: V03:K0:5nuLB1O7nzIZOEWQMWILbpySsvLa5ZCdYUnsJQc2fUHhbjck6uP JK1HlXdB1KjAEuJNax3wrbSRpXV7GZKzUTQW2t8UxfWFCMsjDo6jsB5rkIWbMAHXz3aathX NhnnXPXhIKpYBDL/5PSvza/QbIekl8nvnhEZUbZCLoK+SMf7WN8uEZpn2kP2WS1v3JYIzn2 BWI+SQsr3tsCYxSn/KqJg== X-UI-Out-Filterresults: notjunk:1; V01:K0:uS5RoR/92hQ=:H3bh3m8/fIdT+IZPaElFH4 ozAlduFnU77o5K6JvZtWAPPNT9sfWsC77aw6MCbv19hIm1nzias2rX04Kj3WbniKVCve4d0HR rUDepl5h5M5QN5t9f7sqGISejxaUTD5aUYiSYJHxvgAEP1J5WksM/G1a9knlMjIQ7Febbw7xL 8jBUpzPB/QNwIbQoYkJDsY1N7/cwsmNbhqnAqm9CNniTbyhVlB0k1hFGwjsjtRINBujpadacz t9UNYucDoWLcK+cGpvTohhiFlrTwMEPqjoUwHUNZtDXRLqlTgcgvaKwaBjbIkGSXnEj2A+PaI Svcyn9pI3CYMkzC151bpKePuKiYmzXGDGsmpUrBzne7msrgxch54nmd4sbLMXmZ+smk8ER43o iIG8i2McuQ/2nKyHw25LV34On/vzCjGkRng1dx0oMNWCP4Wxqx53I7uoezV4M6iZI1DMdTH85 3O4/xiwS3k0wty6UqmsS1Le6U134sCllN0BENQkredUFjJ2EFWSQCG0Rv8VpMcTydHCnZwNxi EDKer8iPlIKmpZK/p4q8WCcGx9gvp1pEsActZnVaakbH2dpOSSJ7JnI9hdfNEhr4jSyOiSk7R jl5SNZJlrcUmDb3UOW7dpGaq6/6LfU5gnmy4cVVNJpkNa3NEJPnUYZzLfvenWT8J+bU/tLgIn ry9V5RHmDWDAUCYtSDHDSNjA7LQDSPJNsDHOdjG7CzXF3xOmLZNB9TEFQ7Seek8FlRCH+MUWZ kDCPVcGy2BN8djjJUbnrThcoTYE8VzbR8EPgKIHiCs4onrbPrXNpwqc1HRn7QNelEcaAE4uif BE4InxAFGB0xFpsYN34ZQvKmYwQmg== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A MegaRAID PCI card in my rp5470 acts as PCI-PCI bridge. Resource allocation for PCI devices behind such a bridge is quite incomplete, so that syslog reports those warnings: LBA 0:10: PCI host bridge to bus 0000:50 pci_bus 0000:50: root bus resource [io 0x80000-0x8ffff] (bus address [0x0000-0xffff]) pci_bus 0000:50: root bus resource [mem 0xffffffff94000000-0xffffffff95ffffff] (bus address [0x94000000-0x95ffffff]) pci_bus 0000:50: root bus resource [bus 50-57] pci 0000:50:00.0: [8086:0964] type 01 class 0x060400 pci 0000:50:00.1: [8086:1960] type 00 class 0x0e0001 pci 0000:50:00.1: reg 0x10: [mem 0x00000000-0x003fffff pref] pci 0000:50:00.1: reg 0x30: [mem 0x00000000-0x00007fff pref] pci 0000:50:00.0: Changing bridge control from 0x00000000 to 0x00000023 pci_bus 0000:51: busn_res: can not insert [bus 51-ff] under [bus 50-57] (conflicts with (null) [bus 50-57]) pci 0000:50:00.0: PCI bridge to [bus 51-ff] pci 0000:50:00.0: bridge window [io 0x80000-0x80fff] pci 0000:50:00.0: bridge window [mem 0x00000000-0x000fffff] pci 0000:50:00.0: bridge window [mem 0x00000000-0x000fffff pref] pci 0000:50:00.0: can't claim BAR 14 [mem 0x00000000-0x000fffff]: no compatible bridge window pci 0000:50:00.0: can't claim BAR 15 [mem 0x00000000-0x000fffff pref]: no compatible bridge window pci 0000:50:00.0: can't claim BAR 16 [??? 0x00000000 flags 0x0]: no compatible bridge window pci_bus 0000:51: busn_res: [bus 51-ff] end is updated to 51 pci 0000:50:00.0: BAR 16: [??? 0x00000000 flags 0x20000000] has bogus alignment pci 0000:50:00.1: BAR 0: assigned [mem 0xffffffff94000000-0xffffffff943fffff pref] pci 0000:50:00.0: BAR 14: assigned [mem 0xffffffff94400000-0xffffffff944fffff] pci 0000:50:00.0: BAR 15: assigned [mem 0xffffffff94500000-0xffffffff945fffff pref] pci 0000:50:00.1: BAR 6: assigned [mem 0xffffffff94600000-0xffffffff94607fff pref] pci 0000:50:00.0: PCI bridge to [bus 51] pci 0000:50:00.0: bridge window [io 0x80000-0x80fff] pci 0000:50:00.0: bridge window [mem 0xffffffff94400000-0xffffffff944fffff] pci 0000:50:00.0: bridge window [mem 0xffffffff94500000-0xffffffff945fffff pref] The patch below tries to improve the resource allocation. Output is now: LBA 0:10: PCI host bridge to bus 0000:50 pci_bus 0000:50: root bus resource [io 0x80000-0x8ffff] (bus address [0x0000-0xffff]) pci_bus 0000:50: root bus resource [mem 0xffffffff94000000-0xffffffff95ffffff] (bus address [0x94000000-0x95ffffff]) pci_bus 0000:50: root bus resource [bus 50-57] pci 0000:50:00.0: Changing bridge control from 0x00000000 to 0x00000023 pci 0000:50:00.0: PCI bridge to [bus 51-ff] pci 0000:50:00.1: BAR 0: assigned [mem 0xffffffff94000000-0xffffffff943fffff pref] pci 0000:50:00.1: BAR 6: assigned [mem 0xffffffff94400000-0xffffffff94407fff pref] pci 0000:50:00.0: PCI bridge to [bus 51] pci 0000:50:00.0: bridge window [io 0x80000-0x80fff] Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" 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/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index bc286cb..4dc6df3 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -667,6 +667,42 @@ extend_lmmio_len(unsigned long start, unsigned long end, unsigned long lba_len) #define truncate_pat_collision(r,n) (0) #endif +static void pcibios_allocate_bridge_resources(struct pci_dev *dev) +{ + int idx; + struct resource *r; + + for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { + r = &dev->resource[idx]; + if (!r->flags) + continue; + if (r->parent) /* Already allocated */ + continue; + if (!r->start || pci_claim_bridge_resource(dev, idx) < 0) { + /* + * Something is wrong with the region. + * Invalidate the resource to prevent + * child resource allocations in this + * range. + */ + r->start = r->end = 0; + r->flags = 0; + } + } +} + +static void pcibios_allocate_bus_resources(struct pci_bus *bus) +{ + struct pci_bus *child; + + /* Depth-First Search on bus tree */ + if (bus->self) + pcibios_allocate_bridge_resources(bus->self); + list_for_each_entry(child, &bus->children, node) + pcibios_allocate_bus_resources(child); +} + + /* ** The algorithm is generic code. ** But it needs to access local data structures to get the IRQ base. @@ -693,11 +729,11 @@ lba_fixup_bus(struct pci_bus *bus) ** pci_alloc_primary_bus() mangles this. */ if (bus->parent) { - int i; /* PCI-PCI Bridge */ pci_read_bridge_bases(bus); - for (i = PCI_BRIDGE_RESOURCES; i < PCI_NUM_RESOURCES; i++) - pci_claim_bridge_resource(bus->self, i); + + /* check an allocate bridge resources */ + pcibios_allocate_bus_resources(bus); } else { /* Host-PCI Bridge */ int err;