]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/char/mspec.c
Merge branch 'powerpc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus...
[mv-sheeva.git] / drivers / char / mspec.c
index 049a46cc9f87612b157d2abbe0aedd568d3e3372..fe2a95b5d3c05e36121110de446e7309098d3f6b 100644 (file)
@@ -155,23 +155,22 @@ mspec_open(struct vm_area_struct *vma)
  * mspec_close
  *
  * Called when unmapping a device mapping. Frees all mspec pages
- * belonging to the vma.
+ * belonging to all the vma's sharing this vma_data structure.
  */
 static void
 mspec_close(struct vm_area_struct *vma)
 {
        struct vma_data *vdata;
-       int index, last_index, result;
+       int index, last_index;
        unsigned long my_page;
 
        vdata = vma->vm_private_data;
 
-       BUG_ON(vma->vm_start < vdata->vm_start || vma->vm_end > vdata->vm_end);
+       if (!atomic_dec_and_test(&vdata->refcnt))
+               return;
 
-       spin_lock(&vdata->lock);
-       index = (vma->vm_start - vdata->vm_start) >> PAGE_SHIFT;
-       last_index = (vma->vm_end - vdata->vm_start) >> PAGE_SHIFT;
-       for (; index < last_index; index++) {
+       last_index = (vdata->vm_end - vdata->vm_start) >> PAGE_SHIFT;
+       for (index = 0; index < last_index; index++) {
                if (vdata->maddr[index] == 0)
                        continue;
                /*
@@ -180,20 +179,12 @@ mspec_close(struct vm_area_struct *vma)
                 */
                my_page = vdata->maddr[index];
                vdata->maddr[index] = 0;
-               spin_unlock(&vdata->lock);
-               result = mspec_zero_block(my_page, PAGE_SIZE);
-               if (!result)
-                       uncached_free_page(my_page);
+               if (!mspec_zero_block(my_page, PAGE_SIZE))
+                       uncached_free_page(my_page, 1);
                else
                        printk(KERN_WARNING "mspec_close(): "
-                              "failed to zero page %i\n",
-                              result);
-               spin_lock(&vdata->lock);
+                              "failed to zero page %ld\n", my_page);
        }
-       spin_unlock(&vdata->lock);
-
-       if (!atomic_dec_and_test(&vdata->refcnt))
-               return;
 
        if (vdata->flags & VMD_VMALLOCED)
                vfree(vdata);
@@ -201,7 +192,6 @@ mspec_close(struct vm_area_struct *vma)
                kfree(vdata);
 }
 
-
 /*
  * mspec_nopfn
  *
@@ -219,7 +209,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
        index = (address - vdata->vm_start) >> PAGE_SHIFT;
        maddr = (volatile unsigned long) vdata->maddr[index];
        if (maddr == 0) {
-               maddr = uncached_alloc_page(numa_node_id());
+               maddr = uncached_alloc_page(numa_node_id(), 1);
                if (maddr == 0)
                        return NOPFN_OOM;
 
@@ -228,7 +218,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
                        vdata->count++;
                        vdata->maddr[index] = maddr;
                } else {
-                       uncached_free_page(maddr);
+                       uncached_free_page(maddr, 1);
                        maddr = vdata->maddr[index];
                }
                spin_unlock(&vdata->lock);
@@ -293,7 +283,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
        vdata->refcnt = ATOMIC_INIT(1);
        vma->vm_private_data = vdata;
 
-       vma->vm_flags |= (VM_IO | VM_RESERVED | VM_PFNMAP);
+       vma->vm_flags |= (VM_IO | VM_RESERVED | VM_PFNMAP | VM_DONTEXPAND);
        if (vdata->type == MSPEC_FETCHOP || vdata->type == MSPEC_UNCACHED)
                vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
        vma->vm_ops = &mspec_vm_ops;
@@ -372,12 +362,12 @@ mspec_init(void)
                is_sn2 = 1;
                if (is_shub2()) {
                        ret = -ENOMEM;
-                       for_each_online_node(nid) {
+                       for_each_node_state(nid, N_ONLINE) {
                                int actual_nid;
                                int nasid;
                                unsigned long phys;
 
-                               scratch_page[nid] = uncached_alloc_page(nid);
+                               scratch_page[nid] = uncached_alloc_page(nid, 1);
                                if (scratch_page[nid] == 0)
                                        goto free_scratch_pages;
                                phys = __pa(scratch_page[nid]);
@@ -424,7 +414,7 @@ mspec_init(void)
  free_scratch_pages:
        for_each_node(nid) {
                if (scratch_page[nid] != 0)
-                       uncached_free_page(scratch_page[nid]);
+                       uncached_free_page(scratch_page[nid], 1);
        }
        return ret;
 }
@@ -441,7 +431,7 @@ mspec_exit(void)
 
                for_each_node(nid) {
                        if (scratch_page[nid] != 0)
-                               uncached_free_page(scratch_page[nid]);
+                               uncached_free_page(scratch_page[nid], 1);
                }
        }
 }