From patchwork Fri Jun 10 19:55:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9170389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7496B6048F for ; Fri, 10 Jun 2016 19:58:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6318426E5D for ; Fri, 10 Jun 2016 19:58:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 566EA28325; Fri, 10 Jun 2016 19:58:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B66A226E5D for ; Fri, 10 Jun 2016 19:58:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBSYD-0001ib-AT; Fri, 10 Jun 2016 19:57:05 +0000 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBSXM-000128-9P for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2016 19:56:13 +0000 Received: by mail-lf0-x236.google.com with SMTP id f6so31371601lfg.0 for ; Fri, 10 Jun 2016 12:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o6L4OflEQjzr6EkgdqNlMComFUzsoRkZXcNiP/dKnkw=; b=kfr7hByogMHB1C6nnvH/7h0IoKqQ+7gfMeVXe5pbg/+3m0wE8Xtzd0jjbhES+NHbiA kRjxqaqy+XCza8jXoocq2axGSPE9c6dr08CT6tMqqQmCho2+aBQDccGuyxtfs30Nuzqp Fmbd1PTn0jNj+9AeSV5Ill3sKNu7XBD8zxyGbygP4cmRE3NjXbO1ent0EOyRWZatyUlO hO3rWFaLCXHxBxkpxqj90enIeGrOopCQIGoObDJ8XdFI4VULlddzPlAWFr9NuNZs6SLE hE9QNsQcbYt/qUJ81HanlmcxsNwXy5/eMwawkbcqS+q5ii6HBexgtGTht19T/p1cvAB5 frUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o6L4OflEQjzr6EkgdqNlMComFUzsoRkZXcNiP/dKnkw=; b=gGpefiFzoZfwiReAxuC13Jpuc6DP9SsIl6bScAkuhsA48SBlBxr85ZT0IGGmBRVvdU 77yURJz8qYuee5DsCAP2RBwFrJRvhw3zoHxh4Sjoz93HU/7khnJ/gHIBthbX2D5qg7Hy g22677dLmX4X3cMY6mrhz3h98YK6EoZxErkobpTo7uUDIpPBIVjVAEmQv7cwhuk9+RK7 i1000ubd4jFtteQO7ezbSNr4jB+GoeS+i5szg8emffUesmiGN5v8LAke+NiGRA9XhCGc /mAelwsUv90SfAV/Y3DDfQP9KLXETmZekf3MaWr0cHquA8ia7vAVvVPD3SRXYCEGOeZA ryEg== X-Gm-Message-State: ALyK8tLrSLeRLZZkUBq3yJX5LaEzKOi5LlIecAVaaUutPD1lc3Mbd14HvEDAi3qMbOY9Lg== X-Received: by 10.25.23.72 with SMTP id n69mr1203279lfi.64.1465588550439; Fri, 10 Jun 2016 12:55:50 -0700 (PDT) Received: from tn-HP-4.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id a190sm1377175lfe.21.2016.06.10.12.55.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 12:55:49 -0700 (PDT) From: Tomasz Nowicki To: helgaas@kernel.org, arnd@arndb.de, will.deacon@arm.com, catalin.marinas@arm.com, rafael@kernel.org, hanjun.guo@linaro.org, Lorenzo.Pieralisi@arm.com, okaya@codeaurora.org, jchandra@broadcom.com Subject: [PATCH V9 04/11] ACPI/PCI: Support IO resources when parsing PCI host bridge resources Date: Fri, 10 Jun 2016 21:55:12 +0200 Message-Id: <1465588519-11334-5-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465588519-11334-1-git-send-email-tn@semihalf.com> References: <1465588519-11334-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160610_125612_517526_DB605E23 X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jcm@redhat.com, linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, dhdang@apm.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, jeremy.linton@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, cov@codeaurora.org, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , mw@semihalf.com, andrea.gallo@linaro.org, linux-arm-kernel@lists.infradead.org, liudongdong3@huawei.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jayachandran C Platforms that have memory mapped IO port (such as ARM64) need special handling for PCI I/O resources. For host bridge's resource probing case these resources need to be fixed up with pci_register_io_range()/pci_remap_iospace() etc. The same I/O resources need to be released after hotplug removal so that it can be re-added back by the pci_remap_iospace() function during insertion. As a consequence unmap I/O resources with pci_unmap_iospace() when we release host bridge resources. Signed-off-by: Jayachandran C Signed-off-by: Sinan Kaya [ Tomasz: merged in Sinan's patch to unmap IO resources properly, updated changelog] Signed-off-by: Tomasz Nowicki Reviewed-by: Lorenzo Pieralisi --- drivers/acpi/pci_root.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index ae3fe4e..9a26dd1 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -720,6 +720,40 @@ next: } } +#ifdef PCI_IOBASE +static void acpi_pci_root_remap_iospace(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(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; +} +#else +static inline void acpi_pci_root_remap_iospace(struct resource_entry *entry) +{ +} +#endif + int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) { int ret; @@ -740,6 +774,9 @@ 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(entry); + if (entry->res->flags & IORESOURCE_DISABLED) resource_list_destroy_entry(entry); else @@ -811,6 +848,8 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) resource_list_for_each_entry(entry, &bridge->windows) { res = entry->res; + if (res->flags & IORESOURCE_IO) + pci_unmap_iospace(res); if (res->parent && (res->flags & (IORESOURCE_MEM | IORESOURCE_IO))) release_resource(res);