Skip to content

Commit 582549e

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "Several driver bug fixes posted in the last several weeks - Several bug fixes for the hfi1 driver 'TID RDMA' functionality merged into 5.1. Since TID RDMA is on by default these all seem to be regressions. - Wrong software permission checks on memory in mlx5 - Memory leak in vmw_pvrdma during driver remove - Several bug fixes for hns driver features merged into 5.1" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: IB/hfi1: Do not flush send queue in the TID RDMA second leg RDMA/hns: Bugfix for SCC hem free RDMA/hns: Fix bug that caused srq creation to fail RDMA/vmw_pvrdma: Fix memory leak on pvrdma_pci_remove IB/mlx5: Reset access mask when looping inside page fault handler IB/hfi1: Fix the allocation of RSM table IB/hfi1: Eliminate opcode tests on mr deref IB/hfi1: Clear the IOWAIT pending bits when QP is put into error state IB/hfi1: Failed to drain send queue when QP is put into error state
2 parents ed79cc8 + d737b25 commit 582549e

File tree

9 files changed

+42
-41
lines changed

9 files changed

+42
-41
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 19 additions & 7 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,20 @@ 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 for PSM (num_user_contexts + num_vnic_contexts);
13301+
* 3. VNIC (num_vnic_contexts).
13302+
* It should be noted that PSM FECN oversubscribe num_vnic_contexts
13303+
* entries of RMT because both VNIC and PSM could allocate any receive
13304+
* context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
13305+
* and PSM FECN must reserve an RMT entry for each possible PSM receive
13306+
* context.
13307+
*/
13308+
rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
13309+
if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
13310+
user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
1330113311
dd_dev_err(dd,
1330213312
"RMT size is reducing the number of user receive contexts from %u to %d\n",
1330313313
n_usr_ctxts,
@@ -14285,9 +14295,11 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
1428514295
u64 reg;
1428614296
int i, idx, regoff, regidx;
1428714297
u8 offset;
14298+
u32 total_cnt;
1428814299

1428914300
/* there needs to be enough room in the map table */
14290-
if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
14301+
total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt;
14302+
if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
1429114303
dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n");
1429214304
return;
1429314305
}
@@ -14341,7 +14353,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
1434114353
/* add rule 1 */
1434214354
add_rsm_rule(dd, RSM_INS_FECN, &rrd);
1434314355

14344-
rmt->used += dd->num_user_contexts;
14356+
rmt->used += total_cnt;
1434514357
}
1434614358

1434714359
/* Initialize RSM for VNIC */

drivers/infiniband/hw/hfi1/qp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,9 @@ void notify_error_qp(struct rvt_qp *qp)
898898
if (!list_empty(&priv->s_iowait.list) &&
899899
!(qp->s_flags & RVT_S_BUSY) &&
900900
!(priv->s_flags & RVT_S_BUSY)) {
901-
qp->s_flags &= ~RVT_S_ANY_WAIT_IO;
901+
qp->s_flags &= ~HFI1_S_ANY_WAIT_IO;
902+
iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_IB);
903+
iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_TID);
902904
list_del_init(&priv->s_iowait.list);
903905
priv->s_iowait.lock = NULL;
904906
rvt_put_qp(qp);

drivers/infiniband/hw/hfi1/rc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
30883088
update_ack_queue(qp, next);
30893089
}
30903090
e = &qp->s_ack_queue[qp->r_head_ack_queue];
3091-
if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
3091+
if (e->rdma_sge.mr) {
30923092
rvt_put_mr(e->rdma_sge.mr);
30933093
e->rdma_sge.mr = NULL;
30943094
}
@@ -3166,7 +3166,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
31663166
update_ack_queue(qp, next);
31673167
}
31683168
e = &qp->s_ack_queue[qp->r_head_ack_queue];
3169-
if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
3169+
if (e->rdma_sge.mr) {
31703170
rvt_put_mr(e->rdma_sge.mr);
31713171
e->rdma_sge.mr = NULL;
31723172
}

drivers/infiniband/hw/hfi1/tid_rdma.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5017,24 +5017,14 @@ int hfi1_make_tid_rdma_pkt(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
50175017
make_tid_rdma_ack(qp, ohdr, ps))
50185018
return 1;
50195019

5020-
if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK)) {
5021-
if (!(ib_rvt_state_ops[qp->state] & RVT_FLUSH_SEND))
5022-
goto bail;
5023-
/* We are in the error state, flush the work request. */
5024-
if (qp->s_last == READ_ONCE(qp->s_head))
5025-
goto bail;
5026-
/* If DMAs are in progress, we can't flush immediately. */
5027-
if (iowait_sdma_pending(&priv->s_iowait)) {
5028-
qp->s_flags |= RVT_S_WAIT_DMA;
5029-
goto bail;
5030-
}
5031-
clear_ahg(qp);
5032-
wqe = rvt_get_swqe_ptr(qp, qp->s_last);
5033-
hfi1_trdma_send_complete(qp, wqe, qp->s_last != qp->s_acked ?
5034-
IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR);
5035-
/* will get called again */
5036-
goto done_free_tx;
5037-
}
5020+
/*
5021+
* Bail out if we can't send data.
5022+
* Be reminded that this check must been done after the call to
5023+
* make_tid_rdma_ack() because the responding QP could be in
5024+
* RTR state where it can send TID RDMA ACK, not TID RDMA WRITE DATA.
5025+
*/
5026+
if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK))
5027+
goto bail;
50385028

50395029
if (priv->s_flags & RVT_S_WAIT_ACK)
50405030
goto bail;
@@ -5144,11 +5134,6 @@ int hfi1_make_tid_rdma_pkt(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
51445134
hfi1_make_ruc_header(qp, ohdr, (opcode << 24), bth1, bth2,
51455135
middle, ps);
51465136
return 1;
5147-
done_free_tx:
5148-
hfi1_put_txreq(ps->s_txreq);
5149-
ps->s_txreq = NULL;
5150-
return 1;
5151-
51525137
bail:
51535138
hfi1_put_txreq(ps->s_txreq);
51545139
bail_no_tx:

drivers/infiniband/hw/hns/hns_roce_hem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
792792
idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk;
793793
dma_offset = offset = idx_offset * table->obj_size;
794794
} else {
795+
u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */
796+
795797
hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop);
796798
/* mtt mhop */
797799
i = mhop.l0_idx;
@@ -803,8 +805,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
803805
hem_idx = i;
804806

805807
hem = table->hem[hem_idx];
806-
dma_offset = offset = (obj & (table->num_obj - 1)) *
807-
table->obj_size % mhop.bt_chunk_size;
808+
dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size %
809+
mhop.bt_chunk_size;
808810
if (mhop.hop_num == 2)
809811
dma_offset = offset = 0;
810812
}

drivers/infiniband/hw/hns/hns_roce_mr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,6 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev,
746746
struct hns_roce_hem_table *table;
747747
dma_addr_t dma_handle;
748748
__le64 *mtts;
749-
u32 s = start_index * sizeof(u64);
750749
u32 bt_page_size;
751750
u32 i;
752751

@@ -780,7 +779,8 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev,
780779
return -EINVAL;
781780

782781
mtts = hns_roce_table_find(hr_dev, table,
783-
mtt->first_seg + s / hr_dev->caps.mtt_entry_sz,
782+
mtt->first_seg +
783+
start_index / HNS_ROCE_MTT_ENTRY_PER_SEG,
784784
&dma_handle);
785785
if (!mtts)
786786
return -ENOMEM;

drivers/infiniband/hw/hns/hns_roce_qp.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,6 @@ void hns_roce_qp_free(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
274274
wait_for_completion(&hr_qp->free);
275275

276276
if ((hr_qp->ibqp.qp_type) != IB_QPT_GSI) {
277-
if (hr_dev->caps.sccc_entry_sz)
278-
hns_roce_table_put(hr_dev, &qp_table->sccc_table,
279-
hr_qp->qpn);
280277
if (hr_dev->caps.trrl_entry_sz)
281278
hns_roce_table_put(hr_dev, &qp_table->trrl_table,
282279
hr_qp->qpn);

drivers/infiniband/hw/mlx5/odp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ static int pagefault_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr,
585585
struct ib_umem_odp *odp_mr = to_ib_umem_odp(mr->umem);
586586
bool downgrade = flags & MLX5_PF_FLAGS_DOWNGRADE;
587587
bool prefetch = flags & MLX5_PF_FLAGS_PREFETCH;
588-
u64 access_mask = ODP_READ_ALLOWED_BIT;
588+
u64 access_mask;
589589
u64 start_idx, page_mask;
590590
struct ib_umem_odp *odp;
591591
size_t size;
@@ -607,6 +607,7 @@ static int pagefault_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr,
607607
page_shift = mr->umem->page_shift;
608608
page_mask = ~(BIT(page_shift) - 1);
609609
start_idx = (io_virt - (mr->mmkey.iova & page_mask)) >> page_shift;
610+
access_mask = ODP_READ_ALLOWED_BIT;
610611

611612
if (prefetch && !downgrade && !mr->umem->writable) {
612613
/* prefetch with write-access must

drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,8 @@ static void pvrdma_pci_remove(struct pci_dev *pdev)
11311131
pvrdma_page_dir_cleanup(dev, &dev->cq_pdir);
11321132
pvrdma_page_dir_cleanup(dev, &dev->async_pdir);
11331133
pvrdma_free_slots(dev);
1134+
dma_free_coherent(&pdev->dev, sizeof(*dev->dsr), dev->dsr,
1135+
dev->dsrbase);
11341136

11351137
iounmap(dev->regs);
11361138
kfree(dev->sgid_tbl);

0 commit comments

Comments
 (0)