提交 85e6045d 编写于 作者: L Lang Cheng 提交者: Xie XiuQi

remove unnecessary jiffies operations

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

When use mdelay, some jiffies are unnecessary.

Feature or Bugfix:Bugfix
Signed-off-by: NLang Cheng <chenglang@huawei.com>
Reviewed-by: Nliuyixian <liuyixian@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 741384c7
...@@ -790,9 +790,11 @@ static int hns_roce_v2_cmd_hw_resetting(struct hns_roce_dev *hr_dev, ...@@ -790,9 +790,11 @@ static int hns_roce_v2_cmd_hw_resetting(struct hns_roce_dev *hr_dev,
* reschedule soft reset process once again. * reschedule soft reset process once again.
*/ */
hr_dev->dis_db = true; hr_dev->dis_db = true;
end = msecs_to_jiffies(HNS_ROCE_V2_HW_RST_TIMEOUT) + jiffies; end = HNS_ROCE_V2_HW_RST_TIMEOUT;
while (ops->get_hw_reset_stat(handle) && time_before(jiffies, end)) while (ops->get_hw_reset_stat(handle) && end) {
udelay(1); udelay(1);
end -= 1;
}
if (!ops->get_hw_reset_stat(handle)) if (!ops->get_hw_reset_stat(handle))
hr_dev->is_reset = true; hr_dev->is_reset = true;
...@@ -818,10 +820,12 @@ static int hns_roce_v2_cmd_sw_resetting(struct hns_roce_dev *hr_dev) ...@@ -818,10 +820,12 @@ static int hns_roce_v2_cmd_sw_resetting(struct hns_roce_dev *hr_dev)
* wait until hardware reset finished, we should exit with error. * wait until hardware reset finished, we should exit with error.
*/ */
hr_dev->dis_db = true; hr_dev->dis_db = true;
end = msecs_to_jiffies(HNS_ROCE_V2_HW_RST_TIMEOUT) + jiffies; end = HNS_ROCE_V2_HW_RST_TIMEOUT;
while (ops->ae_dev_reset_cnt(handle) == hr_dev->reset_cnt && while (ops->ae_dev_reset_cnt(handle) == hr_dev->reset_cnt &&
time_before(jiffies, end)) end) {
udelay(1); udelay(1);
end -= 1;
}
if (ops->ae_dev_reset_cnt(handle) != hr_dev->reset_cnt) if (ops->ae_dev_reset_cnt(handle) != hr_dev->reset_cnt)
hr_dev->is_reset = true; hr_dev->is_reset = true;
...@@ -1228,8 +1232,8 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval, ...@@ -1228,8 +1232,8 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval,
dev_warn(hr_dev->dev, dev_warn(hr_dev->dev,
"Func clear is pending, device in resetting state.\n"); "Func clear is pending, device in resetting state.\n");
end = msecs_to_jiffies(HNS_ROCE_V2_HW_RST_TIMEOUT) + jiffies; end = HNS_ROCE_V2_HW_RST_TIMEOUT;
while (time_before(jiffies, end)) { while (end) {
if (!ops->get_hw_reset_stat(handle)) { if (!ops->get_hw_reset_stat(handle)) {
hr_dev->is_reset = true; hr_dev->is_reset = true;
dev_info(hr_dev->dev, dev_info(hr_dev->dev,
...@@ -1237,6 +1241,7 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval, ...@@ -1237,6 +1241,7 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval,
return; return;
} }
msleep(HNS_ROCE_V2_HW_RST_COMPLETION_WAIT); msleep(HNS_ROCE_V2_HW_RST_COMPLETION_WAIT);
end -= HNS_ROCE_V2_HW_RST_COMPLETION_WAIT;
} }
dev_warn(hr_dev->dev, "Func clear failed.\n"); dev_warn(hr_dev->dev, "Func clear failed.\n");
...@@ -1245,8 +1250,8 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval, ...@@ -1245,8 +1250,8 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval,
dev_warn(hr_dev->dev, dev_warn(hr_dev->dev,
"Func clear is pending, device in resetting state.\n"); "Func clear is pending, device in resetting state.\n");
end = msecs_to_jiffies(HNS_ROCE_V2_HW_RST_TIMEOUT) + jiffies; end = HNS_ROCE_V2_HW_RST_TIMEOUT;
while (time_before(jiffies, end)) { while (end) {
if (ops->ae_dev_reset_cnt(handle) != if (ops->ae_dev_reset_cnt(handle) !=
hr_dev->reset_cnt) { hr_dev->reset_cnt) {
hr_dev->is_reset = true; hr_dev->is_reset = true;
...@@ -1255,6 +1260,7 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval, ...@@ -1255,6 +1260,7 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval,
return; return;
} }
msleep(HNS_ROCE_V2_HW_RST_COMPLETION_WAIT); msleep(HNS_ROCE_V2_HW_RST_COMPLETION_WAIT);
end -= HNS_ROCE_V2_HW_RST_COMPLETION_WAIT;
} }
dev_warn(hr_dev->dev, "Func clear failed because of unfinished sw reset\n"); dev_warn(hr_dev->dev, "Func clear failed because of unfinished sw reset\n");
...@@ -1309,12 +1315,13 @@ static void hns_roce_clear_func(struct hns_roce_dev *hr_dev, int vf_id) ...@@ -1309,12 +1315,13 @@ static void hns_roce_clear_func(struct hns_roce_dev *hr_dev, int vf_id)
goto out; goto out;
} }
end = msecs_to_jiffies(HNS_ROCE_V2_FUNC_CLEAR_TIMEOUT_MSECS) + jiffies;
msleep(HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_INTERVAL); msleep(HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_INTERVAL);
while (time_before(jiffies, end)) { end = HNS_ROCE_V2_FUNC_CLEAR_TIMEOUT_MSECS;
while (end) {
if (hns_roce_func_clr_chk_rst(hr_dev)) if (hns_roce_func_clr_chk_rst(hr_dev))
goto out; goto out;
msleep(HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT);
end -= HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT;
hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_FUNC_CLEAR, hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_FUNC_CLEAR,
true); true);
...@@ -1322,7 +1329,6 @@ static void hns_roce_clear_func(struct hns_roce_dev *hr_dev, int vf_id) ...@@ -1322,7 +1329,6 @@ static void hns_roce_clear_func(struct hns_roce_dev *hr_dev, int vf_id)
ret = hns_roce_cmq_send(hr_dev, &desc, 1); ret = hns_roce_cmq_send(hr_dev, &desc, 1);
if (ret) { if (ret) {
msleep(HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT);
continue; continue;
} }
...@@ -6912,9 +6918,11 @@ static int hns_roce_hw_v2_init_instance(struct hnae3_handle *handle) ...@@ -6912,9 +6918,11 @@ static int hns_roce_hw_v2_init_instance(struct hnae3_handle *handle)
* encountered a serious error and cannot be recovered from the reset * encountered a serious error and cannot be recovered from the reset
* processing. * processing.
*/ */
end = msecs_to_jiffies(HNS_ROCE_V2_RST_PRC_MAX_TIME) + jiffies; end = HNS_ROCE_V2_RST_PRC_MAX_TIME;
while (ops->ae_dev_resetting(handle) && time_before(jiffies, end)) while (ops->ae_dev_resetting(handle) && end) {
msleep(20); msleep(20);
end -= 20;
}
if (!ops->ae_dev_resetting(handle)) if (!ops->ae_dev_resetting(handle))
dev_info(&handle->pdev->dev, "Device completed reset.\n"); dev_info(&handle->pdev->dev, "Device completed reset.\n");
...@@ -6956,10 +6964,12 @@ static void hns_roce_hw_v2_uninit_instance(struct hnae3_handle *handle, ...@@ -6956,10 +6964,12 @@ static void hns_roce_hw_v2_uninit_instance(struct hnae3_handle *handle,
if (ops->ae_dev_resetting(handle)) { if (ops->ae_dev_resetting(handle)) {
dev_warn(&handle->pdev->dev, dev_warn(&handle->pdev->dev,
"Device is busy in resetting state. waiting.\n"); "Device is busy in resetting state. waiting.\n");
end = msecs_to_jiffies(HNS_ROCE_V2_RST_PRC_MAX_TIME) + jiffies; end = HNS_ROCE_V2_RST_PRC_MAX_TIME;
while (ops->ae_dev_resetting(handle) && while (ops->ae_dev_resetting(handle) &&
time_before(jiffies, end)) end) {
msleep(20); msleep(20);
end -= 20;
}
if (!ops->ae_dev_resetting(handle)) if (!ops->ae_dev_resetting(handle))
dev_info(&handle->pdev->dev, dev_info(&handle->pdev->dev,
......
...@@ -1289,7 +1289,7 @@ struct hns_roce_pf_func_num { ...@@ -1289,7 +1289,7 @@ struct hns_roce_pf_func_num {
#define FUNC_CLEAR_RST_FUN_DONE_S 0 #define FUNC_CLEAR_RST_FUN_DONE_S 0
#define HNS_ROCE_V2_FUNC_CLEAR_TIMEOUT_MSECS (512 * 100) #define HNS_ROCE_V2_FUNC_CLEAR_TIMEOUT_MSECS (512 * 100 - 40)
#define HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_INTERVAL 40 #define HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_INTERVAL 40
#define HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT 20 #define HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT 20
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册