@@ -765,6 +765,21 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
765
765
qm -> dev_name = sec_name ;
766
766
qm -> fun_type = (pdev -> device == SEC_PF_PCI_DEVICE_ID ) ?
767
767
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
+ }
768
783
qm -> use_dma_api = true;
769
784
770
785
return hisi_qm_init (qm );
@@ -775,8 +790,9 @@ static void sec_qm_uninit(struct hisi_qm *qm)
775
790
hisi_qm_uninit (qm );
776
791
}
777
792
778
- static int sec_probe_init (struct hisi_qm * qm , struct sec_dev * sec )
793
+ static int sec_probe_init (struct sec_dev * sec )
779
794
{
795
+ struct hisi_qm * qm = & sec -> qm ;
780
796
int ret ;
781
797
782
798
/*
@@ -793,40 +809,18 @@ static int sec_probe_init(struct hisi_qm *qm, struct sec_dev *sec)
793
809
return - ENOMEM ;
794
810
}
795
811
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 )
802
813
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 ;
824
821
}
825
822
826
823
return 0 ;
827
- err_probe_uninit :
828
- destroy_workqueue (qm -> wq );
829
- return ret ;
830
824
}
831
825
832
826
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)
865
859
866
860
pci_set_drvdata (pdev , sec );
867
861
868
- sec -> ctx_q_num = ctx_q_num ;
869
- sec_iommu_used_check (sec );
870
-
871
862
qm = & sec -> qm ;
872
-
873
863
ret = sec_qm_init (qm , pdev );
874
864
if (ret ) {
875
- pci_err (pdev , "Failed to pre init qm !\n" );
865
+ pci_err (pdev , "Failed to init SEC QM (%d) !\n" , ret );
876
866
return ret ;
877
867
}
878
868
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 );
880
873
if (ret ) {
881
874
pci_err (pdev , "Failed to probe!\n" );
882
875
goto err_qm_uninit ;
0 commit comments