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: 9170393 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 6706E607DA 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 5890A282F9 for ; Fri, 10 Jun 2016 19:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D5F126E5D; 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 F01E1282F9 for ; Fri, 10 Jun 2016 19:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932220AbcFJT6Q (ORCPT ); Fri, 10 Jun 2016 15:58:16 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:34397 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752883AbcFJTzt (ORCPT ); Fri, 10 Jun 2016 15:55:49 -0400 Received: by mail-lf0-f45.google.com with SMTP id j7so28540351lfg.1 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=E0LXyBlxO7ay921d++DgiZ8iFf75cBzS7A2vy5tid+tiuGRTzrJC4qZ7XnnLRwpEcw iT+svcCo5oYcmVuINWnLnQDex/L4Nii2ZbbwUkaf8n4RBBn5UPUvq8pJM2Hga+GUWX0W cammN+pKUQCAhVVbEfcPzxg6BE9LoQN9ehBXsLb0YQkT1BFRstxvLvGeAC2Dgsxl5fB4 dVByzTgoiKJ+fkszBSoF8vyqa6j/eONos5XpKMPMiPsjKT+zgW+gD3AJMucSd8dGbloD ruQOMjtDIH6/MwSw6+4s1SEgeoPY0o3EYE1ATFJNvZXA6GGPuCkoPGJGFLvwwJs3XPvS AGUg== X-Gm-Message-State: ALyK8tL3SQxneGiEOmpDBOoboOvLJCJYijhhadEtT5JX/LJCxleGfQxm4BxHvdllmes5BQ== 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-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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) {