From patchwork Fri Jun 10 19:55:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9170377 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 90BAD6048F for ; Fri, 10 Jun 2016 19:58:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8157326E5D for ; Fri, 10 Jun 2016 19:58:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75C2E28319; Fri, 10 Jun 2016 19:58:08 +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=ham 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 195CC26E5D for ; Fri, 10 Jun 2016 19:58:08 +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 1bBSXf-0001EY-N9; Fri, 10 Jun 2016 19:56:31 +0000 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBSXJ-00011e-Kt for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2016 19:56:10 +0000 Received: by mail-lf0-x22b.google.com with SMTP id q132so14579458lfe.3 for ; Fri, 10 Jun 2016 12:55:49 -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=CXqJuOs4oXQn07MOLivDQVtA1cy1hg/uV+C5JiMzT/o=; b=dR/peL8A6ajoisw+8cCqDiEIgOe5Vxr5LmAO5rpWmkbym4XTPz4BnrlY+qcSXceEHP ne5SSwk2lGFEC6ee+Smek/ROHG/M3sULFepjpelIS45m8Box64r5bziCgftzfHn+3PT1 FNVMUKq1/wqCVZCfUI4YpVI2XkOaYulCE8HoW/i+iFoUNdWEWvIXxixSH+b8V1Emwb9f 527sjPSgH+oCe9zmoCJn43xxu596YsinBMaMEYYB0nz3kE0amYBIU1wJbAfr+ysHVaWY nvMgUz3ck4TBc5mhsRQFwNuVXid+8+TnVR3y9qKyqQ0FWXh4D9PfV1UeC5ngkh4JACZB R2jQ== 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=CXqJuOs4oXQn07MOLivDQVtA1cy1hg/uV+C5JiMzT/o=; b=Fbm5JAtwLgBdKfhbKcA9c5Kk+jS5bXCLw34BMyD7BR8iVdo7frxlc33ZS7QHusYjjl 27lDG5Fu53WPFOjm5i6qdoeGODQaglH7RcXOq7beGK/tVijSIDXzq9LEXkqqaYM3pIo2 uP+XdvMcybRwrO2A6+17O9zkN6NnmqtXS0INDuUYW1Sev8drxsxLOW4s4fGMNmEMq15W XNRkbUnpA4sroVOlxSCEYBCHrOqWSMaqsJVVex2XdZ+g7S7HowzcHiT4eBFTbJVQz8eK r6PXReXNuI371FmncPW1WSrkExj8eRJIV3PoVE0q9Q+r0BTu8a+Kx7K1zE+C3qBi4uGn Ko6w== X-Gm-Message-State: ALyK8tJ1xK0fzKEjYSnCEyhnI3J8odOCo6BG7yuVxKHOQ6pwQy0L9peQ6LDFJ6VWX1ClVw== X-Received: by 10.25.209.129 with SMTP id i123mr1149705lfg.37.1465588547792; Fri, 10 Jun 2016 12:55:47 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 12:55:47 -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 03/11] PCI: Add new function to unmap IO resources Date: Fri, 10 Jun 2016 21:55:11 +0200 Message-Id: <1465588519-11334-4-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_125609_919588_33F11AFD X-CRM114-Status: GOOD ( 11.21 ) 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: Sinan Kaya We need to release I/O resources so that the same I/O resources can be allocated again in pci_remap_iospace(), like in PCI hotplug removal scenario. Therefore implement new pci_unmap_iospace() call which unmaps I/O space as the symmetry to pci_remap_iospace(). Signed-off-by: Sinan Kaya Signed-off-by: Tomasz Nowicki Acked-by: Lorenzo Pieralisi --- drivers/pci/pci.c | 18 ++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c8b4dbd..eb431b5 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "pci.h" @@ -3165,6 +3166,23 @@ int __weak pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr) #endif } +/** + * pci_unmap_iospace - Unmap the memory mapped I/O space + * @res: resource to be unmapped + * + * Unmap the CPU virtual address @res from virtual address space. + * Only architectures that have memory mapped IO functions defined + * (and the PCI_IOBASE value defined) should call this function. + */ +void pci_unmap_iospace(struct resource *res) +{ +#if defined(PCI_IOBASE) && defined(CONFIG_MMU) + unsigned long vaddr = (unsigned long)PCI_IOBASE + res->start; + + unmap_kernel_range(vaddr, resource_size(res)); +#endif +} + static void __pci_set_master(struct pci_dev *dev, bool enable) { u16 old_cmd, cmd; diff --git a/include/linux/pci.h b/include/linux/pci.h index b67e4df..12349de 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1167,6 +1167,7 @@ int pci_register_io_range(phys_addr_t addr, resource_size_t size); unsigned long pci_address_to_pio(phys_addr_t addr); phys_addr_t pci_pio_to_address(unsigned long pio); int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr); +void pci_unmap_iospace(struct resource *res); static inline pci_bus_addr_t pci_bus_address(struct pci_dev *pdev, int bar) {