提交 a75895b1 编写于 作者: A Andrew Boyer 提交者: Doug Ledford

RDMA/i40iw: Avoid panic when objects are being created and destroyed

A panic occurs when there is a newly-registered element on the QP/CQ MR
list waiting to be attached, but a different MR is deregistered. The
current code only checks for whether the list is empty, not whether the
element being deregistered is actually on the list.

Fix the panic by adding a boolean to track if the object is on the list.

Fixes: d3749841 ("i40iw: add files for iwarp interface")
Signed-off-by: NAndrew Boyer <andrew.boyer@dell.com>
Reviewed-by: NShiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 a0403be8
...@@ -394,6 +394,7 @@ static struct i40iw_pbl *i40iw_get_pbl(unsigned long va, ...@@ -394,6 +394,7 @@ static struct i40iw_pbl *i40iw_get_pbl(unsigned long va,
list_for_each_entry(iwpbl, pbl_list, list) { list_for_each_entry(iwpbl, pbl_list, list) {
if (iwpbl->user_base == va) { if (iwpbl->user_base == va) {
iwpbl->on_list = false;
list_del(&iwpbl->list); list_del(&iwpbl->list);
return iwpbl; return iwpbl;
} }
...@@ -1898,6 +1899,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd, ...@@ -1898,6 +1899,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd,
goto error; goto error;
spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags); spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags);
list_add_tail(&iwpbl->list, &ucontext->qp_reg_mem_list); list_add_tail(&iwpbl->list, &ucontext->qp_reg_mem_list);
iwpbl->on_list = true;
spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags); spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags);
break; break;
case IW_MEMREG_TYPE_CQ: case IW_MEMREG_TYPE_CQ:
...@@ -1908,6 +1910,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd, ...@@ -1908,6 +1910,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd,
spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags); spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
list_add_tail(&iwpbl->list, &ucontext->cq_reg_mem_list); list_add_tail(&iwpbl->list, &ucontext->cq_reg_mem_list);
iwpbl->on_list = true;
spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags); spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags);
break; break;
case IW_MEMREG_TYPE_MEM: case IW_MEMREG_TYPE_MEM:
...@@ -2045,14 +2048,18 @@ static void i40iw_del_memlist(struct i40iw_mr *iwmr, ...@@ -2045,14 +2048,18 @@ static void i40iw_del_memlist(struct i40iw_mr *iwmr,
switch (iwmr->type) { switch (iwmr->type) {
case IW_MEMREG_TYPE_CQ: case IW_MEMREG_TYPE_CQ:
spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags); spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
if (!list_empty(&ucontext->cq_reg_mem_list)) if (iwpbl->on_list) {
iwpbl->on_list = false;
list_del(&iwpbl->list); list_del(&iwpbl->list);
}
spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags); spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags);
break; break;
case IW_MEMREG_TYPE_QP: case IW_MEMREG_TYPE_QP:
spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags); spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags);
if (!list_empty(&ucontext->qp_reg_mem_list)) if (iwpbl->on_list) {
iwpbl->on_list = false;
list_del(&iwpbl->list); list_del(&iwpbl->list);
}
spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags); spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags);
break; break;
default: default:
......
...@@ -78,6 +78,7 @@ struct i40iw_pbl { ...@@ -78,6 +78,7 @@ struct i40iw_pbl {
}; };
bool pbl_allocated; bool pbl_allocated;
bool on_list;
u64 user_base; u64 user_base;
struct i40iw_pble_alloc pble_alloc; struct i40iw_pble_alloc pble_alloc;
struct i40iw_mr *iwmr; struct i40iw_mr *iwmr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册