From patchwork Mon May 30 15:14:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9141703 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 7D2D360777 for ; Mon, 30 May 2016 15:18:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EC1D28185 for ; Mon, 30 May 2016 15:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 633AE281FE; Mon, 30 May 2016 15:18:53 +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 17D4C28185 for ; Mon, 30 May 2016 15:18:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754895AbcE3PSi (ORCPT ); Mon, 30 May 2016 11:18:38 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:34145 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933401AbcE3PPC (ORCPT ); Mon, 30 May 2016 11:15:02 -0400 Received: by mail-lf0-f44.google.com with SMTP id k98so74025375lfi.1 for ; Mon, 30 May 2016 08:15:01 -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=EeNxpMY12pynrytkmKxkYl98umpd3dmO1nVQApyxzBU=; b=fFw+Fhqu1ah4ZU5XBnISIsdjRUtkoOU8wJrlkMvopTURwPSUXN6f2hlWfABoBq9/L5 6mlHtGGrV4wYen3Ye/YHn+17+n41hi78s+Ofvzz4KHFJhXnTQcFxoCLzex0/H9hFo6Y9 Am30VsLYwZh2mZtjfUpHx3za/HIboyffcB2q9yIi18ks7ADtn+aCvjXnHrdpkQ9xyU87 BV3N1dPjfXmjfbMBsmrisnWp1kzMwGSAi/RxlOfJQifxNuVzsY1+zpOQRbU+hS/LB3Uy 06Qnzl9vkKMSvBKPVjIk9xjl3nu2P1fIXX4G0460P2CmMxXoNDMRUGJWt9IC6T7uTf6H 0uDw== 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=EeNxpMY12pynrytkmKxkYl98umpd3dmO1nVQApyxzBU=; b=FcYUt3h92ZC3DJU0ZqGJWYlUBZ4hklZiyGS1kxi8VkM1epm0KWpCsO98nzjWMVHSWo fFUvF6NcGmK8V7Llz83o+DlRaUEOYhvrH38JpzEytP57LdUf7SHt73FakpYNykMwkRCs jrEw49H/j9+w3ctCuejM1dLAydb+5kA9s7eCNWCH1DbjVsYoqSwq7jkT6rPvYlA+usiV NDN/V5RwCmwW8ZjjyhlCjuLnY1JXcBA+fFKOHam+PJ6eQbPw48LlckJiW13Jh7Ye2sj0 UJWXGTIgSZw1Hq7uuJGl3F1WJYysmlp3kg9MW9O2aOEvbD7fLlnhBd9s6eLUaAgaKJR+ VytA== X-Gm-Message-State: ALyK8tKp6g59vH7ly/KdoDNXZKHtmnzFymMGzpd5gxzMQzrCIb1Fi/KVyOWDnFU0oRjfwg== X-Received: by 10.25.23.234 with SMTP id 103mr7329366lfx.38.1464621300795; Mon, 30 May 2016 08:15:00 -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.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 May 2016 08:15:00 -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 3/9] pci: Add new function to unmap IO resources. Date: Mon, 30 May 2016 17:14:16 +0200 Message-Id: <1464621262-26770-4-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 We need to release I/O resources so that the same I/O resources can be allocated again (pci_remap_iospace), like in PCI hotplug removal scenario. Therefore this patch implements 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) {