driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9QO9C
----------------------------------------------------------------------
ucontext list does not work in an atomic context, so there is no need to use a spinlock for protection.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_debugfs.c | 6 ++---- drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- drivers/infiniband/hw/hns/hns_roce_main.c | 12 +++++++----- 3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_debugfs.c b/drivers/infiniband/hw/hns/hns_roce_debugfs.c index 9d3075ee0d22..c8294a836ee3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_debugfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_debugfs.c @@ -287,13 +287,11 @@ static void dca_stats_dev_pool_in_seqfile(struct hns_roce_dev *hr_dev, /* Write kernel DCA pool stats */ dca_print_pool_stats(&hr_dev->dca_ctx, 0, true, file); /* Write user DCA pool stats */ - spin_lock(&hr_dev->uctx_list_lock); + mutex_lock(&hr_dev->uctx_list_mutex); list_for_each_entry_safe(uctx, tmp, &hr_dev->uctx_list, list) { - spin_unlock(&hr_dev->uctx_list_lock); dca_print_pool_stats(&uctx->dca_ctx, uctx->pid, false, file); - spin_lock(&hr_dev->uctx_list_lock); } - spin_unlock(&hr_dev->uctx_list_lock); + mutex_unlock(&hr_dev->uctx_list_mutex); }
struct dca_qp_stats { diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index 9a3c79dc6759..884b642f48e6 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -1126,7 +1126,7 @@ struct hns_roce_dev { struct hns_roce_dev_debugfs dbgfs; /* debugfs for this dev */
struct list_head uctx_list; /* list of all uctx on this dev */ - spinlock_t uctx_list_lock; /* protect @uctx_list */ + struct mutex uctx_list_mutex; /* protect @uctx_list */
struct hns_roce_uar priv_uar; const char *irq_names[HNS_ROCE_MAX_IRQ_NUM]; diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index a1b4f84675bc..4a76f44a5c98 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -611,9 +611,9 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx, if (ret) goto error_fail_copy_to_udata;
- spin_lock(&hr_dev->uctx_list_lock); + mutex_lock(&hr_dev->uctx_list_mutex); list_add(&context->list, &hr_dev->uctx_list); - spin_unlock(&hr_dev->uctx_list_lock); + mutex_unlock(&hr_dev->uctx_list_mutex);
hns_roce_register_uctx_debugfs(hr_dev, context);
@@ -640,9 +640,9 @@ static void hns_roce_dealloc_ucontext(struct ib_ucontext *ibcontext) struct hns_roce_ucontext *context = to_hr_ucontext(ibcontext); struct hns_roce_dev *hr_dev = to_hr_dev(ibcontext->device);
- spin_lock(&hr_dev->uctx_list_lock); + mutex_lock(&hr_dev->uctx_list_mutex); list_del(&context->list); - spin_unlock(&hr_dev->uctx_list_lock); + mutex_unlock(&hr_dev->uctx_list_mutex);
hns_roce_unregister_uctx_debugfs(context);
@@ -1299,6 +1299,7 @@ static void hns_roce_teardown_hca(struct hns_roce_dev *hr_dev) hns_roce_cleanup_dca(hr_dev);
hns_roce_cleanup_bitmap(hr_dev); + mutex_destroy(&hr_dev->uctx_list_mutex); }
/** @@ -1319,7 +1320,7 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev) spin_lock_init(&hr_dev->dip_list_lock);
INIT_LIST_HEAD(&hr_dev->uctx_list); - spin_lock_init(&hr_dev->uctx_list_lock); + mutex_init(&hr_dev->uctx_list_mutex);
INIT_LIST_HEAD(&hr_dev->mtr_unfree_list); spin_lock_init(&hr_dev->mtr_unfree_list_lock); @@ -1367,6 +1368,7 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)
err_uar_table_free: ida_destroy(&hr_dev->uar_ida.ida); + mutex_destroy(&hr_dev->uctx_list_mutex); return ret; }