IB/hfi1: patches for next 07/24/2017
Subsystems (2)
cover IB/hfi1: patches for next 07/24/2017
Hi Doug,
Here is a set of patches for 4.14. These apply on top of the others I have sent previously. This fixes some performance centric bugs like using write combining for bar0 mapping and a fix for not starving an iowait list. There are also a few patches related to improving the code involving user contexts. A bug to fix sending MAD traps until repressed is also included as well as some general code cleanups.
Patches can can also be found in my GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.14
---
Alex Estrin (1):
IB/hfi1: Verify port data VLs credits on transition to Armed
Bartlomiej Dudek (1):
IB/hfi1: Move saving PCI values to a separate function
Byczkowski, Jakub (1):
IB/hfi1: Fix initialization failure for debug firmware
Jan Sokolowski (1):
IB/hfi1: Fix code consistency for if/else blocks in chip.c
Kaike Wan (1):
IB/hfi1: Serve the most starved iowait entry first
Michael J. Ruhl (7):
IB/hfi1: Assign context does not clean up file descriptor correctly on error IB/hfi1: Remove unused user context data members
IB/hfi1: Size rcd array index correctly and consistently IB/hfi1: Use context pointer rather than context index
IB/hfi1: Pass the context pointer rather than the index IB/hfi1: Send MAD traps until repressed
IB/hfi1: Split copy_to_user data copy for better security
Mike Marciniszyn (1):
IB/hfi1: Fix bar0 mapping to use write combining
drivers/infiniband/hw/hfi1/aspm.h | 6 drivers/infiniband/hw/hfi1/chip.c | 227 +++++++++++------- drivers/infiniband/hw/hfi1/chip.h | 15 + drivers/infiniband/hw/hfi1/driver.c | 19 + drivers/infiniband/hw/hfi1/exp_rcv.h | 5 drivers/infiniband/hw/hfi1/file_ops.c | 76 +++--- drivers/infiniband/hw/hfi1/firmware.c | 8 + drivers/infiniband/hw/hfi1/hfi.h | 49 +--- drivers/infiniband/hw/hfi1/init.c | 23 +- drivers/infiniband/hw/hfi1/intr.c | 3 drivers/infiniband/hw/hfi1/iowait.h | 70 +++++ drivers/infiniband/hw/hfi1/mad.c | 373 ++++++++++++++++++++++------- drivers/infiniband/hw/hfi1/mad.h | 3 drivers/infiniband/hw/hfi1/pcie.c | 164 ++++++++----- drivers/infiniband/hw/hfi1/pio.c | 13 + drivers/infiniband/hw/hfi1/qp.c | 9 - drivers/infiniband/hw/hfi1/ruc.c | 5 drivers/infiniband/hw/hfi1/sdma.c | 34 ++- drivers/infiniband/hw/hfi1/sdma.h | 3 drivers/infiniband/hw/hfi1/trace_rx.h | 2 drivers/infiniband/hw/hfi1/user_exp_rcv.c | 3 drivers/infiniband/hw/hfi1/user_sdma.c | 19 - drivers/infiniband/hw/hfi1/user_sdma.h | 3 drivers/infiniband/hw/hfi1/verbs.c | 11 + drivers/infiniband/hw/hfi1/verbs.h | 1 drivers/infiniband/hw/hfi1/vnic.h | 1 drivers/infiniband/hw/hfi1/vnic_main.c | 6 drivers/infiniband/hw/hfi1/vnic_sdma.c | 14 + include/rdma/rdma_vt.h | 17 + 29 files changed, 795 insertions(+), 387 deletions(-)
--
-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
A message that is not in the archive (sent off-list or not yet received): 20170724144415.10034.26787.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org
PATCH 1/13 IB/hfi1: Fix bar0 mapping to use write combining
From: Mike Marciniszyn <[email protected]>
When the debugpat kernel boot flag is turned on the following traces are printed:
[ 1884.793168] x86/PAT: Overlap at 0x90000000-0x92000000 [ 1884.803510] x86/PAT: reserve_memtype added [mem 0x91200000-0x9127ffff], track uncached-minus, req write-combining, ret uncached-minus [ 1884.818167] hfi1 0000:05:00.0: hfi1_0: WC Remapped RcvArray:
ffffc9000a980000
The ioremap_wc() clearly is not returning a write combining mapping due to an overlap where the RcvArray is mapped in a uncached mapping prior to creating the proposed write combining mapping.
The patch replaces the single base register for uncached CSRs that
used to overlap the RcvArray with two mappings. One, kregbase1, from the
bar0 up to the RcvArray and another, kregbase2, from the end of the RcvArray to the pio send buffer space. A new dd field, base2_start, is used to convert the zero-based offset in the CSR routines to the correct kregbase1/kregbase2 mapping. A single direct write of the RcvArray CSRs is replaced with hfi1_put_tid() to insure correct access using the new disjoint mapping.
Additionally, the kregend field is deleted since it is only ever written.
patdebug now shows the RcvArray as write combining:
[ 35.688990] x86/PAT: reserve_memtype added [mem 0x91200000-0x9127ffff],
track write-combining, req write-combining, ret write-combining
To insulate from any potential issues with write combining, all writeq are now flushed in hfi1_put_tid() and rcv_array_wc_fill().
--- drivers/infiniband/hw/hfi1/chip.c | 79 +++++++++++++++++++++++------ drivers/infiniband/hw/hfi1/chip.h | 4 + drivers/infiniband/hw/hfi1/driver.c | 4 + drivers/infiniband/hw/hfi1/exp_rcv.h | 5 +- drivers/infiniband/hw/hfi1/file_ops.c | 2 - drivers/infiniband/hw/hfi1/hfi.h | 20 ++++--- drivers/infiniband/hw/hfi1/pcie.c | 58 +++++++++++++++------ drivers/infiniband/hw/hfi1/user_exp_rcv.c | 3 - 8 files changed, 126 insertions(+), 49 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +62 -17
@@ -1297,25 +1297,71 @@ struct cntr_entry { CNTR_SYNTH, \ access_ibp_##cntr) +/** +* hfi_addr_from_offset - return addr for readq/writeq +* @dd - the dd device +* @offset - the offset of the CSR within bar0 +* +* This routine selects the appropriate base address +* based on the indicated offset. +*/ +static inline void __iomem *hfi1_addr_from_offset ( +const struct hfi1_devdata *dd, +u32 offset) +{ +if (offset >= dd->base2_start) +return dd->kregbase2 + (offset - dd->base2_start); +return dd->kregbase1 + offset; +} + +/** +* read_csr - read CSR at the indicated offset +* @dd - the dd device +* @offset - the offset of the CSR within bar0 +* +* Return: the value read or all FF's if there +* is no mapping +*/ u64 read_csr (const struct hfi1_devdata *dd,u32 offset) { -if (dd->flags &HFI1_PRESENT ) { -return readq ((void __iomem *)dd->kregbase + offset); - } +if (dd->flags &HFI1_PRESENT ) +return readq (hfi1_addr_from_offset (dd, offset));return -1 ; } +/** +* write_csr - write CSR at the indicated offset +* @dd - the dd device +* @offset - the offset of the CSR within bar0 +* @value - value to write +*/ void write_csr (const struct hfi1_devdata *dd,u32 offset,u64 value) { -if (dd->flags &HFI1_PRESENT ) -writeq (value, (void __iomem *)dd->kregbase + offset); +if (dd->flags &HFI1_PRESENT ) { +void __iomem *base =hfi1_addr_from_offset (dd, offset); + +/* avoid write to RcvArray */ +if (WARN_ON (offset >=RCV_ARRAY && offset < dd->base2_start)) +return ; +writeq (value, base); + } } +/** +* get_csr_addr - return te iomem address for offset +* @dd - the dd device +* @offset - the offset of the CSR within bar0 +* +* Return: The iomem address to use in subsequent +* writeq/readq operations. +*/ void __iomem *get_csr_addr ( -struct hfi1_devdata *dd, +const struct hfi1_devdata *dd,u32 offset) { -return (void __iomem *)dd->kregbase + offset; +if (dd->flags &HFI1_PRESENT ) +return hfi1_addr_from_offset (dd, offset); +return NULL ; } static inline u64 read_write_csr(const struct hfi1_devdata *dd, u32 csr,
@@ -9752,14 +9798,13 @@ void hfi1_put_tid(struct hfi1_devdata *dd, u32 index, u32 type, unsigned long pa, u16 order) { u64 reg; -void __iomem *base = (dd->rcvarray_wc ? dd->rcvarray_wc : - (dd->kregbase +RCV_ARRAY ));if (!(dd->flags &HFI1_PRESENT )) goto done; -if (type ==PT_INVALID ) { +if (type ==PT_INVALID || type ==PT_INVALID_FLUSH ) { pa =0 ; + order =0 ; }else if (type >PT_INVALID ) { dd_dev_err(dd, "unexpected receive array type %u for index %u, not handled\n",
@@ -9773,13 +9818,14 @@ void hfi1_put_tid(struct hfi1_devdata *dd, u32 index, | (u64)order << RCV_ARRAY_RT_BUF_SIZE_SHIFT | ((pa >>RT_ADDR_SHIFT ) &RCV_ARRAY_RT_ADDR_MASK ) <<RCV_ARRAY_RT_ADDR_SHIFT ; -trace_hfi1_write_rcvarray (base + (index *8 ), reg); -writeq (reg, base + (index *8 )); +trace_hfi1_write_rcvarray (dd->rcvarray_wc + (index *8 ), reg); +writeq (reg, dd->rcvarray_wc + (index *8 )); -if (type ==PT_EAGER ) +if (type ==PT_EAGER || type ==PT_INVALID_FLUSH || (index &3 ) ==3 )/* -* Eager entries are written one-by-one so we have to push them -* after we write the entry. +* Eager entries are written and flushed +* +* Expected entries are flushed every 4 writes */ flush_wc (); done:
@@ -13411,8 +13457,7 @@ static void write_uninitialized_csrs_and_memories(struct hfi1_devdata *dd)/* RcvArray */ for (i =0 ; i < dd->chip_rcv_array_count; i++) -write_csr (dd,RCV_ARRAY + (8 * i), -RCV_ARRAY_RT_WRITE_ENABLE_SMASK ); +hfi1_put_tid (dd, i,PT_INVALID_FLUSH ,0 ,0 );/* RcvQPMapTable */ for (i =0 ; i <32 ; i++)
drivers/infiniband/hw/hfi1/chip.h +2 -2
@@ -605,11 +605,11 @@ static inline void write_kctxt_csr(struct hfi1_devdata *dd, int ctxt,int write_lcb_csr (struct hfi1_devdata *dd,u32 offset,u64 data);void __iomem *get_csr_addr ( -struct hfi1_devdata *dd, +const struct hfi1_devdata *dd,u32 offset);static inline void __iomem *get_kctxt_csr_addr ( -struct hfi1_devdata *dd, +const struct hfi1_devdata *dd,int ctxt,u32 offset0) {
drivers/infiniband/hw/hfi1/driver.c +2 -2
@@ -196,7 +196,7 @@ int hfi1_count_active_units(void)spin_lock_irqsave (&hfi1_devs_lock, flags);list_for_each_entry (dd, &hfi1_dev_list, list) { -if (!(dd->flags &HFI1_PRESENT ) || !dd->kregbase) +if (!(dd->flags &HFI1_PRESENT ) || !dd->kregbase1)continue ;for (pidx =0 ; pidx < dd->num_pports; ++pidx) { ppd = dd->pport + pidx;
@@ -1283,7 +1283,7 @@ int hfi1_reset_device(int unit)dd_dev_info (dd,"Reset on unit %u requested\n" , unit); -if (!dd->kregbase || !(dd->flags &HFI1_PRESENT )) { +if (!dd->kregbase1 || !(dd->flags &HFI1_PRESENT )) {dd_dev_info (dd,"Invalid unit number %u or not initialized or not present\n" , unit);
drivers/infiniband/hw/hfi1/exp_rcv.h +4 -1
@@ -137,8 +137,11 @@ static inline void rcv_array_wc_fill(struct hfi1_devdata *dd, u32 index)* Doing the WC fill writes only makes sense if the device is * present and the RcvArray has been mapped as WC memory. */ -if ((dd->flags &HFI1_PRESENT ) && dd->rcvarray_wc) +if ((dd->flags &HFI1_PRESENT ) && dd->rcvarray_wc) {writeq (0 , dd->rcvarray_wc + (index *8 )); +if ((index &3 ) ==3 ) +flush_wc (); + } } static inline void tid_group_add_tail(struct tid_group *grp,
drivers/infiniband/hw/hfi1/file_ops.c +1 -1
@@ -181,7 +181,7 @@ static int hfi1_file_open(struct inode *inode, struct file *fp) struct hfi1_devdata, user_cdev); -if (!((dd->flags &HFI1_PRESENT ) && dd->kregbase)) +if (!((dd->flags &HFI1_PRESENT ) && dd->kregbase1))return -EINVAL ;if (!atomic_inc_not_zero (&dd->user_refcount))
drivers/infiniband/hw/hfi1/hfi.h +12 -8
@@ -867,12 +867,15 @@ struct hfi1_devdata {struct device *diag_device;struct device *ui_device; -/* mem-mapped pointer to base of chip regs */ -u8 __iomem *kregbase; -/* end of mem-mapped chip space excluding sendbuf and user regs */ -u8 __iomem *kregend; -/* physical address of chip for io_remap, etc. */ +/* first mapping up to RcvArray */ +u8 __iomem *kregbase1;resource_size_t physaddr; + +/* second uncached mapping from RcvArray to pio send buffers */ +u8 __iomem *kregbase2; +/* for detecting offset above kregbase2 address */ +u32 base2_start; +/* Per VL data. Enough for all VLs but not all elements are set/used. */ struct per_vl_data vld[PER_VL_SEND_CONTEXTS ];/* send context data */
@@ -1236,9 +1239,10 @@ static inline bool hfi1_vnic_is_rsm_full(struct hfi1_devdata *dd, int spare)#define dc8051_ver_patch (a) ((a) & 0x0000ff)/* f_put_tid types */ -#define PT_EXPECTED 0 -#define PT_EAGER 1 -#define PT_INVALID 2 +#define PT_EXPECTED 0 +#define PT_EAGER 1 +#define PT_INVALID_FLUSH 2 +#define PT_INVALID 3struct tid_rb_node ;struct mmu_rb_node ;
drivers/infiniband/hw/hfi1/pcie.c +42 -16
98 lines not on this page · raw message
drivers/infiniband/hw/hfi1/user_exp_rcv.c +1 -2
@@ -814,12 +814,11 @@ static void clear_tid_node(struct hfi1_filedata *fd, struct tid_rb_node *node) node->npages, node->mmu.addr, node->phys, node->dma_addr); -hfi1_put_tid (dd, node->rcventry,PT_INVALID ,0 ,0 );/* * Make sure device has seen the write before we unpin the * pages. */ -flush_wc (); +hfi1_put_tid (dd, node->rcventry,PT_INVALID_FLUSH ,0 ,0 );pci_unmap_single (dd->pcidev, node->dma_addr, node->mmu.len,PCI_DMA_FROMDEVICE );
--
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/13 IB/hfi1: Serve the most starved iowait entry first
In reply to a message not in the archiveFrom: Kaike Wan <[email protected]>
When an egress resource(SDMA descriptors, pio credits) is not available, a sending thread will be put on the resource's wait queue. When the resource becomes available again, up to a fixed number of sending threads can be awakened sequentially and removed from the wait queue, depending on the number of waiting threads and the number of free resources. Since each awakened sending thread will send as many packets as possible, it is highly likely that the first sending thread will consume all the egress resources. Subsequently, it will be put back to the end of the wait queue. Depending on the timing when the later sending threads wake up, they may not be able to send any packet and be again put back to the end of the wait queue sequentially, right behind the first sending thread. This starvation cycle continues until some sending threads exceed their retry limit and consequently fail.
This patch fixes the issue by two simple approaches:
(1) Any starved sending thread will be put to the head of the wait queue while a served sending thread will be put to the tail;
(2) The most starved sending thread will be served first.
--- drivers/infiniband/hw/hfi1/iowait.h | 70 +++++++++++++++++++++++++++++++- drivers/infiniband/hw/hfi1/pio.c | 13 +++++- drivers/infiniband/hw/hfi1/qp.c | 9 +++- drivers/infiniband/hw/hfi1/ruc.c | 5 ++ drivers/infiniband/hw/hfi1/sdma.c | 34 +++++++++++----- drivers/infiniband/hw/hfi1/sdma.h | 3 + drivers/infiniband/hw/hfi1/user_sdma.c | 8 ++-- drivers/infiniband/hw/hfi1/verbs.c | 6 ++- drivers/infiniband/hw/hfi1/verbs.h | 1 drivers/infiniband/hw/hfi1/vnic.h | 1 drivers/infiniband/hw/hfi1/vnic_sdma.c | 14 +++++- 11 files changed, 136 insertions(+), 28 deletions(-)
drivers/infiniband/hw/hfi1/iowait.h +68 -2
@@ -106,7 +106,9 @@ struct iowait {struct sdma_engine *sde, struct iowait *wait, struct sdma_txreq *tx, - unsigned seq); + uint seq, + bool pkts_sent + );void (*wakeup)(struct iowait *wait,int reason);void (*sdma_drained)(struct iowait *wait);seqlock_t *lock;
@@ -118,6 +120,7 @@ struct iowait {u32 count;u32 tx_limit;u32 tx_count; +u8 starved_cnt; };#define SDMA_AVAIL_REASON 0
@@ -143,7 +146,8 @@ static inline void iowait_init(struct sdma_engine *sde, struct iowait *wait, struct sdma_txreq *tx, - unsigned seq), + uint seq, + bool pkts_sent), void (*wakeup)(struct iowait *wait, int reason), void (*sdma_drained)(struct iowait *wait)) {
@@ -305,4 +309,66 @@ static inline void iowait_drain_wakeup(struct iowait *wait) return tx; } +/** +* iowait_queue - Put the iowait on a wait queue +* @pkts_sent: have some packets been sent before queuing? +* @w: the iowait struct +* @wait_head: the wait queue +* +* This function is called to insert an iowait struct into a +* wait queue after a resource (eg, sdma decriptor or pio +* buffer) is run out. +*/ +static inline void iowait_queue (bool pkts_sent,struct iowait *w, +struct list_head *wait_head) +{ +/* +* To play fair, insert the iowait at the tail of the wait queue if it +* has already sent some packets; Otherwise, put it at the head. +*/ +if (pkts_sent) { +list_add_tail (&w->list, wait_head); + w->starved_cnt =0 ; + }else { +list_add (&w->list, wait_head); + w->starved_cnt++; + } +} + +/** +* iowait_starve_clear - clear the wait queue's starve count +* @pkts_sent: have some packets been sent? +* @w: the iowait struct +* +* This function is called to clear the starve count. If no +* packets have been sent, the starve count will not be cleared. +*/ +static inline void iowait_starve_clear (bool pkts_sent,struct iowait *w) +{ +if (pkts_sent) + w->starved_cnt =0 ; +} + +/** +* iowait_starve_find_max - Find the maximum of the starve count +* @w: the iowait struct +* @max: a variable containing the max starve count +* @idx: the index of the current iowait in an array +* @max_idx: a variable containing the array index for the +* iowait entry that has the max starve count +* +* This function is called to compare the starve count of a +* given iowait with the given max starve count. The max starve +* count and the index will be updated if the iowait's start +* count is larger. +*/ +static inline void iowait_starve_find_max (struct iowait *w,u8 *max, +uint idx,uint *max_idx) +{ +if (w->starved_cnt > *max) { + *max = w->starved_cnt; + *max_idx = idx; + } +} +#endif
drivers/infiniband/hw/hfi1/pio.c +10 -3
@@ -1568,7 +1568,8 @@ static void sc_piobufavail(struct send_context *sc)struct rvt_qp *qp;struct hfi1_qp_priv *priv;unsigned long flags; -unsigned i, n =0 ; +uint i, n =0 , max_idx =0 ; +u8 max_starved_cnt =0 ;if (dd->send_contexts[sc->sw_index].type !=SC_KERNEL && dd->send_contexts[sc->sw_index].type !=SC_VL15 )
@@ -1591,6 +1592,7 @@ static void sc_piobufavail(struct send_context *sc) priv = qp->priv;list_del_init (&priv->s_iowait.list); priv->s_iowait.lock =NULL ; +iowait_starve_find_max (wait, &max_starved_cnt, n, &max_idx);/* refcount held until actual wake up */ qps[n++] = qp; }
@@ -1605,9 +1607,14 @@ static void sc_piobufavail(struct send_context *sc) }write_sequnlock_irqrestore (&dev->iowait_lock, flags); -for (i =0 ; i < n; i++) -hfi1_qp_wakeup (qps[i], +/* Wake up the most starved one first */ +if (n) +hfi1_qp_wakeup (qps[max_idx],RVT_S_WAIT_PIO |RVT_S_WAIT_PIO_DRAIN ); +for (i =0 ; i < n; i++) +if (i != max_idx) +hfi1_qp_wakeup (qps[i], +RVT_S_WAIT_PIO |RVT_S_WAIT_PIO_DRAIN ); }/* translate a send credit update to a bit code of reasons */
drivers/infiniband/hw/hfi1/qp.c +6 -3
@@ -68,7 +68,8 @@ static int iowait_sleep(struct sdma_engine *sde, struct iowait *wait, struct sdma_txreq *stx, - unsigned seq); + unsigned int seq, + bool pkts_sent);static void iowait_wakeup (struct iowait *wait,int reason);static void iowait_sdma_drained (struct iowait *wait);static void qp_pio_drain (struct rvt_qp *qp);
@@ -371,7 +372,8 @@ static int iowait_sleep(struct sdma_engine *sde, struct iowait *wait, struct sdma_txreq *stx, - unsigned seq) + uint seq, + bool pkts_sent) { struct verbs_txreq *tx = container_of(stx, struct verbs_txreq, txreq);struct rvt_qp *qp;
@@ -402,7 +404,8 @@ static int iowait_sleep( ibp->rvp.n_dmawait++; qp->s_flags |=RVT_S_WAIT_DMA_DESC ; -list_add_tail (&priv->s_iowait.list, &sde->dmawait); +iowait_queue (pkts_sent, &priv->s_iowait, + &sde->dmawait); priv->s_iowait.lock = &dev->iowait_lock;trace_hfi1_qpsleep (qp,RVT_S_WAIT_DMA_DESC );rvt_get_qp (qp);
drivers/infiniband/hw/hfi1/ruc.c +4 -1
@@ -811,6 +811,8 @@ void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,static bool schedule_send_yield (struct rvt_qp *qp,struct hfi1_pkt_state *ps) { + ps->pkts_sent = true; +if (unlikely (time_after (jiffies, ps->timeout))) {if (!ps->in_thread ||workqueue_congested (ps->cpu, ps->ppd->hfi1_wq)) {
@@ -907,6 +909,7 @@ void hfi1_do_send(struct rvt_qp *qp, bool in_thread) ps.timeout = jiffies + ps.timeout_int; ps.cpu = priv->s_sde ? priv->s_sde->cpu :cpumask_first (cpumask_of_node (ps.ppd->dd->node)); + ps.pkts_sent = false;/* insure a pre-built packet is handled */ ps.s_txreq =get_waiting_verbs_txreq (qp);
@@ -929,7 +932,7 @@ void hfi1_do_send(struct rvt_qp *qp, bool in_thread)spin_lock_irqsave (&qp->s_lock, ps.flags); } }while (make_req (qp, &ps)); - +iowait_starve_clear (ps.pkts_sent, &priv->s_iowait);spin_unlock_irqrestore (&qp->s_lock, ps.flags); }
drivers/infiniband/hw/hfi1/sdma.c +24 -10
@@ -246,7 +246,7 @@ static void __sdma_process_event( enum sdma_events event);static void dump_sdma_state (struct sdma_engine *sde);static void sdma_make_progress (struct sdma_engine *sde,u64 status); -static void sdma_desc_avail (struct sdma_engine *sde,unsigned avail); +static void sdma_desc_avail (struct sdma_engine *sde,uint avail);static void sdma_flush_descq (struct sdma_engine *sde);/**
@@ -1762,13 +1762,14 @@ static inline u16 sdma_gethead(struct sdma_engine *sde)* * This is called with head_lock held. */ -static void sdma_desc_avail (struct sdma_engine *sde,unsigned avail) +static void sdma_desc_avail (struct sdma_engine *sde,uint avail) {struct iowait *wait, *nw;struct iowait *waits[SDMA_WAIT_BATCH_SIZE ]; -unsigned i, n =0 , seq; +uint i, n =0 , seq, max_idx =0 ;struct sdma_txreq *stx;struct hfi1_ibdev *dev = &sde->dd->verbs_dev; +u8 max_starved_cnt =0 ;#ifdef CONFIG_SDMA_VERBOSITY dd_dev_err(sde->dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
@@ -1803,6 +1804,9 @@ static void sdma_desc_avail(struct sdma_engine *sde, unsigned avail)if (num_desc > avail)break ; avail -= num_desc; +/* Find the most starved wait memeber */ +iowait_starve_find_max (wait, &max_starved_cnt, + n, &max_idx);list_del_init (&wait->list); waits[n++] = wait; }
@@ -1811,8 +1815,13 @@ static void sdma_desc_avail(struct sdma_engine *sde, unsigned avail) } }while (read_seqretry (&dev->iowait_lock, seq)); +/* Schedule the most starved one first */ +if (n) + waits[max_idx]->wakeup (waits[max_idx],SDMA_AVAIL_REASON ); +for (i =0 ; i < n; i++) - waits[i]->wakeup (waits[i],SDMA_AVAIL_REASON ); +if (i != max_idx) + waits[i]->wakeup (waits[i],SDMA_AVAIL_REASON ); }/* head_lock must be held */
@@ -2349,7 +2358,8 @@ static inline u16 submit_tx(struct sdma_engine *sde, struct sdma_txreq *tx)static int sdma_check_progress (struct sdma_engine *sde,struct iowait *wait, -struct sdma_txreq *tx) +struct sdma_txreq *tx, +bool pkts_sent) {int ret;
@@ -2362,7 +2372,7 @@ static int sdma_check_progress( seq =raw_seqcount_begin ( (const seqcount_t *)&sde->head_lock.seqcount); - ret = wait->sleep (sde, wait, tx, seq); + ret = wait->sleep (sde, wait, tx, seq, pkts_sent);if (ret == -EAGAIN ) sde->desc_avail =sdma_descq_freecnt (sde); }else {
@@ -2376,6 +2386,7 @@ static int sdma_check_progress(* @sde: sdma engine to use * @wait: wait structure to use when full (may be NULL) * @tx: sdma_txreq to submit +* @pkts_sent: has any packet been sent yet? * * The call submits the tx into the ring. If a iowait structure is non-NULL * the packet will be queued to the list in wait.
@@ -2387,7 +2398,8 @@ static int sdma_check_progress(*/ int sdma_send_txreq (struct sdma_engine *sde,struct iowait *wait, -struct sdma_txreq *tx) +struct sdma_txreq *tx, +bool pkts_sent) {int ret =0 ;u16 tail;
@@ -2429,7 +2441,7 @@ int sdma_send_txreq(struct sdma_engine *sde, ret = -ECOMM ; goto unlock; nodesc: - ret =sdma_check_progress (sde, wait, tx); + ret =sdma_check_progress (sde, wait, tx, pkts_sent);if (ret == -EAGAIN ) { ret =0 ; goto retry;
@@ -2498,8 +2510,10 @@ int sdma_send_txlist(struct sdma_engine *sde, struct iowait *wait, } update_tail: total_count = submit_count + flush_count; -if (wait) +if (wait) {iowait_sdma_add (wait, total_count); +iowait_starve_clear (submit_count >0 , wait); + }if (tail !=INVALID_TAIL )sdma_update_tail (sde, tail);spin_unlock_irqrestore (&sde->tail_lock, flags);
@@ -2527,7 +2541,7 @@ int sdma_send_txlist(struct sdma_engine *sde, struct iowait *wait, ret = -ECOMM ; goto update_tail; nodesc: - ret =sdma_check_progress (sde, wait, tx); + ret =sdma_check_progress (sde, wait, tx, submit_count >0 );if (ret == -EAGAIN ) { ret =0 ; goto retry;
drivers/infiniband/hw/hfi1/sdma.h +2 -1
@@ -852,7 +852,8 @@ static inline int sdma_txadd_kvaddr(int sdma_send_txreq (struct sdma_engine *sde,struct iowait *wait, -struct sdma_txreq *tx); +struct sdma_txreq *tx, +bool pkts_sent); int sdma_send_txlist(struct sdma_engine *sde, struct iowait *wait, struct list_head *tx_list,
drivers/infiniband/hw/hfi1/user_sdma.c +5 -3
@@ -272,7 +272,8 @@ static int defer_packet_queue(struct sdma_engine *sde, struct iowait *wait, struct sdma_txreq *txreq, - unsigned int seq); + uint seq, + bool pkts_sent);static void activate_packet_queue (struct iowait *wait,int reason);static bool sdma_rb_filter (struct mmu_rb_node *node,unsigned long addr,unsigned long len);
@@ -294,7 +295,8 @@ static int defer_packet_queue(struct sdma_engine *sde, struct iowait *wait, struct sdma_txreq *txreq, - unsigned seq) + uint seq, + bool pkts_sent) { struct hfi1_user_sdma_pkt_q *pq = container_of(wait, struct hfi1_user_sdma_pkt_q, busy);
@@ -314,7 +316,7 @@ static int defer_packet_queue(xchg (&pq->state,SDMA_PKT_Q_DEFERRED );write_seqlock (&dev->iowait_lock);if (list_empty (&pq->busy.list)) -list_add_tail (&pq->busy.list, &sde->dmawait); +iowait_queue (pkts_sent, &pq->busy, &sde->dmawait);write_sequnlock (&dev->iowait_lock);return -EBUSY ; eagain:
drivers/infiniband/hw/hfi1/verbs.c +4 -2
@@ -864,7 +864,8 @@ int hfi1_verbs_send_dma(struct rvt_qp *qp, struct hfi1_pkt_state *ps,if (unlikely (ret)) goto bail_build; } - ret =sdma_send_txreq (tx->sde, &priv->s_iowait, &tx->txreq); + ret =sdma_send_txreq (tx->sde, &priv->s_iowait, &tx->txreq, + ps->pkts_sent);if (unlikely (ret <0 )) {if (ret == -ECOMM ) goto bail_ecomm;
@@ -921,7 +922,8 @@ static int pio_wait(struct rvt_qp *qp, dev->n_piodrain += !!(flag &RVT_S_WAIT_PIO_DRAIN ); qp->s_flags |= flag; was_empty =list_empty (&sc->piowait); -list_add_tail (&priv->s_iowait.list, &sc->piowait); +iowait_queue (ps->pkts_sent, &priv->s_iowait, + &sc->piowait); priv->s_iowait.lock = &dev->iowait_lock;trace_hfi1_qpsleep (qp,RVT_S_WAIT_PIO );rvt_get_qp (qp);
drivers/infiniband/hw/hfi1/verbs.h +1 -0
@@ -143,6 +143,7 @@ struct hfi1_pkt_state {unsigned long timeout_int;int cpu;bool in_thread; +bool pkts_sent; };#define HFI1_PSN_CREDIT 16
drivers/infiniband/hw/hfi1/vnic.h +1 -0
@@ -103,6 +103,7 @@ struct hfi1_vnic_sdma {struct sdma_txreq stx;unsigned int state;u8 q_idx; +bool pkts_sent; };/**
drivers/infiniband/hw/hfi1/vnic_sdma.c +11 -3
@@ -198,11 +198,16 @@ int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx, goto free_desc; tx->retry_count =0 ; - ret =sdma_send_txreq (sde, &vnic_sdma->wait, &tx->txreq); + ret =sdma_send_txreq (sde, &vnic_sdma->wait, &tx->txreq, + vnic_sdma->pkts_sent);/* When -ECOMM, sdma callback will be called with ABORT status */ if (unlikely (ret &&unlikely (ret != -ECOMM ))) goto free_desc; +if (!ret) { + vnic_sdma->pkts_sent = true; +iowait_starve_clear (vnic_sdma->pkts_sent, &vnic_sdma->wait); + }return ret; free_desc:
@@ -211,6 +216,8 @@ int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx, tx_err:if (ret != -EBUSY )dev_kfree_skb_any (skb); +else + vnic_sdma->pkts_sent = false;return ret; }
@@ -225,7 +232,8 @@ int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx,static int hfi1_vnic_sdma_sleep (struct sdma_engine *sde,struct iowait *wait,struct sdma_txreq *txreq, -unsigned int seq) +uint seq, +bool pkts_sent) {struct hfi1_vnic_sdma *vnic_sdma = container_of(wait, struct hfi1_vnic_sdma, wait);
@@ -239,7 +247,7 @@ static int hfi1_vnic_sdma_sleep(struct sdma_engine *sde, vnic_sdma->state =HFI1_VNIC_SDMA_Q_DEFERRED ;write_seqlock (&dev->iowait_lock);if (list_empty (&vnic_sdma->wait.list)) -list_add_tail (&vnic_sdma->wait.list, &sde->dmawait); +iowait_queue (pkts_sent, wait, &sde->dmawait);write_sequnlock (&dev->iowait_lock);return -EBUSY ; }
--
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/13 IB/hfi1: Assign context does not clean up file descriptor correctly on error
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
In the error path for context allocation, the file descriptor pointer should not point to a context when an error occurs.
Clean up the appropriate references on error.
--- drivers/infiniband/hw/hfi1/file_ops.c | 37 +++++++++++++++++++++++---------- 1 files changed, 26 insertions(+), 11 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +26 -11
@@ -94,6 +94,7 @@ static int find_sub_ctxt(struct hfi1_filedata *fd, const struct hfi1_user_info *uinfo);static int allocate_ctxt (struct hfi1_filedata *fd,struct hfi1_devdata *dd,struct hfi1_user_info *uinfo); +static void deallocate_ctxt (struct hfi1_ctxtdata *uctxt);static unsigned int poll_urgent (struct file *fp,struct poll_table_struct *pt);static unsigned int poll_next (struct file *fp,struct poll_table_struct *pt); static int user_event_ack(struct hfi1_ctxtdata *uctxt, u16 subctxt,
@@ -813,15 +814,9 @@ static int hfi1_file_close(struct inode *inode, struct file *fp) uctxt->rcvnowait =0 ; uctxt->pionowait =0 ; uctxt->event_flags =0 ; - - hfi1_stats.sps_ctxts--; -if (++dd->freectxts == dd->num_user_contexts) -aspm_enable_all (dd); - -/* _rcd_put() should be done after releasing mutex */ - dd->rcd[uctxt->ctxt] =NULL ;mutex_unlock (&hfi1_mutex); -hfi1_rcd_put (uctxt);/* dd reference */ + +deallocate_ctxt (uctxt); done:mmdrop (fdata->mm);kobject_put (&dd->kobj);
@@ -898,10 +893,9 @@ static int assign_ctxt(struct hfi1_filedata *fd, struct hfi1_user_info *uinfo)if (!ret) ret =init_user_ctxt (fd); -if (ret) { +if (ret)clear_bit (fd->subctxt, fd->uctxt->in_use_ctxts); -hfi1_rcd_put (fd->uctxt); - } + }else if (!ret) { ret =setup_base_ctxt (fd);if (fd->uctxt->subctxt_cnt) {
@@ -917,6 +911,14 @@ static int assign_ctxt(struct hfi1_filedata *fd, struct hfi1_user_info *uinfo) &fd->uctxt->event_flags);wake_up (&fd->uctxt->wait); } +if (ret) +deallocate_ctxt (fd->uctxt); + } + +/* If an error occurred, clear the reference */ +if (ret && fd->uctxt) { +hfi1_rcd_put (fd->uctxt); + fd->uctxt =NULL ; }return ret;
@@ -1087,6 +1089,19 @@ static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,return ret; } +static void deallocate_ctxt (struct hfi1_ctxtdata *uctxt) +{ +mutex_lock (&hfi1_mutex); + hfi1_stats.sps_ctxts--; +if (++uctxt->dd->freectxts == uctxt->dd->num_user_contexts) +aspm_enable_all (uctxt->dd); + +/* _rcd_put() should be done after releasing mutex */ + uctxt->dd->rcd[uctxt->ctxt] =NULL ; +mutex_unlock (&hfi1_mutex); +hfi1_rcd_put (uctxt);/* dd reference */ +} +static int init_subctxts (struct hfi1_ctxtdata *uctxt,const struct hfi1_user_info *uinfo) {
--
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/13 IB/hfi1: Remove unused user context data members
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
Several data members of the user context have become unused over time. Cleaning them up.
--- drivers/infiniband/hw/hfi1/file_ops.c | 6 ------ drivers/infiniband/hw/hfi1/hfi.h | 24 ------------------------ drivers/infiniband/hw/hfi1/user_sdma.c | 11 ----------- drivers/infiniband/hw/hfi1/user_sdma.h | 1 - 4 files changed, 0 insertions(+), 42 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +0 -6
@@ -809,10 +809,6 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)hfi1_free_ctxt_rcv_groups (uctxt);hfi1_clear_ctxt_pkey (dd, uctxt); - uctxt->rcvwait_to =0 ; - uctxt->piowait_to =0 ; - uctxt->rcvnowait =0 ; - uctxt->pionowait =0 ; uctxt->event_flags =0 ;mutex_unlock (&hfi1_mutex);
@@ -1067,8 +1063,6 @@ static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,strlcpy (uctxt->comm, current->comm,sizeof (uctxt->comm));memcpy (uctxt->uuid, uinfo->uuid,sizeof (uctxt->uuid)); uctxt->jkey =generate_jkey (current_uid ()); -INIT_LIST_HEAD (&uctxt->sdma_queues); -spin_lock_init (&uctxt->sdma_qlock); hfi1_stats.sps_ctxts++;/* * Disable ASPM when there are open user/PSM contexts to avoid
drivers/infiniband/hw/hfi1/hfi.h +0 -24
@@ -243,24 +243,10 @@ struct hfi1_ctxtdata {/* lock protecting all Expected TID data */ struct mutex exp_lock; -/* number of pio bufs for this ctxt (all procs, if shared) */ -u32 piocnt; -/* first pio buffer for this ctxt */ -u32 pio_base; -/* chip offset of PIO buffers for this ctxt */ -u32 piobufs;/* per-context configuration flags */ unsigned long flags;/* per-context event flags for fileops/intr communication */ unsigned long event_flags; -/* WAIT_RCV that timed out, no interrupt */ -u32 rcvwait_to; -/* WAIT_PIO that timed out, no interrupt */ -u32 piowait_to; -/* WAIT_RCV already happened, no wait */ -u32 rcvnowait; -/* WAIT_PIO already happened, no wait */ -u32 pionowait;/* total number of polled urgent packets */ u32 urgent;/* saved total number of polled urgent packets for poll edge trigger */
@@ -290,7 +276,6 @@ struct hfi1_ctxtdata {u8 redirect_seq_cnt;/* ctxt rcvhdrq head offset */ u32 head; -u32 pkt_count;/* QPs waiting for context processing */ struct list_head qp_wait_list;/* interrupt handling */
@@ -299,15 +284,6 @@ struct hfi1_ctxtdata {unsigned numa_id;/* numa node of this context */ /* verbs stats per CTX */ struct hfi1_opcode_stats_perctx *opstats; -/* -* This is the kernel thread that will keep making -* progress on the user sdma requests behind the scenes. -* There is one per context (shared contexts use the master's). -*/ -struct task_struct *progress; -struct list_head sdma_queues; -/* protect sdma queues */ -spinlock_t sdma_qlock;/* Is ASPM interrupt supported for this context */ bool aspm_intr_supported;
drivers/infiniband/hw/hfi1/user_sdma.c +0 -11
@@ -346,7 +346,6 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,struct hfi1_devdata *dd;struct hfi1_user_sdma_comp_q *cq;struct hfi1_user_sdma_pkt_q *pq; -unsigned long flags;if (!uctxt || !fd)return -EBADF ;
@@ -360,7 +359,6 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,if (!pq)return -ENOMEM ; -INIT_LIST_HEAD (&pq->list); pq->dd = dd; pq->ctxt = uctxt->ctxt; pq->subctxt = fd->subctxt;
@@ -421,10 +419,6 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, fd->pq = pq; fd->cq = cq; -spin_lock_irqsave (&uctxt->sdma_qlock, flags); -list_add (&pq->list, &uctxt->sdma_queues); -spin_unlock_irqrestore (&uctxt->sdma_qlock, flags); -return 0 ; pq_mmu_fail:
@@ -447,7 +441,6 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd) {struct hfi1_ctxtdata *uctxt = fd->uctxt;struct hfi1_user_sdma_pkt_q *pq; -unsigned long flags;hfi1_cdbg (SDMA ,"[%u:%u:%u] Freeing user SDMA queues" , uctxt->dd->unit, uctxt->ctxt, fd->subctxt);
@@ -455,10 +448,6 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd)if (pq) {if (pq->handler)hfi1_mmu_rb_unregister (pq->handler); -spin_lock_irqsave (&uctxt->sdma_qlock, flags); -if (!list_empty (&pq->list)) -list_del_init (&pq->list); -spin_unlock_irqrestore (&uctxt->sdma_qlock, flags);iowait_sdma_drain (&pq->busy);/* Wait until all requests have been freed. */ wait_event_interruptible(
drivers/infiniband/hw/hfi1/user_sdma.h +0 -1
@@ -56,7 +56,6 @@extern uint extended_psn;struct hfi1_user_sdma_pkt_q { -struct list_head list;unsigned ctxt;u16 subctxt;u16 n_max_reqs;
--
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/13 IB/hfi1: Size rcd array index correctly and consistently
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
The array index for the rcd array is sized several different ways throughout the code.
Use the user interface size (u16) as the standard size and update the necessary code to reflect this.
u16 is large enough for the largest amount of supported contexts.
--- drivers/infiniband/hw/hfi1/aspm.h | 6 +++--- drivers/infiniband/hw/hfi1/chip.c | 10 +++++----- drivers/infiniband/hw/hfi1/chip.h | 8 ++++---- drivers/infiniband/hw/hfi1/driver.c | 15 ++++++++------- drivers/infiniband/hw/hfi1/file_ops.c | 6 +++--- drivers/infiniband/hw/hfi1/hfi.h | 4 ++-- drivers/infiniband/hw/hfi1/init.c | 9 +++++---- drivers/infiniband/hw/hfi1/trace_rx.h | 2 +- drivers/infiniband/hw/hfi1/user_sdma.h | 2 +- drivers/infiniband/hw/hfi1/vnic_main.c | 2 +- 10 files changed, 33 insertions(+), 31 deletions(-)
drivers/infiniband/hw/hfi1/aspm.h +3 -3
@@ -237,7 +237,7 @@ static inline void aspm_disable_all(struct hfi1_devdata *dd) {struct hfi1_ctxtdata *rcd;unsigned long flags; -unsigned i; +u16 i;for (i =0 ; i < dd->first_dyn_alloc_ctxt; i++) { rcd = dd->rcd[i];
@@ -256,7 +256,7 @@ static inline void aspm_enable_all(struct hfi1_devdata *dd) {struct hfi1_ctxtdata *rcd;unsigned long flags; -unsigned i; +u16 i;aspm_enable (dd);
@@ -284,7 +284,7 @@ static inline void aspm_ctx_init(struct hfi1_ctxtdata *rcd)static inline void aspm_init (struct hfi1_devdata *dd) { -unsigned i; +u16 i;spin_lock_init (&dd->aspm_lock); dd->aspm_supported =aspm_hw_l1_supported (dd);
drivers/infiniband/hw/hfi1/chip.c +5 -5
@@ -6802,7 +6802,7 @@ static void rxe_freeze(struct hfi1_devdata *dd)static void rxe_kernel_unfreeze (struct hfi1_devdata *dd) {u32 rcvmask; -int i; +u16 i;/* enable all kernel contexts */ for (i =0 ; i < dd->num_rcv_contexts; i++) {
@@ -11722,7 +11722,7 @@ static u32 encoded_size(u32 size)return 0x1 ;/* if invalid, go with the minimum size */ } -void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op,int ctxt) +void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op,u16 ctxt) {struct hfi1_ctxtdata *rcd;u64 rcvctrl, reg;
@@ -14542,7 +14542,7 @@ static void init_txe(struct hfi1_devdata *dd)write_csr (dd,SEND_CM_TIMER_CTRL ,HFI1_CREDIT_RETURN_RATE ); } -int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,unsigned ctxt,u16 jkey) +int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt,u16 jkey) {struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];unsigned sctxt;
@@ -14579,7 +14579,7 @@ int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt, u16 jkey)return ret; } -int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,unsigned ctxt) +int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt) {struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];unsigned sctxt;
@@ -14608,7 +14608,7 @@ int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt)return ret; } -int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,unsigned ctxt,u16 pkey) +int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,u16 ctxt,u16 pkey) {struct hfi1_ctxtdata *rcd;unsigned sctxt;
drivers/infiniband/hw/hfi1/chip.h +4 -4
@@ -1352,14 +1352,14 @@ enum {void hfi1_put_tid (struct hfi1_devdata *dd,u32 index,u32 type,unsigned long pa,u16 order);void hfi1_quiet_serdes (struct hfi1_pportdata *ppd); -void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op,int ctxt); +void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op,u16 ctxt);u32 hfi1_read_cntrs (struct hfi1_devdata *dd,char **namep,u64 **cntrp);u32 hfi1_read_portcntrs (struct hfi1_pportdata *ppd,char **namep,u64 **cntrp);int hfi1_get_ib_cfg (struct hfi1_pportdata *ppd,int which);int hfi1_set_ib_cfg (struct hfi1_pportdata *ppd,int which,u32 val); -int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,unsigned ctxt,u16 jkey); -int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,unsigned ctxt); -int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,unsigned ctxt,u16 pkey); +int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt,u16 jkey); +int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt); +int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,u16 ctxt,u16 pkey);int hfi1_clear_ctxt_pkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *ctxt);void hfi1_read_link_quality (struct hfi1_devdata *dd,u8 *link_quality);void hfi1_init_vnic_rsm (struct hfi1_devdata *dd);
drivers/infiniband/hw/hfi1/driver.c +8 -7
@@ -838,9 +838,9 @@ int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *rcd, int thread)return last; } -static inline void set_nodma_rtail (struct hfi1_devdata *dd,u8 ctxt) +static inline void set_nodma_rtail (struct hfi1_devdata *dd,u16 ctxt) { -int i; +u16 i;/* * For dynamically allocated kernel contexts (like vnic) switch
@@ -858,9 +858,9 @@ static inline void set_nodma_rtail(struct hfi1_devdata *dd, u8 ctxt) &handle_receive_interrupt_nodma_rtail; } -static inline void set_dma_rtail (struct hfi1_devdata *dd,u8 ctxt) +static inline void set_dma_rtail (struct hfi1_devdata *dd,u16 ctxt) { -int i; +u16 i;/* * For dynamically allocated kernel contexts (like vnic) switch
@@ -880,7 +880,7 @@ static inline void set_dma_rtail(struct hfi1_devdata *dd, u8 ctxt)void set_all_slowpath (struct hfi1_devdata *dd) { -int i; +u16 i;/* HFI1_CTRL_CTXT must always use the slow path interrupt handler */ for (i =HFI1_CTRL_CTXT +1 ; i < dd->num_rcv_contexts; i++) {
@@ -1069,7 +1069,7 @@ void receive_interrupt_work(struct work_struct *work) struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata, linkstate_active_work);struct hfi1_devdata *dd = ppd->dd; -int i; +u16 i;/* Received non-SC15 packet implies neighbor_normal */ ppd->neighbor_normal =1 ;
@@ -1270,7 +1270,8 @@ void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,*/ int hfi1_reset_device (int unit) { -int ret, i; +int ret; +u16 i;struct hfi1_devdata *dd =hfi1_lookup (unit);struct hfi1_pportdata *ppd;unsigned long flags;
drivers/infiniband/hw/hfi1/file_ops.c +3 -3
@@ -927,7 +927,7 @@ static int assign_ctxt(struct hfi1_filedata *fd, struct hfi1_user_info *uinfo)static int find_sub_ctxt (struct hfi1_filedata *fd,const struct hfi1_user_info *uinfo) { -int i; +u16 i;struct hfi1_devdata *dd = fd->dd;u16 subctxt;
@@ -978,7 +978,7 @@ static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd, struct hfi1_user_info *uinfo) {struct hfi1_ctxtdata *uctxt; -unsigned int ctxt; +u16 ctxt;int ret, numa;if (dd->flags &HFI1_FROZEN ) {
@@ -1429,7 +1429,7 @@ int hfi1_set_uevent_bits(struct hfi1_pportdata *ppd, const int evtbit) {struct hfi1_ctxtdata *uctxt;struct hfi1_devdata *dd = ppd->dd; -unsigned ctxt; +u16 ctxt;int ret =0 ;unsigned long flags;
drivers/infiniband/hw/hfi1/hfi.h +2 -2
@@ -217,7 +217,7 @@ struct hfi1_ctxtdata {struct kref kref;/* Device context index */ -unsigned ctxt; +u16 ctxt;/* * non-zero if ctxt can be shared, and defines the maximum number of * sub-contexts for this device context.
@@ -1264,7 +1264,7 @@ struct hfi1_filedata {int hfi1_create_rcvhdrq (struct hfi1_devdata *dd,struct hfi1_ctxtdata *rcd);int hfi1_setup_eagerbufs (struct hfi1_ctxtdata *rcd);int hfi1_create_ctxts (struct hfi1_devdata *dd); -struct hfi1_ctxtdata *hfi1_create_ctxtdata (struct hfi1_pportdata *ppd,u32 ctxt, +struct hfi1_ctxtdata *hfi1_create_ctxtdata (struct hfi1_pportdata *ppd,u16 ctxt,int numa);void hfi1_init_pportdata (struct pci_dev *pdev,struct hfi1_pportdata *ppd,struct hfi1_devdata *dd,u8 hw_pidx,u8 port);
drivers/infiniband/hw/hfi1/init.c +5 -4
@@ -131,7 +131,7 @@*/ int hfi1_create_ctxts (struct hfi1_devdata *dd) { -unsigned i; +u16 i;int ret;/* Control context has to be always 0 */
@@ -233,7 +233,7 @@ void hfi1_rcd_get(struct hfi1_ctxtdata *rcd)/* * Common code for user and kernel context setup. */ -struct hfi1_ctxtdata *hfi1_create_ctxtdata (struct hfi1_pportdata *ppd,u32 ctxt, +struct hfi1_ctxtdata *hfi1_create_ctxtdata (struct hfi1_pportdata *ppd,u16 ctxt,int numa) {struct hfi1_devdata *dd = ppd->dd;
@@ -615,7 +615,7 @@ static int init_after_reset(struct hfi1_devdata *dd)static void enable_chip (struct hfi1_devdata *dd) {u32 rcvmask; -u32 i; +u16 i;/* enable PIO send */ pio_send_control (dd,PSC_GLOBAL_ENABLE );
@@ -692,7 +692,8 @@ static int create_workqueues(struct hfi1_devdata *dd)int hfi1_init (struct hfi1_devdata *dd,int reinit) {int ret =0 , pidx, lastfail =0 ; -unsigned i, len; +unsigned long len; +u16 i;struct hfi1_ctxtdata *rcd;struct hfi1_pportdata *ppd;
drivers/infiniband/hw/hfi1/trace_rx.h +1 -1
@@ -114,7 +114,7 @@ ); TRACE_EVENT(hfi1_receive_interrupt, - TP_PROTO(struct hfi1_devdata *dd, u32 ctxt), + TP_PROTO(struct hfi1_devdata *dd, u16 ctxt), TP_ARGS(dd, ctxt), TP_STRUCT__entry(DD_DEV_ENTRY(dd) __field(u32, ctxt)
drivers/infiniband/hw/hfi1/user_sdma.h +1 -1
@@ -56,7 +56,7 @@extern uint extended_psn;struct hfi1_user_sdma_pkt_q { -unsigned ctxt; +u16 ctxt;u16 subctxt;u16 n_max_reqs;atomic_t n_reqs;
drivers/infiniband/hw/hfi1/vnic_main.c +1 -1
@@ -106,7 +106,7 @@ static int allocate_vnic_ctxt(struct hfi1_devdata *dd, struct hfi1_ctxtdata **vnic_ctxt) {struct hfi1_ctxtdata *uctxt; -unsigned int ctxt; +u16 ctxt;int ret;if (dd->flags &HFI1_FROZEN )
--
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/13 IB/hfi1: Use context pointer rather than context index
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
The hfi1_<set|clear>_ctxt_<j|p>key functions take a context index and look up the context based on that index.
Since the context index is being retrieved from the context, this doesn't seem optimal.
Pass the context pointer for use, rather than the context index.
--- drivers/infiniband/hw/hfi1/chip.c | 90 ++++++++++++++------------------- drivers/infiniband/hw/hfi1/chip.h | 8 ++- drivers/infiniband/hw/hfi1/file_ops.c | 6 +- 3 files changed, 45 insertions(+), 59 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +37 -53
@@ -14542,99 +14542,86 @@ static void init_txe(struct hfi1_devdata *dd)write_csr (dd,SEND_CM_TIMER_CTRL ,HFI1_CREDIT_RETURN_RATE ); } -int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt,u16 jkey) +int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *rcd, +u16 jkey) { -struct hfi1_ctxtdata *rcd = dd->rcd[ctxt]; -unsigned sctxt; -int ret =0 ; +u8 hw_ctxt;u64 reg; -if (!rcd || !rcd->sc) { - ret = -EINVAL ; - goto done; - } - sctxt = rcd->sc->hw_context; +if (!rcd || !rcd->sc) +return -EINVAL ; + + hw_ctxt = rcd->sc->hw_context; reg =SEND_CTXT_CHECK_JOB_KEY_MASK_SMASK |/* mask is always 1's */ ((jkey &SEND_CTXT_CHECK_JOB_KEY_VALUE_MASK ) <<SEND_CTXT_CHECK_JOB_KEY_VALUE_SHIFT );/* JOB_KEY_ALLOW_PERMISSIVE is not allowed by default */ if (HFI1_CAP_KGET_MASK (rcd->flags,ALLOW_PERM_JKEY )) reg |=SEND_CTXT_CHECK_JOB_KEY_ALLOW_PERMISSIVE_SMASK ; -write_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_JOB_KEY , reg); +write_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_JOB_KEY , reg);/* * Enable send-side J_KEY integrity check, unless this is A0 h/w */ if (!is_ax (dd)) { - reg =read_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_ENABLE ); + reg =read_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE ); reg |=SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK ; -write_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_ENABLE , reg); +write_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE , reg); }/* Enable J_KEY check on receive context. */ reg =RCV_KEY_CTRL_JOB_KEY_ENABLE_SMASK | ((jkey &RCV_KEY_CTRL_JOB_KEY_VALUE_MASK ) <<RCV_KEY_CTRL_JOB_KEY_VALUE_SHIFT ); -write_kctxt_csr (dd, ctxt,RCV_KEY_CTRL , reg); -done: -return ret; +write_kctxt_csr (dd, rcd->ctxt,RCV_KEY_CTRL , reg); + +return 0 ; } -int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt) +int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *rcd) { -struct hfi1_ctxtdata *rcd = dd->rcd[ctxt]; -unsigned sctxt; -int ret =0 ; +u8 hw_ctxt;u64 reg; -if (!rcd || !rcd->sc) { - ret = -EINVAL ; - goto done; - } - sctxt = rcd->sc->hw_context; -write_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_JOB_KEY ,0 ); +if (!rcd || !rcd->sc) +return -EINVAL ; + + hw_ctxt = rcd->sc->hw_context; +write_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_JOB_KEY ,0 );/* * Disable send-side J_KEY integrity check, unless this is A0 h/w. * This check would not have been enabled for A0 h/w, see * set_ctxt_jkey(). */ if (!is_ax (dd)) { - reg =read_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_ENABLE ); + reg =read_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE ); reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK ; -write_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_ENABLE , reg); +write_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE , reg); }/* Turn off the J_KEY on the receive side */ -write_kctxt_csr (dd, ctxt,RCV_KEY_CTRL ,0 ); -done: -return ret; +write_kctxt_csr (dd, rcd->ctxt,RCV_KEY_CTRL ,0 ); + +return 0 ; } -int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,u16 ctxt,u16 pkey) +int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *rcd, +u16 pkey) { -struct hfi1_ctxtdata *rcd; -unsigned sctxt; -int ret =0 ; +u8 hw_ctxt;u64 reg; -if (ctxt < dd->num_rcv_contexts) { - rcd = dd->rcd[ctxt]; - }else { - ret = -EINVAL ; - goto done; - } -if (!rcd || !rcd->sc) { - ret = -EINVAL ; - goto done; - } - sctxt = rcd->sc->hw_context; +if (!rcd || !rcd->sc) +return -EINVAL ; + + hw_ctxt = rcd->sc->hw_context; reg = ((u64 )pkey &SEND_CTXT_CHECK_PARTITION_KEY_VALUE_MASK ) <<SEND_CTXT_CHECK_PARTITION_KEY_VALUE_SHIFT ; -write_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_PARTITION_KEY , reg); - reg =read_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_ENABLE ); +write_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_PARTITION_KEY , reg); + reg =read_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE ); reg |=SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK ; reg &= ~SEND_CTXT_CHECK_ENABLE_DISALLOW_KDETH_PACKETS_SMASK ; -write_kctxt_csr (dd, sctxt,SEND_CTXT_CHECK_ENABLE , reg); -done: -return ret; +write_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE , reg); + +return 0 ; }int hfi1_clear_ctxt_pkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *ctxt)
@@ -14645,9 +14632,6 @@ int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, struct hfi1_ctxtdata *ctxt)if (!ctxt || !ctxt->sc)return -EINVAL ; -if (ctxt->ctxt >= dd->num_rcv_contexts) -return -EINVAL ; - hw_ctxt = ctxt->sc->hw_context; reg =read_kctxt_csr (dd, hw_ctxt,SEND_CTXT_CHECK_ENABLE ); reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK ;
drivers/infiniband/hw/hfi1/chip.h +5 -3
@@ -1357,9 +1357,11 @@ void hfi1_put_tid(struct hfi1_devdata *dd, u32 index,u32 hfi1_read_portcntrs (struct hfi1_pportdata *ppd,char **namep,u64 **cntrp);int hfi1_get_ib_cfg (struct hfi1_pportdata *ppd,int which);int hfi1_set_ib_cfg (struct hfi1_pportdata *ppd,int which,u32 val); -int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt,u16 jkey); -int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,u16 ctxt); -int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,u16 ctxt,u16 pkey); +int hfi1_set_ctxt_jkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *rcd, +u16 jkey); +int hfi1_clear_ctxt_jkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *ctxt); +int hfi1_set_ctxt_pkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *ctxt, +u16 pkey);int hfi1_clear_ctxt_pkey (struct hfi1_devdata *dd,struct hfi1_ctxtdata *ctxt);void hfi1_read_link_quality (struct hfi1_devdata *dd,u8 *link_quality);void hfi1_init_vnic_rsm (struct hfi1_devdata *dd);
drivers/infiniband/hw/hfi1/file_ops.c +3 -3
@@ -795,7 +795,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)HFI1_RCVCTRL_NO_RHQ_DROP_DIS | HFI1_RCVCTRL_NO_EGR_DROP_DIS, uctxt->ctxt);/* Clear the context's J_KEY */ -hfi1_clear_ctxt_jkey (dd, uctxt->ctxt); +hfi1_clear_ctxt_jkey (dd, uctxt);/* * If a send context is allocated, reset context integrity * checks to default and disable the send context.
@@ -1172,7 +1172,7 @@ static void user_init(struct hfi1_ctxtdata *uctxt)clear_rcvhdrtail (uctxt);/* Setup J_KEY before enabling the context */ -hfi1_set_ctxt_jkey (uctxt->dd, uctxt->ctxt, uctxt->jkey); +hfi1_set_ctxt_jkey (uctxt->dd, uctxt, uctxt->jkey); rcvctrl_ops =HFI1_RCVCTRL_CTXT_ENB ;if (HFI1_CAP_UGET_MASK (uctxt->flags,HDRSUPP ))
@@ -1545,7 +1545,7 @@ static int set_ctxt_pkey(struct hfi1_ctxtdata *uctxt, u16 subctxt, u16 pkey) }if (intable) - ret =hfi1_set_ctxt_pkey (dd, uctxt->ctxt, pkey); + ret =hfi1_set_ctxt_pkey (dd, uctxt, pkey); done:return ret; }
--
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/13 IB/hfi1: Pass the context pointer rather than the index
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
The hfi1_rcvctrl() function receives an index which it then converts to an rcd. Since most functions have the rcd, use that instead.
--- drivers/infiniband/hw/hfi1/chip.c | 14 ++++++++------ drivers/infiniband/hw/hfi1/chip.h | 3 ++- drivers/infiniband/hw/hfi1/file_ops.c | 11 +++++------ drivers/infiniband/hw/hfi1/init.c | 14 +++++++------- drivers/infiniband/hw/hfi1/intr.c | 2 +- drivers/infiniband/hw/hfi1/vnic_main.c | 4 ++-- 6 files changed, 25 insertions(+), 23 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +8 -6
@@ -6790,7 +6790,7 @@ static void rxe_freeze(struct hfi1_devdata *dd)/* disable all receive contexts */ for (i =0 ; i < dd->num_rcv_contexts; i++) -hfi1_rcvctrl (dd,HFI1_RCVCTRL_CTXT_DIS , i); +hfi1_rcvctrl (dd,HFI1_RCVCTRL_CTXT_DIS , dd->rcd[i]); }/*
@@ -6814,9 +6814,9 @@ static void rxe_kernel_unfreeze(struct hfi1_devdata *dd) rcvmask =HFI1_RCVCTRL_CTXT_ENB ;/* HFI1_RCVCTRL_TAILUPD_[ENB|DIS] needs to be set explicitly */ - rcvmask |=HFI1_CAP_KGET_MASK (dd->rcd[i]->flags,DMA_RTAIL ) ? + rcvmask |=HFI1_CAP_KGET_MASK (rcd->flags,DMA_RTAIL ) ?HFI1_RCVCTRL_TAILUPD_ENB :HFI1_RCVCTRL_TAILUPD_DIS ; -hfi1_rcvctrl (dd, rcvmask, i); +hfi1_rcvctrl (dd, rcvmask, rcd); }/* enable port */
@@ -11722,16 +11722,18 @@ static u32 encoded_size(u32 size)return 0x1 ;/* if invalid, go with the minimum size */ } -void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op,u16 ctxt) +void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op, +struct hfi1_ctxtdata *rcd) { -struct hfi1_ctxtdata *rcd;u64 rcvctrl, reg;int did_enable =0 ; +u16 ctxt; - rcd = dd->rcd[ctxt];if (!rcd)return ; + ctxt = rcd->ctxt; +hfi1_cdbg (RCVCTRL ,"ctxt %d op 0x%x" , ctxt, op); rcvctrl =read_kctxt_csr (dd, ctxt,RCV_CTXT_CTRL );
drivers/infiniband/hw/hfi1/chip.h +2 -1
@@ -1352,7 +1352,8 @@ enum {void hfi1_put_tid (struct hfi1_devdata *dd,u32 index,u32 type,unsigned long pa,u16 order);void hfi1_quiet_serdes (struct hfi1_pportdata *ppd); -void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op,u16 ctxt); +void hfi1_rcvctrl (struct hfi1_devdata *dd,unsigned int op, +struct hfi1_ctxtdata *rcd);u32 hfi1_read_cntrs (struct hfi1_devdata *dd,char **namep,u64 **cntrp);u32 hfi1_read_portcntrs (struct hfi1_pportdata *ppd,char **namep,u64 **cntrp);int hfi1_get_ib_cfg (struct hfi1_pportdata *ppd,int which);
drivers/infiniband/hw/hfi1/file_ops.c +5 -6
@@ -389,8 +389,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,sc_disable (sc); ret =sc_enable (sc); -hfi1_rcvctrl (dd,HFI1_RCVCTRL_CTXT_ENB , - uctxt->ctxt); +hfi1_rcvctrl (dd,HFI1_RCVCTRL_CTXT_ENB , uctxt); }else { ret =sc_restart (sc); }
@@ -793,7 +792,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)HFI1_RCVCTRL_TAILUPD_DIS |HFI1_RCVCTRL_ONE_PKT_EGR_DIS |HFI1_RCVCTRL_NO_RHQ_DROP_DIS | - HFI1_RCVCTRL_NO_EGR_DROP_DIS, uctxt->ctxt); + HFI1_RCVCTRL_NO_EGR_DROP_DIS, uctxt);/* Clear the context's J_KEY */ hfi1_clear_ctxt_jkey (dd, uctxt);/*
@@ -1198,7 +1197,7 @@ static void user_init(struct hfi1_ctxtdata *uctxt) rcvctrl_ops |=HFI1_RCVCTRL_TAILUPD_ENB ; else rcvctrl_ops |= HFI1_RCVCTRL_TAILUPD_DIS; -hfi1_rcvctrl (uctxt->dd, rcvctrl_ops, uctxt->ctxt); +hfi1_rcvctrl (uctxt->dd, rcvctrl_ops, uctxt); } static int get_ctxt_info(struct hfi1_filedata *fd, void __user *ubase,
@@ -1410,7 +1409,7 @@ static unsigned int poll_next(struct file *fp,spin_lock_irq (&dd->uctxt_lock);if (hdrqempty (uctxt)) {set_bit (HFI1_CTXT_WAITING_RCV , &uctxt->event_flags); -hfi1_rcvctrl (dd,HFI1_RCVCTRL_INTRAVAIL_ENB , uctxt->ctxt); +hfi1_rcvctrl (dd,HFI1_RCVCTRL_INTRAVAIL_ENB , uctxt); pollflag =0 ; }else { pollflag =POLLIN |POLLRDNORM ;
@@ -1495,7 +1494,7 @@ static int manage_rcvq(struct hfi1_ctxtdata *uctxt, u16 subctxt, }else { rcvctrl_op =HFI1_RCVCTRL_CTXT_DIS ; } -hfi1_rcvctrl (dd, rcvctrl_op, uctxt->ctxt); +hfi1_rcvctrl (dd, rcvctrl_op, uctxt);/* always; new head should be equal to new tail; see above */ bail:return 0 ;
drivers/infiniband/hw/hfi1/init.c +7 -7
@@ -603,8 +603,8 @@ static int init_after_reset(struct hfi1_devdata *dd)*/ for (i =0 ; i < dd->num_rcv_contexts; i++)hfi1_rcvctrl (dd,HFI1_RCVCTRL_CTXT_DIS | -HFI1_RCVCTRL_INTRAVAIL_DIS | -HFI1_RCVCTRL_TAILUPD_DIS , i); +HFI1_RCVCTRL_INTRAVAIL_DIS | +HFI1_RCVCTRL_TAILUPD_DIS , dd->rcd[i]);pio_send_control (dd,PSC_GLOBAL_DISABLE );for (i =0 ; i < dd->num_send_contexts; i++)sc_disable (dd->send_contexts[i].sc);
@@ -634,7 +634,7 @@ static void enable_chip(struct hfi1_devdata *dd) rcvmask |=HFI1_RCVCTRL_NO_RHQ_DROP_ENB ;if (HFI1_CAP_KGET_MASK (dd->rcd[i]->flags,NODROP_EGR_FULL )) rcvmask |=HFI1_RCVCTRL_NO_EGR_DROP_ENB ; -hfi1_rcvctrl (dd, rcvmask, i); +hfi1_rcvctrl (dd, rcvmask, dd->rcd[i]);sc_enable (dd->rcd[i]->sc); } }
@@ -915,10 +915,10 @@ static void shutdown_device(struct hfi1_devdata *dd) ppd = dd->pport + pidx;for (i =0 ; i < dd->num_rcv_contexts; i++)hfi1_rcvctrl (dd,HFI1_RCVCTRL_TAILUPD_DIS | -HFI1_RCVCTRL_CTXT_DIS | -HFI1_RCVCTRL_INTRAVAIL_DIS | -HFI1_RCVCTRL_PKEY_DIS | -HFI1_RCVCTRL_ONE_PKT_EGR_DIS , i); +HFI1_RCVCTRL_CTXT_DIS | +HFI1_RCVCTRL_INTRAVAIL_DIS | +HFI1_RCVCTRL_PKEY_DIS | +HFI1_RCVCTRL_ONE_PKT_EGR_DIS , dd->rcd[i]);/* * Gracefully stop all sends allowing any in progress to * trickle out first.
drivers/infiniband/hw/hfi1/intr.c +1 -1
@@ -196,7 +196,7 @@ void handle_user_interrupt(struct hfi1_ctxtdata *rcd)if (test_and_clear_bit (HFI1_CTXT_WAITING_RCV , &rcd->event_flags)) {wake_up_interruptible (&rcd->wait); -hfi1_rcvctrl (dd,HFI1_RCVCTRL_INTRAVAIL_DIS , rcd->ctxt); +hfi1_rcvctrl (dd,HFI1_RCVCTRL_INTRAVAIL_DIS , rcd); }else if (test_and_clear_bit (HFI1_CTXT_WAITING_URG , &rcd->event_flags)) { rcd->urgent++;
drivers/infiniband/hw/hfi1/vnic_main.c +2 -2
@@ -95,7 +95,7 @@ static int setup_vnic_ctxt(struct hfi1_devdata *dd, struct hfi1_ctxtdata *uctxt)if (HFI1_CAP_KGET_MASK (uctxt->flags,DMA_RTAIL )) rcvctrl_ops |=HFI1_RCVCTRL_TAILUPD_ENB ; -hfi1_rcvctrl (uctxt->dd, rcvctrl_ops, uctxt->ctxt); +hfi1_rcvctrl (uctxt->dd, rcvctrl_ops, uctxt); uctxt->is_vnic = true; done:
@@ -186,7 +186,7 @@ static void deallocate_vnic_ctxt(struct hfi1_devdata *dd,HFI1_RCVCTRL_INTRAVAIL_DIS |HFI1_RCVCTRL_ONE_PKT_EGR_DIS |HFI1_RCVCTRL_NO_RHQ_DROP_DIS | - HFI1_RCVCTRL_NO_EGR_DROP_DIS, uctxt->ctxt); + HFI1_RCVCTRL_NO_EGR_DROP_DIS, uctxt);/* * VNIC contexts are allocated from user context pool. * Release them back to user context pool.
--
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/13 IB/hfi1: Send MAD traps until repressed
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
A trap should be sent to the FM until the FM sends a repress message. This is in line with the IBTA 13.4.9.
Add the ability to resend traps until a repress message is received.
--- drivers/infiniband/hw/hfi1/mad.c | 373 ++++++++++++++++++++++++++++-------- drivers/infiniband/hw/hfi1/mad.h | 3 drivers/infiniband/hw/hfi1/verbs.c | 5 include/rdma/rdma_vt.h | 17 ++ 4 files changed, 310 insertions(+), 88 deletions(-)
drivers/infiniband/hw/hfi1/mad.c +286 -87
@@ -59,6 +59,16 @@#define OPA_LINK_WIDTH_RESET_OLD 0x0fff#define OPA_LINK_WIDTH_RESET 0xffff +struct trap_node { +struct list_head list; +struct opa_mad_notice_attr data; +__be64 tid; +int len; +u32 retry; +u8 in_use; +u8 repress; +}; +static int smp_length_check (u32 data_size,u32 request_len) {if (unlikely (request_len < data_size))
@@ -97,28 +107,156 @@ void hfi1_event_pkey_change(struct hfi1_devdata *dd, u8 port)ib_dispatch_event (&event); } -static void send_trap (struct hfi1_ibport *ibp,void *data,unsigned len) +/* +* If the port is down, clean up all pending traps. We need to be careful +* with the given trap, because it may be queued. +*/ +static void cleanup_traps (struct hfi1_ibport *ibp,struct trap_node *trap) +{ +struct trap_node *node, *q; +unsigned long flags; +struct list_head trap_list; +int i; + +for (i =0 ; i <RVT_MAX_TRAP_LISTS ; i++) { +spin_lock_irqsave (&ibp->rvp.lock, flags); +list_replace_init (&ibp->rvp.trap_lists[i].list, &trap_list); + ibp->rvp.trap_lists[i].list_len =0 ; +spin_unlock_irqrestore (&ibp->rvp.lock, flags); + +/* +* Remove all items from the list, freeing all the non-given +* traps. +*/ +list_for_each_entry_safe (node, q, &trap_list, list) { +list_del (&node->list); +if (node != trap) +kfree (node); + } + } + +/* +* If this wasn't on one of the lists it would not be freed. If it +* was on the list, it is now safe to free. +*/ +kfree (trap); +} + +static struct trap_node *check_and_add_trap (struct hfi1_ibport *ibp, +struct trap_node *trap) +{ +struct trap_node *node; +struct trap_list *trap_list; +unsigned long flags; +unsigned long timeout; +int found =0 ; + +/* +* Since the retry (handle timeout) does not remove a trap request +* from the list, all we have to do is compare the node. +*/ +spin_lock_irqsave (&ibp->rvp.lock, flags); + trap_list = &ibp->rvp.trap_lists[trap->data.generic_type &0x0F ]; + +list_for_each_entry (node, &trap_list->list, list) { +if (node == trap) { + node->retry++; + found =1 ; +break ; + } + } + +/* If it is not on the list, add it, limited to RVT-MAX_TRAP_LEN. */ +if (!found) { +if (trap_list->list_len <RVT_MAX_TRAP_LEN ) { + trap_list->list_len++; +list_add_tail (&trap->list, &trap_list->list); + }else { +pr_warn_ratelimited ("hfi1: Maximim trap limit reached for 0x%0x traps\n" , + trap->data.generic_type); +kfree (trap); + } + } + +/* +* Next check to see if there is a timer pending. If not, set it up +* and get the first trap from the list. +*/ + node =NULL ; +if (!timer_pending (&ibp->rvp.trap_timer)) { +/* +* o14-2 +* If the time out is set we have to wait until it expires +* before the trap can be sent. +* This should be > RVT_TRAP_TIMEOUT +*/ + timeout = (RVT_TRAP_TIMEOUT * + (1UL << ibp->rvp.subnet_timeout)) /1000 ; +mod_timer (&ibp->rvp.trap_timer, + jiffies +usecs_to_jiffies (timeout)); + node = list_first_entry(&trap_list->list, struct trap_node, + list); + node->in_use =1 ; + } +spin_unlock_irqrestore (&ibp->rvp.lock, flags); + +return node; +} + +static void subn_handle_opa_trap_repress (struct hfi1_ibport *ibp, +struct opa_smp *smp) +{ +struct trap_list *trap_list; +struct trap_node *trap; +unsigned long flags; +int i; + +if (smp->attr_id !=IB_SMP_ATTR_NOTICE ) +return ; + +spin_lock_irqsave (&ibp->rvp.lock, flags); +for (i =0 ; i <RVT_MAX_TRAP_LISTS ; i++) { + trap_list = &ibp->rvp.trap_lists[i]; + trap =list_first_entry_or_null (&trap_list->list, + struct trap_node, list); +if (trap && trap->tid == smp->tid) { +if (trap->in_use) { + trap->repress =1 ; + }else { + trap_list->list_len--; +list_del (&trap->list); +kfree (trap); + } +break ; + } + } +spin_unlock_irqrestore (&ibp->rvp.lock, flags); +} + +static void send_trap (struct hfi1_ibport *ibp,struct trap_node *trap) {struct ib_mad_send_buf *send_buf;struct ib_mad_agent *agent;struct opa_smp *smp; -int ret;unsigned long flags; -unsigned long timeout;int pkey_idx;u32 qpn =ppd_from_ibp (ibp)->sm_trap_qp; agent = ibp->rvp.send_agent; -if (!agent) +if (!agent) { +cleanup_traps (ibp, trap);return ; + }/* o14-3.2.1 */ -if (driver_lstate (ppd_from_ibp (ibp)) !=IB_PORT_ACTIVE ) +if (driver_lstate (ppd_from_ibp (ibp)) !=IB_PORT_ACTIVE ) { +cleanup_traps (ibp, trap);return ; + } -/* o14-2 */ -if (ibp->rvp.trap_timeout &&time_before (jiffies, - ibp->rvp.trap_timeout)) +/* Add the trap to the list if necessary and see if we can send it */ + trap =check_and_add_trap (ibp, trap); +if (!trap)return ; pkey_idx =hfi1_lookup_pkey_idx (ibp,LIM_MGMT_P_KEY );
@@ -139,11 +277,21 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len) smp->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; smp->class_version =OPA_SM_CLASS_VERSION ; smp->method =IB_MGMT_METHOD_TRAP ; - ibp->rvp.tid++; - smp->tid =cpu_to_be64 (ibp->rvp.tid); + +/* Only update the transaction ID for new traps (o13-5). */ +if (trap->tid ==0 ) { + ibp->rvp.tid++; +/* make sure that tid != 0 */ +if (ibp->rvp.tid ==0 ) + ibp->rvp.tid++; + trap->tid =cpu_to_be64 (ibp->rvp.tid); + } + smp->tid = trap->tid; + smp->attr_id =IB_SMP_ATTR_NOTICE ;/* o14-1: smp->mkey = 0; */ -memcpy (smp->route.lid.data, data, len); + +memcpy (smp->route.lid.data, &trap->data, trap->len);spin_lock_irqsave (&ibp->rvp.lock, flags);if (!ibp->rvp.sm_ah) {
@@ -152,31 +300,72 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len) ah =hfi1_create_qp0_ah (ibp, ibp->rvp.sm_lid);if (IS_ERR (ah)) { - ret =PTR_ERR (ah); - }else { - send_buf->ah = ah; - ibp->rvp.sm_ah =ibah_to_rvtah (ah); - ret =0 ; +spin_unlock_irqrestore (&ibp->rvp.lock, flags); +return ; } + send_buf->ah = ah; + ibp->rvp.sm_ah =ibah_to_rvtah (ah); }else { - ret = -EINVAL ; +spin_unlock_irqrestore (&ibp->rvp.lock, flags); +return ; } }else { send_buf->ah = &ibp->rvp.sm_ah->ibah; - ret =0 ; } + +/* +* If the trap was repressed while things were getting set up, don't +* bother sending it. This could happen for a retry. +*/ +if (trap->repress) { +list_del (&trap->list); +spin_unlock_irqrestore (&ibp->rvp.lock, flags); +kfree (trap); +ib_free_send_mad (send_buf); +return ; + } + + trap->in_use =0 ;spin_unlock_irqrestore (&ibp->rvp.lock, flags); -if (!ret) - ret =ib_post_send_mad (send_buf,NULL ); -if (!ret) { -/* 4.096 usec. */ - timeout = (4096 * (1UL << ibp->rvp.subnet_timeout)) /1000 ; - ibp->rvp.trap_timeout = jiffies +usecs_to_jiffies (timeout); - }else { +if (ib_post_send_mad (send_buf,NULL ))ib_free_send_mad (send_buf); - ibp->rvp.trap_timeout =0 ; +} + +void hfi1_handle_trap_timer (unsigned long data) +{ +struct hfi1_ibport *ibp = (struct hfi1_ibport *)data; +struct trap_node *trap =NULL ; +unsigned long flags; +int i; + +/* Find the trap with the highest priority */ +spin_lock_irqsave (&ibp->rvp.lock, flags); +for (i =0 ; !trap && i <RVT_MAX_TRAP_LISTS ; i++) { + trap =list_first_entry_or_null (&ibp->rvp.trap_lists[i].list, + struct trap_node, list); } +spin_unlock_irqrestore (&ibp->rvp.lock, flags); + +if (trap) +send_trap (ibp, trap); +} + +static struct trap_node *create_trap_node (u8 type,__be16 trap_num,u32 lid) +{ +struct trap_node *trap; + + trap =kzalloc (sizeof (*trap),GFP_ATOMIC ); +if (!trap) +return NULL ; + +INIT_LIST_HEAD (&trap->list); + trap->data.generic_type = type; + trap->data.prod_type_lsb =IB_NOTICE_PROD_CA ; + trap->data.trap_num = trap_num; + trap->data.issuer_lid =cpu_to_be32 (lid); + +return trap; }/*
@@ -185,28 +374,29 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len)void hfi1_bad_pkey (struct hfi1_ibport *ibp,u32 key,u32 sl,u32 qp1,u32 qp2,u16 lid1,u16 lid2) { -struct opa_mad_notice_attr data; +struct trap_node *trap;u32 lid =ppd_from_ibp (ibp)->lid;u32 _lid1 = lid1;u32 _lid2 = lid2; -memset (&data,0 ,sizeof (data)); ibp->rvp.n_pkt_drops++; ibp->rvp.pkey_violations++; + trap =create_trap_node (IB_NOTICE_TYPE_SECURITY ,OPA_TRAP_BAD_P_KEY , + lid); +if (!trap) +return ; +/* Send violation trap */ - data.generic_type =IB_NOTICE_TYPE_SECURITY ; - data.prod_type_lsb =IB_NOTICE_PROD_CA ; - data.trap_num =OPA_TRAP_BAD_P_KEY ; - data.issuer_lid =cpu_to_be32 (lid); - data.ntc_257_258.lid1 =cpu_to_be32 (_lid1); - data.ntc_257_258.lid2 =cpu_to_be32 (_lid2); - data.ntc_257_258.key =cpu_to_be32 (key); - data.ntc_257_258.sl = sl <<3 ; - data.ntc_257_258.qp1 =cpu_to_be32 (qp1); - data.ntc_257_258.qp2 =cpu_to_be32 (qp2); - -send_trap (ibp, &data,sizeof (data)); + trap->data.ntc_257_258.lid1 =cpu_to_be32 (_lid1); + trap->data.ntc_257_258.lid2 =cpu_to_be32 (_lid2); + trap->data.ntc_257_258.key =cpu_to_be32 (key); + trap->data.ntc_257_258.sl = sl <<3 ; + trap->data.ntc_257_258.qp1 =cpu_to_be32 (qp1); + trap->data.ntc_257_258.qp2 =cpu_to_be32 (qp2); + + trap->len =sizeof (trap->data); +send_trap (ibp, trap); }/*
@@ -215,34 +405,36 @@ void hfi1_bad_pkey(struct hfi1_ibport *ibp, u32 key, u32 sl,static void bad_mkey (struct hfi1_ibport *ibp,struct ib_mad_hdr *mad,__be64 mkey,__be32 dr_slid,u8 return_path[],u8 hop_cnt) { -struct opa_mad_notice_attr data; +struct trap_node *trap;u32 lid =ppd_from_ibp (ibp)->lid; -memset (&data,0 ,sizeof (data)); + trap =create_trap_node (IB_NOTICE_TYPE_SECURITY ,OPA_TRAP_BAD_M_KEY , + lid); +if (!trap) +return ; +/* Send violation trap */ - data.generic_type =IB_NOTICE_TYPE_SECURITY ; - data.prod_type_lsb =IB_NOTICE_PROD_CA ; - data.trap_num =OPA_TRAP_BAD_M_KEY ; - data.issuer_lid =cpu_to_be32 (lid); - data.ntc_256.lid = data.issuer_lid; - data.ntc_256.method = mad->method; - data.ntc_256.attr_id = mad->attr_id; - data.ntc_256.attr_mod = mad->attr_mod; - data.ntc_256.mkey = mkey; + trap->data.ntc_256.lid = trap->data.issuer_lid; + trap->data.ntc_256.method = mad->method; + trap->data.ntc_256.attr_id = mad->attr_id; + trap->data.ntc_256.attr_mod = mad->attr_mod; + trap->data.ntc_256.mkey = mkey;if (mad->mgmt_class ==IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) { - data.ntc_256.dr_slid = dr_slid; - data.ntc_256.dr_trunc_hop =IB_NOTICE_TRAP_DR_NOTICE ; -if (hop_cnt >ARRAY_SIZE (data.ntc_256.dr_rtn_path)) { - data.ntc_256.dr_trunc_hop |= + trap->data.ntc_256.dr_slid = dr_slid; + trap->data.ntc_256.dr_trunc_hop =IB_NOTICE_TRAP_DR_NOTICE ; +if (hop_cnt >ARRAY_SIZE (trap->data.ntc_256.dr_rtn_path)) { + trap->data.ntc_256.dr_trunc_hop |=IB_NOTICE_TRAP_DR_TRUNC ; - hop_cnt =ARRAY_SIZE (data.ntc_256.dr_rtn_path); + hop_cnt =ARRAY_SIZE (trap->data.ntc_256.dr_rtn_path); } - data.ntc_256.dr_trunc_hop |= hop_cnt; -memcpy (data.ntc_256.dr_rtn_path, return_path, + trap->data.ntc_256.dr_trunc_hop |= hop_cnt; +memcpy (trap->data.ntc_256.dr_rtn_path, return_path, hop_cnt); } -send_trap (ibp, &data,sizeof (data)); + trap->len =sizeof (trap->data); + +send_trap (ibp, trap); }/*
@@ -250,23 +442,24 @@ static void bad_mkey(struct hfi1_ibport *ibp, struct ib_mad_hdr *mad,*/ void hfi1_cap_mask_chg (struct rvt_dev_info *rdi,u8 port_num) { -struct opa_mad_notice_attr data; +struct trap_node *trap;struct hfi1_ibdev *verbs_dev =dev_from_rdi (rdi);struct hfi1_devdata *dd =dd_from_dev (verbs_dev);struct hfi1_ibport *ibp = &dd->pport[port_num -1 ].ibport_data;u32 lid =ppd_from_ibp (ibp)->lid; -memset (&data,0 ,sizeof (data)); + trap =create_trap_node (IB_NOTICE_TYPE_INFO , +OPA_TRAP_CHANGE_CAPABILITY , + lid); +if (!trap) +return ; - data.generic_type =IB_NOTICE_TYPE_INFO ; - data.prod_type_lsb =IB_NOTICE_PROD_CA ; - data.trap_num =OPA_TRAP_CHANGE_CAPABILITY ; - data.issuer_lid =cpu_to_be32 (lid); - data.ntc_144.lid = data.issuer_lid; - data.ntc_144.new_cap_mask =cpu_to_be32 (ibp->rvp.port_cap_flags); - data.ntc_144.cap_mask3 =cpu_to_be16 (ibp->rvp.port_cap3_flags); + trap->data.ntc_144.lid = trap->data.issuer_lid; + trap->data.ntc_144.new_cap_mask =cpu_to_be32 (ibp->rvp.port_cap_flags); + trap->data.ntc_144.cap_mask3 =cpu_to_be16 (ibp->rvp.port_cap3_flags); -send_trap (ibp, &data,sizeof (data)); + trap->len =sizeof (trap->data); +send_trap (ibp, trap); }/*
@@ -274,19 +467,19 @@ void hfi1_cap_mask_chg(struct rvt_dev_info *rdi, u8 port_num)*/ void hfi1_sys_guid_chg (struct hfi1_ibport *ibp) { -struct opa_mad_notice_attr data; +struct trap_node *trap;u32 lid =ppd_from_ibp (ibp)->lid; -memset (&data,0 ,sizeof (data)); + trap =create_trap_node (IB_NOTICE_TYPE_INFO ,OPA_TRAP_CHANGE_SYSGUID , + lid); +if (!trap) +return ; - data.generic_type =IB_NOTICE_TYPE_INFO ; - data.prod_type_lsb =IB_NOTICE_PROD_CA ; - data.trap_num =OPA_TRAP_CHANGE_SYSGUID ; - data.issuer_lid =cpu_to_be32 (lid); - data.ntc_145.new_sys_guid = ib_hfi1_sys_image_guid; - data.ntc_145.lid = data.issuer_lid; + trap->data.ntc_145.new_sys_guid = ib_hfi1_sys_image_guid; + trap->data.ntc_145.lid = trap->data.issuer_lid; -send_trap (ibp, &data,sizeof (data)); + trap->len =sizeof (trap->data); +send_trap (ibp, trap); }/*
@@ -294,20 +487,21 @@ void hfi1_sys_guid_chg(struct hfi1_ibport *ibp)*/ void hfi1_node_desc_chg (struct hfi1_ibport *ibp) { -struct opa_mad_notice_attr data; +struct trap_node *trap;u32 lid =ppd_from_ibp (ibp)->lid; -memset (&data,0 ,sizeof (data)); + trap =create_trap_node (IB_NOTICE_TYPE_INFO , +OPA_TRAP_CHANGE_CAPABILITY , + lid); +if (!trap) +return ; - data.generic_type =IB_NOTICE_TYPE_INFO ; - data.prod_type_lsb =IB_NOTICE_PROD_CA ; - data.trap_num =OPA_TRAP_CHANGE_CAPABILITY ; - data.issuer_lid =cpu_to_be32 (lid); - data.ntc_144.lid = data.issuer_lid; - data.ntc_144.change_flags = + trap->data.ntc_144.lid = trap->data.issuer_lid; + trap->data.ntc_144.change_flags =cpu_to_be16 (OPA_NOTICE_TRAP_NODE_DESC_CHG ); -send_trap (ibp, &data,sizeof (data)); + trap->len =sizeof (trap->data); +send_trap (ibp, trap); } static int __subn_get_opa_nodedesc(struct opa_smp *smp, u32 am,
@@ -4144,6 +4338,11 @@ static int process_subn_opa(struct ib_device *ibdev, int mad_flags,*/ ret =IB_MAD_RESULT_SUCCESS ;break ; +case IB_MGMT_METHOD_TRAP_REPRESS : +subn_handle_opa_trap_repress (ibp, smp); +/* Always successful */ + ret =IB_MAD_RESULT_SUCCESS ; +break ;default : smp->status |=IB_SMP_UNSUP_METHOD ; ret =reply ((struct ib_mad_hdr *)smp);
drivers/infiniband/hw/hfi1/mad.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.
@@ -428,5 +428,6 @@ struct sc2vlnt { COUNTER_MASK(1, 4))void hfi1_event_pkey_change (struct hfi1_devdata *dd,u8 port); +void hfi1_handle_trap_timer (unsigned long data);#endif /* _HFI1_MAD_H */
drivers/infiniband/hw/hfi1/verbs.c +5 -0
@@ -1535,6 +1535,11 @@ static void init_ibport(struct hfi1_pportdata *ppd) ibp->sc_to_sl[i] = i; } +for (i =0 ; i <RVT_MAX_TRAP_LISTS ; i++) +INIT_LIST_HEAD (&ibp->rvp.trap_lists[i].list); +setup_timer (&ibp->rvp.trap_timer, hfi1_handle_trap_timer, + (unsigned long )ibp); +spin_lock_init (&ibp->rvp.lock);/* Set the prefix to the default value (see ch. 4.1.1) */ ibp->rvp.gid_prefix =IB_DEFAULT_GID_PREFIX ;
include/rdma/rdma_vt.h +17 -0
@@ -57,11 +57,21 @@#include <linux/list.h> #include <linux/hash.h> #include <rdma/ib_verbs.h> +#include <rdma/ib_mad.h> #include <rdma/rdmavt_mr.h> #include <rdma/rdmavt_qp.h> #define RVT_MAX_PKEY_VALUES 16 +#define RVT_MAX_TRAP_LEN 100/* Limit pending trap list */ +#define RVT_MAX_TRAP_LISTS ((IB_NOTICE_TYPE_INFO & 0x0F) + 1) +#define RVT_TRAP_TIMEOUT 4096/* 4.096 usec */ + +struct trap_list { +u32 list_len; +struct list_head list; +}; +struct rvt_ibport {struct rvt_qp __rcu *qp[2 ];struct ib_mad_agent *send_agent;/* agent for SMI (traps) */
@@ -128,6 +138,13 @@ struct rvt_ibport {u16 *pkey_table;struct rvt_ah *sm_ah; + +/* +* Keep a list of traps that have not been repressed. They will be +* resent based on trap_timer. +*/ +struct trap_list trap_lists[RVT_MAX_TRAP_LISTS ]; +struct timer_list trap_timer; };#define RVT_CQN_MAX 16/* maximum length of cq name */
--
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/13 IB/hfi1: Fix code consistency for if/else blocks in chip.c
In reply to a message not in the archiveFrom: Jan Sokolowski <[email protected]>
Code structure is not consistent for if/else blocks and break instructions in set_link_state for case HLS_UP_INIT. Physical state uses break in case of an error and if/else blocks for logical use cases. These blocks should be implemented consistently.
--- drivers/infiniband/hw/hfi1/chip.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +11 -10
@@ -10569,18 +10569,19 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)dd_dev_err (dd,"%s: logical state did not change to INIT\n" , __func__); - }else { -/* clear old transient LINKINIT_REASON code */ -if (ppd->linkinit_reason >=OPA_LINKINIT_REASON_CLEAR ) - ppd->linkinit_reason = -OPA_LINKINIT_REASON_LINKUP ; +break ; + } -/* enable the port */ -add_rcvctrl (dd,RCV_CTRL_RCV_PORT_ENABLE_SMASK ); +/* clear old transient LINKINIT_REASON code */ +if (ppd->linkinit_reason >=OPA_LINKINIT_REASON_CLEAR ) + ppd->linkinit_reason = +OPA_LINKINIT_REASON_LINKUP ; -handle_linkup_change (dd,1 ); - ppd->host_link_state =HLS_UP_INIT ; - } +/* enable the port */ +add_rcvctrl (dd,RCV_CTRL_RCV_PORT_ENABLE_SMASK ); + +handle_linkup_change (dd,1 ); + ppd->host_link_state =HLS_UP_INIT ;break ;case HLS_UP_ARMED :if (ppd->host_link_state !=HLS_UP_INIT )
--
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 10/13 IB/hfi1: Fix initialization failure for debug firmware
In reply to a message not in the archiveFrom: Byczkowski, Jakub <[email protected]>
Loading debug signed firmware fails if started immediately after failed attempt to load production firmware. A short delay is required so add about a 100us delay after RSA check failure.
--- drivers/infiniband/hw/hfi1/firmware.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/firmware.c +8 -0
@@ -615,6 +615,14 @@ static void __obtain_firmware(struct hfi1_devdata *dd) fw_fabric_serdes_name =ALT_FW_FABRIC_NAME ; fw_sbus_name =ALT_FW_SBUS_NAME ; fw_pcie_serdes_name =ALT_FW_PCIE_NAME ; + +/* +* Add a delay before obtaining and loading debug firmware. +* Authorization will fail if the delay between firmware +* authorization events is shorter than 50us. Add 100us to +* make a delay time safe. +*/ +usleep_range (100 ,120 ); }if (fw_sbus_load) {
--
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 11/13 IB/hfi1: Move saving PCI values to a separate function
In reply to a message not in the archiveFrom: Bartlomiej Dudek <[email protected]>
During PCIe initialization some registers' values from PCI config space are saved in order to restore them later (i.e. after reset). Restoring those value is done by a function called restore_pci_variables, while saving them is put directly into function hfi1_pcie_ddinit. Move saving values to a separate function in the image of restoring functionality.
--- drivers/infiniband/hw/hfi1/chip.c | 5 ++ drivers/infiniband/hw/hfi1/hfi.h | 1 drivers/infiniband/hw/hfi1/pcie.c | 110 ++++++++++++++++++++----------------- 3 files changed, 64 insertions(+), 52 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +5 -0
@@ -14866,6 +14866,11 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,if (ret <0 ) goto bail_free; +/* Save PCI space registers to rewrite after device reset */ + ret =save_pci_variables (dd); +if (ret <0 ) + goto bail_cleanup; +/* verify that reads actually work, save revision for reset check */ dd->revision =read_csr (dd,CCE_REVISION );if (dd->revision == ~(u64 )0 ) {
drivers/infiniband/hw/hfi1/hfi.h +1 -0
@@ -1835,6 +1835,7 @@ int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num,int pcie_speeds (struct hfi1_devdata *dd);int request_msix (struct hfi1_devdata *dd,u32 msireq);int restore_pci_variables (struct hfi1_devdata *dd); +int save_pci_variables (struct hfi1_devdata *dd);int do_pcie_gen3_transition (struct hfi1_devdata *dd);int parse_platform_config (struct hfi1_devdata *dd); int get_platform_config_field(struct hfi1_devdata *dd,
drivers/infiniband/hw/hfi1/pcie.c +58 -52
127 lines not on this page · raw message
--
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 12/13 IB/hfi1: Verify port data VLs credits on transition to Armed
In reply to a message not in the archiveFrom: Alex Estrin <[email protected]>
There is a window where the FM can read the buffer control table and decide not to program buffers. When a port goes down, the code clears the table and if it is not programmed, posted SDMA descriptors will never complete due to no buffer credits.
--- drivers/infiniband/hw/hfi1/chip.c | 16 +++++++++++++++- drivers/infiniband/hw/hfi1/intr.c | 1 + 2 files changed, 16 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +15 -1
@@ -10490,6 +10490,14 @@ void set_link_down_reason(struct hfi1_pportdata *ppd, u8 lcl_reason, }/* +* Verify if BCT for data VLs is non-zero. +*/ +static inline bool data_vls_operational (struct hfi1_pportdata *ppd) +{ +return !!ppd->actual_vls_operational; +} + +/* * Change the physical and/or logical link state. * * Do not call this routine while inside an interrupt. It contains
@@ -10587,6 +10595,13 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)if (ppd->host_link_state !=HLS_UP_INIT ) goto unexpected; +if (!data_vls_operational (ppd)) { +dd_dev_err (dd, +"%s: data VLs not operational\n" , __func__); + ret = -EINVAL ; +break ; + } + ppd->host_link_state =HLS_UP_ARMED ;set_logical_state (dd,LSTATE_ARMED ); ret =wait_logical_linkstate (ppd,IB_PORT_ARMED ,1000 );
@@ -14832,7 +14847,6 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev, } ppd->vls_supported = num_vls; ppd->vls_operational = ppd->vls_supported; - ppd->actual_vls_operational = ppd->vls_supported;/* Set the default MTU. */ for (vl =0 ; vl < num_vls; vl++) dd->vld[vl].mtu = hfi1_max_mtu;
drivers/infiniband/hw/hfi1/intr.c +1 -0
@@ -164,6 +164,7 @@ void handle_linkup_change(struct hfi1_devdata *dd, u32 linkup) ppd->linkup =0 ;/* clear HW details of the previous connection */ + ppd->actual_vls_operational =0 ;reset_link_credits (dd);/* freeze after a link down to guarantee a clean egress */
--
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 13/13 IB/hfi1: Split copy_to_user data copy for better security
In reply to a message not in the archiveFrom: Michael J. Ruhl <[email protected]>
A copy_to_user() call assumes that two members of a data structure are sequential. Since this may not always be true, separate the copies to ensure a safe copy.
--- drivers/infiniband/hw/hfi1/file_ops.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +5 -3
@@ -268,12 +268,14 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,/* * Copy the number of tidlist entries we used * and the length of the buffer we registered. -* These fields are adjacent in the structure so -* we can copy them at the same time. */ addr = arg + offsetof(struct hfi1_tid_info , tidcnt);if (copy_to_user ((void __user *)addr, &tinfo.tidcnt, -sizeof (tinfo.tidcnt) + +sizeof (tinfo.tidcnt))) +return -EFAULT ; + + addr = arg + offsetof(struct hfi1_tid_info , length); +if (copy_to_user ((void __user *)addr, &tinfo.length,sizeof (tinfo.length))) ret = -EFAULT ; }
--
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 44 lines · Dennis Dalessandro
Hi Doug,
Here is a set of patches for 4.14. These apply on top of the others I have sent
previously. This fixes some performance centric bugs like using write combining
for bar0 mapping and a fix for not starving an iowait list. There are also a few
patches related to improving the code involving user contexts. A bug to fix
sending MAD traps until repressed is also included as well as some general code
cleanups.Patches can can also be found in my GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.14---
Alex Estrin (1):
IB/hfi1: Verify port data VLs credits on transition to ArmedBartlomiej Dudek (1):
IB/hfi1: Move saving PCI values to a separate functionByczkowski, Jakub (1):
IB/hfi1: Fix initialization failure for debug firmwareJan Sokolowski (1):
IB/hfi1: Fix code consistency for if/else blocks inchip.cKaike Wan (1):
IB/hfi1: Serve the most starved iowait entry firstMichael J. Ruhl (7):
IB/hfi1: Assign context does not clean up file descriptor
correctly on error
IB/hfi1: Remove unused user context data members IB/hfi1: Size rcd array index correctly and consistently IB/hfi1: Use context pointer rather than context index IB/hfi1: Pass the context pointer rather than the index IB/hfi1: Send MAD traps until repressed IB/hfi1: Splitcopy_to_userdata copy for better security
Quoted 2 lines
Mike Marciniszyn (1):
IB/hfi1: Fix bar0 mapping to use write combining
Series applied, thanks.
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