Lines Matching full:ab

25 static int ath12k_core_rfkill_config(struct ath12k_base *ab)  in ath12k_core_rfkill_config()  argument
30 if (!(ab->target_caps.sys_cap_info & WMI_SYS_CAP_INFO_RFKILL)) in ath12k_core_rfkill_config()
33 for (i = 0; i < ab->num_radios; i++) { in ath12k_core_rfkill_config()
34 ar = ab->pdevs[i].ar; in ath12k_core_rfkill_config()
38 ath12k_warn(ab, "failed to configure rfkill: %d", ret); in ath12k_core_rfkill_config()
52 static int ath12k_core_continue_suspend_resume(struct ath12k_base *ab) in ath12k_core_continue_suspend_resume() argument
56 if (!ab->hw_params->supports_suspend) in ath12k_core_continue_suspend_resume()
62 ar = ab->pdevs[0].ar; in ath12k_core_continue_suspend_resume()
69 int ath12k_core_suspend(struct ath12k_base *ab) in ath12k_core_suspend() argument
74 ret = ath12k_core_continue_suspend_resume(ab); in ath12k_core_suspend()
78 for (i = 0; i < ab->num_radios; i++) { in ath12k_core_suspend()
79 ar = ab->pdevs[i].ar; in ath12k_core_suspend()
84 ath12k_warn(ab, "failed to wait tx complete: %d\n", ret); in ath12k_core_suspend()
94 * no chance to call complete(&ab->restart_completed) in in ath12k_core_suspend()
100 complete(&ab->restart_completed); in ath12k_core_suspend()
106 int ath12k_core_suspend_late(struct ath12k_base *ab) in ath12k_core_suspend_late() argument
110 ret = ath12k_core_continue_suspend_resume(ab); in ath12k_core_suspend_late()
114 ath12k_acpi_stop(ab); in ath12k_core_suspend_late()
116 ath12k_hif_irq_disable(ab); in ath12k_core_suspend_late()
117 ath12k_hif_ce_irq_disable(ab); in ath12k_core_suspend_late()
119 ath12k_hif_power_down(ab, true); in ath12k_core_suspend_late()
125 int ath12k_core_resume_early(struct ath12k_base *ab) in ath12k_core_resume_early() argument
129 ret = ath12k_core_continue_suspend_resume(ab); in ath12k_core_resume_early()
133 reinit_completion(&ab->restart_completed); in ath12k_core_resume_early()
134 ret = ath12k_hif_power_up(ab); in ath12k_core_resume_early()
136 ath12k_warn(ab, "failed to power up hif during resume: %d\n", ret); in ath12k_core_resume_early()
142 int ath12k_core_resume(struct ath12k_base *ab) in ath12k_core_resume() argument
147 ret = ath12k_core_continue_suspend_resume(ab); in ath12k_core_resume()
151 time_left = wait_for_completion_timeout(&ab->restart_completed, in ath12k_core_resume()
154 ath12k_warn(ab, "timeout while waiting for restart complete"); in ath12k_core_resume()
162 static int __ath12k_core_create_board_name(struct ath12k_base *ab, char *name, in __ath12k_core_create_board_name() argument
166 /* strlen(',variant=') + strlen(ab->qmi.target.bdf_ext) */ in __ath12k_core_create_board_name()
169 if (with_variant && ab->qmi.target.bdf_ext[0] != '\0') in __ath12k_core_create_board_name()
171 ab->qmi.target.bdf_ext); in __ath12k_core_create_board_name()
173 switch (ab->id.bdf_search) { in __ath12k_core_create_board_name()
178 ath12k_bus_str(ab->hif.bus)); in __ath12k_core_create_board_name()
182 ath12k_bus_str(ab->hif.bus), in __ath12k_core_create_board_name()
183 ab->id.vendor, ab->id.device, in __ath12k_core_create_board_name()
184 ab->id.subsystem_vendor, in __ath12k_core_create_board_name()
185 ab->id.subsystem_device, in __ath12k_core_create_board_name()
186 ab->qmi.target.chip_id, in __ath12k_core_create_board_name()
187 ab->qmi.target.board_id, in __ath12k_core_create_board_name()
193 ath12k_bus_str(ab->hif.bus), in __ath12k_core_create_board_name()
194 ab->qmi.target.chip_id, in __ath12k_core_create_board_name()
195 ab->qmi.target.board_id, variant); in __ath12k_core_create_board_name()
199 ath12k_dbg(ab, ATH12K_DBG_BOOT, "boot using board name '%s'\n", name); in __ath12k_core_create_board_name()
204 static int ath12k_core_create_board_name(struct ath12k_base *ab, char *name, in ath12k_core_create_board_name() argument
207 return __ath12k_core_create_board_name(ab, name, name_len, true, false); in ath12k_core_create_board_name()
210 static int ath12k_core_create_fallback_board_name(struct ath12k_base *ab, char *name, in ath12k_core_create_fallback_board_name() argument
213 return __ath12k_core_create_board_name(ab, name, name_len, false, false); in ath12k_core_create_fallback_board_name()
216 static int ath12k_core_create_bus_type_board_name(struct ath12k_base *ab, char *name, in ath12k_core_create_bus_type_board_name() argument
219 return __ath12k_core_create_board_name(ab, name, name_len, false, true); in ath12k_core_create_bus_type_board_name()
222 const struct firmware *ath12k_core_firmware_request(struct ath12k_base *ab, in ath12k_core_firmware_request() argument
232 ath12k_core_create_firmware_path(ab, file, path, sizeof(path)); in ath12k_core_firmware_request()
234 ret = firmware_request_nowarn(&fw, path, ab->dev); in ath12k_core_firmware_request()
238 ath12k_dbg(ab, ATH12K_DBG_BOOT, "boot firmware request %s size %zu\n", in ath12k_core_firmware_request()
244 void ath12k_core_free_bdf(struct ath12k_base *ab, struct ath12k_board_data *bd) in ath12k_core_free_bdf() argument
252 static int ath12k_core_parse_bd_ie_board(struct ath12k_base *ab, in ath12k_core_parse_bd_ie_board() argument
279 ath12k_err(ab, "invalid %s length: %zu < %zu\n", in ath12k_core_parse_bd_ie_board()
287 ath12k_dbg_dump(ab, ATH12K_DBG_BOOT, "board name", "", in ath12k_core_parse_bd_ie_board()
298 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_parse_bd_ie_board()
307 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_parse_bd_ie_board()
318 ath12k_warn(ab, "unknown %s id found: %d\n", in ath12k_core_parse_bd_ie_board()
337 static int ath12k_core_fetch_board_data_api_n(struct ath12k_base *ab, in ath12k_core_fetch_board_data_api_n() argument
354 bd->fw = ath12k_core_firmware_request(ab, filename); in ath12k_core_fetch_board_data_api_n()
362 ath12k_core_create_firmware_path(ab, filename, in ath12k_core_fetch_board_data_api_n()
368 ath12k_err(ab, "failed to find magic value in %s, file too short: %zu\n", in ath12k_core_fetch_board_data_api_n()
375 ath12k_err(ab, "found invalid board magic\n"); in ath12k_core_fetch_board_data_api_n()
383 ath12k_err(ab, "failed: %s too small to contain board data, len: %zu\n", in ath12k_core_fetch_board_data_api_n()
401 ath12k_err(ab, "invalid length for board ie_id %d ie_len %zu len %zu\n", in ath12k_core_fetch_board_data_api_n()
408 ret = ath12k_core_parse_bd_ie_board(ab, bd, data, in ath12k_core_fetch_board_data_api_n()
433 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_fetch_board_data_api_n()
444 ath12k_core_free_bdf(ab, bd); in ath12k_core_fetch_board_data_api_n()
448 int ath12k_core_fetch_board_data_api_1(struct ath12k_base *ab, in ath12k_core_fetch_board_data_api_1() argument
452 bd->fw = ath12k_core_firmware_request(ab, filename); in ath12k_core_fetch_board_data_api_1()
463 int ath12k_core_fetch_bdf(struct ath12k_base *ab, struct ath12k_board_data *bd) in ath12k_core_fetch_bdf() argument
472 ret = ath12k_core_create_board_name(ab, boardname, sizeof(boardname)); in ath12k_core_fetch_bdf()
474 ath12k_err(ab, "failed to create board name: %d", ret); in ath12k_core_fetch_bdf()
479 ret = ath12k_core_fetch_board_data_api_n(ab, bd, boardname, in ath12k_core_fetch_bdf()
486 ret = ath12k_core_create_fallback_board_name(ab, fallback_boardname, in ath12k_core_fetch_bdf()
489 ath12k_err(ab, "failed to create fallback board name: %d", ret); in ath12k_core_fetch_bdf()
493 ret = ath12k_core_fetch_board_data_api_n(ab, bd, fallback_boardname, in ath12k_core_fetch_bdf()
501 ret = ath12k_core_fetch_board_data_api_1(ab, bd, ATH12K_DEFAULT_BOARD_FILE); in ath12k_core_fetch_bdf()
503 ath12k_core_create_firmware_path(ab, filename, in ath12k_core_fetch_bdf()
505 ath12k_err(ab, "failed to fetch board data for %s from %s\n", in ath12k_core_fetch_bdf()
508 ath12k_err(ab, "failed to fetch board data for %s from %s\n", in ath12k_core_fetch_bdf()
511 ath12k_err(ab, "failed to fetch board.bin from %s\n", in ath12k_core_fetch_bdf()
512 ab->hw_params->fw.dir); in ath12k_core_fetch_bdf()
517 ath12k_dbg(ab, ATH12K_DBG_BOOT, "using board api %d\n", bd_api); in ath12k_core_fetch_bdf()
521 int ath12k_core_fetch_regdb(struct ath12k_base *ab, struct ath12k_board_data *bd) in ath12k_core_fetch_regdb() argument
526 ret = ath12k_core_create_board_name(ab, boardname, BOARD_NAME_SIZE); in ath12k_core_fetch_regdb()
528 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_fetch_regdb()
533 ret = ath12k_core_fetch_board_data_api_n(ab, bd, boardname, in ath12k_core_fetch_regdb()
540 ret = ath12k_core_create_bus_type_board_name(ab, default_boardname, in ath12k_core_fetch_regdb()
543 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_fetch_regdb()
548 ret = ath12k_core_fetch_board_data_api_n(ab, bd, default_boardname, in ath12k_core_fetch_regdb()
555 ret = ath12k_core_fetch_board_data_api_1(ab, bd, ATH12K_REGDB_FILE_NAME); in ath12k_core_fetch_regdb()
557 ath12k_dbg(ab, ATH12K_DBG_BOOT, "failed to fetch %s from %s\n", in ath12k_core_fetch_regdb()
558 ATH12K_REGDB_FILE_NAME, ab->hw_params->fw.dir); in ath12k_core_fetch_regdb()
562 ath12k_dbg(ab, ATH12K_DBG_BOOT, "fetched regdb\n"); in ath12k_core_fetch_regdb()
567 u32 ath12k_core_get_max_station_per_radio(struct ath12k_base *ab) in ath12k_core_get_max_station_per_radio() argument
569 if (ab->num_radios == 2) in ath12k_core_get_max_station_per_radio()
571 else if (ab->num_radios == 3) in ath12k_core_get_max_station_per_radio()
576 u32 ath12k_core_get_max_peers_per_radio(struct ath12k_base *ab) in ath12k_core_get_max_peers_per_radio() argument
578 if (ab->num_radios == 2) in ath12k_core_get_max_peers_per_radio()
580 else if (ab->num_radios == 3) in ath12k_core_get_max_peers_per_radio()
585 u32 ath12k_core_get_max_num_tids(struct ath12k_base *ab) in ath12k_core_get_max_num_tids() argument
587 if (ab->num_radios == 2) in ath12k_core_get_max_num_tids()
589 else if (ab->num_radios == 3) in ath12k_core_get_max_num_tids()
594 static void ath12k_core_stop(struct ath12k_base *ab) in ath12k_core_stop() argument
596 if (!test_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags)) in ath12k_core_stop()
597 ath12k_qmi_firmware_stop(ab); in ath12k_core_stop()
599 ath12k_acpi_stop(ab); in ath12k_core_stop()
601 ath12k_hif_stop(ab); in ath12k_core_stop()
602 ath12k_wmi_detach(ab); in ath12k_core_stop()
603 ath12k_dp_rx_pdev_reo_cleanup(ab); in ath12k_core_stop()
610 struct ath12k_base *ab = data; in ath12k_core_check_bdfext() local
617 if (ab->qmi.target.bdf_ext[0] != '\0') in ath12k_core_check_bdfext()
624 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_check_bdfext()
631 ath12k_dbg(ab, ATH12K_DBG_BOOT, "bdf variant name not found.\n"); in ath12k_core_check_bdfext()
637 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_check_bdfext()
643 strlen(smbios->bdf_ext), sizeof(ab->qmi.target.bdf_ext)); in ath12k_core_check_bdfext()
646 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_check_bdfext()
653 copied = strscpy(ab->qmi.target.bdf_ext, smbios->bdf_ext + strlen(magic), in ath12k_core_check_bdfext()
654 sizeof(ab->qmi.target.bdf_ext)); in ath12k_core_check_bdfext()
656 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_check_bdfext()
661 ath12k_dbg(ab, ATH12K_DBG_BOOT, in ath12k_core_check_bdfext()
663 ATH12K_SMBIOS_BDF_EXT_TYPE, ab->qmi.target.bdf_ext); in ath12k_core_check_bdfext()
666 int ath12k_core_check_smbios(struct ath12k_base *ab) in ath12k_core_check_smbios() argument
668 ab->qmi.target.bdf_ext[0] = '\0'; in ath12k_core_check_smbios()
669 dmi_walk(ath12k_core_check_bdfext, ab); in ath12k_core_check_smbios()
671 if (ab->qmi.target.bdf_ext[0] == '\0') in ath12k_core_check_smbios()
677 static int ath12k_core_soc_create(struct ath12k_base *ab) in ath12k_core_soc_create() argument
681 ret = ath12k_qmi_init_service(ab); in ath12k_core_soc_create()
683 ath12k_err(ab, "failed to initialize qmi :%d\n", ret); in ath12k_core_soc_create()
687 ath12k_debugfs_soc_create(ab); in ath12k_core_soc_create()
689 ret = ath12k_hif_power_up(ab); in ath12k_core_soc_create()
691 ath12k_err(ab, "failed to power up :%d\n", ret); in ath12k_core_soc_create()
698 ath12k_debugfs_soc_destroy(ab); in ath12k_core_soc_create()
699 ath12k_qmi_deinit_service(ab); in ath12k_core_soc_create()
703 static void ath12k_core_soc_destroy(struct ath12k_base *ab) in ath12k_core_soc_destroy() argument
705 ath12k_dp_free(ab); in ath12k_core_soc_destroy()
706 ath12k_reg_free(ab); in ath12k_core_soc_destroy()
707 ath12k_debugfs_soc_destroy(ab); in ath12k_core_soc_destroy()
708 ath12k_qmi_deinit_service(ab); in ath12k_core_soc_destroy()
711 static int ath12k_core_pdev_create(struct ath12k_base *ab) in ath12k_core_pdev_create() argument
715 ret = ath12k_mac_register(ab); in ath12k_core_pdev_create()
717 ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret); in ath12k_core_pdev_create()
721 ret = ath12k_dp_pdev_alloc(ab); in ath12k_core_pdev_create()
723 ath12k_err(ab, "failed to attach DP pdev: %d\n", ret); in ath12k_core_pdev_create()
730 ath12k_mac_unregister(ab); in ath12k_core_pdev_create()
735 static void ath12k_core_pdev_destroy(struct ath12k_base *ab) in ath12k_core_pdev_destroy() argument
737 ath12k_mac_unregister(ab); in ath12k_core_pdev_destroy()
738 ath12k_hif_irq_disable(ab); in ath12k_core_pdev_destroy()
739 ath12k_dp_pdev_free(ab); in ath12k_core_pdev_destroy()
742 static int ath12k_core_start(struct ath12k_base *ab, in ath12k_core_start() argument
747 ret = ath12k_wmi_attach(ab); in ath12k_core_start()
749 ath12k_err(ab, "failed to attach wmi: %d\n", ret); in ath12k_core_start()
753 ret = ath12k_htc_init(ab); in ath12k_core_start()
755 ath12k_err(ab, "failed to init htc: %d\n", ret); in ath12k_core_start()
759 ret = ath12k_hif_start(ab); in ath12k_core_start()
761 ath12k_err(ab, "failed to start HIF: %d\n", ret); in ath12k_core_start()
765 ret = ath12k_htc_wait_target(&ab->htc); in ath12k_core_start()
767 ath12k_err(ab, "failed to connect to HTC: %d\n", ret); in ath12k_core_start()
771 ret = ath12k_dp_htt_connect(&ab->dp); in ath12k_core_start()
773 ath12k_err(ab, "failed to connect to HTT: %d\n", ret); in ath12k_core_start()
777 ret = ath12k_wmi_connect(ab); in ath12k_core_start()
779 ath12k_err(ab, "failed to connect wmi: %d\n", ret); in ath12k_core_start()
783 ret = ath12k_htc_start(&ab->htc); in ath12k_core_start()
785 ath12k_err(ab, "failed to start HTC: %d\n", ret); in ath12k_core_start()
789 ret = ath12k_wmi_wait_for_service_ready(ab); in ath12k_core_start()
791 ath12k_err(ab, "failed to receive wmi service ready event: %d\n", in ath12k_core_start()
796 ret = ath12k_mac_allocate(ab); in ath12k_core_start()
798 ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", in ath12k_core_start()
803 ath12k_dp_cc_config(ab); in ath12k_core_start()
805 ret = ath12k_dp_rx_pdev_reo_setup(ab); in ath12k_core_start()
807 ath12k_err(ab, "failed to initialize reo destination rings: %d\n", ret); in ath12k_core_start()
811 ath12k_dp_hal_rx_desc_init(ab); in ath12k_core_start()
813 ret = ath12k_wmi_cmd_init(ab); in ath12k_core_start()
815 ath12k_err(ab, "failed to send wmi init cmd: %d\n", ret); in ath12k_core_start()
819 ret = ath12k_wmi_wait_for_unified_ready(ab); in ath12k_core_start()
821 ath12k_err(ab, "failed to receive wmi unified ready event: %d\n", in ath12k_core_start()
827 if (ab->hw_params->single_pdev_only) { in ath12k_core_start()
828 ret = ath12k_wmi_set_hw_mode(ab, WMI_HOST_HW_MODE_DBS); in ath12k_core_start()
830 ath12k_err(ab, "failed to send dbs mode: %d\n", ret); in ath12k_core_start()
835 ret = ath12k_dp_tx_htt_h2t_ver_req_msg(ab); in ath12k_core_start()
837 ath12k_err(ab, "failed to send htt version request message: %d\n", in ath12k_core_start()
842 ret = ath12k_acpi_start(ab); in ath12k_core_start()
845 ath12k_dbg(ab, ATH12K_DBG_BOOT, "acpi failed: %d\n", ret); in ath12k_core_start()
850 ath12k_dp_rx_pdev_reo_cleanup(ab); in ath12k_core_start()
852 ath12k_mac_destroy(ab); in ath12k_core_start()
854 ath12k_hif_stop(ab); in ath12k_core_start()
856 ath12k_wmi_detach(ab); in ath12k_core_start()
860 static int ath12k_core_start_firmware(struct ath12k_base *ab, in ath12k_core_start_firmware() argument
865 ath12k_ce_get_shadow_config(ab, &ab->qmi.ce_cfg.shadow_reg_v3, in ath12k_core_start_firmware()
866 &ab->qmi.ce_cfg.shadow_reg_v3_len); in ath12k_core_start_firmware()
868 ret = ath12k_qmi_firmware_start(ab, mode); in ath12k_core_start_firmware()
870 ath12k_err(ab, "failed to send firmware start: %d\n", ret); in ath12k_core_start_firmware()
877 int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) in ath12k_core_qmi_firmware_ready() argument
881 ret = ath12k_core_start_firmware(ab, ATH12K_FIRMWARE_MODE_NORMAL); in ath12k_core_qmi_firmware_ready()
883 ath12k_err(ab, "failed to start firmware: %d\n", ret); in ath12k_core_qmi_firmware_ready()
887 ret = ath12k_ce_init_pipes(ab); in ath12k_core_qmi_firmware_ready()
889 ath12k_err(ab, "failed to initialize CE: %d\n", ret); in ath12k_core_qmi_firmware_ready()
893 ret = ath12k_dp_alloc(ab); in ath12k_core_qmi_firmware_ready()
895 ath12k_err(ab, "failed to init DP: %d\n", ret); in ath12k_core_qmi_firmware_ready()
899 mutex_lock(&ab->core_lock); in ath12k_core_qmi_firmware_ready()
900 ret = ath12k_core_start(ab, ATH12K_FIRMWARE_MODE_NORMAL); in ath12k_core_qmi_firmware_ready()
902 ath12k_err(ab, "failed to start core: %d\n", ret); in ath12k_core_qmi_firmware_ready()
906 ret = ath12k_core_pdev_create(ab); in ath12k_core_qmi_firmware_ready()
908 ath12k_err(ab, "failed to create pdev core: %d\n", ret); in ath12k_core_qmi_firmware_ready()
911 ath12k_hif_irq_enable(ab); in ath12k_core_qmi_firmware_ready()
913 ret = ath12k_core_rfkill_config(ab); in ath12k_core_qmi_firmware_ready()
915 ath12k_err(ab, "failed to config rfkill: %d\n", ret); in ath12k_core_qmi_firmware_ready()
919 mutex_unlock(&ab->core_lock); in ath12k_core_qmi_firmware_ready()
924 ath12k_core_pdev_destroy(ab); in ath12k_core_qmi_firmware_ready()
926 ath12k_core_stop(ab); in ath12k_core_qmi_firmware_ready()
927 ath12k_mac_destroy(ab); in ath12k_core_qmi_firmware_ready()
929 ath12k_dp_free(ab); in ath12k_core_qmi_firmware_ready()
930 mutex_unlock(&ab->core_lock); in ath12k_core_qmi_firmware_ready()
932 ath12k_qmi_firmware_stop(ab); in ath12k_core_qmi_firmware_ready()
937 static int ath12k_core_reconfigure_on_crash(struct ath12k_base *ab) in ath12k_core_reconfigure_on_crash() argument
941 mutex_lock(&ab->core_lock); in ath12k_core_reconfigure_on_crash()
942 ath12k_dp_pdev_free(ab); in ath12k_core_reconfigure_on_crash()
943 ath12k_ce_cleanup_pipes(ab); in ath12k_core_reconfigure_on_crash()
944 ath12k_wmi_detach(ab); in ath12k_core_reconfigure_on_crash()
945 ath12k_dp_rx_pdev_reo_cleanup(ab); in ath12k_core_reconfigure_on_crash()
946 mutex_unlock(&ab->core_lock); in ath12k_core_reconfigure_on_crash()
948 ath12k_dp_free(ab); in ath12k_core_reconfigure_on_crash()
949 ath12k_hal_srng_deinit(ab); in ath12k_core_reconfigure_on_crash()
951 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; in ath12k_core_reconfigure_on_crash()
953 ret = ath12k_hal_srng_init(ab); in ath12k_core_reconfigure_on_crash()
957 clear_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath12k_core_reconfigure_on_crash()
959 ret = ath12k_core_qmi_firmware_ready(ab); in ath12k_core_reconfigure_on_crash()
963 clear_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); in ath12k_core_reconfigure_on_crash()
968 ath12k_hal_srng_deinit(ab); in ath12k_core_reconfigure_on_crash()
974 struct ath12k_base *ab = container_of(work, struct ath12k_base, rfkill_work); in ath12k_rfkill_work() local
981 spin_lock_bh(&ab->base_lock); in ath12k_rfkill_work()
982 rfkill_radio_on = ab->rfkill_radio_on; in ath12k_rfkill_work()
983 spin_unlock_bh(&ab->base_lock); in ath12k_rfkill_work()
985 for (i = 0; i < ab->num_hw; i++) { in ath12k_rfkill_work()
986 ah = ab->ah[i]; in ath12k_rfkill_work()
1005 struct ath12k_base *ab = ar->ab; in ath12k_core_halt() local
1016 cancel_work_sync(&ab->rfkill_work); in ath12k_core_halt()
1018 rcu_assign_pointer(ab->pdevs_active[ar->pdev_idx], NULL); in ath12k_core_halt()
1024 static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab) in ath12k_core_pre_reconfigure_recovery() argument
1030 spin_lock_bh(&ab->base_lock); in ath12k_core_pre_reconfigure_recovery()
1031 ab->stats.fw_crash_counter++; in ath12k_core_pre_reconfigure_recovery()
1032 spin_unlock_bh(&ab->base_lock); in ath12k_core_pre_reconfigure_recovery()
1034 if (ab->is_reset) in ath12k_core_pre_reconfigure_recovery()
1035 set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath12k_core_pre_reconfigure_recovery()
1037 for (i = 0; i < ab->num_hw; i++) { in ath12k_core_pre_reconfigure_recovery()
1038 ah = ab->ah[i]; in ath12k_core_pre_reconfigure_recovery()
1066 wake_up(&ab->wmi_ab.tx_credits_wq); in ath12k_core_pre_reconfigure_recovery()
1067 wake_up(&ab->peer_mapping_wq); in ath12k_core_pre_reconfigure_recovery()
1070 static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab) in ath12k_core_post_reconfigure_recovery() argument
1076 for (i = 0; i < ab->num_hw; i++) { in ath12k_core_post_reconfigure_recovery()
1077 ah = ab->ah[i]; in ath12k_core_post_reconfigure_recovery()
1097 ath12k_warn(ab, in ath12k_core_post_reconfigure_recovery()
1107 ath12k_warn(ab, in ath12k_core_post_reconfigure_recovery()
1115 complete(&ab->driver_recovery); in ath12k_core_post_reconfigure_recovery()
1120 struct ath12k_base *ab = container_of(work, struct ath12k_base, restart_work); in ath12k_core_restart() local
1124 ret = ath12k_core_reconfigure_on_crash(ab); in ath12k_core_restart()
1126 ath12k_err(ab, "failed to reconfigure driver on crash recovery\n"); in ath12k_core_restart()
1130 if (ab->is_reset) { in ath12k_core_restart()
1131 for (i = 0; i < ab->num_hw; i++) { in ath12k_core_restart()
1132 ah = ab->ah[i]; in ath12k_core_restart()
1137 complete(&ab->restart_completed); in ath12k_core_restart()
1142 struct ath12k_base *ab = container_of(work, struct ath12k_base, reset_work); in ath12k_core_reset() local
1146 if (!(test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags))) { in ath12k_core_reset()
1147 ath12k_warn(ab, "ignore reset dev flags 0x%lx\n", ab->dev_flags); in ath12k_core_reset()
1154 fail_cont_count = atomic_read(&ab->fail_cont_count); in ath12k_core_reset()
1160 time_before(jiffies, ab->reset_fail_timeout)) in ath12k_core_reset()
1163 reset_count = atomic_inc_return(&ab->reset_count); in ath12k_core_reset()
1170 ath12k_warn(ab, "already resetting count %d\n", reset_count); in ath12k_core_reset()
1172 reinit_completion(&ab->reset_complete); in ath12k_core_reset()
1173 time_left = wait_for_completion_timeout(&ab->reset_complete, in ath12k_core_reset()
1176 ath12k_dbg(ab, ATH12K_DBG_BOOT, "to skip reset\n"); in ath12k_core_reset()
1177 atomic_dec(&ab->reset_count); in ath12k_core_reset()
1181 ab->reset_fail_timeout = jiffies + ATH12K_RESET_FAIL_TIMEOUT_HZ; in ath12k_core_reset()
1183 fail_cont_count = atomic_inc_return(&ab->fail_cont_count); in ath12k_core_reset()
1186 ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset starting\n"); in ath12k_core_reset()
1188 ab->is_reset = true; in ath12k_core_reset()
1189 atomic_set(&ab->recovery_count, 0); in ath12k_core_reset()
1191 ath12k_core_pre_reconfigure_recovery(ab); in ath12k_core_reset()
1193 ath12k_core_post_reconfigure_recovery(ab); in ath12k_core_reset()
1195 ath12k_dbg(ab, ATH12K_DBG_BOOT, "waiting recovery start...\n"); in ath12k_core_reset()
1197 ath12k_hif_irq_disable(ab); in ath12k_core_reset()
1198 ath12k_hif_ce_irq_disable(ab); in ath12k_core_reset()
1200 ath12k_hif_power_down(ab, false); in ath12k_core_reset()
1201 ath12k_hif_power_up(ab); in ath12k_core_reset()
1203 ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset started\n"); in ath12k_core_reset()
1206 int ath12k_core_pre_init(struct ath12k_base *ab) in ath12k_core_pre_init() argument
1210 ret = ath12k_hw_init(ab); in ath12k_core_pre_init()
1212 ath12k_err(ab, "failed to init hw params: %d\n", ret); in ath12k_core_pre_init()
1216 ath12k_fw_map(ab); in ath12k_core_pre_init()
1224 struct ath12k_base *ab = container_of(nb, struct ath12k_base, in ath12k_core_panic_handler() local
1227 return ath12k_hif_panic_handler(ab); in ath12k_core_panic_handler()
1230 static int ath12k_core_panic_notifier_register(struct ath12k_base *ab) in ath12k_core_panic_notifier_register() argument
1232 ab->panic_nb.notifier_call = ath12k_core_panic_handler; in ath12k_core_panic_notifier_register()
1235 &ab->panic_nb); in ath12k_core_panic_notifier_register()
1238 static void ath12k_core_panic_notifier_unregister(struct ath12k_base *ab) in ath12k_core_panic_notifier_unregister() argument
1241 &ab->panic_nb); in ath12k_core_panic_notifier_unregister()
1244 int ath12k_core_init(struct ath12k_base *ab) in ath12k_core_init() argument
1248 ret = ath12k_core_soc_create(ab); in ath12k_core_init()
1250 ath12k_err(ab, "failed to create soc core: %d\n", ret); in ath12k_core_init()
1254 ret = ath12k_core_panic_notifier_register(ab); in ath12k_core_init()
1256 ath12k_warn(ab, "failed to register panic handler: %d\n", ret); in ath12k_core_init()
1261 void ath12k_core_deinit(struct ath12k_base *ab) in ath12k_core_deinit() argument
1263 ath12k_core_panic_notifier_unregister(ab); in ath12k_core_deinit()
1265 mutex_lock(&ab->core_lock); in ath12k_core_deinit()
1267 ath12k_core_pdev_destroy(ab); in ath12k_core_deinit()
1268 ath12k_core_stop(ab); in ath12k_core_deinit()
1270 mutex_unlock(&ab->core_lock); in ath12k_core_deinit()
1272 ath12k_hif_power_down(ab, false); in ath12k_core_deinit()
1273 ath12k_mac_destroy(ab); in ath12k_core_deinit()
1274 ath12k_core_soc_destroy(ab); in ath12k_core_deinit()
1275 ath12k_fw_unmap(ab); in ath12k_core_deinit()
1278 void ath12k_core_free(struct ath12k_base *ab) in ath12k_core_free() argument
1280 timer_delete_sync(&ab->rx_replenish_retry); in ath12k_core_free()
1281 destroy_workqueue(ab->workqueue_aux); in ath12k_core_free()
1282 destroy_workqueue(ab->workqueue); in ath12k_core_free()
1283 kfree(ab); in ath12k_core_free()
1289 struct ath12k_base *ab; in ath12k_core_alloc() local
1291 ab = kzalloc(sizeof(*ab) + priv_size, GFP_KERNEL); in ath12k_core_alloc()
1292 if (!ab) in ath12k_core_alloc()
1295 init_completion(&ab->driver_recovery); in ath12k_core_alloc()
1297 ab->workqueue = create_singlethread_workqueue("ath12k_wq"); in ath12k_core_alloc()
1298 if (!ab->workqueue) in ath12k_core_alloc()
1301 ab->workqueue_aux = create_singlethread_workqueue("ath12k_aux_wq"); in ath12k_core_alloc()
1302 if (!ab->workqueue_aux) in ath12k_core_alloc()
1305 mutex_init(&ab->core_lock); in ath12k_core_alloc()
1306 spin_lock_init(&ab->base_lock); in ath12k_core_alloc()
1307 init_completion(&ab->reset_complete); in ath12k_core_alloc()
1309 INIT_LIST_HEAD(&ab->peers); in ath12k_core_alloc()
1310 init_waitqueue_head(&ab->peer_mapping_wq); in ath12k_core_alloc()
1311 init_waitqueue_head(&ab->wmi_ab.tx_credits_wq); in ath12k_core_alloc()
1312 INIT_WORK(&ab->restart_work, ath12k_core_restart); in ath12k_core_alloc()
1313 INIT_WORK(&ab->reset_work, ath12k_core_reset); in ath12k_core_alloc()
1314 INIT_WORK(&ab->rfkill_work, ath12k_rfkill_work); in ath12k_core_alloc()
1316 timer_setup(&ab->rx_replenish_retry, ath12k_ce_rx_replenish_retry, 0); in ath12k_core_alloc()
1317 init_completion(&ab->htc_suspend); in ath12k_core_alloc()
1318 init_completion(&ab->restart_completed); in ath12k_core_alloc()
1319 init_completion(&ab->wow.wakeup_completed); in ath12k_core_alloc()
1321 ab->dev = dev; in ath12k_core_alloc()
1322 ab->hif.bus = bus; in ath12k_core_alloc()
1323 ab->qmi.num_radios = U8_MAX; in ath12k_core_alloc()
1324 ab->mlo_capable_flags = ATH12K_INTRA_DEVICE_MLO_SUPPORT; in ath12k_core_alloc()
1334 ab->device_id = 0; in ath12k_core_alloc()
1336 return ab; in ath12k_core_alloc()
1339 destroy_workqueue(ab->workqueue); in ath12k_core_alloc()
1341 kfree(ab); in ath12k_core_alloc()