Commit d08f90ea authored by Chengchang Tang's avatar Chengchang Tang Committed by Juan Zhou
Browse files

RDMA/hns: Fix missing reset notification by user space driver

driver inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I83L7U



----------------------------------------------------------

Currently, the driver notifies user mode whether a reset has occurred
through setting a shared variable to non-zero value. However, if the
user fails to obtain this variable in time, the notification will be
lost because this variable will be clear after completes the reset.

This patch adds a new reset variable to ensure that the user mode can
obtain whether the driver has been reset at any time. A non-zero value
will be assigned to this variable, which will permanently become 0 once
a reset occurs. During reset, the driver will assign 0 to this variable.
After reset, this variable will be remapped to a page of all zeros. The
userspace driver can judge whether the driver has been reset by whether
this variable is 0.

Fixes: e8b1fec4 ("RDMA/hns: Kernel notify usr space to stop ring db")
Signed-off-by: default avatarChengchang Tang <tangchengchang@huawei.com>
parent c6fd990a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2740,6 +2740,8 @@ static void free_dip_list(struct hns_roce_dev *hr_dev)

static int hns_roce_v2_get_reset_page(struct hns_roce_dev *hr_dev)
{
	struct hns_roce_v2_reset_state *state;

	hr_dev->reset_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
	if (!hr_dev->reset_page)
		return -ENOMEM;
@@ -2748,6 +2750,9 @@ static int hns_roce_v2_get_reset_page(struct hns_roce_dev *hr_dev)
	if (!hr_dev->reset_kaddr)
		goto err_with_vmap;

	state = hr_dev->reset_kaddr;
	state->hw_ready = ~state->hw_ready;

	return 0;

err_with_vmap:
@@ -7425,6 +7430,7 @@ static void hns_roce_v2_reset_notify_user(struct hns_roce_dev *hr_dev)
	state = (struct hns_roce_v2_reset_state *)hr_dev->reset_kaddr;

	state->reset_state = HNS_ROCE_IS_RESETTING;
	state->hw_ready = 0;
	/* Ensure reset state was flushed in memory */
	wmb();
}
+1 −0
Original line number Diff line number Diff line
@@ -1314,6 +1314,7 @@ struct hns_roce_link_table {

struct hns_roce_v2_reset_state {
	u32 reset_state; /* stored to use in user space */
	u32 hw_ready;
};

struct hns_roce_v2_free_mr {