@@ -604,6 +604,8 @@ u32 ath12k_core_get_max_num_tids(struct ath12k_base *ab)
604
604
605
605
static void ath12k_core_stop (struct ath12k_base * ab )
606
606
{
607
+ ath12k_core_stopped (ab );
608
+
607
609
if (!test_bit (ATH12K_FLAG_CRASH_FLUSH , & ab -> dev_flags ))
608
610
ath12k_qmi_firmware_stop (ab );
609
611
@@ -743,6 +745,8 @@ static int ath12k_core_start(struct ath12k_base *ab,
743
745
{
744
746
int ret ;
745
747
748
+ lockdep_assert_held (& ab -> core_lock );
749
+
746
750
ret = ath12k_wmi_attach (ab );
747
751
if (ret ) {
748
752
ath12k_err (ab , "failed to attach wmi: %d\n" , ret );
@@ -836,6 +840,10 @@ static int ath12k_core_start(struct ath12k_base *ab,
836
840
/* ACPI is optional so continue in case of an error */
837
841
ath12k_dbg (ab , ATH12K_DBG_BOOT , "acpi failed: %d\n" , ret );
838
842
843
+ if (!test_bit (ATH12K_FLAG_RECOVERY , & ab -> dev_flags ))
844
+ /* Indicate the core start in the appropriate group */
845
+ ath12k_core_started (ab );
846
+
839
847
return 0 ;
840
848
841
849
err_reo_cleanup :
@@ -847,6 +855,96 @@ static int ath12k_core_start(struct ath12k_base *ab,
847
855
return ret ;
848
856
}
849
857
858
+ static void ath12k_core_device_cleanup (struct ath12k_base * ab )
859
+ {
860
+ mutex_lock (& ab -> core_lock );
861
+
862
+ ath12k_hif_irq_disable (ab );
863
+ ath12k_core_pdev_destroy (ab );
864
+ ath12k_mac_unregister (ab );
865
+ ath12k_mac_destroy (ab );
866
+
867
+ mutex_unlock (& ab -> core_lock );
868
+ }
869
+
870
+ static void ath12k_core_hw_group_stop (struct ath12k_hw_group * ag )
871
+ {
872
+ struct ath12k_base * ab ;
873
+ int i ;
874
+
875
+ lockdep_assert_held (& ag -> mutex );
876
+
877
+ for (i = ag -> num_devices - 1 ; i >= 0 ; i -- ) {
878
+ ab = ag -> ab [i ];
879
+ if (!ab )
880
+ continue ;
881
+ ath12k_core_device_cleanup (ab );
882
+ }
883
+ }
884
+
885
+ static int ath12k_core_hw_group_start (struct ath12k_hw_group * ag )
886
+ {
887
+ struct ath12k_base * ab ;
888
+ int ret , i ;
889
+
890
+ lockdep_assert_held (& ag -> mutex );
891
+
892
+ for (i = 0 ; i < ag -> num_devices ; i ++ ) {
893
+ ab = ag -> ab [i ];
894
+ if (!ab )
895
+ continue ;
896
+
897
+ mutex_lock (& ab -> core_lock );
898
+
899
+ /* Check if already registered or not, since same flow
900
+ * execute for HW restart case.
901
+ */
902
+ if (test_bit (ATH12K_FLAG_REGISTERED , & ab -> dev_flags ))
903
+ goto core_pdev_create ;
904
+
905
+ ret = ath12k_mac_allocate (ab );
906
+ if (ret ) {
907
+ ath12k_err (ab , "failed to create new hw device with mac80211 :%d\n" ,
908
+ ret );
909
+ mutex_unlock (& ab -> core_lock );
910
+ return ret ;
911
+ }
912
+
913
+ ret = ath12k_mac_register (ab );
914
+ if (ret ) {
915
+ ath12k_err (ab , "failed to register radio with mac80211: %d\n" ,
916
+ ret );
917
+ mutex_unlock (& ab -> core_lock );
918
+ goto err ;
919
+ }
920
+
921
+ core_pdev_create :
922
+ ret = ath12k_core_pdev_create (ab );
923
+ if (ret ) {
924
+ ath12k_err (ab , "failed to create pdev core %d\n" , ret );
925
+ mutex_unlock (& ab -> core_lock );
926
+ goto err ;
927
+ }
928
+
929
+ ath12k_hif_irq_enable (ab );
930
+
931
+ ret = ath12k_core_rfkill_config (ab );
932
+ if (ret && ret != - EOPNOTSUPP ) {
933
+ mutex_unlock (& ab -> core_lock );
934
+ goto err ;
935
+ }
936
+
937
+ mutex_unlock (& ab -> core_lock );
938
+ }
939
+
940
+ return 0 ;
941
+
942
+ err :
943
+ ath12k_core_hw_group_stop (ag );
944
+
945
+ return ret ;
946
+ }
947
+
850
948
static int ath12k_core_start_firmware (struct ath12k_base * ab ,
851
949
enum ath12k_firmware_mode mode )
852
950
{
@@ -864,9 +962,18 @@ static int ath12k_core_start_firmware(struct ath12k_base *ab,
864
962
return ret ;
865
963
}
866
964
965
+ static inline
966
+ bool ath12k_core_hw_group_start_ready (struct ath12k_hw_group * ag )
967
+ {
968
+ lockdep_assert_held (& ag -> mutex );
969
+
970
+ return (ag -> num_started == ag -> num_devices );
971
+ }
972
+
867
973
int ath12k_core_qmi_firmware_ready (struct ath12k_base * ab )
868
974
{
869
- int ret ;
975
+ struct ath12k_hw_group * ag = ath12k_ab_to_ag (ab );
976
+ int ret , i ;
870
977
871
978
ret = ath12k_core_start_firmware (ab , ATH12K_FIRMWARE_MODE_NORMAL );
872
979
if (ret ) {
@@ -886,59 +993,50 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
886
993
goto err_firmware_stop ;
887
994
}
888
995
996
+ mutex_lock (& ag -> mutex );
889
997
mutex_lock (& ab -> core_lock );
998
+
890
999
ret = ath12k_core_start (ab , ATH12K_FIRMWARE_MODE_NORMAL );
891
1000
if (ret ) {
892
1001
ath12k_err (ab , "failed to start core: %d\n" , ret );
893
1002
goto err_dp_free ;
894
1003
}
895
1004
896
- ret = ath12k_mac_allocate (ab );
897
- if (ret ) {
898
- ath12k_err (ab , "failed to create new hw device with mac80211 :%d\n" ,
899
- ret );
900
- goto err_core_stop ;
901
- }
902
-
903
- ret = ath12k_mac_register (ab );
904
- if (ret ) {
905
- ath12k_err (ab , "failed register the radio with mac80211: %d\n" , ret );
906
- goto err_mac_destroy ;
907
- }
908
-
909
- ret = ath12k_core_pdev_create (ab );
910
- if (ret ) {
911
- ath12k_err (ab , "failed to create pdev core: %d\n" , ret );
912
- goto err_mac_unregister ;
913
- }
914
-
915
- ath12k_hif_irq_enable (ab );
1005
+ mutex_unlock (& ab -> core_lock );
916
1006
917
- ret = ath12k_core_rfkill_config (ab );
918
- if (ret && ret != - EOPNOTSUPP ) {
919
- ath12k_err (ab , "failed to config rfkill: %d\n" , ret );
920
- goto err_hif_irq_disable ;
1007
+ if (ath12k_core_hw_group_start_ready (ag )) {
1008
+ ret = ath12k_core_hw_group_start (ag );
1009
+ if (ret ) {
1010
+ ath12k_warn (ab , "unable to start hw group\n" );
1011
+ goto err_core_stop ;
1012
+ }
1013
+ ath12k_dbg (ab , ATH12K_DBG_BOOT , "group %d started\n" , ag -> id );
921
1014
}
922
1015
923
- mutex_unlock (& ab -> core_lock );
1016
+ mutex_unlock (& ag -> mutex );
924
1017
925
1018
return 0 ;
926
1019
927
- err_hif_irq_disable :
928
- ath12k_hif_irq_disable (ab );
929
- ath12k_core_pdev_destroy (ab );
930
- err_mac_unregister :
931
- ath12k_mac_unregister (ab );
932
- err_mac_destroy :
933
- ath12k_mac_destroy (ab );
934
1020
err_core_stop :
935
- ath12k_core_stop (ab );
1021
+ for (i = ag -> num_devices - 1 ; i >= 0 ; i -- ) {
1022
+ ab = ag -> ab [i ];
1023
+ if (!ab )
1024
+ continue ;
1025
+
1026
+ mutex_lock (& ab -> core_lock );
1027
+ ath12k_core_stop (ab );
1028
+ mutex_unlock (& ab -> core_lock );
1029
+ }
1030
+ goto exit ;
1031
+
936
1032
err_dp_free :
937
1033
ath12k_dp_free (ab );
938
1034
mutex_unlock (& ab -> core_lock );
939
1035
err_firmware_stop :
940
1036
ath12k_qmi_firmware_stop (ab );
941
1037
1038
+ exit :
1039
+ mutex_unlock (& ag -> mutex );
942
1040
return ret ;
943
1041
}
944
1042
@@ -1135,6 +1233,14 @@ static void ath12k_core_restart(struct work_struct *work)
1135
1233
}
1136
1234
1137
1235
if (ab -> is_reset ) {
1236
+ if (!test_bit (ATH12K_FLAG_REGISTERED , & ab -> dev_flags )) {
1237
+ atomic_dec (& ab -> reset_count );
1238
+ complete (& ab -> reset_complete );
1239
+ ab -> is_reset = false;
1240
+ atomic_set (& ab -> fail_cont_count , 0 );
1241
+ ath12k_dbg (ab , ATH12K_DBG_BOOT , "reset success\n" );
1242
+ }
1243
+
1138
1244
for (i = 0 ; i < ath12k_get_num_hw (ab ); i ++ ) {
1139
1245
ah = ath12k_ab_to_ah (ab , i );
1140
1246
ieee80211_restart_hw (ah -> hw );
@@ -1319,7 +1425,7 @@ static struct ath12k_hw_group *ath12k_core_hw_group_assign(struct ath12k_base *a
1319
1425
1320
1426
void ath12k_core_hw_group_unassign (struct ath12k_base * ab )
1321
1427
{
1322
- struct ath12k_hw_group * ag = ab -> ag ;
1428
+ struct ath12k_hw_group * ag = ath12k_ab_to_ag ( ab ) ;
1323
1429
u8 device_id = ab -> device_id ;
1324
1430
int num_probed ;
1325
1431
@@ -1353,19 +1459,6 @@ void ath12k_core_hw_group_unassign(struct ath12k_base *ab)
1353
1459
ath12k_core_hw_group_free (ag );
1354
1460
}
1355
1461
1356
- static void ath12k_core_device_cleanup (struct ath12k_base * ab )
1357
- {
1358
- mutex_lock (& ab -> core_lock );
1359
-
1360
- ath12k_hif_irq_disable (ab );
1361
- ath12k_core_pdev_destroy (ab );
1362
- ath12k_mac_unregister (ab );
1363
- ath12k_mac_destroy (ab );
1364
- ath12k_core_stop (ab );
1365
-
1366
- mutex_unlock (& ab -> core_lock );
1367
- }
1368
-
1369
1462
static void ath12k_core_hw_group_destroy (struct ath12k_hw_group * ag )
1370
1463
{
1371
1464
struct ath12k_base * ab ;
@@ -1393,12 +1486,16 @@ static void ath12k_core_hw_group_cleanup(struct ath12k_hw_group *ag)
1393
1486
1394
1487
mutex_lock (& ag -> mutex );
1395
1488
1489
+ ath12k_core_hw_group_stop (ag );
1490
+
1396
1491
for (i = 0 ; i < ag -> num_devices ; i ++ ) {
1397
1492
ab = ag -> ab [i ];
1398
1493
if (!ab )
1399
1494
continue ;
1400
1495
1401
- ath12k_core_device_cleanup (ab );
1496
+ mutex_lock (& ab -> core_lock );
1497
+ ath12k_core_stop (ab );
1498
+ mutex_unlock (& ab -> core_lock );
1402
1499
}
1403
1500
1404
1501
mutex_unlock (& ag -> mutex );
0 commit comments