From patchwork Fri Jan 29 09:05:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jayachandran C." X-Patchwork-Id: 8160371 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A70ABEEE5 for ; Fri, 29 Jan 2016 08:44:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F0D6201D3 for ; Fri, 29 Jan 2016 08:44:10 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FEF620382 for ; Fri, 29 Jan 2016 08:44:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aP4c7-0007fD-7o; Fri, 29 Jan 2016 08:41:07 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aP4c5-0007e9-Ks for xen-devel@lists.xenproject.org; Fri, 29 Jan 2016 08:41:05 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id 08/C4-25438-0A52BA65; Fri, 29 Jan 2016 08:41:04 +0000 X-Env-Sender: jchandra@broadcom.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1454056863!11376189!1 X-Originating-IP: [216.31.210.63] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63706 invoked from network); 29 Jan 2016 08:41:03 -0000 Received: from mail-gw2-out.broadcom.com (HELO mail-gw2-out.broadcom.com) (216.31.210.63) by server-11.tower-27.messagelabs.com with SMTP; 29 Jan 2016 08:41:03 -0000 X-IronPort-AV: E=Sophos;i="5.22,363,1449561600"; d="scan'208";a="86733891" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw2-out.broadcom.com with ESMTP; 29 Jan 2016 01:23:52 -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; Fri, 29 Jan 2016 00:40:53 -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; Fri, 29 Jan 2016 00:40:52 -0800 Received: from netl-snoppy.ban.broadcom.com (unknown [10.132.128.129]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 05FA840FEA; Fri, 29 Jan 2016 00:36:56 -0800 (PST) From: Jayachandran C To: , Bjorn Helgaas , , Arnd Bergmann , , "Rafael J. Wysocki" Date: Fri, 29 Jan 2016 14:35:37 +0530 Message-ID: <1454058340-7904-3-git-send-email-jchandra@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454058340-7904-1-git-send-email-jchandra@broadcom.com> References: <1454058340-7904-1-git-send-email-jchandra@broadcom.com> MIME-Version: 1.0 Cc: Tomasz Nowicki , Lorenzo Pieralisi , Jayachandran C , xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v7 2/5] ACPI: PCI: Support platforms that need pci_remap_iospace X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 d02fd53..9672070 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -127,8 +127,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;