From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-kernel@vger.kernel.org,
Jayachandran C <jchandra@broadcom.com>,
Sinan Kaya <okaya@codeaurora.org>,
Tomasz Nowicki <tn@semihalf.com>, Arnd Bergmann <arnd@arndb.de>,
Boris Brezillon <boris.brezillon@bootlin.com>,
Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: how to fix acpi_pci_root_remap_iospace?
Date: Fri, 17 Aug 2018 12:24:24 +0100 [thread overview]
Message-ID: <20180817112424.GA31375@e107981-ln.cambridge.arm.com> (raw)
In-Reply-To: <20180816204506.GA21144@agluck-desk>
On Thu, Aug 16, 2018 at 01:45:07PM -0700, Luck, Tony wrote:
> Bjorn,
>
> Back in commit:
>
> 0a70abb38062 ("PCI/ACPI: Support I/O resources when parsing host bridge resources")
>
> we added acpi_pci_root_remap_iospace(). On ia64 this was a no-op because ia64
> didn't define PCI_IOBASE, so the entire body of the function was skipped.
>
> But in the current merge window commit:
>
> 0bbf47eab469 ("ia64: use asm-generic/io.h")
>
> ended up defining PCI_IOBASE for us, and now we die horribly
> in early boot with:
>
> kernel BUG at lib/ioremap.c:72!
>
>
> Is PCI_IOBASE the right thing to check for to decide whether
> acpi_pci_root_remap_iospace() needs to do anything?
>
> The ugly fix would be:
>
>
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 7433035ded95..de06377de13b 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -741,7 +741,7 @@ static void acpi_pci_root_validate_resources(struct device *dev,
> static void acpi_pci_root_remap_iospace(struct fwnode_handle *fwnode,
> struct resource_entry *entry)
> {
> -#ifdef PCI_IOBASE
> +#if defined(PCI_IOBASE) && !defined(CONFIG_IA64)
> struct resource *res = entry->res;
> resource_size_t cpu_addr = res->start;
> resource_size_t pci_addr = cpu_addr - entry->offset;
>
> or we can do some other juggling with defines to get the
> same outcome.
>
> -Tony
If that gives too much trouble we could move
acpi_pci_root_remap_iospace() to arch/arm64 too (patch compile tested
below) given that at the moment it is generic in theory, just let me
know what's the best course of action.
Lorenzo
-- >8 --
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 0e2ea1c78542..06e27879087b 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -98,13 +98,46 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
return 0;
}
+static void acpi_pci_root_remap_iospace(struct fwnode_handle *fwnode,
+ struct resource_entry *entry)
+{
+ struct resource *res = entry->res;
+ resource_size_t cpu_addr = res->start;
+ resource_size_t pci_addr = cpu_addr - entry->offset;
+ resource_size_t length = resource_size(res);
+ unsigned long port;
+
+ if (pci_register_io_range(fwnode, cpu_addr, length))
+ goto err;
+
+ port = pci_address_to_pio(cpu_addr);
+ if (port == (unsigned long)-1)
+ goto err;
+
+ res->start = port;
+ res->end = port + length - 1;
+ entry->offset = port - pci_addr;
+
+ if (pci_remap_iospace(res, cpu_addr) < 0)
+ goto err;
+
+ pr_info("Remapped I/O %pa to %pR\n", &cpu_addr, res);
+ return;
+err:
+ res->flags |= IORESOURCE_DISABLED;
+}
+
static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci)
{
struct resource_entry *entry, *tmp;
+ struct acpi_device *device = ci->bridge;
int status;
status = acpi_pci_probe_root_resources(ci);
resource_list_for_each_entry_safe(entry, tmp, &ci->resources) {
+ if (entry->res->flags & IORESOURCE_IO)
+ acpi_pci_root_remap_iospace(&device->fwnode, entry);
+
if (!(entry->res->flags & IORESOURCE_WINDOW))
resource_list_destroy_entry(entry);
}
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7433035ded95..0f9fb87b6e26 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -738,37 +738,6 @@ static void acpi_pci_root_validate_resources(struct device *dev,
}
}
-static void acpi_pci_root_remap_iospace(struct fwnode_handle *fwnode,
- struct resource_entry *entry)
-{
-#ifdef PCI_IOBASE
- struct resource *res = entry->res;
- resource_size_t cpu_addr = res->start;
- resource_size_t pci_addr = cpu_addr - entry->offset;
- resource_size_t length = resource_size(res);
- unsigned long port;
-
- if (pci_register_io_range(fwnode, cpu_addr, length))
- goto err;
-
- port = pci_address_to_pio(cpu_addr);
- if (port == (unsigned long)-1)
- goto err;
-
- res->start = port;
- res->end = port + length - 1;
- entry->offset = port - pci_addr;
-
- if (pci_remap_iospace(res, cpu_addr) < 0)
- goto err;
-
- pr_info("Remapped I/O %pa to %pR\n", &cpu_addr, res);
- return;
-err:
- res->flags |= IORESOURCE_DISABLED;
-#endif
-}
-
int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info)
{
int ret;
@@ -789,10 +758,6 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info)
"no IO and memory resources present in _CRS\n");
else {
resource_list_for_each_entry_safe(entry, tmp, list) {
- if (entry->res->flags & IORESOURCE_IO)
- acpi_pci_root_remap_iospace(&device->fwnode,
- entry);
-
if (entry->res->flags & IORESOURCE_DISABLED)
resource_list_destroy_entry(entry);
else
prev parent reply other threads:[~2018-08-17 11:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 20:45 Luck, Tony
2018-08-16 21:10 ` Arnd Bergmann
2018-08-16 23:26 ` Luck, Tony
2018-08-17 8:47 ` Arnd Bergmann
2018-08-17 8:55 ` Boris Brezillon
2018-08-17 15:56 ` Luck, Tony
2018-08-17 16:20 ` Boris Brezillon
2018-08-17 19:01 ` Arnd Bergmann
2018-08-20 16:31 ` [PATCH] ia64: Fix kernel BUG at lib/ioremap.c:72! Tony Luck
2018-08-20 19:23 ` Linus Torvalds
2018-08-17 11:24 ` Lorenzo Pieralisi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180817112424.GA31375@e107981-ln.cambridge.arm.com \
--to=lorenzo.pieralisi@arm.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=boris.brezillon@bootlin.com \
--cc=jchandra@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=okaya@codeaurora.org \
--cc=tn@semihalf.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®