Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: hisilicon/sec - Fix a module parameter error

ctx_q_num is a module parameter set by the user to specify the
number of qp queues required to create a ctx.

When the number of qp queues allocated by PF or VF is less than
the ctx_q_num, an error will be reported when ctx is initialized
in kernel mode, which leads to the problem that the registered
algorithms cannot be used.

Therefore, when PF or VF is initialized, if the number of qp queues
is not enough to create a ctx, the kernel mode cannot be used,
and there is no need to register the kernel mode algorithms.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Longfang Liu and committed by
Herbert Xu
da6503f5 ac1af1a7

+12 -5
+12 -5
drivers/crypto/hisilicon/sec2/sec_main.c
··· 867 867 if (ret) 868 868 pci_warn(pdev, "Failed to init debugfs!\n"); 869 869 870 - ret = hisi_qm_alg_register(qm, &sec_devices); 871 - if (ret < 0) { 872 - pr_err("Failed to register driver to crypto.\n"); 873 - goto err_qm_stop; 870 + if (qm->qp_num >= ctx_q_num) { 871 + ret = hisi_qm_alg_register(qm, &sec_devices); 872 + if (ret < 0) { 873 + pr_err("Failed to register driver to crypto.\n"); 874 + goto err_qm_stop; 875 + } 876 + } else { 877 + pci_warn(qm->pdev, 878 + "Failed to use kernel mode, qp not enough!\n"); 874 879 } 875 880 876 881 if (qm->uacce) { ··· 911 906 struct hisi_qm *qm = pci_get_drvdata(pdev); 912 907 913 908 hisi_qm_wait_task_finish(qm, &sec_devices); 914 - hisi_qm_alg_unregister(qm, &sec_devices); 909 + if (qm->qp_num >= ctx_q_num) 910 + hisi_qm_alg_unregister(qm, &sec_devices); 911 + 915 912 if (qm->fun_type == QM_HW_PF && qm->vfs_num) 916 913 hisi_qm_sriov_disable(pdev, true); 917 914