Skip to content

Commit e4a064d

Browse files
Dean Nelsonaegl
authored andcommitted
[IA64] allocate multiple contiguous pages via uncached allocator
Enable the uncached allocator to allocate multiple pages of contiguous uncached memory. Signed-off-by: Dean Nelson <dcn@sgi.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent e617fce commit e4a064d

4 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎arch/ia64/kernel/uncached.c‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2001-2006 Silicon Graphics, Inc. All rights reserved.
2+
* Copyright (C) 2001-2008 Silicon Graphics, Inc. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms of version 2 of the GNU General Public License
@@ -177,12 +177,13 @@ static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid)
177177
* uncached_alloc_page
178178
*
179179
* @starting_nid: node id of node to start with, or -1
180+
* @n_pages: number of contiguous pages to allocate
180181
*
181-
* Allocate 1 uncached page. Allocates on the requested node. If no
182-
* uncached pages are available on the requested node, roundrobin starting
183-
* with the next higher node.
182+
* Allocate the specified number of contiguous uncached pages on the
183+
* the requested node. If not enough contiguous uncached pages are available
184+
* on the requested node, roundrobin starting with the next higher node.
184185
*/
185-
unsigned long uncached_alloc_page(int starting_nid)
186+
unsigned long uncached_alloc_page(int starting_nid, int n_pages)
186187
{
187188
unsigned long uc_addr;
188189
struct uncached_pool *uc_pool;
@@ -202,7 +203,8 @@ unsigned long uncached_alloc_page(int starting_nid)
202203
if (uc_pool->pool == NULL)
203204
continue;
204205
do {
205-
uc_addr = gen_pool_alloc(uc_pool->pool, PAGE_SIZE);
206+
uc_addr = gen_pool_alloc(uc_pool->pool,
207+
n_pages * PAGE_SIZE);
206208
if (uc_addr != 0)
207209
return uc_addr;
208210
} while (uncached_add_chunk(uc_pool, nid) == 0);
@@ -217,11 +219,12 @@ EXPORT_SYMBOL(uncached_alloc_page);
217219
/*
218220
* uncached_free_page
219221
*
220-
* @uc_addr: uncached address of page to free
222+
* @uc_addr: uncached address of first page to free
223+
* @n_pages: number of contiguous pages to free
221224
*
222-
* Free a single uncached page.
225+
* Free the specified number of uncached pages.
223226
*/
224-
void uncached_free_page(unsigned long uc_addr)
227+
void uncached_free_page(unsigned long uc_addr, int n_pages)
225228
{
226229
int nid = paddr_to_nid(uc_addr - __IA64_UNCACHED_OFFSET);
227230
struct gen_pool *pool = uncached_pools[nid].pool;
@@ -232,7 +235,7 @@ void uncached_free_page(unsigned long uc_addr)
232235
if ((uc_addr & (0XFUL << 60)) != __IA64_UNCACHED_OFFSET)
233236
panic("uncached_free_page invalid address %lx\n", uc_addr);
234237

235-
gen_pool_free(pool, uc_addr, PAGE_SIZE);
238+
gen_pool_free(pool, uc_addr, n_pages * PAGE_SIZE);
236239
}
237240
EXPORT_SYMBOL(uncached_free_page);
238241

‎drivers/char/mspec.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ mspec_close(struct vm_area_struct *vma)
180180
my_page = vdata->maddr[index];
181181
vdata->maddr[index] = 0;
182182
if (!mspec_zero_block(my_page, PAGE_SIZE))
183-
uncached_free_page(my_page);
183+
uncached_free_page(my_page, 1);
184184
else
185185
printk(KERN_WARNING "mspec_close(): "
186186
"failed to zero page %ld\n", my_page);
@@ -209,7 +209,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
209209
index = (address - vdata->vm_start) >> PAGE_SHIFT;
210210
maddr = (volatile unsigned long) vdata->maddr[index];
211211
if (maddr == 0) {
212-
maddr = uncached_alloc_page(numa_node_id());
212+
maddr = uncached_alloc_page(numa_node_id(), 1);
213213
if (maddr == 0)
214214
return NOPFN_OOM;
215215

@@ -218,7 +218,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
218218
vdata->count++;
219219
vdata->maddr[index] = maddr;
220220
} else {
221-
uncached_free_page(maddr);
221+
uncached_free_page(maddr, 1);
222222
maddr = vdata->maddr[index];
223223
}
224224
spin_unlock(&vdata->lock);
@@ -367,7 +367,7 @@ mspec_init(void)
367367
int nasid;
368368
unsigned long phys;
369369

370-
scratch_page[nid] = uncached_alloc_page(nid);
370+
scratch_page[nid] = uncached_alloc_page(nid, 1);
371371
if (scratch_page[nid] == 0)
372372
goto free_scratch_pages;
373373
phys = __pa(scratch_page[nid]);
@@ -414,7 +414,7 @@ mspec_init(void)
414414
free_scratch_pages:
415415
for_each_node(nid) {
416416
if (scratch_page[nid] != 0)
417-
uncached_free_page(scratch_page[nid]);
417+
uncached_free_page(scratch_page[nid], 1);
418418
}
419419
return ret;
420420
}
@@ -431,7 +431,7 @@ mspec_exit(void)
431431

432432
for_each_node(nid) {
433433
if (scratch_page[nid] != 0)
434-
uncached_free_page(scratch_page[nid]);
434+
uncached_free_page(scratch_page[nid], 1);
435435
}
436436
}
437437
}

‎drivers/misc/sgi-xp/xpc_partition.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ xpc_rsvd_page_init(void)
211211
*/
212212
amos_page = xpc_vars->amos_page;
213213
if (amos_page == NULL) {
214-
amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0));
214+
amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0, 1));
215215
if (amos_page == NULL) {
216216
dev_err(xpc_part, "can't allocate page of AMOs\n");
217217
return NULL;
@@ -230,7 +230,7 @@ xpc_rsvd_page_init(void)
230230
dev_err(xpc_part, "can't change memory "
231231
"protections\n");
232232
uncached_free_page(__IA64_UNCACHED_OFFSET |
233-
TO_PHYS((u64)amos_page));
233+
TO_PHYS((u64)amos_page), 1);
234234
return NULL;
235235
}
236236
}

‎include/asm-ia64/uncached.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2001-2005 Silicon Graphics, Inc. All rights reserved.
2+
* Copyright (C) 2001-2008 Silicon Graphics, Inc. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms of version 2 of the GNU General Public License
@@ -8,5 +8,5 @@
88
* Prototypes for the uncached page allocator
99
*/
1010

11-
extern unsigned long uncached_alloc_page(int nid);
12-
extern void uncached_free_page(unsigned long);
11+
extern unsigned long uncached_alloc_page(int starting_nid, int n_pages);
12+
extern void uncached_free_page(unsigned long uc_addr, int n_pages);

0 commit comments

Comments
 (0)