]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/mthca/mthca_provider.c
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-mmc
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / mthca / mthca_provider.c
index 565a24b1756f10647688e0ffb3b70a5b948160c6..230ae21db8fd3c15a2c8664443987efec352912e 100644 (file)
@@ -115,6 +115,16 @@ static int mthca_query_device(struct ib_device *ibdev,
        props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
        props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
                                           props->max_mcast_grp;
+       /*
+        * If Sinai memory key optimization is being used, then only
+        * the 8-bit key portion will change.  For other HCAs, the
+        * unused index bits will also be used for FMR remapping.
+        */
+       if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+               props->max_map_per_fmr = 255;
+       else
+               props->max_map_per_fmr =
+                       (1 << (32 - long_log2(mdev->limits.num_mpts))) - 1;
 
        err = 0;
  out:
@@ -306,7 +316,7 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
                goto out;
        }
 
-       memcpy(gid->raw + 8, out_mad->data + (index % 8) * 16, 8);
+       memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
 
  out:
        kfree(in_mad);
@@ -783,18 +793,24 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
        if (entries < 1 || entries > dev->limits.max_cqes)
                return -EINVAL;
 
+       mutex_lock(&cq->mutex);
+
        entries = roundup_pow_of_two(entries + 1);
-       if (entries == ibcq->cqe + 1)
-               return 0;
+       if (entries == ibcq->cqe + 1) {
+               ret = 0;
+               goto out;
+       }
 
        if (cq->is_kernel) {
                ret = mthca_alloc_resize_buf(dev, cq, entries);
                if (ret)
-                       return ret;
+                       goto out;
                lkey = cq->resize_buf->buf.mr.ibmr.lkey;
        } else {
-               if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
-                       return -EFAULT;
+               if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+                       ret = -EFAULT;
+                       goto out;
+               }
                lkey = ucmd.lkey;
        }
 
@@ -811,7 +827,7 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
                        cq->resize_buf = NULL;
                        spin_unlock_irq(&cq->lock);
                }
-               return ret;
+               goto out;
        }
 
        if (cq->is_kernel) {
@@ -838,7 +854,10 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
        } else
                ibcq->cqe = entries - 1;
 
-       return 0;
+out:
+       mutex_unlock(&cq->mutex);
+
+       return ret;
 }
 
 static int mthca_destroy_cq(struct ib_cq *cq)