IB/hfi1: Another round of fixes
Subsystems (2)
cover IB/hfi1: Another round of fixes
Doug,
Here is another set of mostly small fixes. I think it could go in the RC, but if not I can respin for next.
Can also be found in GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.9
---
Dasaratharaman Chandramouli (1):
IB/hfi1: Fix ECN processing in prescan_rxq
Dennis Dalessandro (1):
IB/hfi1: Remove incorrect IS_ERR check
Jakub Pawlak (1):
IB/hfi1: Fix status error code for unsupported packets
Jianxin Xiong (1):
IB/hfi1: Prevent hardware counter names from being cut off
Krzysztof Blaszkowski (1):
IB/hfi1: Relocate rcvhdrcnt module parameter check.
Sebastian Sanchez (2):
IB/hfi1: Get rid of divide in pio buffer allocator IB/hfi1: Optimize pio_buf and send_context structs
drivers/infiniband/hw/hfi1/chip.c | 2 + drivers/infiniband/hw/hfi1/chip.h | 3 ++ drivers/infiniband/hw/hfi1/driver.c | 37 +++++++++++++++++++-------- drivers/infiniband/hw/hfi1/init.c | 44 +++++++++++++++++++------------- drivers/infiniband/hw/hfi1/pio.c | 16 +++++++----- drivers/infiniband/hw/hfi1/pio.h | 30 ++++++++++++---------- drivers/infiniband/hw/hfi1/pio_copy.c | 22 ++++++++-------- drivers/infiniband/hw/hfi1/user_sdma.c | 2 + 8 files changed, 93 insertions(+), 63 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
PATCH 1/7 IB/hfi1: Relocate rcvhdrcnt module parameter check.
In reply to a message not in the archiveFrom: Krzysztof Blaszkowski <[email protected]>
Validate the rcvhdrcnt module parameter in a single function at module load time. This allows proper error reporting.
--- drivers/infiniband/hw/hfi1/init.c | 44 ++++++++++++++++++++++--------------- 1 files changed, 26 insertions(+), 18 deletions(-)
drivers/infiniband/hw/hfi1/init.c +26 -18
@@ -262,13 +262,6 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt, } rcd->eager_base = base * dd->rcv_entries.group_size; -/* Validate and initialize Rcv Hdr Q variables */ -if (rcvhdrcnt %HDRQ_INCREMENT ) { -dd_dev_err (dd, -"ctxt%u: header queue count %d must be divisible by %lu\n" , - rcd->ctxt, rcvhdrcnt,HDRQ_INCREMENT ); - goto bail; - } rcd->rcvhdrq_cnt = rcvhdrcnt; rcd->rcvhdrqentsize = hfi1_hdrq_entsize;/*
@@ -1399,6 +1392,29 @@ static void postinit_cleanup(struct hfi1_devdata *dd)hfi1_free_devdata (dd); } +static int init_validate_rcvhdrcnt (struct device *dev,uint thecnt) +{ +if (thecnt <=HFI1_MIN_HDRQ_EGRBUF_CNT ) { +hfi1_early_err (dev,"Receive header queue count too small\n" ); +return -EINVAL ; + } + +if (thecnt >HFI1_MAX_HDRQ_EGRBUF_CNT ) { +hfi1_early_err (dev, +"Receive header queue count cannot be greater than %u\n" , +HFI1_MAX_HDRQ_EGRBUF_CNT ); +return -EINVAL ; + } + +if (thecnt %HDRQ_INCREMENT ) { +hfi1_early_err (dev,"Receive header queue count %d must be divisible by %lu\n" , + thecnt,HDRQ_INCREMENT ); +return -EINVAL ; + } + +return 0 ; +} +static int init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {int ret =0 , j, pidx, initfail;
@@ -1409,18 +1425,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)HFI1_CAP_LOCK ();/* Validate some global module parameters */ -if (rcvhdrcnt <=HFI1_MIN_HDRQ_EGRBUF_CNT ) { -hfi1_early_err (&pdev->dev,"Header queue count too small\n" ); - ret = -EINVAL ; - goto bail; - } -if (rcvhdrcnt >HFI1_MAX_HDRQ_EGRBUF_CNT ) { -hfi1_early_err (&pdev->dev, -"Receive header queue count cannot be greater than %u\n" , -HFI1_MAX_HDRQ_EGRBUF_CNT ); - ret = -EINVAL ; + ret =init_validate_rcvhdrcnt (&pdev->dev, rcvhdrcnt); +if (ret) goto bail; - } +/* use the encoding function as a sanitization check */ if (!encode_rcv_header_entry_size (hfi1_hdrq_entsize)) { hfi1_early_err(&pdev->dev, "Invalid HdrQ Entry size %u\n",
--
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/7 IB/hfi1: Fix status error code for unsupported packets
In reply to a message not in the archiveFrom: Jakub Pawlak <[email protected]>
Set the status code BAD_L2 when unsupported type of packet is received and dropped.
--- drivers/infiniband/hw/hfi1/chip.h | 3 +++ drivers/infiniband/hw/hfi1/driver.c | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/chip.h +3 -0
@@ -320,6 +320,9 @@/* DC_DC8051_CFG_MODE.GENERAL bits */ #define DISABLE_SELF_GUID_CHECK 0x2 +/* Bad L2 frame error code */ +#define BAD_L2_ERR 0x6 +/* * Eager buffer minimum and maximum sizes supported by the hardware. * All power-of-two sizes in between are supported as well.
drivers/infiniband/hw/hfi1/driver.c +15 -2
@@ -1360,12 +1360,25 @@ int process_receive_ib(struct hfi1_packet *packet)int process_receive_bypass (struct hfi1_packet *packet) { +struct hfi1_devdata *dd = packet->rcd->dd; +if (unlikely (rhf_err_flags (packet->rhf)))handle_eflags (packet); -dd_dev_err (packet->rcd->dd, +dd_dev_err (dd,"Bypass packets are not supported in normal operation. Dropping\n" ); -incr_cntr64 (&packet->rcd->dd->sw_rcv_bypass_packet_errors); +incr_cntr64 (&dd->sw_rcv_bypass_packet_errors); +if (!(dd->err_info_rcvport.status_and_code &OPA_EI_STATUS_SMASK )) { +u64 *flits = packet->ebuf; + +if (flits && !(packet->rhf &RHF_LEN_ERR )) { + dd->err_info_rcvport.packet_flit1 = flits[0 ]; + dd->err_info_rcvport.packet_flit2 = + packet->tlen >sizeof (flits[0 ]) ? flits[1 ] :0 ; + } + dd->err_info_rcvport.status_and_code |= + (OPA_EI_STATUS_SMASK |BAD_L2_ERR ); + }return RHF_RCV_CONTINUE ; }
--
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/7 IB/hfi1: Fix ECN processing in prescan_rxq
In reply to a message not in the archiveFrom: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
When processing ECN via the prescan_rxq path, some fields in the packet structure are passed uninitialized. This can potentially cause NULL pointer exceptions during ECN handling.
--- drivers/infiniband/hw/hfi1/driver.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
drivers/infiniband/hw/hfi1/driver.c +11 -9
@@ -599,7 +599,6 @@ static void __prescan_rxq(struct hfi1_packet *packet) dd->rhf_offset;struct rvt_qp *qp;struct ib_header *hdr; -struct ib_other_headers *ohdr;struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;u64 rhf =rhf_to_cpu (rhf_addr);u32 etype =rhf_rcv_type (rhf), qpn, bth1;
@@ -615,18 +614,21 @@ static void __prescan_rxq(struct hfi1_packet *packet)if (etype !=RHF_RCV_TYPE_IB ) goto next; - hdr =hfi1_get_msgheader (dd, rhf_addr); + packet->hdr =hfi1_get_msgheader (dd, rhf_addr); + hdr = packet->hdr; lnh =be16_to_cpu (hdr->lrh[0 ]) &3 ; -if (lnh ==HFI1_LRH_BTH ) - ohdr = &hdr->u.oth; -else if (lnh ==HFI1_LRH_GRH ) - ohdr = &hdr->u.l.oth; -else +if (lnh ==HFI1_LRH_BTH ) { + packet->ohdr = &hdr->u.oth; + }else if (lnh ==HFI1_LRH_GRH ) { + packet->ohdr = &hdr->u.l.oth; + packet->rcv_flags |=HFI1_HAS_GRH ; + }else { goto next;/* just in case */ + } - bth1 =be32_to_cpu (ohdr->bth[1 ]); + bth1 =be32_to_cpu (packet->ohdr->bth[1 ]); is_ecn = !!(bth1 & (HFI1_FECN_SMASK |HFI1_BECN_SMASK ));if (!is_ecn)
@@ -646,7 +648,7 @@ static void __prescan_rxq(struct hfi1_packet *packet)/* turn off BECN, FECN */ bth1 &= ~(HFI1_FECN_SMASK |HFI1_BECN_SMASK ); - ohdr->bth[1 ] =cpu_to_be32 (bth1); + packet->ohdr->bth[1 ] =cpu_to_be32 (bth1); next:update_ps_mdata (&mdata, rcd); }
--
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/7 IB/hfi1: Get rid of divide in pio buffer allocator
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
The div instruction shows costly in profiles.
--- drivers/infiniband/hw/hfi1/pio.c | 11 +++++++---- drivers/infiniband/hw/hfi1/pio.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/pio.c +7 -4
@@ -1242,6 +1242,7 @@ int sc_enable(struct send_context *sc) sc->free =0 ; sc->alloc_free =0 ; sc->fill =0 ; + sc->fill_wrap =0 ; sc->sr_head =0 ; sc->sr_tail =0 ; sc->flags =0 ;
@@ -1385,7 +1386,7 @@ struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len,unsigned long flags;unsigned long avail;unsigned long blocks =dwords_to_blocks (dw_len); -unsigned long start_fill; +u32 fill_wrap;int trycount =0 ;u32 head, next;
@@ -1428,8 +1429,11 @@ retry: head = sc->sr_head;/* "allocate" the buffer */ - start_fill = sc->fill; sc->fill += blocks; + fill_wrap = sc->fill_wrap; + sc->fill_wrap += blocks; +if (sc->fill_wrap >= sc->credits) + sc->fill_wrap = sc->fill_wrap - sc->credits;/* * Fill the parts that the releaser looks at before moving the head.
@@ -1458,8 +1462,7 @@ retry:spin_unlock_irqrestore (&sc->alloc_lock, flags);/* finish filling in the buffer outside the lock */ - pbuf->start = sc->base_addr + ((start_fill % sc->credits) - *PIO_BLOCK_SIZE ); + pbuf->start = sc->base_addr + fill_wrap *PIO_BLOCK_SIZE ; pbuf->size = sc->credits *PIO_BLOCK_SIZE ; pbuf->end = sc->base_addr + pbuf->size; pbuf->block_count = blocks;
drivers/infiniband/hw/hfi1/pio.h +1 -0
@@ -119,6 +119,7 @@ struct send_context {unsigned long fill;/* official alloc count */ unsigned long alloc_free;/* copy of free (less cache thrash) */ u32 __percpu *buffers_allocated;/* count of buffers allocated */ +u32 fill_wrap;/* tracks fill within ring */ /* releaser fields */ spinlock_t release_lock____cacheline_aligned_in_smp ;u32 sr_tail;/* shadow ring tail */
--
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/7 IB/hfi1: Optimize pio_buf and send_context structs
In reply to a message not in the archiveFrom: Sebastian Sanchez <[email protected]>
Both pio_buf and send_context structs have oversized fields and have cachelines that can be optimized.
Reduce oversized fields for both structs.
Make sure pio_buf struct fits within a cacheline.
Move read-only fields to their own cacheline insend_context struct.
All of this will avoid cacheline trading as the ring progresses and pio buffers/send contexts are used.
--- drivers/infiniband/hw/hfi1/pio.c | 5 ++--- drivers/infiniband/hw/hfi1/pio.h | 29 +++++++++++++++-------------- drivers/infiniband/hw/hfi1/pio_copy.c | 22 +++++++++++----------- 3 files changed, 28 insertions(+), 28 deletions(-)
drivers/infiniband/hw/hfi1/pio.c +2 -3
@@ -758,6 +758,7 @@ struct send_context *sc_alloc(struct hfi1_devdata *dd, int type, sc->hw_context = hw_context;cr_group_addresses (sc, &dma); sc->credits = sci->credits; + sc->size = sc->credits *PIO_BLOCK_SIZE ;/* PIO Send Memory Address details */ #define PIO_ADDR_CONTEXT_MASK 0xfful
@@ -1463,9 +1464,7 @@ retry:/* finish filling in the buffer outside the lock */ pbuf->start = sc->base_addr + fill_wrap *PIO_BLOCK_SIZE ; - pbuf->size = sc->credits *PIO_BLOCK_SIZE ; - pbuf->end = sc->base_addr + pbuf->size; - pbuf->block_count = blocks; + pbuf->end = sc->base_addr + sc->size; pbuf->qw_written =0 ; pbuf->carry_bytes =0 ; pbuf->carry.val64 =0 ;
drivers/infiniband/hw/hfi1/pio.h +15 -14
@@ -83,43 +83,43 @@ struct pio_buf {void *arg;/* argument for cb */ void __iomem *start;/* buffer start address */ void __iomem *end;/* context end address */ -unsigned long size;/* context size, in bytes */ unsigned long sent_at;/* buffer is sent when <= free */ -u32 block_count;/* size of buffer, in blocks */ -u32 qw_written;/* QW written so far */ -u32 carry_bytes;/* number of valid bytes in carry */ union mix carry;/* pending unwritten bytes */ +u16 qw_written;/* QW written so far */ +u8 carry_bytes;/* number of valid bytes in carry */ };/* cache line aligned pio buffer array */ union pio_shadow_ring {struct pio_buf pbuf; -u64 unused[16 ];/* cache line spacer */ }____cacheline_aligned ;/* per-NUMA send context */ struct send_context {/* read-only after init */ struct hfi1_devdata *dd;/* device */ -void __iomem *base_addr;/* start of PIO memory */ union pio_shadow_ring *sr;/* shadow ring */ +void __iomem *base_addr;/* start of PIO memory */ +u32 __percpu *buffers_allocated;/* count of buffers allocated */ +u32 size;/* context size, in bytes */ -struct work_struct halt_work;/* halted context work queue entry */ -unsigned long flags;/* flags */ int node;/* context home node */ -int type;/* context type */ -u32 sw_index;/* software index number */ -u32 hw_context;/* hardware context number */ -u32 credits;/* number of blocks in context */ u32 sr_size;/* size of the shadow ring */ -u32 group;/* credit return group */ +u16 flags;/* flags */ +u8 type;/* context type */ +u8 sw_index;/* software index number */ +u8 hw_context;/* hardware context number */ +u8 group;/* credit return group */ +/* allocator fields */ spinlock_t alloc_lock____cacheline_aligned_in_smp ;u32 sr_head;/* shadow ring head */ unsigned long fill;/* official alloc count */ unsigned long alloc_free;/* copy of free (less cache thrash) */ -u32 __percpu *buffers_allocated;/* count of buffers allocated */ u32 fill_wrap;/* tracks fill within ring */ +u32 credits;/* number of blocks in context */ +/* adding a new field here would make it part of this cacheline */ +/* releaser fields */ spinlock_t release_lock____cacheline_aligned_in_smp ;u32 sr_tail;/* shadow ring tail */
@@ -131,6 +131,7 @@ struct send_context {u32 credit_intr_count;/* count of credit intr users */ u64 credit_ctrl;/* cache for credit control */ wait_queue_head_t halt_wait;/* wait until kernel sees interrupt */ +struct work_struct halt_work;/* halted context work queue entry */ };/* send context flags */
drivers/infiniband/hw/hfi1/pio_copy.c +11 -11
@@ -129,8 +129,8 @@ void pio_copy(struct hfi1_devdata *dd, struct pio_buf *pbuf, u64 pbc, dest +=sizeof (u64); } - dest -= pbuf->size; - dend -= pbuf->size; + dest -= pbuf->sc->size; + dend -= pbuf->sc->size; }/* write 8-byte non-SOP, non-wrap chunk data */
@@ -361,8 +361,8 @@ void seg_pio_copy_start(struct pio_buf *pbuf, u64 pbc, dest +=sizeof (u64); } - dest -= pbuf->size; - dend -= pbuf->size; + dest -= pbuf->sc->size; + dend -= pbuf->sc->size; }/* write 8-byte non-SOP, non-wrap chunk data */
@@ -458,8 +458,8 @@ static void mid_copy_mix(struct pio_buf *pbuf, const void *from, size_t nbytes) dest +=sizeof (u64); } - dest -= pbuf->size; - dend -= pbuf->size; + dest -= pbuf->sc->size; + dend -= pbuf->sc->size; }/* write 8-byte non-SOP, non-wrap chunk data */
@@ -492,7 +492,7 @@ static void mid_copy_mix(struct pio_buf *pbuf, const void *from, size_t nbytes)*/ /* adjust if we have wrapped */ if (dest >= pbuf->end) - dest -= pbuf->size; + dest -= pbuf->sc->size;/* jump to the SOP range if within the first block */ else if (pbuf->qw_written <PIO_BLOCK_QWS ) dest +=SOP_DISTANCE ;
@@ -584,8 +584,8 @@ static void mid_copy_straight(struct pio_buf *pbuf, dest +=sizeof (u64); } - dest -= pbuf->size; - dend -= pbuf->size; + dest -= pbuf->sc->size; + dend -= pbuf->sc->size; }/* write 8-byte non-SOP, non-wrap chunk data */
@@ -666,7 +666,7 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes)*/ /* adjust if we've wrapped */ if (dest >= pbuf->end) - dest -= pbuf->size; + dest -= pbuf->sc->size;/* jump to SOP range if within the first block */ else if (pbuf->qw_written <PIO_BLOCK_QWS ) dest +=SOP_DISTANCE ;
@@ -719,7 +719,7 @@ void seg_pio_copy_end(struct pio_buf *pbuf)*/ /* adjust if we have wrapped */ if (dest >= pbuf->end) - dest -= pbuf->size; + dest -= pbuf->sc->size;/* jump to the SOP range if within the first block */ else if (pbuf->qw_written <PIO_BLOCK_QWS ) dest +=SOP_DISTANCE ;
--
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/7 IB/hfi1: Prevent hardware counter names from being cut off
In reply to a message not in the archiveFrom: Jianxin Xiong <[email protected]>
Increase the size of the buffer that is used to construct per-VL and per-SDMA counter names.
--- drivers/infiniband/hw/hfi1/chip.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +1 -1
@@ -12098,7 +12098,7 @@ static void update_synth_timer(unsigned long opaque)mod_timer (&dd->synth_stats_timer, jiffies +HZ *SYNTH_CNT_TIME ); } -#define C_MAX_NAME 13/* 12 chars + one for /0 */ +#define C_MAX_NAME 16/* 15 chars + one for /0 */ static int init_cntrs (struct hfi1_devdata *dd) {int i, rcv_ctxts, j;
--
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/7 IB/hfi1: Remove incorrect IS_ERR check
In reply to a message not in the archiveRemove IS_ERR check from caching code as the function being called does not actually return error pointers.
--- drivers/infiniband/hw/hfi1/user_sdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/user_sdma.c +1 -1
@@ -1144,7 +1144,7 @@ static int pin_vector_pages(struct user_sdma_request *req, rb_node =hfi1_mmu_rb_extract (pq->handler, (unsigned long )iovec->iov.iov_base, iovec->iov.iov_len); -if (rb_node && !IS_ERR (rb_node)) +if (rb_node) node = container_of(rb_node, struct sdma_mmu_node, rb);else rb_node =NULL ;
--
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