Skip to content

Commit 1861423

Browse files
Longfang Liuherbertx
authored andcommitted
crypto: hisilicon/sec2 - modify the SEC probe process
Adjust the position of SMMU status check and SEC queue initialization in SEC probe Signed-off-by: Longfang Liu <[email protected]> Signed-off-by: Zaibo Xu <[email protected]> Signed-off-by: Shukun Tan <[email protected]> Reviewed-by: Zhou Wang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent c549e81 commit 1861423

File tree

1 file changed

+30
-37
lines changed

1 file changed

+30
-37
lines changed

drivers/crypto/hisilicon/sec2/sec_main.c

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,21 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
765765
qm->dev_name = sec_name;
766766
qm->fun_type = (pdev->device == SEC_PF_PCI_DEVICE_ID) ?
767767
QM_HW_PF : QM_HW_VF;
768+
if (qm->fun_type == QM_HW_PF) {
769+
qm->qp_base = SEC_PF_DEF_Q_BASE;
770+
qm->qp_num = pf_q_num;
771+
qm->debug.curr_qm_qp_num = pf_q_num;
772+
qm->qm_list = &sec_devices;
773+
} else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V1) {
774+
/*
775+
* have no way to get qm configure in VM in v1 hardware,
776+
* so currently force PF to uses SEC_PF_DEF_Q_NUM, and force
777+
* to trigger only one VF in v1 hardware.
778+
* v2 hardware has no such problem.
779+
*/
780+
qm->qp_base = SEC_PF_DEF_Q_NUM;
781+
qm->qp_num = SEC_QUEUE_NUM_V1 - SEC_PF_DEF_Q_NUM;
782+
}
768783
qm->use_dma_api = true;
769784

770785
return hisi_qm_init(qm);
@@ -775,8 +790,9 @@ static void sec_qm_uninit(struct hisi_qm *qm)
775790
hisi_qm_uninit(qm);
776791
}
777792

778-
static int sec_probe_init(struct hisi_qm *qm, struct sec_dev *sec)
793+
static int sec_probe_init(struct sec_dev *sec)
779794
{
795+
struct hisi_qm *qm = &sec->qm;
780796
int ret;
781797

782798
/*
@@ -793,40 +809,18 @@ static int sec_probe_init(struct hisi_qm *qm, struct sec_dev *sec)
793809
return -ENOMEM;
794810
}
795811

796-
if (qm->fun_type == QM_HW_PF) {
797-
qm->qp_base = SEC_PF_DEF_Q_BASE;
798-
qm->qp_num = pf_q_num;
799-
qm->debug.curr_qm_qp_num = pf_q_num;
800-
qm->qm_list = &sec_devices;
801-
812+
if (qm->fun_type == QM_HW_PF)
802813
ret = sec_pf_probe_init(sec);
803-
if (ret)
804-
goto err_probe_uninit;
805-
} else if (qm->fun_type == QM_HW_VF) {
806-
/*
807-
* have no way to get qm configure in VM in v1 hardware,
808-
* so currently force PF to uses SEC_PF_DEF_Q_NUM, and force
809-
* to trigger only one VF in v1 hardware.
810-
* v2 hardware has no such problem.
811-
*/
812-
if (qm->ver == QM_HW_V1) {
813-
qm->qp_base = SEC_PF_DEF_Q_NUM;
814-
qm->qp_num = SEC_QUEUE_NUM_V1 - SEC_PF_DEF_Q_NUM;
815-
} else if (qm->ver == QM_HW_V2) {
816-
/* v2 starts to support get vft by mailbox */
817-
ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num);
818-
if (ret)
819-
goto err_probe_uninit;
820-
}
821-
} else {
822-
ret = -ENODEV;
823-
goto err_probe_uninit;
814+
else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V2)
815+
/* v2 starts to support get vft by mailbox */
816+
ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num);
817+
818+
if (ret) {
819+
destroy_workqueue(qm->wq);
820+
return ret;
824821
}
825822

826823
return 0;
827-
err_probe_uninit:
828-
destroy_workqueue(qm->wq);
829-
return ret;
830824
}
831825

832826
static void sec_probe_uninit(struct hisi_qm *qm)
@@ -865,18 +859,17 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
865859

866860
pci_set_drvdata(pdev, sec);
867861

868-
sec->ctx_q_num = ctx_q_num;
869-
sec_iommu_used_check(sec);
870-
871862
qm = &sec->qm;
872-
873863
ret = sec_qm_init(qm, pdev);
874864
if (ret) {
875-
pci_err(pdev, "Failed to pre init qm!\n");
865+
pci_err(pdev, "Failed to init SEC QM (%d)!\n", ret);
876866
return ret;
877867
}
878868

879-
ret = sec_probe_init(qm, sec);
869+
sec->ctx_q_num = ctx_q_num;
870+
sec_iommu_used_check(sec);
871+
872+
ret = sec_probe_init(sec);
880873
if (ret) {
881874
pci_err(pdev, "Failed to probe!\n");
882875
goto err_qm_uninit;

0 commit comments

Comments
 (0)