From patchwork Fri Oct 9 22:16:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7364681 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 32D639F36A for ; Fri, 9 Oct 2015 22:25:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFCDD20762 for ; Fri, 9 Oct 2015 22:25:38 +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 32F8620857 for ; Fri, 9 Oct 2015 22:25:37 +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 1Zkg4p-000329-NH; Fri, 09 Oct 2015 22:23:47 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zkg3d-0001EL-HZ for linux-arm-kernel@lists.infradead.org; Fri, 09 Oct 2015 22:22:37 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 09 Oct 2015 15:22:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,660,1437462000"; d="scan'208";a="577610605" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.39]) by FMSMGA003.fm.intel.com with ESMTP; 09 Oct 2015 15:22:12 -0700 Subject: [PATCH 10/20] acpi: switch from ioremap_cache to memremap From: Dan Williams To: linux-kernel@vger.kernel.org Date: Fri, 09 Oct 2015 18:16:30 -0400 Message-ID: <20151009221630.32203.96152.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20151009221537.32203.5867.stgit@dwillia2-desk3.jf.intel.com> References: <20151009221537.32203.5867.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151009_152233_938052_EBF92D0F X-CRM114-Status: GOOD ( 15.70 ) X-Spam-Score: -6.9 (------) 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: linux-arch@vger.kernel.org, "Rafael J. Wysocki" , Bob Moore , Lv Zheng , Russell King , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 In preparation for deprecating ioremap_cache() convert its usage in drivers/acpi and include/acpi/ to memremap. This includes dropping the __iomem annotation throughout ACPI since the memremap can be treated as a normal memory pointer. Finally, memremap automatically handles requests to map normal memory pages, so this also drops the calls to "should_use_kmap()". It seems ARM had a local definition of acpi_os_ioremap() to handle RAM addresses, but it can be deleted now that memremap() handles this generically. Cc: Bob Moore Cc: Lv Zheng Cc: Russell King Acked-by: Rafael J. Wysocki Signed-off-by: Dan Williams --- arch/arm64/include/asm/acpi.h | 8 ----- drivers/acpi/apei/einj.c | 9 +++-- drivers/acpi/apei/erst.c | 6 ++-- drivers/acpi/nvs.c | 6 ++-- drivers/acpi/osl.c | 70 +++++++++++------------------------------ include/acpi/acpi_io.h | 6 +--- 6 files changed, 32 insertions(+), 73 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index a24a9b1cc91d..197d02047d00 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -29,14 +29,6 @@ /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI -/* ACPI table mapping after acpi_gbl_permanent_mmap is set */ -static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, - acpi_size size) -{ - return memremap(phys, size, MEMREMAP_WB); -} -#define acpi_os_ioremap acpi_os_ioremap - typedef u64 phys_cpuid_t; #define PHYS_CPUID_INVALID INVALID_HWID diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index 0431883653be..9f71010f6339 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -314,7 +314,8 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type, sizeof(*trigger_tab) - 1); goto out; } - trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab)); + trigger_tab = memremap(trigger_paddr, sizeof(*trigger_tab), + MEMREMAP_WB); if (!trigger_tab) { pr_err(EINJ_PFX "Failed to map trigger table!\n"); goto out_rel_header; @@ -342,8 +343,8 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type, (unsigned long long)trigger_paddr + table_size - 1); goto out_rel_header; } - iounmap(trigger_tab); - trigger_tab = ioremap_cache(trigger_paddr, table_size); + memunmap(trigger_tab); + trigger_tab = memremap(trigger_paddr, table_size, MEMREMAP_WB); if (!trigger_tab) { pr_err(EINJ_PFX "Failed to map trigger table!\n"); goto out_rel_entry; @@ -405,7 +406,7 @@ out_rel_header: release_mem_region(trigger_paddr, sizeof(*trigger_tab)); out: if (trigger_tab) - iounmap(trigger_tab); + memunmap(trigger_tab); return rc; } diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 6682c5daf742..4ef62b54fabf 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c @@ -73,7 +73,7 @@ static struct acpi_table_erst *erst_tab; static struct erst_erange { u64 base; u64 size; - void __iomem *vaddr; + void *vaddr; u32 attr; } erst_erange; @@ -1181,8 +1181,8 @@ static int __init erst_init(void) goto err_unmap_reg; } rc = -ENOMEM; - erst_erange.vaddr = ioremap_cache(erst_erange.base, - erst_erange.size); + erst_erange.vaddr = memremap(erst_erange.base, erst_erange.size, + MEMREMAP_WB); if (!erst_erange.vaddr) goto err_release_erange; diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c index 85287b8fe3aa..e0e15af93b22 100644 --- a/drivers/acpi/nvs.c +++ b/drivers/acpi/nvs.c @@ -136,7 +136,7 @@ void suspend_nvs_free(void) entry->data = NULL; if (entry->kaddr) { if (entry->unmap) { - iounmap(entry->kaddr); + memunmap(entry->kaddr); entry->unmap = false; } else { acpi_os_unmap_iomem(entry->kaddr, @@ -180,7 +180,7 @@ int suspend_nvs_save(void) entry->kaddr = acpi_os_get_iomem(phys, size); if (!entry->kaddr) { - entry->kaddr = acpi_os_ioremap(phys, size); + entry->kaddr = acpi_os_memremap(phys, size); entry->unmap = !!entry->kaddr; } if (!entry->kaddr) { @@ -197,7 +197,7 @@ int suspend_nvs_save(void) * suspend_nvs_restore - restore NVS memory regions * * This function is going to be called with interrupts disabled, so it - * cannot iounmap the virtual addresses used to access the NVS region. + * cannot memunmap the virtual addresses used to access the NVS region. */ void suspend_nvs_restore(void) { diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 739a4a6b3b9b..d629eef2a56e 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -40,8 +39,8 @@ #include #include #include +#include -#include #include #include @@ -88,7 +87,7 @@ static bool acpi_os_initialized; */ struct acpi_ioremap { struct list_head list; - void __iomem *virt; + void *virt; acpi_physical_address phys; acpi_size size; unsigned long refcount; @@ -292,7 +291,7 @@ acpi_map_lookup(acpi_physical_address phys, acpi_size size) } /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ -static void __iomem * +static void * acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size) { struct acpi_ioremap *map; @@ -304,10 +303,10 @@ acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size) return NULL; } -void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size) +void *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size) { struct acpi_ioremap *map; - void __iomem *virt = NULL; + void *virt = NULL; mutex_lock(&acpi_ioremap_lock); map = acpi_map_lookup(phys, size); @@ -322,7 +321,7 @@ EXPORT_SYMBOL_GPL(acpi_os_get_iomem); /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap * -acpi_map_lookup_virt(void __iomem *virt, acpi_size size) +acpi_map_lookup_virt(void *virt, acpi_size size) { struct acpi_ioremap *map; @@ -334,44 +333,13 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size) return NULL; } -#if defined(CONFIG_IA64) || defined(CONFIG_ARM64) -/* ioremap will take care of cache attributes */ -#define should_use_kmap(pfn) 0 -#else -#define should_use_kmap(pfn) page_is_ram(pfn) -#endif - -static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz) -{ - unsigned long pfn; - - pfn = pg_off >> PAGE_SHIFT; - if (should_use_kmap(pfn)) { - if (pg_sz > PAGE_SIZE) - return NULL; - return (void __iomem __force *)kmap(pfn_to_page(pfn)); - } else - return acpi_os_ioremap(pg_off, pg_sz); -} - -static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr) -{ - unsigned long pfn; - - pfn = pg_off >> PAGE_SHIFT; - if (should_use_kmap(pfn)) - kunmap(pfn_to_page(pfn)); - else - iounmap(vaddr); -} - -void __iomem *__init_refok +void *__init_refok acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) { struct acpi_ioremap *map; - void __iomem *virt; acpi_physical_address pg_off; acpi_size pg_sz; + void *virt; if (phys > ULONG_MAX) { printk(KERN_ERR PREFIX "Cannot map memory that high\n"); @@ -397,7 +365,7 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) pg_off = round_down(phys, PAGE_SIZE); pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; - virt = acpi_map(pg_off, pg_sz); + virt = acpi_os_memremap(pg_off, pg_sz); if (!virt) { mutex_unlock(&acpi_ioremap_lock); kfree(map); @@ -435,7 +403,7 @@ static void acpi_os_map_cleanup(struct acpi_ioremap *map) { if (!map->refcount) { synchronize_rcu_expedited(); - acpi_unmap(map->phys, map->virt); + memunmap(map->virt); kfree(map); } } @@ -948,7 +916,7 @@ EXPORT_SYMBOL(acpi_os_write_port); acpi_status acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) { - void __iomem *virt_addr; + void *virt_addr; unsigned int size = width / 8; bool unmap = false; u64 dummy; @@ -957,7 +925,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) virt_addr = acpi_map_vaddr_lookup(phys_addr, size); if (!virt_addr) { rcu_read_unlock(); - virt_addr = acpi_os_ioremap(phys_addr, size); + virt_addr = acpi_os_memremap(phys_addr, size); if (!virt_addr) return AE_BAD_ADDRESS; unmap = true; @@ -968,23 +936,23 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) switch (width) { case 8: - *(u8 *) value = readb(virt_addr); + *(u8 *) value = *(u8 *) virt_addr; break; case 16: - *(u16 *) value = readw(virt_addr); + *(u16 *) value = *(u16 *) virt_addr; break; case 32: - *(u32 *) value = readl(virt_addr); + *(u32 *) value = *(u32 *) virt_addr; break; case 64: - *(u64 *) value = readq(virt_addr); + *(u64 *) value = *(u64 *) virt_addr; break; default: BUG(); } if (unmap) - iounmap(virt_addr); + memunmap(virt_addr); else rcu_read_unlock(); @@ -1002,7 +970,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width) virt_addr = acpi_map_vaddr_lookup(phys_addr, size); if (!virt_addr) { rcu_read_unlock(); - virt_addr = acpi_os_ioremap(phys_addr, size); + virt_addr = acpi_os_memremap(phys_addr, size); if (!virt_addr) return AE_BAD_ADDRESS; unmap = true; @@ -1026,7 +994,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width) } if (unmap) - iounmap(virt_addr); + memunmap(virt_addr); else rcu_read_unlock(); diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h index dd86c5fc102d..646ce8714109 100644 --- a/include/acpi/acpi_io.h +++ b/include/acpi/acpi_io.h @@ -5,13 +5,11 @@ #include -#ifndef acpi_os_ioremap -static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, +static inline void *acpi_os_memremap(acpi_physical_address phys, acpi_size size) { - return ioremap_cache(phys, size); + return memremap(phys, size, MEMREMAP_WB); } -#endif void __iomem *__init_refok acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);