headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / infiniband / hw / ipath / ipath_ud.c
index 36aa242..7420715 100644 (file)
@@ -31,6 +31,7 @@
  * SOFTWARE.
  */
 
+#include <linux/sched.h>
 #include <rdma/ib_smi.h>
 
 #include "ipath_verbs.h"
@@ -70,8 +71,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
                goto done;
        }
 
-       rsge.sg_list = NULL;
-
        /*
         * Check that the qkey matches (except for QP0, see 9.6.1.4.1).
         * Qkeys with the high order bit set mean use the
@@ -115,21 +114,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
                rq = &qp->r_rq;
        }
 
-       if (rq->max_sge > 1) {
-               /*
-                * XXX We could use GFP_KERNEL if ipath_do_send()
-                * was always called from the tasklet instead of
-                * from ipath_post_send().
-                */
-               rsge.sg_list = kmalloc((rq->max_sge - 1) *
-                                       sizeof(struct ipath_sge),
-                                      GFP_ATOMIC);
-               if (!rsge.sg_list) {
-                       dev->n_pkt_drops++;
-                       goto drop;
-               }
-       }
-
        /*
         * Get the next work request entry to find where to put the data.
         * Note that it is safe to drop the lock after changing rq->tail
@@ -147,6 +131,7 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
                goto drop;
        }
        wqe = get_rwqe_ptr(rq, tail);
+       rsge.sg_list = qp->r_ud_sg_list;
        if (!ipath_init_sge(qp, wqe, &rlen, &rsge)) {
                spin_unlock_irqrestore(&rq->lock, flags);
                dev->n_pkt_drops++;
@@ -242,7 +227,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
        ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
                       swqe->wr.send_flags & IB_SEND_SOLICITED);
 drop:
-       kfree(rsge.sg_list);
        if (atomic_dec_and_test(&qp->refcount))
                wake_up(&qp->wait);
 done:;
@@ -267,6 +251,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
        u16 lrh0;
        u16 lid;
        int ret = 0;
+       int next_cur;
 
        spin_lock_irqsave(&qp->s_lock, flags);
 
@@ -290,8 +275,9 @@ int ipath_make_ud_req(struct ipath_qp *qp)
                goto bail;
 
        wqe = get_swqe_ptr(qp, qp->s_cur);
-       if (++qp->s_cur >= qp->s_size)
-               qp->s_cur = 0;
+       next_cur = qp->s_cur + 1;
+       if (next_cur >= qp->s_size)
+               next_cur = 0;
 
        /* Construct the header. */
        ah_attr = &to_iah(wqe->wr.wr.ud.ah)->attr;
@@ -315,6 +301,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
                                qp->s_flags |= IPATH_S_WAIT_DMA;
                                goto bail;
                        }
+                       qp->s_cur = next_cur;
                        spin_unlock_irqrestore(&qp->s_lock, flags);
                        ipath_ud_loopback(qp, wqe);
                        spin_lock_irqsave(&qp->s_lock, flags);
@@ -323,6 +310,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
                }
        }
 
+       qp->s_cur = next_cur;
        extra_bytes = -wqe->length & 3;
        nwords = (wqe->length + extra_bytes) >> 2;
 
@@ -383,7 +371,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
         */
        ohdr->bth[1] = ah_attr->dlid >= IPATH_MULTICAST_LID_BASE &&
                ah_attr->dlid != IPATH_PERMISSIVE_LID ?
-               __constant_cpu_to_be32(IPATH_MULTICAST_QPN) :
+               cpu_to_be32(IPATH_MULTICAST_QPN) :
                cpu_to_be32(wqe->wr.wr.ud.remote_qpn);
        ohdr->bth[2] = cpu_to_be32(qp->s_next_psn++ & IPATH_PSN_MASK);
        /*
@@ -586,7 +574,7 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
        /* Signal completion event if the solicited bit is set. */
        ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
                       (ohdr->bth[0] &
-                       __constant_cpu_to_be32(1 << 23)) != 0);
+                       cpu_to_be32(1 << 23)) != 0);
 
 bail:;
 }