93 lines
3.0 KiB
Diff
93 lines
3.0 KiB
Diff
|
|
From de7b9a04b5bfd5cf40cc6c89dae3757f1823432a Mon Sep 17 00:00:00 2001
|
||
|
|
From: Chengchang Tang <tangchengchang@huawei.com>
|
||
|
|
Date: Tue, 26 Sep 2023 19:19:10 +0800
|
||
|
|
Subject: [PATCH 5/5] libhns: Fix missing reset notification.
|
||
|
|
|
||
|
|
driver inclusion
|
||
|
|
category: bugfix
|
||
|
|
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I83L7U
|
||
|
|
|
||
|
|
----------------------------------------------------------
|
||
|
|
|
||
|
|
Currently, userspace driver get the reset notification by reading a
|
||
|
|
a shared variable which would be set to non-zero during reset. However,
|
||
|
|
if the user does not call driver's IO interface during reset, the reset
|
||
|
|
notification will be ignored. because this variable will be clear after
|
||
|
|
completes the reset.
|
||
|
|
|
||
|
|
This patch use a new reset flag to get whether the driver has been reset
|
||
|
|
at any time. A non-zero value will be assigned to this new reset
|
||
|
|
flag by default, which will permanently become 0 once a reset occurs.
|
||
|
|
During reset, the kernel space 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: 34f2ad8085c2 ("libhns: Add reset stop flow mechanism")
|
||
|
|
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
|
||
|
|
---
|
||
|
|
providers/hns/hns_roce_u.c | 4 ++++
|
||
|
|
providers/hns/hns_roce_u.h | 2 ++
|
||
|
|
providers/hns/hns_roce_u_hw_v2.c | 3 +++
|
||
|
|
3 files changed, 9 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
|
||
|
|
index 87f9ed8..0660081 100644
|
||
|
|
--- a/providers/hns/hns_roce_u.c
|
||
|
|
+++ b/providers/hns/hns_roce_u.c
|
||
|
|
@@ -226,6 +226,7 @@ static int init_reset_context(struct hns_roce_context *ctx, int cmd_fd,
|
||
|
|
int page_size)
|
||
|
|
{
|
||
|
|
uint64_t reset_mmap_key = resp->reset_mmap_key;
|
||
|
|
+ struct hns_roce_v2_reset_state *state;
|
||
|
|
|
||
|
|
/* The reset mmap key is 0, which means it is not supported. */
|
||
|
|
if (reset_mmap_key == 0)
|
||
|
|
@@ -236,6 +237,9 @@ static int init_reset_context(struct hns_roce_context *ctx, int cmd_fd,
|
||
|
|
if (ctx->reset_state == MAP_FAILED)
|
||
|
|
return -ENOMEM;
|
||
|
|
|
||
|
|
+ state = ctx->reset_state;
|
||
|
|
+ ctx->use_new_reset_flag = state->hw_ready;
|
||
|
|
+
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h
|
||
|
|
index b3f21ba..5501d8e 100644
|
||
|
|
--- a/providers/hns/hns_roce_u.h
|
||
|
|
+++ b/providers/hns/hns_roce_u.h
|
||
|
|
@@ -235,6 +235,7 @@ struct hns_roce_dca_ctx {
|
||
|
|
|
||
|
|
struct hns_roce_v2_reset_state {
|
||
|
|
uint32_t is_reset;
|
||
|
|
+ uint32_t hw_ready;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct hns_roce_cmd_flag {
|
||
|
|
@@ -278,6 +279,7 @@ struct hns_roce_context {
|
||
|
|
|
||
|
|
struct hns_roce_dca_ctx dca_ctx;
|
||
|
|
|
||
|
|
+ bool use_new_reset_flag;
|
||
|
|
bool reseted;
|
||
|
|
};
|
||
|
|
|
||
|
|
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
|
||
|
|
index 29b6268..ac40d5d 100644
|
||
|
|
--- a/providers/hns/hns_roce_u_hw_v2.c
|
||
|
|
+++ b/providers/hns/hns_roce_u_hw_v2.c
|
||
|
|
@@ -1011,6 +1011,9 @@ static bool hns_roce_reseted(struct hns_roce_context *ctx)
|
||
|
|
{
|
||
|
|
struct hns_roce_v2_reset_state *state = ctx->reset_state;
|
||
|
|
|
||
|
|
+ if (ctx->use_new_reset_flag)
|
||
|
|
+ return !state->hw_ready;
|
||
|
|
+
|
||
|
|
if (state && state->is_reset)
|
||
|
|
ctx->reseted = true;
|
||
|
|
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|