hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/infiniband/hw/hfi1/pio.c
....@@ -71,14 +71,6 @@
7171 }
7272 }
7373
74
-/* defined in header release 48 and higher */
75
-#ifndef SEND_CTRL_UNSUPPORTED_VL_SHIFT
76
-#define SEND_CTRL_UNSUPPORTED_VL_SHIFT 3
77
-#define SEND_CTRL_UNSUPPORTED_VL_MASK 0xffull
78
-#define SEND_CTRL_UNSUPPORTED_VL_SMASK (SEND_CTRL_UNSUPPORTED_VL_MASK \
79
- << SEND_CTRL_UNSUPPORTED_VL_SHIFT)
80
-#endif
81
-
8274 /* global control of PIO send */
8375 void pio_send_control(struct hfi1_devdata *dd, int op)
8476 {
....@@ -94,7 +86,7 @@
9486 switch (op) {
9587 case PSC_GLOBAL_ENABLE:
9688 reg |= SEND_CTRL_SEND_ENABLE_SMASK;
97
- /* Fall through */
89
+ fallthrough;
9890 case PSC_DATA_VL_ENABLE:
9991 mask = 0;
10092 for (i = 0; i < ARRAY_SIZE(dd->vld); i++)
....@@ -750,6 +742,7 @@
750742 spin_lock_init(&sc->alloc_lock);
751743 spin_lock_init(&sc->release_lock);
752744 spin_lock_init(&sc->credit_ctrl_lock);
745
+ seqlock_init(&sc->waitlock);
753746 INIT_LIST_HEAD(&sc->piowait);
754747 INIT_WORK(&sc->halt_work, sc_halted);
755748 init_waitqueue_head(&sc->halt_wait);
....@@ -927,6 +920,7 @@
927920 {
928921 u64 reg;
929922 struct pio_buf *pbuf;
923
+ LIST_HEAD(wake_list);
930924
931925 if (!sc)
932926 return;
....@@ -959,6 +953,23 @@
959953 }
960954 }
961955 spin_unlock(&sc->release_lock);
956
+
957
+ write_seqlock(&sc->waitlock);
958
+ list_splice_init(&sc->piowait, &wake_list);
959
+ write_sequnlock(&sc->waitlock);
960
+ while (!list_empty(&wake_list)) {
961
+ struct iowait *wait;
962
+ struct rvt_qp *qp;
963
+ struct hfi1_qp_priv *priv;
964
+
965
+ wait = list_first_entry(&wake_list, struct iowait, list);
966
+ qp = iowait_to_qp(wait);
967
+ priv = qp->priv;
968
+ list_del_init(&priv->s_iowait.list);
969
+ priv->s_iowait.lock = NULL;
970
+ hfi1_qp_wakeup(qp, RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN);
971
+ }
972
+
962973 spin_unlock_irq(&sc->alloc_lock);
963974 }
964975
....@@ -1585,10 +1596,8 @@
15851596 else
15861597 sc_del_credit_return_intr(sc);
15871598 trace_hfi1_wantpiointr(sc, needint, sc->credit_ctrl);
1588
- if (needint) {
1589
- mmiowb();
1599
+ if (needint)
15901600 sc_return_credits(sc);
1591
- }
15921601 }
15931602
15941603 /**
....@@ -1602,14 +1611,12 @@
16021611 static void sc_piobufavail(struct send_context *sc)
16031612 {
16041613 struct hfi1_devdata *dd = sc->dd;
1605
- struct hfi1_ibdev *dev = &dd->verbs_dev;
16061614 struct list_head *list;
16071615 struct rvt_qp *qps[PIO_WAIT_BATCH_SIZE];
16081616 struct rvt_qp *qp;
16091617 struct hfi1_qp_priv *priv;
16101618 unsigned long flags;
1611
- uint i, n = 0, max_idx = 0;
1612
- u8 max_starved_cnt = 0;
1619
+ uint i, n = 0, top_idx = 0;
16131620
16141621 if (dd->send_contexts[sc->sw_index].type != SC_KERNEL &&
16151622 dd->send_contexts[sc->sw_index].type != SC_VL15)
....@@ -1621,18 +1628,25 @@
16211628 * could end up with QPs on the wait list with the interrupt
16221629 * disabled.
16231630 */
1624
- write_seqlock_irqsave(&dev->iowait_lock, flags);
1631
+ write_seqlock_irqsave(&sc->waitlock, flags);
16251632 while (!list_empty(list)) {
16261633 struct iowait *wait;
16271634
16281635 if (n == ARRAY_SIZE(qps))
16291636 break;
16301637 wait = list_first_entry(list, struct iowait, list);
1638
+ iowait_get_priority(wait);
16311639 qp = iowait_to_qp(wait);
16321640 priv = qp->priv;
16331641 list_del_init(&priv->s_iowait.list);
16341642 priv->s_iowait.lock = NULL;
1635
- iowait_starve_find_max(wait, &max_starved_cnt, n, &max_idx);
1643
+ if (n) {
1644
+ priv = qps[top_idx]->priv;
1645
+ top_idx = iowait_priority_update_top(wait,
1646
+ &priv->s_iowait,
1647
+ n, top_idx);
1648
+ }
1649
+
16361650 /* refcount held until actual wake up */
16371651 qps[n++] = qp;
16381652 }
....@@ -1645,14 +1659,14 @@
16451659 if (!list_empty(list))
16461660 hfi1_sc_wantpiobuf_intr(sc, 1);
16471661 }
1648
- write_sequnlock_irqrestore(&dev->iowait_lock, flags);
1662
+ write_sequnlock_irqrestore(&sc->waitlock, flags);
16491663
1650
- /* Wake up the most starved one first */
1664
+ /* Wake up the top-priority one first */
16511665 if (n)
1652
- hfi1_qp_wakeup(qps[max_idx],
1666
+ hfi1_qp_wakeup(qps[top_idx],
16531667 RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN);
16541668 for (i = 0; i < n; i++)
1655
- if (i != max_idx)
1669
+ if (i != top_idx)
16561670 hfi1_qp_wakeup(qps[i],
16571671 RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN);
16581672 }
....@@ -2107,11 +2121,10 @@
21072121 int bytes = TXE_NUM_CONTEXTS * sizeof(struct credit_return);
21082122
21092123 set_dev_node(&dd->pcidev->dev, i);
2110
- dd->cr_base[i].va = dma_zalloc_coherent(
2111
- &dd->pcidev->dev,
2112
- bytes,
2113
- &dd->cr_base[i].dma,
2114
- GFP_KERNEL);
2124
+ dd->cr_base[i].va = dma_alloc_coherent(&dd->pcidev->dev,
2125
+ bytes,
2126
+ &dd->cr_base[i].dma,
2127
+ GFP_KERNEL);
21152128 if (!dd->cr_base[i].va) {
21162129 set_dev_node(&dd->pcidev->dev, dd->node);
21172130 dd_dev_err(dd,
....@@ -2146,3 +2159,28 @@
21462159 kfree(dd->cr_base);
21472160 dd->cr_base = NULL;
21482161 }
2162
+
2163
+void seqfile_dump_sci(struct seq_file *s, u32 i,
2164
+ struct send_context_info *sci)
2165
+{
2166
+ struct send_context *sc = sci->sc;
2167
+ u64 reg;
2168
+
2169
+ seq_printf(s, "SCI %u: type %u base %u credits %u\n",
2170
+ i, sci->type, sci->base, sci->credits);
2171
+ seq_printf(s, " flags 0x%x sw_inx %u hw_ctxt %u grp %u\n",
2172
+ sc->flags, sc->sw_index, sc->hw_context, sc->group);
2173
+ seq_printf(s, " sr_size %u credits %u sr_head %u sr_tail %u\n",
2174
+ sc->sr_size, sc->credits, sc->sr_head, sc->sr_tail);
2175
+ seq_printf(s, " fill %lu free %lu fill_wrap %u alloc_free %lu\n",
2176
+ sc->fill, sc->free, sc->fill_wrap, sc->alloc_free);
2177
+ seq_printf(s, " credit_intr_count %u credit_ctrl 0x%llx\n",
2178
+ sc->credit_intr_count, sc->credit_ctrl);
2179
+ reg = read_kctxt_csr(sc->dd, sc->hw_context, SC(CREDIT_STATUS));
2180
+ seq_printf(s, " *hw_free %llu CurrentFree %llu LastReturned %llu\n",
2181
+ (le64_to_cpu(*sc->hw_free) & CR_COUNTER_SMASK) >>
2182
+ CR_COUNTER_SHIFT,
2183
+ (reg >> SC(CREDIT_STATUS_CURRENT_FREE_COUNTER_SHIFT)) &
2184
+ SC(CREDIT_STATUS_CURRENT_FREE_COUNTER_MASK),
2185
+ reg & SC(CREDIT_STATUS_LAST_RETURNED_COUNTER_SMASK));
2186
+}