Skip to content

Commit 1c726c4

Browse files
committed
Merge HFI1 updates into k.o/for-next
Based on rdma.git for-rc for dependencies. From Dennis Dalessandro: ==================== Here are some code improvement patches and fixes for less serious bugs to TID RDMA than we sent for RC. ==================== * HFI1 updates: IB/hfi1: Implement CCA for TID RDMA protocol IB/hfi1: Remove WARN_ON when freeing expected receive groups IB/hfi1: Unify the software PSN check for TID RDMA READ/WRITE IB/hfi1: Add a function to read next expected psn from hardware flow IB/hfi1: Delay the release of destination mr for TID RDMA WRITE DATA Signed-off-by: Jason Gunthorpe <[email protected]>
2 parents 061ccb5 + 747b931 commit 1c726c4

File tree

10 files changed

+255
-131
lines changed

10 files changed

+255
-131
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13232,7 +13232,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
1323213232
int total_contexts;
1323313233
int ret;
1323413234
unsigned ngroups;
13235-
int qos_rmt_count;
13235+
int rmt_count;
1323613236
int user_rmt_reduced;
1323713237
u32 n_usr_ctxts;
1323813238
u32 send_contexts = chip_send_contexts(dd);
@@ -13294,10 +13294,23 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
1329413294
n_usr_ctxts = rcv_contexts - total_contexts;
1329513295
}
1329613296

13297-
/* each user context requires an entry in the RMT */
13298-
qos_rmt_count = qos_rmt_entries(dd, NULL, NULL);
13299-
if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13300-
user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count;
13297+
/*
13298+
* The RMT entries are currently allocated as shown below:
13299+
* 1. QOS (0 to 128 entries);
13300+
* 2. FECN (num_kernel_context - 1 + num_user_contexts +
13301+
* num_vnic_contexts);
13302+
* 3. VNIC (num_vnic_contexts).
13303+
* It should be noted that FECN oversubscribe num_vnic_contexts
13304+
* entries of RMT because both VNIC and PSM could allocate any receive
13305+
* context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
13306+
* and PSM FECN must reserve an RMT entry for each possible PSM receive
13307+
* context.
13308+
*/
13309+
rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
13310+
if (HFI1_CAP_IS_KSET(TID_RDMA))
13311+
rmt_count += num_kernel_contexts - 1;
13312+
if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13313+
user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
1330113314
dd_dev_err(dd,
1330213315
"RMT size is reducing the number of user receive contexts from %u to %d\n",
1330313316
n_usr_ctxts,
@@ -14278,35 +14291,43 @@ static void init_qos(struct hfi1_devdata *dd, struct rsm_map_table *rmt)
1427814291
init_qpmap_table(dd, FIRST_KERNEL_KCTXT, dd->n_krcv_queues - 1);
1427914292
}
1428014293

14281-
static void init_user_fecn_handling(struct hfi1_devdata *dd,
14282-
struct rsm_map_table *rmt)
14294+
static void init_fecn_handling(struct hfi1_devdata *dd,
14295+
struct rsm_map_table *rmt)
1428314296
{
1428414297
struct rsm_rule_data rrd;
1428514298
u64 reg;
14286-
int i, idx, regoff, regidx;
14299+
int i, idx, regoff, regidx, start;
1428714300
u8 offset;
14301+
u32 total_cnt;
14302+
14303+
if (HFI1_CAP_IS_KSET(TID_RDMA))
14304+
/* Exclude context 0 */
14305+
start = 1;
14306+
else
14307+
start = dd->first_dyn_alloc_ctxt;
14308+
14309+
total_cnt = dd->num_rcv_contexts - start;
1428814310

1428914311
/* there needs to be enough room in the map table */
14290-
if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
14291-
dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n");
14312+
if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
14313+
dd_dev_err(dd, "FECN handling disabled - too many contexts allocated\n");
1429214314
return;
1429314315
}
1429414316

1429514317
/*
1429614318
* RSM will extract the destination context as an index into the
1429714319
* map table. The destination contexts are a sequential block
14298-
* in the range first_dyn_alloc_ctxt...num_rcv_contexts-1 (inclusive).
14320+
* in the range start...num_rcv_contexts-1 (inclusive).
1429914321
* Map entries are accessed as offset + extracted value. Adjust
1430014322
* the added offset so this sequence can be placed anywhere in
1430114323
* the table - as long as the entries themselves do not wrap.
1430214324
* There are only enough bits in offset for the table size, so
1430314325
* start with that to allow for a "negative" offset.
1430414326
*/
14305-
offset = (u8)(NUM_MAP_ENTRIES + (int)rmt->used -
14306-
(int)dd->first_dyn_alloc_ctxt);
14327+
offset = (u8)(NUM_MAP_ENTRIES + rmt->used - start);
1430714328

14308-
for (i = dd->first_dyn_alloc_ctxt, idx = rmt->used;
14309-
i < dd->num_rcv_contexts; i++, idx++) {
14329+
for (i = start, idx = rmt->used; i < dd->num_rcv_contexts;
14330+
i++, idx++) {
1431014331
/* replace with identity mapping */
1431114332
regoff = (idx % 8) * 8;
1431214333
regidx = idx / 8;
@@ -14341,7 +14362,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
1434114362
/* add rule 1 */
1434214363
add_rsm_rule(dd, RSM_INS_FECN, &rrd);
1434314364

14344-
rmt->used += dd->num_user_contexts;
14365+
rmt->used += total_cnt;
1434514366
}
1434614367

1434714368
/* Initialize RSM for VNIC */
@@ -14428,7 +14449,7 @@ static void init_rxe(struct hfi1_devdata *dd)
1442814449
rmt = alloc_rsm_map_table(dd);
1442914450
/* set up QOS, including the QPN map table */
1443014451
init_qos(dd, rmt);
14431-
init_user_fecn_handling(dd, rmt);
14452+
init_fecn_handling(dd, rmt);
1443214453
complete_rsm_map_table(dd, rmt);
1443314454
/* record number of used rsm map entries for vnic */
1443414455
dd->vnic.rmt_start = rmt->used;

drivers/infiniband/hw/hfi1/driver.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ bool hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
514514
*/
515515
do_cnp = prescan ||
516516
(opcode >= IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST &&
517-
opcode <= IB_OPCODE_RC_ATOMIC_ACKNOWLEDGE);
517+
opcode <= IB_OPCODE_RC_ATOMIC_ACKNOWLEDGE) ||
518+
opcode == TID_OP(READ_RESP) ||
519+
opcode == TID_OP(ACK);
518520

519521
/* Call appropriate CNP handler */
520522
if (!ignore_fecn && do_cnp && fecn)

drivers/infiniband/hw/hfi1/exp_rcv.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ int hfi1_alloc_ctxt_rcv_groups(struct hfi1_ctxtdata *rcd)
112112
*/
113113
void hfi1_free_ctxt_rcv_groups(struct hfi1_ctxtdata *rcd)
114114
{
115-
WARN_ON(!EXP_TID_SET_EMPTY(rcd->tid_full_list));
116-
WARN_ON(!EXP_TID_SET_EMPTY(rcd->tid_used_list));
117-
118115
kfree(rcd->groups);
119116
rcd->groups = NULL;
120117
hfi1_exp_tid_group_init(rcd);

drivers/infiniband/hw/hfi1/qp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ void notify_error_qp(struct rvt_qp *qp)
900900
if (!list_empty(&priv->s_iowait.list) &&
901901
!(qp->s_flags & RVT_S_BUSY) &&
902902
!(priv->s_flags & RVT_S_BUSY)) {
903-
qp->s_flags &= ~RVT_S_ANY_WAIT_IO;
903+
qp->s_flags &= ~HFI1_S_ANY_WAIT_IO;
904+
iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_IB);
905+
iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_TID);
904906
list_del_init(&priv->s_iowait.list);
905907
priv->s_iowait.lock = NULL;
906908
rvt_put_qp(qp);

drivers/infiniband/hw/hfi1/rc.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
140140
case OP(RDMA_READ_RESPONSE_LAST):
141141
case OP(RDMA_READ_RESPONSE_ONLY):
142142
e = &qp->s_ack_queue[qp->s_tail_ack_queue];
143-
if (e->rdma_sge.mr) {
144-
rvt_put_mr(e->rdma_sge.mr);
145-
e->rdma_sge.mr = NULL;
146-
}
143+
release_rdma_sge_mr(e);
147144
/* FALLTHROUGH */
148145
case OP(ATOMIC_ACKNOWLEDGE):
149146
/*
@@ -343,7 +340,8 @@ static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
343340
break;
344341

345342
e->sent = 1;
346-
qp->s_ack_state = OP(RDMA_READ_RESPONSE_LAST);
343+
/* Do not free e->rdma_sge until all data are received */
344+
qp->s_ack_state = OP(ATOMIC_ACKNOWLEDGE);
347345
break;
348346

349347
case TID_OP(READ_RESP):
@@ -2643,10 +2641,7 @@ static noinline int rc_rcv_error(struct ib_other_headers *ohdr, void *data,
26432641
len = be32_to_cpu(reth->length);
26442642
if (unlikely(offset + len != e->rdma_sge.sge_length))
26452643
goto unlock_done;
2646-
if (e->rdma_sge.mr) {
2647-
rvt_put_mr(e->rdma_sge.mr);
2648-
e->rdma_sge.mr = NULL;
2649-
}
2644+
release_rdma_sge_mr(e);
26502645
if (len != 0) {
26512646
u32 rkey = be32_to_cpu(reth->rkey);
26522647
u64 vaddr = get_ib_reth_vaddr(reth);
@@ -3088,10 +3083,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
30883083
update_ack_queue(qp, next);
30893084
}
30903085
e = &qp->s_ack_queue[qp->r_head_ack_queue];
3091-
if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
3092-
rvt_put_mr(e->rdma_sge.mr);
3093-
e->rdma_sge.mr = NULL;
3094-
}
3086+
release_rdma_sge_mr(e);
30953087
reth = &ohdr->u.rc.reth;
30963088
len = be32_to_cpu(reth->length);
30973089
if (len) {
@@ -3166,10 +3158,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
31663158
update_ack_queue(qp, next);
31673159
}
31683160
e = &qp->s_ack_queue[qp->r_head_ack_queue];
3169-
if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
3170-
rvt_put_mr(e->rdma_sge.mr);
3171-
e->rdma_sge.mr = NULL;
3172-
}
3161+
release_rdma_sge_mr(e);
31733162
/* Process OPFN special virtual address */
31743163
if (opfn) {
31753164
opfn_conn_response(qp, e, ateth);

drivers/infiniband/hw/hfi1/rc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ static inline u32 restart_sge(struct rvt_sge_state *ss, struct rvt_swqe *wqe,
4141
return rvt_restart_sge(ss, wqe, len);
4242
}
4343

44+
static inline void release_rdma_sge_mr(struct rvt_ack_entry *e)
45+
{
46+
if (e->rdma_sge.mr) {
47+
rvt_put_mr(e->rdma_sge.mr);
48+
e->rdma_sge.mr = NULL;
49+
}
50+
}
51+
4452
struct rvt_ack_entry *find_prev_entry(struct rvt_qp *qp, u32 psn, u8 *prev,
4553
u8 *prev_ack, bool *scheduled);
4654
int do_rc_ack(struct rvt_qp *qp, u32 aeth, u32 psn, int opcode, u64 val,

0 commit comments

Comments
 (0)