From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hanjun Guo Subject: Re: [PATCH v3] PCI: ACPI: IA64: fix IO port generic range check Date: Wed, 23 Mar 2016 16:35:30 +0800 Message-ID: <56F25552.3080609@linaro.org> References: <1458558775-6242-1-git-send-email-lorenzo.pieralisi@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1458558775-6242-1-git-send-email-lorenzo.pieralisi@arm.com> Sender: linux-ia64-owner@vger.kernel.org To: Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas , Jiang Liu , Tony Luck , Tomasz Nowicki , Mark Salter , "Rafael J. Wysocki" List-Id: linux-acpi@vger.kernel.org On 2016/3/21 19:12, Lorenzo Pieralisi wrote: > The [0 - 64k] ACPI PCI IO port resource boundary check in: > > acpi_dev_ioresource_flags() > > is currently applied blindly in the ACPI resource parsing to all > architectures, but only x86 suffers from that IO space limitation. > > On arches (ie IA64 and ARM64) where IO space is memory mapped, > the PCI root bridges IO resource windows are firstly initialized from > the _CRS (in acpi_decode_space()) and contain the CPU physical address > at which a root bridge decodes IO space in the CPU physical address > space with the offset value representing the offset required to translate > the PCI bus address into the CPU physical address. > > The IO resource windows are then parsed and updated in arch code > before creating and enumerating PCI buses (eg IA64 add_io_space()) > to map in an arch specific way the obtained CPU physical address range > to a slice of virtual address space reserved to map PCI IO space, > ending up with PCI bridges resource windows containing IO > resources like the following on a working IA64 configuration: > > PCI host bridge to bus 0000:00 > pci_bus 0000:00: root bus resource [io 0x1000000-0x100ffff window] (bus > address [0x0000-0xffff]) > pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000fffff window] > pci_bus 0000:00: root bus resource [mem 0x80000000-0x8fffffff window] > pci_bus 0000:00: root bus resource [mem 0x80004000000-0x800ffffffff window] > pci_bus 0000:00: root bus resource [bus 00] > > This implies that the [0 - 64K] check in acpi_dev_ioresource_flags() > leaves platforms with memory mapped IO space (ie IA64) broken (ie kernel > can't claim IO resources since the host bridge IO resource is disabled > and discarded by ACPI core code, see log on IA64 with missing root bridge > IO resource, silently filtered by current [0 - 64k] check in > acpi_dev_ioresource_flags()): > > PCI host bridge to bus 0000:00 > pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000fffff window] > pci_bus 0000:00: root bus resource [mem 0x80000000-0x8fffffff window] > pci_bus 0000:00: root bus resource [mem 0x80004000000-0x800ffffffff window] > pci_bus 0000:00: root bus resource [bus 00] > > [...] > > pci 0000:00:03.0: [1002:515e] type 00 class 0x030000 > pci 0000:00:03.0: reg 0x10: [mem 0x80000000-0x87ffffff pref] > pci 0000:00:03.0: reg 0x14: [io 0x1000-0x10ff] > pci 0000:00:03.0: reg 0x18: [mem 0x88020000-0x8802ffff] > pci 0000:00:03.0: reg 0x30: [mem 0x88000000-0x8801ffff pref] > pci 0000:00:03.0: supports D1 D2 > pci 0000:00:03.0: can't claim BAR 1 [io 0x1000-0x10ff]: no compatible > bridge window > > For this reason, the IO port resources boundaries check in generic ACPI > parsing code should be guarded with a CONFIG_X86 guard so that more arches > (ie ARM64) can benefit from the generic ACPI resources parsing interface > without incurring in unexpected resource filtering, fixing at the same > time current breakage on IA64. > > This patch factors out IO ports boundary [0 - 64k] check in generic ACPI > code and makes the IO space check X86 specific to make sure that IO > space resources are usable on other arches too. > > Fixes: 3772aea7d6f3 ("ia64/PCI/ACPI: Use common ACPI resource parsing > interface for host bridge") > Signed-off-by: Lorenzo Pieralisi > Cc: Bjorn Helgaas > Cc: Hanjun Guo > Cc: Jiang Liu > Cc: Tony Luck > Cc: Tomasz Nowicki > Cc: Mark Salter > Cc: "Rafael J. Wysocki" > --- > v2 -> v3 > > - Moved IO resource check to generic ACPI resource code > - Dropped Tested-by tags > - Rebased against v4.5 Add this patch on top of Linus's latest tree, and test it on a HP rx2660 IA64 machine, the machine boot with NIC working properly, and no regressions in boot log. Tested-by: Hanjun Guo Thanks Hanjun From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hanjun Guo Date: Wed, 23 Mar 2016 08:35:30 +0000 Subject: Re: [PATCH v3] PCI: ACPI: IA64: fix IO port generic range check Message-Id: <56F25552.3080609@linaro.org> List-Id: References: <1458558775-6242-1-git-send-email-lorenzo.pieralisi@arm.com> In-Reply-To: <1458558775-6242-1-git-send-email-lorenzo.pieralisi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas , Jiang Liu , Tony Luck , Tomasz Nowicki , Mark Salter , "Rafael J. Wysocki" On 2016/3/21 19:12, Lorenzo Pieralisi wrote: > The [0 - 64k] ACPI PCI IO port resource boundary check in: > > acpi_dev_ioresource_flags() > > is currently applied blindly in the ACPI resource parsing to all > architectures, but only x86 suffers from that IO space limitation. > > On arches (ie IA64 and ARM64) where IO space is memory mapped, > the PCI root bridges IO resource windows are firstly initialized from > the _CRS (in acpi_decode_space()) and contain the CPU physical address > at which a root bridge decodes IO space in the CPU physical address > space with the offset value representing the offset required to translate > the PCI bus address into the CPU physical address. > > The IO resource windows are then parsed and updated in arch code > before creating and enumerating PCI buses (eg IA64 add_io_space()) > to map in an arch specific way the obtained CPU physical address range > to a slice of virtual address space reserved to map PCI IO space, > ending up with PCI bridges resource windows containing IO > resources like the following on a working IA64 configuration: > > PCI host bridge to bus 0000:00 > pci_bus 0000:00: root bus resource [io 0x1000000-0x100ffff window] (bus > address [0x0000-0xffff]) > pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000fffff window] > pci_bus 0000:00: root bus resource [mem 0x80000000-0x8fffffff window] > pci_bus 0000:00: root bus resource [mem 0x80004000000-0x800ffffffff window] > pci_bus 0000:00: root bus resource [bus 00] > > This implies that the [0 - 64K] check in acpi_dev_ioresource_flags() > leaves platforms with memory mapped IO space (ie IA64) broken (ie kernel > can't claim IO resources since the host bridge IO resource is disabled > and discarded by ACPI core code, see log on IA64 with missing root bridge > IO resource, silently filtered by current [0 - 64k] check in > acpi_dev_ioresource_flags()): > > PCI host bridge to bus 0000:00 > pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000fffff window] > pci_bus 0000:00: root bus resource [mem 0x80000000-0x8fffffff window] > pci_bus 0000:00: root bus resource [mem 0x80004000000-0x800ffffffff window] > pci_bus 0000:00: root bus resource [bus 00] > > [...] > > pci 0000:00:03.0: [1002:515e] type 00 class 0x030000 > pci 0000:00:03.0: reg 0x10: [mem 0x80000000-0x87ffffff pref] > pci 0000:00:03.0: reg 0x14: [io 0x1000-0x10ff] > pci 0000:00:03.0: reg 0x18: [mem 0x88020000-0x8802ffff] > pci 0000:00:03.0: reg 0x30: [mem 0x88000000-0x8801ffff pref] > pci 0000:00:03.0: supports D1 D2 > pci 0000:00:03.0: can't claim BAR 1 [io 0x1000-0x10ff]: no compatible > bridge window > > For this reason, the IO port resources boundaries check in generic ACPI > parsing code should be guarded with a CONFIG_X86 guard so that more arches > (ie ARM64) can benefit from the generic ACPI resources parsing interface > without incurring in unexpected resource filtering, fixing at the same > time current breakage on IA64. > > This patch factors out IO ports boundary [0 - 64k] check in generic ACPI > code and makes the IO space check X86 specific to make sure that IO > space resources are usable on other arches too. > > Fixes: 3772aea7d6f3 ("ia64/PCI/ACPI: Use common ACPI resource parsing > interface for host bridge") > Signed-off-by: Lorenzo Pieralisi > Cc: Bjorn Helgaas > Cc: Hanjun Guo > Cc: Jiang Liu > Cc: Tony Luck > Cc: Tomasz Nowicki > Cc: Mark Salter > Cc: "Rafael J. Wysocki" > --- > v2 -> v3 > > - Moved IO resource check to generic ACPI resource code > - Dropped Tested-by tags > - Rebased against v4.5 Add this patch on top of Linus's latest tree, and test it on a HP rx2660 IA64 machine, the machine boot with NIC working properly, and no regressions in boot log. Tested-by: Hanjun Guo Thanks Hanjun