All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jayachandran C <jchandra@broadcom.com>
To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	linux-acpi@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	linux-arm-kernel@lists.infradead.org,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Tomasz Nowicki <tn@semihalf.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Jayachandran C <jchandra@broadcom.com>,
	xen-devel@lists.xenproject.org
Subject: [PATCH v6 3/5] ACPI: PCI: Support platforms that need pci_remap_iospace
Date: Thu, 14 Jan 2016 13:02:39 +0530	[thread overview]
Message-ID: <1452756761-29584-4-git-send-email-jchandra__35774.0037296482$1452755716$gmane$org@broadcom.com> (raw)
In-Reply-To: <1452756761-29584-1-git-send-email-jchandra@broadcom.com>

On some platforms (in this case ARM64), the PCI iospace needs to
be mapped with pci_remap_iospace and the resources have to be
adjusted for the iospace physical address.

This has to be done before acpi_pci_root_validate_resources()
checks and removes resource windows. Handle this by adding
a function acpi_pci_root_remap_iospace that is called in
acpi_pci_probe_root_resources(), before the validate call.

Also fix the address check in acpi_dev_ioresource_flags for
similar platforms.

Signed-off-by: Jayachandran C <jchandra@broadcom.com>
---
 drivers/acpi/pci_root.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/acpi/resource.c |  2 ++
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index ae3fe4e..fcaa484 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -720,6 +720,61 @@ next:
 	}
 }
 
+#ifdef PCI_IOBASE
+/*
+ * The IO ports are mapped to a memory range, fixup IO resources to
+ * handle that
+ */
+static int acpi_pci_root_remap_iospace(struct acpi_pci_root_info *ci)
+{
+	struct resource_entry *entry;
+	struct resource iores;
+	resource_size_t iostart;
+	int err;
+
+	iores.flags = IORESOURCE_IO;
+	iores.start = (resource_size_t)-1;
+	iores.end = 0;
+	resource_list_for_each_entry(entry, &ci->resources) {
+		if (entry->res->flags & IORESOURCE_IO) {
+			iores.start = min(entry->res->start, iores.start);
+			iores.end = max(entry->res->end, iores.end);
+		}
+	}
+	if (iores.end == 0)
+		return 0;
+	iostart = iores.start;
+
+	resource_list_for_each_entry(entry, &ci->resources) {
+		if (entry->res->flags & IORESOURCE_IO) {
+			entry->res->start -= iostart;
+			entry->res->end -= iostart;
+			entry->offset -= iostart;
+		}
+	}
+	iores.start -= iostart;
+	iores.end -= iostart;
+
+	err = pci_remap_iospace(&iores, iostart);
+	if (err) {
+		pr_err("PCI: ACPI: err %d mapping IO %pR\n", err, &iores);
+		return -ENODEV;
+	}
+	pr_info(PREFIX "Mapped %pR at %#lx for IO.\n",
+			&iores, (unsigned long)iostart);
+	return 0;
+}
+#else
+/*
+ * The IO ports are mapped to a memory range, fixup IO resources to
+ * handle that
+ */
+static int acpi_pci_root_remap_iospace(struct acpi_pci_root_info *ci)
+{
+	return 0;
+}
+#endif /* PCI_IOBASE */
+
 int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info)
 {
 	int ret;
@@ -745,10 +800,13 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info)
 			else
 				entry->res->name = info->name;
 		}
-		acpi_pci_root_validate_resources(&device->dev, list,
+		ret = acpi_pci_root_remap_iospace(info);
+		if (ret >= 0) {
+			acpi_pci_root_validate_resources(&device->dev, list,
 						 IORESOURCE_MEM);
-		acpi_pci_root_validate_resources(&device->dev, list,
+			acpi_pci_root_validate_resources(&device->dev, list,
 						 IORESOURCE_IO);
+		}
 	}
 
 	return ret;
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index cdc5c25..530cad4 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -126,8 +126,10 @@ static void acpi_dev_ioresource_flags(struct resource *res, u64 len,
 	if (!acpi_dev_resource_len_valid(res->start, res->end, len, true))
 		res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
 
+#ifndef PCI_IOBASE
 	if (res->end >= 0x10003)
 		res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
+#endif
 
 	if (io_decode == ACPI_DECODE_16)
 		res->flags |= IORESOURCE_IO_16BIT_ADDR;
-- 
1.9.1

  parent reply	other threads:[~2016-01-14  7:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14  7:32 [PATCH v6 0/5] ACPI based PCI support for arm64 Jayachandran C
2016-01-14  7:32 ` Jayachandran C
2016-01-14  7:32 ` Jayachandran C
2016-01-14  7:32 ` [PATCH v6 1/5] APCI: MCFG: Move mmcfg_list management to drivers/acpi Jayachandran C
2016-01-14  7:32 ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  8:48   ` Dennis Chen
2016-01-14  8:48     ` Dennis Chen
2016-01-14  8:48   ` Dennis Chen
2016-01-14 10:33   ` [Xen-devel] " David Vrabel
2016-01-14 10:33     ` David Vrabel
2016-01-14 10:33     ` David Vrabel
2016-01-14 10:33   ` David Vrabel
2016-01-14  7:32 ` [PATCH v6 2/5] PCI: Handle ACPI companion and domain number Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32 ` Jayachandran C
2016-01-14  7:32 ` Jayachandran C [this message]
2016-01-14  7:32 ` [PATCH v6 3/5] ACPI: PCI: Support platforms that need pci_remap_iospace Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32 ` [PATCH v6 4/5] arm64: pci: Add ACPI support Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32 ` Jayachandran C
2016-01-14  7:32 ` [PATCH v6 5/5] PCI: ACPI: Add a generic ACPI based host controller Jayachandran C
2016-01-14  7:32 ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C
2016-01-14  7:32   ` Jayachandran C

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='1452756761-29584-4-git-send-email-jchandra__35774.0037296482$1452755716$gmane$org@broadcom.com' \
    --to=jchandra@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=tn@semihalf.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.