[PATCH] IB/ipath: use more appropriate gfp flags
[pandora-kernel.git] / drivers / infiniband / hw / ipath / ipath_file_ops.c
index ada267e..03689db 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2006 QLogic, Inc. All rights reserved.
  * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -704,6 +705,15 @@ static int ipath_create_user_egr(struct ipath_portdata *pd)
        unsigned e, egrcnt, alloced, egrperchunk, chunk, egrsize, egroff;
        size_t size;
        int ret;
+       gfp_t gfp_flags;
+
+       /*
+        * GFP_USER, but without GFP_FS, so buffer cache can be
+        * coalesced (we hope); otherwise, even at order 4,
+        * heavy filesystem activity makes these fail, and we can
+        * use compound pages.
+        */
+       gfp_flags = __GFP_WAIT | __GFP_IO | __GFP_COMP;
 
        egrcnt = dd->ipath_rcvegrcnt;
        /* TID number offset for this port */
@@ -720,10 +730,8 @@ static int ipath_create_user_egr(struct ipath_portdata *pd)
         * memory pressure (creating large files and then copying them over
         * NFS while doing lots of MPI jobs), we hit some allocation
         * failures, even though we can sleep...  (2.6.10) Still get
-        * failures at 64K.  32K is the lowest we can go without waiting
-        * more memory again.  It seems likely that the coalescing in
-        * free_pages, etc. still has issues (as it has had previously
-        * during 2.6.x development).
+        * failures at 64K.  32K is the lowest we can go without wasting
+        * additional memory.
         */
        size = 0x8000;
        alloced = ALIGN(egrsize * egrcnt, size);
@@ -744,12 +752,6 @@ static int ipath_create_user_egr(struct ipath_portdata *pd)
                goto bail_rcvegrbuf;
        }
        for (e = 0; e < pd->port_rcvegrbuf_chunks; e++) {
-               /*
-                * GFP_USER, but without GFP_FS, so buffer cache can be
-                * coalesced (we hope); otherwise, even at order 4,
-                * heavy filesystem activity makes these fail
-                */
-               gfp_t gfp_flags = __GFP_WAIT | __GFP_IO | __GFP_COMP;
 
                pd->port_rcvegrbuf[e] = dma_alloc_coherent(
                        &dd->pcidev->dev, size, &pd->port_rcvegrbuf_phys[e],
@@ -1166,9 +1168,10 @@ static int ipath_mmap(struct file *fp, struct vm_area_struct *vma)
 
        ureg = dd->ipath_uregbase + dd->ipath_palign * pd->port_port;
 
-       ipath_cdbg(MM, "ushare: pgaddr %llx vm_start=%lx, vmlen %lx\n",
+       ipath_cdbg(MM, "pgaddr %llx vm_start=%lx len %lx port %u:%u\n",
                   (unsigned long long) pgaddr, vma->vm_start,
-                  vma->vm_end - vma->vm_start);
+                  vma->vm_end - vma->vm_start, dd->ipath_unit,
+                  pd->port_port);
 
        if (pgaddr == ureg)
                ret = mmap_ureg(vma, dd, ureg);
@@ -1442,16 +1445,16 @@ done:
 
 static int ipath_open(struct inode *in, struct file *fp)
 {
-       int ret, minor;
+       int ret, user_minor;
 
        mutex_lock(&ipath_mutex);
 
-       minor = iminor(in);
+       user_minor = iminor(in) - IPATH_USER_MINOR_BASE;
        ipath_cdbg(VERBOSE, "open on dev %lx (minor %d)\n",
-                  (long)in->i_rdev, minor);
+                  (long)in->i_rdev, user_minor);
 
-       if (minor)
-               ret = find_free_port(minor - 1, fp);
+       if (user_minor)
+               ret = find_free_port(user_minor - 1, fp);
        else
                ret = find_best_unit(fp);
 
@@ -1859,19 +1862,12 @@ int ipath_user_add(struct ipath_devdata *dd)
                                      "error %d\n", -ret);
                        goto bail;
                }
-               ret = ipath_diag_init();
-               if (ret < 0) {
-                       ipath_dev_err(dd, "Unable to set up diag support: "
-                                     "error %d\n", -ret);
-                       goto bail_sma;
-               }
-
                ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev,
                                &wildcard_class_dev);
                if (ret < 0) {
                        ipath_dev_err(dd, "Could not create wildcard "
                                      "minor: error %d\n", -ret);
-                       goto bail_diag;
+                       goto bail_sma;
                }
 
                atomic_set(&user_setup, 1);
@@ -1880,31 +1876,28 @@ int ipath_user_add(struct ipath_devdata *dd)
        snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit);
 
        ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops,
-                       &dd->cdev, &dd->class_dev);
+                       &dd->user_cdev, &dd->user_class_dev);
        if (ret < 0)
                ipath_dev_err(dd, "Could not create user minor %d, %s\n",
                              dd->ipath_unit + 1, name);
 
        goto bail;
 
-bail_diag:
-       ipath_diag_cleanup();
 bail_sma:
        user_cleanup();
 bail:
        return ret;
 }
 
-void ipath_user_del(struct ipath_devdata *dd)
+void ipath_user_remove(struct ipath_devdata *dd)
 {
-       cleanup_cdev(&dd->cdev, &dd->class_dev);
+       cleanup_cdev(&dd->user_cdev, &dd->user_class_dev);
 
        if (atomic_dec_return(&user_count) == 0) {
                if (atomic_read(&user_setup) == 0)
                        goto bail;
 
                cleanup_cdev(&wildcard_cdev, &wildcard_class_dev);
-               ipath_diag_cleanup();
                user_cleanup();
 
                atomic_set(&user_setup, 0);