33 #include <linux/types.h>
34 #include <linux/kernel.h>
35 #include <linux/module.h>
37 #include <linux/errno.h>
43 #include <linux/string.h>
44 #include <linux/slab.h>
47 #include <asm/pgtable.h>
49 #include <asm/tlbflush.h>
50 #include <asm/uncached.h>
51 #include <asm/sn/addrs.h>
52 #include <asm/sn/arch.h>
55 #include <asm/sn/io.h>
60 #define FETCHOP_ID "SGI Fetchop,"
61 #define CACHED_ID "Cached,"
62 #define UNCACHED_ID "Uncached"
63 #define REVISION "4.0"
64 #define MSPEC_BASENAME "mspec"
102 #define VMD_VMALLOCED 0x1
106 #define SH2_AMO_CACHE_ENTRIES 4
109 mspec_zero_block(
unsigned long addr,
int len)
120 p = (
void *)
TO_AMO(scratch_page[nid]);
131 memset((
char *) addr, 0, len);
163 int index, last_index;
164 unsigned long my_page;
172 for (index = 0; index < last_index; index++) {
173 if (vdata->
maddr[index] == 0)
181 if (!mspec_zero_block(my_page,
PAGE_SIZE))
185 "failed to zero page %ld\n", my_page);
207 maddr = (
volatile unsigned long) vdata->
maddr[index];
213 spin_lock(&vdata->
lock);
214 if (vdata->
maddr[index] == 0) {
221 spin_unlock(&vdata->
lock);
236 vm_insert_pfn(vma, (
unsigned long)vmf->virtual_address, pfn);
238 return VM_FAULT_NOPAGE;
241 static const struct vm_operations_struct mspec_vm_ops = {
243 .close = mspec_close,
244 .fault = mspec_fault,
264 if ((vma->
vm_flags & VM_SHARED) == 0)
267 if ((vma->
vm_flags & VM_WRITE) == 0)
271 vdata_size =
sizeof(
struct vma_data) + pages *
sizeof(
long);
289 vma->
vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
292 vma->
vm_ops = &mspec_vm_ops;
317 .mmap = fetchop_mmap,
323 .name =
"sgi_fetchop",
324 .fops = &fetchop_fops
335 .name =
"mspec_cached",
341 .mmap = uncached_mmap,
347 .name =
"mspec_uncached",
348 .fops = &uncached_fops
377 if (scratch_page[nid] == 0)
378 goto free_scratch_pages;
379 phys =
__pa(scratch_page[nid]);
382 if (actual_nid != nid)
383 goto free_scratch_pages;
390 "%s: failed to register device %i\n",
392 goto free_scratch_pages;
402 goto free_scratch_pages;
411 goto free_scratch_pages;
422 if (scratch_page[nid] != 0)
439 if (scratch_page[nid] != 0)