Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 28 | #include <linux/pci.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/if_arp.h> |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 32 | #include "qdf_lock.h" |
| 33 | #include "qdf_types.h" |
| 34 | #include "qdf_status.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 35 | #include "regtable.h" |
| 36 | #include "hif.h" |
| 37 | #include "hif_io32.h" |
| 38 | #include "ce_main.h" |
| 39 | #include "ce_api.h" |
| 40 | #include "ce_reg.h" |
| 41 | #include "ce_internal.h" |
Houston Hoffman | 247f09b | 2016-04-06 21:21:40 -0700 | [diff] [blame] | 42 | #include "ce_tasklet.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 43 | #ifdef CONFIG_CNSS |
| 44 | #include <net/cnss.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 45 | #endif |
Houston Hoffman | 4849fcc | 2016-05-05 15:42:35 -0700 | [diff] [blame^] | 46 | #include "platform_icnss.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 47 | #include "hif_debug.h" |
| 48 | #include "hif_napi.h" |
| 49 | |
| 50 | |
| 51 | /** |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 52 | * struct tasklet_work |
| 53 | * |
| 54 | * @id: ce_id |
| 55 | * @work: work |
| 56 | */ |
| 57 | struct tasklet_work { |
| 58 | enum ce_id_type id; |
| 59 | void *data; |
| 60 | struct work_struct work; |
| 61 | }; |
| 62 | |
| 63 | |
| 64 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 65 | * reschedule_ce_tasklet_work_handler() - reschedule work |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 66 | * @work: struct work_struct |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 67 | * |
| 68 | * Return: N/A |
| 69 | */ |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 70 | static void reschedule_ce_tasklet_work_handler(struct work_struct *work) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 71 | { |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 72 | struct tasklet_work *ce_work = container_of(work, struct tasklet_work, |
| 73 | work); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 74 | struct hif_softc *scn = ce_work->data; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 75 | struct HIF_CE_state *hif_ce_state; |
| 76 | |
| 77 | if (NULL == scn) { |
| 78 | HIF_ERROR("%s: tasklet scn is null", __func__); |
| 79 | return; |
| 80 | } |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 81 | |
| 82 | hif_ce_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 83 | |
| 84 | if (scn->hif_init_done == false) { |
| 85 | HIF_ERROR("%s: wlan driver is unloaded", __func__); |
| 86 | return; |
| 87 | } |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 88 | tasklet_schedule(&hif_ce_state->tasklets[ce_work->id].intr_tq); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 89 | return; |
| 90 | } |
| 91 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 92 | static struct tasklet_work tasklet_workers[CE_ID_MAX]; |
| 93 | static bool work_initialized; |
| 94 | |
| 95 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 96 | * init_tasklet_work() - init_tasklet_work |
| 97 | * @work: struct work_struct |
| 98 | * @work_handler: work_handler |
| 99 | * |
| 100 | * Return: N/A |
| 101 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 102 | static void init_tasklet_work(struct work_struct *work, |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 103 | work_func_t work_handler) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 104 | { |
| 105 | INIT_WORK(work, work_handler); |
| 106 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * init_tasklet_workers() - init_tasklet_workers |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 110 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 111 | * |
| 112 | * Return: N/A |
| 113 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 114 | void init_tasklet_workers(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 115 | { |
| 116 | uint32_t id; |
| 117 | |
| 118 | for (id = 0; id < CE_ID_MAX; id++) { |
| 119 | tasklet_workers[id].id = id; |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 120 | tasklet_workers[id].data = scn; |
| 121 | init_tasklet_work(&tasklet_workers[id].work, |
| 122 | reschedule_ce_tasklet_work_handler); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 123 | } |
| 124 | work_initialized = true; |
| 125 | } |
| 126 | |
| 127 | #ifdef CONFIG_SLUB_DEBUG_ON |
| 128 | /** |
| 129 | * ce_schedule_tasklet() - schedule ce tasklet |
| 130 | * @tasklet_entry: struct ce_tasklet_entry |
| 131 | * |
| 132 | * Return: N/A |
| 133 | */ |
| 134 | static inline void ce_schedule_tasklet(struct ce_tasklet_entry *tasklet_entry) |
| 135 | { |
Orhan K AKYILDIZ | 0615891 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 136 | if (work_initialized && (tasklet_entry->ce_id < CE_ID_MAX)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 137 | schedule_work(&tasklet_workers[tasklet_entry->ce_id].work); |
| 138 | else |
| 139 | HIF_ERROR("%s: work_initialized = %d, ce_id = %d", |
| 140 | __func__, work_initialized, tasklet_entry->ce_id); |
| 141 | } |
| 142 | #else |
| 143 | /** |
| 144 | * ce_schedule_tasklet() - schedule ce tasklet |
| 145 | * @tasklet_entry: struct ce_tasklet_entry |
| 146 | * |
| 147 | * Return: N/A |
| 148 | */ |
| 149 | static inline void ce_schedule_tasklet(struct ce_tasklet_entry *tasklet_entry) |
| 150 | { |
| 151 | tasklet_schedule(&tasklet_entry->intr_tq); |
| 152 | } |
| 153 | #endif |
| 154 | |
| 155 | /** |
| 156 | * ce_tasklet() - ce_tasklet |
| 157 | * @data: data |
| 158 | * |
| 159 | * Return: N/A |
| 160 | */ |
| 161 | static void ce_tasklet(unsigned long data) |
| 162 | { |
| 163 | struct ce_tasklet_entry *tasklet_entry = |
| 164 | (struct ce_tasklet_entry *)data; |
| 165 | struct HIF_CE_state *hif_ce_state = tasklet_entry->hif_ce_state; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 166 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ce_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 167 | struct CE_state *CE_state = scn->ce_id_to_state[tasklet_entry->ce_id]; |
| 168 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 169 | hif_record_ce_desc_event(scn, tasklet_entry->ce_id, |
| 170 | HIF_CE_TASKLET_ENTRY, NULL, NULL, 0); |
Houston Hoffman | 4275ba2 | 2015-12-06 21:02:11 -0800 | [diff] [blame] | 171 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 172 | if (qdf_atomic_read(&scn->link_suspended)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 173 | HIF_ERROR("%s: ce %d tasklet fired after link suspend.", |
| 174 | __func__, tasklet_entry->ce_id); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 175 | QDF_BUG(0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | ce_per_engine_service(scn, tasklet_entry->ce_id); |
| 179 | |
Dhanashri Atre | 65b674f | 2015-10-30 15:12:03 -0700 | [diff] [blame] | 180 | if (CE_state->lro_flush_cb != NULL) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 181 | CE_state->lro_flush_cb(CE_state->lro_data); |
| 182 | } |
| 183 | |
Houston Hoffman | eb2516c | 2016-04-01 12:53:50 -0700 | [diff] [blame] | 184 | if (ce_check_rx_pending(CE_state)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 185 | /* |
| 186 | * There are frames pending, schedule tasklet to process them. |
| 187 | * Enable the interrupt only when there is no pending frames in |
| 188 | * any of the Copy Engine pipes. |
| 189 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 190 | hif_record_ce_desc_event(scn, tasklet_entry->ce_id, |
Houston Hoffman | 4275ba2 | 2015-12-06 21:02:11 -0800 | [diff] [blame] | 191 | HIF_CE_TASKLET_RESCHEDULE, NULL, NULL, 0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 192 | ce_schedule_tasklet(tasklet_entry); |
| 193 | return; |
| 194 | } |
| 195 | |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 196 | if (scn->target_status != TARGET_STATUS_RESET) |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 197 | hif_irq_enable(scn, tasklet_entry->ce_id); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 198 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 199 | hif_record_ce_desc_event(scn, tasklet_entry->ce_id, HIF_CE_TASKLET_EXIT, |
| 200 | NULL, NULL, 0); |
Houston Hoffman | 4275ba2 | 2015-12-06 21:02:11 -0800 | [diff] [blame] | 201 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 202 | qdf_atomic_dec(&scn->active_tasklet_cnt); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 203 | } |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 204 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 205 | /** |
| 206 | * ce_tasklet_init() - ce_tasklet_init |
| 207 | * @hif_ce_state: hif_ce_state |
| 208 | * @mask: mask |
| 209 | * |
| 210 | * Return: N/A |
| 211 | */ |
| 212 | void ce_tasklet_init(struct HIF_CE_state *hif_ce_state, uint32_t mask) |
| 213 | { |
| 214 | int i; |
| 215 | |
| 216 | for (i = 0; i < CE_COUNT_MAX; i++) { |
| 217 | if (mask & (1 << i)) { |
| 218 | hif_ce_state->tasklets[i].ce_id = i; |
| 219 | hif_ce_state->tasklets[i].inited = true; |
| 220 | hif_ce_state->tasklets[i].hif_ce_state = hif_ce_state; |
| 221 | tasklet_init(&hif_ce_state->tasklets[i].intr_tq, |
| 222 | ce_tasklet, |
| 223 | (unsigned long)&hif_ce_state->tasklets[i]); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | /** |
| 228 | * ce_tasklet_kill() - ce_tasklet_kill |
| 229 | * @hif_ce_state: hif_ce_state |
| 230 | * |
| 231 | * Return: N/A |
| 232 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 233 | void ce_tasklet_kill(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 234 | { |
| 235 | int i; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 236 | struct HIF_CE_state *hif_ce_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 237 | |
| 238 | for (i = 0; i < CE_COUNT_MAX; i++) |
| 239 | if (hif_ce_state->tasklets[i].inited) { |
| 240 | tasklet_kill(&hif_ce_state->tasklets[i].intr_tq); |
| 241 | hif_ce_state->tasklets[i].inited = false; |
| 242 | } |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 243 | qdf_atomic_set(&scn->active_tasklet_cnt, 0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 244 | } |
Houston Hoffman | 247f09b | 2016-04-06 21:21:40 -0700 | [diff] [blame] | 245 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 246 | /** |
Houston Hoffman | 247f09b | 2016-04-06 21:21:40 -0700 | [diff] [blame] | 247 | * hif_snoc_interrupt_handler() - hif_snoc_interrupt_handler |
| 248 | * @irq: irq coming from kernel |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 249 | * @context: context |
| 250 | * |
| 251 | * Return: N/A |
| 252 | */ |
Houston Hoffman | 247f09b | 2016-04-06 21:21:40 -0700 | [diff] [blame] | 253 | static irqreturn_t hif_snoc_interrupt_handler(int irq, void *context) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 254 | { |
| 255 | struct ce_tasklet_entry *tasklet_entry = context; |
Houston Hoffman | 247f09b | 2016-04-06 21:21:40 -0700 | [diff] [blame] | 256 | return ce_dispatch_interrupt(icnss_get_ce_id(irq), tasklet_entry); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * ce_dispatch_interrupt() - dispatch an interrupt to a processing context |
| 261 | * @ce_id: ce_id |
| 262 | * @tasklet_entry: context |
| 263 | * |
| 264 | * Return: N/A |
| 265 | */ |
| 266 | irqreturn_t ce_dispatch_interrupt(int ce_id, |
| 267 | struct ce_tasklet_entry *tasklet_entry) |
| 268 | { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 269 | struct HIF_CE_state *hif_ce_state = tasklet_entry->hif_ce_state; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 270 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ce_state); |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 271 | struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 272 | |
| 273 | if (tasklet_entry->ce_id != ce_id) { |
| 274 | HIF_ERROR("%s: ce_id (expect %d, received %d) does not match", |
| 275 | __func__, tasklet_entry->ce_id, ce_id); |
| 276 | return IRQ_NONE; |
| 277 | } |
Orhan K AKYILDIZ | 0615891 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 278 | if (unlikely(ce_id >= CE_COUNT_MAX)) { |
| 279 | HIF_ERROR("%s: ce_id=%d > CE_COUNT_MAX=%d", |
| 280 | __func__, tasklet_entry->ce_id, CE_COUNT_MAX); |
| 281 | return IRQ_NONE; |
| 282 | } |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 283 | hif_irq_disable(scn, ce_id); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 284 | qdf_atomic_inc(&scn->active_tasklet_cnt); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 285 | hif_record_ce_desc_event(scn, ce_id, HIF_IRQ_EVENT, NULL, NULL, 0); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 286 | if (hif_napi_enabled(hif_hdl, ce_id)) |
| 287 | hif_napi_schedule(hif_hdl, ce_id); |
Houston Hoffman | e9afdc1 | 2015-11-18 19:41:52 -0800 | [diff] [blame] | 288 | else |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 289 | tasklet_schedule(&tasklet_entry->intr_tq); |
Houston Hoffman | e9afdc1 | 2015-11-18 19:41:52 -0800 | [diff] [blame] | 290 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 291 | return IRQ_HANDLED; |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * const char *ce_name |
| 296 | * |
| 297 | * @ce_name: ce_name |
| 298 | */ |
| 299 | const char *ce_name[ICNSS_MAX_IRQ_REGISTRATIONS] = { |
| 300 | "WLAN_CE_0", |
| 301 | "WLAN_CE_1", |
| 302 | "WLAN_CE_2", |
| 303 | "WLAN_CE_3", |
| 304 | "WLAN_CE_4", |
| 305 | "WLAN_CE_5", |
| 306 | "WLAN_CE_6", |
| 307 | "WLAN_CE_7", |
| 308 | "WLAN_CE_8", |
| 309 | "WLAN_CE_9", |
| 310 | "WLAN_CE_10", |
| 311 | "WLAN_CE_11", |
| 312 | }; |
| 313 | /** |
| 314 | * ce_unregister_irq() - ce_unregister_irq |
| 315 | * @hif_ce_state: hif_ce_state copy engine device handle |
| 316 | * @mask: which coppy engines to unregister for. |
| 317 | * |
| 318 | * Unregisters copy engine irqs matching mask. If a 1 is set at bit x, |
| 319 | * unregister for copy engine x. |
| 320 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 321 | * Return: QDF_STATUS |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 322 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 323 | QDF_STATUS ce_unregister_irq(struct HIF_CE_state *hif_ce_state, uint32_t mask) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 324 | { |
| 325 | int id; |
Houston Hoffman | d6f946c | 2016-04-06 15:16:00 -0700 | [diff] [blame] | 326 | int ce_count = HIF_GET_SOFTC(hif_ce_state)->ce_count; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 327 | int ret; |
| 328 | |
| 329 | if (hif_ce_state == NULL) { |
| 330 | HIF_WARN("%s: hif_ce_state = NULL", __func__); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 331 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 332 | } |
Houston Hoffman | d6f946c | 2016-04-06 15:16:00 -0700 | [diff] [blame] | 333 | for (id = 0; id < ce_count; id++) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 334 | if ((mask & (1 << id)) && hif_ce_state->tasklets[id].inited) { |
| 335 | ret = icnss_ce_free_irq(id, |
| 336 | &hif_ce_state->tasklets[id]); |
| 337 | if (ret < 0) |
| 338 | HIF_ERROR( |
| 339 | "%s: icnss_unregister_irq error - ce_id = %d, ret = %d", |
| 340 | __func__, id, ret); |
| 341 | } |
| 342 | } |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 343 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 344 | } |
| 345 | /** |
| 346 | * ce_register_irq() - ce_register_irq |
| 347 | * @hif_ce_state: hif_ce_state |
| 348 | * @mask: which coppy engines to unregister for. |
| 349 | * |
| 350 | * Registers copy engine irqs matching mask. If a 1 is set at bit x, |
| 351 | * Register for copy engine x. |
| 352 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 353 | * Return: QDF_STATUS |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 354 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 355 | QDF_STATUS ce_register_irq(struct HIF_CE_state *hif_ce_state, uint32_t mask) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 356 | { |
| 357 | int id; |
Houston Hoffman | d6f946c | 2016-04-06 15:16:00 -0700 | [diff] [blame] | 358 | int ce_count = HIF_GET_SOFTC(hif_ce_state)->ce_count; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 359 | int ret; |
| 360 | unsigned long irqflags = IRQF_TRIGGER_RISING; |
| 361 | uint32_t done_mask = 0; |
| 362 | |
Houston Hoffman | d6f946c | 2016-04-06 15:16:00 -0700 | [diff] [blame] | 363 | for (id = 0; id < ce_count; id++) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 364 | if ((mask & (1 << id)) && hif_ce_state->tasklets[id].inited) { |
Houston Hoffman | 247f09b | 2016-04-06 21:21:40 -0700 | [diff] [blame] | 365 | ret = icnss_ce_request_irq(id, |
| 366 | hif_snoc_interrupt_handler, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 367 | irqflags, ce_name[id], |
| 368 | &hif_ce_state->tasklets[id]); |
| 369 | if (ret) { |
| 370 | HIF_ERROR( |
| 371 | "%s: cannot register CE %d irq handler, ret = %d", |
| 372 | __func__, id, ret); |
| 373 | ce_unregister_irq(hif_ce_state, done_mask); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 374 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 375 | } else { |
| 376 | done_mask |= 1 << id; |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 381 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 382 | } |