Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Naman Padhiar | 07f0c71 | 2019-12-09 23:01:12 +0530 | [diff] [blame] | 2 | * Copyright (c) 2015-2020 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/pci.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21 | #include "cds_api.h" |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 22 | #include "qdf_status.h" |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 23 | #include "qdf_lock.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 24 | #include "cds_sched.h" |
| 25 | #include "osdep.h" |
| 26 | #include "hif.h" |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 27 | #include "htc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 28 | #include "epping_main.h" |
Dustin Brown | 6412d1f | 2019-02-05 14:52:29 -0800 | [diff] [blame] | 29 | #include "osif_sync.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 30 | #include "wlan_hdd_main.h" |
| 31 | #include "wlan_hdd_power.h" |
| 32 | #include "wlan_logging_sock_svc.h" |
| 33 | #include "wma_api.h" |
| 34 | #include "wlan_hdd_napi.h" |
Tushnim Bhattacharyya | 9028cc7 | 2017-03-09 13:10:49 -0800 | [diff] [blame] | 35 | #include "wlan_policy_mgr_api.h" |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 36 | #include "qwlan_version.h" |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 37 | #include "bmi.h" |
Rakesh Pillai | d2e5385 | 2019-09-13 04:20:13 +0530 | [diff] [blame] | 38 | #include <ol_defines.h> |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 39 | #include "cdp_txrx_bus.h" |
Sarada Prasanna Garnayak | e172263 | 2017-01-05 15:27:15 +0530 | [diff] [blame] | 40 | #include "cdp_txrx_misc.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 41 | #include "pld_common.h" |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 42 | #include "wlan_hdd_driver_ops.h" |
Sravan Kumar Kairam | 983a445 | 2018-03-20 13:30:22 +0530 | [diff] [blame] | 43 | #include "wlan_ipa_ucfg_api.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 44 | #include "wlan_hdd_debugfs.h" |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 45 | #include "cfg_ucfg_api.h" |
Alan Chen | 0f29e97 | 2019-09-04 12:04:22 -0700 | [diff] [blame] | 46 | #include <linux/suspend.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 47 | |
| 48 | #ifdef MODULE |
| 49 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 50 | #else |
| 51 | #define WLAN_MODULE_NAME "wlan" |
| 52 | #endif |
| 53 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 54 | #define DISABLE_KRAIT_IDLE_PS_VAL 1 |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 55 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 56 | #define SSR_MAX_FAIL_CNT 3 |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 57 | static uint8_t re_init_fail_cnt, probe_fail_cnt; |
| 58 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 59 | /* |
| 60 | * In BMI Phase we are only sending small chunk (256 bytes) of the FW image at |
| 61 | * a time, and wait for the completion interrupt to start the next transfer. |
| 62 | * During this phase, the KRAIT is entering IDLE/StandAlone(SA) Power Save(PS). |
| 63 | * The delay incurred for resuming from IDLE/SA PS is huge during driver load. |
| 64 | * So prevent APPS IDLE/SA PS durint driver load for reducing interrupt latency. |
| 65 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 66 | |
| 67 | static inline void hdd_request_pm_qos(struct device *dev, int val) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 68 | { |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 69 | pld_request_pm_qos(dev, val); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 70 | } |
| 71 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 72 | static inline void hdd_remove_pm_qos(struct device *dev) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 73 | { |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 74 | pld_remove_pm_qos(dev); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 75 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 76 | |
| 77 | /** |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 78 | * hdd_set_recovery_in_progress() - API to set recovery in progress |
| 79 | * @data: Context |
| 80 | * @val: Value to set |
| 81 | * |
| 82 | * Return: None |
| 83 | */ |
| 84 | static void hdd_set_recovery_in_progress(void *data, uint8_t val) |
| 85 | { |
| 86 | cds_set_recovery_in_progress(val); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * hdd_is_driver_unloading() - API to query if driver is unloading |
| 91 | * @data: Private Data |
| 92 | * |
| 93 | * Return: True/False |
| 94 | */ |
| 95 | static bool hdd_is_driver_unloading(void *data) |
| 96 | { |
| 97 | return cds_is_driver_unloading(); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * hdd_is_load_or_unload_in_progress() - API to query if driver is |
| 102 | * loading/unloading |
| 103 | * @data: Private Data |
| 104 | * |
| 105 | * Return: bool |
| 106 | */ |
| 107 | static bool hdd_is_load_or_unload_in_progress(void *data) |
| 108 | { |
| 109 | return cds_is_load_or_unload_in_progress(); |
| 110 | } |
| 111 | |
| 112 | /** |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 113 | * hdd_is_recovery_in_progress() - API to query if recovery in progress |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 114 | * @data: Private Data |
| 115 | * |
| 116 | * Return: bool |
| 117 | */ |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 118 | static bool hdd_is_recovery_in_progress(void *data) |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 119 | { |
| 120 | return cds_is_driver_recovering(); |
| 121 | } |
| 122 | |
| 123 | /** |
Govind Singh | a1f6dac | 2017-06-13 11:45:07 +0530 | [diff] [blame] | 124 | * hdd_is_target_ready() - API to query if target is in ready state |
| 125 | * @data: Private Data |
| 126 | * |
| 127 | * Return: bool |
| 128 | */ |
| 129 | static bool hdd_is_target_ready(void *data) |
| 130 | { |
| 131 | return cds_is_target_ready(); |
| 132 | } |
| 133 | |
| 134 | /** |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 135 | * hdd_hif_init_driver_state_callbacks() - API to initialize HIF callbacks |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 136 | * @data: Private Data |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 137 | * @cbk: HIF Driver State callbacks |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 138 | * |
| 139 | * HIF should be independent of CDS calls. Pass CDS Callbacks to HIF, HIF will |
| 140 | * call the callbacks. |
| 141 | * |
| 142 | * Return: void |
| 143 | */ |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 144 | static void hdd_hif_init_driver_state_callbacks(void *data, |
| 145 | struct hif_driver_state_callbacks *cbk) |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 146 | { |
| 147 | cbk->context = data; |
| 148 | cbk->set_recovery_in_progress = hdd_set_recovery_in_progress; |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 149 | cbk->is_recovery_in_progress = hdd_is_recovery_in_progress; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 150 | cbk->is_load_unload_in_progress = hdd_is_load_or_unload_in_progress; |
| 151 | cbk->is_driver_unloading = hdd_is_driver_unloading; |
Govind Singh | a1f6dac | 2017-06-13 11:45:07 +0530 | [diff] [blame] | 152 | cbk->is_target_ready = hdd_is_target_ready; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 153 | } |
| 154 | |
Venkata Sharath Chandra Manchala | 06f1f12 | 2019-10-29 13:22:15 -0700 | [diff] [blame] | 155 | #ifdef FORCE_WAKE |
| 156 | void hdd_set_hif_init_phase(struct hif_opaque_softc *hif_ctx, |
| 157 | bool hal_init_phase) |
| 158 | { |
| 159 | hif_srng_init_phase(hif_ctx, hal_init_phase); |
| 160 | } |
| 161 | #endif /* FORCE_WAKE */ |
| 162 | |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 163 | /** |
hangtian | 1c37fb9 | 2019-04-10 11:15:20 +0800 | [diff] [blame] | 164 | * hdd_hif_set_attribute() - API to set CE attribute if memory is limited |
| 165 | * @hif_ctx: hif context |
| 166 | * |
| 167 | * Return: None |
| 168 | */ |
Hangtian Zhu | 39e2e21 | 2019-09-02 13:34:57 +0800 | [diff] [blame] | 169 | #ifdef SLUB_MEM_OPTIMIZE |
hangtian | 1c37fb9 | 2019-04-10 11:15:20 +0800 | [diff] [blame] | 170 | static void hdd_hif_set_attribute(struct hif_opaque_softc *hif_ctx) |
| 171 | { |
| 172 | hif_set_attribute(hif_ctx, HIF_LOWDESC_CE_NO_PKTLOG_CFG); |
| 173 | } |
| 174 | #else |
| 175 | static void hdd_hif_set_attribute(struct hif_opaque_softc *hif_ctx) |
| 176 | {} |
| 177 | #endif |
| 178 | |
| 179 | /** |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 180 | * hdd_init_cds_hif_context() - API to set CDS HIF Context |
| 181 | * @hif: HIF Context |
| 182 | * |
| 183 | * Return: success/failure |
| 184 | */ |
| 185 | static int hdd_init_cds_hif_context(void *hif) |
| 186 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 187 | QDF_STATUS status; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 188 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 189 | status = cds_set_context(QDF_MODULE_ID_HIF, hif); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 190 | |
| 191 | if (status) |
| 192 | return -ENOENT; |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * hdd_deinit_cds_hif_context() - API to clear CDS HIF COntext |
| 199 | * |
| 200 | * Return: None |
| 201 | */ |
| 202 | static void hdd_deinit_cds_hif_context(void) |
| 203 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 204 | QDF_STATUS status; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 205 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 206 | status = cds_set_context(QDF_MODULE_ID_HIF, NULL); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 207 | |
| 208 | if (status) |
| 209 | hdd_err("Failed to reset CDS HIF Context"); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 213 | * to_bus_type() - Map PLD bus type to low level bus type |
| 214 | * @bus_type: PLD bus type |
| 215 | * |
| 216 | * Map PLD bus type to low level bus type. |
| 217 | * |
| 218 | * Return: low level bus type. |
| 219 | */ |
| 220 | static enum qdf_bus_type to_bus_type(enum pld_bus_type bus_type) |
| 221 | { |
| 222 | switch (bus_type) { |
Naman Padhiar | c52e7fd | 2019-06-23 01:21:42 +0530 | [diff] [blame] | 223 | case PLD_BUS_TYPE_PCIE_FW_SIM: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 224 | case PLD_BUS_TYPE_PCIE: |
| 225 | return QDF_BUS_TYPE_PCI; |
Naman Padhiar | c52e7fd | 2019-06-23 01:21:42 +0530 | [diff] [blame] | 226 | case PLD_BUS_TYPE_SNOC_FW_SIM: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 227 | case PLD_BUS_TYPE_SNOC: |
| 228 | return QDF_BUS_TYPE_SNOC; |
Poddar, Siddarth | 3e9fa5c | 2016-05-13 14:25:05 +0530 | [diff] [blame] | 229 | case PLD_BUS_TYPE_SDIO: |
| 230 | return QDF_BUS_TYPE_SDIO; |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 231 | case PLD_BUS_TYPE_USB: |
| 232 | return QDF_BUS_TYPE_USB; |
Naman Padhiar | 07f0c71 | 2019-12-09 23:01:12 +0530 | [diff] [blame] | 233 | case PLD_BUS_TYPE_IPCI: |
| 234 | return QDF_BUS_TYPE_IPCI; |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 235 | default: |
| 236 | return QDF_BUS_TYPE_NONE; |
| 237 | } |
| 238 | } |
| 239 | |
Manikandan Mohan | 617a516 | 2017-04-10 13:14:40 -0700 | [diff] [blame] | 240 | int hdd_hif_open(struct device *dev, void *bdev, const struct hif_bus_id *bid, |
Anurag Chouhan | 2ed1fce | 2016-02-22 15:07:01 +0530 | [diff] [blame] | 241 | enum qdf_bus_type bus_type, bool reinit) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 242 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 243 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 244 | int ret = 0; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 245 | struct hif_opaque_softc *hif_ctx; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 246 | qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 247 | struct hif_driver_state_callbacks cbk; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 248 | uint32_t mode = cds_get_conparam(); |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 249 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Govind Singh | 068c4b0 | 2016-08-17 16:37:13 +0530 | [diff] [blame] | 250 | |
| 251 | if (!hdd_ctx) { |
| 252 | hdd_err("hdd_ctx error"); |
| 253 | return -EFAULT; |
| 254 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 255 | |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 256 | hdd_hif_init_driver_state_callbacks(dev, &cbk); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 257 | |
Venkata Sharath Chandra Manchala | 0d0ef55 | 2020-01-07 16:37:43 -0800 | [diff] [blame^] | 258 | hif_ctx = hif_open(qdf_ctx, mode, bus_type, &cbk, hdd_ctx->psoc); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 259 | if (!hif_ctx) { |
| 260 | hdd_err("hif_open error"); |
| 261 | return -ENOMEM; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 264 | ret = hdd_init_cds_hif_context(hif_ctx); |
| 265 | if (ret) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 266 | hdd_err("Failed to set global HIF CDS Context err: %d", ret); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 267 | goto err_hif_close; |
| 268 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 269 | |
hangtian | 1c37fb9 | 2019-04-10 11:15:20 +0800 | [diff] [blame] | 270 | hdd_hif_set_attribute(hif_ctx); |
| 271 | |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 272 | status = hif_enable(hif_ctx, dev, bdev, bid, bus_type, |
| 273 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 274 | HIF_ENABLE_TYPE_PROBE); |
| 275 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 276 | hdd_err("hif_enable failed status: %d, reinit: %d", |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 277 | status, reinit); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 278 | |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 279 | ret = qdf_status_to_os_return(status); |
| 280 | goto err_hif_close; |
| 281 | } else { |
Yuanyuan Liu | 057fc4c | 2018-01-08 10:50:28 -0800 | [diff] [blame] | 282 | cds_set_target_ready(true); |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 283 | ret = hdd_napi_create(); |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 284 | hdd_debug("hdd_napi_create returned: %d", ret); |
Manjunathappa Prakash | 9dd1913 | 2016-04-21 16:27:04 -0700 | [diff] [blame] | 285 | if (ret == 0) |
| 286 | hdd_warn("NAPI: no instances are created"); |
| 287 | else if (ret < 0) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 288 | hdd_err("NAPI creation error, rc: 0x%x, reinit: %d", |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 289 | ret, reinit); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 290 | ret = -EFAULT; |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 291 | goto mark_target_not_ready; |
Govind Singh | 068c4b0 | 2016-08-17 16:37:13 +0530 | [diff] [blame] | 292 | } else { |
| 293 | hdd_napi_event(NAPI_EVT_INI_FILE, |
| 294 | (void *)hdd_ctx->napi_enable); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | |
Himanshu Agarwal | 24aa27e | 2017-05-23 11:07:50 +0530 | [diff] [blame] | 298 | hif_set_ce_service_max_yield_time(hif_ctx, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 299 | cfg_get(hdd_ctx->psoc, |
| 300 | CFG_DP_CE_SERVICE_MAX_YIELD_TIME)); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 301 | ucfg_pmo_psoc_set_hif_handle(hdd_ctx->psoc, hif_ctx); |
Poddar, Siddarth | 04eed33 | 2017-06-28 14:20:26 +0530 | [diff] [blame] | 302 | hif_set_ce_service_max_rx_ind_flush(hif_ctx, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 303 | cfg_get(hdd_ctx->psoc, |
| 304 | CFG_DP_CE_SERVICE_MAX_RX_IND_FLUSH)); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 305 | return 0; |
| 306 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 307 | mark_target_not_ready: |
| 308 | cds_set_target_ready(false); |
| 309 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 310 | err_hif_close: |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 311 | hdd_deinit_cds_hif_context(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 312 | hif_close(hif_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 313 | return ret; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 316 | void hdd_hif_close(struct hdd_context *hdd_ctx, void *hif_ctx) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 317 | { |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 318 | if (!hdd_ctx) { |
| 319 | hdd_err("hdd_ctx error"); |
| 320 | return; |
| 321 | } |
| 322 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 323 | if (!hif_ctx) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 324 | return; |
| 325 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 326 | cds_set_target_ready(false); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 327 | hif_disable(hif_ctx, HIF_DISABLE_TYPE_REMOVE); |
| 328 | |
| 329 | hdd_napi_destroy(true); |
| 330 | |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 331 | hdd_deinit_cds_hif_context(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 332 | hif_close(hif_ctx); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 333 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 334 | ucfg_pmo_psoc_set_hif_handle(hdd_ctx->psoc, NULL); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 335 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | |
| 337 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 338 | * hdd_init_qdf_ctx() - API to initialize global QDF Device structure |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 339 | * @dev: Device Pointer |
| 340 | * @bdev: Bus Device pointer |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 341 | * @bus_type: Underlying bus type |
| 342 | * @bid: Bus id passed by platform driver |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 343 | * |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 344 | * Return: 0 - success, < 0 - failure |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 345 | */ |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 346 | static int hdd_init_qdf_ctx(struct device *dev, void *bdev, |
| 347 | enum qdf_bus_type bus_type, |
| 348 | const struct hif_bus_id *bid) |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 349 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 350 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 351 | |
Jeff Johnson | 615d4bb | 2016-07-20 11:03:04 -0700 | [diff] [blame] | 352 | if (!qdf_dev) { |
| 353 | hdd_err("Invalid QDF device"); |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 354 | return -EINVAL; |
Jeff Johnson | 615d4bb | 2016-07-20 11:03:04 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 357 | qdf_dev->dev = dev; |
| 358 | qdf_dev->drv_hdl = bdev; |
Govind Singh | 9db91ba | 2016-04-29 14:15:47 +0530 | [diff] [blame] | 359 | qdf_dev->bus_type = bus_type; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 360 | qdf_dev->bid = bid; |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 361 | |
Sravan Kumar Kairam | 983a445 | 2018-03-20 13:30:22 +0530 | [diff] [blame] | 362 | if (cds_smmu_mem_map_setup(qdf_dev, ucfg_ipa_is_present()) != |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 363 | QDF_STATUS_SUCCESS) { |
| 364 | hdd_err("cds_smmu_mem_map_setup() failed"); |
| 365 | return -EFAULT; |
| 366 | } |
| 367 | |
| 368 | return 0; |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /** |
Yuanyuan Liu | 5583b2c | 2017-10-09 17:30:13 -0700 | [diff] [blame] | 372 | * check_for_probe_defer() - API to check return value |
| 373 | * @ret: Return Value |
| 374 | * |
| 375 | * Return: return -EPROBE_DEFER to platform driver if return value |
| 376 | * is -ENOMEM. Platform driver will try to re-probe. |
| 377 | */ |
| 378 | #ifdef MODULE |
| 379 | static int check_for_probe_defer(int ret) |
| 380 | { |
| 381 | return ret; |
| 382 | } |
| 383 | #else |
| 384 | static int check_for_probe_defer(int ret) |
| 385 | { |
| 386 | if (ret == -ENOMEM) |
| 387 | return -EPROBE_DEFER; |
| 388 | return ret; |
| 389 | } |
| 390 | #endif |
| 391 | |
Alan Chen | 32c6048 | 2019-08-08 17:26:54 -0700 | [diff] [blame] | 392 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 393 | static void hdd_abort_system_suspend(struct device *dev) |
Alan Chen | e523cd9 | 2019-07-15 16:45:09 -0700 | [diff] [blame] | 394 | { |
Alan Chen | e119c7d | 2019-11-14 15:05:37 -0800 | [diff] [blame] | 395 | qdf_pm_system_wakeup(); |
Alan Chen | 32c6048 | 2019-08-08 17:26:54 -0700 | [diff] [blame] | 396 | } |
| 397 | #else |
| 398 | static void hdd_abort_system_suspend(struct device *dev) |
| 399 | { |
| 400 | } |
| 401 | #endif |
| 402 | |
Alan Chen | 0f29e97 | 2019-09-04 12:04:22 -0700 | [diff] [blame] | 403 | int hdd_soc_idle_restart_lock(struct device *dev) |
| 404 | { |
Alan Chen | e523cd9 | 2019-07-15 16:45:09 -0700 | [diff] [blame] | 405 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_IDLE_RESTART); |
Alan Chen | 0f29e97 | 2019-09-04 12:04:22 -0700 | [diff] [blame] | 406 | |
| 407 | hdd_abort_system_suspend(dev); |
| 408 | |
Alan Chen | 0f29e97 | 2019-09-04 12:04:22 -0700 | [diff] [blame] | 409 | return 0; |
Alan Chen | e523cd9 | 2019-07-15 16:45:09 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | void hdd_soc_idle_restart_unlock(void) |
| 413 | { |
| 414 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_IDLE_RESTART); |
| 415 | } |
| 416 | |
Dustin Brown | b748768 | 2019-03-19 13:48:55 -0700 | [diff] [blame] | 417 | static void hdd_soc_load_lock(struct device *dev) |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 418 | { |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 419 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
| 420 | hdd_request_pm_qos(dev, DISABLE_KRAIT_IDLE_PS_VAL); |
| 421 | } |
| 422 | |
| 423 | static void hdd_soc_load_unlock(struct device *dev) |
| 424 | { |
| 425 | hdd_remove_pm_qos(dev); |
| 426 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 427 | } |
| 428 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 429 | static int __hdd_soc_probe(struct device *dev, |
| 430 | void *bdev, |
| 431 | const struct hif_bus_id *bid, |
| 432 | enum qdf_bus_type bus_type) |
| 433 | { |
| 434 | struct hdd_context *hdd_ctx; |
| 435 | QDF_STATUS status; |
| 436 | int errno; |
| 437 | |
| 438 | hdd_info("probing driver"); |
| 439 | |
Dustin Brown | b748768 | 2019-03-19 13:48:55 -0700 | [diff] [blame] | 440 | hdd_soc_load_lock(dev); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 441 | cds_set_load_in_progress(true); |
| 442 | cds_set_driver_in_bad_state(false); |
| 443 | cds_set_recovery_in_progress(false); |
| 444 | |
| 445 | errno = hdd_init_qdf_ctx(dev, bdev, bus_type, bid); |
| 446 | if (errno) |
| 447 | goto unlock; |
| 448 | |
| 449 | hdd_ctx = hdd_context_create(dev); |
| 450 | if (IS_ERR(hdd_ctx)) { |
| 451 | errno = PTR_ERR(hdd_ctx); |
| 452 | goto assert_fail_count; |
| 453 | } |
| 454 | |
| 455 | errno = hdd_wlan_startup(hdd_ctx); |
| 456 | if (errno) |
| 457 | goto hdd_context_destroy; |
| 458 | |
| 459 | status = hdd_psoc_create_vdevs(hdd_ctx); |
| 460 | if (QDF_IS_STATUS_ERROR(status)) { |
| 461 | errno = qdf_status_to_os_return(status); |
| 462 | goto wlan_exit; |
| 463 | } |
| 464 | |
| 465 | probe_fail_cnt = 0; |
| 466 | cds_set_driver_loaded(true); |
| 467 | cds_set_load_in_progress(false); |
| 468 | hdd_start_complete(0); |
| 469 | |
| 470 | hdd_soc_load_unlock(dev); |
| 471 | |
| 472 | return 0; |
| 473 | |
| 474 | wlan_exit: |
| 475 | hdd_wlan_exit(hdd_ctx); |
| 476 | |
| 477 | hdd_context_destroy: |
| 478 | hdd_context_destroy(hdd_ctx); |
| 479 | |
| 480 | assert_fail_count: |
| 481 | probe_fail_cnt++; |
| 482 | hdd_err("consecutive probe failures:%u", probe_fail_cnt); |
| 483 | QDF_BUG(probe_fail_cnt < SSR_MAX_FAIL_CNT); |
| 484 | |
| 485 | unlock: |
| 486 | cds_set_load_in_progress(false); |
| 487 | hdd_soc_load_unlock(dev); |
| 488 | |
| 489 | return check_for_probe_defer(errno); |
| 490 | } |
| 491 | |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 492 | /** |
| 493 | * hdd_soc_probe() - perform SoC probe |
| 494 | * @dev: kernel device being probed |
| 495 | * @bdev: bus device structure |
| 496 | * @bid: bus identifier for shared busses |
| 497 | * @bus_type: underlying bus type |
| 498 | * |
| 499 | * A SoC probe indicates new SoC hardware has become available and needs to be |
| 500 | * initialized. |
| 501 | * |
| 502 | * Return: Errno |
| 503 | */ |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 504 | static int hdd_soc_probe(struct device *dev, |
| 505 | void *bdev, |
| 506 | const struct hif_bus_id *bid, |
| 507 | enum qdf_bus_type bus_type) |
| 508 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 509 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 510 | int errno; |
| 511 | |
| 512 | hdd_info("probing driver"); |
| 513 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 514 | errno = osif_psoc_sync_create_and_trans(&psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 515 | if (errno) |
| 516 | return errno; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 517 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 518 | osif_psoc_sync_register(dev, psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 519 | errno = __hdd_soc_probe(dev, bdev, bid, bus_type); |
| 520 | if (errno) |
| 521 | goto destroy_sync; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 522 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 523 | osif_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 524 | |
| 525 | return 0; |
| 526 | |
| 527 | destroy_sync: |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 528 | osif_psoc_sync_unregister(dev); |
| 529 | osif_psoc_sync_wait_for_ops(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 530 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 531 | osif_psoc_sync_trans_stop(psoc_sync); |
| 532 | osif_psoc_sync_destroy(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 533 | |
| 534 | return errno; |
| 535 | } |
| 536 | |
| 537 | static int __hdd_soc_recovery_reinit(struct device *dev, |
| 538 | void *bdev, |
| 539 | const struct hif_bus_id *bid, |
| 540 | enum qdf_bus_type bus_type) |
| 541 | { |
| 542 | int errno; |
| 543 | |
| 544 | hdd_info("re-probing driver"); |
| 545 | |
Dustin Brown | b748768 | 2019-03-19 13:48:55 -0700 | [diff] [blame] | 546 | hdd_soc_load_lock(dev); |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 547 | cds_set_driver_in_bad_state(false); |
| 548 | |
| 549 | errno = hdd_init_qdf_ctx(dev, bdev, bus_type, bid); |
| 550 | if (errno) |
| 551 | goto unlock; |
| 552 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 553 | errno = hdd_wlan_re_init(); |
| 554 | if (errno) { |
| 555 | re_init_fail_cnt++; |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 556 | goto assert_fail_count; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 559 | re_init_fail_cnt = 0; |
| 560 | cds_set_recovery_in_progress(false); |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 561 | |
| 562 | hdd_soc_load_unlock(dev); |
| 563 | |
| 564 | return 0; |
| 565 | |
| 566 | assert_fail_count: |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 567 | hdd_err("consecutive reinit failures:%u", re_init_fail_cnt); |
| 568 | QDF_BUG(re_init_fail_cnt < SSR_MAX_FAIL_CNT); |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 569 | |
| 570 | unlock: |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 571 | cds_set_driver_in_bad_state(true); |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 572 | hdd_soc_load_unlock(dev); |
| 573 | |
| 574 | return check_for_probe_defer(errno); |
| 575 | } |
| 576 | |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 577 | /** |
| 578 | * hdd_soc_recovery_reinit() - perform PDR/SSR SoC reinit |
| 579 | * @dev: the kernel device being re-initialized |
| 580 | * @bdev: bus device structure |
| 581 | * @bid: bus identifier for shared busses |
| 582 | * @bus_type: underlying bus type |
| 583 | * |
| 584 | * When communication with firmware breaks down, a SoC recovery process kicks in |
| 585 | * with two phases: shutdown and reinit. |
| 586 | * |
| 587 | * SSR reinit is similar to a 'probe' but happens in response to an SSR |
| 588 | * shutdown. The idea is to re-initialize the SoC to as close to its old, |
| 589 | * pre-communications-breakdown configuration as possible. This is completely |
| 590 | * transparent from a userspace point of view. |
| 591 | * |
| 592 | * Return: Errno |
| 593 | */ |
| 594 | static int hdd_soc_recovery_reinit(struct device *dev, |
| 595 | void *bdev, |
| 596 | const struct hif_bus_id *bid, |
| 597 | enum qdf_bus_type bus_type) |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 598 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 599 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 600 | int errno; |
| 601 | |
Dustin Brown | f967e48 | 2018-09-20 16:29:04 -0700 | [diff] [blame] | 602 | /* SSR transition is initiated at the beginning of soc shutdown */ |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 603 | errno = osif_psoc_sync_trans_resume(dev, &psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 604 | QDF_BUG(!errno); |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 605 | if (errno) |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 606 | return errno; |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 607 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 608 | errno = __hdd_soc_recovery_reinit(dev, bdev, bid, bus_type); |
| 609 | if (errno) |
| 610 | return errno; |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 611 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 612 | osif_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | f967e48 | 2018-09-20 16:29:04 -0700 | [diff] [blame] | 613 | |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 614 | return 0; |
Dustin Brown | 024c9cd | 2018-07-31 17:09:30 -0700 | [diff] [blame] | 615 | } |
| 616 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 617 | static void __hdd_soc_remove(struct device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 618 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 619 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | f10f177 | 2018-12-28 12:00:15 -0800 | [diff] [blame] | 620 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 621 | QDF_BUG(hdd_ctx); |
| 622 | if (!hdd_ctx) |
Rajeev Kumar | f10f177 | 2018-12-28 12:00:15 -0800 | [diff] [blame] | 623 | return; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 624 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 625 | pr_info("%s: Removing driver v%s\n", WLAN_MODULE_NAME, |
| 626 | QWLAN_VERSIONSTR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 627 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 628 | cds_set_driver_loaded(false); |
| 629 | cds_set_unload_in_progress(true); |
| 630 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 631 | if (!hdd_wait_for_debugfs_threads_completion()) |
| 632 | hdd_warn("Debugfs threads are still active attempting driver unload anyway"); |
| 633 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 634 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 635 | hdd_wlan_stop_modules(hdd_ctx, false); |
Guisen Yang | 2780b92 | 2019-06-03 16:21:39 +0800 | [diff] [blame] | 636 | qdf_nbuf_deinit_replenish_timer(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 637 | } else { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 638 | hdd_wlan_exit(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | } |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 640 | |
| 641 | hdd_context_destroy(hdd_ctx); |
| 642 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 643 | cds_set_driver_in_bad_state(false); |
Hanumanth Reddy Pothula | fc70ea3 | 2017-01-18 18:19:08 +0530 | [diff] [blame] | 644 | cds_set_unload_in_progress(false); |
| 645 | |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 646 | pr_info("%s: Driver De-initialized\n", WLAN_MODULE_NAME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 647 | } |
| 648 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 649 | /** |
| 650 | * hdd_soc_remove() - perform SoC remove |
| 651 | * @dev: the kernel device being removed |
| 652 | * |
| 653 | * A SoC remove indicates the attached SoC hardware is about to go away and |
| 654 | * needs to be cleaned up. |
| 655 | * |
| 656 | * Return: void |
| 657 | */ |
| 658 | static void hdd_soc_remove(struct device *dev) |
| 659 | { |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 660 | __hdd_soc_remove(dev); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 661 | } |
| 662 | |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 663 | #ifdef FEATURE_WLAN_DIAG_SUPPORT |
| 664 | /** |
| 665 | * hdd_wlan_ssr_shutdown_event()- send ssr shutdown state |
| 666 | * |
| 667 | * This Function send send ssr shutdown state diag event |
| 668 | * |
| 669 | * Return: void. |
| 670 | */ |
| 671 | static void hdd_wlan_ssr_shutdown_event(void) |
| 672 | { |
| 673 | WLAN_HOST_DIAG_EVENT_DEF(ssr_shutdown, |
| 674 | struct host_event_wlan_ssr_shutdown); |
| 675 | qdf_mem_zero(&ssr_shutdown, sizeof(ssr_shutdown)); |
| 676 | ssr_shutdown.status = SSR_SUB_SYSTEM_SHUTDOWN; |
| 677 | WLAN_HOST_DIAG_EVENT_REPORT(&ssr_shutdown, |
| 678 | EVENT_WLAN_SSR_SHUTDOWN_SUBSYSTEM); |
| 679 | } |
| 680 | #else |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 681 | static inline void hdd_wlan_ssr_shutdown_event(void) { } |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 682 | #endif |
| 683 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 684 | /** |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 685 | * hdd_send_hang_reason() - Send hang reason to the userspace |
| 686 | * |
| 687 | * Return: None |
| 688 | */ |
| 689 | static void hdd_send_hang_reason(void) |
| 690 | { |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 691 | enum qdf_hang_reason reason = QDF_REASON_UNSPECIFIED; |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 692 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 693 | |
Sourav Mohapatra | 07b057f | 2019-10-29 11:31:39 +0530 | [diff] [blame] | 694 | if (!hdd_ctx) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 695 | return; |
| 696 | |
| 697 | cds_get_recovery_reason(&reason); |
| 698 | cds_reset_recovery_reason(); |
| 699 | wlan_hdd_send_hang_reason_event(hdd_ctx, reason); |
| 700 | } |
| 701 | |
| 702 | /** |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 703 | * hdd_psoc_shutdown_notify() - notify the various interested parties that the |
| 704 | * soc is starting recovery shutdown |
| 705 | * @hdd_ctx: the HDD context corresponding to the soc undergoing shutdown |
| 706 | * |
| 707 | * Return: None |
| 708 | */ |
| 709 | static void hdd_psoc_shutdown_notify(struct hdd_context *hdd_ctx) |
| 710 | { |
| 711 | /* Notify external threads currently waiting on firmware by forcefully |
| 712 | * completing waiting events with a "reset" status. This will cause the |
| 713 | * event to fail early instead of timing out. |
| 714 | */ |
| 715 | qdf_complete_wait_events(); |
| 716 | |
| 717 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
| 718 | |
| 719 | if (ucfg_ipa_is_enabled()) { |
| 720 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->pdev); |
| 721 | |
Vevek Venkatesan | 789b6b3 | 2019-04-15 13:05:10 +0530 | [diff] [blame] | 722 | if (pld_is_fw_rejuvenate(hdd_ctx->parent_dev) || |
| 723 | pld_is_pdr(hdd_ctx->parent_dev)) |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 724 | ucfg_ipa_fw_rejuvenate_send_msg(hdd_ctx->pdev); |
| 725 | } |
| 726 | |
| 727 | cds_shutdown_notifier_call(); |
| 728 | cds_shutdown_notifier_purge(); |
| 729 | |
| 730 | hdd_wlan_ssr_shutdown_event(); |
| 731 | hdd_send_hang_reason(); |
| 732 | } |
| 733 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 734 | static void __hdd_soc_recovery_shutdown(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 735 | { |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 736 | struct hdd_context *hdd_ctx; |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 737 | void *hif_ctx; |
bings | 5f0ae14 | 2017-07-14 17:52:45 +0800 | [diff] [blame] | 738 | |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 739 | /* recovery starts via firmware down indication; ensure we got one */ |
| 740 | QDF_BUG(cds_is_driver_recovering()); |
| 741 | |
| 742 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 743 | if (!hdd_ctx) { |
| 744 | hdd_err("hdd_ctx is null"); |
| 745 | return; |
| 746 | } |
| 747 | |
| 748 | /* cancel/flush any pending/active idle shutdown work */ |
| 749 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Kumar Khandavalli | a4cedce | 2019-11-25 20:03:09 +0530 | [diff] [blame] | 750 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 751 | |
| 752 | /* nothing to do if the soc is already unloaded */ |
| 753 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 754 | hdd_info("Driver modules are already closed"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 755 | return; |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 756 | } |
| 757 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 758 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 759 | hdd_info("Load/unload in progress, ignore SSR shutdown"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 760 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | } |
Ashish Kumar Dhanotiya | e4e6c5b | 2018-03-22 14:41:10 +0530 | [diff] [blame] | 762 | |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 763 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 764 | if (!hif_ctx) { |
| 765 | hdd_err("Failed to get HIF context, ignore SSR shutdown"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 766 | return; |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | /* mask the host controller interrupts */ |
| 770 | hif_mask_interrupt_call(hif_ctx); |
| 771 | |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 772 | hdd_psoc_shutdown_notify(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 773 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 774 | if (!hdd_wait_for_debugfs_threads_completion()) |
| 775 | hdd_err("Debufs threads are still pending, attempting SSR anyway"); |
| 776 | |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 777 | if (!QDF_IS_EPPING_ENABLED(cds_get_conparam())) { |
bings | 5f0ae14 | 2017-07-14 17:52:45 +0800 | [diff] [blame] | 778 | hif_disable_isr(hif_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 779 | hdd_wlan_shutdown(); |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 780 | } |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | /** |
| 784 | * hdd_soc_recovery_shutdown() - perform PDR/SSR SoC shutdown |
| 785 | * @dev: the device to shutdown |
| 786 | * |
| 787 | * When communication with firmware breaks down, a SoC recovery process kicks in |
| 788 | * with two phases: shutdown and reinit. |
| 789 | * |
| 790 | * SSR shutdown is similar to a 'remove' but without communication with |
| 791 | * firmware. The idea is to retain as much SoC configuration as possible, so it |
| 792 | * can be re-initialized to the same state after a reset. This is completely |
| 793 | * transparent from a userspace point of view. |
| 794 | * |
| 795 | * Return: void |
| 796 | */ |
| 797 | static void hdd_soc_recovery_shutdown(struct device *dev) |
| 798 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 799 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 800 | int errno; |
| 801 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 802 | errno = osif_psoc_sync_trans_start_wait(dev, &psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 803 | QDF_BUG(!errno); |
| 804 | if (errno) |
| 805 | return; |
| 806 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 807 | osif_psoc_sync_wait_for_ops(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 808 | |
| 809 | __hdd_soc_recovery_shutdown(); |
Dustin Brown | f967e48 | 2018-09-20 16:29:04 -0700 | [diff] [blame] | 810 | |
Dustin Brown | 5a26dae | 2018-11-15 10:08:42 -0800 | [diff] [blame] | 811 | /* SSR transition is concluded at the end of soc re-init */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | /** |
| 815 | * wlan_hdd_crash_shutdown() - wlan_hdd_crash_shutdown |
| 816 | * |
Jeff Johnson | 37a4126 | 2018-05-06 17:09:55 -0700 | [diff] [blame] | 817 | * HDD crash shutdown function: This function is called by |
Jeff Johnson | 453e6c0 | 2018-05-06 15:52:11 -0700 | [diff] [blame] | 818 | * platform driver's crash shutdown routine |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 819 | * |
| 820 | * Return: void |
| 821 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 822 | static void wlan_hdd_crash_shutdown(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | { |
Yu Wang | 46082dc | 2017-09-19 12:25:38 +0800 | [diff] [blame] | 824 | QDF_STATUS ret; |
| 825 | WMA_HANDLE wma_handle = cds_get_context(QDF_MODULE_ID_WMA); |
| 826 | |
| 827 | if (!wma_handle) { |
| 828 | hdd_err("wma_handle is null"); |
| 829 | return; |
| 830 | } |
| 831 | |
| 832 | /* |
| 833 | * When kernel panic happen, if WiFi FW is still active |
| 834 | * it may cause NOC errors/memory corruption, to avoid |
| 835 | * this, inject a fw crash first. |
| 836 | * send crash_inject to FW directly, because we are now |
| 837 | * in an atomic context, and preempt has been disabled, |
| 838 | * MCThread won't be scheduled at the moment, at the same |
| 839 | * time, TargetFailure event wont't be received after inject |
| 840 | * crash due to the same reason. |
| 841 | */ |
| 842 | ret = wma_crash_inject(wma_handle, RECOVERY_SIM_ASSERT, 0); |
| 843 | if (QDF_IS_STATUS_ERROR(ret)) { |
| 844 | hdd_err("Failed to send crash inject:%d", ret); |
| 845 | return; |
| 846 | } |
| 847 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 848 | hif_crash_shutdown(cds_get_context(QDF_MODULE_ID_HIF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | /** |
| 852 | * wlan_hdd_notify_handler() - wlan_hdd_notify_handler |
| 853 | * |
| 854 | * This function is called by the platform driver to notify the |
| 855 | * COEX |
| 856 | * |
| 857 | * @state: state |
| 858 | * |
| 859 | * Return: void |
| 860 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 861 | static void wlan_hdd_notify_handler(int state) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 862 | { |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 863 | if (!QDF_IS_EPPING_ENABLED(cds_get_conparam())) { |
Jeff Johnson | 10251bc | 2017-03-24 15:30:52 -0700 | [diff] [blame] | 864 | int ret; |
| 865 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | ret = hdd_wlan_notify_modem_power_state(state); |
| 867 | if (ret < 0) |
Jeff Johnson | bd561a9 | 2016-01-07 18:31:35 -0800 | [diff] [blame] | 868 | hdd_err("Fail to send notify"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | } |
| 870 | } |
| 871 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 872 | static int hdd_to_pmo_interface_pause(enum wow_interface_pause hdd_pause, |
| 873 | enum pmo_wow_interface_pause *pmo_pause) |
| 874 | { |
| 875 | switch (hdd_pause) { |
| 876 | case WOW_INTERFACE_PAUSE_DEFAULT: |
| 877 | *pmo_pause = PMO_WOW_INTERFACE_PAUSE_DEFAULT; |
| 878 | break; |
| 879 | case WOW_INTERFACE_PAUSE_ENABLE: |
| 880 | *pmo_pause = PMO_WOW_INTERFACE_PAUSE_ENABLE; |
| 881 | break; |
| 882 | case WOW_INTERFACE_PAUSE_DISABLE: |
| 883 | *pmo_pause = PMO_WOW_INTERFACE_PAUSE_DISABLE; |
| 884 | break; |
| 885 | default: |
| 886 | hdd_err("Invalid interface pause: %d", hdd_pause); |
| 887 | return -EINVAL; |
| 888 | } |
| 889 | |
| 890 | return 0; |
| 891 | } |
| 892 | |
| 893 | static int hdd_to_pmo_resume_trigger(enum wow_resume_trigger hdd_trigger, |
| 894 | enum pmo_wow_resume_trigger *pmo_trigger) |
| 895 | { |
| 896 | switch (hdd_trigger) { |
| 897 | case WOW_RESUME_TRIGGER_DEFAULT: |
| 898 | *pmo_trigger = PMO_WOW_RESUME_TRIGGER_DEFAULT; |
| 899 | break; |
| 900 | case WOW_RESUME_TRIGGER_HTC_WAKEUP: |
| 901 | *pmo_trigger = PMO_WOW_RESUME_TRIGGER_HTC_WAKEUP; |
| 902 | break; |
| 903 | case WOW_RESUME_TRIGGER_GPIO: |
| 904 | *pmo_trigger = PMO_WOW_RESUME_TRIGGER_GPIO; |
| 905 | break; |
| 906 | default: |
| 907 | hdd_err("Invalid resume trigger: %d", hdd_trigger); |
| 908 | return -EINVAL; |
| 909 | } |
| 910 | |
| 911 | return 0; |
| 912 | } |
| 913 | |
| 914 | static int |
| 915 | hdd_to_pmo_wow_enable_params(struct wow_enable_params *in_params, |
| 916 | struct pmo_wow_enable_params *out_params) |
| 917 | { |
| 918 | int err; |
| 919 | |
| 920 | /* unit-test suspend */ |
| 921 | out_params->is_unit_test = in_params->is_unit_test; |
| 922 | |
| 923 | /* interface pause */ |
| 924 | err = hdd_to_pmo_interface_pause(in_params->interface_pause, |
| 925 | &out_params->interface_pause); |
| 926 | if (err) |
| 927 | return err; |
| 928 | |
| 929 | /* resume trigger */ |
| 930 | err = hdd_to_pmo_resume_trigger(in_params->resume_trigger, |
| 931 | &out_params->resume_trigger); |
| 932 | if (err) |
| 933 | return err; |
| 934 | |
| 935 | return 0; |
| 936 | } |
| 937 | |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 938 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 939 | * __wlan_hdd_bus_suspend() - handles platform supsend |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 940 | * @wow_params: collection of wow enable override parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | * |
| 942 | * Does precondtion validation. Ensures that a subsystem restart isn't in |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 943 | * progress. Ensures that no load or unload is in progress. Does: |
| 944 | * data path suspend |
| 945 | * component (pmo) suspend |
| 946 | * hif (bus) suspend |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 947 | * |
| 948 | * Return: 0 for success, -EFAULT for null pointers, |
| 949 | * -EBUSY or -EAGAIN if another opperation is in progress and |
| 950 | * wlan will not be ready to suspend in time. |
| 951 | */ |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 952 | static int __wlan_hdd_bus_suspend(struct wow_enable_params wow_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 953 | { |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 954 | int err; |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 955 | QDF_STATUS status; |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 956 | struct hdd_context *hdd_ctx; |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 957 | void *hif_ctx; |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 958 | void *dp_soc; |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 959 | struct pmo_wow_enable_params pmo_params; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 960 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 961 | hdd_info("starting bus suspend"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 962 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 963 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 964 | err = wlan_hdd_validate_context(hdd_ctx); |
| 965 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 966 | hdd_err("Invalid hdd context: %d", err); |
| 967 | return err; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 968 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 970 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 971 | hdd_debug("Driver Module closed; skipping suspend"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 972 | return 0; |
| 973 | } |
| 974 | |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 975 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 976 | if (!hif_ctx) { |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 977 | hdd_err("Failed to get hif context"); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 978 | return -EINVAL; |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 979 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 980 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 981 | err = hdd_to_pmo_wow_enable_params(&wow_params, &pmo_params); |
| 982 | if (err) { |
| 983 | hdd_err("Invalid WoW enable parameters: %d", err); |
| 984 | return err; |
| 985 | } |
| 986 | |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 987 | dp_soc = cds_get_context(QDF_MODULE_ID_SOC); |
Rakesh Pillai | d2e5385 | 2019-09-13 04:20:13 +0530 | [diff] [blame] | 988 | err = qdf_status_to_os_return(cdp_bus_suspend(dp_soc, OL_TXRX_PDEV_ID)); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 989 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 990 | hdd_err("Failed cdp bus suspend: %d", err); |
| 991 | return err; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 992 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | |
Mohit Khanna | 5b42d1b | 2019-11-04 17:28:00 -0800 | [diff] [blame] | 994 | if (ucfg_ipa_is_tx_pending(hdd_ctx->pdev)) { |
| 995 | hdd_err("failed due to pending IPA TX comps"); |
| 996 | err = -EBUSY; |
| 997 | goto resume_cdp; |
| 998 | } |
| 999 | |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 1000 | err = hif_bus_early_suspend(hif_ctx); |
| 1001 | if (err) { |
| 1002 | hdd_err("Failed hif bus early suspend"); |
| 1003 | goto resume_cdp; |
| 1004 | } |
| 1005 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1006 | status = ucfg_pmo_psoc_bus_suspend_req(hdd_ctx->psoc, |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1007 | QDF_SYSTEM_SUSPEND, |
| 1008 | &pmo_params); |
| 1009 | err = qdf_status_to_os_return(status); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1010 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1011 | hdd_err("Failed pmo bus suspend: %d", status); |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 1012 | goto late_hif_resume; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1013 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1014 | |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 1015 | err = hif_bus_suspend(hif_ctx); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1016 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1017 | hdd_err("Failed hif bus suspend: %d", err); |
| 1018 | goto resume_pmo; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1019 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1020 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1021 | hdd_info("bus suspend succeeded"); |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1022 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1023 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1024 | resume_pmo: |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1025 | status = ucfg_pmo_psoc_bus_resume_req(hdd_ctx->psoc, |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1026 | QDF_SYSTEM_SUSPEND); |
| 1027 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 1028 | |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 1029 | late_hif_resume: |
| 1030 | status = hif_bus_late_resume(hif_ctx); |
| 1031 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 1032 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1033 | resume_cdp: |
Rakesh Pillai | d2e5385 | 2019-09-13 04:20:13 +0530 | [diff] [blame] | 1034 | status = cdp_bus_resume(dp_soc, OL_TXRX_PDEV_ID); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1035 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 1036 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | return err; |
| 1038 | } |
| 1039 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1040 | int wlan_hdd_bus_suspend(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | { |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 1042 | struct wow_enable_params default_params = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1043 | |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1044 | return __wlan_hdd_bus_suspend(default_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1045 | } |
| 1046 | |
Dustin Brown | e70fd97 | 2016-11-10 11:17:40 -0800 | [diff] [blame] | 1047 | #ifdef WLAN_SUSPEND_RESUME_TEST |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1048 | int wlan_hdd_unit_test_bus_suspend(struct wow_enable_params wow_params) |
Dustin Brown | e70fd97 | 2016-11-10 11:17:40 -0800 | [diff] [blame] | 1049 | { |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 1050 | return __wlan_hdd_bus_suspend(wow_params); |
Dustin Brown | e70fd97 | 2016-11-10 11:17:40 -0800 | [diff] [blame] | 1051 | } |
| 1052 | #endif |
| 1053 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1054 | /** |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1055 | * wlan_hdd_bus_suspend_noirq() - handle .suspend_noirq callback |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1056 | * |
| 1057 | * This function is called by the platform driver to complete the |
| 1058 | * bus suspend callback when device interrupts are disabled by kernel. |
| 1059 | * Call HIF and WMA suspend_noirq callbacks to make sure there is no |
| 1060 | * wake up pending from FW before allowing suspend. |
| 1061 | * |
| 1062 | * Return: 0 for success and -EBUSY if FW is requesting wake up |
| 1063 | */ |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1064 | int wlan_hdd_bus_suspend_noirq(void) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1065 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1066 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1067 | void *hif_ctx; |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1068 | int errno; |
| 1069 | uint32_t pending_events; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1070 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1071 | hdd_info("start bus_suspend_noirq"); |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1072 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 1073 | if (errno) { |
| 1074 | hdd_err("Invalid HDD context: errno %d", errno); |
| 1075 | return errno; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1079 | hdd_debug("Driver module closed; skip bus-noirq suspend"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1080 | return 0; |
| 1081 | } |
| 1082 | |
| 1083 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1084 | if (!hif_ctx) { |
| 1085 | hdd_err("hif_ctx is null"); |
| 1086 | return -EINVAL; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1087 | } |
| 1088 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1089 | errno = hif_bus_suspend_noirq(hif_ctx); |
| 1090 | if (errno) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1091 | goto done; |
| 1092 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1093 | errno = ucfg_pmo_psoc_is_target_wake_up_received(hdd_ctx->psoc); |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1094 | if (errno == -EAGAIN) { |
| 1095 | hdd_err("Firmware attempting wakeup, try again"); |
| 1096 | wlan_hdd_inc_suspend_stats(hdd_ctx, |
| 1097 | SUSPEND_FAIL_INITIAL_WAKEUP); |
| 1098 | } |
| 1099 | if (errno) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1100 | goto resume_hif_noirq; |
| 1101 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1102 | pending_events = wma_critical_events_in_flight(); |
| 1103 | if (pending_events) { |
| 1104 | hdd_err("%d critical event(s) in flight; try again", |
| 1105 | pending_events); |
| 1106 | errno = -EAGAIN; |
| 1107 | goto resume_hif_noirq; |
| 1108 | } |
| 1109 | |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1110 | hdd_ctx->suspend_resume_stats.suspends++; |
| 1111 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1112 | hdd_info("bus_suspend_noirq done"); |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1113 | return 0; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1114 | |
| 1115 | resume_hif_noirq: |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1116 | QDF_BUG(!hif_bus_resume_noirq(hif_ctx)); |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1117 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1118 | done: |
| 1119 | hdd_err("suspend_noirq failed, status: %d", errno); |
| 1120 | |
| 1121 | return errno; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1124 | /** |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1125 | * wlan_hdd_bus_resume() - handles platform resume |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | * |
| 1127 | * Does precondtion validation. Ensures that a subsystem restart isn't in |
| 1128 | * progress. Ensures that no load or unload is in progress. Ensures that |
| 1129 | * it has valid pointers for the required contexts. |
| 1130 | * Calls into hif to resume the bus opperation. |
| 1131 | * Calls into wma to handshake with firmware and notify it that the bus is up. |
| 1132 | * Calls into ol_txrx for symetry. |
| 1133 | * Failures are treated as catastrophic. |
| 1134 | * |
| 1135 | * return: error code or 0 for success |
| 1136 | */ |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1137 | int wlan_hdd_bus_resume(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1139 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 1140 | void *hif_ctx; |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1141 | int status; |
| 1142 | QDF_STATUS qdf_status; |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 1143 | void *dp_soc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1144 | |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1145 | if (cds_is_driver_recovering()) |
| 1146 | return 0; |
| 1147 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1148 | hdd_info("starting bus resume"); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1149 | |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1150 | status = wlan_hdd_validate_context(hdd_ctx); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1151 | if (status) { |
| 1152 | hdd_err("Invalid hdd context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1153 | return status; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1154 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1155 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1156 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 1157 | hdd_debug("Driver Module closed; return success"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1158 | return 0; |
| 1159 | } |
| 1160 | |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 1161 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1162 | if (!hif_ctx) { |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1163 | hdd_err("Failed to get hif context"); |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 1164 | return -EINVAL; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1165 | } |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 1166 | |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 1167 | status = hif_bus_resume(hif_ctx); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1168 | if (status) { |
| 1169 | hdd_err("Failed hif bus resume"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1170 | goto out; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1171 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1173 | qdf_status = ucfg_pmo_psoc_bus_resume_req(hdd_ctx->psoc, |
| 1174 | QDF_SYSTEM_SUSPEND); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1175 | status = qdf_status_to_os_return(qdf_status); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1176 | if (status) { |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 1177 | hdd_err("Failed pmo bus resume"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1178 | goto out; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1179 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1180 | |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 1181 | status = hif_bus_late_resume(hif_ctx); |
| 1182 | if (status) { |
| 1183 | hdd_err("Failed hif bus late resume"); |
| 1184 | goto out; |
| 1185 | } |
| 1186 | |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 1187 | dp_soc = cds_get_context(QDF_MODULE_ID_SOC); |
Rakesh Pillai | d2e5385 | 2019-09-13 04:20:13 +0530 | [diff] [blame] | 1188 | qdf_status = cdp_bus_resume(dp_soc, OL_TXRX_PDEV_ID); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1189 | status = qdf_status_to_os_return(qdf_status); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1190 | if (status) { |
| 1191 | hdd_err("Failed cdp bus resume"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1192 | goto out; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 1193 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1194 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1195 | hdd_info("bus resume succeeded"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1196 | return 0; |
| 1197 | |
| 1198 | out: |
Rajeev Kumar | 1046601 | 2018-01-24 14:12:20 -0800 | [diff] [blame] | 1199 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() || |
| 1200 | cds_is_fw_down()) |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1201 | return 0; |
| 1202 | |
| 1203 | QDF_BUG(false); |
| 1204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | return status; |
| 1206 | } |
| 1207 | |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1208 | /** |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1209 | * wlan_hdd_bus_resume_noirq(): handle bus resume no irq |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1210 | * |
| 1211 | * This function is called by the platform driver to do bus |
| 1212 | * resume no IRQ before calling resume callback. Call WMA and HIF |
| 1213 | * layers to complete the resume_noirq. |
| 1214 | * |
| 1215 | * Return: 0 for success and negative error code for failure |
| 1216 | */ |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1217 | int wlan_hdd_bus_resume_noirq(void) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1218 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1219 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1220 | void *hif_ctx; |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1221 | int status; |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1222 | QDF_STATUS qdf_status; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1223 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1224 | hdd_info("starting bus_resume_noirq"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1225 | if (cds_is_driver_recovering()) |
| 1226 | return 0; |
| 1227 | |
| 1228 | status = wlan_hdd_validate_context(hdd_ctx); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1229 | if (status) { |
| 1230 | hdd_err("Invalid HDD context: %d", status); |
| 1231 | return status; |
| 1232 | } |
| 1233 | |
| 1234 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 1235 | hdd_debug("Driver Module closed return success"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1236 | return 0; |
| 1237 | } |
| 1238 | |
| 1239 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1240 | if (!hif_ctx) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1241 | return -EINVAL; |
| 1242 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1243 | qdf_status = ucfg_pmo_psoc_clear_target_wake_up(hdd_ctx->psoc); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1244 | QDF_BUG(!qdf_status); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1245 | |
| 1246 | status = hif_bus_resume_noirq(hif_ctx); |
| 1247 | QDF_BUG(!status); |
| 1248 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1249 | hdd_info("bus_resume_noirq done"); |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1250 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1251 | return status; |
| 1252 | } |
| 1253 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1254 | /** |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1255 | * wlan_hdd_bus_reset_resume() - resume wlan bus after reset |
| 1256 | * |
| 1257 | * This function is called to tell the driver that the device has been resumed |
| 1258 | * and it has also been reset. The driver should redo any necessary |
| 1259 | * initialization. It is mainly used by the USB bus |
| 1260 | * |
| 1261 | * Return: int 0 for success, non zero for failure |
| 1262 | */ |
| 1263 | static int wlan_hdd_bus_reset_resume(void) |
| 1264 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1265 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 1266 | |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 1267 | if (!scn) { |
| 1268 | hdd_err("Failed to get HIF context"); |
| 1269 | return -EFAULT; |
| 1270 | } |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1271 | |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1272 | return hif_bus_reset_resume(scn); |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1273 | } |
| 1274 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1275 | #ifdef FEATURE_RUNTIME_PM |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1276 | /** |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1277 | * hdd_pld_runtime_suspend_cb() - Runtime suspend callback from PMO |
| 1278 | * |
| 1279 | * Return: 0 on success or error value otherwise |
| 1280 | */ |
| 1281 | static int hdd_pld_runtime_suspend_cb(void) |
| 1282 | { |
| 1283 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1284 | |
| 1285 | if (!qdf_dev) { |
| 1286 | hdd_err("Invalid context"); |
| 1287 | return -EINVAL; |
| 1288 | } |
| 1289 | |
| 1290 | return pld_auto_suspend(qdf_dev->dev); |
| 1291 | } |
| 1292 | |
| 1293 | /** |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1294 | * wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1295 | * |
| 1296 | * Each layer is responsible for its own suspend actions. wma_runtime_suspend |
| 1297 | * takes care of the parts of the 802.11 suspend that we want to do for runtime |
| 1298 | * suspend. |
| 1299 | * |
| 1300 | * Return: 0 or errno |
| 1301 | */ |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1302 | static int wlan_hdd_runtime_suspend(struct device *dev) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1303 | { |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1304 | int err; |
| 1305 | QDF_STATUS status; |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1306 | struct hdd_context *hdd_ctx; |
Alan Chen | abd1947 | 2019-08-30 12:07:03 -0700 | [diff] [blame] | 1307 | qdf_time_t delta; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1308 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1309 | hdd_debug("Starting runtime suspend"); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1310 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1311 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1312 | err = wlan_hdd_validate_context(hdd_ctx); |
| 1313 | if (err) |
| 1314 | return err; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1315 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1316 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1317 | hdd_debug("Driver module closed skipping runtime suspend"); |
| 1318 | return 0; |
| 1319 | } |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1320 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1321 | if (ucfg_scan_get_pdev_status(hdd_ctx->pdev) != |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1322 | SCAN_NOT_IN_PROGRESS) { |
| 1323 | hdd_debug("Scan in progress, ignore runtime suspend"); |
| 1324 | return -EBUSY; |
| 1325 | } |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 1326 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1327 | status = ucfg_pmo_psoc_bus_runtime_suspend(hdd_ctx->psoc, |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1328 | hdd_pld_runtime_suspend_cb); |
| 1329 | err = qdf_status_to_os_return(status); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1330 | |
Alan Chen | f8a46d5 | 2019-09-04 11:01:12 -0700 | [diff] [blame] | 1331 | hdd_ctx->runtime_suspend_done_time_stamp = |
| 1332 | qdf_get_log_timestamp_usecs(); |
Alan Chen | abd1947 | 2019-08-30 12:07:03 -0700 | [diff] [blame] | 1333 | delta = hdd_ctx->runtime_suspend_done_time_stamp - |
| 1334 | hdd_ctx->runtime_resume_start_time_stamp; |
| 1335 | |
| 1336 | if (hdd_ctx->runtime_suspend_done_time_stamp > |
| 1337 | hdd_ctx->runtime_resume_start_time_stamp) |
Alan Chen | f8a46d5 | 2019-09-04 11:01:12 -0700 | [diff] [blame] | 1338 | hdd_debug("Runtime suspend done result: %d total cxpc up time %lu microseconds", |
Alan Chen | abd1947 | 2019-08-30 12:07:03 -0700 | [diff] [blame] | 1339 | err, delta); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1340 | |
Manjunathappa Prakash | f065fcd | 2019-08-06 16:47:08 -0700 | [diff] [blame] | 1341 | if (status == QDF_STATUS_SUCCESS) |
| 1342 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 1343 | |
| 1344 | hdd_debug("Runtime suspend done result: %d", err); |
| 1345 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1346 | return err; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1347 | } |
| 1348 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1349 | /** |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1350 | * hdd_pld_runtime_resume_cb() - Runtime resume callback from PMO |
| 1351 | * |
| 1352 | * Return: 0 on success or error value otherwise |
| 1353 | */ |
| 1354 | static int hdd_pld_runtime_resume_cb(void) |
| 1355 | { |
| 1356 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1357 | |
| 1358 | if (!qdf_dev) { |
| 1359 | hdd_err("Invalid context"); |
| 1360 | return -EINVAL; |
| 1361 | } |
| 1362 | |
| 1363 | return pld_auto_resume(qdf_dev->dev); |
| 1364 | } |
| 1365 | |
| 1366 | /** |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1367 | * wlan_hdd_runtime_resume() - resume the wlan bus from runtime suspend |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1368 | * |
| 1369 | * Sets the runtime pm state and coordinates resume between hif wma and |
| 1370 | * ol_txrx. |
| 1371 | * |
| 1372 | * Return: success since failure is a bug |
| 1373 | */ |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1374 | static int wlan_hdd_runtime_resume(struct device *dev) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1375 | { |
Alan Chen | 35cb57c | 2019-09-11 12:02:50 -0700 | [diff] [blame] | 1376 | struct hdd_context *hdd_ctx; |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1377 | QDF_STATUS status; |
Alan Chen | abd1947 | 2019-08-30 12:07:03 -0700 | [diff] [blame] | 1378 | qdf_time_t delta; |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 1379 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1380 | hdd_debug("Starting runtime resume"); |
| 1381 | |
Alan Chen | 35cb57c | 2019-09-11 12:02:50 -0700 | [diff] [blame] | 1382 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1383 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 1384 | return 0; |
| 1385 | |
| 1386 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1387 | hdd_debug("Driver module closed skipping runtime resume"); |
| 1388 | return 0; |
| 1389 | } |
| 1390 | |
Alan Chen | 35cb57c | 2019-09-11 12:02:50 -0700 | [diff] [blame] | 1391 | hdd_ctx->runtime_resume_start_time_stamp = |
| 1392 | qdf_get_log_timestamp_usecs(); |
| 1393 | delta = hdd_ctx->runtime_resume_start_time_stamp - |
| 1394 | hdd_ctx->runtime_suspend_done_time_stamp; |
| 1395 | hdd_debug("Starting runtime resume total cxpc down time %lu microseconds", |
| 1396 | delta); |
| 1397 | |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 1398 | status = ucfg_pmo_psoc_bus_runtime_resume(hdd_ctx->psoc, |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1399 | hdd_pld_runtime_resume_cb); |
Manjunathappa Prakash | f065fcd | 2019-08-06 16:47:08 -0700 | [diff] [blame] | 1400 | if (status != QDF_STATUS_SUCCESS) { |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1401 | hdd_err("PMO Runtime resume failed: %d", status); |
Manjunathappa Prakash | f065fcd | 2019-08-06 16:47:08 -0700 | [diff] [blame] | 1402 | } else { |
| 1403 | if (policy_mgr_get_connection_count(hdd_ctx->psoc)) |
| 1404 | hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 1405 | } |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1406 | |
| 1407 | hdd_debug("Runtime resume done"); |
| 1408 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1409 | return 0; |
| 1410 | } |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1411 | #endif |
| 1412 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1413 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1414 | * wlan_hdd_pld_probe() - probe function registered to PLD |
| 1415 | * @dev: device |
| 1416 | * @pld_bus_type: PLD bus type |
| 1417 | * @bdev: bus device structure |
| 1418 | * @id: bus identifier for shared busses |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1419 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1420 | * Return: 0 on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1421 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1422 | static int wlan_hdd_pld_probe(struct device *dev, |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1423 | enum pld_bus_type pld_bus_type, |
| 1424 | void *bdev, |
| 1425 | void *id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1426 | { |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1427 | enum qdf_bus_type bus_type = to_bus_type(pld_bus_type); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1428 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1429 | if (bus_type == QDF_BUS_TYPE_NONE) { |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1430 | hdd_err("Invalid bus type %d->%d", pld_bus_type, bus_type); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1431 | return -EINVAL; |
| 1432 | } |
| 1433 | |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1434 | return hdd_soc_probe(dev, bdev, id, bus_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1438 | * wlan_hdd_pld_remove() - remove function registered to PLD |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1439 | * @dev: device to remove |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1440 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1441 | * |
| 1442 | * Return: void |
| 1443 | */ |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1444 | static void wlan_hdd_pld_remove(struct device *dev, enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1445 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1446 | hdd_enter(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1447 | |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1448 | hdd_soc_remove(dev); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1449 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1450 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | /** |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 1454 | * wlan_hdd_pld_idle_shutdown() - wifi module idle shutdown after interface |
| 1455 | * inactivity timeout has trigerred idle shutdown |
| 1456 | * @dev: device to remove |
| 1457 | * @pld_bus_type: PLD bus type |
| 1458 | * |
| 1459 | * Return: 0 for success and negative error code for failure |
| 1460 | */ |
| 1461 | static int wlan_hdd_pld_idle_shutdown(struct device *dev, |
| 1462 | enum pld_bus_type bus_type) |
| 1463 | { |
| 1464 | return hdd_psoc_idle_shutdown(dev); |
| 1465 | } |
| 1466 | |
| 1467 | /** |
| 1468 | * wlan_hdd_pld_idle_restart() - wifi module idle restart after idle shutdown |
| 1469 | * @dev: device to remove |
| 1470 | * @pld_bus_type: PLD bus type |
| 1471 | * |
| 1472 | * Return: 0 for success and negative error code for failure |
| 1473 | */ |
| 1474 | static int wlan_hdd_pld_idle_restart(struct device *dev, |
| 1475 | enum pld_bus_type bus_type) |
| 1476 | { |
| 1477 | return hdd_psoc_idle_restart(dev); |
| 1478 | } |
| 1479 | |
| 1480 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1481 | * wlan_hdd_pld_shutdown() - shutdown function registered to PLD |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1482 | * @dev: device to shutdown |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1483 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1484 | * |
| 1485 | * Return: void |
| 1486 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1487 | static void wlan_hdd_pld_shutdown(struct device *dev, |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1488 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1489 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1490 | hdd_enter(); |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1491 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 1492 | hdd_soc_recovery_shutdown(dev); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1493 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1494 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1495 | } |
| 1496 | |
| 1497 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1498 | * wlan_hdd_pld_reinit() - reinit function registered to PLD |
| 1499 | * @dev: device |
| 1500 | * @pld_bus_type: PLD bus type |
| 1501 | * @bdev: bus device structure |
| 1502 | * @id: bus identifier for shared busses |
| 1503 | * |
| 1504 | * Return: 0 on success |
| 1505 | */ |
| 1506 | static int wlan_hdd_pld_reinit(struct device *dev, |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1507 | enum pld_bus_type pld_bus_type, |
| 1508 | void *bdev, |
| 1509 | void *id) |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1510 | { |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1511 | enum qdf_bus_type bus_type = to_bus_type(pld_bus_type); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1512 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1513 | if (bus_type == QDF_BUS_TYPE_NONE) { |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1514 | hdd_err("Invalid bus type %d->%d", pld_bus_type, bus_type); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1515 | return -EINVAL; |
| 1516 | } |
| 1517 | |
Dustin Brown | 32ffab3 | 2018-09-21 11:36:54 -0700 | [diff] [blame] | 1518 | return hdd_soc_recovery_reinit(dev, bdev, id, bus_type); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1519 | } |
| 1520 | |
| 1521 | /** |
| 1522 | * wlan_hdd_pld_crash_shutdown() - crash_shutdown function registered to PLD |
| 1523 | * @dev: device |
| 1524 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1525 | * |
| 1526 | * Return: void |
| 1527 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1528 | static void wlan_hdd_pld_crash_shutdown(struct device *dev, |
| 1529 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | { |
| 1531 | wlan_hdd_crash_shutdown(); |
| 1532 | } |
| 1533 | |
| 1534 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1535 | * wlan_hdd_pld_suspend() - suspend function registered to PLD |
| 1536 | * @dev: device |
| 1537 | * @pld_bus_type: PLD bus type |
| 1538 | * @state: PM state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1540 | * Return: 0 on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1542 | static int wlan_hdd_pld_suspend(struct device *dev, |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1543 | enum pld_bus_type bus_type, |
| 1544 | pm_message_t state) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1545 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1547 | struct osif_psoc_sync *psoc_sync; |
| 1548 | int errno; |
| 1549 | |
| 1550 | errno = osif_psoc_sync_op_start(dev, &psoc_sync); |
| 1551 | if (errno) |
| 1552 | return errno; |
| 1553 | |
| 1554 | errno = wlan_hdd_bus_suspend(); |
| 1555 | |
| 1556 | osif_psoc_sync_op_stop(psoc_sync); |
| 1557 | |
| 1558 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1559 | } |
| 1560 | |
| 1561 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1562 | * wlan_hdd_pld_resume() - resume function registered to PLD |
| 1563 | * @dev: device |
| 1564 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1566 | * Return: 0 on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1568 | static int wlan_hdd_pld_resume(struct device *dev, |
| 1569 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1571 | struct osif_psoc_sync *psoc_sync; |
| 1572 | int errno; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1573 | |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1574 | errno = osif_psoc_sync_op_start(dev, &psoc_sync); |
| 1575 | if (errno) |
| 1576 | return errno; |
| 1577 | |
| 1578 | errno = wlan_hdd_bus_resume(); |
| 1579 | |
| 1580 | osif_psoc_sync_op_stop(psoc_sync); |
| 1581 | |
| 1582 | return errno; |
| 1583 | } |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1584 | |
| 1585 | /** |
| 1586 | * wlan_hdd_pld_suspend_noirq() - handle suspend no irq |
| 1587 | * @dev: device |
| 1588 | * @pld_bus_type: PLD bus type |
| 1589 | * |
| 1590 | * Complete the actions started by suspend(). Carry out any |
| 1591 | * additional operations required for suspending the device that might be |
| 1592 | * racing with its driver's interrupt handler, which is guaranteed not to |
| 1593 | * run while suspend_noirq() is being executed. Make sure to resume device |
| 1594 | * if FW has sent initial wake up message and expecting APPS to wake up. |
| 1595 | * |
| 1596 | * Return: 0 on success |
| 1597 | */ |
| 1598 | static int wlan_hdd_pld_suspend_noirq(struct device *dev, |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1599 | enum pld_bus_type bus_type) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1600 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1601 | struct osif_psoc_sync *psoc_sync; |
| 1602 | int errno; |
| 1603 | |
| 1604 | errno = osif_psoc_sync_op_start(dev, &psoc_sync); |
| 1605 | if (errno) |
| 1606 | return errno; |
| 1607 | |
| 1608 | errno = wlan_hdd_bus_suspend_noirq(); |
| 1609 | |
| 1610 | osif_psoc_sync_op_stop(psoc_sync); |
| 1611 | |
| 1612 | return errno; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1613 | } |
| 1614 | |
| 1615 | /** |
| 1616 | * wlan_hdd_pld_resume_noirq() - handle resume no irq |
| 1617 | * @dev: device |
| 1618 | * @pld_bus_type: PLD bus type |
| 1619 | * |
| 1620 | * Prepare for the execution of resume() by carrying out any |
| 1621 | * operations required for resuming the device that might be racing with |
| 1622 | * its driver's interrupt handler, which is guaranteed not to run while |
| 1623 | * resume_noirq() is being executed. Make sure to clear target initial |
| 1624 | * wake up request such that next suspend can happen cleanly. |
| 1625 | * |
| 1626 | * Return: 0 on success |
| 1627 | */ |
| 1628 | static int wlan_hdd_pld_resume_noirq(struct device *dev, |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1629 | enum pld_bus_type bus_type) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1630 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1631 | struct osif_psoc_sync *psoc_sync; |
| 1632 | int errno; |
| 1633 | |
| 1634 | errno = osif_psoc_sync_op_start(dev, &psoc_sync); |
| 1635 | if (errno) |
| 1636 | return errno; |
| 1637 | |
| 1638 | errno = wlan_hdd_bus_resume_noirq(); |
| 1639 | |
| 1640 | osif_psoc_sync_op_stop(psoc_sync); |
| 1641 | |
| 1642 | return errno; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1643 | } |
| 1644 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1645 | /** |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1646 | * wlan_hdd_pld_reset_resume() - reset resume function registered to PLD |
| 1647 | * @dev: device |
| 1648 | * @pld_bus_type: PLD bus type |
| 1649 | * |
| 1650 | * Return: 0 on success |
| 1651 | */ |
| 1652 | static int wlan_hdd_pld_reset_resume(struct device *dev, |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1653 | enum pld_bus_type bus_type) |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1654 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1655 | struct osif_psoc_sync *psoc_sync; |
| 1656 | int errno; |
| 1657 | |
| 1658 | errno = osif_psoc_sync_op_start(dev, &psoc_sync); |
| 1659 | if (errno) |
| 1660 | return errno; |
| 1661 | |
| 1662 | errno = wlan_hdd_bus_reset_resume(); |
| 1663 | |
| 1664 | osif_psoc_sync_op_stop(psoc_sync); |
| 1665 | |
| 1666 | return errno; |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1667 | } |
| 1668 | |
| 1669 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1670 | * wlan_hdd_pld_notify_handler() - notify_handler function registered to PLD |
| 1671 | * @dev: device |
| 1672 | * @pld_bus_type: PLD bus type |
| 1673 | * @state: Modem power state |
| 1674 | * |
| 1675 | * Return: void |
| 1676 | */ |
| 1677 | static void wlan_hdd_pld_notify_handler(struct device *dev, |
| 1678 | enum pld_bus_type bus_type, |
| 1679 | int state) |
| 1680 | { |
| 1681 | wlan_hdd_notify_handler(state); |
| 1682 | } |
| 1683 | |
Dustin Brown | 8f05f65 | 2018-10-25 15:17:30 -0700 | [diff] [blame] | 1684 | /** |
| 1685 | * wlan_hdd_pld_uevent() - platform uevent handler |
| 1686 | * @dev: device on which the uevent occurred |
| 1687 | * @event_data: uevent parameters |
| 1688 | * |
| 1689 | * Return: None |
| 1690 | */ |
| 1691 | static void |
| 1692 | wlan_hdd_pld_uevent(struct device *dev, struct pld_uevent_data *event_data) |
| 1693 | { |
Dustin Brown | 8f05f65 | 2018-10-25 15:17:30 -0700 | [diff] [blame] | 1694 | switch (event_data->uevent) { |
| 1695 | case PLD_FW_DOWN: |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 1696 | hdd_info("Received firmware down indication"); |
| 1697 | |
| 1698 | /* NOTE! SSR cleanup logic goes in pld shutdown, not here */ |
| 1699 | |
| 1700 | cds_set_target_ready(false); |
| 1701 | cds_set_recovery_in_progress(true); |
| 1702 | |
| 1703 | /* SSR cleanup happens in pld shutdown, which is serialized by |
| 1704 | * the platform driver. Other operations are also serialized by |
| 1705 | * platform driver, such as probe, remove, and reinit. If the |
| 1706 | * firmware goes down during one of these operations, the driver |
| 1707 | * would normally have to wait for a timeout before shutdown |
| 1708 | * could begin. Instead, forcefully complete events waiting on |
| 1709 | * firmware with a "reset" status to avoid waiting to time out |
| 1710 | * on a firmware we already know is down. |
| 1711 | */ |
| 1712 | qdf_complete_wait_events(); |
| 1713 | |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1714 | break; |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1715 | default: |
Dustin Brown | af8fea0 | 2018-10-29 11:31:49 -0700 | [diff] [blame] | 1716 | /* other events intentionally not handled */ |
| 1717 | hdd_debug("Received uevent %d", event_data->uevent); |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1718 | break; |
| 1719 | } |
| 1720 | } |
| 1721 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1722 | #ifdef FEATURE_RUNTIME_PM |
| 1723 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1724 | * wlan_hdd_pld_runtime_suspend() - runtime suspend function registered to PLD |
| 1725 | * @dev: device |
| 1726 | * @pld_bus_type: PLD bus type |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1727 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1728 | * Return: 0 on success |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1729 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1730 | static int wlan_hdd_pld_runtime_suspend(struct device *dev, |
| 1731 | enum pld_bus_type bus_type) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1732 | { |
Dustin Brown | bda9e54 | 2019-02-27 10:24:34 -0800 | [diff] [blame] | 1733 | struct osif_psoc_sync *psoc_sync; |
| 1734 | int errno; |
| 1735 | |
| 1736 | errno = osif_psoc_sync_op_start(dev, &psoc_sync); |
| 1737 | if (errno) |
| 1738 | return errno; |
| 1739 | |
| 1740 | errno = wlan_hdd_runtime_suspend(dev); |
| 1741 | |
| 1742 | osif_psoc_sync_op_stop(psoc_sync); |
| 1743 | |
| 1744 | return errno; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1745 | } |
| 1746 | |
| 1747 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1748 | * wlan_hdd_pld_runtime_resume() - runtime resume function registered to PLD |
| 1749 | * @dev: device |
| 1750 | * @pld_bus_type: PLD bus type |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1751 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1752 | * Return: 0 on success |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1753 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1754 | static int wlan_hdd_pld_runtime_resume(struct device *dev, |
| 1755 | enum pld_bus_type bus_type) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1756 | { |
Yue Ma | 80fb30c | 2019-04-29 15:11:40 -0700 | [diff] [blame] | 1757 | /* As opposite to suspend, Runtime PM resume can happen |
| 1758 | * synchronously during driver shutdown or idle shutown, |
| 1759 | * so remove PSOC sync protection here. |
| 1760 | */ |
| 1761 | return wlan_hdd_runtime_resume(dev); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1762 | } |
| 1763 | #endif |
| 1764 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1765 | struct pld_driver_ops wlan_drv_ops = { |
| 1766 | .probe = wlan_hdd_pld_probe, |
| 1767 | .remove = wlan_hdd_pld_remove, |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 1768 | .idle_shutdown = wlan_hdd_pld_idle_shutdown, |
| 1769 | .idle_restart = wlan_hdd_pld_idle_restart, |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1770 | .shutdown = wlan_hdd_pld_shutdown, |
| 1771 | .reinit = wlan_hdd_pld_reinit, |
| 1772 | .crash_shutdown = wlan_hdd_pld_crash_shutdown, |
| 1773 | .suspend = wlan_hdd_pld_suspend, |
| 1774 | .resume = wlan_hdd_pld_resume, |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1775 | .suspend_noirq = wlan_hdd_pld_suspend_noirq, |
| 1776 | .resume_noirq = wlan_hdd_pld_resume_noirq, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1777 | .reset_resume = wlan_hdd_pld_reset_resume, |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1778 | .modem_status = wlan_hdd_pld_notify_handler, |
Anurag Chouhan | 1ddb9b3 | 2017-04-13 13:57:09 +0530 | [diff] [blame] | 1779 | .uevent = wlan_hdd_pld_uevent, |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1780 | #ifdef FEATURE_RUNTIME_PM |
Jeff Johnson | 330292a | 2016-05-16 16:09:49 -0700 | [diff] [blame] | 1781 | .runtime_suspend = wlan_hdd_pld_runtime_suspend, |
| 1782 | .runtime_resume = wlan_hdd_pld_runtime_resume, |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1783 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1784 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1785 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1786 | int wlan_hdd_register_driver(void) |
| 1787 | { |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1788 | return pld_register_driver(&wlan_drv_ops); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1789 | } |
| 1790 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1791 | void wlan_hdd_unregister_driver(void) |
| 1792 | { |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1793 | pld_unregister_driver(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1794 | } |