IB/hfi1, qib, rdmavt: patches for next 08/28/2017
Subsystems (3)
cover IB/hfi1, qib, rdmavt: patches for next 08/28/2017
Hi Doug,
Here is the next round of patches for our drivers. There are a few patches from Mike that adds a qp iterator and starts the work of cleaning up some of our code that needs to walk qps. The rest are minor bug fixes.
Patches can can also be found in my GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.14
---
Jan Sokolowski (1):
IB/hfi1: Acquire QSFP cable information on loopback
Kaike Wan (1):
IB/hfi1: Use accessor to determine ring size
Kamenee Arumugam (1):
IB/qib: Stricter bounds checking for copy to buffer
Michael J. Ruhl (1):
IB/hif1: Remove static tracing from SDMA hot path
Mike Marciniszyn (5):
IB/rdmavt: Add QP iterator API for QPs
IB/hfi1: Convert hfi1_error_port_qps() to use new QP iterator IB/hfi1: Convert qp_stats debugfs interface to use new iterator API IB/qib: Convert qp_stats debugfs interface to use new iterator API IB/rdmavt: Handle dereg of inuse MRs properly
drivers/infiniband/hw/hfi1/debugfs.c | 15 +- drivers/infiniband/hw/hfi1/file_ops.c | 3 drivers/infiniband/hw/hfi1/mmu_rb.c | 13 +- drivers/infiniband/hw/hfi1/platform.c | 15 ++ drivers/infiniband/hw/hfi1/qp.c | 164 ++++++-------------- drivers/infiniband/hw/hfi1/qp.h | 23 --- drivers/infiniband/hw/hfi1/trace.h | 3 drivers/infiniband/hw/hfi1/trace_mmu.h | 95 ++++++++++++ drivers/infiniband/hw/hfi1/trace_tx.h | 136 ++++++++++++++++ drivers/infiniband/hw/hfi1/user_sdma.c | 31 ++-- drivers/infiniband/hw/hfi1/user_sdma.h | 3 drivers/infiniband/hw/qib/qib_debugfs.c | 18 +- drivers/infiniband/hw/qib/qib_iba7322.c | 4 drivers/infiniband/hw/qib/qib_qp.c | 51 +----- drivers/infiniband/hw/qib/qib_verbs.h | 10 - drivers/infiniband/sw/rdmavt/mr.c | 121 +++++++++++++-- drivers/infiniband/sw/rdmavt/qp.c | 256 +++++++++++++++++++++++++++++++ include/rdma/rdmavt_mr.h | 3 include/rdma/rdmavt_qp.h | 30 ++++ 19 files changed, 733 insertions(+), 261 deletions(-) create mode 100644 drivers/infiniband/hw/hfi1/trace_mmu.h
--
-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/9 IB/hfi1: Acquire QSFP cable information on loopback
In reply to a message not in the archiveFrom: Jan Sokolowski <[email protected]>
Currently, QSFP information is not queried
in cases where loopback was set up and QSFP module is present.
Acquire QSFP information in case of loopback.
--- drivers/infiniband/hw/hfi1/platform.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/platform.c +15 -0
@@ -944,6 +944,21 @@ void tune_serdes(struct hfi1_pportdata *ppd)if (loopback !=LOOPBACK_NONE || ppd->dd->icode ==ICODE_FUNCTIONAL_SIMULATOR ) { ppd->driver_link_ready =1 ; + +if (qsfp_mod_present (ppd)) { + ret =acquire_chip_resource (ppd->dd, +qsfp_resource (ppd->dd), +QSFP_WAIT ); +if (ret) { +dd_dev_err (ppd->dd,"%s: hfi%d: cannot lock i2c chain\n" , + __func__, (int )ppd->dd->hfi1_id); + goto bail; + } + +refresh_qsfp_cache (ppd, &ppd->qsfp_info); +release_chip_resource (ppd->dd,qsfp_resource (ppd->dd)); + } +return ; }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/9 IB/hif1: Remove static tracing from SDMA hot path
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
The hfi1_cdbg() macro can be instantiated in the hot path even when it is not in use. This shows up on perf profiles.
Rework the macros (for SDMA and MMU), to use the trace interface directly to eliminate this performance hit.
--- drivers/infiniband/hw/hfi1/file_ops.c | 3 - drivers/infiniband/hw/hfi1/mmu_rb.c | 13 +-- drivers/infiniband/hw/hfi1/trace.h | 3 - drivers/infiniband/hw/hfi1/trace_mmu.h | 95 ++++++++++++++++++++++ drivers/infiniband/hw/hfi1/trace_tx.h | 136 ++++++++++++++++++++++++++++++++ drivers/infiniband/hw/hfi1/user_sdma.c | 31 ++++--- drivers/infiniband/hw/hfi1/user_sdma.h | 3 - 7 files changed, 255 insertions(+), 29 deletions(-) create mode 100644 drivers/infiniband/hw/hfi1/trace_mmu.h
drivers/infiniband/hw/hfi1/file_ops.c +1 -2
@@ -430,8 +430,7 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)if (!iter_is_iovec (from) || !dim)return -EINVAL ; -hfi1_cdbg (SDMA ,"SDMA request from %u:%u (%lu)" , - fd->uctxt->ctxt, fd->subctxt, dim); +trace_hfi1_sdma_request (fd->dd, fd->uctxt->ctxt, fd->subctxt, dim);if (atomic_read (&pq->n_reqs) == pq->n_max_reqs)return -ENOSPC ;
drivers/infiniband/hw/hfi1/mmu_rb.c +5 -8
@@ -1,5 +1,5 @@/* -* Copyright(c) 2016 Intel Corporation. +* Copyright(c) 2016 - 2017 Intel Corporation. * * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license.
@@ -172,9 +172,8 @@ int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler,unsigned long flags;int ret =0 ; +trace_hfi1_mmu_rb_insert (mnode->addr, mnode->len);spin_lock_irqsave (&handler->lock, flags); -hfi1_cdbg (MMU ,"Inserting node addr 0x%llx, len %u" , mnode->addr, - mnode->len); node =__mmu_rb_search (handler, mnode->addr, mnode->len);if (node) { ret = -EINVAL ;
@@ -200,7 +199,7 @@ int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler, {struct mmu_rb_node *node =NULL ; -hfi1_cdbg (MMU ,"Searching for addr 0x%llx, len %u" , addr, len); +trace_hfi1_mmu_rb_search (addr, len);if (!handler->ops->filter) { node =__mmu_int_rb_iter_first (&handler->root, addr, (addr + len) -1 );
@@ -281,8 +280,7 @@ void hfi1_mmu_rb_remove(struct mmu_rb_handler *handler,unsigned long flags;/* Validity of handler and node pointers has been checked by caller. */ -hfi1_cdbg (MMU ,"Removing node addr 0x%llx, len %u" , node->addr, - node->len); +trace_hfi1_mmu_rb_remove (node->addr, node->len);spin_lock_irqsave (&handler->lock, flags);__mmu_int_rb_remove (node, &handler->root);list_del (&node->list);/* remove from LRU list */
@@ -321,8 +319,7 @@ static void mmu_notifier_mem_invalidate(struct mmu_notifier *mn, node; node = ptr) {/* Guard against node removal. */ ptr =__mmu_int_rb_iter_next (node, start, end -1 ); -hfi1_cdbg (MMU ,"Invalidating node addr 0x%llx, len %u" , - node->addr, node->len); +trace_hfi1_mmu_mem_invalidate (node->addr, node->len);if (handler->ops->invalidate (handler->ops_arg, node)) {__mmu_int_rb_remove (node, root);/* move from LRU list to delete list */
drivers/infiniband/hw/hfi1/trace.h +2 -1
@@ -1,5 +1,5 @@/* -* Copyright(c) 2015, 2016 Intel Corporation. +* Copyright(c) 2015 - 2017 Intel Corporation. * * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license.
@@ -51,3 +51,4 @@#include "trace_rc.h" #include "trace_rx.h" #include "trace_tx.h" +#include "trace_mmu.h"
drivers/infiniband/hw/hfi1/trace_mmu.h new file +95 -0
95 lines not on this page · raw message
drivers/infiniband/hw/hfi1/trace_tx.h +135 -1
146 lines not on this page · raw message
drivers/infiniband/hw/hfi1/user_sdma.c +17 -14
@@ -266,8 +266,8 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd, {struct hfi1_user_sdma_pkt_q *pq; -hfi1_cdbg (SDMA ,"[%u:%u:%u] Freeing user SDMA queues" , uctxt->dd->unit, - uctxt->ctxt, fd->subctxt); +trace_hfi1_sdma_user_free_queues (uctxt->dd, uctxt->ctxt, fd->subctxt); + pq = fd->pq;if (pq) {if (pq->handler)
@@ -349,7 +349,6 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,trace_hfi1_sdma_user_reqinfo (dd, uctxt->ctxt, fd->subctxt, (u16 *)&info); -if (info.comp_idx >= hfi1_sdma_comp_ring_size) { hfi1_cdbg(SDMA, "[%u:%u:%u:%u] Invalid comp index",
@@ -386,8 +385,8 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,/* * All safety checks have been done and this request has been claimed. */ -hfi1_cdbg (SDMA ,"[%u:%u:%u] Using req/comp entry %u\n" , dd->unit, - uctxt->ctxt, fd->subctxt, info.comp_idx); +trace_hfi1_sdma_user_process_request (dd, uctxt->ctxt, fd->subctxt, + info.comp_idx); req = pq->reqs + info.comp_idx; req->data_iovs =req_iovcnt (info.ctrl) -1 ;/* subtract header vector */ req->data_len =0 ;
@@ -487,7 +486,8 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd, req->tidoffset =KDETH_GET (req->hdr.kdeth.ver_tid_offset,OFFSET ) * (KDETH_GET (req->hdr.kdeth.ver_tid_offset,OM ) ?KDETH_OM_LARGE :KDETH_OM_SMALL ); -SDMA_DBG (req,"Initial TID offset %u" , req->tidoffset); +trace_hfi1_sdma_user_initial_tidoffset (dd, uctxt->ctxt, fd->subctxt, + info.comp_idx, req->tidoffset); idx++;/* Save all the IO vector structures */
@@ -505,8 +505,8 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd, } req->data_len += req->iovs[i].iov.iov_len; } -SDMA_DBG (req,"total data length %u" , req->data_len); - +trace_hfi1_sdma_user_data_length (dd, uctxt->ctxt, fd->subctxt, + info.comp_idx, req->data_len);if (pcount > req->info.npkts) pcount = req->info.npkts;/*
@@ -661,7 +661,11 @@ static inline u32 compute_data_length(struct user_sdma_request *req, }else { len =min (req->data_len - req->sent, (u32 )req->info.fragsize); } -SDMA_DBG (req,"Data Length = %u" , len); +trace_hfi1_sdma_user_compute_length (req->pq->dd, + req->pq->ctxt, + req->pq->subctxt, + req->info.comp_idx, + len);return len; }
@@ -1231,9 +1235,10 @@ static int set_txreq_header(struct user_sdma_request *req,* Set the KDETH.OFFSET and KDETH.OM based on size of * transfer. */ -SDMA_DBG (req,"TID offset %ubytes %uunits om%u" , - req->tidoffset, req->tidoffset >> omfactor, - omfactor !=KDETH_OM_SMALL_SHIFT ); +trace_hfi1_sdma_user_tid_info ( + pq->dd, pq->ctxt, pq->subctxt, req->info.comp_idx, + req->tidoffset, req->tidoffset >> omfactor, + omfactor !=KDETH_OM_SMALL_SHIFT );KDETH_SET (hdr->kdeth.ver_tid_offset,OFFSET , req->tidoffset >> omfactor); KDETH_SET(hdr->kdeth.ver_tid_offset, OM,
@@ -1441,8 +1446,6 @@ static inline void set_comp_state(struct hfi1_user_sdma_pkt_q *pq, u16 idx, enum hfi1_sdma_comp_state state, int ret) { - hfi1_cdbg(SDMA, "[%u:%u:%u:%u] Setting completion status %u %d", - pq->dd->unit, pq->ctxt, pq->subctxt, idx, state, ret); if (state == ERROR) cq->comps[idx].errcode = -ret;smp_wmb ();/* make sure errcode is visible first */
drivers/infiniband/hw/hfi1/user_sdma.h +0 -3
@@ -110,9 +110,6 @@hfi1_cdbg (SDMA ,"[%u:%u:%u:%u] " fmt, (req)->pq->dd->unit, \ (req)->pq->ctxt, (req)->pq->subctxt, (req)->info.comp_idx, \ ##__VA_ARGS__) -#define SDMA_Q_DBG (pq, fmt, ...) \ - hfi1_cdbg(SDMA, "[%u:%u:%u] " fmt, (pq)->dd->unit, (pq)->ctxt, \ - (pq)->subctxt, ##__VA_ARGS__)extern uint extended_psn;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/9 IB/qib: Stricter bounds checking for copy to buffer
In reply to a message not in the archiveFrom: Kamenee Arumugam <[email protected]>
Replace 'strcpy' with 'strncpy' to restrict the number of bytes copied to the buffer.
--- drivers/infiniband/hw/qib/qib_iba7322.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/qib/qib_iba7322.c +2 -2
@@ -6175,7 +6175,7 @@ static int setup_txselect(const char *str, struct kernel_param *kp)unsigned long val;char *n; -if (strlen (str) >=MAX_ATTEN_LEN ) { +if (strlen (str) >=ARRAY_SIZE (txselect_list)) {pr_info ("txselect_values string too long\n" );return -ENOSPC ; }
@@ -6186,7 +6186,7 @@ static int setup_txselect(const char *str, struct kernel_param *kp) TXDDS_TABLE_SZ + TXDDS_EXTRA_SZ + TXDDS_MFG_SZ);return -EINVAL ; } -strcpy (txselect_list, str); +strncpy (txselect_list, str,ARRAY_SIZE (txselect_list) -1 );list_for_each_entry (dd, &qib_dev_list, list)if (dd->deviceid ==PCI_DEVICE_ID_QLOGIC_IB_7322 )
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/9 IB/hfi1: Use accessor to determine ring size
In reply to a message not in the archiveFrom: Kaike Wan <[email protected]>
The qp_stats print will soon be moving to rdmavt, so use the proper accessor to get the ring size rather than a driver supplied constant.
--- drivers/infiniband/hw/hfi1/qp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/qp.c +1 -1
@@ -659,7 +659,7 @@ void qp_iter_print(struct seq_file *s, struct qp_iter *iter) qp->s_avail,/* ack_queue ring pointers, size */ qp->s_tail_ack_queue, qp->r_head_ack_queue, -HFI1_MAX_RDMA_ATOMIC , +rvt_max_atomic (&to_idev (qp->ibqp.device)->rdi),/* remote QP info */ qp->remote_qpn, rdma_ah_get_dlid(&qp->remote_ah_attr),
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/9 IB/rdmavt: Add QP iterator API for QPs
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
There are currently 3 spots in the qib and hfi1 driver that have knowledge of the internal QP hash list that should only be in scope to rdmavt QP code.
Add an iterator API for processing all QPs to hide the nature of the RCU hashlist.
The API consists of:
- rvt_qp_iter_init()
* For iterating QPs one at a time for seq_file semantics
- rvt_qp_iter_next()
* For iterating QPs one at a time for seq_file semantics
- rvt_qp_iter()
* For iterating all QPs
The first two are used for things like seq_file prints.
The last is for code that just needs to iterate all QPs in the system.
--- drivers/infiniband/sw/rdmavt/qp.c | 144 +++++++++++++++++++++++++++++++++++++ include/rdma/rdmavt_qp.h | 29 +++++++ 2 files changed, 173 insertions(+), 0 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +144 -0
@@ -2069,3 +2069,147 @@ enum hrtimer_restart rvt_rc_rnr_retry(struct hrtimer *t)return HRTIMER_NORESTART ; }EXPORT_SYMBOL (rvt_rc_rnr_retry); + +/** +* rvt_qp_iter_init - initial for QP iteration +* @rdi - rvt devinfo +* @v - u64 value +* +* This returns an iterator suitable for iterating QPs +* in the system. +* +* The @cb is a user defined callback and @v is a 64 +* bit value passed to and relevant for processing in the +* @cb. An example use case would be to alter QP processing +* based on criteria not part of the rvt_qp. +* +* Use cases that require memory allocation to succeed +* must preallocate appropriately. +* +* Return: a pointer to an rvt_qp_iter or NULL +*/ +struct rvt_qp_iter *rvt_qp_iter_init (struct rvt_dev_info *rdi, +u64 v, +void (*cb)(struct rvt_qp *qp,u64 v)) +{ +struct rvt_qp_iter *i; + + i =kzalloc (sizeof (*i),GFP_KERNEL ); +if (!i) +return NULL ; + + i->rdi = rdi; +/* number of special QPs (SMI/GSI) for device */ + i->specials = rdi->ibdev.phys_port_cnt *2 ; + i->v = v; + i->cb = cb; + +return i; +} +EXPORT_SYMBOL (rvt_qp_iter_init); + +/** +* rvt_qp_iter_next - return the next QP in iter +* @iter - the iterator +* +* Fine grained QP iterator suitable for use +* with debugfs seq_file mechanisms. +* +* Updates iter->qp with the current QP when the return +* value is 0. +* +* Return: 0 - iter->qp is valid 1 - no more QPs +*/ +int rvt_qp_iter_next (struct rvt_qp_iter *iter) +__must_hold (RCU ) +{ +int n = iter->n; +int ret =1 ; +struct rvt_qp *pqp = iter->qp; +struct rvt_qp *qp; +struct rvt_dev_info *rdi = iter->rdi; + +/* +* The approach is to consider the special qps +* as additional table entries before the +* real hash table. Since the qp code sets +* the qp->next hash link to NULL, this works just fine. +* +* iter->specials is 2 * # ports +* +* n = 0..iter->specials is the special qp indices +* +* n = iter->specials..rdi->qp_dev->qp_table_size+iter->specials are +* the potential hash bucket entries +* +*/ +for (; n < rdi->qp_dev->qp_table_size + iter->specials; n++) { +if (pqp) { + qp =rcu_dereference (pqp->next); + }else { +if (n < iter->specials) { +struct rvt_ibport *rvp; +int pidx; + + pidx = n % rdi->ibdev.phys_port_cnt; + rvp = rdi->ports[pidx]; + qp =rcu_dereference (rvp->qp[n &1 ]); + }else { + qp =rcu_dereference ( + rdi->qp_dev->qp_table[ + (n - iter->specials)]); + } + } + pqp = qp; +if (qp) { + iter->qp = qp; + iter->n = n; +return 0 ; + } + } +return ret; +} +EXPORT_SYMBOL (rvt_qp_iter_next); + +/** +* rvt_qp_iter - iterate all QPs +* @rdi - rvt devinfo +* @v - a 64 bit value +* @cb - a callback +* +* This provides a way for iterating all QPs. +* +* The @cb is a user defined callback and @v is a 64 +* bit value passed to and relevant for processing in the +* cb. An example use case would be to alter QP processing +* based on criteria not part of the rvt_qp. +* +* The code has an internal iterator to simplify +* non seq_file use cases. +*/ +void rvt_qp_iter (struct rvt_dev_info *rdi, +u64 v, +void (*cb)(struct rvt_qp *qp,u64 v)) +{ +int ret; +struct rvt_qp_iter i = { + .rdi = rdi, + .specials = rdi->ibdev.phys_port_cnt *2 , + .v = v, + .cb = cb + }; + +rcu_read_lock (); +do { + ret =rvt_qp_iter_next (&i); +if (!ret) { +rvt_get_qp (i.qp); +rcu_read_unlock (); + i.cb (i.qp, i.v); +rcu_read_lock (); +rvt_put_qp (i.qp); + } + }while (!ret); +rcu_read_unlock (); +} +EXPORT_SYMBOL (rvt_qp_iter);
include/rdma/rdmavt_qp.h +29 -0
@@ -673,4 +673,33 @@ static inline unsigned long rvt_timeout_to_jiffies(u8 timeout)void rvt_stop_rc_timers (struct rvt_qp *qp);void rvt_add_retry_timer (struct rvt_qp *qp); +/** +* struct rvt_qp_iter - the iterator for QPs +* @qp - the current QP +* +* This structure defines the current iterator +* state for sequenced access to all QPs relative +* to an rvt_dev_info. +*/ +struct rvt_qp_iter { +struct rvt_qp *qp; +/* private: backpointer */ +struct rvt_dev_info *rdi; +/* private: callback routine */ +void (*cb)(struct rvt_qp *qp,u64 v); +/* private: for arg to callback routine */ +u64 v; +/* private: number of SMI,GSI QPs for device */ +int specials; +/* private: current iterator index */ +int n; +}; + +struct rvt_qp_iter *rvt_qp_iter_init (struct rvt_dev_info *rdi, +u64 v, +void (*cb)(struct rvt_qp *qp,u64 v)); +int rvt_qp_iter_next (struct rvt_qp_iter *iter); +void rvt_qp_iter (struct rvt_dev_info *rdi, +u64 v, +void (*cb)(struct rvt_qp *qp,u64 v));#endif /* DEF_RDMAVT_INCQP_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/9 IB/hfi1: Convert hfi1_error_port_qps() to use new QP iterator
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Change hfi1_error_port_qps() to use the new rvt_qp_iter() in its QP scanning.
--- drivers/infiniband/hw/hfi1/qp.c | 79 ++++++++++++++++++++------------------- 1 files changed, 41 insertions(+), 38 deletions(-)
drivers/infiniband/hw/hfi1/qp.c +41 -38
@@ -1,5 +1,5 @@/* -* Copyright(c) 2015, 2016 Intel Corporation. +* Copyright(c) 2015 - 2017 Intel Corporation. * * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license.
@@ -870,6 +870,45 @@ void notify_error_qp(struct rvt_qp *qp) }/** +* hfi1_qp_iter_cb - callback for iterator +* @qp - the qp +* @v - the sl in low bits of v +* +* This is called from the iterator callback to work +* on an individual qp. +*/ +static void hfi1_qp_iter_cb (struct rvt_qp *qp,u64 v) +{ +int lastwqe; +struct ib_event ev; +struct hfi1_ibport *ibp = +to_iport (qp->ibqp.device, qp->port_num); +struct hfi1_pportdata *ppd =ppd_from_ibp (ibp); +u8 sl = (u8 )v; + +if (qp->port_num != ppd->port || + (qp->ibqp.qp_type !=IB_QPT_UC && + qp->ibqp.qp_type !=IB_QPT_RC ) || +rdma_ah_get_sl (&qp->remote_ah_attr) != sl || + !(ib_rvt_state_ops[qp->state] &RVT_POST_SEND_OK )) +return ; + +spin_lock_irq (&qp->r_lock); +spin_lock (&qp->s_hlock); +spin_lock (&qp->s_lock); + lastwqe =rvt_error_qp (qp,IB_WC_WR_FLUSH_ERR ); +spin_unlock (&qp->s_lock); +spin_unlock (&qp->s_hlock); +spin_unlock_irq (&qp->r_lock); +if (lastwqe) { + ev.device = qp->ibqp.device; + ev.element.qp = &qp->ibqp; + ev.event =IB_EVENT_QP_LAST_WQE_REACHED ; + qp->ibqp.event_handler (&ev, qp->ibqp.qp_context); + } +} + +/** * hfi1_error_port_qps - put a port's RC/UC qps into error state * @ibp: the ibport. * @sl: the service level.
@@ -880,44 +919,8 @@ void notify_error_qp(struct rvt_qp *qp)*/ void hfi1_error_port_qps (struct hfi1_ibport *ibp,u8 sl) { -struct rvt_qp *qp =NULL ;struct hfi1_pportdata *ppd =ppd_from_ibp (ibp);struct hfi1_ibdev *dev = &ppd->dd->verbs_dev; -int n; -int lastwqe; -struct ib_event ev; - -rcu_read_lock (); - -/* Deal only with RC/UC qps that use the given SL. */ -for (n =0 ; n < dev->rdi.qp_dev->qp_table_size; n++) { -for (qp =rcu_dereference (dev->rdi.qp_dev->qp_table[n]); qp; - qp =rcu_dereference (qp->next)) { -if (qp->port_num == ppd->port && - (qp->ibqp.qp_type ==IB_QPT_UC || - qp->ibqp.qp_type ==IB_QPT_RC ) && -rdma_ah_get_sl (&qp->remote_ah_attr) == sl && - (ib_rvt_state_ops[qp->state] & -RVT_POST_SEND_OK )) { -spin_lock_irq (&qp->r_lock); -spin_lock (&qp->s_hlock); -spin_lock (&qp->s_lock); - lastwqe =rvt_error_qp (qp, -IB_WC_WR_FLUSH_ERR ); -spin_unlock (&qp->s_lock); -spin_unlock (&qp->s_hlock); -spin_unlock_irq (&qp->r_lock); -if (lastwqe) { - ev.device = qp->ibqp.device; - ev.element.qp = &qp->ibqp; - ev.event = -IB_EVENT_QP_LAST_WQE_REACHED ; - qp->ibqp.event_handler (&ev, - qp->ibqp.qp_context); - } - } - } - } -rcu_read_unlock (); +rvt_qp_iter (&dev->rdi, sl, hfi1_qp_iter_cb); }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/9 IB/hfi1: Convert qp_stats debugfs interface to use new iterator API
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Continue moving copy/paste code into rdmavt.
--- drivers/infiniband/hw/hfi1/debugfs.c | 15 ++---- drivers/infiniband/hw/hfi1/qp.c | 83 ++-------------------------------- drivers/infiniband/hw/hfi1/qp.h | 23 +-------- 3 files changed, 14 insertions(+), 107 deletions(-)
drivers/infiniband/hw/hfi1/debugfs.c +6 -9
@@ -1,4 +1,3 @@ -#ifdef CONFIG_DEBUG_FS /* * Copyright(c) 2015-2017 Intel Corporation. *
@@ -267,10 +266,10 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v)static void *_qp_stats_seq_start (struct seq_file *s,loff_t *pos)__acquires (RCU ) { -struct qp_iter *iter; +struct rvt_qp_iter *iter;loff_t n = *pos; - iter =qp_iter_init (s->private); + iter =rvt_qp_iter_init (s->private,0 ,NULL );/* stop calls rcu_read_unlock */ rcu_read_lock ();
@@ -279,7 +278,7 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v)return NULL ; do { - if (qp_iter_next(iter)) { + if (rvt_qp_iter_next(iter)) { kfree(iter); return NULL; }
@@ -292,11 +291,11 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v) loff_t *pos)__must_hold (RCU ) { -struct qp_iter *iter = iter_ptr; +struct rvt_qp_iter *iter = iter_ptr; (*pos)++; -if (qp_iter_next (iter)) { +if (rvt_qp_iter_next (iter)) {kfree (iter);return NULL ; }
@@ -312,7 +311,7 @@ static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr)static int _qp_stats_seq_show (struct seq_file *s,void *iter_ptr) { -struct qp_iter *iter = iter_ptr; +struct rvt_qp_iter *iter = iter_ptr;if (!iter)return 0 ;
@@ -1535,5 +1534,3 @@ void hfi1_dbg_exit(void)debugfs_remove_recursive (hfi1_dbg_root); hfi1_dbg_root =NULL ; } - -#endif
drivers/infiniband/hw/hfi1/qp.c +6 -77
95 lines not on this page · raw message
drivers/infiniband/hw/hfi1/qp.h +2 -21
@@ -1,7 +1,7 @@#ifndef _QP_H#define _QP_H/* -* Copyright(c) 2015, 2016 Intel Corporation. +* Copyright(c) 2015 - 2017 Intel Corporation. * * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license.
@@ -94,26 +94,7 @@ struct ib_qp *hfi1_create_qp(struct ib_pd *ibpd,struct sdma_engine *qp_to_sdma_engine (struct rvt_qp *qp,u8 sc5);struct send_context *qp_to_send_context (struct rvt_qp *qp,u8 sc5); -struct qp_iter ; - -/** -* qp_iter_init - initialize the iterator for the qp hash list -* @dev: the hfi1_ibdev -*/ -struct qp_iter *qp_iter_init (struct hfi1_ibdev *dev); - -/** -* qp_iter_next - Find the next qp in the hash list -* @iter: the iterator for the qp hash list -*/ -int qp_iter_next (struct qp_iter *iter); - -/** -* qp_iter_print - print the qp information to seq_file -* @s: the seq_file to emit the qp information on -* @iter: the iterator for the qp hash list -*/ -void qp_iter_print (struct seq_file *s,struct qp_iter *iter); +void qp_iter_print (struct seq_file *s,struct rvt_qp_iter *iter);void _hfi1_schedule_send (struct rvt_qp *qp);void hfi1_schedule_send (struct rvt_qp *qp);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/9 IB/qib: Convert qp_stats debugfs interface to use new iterator API
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
Continue porting copy/paste code into rdmavt from qib.
--- drivers/infiniband/hw/qib/qib_debugfs.c | 18 ++++------- drivers/infiniband/hw/qib/qib_qp.c | 51 ++++--------------------------- drivers/infiniband/hw/qib/qib_verbs.h | 10 +----- 3 files changed, 16 insertions(+), 63 deletions(-)
drivers/infiniband/hw/qib/qib_debugfs.c +7 -11
@@ -1,6 +1,5 @@ -#ifdef CONFIG_DEBUG_FS /* -* Copyright (c) 2013 Intel Corporation. All rights reserved. +* Copyright (c) 2013 - 2017 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU
@@ -191,10 +190,10 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v)static void *_qp_stats_seq_start (struct seq_file *s,loff_t *pos)__acquires (RCU ) { -struct qib_qp_iter *iter; +struct rvt_qp_iter *iter;loff_t n = *pos; - iter =qib_qp_iter_init (s->private); + iter =rvt_qp_iter_init (s->private,0 ,NULL );/* stop calls rcu_read_unlock */ rcu_read_lock ();
@@ -203,7 +202,7 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v)return NULL ; do { - if (qib_qp_iter_next(iter)) { + if (rvt_qp_iter_next(iter)) { kfree(iter); return NULL; }
@@ -216,11 +215,11 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v) loff_t *pos)__must_hold (RCU ) { -struct qib_qp_iter *iter = iter_ptr; +struct rvt_qp_iter *iter = iter_ptr; (*pos)++; -if (qib_qp_iter_next (iter)) { +if (rvt_qp_iter_next (iter)) {kfree (iter);return NULL ; }
@@ -236,7 +235,7 @@ static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr)static int _qp_stats_seq_show (struct seq_file *s,void *iter_ptr) { -struct qib_qp_iter *iter = iter_ptr; +struct rvt_qp_iter *iter = iter_ptr;if (!iter)return 0 ;
@@ -284,6 +283,3 @@ void qib_dbg_exit(void)debugfs_remove_recursive (qib_dbg_root); qib_dbg_root =NULL ; } - -#endif -
drivers/infiniband/hw/qib/qib_qp.c +7 -44
65 lines not on this page · raw message
drivers/infiniband/hw/qib/qib_verbs.h +2 -8
@@ -1,5 +1,5 @@/* -* Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. +* Copyright (c) 2012 - 2017 Intel Corporation. All rights reserved. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. *
@@ -282,13 +282,7 @@ int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,void qib_restart_rc (struct rvt_qp *qp,u32 psn,int wait);#ifdef CONFIG_DEBUG_FS -struct qib_qp_iter ; - -struct qib_qp_iter *qib_qp_iter_init (struct qib_ibdev *dev); - -int qib_qp_iter_next (struct qib_qp_iter *iter); - -void qib_qp_iter_print (struct seq_file *s,struct qib_qp_iter *iter); +void qib_qp_iter_print (struct seq_file *s,struct rvt_qp_iter *iter);#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/9 IB/rdmavt: Handle dereg of inuse MRs properly
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
A destroy of an MR prior to destroying the QP can cause the following diagnostic if the QP is referencing the MR being de-registered:
hfi1 0000:05:00.0: hfi1_0: rvt_dereg_mr timeout mr ffff8808562108
00 pd ffff880859b20b00
The solution is to when the a non-zero refcount is encountered when the MR is destroyed the QPs needs to be iterated looking for QPs in the same PD as the MR. If rvt_qp_mr_clean() detects any such QP references the rkey/lkey, the QP needs to be put into an error state via a call to rvt_qp_error() which will trigger the clean up of any stuck references.
This solution is as specified in IBTA 1.3 Volume 1 11.2.10.5.
[This is reproduced with the 0.4.9 version of qperf and the rc_bw test]
--- drivers/infiniband/sw/rdmavt/mr.c | 121 ++++++++++++++++++++++++++++++++----- drivers/infiniband/sw/rdmavt/qp.c | 112 +++++++++++++++++++++++++++++++++- include/rdma/rdmavt_mr.h | 3 + include/rdma/rdmavt_qp.h | 1 4 files changed, 216 insertions(+), 21 deletions(-)
drivers/infiniband/sw/rdmavt/mr.c +104 -17
@@ -441,6 +441,105 @@ struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, }/** +* rvt_dereg_clean_qp_cb - callback from iterator +* @qp - the qp +* @v - the mregion (as u64) +* +* This routine fields the callback for all QPs and +* for QPs in the same PD as the MR will call the +* rvt_qp_mr_clean() to potentially cleanup references. +*/ +static void rvt_dereg_clean_qp_cb (struct rvt_qp *qp,u64 v) +{ +struct rvt_mregion *mr = (struct rvt_mregion *)v; + +/* skip PDs that are not ours */ +if (mr->pd != qp->ibqp.pd) +return ; +rvt_qp_mr_clean (qp, mr->lkey); +} + +/** +* rvt_dereg_clean_qps - find QPs for reference cleanup +* @mr - the MR that is being deregistered +* +* This routine iterates RC QPs looking for references +* to the lkey noted in mr. +*/ +static void rvt_dereg_clean_qps (struct rvt_mregion *mr) +{ +struct rvt_dev_info *rdi =ib_to_rvt (mr->pd->device); + +rvt_qp_iter (rdi, (u64 )mr, rvt_dereg_clean_qp_cb); +} + +/** +* rvt_check_refs - check references +* @mr - the megion +* @t - the caller identification +* +* This routine checks MRs holding a reference during +* when being de-registered. +* +* If the count is non-zero, the code calls a clean routine then +* waits for the timeout for the count to zero. +*/ +static int rvt_check_refs (struct rvt_mregion *mr,const char *t) +{ +unsigned long timeout; +struct rvt_dev_info *rdi =ib_to_rvt (mr->pd->device); + +if (percpu_ref_is_zero (&mr->refcount)) +return 0 ; +/* avoid dma mr */ +if (mr->lkey) +rvt_dereg_clean_qps (mr); + timeout =wait_for_completion_timeout (&mr->comp,5 *HZ ); +if (!timeout) { +rvt_pr_err (rdi, +"%s timeout mr %p pd %p lkey %x refcount %ld\n" , + t, mr, mr->pd, mr->lkey, +atomic_long_read (&mr->refcount.count)); +rvt_get_mr (mr); +return -EBUSY ; + } +return 0 ; +} + +/** +* rvt_mr_has_lkey - is MR +* @mr - the mregion +* @lkey - the lkey +*/ +bool rvt_mr_has_lkey (struct rvt_mregion *mr,u32 lkey) +{ +return mr && lkey == mr->lkey; +} + +/** +* rvt_ss_has_lkey - is mr in sge tests +* @ss - the sge state +* @lkey +* +* This code tests for an MR in the indicated +* sge state. +*/ +bool rvt_ss_has_lkey (struct rvt_sge_state *ss,u32 lkey) +{ +int i; +bool rval = false; + +if (!ss->num_sge) +return rval; +/* first one */ + rval =rvt_mr_has_lkey (ss->sge.mr, lkey); +/* any others */ +for (i =0 ; !rval && i < ss->num_sge -1 ; i++) + rval =rvt_mr_has_lkey (ss->sg_list[i].mr, lkey); +return rval; +} + +/** * rvt_dereg_mr - unregister and free a memory region * @ibmr: the memory region to free *
@@ -453,22 +552,14 @@ struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,int rvt_dereg_mr (struct ib_mr *ibmr) {struct rvt_mr *mr =to_imr (ibmr); -struct rvt_dev_info *rdi =ib_to_rvt (ibmr->pd->device); -int ret =0 ; -unsigned long timeout; +int ret;rvt_free_lkey (&mr->mr);rvt_put_mr (&mr->mr);/* will set completion if last */ - timeout =wait_for_completion_timeout (&mr->mr.comp,5 *HZ ); -if (!timeout) { -rvt_pr_err (rdi, -"rvt_dereg_mr timeout mr %p pd %p\n" , - mr, mr->mr.pd); -rvt_get_mr (&mr->mr); - ret = -EBUSY ; + ret =rvt_check_refs (&mr->mr, __func__); +if (ret) goto out; - }rvt_deinit_mregion (&mr->mr);if (mr->umem)ib_umem_release (mr->umem);
@@ -761,16 +852,12 @@ int rvt_dealloc_fmr(struct ib_fmr *ibfmr) {struct rvt_fmr *fmr =to_ifmr (ibfmr);int ret =0 ; -unsigned long timeout;rvt_free_lkey (&fmr->mr);rvt_put_mr (&fmr->mr);/* will set completion if last */ - timeout =wait_for_completion_timeout (&fmr->mr.comp,5 *HZ ); -if (!timeout) { -rvt_get_mr (&fmr->mr); - ret = -EBUSY ; + ret =rvt_check_refs (&fmr->mr, __func__); +if (ret) goto out; - }rvt_deinit_mregion (&fmr->mr);kfree (fmr); out:
drivers/infiniband/sw/rdmavt/qp.c +108 -4
124 lines not on this page · raw message
include/rdma/rdmavt_mr.h +3 -0
@@ -191,4 +191,7 @@ static inline void rvt_skip_sge(struct rvt_sge_state *ss, u32 length, } } +bool rvt_ss_has_lkey (struct rvt_sge_state *ss,u32 lkey); +bool rvt_mr_has_lkey (struct rvt_mregion *mr,u32 lkey); +#endif /* DEF_RDMAVT_INCMRH */
include/rdma/rdmavt_qp.h +1 -0
@@ -702,4 +702,5 @@ struct rvt_qp_iter *rvt_qp_iter_init(struct rvt_dev_info *rdi,void rvt_qp_iter (struct rvt_dev_info *rdi,u64 v,void (*cb)(struct rvt_qp *qp,u64 v)); +void rvt_qp_mr_clean (struct rvt_qp *qp,u32 lkey);#endif /* DEF_RDMAVT_INCQP_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Dennis Dalessandro
Hi Doug,
Here is the next round of patches for our drivers. There are a few patches from
Mike that adds a qp iterator and starts the work of cleaning up some of our code
that needs to walk qps. The rest are minor bug fixes.Patches can can also be found in my GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.14
Thanks, series applied.
Signature · 8 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html