rx.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
  4. *
  5. * Portions of this file are derived from the ipw3945 project, as well
  6. * as portions of the ieee80211 subsystem header files.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of version 2 of the GNU General Public License as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  20. *
  21. * The full GNU General Public License is included in this distribution in the
  22. * file called LICENSE.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. *****************************************************************************/
  29. #include <linux/sched.h>
  30. #include <linux/wait.h>
  31. #include <linux/gfp.h>
  32. #include "iwl-prph.h"
  33. #include "iwl-io.h"
  34. #include "internal.h"
  35. #include "iwl-op-mode.h"
  36. /******************************************************************************
  37. *
  38. * RX path functions
  39. *
  40. ******************************************************************************/
  41. /*
  42. * Rx theory of operation
  43. *
  44. * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs),
  45. * each of which point to Receive Buffers to be filled by the NIC. These get
  46. * used not only for Rx frames, but for any command response or notification
  47. * from the NIC. The driver and NIC manage the Rx buffers by means
  48. * of indexes into the circular buffer.
  49. *
  50. * Rx Queue Indexes
  51. * The host/firmware share two index registers for managing the Rx buffers.
  52. *
  53. * The READ index maps to the first position that the firmware may be writing
  54. * to -- the driver can read up to (but not including) this position and get
  55. * good data.
  56. * The READ index is managed by the firmware once the card is enabled.
  57. *
  58. * The WRITE index maps to the last position the driver has read from -- the
  59. * position preceding WRITE is the last slot the firmware can place a packet.
  60. *
  61. * The queue is empty (no good data) if WRITE = READ - 1, and is full if
  62. * WRITE = READ.
  63. *
  64. * During initialization, the host sets up the READ queue position to the first
  65. * INDEX position, and WRITE to the last (READ - 1 wrapped)
  66. *
  67. * When the firmware places a packet in a buffer, it will advance the READ index
  68. * and fire the RX interrupt. The driver can then query the READ index and
  69. * process as many packets as possible, moving the WRITE index forward as it
  70. * resets the Rx queue buffers with new memory.
  71. *
  72. * The management in the driver is as follows:
  73. * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When
  74. * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
  75. * to replenish the iwl->rxq->rx_free.
  76. * + In iwl_rx_replenish (scheduled) if 'processed' != 'read' then the
  77. * iwl->rxq is replenished and the READ INDEX is updated (updating the
  78. * 'processed' and 'read' driver indexes as well)
  79. * + A received packet is processed and handed to the kernel network stack,
  80. * detached from the iwl->rxq. The driver 'processed' index is updated.
  81. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free
  82. * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ
  83. * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there
  84. * were enough free buffers and RX_STALLED is set it is cleared.
  85. *
  86. *
  87. * Driver sequence:
  88. *
  89. * iwl_rx_queue_alloc() Allocates rx_free
  90. * iwl_rx_replenish() Replenishes rx_free list from rx_used, and calls
  91. * iwl_rx_queue_restock
  92. * iwl_rx_queue_restock() Moves available buffers from rx_free into Rx
  93. * queue, updates firmware pointers, and updates
  94. * the WRITE index. If insufficient rx_free buffers
  95. * are available, schedules iwl_rx_replenish
  96. *
  97. * -- enable interrupts --
  98. * ISR - iwl_rx() Detach iwl_rx_mem_buffers from pool up to the
  99. * READ INDEX, detaching the SKB from the pool.
  100. * Moves the packet buffer from queue to rx_used.
  101. * Calls iwl_rx_queue_restock to refill any empty
  102. * slots.
  103. * ...
  104. *
  105. */
  106. /**
  107. * iwl_rx_queue_space - Return number of free slots available in queue.
  108. */
  109. static int iwl_rx_queue_space(const struct iwl_rx_queue *q)
  110. {
  111. int s = q->read - q->write;
  112. if (s <= 0)
  113. s += RX_QUEUE_SIZE;
  114. /* keep some buffer to not confuse full and empty queue */
  115. s -= 2;
  116. if (s < 0)
  117. s = 0;
  118. return s;
  119. }
  120. /**
  121. * iwl_rx_queue_update_write_ptr - Update the write pointer for the RX queue
  122. */
  123. void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans,
  124. struct iwl_rx_queue *q)
  125. {
  126. unsigned long flags;
  127. u32 reg;
  128. spin_lock_irqsave(&q->lock, flags);
  129. if (q->need_update == 0)
  130. goto exit_unlock;
  131. if (trans->cfg->base_params->shadow_reg_enable) {
  132. /* shadow register enabled */
  133. /* Device expects a multiple of 8 */
  134. q->write_actual = (q->write & ~0x7);
  135. iwl_write32(trans, FH_RSCSR_CHNL0_WPTR, q->write_actual);
  136. } else {
  137. struct iwl_trans_pcie *trans_pcie =
  138. IWL_TRANS_GET_PCIE_TRANS(trans);
  139. /* If power-saving is in use, make sure device is awake */
  140. if (test_bit(STATUS_TPOWER_PMI, &trans_pcie->status)) {
  141. reg = iwl_read32(trans, CSR_UCODE_DRV_GP1);
  142. if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
  143. IWL_DEBUG_INFO(trans,
  144. "Rx queue requesting wakeup,"
  145. " GP1 = 0x%x\n", reg);
  146. iwl_set_bit(trans, CSR_GP_CNTRL,
  147. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  148. goto exit_unlock;
  149. }
  150. q->write_actual = (q->write & ~0x7);
  151. iwl_write_direct32(trans, FH_RSCSR_CHNL0_WPTR,
  152. q->write_actual);
  153. /* Else device is assumed to be awake */
  154. } else {
  155. /* Device expects a multiple of 8 */
  156. q->write_actual = (q->write & ~0x7);
  157. iwl_write_direct32(trans, FH_RSCSR_CHNL0_WPTR,
  158. q->write_actual);
  159. }
  160. }
  161. q->need_update = 0;
  162. exit_unlock:
  163. spin_unlock_irqrestore(&q->lock, flags);
  164. }
  165. /**
  166. * iwl_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
  167. */
  168. static inline __le32 iwl_dma_addr2rbd_ptr(dma_addr_t dma_addr)
  169. {
  170. return cpu_to_le32((u32)(dma_addr >> 8));
  171. }
  172. /**
  173. * iwl_rx_queue_restock - refill RX queue from pre-allocated pool
  174. *
  175. * If there are slots in the RX queue that need to be restocked,
  176. * and we have free pre-allocated buffers, fill the ranks as much
  177. * as we can, pulling from rx_free.
  178. *
  179. * This moves the 'write' index forward to catch up with 'processed', and
  180. * also updates the memory address in the firmware to reference the new
  181. * target buffer.
  182. */
  183. static void iwl_rx_queue_restock(struct iwl_trans *trans)
  184. {
  185. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  186. struct iwl_rx_queue *rxq = &trans_pcie->rxq;
  187. struct iwl_rx_mem_buffer *rxb;
  188. unsigned long flags;
  189. /*
  190. * If the device isn't enabled - not need to try to add buffers...
  191. * This can happen when we stop the device and still have an interrupt
  192. * pending. We stop the APM before we sync the interrupts / tasklets
  193. * because we have to (see comment there). On the other hand, since
  194. * the APM is stopped, we cannot access the HW (in particular not prph).
  195. * So don't try to restock if the APM has been already stopped.
  196. */
  197. if (!test_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status))
  198. return;
  199. spin_lock_irqsave(&rxq->lock, flags);
  200. while ((iwl_rx_queue_space(rxq) > 0) && (rxq->free_count)) {
  201. /* The overwritten rxb must be a used one */
  202. rxb = rxq->queue[rxq->write];
  203. BUG_ON(rxb && rxb->page);
  204. /* Get next free Rx buffer, remove from free list */
  205. rxb = list_first_entry(&rxq->rx_free, struct iwl_rx_mem_buffer,
  206. list);
  207. list_del(&rxb->list);
  208. /* Point to Rx buffer via next RBD in circular buffer */
  209. rxq->bd[rxq->write] = iwl_dma_addr2rbd_ptr(rxb->page_dma);
  210. rxq->queue[rxq->write] = rxb;
  211. rxq->write = (rxq->write + 1) & RX_QUEUE_MASK;
  212. rxq->free_count--;
  213. }
  214. spin_unlock_irqrestore(&rxq->lock, flags);
  215. /* If the pre-allocated buffer pool is dropping low, schedule to
  216. * refill it */
  217. if (rxq->free_count <= RX_LOW_WATERMARK)
  218. schedule_work(&trans_pcie->rx_replenish);
  219. /* If we've added more space for the firmware to place data, tell it.
  220. * Increment device's write pointer in multiples of 8. */
  221. if (rxq->write_actual != (rxq->write & ~0x7)) {
  222. spin_lock_irqsave(&rxq->lock, flags);
  223. rxq->need_update = 1;
  224. spin_unlock_irqrestore(&rxq->lock, flags);
  225. iwl_rx_queue_update_write_ptr(trans, rxq);
  226. }
  227. }
  228. /*
  229. * iwl_rx_allocate - allocate a page for each used RBD
  230. *
  231. * A used RBD is an Rx buffer that has been given to the stack. To use it again
  232. * a page must be allocated and the RBD must point to the page. This function
  233. * doesn't change the HW pointer but handles the list of pages that is used by
  234. * iwl_rx_queue_restock. The latter function will update the HW to use the newly
  235. * allocated buffers.
  236. */
  237. static void iwl_rx_allocate(struct iwl_trans *trans, gfp_t priority)
  238. {
  239. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  240. struct iwl_rx_queue *rxq = &trans_pcie->rxq;
  241. struct iwl_rx_mem_buffer *rxb;
  242. struct page *page;
  243. unsigned long flags;
  244. gfp_t gfp_mask = priority;
  245. while (1) {
  246. spin_lock_irqsave(&rxq->lock, flags);
  247. if (list_empty(&rxq->rx_used)) {
  248. spin_unlock_irqrestore(&rxq->lock, flags);
  249. return;
  250. }
  251. spin_unlock_irqrestore(&rxq->lock, flags);
  252. if (rxq->free_count > RX_LOW_WATERMARK)
  253. gfp_mask |= __GFP_NOWARN;
  254. if (trans_pcie->rx_page_order > 0)
  255. gfp_mask |= __GFP_COMP;
  256. /* Alloc a new receive buffer */
  257. page = alloc_pages(gfp_mask, trans_pcie->rx_page_order);
  258. if (!page) {
  259. if (net_ratelimit())
  260. IWL_DEBUG_INFO(trans, "alloc_pages failed, "
  261. "order: %d\n",
  262. trans_pcie->rx_page_order);
  263. if ((rxq->free_count <= RX_LOW_WATERMARK) &&
  264. net_ratelimit())
  265. IWL_CRIT(trans, "Failed to alloc_pages with %s."
  266. "Only %u free buffers remaining.\n",
  267. priority == GFP_ATOMIC ?
  268. "GFP_ATOMIC" : "GFP_KERNEL",
  269. rxq->free_count);
  270. /* We don't reschedule replenish work here -- we will
  271. * call the restock method and if it still needs
  272. * more buffers it will schedule replenish */
  273. return;
  274. }
  275. spin_lock_irqsave(&rxq->lock, flags);
  276. if (list_empty(&rxq->rx_used)) {
  277. spin_unlock_irqrestore(&rxq->lock, flags);
  278. __free_pages(page, trans_pcie->rx_page_order);
  279. return;
  280. }
  281. rxb = list_first_entry(&rxq->rx_used, struct iwl_rx_mem_buffer,
  282. list);
  283. list_del(&rxb->list);
  284. spin_unlock_irqrestore(&rxq->lock, flags);
  285. BUG_ON(rxb->page);
  286. rxb->page = page;
  287. /* Get physical address of the RB */
  288. rxb->page_dma =
  289. dma_map_page(trans->dev, page, 0,
  290. PAGE_SIZE << trans_pcie->rx_page_order,
  291. DMA_FROM_DEVICE);
  292. if (dma_mapping_error(trans->dev, rxb->page_dma)) {
  293. rxb->page = NULL;
  294. spin_lock_irqsave(&rxq->lock, flags);
  295. list_add(&rxb->list, &rxq->rx_used);
  296. spin_unlock_irqrestore(&rxq->lock, flags);
  297. __free_pages(page, trans_pcie->rx_page_order);
  298. return;
  299. }
  300. /* dma address must be no more than 36 bits */
  301. BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36));
  302. /* and also 256 byte aligned! */
  303. BUG_ON(rxb->page_dma & DMA_BIT_MASK(8));
  304. spin_lock_irqsave(&rxq->lock, flags);
  305. list_add_tail(&rxb->list, &rxq->rx_free);
  306. rxq->free_count++;
  307. spin_unlock_irqrestore(&rxq->lock, flags);
  308. }
  309. }
  310. /*
  311. * iwl_rx_replenish - Move all used buffers from rx_used to rx_free
  312. *
  313. * When moving to rx_free an page is allocated for the slot.
  314. *
  315. * Also restock the Rx queue via iwl_rx_queue_restock.
  316. * This is called as a scheduled work item (except for during initialization)
  317. */
  318. void iwl_rx_replenish(struct iwl_trans *trans)
  319. {
  320. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  321. unsigned long flags;
  322. iwl_rx_allocate(trans, GFP_KERNEL);
  323. spin_lock_irqsave(&trans_pcie->irq_lock, flags);
  324. iwl_rx_queue_restock(trans);
  325. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  326. }
  327. static void iwl_rx_replenish_now(struct iwl_trans *trans)
  328. {
  329. iwl_rx_allocate(trans, GFP_ATOMIC);
  330. iwl_rx_queue_restock(trans);
  331. }
  332. void iwl_bg_rx_replenish(struct work_struct *data)
  333. {
  334. struct iwl_trans_pcie *trans_pcie =
  335. container_of(data, struct iwl_trans_pcie, rx_replenish);
  336. iwl_rx_replenish(trans_pcie->trans);
  337. }
  338. static void iwl_rx_handle_rxbuf(struct iwl_trans *trans,
  339. struct iwl_rx_mem_buffer *rxb)
  340. {
  341. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  342. struct iwl_rx_queue *rxq = &trans_pcie->rxq;
  343. struct iwl_tx_queue *txq = &trans_pcie->txq[trans_pcie->cmd_queue];
  344. unsigned long flags;
  345. bool page_stolen = false;
  346. int max_len = PAGE_SIZE << trans_pcie->rx_page_order;
  347. u32 offset = 0;
  348. if (WARN_ON(!rxb))
  349. return;
  350. dma_unmap_page(trans->dev, rxb->page_dma, max_len, DMA_FROM_DEVICE);
  351. while (offset + sizeof(u32) + sizeof(struct iwl_cmd_header) < max_len) {
  352. struct iwl_rx_packet *pkt;
  353. struct iwl_device_cmd *cmd;
  354. u16 sequence;
  355. bool reclaim;
  356. int index, cmd_index, err, len;
  357. struct iwl_rx_cmd_buffer rxcb = {
  358. ._offset = offset,
  359. ._page = rxb->page,
  360. ._page_stolen = false,
  361. .truesize = max_len,
  362. };
  363. pkt = rxb_addr(&rxcb);
  364. if (pkt->len_n_flags == cpu_to_le32(FH_RSCSR_FRAME_INVALID))
  365. break;
  366. IWL_DEBUG_RX(trans, "cmd at offset %d: %s (0x%.2x)\n",
  367. rxcb._offset,
  368. trans_pcie_get_cmd_string(trans_pcie, pkt->hdr.cmd),
  369. pkt->hdr.cmd);
  370. len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
  371. len += sizeof(u32); /* account for status word */
  372. trace_iwlwifi_dev_rx(trans->dev, trans, pkt, len);
  373. trace_iwlwifi_dev_rx_data(trans->dev, trans, pkt, len);
  374. /* Reclaim a command buffer only if this packet is a response
  375. * to a (driver-originated) command.
  376. * If the packet (e.g. Rx frame) originated from uCode,
  377. * there is no command buffer to reclaim.
  378. * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
  379. * but apparently a few don't get set; catch them here. */
  380. reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME);
  381. if (reclaim) {
  382. int i;
  383. for (i = 0; i < trans_pcie->n_no_reclaim_cmds; i++) {
  384. if (trans_pcie->no_reclaim_cmds[i] ==
  385. pkt->hdr.cmd) {
  386. reclaim = false;
  387. break;
  388. }
  389. }
  390. }
  391. sequence = le16_to_cpu(pkt->hdr.sequence);
  392. index = SEQ_TO_INDEX(sequence);
  393. cmd_index = get_cmd_index(&txq->q, index);
  394. if (reclaim) {
  395. struct iwl_pcie_tx_queue_entry *ent;
  396. ent = &txq->entries[cmd_index];
  397. cmd = ent->copy_cmd;
  398. WARN_ON_ONCE(!cmd && ent->meta.flags & CMD_WANT_HCMD);
  399. } else {
  400. cmd = NULL;
  401. }
  402. err = iwl_op_mode_rx(trans->op_mode, &rxcb, cmd);
  403. if (reclaim) {
  404. /* The original command isn't needed any more */
  405. kfree(txq->entries[cmd_index].copy_cmd);
  406. txq->entries[cmd_index].copy_cmd = NULL;
  407. /* nor is the duplicated part of the command */
  408. kfree(txq->entries[cmd_index].free_buf);
  409. txq->entries[cmd_index].free_buf = NULL;
  410. }
  411. /*
  412. * After here, we should always check rxcb._page_stolen,
  413. * if it is true then one of the handlers took the page.
  414. */
  415. if (reclaim) {
  416. /* Invoke any callbacks, transfer the buffer to caller,
  417. * and fire off the (possibly) blocking
  418. * iwl_trans_send_cmd()
  419. * as we reclaim the driver command queue */
  420. if (!rxcb._page_stolen)
  421. iwl_tx_cmd_complete(trans, &rxcb, err);
  422. else
  423. IWL_WARN(trans, "Claim null rxb?\n");
  424. }
  425. page_stolen |= rxcb._page_stolen;
  426. offset += ALIGN(len, FH_RSCSR_FRAME_ALIGN);
  427. }
  428. /* page was stolen from us -- free our reference */
  429. if (page_stolen) {
  430. __free_pages(rxb->page, trans_pcie->rx_page_order);
  431. rxb->page = NULL;
  432. }
  433. /* Reuse the page if possible. For notification packets and
  434. * SKBs that fail to Rx correctly, add them back into the
  435. * rx_free list for reuse later. */
  436. spin_lock_irqsave(&rxq->lock, flags);
  437. if (rxb->page != NULL) {
  438. rxb->page_dma =
  439. dma_map_page(trans->dev, rxb->page, 0,
  440. PAGE_SIZE << trans_pcie->rx_page_order,
  441. DMA_FROM_DEVICE);
  442. if (dma_mapping_error(trans->dev, rxb->page_dma)) {
  443. /*
  444. * free the page(s) as well to not break
  445. * the invariant that the items on the used
  446. * list have no page(s)
  447. */
  448. __free_pages(rxb->page, trans_pcie->rx_page_order);
  449. rxb->page = NULL;
  450. list_add_tail(&rxb->list, &rxq->rx_used);
  451. } else {
  452. list_add_tail(&rxb->list, &rxq->rx_free);
  453. rxq->free_count++;
  454. }
  455. } else
  456. list_add_tail(&rxb->list, &rxq->rx_used);
  457. spin_unlock_irqrestore(&rxq->lock, flags);
  458. }
  459. /**
  460. * iwl_rx_handle - Main entry function for receiving responses from uCode
  461. *
  462. * Uses the priv->rx_handlers callback function array to invoke
  463. * the appropriate handlers, including command responses,
  464. * frame-received notifications, and other notifications.
  465. */
  466. static void iwl_rx_handle(struct iwl_trans *trans)
  467. {
  468. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  469. struct iwl_rx_queue *rxq = &trans_pcie->rxq;
  470. u32 r, i;
  471. u8 fill_rx = 0;
  472. u32 count = 8;
  473. int total_empty;
  474. /* uCode's read index (stored in shared DRAM) indicates the last Rx
  475. * buffer that the driver may process (last buffer filled by ucode). */
  476. r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF;
  477. i = rxq->read;
  478. /* Rx interrupt, but nothing sent from uCode */
  479. if (i == r)
  480. IWL_DEBUG_RX(trans, "HW = SW = %d\n", r);
  481. /* calculate total frames need to be restock after handling RX */
  482. total_empty = r - rxq->write_actual;
  483. if (total_empty < 0)
  484. total_empty += RX_QUEUE_SIZE;
  485. if (total_empty > (RX_QUEUE_SIZE / 2))
  486. fill_rx = 1;
  487. while (i != r) {
  488. struct iwl_rx_mem_buffer *rxb;
  489. rxb = rxq->queue[i];
  490. rxq->queue[i] = NULL;
  491. IWL_DEBUG_RX(trans, "rxbuf: HW = %d, SW = %d (%p)\n",
  492. r, i, rxb);
  493. iwl_rx_handle_rxbuf(trans, rxb);
  494. i = (i + 1) & RX_QUEUE_MASK;
  495. /* If there are a lot of unused frames,
  496. * restock the Rx queue so ucode wont assert. */
  497. if (fill_rx) {
  498. count++;
  499. if (count >= 8) {
  500. rxq->read = i;
  501. iwl_rx_replenish_now(trans);
  502. count = 0;
  503. }
  504. }
  505. }
  506. /* Backtrack one entry */
  507. rxq->read = i;
  508. if (fill_rx)
  509. iwl_rx_replenish_now(trans);
  510. else
  511. iwl_rx_queue_restock(trans);
  512. }
  513. /**
  514. * iwl_irq_handle_error - called for HW or SW error interrupt from card
  515. */
  516. static void iwl_irq_handle_error(struct iwl_trans *trans)
  517. {
  518. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  519. /* W/A for WiFi/WiMAX coex and WiMAX own the RF */
  520. if (trans->cfg->internal_wimax_coex &&
  521. (!(iwl_read_prph(trans, APMG_CLK_CTRL_REG) &
  522. APMS_CLK_VAL_MRB_FUNC_MODE) ||
  523. (iwl_read_prph(trans, APMG_PS_CTRL_REG) &
  524. APMG_PS_CTRL_VAL_RESET_REQ))) {
  525. clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status);
  526. iwl_op_mode_wimax_active(trans->op_mode);
  527. wake_up(&trans_pcie->wait_command_queue);
  528. return;
  529. }
  530. iwl_dump_csr(trans);
  531. iwl_dump_fh(trans, NULL);
  532. set_bit(STATUS_FW_ERROR, &trans_pcie->status);
  533. clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status);
  534. wake_up(&trans_pcie->wait_command_queue);
  535. iwl_op_mode_nic_error(trans->op_mode);
  536. }
  537. /* tasklet for iwlagn interrupt */
  538. void iwl_irq_tasklet(struct iwl_trans *trans)
  539. {
  540. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  541. struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
  542. u32 inta = 0;
  543. u32 handled = 0;
  544. unsigned long flags;
  545. u32 i;
  546. #ifdef CONFIG_IWLWIFI_DEBUG
  547. u32 inta_mask;
  548. #endif
  549. spin_lock_irqsave(&trans_pcie->irq_lock, flags);
  550. /* Ack/clear/reset pending uCode interrupts.
  551. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
  552. */
  553. /* There is a hardware bug in the interrupt mask function that some
  554. * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if
  555. * they are disabled in the CSR_INT_MASK register. Furthermore the
  556. * ICT interrupt handling mechanism has another bug that might cause
  557. * these unmasked interrupts fail to be detected. We workaround the
  558. * hardware bugs here by ACKing all the possible interrupts so that
  559. * interrupt coalescing can still be achieved.
  560. */
  561. iwl_write32(trans, CSR_INT,
  562. trans_pcie->inta | ~trans_pcie->inta_mask);
  563. inta = trans_pcie->inta;
  564. #ifdef CONFIG_IWLWIFI_DEBUG
  565. if (iwl_have_debug_level(IWL_DL_ISR)) {
  566. /* just for debug */
  567. inta_mask = iwl_read32(trans, CSR_INT_MASK);
  568. IWL_DEBUG_ISR(trans, "inta 0x%08x, enabled 0x%08x\n",
  569. inta, inta_mask);
  570. }
  571. #endif
  572. /* saved interrupt in inta variable now we can reset trans_pcie->inta */
  573. trans_pcie->inta = 0;
  574. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  575. /* Now service all interrupt bits discovered above. */
  576. if (inta & CSR_INT_BIT_HW_ERR) {
  577. IWL_ERR(trans, "Hardware error detected. Restarting.\n");
  578. /* Tell the device to stop sending interrupts */
  579. iwl_disable_interrupts(trans);
  580. isr_stats->hw++;
  581. iwl_irq_handle_error(trans);
  582. handled |= CSR_INT_BIT_HW_ERR;
  583. return;
  584. }
  585. #ifdef CONFIG_IWLWIFI_DEBUG
  586. if (iwl_have_debug_level(IWL_DL_ISR)) {
  587. /* NIC fires this, but we don't use it, redundant with WAKEUP */
  588. if (inta & CSR_INT_BIT_SCD) {
  589. IWL_DEBUG_ISR(trans, "Scheduler finished to transmit "
  590. "the frame/frames.\n");
  591. isr_stats->sch++;
  592. }
  593. /* Alive notification via Rx interrupt will do the real work */
  594. if (inta & CSR_INT_BIT_ALIVE) {
  595. IWL_DEBUG_ISR(trans, "Alive interrupt\n");
  596. isr_stats->alive++;
  597. }
  598. }
  599. #endif
  600. /* Safely ignore these bits for debug checks below */
  601. inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
  602. /* HW RF KILL switch toggled */
  603. if (inta & CSR_INT_BIT_RF_KILL) {
  604. bool hw_rfkill;
  605. hw_rfkill = iwl_is_rfkill_set(trans);
  606. IWL_WARN(trans, "RF_KILL bit toggled to %s.\n",
  607. hw_rfkill ? "disable radio" : "enable radio");
  608. isr_stats->rfkill++;
  609. iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
  610. if (hw_rfkill) {
  611. set_bit(STATUS_RFKILL, &trans_pcie->status);
  612. if (test_and_clear_bit(STATUS_HCMD_ACTIVE,
  613. &trans_pcie->status))
  614. IWL_DEBUG_RF_KILL(trans,
  615. "Rfkill while SYNC HCMD in flight\n");
  616. wake_up(&trans_pcie->wait_command_queue);
  617. } else {
  618. clear_bit(STATUS_RFKILL, &trans_pcie->status);
  619. }
  620. handled |= CSR_INT_BIT_RF_KILL;
  621. }
  622. /* Chip got too hot and stopped itself */
  623. if (inta & CSR_INT_BIT_CT_KILL) {
  624. IWL_ERR(trans, "Microcode CT kill error detected.\n");
  625. isr_stats->ctkill++;
  626. handled |= CSR_INT_BIT_CT_KILL;
  627. }
  628. /* Error detected by uCode */
  629. if (inta & CSR_INT_BIT_SW_ERR) {
  630. IWL_ERR(trans, "Microcode SW error detected. "
  631. " Restarting 0x%X.\n", inta);
  632. isr_stats->sw++;
  633. iwl_irq_handle_error(trans);
  634. handled |= CSR_INT_BIT_SW_ERR;
  635. }
  636. /* uCode wakes up after power-down sleep */
  637. if (inta & CSR_INT_BIT_WAKEUP) {
  638. IWL_DEBUG_ISR(trans, "Wakeup interrupt\n");
  639. iwl_rx_queue_update_write_ptr(trans, &trans_pcie->rxq);
  640. for (i = 0; i < trans->cfg->base_params->num_of_queues; i++)
  641. iwl_txq_update_write_ptr(trans,
  642. &trans_pcie->txq[i]);
  643. isr_stats->wakeup++;
  644. handled |= CSR_INT_BIT_WAKEUP;
  645. }
  646. /* All uCode command responses, including Tx command responses,
  647. * Rx "responses" (frame-received notification), and other
  648. * notifications from uCode come through here*/
  649. if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX |
  650. CSR_INT_BIT_RX_PERIODIC)) {
  651. IWL_DEBUG_ISR(trans, "Rx interrupt\n");
  652. if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
  653. handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
  654. iwl_write32(trans, CSR_FH_INT_STATUS,
  655. CSR_FH_INT_RX_MASK);
  656. }
  657. if (inta & CSR_INT_BIT_RX_PERIODIC) {
  658. handled |= CSR_INT_BIT_RX_PERIODIC;
  659. iwl_write32(trans,
  660. CSR_INT, CSR_INT_BIT_RX_PERIODIC);
  661. }
  662. /* Sending RX interrupt require many steps to be done in the
  663. * the device:
  664. * 1- write interrupt to current index in ICT table.
  665. * 2- dma RX frame.
  666. * 3- update RX shared data to indicate last write index.
  667. * 4- send interrupt.
  668. * This could lead to RX race, driver could receive RX interrupt
  669. * but the shared data changes does not reflect this;
  670. * periodic interrupt will detect any dangling Rx activity.
  671. */
  672. /* Disable periodic interrupt; we use it as just a one-shot. */
  673. iwl_write8(trans, CSR_INT_PERIODIC_REG,
  674. CSR_INT_PERIODIC_DIS);
  675. iwl_rx_handle(trans);
  676. /*
  677. * Enable periodic interrupt in 8 msec only if we received
  678. * real RX interrupt (instead of just periodic int), to catch
  679. * any dangling Rx interrupt. If it was just the periodic
  680. * interrupt, there was no dangling Rx activity, and no need
  681. * to extend the periodic interrupt; one-shot is enough.
  682. */
  683. if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX))
  684. iwl_write8(trans, CSR_INT_PERIODIC_REG,
  685. CSR_INT_PERIODIC_ENA);
  686. isr_stats->rx++;
  687. }
  688. /* This "Tx" DMA channel is used only for loading uCode */
  689. if (inta & CSR_INT_BIT_FH_TX) {
  690. iwl_write32(trans, CSR_FH_INT_STATUS, CSR_FH_INT_TX_MASK);
  691. IWL_DEBUG_ISR(trans, "uCode load interrupt\n");
  692. isr_stats->tx++;
  693. handled |= CSR_INT_BIT_FH_TX;
  694. /* Wake up uCode load routine, now that load is complete */
  695. trans_pcie->ucode_write_complete = true;
  696. wake_up(&trans_pcie->ucode_write_waitq);
  697. }
  698. if (inta & ~handled) {
  699. IWL_ERR(trans, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
  700. isr_stats->unhandled++;
  701. }
  702. if (inta & ~(trans_pcie->inta_mask)) {
  703. IWL_WARN(trans, "Disabled INTA bits 0x%08x were pending\n",
  704. inta & ~trans_pcie->inta_mask);
  705. }
  706. /* Re-enable all interrupts */
  707. /* only Re-enable if disabled by irq */
  708. if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status))
  709. iwl_enable_interrupts(trans);
  710. /* Re-enable RF_KILL if it occurred */
  711. else if (handled & CSR_INT_BIT_RF_KILL)
  712. iwl_enable_rfkill_int(trans);
  713. }
  714. /******************************************************************************
  715. *
  716. * ICT functions
  717. *
  718. ******************************************************************************/
  719. /* a device (PCI-E) page is 4096 bytes long */
  720. #define ICT_SHIFT 12
  721. #define ICT_SIZE (1 << ICT_SHIFT)
  722. #define ICT_COUNT (ICT_SIZE / sizeof(u32))
  723. /* Free dram table */
  724. void iwl_free_isr_ict(struct iwl_trans *trans)
  725. {
  726. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  727. if (trans_pcie->ict_tbl) {
  728. dma_free_coherent(trans->dev, ICT_SIZE,
  729. trans_pcie->ict_tbl,
  730. trans_pcie->ict_tbl_dma);
  731. trans_pcie->ict_tbl = NULL;
  732. trans_pcie->ict_tbl_dma = 0;
  733. }
  734. }
  735. /*
  736. * allocate dram shared table, it is an aligned memory
  737. * block of ICT_SIZE.
  738. * also reset all data related to ICT table interrupt.
  739. */
  740. int iwl_alloc_isr_ict(struct iwl_trans *trans)
  741. {
  742. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  743. trans_pcie->ict_tbl =
  744. dma_alloc_coherent(trans->dev, ICT_SIZE,
  745. &trans_pcie->ict_tbl_dma,
  746. GFP_KERNEL);
  747. if (!trans_pcie->ict_tbl)
  748. return -ENOMEM;
  749. /* just an API sanity check ... it is guaranteed to be aligned */
  750. if (WARN_ON(trans_pcie->ict_tbl_dma & (ICT_SIZE - 1))) {
  751. iwl_free_isr_ict(trans);
  752. return -EINVAL;
  753. }
  754. IWL_DEBUG_ISR(trans, "ict dma addr %Lx\n",
  755. (unsigned long long)trans_pcie->ict_tbl_dma);
  756. IWL_DEBUG_ISR(trans, "ict vir addr %p\n", trans_pcie->ict_tbl);
  757. /* reset table and index to all 0 */
  758. memset(trans_pcie->ict_tbl, 0, ICT_SIZE);
  759. trans_pcie->ict_index = 0;
  760. /* add periodic RX interrupt */
  761. trans_pcie->inta_mask |= CSR_INT_BIT_RX_PERIODIC;
  762. return 0;
  763. }
  764. /* Device is going up inform it about using ICT interrupt table,
  765. * also we need to tell the driver to start using ICT interrupt.
  766. */
  767. void iwl_reset_ict(struct iwl_trans *trans)
  768. {
  769. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  770. u32 val;
  771. unsigned long flags;
  772. if (!trans_pcie->ict_tbl)
  773. return;
  774. spin_lock_irqsave(&trans_pcie->irq_lock, flags);
  775. iwl_disable_interrupts(trans);
  776. memset(trans_pcie->ict_tbl, 0, ICT_SIZE);
  777. val = trans_pcie->ict_tbl_dma >> ICT_SHIFT;
  778. val |= CSR_DRAM_INT_TBL_ENABLE;
  779. val |= CSR_DRAM_INIT_TBL_WRAP_CHECK;
  780. IWL_DEBUG_ISR(trans, "CSR_DRAM_INT_TBL_REG =0x%x\n", val);
  781. iwl_write32(trans, CSR_DRAM_INT_TBL_REG, val);
  782. trans_pcie->use_ict = true;
  783. trans_pcie->ict_index = 0;
  784. iwl_write32(trans, CSR_INT, trans_pcie->inta_mask);
  785. iwl_enable_interrupts(trans);
  786. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  787. }
  788. /* Device is going down disable ict interrupt usage */
  789. void iwl_disable_ict(struct iwl_trans *trans)
  790. {
  791. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  792. unsigned long flags;
  793. spin_lock_irqsave(&trans_pcie->irq_lock, flags);
  794. trans_pcie->use_ict = false;
  795. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  796. }
  797. /* legacy (non-ICT) ISR. Assumes that trans_pcie->irq_lock is held */
  798. static irqreturn_t iwl_isr(int irq, void *data)
  799. {
  800. struct iwl_trans *trans = data;
  801. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  802. u32 inta, inta_mask;
  803. #ifdef CONFIG_IWLWIFI_DEBUG
  804. u32 inta_fh;
  805. #endif
  806. lockdep_assert_held(&trans_pcie->irq_lock);
  807. trace_iwlwifi_dev_irq(trans->dev);
  808. /* Disable (but don't clear!) interrupts here to avoid
  809. * back-to-back ISRs and sporadic interrupts from our NIC.
  810. * If we have something to service, the tasklet will re-enable ints.
  811. * If we *don't* have something, we'll re-enable before leaving here. */
  812. inta_mask = iwl_read32(trans, CSR_INT_MASK); /* just for debug */
  813. iwl_write32(trans, CSR_INT_MASK, 0x00000000);
  814. /* Discover which interrupts are active/pending */
  815. inta = iwl_read32(trans, CSR_INT);
  816. /* Ignore interrupt if there's nothing in NIC to service.
  817. * This may be due to IRQ shared with another device,
  818. * or due to sporadic interrupts thrown from our NIC. */
  819. if (!inta) {
  820. IWL_DEBUG_ISR(trans, "Ignore interrupt, inta == 0\n");
  821. goto none;
  822. }
  823. if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
  824. /* Hardware disappeared. It might have already raised
  825. * an interrupt */
  826. IWL_WARN(trans, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
  827. return IRQ_HANDLED;
  828. }
  829. #ifdef CONFIG_IWLWIFI_DEBUG
  830. if (iwl_have_debug_level(IWL_DL_ISR)) {
  831. inta_fh = iwl_read32(trans, CSR_FH_INT_STATUS);
  832. IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled 0x%08x, "
  833. "fh 0x%08x\n", inta, inta_mask, inta_fh);
  834. }
  835. #endif
  836. trans_pcie->inta |= inta;
  837. /* iwl_irq_tasklet() will service interrupts and re-enable them */
  838. if (likely(inta))
  839. tasklet_schedule(&trans_pcie->irq_tasklet);
  840. else if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) &&
  841. !trans_pcie->inta)
  842. iwl_enable_interrupts(trans);
  843. none:
  844. /* re-enable interrupts here since we don't have anything to service. */
  845. /* only Re-enable if disabled by irq and no schedules tasklet. */
  846. if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) &&
  847. !trans_pcie->inta)
  848. iwl_enable_interrupts(trans);
  849. return IRQ_NONE;
  850. }
  851. /* interrupt handler using ict table, with this interrupt driver will
  852. * stop using INTA register to get device's interrupt, reading this register
  853. * is expensive, device will write interrupts in ICT dram table, increment
  854. * index then will fire interrupt to driver, driver will OR all ICT table
  855. * entries from current index up to table entry with 0 value. the result is
  856. * the interrupt we need to service, driver will set the entries back to 0 and
  857. * set index.
  858. */
  859. irqreturn_t iwl_isr_ict(int irq, void *data)
  860. {
  861. struct iwl_trans *trans = data;
  862. struct iwl_trans_pcie *trans_pcie;
  863. u32 inta, inta_mask;
  864. u32 val = 0;
  865. u32 read;
  866. unsigned long flags;
  867. if (!trans)
  868. return IRQ_NONE;
  869. trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  870. spin_lock_irqsave(&trans_pcie->irq_lock, flags);
  871. /* dram interrupt table not set yet,
  872. * use legacy interrupt.
  873. */
  874. if (unlikely(!trans_pcie->use_ict)) {
  875. irqreturn_t ret = iwl_isr(irq, data);
  876. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  877. return ret;
  878. }
  879. trace_iwlwifi_dev_irq(trans->dev);
  880. /* Disable (but don't clear!) interrupts here to avoid
  881. * back-to-back ISRs and sporadic interrupts from our NIC.
  882. * If we have something to service, the tasklet will re-enable ints.
  883. * If we *don't* have something, we'll re-enable before leaving here.
  884. */
  885. inta_mask = iwl_read32(trans, CSR_INT_MASK); /* just for debug */
  886. iwl_write32(trans, CSR_INT_MASK, 0x00000000);
  887. /* Ignore interrupt if there's nothing in NIC to service.
  888. * This may be due to IRQ shared with another device,
  889. * or due to sporadic interrupts thrown from our NIC. */
  890. read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]);
  891. trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index, read);
  892. if (!read) {
  893. IWL_DEBUG_ISR(trans, "Ignore interrupt, inta == 0\n");
  894. goto none;
  895. }
  896. /*
  897. * Collect all entries up to the first 0, starting from ict_index;
  898. * note we already read at ict_index.
  899. */
  900. do {
  901. val |= read;
  902. IWL_DEBUG_ISR(trans, "ICT index %d value 0x%08X\n",
  903. trans_pcie->ict_index, read);
  904. trans_pcie->ict_tbl[trans_pcie->ict_index] = 0;
  905. trans_pcie->ict_index =
  906. iwl_queue_inc_wrap(trans_pcie->ict_index, ICT_COUNT);
  907. read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]);
  908. trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index,
  909. read);
  910. } while (read);
  911. /* We should not get this value, just ignore it. */
  912. if (val == 0xffffffff)
  913. val = 0;
  914. /*
  915. * this is a w/a for a h/w bug. the h/w bug may cause the Rx bit
  916. * (bit 15 before shifting it to 31) to clear when using interrupt
  917. * coalescing. fortunately, bits 18 and 19 stay set when this happens
  918. * so we use them to decide on the real state of the Rx bit.
  919. * In order words, bit 15 is set if bit 18 or bit 19 are set.
  920. */
  921. if (val & 0xC0000)
  922. val |= 0x8000;
  923. inta = (0xff & val) | ((0xff00 & val) << 16);
  924. IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled 0x%08x ict 0x%08x\n",
  925. inta, inta_mask, val);
  926. inta &= trans_pcie->inta_mask;
  927. trans_pcie->inta |= inta;
  928. /* iwl_irq_tasklet() will service interrupts and re-enable them */
  929. if (likely(inta))
  930. tasklet_schedule(&trans_pcie->irq_tasklet);
  931. else if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) &&
  932. !trans_pcie->inta) {
  933. /* Allow interrupt if was disabled by this handler and
  934. * no tasklet was schedules, We should not enable interrupt,
  935. * tasklet will enable it.
  936. */
  937. iwl_enable_interrupts(trans);
  938. }
  939. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  940. return IRQ_HANDLED;
  941. none:
  942. /* re-enable interrupts here since we don't have anything to service.
  943. * only Re-enable if disabled by irq.
  944. */
  945. if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) &&
  946. !trans_pcie->inta)
  947. iwl_enable_interrupts(trans);
  948. spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  949. return IRQ_NONE;
  950. }