]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/staging/rdma/hfi1/ruc.c
Merge remote-tracking branch 'staging/staging-next'
[karo-tx-linux.git] / drivers / staging / rdma / hfi1 / ruc.c
index d614474770b31cf7f3bf4424bb85d010858399d7..49bc9fd7a51aee2c3e0e57717ff2514a02c2e327 100644 (file)
@@ -695,19 +695,6 @@ u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,
        return sizeof(struct ib_grh) / sizeof(u32);
 }
 
-/*
- * free_ahg - clear ahg from QP
- */
-void clear_ahg(struct hfi1_qp *qp)
-{
-       qp->s_hdr->ahgcount = 0;
-       qp->s_flags &= ~(HFI1_S_AHG_VALID | HFI1_S_AHG_CLEAR);
-       if (qp->s_sde)
-               sdma_ahg_free(qp->s_sde, qp->s_ahgidx);
-       qp->s_ahgidx = -1;
-       qp->s_sde = NULL;
-}
-
 #define BTH2_OFFSET (offsetof(struct hfi1_pio_header, hdr.u.oth.bth[2]) / 4)
 
 /**
@@ -833,6 +820,9 @@ void hfi1_make_ruc_header(struct hfi1_qp *qp, struct hfi1_other_headers *ohdr,
        ohdr->bth[2] = cpu_to_be32(bth2);
 }
 
+/* when sending, force a reschedule every one of these periods */
+#define SEND_RESCHED_TIMEOUT (5 * HZ)  /* 5s in jiffies */
+
 /**
  * hfi1_do_send - perform a send on a QP
  * @work: contains a pointer to the QP
@@ -849,6 +839,7 @@ void hfi1_do_send(struct work_struct *work)
        struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
        int (*make_req)(struct hfi1_qp *qp);
        unsigned long flags;
+       unsigned long timeout;
 
        if ((qp->ibqp.qp_type == IB_QPT_RC ||
             qp->ibqp.qp_type == IB_QPT_UC) &&
@@ -877,6 +868,7 @@ void hfi1_do_send(struct work_struct *work)
 
        spin_unlock_irqrestore(&qp->s_lock, flags);
 
+       timeout = jiffies + SEND_RESCHED_TIMEOUT;
        do {
                /* Check for a constructed packet to be sent. */
                if (qp->s_hdrwords != 0) {
@@ -890,6 +882,13 @@ void hfi1_do_send(struct work_struct *work)
                        /* Record that s_hdr is empty. */
                        qp->s_hdrwords = 0;
                }
+
+               /* allow other tasks to run */
+               if (unlikely(time_after(jiffies, timeout))) {
+                       cond_resched();
+                       ppd->dd->verbs_dev.n_send_schedule++;
+                       timeout = jiffies + SEND_RESCHED_TIMEOUT;
+               }
        } while (make_req(qp));
 }