i40iw: Fixes for i40iw
cover i40iw: Fixes for i40iw
The following patch series has fixes for the i40iw driver.
Mustafa Ismail (4):
i40iw: Fix double free of QP
i40iw: Fix memory leak in CQP destroy when in reset
i40iw: Assign MSS only when it is a new MTU
i40iw: Fix incorrect check for error
Shiraz Saleem (2):
i40iw: Fix QP flush to not hang on empty queues or failure
i40iw: Fix race condition in terminate timer's handler
drivers/infiniband/hw/i40iw/i40iw.h | 11 +++++++---- drivers/infiniband/hw/i40iw/i40iw_cm.c | 22 +++++++++++++++++----- drivers/infiniband/hw/i40iw/i40iw_hw.c | 30 +++++++++++++++++++++++++++--- drivers/infiniband/hw/i40iw/i40iw_main.c | 11 +++++------ drivers/infiniband/hw/i40iw/i40iw_puda.c | 2 +- drivers/infiniband/hw/i40iw/i40iw_utils.c | 5 ++++- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- 7 files changed, 62 insertions(+), 21 deletions(-)
Signature · 6 lines
2.8.3 -- 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/6 i40iw: Fix double free of QP
In reply to a message not in the archiveFrom: Mustafa Ismail <[email protected]>
A QP can be double freed if i40iw_cm_disconn() is called while it is currently being freed by i40iw_rem_ref(). The fix in i40iw_cm_disconn() will first check if the QP is already freed before making another request for the QP to be freed.
--- drivers/infiniband/hw/i40iw/i40iw.h | 2 +- drivers/infiniband/hw/i40iw/i40iw_cm.c | 20 ++++++++++++++++---- drivers/infiniband/hw/i40iw/i40iw_hw.c | 4 +++- 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/infiniband/hw/i40iw/i40iw.h +1 -1
@@ -512,7 +512,7 @@ u32 i40iw_initialize_hw_resources(struct i40iw_device *iwdev);int i40iw_register_rdma_device (struct i40iw_device *iwdev);void i40iw_port_ibevent (struct i40iw_device *iwdev); -int i40iw_cm_disconn (struct i40iw_qp *); +void i40iw_cm_disconn (struct i40iw_qp *iwqp);void i40iw_cm_disconn_worker (void *);int mini_cm_recv_pkt (struct i40iw_cm_core *,struct i40iw_device *,struct sk_buff *);
drivers/infiniband/hw/i40iw/i40iw_cm.c +16 -4
@@ -3359,21 +3359,33 @@ static void i40iw_cm_init_tsa_conn(struct i40iw_qp *iwqp,* i40iw_cm_disconn - when a connection is being closed * @iwqp: associate qp for the connection */ -int i40iw_cm_disconn (struct i40iw_qp *iwqp) +void i40iw_cm_disconn (struct i40iw_qp *iwqp) {struct disconn_work *work;struct i40iw_device *iwdev = iwqp->iwdev;struct i40iw_cm_core *cm_core = &iwdev->cm_core; +unsigned long flags; work =kzalloc (sizeof (*work),GFP_ATOMIC );if (!work) -return -ENOMEM ;/* Timer will clean up */ - +return ;/* Timer will clean up */ + +spin_lock_irqsave (&iwdev->qptable_lock, flags); +if (!iwdev->qp_table[iwqp->ibqp.qp_num]) { +spin_unlock_irqrestore (&iwdev->qptable_lock, flags); +i40iw_debug (&iwdev->sc_dev,I40IW_DEBUG_CM , +"%s qp_id %d is already freed\n" , + __func__, iwqp->ibqp.qp_num); +kfree (work); +return ; + }i40iw_add_ref (&iwqp->ibqp); +spin_unlock_irqrestore (&iwdev->qptable_lock, flags); + work->iwqp = iwqp;INIT_WORK (&work->work, i40iw_disconnect_worker);queue_work (cm_core->disconn_wq, &work->work); -return 0 ; +return ; }/**
drivers/infiniband/hw/i40iw/i40iw_hw.c +3 -1
@@ -308,7 +308,9 @@ void i40iw_process_aeq(struct i40iw_device *iwdev) iwqp = iwdev->qp_table[info->qp_cq_id];if (!iwqp) {spin_unlock_irqrestore (&iwdev->qptable_lock, flags); -i40iw_pr_err ("qp_id %d is already freed\n" , info->qp_cq_id); +i40iw_debug (dev,I40IW_DEBUG_AEQ , +"%s qp_id %d is already freed\n" , + __func__, info->qp_cq_id);continue ; }i40iw_add_ref (&iwqp->ibqp);
Signature · 6 lines
2.8.3 -- 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/6 i40iw: Fix QP flush to not hang on empty queues or failure
In reply to a message not in the archiveFrom: Shiraz Saleem <[email protected]>
When flush QP and there are no pending work requests, signal completion to unblock i40iw_drain_sq and i40iw_drain_rq which are waiting on completion for iwqp->sq_drained and iwqp->sq_drained respectively. Also, signal completion if flush QP fails to prevent the drain SQ or RQ from being blocked indefintely.
--- drivers/infiniband/hw/i40iw/i40iw.h | 9 ++++++--- drivers/infiniband/hw/i40iw/i40iw_hw.c | 26 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-)
drivers/infiniband/hw/i40iw/i40iw.h +6 -3
@@ -112,9 +112,12 @@#define I40IW_DRV_OPT_MCAST_LOGPORT_MAP 0x00000800#define IW_HMC_OBJ_TYPE_NUM ARRAY_SIZE(iw_hmc_obj_types) -#define IW_CFG_FPM_QP_COUNT 32768 -#define I40IW_MAX_PAGES_PER_FMR 512 -#define I40IW_MIN_PAGES_PER_FMR 1 +#define IW_CFG_FPM_QP_COUNT 32768 +#define I40IW_MAX_PAGES_PER_FMR 512 +#define I40IW_MIN_PAGES_PER_FMR 1 +#define I40IW_CQP_COMPL_RQ_WQE_FLUSHED 2 +#define I40IW_CQP_COMPL_SQ_WQE_FLUSHED 3 +#define I40IW_CQP_COMPL_RQ_SQ_WQE_FLUSHED 4#define I40IW_MTU_TO_MSS 40#define I40IW_DEFAULT_MSS 1460
drivers/infiniband/hw/i40iw/i40iw_hw.c +24 -2
@@ -622,6 +622,7 @@ enum i40iw_status_code i40iw_hw_flush_wqes(struct i40iw_device *iwdev,struct i40iw_qp_flush_info *hw_info;struct i40iw_cqp_request *cqp_request;struct cqp_commands_info *cqp_info; +struct i40iw_qp *iwqp = (struct i40iw_qp *)qp->back_qp; cqp_request =i40iw_get_cqp_request (&iwdev->cqp, wait);if (!cqp_request)
@@ -636,9 +637,30 @@ enum i40iw_status_code i40iw_hw_flush_wqes(struct i40iw_device *iwdev, cqp_info->in.u.qp_flush_wqes.qp = qp; cqp_info->in.u.qp_flush_wqes.scratch = (uintptr_t )cqp_request; status =i40iw_handle_cqp_op (iwdev, cqp_request); -if (status) +if (status) {i40iw_pr_err ("CQP-OP Flush WQE's fail" ); -return status; +complete (&iwqp->sq_drained); +complete (&iwqp->rq_drained); +return status; + } +if (!cqp_request->compl_info.maj_err_code) { +switch (cqp_request->compl_info.min_err_code) { +case I40IW_CQP_COMPL_RQ_WQE_FLUSHED : +complete (&iwqp->sq_drained); +break ; +case I40IW_CQP_COMPL_SQ_WQE_FLUSHED : +complete (&iwqp->rq_drained); +break ; +case I40IW_CQP_COMPL_RQ_SQ_WQE_FLUSHED : +break ; +default : +complete (&iwqp->sq_drained); +complete (&iwqp->rq_drained); +break ; + } + } + +return 0 ; }/**
Signature · 6 lines
2.8.3 -- 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/6 i40iw: Fix memory leak in CQP destroy when in reset
In reply to a message not in the archiveFrom: Mustafa Ismail <[email protected]>
On a device close, the control QP (CQP) is destroyed by calling cqp_destroy which destroys the CQP and frees its SD buffer memory. However, if the reset flag is true, cqp_destroy is never called and leads to a memory leak on SD buffer memory. Fix this by always calling cqp_destroy, on device close, regardless of reset. The exception to this when CQP create fails. In this case, the SD buffer memory is already freed on an error check and there is no need to call cqp_destroy.
--- drivers/infiniband/hw/i40iw/i40iw_main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_main.c +3 -6
@@ -237,14 +237,11 @@ static irqreturn_t i40iw_irq_handler(int irq, void *data)*/ static void i40iw_destroy_cqp (struct i40iw_device *iwdev,bool free_hwcqp) { -enum i40iw_status_code status =0 ;struct i40iw_sc_dev *dev = &iwdev->sc_dev;struct i40iw_cqp *cqp = &iwdev->cqp; -if (free_hwcqp && dev->cqp_ops->cqp_destroy) - status = dev->cqp_ops->cqp_destroy (dev->cqp); -if (status) -i40iw_pr_err ("destroy cqp failed" ); +if (free_hwcqp) + dev->cqp_ops->cqp_destroy (dev->cqp);i40iw_free_dma_mem (dev->hw, &cqp->sq);kfree (cqp->scratch_array);
@@ -1475,7 +1472,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset)i40iw_del_hmc_objects (dev, dev->hmc_info, true, reset);/* fallthrough */ case CQP_CREATED : -i40iw_destroy_cqp (iwdev, !reset); +i40iw_destroy_cqp (iwdev, true);/* fallthrough */ case INITIAL_STATE :i40iw_cleanup_cm_core (&iwdev->cm_core);
Signature · 6 lines
2.8.3 -- 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/6 i40iw: Fix race condition in terminate timer's handler
In reply to a message not in the archiveFrom: Shiraz Saleem <[email protected]>
Add a QP reference when terminate timer is started to ensure the destroy QP doesn't race ahead to free the QP while it is being referenced in the terminate timer's handler.
--- drivers/infiniband/hw/i40iw/i40iw_cm.c | 2 +- drivers/infiniband/hw/i40iw/i40iw_utils.c | 5 ++++- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_cm.c +1 -1
@@ -3471,7 +3471,7 @@ static void i40iw_cm_disconn_true(struct i40iw_qp *iwqp)*terminate-handler to issue cm_disconn which can re-free *a QP even after its refcnt=0. */ -del_timer (&iwqp->terminate_timer); +i40iw_terminate_del_timer (qp);if (!iwqp->flush_issued) { iwqp->flush_issued =1 ; issue_flush =1 ;
drivers/infiniband/hw/i40iw/i40iw_utils.c +4 -1
@@ -823,6 +823,7 @@ static void i40iw_terminate_timeout(unsigned long context)struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)&iwqp->sc_qp;i40iw_terminate_done (qp,1 ); +i40iw_rem_ref (&iwqp->ibqp); }/**
@@ -834,6 +835,7 @@ void i40iw_terminate_start_timer(struct i40iw_sc_qp *qp)struct i40iw_qp *iwqp; iwqp = (struct i40iw_qp *)qp->back_qp; +i40iw_add_ref (&iwqp->ibqp);init_timer (&iwqp->terminate_timer); iwqp->terminate_timer.function = i40iw_terminate_timeout; iwqp->terminate_timer.expires = jiffies +HZ ;
@@ -850,7 +852,8 @@ void i40iw_terminate_del_timer(struct i40iw_sc_qp *qp)struct i40iw_qp *iwqp; iwqp = (struct i40iw_qp *)qp->back_qp; -del_timer (&iwqp->terminate_timer); +if (del_timer (&iwqp->terminate_timer)) +i40iw_rem_ref (&iwqp->ibqp); }/**
drivers/infiniband/hw/i40iw/i40iw_verbs.c +1 -1
@@ -959,7 +959,7 @@ int i40iw_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, goto exit; }if (iwqp->sc_qp.term_flags) -del_timer (&iwqp->terminate_timer); +i40iw_terminate_del_timer (&iwqp->sc_qp); info.next_iwarp_state =I40IW_QP_STATE_ERROR ; if ((iwqp->hw_tcp_state > I40IW_TCP_STATE_CLOSED) && iwdev->iw_status &&
Signature · 6 lines
2.8.3 -- 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/6 i40iw: Assign MSS only when it is a new MTU
In reply to a message not in the archiveFrom: Mustafa Ismail <[email protected]>
Currently we are changing the MSS regardless of whether there is a change or not in MTU. Fix to make the assignment of MSS dependent on an MTU change.
--- drivers/infiniband/hw/i40iw/i40iw_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/i40iw/i40iw_main.c +2 -0
@@ -1724,6 +1724,8 @@ static void i40iw_l2param_change(struct i40e_info *ldev, struct i40e_client *clifor (i =0 ; i <I40E_CLIENT_MAX_USER_PRIORITY ; i++) l2params->qs_handle_list[i] = params->qos.prio_qos[i].qs_handle; + l2params->mss = (params->mtu) ? params->mtu -I40IW_MTU_TO_MSS : iwdev->mss; +INIT_WORK (&work->work, i40iw_l2params_worker);queue_work (iwdev->param_wq, &work->work); }
Signature · 6 lines
2.8.3 -- 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/6 i40iw: Fix incorrect check for error
In reply to a message not in the archiveFrom: Mustafa Ismail <[email protected]>
In i40iw_ieq_handle_partial() the check for !status is incorrect.
--- drivers/infiniband/hw/i40iw/i40iw_puda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/i40iw/i40iw_puda.c +1 -1
@@ -1132,7 +1132,7 @@ static enum i40iw_status_code i40iw_ieq_handle_partial(struct i40iw_puda_rsrc *ilist_add (&buf->list, &pbufl); status =i40iw_ieq_create_pbufl (pfpdu, rxlist, &pbufl, buf, fpdu_len); -if (!status) +if (status) goto error; txbuf =i40iw_puda_get_bufpool (ieq);
Signature · 6 lines
2.8.3 -- 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 12 lines · Henry Orosco
The following patch series has fixes for the i40iw driver.
Mustafa Ismail (4):
i40iw: Fix double free of QP
i40iw: Fix memory leak in CQP destroy when in reset
i40iw: Assign MSS only when it is a new MTU
i40iw: Fix incorrect check for errorShiraz Saleem (2):
i40iw: Fix QP flush to not hang on empty queues or failure
i40iw: Fix race condition in terminate timer's handler
Quoted 9 lines
drivers/infiniband/hw/i40iw/i40iw.h | 11 +++++++---- drivers/infiniband/hw/i40iw/i40iw_cm.c | 22 +++++++++++++++++----- drivers/infiniband/hw/i40iw/i40iw_hw.c | 30 +++++++++++++++++++++++++++--- drivers/infiniband/hw/i40iw/i40iw_main.c | 11 +++++------ drivers/infiniband/hw/i40iw/i40iw_puda.c | 2 +- drivers/infiniband/hw/i40iw/i40iw_utils.c | 5 ++++- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- 7 files changed, 62 insertions(+), 21 deletions(-)
Series applied, thanks.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD