提交 f16cf291 编写于 作者: Z zhangwei 提交者: Xie XiuQi

ACC: fixup sec2 create multi crypt disk failed problem

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

Feature or Bugfix:Bugfix
Signed-off-by: NZhangwei <zhangwei375@huawei.com>
Reviewed-by: Nhucheng.hu <hucheng.hu@huawei.com>
Signed-off-by: Nlingmingqiang <lingmingqiang@huawei.com>
Reviewed-by: Nlingmingqiang <lingmingqiang@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ffd62ef4
...@@ -50,6 +50,8 @@ struct hisi_sec { ...@@ -50,6 +50,8 @@ struct hisi_sec {
struct hisi_sec_dfx sec_dfx; struct hisi_sec_dfx sec_dfx;
struct hisi_sec_ctrl *ctrl; struct hisi_sec_ctrl *ctrl;
struct dma_pool *sgl_pool; struct dma_pool *sgl_pool;
struct mutex *hisi_sec_list_lock;
int q_ref;
int ctx_q_num; int ctx_q_num;
int fusion_limit; int fusion_limit;
int fusion_tmout_usec; int fusion_tmout_usec;
......
...@@ -446,6 +446,10 @@ static void hisi_sec_cipher_ctx_exit(struct crypto_skcipher *tfm) ...@@ -446,6 +446,10 @@ static void hisi_sec_cipher_ctx_exit(struct crypto_skcipher *tfm)
hisi_sec_release_qp_ctx(&ctx->qp_ctx[i]); hisi_sec_release_qp_ctx(&ctx->qp_ctx[i]);
kfree(ctx->qp_ctx); kfree(ctx->qp_ctx);
mutex_lock(ctx->sec->hisi_sec_list_lock);
ctx->sec->q_ref -= ctx->sec->ctx_q_num;
mutex_unlock(ctx->sec->hisi_sec_list_lock);
} }
static void hisi_sec_req_cb(struct hisi_qp *qp, void *resp) static void hisi_sec_req_cb(struct hisi_qp *qp, void *resp)
......
...@@ -100,28 +100,68 @@ ...@@ -100,28 +100,68 @@
static const char hisi_sec_name[] = "hisi_sec"; static const char hisi_sec_name[] = "hisi_sec";
static atomic_t hisi_sec_ref = {0}; static atomic_t hisi_sec_ref = {0};
static struct dentry *hsec_debugfs_root; static struct dentry *hsec_debugfs_root;
static u32 pf_q_num = HSEC_PF_DEF_Q_NUM;
static struct workqueue_struct *sec_wq;
LIST_HEAD(hisi_sec_list); LIST_HEAD(hisi_sec_list);
DEFINE_MUTEX(hisi_sec_list_lock); DEFINE_MUTEX(hisi_sec_list_lock);
static struct workqueue_struct *sec_wq; struct hisi_sec_resource {
struct hisi_sec *hsec;
int distance;
struct list_head list;
};
static void free_list(struct list_head *head)
{
struct hisi_sec_resource *res, *tmp;
list_for_each_entry_safe(res, tmp, head, list) {
list_del(&res->list);
kfree(res);
}
}
struct hisi_sec *find_sec_device(int node) struct hisi_sec *find_sec_device(int node)
{ {
struct hisi_sec *ret = NULL; struct hisi_sec *ret = NULL;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
struct hisi_sec_resource *res, *tmp;
struct hisi_sec *hisi_sec; struct hisi_sec *hisi_sec;
int min_distance = 100; struct list_head *n;
struct device *dev; struct device *dev;
LIST_HEAD(head);
mutex_lock(&hisi_sec_list_lock); mutex_lock(&hisi_sec_list_lock);
list_for_each_entry(hisi_sec, &hisi_sec_list, list) { list_for_each_entry(hisi_sec, &hisi_sec_list, list) {
res = kzalloc(sizeof(*res), GFP_KERNEL);
if (!res)
goto err;
dev = &hisi_sec->qm.pdev->dev; dev = &hisi_sec->qm.pdev->dev;
if (node_distance(dev->numa_node, node) < min_distance) { res->hsec = hisi_sec;
ret = hisi_sec; res->distance = node_distance(dev->numa_node, node);
min_distance = node_distance(dev->numa_node, node);
n = &head;
list_for_each_entry(tmp, &head, list) {
if (res->distance < tmp->distance) {
n = &tmp->list;
break;
}
}
list_add_tail(&res->list, n);
}
list_for_each_entry(tmp, &head, list) {
if (tmp->hsec->q_ref + tmp->hsec->ctx_q_num <= pf_q_num) {
tmp->hsec->q_ref += tmp->hsec->ctx_q_num;
ret = tmp->hsec;
break;
} }
} }
free_list(&head);
#else #else
mutex_lock(&hisi_sec_list_lock); mutex_lock(&hisi_sec_list_lock);
...@@ -130,6 +170,10 @@ struct hisi_sec *find_sec_device(int node) ...@@ -130,6 +170,10 @@ struct hisi_sec *find_sec_device(int node)
mutex_unlock(&hisi_sec_list_lock); mutex_unlock(&hisi_sec_list_lock);
return ret; return ret;
err:
free_list(&head);
return NULL;
} }
struct hisi_sec_hw_error { struct hisi_sec_hw_error {
...@@ -267,7 +311,6 @@ static const struct kernel_param_ops uacce_mode_ops = { ...@@ -267,7 +311,6 @@ static const struct kernel_param_ops uacce_mode_ops = {
.get = param_get_int, .get = param_get_int,
}; };
static u32 pf_q_num = HSEC_PF_DEF_Q_NUM;
module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444); module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444);
MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 0-4096, v2 0-1024)"); MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 0-4096, v2 0-1024)");
...@@ -838,6 +881,8 @@ static int hisi_sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -838,6 +881,8 @@ static int hisi_sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
hisi_sec_add_to_list(hisi_sec); hisi_sec_add_to_list(hisi_sec);
hisi_sec->hisi_sec_list_lock = &hisi_sec_list_lock;
hisi_sec->sgl_pool = acc_create_sgl_pool(&pdev->dev, "hsec-sgl"); hisi_sec->sgl_pool = acc_create_sgl_pool(&pdev->dev, "hsec-sgl");
if (!hisi_sec->sgl_pool) if (!hisi_sec->sgl_pool)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册