未验证 提交 1f5570d3 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!923 [sync] PR-918: Misc fixes for Kunpeng accelerator drivers!

Merge Pull Request from: @openeuler-sync-bot 
 

Origin pull request: 
https://gitee.com/openeuler/kernel/pulls/918 
 
* crypto: hisilicon/qm - remove unnecessary aer.h include
* crypto: hisilicon/qm - prevent soft lockup in qm_poll_req_cb()'s loop
* crypto: hisilicon/hpre - ensure private key less than n
* crypto: hisilicon/qm - stop function and write data to memory

issue: https://gitee.com/openeuler/kernel/issues/I7AUVE 
 
Link:https://gitee.com/openeuler/kernel/pulls/923 

Reviewed-by: Yang Shen <shenyang39@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
...@@ -1382,9 +1382,9 @@ static int hpre_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, ...@@ -1382,9 +1382,9 @@ static int hpre_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,
unsigned int len) unsigned int len)
{ {
struct hpre_ctx *ctx = kpp_tfm_ctx(tfm); struct hpre_ctx *ctx = kpp_tfm_ctx(tfm);
unsigned int sz, sz_shift, curve_sz;
struct device *dev = ctx->dev; struct device *dev = ctx->dev;
char key[HPRE_ECC_MAX_KSZ]; char key[HPRE_ECC_MAX_KSZ];
unsigned int sz, sz_shift;
struct ecdh params; struct ecdh params;
int ret; int ret;
...@@ -1396,7 +1396,13 @@ static int hpre_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, ...@@ -1396,7 +1396,13 @@ static int hpre_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,
/* Use stdrng to generate private key */ /* Use stdrng to generate private key */
if (!params.key || !params.key_size) { if (!params.key || !params.key_size) {
params.key = key; params.key = key;
params.key_size = hpre_ecdh_get_curvesz(ctx->curve_id); curve_sz = hpre_ecdh_get_curvesz(ctx->curve_id);
if (!curve_sz) {
dev_err(dev, "Invalid curve size!\n");
return -EINVAL;
}
params.key_size = curve_sz - 1;
ret = ecdh_gen_privkey(ctx, &params); ret = ecdh_gen_privkey(ctx, &params);
if (ret) if (ret)
return ret; return ret;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
/* Copyright (c) 2019 HiSilicon Limited. */ /* Copyright (c) 2019 HiSilicon Limited. */
#include <asm/page.h> #include <asm/page.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/aer.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/idr.h> #include <linux/idr.h>
...@@ -869,6 +868,8 @@ static void qm_poll_req_cb(struct hisi_qp *qp) ...@@ -869,6 +868,8 @@ static void qm_poll_req_cb(struct hisi_qp *qp)
qm_db(qm, qp->qp_id, QM_DOORBELL_CMD_CQ, qm_db(qm, qp->qp_id, QM_DOORBELL_CMD_CQ,
qp->qp_status.cq_head, 0); qp->qp_status.cq_head, 0);
atomic_dec(&qp->qp_status.used); atomic_dec(&qp->qp_status.used);
cond_resched();
} }
/* set c_flag */ /* set c_flag */
...@@ -1019,7 +1020,7 @@ static void qm_reset_function(struct hisi_qm *qm) ...@@ -1019,7 +1020,7 @@ static void qm_reset_function(struct hisi_qm *qm)
return; return;
} }
ret = hisi_qm_stop(qm, QM_FLR); ret = hisi_qm_stop(qm, QM_DOWN);
if (ret) { if (ret) {
dev_err(dev, "failed to stop qm when reset function\n"); dev_err(dev, "failed to stop qm when reset function\n");
goto clear_bit; goto clear_bit;
...@@ -3395,7 +3396,7 @@ int hisi_qm_stop(struct hisi_qm *qm, enum qm_stop_reason r) ...@@ -3395,7 +3396,7 @@ int hisi_qm_stop(struct hisi_qm *qm, enum qm_stop_reason r)
} }
if (qm->status.stop_reason == QM_SOFT_RESET || if (qm->status.stop_reason == QM_SOFT_RESET ||
qm->status.stop_reason == QM_FLR) { qm->status.stop_reason == QM_DOWN) {
hisi_qm_set_hw_reset(qm, QM_RESET_STOP_TX_OFFSET); hisi_qm_set_hw_reset(qm, QM_RESET_STOP_TX_OFFSET);
ret = qm_stop_started_qp(qm); ret = qm_stop_started_qp(qm);
if (ret < 0) { if (ret < 0) {
...@@ -4691,11 +4692,11 @@ void hisi_qm_reset_prepare(struct pci_dev *pdev) ...@@ -4691,11 +4692,11 @@ void hisi_qm_reset_prepare(struct pci_dev *pdev)
if (qm->fun_type == QM_HW_PF) if (qm->fun_type == QM_HW_PF)
qm_cmd_uninit(qm); qm_cmd_uninit(qm);
ret = qm_try_stop_vfs(qm, QM_PF_FLR_PREPARE, QM_FLR); ret = qm_try_stop_vfs(qm, QM_PF_FLR_PREPARE, QM_DOWN);
if (ret) if (ret)
pci_err(pdev, "failed to stop vfs by pf in FLR.\n"); pci_err(pdev, "failed to stop vfs by pf in FLR.\n");
ret = hisi_qm_stop(qm, QM_FLR); ret = hisi_qm_stop(qm, QM_DOWN);
if (ret) { if (ret) {
pci_err(pdev, "Failed to stop QM, ret = %d.\n", ret); pci_err(pdev, "Failed to stop QM, ret = %d.\n", ret);
hisi_qm_set_hw_reset(qm, QM_RESET_STOP_TX_OFFSET); hisi_qm_set_hw_reset(qm, QM_RESET_STOP_TX_OFFSET);
...@@ -4793,10 +4794,11 @@ void hisi_qm_dev_shutdown(struct pci_dev *pdev) ...@@ -4793,10 +4794,11 @@ void hisi_qm_dev_shutdown(struct pci_dev *pdev)
struct hisi_qm *qm = pci_get_drvdata(pdev); struct hisi_qm *qm = pci_get_drvdata(pdev);
int ret; int ret;
ret = hisi_qm_stop(qm, QM_NORMAL); ret = hisi_qm_stop(qm, QM_DOWN);
if (ret) if (ret)
dev_err(&pdev->dev, "Fail to stop qm in shutdown!\n"); dev_err(&pdev->dev, "Fail to stop qm in shutdown!\n");
hisi_qm_cache_wb(qm);
qm_remove_uacce(qm); qm_remove_uacce(qm);
} }
EXPORT_SYMBOL_GPL(hisi_qm_dev_shutdown); EXPORT_SYMBOL_GPL(hisi_qm_dev_shutdown);
...@@ -4961,7 +4963,7 @@ static void qm_handle_cmd_msg(struct hisi_qm *qm, u32 fun_num) ...@@ -4961,7 +4963,7 @@ static void qm_handle_cmd_msg(struct hisi_qm *qm, u32 fun_num)
cmd = msg & QM_MB_CMD_DATA_MASK; cmd = msg & QM_MB_CMD_DATA_MASK;
switch (cmd) { switch (cmd) {
case QM_PF_FLR_PREPARE: case QM_PF_FLR_PREPARE:
qm_pf_reset_vf_process(qm, QM_FLR); qm_pf_reset_vf_process(qm, QM_DOWN);
break; break;
case QM_PF_SRST_PREPARE: case QM_PF_SRST_PREPARE:
qm_pf_reset_vf_process(qm, QM_SOFT_RESET); qm_pf_reset_vf_process(qm, QM_SOFT_RESET);
......
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
enum qm_stop_reason { enum qm_stop_reason {
QM_NORMAL, QM_NORMAL,
QM_SOFT_RESET, QM_SOFT_RESET,
QM_FLR, QM_DOWN,
}; };
enum qm_state { enum qm_state {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册