From patchwork Mon May 30 15:14:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9141687 X-Patchwork-Delegate: bhelgaas@google.com 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 A68BA60801 for ; Mon, 30 May 2016 15:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9801F28185 for ; Mon, 30 May 2016 15:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D01F28224; Mon, 30 May 2016 15:18:26 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06AB32819E for ; Mon, 30 May 2016 15:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751736AbcE3PSU (ORCPT ); Mon, 30 May 2016 11:18:20 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:34157 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933360AbcE3PPF (ORCPT ); Mon, 30 May 2016 11:15:05 -0400 Received: by mail-lf0-f47.google.com with SMTP id k98so74026022lfi.1 for ; Mon, 30 May 2016 08:15:04 -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=MW1cPQvE42QPRYdYnZf6VlrjzYem1Y3aKQTOdpANGnE=; b=Pq3YmePDdwCIDWe8/Txb8DVQa7wDL7wQUUa5ZACMwJqLrgGtGxJ90vgsV31l7NEMpv IMB1nMAQ9x8dDII/Qd039q+JghnKYjTzpWi6nJY9GmX/OvLSumgA9sRwBmVkefml+QlY UQ62Kcxu+4i1ITzmWQ3+2opI1gUQDdoSJGcmY4a9O4VUR9KT1k5guln9DKbkQqEoql+C XSK544eUR6k18kx87YRmLEgon4FkEG0+jTc7gLfzxsVkiniBXNhloyvUWov/d8KWysvc BaIn3O3dD0nbHbxpEeYRRB1ZedwkrsKYEm0m+IInv1Vi7dYdm0nLwRemuc5O8Jf1efT4 bwcg== 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=MW1cPQvE42QPRYdYnZf6VlrjzYem1Y3aKQTOdpANGnE=; b=NY9AVUFY63/x/MTWZqhShLqOv/YefTt3YgyyQs6SSXv16OXF/B/0A37XcDC8MuixrX kWJNu4W8y7lIBEecAXi8eVha6FH+1jmV8hvvMPNAozD/qniU9JQ83NZEMn83HgwCNUJI 5cSArt1b02QEksRJCTCQF6r7PUQ+k/PMXFIdmxLbISg/B7QBrtD053zbgADBAZJf41WQ /eg02nbz8FTp7MTkL77SF6d0LraWPYobDFfq+0v4MwoYqnDAnYqjdEX2s0h5BiMYporI 4cjfi02npBnGX2h/oDyaZHMslvz0jrnVGgXHPNnHpCYH+ZpUsoFH9zoFkh1dU+E/Uedg v8yg== X-Gm-Message-State: ALyK8tIRWc2HPeWQD+4NzJNi04P0Zam7+sOt5Au3V72hK3fv0fkHI+X+cWevyXMGU2IQDg== X-Received: by 10.25.73.137 with SMTP id w131mr7556528lfa.22.1464621303525; Mon, 30 May 2016 08:15:03 -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 n13sm1392264lfb.33.2016.05.30.08.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 May 2016 08:15:02 -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 Cc: robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, wangyijing@huawei.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, jcm@redhat.com, andrea.gallo@linaro.org, dhdang@apm.com, jeremy.linton@arm.com, liudongdong3@huawei.com, cov@codeaurora.org, Tomasz Nowicki Subject: [PATCH V8 4/9] acpi, pci: Support IO resources when parsing PCI host bridge resources. Date: Mon, 30 May 2016 17:14:17 +0200 Message-Id: <1464621262-26770-5-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464621262-26770-1-git-send-email-tn@semihalf.com> References: <1464621262-26770-1-git-send-email-tn@semihalf.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 we unmap I/O resources with pci_unmap_iospace when we release host bridge resources. Signed-off-by: Jayachandran C Signed-off-by: Sinan Kaya 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..ee3b728 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 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);