From patchwork Mon Dec 7 17:20:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jayachandran Chandrashekaran X-Patchwork-Id: 57808 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp1271018lbb; Mon, 7 Dec 2015 08:59:39 -0800 (PST) X-Received: by 10.98.67.9 with SMTP id q9mr45041473pfa.138.1449507577535; Mon, 07 Dec 2015 08:59:37 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ll4si2438686pab.39.2015.12.07.08.59.37; Mon, 07 Dec 2015 08:59:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756303AbbLGQ7g (ORCPT + 6 others); Mon, 7 Dec 2015 11:59:36 -0500 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:62745 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756301AbbLGQ7f (ORCPT ); Mon, 7 Dec 2015 11:59:35 -0500 X-IronPort-AV: E=Sophos;i="5.20,395,1444719600"; d="scan'208";a="82660703" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw2-out.broadcom.com with ESMTP; 07 Dec 2015 09:35:12 -0800 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.235.1; Mon, 7 Dec 2015 08:59:34 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.235.1; Mon, 7 Dec 2015 08:59:34 -0800 Received: from netl-snoppy.ban.broadcom.com (unknown [10.132.128.129]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 684C040FE8; Mon, 7 Dec 2015 08:56:08 -0800 (PST) From: Jayachandran C To: , Bjorn Helgaas , , Arnd Bergmann , CC: Jayachandran C , Lorenzo Pieralisi , Tomasz Nowicki Subject: [RFC PATCH v2 4/4] ACPI: PCI: Support platforms that need pci_remap_iospace Date: Mon, 7 Dec 2015 22:50:29 +0530 Message-ID: <1449508829-10797-5-git-send-email-jchandra@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449508829-10797-1-git-send-email-jchandra@broadcom.com> References: <1449508829-10797-1-git-send-email-jchandra@broadcom.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- drivers/acpi/pci_root.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++-- drivers/acpi/resource.c | 2 ++ 2 files changed, 62 insertions(+), 2 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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/acpi/pci_root.c b/drivers/acpi/pci_root.c index 850d7bf..58093ba 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;