[MLX4] added debug prints in case of errors. [mlnx: 4664]
[mirror/winof/.git] / hw / mlx4 / kernel / bus / ib / cq.c
index 77f56d3..0ff7e01 100644 (file)
@@ -135,8 +135,10 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector
                return ERR_PTR(-EINVAL);\r
 \r
        cq = kzalloc(sizeof *cq, GFP_KERNEL);\r
-       if (!cq)\r
+       if (!cq) {\r
+               printk(KERN_ERR "mlx4_ib_create_cq: -ENOMEM \n");\r
                return ERR_PTR(-ENOMEM);\r
+       }\r
 \r
        entries      = roundup_pow_of_two(entries + 1);\r
        cq->ibcq.cqe = entries - 1;\r
@@ -155,36 +157,47 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector
                                       IB_ACCESS_LOCAL_WRITE, FALSE);\r
                if (IS_ERR(cq->umem)) {\r
                        err = PTR_ERR(cq->umem);\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: ib_umem_get failed with %d \n", err);\r
                        goto err_cq;\r
                }\r
 \r
                err = mlx4_mtt_init(dev->dev, ib_umem_page_count(cq->umem),\r
                                    ilog2(cq->umem->page_size), &cq->buf.mtt);\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_mtt_init failed with %d \n", err);\r
                        goto err_buf;\r
+               }\r
 \r
                err = mlx4_ib_umem_write_mtt(dev, &cq->buf.mtt, cq->umem);\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_ib_umem_write_mtt failed with %d \n", err);\r
                        goto err_mtt;\r
+               }\r
 \r
                err = mlx4_ib_db_map_user(to_mucontext(context), ucmd.db_addr,\r
                                          &cq->db);\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_ib_db_map_user failed with %d \n", err);\r
                        goto err_mtt;\r
+               }\r
 \r
                // add mapping to user's arm_sn variable\r
                // we have no way pass the completion event to provider library\r
                // so we'll increment user's arm_sn in kernel\r
                err = ib_umem_map( ucmd.arm_sn_addr, sizeof(int), \r
                        IB_ACCESS_LOCAL_WRITE, &cq->mcq.mdl, &cq->mcq.p_u_arm_sn );\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: ib_umem_map failed with %d \n", err);\r
                        goto err_dbmap;\r
+               }\r
 \r
                uar = &to_mucontext(context)->uar;\r
        } else {\r
                err = mlx4_ib_db_alloc(dev, &cq->db, 1);\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_ib_db_alloc failed with %d \n", err);\r
                        goto err_cq;\r
+               }\r
 \r
                cq->mcq.set_ci_db  = cq->db.db;\r
                cq->mcq.arm_db     = cq->db.db + 1;\r
@@ -192,18 +205,24 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector
                *cq->mcq.arm_db    = 0;\r
 \r
                if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2, &cq->buf.buf)) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_buf_alloc failed for buf_size %d (entries %d) "\r
+                                  "on CQ %06x\n", buf_size, entries, cq->mcq.cqn);\r
                        err = -ENOMEM;\r
                        goto err_db;\r
                }\r
 \r
                err = mlx4_mtt_init(dev->dev, cq->buf.buf.npages, cq->buf.buf.page_shift,\r
                                    &cq->buf.mtt);\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_mtt_init failed with %d \n", err);\r
                        goto err_buf;\r
+               }\r
 \r
                err = mlx4_buf_write_mtt(dev->dev, &cq->buf.mtt, &cq->buf.buf);\r
-               if (err)\r
+               if (err) {\r
+                       printk(KERN_ERR "mlx4_ib_create_cq: mlx4_buf_write_mtt failed with %d \n", err);\r
                        goto err_mtt;\r
+               }\r
 \r
                cq->mcq.p_u_arm_sn = NULL;\r
                uar = &dev->priv_uar;\r
@@ -211,8 +230,10 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector
 \r
        err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar,\r
                cq->db.dma.da, &cq->mcq, vector, 0);\r
-       if (err)\r
+       if (err) {\r
+               printk(KERN_ERR "mlx4_ib_create_cq: mlx4_cq_alloc failed with %d \n", err);\r
                goto err_dbmap;\r
+       }\r
 \r
        cq->mcq.comp  = mlx4_ib_cq_comp;\r
        cq->mcq.event = mlx4_ib_cq_event;\r