Thomas Gleixner | 25763b3 | 2019-05-28 10:10:09 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 2 | /* |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 3 | * Copyright (C) 2001-2008 Silicon Graphics, Inc. All rights reserved. |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 4 | * |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 5 | * A simple uncached page allocator using the generic allocator. This |
| 6 | * allocator first utilizes the spare (spill) pages found in the EFI |
| 7 | * memmap and will then start converting cached pages to uncached ones |
| 8 | * at a granule at a time. Node awareness is implemented by having a |
| 9 | * pool of pages per node. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/types.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/errno.h> |
| 17 | #include <linux/string.h> |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 18 | #include <linux/efi.h> |
Ingo Molnar | 38b8d20 | 2017-02-08 18:51:31 +0100 | [diff] [blame] | 19 | #include <linux/nmi.h> |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 20 | #include <linux/genalloc.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 21 | #include <linux/gfp.h> |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 22 | #include <asm/page.h> |
| 23 | #include <asm/pal.h> |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 24 | #include <asm/pgtable.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 25 | #include <linux/atomic.h> |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 26 | #include <asm/tlbflush.h> |
| 27 | #include <asm/sn/arch.h> |
| 28 | |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 29 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 30 | extern void __init efi_memmap_walk_uc(efi_freemem_callback_t, void *); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 31 | |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 32 | struct uncached_pool { |
| 33 | struct gen_pool *pool; |
| 34 | struct mutex add_chunk_mutex; /* serialize adding a converted chunk */ |
| 35 | int nchunks_added; /* #of converted chunks added to pool */ |
| 36 | atomic_t status; /* smp called function's return status*/ |
| 37 | }; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 38 | |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 39 | #define MAX_CONVERTED_CHUNKS_PER_NODE 2 |
| 40 | |
| 41 | struct uncached_pool uncached_pools[MAX_NUMNODES]; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 42 | |
| 43 | |
| 44 | static void uncached_ipi_visibility(void *data) |
| 45 | { |
| 46 | int status; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 47 | struct uncached_pool *uc_pool = (struct uncached_pool *)data; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 48 | |
| 49 | status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL); |
| 50 | if ((status != PAL_VISIBILITY_OK) && |
| 51 | (status != PAL_VISIBILITY_OK_REMOTE_NEEDED)) |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 52 | atomic_inc(&uc_pool->status); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | |
| 56 | static void uncached_ipi_mc_drain(void *data) |
| 57 | { |
| 58 | int status; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 59 | struct uncached_pool *uc_pool = (struct uncached_pool *)data; |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 60 | |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 61 | status = ia64_pal_mc_drain(); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 62 | if (status != PAL_STATUS_SUCCESS) |
| 63 | atomic_inc(&uc_pool->status); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 67 | /* |
| 68 | * Add a new chunk of uncached memory pages to the specified pool. |
| 69 | * |
| 70 | * @pool: pool to add new chunk of uncached memory to |
| 71 | * @nid: node id of node to allocate memory from, or -1 |
| 72 | * |
| 73 | * This is accomplished by first allocating a granule of cached memory pages |
| 74 | * and then converting them to uncached memory pages. |
| 75 | */ |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 76 | static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid) |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 77 | { |
| 78 | struct page *page; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 79 | int status, i, nchunks_added = uc_pool->nchunks_added; |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 80 | unsigned long c_addr, uc_addr; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 81 | |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 82 | if (mutex_lock_interruptible(&uc_pool->add_chunk_mutex) != 0) |
| 83 | return -1; /* interrupted by a signal */ |
| 84 | |
| 85 | if (uc_pool->nchunks_added > nchunks_added) { |
| 86 | /* someone added a new chunk while we were waiting */ |
| 87 | mutex_unlock(&uc_pool->add_chunk_mutex); |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | if (uc_pool->nchunks_added >= MAX_CONVERTED_CHUNKS_PER_NODE) { |
| 92 | mutex_unlock(&uc_pool->add_chunk_mutex); |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 93 | return -1; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 94 | } |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 95 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 96 | /* attempt to allocate a granule's worth of cached memory pages */ |
| 97 | |
Vlastimil Babka | 96db800 | 2015-09-08 15:03:50 -0700 | [diff] [blame] | 98 | page = __alloc_pages_node(nid, |
Johannes Weiner | e97ca8e5 | 2014-03-10 15:49:43 -0700 | [diff] [blame] | 99 | GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE, |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 100 | IA64_GRANULE_SHIFT-PAGE_SHIFT); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 101 | if (!page) { |
| 102 | mutex_unlock(&uc_pool->add_chunk_mutex); |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 103 | return -1; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 104 | } |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 105 | |
| 106 | /* convert the memory pages from cached to uncached */ |
| 107 | |
| 108 | c_addr = (unsigned long)page_address(page); |
| 109 | uc_addr = c_addr - PAGE_OFFSET + __IA64_UNCACHED_OFFSET; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 110 | |
| 111 | /* |
| 112 | * There's a small race here where it's possible for someone to |
| 113 | * access the page through /dev/mem halfway through the conversion |
| 114 | * to uncached - not sure it's really worth bothering about |
| 115 | */ |
| 116 | for (i = 0; i < (IA64_GRANULE_SIZE / PAGE_SIZE); i++) |
| 117 | SetPageUncached(&page[i]); |
| 118 | |
Jan Beulich | 285fbd6 | 2007-12-19 12:30:30 -0800 | [diff] [blame] | 119 | flush_tlb_kernel_range(uc_addr, uc_addr + IA64_GRANULE_SIZE); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 120 | |
| 121 | status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 122 | if (status == PAL_VISIBILITY_OK_REMOTE_NEEDED) { |
| 123 | atomic_set(&uc_pool->status, 0); |
Jens Axboe | 8691e5a | 2008-06-06 11:18:06 +0200 | [diff] [blame] | 124 | status = smp_call_function(uncached_ipi_visibility, uc_pool, 1); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 125 | if (status || atomic_read(&uc_pool->status)) |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 126 | goto failed; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 127 | } else if (status != PAL_VISIBILITY_OK) |
| 128 | goto failed; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 129 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 130 | preempt_disable(); |
| 131 | |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 132 | if (ia64_platform_is("sn2")) |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 133 | sn_flush_all_caches(uc_addr, IA64_GRANULE_SIZE); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 134 | else |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 135 | flush_icache_range(uc_addr, uc_addr + IA64_GRANULE_SIZE); |
| 136 | |
| 137 | /* flush the just introduced uncached translation from the TLB */ |
| 138 | local_flush_tlb_all(); |
| 139 | |
| 140 | preempt_enable(); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 141 | |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 142 | status = ia64_pal_mc_drain(); |
| 143 | if (status != PAL_STATUS_SUCCESS) |
| 144 | goto failed; |
| 145 | atomic_set(&uc_pool->status, 0); |
Jens Axboe | 8691e5a | 2008-06-06 11:18:06 +0200 | [diff] [blame] | 146 | status = smp_call_function(uncached_ipi_mc_drain, uc_pool, 1); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 147 | if (status || atomic_read(&uc_pool->status)) |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 148 | goto failed; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 149 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 150 | /* |
| 151 | * The chunk of memory pages has been converted to uncached so now we |
| 152 | * can add it to the pool. |
| 153 | */ |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 154 | status = gen_pool_add(uc_pool->pool, uc_addr, IA64_GRANULE_SIZE, nid); |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 155 | if (status) |
| 156 | goto failed; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 157 | |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 158 | uc_pool->nchunks_added++; |
| 159 | mutex_unlock(&uc_pool->add_chunk_mutex); |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 160 | return 0; |
| 161 | |
| 162 | /* failed to convert or add the chunk so give it back to the kernel */ |
| 163 | failed: |
| 164 | for (i = 0; i < (IA64_GRANULE_SIZE / PAGE_SIZE); i++) |
| 165 | ClearPageUncached(&page[i]); |
| 166 | |
| 167 | free_pages(c_addr, IA64_GRANULE_SHIFT-PAGE_SHIFT); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 168 | mutex_unlock(&uc_pool->add_chunk_mutex); |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 169 | return -1; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | |
| 173 | /* |
| 174 | * uncached_alloc_page |
| 175 | * |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 176 | * @starting_nid: node id of node to start with, or -1 |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 177 | * @n_pages: number of contiguous pages to allocate |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 178 | * |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 179 | * Allocate the specified number of contiguous uncached pages on the |
| 180 | * the requested node. If not enough contiguous uncached pages are available |
| 181 | * on the requested node, roundrobin starting with the next higher node. |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 182 | */ |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 183 | unsigned long uncached_alloc_page(int starting_nid, int n_pages) |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 184 | { |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 185 | unsigned long uc_addr; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 186 | struct uncached_pool *uc_pool; |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 187 | int nid; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 188 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 189 | if (unlikely(starting_nid >= MAX_NUMNODES)) |
| 190 | return 0; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 191 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 192 | if (starting_nid < 0) |
| 193 | starting_nid = numa_node_id(); |
| 194 | nid = starting_nid; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 195 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 196 | do { |
Christoph Lameter | 2dca53a | 2007-10-16 01:25:33 -0700 | [diff] [blame] | 197 | if (!node_state(nid, N_HIGH_MEMORY)) |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 198 | continue; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 199 | uc_pool = &uncached_pools[nid]; |
| 200 | if (uc_pool->pool == NULL) |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 201 | continue; |
| 202 | do { |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 203 | uc_addr = gen_pool_alloc(uc_pool->pool, |
| 204 | n_pages * PAGE_SIZE); |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 205 | if (uc_addr != 0) |
| 206 | return uc_addr; |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 207 | } while (uncached_add_chunk(uc_pool, nid) == 0); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 208 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 209 | } while ((nid = (nid + 1) % MAX_NUMNODES) != starting_nid); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 210 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 211 | return 0; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 212 | } |
| 213 | EXPORT_SYMBOL(uncached_alloc_page); |
| 214 | |
| 215 | |
| 216 | /* |
| 217 | * uncached_free_page |
| 218 | * |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 219 | * @uc_addr: uncached address of first page to free |
| 220 | * @n_pages: number of contiguous pages to free |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 221 | * |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 222 | * Free the specified number of uncached pages. |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 223 | */ |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 224 | void uncached_free_page(unsigned long uc_addr, int n_pages) |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 225 | { |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 226 | int nid = paddr_to_nid(uc_addr - __IA64_UNCACHED_OFFSET); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 227 | struct gen_pool *pool = uncached_pools[nid].pool; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 228 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 229 | if (unlikely(pool == NULL)) |
| 230 | return; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 231 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 232 | if ((uc_addr & (0XFUL << 60)) != __IA64_UNCACHED_OFFSET) |
| 233 | panic("uncached_free_page invalid address %lx\n", uc_addr); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 234 | |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 235 | gen_pool_free(pool, uc_addr, n_pages * PAGE_SIZE); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 236 | } |
| 237 | EXPORT_SYMBOL(uncached_free_page); |
| 238 | |
| 239 | |
| 240 | /* |
| 241 | * uncached_build_memmap, |
| 242 | * |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 243 | * @uc_start: uncached starting address of a chunk of uncached memory |
| 244 | * @uc_end: uncached ending address of a chunk of uncached memory |
| 245 | * @arg: ignored, (NULL argument passed in on call to efi_memmap_walk_uc()) |
| 246 | * |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 247 | * Called at boot time to build a map of pages that can be used for |
| 248 | * memory special operations. |
| 249 | */ |
Matthew Wilcox | e088a4a | 2009-05-22 13:49:49 -0700 | [diff] [blame] | 250 | static int __init uncached_build_memmap(u64 uc_start, u64 uc_end, void *arg) |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 251 | { |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 252 | int nid = paddr_to_nid(uc_start - __IA64_UNCACHED_OFFSET); |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 253 | struct gen_pool *pool = uncached_pools[nid].pool; |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 254 | size_t size = uc_end - uc_start; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 255 | |
John Hawkes | 386d1d5 | 2006-01-18 23:46:53 -0800 | [diff] [blame] | 256 | touch_softlockup_watchdog(); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 257 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 258 | if (pool != NULL) { |
| 259 | memset((char *)uc_start, 0, size); |
| 260 | (void) gen_pool_add(pool, uc_start, size, nid); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 261 | } |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 266 | static int __init uncached_init(void) |
| 267 | { |
| 268 | int nid; |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 269 | |
Christoph Lameter | 2dca53a | 2007-10-16 01:25:33 -0700 | [diff] [blame] | 270 | for_each_node_state(nid, N_ONLINE) { |
Dean Nelson | eca7994f | 2006-06-28 13:50:09 -0500 | [diff] [blame] | 271 | uncached_pools[nid].pool = gen_pool_create(PAGE_SHIFT, nid); |
| 272 | mutex_init(&uncached_pools[nid].add_chunk_mutex); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Dean Nelson | 929f972 | 2006-06-23 02:03:21 -0700 | [diff] [blame] | 275 | efi_memmap_walk_uc(uncached_build_memmap, NULL); |
Jes Sorensen | f14f75b | 2005-06-21 17:15:02 -0700 | [diff] [blame] | 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | __initcall(uncached_init); |