[MTHCA]bug fixes:
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 15 Feb 2007 07:39:49 +0000 (07:39 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 15 Feb 2007 07:39:49 +0000 (07:39 +0000)
1. Read the right length in atomic cqes (only 8 bytes)
2. Zero few structures before using
3. name change in the spinlock macros

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@593 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/mt_spinlock.h
hw/mthca/kernel/mthca_cq.c
hw/mthca/kernel/mthca_dev.h
hw/mthca/kernel/mthca_main.c
hw/mthca/kernel/mthca_qp.c
hw/mthca/user/mlnx_uvp.c
hw/mthca/user/mlnx_uvp.h
hw/mthca/user/mlnx_uvp_cq.c
hw/mthca/user/mlnx_uvp_qp.c
hw/mthca/user/mlnx_uvp_verbs.c

index 111d02a..57f3ea5 100644 (file)
@@ -18,7 +18,7 @@ typedef struct {
 #ifdef SUPPORT_SPINLOCK_ISR    
 
 static inline void
-spin_lock_isr_setint( 
+spin_lock_setint( 
        IN              spinlock_t* const       l, 
        IN PKINTERRUPT  p_int_obj )
 {
@@ -26,7 +26,7 @@ spin_lock_isr_setint(
        l->p_int_obj = p_int_obj;
 }
 
-static inline void spin_lock_isr_init(
+static inline void spin_lock_irq_init(
        IN              spinlock_t* const l,
        IN      PKINTERRUPT int_obj
        )
@@ -36,7 +36,7 @@ static inline void spin_lock_isr_init(
 }
 
 static inline unsigned long
-spin_lock_isr
+spin_lock_irq
        IN              spinlock_t* const       l)
 {
        MT_ASSERT( l );
@@ -45,7 +45,7 @@ spin_lock_isr(
 }
 
 static inline void
-spin_unlock_isr
+spin_unlock_irq
        IN              spinlock_t* const p_spinlock ) 
 {
        MT_ASSERT( p_spinlock );
index 6030097..c64bc0b 100644 (file)
@@ -540,11 +540,11 @@ static inline int mthca_poll_one(struct mthca_dev *dev,
                        break;
                case MTHCA_OPCODE_ATOMIC_CS:
                        entry->wc_type    = IB_WC_COMPARE_SWAP;
-                       entry->length  = cl_ntoh32(cqe->byte_cnt);
+                       entry->length = MTHCA_BYTES_PER_ATOMIC_COMPL;
                        break;
                case MTHCA_OPCODE_ATOMIC_FA:
                        entry->wc_type    = IB_WC_FETCH_ADD;
-                       entry->length  = cl_ntoh32(cqe->byte_cnt);
+                       entry->length = MTHCA_BYTES_PER_ATOMIC_COMPL;
                        break;
                case MTHCA_OPCODE_BIND_MW:
                        entry->wc_type    = IB_WC_MW_BIND;
index 07a3a2f..dc7767d 100644 (file)
@@ -96,6 +96,10 @@ enum {
        MTHCA_NUM_EQ
 };
 
+enum {
+       MTHCA_BYTES_PER_ATOMIC_COMPL = 8
+};
+
 enum mthca_wr_opcode{
        MTHCA_OPCODE_NOP            = 0x00,
        MTHCA_OPCODE_RDMA_WRITE     = 0x08,
index fe8829c..f918ecd 100644 (file)
@@ -612,6 +612,7 @@ static int  mthca_init_arbel(struct mthca_dev *mdev)
        if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
                profile.num_srq = dev_lim.max_srqs;
 
+       RtlZeroMemory( &init_hca, sizeof(init_hca));
        icm_size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca);
        if ((int) icm_size < 0) {
                err = (int)icm_size;
index a07b4da..cd1d291 100644 (file)
@@ -1087,12 +1087,15 @@ static int mthca_alloc_memfree(struct mthca_dev *dev,
                qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ,
                                                 qp->qpn, &qp->rq.db);
                if (qp->rq.db_index < 0)
-                       return ret;
+                       return qp->rq.db_index;
 
                qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ,
                                                 qp->qpn, &qp->sq.db);
-               if (qp->sq.db_index < 0)
+               if (qp->sq.db_index < 0){
                        mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
+                       return qp->sq.db_index;
+               }
+
        }
 
        return ret;
index 0c19bc5..2e36bb6 100644 (file)
@@ -152,7 +152,7 @@ struct ibv_context *mthca_alloc_context(struct ibv_get_context_resp *resp_p)
        int                                             i;
 
        /* allocate context */
-       context = cl_malloc(sizeof *context);
+       context = cl_zalloc(sizeof *context);
        if (!context)
                return NULL;
 
index f0c1d43..00e18b6 100644 (file)
@@ -50,7 +50,8 @@ enum mthca_hca_type {
 };
 
 enum {
-       MTHCA_CQ_ENTRY_SIZE = 0x20
+       MTHCA_CQ_ENTRY_SIZE = 0x20,
+       MTHCA_BYTES_PER_ATOMIC_COMPL = 0x8
 };
 
 enum {
index 7a18129..ebbf426 100644 (file)
@@ -379,11 +379,11 @@ static inline int mthca_poll_one(struct mthca_cq *cq,
                        break;
                case MTHCA_OPCODE_ATOMIC_CS:
                        entry->wc_type    = IB_WC_COMPARE_SWAP;
-                       entry->length  = cl_ntoh32(cqe->byte_cnt);
+                       entry->length  = MTHCA_BYTES_PER_ATOMIC_COMPL;
                        break;
                case MTHCA_OPCODE_ATOMIC_FA:
                        entry->wc_type    = IB_WC_FETCH_ADD;
-                       entry->length  = cl_ntoh32(cqe->byte_cnt);
+                       entry->length  = MTHCA_BYTES_PER_ATOMIC_COMPL;
                        break;
                case MTHCA_OPCODE_BIND_MW:
                        entry->wc_type    = IB_WC_MW_BIND;
index 51d1229..4cbca73 100644 (file)
@@ -306,7 +306,7 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
                if (wr->send_opt & IB_SEND_OPT_INLINE) {
                        if (wr->num_ds) {
                                struct mthca_inline_seg *seg = (struct mthca_inline_seg *)wqe;
-                               int s = 0;
+                               uint32_t s = 0;
 
                                wqe += sizeof *seg;
                                for (i = 0; i < (int)wr->num_ds; ++i) {
@@ -314,7 +314,7 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
 
                                        s += sge->length;
 
-                                       if (s > qp->max_inline_data) {
+                                       if (s > (uint32_t)qp->max_inline_data) {
                                                ret = -1;
                                                if (bad_wr)
                                                        *bad_wr = wr;
@@ -704,7 +704,7 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
                if (wr->send_opt & IB_SEND_OPT_INLINE) {
                        if (wr->num_ds) {
                                struct mthca_inline_seg *seg = (struct mthca_inline_seg *)wqe;
-                               int s = 0;
+                               uint32_t s = 0;
 
                                wqe += sizeof *seg;
                                for (i = 0; i < (int)wr->num_ds; ++i) {
@@ -712,7 +712,7 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
 
                                        s += sge->length;
 
-                                       if (s > qp->max_inline_data) {
+                                       if (s > (uint32_t)qp->max_inline_data) {
                                                ret = -1;
                                                if (bad_wr)
                                                        *bad_wr = wr;
index 445b283..264c60e 100644 (file)
@@ -48,7 +48,7 @@ struct ibv_pd *mthca_alloc_pd(struct ibv_context *context, struct ibv_alloc_pd_r
 {
        struct mthca_pd           *pd;
 
-       pd = cl_malloc(sizeof *pd);
+       pd = cl_zalloc(sizeof *pd);
        if (!pd)
                goto err_malloc;
 
@@ -106,7 +106,7 @@ struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *p_cqe,
        if (*p_cqe > 131072)
                goto exit;
 
-       cq = cl_malloc(sizeof *cq);
+       cq = cl_zalloc(sizeof *cq);
        if (!cq)
                goto exit;
 
@@ -285,7 +285,7 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd,
                goto exit;
                }
 
-       qp = cl_malloc(sizeof *qp);
+       qp = cl_zalloc(sizeof *qp);
        if (!qp) {
                UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("cl_malloc  failed (%d)\n",ret));
                goto err_nomem;