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: 9170391 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 498D76048F for ; Fri, 10 Jun 2016 19:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B3FD26E5D for ; Fri, 10 Jun 2016 19:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FFA528325; Fri, 10 Jun 2016 19:58:38 +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 C804C26E5D for ; Fri, 10 Jun 2016 19:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932138AbcFJT6P (ORCPT ); Fri, 10 Jun 2016 15:58:15 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:33017 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752910AbcFJTzt (ORCPT ); Fri, 10 Jun 2016 15:55:49 -0400 Received: by mail-lf0-f42.google.com with SMTP id f6so31370998lfg.0 for ; Fri, 10 Jun 2016 12:55:48 -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=hQEJHESffuDxs3sNhyOeR1TAjEp2uma4VEbx098uFzZa9qskc6NfxR+SNvA2pf+kSW TPpyf9tbb0BxYPCp3MaFNPGi/705vjSho25k/3YHSSn162UbWHJ4HdJQJIgieijig7TE iEQ+XoyDsq7qbM6WdMCzYIYD+tn4rjtZXXAV02i03l55W5fwDgydfKH/yC4AxU1YJOGr MRNLZ24SfWUEZGRX84sJ0rtNxp3MRSqxeFMRLSSMYHudr2FhHMg7fKMfI5fRKP7YIUTq dVGCLD2wmzCBmuGEaDcPTOgM7ti7Fjrbz+de0msfMa7wBhFF0vVCij1RfNXLNhpk1e2w D3xw== X-Gm-Message-State: ALyK8tIhgFj+17vEhi7WUhobZD22WZnQhH64RBvIBsu4ONWArOoydhJCp1VmT640U75SfQ== 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 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 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> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.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) {