From patchwork Tue May 10 15:19:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9059361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2A3DC9F1C1 for ; Tue, 10 May 2016 15:23:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C46520103 for ; Tue, 10 May 2016 15:23:18 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 629BC200E5 for ; Tue, 10 May 2016 15:23:17 +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 1b09Tf-0005vg-8O; Tue, 10 May 2016 15:21:39 +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 1b09ST-0003tw-Dl for linux-arm-kernel@lists.infradead.org; Tue, 10 May 2016 15:20:33 +0000 Received: by mail-lf0-x236.google.com with SMTP id y84so18910110lfc.0 for ; Tue, 10 May 2016 08:20:05 -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=HlNOdJTYpPmgxRNjXYivXFLA6rOacZYcKd8y2FXJpmc=; b=DCFMyms3KxALs0qe1lyFpd6kOfsIUzx3Zbo4nkKRTCHUczHZWXtP1FtFQVjJGEv8hG qYBiOdK1w2qUzTC9EaK4JJfwqCXyJmTjosy5DuONHawgY+W/8kdqrRPMah9l9jtadCYu zegcOQfzdzgUP7dhHYO6bRw/2BWvNo48CXQutBOJPI07ADiZFESBe98VODfgEP2GZiPe NndRZ5djDYmHzbNxC1Cb5Qmppb7umr2M7RsGwxN7z3srPsVdRJJUBjBRC/g4lsFB0EuO b1BHUXf216I9+/jLrr5nYqc/7A3x6WbxUD6CdfF4Go8tn8LrbThTVQDA75MHd2C3aIQ5 z09g== 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=HlNOdJTYpPmgxRNjXYivXFLA6rOacZYcKd8y2FXJpmc=; b=dPqg7ZeQ4BahYnRfvZqG8n/EDumOMP+wv28pgFwwdi9DJRcX4Cx+diqtcJ5fTgZt3v 74GZ66Vwg34ie34grPGMUVWVC6jas+PYljJaaRv3/kJKreoIgK4mo0Wcukk89JN2h8Up 2GAHXY6BB4RPjo2RWhv8XoQKhwjpa7TgsLS/9Cln74L/jamXV13QwEeUrMVgou5IsGkz UPDERAUy7Gslag270bVXBsIOsVEw+KozEiQtHcjU9M+6qdrKo8Nil4Ua8yhKX9x6YHA/ R/qphcOEt21TYiLGOYFWRjKL5mTPNJyz1IaNoY86ksaHnVeKrC4WMhFT3SgGxqTBGfB1 tJWg== X-Gm-Message-State: AOPr4FU8eUIY6mpVqRyTos1I3yJvOC7bUKHqnUJhW+3mAGv2FKOIXD4oj9S2EkjxPEeTig== X-Received: by 10.112.139.71 with SMTP id qw7mr17486464lbb.40.1462893603482; Tue, 10 May 2016 08:20:03 -0700 (PDT) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id s194sm468002lfs.40.2016.05.10.08.20.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 May 2016 08:20: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 Subject: [PATCH V7 04/11] pci: Add new function to unmap IO resources. Date: Tue, 10 May 2016 17:19:54 +0200 Message-Id: <1462893601-8937-5-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462893601-8937-1-git-send-email-tn@semihalf.com> References: <1462893601-8937-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160510_082025_979670_31D64BA9 X-CRM114-Status: GOOD ( 13.33 ) X-Spam-Score: -2.6 (--) 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-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 It is very useful 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 --- drivers/pci/pci.c | 24 ++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index bc0c914..ff97a0b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "pci.h" @@ -3167,6 +3168,29 @@ 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)); +#else + /* + * This architecture does not have memory mapped I/O space, + * so this function should never be called. + */ + WARN_ONCE(1, "This architecture does not support memory mapped I/O\n"); +#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 d2a57f3..d6ea6ce 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1169,6 +1169,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) {