git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
infiniband
/
hw
/
mthca
/
mthca_srq.c
diff --git
a/drivers/infiniband/hw/mthca/mthca_srq.c
b/drivers/infiniband/hw/mthca/mthca_srq.c
index
b292fef
..
10684da
100644
(file)
--- a/
drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/
drivers/infiniband/hw/mthca/mthca_srq.c
@@
-35,6
+35,8
@@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <asm/io.h>
+
#include "mthca_dev.h"
#include "mthca_cmd.h"
#include "mthca_memfree.h"
#include "mthca_dev.h"
#include "mthca_cmd.h"
#include "mthca_memfree.h"
@@
-118,7
+120,7
@@
static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
memset(context, 0, sizeof *context);
memset(context, 0, sizeof *context);
- logsize =
long_log2(srq->max) + srq->wqe_shift
;
+ logsize =
ilog2(srq->max)
;
context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
context->db_index = cpu_to_be32(srq->db_index);
context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
context->db_index = cpu_to_be32(srq->db_index);
@@
-201,6
+203,8
@@
int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
if (mthca_is_memfree(dev))
srq->max = roundup_pow_of_two(srq->max + 1);
if (mthca_is_memfree(dev))
srq->max = roundup_pow_of_two(srq->max + 1);
+ else
+ srq->max = srq->max + 1;
ds = max(64UL,
roundup_pow_of_two(sizeof (struct mthca_next_seg) +
ds = max(64UL,
roundup_pow_of_two(sizeof (struct mthca_next_seg) +
@@
-209,7
+213,7
@@
int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
if (!mthca_is_memfree(dev) && (ds > dev->limits.max_desc_sz))
return -EINVAL;
if (!mthca_is_memfree(dev) && (ds > dev->limits.max_desc_sz))
return -EINVAL;
- srq->wqe_shift =
long_
log2(ds);
+ srq->wqe_shift =
i
log2(ds);
srq->srqn = mthca_alloc(&dev->srq_table.alloc);
if (srq->srqn == -1)
srq->srqn = mthca_alloc(&dev->srq_table.alloc);
if (srq->srqn == -1)
@@
-243,6
+247,7
@@
int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
spin_lock_init(&srq->lock);
srq->refcount = 1;
init_waitqueue_head(&srq->wait);
spin_lock_init(&srq->lock);
srq->refcount = 1;
init_waitqueue_head(&srq->wait);
+ mutex_init(&srq->mutex);
if (mthca_is_memfree(dev))
mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf);
if (mthca_is_memfree(dev))
mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf);
@@
-276,7
+281,7
@@
int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
srq->first_free = 0;
srq->last_free = srq->max - 1;
srq->first_free = 0;
srq->last_free = srq->max - 1;
- attr->max_wr =
(mthca_is_memfree(dev)) ? srq->max - 1 : srq->max
;
+ attr->max_wr =
srq->max - 1
;
attr->max_sge = srq->max_gs;
return 0;
attr->max_sge = srq->max_gs;
return 0;
@@
-357,7
+362,7
@@
void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq)
}
int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
}
int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
- enum ib_srq_attr_mask attr_mask)
+ enum ib_srq_attr_mask attr_mask
, struct ib_udata *udata
)
{
struct mthca_dev *dev = to_mdev(ibsrq->device);
struct mthca_srq *srq = to_msrq(ibsrq);
{
struct mthca_dev *dev = to_mdev(ibsrq->device);
struct mthca_srq *srq = to_msrq(ibsrq);
@@
-369,9
+374,14
@@
int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
return -EINVAL;
if (attr_mask & IB_SRQ_LIMIT) {
return -EINVAL;
if (attr_mask & IB_SRQ_LIMIT) {
- if (attr->srq_limit > srq->max)
+ u32 max_wr = mthca_is_memfree(dev) ? srq->max - 1 : srq->max;
+ if (attr->srq_limit > max_wr)
return -EINVAL;
return -EINVAL;
+
+ mutex_lock(&srq->mutex);
ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
+ mutex_unlock(&srq->mutex);
+
if (ret)
return ret;
if (status)
if (ret)
return ret;
if (status)
@@
-407,7
+417,7
@@
int mthca_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
srq_attr->srq_limit = be16_to_cpu(tavor_ctx->limit_watermark);
}
srq_attr->srq_limit = be16_to_cpu(tavor_ctx->limit_watermark);
}
- srq_attr->max_wr =
(mthca_is_memfree(dev)) ? srq->max - 1 : srq->max
;
+ srq_attr->max_wr =
srq->max - 1
;
srq_attr->max_sge = srq->max_gs;
out:
srq_attr->max_sge = srq->max_gs;
out:
@@
-587,6
+597,12
@@
int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
}
MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
}
+ /*
+ * Make sure doorbells don't leak out of SRQ spinlock and
+ * reach the HCA out of order:
+ */
+ mmiowb();
+
spin_unlock_irqrestore(&srq->lock, flags);
return err;
}
spin_unlock_irqrestore(&srq->lock, flags);
return err;
}
@@
-699,7
+715,7
@@
int mthca_max_srq_sge(struct mthca_dev *dev)
sizeof (struct mthca_data_seg));
}
sizeof (struct mthca_data_seg));
}
-int
__devinit
mthca_init_srq_table(struct mthca_dev *dev)
+int mthca_init_srq_table(struct mthca_dev *dev)
{
int err;
{
int err;