Skip to content

Commit fc38e93

Browse files
Karthikeyan Periyasamykvalo
authored andcommitted
wifi: ath12k: Refactor core startup
In the upcoming hardware device group abstraction radios across different devices can be grouped together to support multi-link operation and register as a device group to mac80211. Currently, ath12k_mac_allocate() and ath12k_mac_register() are part of ath12k_core_start() and ath12k_core_pdev_create() respectively and are based on per device (struct ath12k_base). These APIs can be decoupled and moved out to ath12k_core_qmi_firmware_ready() itself. This refactor is helpful for device group abstraction when mac80211 allocate and register will be changed from per device (struct ath12k_base) to per device group (struct ath12k_hw_group). Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Karthikeyan Periyasamy <[email protected]> Signed-off-by: Harshitha Prem <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 8c21437 commit fc38e93

File tree

4 files changed

+50
-33
lines changed

4 files changed

+50
-33
lines changed

drivers/net/wireless/ath/ath12k/core.c

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,10 @@ static void ath12k_core_stop(struct ath12k_base *ab)
604604

605605
ath12k_acpi_stop(ab);
606606

607+
ath12k_dp_rx_pdev_reo_cleanup(ab);
607608
ath12k_hif_stop(ab);
608609
ath12k_wmi_detach(ab);
609-
ath12k_dp_rx_pdev_reo_cleanup(ab);
610+
ath12k_dp_free(ab);
610611

611612
/* De-Init of components as needed */
612613
}
@@ -708,7 +709,7 @@ static int ath12k_core_soc_create(struct ath12k_base *ab)
708709

709710
static void ath12k_core_soc_destroy(struct ath12k_base *ab)
710711
{
711-
ath12k_dp_free(ab);
712+
ath12k_hif_power_down(ab, false);
712713
ath12k_reg_free(ab);
713714
ath12k_debugfs_soc_destroy(ab);
714715
ath12k_qmi_deinit_service(ab);
@@ -718,30 +719,17 @@ static int ath12k_core_pdev_create(struct ath12k_base *ab)
718719
{
719720
int ret;
720721

721-
ret = ath12k_mac_register(ab);
722-
if (ret) {
723-
ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret);
724-
return ret;
725-
}
726-
727722
ret = ath12k_dp_pdev_alloc(ab);
728723
if (ret) {
729724
ath12k_err(ab, "failed to attach DP pdev: %d\n", ret);
730-
goto err_mac_unregister;
725+
return ret;
731726
}
732727

733728
return 0;
734-
735-
err_mac_unregister:
736-
ath12k_mac_unregister(ab);
737-
738-
return ret;
739729
}
740730

741731
static void ath12k_core_pdev_destroy(struct ath12k_base *ab)
742732
{
743-
ath12k_mac_unregister(ab);
744-
ath12k_hif_irq_disable(ab);
745733
ath12k_dp_pdev_free(ab);
746734
}
747735

@@ -799,19 +787,12 @@ static int ath12k_core_start(struct ath12k_base *ab,
799787
goto err_hif_stop;
800788
}
801789

802-
ret = ath12k_mac_allocate(ab);
803-
if (ret) {
804-
ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n",
805-
ret);
806-
goto err_hif_stop;
807-
}
808-
809790
ath12k_dp_cc_config(ab);
810791

811792
ret = ath12k_dp_rx_pdev_reo_setup(ab);
812793
if (ret) {
813794
ath12k_err(ab, "failed to initialize reo destination rings: %d\n", ret);
814-
goto err_mac_destroy;
795+
goto err_hif_stop;
815796
}
816797

817798
ath12k_dp_hal_rx_desc_init(ab);
@@ -854,8 +835,6 @@ static int ath12k_core_start(struct ath12k_base *ab,
854835

855836
err_reo_cleanup:
856837
ath12k_dp_rx_pdev_reo_cleanup(ab);
857-
err_mac_destroy:
858-
ath12k_mac_destroy(ab);
859838
err_hif_stop:
860839
ath12k_hif_stop(ab);
861840
err_wmi_detach:
@@ -909,28 +888,46 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
909888
goto err_dp_free;
910889
}
911890

891+
ret = ath12k_mac_allocate(ab);
892+
if (ret) {
893+
ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n",
894+
ret);
895+
goto err_core_stop;
896+
}
897+
898+
ret = ath12k_mac_register(ab);
899+
if (ret) {
900+
ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret);
901+
goto err_mac_destroy;
902+
}
903+
912904
ret = ath12k_core_pdev_create(ab);
913905
if (ret) {
914906
ath12k_err(ab, "failed to create pdev core: %d\n", ret);
915-
goto err_core_stop;
907+
goto err_mac_unregister;
916908
}
909+
917910
ath12k_hif_irq_enable(ab);
918911

919912
ret = ath12k_core_rfkill_config(ab);
920913
if (ret && ret != -EOPNOTSUPP) {
921914
ath12k_err(ab, "failed to config rfkill: %d\n", ret);
922-
goto err_core_pdev_destroy;
915+
goto err_hif_irq_disable;
923916
}
924917

925918
mutex_unlock(&ab->core_lock);
926919

927920
return 0;
928921

929-
err_core_pdev_destroy:
922+
err_hif_irq_disable:
923+
ath12k_hif_irq_disable(ab);
930924
ath12k_core_pdev_destroy(ab);
925+
err_mac_unregister:
926+
ath12k_mac_unregister(ab);
927+
err_mac_destroy:
928+
ath12k_mac_destroy(ab);
931929
err_core_stop:
932930
ath12k_core_stop(ab);
933-
ath12k_mac_destroy(ab);
934931
err_dp_free:
935932
ath12k_dp_free(ab);
936933
mutex_unlock(&ab->core_lock);
@@ -1270,15 +1267,15 @@ void ath12k_core_deinit(struct ath12k_base *ab)
12701267

12711268
mutex_lock(&ab->core_lock);
12721269

1270+
ath12k_hif_irq_disable(ab);
12731271
ath12k_core_pdev_destroy(ab);
1272+
ath12k_mac_unregister(ab);
1273+
ath12k_mac_destroy(ab);
12741274
ath12k_core_stop(ab);
12751275

12761276
mutex_unlock(&ab->core_lock);
12771277

1278-
ath12k_hif_power_down(ab, false);
1279-
ath12k_mac_destroy(ab);
12801278
ath12k_core_soc_destroy(ab);
1281-
ath12k_fw_unmap(ab);
12821279
}
12831280

12841281
void ath12k_core_free(struct ath12k_base *ab)

drivers/net/wireless/ath/ath12k/dp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,9 @@ void ath12k_dp_pdev_free(struct ath12k_base *ab)
982982
{
983983
int i;
984984

985+
if (!ab->mon_reap_timer.function)
986+
return;
987+
985988
del_timer_sync(&ab->mon_reap_timer);
986989

987990
for (i = 0; i < ab->num_radios; i++)
@@ -1289,6 +1292,9 @@ void ath12k_dp_free(struct ath12k_base *ab)
12891292
struct ath12k_dp *dp = &ab->dp;
12901293
int i;
12911294

1295+
if (!dp->ab)
1296+
return;
1297+
12921298
ath12k_dp_link_desc_cleanup(ab, dp->link_desc_banks,
12931299
HAL_WBM_IDLE_LINK, &dp->wbm_idle_ring);
12941300

@@ -1306,6 +1312,7 @@ void ath12k_dp_free(struct ath12k_base *ab)
13061312

13071313
ath12k_dp_rx_free(ab);
13081314
/* Deinit any SOC level resource */
1315+
dp->ab = NULL;
13091316
}
13101317

13111318
void ath12k_dp_cc_config(struct ath12k_base *ab)

drivers/net/wireless/ath/ath12k/pci.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,9 @@ void ath12k_pci_ext_irq_enable(struct ath12k_base *ab)
11231123

11241124
void ath12k_pci_ext_irq_disable(struct ath12k_base *ab)
11251125
{
1126+
if (!test_bit(ATH12K_FLAG_EXT_IRQ_ENABLED, &ab->dev_flags))
1127+
return;
1128+
11261129
__ath12k_pci_ext_irq_disable(ab);
11271130
ath12k_pci_sync_ext_irqs(ab);
11281131
}
@@ -1147,6 +1150,11 @@ int ath12k_pci_hif_resume(struct ath12k_base *ab)
11471150

11481151
void ath12k_pci_stop(struct ath12k_base *ab)
11491152
{
1153+
struct ath12k_pci *ab_pci = ath12k_pci_priv(ab);
1154+
1155+
if (!test_bit(ATH12K_PCI_FLAG_INIT_DONE, &ab_pci->flags))
1156+
return;
1157+
11501158
ath12k_pci_ce_irq_disable_sync(ab);
11511159
ath12k_ce_cleanup_pipes(ab);
11521160
}
@@ -1725,6 +1733,7 @@ static void ath12k_pci_remove(struct pci_dev *pdev)
17251733
cancel_work_sync(&ab->reset_work);
17261734
cancel_work_sync(&ab->dump_work);
17271735
ath12k_core_deinit(ab);
1736+
ath12k_fw_unmap(ab);
17281737

17291738
qmi_fail:
17301739
ath12k_mhi_unregister(ab_pci);

drivers/net/wireless/ath/ath12k/qmi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,11 +3402,15 @@ int ath12k_qmi_init_service(struct ath12k_base *ab)
34023402

34033403
void ath12k_qmi_deinit_service(struct ath12k_base *ab)
34043404
{
3405+
if (!ab->qmi.ab)
3406+
return;
3407+
34053408
qmi_handle_release(&ab->qmi.handle);
34063409
cancel_work_sync(&ab->qmi.event_work);
34073410
destroy_workqueue(ab->qmi.event_wq);
34083411
ath12k_qmi_m3_free(ab);
34093412
ath12k_qmi_free_target_mem_chunk(ab);
3413+
ab->qmi.ab = NULL;
34103414
}
34113415

34123416
void ath12k_qmi_free_resource(struct ath12k_base *ab)

0 commit comments

Comments
 (0)