.. | .. |
---|
5 | 5 | * |
---|
6 | 6 | * GPL LICENSE SUMMARY |
---|
7 | 7 | * |
---|
8 | | - * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved. |
---|
9 | 8 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
---|
10 | 9 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
---|
11 | | - * Copyright(c) 2018 Intel Corporation |
---|
| 10 | + * Copyright(c) 2007 - 2015, 2018 - 2020 Intel Corporation |
---|
12 | 11 | * |
---|
13 | 12 | * This program is free software; you can redistribute it and/or modify |
---|
14 | 13 | * it under the terms of version 2 of the GNU General Public License as |
---|
.. | .. |
---|
19 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
20 | 19 | * General Public License for more details. |
---|
21 | 20 | * |
---|
22 | | - * You should have received a copy of the GNU General Public License |
---|
23 | | - * along with this program; if not, write to the Free Software |
---|
24 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
---|
25 | | - * USA |
---|
26 | | - * |
---|
27 | 21 | * The full GNU General Public License is included in this distribution |
---|
28 | 22 | * in the file called COPYING. |
---|
29 | 23 | * |
---|
.. | .. |
---|
33 | 27 | * |
---|
34 | 28 | * BSD LICENSE |
---|
35 | 29 | * |
---|
36 | | - * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved. |
---|
37 | 30 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
---|
38 | 31 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
---|
39 | | - * Copyright(c) 2018 Intel Corporation |
---|
| 32 | + * Copyright(c) 2007 - 2015, 2018 - 2020 Intel Corporation |
---|
40 | 33 | * All rights reserved. |
---|
41 | 34 | * |
---|
42 | 35 | * Redistribution and use in source and binary forms, with or without |
---|
.. | .. |
---|
67 | 60 | * |
---|
68 | 61 | *****************************************************************************/ |
---|
69 | 62 | #include <linux/pci.h> |
---|
70 | | -#include <linux/pci-aspm.h> |
---|
71 | 63 | #include <linux/interrupt.h> |
---|
72 | 64 | #include <linux/debugfs.h> |
---|
73 | 65 | #include <linux/sched.h> |
---|
74 | 66 | #include <linux/bitops.h> |
---|
75 | 67 | #include <linux/gfp.h> |
---|
76 | 68 | #include <linux/vmalloc.h> |
---|
77 | | -#include <linux/pm_runtime.h> |
---|
78 | 69 | #include <linux/module.h> |
---|
| 70 | +#include <linux/wait.h> |
---|
| 71 | +#include <linux/seq_file.h> |
---|
79 | 72 | |
---|
80 | 73 | #include "iwl-drv.h" |
---|
81 | 74 | #include "iwl-trans.h" |
---|
.. | .. |
---|
85 | 78 | #include "iwl-agn-hw.h" |
---|
86 | 79 | #include "fw/error-dump.h" |
---|
87 | 80 | #include "fw/dbg.h" |
---|
| 81 | +#include "fw/api/tx.h" |
---|
88 | 82 | #include "internal.h" |
---|
89 | 83 | #include "iwl-fh.h" |
---|
| 84 | +#include "iwl-context-info-gen3.h" |
---|
90 | 85 | |
---|
91 | 86 | /* extended range in FW SRAM */ |
---|
92 | 87 | #define IWL_FW_MEM_EXTENDED_START 0x40000 |
---|
93 | 88 | #define IWL_FW_MEM_EXTENDED_END 0x57FFF |
---|
94 | 89 | |
---|
95 | | -static void iwl_trans_pcie_dump_regs(struct iwl_trans *trans) |
---|
| 90 | +void iwl_trans_pcie_dump_regs(struct iwl_trans *trans) |
---|
96 | 91 | { |
---|
97 | | -#define PCI_DUMP_SIZE 64 |
---|
98 | | -#define PREFIX_LEN 32 |
---|
| 92 | +#define PCI_DUMP_SIZE 352 |
---|
| 93 | +#define PCI_MEM_DUMP_SIZE 64 |
---|
| 94 | +#define PCI_PARENT_DUMP_SIZE 524 |
---|
| 95 | +#define PREFIX_LEN 32 |
---|
99 | 96 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
100 | 97 | struct pci_dev *pdev = trans_pcie->pci_dev; |
---|
101 | 98 | u32 i, pos, alloc_size, *ptr, *buf; |
---|
.. | .. |
---|
106 | 103 | |
---|
107 | 104 | /* Should be a multiple of 4 */ |
---|
108 | 105 | BUILD_BUG_ON(PCI_DUMP_SIZE > 4096 || PCI_DUMP_SIZE & 0x3); |
---|
| 106 | + BUILD_BUG_ON(PCI_MEM_DUMP_SIZE > 4096 || PCI_MEM_DUMP_SIZE & 0x3); |
---|
| 107 | + BUILD_BUG_ON(PCI_PARENT_DUMP_SIZE > 4096 || PCI_PARENT_DUMP_SIZE & 0x3); |
---|
| 108 | + |
---|
109 | 109 | /* Alloc a max size buffer */ |
---|
110 | | - if (PCI_ERR_ROOT_ERR_SRC + 4 > PCI_DUMP_SIZE) |
---|
111 | | - alloc_size = PCI_ERR_ROOT_ERR_SRC + 4 + PREFIX_LEN; |
---|
112 | | - else |
---|
113 | | - alloc_size = PCI_DUMP_SIZE + PREFIX_LEN; |
---|
| 110 | + alloc_size = PCI_ERR_ROOT_ERR_SRC + 4 + PREFIX_LEN; |
---|
| 111 | + alloc_size = max_t(u32, alloc_size, PCI_DUMP_SIZE + PREFIX_LEN); |
---|
| 112 | + alloc_size = max_t(u32, alloc_size, PCI_MEM_DUMP_SIZE + PREFIX_LEN); |
---|
| 113 | + alloc_size = max_t(u32, alloc_size, PCI_PARENT_DUMP_SIZE + PREFIX_LEN); |
---|
| 114 | + |
---|
114 | 115 | buf = kmalloc(alloc_size, GFP_ATOMIC); |
---|
115 | 116 | if (!buf) |
---|
116 | 117 | return; |
---|
.. | .. |
---|
127 | 128 | print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); |
---|
128 | 129 | |
---|
129 | 130 | IWL_ERR(trans, "iwlwifi device memory mapped registers:\n"); |
---|
130 | | - for (i = 0, ptr = buf; i < PCI_DUMP_SIZE; i += 4, ptr++) |
---|
| 131 | + for (i = 0, ptr = buf; i < PCI_MEM_DUMP_SIZE; i += 4, ptr++) |
---|
131 | 132 | *ptr = iwl_read32(trans, i); |
---|
132 | 133 | print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); |
---|
133 | 134 | |
---|
.. | .. |
---|
150 | 151 | |
---|
151 | 152 | IWL_ERR(trans, "iwlwifi parent port (%s) config registers:\n", |
---|
152 | 153 | pci_name(pdev)); |
---|
153 | | - for (i = 0, ptr = buf; i < PCI_DUMP_SIZE; i += 4, ptr++) |
---|
| 154 | + for (i = 0, ptr = buf; i < PCI_PARENT_DUMP_SIZE; i += 4, ptr++) |
---|
154 | 155 | if (pci_read_config_dword(pdev, i, ptr)) |
---|
155 | 156 | goto err_read; |
---|
156 | 157 | print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); |
---|
.. | .. |
---|
183 | 184 | static void iwl_trans_pcie_sw_reset(struct iwl_trans *trans) |
---|
184 | 185 | { |
---|
185 | 186 | /* Reset entire device - do controller reset (results in SHRD_HW_RST) */ |
---|
186 | | - iwl_set_bit(trans, trans->cfg->csr->addr_sw_reset, |
---|
187 | | - BIT(trans->cfg->csr->flag_sw_reset)); |
---|
| 187 | + iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
---|
188 | 188 | usleep_range(5000, 6000); |
---|
189 | 189 | } |
---|
190 | 190 | |
---|
191 | 191 | static void iwl_pcie_free_fw_monitor(struct iwl_trans *trans) |
---|
192 | 192 | { |
---|
193 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 193 | + struct iwl_dram_data *fw_mon = &trans->dbg.fw_mon; |
---|
194 | 194 | |
---|
195 | | - if (!trans_pcie->fw_mon_page) |
---|
| 195 | + if (!fw_mon->size) |
---|
196 | 196 | return; |
---|
197 | 197 | |
---|
198 | | - dma_unmap_page(trans->dev, trans_pcie->fw_mon_phys, |
---|
199 | | - trans_pcie->fw_mon_size, DMA_FROM_DEVICE); |
---|
200 | | - __free_pages(trans_pcie->fw_mon_page, |
---|
201 | | - get_order(trans_pcie->fw_mon_size)); |
---|
202 | | - trans_pcie->fw_mon_page = NULL; |
---|
203 | | - trans_pcie->fw_mon_phys = 0; |
---|
204 | | - trans_pcie->fw_mon_size = 0; |
---|
| 198 | + dma_free_coherent(trans->dev, fw_mon->size, fw_mon->block, |
---|
| 199 | + fw_mon->physical); |
---|
| 200 | + |
---|
| 201 | + fw_mon->block = NULL; |
---|
| 202 | + fw_mon->physical = 0; |
---|
| 203 | + fw_mon->size = 0; |
---|
| 204 | +} |
---|
| 205 | + |
---|
| 206 | +static void iwl_pcie_alloc_fw_monitor_block(struct iwl_trans *trans, |
---|
| 207 | + u8 max_power, u8 min_power) |
---|
| 208 | +{ |
---|
| 209 | + struct iwl_dram_data *fw_mon = &trans->dbg.fw_mon; |
---|
| 210 | + void *block = NULL; |
---|
| 211 | + dma_addr_t physical = 0; |
---|
| 212 | + u32 size = 0; |
---|
| 213 | + u8 power; |
---|
| 214 | + |
---|
| 215 | + if (fw_mon->size) |
---|
| 216 | + return; |
---|
| 217 | + |
---|
| 218 | + for (power = max_power; power >= min_power; power--) { |
---|
| 219 | + size = BIT(power); |
---|
| 220 | + block = dma_alloc_coherent(trans->dev, size, &physical, |
---|
| 221 | + GFP_KERNEL | __GFP_NOWARN); |
---|
| 222 | + if (!block) |
---|
| 223 | + continue; |
---|
| 224 | + |
---|
| 225 | + IWL_INFO(trans, |
---|
| 226 | + "Allocated 0x%08x bytes for firmware monitor.\n", |
---|
| 227 | + size); |
---|
| 228 | + break; |
---|
| 229 | + } |
---|
| 230 | + |
---|
| 231 | + if (WARN_ON_ONCE(!block)) |
---|
| 232 | + return; |
---|
| 233 | + |
---|
| 234 | + if (power != max_power) |
---|
| 235 | + IWL_ERR(trans, |
---|
| 236 | + "Sorry - debug buffer is only %luK while you requested %luK\n", |
---|
| 237 | + (unsigned long)BIT(power - 10), |
---|
| 238 | + (unsigned long)BIT(max_power - 10)); |
---|
| 239 | + |
---|
| 240 | + fw_mon->block = block; |
---|
| 241 | + fw_mon->physical = physical; |
---|
| 242 | + fw_mon->size = size; |
---|
205 | 243 | } |
---|
206 | 244 | |
---|
207 | 245 | void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans, u8 max_power) |
---|
208 | 246 | { |
---|
209 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
210 | | - struct page *page = NULL; |
---|
211 | | - dma_addr_t phys; |
---|
212 | | - u32 size = 0; |
---|
213 | | - u8 power; |
---|
214 | | - |
---|
215 | 247 | if (!max_power) { |
---|
216 | 248 | /* default max_power is maximum */ |
---|
217 | 249 | max_power = 26; |
---|
.. | .. |
---|
224 | 256 | max_power)) |
---|
225 | 257 | return; |
---|
226 | 258 | |
---|
227 | | - if (trans_pcie->fw_mon_page) { |
---|
228 | | - dma_sync_single_for_device(trans->dev, trans_pcie->fw_mon_phys, |
---|
229 | | - trans_pcie->fw_mon_size, |
---|
230 | | - DMA_FROM_DEVICE); |
---|
231 | | - return; |
---|
232 | | - } |
---|
233 | | - |
---|
234 | | - phys = 0; |
---|
235 | | - for (power = max_power; power >= 11; power--) { |
---|
236 | | - int order; |
---|
237 | | - |
---|
238 | | - size = BIT(power); |
---|
239 | | - order = get_order(size); |
---|
240 | | - page = alloc_pages(__GFP_COMP | __GFP_NOWARN | __GFP_ZERO, |
---|
241 | | - order); |
---|
242 | | - if (!page) |
---|
243 | | - continue; |
---|
244 | | - |
---|
245 | | - phys = dma_map_page(trans->dev, page, 0, PAGE_SIZE << order, |
---|
246 | | - DMA_FROM_DEVICE); |
---|
247 | | - if (dma_mapping_error(trans->dev, phys)) { |
---|
248 | | - __free_pages(page, order); |
---|
249 | | - page = NULL; |
---|
250 | | - continue; |
---|
251 | | - } |
---|
252 | | - IWL_INFO(trans, |
---|
253 | | - "Allocated 0x%08x bytes (order %d) for firmware monitor.\n", |
---|
254 | | - size, order); |
---|
255 | | - break; |
---|
256 | | - } |
---|
257 | | - |
---|
258 | | - if (WARN_ON_ONCE(!page)) |
---|
| 259 | + if (trans->dbg.fw_mon.size) |
---|
259 | 260 | return; |
---|
260 | 261 | |
---|
261 | | - if (power != max_power) |
---|
262 | | - IWL_ERR(trans, |
---|
263 | | - "Sorry - debug buffer is only %luK while you requested %luK\n", |
---|
264 | | - (unsigned long)BIT(power - 10), |
---|
265 | | - (unsigned long)BIT(max_power - 10)); |
---|
266 | | - |
---|
267 | | - trans_pcie->fw_mon_page = page; |
---|
268 | | - trans_pcie->fw_mon_phys = phys; |
---|
269 | | - trans_pcie->fw_mon_size = size; |
---|
| 262 | + iwl_pcie_alloc_fw_monitor_block(trans, max_power, 11); |
---|
270 | 263 | } |
---|
271 | 264 | |
---|
272 | 265 | static u32 iwl_trans_pcie_read_shr(struct iwl_trans *trans, u32 reg) |
---|
.. | .. |
---|
308 | 301 | u16 cap; |
---|
309 | 302 | |
---|
310 | 303 | /* |
---|
311 | | - * HW bug W/A for instability in PCIe bus L0S->L1 transition. |
---|
312 | | - * Check if BIOS (or OS) enabled L1-ASPM on this device. |
---|
313 | | - * If so (likely), disable L0S, so device moves directly L0->L1; |
---|
314 | | - * costs negligible amount of power savings. |
---|
315 | | - * If not (unlikely), enable L0S, so there is at least some |
---|
316 | | - * power savings, even without L1. |
---|
| 304 | + * L0S states have been found to be unstable with our devices |
---|
| 305 | + * and in newer hardware they are not officially supported at |
---|
| 306 | + * all, so we must always set the L0S_DISABLED bit. |
---|
317 | 307 | */ |
---|
| 308 | + iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_DISABLED); |
---|
| 309 | + |
---|
318 | 310 | pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); |
---|
319 | | - if (lctl & PCI_EXP_LNKCTL_ASPM_L1) |
---|
320 | | - iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); |
---|
321 | | - else |
---|
322 | | - iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); |
---|
323 | 311 | trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S); |
---|
324 | 312 | |
---|
325 | 313 | pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_DEVCTL2, &cap); |
---|
.. | .. |
---|
346 | 334 | */ |
---|
347 | 335 | |
---|
348 | 336 | /* Disable L0S exit timer (platform NMI Work/Around) */ |
---|
349 | | - if (trans->cfg->device_family < IWL_DEVICE_FAMILY_8000) |
---|
| 337 | + if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_8000) |
---|
350 | 338 | iwl_set_bit(trans, CSR_GIO_CHICKEN_BITS, |
---|
351 | 339 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); |
---|
352 | 340 | |
---|
.. | .. |
---|
370 | 358 | iwl_pcie_apm_config(trans); |
---|
371 | 359 | |
---|
372 | 360 | /* Configure analog phase-lock-loop before activating to D0A */ |
---|
373 | | - if (trans->cfg->base_params->pll_cfg) |
---|
| 361 | + if (trans->trans_cfg->base_params->pll_cfg) |
---|
374 | 362 | iwl_set_bit(trans, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); |
---|
375 | 363 | |
---|
376 | | - /* |
---|
377 | | - * Set "initialization complete" bit to move adapter from |
---|
378 | | - * D0U* --> D0A* (powered-up active) state. |
---|
379 | | - */ |
---|
380 | | - iwl_set_bit(trans, CSR_GP_CNTRL, |
---|
381 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
382 | | - |
---|
383 | | - /* |
---|
384 | | - * Wait for clock stabilization; once stabilized, access to |
---|
385 | | - * device-internal resources is supported, e.g. iwl_write_prph() |
---|
386 | | - * and accesses to uCode SRAM. |
---|
387 | | - */ |
---|
388 | | - ret = iwl_poll_bit(trans, CSR_GP_CNTRL, |
---|
389 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
390 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
391 | | - 25000); |
---|
392 | | - if (ret < 0) { |
---|
393 | | - IWL_ERR(trans, "Failed to init the card\n"); |
---|
| 364 | + ret = iwl_finish_nic_init(trans, trans->trans_cfg); |
---|
| 365 | + if (ret) |
---|
394 | 366 | return ret; |
---|
395 | | - } |
---|
396 | 367 | |
---|
397 | 368 | if (trans->cfg->host_interrupt_operation_mode) { |
---|
398 | 369 | /* |
---|
.. | .. |
---|
462 | 433 | |
---|
463 | 434 | iwl_trans_pcie_sw_reset(trans); |
---|
464 | 435 | |
---|
465 | | - /* |
---|
466 | | - * Set "initialization complete" bit to move adapter from |
---|
467 | | - * D0U* --> D0A* (powered-up active) state. |
---|
468 | | - */ |
---|
469 | | - iwl_set_bit(trans, CSR_GP_CNTRL, |
---|
470 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
471 | | - |
---|
472 | | - /* |
---|
473 | | - * Wait for clock stabilization; once stabilized, access to |
---|
474 | | - * device-internal resources is possible. |
---|
475 | | - */ |
---|
476 | | - ret = iwl_poll_bit(trans, CSR_GP_CNTRL, |
---|
477 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
478 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
479 | | - 25000); |
---|
480 | | - if (WARN_ON(ret < 0)) { |
---|
481 | | - IWL_ERR(trans, "Access time out - failed to enable LP XTAL\n"); |
---|
| 436 | + ret = iwl_finish_nic_init(trans, trans->trans_cfg); |
---|
| 437 | + if (WARN_ON(ret)) { |
---|
482 | 438 | /* Release XTAL ON request */ |
---|
483 | 439 | __iwl_trans_pcie_clear_bit(trans, CSR_GP_CNTRL, |
---|
484 | 440 | CSR_GP_CNTRL_REG_FLAG_XTAL_ON); |
---|
.. | .. |
---|
526 | 482 | * Clear "initialization complete" bit to move adapter from |
---|
527 | 483 | * D0A* (powered-up Active) --> D0U* (Uninitialized) state. |
---|
528 | 484 | */ |
---|
529 | | - iwl_clear_bit(trans, CSR_GP_CNTRL, |
---|
530 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
| 485 | + iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
---|
531 | 486 | |
---|
532 | 487 | /* Activates XTAL resources monitor */ |
---|
533 | 488 | __iwl_trans_pcie_set_bit(trans, CSR_MONITOR_CFG_REG, |
---|
.. | .. |
---|
549 | 504 | int ret; |
---|
550 | 505 | |
---|
551 | 506 | /* stop device's busmaster DMA activity */ |
---|
552 | | - iwl_set_bit(trans, trans->cfg->csr->addr_sw_reset, |
---|
553 | | - BIT(trans->cfg->csr->flag_stop_master)); |
---|
| 507 | + iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); |
---|
554 | 508 | |
---|
555 | | - ret = iwl_poll_bit(trans, trans->cfg->csr->addr_sw_reset, |
---|
556 | | - BIT(trans->cfg->csr->flag_master_dis), |
---|
557 | | - BIT(trans->cfg->csr->flag_master_dis), 100); |
---|
| 509 | + ret = iwl_poll_bit(trans, CSR_RESET, |
---|
| 510 | + CSR_RESET_REG_FLAG_MASTER_DISABLED, |
---|
| 511 | + CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); |
---|
558 | 512 | if (ret < 0) |
---|
559 | 513 | IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n"); |
---|
560 | 514 | |
---|
.. | .. |
---|
570 | 524 | iwl_pcie_apm_init(trans); |
---|
571 | 525 | |
---|
572 | 526 | /* inform ME that we are leaving */ |
---|
573 | | - if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) |
---|
| 527 | + if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_7000) |
---|
574 | 528 | iwl_set_bits_prph(trans, APMG_PCIDEV_STT_REG, |
---|
575 | 529 | APMG_PCIDEV_STT_VAL_WAKE_ME); |
---|
576 | | - else if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) { |
---|
| 530 | + else if (trans->trans_cfg->device_family >= |
---|
| 531 | + IWL_DEVICE_FAMILY_8000) { |
---|
577 | 532 | iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, |
---|
578 | 533 | CSR_RESET_LINK_PWR_MGMT_DISABLED); |
---|
579 | 534 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
---|
.. | .. |
---|
602 | 557 | * Clear "initialization complete" bit to move adapter from |
---|
603 | 558 | * D0A* (powered-up Active) --> D0U* (Uninitialized) state. |
---|
604 | 559 | */ |
---|
605 | | - iwl_clear_bit(trans, CSR_GP_CNTRL, |
---|
606 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
| 560 | + iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
---|
607 | 561 | } |
---|
608 | 562 | |
---|
609 | 563 | static int iwl_pcie_nic_init(struct iwl_trans *trans) |
---|
.. | .. |
---|
630 | 584 | if (iwl_pcie_tx_init(trans)) |
---|
631 | 585 | return -ENOMEM; |
---|
632 | 586 | |
---|
633 | | - if (trans->cfg->base_params->shadow_reg_enable) { |
---|
| 587 | + if (trans->trans_cfg->base_params->shadow_reg_enable) { |
---|
634 | 588 | /* enable shadow regs in HW */ |
---|
635 | 589 | iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL, 0x800FFFFF); |
---|
636 | 590 | IWL_DEBUG_INFO(trans, "Enabling shadow registers in device\n"); |
---|
.. | .. |
---|
666 | 620 | int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) |
---|
667 | 621 | { |
---|
668 | 622 | int ret; |
---|
669 | | - int t = 0; |
---|
670 | 623 | int iter; |
---|
671 | 624 | |
---|
672 | 625 | IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n"); |
---|
.. | .. |
---|
681 | 634 | usleep_range(1000, 2000); |
---|
682 | 635 | |
---|
683 | 636 | for (iter = 0; iter < 10; iter++) { |
---|
| 637 | + int t = 0; |
---|
| 638 | + |
---|
684 | 639 | /* If HW is not ready, prepare the conditions to check again */ |
---|
685 | 640 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
---|
686 | 641 | CSR_HW_IF_CONFIG_REG_PREPARE); |
---|
.. | .. |
---|
868 | 823 | |
---|
869 | 824 | iwl_enable_interrupts(trans); |
---|
870 | 825 | |
---|
871 | | - if (trans->cfg->use_tfh) { |
---|
| 826 | + if (trans->trans_cfg->use_tfh) { |
---|
872 | 827 | if (cpu == 1) |
---|
873 | 828 | iwl_write_prph(trans, UREG_UCODE_LOAD_STATUS, |
---|
874 | 829 | 0xFFFF); |
---|
.. | .. |
---|
928 | 883 | return 0; |
---|
929 | 884 | } |
---|
930 | 885 | |
---|
| 886 | +static void iwl_pcie_apply_destination_ini(struct iwl_trans *trans) |
---|
| 887 | +{ |
---|
| 888 | + enum iwl_fw_ini_allocation_id alloc_id = IWL_FW_INI_ALLOCATION_ID_DBGC1; |
---|
| 889 | + struct iwl_fw_ini_allocation_tlv *fw_mon_cfg = |
---|
| 890 | + &trans->dbg.fw_mon_cfg[alloc_id]; |
---|
| 891 | + struct iwl_dram_data *frag; |
---|
| 892 | + |
---|
| 893 | + if (!iwl_trans_dbg_ini_valid(trans)) |
---|
| 894 | + return; |
---|
| 895 | + |
---|
| 896 | + if (le32_to_cpu(fw_mon_cfg->buf_location) == |
---|
| 897 | + IWL_FW_INI_LOCATION_SRAM_PATH) { |
---|
| 898 | + IWL_DEBUG_FW(trans, "WRT: Applying SMEM buffer destination\n"); |
---|
| 899 | + /* set sram monitor by enabling bit 7 */ |
---|
| 900 | + iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
---|
| 901 | + CSR_HW_IF_CONFIG_REG_BIT_MONITOR_SRAM); |
---|
| 902 | + |
---|
| 903 | + return; |
---|
| 904 | + } |
---|
| 905 | + |
---|
| 906 | + if (le32_to_cpu(fw_mon_cfg->buf_location) != |
---|
| 907 | + IWL_FW_INI_LOCATION_DRAM_PATH || |
---|
| 908 | + !trans->dbg.fw_mon_ini[alloc_id].num_frags) |
---|
| 909 | + return; |
---|
| 910 | + |
---|
| 911 | + frag = &trans->dbg.fw_mon_ini[alloc_id].frags[0]; |
---|
| 912 | + |
---|
| 913 | + IWL_DEBUG_FW(trans, "WRT: Applying DRAM destination (alloc_id=%u)\n", |
---|
| 914 | + alloc_id); |
---|
| 915 | + |
---|
| 916 | + iwl_write_umac_prph(trans, MON_BUFF_BASE_ADDR_VER2, |
---|
| 917 | + frag->physical >> MON_BUFF_SHIFT_VER2); |
---|
| 918 | + iwl_write_umac_prph(trans, MON_BUFF_END_ADDR_VER2, |
---|
| 919 | + (frag->physical + frag->size - 256) >> |
---|
| 920 | + MON_BUFF_SHIFT_VER2); |
---|
| 921 | +} |
---|
| 922 | + |
---|
931 | 923 | void iwl_pcie_apply_destination(struct iwl_trans *trans) |
---|
932 | 924 | { |
---|
933 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
934 | | - const struct iwl_fw_dbg_dest_tlv_v1 *dest = trans->dbg_dest_tlv; |
---|
| 925 | + const struct iwl_fw_dbg_dest_tlv_v1 *dest = trans->dbg.dest_tlv; |
---|
| 926 | + const struct iwl_dram_data *fw_mon = &trans->dbg.fw_mon; |
---|
935 | 927 | int i; |
---|
| 928 | + |
---|
| 929 | + if (iwl_trans_dbg_ini_valid(trans)) { |
---|
| 930 | + iwl_pcie_apply_destination_ini(trans); |
---|
| 931 | + return; |
---|
| 932 | + } |
---|
936 | 933 | |
---|
937 | 934 | IWL_INFO(trans, "Applying debug destination %s\n", |
---|
938 | 935 | get_fw_dbg_mode_string(dest->monitor_mode)); |
---|
.. | .. |
---|
942 | 939 | else |
---|
943 | 940 | IWL_WARN(trans, "PCI should have external buffer debug\n"); |
---|
944 | 941 | |
---|
945 | | - for (i = 0; i < trans->dbg_dest_reg_num; i++) { |
---|
| 942 | + for (i = 0; i < trans->dbg.n_dest_reg; i++) { |
---|
946 | 943 | u32 addr = le32_to_cpu(dest->reg_ops[i].addr); |
---|
947 | 944 | u32 val = le32_to_cpu(dest->reg_ops[i].val); |
---|
948 | 945 | |
---|
.. | .. |
---|
981 | 978 | } |
---|
982 | 979 | |
---|
983 | 980 | monitor: |
---|
984 | | - if (dest->monitor_mode == EXTERNAL_MODE && trans_pcie->fw_mon_size) { |
---|
| 981 | + if (dest->monitor_mode == EXTERNAL_MODE && fw_mon->size) { |
---|
985 | 982 | iwl_write_prph(trans, le32_to_cpu(dest->base_reg), |
---|
986 | | - trans_pcie->fw_mon_phys >> dest->base_shift); |
---|
987 | | - if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
| 983 | + fw_mon->physical >> dest->base_shift); |
---|
| 984 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
988 | 985 | iwl_write_prph(trans, le32_to_cpu(dest->end_reg), |
---|
989 | | - (trans_pcie->fw_mon_phys + |
---|
990 | | - trans_pcie->fw_mon_size - 256) >> |
---|
991 | | - dest->end_shift); |
---|
| 986 | + (fw_mon->physical + fw_mon->size - |
---|
| 987 | + 256) >> dest->end_shift); |
---|
992 | 988 | else |
---|
993 | 989 | iwl_write_prph(trans, le32_to_cpu(dest->end_reg), |
---|
994 | | - (trans_pcie->fw_mon_phys + |
---|
995 | | - trans_pcie->fw_mon_size) >> |
---|
996 | | - dest->end_shift); |
---|
| 990 | + (fw_mon->physical + fw_mon->size) >> |
---|
| 991 | + dest->end_shift); |
---|
997 | 992 | } |
---|
998 | 993 | } |
---|
999 | 994 | |
---|
1000 | 995 | static int iwl_pcie_load_given_ucode(struct iwl_trans *trans, |
---|
1001 | 996 | const struct fw_img *image) |
---|
1002 | 997 | { |
---|
1003 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1004 | 998 | int ret = 0; |
---|
1005 | 999 | int first_ucode_section; |
---|
1006 | 1000 | |
---|
.. | .. |
---|
1025 | 1019 | return ret; |
---|
1026 | 1020 | } |
---|
1027 | 1021 | |
---|
1028 | | - /* supported for 7000 only for the moment */ |
---|
1029 | | - if (iwlwifi_mod_params.fw_monitor && |
---|
1030 | | - trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) { |
---|
1031 | | - iwl_pcie_alloc_fw_monitor(trans, 0); |
---|
1032 | | - |
---|
1033 | | - if (trans_pcie->fw_mon_size) { |
---|
1034 | | - iwl_write_prph(trans, MON_BUFF_BASE_ADDR, |
---|
1035 | | - trans_pcie->fw_mon_phys >> 4); |
---|
1036 | | - iwl_write_prph(trans, MON_BUFF_END_ADDR, |
---|
1037 | | - (trans_pcie->fw_mon_phys + |
---|
1038 | | - trans_pcie->fw_mon_size) >> 4); |
---|
1039 | | - } |
---|
1040 | | - } else if (trans->dbg_dest_tlv) { |
---|
| 1022 | + if (iwl_pcie_dbg_on(trans)) |
---|
1041 | 1023 | iwl_pcie_apply_destination(trans); |
---|
1042 | | - } |
---|
1043 | 1024 | |
---|
1044 | 1025 | iwl_enable_interrupts(trans); |
---|
1045 | 1026 | |
---|
.. | .. |
---|
1058 | 1039 | IWL_DEBUG_FW(trans, "working with %s CPU\n", |
---|
1059 | 1040 | image->is_dual_cpus ? "Dual" : "Single"); |
---|
1060 | 1041 | |
---|
1061 | | - if (trans->dbg_dest_tlv) |
---|
| 1042 | + if (iwl_pcie_dbg_on(trans)) |
---|
1062 | 1043 | iwl_pcie_apply_destination(trans); |
---|
1063 | 1044 | |
---|
1064 | 1045 | IWL_DEBUG_POWER(trans, "Original WFPM value = 0x%08X\n", |
---|
.. | .. |
---|
1123 | 1104 | {MSIX_FH_INT_CAUSES_FH_ERR, CSR_MSIX_FH_INT_MASK_AD, 0x5}, |
---|
1124 | 1105 | {MSIX_HW_INT_CAUSES_REG_ALIVE, CSR_MSIX_HW_INT_MASK_AD, 0x10}, |
---|
1125 | 1106 | {MSIX_HW_INT_CAUSES_REG_WAKEUP, CSR_MSIX_HW_INT_MASK_AD, 0x11}, |
---|
| 1107 | + {MSIX_HW_INT_CAUSES_REG_IML, CSR_MSIX_HW_INT_MASK_AD, 0x12}, |
---|
1126 | 1108 | {MSIX_HW_INT_CAUSES_REG_CT_KILL, CSR_MSIX_HW_INT_MASK_AD, 0x16}, |
---|
1127 | 1109 | {MSIX_HW_INT_CAUSES_REG_RF_KILL, CSR_MSIX_HW_INT_MASK_AD, 0x17}, |
---|
1128 | 1110 | {MSIX_HW_INT_CAUSES_REG_PERIODIC, CSR_MSIX_HW_INT_MASK_AD, 0x18}, |
---|
.. | .. |
---|
1133 | 1115 | {MSIX_HW_INT_CAUSES_REG_HAP, CSR_MSIX_HW_INT_MASK_AD, 0x2E}, |
---|
1134 | 1116 | }; |
---|
1135 | 1117 | |
---|
1136 | | -static struct iwl_causes_list causes_list_v2[] = { |
---|
1137 | | - {MSIX_FH_INT_CAUSES_D2S_CH0_NUM, CSR_MSIX_FH_INT_MASK_AD, 0}, |
---|
1138 | | - {MSIX_FH_INT_CAUSES_D2S_CH1_NUM, CSR_MSIX_FH_INT_MASK_AD, 0x1}, |
---|
1139 | | - {MSIX_FH_INT_CAUSES_S2D, CSR_MSIX_FH_INT_MASK_AD, 0x3}, |
---|
1140 | | - {MSIX_FH_INT_CAUSES_FH_ERR, CSR_MSIX_FH_INT_MASK_AD, 0x5}, |
---|
1141 | | - {MSIX_HW_INT_CAUSES_REG_ALIVE, CSR_MSIX_HW_INT_MASK_AD, 0x10}, |
---|
1142 | | - {MSIX_HW_INT_CAUSES_REG_IPC, CSR_MSIX_HW_INT_MASK_AD, 0x11}, |
---|
1143 | | - {MSIX_HW_INT_CAUSES_REG_SW_ERR_V2, CSR_MSIX_HW_INT_MASK_AD, 0x15}, |
---|
1144 | | - {MSIX_HW_INT_CAUSES_REG_CT_KILL, CSR_MSIX_HW_INT_MASK_AD, 0x16}, |
---|
1145 | | - {MSIX_HW_INT_CAUSES_REG_RF_KILL, CSR_MSIX_HW_INT_MASK_AD, 0x17}, |
---|
1146 | | - {MSIX_HW_INT_CAUSES_REG_PERIODIC, CSR_MSIX_HW_INT_MASK_AD, 0x18}, |
---|
1147 | | - {MSIX_HW_INT_CAUSES_REG_SCD, CSR_MSIX_HW_INT_MASK_AD, 0x2A}, |
---|
1148 | | - {MSIX_HW_INT_CAUSES_REG_FH_TX, CSR_MSIX_HW_INT_MASK_AD, 0x2B}, |
---|
1149 | | - {MSIX_HW_INT_CAUSES_REG_HW_ERR, CSR_MSIX_HW_INT_MASK_AD, 0x2D}, |
---|
1150 | | - {MSIX_HW_INT_CAUSES_REG_HAP, CSR_MSIX_HW_INT_MASK_AD, 0x2E}, |
---|
1151 | | -}; |
---|
1152 | | - |
---|
1153 | 1118 | static void iwl_pcie_map_non_rx_causes(struct iwl_trans *trans) |
---|
1154 | 1119 | { |
---|
1155 | 1120 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1156 | 1121 | int val = trans_pcie->def_irq | MSIX_NON_AUTO_CLEAR_CAUSE; |
---|
1157 | | - int i, arr_size = |
---|
1158 | | - (trans->cfg->device_family < IWL_DEVICE_FAMILY_22560) ? |
---|
1159 | | - ARRAY_SIZE(causes_list) : ARRAY_SIZE(causes_list_v2); |
---|
| 1122 | + int i, arr_size = ARRAY_SIZE(causes_list); |
---|
| 1123 | + struct iwl_causes_list *causes = causes_list; |
---|
1160 | 1124 | |
---|
1161 | 1125 | /* |
---|
1162 | 1126 | * Access all non RX causes and map them to the default irq. |
---|
.. | .. |
---|
1164 | 1128 | * the first interrupt vector will serve non-RX and FBQ causes. |
---|
1165 | 1129 | */ |
---|
1166 | 1130 | for (i = 0; i < arr_size; i++) { |
---|
1167 | | - struct iwl_causes_list *causes = |
---|
1168 | | - (trans->cfg->device_family < IWL_DEVICE_FAMILY_22560) ? |
---|
1169 | | - causes_list : causes_list_v2; |
---|
1170 | | - |
---|
1171 | 1131 | iwl_write8(trans, CSR_MSIX_IVAR(causes[i].addr), val); |
---|
1172 | 1132 | iwl_clear_bit(trans, causes[i].mask_reg, |
---|
1173 | 1133 | causes[i].cause_num); |
---|
.. | .. |
---|
1209 | 1169 | struct iwl_trans *trans = trans_pcie->trans; |
---|
1210 | 1170 | |
---|
1211 | 1171 | if (!trans_pcie->msix_enabled) { |
---|
1212 | | - if (trans->cfg->mq_rx_supported && |
---|
| 1172 | + if (trans->trans_cfg->mq_rx_supported && |
---|
1213 | 1173 | test_bit(STATUS_DEVICE_ENABLED, &trans->status)) |
---|
1214 | | - iwl_write_prph(trans, UREG_CHICK, |
---|
1215 | | - UREG_CHICK_MSI_ENABLE); |
---|
| 1174 | + iwl_write_umac_prph(trans, UREG_CHICK, |
---|
| 1175 | + UREG_CHICK_MSI_ENABLE); |
---|
1216 | 1176 | return; |
---|
1217 | 1177 | } |
---|
1218 | 1178 | /* |
---|
.. | .. |
---|
1221 | 1181 | * prph. |
---|
1222 | 1182 | */ |
---|
1223 | 1183 | if (test_bit(STATUS_DEVICE_ENABLED, &trans->status)) |
---|
1224 | | - iwl_write_prph(trans, UREG_CHICK, UREG_CHICK_MSIX_ENABLE); |
---|
| 1184 | + iwl_write_umac_prph(trans, UREG_CHICK, UREG_CHICK_MSIX_ENABLE); |
---|
1225 | 1185 | |
---|
1226 | 1186 | /* |
---|
1227 | 1187 | * Each cause from the causes list above and the RX causes is |
---|
.. | .. |
---|
1250 | 1210 | trans_pcie->hw_mask = trans_pcie->hw_init_mask; |
---|
1251 | 1211 | } |
---|
1252 | 1212 | |
---|
1253 | | -static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power) |
---|
| 1213 | +static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans) |
---|
1254 | 1214 | { |
---|
1255 | 1215 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1256 | 1216 | |
---|
.. | .. |
---|
1260 | 1220 | return; |
---|
1261 | 1221 | |
---|
1262 | 1222 | trans_pcie->is_down = true; |
---|
1263 | | - |
---|
1264 | | - /* Stop dbgc before stopping device */ |
---|
1265 | | - if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) { |
---|
1266 | | - iwl_set_bits_prph(trans, MON_BUFF_SAMPLE_CTL, 0x100); |
---|
1267 | | - } else { |
---|
1268 | | - iwl_write_prph(trans, DBGC_IN_SAMPLE, 0); |
---|
1269 | | - udelay(100); |
---|
1270 | | - iwl_write_prph(trans, DBGC_OUT_CTRL, 0); |
---|
1271 | | - } |
---|
1272 | 1223 | |
---|
1273 | 1224 | /* tell the device to stop sending interrupts */ |
---|
1274 | 1225 | iwl_disable_interrupts(trans); |
---|
.. | .. |
---|
1299 | 1250 | |
---|
1300 | 1251 | /* Make sure (redundant) we've released our request to stay awake */ |
---|
1301 | 1252 | iwl_clear_bit(trans, CSR_GP_CNTRL, |
---|
1302 | | - BIT(trans->cfg->csr->flag_mac_access_req)); |
---|
| 1253 | + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
---|
1303 | 1254 | |
---|
1304 | 1255 | /* Stop the device, and put it in low power state */ |
---|
1305 | 1256 | iwl_pcie_apm_stop(trans, false); |
---|
.. | .. |
---|
1425 | 1376 | iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); |
---|
1426 | 1377 | |
---|
1427 | 1378 | /* Load the given image to the HW */ |
---|
1428 | | - if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
| 1379 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
1429 | 1380 | ret = iwl_pcie_load_given_ucode_8000(trans, fw); |
---|
1430 | 1381 | else |
---|
1431 | 1382 | ret = iwl_pcie_load_given_ucode(trans, fw); |
---|
.. | .. |
---|
1475 | 1426 | iwl_trans_pcie_rf_kill(trans, hw_rfkill); |
---|
1476 | 1427 | } |
---|
1477 | 1428 | |
---|
1478 | | -static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power) |
---|
| 1429 | +static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) |
---|
1479 | 1430 | { |
---|
1480 | 1431 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1481 | 1432 | bool was_in_rfkill; |
---|
.. | .. |
---|
1483 | 1434 | mutex_lock(&trans_pcie->mutex); |
---|
1484 | 1435 | trans_pcie->opmode_down = true; |
---|
1485 | 1436 | was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status); |
---|
1486 | | - _iwl_trans_pcie_stop_device(trans, low_power); |
---|
| 1437 | + _iwl_trans_pcie_stop_device(trans); |
---|
1487 | 1438 | iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill); |
---|
1488 | 1439 | mutex_unlock(&trans_pcie->mutex); |
---|
1489 | 1440 | } |
---|
.. | .. |
---|
1498 | 1449 | IWL_WARN(trans, "reporting RF_KILL (radio %s)\n", |
---|
1499 | 1450 | state ? "disabled" : "enabled"); |
---|
1500 | 1451 | if (iwl_op_mode_hw_rf_kill(trans->op_mode, state)) { |
---|
1501 | | - if (trans->cfg->gen2) |
---|
1502 | | - _iwl_trans_pcie_gen2_stop_device(trans, true); |
---|
| 1452 | + if (trans->trans_cfg->gen2) |
---|
| 1453 | + _iwl_trans_pcie_gen2_stop_device(trans); |
---|
1503 | 1454 | else |
---|
1504 | | - _iwl_trans_pcie_stop_device(trans, true); |
---|
| 1455 | + _iwl_trans_pcie_stop_device(trans); |
---|
1505 | 1456 | } |
---|
1506 | 1457 | } |
---|
1507 | 1458 | |
---|
1508 | | -static void iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test, |
---|
1509 | | - bool reset) |
---|
| 1459 | +void iwl_pcie_d3_complete_suspend(struct iwl_trans *trans, |
---|
| 1460 | + bool test, bool reset) |
---|
1510 | 1461 | { |
---|
1511 | | - if (!reset) { |
---|
1512 | | - /* Enable persistence mode to avoid reset */ |
---|
1513 | | - iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
---|
1514 | | - CSR_HW_IF_CONFIG_REG_PERSIST_MODE); |
---|
1515 | | - } |
---|
1516 | | - |
---|
1517 | 1462 | iwl_disable_interrupts(trans); |
---|
1518 | 1463 | |
---|
1519 | 1464 | /* |
---|
.. | .. |
---|
1528 | 1473 | iwl_pcie_synchronize_irqs(trans); |
---|
1529 | 1474 | |
---|
1530 | 1475 | iwl_clear_bit(trans, CSR_GP_CNTRL, |
---|
1531 | | - BIT(trans->cfg->csr->flag_mac_access_req)); |
---|
1532 | | - iwl_clear_bit(trans, CSR_GP_CNTRL, |
---|
1533 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
1534 | | - |
---|
1535 | | - iwl_pcie_enable_rx_wake(trans, false); |
---|
| 1476 | + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
---|
| 1477 | + iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
---|
1536 | 1478 | |
---|
1537 | 1479 | if (reset) { |
---|
1538 | 1480 | /* |
---|
.. | .. |
---|
1546 | 1488 | iwl_pcie_set_pwr(trans, true); |
---|
1547 | 1489 | } |
---|
1548 | 1490 | |
---|
| 1491 | +static int iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test, |
---|
| 1492 | + bool reset) |
---|
| 1493 | +{ |
---|
| 1494 | + int ret; |
---|
| 1495 | + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 1496 | + |
---|
| 1497 | + if (!reset) |
---|
| 1498 | + /* Enable persistence mode to avoid reset */ |
---|
| 1499 | + iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
---|
| 1500 | + CSR_HW_IF_CONFIG_REG_PERSIST_MODE); |
---|
| 1501 | + |
---|
| 1502 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { |
---|
| 1503 | + iwl_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6, |
---|
| 1504 | + UREG_DOORBELL_TO_ISR6_SUSPEND); |
---|
| 1505 | + |
---|
| 1506 | + ret = wait_event_timeout(trans_pcie->sx_waitq, |
---|
| 1507 | + trans_pcie->sx_complete, 2 * HZ); |
---|
| 1508 | + /* |
---|
| 1509 | + * Invalidate it toward resume. |
---|
| 1510 | + */ |
---|
| 1511 | + trans_pcie->sx_complete = false; |
---|
| 1512 | + |
---|
| 1513 | + if (!ret) { |
---|
| 1514 | + IWL_ERR(trans, "Timeout entering D3\n"); |
---|
| 1515 | + return -ETIMEDOUT; |
---|
| 1516 | + } |
---|
| 1517 | + } |
---|
| 1518 | + iwl_pcie_d3_complete_suspend(trans, test, reset); |
---|
| 1519 | + |
---|
| 1520 | + return 0; |
---|
| 1521 | +} |
---|
| 1522 | + |
---|
1549 | 1523 | static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans, |
---|
1550 | 1524 | enum iwl_d3_status *status, |
---|
1551 | 1525 | bool test, bool reset) |
---|
.. | .. |
---|
1557 | 1531 | if (test) { |
---|
1558 | 1532 | iwl_enable_interrupts(trans); |
---|
1559 | 1533 | *status = IWL_D3_STATUS_ALIVE; |
---|
1560 | | - return 0; |
---|
| 1534 | + goto out; |
---|
1561 | 1535 | } |
---|
1562 | 1536 | |
---|
1563 | | - iwl_pcie_enable_rx_wake(trans, true); |
---|
1564 | | - |
---|
1565 | 1537 | iwl_set_bit(trans, CSR_GP_CNTRL, |
---|
1566 | | - BIT(trans->cfg->csr->flag_mac_access_req)); |
---|
1567 | | - iwl_set_bit(trans, CSR_GP_CNTRL, |
---|
1568 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
| 1538 | + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
---|
1569 | 1539 | |
---|
1570 | | - if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
1571 | | - udelay(2); |
---|
1572 | | - |
---|
1573 | | - ret = iwl_poll_bit(trans, CSR_GP_CNTRL, |
---|
1574 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
1575 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
1576 | | - 25000); |
---|
1577 | | - if (ret < 0) { |
---|
1578 | | - IWL_ERR(trans, "Failed to resume the device (mac ready)\n"); |
---|
| 1540 | + ret = iwl_finish_nic_init(trans, trans->trans_cfg); |
---|
| 1541 | + if (ret) |
---|
1579 | 1542 | return ret; |
---|
1580 | | - } |
---|
1581 | 1543 | |
---|
1582 | 1544 | /* |
---|
1583 | 1545 | * Reconfigure IVAR table in case of MSIX or reset ict table in |
---|
.. | .. |
---|
1595 | 1557 | |
---|
1596 | 1558 | if (!reset) { |
---|
1597 | 1559 | iwl_clear_bit(trans, CSR_GP_CNTRL, |
---|
1598 | | - BIT(trans->cfg->csr->flag_mac_access_req)); |
---|
| 1560 | + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
---|
1599 | 1561 | } else { |
---|
1600 | 1562 | iwl_trans_pcie_tx_reset(trans); |
---|
1601 | 1563 | |
---|
.. | .. |
---|
1608 | 1570 | } |
---|
1609 | 1571 | |
---|
1610 | 1572 | IWL_DEBUG_POWER(trans, "WFPM value upon resume = 0x%08X\n", |
---|
1611 | | - iwl_read_prph(trans, WFPM_GP2)); |
---|
| 1573 | + iwl_read_umac_prph(trans, WFPM_GP2)); |
---|
1612 | 1574 | |
---|
1613 | 1575 | val = iwl_read32(trans, CSR_RESET); |
---|
1614 | 1576 | if (val & CSR_RESET_REG_FLAG_NEVO_RESET) |
---|
.. | .. |
---|
1616 | 1578 | else |
---|
1617 | 1579 | *status = IWL_D3_STATUS_ALIVE; |
---|
1618 | 1580 | |
---|
| 1581 | +out: |
---|
| 1582 | + if (*status == IWL_D3_STATUS_ALIVE && |
---|
| 1583 | + trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { |
---|
| 1584 | + trans_pcie->sx_complete = false; |
---|
| 1585 | + iwl_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6, |
---|
| 1586 | + UREG_DOORBELL_TO_ISR6_RESUME); |
---|
| 1587 | + |
---|
| 1588 | + ret = wait_event_timeout(trans_pcie->sx_waitq, |
---|
| 1589 | + trans_pcie->sx_complete, 2 * HZ); |
---|
| 1590 | + /* |
---|
| 1591 | + * Invalidate it toward next suspend. |
---|
| 1592 | + */ |
---|
| 1593 | + trans_pcie->sx_complete = false; |
---|
| 1594 | + |
---|
| 1595 | + if (!ret) { |
---|
| 1596 | + IWL_ERR(trans, "Timeout exiting D3\n"); |
---|
| 1597 | + return -ETIMEDOUT; |
---|
| 1598 | + } |
---|
| 1599 | + } |
---|
1619 | 1600 | return 0; |
---|
1620 | 1601 | } |
---|
1621 | 1602 | |
---|
1622 | | -static void iwl_pcie_set_interrupt_capa(struct pci_dev *pdev, |
---|
1623 | | - struct iwl_trans *trans) |
---|
| 1603 | +static void |
---|
| 1604 | +iwl_pcie_set_interrupt_capa(struct pci_dev *pdev, |
---|
| 1605 | + struct iwl_trans *trans, |
---|
| 1606 | + const struct iwl_cfg_trans_params *cfg_trans) |
---|
1624 | 1607 | { |
---|
1625 | 1608 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1626 | 1609 | int max_irqs, num_irqs, i, ret; |
---|
1627 | 1610 | u16 pci_cmd; |
---|
| 1611 | + u32 max_rx_queues = IWL_MAX_RX_HW_QUEUES; |
---|
1628 | 1612 | |
---|
1629 | | - if (!trans->cfg->mq_rx_supported) |
---|
| 1613 | + if (!cfg_trans->mq_rx_supported) |
---|
1630 | 1614 | goto enable_msi; |
---|
1631 | 1615 | |
---|
1632 | | - max_irqs = min_t(u32, num_online_cpus() + 2, IWL_MAX_RX_HW_QUEUES); |
---|
| 1616 | + if (cfg_trans->device_family <= IWL_DEVICE_FAMILY_9000) |
---|
| 1617 | + max_rx_queues = IWL_9000_MAX_RX_HW_QUEUES; |
---|
| 1618 | + |
---|
| 1619 | + max_irqs = min_t(u32, num_online_cpus() + 2, max_rx_queues); |
---|
1633 | 1620 | for (i = 0; i < max_irqs; i++) |
---|
1634 | 1621 | trans_pcie->msix_entries[i].entry = i; |
---|
1635 | 1622 | |
---|
.. | .. |
---|
1743 | 1730 | return 0; |
---|
1744 | 1731 | } |
---|
1745 | 1732 | |
---|
1746 | | -static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power) |
---|
| 1733 | +static int iwl_trans_pcie_clear_persistence_bit(struct iwl_trans *trans) |
---|
| 1734 | +{ |
---|
| 1735 | + u32 hpm, wprot; |
---|
| 1736 | + |
---|
| 1737 | + switch (trans->trans_cfg->device_family) { |
---|
| 1738 | + case IWL_DEVICE_FAMILY_9000: |
---|
| 1739 | + wprot = PREG_PRPH_WPROT_9000; |
---|
| 1740 | + break; |
---|
| 1741 | + case IWL_DEVICE_FAMILY_22000: |
---|
| 1742 | + wprot = PREG_PRPH_WPROT_22000; |
---|
| 1743 | + break; |
---|
| 1744 | + default: |
---|
| 1745 | + return 0; |
---|
| 1746 | + } |
---|
| 1747 | + |
---|
| 1748 | + hpm = iwl_read_umac_prph_no_grab(trans, HPM_DEBUG); |
---|
| 1749 | + if (hpm != 0xa5a5a5a0 && (hpm & PERSISTENCE_BIT)) { |
---|
| 1750 | + u32 wprot_val = iwl_read_umac_prph_no_grab(trans, wprot); |
---|
| 1751 | + |
---|
| 1752 | + if (wprot_val & PREG_WFPM_ACCESS) { |
---|
| 1753 | + IWL_ERR(trans, |
---|
| 1754 | + "Error, can not clear persistence bit\n"); |
---|
| 1755 | + return -EPERM; |
---|
| 1756 | + } |
---|
| 1757 | + iwl_write_umac_prph_no_grab(trans, HPM_DEBUG, |
---|
| 1758 | + hpm & ~PERSISTENCE_BIT); |
---|
| 1759 | + } |
---|
| 1760 | + |
---|
| 1761 | + return 0; |
---|
| 1762 | +} |
---|
| 1763 | + |
---|
| 1764 | +static int iwl_pcie_gen2_force_power_gating(struct iwl_trans *trans) |
---|
| 1765 | +{ |
---|
| 1766 | + int ret; |
---|
| 1767 | + |
---|
| 1768 | + ret = iwl_finish_nic_init(trans, trans->trans_cfg); |
---|
| 1769 | + if (ret < 0) |
---|
| 1770 | + return ret; |
---|
| 1771 | + |
---|
| 1772 | + iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG, |
---|
| 1773 | + HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE); |
---|
| 1774 | + udelay(20); |
---|
| 1775 | + iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG, |
---|
| 1776 | + HPM_HIPM_GEN_CFG_CR_PG_EN | |
---|
| 1777 | + HPM_HIPM_GEN_CFG_CR_SLP_EN); |
---|
| 1778 | + udelay(20); |
---|
| 1779 | + iwl_clear_bits_prph(trans, HPM_HIPM_GEN_CFG, |
---|
| 1780 | + HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE); |
---|
| 1781 | + |
---|
| 1782 | + iwl_trans_pcie_sw_reset(trans); |
---|
| 1783 | + |
---|
| 1784 | + return 0; |
---|
| 1785 | +} |
---|
| 1786 | + |
---|
| 1787 | +static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans) |
---|
1747 | 1788 | { |
---|
1748 | 1789 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1749 | | - u32 hpm; |
---|
1750 | 1790 | int err; |
---|
1751 | 1791 | |
---|
1752 | 1792 | lockdep_assert_held(&trans_pcie->mutex); |
---|
.. | .. |
---|
1757 | 1797 | return err; |
---|
1758 | 1798 | } |
---|
1759 | 1799 | |
---|
1760 | | - hpm = iwl_trans_read_prph(trans, HPM_DEBUG); |
---|
1761 | | - if (hpm != 0xa5a5a5a0 && (hpm & PERSISTENCE_BIT)) { |
---|
1762 | | - if (iwl_trans_read_prph(trans, PREG_PRPH_WPROT_0) & |
---|
1763 | | - PREG_WFPM_ACCESS) { |
---|
1764 | | - IWL_ERR(trans, |
---|
1765 | | - "Error, can not clear persistence bit\n"); |
---|
1766 | | - return -EPERM; |
---|
1767 | | - } |
---|
1768 | | - iwl_trans_write_prph(trans, HPM_DEBUG, hpm & ~PERSISTENCE_BIT); |
---|
1769 | | - } |
---|
| 1800 | + err = iwl_trans_pcie_clear_persistence_bit(trans); |
---|
| 1801 | + if (err) |
---|
| 1802 | + return err; |
---|
1770 | 1803 | |
---|
1771 | 1804 | iwl_trans_pcie_sw_reset(trans); |
---|
| 1805 | + |
---|
| 1806 | + if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000 && |
---|
| 1807 | + trans->trans_cfg->integrated) { |
---|
| 1808 | + err = iwl_pcie_gen2_force_power_gating(trans); |
---|
| 1809 | + if (err) |
---|
| 1810 | + return err; |
---|
| 1811 | + } |
---|
1772 | 1812 | |
---|
1773 | 1813 | err = iwl_pcie_apm_init(trans); |
---|
1774 | 1814 | if (err) |
---|
.. | .. |
---|
1787 | 1827 | /* ...rfkill can call stop_device and set it false if needed */ |
---|
1788 | 1828 | iwl_pcie_check_hw_rf_kill(trans); |
---|
1789 | 1829 | |
---|
1790 | | - /* Make sure we sync here, because we'll need full access later */ |
---|
1791 | | - if (low_power) |
---|
1792 | | - pm_runtime_resume(trans->dev); |
---|
1793 | | - |
---|
1794 | 1830 | return 0; |
---|
1795 | 1831 | } |
---|
1796 | 1832 | |
---|
1797 | | -static int iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power) |
---|
| 1833 | +static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) |
---|
1798 | 1834 | { |
---|
1799 | 1835 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1800 | 1836 | int ret; |
---|
1801 | 1837 | |
---|
1802 | 1838 | mutex_lock(&trans_pcie->mutex); |
---|
1803 | | - ret = _iwl_trans_pcie_start_hw(trans, low_power); |
---|
| 1839 | + ret = _iwl_trans_pcie_start_hw(trans); |
---|
1804 | 1840 | mutex_unlock(&trans_pcie->mutex); |
---|
1805 | 1841 | |
---|
1806 | 1842 | return ret; |
---|
.. | .. |
---|
1843 | 1879 | |
---|
1844 | 1880 | static u32 iwl_trans_pcie_prph_msk(struct iwl_trans *trans) |
---|
1845 | 1881 | { |
---|
1846 | | - if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) |
---|
| 1882 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) |
---|
1847 | 1883 | return 0x00FFFFFF; |
---|
1848 | 1884 | else |
---|
1849 | 1885 | return 0x000FFFFF; |
---|
.. | .. |
---|
1873 | 1909 | { |
---|
1874 | 1910 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1875 | 1911 | |
---|
1876 | | - trans_pcie->cmd_queue = trans_cfg->cmd_queue; |
---|
1877 | | - trans_pcie->cmd_fifo = trans_cfg->cmd_fifo; |
---|
1878 | | - trans_pcie->cmd_q_wdg_timeout = trans_cfg->cmd_q_wdg_timeout; |
---|
| 1912 | + /* free all first - we might be reconfigured for a different size */ |
---|
| 1913 | + iwl_pcie_free_rbs_pool(trans); |
---|
| 1914 | + |
---|
| 1915 | + trans->txqs.cmd.q_id = trans_cfg->cmd_queue; |
---|
| 1916 | + trans->txqs.cmd.fifo = trans_cfg->cmd_fifo; |
---|
| 1917 | + trans->txqs.cmd.wdg_timeout = trans_cfg->cmd_q_wdg_timeout; |
---|
| 1918 | + trans->txqs.page_offs = trans_cfg->cb_data_offs; |
---|
| 1919 | + trans->txqs.dev_cmd_offs = trans_cfg->cb_data_offs + sizeof(void *); |
---|
| 1920 | + |
---|
1879 | 1921 | if (WARN_ON(trans_cfg->n_no_reclaim_cmds > MAX_NO_RECLAIM_CMDS)) |
---|
1880 | 1922 | trans_pcie->n_no_reclaim_cmds = 0; |
---|
1881 | 1923 | else |
---|
.. | .. |
---|
1887 | 1929 | trans_pcie->rx_buf_size = trans_cfg->rx_buf_size; |
---|
1888 | 1930 | trans_pcie->rx_page_order = |
---|
1889 | 1931 | iwl_trans_get_rb_size_order(trans_pcie->rx_buf_size); |
---|
| 1932 | + trans_pcie->rx_buf_bytes = |
---|
| 1933 | + iwl_trans_get_rb_size(trans_pcie->rx_buf_size); |
---|
| 1934 | + trans_pcie->supported_dma_mask = DMA_BIT_MASK(12); |
---|
| 1935 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) |
---|
| 1936 | + trans_pcie->supported_dma_mask = DMA_BIT_MASK(11); |
---|
1890 | 1937 | |
---|
1891 | | - trans_pcie->bc_table_dword = trans_cfg->bc_table_dword; |
---|
| 1938 | + trans->txqs.bc_table_dword = trans_cfg->bc_table_dword; |
---|
1892 | 1939 | trans_pcie->scd_set_active = trans_cfg->scd_set_active; |
---|
1893 | 1940 | trans_pcie->sw_csum_tx = trans_cfg->sw_csum_tx; |
---|
1894 | | - |
---|
1895 | | - trans_pcie->page_offs = trans_cfg->cb_data_offs; |
---|
1896 | | - trans_pcie->dev_cmd_offs = trans_cfg->cb_data_offs + sizeof(void *); |
---|
1897 | 1941 | |
---|
1898 | 1942 | trans->command_groups = trans_cfg->command_groups; |
---|
1899 | 1943 | trans->command_groups_size = trans_cfg->command_groups_size; |
---|
.. | .. |
---|
1914 | 1958 | |
---|
1915 | 1959 | iwl_pcie_synchronize_irqs(trans); |
---|
1916 | 1960 | |
---|
1917 | | - if (trans->cfg->gen2) |
---|
1918 | | - iwl_pcie_gen2_tx_free(trans); |
---|
| 1961 | + if (trans->trans_cfg->gen2) |
---|
| 1962 | + iwl_txq_gen2_tx_free(trans); |
---|
1919 | 1963 | else |
---|
1920 | 1964 | iwl_pcie_tx_free(trans); |
---|
1921 | 1965 | iwl_pcie_rx_free(trans); |
---|
.. | .. |
---|
1939 | 1983 | |
---|
1940 | 1984 | iwl_pcie_free_fw_monitor(trans); |
---|
1941 | 1985 | |
---|
1942 | | - for_each_possible_cpu(i) { |
---|
1943 | | - struct iwl_tso_hdr_page *p = |
---|
1944 | | - per_cpu_ptr(trans_pcie->tso_hdr_page, i); |
---|
| 1986 | + if (trans_pcie->pnvm_dram.size) |
---|
| 1987 | + dma_free_coherent(trans->dev, trans_pcie->pnvm_dram.size, |
---|
| 1988 | + trans_pcie->pnvm_dram.block, |
---|
| 1989 | + trans_pcie->pnvm_dram.physical); |
---|
1945 | 1990 | |
---|
1946 | | - if (p->page) |
---|
1947 | | - __free_page(p->page); |
---|
1948 | | - } |
---|
1949 | | - |
---|
1950 | | - free_percpu(trans_pcie->tso_hdr_page); |
---|
1951 | 1991 | mutex_destroy(&trans_pcie->mutex); |
---|
1952 | 1992 | iwl_trans_free(trans); |
---|
1953 | 1993 | } |
---|
.. | .. |
---|
1970 | 2010 | struct iwl_trans_pcie_removal *removal = |
---|
1971 | 2011 | container_of(wk, struct iwl_trans_pcie_removal, work); |
---|
1972 | 2012 | struct pci_dev *pdev = removal->pdev; |
---|
1973 | | - char *prop[] = {"EVENT=INACCESSIBLE", NULL}; |
---|
| 2013 | + static char *prop[] = {"EVENT=INACCESSIBLE", NULL}; |
---|
1974 | 2014 | |
---|
1975 | 2015 | dev_err(&pdev->dev, "Device gone - attempting removal\n"); |
---|
1976 | 2016 | kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop); |
---|
.. | .. |
---|
1989 | 2029 | int ret; |
---|
1990 | 2030 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
1991 | 2031 | |
---|
1992 | | - spin_lock_irqsave(&trans_pcie->reg_lock, *flags); |
---|
| 2032 | + spin_lock_bh(&trans_pcie->reg_lock); |
---|
1993 | 2033 | |
---|
1994 | 2034 | if (trans_pcie->cmd_hold_nic_awake) |
---|
1995 | 2035 | goto out; |
---|
1996 | 2036 | |
---|
1997 | 2037 | /* this bit wakes up the NIC */ |
---|
1998 | 2038 | __iwl_trans_pcie_set_bit(trans, CSR_GP_CNTRL, |
---|
1999 | | - BIT(trans->cfg->csr->flag_mac_access_req)); |
---|
2000 | | - if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
| 2039 | + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
---|
| 2040 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_8000) |
---|
2001 | 2041 | udelay(2); |
---|
2002 | 2042 | |
---|
2003 | 2043 | /* |
---|
.. | .. |
---|
2021 | 2061 | * and do not save/restore SRAM when power cycling. |
---|
2022 | 2062 | */ |
---|
2023 | 2063 | ret = iwl_poll_bit(trans, CSR_GP_CNTRL, |
---|
2024 | | - BIT(trans->cfg->csr->flag_val_mac_access_en), |
---|
2025 | | - (BIT(trans->cfg->csr->flag_mac_clock_ready) | |
---|
| 2064 | + CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, |
---|
| 2065 | + (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | |
---|
2026 | 2066 | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); |
---|
2027 | 2067 | if (unlikely(ret < 0)) { |
---|
2028 | 2068 | u32 cntrl = iwl_read32(trans, CSR_GP_CNTRL); |
---|
.. | .. |
---|
2036 | 2076 | if (iwlwifi_mod_params.remove_when_gone && cntrl == ~0U) { |
---|
2037 | 2077 | struct iwl_trans_pcie_removal *removal; |
---|
2038 | 2078 | |
---|
2039 | | - if (trans_pcie->scheduled_for_removal) |
---|
| 2079 | + if (test_bit(STATUS_TRANS_DEAD, &trans->status)) |
---|
2040 | 2080 | goto err; |
---|
2041 | 2081 | |
---|
2042 | 2082 | IWL_ERR(trans, "Device gone - scheduling removal!\n"); |
---|
.. | .. |
---|
2062 | 2102 | * we don't need to clear this flag, because |
---|
2063 | 2103 | * the trans will be freed and reallocated. |
---|
2064 | 2104 | */ |
---|
2065 | | - trans_pcie->scheduled_for_removal = true; |
---|
| 2105 | + set_bit(STATUS_TRANS_DEAD, &trans->status); |
---|
2066 | 2106 | |
---|
2067 | 2107 | removal->pdev = to_pci_dev(trans->dev); |
---|
2068 | 2108 | INIT_WORK(&removal->work, iwl_trans_pcie_removal_wk); |
---|
.. | .. |
---|
2074 | 2114 | } |
---|
2075 | 2115 | |
---|
2076 | 2116 | err: |
---|
2077 | | - spin_unlock_irqrestore(&trans_pcie->reg_lock, *flags); |
---|
| 2117 | + spin_unlock_bh(&trans_pcie->reg_lock); |
---|
2078 | 2118 | return false; |
---|
2079 | 2119 | } |
---|
2080 | 2120 | |
---|
.. | .. |
---|
2104 | 2144 | goto out; |
---|
2105 | 2145 | |
---|
2106 | 2146 | __iwl_trans_pcie_clear_bit(trans, CSR_GP_CNTRL, |
---|
2107 | | - BIT(trans->cfg->csr->flag_mac_access_req)); |
---|
| 2147 | + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
---|
2108 | 2148 | /* |
---|
2109 | 2149 | * Above we read the CSR_GP_CNTRL register, which will flush |
---|
2110 | 2150 | * any previous writes, but we need the write that clears the |
---|
2111 | 2151 | * MAC_ACCESS_REQ bit to be performed before any other writes |
---|
2112 | 2152 | * scheduled on different CPUs (after we drop reg_lock). |
---|
2113 | 2153 | */ |
---|
2114 | | - mmiowb(); |
---|
2115 | 2154 | out: |
---|
2116 | | - spin_unlock_irqrestore(&trans_pcie->reg_lock, *flags); |
---|
| 2155 | + spin_unlock_bh(&trans_pcie->reg_lock); |
---|
2117 | 2156 | } |
---|
2118 | 2157 | |
---|
2119 | 2158 | static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, |
---|
.. | .. |
---|
2173 | 2212 | return ret; |
---|
2174 | 2213 | } |
---|
2175 | 2214 | |
---|
| 2215 | +static int iwl_trans_pcie_read_config32(struct iwl_trans *trans, u32 ofs, |
---|
| 2216 | + u32 *val) |
---|
| 2217 | +{ |
---|
| 2218 | + return pci_read_config_dword(IWL_TRANS_GET_PCIE_TRANS(trans)->pci_dev, |
---|
| 2219 | + ofs, val); |
---|
| 2220 | +} |
---|
| 2221 | + |
---|
2176 | 2222 | static void iwl_trans_pcie_freeze_txq_timer(struct iwl_trans *trans, |
---|
2177 | 2223 | unsigned long txqs, |
---|
2178 | 2224 | bool freeze) |
---|
2179 | 2225 | { |
---|
2180 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2181 | 2226 | int queue; |
---|
2182 | 2227 | |
---|
2183 | 2228 | for_each_set_bit(queue, &txqs, BITS_PER_LONG) { |
---|
2184 | | - struct iwl_txq *txq = trans_pcie->txq[queue]; |
---|
| 2229 | + struct iwl_txq *txq = trans->txqs.txq[queue]; |
---|
2185 | 2230 | unsigned long now; |
---|
2186 | 2231 | |
---|
2187 | 2232 | spin_lock_bh(&txq->lock); |
---|
.. | .. |
---|
2229 | 2274 | |
---|
2230 | 2275 | static void iwl_trans_pcie_block_txq_ptrs(struct iwl_trans *trans, bool block) |
---|
2231 | 2276 | { |
---|
2232 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2233 | 2277 | int i; |
---|
2234 | 2278 | |
---|
2235 | | - for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) { |
---|
2236 | | - struct iwl_txq *txq = trans_pcie->txq[i]; |
---|
| 2279 | + for (i = 0; i < trans->trans_cfg->base_params->num_of_queues; i++) { |
---|
| 2280 | + struct iwl_txq *txq = trans->txqs.txq[i]; |
---|
2237 | 2281 | |
---|
2238 | | - if (i == trans_pcie->cmd_queue) |
---|
| 2282 | + if (i == trans->txqs.cmd.q_id) |
---|
2239 | 2283 | continue; |
---|
2240 | 2284 | |
---|
2241 | 2285 | spin_lock_bh(&txq->lock); |
---|
.. | .. |
---|
2256 | 2300 | |
---|
2257 | 2301 | #define IWL_FLUSH_WAIT_MS 2000 |
---|
2258 | 2302 | |
---|
2259 | | -void iwl_trans_pcie_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq) |
---|
2260 | | -{ |
---|
2261 | | - u32 txq_id = txq->id; |
---|
2262 | | - u32 status; |
---|
2263 | | - bool active; |
---|
2264 | | - u8 fifo; |
---|
2265 | | - |
---|
2266 | | - if (trans->cfg->use_tfh) { |
---|
2267 | | - IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id, |
---|
2268 | | - txq->read_ptr, txq->write_ptr); |
---|
2269 | | - /* TODO: access new SCD registers and dump them */ |
---|
2270 | | - return; |
---|
2271 | | - } |
---|
2272 | | - |
---|
2273 | | - status = iwl_read_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id)); |
---|
2274 | | - fifo = (status >> SCD_QUEUE_STTS_REG_POS_TXF) & 0x7; |
---|
2275 | | - active = !!(status & BIT(SCD_QUEUE_STTS_REG_POS_ACTIVE)); |
---|
2276 | | - |
---|
2277 | | - IWL_ERR(trans, |
---|
2278 | | - "Queue %d is %sactive on fifo %d and stuck for %u ms. SW [%d, %d] HW [%d, %d] FH TRB=0x0%x\n", |
---|
2279 | | - txq_id, active ? "" : "in", fifo, |
---|
2280 | | - jiffies_to_msecs(txq->wd_timeout), |
---|
2281 | | - txq->read_ptr, txq->write_ptr, |
---|
2282 | | - iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & |
---|
2283 | | - (trans->cfg->base_params->max_tfd_queue_size - 1), |
---|
2284 | | - iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id)) & |
---|
2285 | | - (trans->cfg->base_params->max_tfd_queue_size - 1), |
---|
2286 | | - iwl_read_direct32(trans, FH_TX_TRB_REG(fifo))); |
---|
2287 | | -} |
---|
2288 | | - |
---|
2289 | 2303 | static int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue, |
---|
2290 | 2304 | struct iwl_trans_rxq_dma_data *data) |
---|
2291 | 2305 | { |
---|
.. | .. |
---|
2304 | 2318 | |
---|
2305 | 2319 | static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, int txq_idx) |
---|
2306 | 2320 | { |
---|
2307 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2308 | 2321 | struct iwl_txq *txq; |
---|
2309 | 2322 | unsigned long now = jiffies; |
---|
| 2323 | + bool overflow_tx; |
---|
2310 | 2324 | u8 wr_ptr; |
---|
2311 | 2325 | |
---|
2312 | | - if (!test_bit(txq_idx, trans_pcie->queue_used)) |
---|
| 2326 | + /* Make sure the NIC is still alive in the bus */ |
---|
| 2327 | + if (test_bit(STATUS_TRANS_DEAD, &trans->status)) |
---|
| 2328 | + return -ENODEV; |
---|
| 2329 | + |
---|
| 2330 | + if (!test_bit(txq_idx, trans->txqs.queue_used)) |
---|
2313 | 2331 | return -EINVAL; |
---|
2314 | 2332 | |
---|
2315 | 2333 | IWL_DEBUG_TX_QUEUES(trans, "Emptying queue %d...\n", txq_idx); |
---|
2316 | | - txq = trans_pcie->txq[txq_idx]; |
---|
| 2334 | + txq = trans->txqs.txq[txq_idx]; |
---|
| 2335 | + |
---|
| 2336 | + spin_lock_bh(&txq->lock); |
---|
| 2337 | + overflow_tx = txq->overflow_tx || |
---|
| 2338 | + !skb_queue_empty(&txq->overflow_q); |
---|
| 2339 | + spin_unlock_bh(&txq->lock); |
---|
| 2340 | + |
---|
2317 | 2341 | wr_ptr = READ_ONCE(txq->write_ptr); |
---|
2318 | 2342 | |
---|
2319 | | - while (txq->read_ptr != READ_ONCE(txq->write_ptr) && |
---|
| 2343 | + while ((txq->read_ptr != READ_ONCE(txq->write_ptr) || |
---|
| 2344 | + overflow_tx) && |
---|
2320 | 2345 | !time_after(jiffies, |
---|
2321 | 2346 | now + msecs_to_jiffies(IWL_FLUSH_WAIT_MS))) { |
---|
2322 | 2347 | u8 write_ptr = READ_ONCE(txq->write_ptr); |
---|
2323 | 2348 | |
---|
2324 | | - if (WARN_ONCE(wr_ptr != write_ptr, |
---|
| 2349 | + /* |
---|
| 2350 | + * If write pointer moved during the wait, warn only |
---|
| 2351 | + * if the TX came from op mode. In case TX came from |
---|
| 2352 | + * trans layer (overflow TX) don't warn. |
---|
| 2353 | + */ |
---|
| 2354 | + if (WARN_ONCE(wr_ptr != write_ptr && !overflow_tx, |
---|
2325 | 2355 | "WR pointer moved while flushing %d -> %d\n", |
---|
2326 | 2356 | wr_ptr, write_ptr)) |
---|
2327 | 2357 | return -ETIMEDOUT; |
---|
| 2358 | + wr_ptr = write_ptr; |
---|
| 2359 | + |
---|
2328 | 2360 | usleep_range(1000, 2000); |
---|
| 2361 | + |
---|
| 2362 | + spin_lock_bh(&txq->lock); |
---|
| 2363 | + overflow_tx = txq->overflow_tx || |
---|
| 2364 | + !skb_queue_empty(&txq->overflow_q); |
---|
| 2365 | + spin_unlock_bh(&txq->lock); |
---|
2329 | 2366 | } |
---|
2330 | 2367 | |
---|
2331 | 2368 | if (txq->read_ptr != txq->write_ptr) { |
---|
2332 | 2369 | IWL_ERR(trans, |
---|
2333 | 2370 | "fail to flush all tx fifo queues Q %d\n", txq_idx); |
---|
2334 | | - iwl_trans_pcie_log_scd_error(trans, txq); |
---|
| 2371 | + iwl_txq_log_scd_error(trans, txq); |
---|
2335 | 2372 | return -ETIMEDOUT; |
---|
2336 | 2373 | } |
---|
2337 | 2374 | |
---|
.. | .. |
---|
2342 | 2379 | |
---|
2343 | 2380 | static int iwl_trans_pcie_wait_txqs_empty(struct iwl_trans *trans, u32 txq_bm) |
---|
2344 | 2381 | { |
---|
2345 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2346 | 2382 | int cnt; |
---|
2347 | 2383 | int ret = 0; |
---|
2348 | 2384 | |
---|
2349 | 2385 | /* waiting for all the tx frames complete might take a while */ |
---|
2350 | | - for (cnt = 0; cnt < trans->cfg->base_params->num_of_queues; cnt++) { |
---|
| 2386 | + for (cnt = 0; |
---|
| 2387 | + cnt < trans->trans_cfg->base_params->num_of_queues; |
---|
| 2388 | + cnt++) { |
---|
2351 | 2389 | |
---|
2352 | | - if (cnt == trans_pcie->cmd_queue) |
---|
| 2390 | + if (cnt == trans->txqs.cmd.q_id) |
---|
2353 | 2391 | continue; |
---|
2354 | | - if (!test_bit(cnt, trans_pcie->queue_used)) |
---|
| 2392 | + if (!test_bit(cnt, trans->txqs.queue_used)) |
---|
2355 | 2393 | continue; |
---|
2356 | 2394 | if (!(BIT(cnt) & txq_bm)) |
---|
2357 | 2395 | continue; |
---|
.. | .. |
---|
2368 | 2406 | u32 mask, u32 value) |
---|
2369 | 2407 | { |
---|
2370 | 2408 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2371 | | - unsigned long flags; |
---|
2372 | 2409 | |
---|
2373 | | - spin_lock_irqsave(&trans_pcie->reg_lock, flags); |
---|
| 2410 | + spin_lock_bh(&trans_pcie->reg_lock); |
---|
2374 | 2411 | __iwl_trans_pcie_set_bits_mask(trans, reg, mask, value); |
---|
2375 | | - spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); |
---|
2376 | | -} |
---|
2377 | | - |
---|
2378 | | -static void iwl_trans_pcie_ref(struct iwl_trans *trans) |
---|
2379 | | -{ |
---|
2380 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2381 | | - |
---|
2382 | | - if (iwlwifi_mod_params.d0i3_disable) |
---|
2383 | | - return; |
---|
2384 | | - |
---|
2385 | | - pm_runtime_get(&trans_pcie->pci_dev->dev); |
---|
2386 | | - |
---|
2387 | | -#ifdef CONFIG_PM |
---|
2388 | | - IWL_DEBUG_RPM(trans, "runtime usage count: %d\n", |
---|
2389 | | - atomic_read(&trans_pcie->pci_dev->dev.power.usage_count)); |
---|
2390 | | -#endif /* CONFIG_PM */ |
---|
2391 | | -} |
---|
2392 | | - |
---|
2393 | | -static void iwl_trans_pcie_unref(struct iwl_trans *trans) |
---|
2394 | | -{ |
---|
2395 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2396 | | - |
---|
2397 | | - if (iwlwifi_mod_params.d0i3_disable) |
---|
2398 | | - return; |
---|
2399 | | - |
---|
2400 | | - pm_runtime_mark_last_busy(&trans_pcie->pci_dev->dev); |
---|
2401 | | - pm_runtime_put_autosuspend(&trans_pcie->pci_dev->dev); |
---|
2402 | | - |
---|
2403 | | -#ifdef CONFIG_PM |
---|
2404 | | - IWL_DEBUG_RPM(trans, "runtime usage count: %d\n", |
---|
2405 | | - atomic_read(&trans_pcie->pci_dev->dev.power.usage_count)); |
---|
2406 | | -#endif /* CONFIG_PM */ |
---|
| 2412 | + spin_unlock_bh(&trans_pcie->reg_lock); |
---|
2407 | 2413 | } |
---|
2408 | 2414 | |
---|
2409 | 2415 | static const char *get_csr_string(int cmd) |
---|
.. | .. |
---|
2482 | 2488 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
---|
2483 | 2489 | /* create and remove of files */ |
---|
2484 | 2490 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
---|
2485 | | - if (!debugfs_create_file(#name, mode, parent, trans, \ |
---|
2486 | | - &iwl_dbgfs_##name##_ops)) \ |
---|
2487 | | - goto err; \ |
---|
| 2491 | + debugfs_create_file(#name, mode, parent, trans, \ |
---|
| 2492 | + &iwl_dbgfs_##name##_ops); \ |
---|
2488 | 2493 | } while (0) |
---|
2489 | 2494 | |
---|
2490 | 2495 | /* file operation */ |
---|
.. | .. |
---|
2510 | 2515 | .llseek = generic_file_llseek, \ |
---|
2511 | 2516 | }; |
---|
2512 | 2517 | |
---|
2513 | | -static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, |
---|
2514 | | - char __user *user_buf, |
---|
2515 | | - size_t count, loff_t *ppos) |
---|
| 2518 | +struct iwl_dbgfs_tx_queue_priv { |
---|
| 2519 | + struct iwl_trans *trans; |
---|
| 2520 | +}; |
---|
| 2521 | + |
---|
| 2522 | +struct iwl_dbgfs_tx_queue_state { |
---|
| 2523 | + loff_t pos; |
---|
| 2524 | +}; |
---|
| 2525 | + |
---|
| 2526 | +static void *iwl_dbgfs_tx_queue_seq_start(struct seq_file *seq, loff_t *pos) |
---|
2516 | 2527 | { |
---|
2517 | | - struct iwl_trans *trans = file->private_data; |
---|
2518 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2519 | | - struct iwl_txq *txq; |
---|
2520 | | - char *buf; |
---|
2521 | | - int pos = 0; |
---|
2522 | | - int cnt; |
---|
2523 | | - int ret; |
---|
2524 | | - size_t bufsz; |
---|
| 2528 | + struct iwl_dbgfs_tx_queue_priv *priv = seq->private; |
---|
| 2529 | + struct iwl_dbgfs_tx_queue_state *state; |
---|
2525 | 2530 | |
---|
2526 | | - bufsz = sizeof(char) * 75 * trans->cfg->base_params->num_of_queues; |
---|
| 2531 | + if (*pos >= priv->trans->trans_cfg->base_params->num_of_queues) |
---|
| 2532 | + return NULL; |
---|
2527 | 2533 | |
---|
2528 | | - if (!trans_pcie->txq_memory) |
---|
2529 | | - return -EAGAIN; |
---|
| 2534 | + state = kmalloc(sizeof(*state), GFP_KERNEL); |
---|
| 2535 | + if (!state) |
---|
| 2536 | + return NULL; |
---|
| 2537 | + state->pos = *pos; |
---|
| 2538 | + return state; |
---|
| 2539 | +} |
---|
2530 | 2540 | |
---|
2531 | | - buf = kzalloc(bufsz, GFP_KERNEL); |
---|
2532 | | - if (!buf) |
---|
| 2541 | +static void *iwl_dbgfs_tx_queue_seq_next(struct seq_file *seq, |
---|
| 2542 | + void *v, loff_t *pos) |
---|
| 2543 | +{ |
---|
| 2544 | + struct iwl_dbgfs_tx_queue_priv *priv = seq->private; |
---|
| 2545 | + struct iwl_dbgfs_tx_queue_state *state = v; |
---|
| 2546 | + |
---|
| 2547 | + *pos = ++state->pos; |
---|
| 2548 | + |
---|
| 2549 | + if (*pos >= priv->trans->trans_cfg->base_params->num_of_queues) |
---|
| 2550 | + return NULL; |
---|
| 2551 | + |
---|
| 2552 | + return state; |
---|
| 2553 | +} |
---|
| 2554 | + |
---|
| 2555 | +static void iwl_dbgfs_tx_queue_seq_stop(struct seq_file *seq, void *v) |
---|
| 2556 | +{ |
---|
| 2557 | + kfree(v); |
---|
| 2558 | +} |
---|
| 2559 | + |
---|
| 2560 | +static int iwl_dbgfs_tx_queue_seq_show(struct seq_file *seq, void *v) |
---|
| 2561 | +{ |
---|
| 2562 | + struct iwl_dbgfs_tx_queue_priv *priv = seq->private; |
---|
| 2563 | + struct iwl_dbgfs_tx_queue_state *state = v; |
---|
| 2564 | + struct iwl_trans *trans = priv->trans; |
---|
| 2565 | + struct iwl_txq *txq = trans->txqs.txq[state->pos]; |
---|
| 2566 | + |
---|
| 2567 | + seq_printf(seq, "hwq %.3u: used=%d stopped=%d ", |
---|
| 2568 | + (unsigned int)state->pos, |
---|
| 2569 | + !!test_bit(state->pos, trans->txqs.queue_used), |
---|
| 2570 | + !!test_bit(state->pos, trans->txqs.queue_stopped)); |
---|
| 2571 | + if (txq) |
---|
| 2572 | + seq_printf(seq, |
---|
| 2573 | + "read=%u write=%u need_update=%d frozen=%d n_window=%d ampdu=%d", |
---|
| 2574 | + txq->read_ptr, txq->write_ptr, |
---|
| 2575 | + txq->need_update, txq->frozen, |
---|
| 2576 | + txq->n_window, txq->ampdu); |
---|
| 2577 | + else |
---|
| 2578 | + seq_puts(seq, "(unallocated)"); |
---|
| 2579 | + |
---|
| 2580 | + if (state->pos == trans->txqs.cmd.q_id) |
---|
| 2581 | + seq_puts(seq, " (HCMD)"); |
---|
| 2582 | + seq_puts(seq, "\n"); |
---|
| 2583 | + |
---|
| 2584 | + return 0; |
---|
| 2585 | +} |
---|
| 2586 | + |
---|
| 2587 | +static const struct seq_operations iwl_dbgfs_tx_queue_seq_ops = { |
---|
| 2588 | + .start = iwl_dbgfs_tx_queue_seq_start, |
---|
| 2589 | + .next = iwl_dbgfs_tx_queue_seq_next, |
---|
| 2590 | + .stop = iwl_dbgfs_tx_queue_seq_stop, |
---|
| 2591 | + .show = iwl_dbgfs_tx_queue_seq_show, |
---|
| 2592 | +}; |
---|
| 2593 | + |
---|
| 2594 | +static int iwl_dbgfs_tx_queue_open(struct inode *inode, struct file *filp) |
---|
| 2595 | +{ |
---|
| 2596 | + struct iwl_dbgfs_tx_queue_priv *priv; |
---|
| 2597 | + |
---|
| 2598 | + priv = __seq_open_private(filp, &iwl_dbgfs_tx_queue_seq_ops, |
---|
| 2599 | + sizeof(*priv)); |
---|
| 2600 | + |
---|
| 2601 | + if (!priv) |
---|
2533 | 2602 | return -ENOMEM; |
---|
2534 | 2603 | |
---|
2535 | | - for (cnt = 0; cnt < trans->cfg->base_params->num_of_queues; cnt++) { |
---|
2536 | | - txq = trans_pcie->txq[cnt]; |
---|
2537 | | - pos += scnprintf(buf + pos, bufsz - pos, |
---|
2538 | | - "hwq %.2d: read=%u write=%u use=%d stop=%d need_update=%d frozen=%d%s\n", |
---|
2539 | | - cnt, txq->read_ptr, txq->write_ptr, |
---|
2540 | | - !!test_bit(cnt, trans_pcie->queue_used), |
---|
2541 | | - !!test_bit(cnt, trans_pcie->queue_stopped), |
---|
2542 | | - txq->need_update, txq->frozen, |
---|
2543 | | - (cnt == trans_pcie->cmd_queue ? " HCMD" : "")); |
---|
2544 | | - } |
---|
2545 | | - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
---|
2546 | | - kfree(buf); |
---|
2547 | | - return ret; |
---|
| 2604 | + priv->trans = inode->i_private; |
---|
| 2605 | + return 0; |
---|
2548 | 2606 | } |
---|
2549 | 2607 | |
---|
2550 | 2608 | static ssize_t iwl_dbgfs_rx_queue_read(struct file *file, |
---|
.. | .. |
---|
2555 | 2613 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2556 | 2614 | char *buf; |
---|
2557 | 2615 | int pos = 0, i, ret; |
---|
2558 | | - size_t bufsz = sizeof(buf); |
---|
| 2616 | + size_t bufsz; |
---|
2559 | 2617 | |
---|
2560 | 2618 | bufsz = sizeof(char) * 121 * trans->num_rx_queues; |
---|
2561 | 2619 | |
---|
.. | .. |
---|
2727 | 2785 | { |
---|
2728 | 2786 | struct iwl_trans *trans = file->private_data; |
---|
2729 | 2787 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2730 | | - bool old = trans_pcie->debug_rfkill; |
---|
| 2788 | + bool new_value; |
---|
2731 | 2789 | int ret; |
---|
2732 | 2790 | |
---|
2733 | | - ret = kstrtobool_from_user(user_buf, count, &trans_pcie->debug_rfkill); |
---|
| 2791 | + ret = kstrtobool_from_user(user_buf, count, &new_value); |
---|
2734 | 2792 | if (ret) |
---|
2735 | 2793 | return ret; |
---|
2736 | | - if (old == trans_pcie->debug_rfkill) |
---|
| 2794 | + if (new_value == trans_pcie->debug_rfkill) |
---|
2737 | 2795 | return count; |
---|
2738 | 2796 | IWL_WARN(trans, "changing debug rfkill %d->%d\n", |
---|
2739 | | - old, trans_pcie->debug_rfkill); |
---|
| 2797 | + trans_pcie->debug_rfkill, new_value); |
---|
| 2798 | + trans_pcie->debug_rfkill = new_value; |
---|
2740 | 2799 | iwl_pcie_handle_rfkill_irq(trans); |
---|
2741 | 2800 | |
---|
2742 | 2801 | return count; |
---|
2743 | 2802 | } |
---|
2744 | 2803 | |
---|
| 2804 | +static int iwl_dbgfs_monitor_data_open(struct inode *inode, |
---|
| 2805 | + struct file *file) |
---|
| 2806 | +{ |
---|
| 2807 | + struct iwl_trans *trans = inode->i_private; |
---|
| 2808 | + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 2809 | + |
---|
| 2810 | + if (!trans->dbg.dest_tlv || |
---|
| 2811 | + trans->dbg.dest_tlv->monitor_mode != EXTERNAL_MODE) { |
---|
| 2812 | + IWL_ERR(trans, "Debug destination is not set to DRAM\n"); |
---|
| 2813 | + return -ENOENT; |
---|
| 2814 | + } |
---|
| 2815 | + |
---|
| 2816 | + if (trans_pcie->fw_mon_data.state != IWL_FW_MON_DBGFS_STATE_CLOSED) |
---|
| 2817 | + return -EBUSY; |
---|
| 2818 | + |
---|
| 2819 | + trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_OPEN; |
---|
| 2820 | + return simple_open(inode, file); |
---|
| 2821 | +} |
---|
| 2822 | + |
---|
| 2823 | +static int iwl_dbgfs_monitor_data_release(struct inode *inode, |
---|
| 2824 | + struct file *file) |
---|
| 2825 | +{ |
---|
| 2826 | + struct iwl_trans_pcie *trans_pcie = |
---|
| 2827 | + IWL_TRANS_GET_PCIE_TRANS(inode->i_private); |
---|
| 2828 | + |
---|
| 2829 | + if (trans_pcie->fw_mon_data.state == IWL_FW_MON_DBGFS_STATE_OPEN) |
---|
| 2830 | + trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED; |
---|
| 2831 | + return 0; |
---|
| 2832 | +} |
---|
| 2833 | + |
---|
| 2834 | +static bool iwl_write_to_user_buf(char __user *user_buf, ssize_t count, |
---|
| 2835 | + void *buf, ssize_t *size, |
---|
| 2836 | + ssize_t *bytes_copied) |
---|
| 2837 | +{ |
---|
| 2838 | + ssize_t buf_size_left = count - *bytes_copied; |
---|
| 2839 | + |
---|
| 2840 | + buf_size_left = buf_size_left - (buf_size_left % sizeof(u32)); |
---|
| 2841 | + if (*size > buf_size_left) |
---|
| 2842 | + *size = buf_size_left; |
---|
| 2843 | + |
---|
| 2844 | + *size -= copy_to_user(user_buf, buf, *size); |
---|
| 2845 | + *bytes_copied += *size; |
---|
| 2846 | + |
---|
| 2847 | + if (buf_size_left == *size) |
---|
| 2848 | + return true; |
---|
| 2849 | + return false; |
---|
| 2850 | +} |
---|
| 2851 | + |
---|
| 2852 | +static ssize_t iwl_dbgfs_monitor_data_read(struct file *file, |
---|
| 2853 | + char __user *user_buf, |
---|
| 2854 | + size_t count, loff_t *ppos) |
---|
| 2855 | +{ |
---|
| 2856 | + struct iwl_trans *trans = file->private_data; |
---|
| 2857 | + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 2858 | + void *cpu_addr = (void *)trans->dbg.fw_mon.block, *curr_buf; |
---|
| 2859 | + struct cont_rec *data = &trans_pcie->fw_mon_data; |
---|
| 2860 | + u32 write_ptr_addr, wrap_cnt_addr, write_ptr, wrap_cnt; |
---|
| 2861 | + ssize_t size, bytes_copied = 0; |
---|
| 2862 | + bool b_full; |
---|
| 2863 | + |
---|
| 2864 | + if (trans->dbg.dest_tlv) { |
---|
| 2865 | + write_ptr_addr = |
---|
| 2866 | + le32_to_cpu(trans->dbg.dest_tlv->write_ptr_reg); |
---|
| 2867 | + wrap_cnt_addr = le32_to_cpu(trans->dbg.dest_tlv->wrap_count); |
---|
| 2868 | + } else { |
---|
| 2869 | + write_ptr_addr = MON_BUFF_WRPTR; |
---|
| 2870 | + wrap_cnt_addr = MON_BUFF_CYCLE_CNT; |
---|
| 2871 | + } |
---|
| 2872 | + |
---|
| 2873 | + if (unlikely(!trans->dbg.rec_on)) |
---|
| 2874 | + return 0; |
---|
| 2875 | + |
---|
| 2876 | + mutex_lock(&data->mutex); |
---|
| 2877 | + if (data->state == |
---|
| 2878 | + IWL_FW_MON_DBGFS_STATE_DISABLED) { |
---|
| 2879 | + mutex_unlock(&data->mutex); |
---|
| 2880 | + return 0; |
---|
| 2881 | + } |
---|
| 2882 | + |
---|
| 2883 | + /* write_ptr position in bytes rather then DW */ |
---|
| 2884 | + write_ptr = iwl_read_prph(trans, write_ptr_addr) * sizeof(u32); |
---|
| 2885 | + wrap_cnt = iwl_read_prph(trans, wrap_cnt_addr); |
---|
| 2886 | + |
---|
| 2887 | + if (data->prev_wrap_cnt == wrap_cnt) { |
---|
| 2888 | + size = write_ptr - data->prev_wr_ptr; |
---|
| 2889 | + curr_buf = cpu_addr + data->prev_wr_ptr; |
---|
| 2890 | + b_full = iwl_write_to_user_buf(user_buf, count, |
---|
| 2891 | + curr_buf, &size, |
---|
| 2892 | + &bytes_copied); |
---|
| 2893 | + data->prev_wr_ptr += size; |
---|
| 2894 | + |
---|
| 2895 | + } else if (data->prev_wrap_cnt == wrap_cnt - 1 && |
---|
| 2896 | + write_ptr < data->prev_wr_ptr) { |
---|
| 2897 | + size = trans->dbg.fw_mon.size - data->prev_wr_ptr; |
---|
| 2898 | + curr_buf = cpu_addr + data->prev_wr_ptr; |
---|
| 2899 | + b_full = iwl_write_to_user_buf(user_buf, count, |
---|
| 2900 | + curr_buf, &size, |
---|
| 2901 | + &bytes_copied); |
---|
| 2902 | + data->prev_wr_ptr += size; |
---|
| 2903 | + |
---|
| 2904 | + if (!b_full) { |
---|
| 2905 | + size = write_ptr; |
---|
| 2906 | + b_full = iwl_write_to_user_buf(user_buf, count, |
---|
| 2907 | + cpu_addr, &size, |
---|
| 2908 | + &bytes_copied); |
---|
| 2909 | + data->prev_wr_ptr = size; |
---|
| 2910 | + data->prev_wrap_cnt++; |
---|
| 2911 | + } |
---|
| 2912 | + } else { |
---|
| 2913 | + if (data->prev_wrap_cnt == wrap_cnt - 1 && |
---|
| 2914 | + write_ptr > data->prev_wr_ptr) |
---|
| 2915 | + IWL_WARN(trans, |
---|
| 2916 | + "write pointer passed previous write pointer, start copying from the beginning\n"); |
---|
| 2917 | + else if (!unlikely(data->prev_wrap_cnt == 0 && |
---|
| 2918 | + data->prev_wr_ptr == 0)) |
---|
| 2919 | + IWL_WARN(trans, |
---|
| 2920 | + "monitor data is out of sync, start copying from the beginning\n"); |
---|
| 2921 | + |
---|
| 2922 | + size = write_ptr; |
---|
| 2923 | + b_full = iwl_write_to_user_buf(user_buf, count, |
---|
| 2924 | + cpu_addr, &size, |
---|
| 2925 | + &bytes_copied); |
---|
| 2926 | + data->prev_wr_ptr = size; |
---|
| 2927 | + data->prev_wrap_cnt = wrap_cnt; |
---|
| 2928 | + } |
---|
| 2929 | + |
---|
| 2930 | + mutex_unlock(&data->mutex); |
---|
| 2931 | + |
---|
| 2932 | + return bytes_copied; |
---|
| 2933 | +} |
---|
| 2934 | + |
---|
2745 | 2935 | DEBUGFS_READ_WRITE_FILE_OPS(interrupt); |
---|
2746 | 2936 | DEBUGFS_READ_FILE_OPS(fh_reg); |
---|
2747 | 2937 | DEBUGFS_READ_FILE_OPS(rx_queue); |
---|
2748 | | -DEBUGFS_READ_FILE_OPS(tx_queue); |
---|
2749 | 2938 | DEBUGFS_WRITE_FILE_OPS(csr); |
---|
2750 | 2939 | DEBUGFS_READ_WRITE_FILE_OPS(rfkill); |
---|
| 2940 | +static const struct file_operations iwl_dbgfs_tx_queue_ops = { |
---|
| 2941 | + .owner = THIS_MODULE, |
---|
| 2942 | + .open = iwl_dbgfs_tx_queue_open, |
---|
| 2943 | + .read = seq_read, |
---|
| 2944 | + .llseek = seq_lseek, |
---|
| 2945 | + .release = seq_release_private, |
---|
| 2946 | +}; |
---|
| 2947 | + |
---|
| 2948 | +static const struct file_operations iwl_dbgfs_monitor_data_ops = { |
---|
| 2949 | + .read = iwl_dbgfs_monitor_data_read, |
---|
| 2950 | + .open = iwl_dbgfs_monitor_data_open, |
---|
| 2951 | + .release = iwl_dbgfs_monitor_data_release, |
---|
| 2952 | +}; |
---|
2751 | 2953 | |
---|
2752 | 2954 | /* Create the debugfs files and directories */ |
---|
2753 | | -int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans) |
---|
| 2955 | +void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans) |
---|
2754 | 2956 | { |
---|
2755 | 2957 | struct dentry *dir = trans->dbgfs_dir; |
---|
2756 | 2958 | |
---|
.. | .. |
---|
2760 | 2962 | DEBUGFS_ADD_FILE(csr, dir, 0200); |
---|
2761 | 2963 | DEBUGFS_ADD_FILE(fh_reg, dir, 0400); |
---|
2762 | 2964 | DEBUGFS_ADD_FILE(rfkill, dir, 0600); |
---|
2763 | | - return 0; |
---|
| 2965 | + DEBUGFS_ADD_FILE(monitor_data, dir, 0400); |
---|
| 2966 | +} |
---|
2764 | 2967 | |
---|
2765 | | -err: |
---|
2766 | | - IWL_ERR(trans, "failed to create the trans debugfs entry\n"); |
---|
2767 | | - return -ENOMEM; |
---|
| 2968 | +static void iwl_trans_pcie_debugfs_cleanup(struct iwl_trans *trans) |
---|
| 2969 | +{ |
---|
| 2970 | + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 2971 | + struct cont_rec *data = &trans_pcie->fw_mon_data; |
---|
| 2972 | + |
---|
| 2973 | + mutex_lock(&data->mutex); |
---|
| 2974 | + data->state = IWL_FW_MON_DBGFS_STATE_DISABLED; |
---|
| 2975 | + mutex_unlock(&data->mutex); |
---|
2768 | 2976 | } |
---|
2769 | 2977 | #endif /*CONFIG_IWLWIFI_DEBUGFS */ |
---|
2770 | 2978 | |
---|
2771 | 2979 | static u32 iwl_trans_pcie_get_cmdlen(struct iwl_trans *trans, void *tfd) |
---|
2772 | 2980 | { |
---|
2773 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2774 | 2981 | u32 cmdlen = 0; |
---|
2775 | 2982 | int i; |
---|
2776 | 2983 | |
---|
2777 | | - for (i = 0; i < trans_pcie->max_tbs; i++) |
---|
2778 | | - cmdlen += iwl_pcie_tfd_tb_get_len(trans, tfd, i); |
---|
| 2984 | + for (i = 0; i < trans->txqs.tfd.max_tbs; i++) |
---|
| 2985 | + cmdlen += iwl_txq_gen1_tfd_tb_get_len(trans, tfd, i); |
---|
2779 | 2986 | |
---|
2780 | 2987 | return cmdlen; |
---|
2781 | 2988 | } |
---|
.. | .. |
---|
2785 | 2992 | int allocated_rb_nums) |
---|
2786 | 2993 | { |
---|
2787 | 2994 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2788 | | - int max_len = PAGE_SIZE << trans_pcie->rx_page_order; |
---|
| 2995 | + int max_len = trans_pcie->rx_buf_bytes; |
---|
2789 | 2996 | /* Dump RBs is supported only for pre-9000 devices (1 queue) */ |
---|
2790 | 2997 | struct iwl_rxq *rxq = &trans_pcie->rxq[0]; |
---|
2791 | 2998 | u32 i, r, j, rb_len = 0; |
---|
.. | .. |
---|
2811 | 3018 | rb->index = cpu_to_le32(i); |
---|
2812 | 3019 | memcpy(rb->data, page_address(rxb->page), max_len); |
---|
2813 | 3020 | /* remap the page for the free benefit */ |
---|
2814 | | - rxb->page_dma = dma_map_page(trans->dev, rxb->page, 0, |
---|
2815 | | - max_len, |
---|
2816 | | - DMA_FROM_DEVICE); |
---|
| 3021 | + rxb->page_dma = dma_map_page(trans->dev, rxb->page, |
---|
| 3022 | + rxb->offset, max_len, |
---|
| 3023 | + DMA_FROM_DEVICE); |
---|
2817 | 3024 | |
---|
2818 | 3025 | *data = iwl_fw_error_next_data(*data); |
---|
2819 | 3026 | } |
---|
.. | .. |
---|
2858 | 3065 | (*data)->len = cpu_to_le32(fh_regs_len); |
---|
2859 | 3066 | val = (void *)(*data)->data; |
---|
2860 | 3067 | |
---|
2861 | | - if (!trans->cfg->gen2) |
---|
| 3068 | + if (!trans->trans_cfg->gen2) |
---|
2862 | 3069 | for (i = FH_MEM_LOWER_BOUND; i < FH_MEM_UPPER_BOUND; |
---|
2863 | 3070 | i += sizeof(u32)) |
---|
2864 | 3071 | *val++ = cpu_to_le32(iwl_trans_pcie_read32(trans, i)); |
---|
2865 | 3072 | else |
---|
2866 | | - for (i = FH_MEM_LOWER_BOUND_GEN2; i < FH_MEM_UPPER_BOUND_GEN2; |
---|
| 3073 | + for (i = iwl_umac_prph(trans, FH_MEM_LOWER_BOUND_GEN2); |
---|
| 3074 | + i < iwl_umac_prph(trans, FH_MEM_UPPER_BOUND_GEN2); |
---|
2867 | 3075 | i += sizeof(u32)) |
---|
2868 | 3076 | *val++ = cpu_to_le32(iwl_trans_pcie_read_prph(trans, |
---|
2869 | 3077 | i)); |
---|
.. | .. |
---|
2888 | 3096 | if (!iwl_trans_grab_nic_access(trans, &flags)) |
---|
2889 | 3097 | return 0; |
---|
2890 | 3098 | |
---|
2891 | | - iwl_write_prph_no_grab(trans, MON_DMARB_RD_CTL_ADDR, 0x1); |
---|
| 3099 | + iwl_write_umac_prph_no_grab(trans, MON_DMARB_RD_CTL_ADDR, 0x1); |
---|
2892 | 3100 | for (i = 0; i < buf_size_in_dwords; i++) |
---|
2893 | | - buffer[i] = iwl_read_prph_no_grab(trans, |
---|
2894 | | - MON_DMARB_RD_DATA_ADDR); |
---|
2895 | | - iwl_write_prph_no_grab(trans, MON_DMARB_RD_CTL_ADDR, 0x0); |
---|
| 3101 | + buffer[i] = iwl_read_umac_prph_no_grab(trans, |
---|
| 3102 | + MON_DMARB_RD_DATA_ADDR); |
---|
| 3103 | + iwl_write_umac_prph_no_grab(trans, MON_DMARB_RD_CTL_ADDR, 0x0); |
---|
2896 | 3104 | |
---|
2897 | 3105 | iwl_trans_release_nic_access(trans, &flags); |
---|
2898 | 3106 | |
---|
2899 | 3107 | return monitor_len; |
---|
| 3108 | +} |
---|
| 3109 | + |
---|
| 3110 | +static void |
---|
| 3111 | +iwl_trans_pcie_dump_pointers(struct iwl_trans *trans, |
---|
| 3112 | + struct iwl_fw_error_dump_fw_mon *fw_mon_data) |
---|
| 3113 | +{ |
---|
| 3114 | + u32 base, base_high, write_ptr, write_ptr_val, wrap_cnt; |
---|
| 3115 | + |
---|
| 3116 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { |
---|
| 3117 | + base = DBGC_CUR_DBGBUF_BASE_ADDR_LSB; |
---|
| 3118 | + base_high = DBGC_CUR_DBGBUF_BASE_ADDR_MSB; |
---|
| 3119 | + write_ptr = DBGC_CUR_DBGBUF_STATUS; |
---|
| 3120 | + wrap_cnt = DBGC_DBGBUF_WRAP_AROUND; |
---|
| 3121 | + } else if (trans->dbg.dest_tlv) { |
---|
| 3122 | + write_ptr = le32_to_cpu(trans->dbg.dest_tlv->write_ptr_reg); |
---|
| 3123 | + wrap_cnt = le32_to_cpu(trans->dbg.dest_tlv->wrap_count); |
---|
| 3124 | + base = le32_to_cpu(trans->dbg.dest_tlv->base_reg); |
---|
| 3125 | + } else { |
---|
| 3126 | + base = MON_BUFF_BASE_ADDR; |
---|
| 3127 | + write_ptr = MON_BUFF_WRPTR; |
---|
| 3128 | + wrap_cnt = MON_BUFF_CYCLE_CNT; |
---|
| 3129 | + } |
---|
| 3130 | + |
---|
| 3131 | + write_ptr_val = iwl_read_prph(trans, write_ptr); |
---|
| 3132 | + fw_mon_data->fw_mon_cycle_cnt = |
---|
| 3133 | + cpu_to_le32(iwl_read_prph(trans, wrap_cnt)); |
---|
| 3134 | + fw_mon_data->fw_mon_base_ptr = |
---|
| 3135 | + cpu_to_le32(iwl_read_prph(trans, base)); |
---|
| 3136 | + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { |
---|
| 3137 | + fw_mon_data->fw_mon_base_high_ptr = |
---|
| 3138 | + cpu_to_le32(iwl_read_prph(trans, base_high)); |
---|
| 3139 | + write_ptr_val &= DBGC_CUR_DBGBUF_STATUS_OFFSET_MSK; |
---|
| 3140 | + } |
---|
| 3141 | + fw_mon_data->fw_mon_wr_ptr = cpu_to_le32(write_ptr_val); |
---|
2900 | 3142 | } |
---|
2901 | 3143 | |
---|
2902 | 3144 | static u32 |
---|
.. | .. |
---|
2904 | 3146 | struct iwl_fw_error_dump_data **data, |
---|
2905 | 3147 | u32 monitor_len) |
---|
2906 | 3148 | { |
---|
2907 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 3149 | + struct iwl_dram_data *fw_mon = &trans->dbg.fw_mon; |
---|
2908 | 3150 | u32 len = 0; |
---|
2909 | 3151 | |
---|
2910 | | - if ((trans_pcie->fw_mon_page && |
---|
2911 | | - trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) || |
---|
2912 | | - trans->dbg_dest_tlv) { |
---|
| 3152 | + if (trans->dbg.dest_tlv || |
---|
| 3153 | + (fw_mon->size && |
---|
| 3154 | + (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_7000 || |
---|
| 3155 | + trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210))) { |
---|
2913 | 3156 | struct iwl_fw_error_dump_fw_mon *fw_mon_data; |
---|
2914 | | - u32 base, write_ptr, wrap_cnt; |
---|
2915 | | - |
---|
2916 | | - /* If there was a dest TLV - use the values from there */ |
---|
2917 | | - if (trans->dbg_dest_tlv) { |
---|
2918 | | - write_ptr = |
---|
2919 | | - le32_to_cpu(trans->dbg_dest_tlv->write_ptr_reg); |
---|
2920 | | - wrap_cnt = le32_to_cpu(trans->dbg_dest_tlv->wrap_count); |
---|
2921 | | - base = le32_to_cpu(trans->dbg_dest_tlv->base_reg); |
---|
2922 | | - } else { |
---|
2923 | | - base = MON_BUFF_BASE_ADDR; |
---|
2924 | | - write_ptr = MON_BUFF_WRPTR; |
---|
2925 | | - wrap_cnt = MON_BUFF_CYCLE_CNT; |
---|
2926 | | - } |
---|
2927 | 3157 | |
---|
2928 | 3158 | (*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_FW_MONITOR); |
---|
2929 | 3159 | fw_mon_data = (void *)(*data)->data; |
---|
2930 | | - fw_mon_data->fw_mon_wr_ptr = |
---|
2931 | | - cpu_to_le32(iwl_read_prph(trans, write_ptr)); |
---|
2932 | | - fw_mon_data->fw_mon_cycle_cnt = |
---|
2933 | | - cpu_to_le32(iwl_read_prph(trans, wrap_cnt)); |
---|
2934 | | - fw_mon_data->fw_mon_base_ptr = |
---|
2935 | | - cpu_to_le32(iwl_read_prph(trans, base)); |
---|
| 3160 | + |
---|
| 3161 | + iwl_trans_pcie_dump_pointers(trans, fw_mon_data); |
---|
2936 | 3162 | |
---|
2937 | 3163 | len += sizeof(**data) + sizeof(*fw_mon_data); |
---|
2938 | | - if (trans_pcie->fw_mon_page) { |
---|
2939 | | - /* |
---|
2940 | | - * The firmware is now asserted, it won't write anything |
---|
2941 | | - * to the buffer. CPU can take ownership to fetch the |
---|
2942 | | - * data. The buffer will be handed back to the device |
---|
2943 | | - * before the firmware will be restarted. |
---|
2944 | | - */ |
---|
2945 | | - dma_sync_single_for_cpu(trans->dev, |
---|
2946 | | - trans_pcie->fw_mon_phys, |
---|
2947 | | - trans_pcie->fw_mon_size, |
---|
2948 | | - DMA_FROM_DEVICE); |
---|
2949 | | - memcpy(fw_mon_data->data, |
---|
2950 | | - page_address(trans_pcie->fw_mon_page), |
---|
2951 | | - trans_pcie->fw_mon_size); |
---|
2952 | | - |
---|
2953 | | - monitor_len = trans_pcie->fw_mon_size; |
---|
2954 | | - } else if (trans->dbg_dest_tlv->monitor_mode == SMEM_MODE) { |
---|
| 3164 | + if (fw_mon->size) { |
---|
| 3165 | + memcpy(fw_mon_data->data, fw_mon->block, fw_mon->size); |
---|
| 3166 | + monitor_len = fw_mon->size; |
---|
| 3167 | + } else if (trans->dbg.dest_tlv->monitor_mode == SMEM_MODE) { |
---|
| 3168 | + u32 base = le32_to_cpu(fw_mon_data->fw_mon_base_ptr); |
---|
2955 | 3169 | /* |
---|
2956 | 3170 | * Update pointers to reflect actual values after |
---|
2957 | 3171 | * shifting |
---|
2958 | 3172 | */ |
---|
2959 | | - if (trans->dbg_dest_tlv->version) { |
---|
| 3173 | + if (trans->dbg.dest_tlv->version) { |
---|
2960 | 3174 | base = (iwl_read_prph(trans, base) & |
---|
2961 | 3175 | IWL_LDBG_M2S_BUF_BA_MSK) << |
---|
2962 | | - trans->dbg_dest_tlv->base_shift; |
---|
| 3176 | + trans->dbg.dest_tlv->base_shift; |
---|
2963 | 3177 | base *= IWL_M2S_UNIT_SIZE; |
---|
2964 | 3178 | base += trans->cfg->smem_offset; |
---|
2965 | 3179 | } else { |
---|
2966 | 3180 | base = iwl_read_prph(trans, base) << |
---|
2967 | | - trans->dbg_dest_tlv->base_shift; |
---|
| 3181 | + trans->dbg.dest_tlv->base_shift; |
---|
2968 | 3182 | } |
---|
2969 | 3183 | |
---|
2970 | 3184 | iwl_trans_read_mem(trans, base, fw_mon_data->data, |
---|
2971 | 3185 | monitor_len / sizeof(u32)); |
---|
2972 | | - } else if (trans->dbg_dest_tlv->monitor_mode == MARBH_MODE) { |
---|
| 3186 | + } else if (trans->dbg.dest_tlv->monitor_mode == MARBH_MODE) { |
---|
2973 | 3187 | monitor_len = |
---|
2974 | 3188 | iwl_trans_pci_dump_marbh_monitor(trans, |
---|
2975 | 3189 | fw_mon_data, |
---|
.. | .. |
---|
2986 | 3200 | return len; |
---|
2987 | 3201 | } |
---|
2988 | 3202 | |
---|
2989 | | -static struct iwl_trans_dump_data |
---|
2990 | | -*iwl_trans_pcie_dump_data(struct iwl_trans *trans, |
---|
2991 | | - const struct iwl_fw_dbg_trigger_tlv *trigger) |
---|
| 3203 | +static int iwl_trans_get_fw_monitor_len(struct iwl_trans *trans, u32 *len) |
---|
2992 | 3204 | { |
---|
2993 | | - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
2994 | | - struct iwl_fw_error_dump_data *data; |
---|
2995 | | - struct iwl_txq *cmdq = trans_pcie->txq[trans_pcie->cmd_queue]; |
---|
2996 | | - struct iwl_fw_error_dump_txcmd *txcmd; |
---|
2997 | | - struct iwl_trans_dump_data *dump_data; |
---|
2998 | | - u32 len, num_rbs = 0; |
---|
2999 | | - u32 monitor_len; |
---|
3000 | | - int i, ptr; |
---|
3001 | | - bool dump_rbs = test_bit(STATUS_FW_ERROR, &trans->status) && |
---|
3002 | | - !trans->cfg->mq_rx_supported && |
---|
3003 | | - trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_RB); |
---|
| 3205 | + if (trans->dbg.fw_mon.size) { |
---|
| 3206 | + *len += sizeof(struct iwl_fw_error_dump_data) + |
---|
| 3207 | + sizeof(struct iwl_fw_error_dump_fw_mon) + |
---|
| 3208 | + trans->dbg.fw_mon.size; |
---|
| 3209 | + return trans->dbg.fw_mon.size; |
---|
| 3210 | + } else if (trans->dbg.dest_tlv) { |
---|
| 3211 | + u32 base, end, cfg_reg, monitor_len; |
---|
3004 | 3212 | |
---|
3005 | | - /* transport dump header */ |
---|
3006 | | - len = sizeof(*dump_data); |
---|
3007 | | - |
---|
3008 | | - /* host commands */ |
---|
3009 | | - len += sizeof(*data) + |
---|
3010 | | - cmdq->n_window * (sizeof(*txcmd) + TFD_MAX_PAYLOAD_SIZE); |
---|
3011 | | - |
---|
3012 | | - /* FW monitor */ |
---|
3013 | | - if (trans_pcie->fw_mon_page) { |
---|
3014 | | - len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) + |
---|
3015 | | - trans_pcie->fw_mon_size; |
---|
3016 | | - monitor_len = trans_pcie->fw_mon_size; |
---|
3017 | | - } else if (trans->dbg_dest_tlv) { |
---|
3018 | | - u32 base, end, cfg_reg; |
---|
3019 | | - |
---|
3020 | | - if (trans->dbg_dest_tlv->version == 1) { |
---|
3021 | | - cfg_reg = le32_to_cpu(trans->dbg_dest_tlv->base_reg); |
---|
| 3213 | + if (trans->dbg.dest_tlv->version == 1) { |
---|
| 3214 | + cfg_reg = le32_to_cpu(trans->dbg.dest_tlv->base_reg); |
---|
3022 | 3215 | cfg_reg = iwl_read_prph(trans, cfg_reg); |
---|
3023 | 3216 | base = (cfg_reg & IWL_LDBG_M2S_BUF_BA_MSK) << |
---|
3024 | | - trans->dbg_dest_tlv->base_shift; |
---|
| 3217 | + trans->dbg.dest_tlv->base_shift; |
---|
3025 | 3218 | base *= IWL_M2S_UNIT_SIZE; |
---|
3026 | 3219 | base += trans->cfg->smem_offset; |
---|
3027 | 3220 | |
---|
3028 | 3221 | monitor_len = |
---|
3029 | 3222 | (cfg_reg & IWL_LDBG_M2S_BUF_SIZE_MSK) >> |
---|
3030 | | - trans->dbg_dest_tlv->end_shift; |
---|
| 3223 | + trans->dbg.dest_tlv->end_shift; |
---|
3031 | 3224 | monitor_len *= IWL_M2S_UNIT_SIZE; |
---|
3032 | 3225 | } else { |
---|
3033 | | - base = le32_to_cpu(trans->dbg_dest_tlv->base_reg); |
---|
3034 | | - end = le32_to_cpu(trans->dbg_dest_tlv->end_reg); |
---|
| 3226 | + base = le32_to_cpu(trans->dbg.dest_tlv->base_reg); |
---|
| 3227 | + end = le32_to_cpu(trans->dbg.dest_tlv->end_reg); |
---|
3035 | 3228 | |
---|
3036 | 3229 | base = iwl_read_prph(trans, base) << |
---|
3037 | | - trans->dbg_dest_tlv->base_shift; |
---|
| 3230 | + trans->dbg.dest_tlv->base_shift; |
---|
3038 | 3231 | end = iwl_read_prph(trans, end) << |
---|
3039 | | - trans->dbg_dest_tlv->end_shift; |
---|
| 3232 | + trans->dbg.dest_tlv->end_shift; |
---|
3040 | 3233 | |
---|
3041 | 3234 | /* Make "end" point to the actual end */ |
---|
3042 | | - if (trans->cfg->device_family >= |
---|
| 3235 | + if (trans->trans_cfg->device_family >= |
---|
3043 | 3236 | IWL_DEVICE_FAMILY_8000 || |
---|
3044 | | - trans->dbg_dest_tlv->monitor_mode == MARBH_MODE) |
---|
3045 | | - end += (1 << trans->dbg_dest_tlv->end_shift); |
---|
| 3237 | + trans->dbg.dest_tlv->monitor_mode == MARBH_MODE) |
---|
| 3238 | + end += (1 << trans->dbg.dest_tlv->end_shift); |
---|
3046 | 3239 | monitor_len = end - base; |
---|
3047 | 3240 | } |
---|
3048 | | - len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) + |
---|
3049 | | - monitor_len; |
---|
3050 | | - } else { |
---|
3051 | | - monitor_len = 0; |
---|
| 3241 | + *len += sizeof(struct iwl_fw_error_dump_data) + |
---|
| 3242 | + sizeof(struct iwl_fw_error_dump_fw_mon) + |
---|
| 3243 | + monitor_len; |
---|
| 3244 | + return monitor_len; |
---|
3052 | 3245 | } |
---|
| 3246 | + return 0; |
---|
| 3247 | +} |
---|
3053 | 3248 | |
---|
3054 | | - if (trigger && (trigger->mode & IWL_FW_DBG_TRIGGER_MONITOR_ONLY)) { |
---|
3055 | | - if (!(trans->dbg_dump_mask & |
---|
3056 | | - BIT(IWL_FW_ERROR_DUMP_FW_MONITOR))) |
---|
3057 | | - return NULL; |
---|
| 3249 | +static struct iwl_trans_dump_data |
---|
| 3250 | +*iwl_trans_pcie_dump_data(struct iwl_trans *trans, |
---|
| 3251 | + u32 dump_mask) |
---|
| 3252 | +{ |
---|
| 3253 | + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 3254 | + struct iwl_fw_error_dump_data *data; |
---|
| 3255 | + struct iwl_txq *cmdq = trans->txqs.txq[trans->txqs.cmd.q_id]; |
---|
| 3256 | + struct iwl_fw_error_dump_txcmd *txcmd; |
---|
| 3257 | + struct iwl_trans_dump_data *dump_data; |
---|
| 3258 | + u32 len, num_rbs = 0, monitor_len = 0; |
---|
| 3259 | + int i, ptr; |
---|
| 3260 | + bool dump_rbs = test_bit(STATUS_FW_ERROR, &trans->status) && |
---|
| 3261 | + !trans->trans_cfg->mq_rx_supported && |
---|
| 3262 | + dump_mask & BIT(IWL_FW_ERROR_DUMP_RB); |
---|
3058 | 3263 | |
---|
3059 | | - dump_data = vzalloc(len); |
---|
3060 | | - if (!dump_data) |
---|
3061 | | - return NULL; |
---|
| 3264 | + if (!dump_mask) |
---|
| 3265 | + return NULL; |
---|
3062 | 3266 | |
---|
3063 | | - data = (void *)dump_data->data; |
---|
3064 | | - len = iwl_trans_pcie_dump_monitor(trans, &data, monitor_len); |
---|
3065 | | - dump_data->len = len; |
---|
| 3267 | + /* transport dump header */ |
---|
| 3268 | + len = sizeof(*dump_data); |
---|
3066 | 3269 | |
---|
3067 | | - return dump_data; |
---|
3068 | | - } |
---|
| 3270 | + /* host commands */ |
---|
| 3271 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_TXCMD) && cmdq) |
---|
| 3272 | + len += sizeof(*data) + |
---|
| 3273 | + cmdq->n_window * (sizeof(*txcmd) + |
---|
| 3274 | + TFD_MAX_PAYLOAD_SIZE); |
---|
| 3275 | + |
---|
| 3276 | + /* FW monitor */ |
---|
| 3277 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_FW_MONITOR)) |
---|
| 3278 | + monitor_len = iwl_trans_get_fw_monitor_len(trans, &len); |
---|
3069 | 3279 | |
---|
3070 | 3280 | /* CSR registers */ |
---|
3071 | | - if (trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_CSR)) |
---|
| 3281 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_CSR)) |
---|
3072 | 3282 | len += sizeof(*data) + IWL_CSR_TO_DUMP; |
---|
3073 | 3283 | |
---|
3074 | 3284 | /* FH registers */ |
---|
3075 | | - if (trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_FH_REGS)) { |
---|
3076 | | - if (trans->cfg->gen2) |
---|
| 3285 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_FH_REGS)) { |
---|
| 3286 | + if (trans->trans_cfg->gen2) |
---|
3077 | 3287 | len += sizeof(*data) + |
---|
3078 | | - (FH_MEM_UPPER_BOUND_GEN2 - |
---|
3079 | | - FH_MEM_LOWER_BOUND_GEN2); |
---|
| 3288 | + (iwl_umac_prph(trans, FH_MEM_UPPER_BOUND_GEN2) - |
---|
| 3289 | + iwl_umac_prph(trans, FH_MEM_LOWER_BOUND_GEN2)); |
---|
3080 | 3290 | else |
---|
3081 | 3291 | len += sizeof(*data) + |
---|
3082 | 3292 | (FH_MEM_UPPER_BOUND - |
---|
.. | .. |
---|
3097 | 3307 | } |
---|
3098 | 3308 | |
---|
3099 | 3309 | /* Paged memory for gen2 HW */ |
---|
3100 | | - if (trans->cfg->gen2 && |
---|
3101 | | - trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_PAGING)) |
---|
3102 | | - for (i = 0; i < trans_pcie->init_dram.paging_cnt; i++) |
---|
| 3310 | + if (trans->trans_cfg->gen2 && dump_mask & BIT(IWL_FW_ERROR_DUMP_PAGING)) |
---|
| 3311 | + for (i = 0; i < trans->init_dram.paging_cnt; i++) |
---|
3103 | 3312 | len += sizeof(*data) + |
---|
3104 | 3313 | sizeof(struct iwl_fw_error_dump_paging) + |
---|
3105 | | - trans_pcie->init_dram.paging[i].size; |
---|
| 3314 | + trans->init_dram.paging[i].size; |
---|
3106 | 3315 | |
---|
3107 | 3316 | dump_data = vzalloc(len); |
---|
3108 | 3317 | if (!dump_data) |
---|
.. | .. |
---|
3111 | 3320 | len = 0; |
---|
3112 | 3321 | data = (void *)dump_data->data; |
---|
3113 | 3322 | |
---|
3114 | | - if (trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_TXCMD)) { |
---|
3115 | | - u16 tfd_size = trans_pcie->tfd_size; |
---|
| 3323 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_TXCMD) && cmdq) { |
---|
| 3324 | + u16 tfd_size = trans->txqs.tfd.size; |
---|
3116 | 3325 | |
---|
3117 | 3326 | data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXCMD); |
---|
3118 | 3327 | txcmd = (void *)data->data; |
---|
3119 | 3328 | spin_lock_bh(&cmdq->lock); |
---|
3120 | 3329 | ptr = cmdq->write_ptr; |
---|
3121 | 3330 | for (i = 0; i < cmdq->n_window; i++) { |
---|
3122 | | - u8 idx = iwl_pcie_get_cmd_index(cmdq, ptr); |
---|
| 3331 | + u8 idx = iwl_txq_get_cmd_index(cmdq, ptr); |
---|
| 3332 | + u8 tfdidx; |
---|
3123 | 3333 | u32 caplen, cmdlen; |
---|
3124 | 3334 | |
---|
| 3335 | + if (trans->trans_cfg->use_tfh) |
---|
| 3336 | + tfdidx = idx; |
---|
| 3337 | + else |
---|
| 3338 | + tfdidx = ptr; |
---|
| 3339 | + |
---|
3125 | 3340 | cmdlen = iwl_trans_pcie_get_cmdlen(trans, |
---|
3126 | | - cmdq->tfds + |
---|
3127 | | - tfd_size * ptr); |
---|
| 3341 | + (u8 *)cmdq->tfds + |
---|
| 3342 | + tfd_size * tfdidx); |
---|
3128 | 3343 | caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen); |
---|
3129 | 3344 | |
---|
3130 | 3345 | if (cmdlen) { |
---|
.. | .. |
---|
3136 | 3351 | txcmd = (void *)((u8 *)txcmd->data + caplen); |
---|
3137 | 3352 | } |
---|
3138 | 3353 | |
---|
3139 | | - ptr = iwl_queue_dec_wrap(trans, ptr); |
---|
| 3354 | + ptr = iwl_txq_dec_wrap(trans, ptr); |
---|
3140 | 3355 | } |
---|
3141 | 3356 | spin_unlock_bh(&cmdq->lock); |
---|
3142 | 3357 | |
---|
.. | .. |
---|
3145 | 3360 | data = iwl_fw_error_next_data(data); |
---|
3146 | 3361 | } |
---|
3147 | 3362 | |
---|
3148 | | - if (trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_CSR)) |
---|
| 3363 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_CSR)) |
---|
3149 | 3364 | len += iwl_trans_pcie_dump_csr(trans, &data); |
---|
3150 | | - if (trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_FH_REGS)) |
---|
| 3365 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_FH_REGS)) |
---|
3151 | 3366 | len += iwl_trans_pcie_fh_regs_dump(trans, &data); |
---|
3152 | 3367 | if (dump_rbs) |
---|
3153 | 3368 | len += iwl_trans_pcie_dump_rbs(trans, &data, num_rbs); |
---|
3154 | 3369 | |
---|
3155 | 3370 | /* Paged memory for gen2 HW */ |
---|
3156 | | - if (trans->cfg->gen2 && |
---|
3157 | | - trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_PAGING)) { |
---|
3158 | | - for (i = 0; i < trans_pcie->init_dram.paging_cnt; i++) { |
---|
| 3371 | + if (trans->trans_cfg->gen2 && |
---|
| 3372 | + dump_mask & BIT(IWL_FW_ERROR_DUMP_PAGING)) { |
---|
| 3373 | + for (i = 0; i < trans->init_dram.paging_cnt; i++) { |
---|
3159 | 3374 | struct iwl_fw_error_dump_paging *paging; |
---|
3160 | | - dma_addr_t addr = |
---|
3161 | | - trans_pcie->init_dram.paging[i].physical; |
---|
3162 | | - u32 page_len = trans_pcie->init_dram.paging[i].size; |
---|
| 3375 | + u32 page_len = trans->init_dram.paging[i].size; |
---|
3163 | 3376 | |
---|
3164 | 3377 | data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PAGING); |
---|
3165 | 3378 | data->len = cpu_to_le32(sizeof(*paging) + page_len); |
---|
3166 | 3379 | paging = (void *)data->data; |
---|
3167 | 3380 | paging->index = cpu_to_le32(i); |
---|
3168 | | - dma_sync_single_for_cpu(trans->dev, addr, page_len, |
---|
3169 | | - DMA_BIDIRECTIONAL); |
---|
3170 | 3381 | memcpy(paging->data, |
---|
3171 | | - trans_pcie->init_dram.paging[i].block, page_len); |
---|
| 3382 | + trans->init_dram.paging[i].block, page_len); |
---|
3172 | 3383 | data = iwl_fw_error_next_data(data); |
---|
3173 | 3384 | |
---|
3174 | 3385 | len += sizeof(*data) + sizeof(*paging) + page_len; |
---|
3175 | 3386 | } |
---|
3176 | 3387 | } |
---|
3177 | | - if (trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_FW_MONITOR)) |
---|
| 3388 | + if (dump_mask & BIT(IWL_FW_ERROR_DUMP_FW_MONITOR)) |
---|
3178 | 3389 | len += iwl_trans_pcie_dump_monitor(trans, &data, monitor_len); |
---|
3179 | 3390 | |
---|
3180 | 3391 | dump_data->len = len; |
---|
.. | .. |
---|
3185 | 3396 | #ifdef CONFIG_PM_SLEEP |
---|
3186 | 3397 | static int iwl_trans_pcie_suspend(struct iwl_trans *trans) |
---|
3187 | 3398 | { |
---|
3188 | | - if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3 && |
---|
3189 | | - (trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3)) |
---|
3190 | | - return iwl_pci_fw_enter_d0i3(trans); |
---|
3191 | | - |
---|
3192 | 3399 | return 0; |
---|
3193 | 3400 | } |
---|
3194 | 3401 | |
---|
3195 | 3402 | static void iwl_trans_pcie_resume(struct iwl_trans *trans) |
---|
3196 | 3403 | { |
---|
3197 | | - if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3 && |
---|
3198 | | - (trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3)) |
---|
3199 | | - iwl_pci_fw_exit_d0i3(trans); |
---|
3200 | 3404 | } |
---|
3201 | 3405 | #endif /* CONFIG_PM_SLEEP */ |
---|
3202 | 3406 | |
---|
.. | .. |
---|
3209 | 3413 | .write_prph = iwl_trans_pcie_write_prph, \ |
---|
3210 | 3414 | .read_mem = iwl_trans_pcie_read_mem, \ |
---|
3211 | 3415 | .write_mem = iwl_trans_pcie_write_mem, \ |
---|
| 3416 | + .read_config32 = iwl_trans_pcie_read_config32, \ |
---|
3212 | 3417 | .configure = iwl_trans_pcie_configure, \ |
---|
3213 | 3418 | .set_pmi = iwl_trans_pcie_set_pmi, \ |
---|
3214 | 3419 | .sw_reset = iwl_trans_pcie_sw_reset, \ |
---|
3215 | 3420 | .grab_nic_access = iwl_trans_pcie_grab_nic_access, \ |
---|
3216 | 3421 | .release_nic_access = iwl_trans_pcie_release_nic_access, \ |
---|
3217 | 3422 | .set_bits_mask = iwl_trans_pcie_set_bits_mask, \ |
---|
3218 | | - .ref = iwl_trans_pcie_ref, \ |
---|
3219 | | - .unref = iwl_trans_pcie_unref, \ |
---|
3220 | 3423 | .dump_data = iwl_trans_pcie_dump_data, \ |
---|
3221 | | - .dump_regs = iwl_trans_pcie_dump_regs, \ |
---|
3222 | 3424 | .d3_suspend = iwl_trans_pcie_d3_suspend, \ |
---|
3223 | | - .d3_resume = iwl_trans_pcie_d3_resume |
---|
| 3425 | + .d3_resume = iwl_trans_pcie_d3_resume, \ |
---|
| 3426 | + .sync_nmi = iwl_trans_pcie_sync_nmi |
---|
3224 | 3427 | |
---|
3225 | 3428 | #ifdef CONFIG_PM_SLEEP |
---|
3226 | 3429 | #define IWL_TRANS_PM_OPS \ |
---|
.. | .. |
---|
3252 | 3455 | |
---|
3253 | 3456 | .freeze_txq_timer = iwl_trans_pcie_freeze_txq_timer, |
---|
3254 | 3457 | .block_txq_ptrs = iwl_trans_pcie_block_txq_ptrs, |
---|
| 3458 | +#ifdef CONFIG_IWLWIFI_DEBUGFS |
---|
| 3459 | + .debugfs_cleanup = iwl_trans_pcie_debugfs_cleanup, |
---|
| 3460 | +#endif |
---|
3255 | 3461 | }; |
---|
3256 | 3462 | |
---|
3257 | 3463 | static const struct iwl_trans_ops trans_ops_pcie_gen2 = { |
---|
.. | .. |
---|
3264 | 3470 | |
---|
3265 | 3471 | .send_cmd = iwl_trans_pcie_gen2_send_hcmd, |
---|
3266 | 3472 | |
---|
3267 | | - .tx = iwl_trans_pcie_gen2_tx, |
---|
| 3473 | + .tx = iwl_txq_gen2_tx, |
---|
3268 | 3474 | .reclaim = iwl_trans_pcie_reclaim, |
---|
3269 | 3475 | |
---|
3270 | | - .txq_alloc = iwl_trans_pcie_dyn_txq_alloc, |
---|
3271 | | - .txq_free = iwl_trans_pcie_dyn_txq_free, |
---|
| 3476 | + .set_q_ptrs = iwl_trans_pcie_set_q_ptrs, |
---|
| 3477 | + |
---|
| 3478 | + .txq_alloc = iwl_txq_dyn_alloc, |
---|
| 3479 | + .txq_free = iwl_txq_dyn_free, |
---|
3272 | 3480 | .wait_txq_empty = iwl_trans_pcie_wait_txq_empty, |
---|
3273 | 3481 | .rxq_dma_data = iwl_trans_pcie_rxq_dma_data, |
---|
| 3482 | + .set_pnvm = iwl_trans_pcie_ctx_info_gen3_set_pnvm, |
---|
| 3483 | +#ifdef CONFIG_IWLWIFI_DEBUGFS |
---|
| 3484 | + .debugfs_cleanup = iwl_trans_pcie_debugfs_cleanup, |
---|
| 3485 | +#endif |
---|
3274 | 3486 | }; |
---|
3275 | 3487 | |
---|
3276 | 3488 | struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, |
---|
3277 | | - const struct pci_device_id *ent, |
---|
3278 | | - const struct iwl_cfg *cfg) |
---|
| 3489 | + const struct pci_device_id *ent, |
---|
| 3490 | + const struct iwl_cfg_trans_params *cfg_trans) |
---|
3279 | 3491 | { |
---|
3280 | 3492 | struct iwl_trans_pcie *trans_pcie; |
---|
3281 | 3493 | struct iwl_trans *trans; |
---|
3282 | 3494 | int ret, addr_size; |
---|
| 3495 | + const struct iwl_trans_ops *ops = &trans_ops_pcie_gen2; |
---|
| 3496 | + |
---|
| 3497 | + if (!cfg_trans->gen2) |
---|
| 3498 | + ops = &trans_ops_pcie; |
---|
3283 | 3499 | |
---|
3284 | 3500 | ret = pcim_enable_device(pdev); |
---|
3285 | 3501 | if (ret) |
---|
3286 | 3502 | return ERR_PTR(ret); |
---|
3287 | 3503 | |
---|
3288 | | - if (cfg->gen2) |
---|
3289 | | - trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), |
---|
3290 | | - &pdev->dev, cfg, &trans_ops_pcie_gen2); |
---|
3291 | | - else |
---|
3292 | | - trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), |
---|
3293 | | - &pdev->dev, cfg, &trans_ops_pcie); |
---|
| 3504 | + trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, ops, |
---|
| 3505 | + cfg_trans); |
---|
3294 | 3506 | if (!trans) |
---|
3295 | 3507 | return ERR_PTR(-ENOMEM); |
---|
3296 | 3508 | |
---|
.. | .. |
---|
3300 | 3512 | trans_pcie->opmode_down = true; |
---|
3301 | 3513 | spin_lock_init(&trans_pcie->irq_lock); |
---|
3302 | 3514 | spin_lock_init(&trans_pcie->reg_lock); |
---|
| 3515 | + spin_lock_init(&trans_pcie->alloc_page_lock); |
---|
3303 | 3516 | mutex_init(&trans_pcie->mutex); |
---|
3304 | 3517 | init_waitqueue_head(&trans_pcie->ucode_write_waitq); |
---|
3305 | 3518 | |
---|
.. | .. |
---|
3311 | 3524 | } |
---|
3312 | 3525 | INIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work); |
---|
3313 | 3526 | |
---|
3314 | | - trans_pcie->tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page); |
---|
3315 | | - if (!trans_pcie->tso_hdr_page) { |
---|
3316 | | - ret = -ENOMEM; |
---|
3317 | | - goto out_no_pci; |
---|
3318 | | - } |
---|
| 3527 | + trans_pcie->debug_rfkill = -1; |
---|
3319 | 3528 | |
---|
3320 | | - |
---|
3321 | | - if (!cfg->base_params->pcie_l1_allowed) { |
---|
| 3529 | + if (!cfg_trans->base_params->pcie_l1_allowed) { |
---|
3322 | 3530 | /* |
---|
3323 | 3531 | * W/A - seems to solve weird behavior. We need to remove this |
---|
3324 | 3532 | * if we don't want to stay in L1 all the time. This wastes a |
---|
.. | .. |
---|
3329 | 3537 | PCIE_LINK_STATE_CLKPM); |
---|
3330 | 3538 | } |
---|
3331 | 3539 | |
---|
3332 | | - if (cfg->use_tfh) { |
---|
3333 | | - addr_size = 64; |
---|
3334 | | - trans_pcie->max_tbs = IWL_TFH_NUM_TBS; |
---|
3335 | | - trans_pcie->tfd_size = sizeof(struct iwl_tfh_tfd); |
---|
3336 | | - } else { |
---|
3337 | | - addr_size = 36; |
---|
3338 | | - trans_pcie->max_tbs = IWL_NUM_OF_TBS; |
---|
3339 | | - trans_pcie->tfd_size = sizeof(struct iwl_tfd); |
---|
3340 | | - } |
---|
3341 | | - trans->max_skb_frags = IWL_PCIE_MAX_FRAGS(trans_pcie); |
---|
| 3540 | + trans_pcie->def_rx_queue = 0; |
---|
3342 | 3541 | |
---|
3343 | 3542 | pci_set_master(pdev); |
---|
3344 | 3543 | |
---|
| 3544 | + addr_size = trans->txqs.tfd.addr_size; |
---|
3345 | 3545 | ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(addr_size)); |
---|
3346 | 3546 | if (!ret) |
---|
3347 | 3547 | ret = pci_set_consistent_dma_mask(pdev, |
---|
.. | .. |
---|
3379 | 3579 | iwl_disable_interrupts(trans); |
---|
3380 | 3580 | |
---|
3381 | 3581 | trans->hw_rev = iwl_read32(trans, CSR_HW_REV); |
---|
| 3582 | + if (trans->hw_rev == 0xffffffff) { |
---|
| 3583 | + dev_err(&pdev->dev, "HW_REV=0xFFFFFFFF, PCI issues?\n"); |
---|
| 3584 | + ret = -EIO; |
---|
| 3585 | + goto out_no_pci; |
---|
| 3586 | + } |
---|
| 3587 | + |
---|
3382 | 3588 | /* |
---|
3383 | 3589 | * In the 8000 HW family the format of the 4 bytes of CSR_HW_REV have |
---|
3384 | 3590 | * changed, and now the revision step also includes bit 0-1 (no more |
---|
3385 | 3591 | * "dash" value). To keep hw_rev backwards compatible - we'll store it |
---|
3386 | 3592 | * in the old format. |
---|
3387 | 3593 | */ |
---|
3388 | | - if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) { |
---|
3389 | | - unsigned long flags; |
---|
3390 | | - |
---|
| 3594 | + if (cfg_trans->device_family >= IWL_DEVICE_FAMILY_8000) { |
---|
3391 | 3595 | trans->hw_rev = (trans->hw_rev & 0xfff0) | |
---|
3392 | 3596 | (CSR_HW_REV_STEP(trans->hw_rev << 2) << 2); |
---|
3393 | 3597 | |
---|
.. | .. |
---|
3401 | 3605 | * in-order to recognize C step driver should read chip version |
---|
3402 | 3606 | * id located at the AUX bus MISC address space. |
---|
3403 | 3607 | */ |
---|
3404 | | - iwl_set_bit(trans, CSR_GP_CNTRL, |
---|
3405 | | - BIT(trans->cfg->csr->flag_init_done)); |
---|
3406 | | - udelay(2); |
---|
3407 | | - |
---|
3408 | | - ret = iwl_poll_bit(trans, CSR_GP_CNTRL, |
---|
3409 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
3410 | | - BIT(trans->cfg->csr->flag_mac_clock_ready), |
---|
3411 | | - 25000); |
---|
3412 | | - if (ret < 0) { |
---|
3413 | | - IWL_DEBUG_INFO(trans, "Failed to wake up the nic\n"); |
---|
| 3608 | + ret = iwl_finish_nic_init(trans, cfg_trans); |
---|
| 3609 | + if (ret) |
---|
3414 | 3610 | goto out_no_pci; |
---|
3415 | | - } |
---|
3416 | 3611 | |
---|
3417 | | - if (iwl_trans_grab_nic_access(trans, &flags)) { |
---|
3418 | | - u32 hw_step; |
---|
3419 | | - |
---|
3420 | | - hw_step = iwl_read_prph_no_grab(trans, WFPM_CTRL_REG); |
---|
3421 | | - hw_step |= ENABLE_WFPM; |
---|
3422 | | - iwl_write_prph_no_grab(trans, WFPM_CTRL_REG, hw_step); |
---|
3423 | | - hw_step = iwl_read_prph_no_grab(trans, AUX_MISC_REG); |
---|
3424 | | - hw_step = (hw_step >> HW_STEP_LOCATION_BITS) & 0xF; |
---|
3425 | | - if (hw_step == 0x3) |
---|
3426 | | - trans->hw_rev = (trans->hw_rev & 0xFFFFFFF3) | |
---|
3427 | | - (SILICON_C_STEP << 2); |
---|
3428 | | - iwl_trans_release_nic_access(trans, &flags); |
---|
3429 | | - } |
---|
3430 | 3612 | } |
---|
3431 | 3613 | |
---|
3432 | | - /* |
---|
3433 | | - * 9000-series integrated A-step has a problem with suspend/resume |
---|
3434 | | - * and sometimes even causes the whole platform to get stuck. This |
---|
3435 | | - * workaround makes the hardware not go into the problematic state. |
---|
3436 | | - */ |
---|
3437 | | - if (trans->cfg->integrated && |
---|
3438 | | - trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 && |
---|
3439 | | - CSR_HW_REV_STEP(trans->hw_rev) == SILICON_A_STEP) |
---|
3440 | | - iwl_set_bit(trans, CSR_HOST_CHICKEN, |
---|
3441 | | - CSR_HOST_CHICKEN_PM_IDLE_SRC_DIS_SB_PME); |
---|
| 3614 | + IWL_DEBUG_INFO(trans, "HW REV: 0x%0x\n", trans->hw_rev); |
---|
3442 | 3615 | |
---|
3443 | | -#if IS_ENABLED(CONFIG_IWLMVM) |
---|
3444 | | - trans->hw_rf_id = iwl_read32(trans, CSR_HW_RF_ID); |
---|
3445 | | - |
---|
3446 | | - if (cfg == &iwl22000_2ax_cfg_hr) { |
---|
3447 | | - if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == |
---|
3448 | | - CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) { |
---|
3449 | | - trans->cfg = &iwl22000_2ax_cfg_hr; |
---|
3450 | | - } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == |
---|
3451 | | - CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_JF)) { |
---|
3452 | | - trans->cfg = &iwl22000_2ax_cfg_jf; |
---|
3453 | | - } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == |
---|
3454 | | - CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HRCDB)) { |
---|
3455 | | - IWL_ERR(trans, "RF ID HRCDB is not supported\n"); |
---|
3456 | | - ret = -EINVAL; |
---|
3457 | | - goto out_no_pci; |
---|
3458 | | - } else { |
---|
3459 | | - IWL_ERR(trans, "Unrecognized RF ID 0x%08x\n", |
---|
3460 | | - CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id)); |
---|
3461 | | - ret = -EINVAL; |
---|
3462 | | - goto out_no_pci; |
---|
3463 | | - } |
---|
3464 | | - } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == |
---|
3465 | | - CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) { |
---|
3466 | | - u32 hw_status; |
---|
3467 | | - |
---|
3468 | | - hw_status = iwl_read_prph(trans, UMAG_GEN_HW_STATUS); |
---|
3469 | | - if (CSR_HW_RF_STEP(trans->hw_rf_id) == SILICON_B_STEP) |
---|
3470 | | - /* |
---|
3471 | | - * b step fw is the same for physical card and fpga |
---|
3472 | | - */ |
---|
3473 | | - trans->cfg = &iwl22000_2ax_cfg_qnj_hr_b0; |
---|
3474 | | - else if ((hw_status & UMAG_GEN_HW_IS_FPGA) && |
---|
3475 | | - CSR_HW_RF_STEP(trans->hw_rf_id) == SILICON_A_STEP) { |
---|
3476 | | - trans->cfg = &iwl22000_2ax_cfg_qnj_hr_a0_f0; |
---|
3477 | | - } else { |
---|
3478 | | - /* |
---|
3479 | | - * a step no FPGA |
---|
3480 | | - */ |
---|
3481 | | - trans->cfg = &iwl22000_2ac_cfg_hr; |
---|
3482 | | - } |
---|
3483 | | - } |
---|
3484 | | -#endif |
---|
3485 | | - |
---|
3486 | | - iwl_pcie_set_interrupt_capa(pdev, trans); |
---|
| 3616 | + iwl_pcie_set_interrupt_capa(pdev, trans, cfg_trans); |
---|
3487 | 3617 | trans->hw_id = (pdev->device << 16) + pdev->subsystem_device; |
---|
3488 | 3618 | snprintf(trans->hw_id_str, sizeof(trans->hw_id_str), |
---|
3489 | 3619 | "PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device); |
---|
.. | .. |
---|
3491 | 3621 | /* Initialize the wait queue for commands */ |
---|
3492 | 3622 | init_waitqueue_head(&trans_pcie->wait_command_queue); |
---|
3493 | 3623 | |
---|
3494 | | - init_waitqueue_head(&trans_pcie->d0i3_waitq); |
---|
| 3624 | + init_waitqueue_head(&trans_pcie->sx_waitq); |
---|
| 3625 | + |
---|
3495 | 3626 | |
---|
3496 | 3627 | if (trans_pcie->msix_enabled) { |
---|
3497 | 3628 | ret = iwl_pcie_init_msix_handler(pdev, trans_pcie); |
---|
.. | .. |
---|
3513 | 3644 | trans_pcie->inta_mask = CSR_INI_SET_MASK; |
---|
3514 | 3645 | } |
---|
3515 | 3646 | |
---|
3516 | | -#ifdef CONFIG_IWLWIFI_PCIE_RTPM |
---|
3517 | | - trans->runtime_pm_mode = IWL_PLAT_PM_MODE_D0I3; |
---|
3518 | | -#else |
---|
3519 | | - trans->runtime_pm_mode = IWL_PLAT_PM_MODE_DISABLED; |
---|
3520 | | -#endif /* CONFIG_IWLWIFI_PCIE_RTPM */ |
---|
| 3647 | +#ifdef CONFIG_IWLWIFI_DEBUGFS |
---|
| 3648 | + trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED; |
---|
| 3649 | + mutex_init(&trans_pcie->fw_mon_data.mutex); |
---|
| 3650 | +#endif |
---|
| 3651 | + |
---|
| 3652 | + iwl_dbg_tlv_init(trans); |
---|
3521 | 3653 | |
---|
3522 | 3654 | return trans; |
---|
3523 | 3655 | |
---|
3524 | 3656 | out_free_ict: |
---|
3525 | 3657 | iwl_pcie_free_ict(trans); |
---|
3526 | 3658 | out_no_pci: |
---|
3527 | | - free_percpu(trans_pcie->tso_hdr_page); |
---|
3528 | 3659 | destroy_workqueue(trans_pcie->rba.alloc_wq); |
---|
3529 | 3660 | out_free_trans: |
---|
3530 | 3661 | iwl_trans_free(trans); |
---|
3531 | 3662 | return ERR_PTR(ret); |
---|
3532 | 3663 | } |
---|
| 3664 | + |
---|
| 3665 | +void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans) |
---|
| 3666 | +{ |
---|
| 3667 | + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
---|
| 3668 | + unsigned long timeout = jiffies + IWL_TRANS_NMI_TIMEOUT; |
---|
| 3669 | + bool interrupts_enabled = test_bit(STATUS_INT_ENABLED, &trans->status); |
---|
| 3670 | + u32 inta_addr, sw_err_bit; |
---|
| 3671 | + |
---|
| 3672 | + if (trans_pcie->msix_enabled) { |
---|
| 3673 | + inta_addr = CSR_MSIX_HW_INT_CAUSES_AD; |
---|
| 3674 | + sw_err_bit = MSIX_HW_INT_CAUSES_REG_SW_ERR; |
---|
| 3675 | + } else { |
---|
| 3676 | + inta_addr = CSR_INT; |
---|
| 3677 | + sw_err_bit = CSR_INT_BIT_SW_ERR; |
---|
| 3678 | + } |
---|
| 3679 | + |
---|
| 3680 | + /* if the interrupts were already disabled, there is no point in |
---|
| 3681 | + * calling iwl_disable_interrupts |
---|
| 3682 | + */ |
---|
| 3683 | + if (interrupts_enabled) |
---|
| 3684 | + iwl_disable_interrupts(trans); |
---|
| 3685 | + |
---|
| 3686 | + iwl_force_nmi(trans); |
---|
| 3687 | + while (time_after(timeout, jiffies)) { |
---|
| 3688 | + u32 inta_hw = iwl_read32(trans, inta_addr); |
---|
| 3689 | + |
---|
| 3690 | + /* Error detected by uCode */ |
---|
| 3691 | + if (inta_hw & sw_err_bit) { |
---|
| 3692 | + /* Clear causes register */ |
---|
| 3693 | + iwl_write32(trans, inta_addr, inta_hw & sw_err_bit); |
---|
| 3694 | + break; |
---|
| 3695 | + } |
---|
| 3696 | + |
---|
| 3697 | + mdelay(1); |
---|
| 3698 | + } |
---|
| 3699 | + |
---|
| 3700 | + /* enable interrupts only if there were already enabled before this |
---|
| 3701 | + * function to avoid a case were the driver enable interrupts before |
---|
| 3702 | + * proper configurations were made |
---|
| 3703 | + */ |
---|
| 3704 | + if (interrupts_enabled) |
---|
| 3705 | + iwl_enable_interrupts(trans); |
---|
| 3706 | + |
---|
| 3707 | + iwl_trans_fw_error(trans); |
---|
| 3708 | +} |
---|