include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / infiniband / hw / amso1100 / c2_cq.c
index 9d7bcc5..f7b0fc2 100644 (file)
@@ -35,6 +35,8 @@
  * SOFTWARE.
  *
  */
+#include <linux/gfp.h>
+
 #include "c2.h"
 #include "c2_vq.h"
 #include "c2_status.h"
@@ -133,7 +135,7 @@ static inline int c2_poll_one(struct c2_dev *c2dev,
        struct c2_qp *qp;
        int is_recv = 0;
 
-       ce = (struct c2wr_ce *) c2_mq_consume(&cq->mq);
+       ce = c2_mq_consume(&cq->mq);
        if (!ce) {
                return -EAGAIN;
        }
@@ -146,14 +148,14 @@ static inline int c2_poll_one(struct c2_dev *c2dev,
        while ((qp =
                (struct c2_qp *) (unsigned long) ce->qp_user_context) == NULL) {
                c2_mq_free(&cq->mq);
-               ce = (struct c2wr_ce *) c2_mq_consume(&cq->mq);
+               ce = c2_mq_consume(&cq->mq);
                if (!ce)
                        return -EAGAIN;
        }
 
        entry->status = c2_cqe_status_to_openib(c2_wr_get_result(ce));
        entry->wr_id = ce->hdr.context;
-       entry->qp_num = ce->handle;
+       entry->qp = &qp->ibqp;
        entry->wc_flags = 0;
        entry->slid = 0;
        entry->sl = 0;
@@ -217,17 +219,19 @@ int c2_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry)
        return npolled;
 }
 
-int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
+int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags)
 {
        struct c2_mq_shared __iomem *shared;
        struct c2_cq *cq;
+       unsigned long flags;
+       int ret = 0;
 
        cq = to_c2cq(ibcq);
        shared = cq->mq.peer;
 
-       if (notify == IB_CQ_NEXT_COMP)
+       if ((notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_NEXT_COMP)
                writeb(C2_CQ_NOTIFICATION_TYPE_NEXT, &shared->notification_type);
-       else if (notify == IB_CQ_SOLICITED)
+       else if ((notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED)
                writeb(C2_CQ_NOTIFICATION_TYPE_NEXT_SE, &shared->notification_type);
        else
                return -EINVAL;
@@ -241,25 +245,28 @@ int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
         */
        readb(&shared->armed);
 
-       return 0;
+       if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+               spin_lock_irqsave(&cq->lock, flags);
+               ret = !c2_mq_empty(&cq->mq);
+               spin_unlock_irqrestore(&cq->lock, flags);
+       }
+
+       return ret;
 }
 
 static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
 {
-
-       dma_unmap_single(c2dev->ibdev.dma_device, pci_unmap_addr(mq, mapping),
-                        mq->q_size * mq->msg_size, DMA_FROM_DEVICE);
-       free_pages((unsigned long) mq->msg_pool.host,
-                  get_order(mq->q_size * mq->msg_size));
+       dma_free_coherent(&c2dev->pcidev->dev, mq->q_size * mq->msg_size,
+                         mq->msg_pool.host, pci_unmap_addr(mq, mapping));
 }
 
 static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
                           int msg_size)
 {
-       unsigned long pool_start;
+       u8 *pool_start;
 
-       pool_start = __get_free_pages(GFP_KERNEL,
-                                     get_order(q_size * msg_size));
+       pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size,
+                                       &mq->host_dma, GFP_KERNEL);
        if (!pool_start)
                return -ENOMEM;
 
@@ -267,13 +274,10 @@ static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
                       0,               /* index (currently unknown) */
                       q_size,
                       msg_size,
-                      (u8 *) pool_start,
+                      pool_start,
                       NULL,    /* peer (currently unknown) */
                       C2_MQ_HOST_TARGET);
 
-       mq->host_dma = dma_map_single(c2dev->ibdev.dma_device,
-                                     (void *)pool_start,
-                                     q_size * msg_size, DMA_FROM_DEVICE);
        pci_unmap_addr_set(mq, mapping, mq->host_dma);
 
        return 0;
@@ -420,8 +424,8 @@ void c2_free_cq(struct c2_dev *c2dev, struct c2_cq *cq)
                goto bail1;
 
        reply = (struct c2wr_cq_destroy_rep *) (unsigned long) (vq_req->reply_msg);
-
-       vq_repbuf_free(c2dev, reply);
+       if (reply)
+               vq_repbuf_free(c2dev, reply);
       bail1:
        vq_req_free(c2dev, vq_req);
       bail0: