ql4_isr.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2010 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #include "ql4_def.h"
  8. #include "ql4_glbl.h"
  9. #include "ql4_dbg.h"
  10. #include "ql4_inline.h"
  11. /**
  12. * qla4xxx_copy_sense - copy sense data into cmd sense buffer
  13. * @ha: Pointer to host adapter structure.
  14. * @sts_entry: Pointer to status entry structure.
  15. * @srb: Pointer to srb structure.
  16. **/
  17. static void qla4xxx_copy_sense(struct scsi_qla_host *ha,
  18. struct status_entry *sts_entry,
  19. struct srb *srb)
  20. {
  21. struct scsi_cmnd *cmd = srb->cmd;
  22. uint16_t sense_len;
  23. memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
  24. sense_len = le16_to_cpu(sts_entry->senseDataByteCnt);
  25. if (sense_len == 0) {
  26. DEBUG2(ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d:%d: %s:"
  27. " sense len 0\n", ha->host_no,
  28. cmd->device->channel, cmd->device->id,
  29. cmd->device->lun, __func__));
  30. ha->status_srb = NULL;
  31. return;
  32. }
  33. /* Save total available sense length,
  34. * not to exceed cmd's sense buffer size */
  35. sense_len = min_t(uint16_t, sense_len, SCSI_SENSE_BUFFERSIZE);
  36. srb->req_sense_ptr = cmd->sense_buffer;
  37. srb->req_sense_len = sense_len;
  38. /* Copy sense from sts_entry pkt */
  39. sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN);
  40. memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len);
  41. DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: %s: sense key = %x, "
  42. "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no,
  43. cmd->device->channel, cmd->device->id,
  44. cmd->device->lun, __func__,
  45. sts_entry->senseData[2] & 0x0f,
  46. sts_entry->senseData[7],
  47. sts_entry->senseData[12],
  48. sts_entry->senseData[13]));
  49. DEBUG5(qla4xxx_dump_buffer(cmd->sense_buffer, sense_len));
  50. srb->flags |= SRB_GOT_SENSE;
  51. /* Update srb, in case a sts_cont pkt follows */
  52. srb->req_sense_ptr += sense_len;
  53. srb->req_sense_len -= sense_len;
  54. if (srb->req_sense_len != 0)
  55. ha->status_srb = srb;
  56. else
  57. ha->status_srb = NULL;
  58. }
  59. /**
  60. * qla4xxx_status_cont_entry - Process a Status Continuations entry.
  61. * @ha: SCSI driver HA context
  62. * @sts_cont: Entry pointer
  63. *
  64. * Extended sense data.
  65. */
  66. static void
  67. qla4xxx_status_cont_entry(struct scsi_qla_host *ha,
  68. struct status_cont_entry *sts_cont)
  69. {
  70. struct srb *srb = ha->status_srb;
  71. struct scsi_cmnd *cmd;
  72. uint16_t sense_len;
  73. if (srb == NULL)
  74. return;
  75. cmd = srb->cmd;
  76. if (cmd == NULL) {
  77. DEBUG2(printk(KERN_INFO "scsi%ld: %s: Cmd already returned "
  78. "back to OS srb=%p srb->state:%d\n", ha->host_no,
  79. __func__, srb, srb->state));
  80. ha->status_srb = NULL;
  81. return;
  82. }
  83. /* Copy sense data. */
  84. sense_len = min_t(uint16_t, srb->req_sense_len,
  85. IOCB_MAX_EXT_SENSEDATA_LEN);
  86. memcpy(srb->req_sense_ptr, sts_cont->ext_sense_data, sense_len);
  87. DEBUG5(qla4xxx_dump_buffer(srb->req_sense_ptr, sense_len));
  88. srb->req_sense_ptr += sense_len;
  89. srb->req_sense_len -= sense_len;
  90. /* Place command on done queue. */
  91. if (srb->req_sense_len == 0) {
  92. kref_put(&srb->srb_ref, qla4xxx_srb_compl);
  93. ha->status_srb = NULL;
  94. }
  95. }
  96. /**
  97. * qla4xxx_status_entry - processes status IOCBs
  98. * @ha: Pointer to host adapter structure.
  99. * @sts_entry: Pointer to status entry structure.
  100. **/
  101. static void qla4xxx_status_entry(struct scsi_qla_host *ha,
  102. struct status_entry *sts_entry)
  103. {
  104. uint8_t scsi_status;
  105. struct scsi_cmnd *cmd;
  106. struct srb *srb;
  107. struct ddb_entry *ddb_entry;
  108. uint32_t residual;
  109. srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle));
  110. if (!srb) {
  111. DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Status Entry invalid "
  112. "handle 0x%x, sp=%p. This cmd may have already "
  113. "been completed.\n", ha->host_no, __func__,
  114. le32_to_cpu(sts_entry->handle), srb));
  115. ql4_printk(KERN_WARNING, ha, "%s invalid status entry:"
  116. " handle=0x%0x\n", __func__, sts_entry->handle);
  117. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  118. return;
  119. }
  120. cmd = srb->cmd;
  121. if (cmd == NULL) {
  122. DEBUG2(printk("scsi%ld: %s: Command already returned back to "
  123. "OS pkt->handle=%d srb=%p srb->state:%d\n",
  124. ha->host_no, __func__, sts_entry->handle,
  125. srb, srb->state));
  126. ql4_printk(KERN_WARNING, ha, "Command is NULL:"
  127. " already returned to OS (srb=%p)\n", srb);
  128. return;
  129. }
  130. ddb_entry = srb->ddb;
  131. if (ddb_entry == NULL) {
  132. cmd->result = DID_NO_CONNECT << 16;
  133. goto status_entry_exit;
  134. }
  135. residual = le32_to_cpu(sts_entry->residualByteCnt);
  136. /* Translate ISP error to a Linux SCSI error. */
  137. scsi_status = sts_entry->scsiStatus;
  138. switch (sts_entry->completionStatus) {
  139. case SCS_COMPLETE:
  140. if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
  141. cmd->result = DID_ERROR << 16;
  142. break;
  143. }
  144. if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) {
  145. scsi_set_resid(cmd, residual);
  146. if (!scsi_status && ((scsi_bufflen(cmd) - residual) <
  147. cmd->underflow)) {
  148. cmd->result = DID_ERROR << 16;
  149. DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
  150. "Mid-layer Data underrun0, "
  151. "xferlen = 0x%x, "
  152. "residual = 0x%x\n", ha->host_no,
  153. cmd->device->channel,
  154. cmd->device->id,
  155. cmd->device->lun, __func__,
  156. scsi_bufflen(cmd), residual));
  157. break;
  158. }
  159. }
  160. cmd->result = DID_OK << 16 | scsi_status;
  161. if (scsi_status != SCSI_CHECK_CONDITION)
  162. break;
  163. /* Copy Sense Data into sense buffer. */
  164. qla4xxx_copy_sense(ha, sts_entry, srb);
  165. break;
  166. case SCS_INCOMPLETE:
  167. /* Always set the status to DID_ERROR, since
  168. * all conditions result in that status anyway */
  169. cmd->result = DID_ERROR << 16;
  170. break;
  171. case SCS_RESET_OCCURRED:
  172. DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Device RESET occurred\n",
  173. ha->host_no, cmd->device->channel,
  174. cmd->device->id, cmd->device->lun, __func__));
  175. cmd->result = DID_RESET << 16;
  176. break;
  177. case SCS_ABORTED:
  178. DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Abort occurred\n",
  179. ha->host_no, cmd->device->channel,
  180. cmd->device->id, cmd->device->lun, __func__));
  181. cmd->result = DID_RESET << 16;
  182. break;
  183. case SCS_TIMEOUT:
  184. DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: Timeout\n",
  185. ha->host_no, cmd->device->channel,
  186. cmd->device->id, cmd->device->lun));
  187. cmd->result = DID_TRANSPORT_DISRUPTED << 16;
  188. /*
  189. * Mark device missing so that we won't continue to send
  190. * I/O to this device. We should get a ddb state change
  191. * AEN soon.
  192. */
  193. if (iscsi_is_session_online(ddb_entry->sess))
  194. qla4xxx_mark_device_missing(ddb_entry->sess);
  195. break;
  196. case SCS_DATA_UNDERRUN:
  197. case SCS_DATA_OVERRUN:
  198. if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
  199. (sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
  200. DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun\n",
  201. ha->host_no,
  202. cmd->device->channel, cmd->device->id,
  203. cmd->device->lun, __func__));
  204. cmd->result = DID_ERROR << 16;
  205. break;
  206. }
  207. scsi_set_resid(cmd, residual);
  208. /*
  209. * If there is scsi_status, it takes precedense over
  210. * underflow condition.
  211. */
  212. if (scsi_status != 0) {
  213. cmd->result = DID_OK << 16 | scsi_status;
  214. if (scsi_status != SCSI_CHECK_CONDITION)
  215. break;
  216. /* Copy Sense Data into sense buffer. */
  217. qla4xxx_copy_sense(ha, sts_entry, srb);
  218. } else {
  219. /*
  220. * If RISC reports underrun and target does not
  221. * report it then we must have a lost frame, so
  222. * tell upper layer to retry it by reporting a
  223. * bus busy.
  224. */
  225. if ((sts_entry->iscsiFlags &
  226. ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
  227. cmd->result = DID_BUS_BUSY << 16;
  228. } else if ((scsi_bufflen(cmd) - residual) <
  229. cmd->underflow) {
  230. /*
  231. * Handle mid-layer underflow???
  232. *
  233. * For kernels less than 2.4, the driver must
  234. * return an error if an underflow is detected.
  235. * For kernels equal-to and above 2.4, the
  236. * mid-layer will appearantly handle the
  237. * underflow by detecting the residual count --
  238. * unfortunately, we do not see where this is
  239. * actually being done. In the interim, we
  240. * will return DID_ERROR.
  241. */
  242. DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
  243. "Mid-layer Data underrun1, "
  244. "xferlen = 0x%x, "
  245. "residual = 0x%x\n", ha->host_no,
  246. cmd->device->channel,
  247. cmd->device->id,
  248. cmd->device->lun, __func__,
  249. scsi_bufflen(cmd), residual));
  250. cmd->result = DID_ERROR << 16;
  251. } else {
  252. cmd->result = DID_OK << 16;
  253. }
  254. }
  255. break;
  256. case SCS_DEVICE_LOGGED_OUT:
  257. case SCS_DEVICE_UNAVAILABLE:
  258. DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: SCS_DEVICE "
  259. "state: 0x%x\n", ha->host_no,
  260. cmd->device->channel, cmd->device->id,
  261. cmd->device->lun, sts_entry->completionStatus));
  262. /*
  263. * Mark device missing so that we won't continue to
  264. * send I/O to this device. We should get a ddb
  265. * state change AEN soon.
  266. */
  267. if (iscsi_is_session_online(ddb_entry->sess))
  268. qla4xxx_mark_device_missing(ddb_entry->sess);
  269. cmd->result = DID_TRANSPORT_DISRUPTED << 16;
  270. break;
  271. case SCS_QUEUE_FULL:
  272. /*
  273. * SCSI Mid-Layer handles device queue full
  274. */
  275. cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
  276. DEBUG2(printk("scsi%ld:%d:%d: %s: QUEUE FULL detected "
  277. "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
  278. " iResp=%02x\n", ha->host_no, cmd->device->id,
  279. cmd->device->lun, __func__,
  280. sts_entry->completionStatus,
  281. sts_entry->scsiStatus, sts_entry->state_flags,
  282. sts_entry->iscsiFlags,
  283. sts_entry->iscsiResponse));
  284. break;
  285. default:
  286. cmd->result = DID_ERROR << 16;
  287. break;
  288. }
  289. status_entry_exit:
  290. /* complete the request, if not waiting for status_continuation pkt */
  291. srb->cc_stat = sts_entry->completionStatus;
  292. if (ha->status_srb == NULL)
  293. kref_put(&srb->srb_ref, qla4xxx_srb_compl);
  294. }
  295. /**
  296. * qla4xxx_passthru_status_entry - processes passthru status IOCBs (0x3C)
  297. * @ha: Pointer to host adapter structure.
  298. * @sts_entry: Pointer to status entry structure.
  299. **/
  300. static void qla4xxx_passthru_status_entry(struct scsi_qla_host *ha,
  301. struct passthru_status *sts_entry)
  302. {
  303. struct iscsi_task *task;
  304. struct ddb_entry *ddb_entry;
  305. struct ql4_task_data *task_data;
  306. struct iscsi_cls_conn *cls_conn;
  307. struct iscsi_conn *conn;
  308. itt_t itt;
  309. uint32_t fw_ddb_index;
  310. itt = sts_entry->handle;
  311. fw_ddb_index = le32_to_cpu(sts_entry->target);
  312. ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, fw_ddb_index);
  313. if (ddb_entry == NULL) {
  314. ql4_printk(KERN_ERR, ha, "%s: Invalid target index = 0x%x\n",
  315. __func__, sts_entry->target);
  316. return;
  317. }
  318. cls_conn = ddb_entry->conn;
  319. conn = cls_conn->dd_data;
  320. spin_lock(&conn->session->lock);
  321. task = iscsi_itt_to_task(conn, itt);
  322. spin_unlock(&conn->session->lock);
  323. if (task == NULL) {
  324. ql4_printk(KERN_ERR, ha, "%s: Task is NULL\n", __func__);
  325. return;
  326. }
  327. task_data = task->dd_data;
  328. memcpy(&task_data->sts, sts_entry, sizeof(struct passthru_status));
  329. ha->req_q_count += task_data->iocb_req_cnt;
  330. ha->iocb_cnt -= task_data->iocb_req_cnt;
  331. queue_work(ha->task_wq, &task_data->task_work);
  332. }
  333. /**
  334. * qla4xxx_process_response_queue - process response queue completions
  335. * @ha: Pointer to host adapter structure.
  336. *
  337. * This routine process response queue completions in interrupt context.
  338. * Hardware_lock locked upon entry
  339. **/
  340. void qla4xxx_process_response_queue(struct scsi_qla_host *ha)
  341. {
  342. uint32_t count = 0;
  343. struct srb *srb = NULL;
  344. struct status_entry *sts_entry;
  345. /* Process all responses from response queue */
  346. while ((ha->response_ptr->signature != RESPONSE_PROCESSED)) {
  347. sts_entry = (struct status_entry *) ha->response_ptr;
  348. count++;
  349. /* Advance pointers for next entry */
  350. if (ha->response_out == (RESPONSE_QUEUE_DEPTH - 1)) {
  351. ha->response_out = 0;
  352. ha->response_ptr = ha->response_ring;
  353. } else {
  354. ha->response_out++;
  355. ha->response_ptr++;
  356. }
  357. /* process entry */
  358. switch (sts_entry->hdr.entryType) {
  359. case ET_STATUS:
  360. /* Common status */
  361. qla4xxx_status_entry(ha, sts_entry);
  362. break;
  363. case ET_PASSTHRU_STATUS:
  364. if (sts_entry->hdr.systemDefined == SD_ISCSI_PDU)
  365. qla4xxx_passthru_status_entry(ha,
  366. (struct passthru_status *)sts_entry);
  367. else
  368. ql4_printk(KERN_ERR, ha,
  369. "%s: Invalid status received\n",
  370. __func__);
  371. break;
  372. case ET_STATUS_CONTINUATION:
  373. qla4xxx_status_cont_entry(ha,
  374. (struct status_cont_entry *) sts_entry);
  375. break;
  376. case ET_COMMAND:
  377. /* ISP device queue is full. Command not
  378. * accepted by ISP. Queue command for
  379. * later */
  380. srb = qla4xxx_del_from_active_array(ha,
  381. le32_to_cpu(sts_entry->
  382. handle));
  383. if (srb == NULL)
  384. goto exit_prq_invalid_handle;
  385. DEBUG2(printk("scsi%ld: %s: FW device queue full, "
  386. "srb %p\n", ha->host_no, __func__, srb));
  387. /* ETRY normally by sending it back with
  388. * DID_BUS_BUSY */
  389. srb->cmd->result = DID_BUS_BUSY << 16;
  390. kref_put(&srb->srb_ref, qla4xxx_srb_compl);
  391. break;
  392. case ET_CONTINUE:
  393. /* Just throw away the continuation entries */
  394. DEBUG2(printk("scsi%ld: %s: Continuation entry - "
  395. "ignoring\n", ha->host_no, __func__));
  396. break;
  397. default:
  398. /*
  399. * Invalid entry in response queue, reset RISC
  400. * firmware.
  401. */
  402. DEBUG2(printk("scsi%ld: %s: Invalid entry %x in "
  403. "response queue \n", ha->host_no,
  404. __func__,
  405. sts_entry->hdr.entryType));
  406. goto exit_prq_error;
  407. }
  408. ((struct response *)sts_entry)->signature = RESPONSE_PROCESSED;
  409. wmb();
  410. }
  411. /*
  412. * Tell ISP we're done with response(s). This also clears the interrupt.
  413. */
  414. ha->isp_ops->complete_iocb(ha);
  415. return;
  416. exit_prq_invalid_handle:
  417. DEBUG2(printk("scsi%ld: %s: Invalid handle(srb)=%p type=%x IOCS=%x\n",
  418. ha->host_no, __func__, srb, sts_entry->hdr.entryType,
  419. sts_entry->completionStatus));
  420. exit_prq_error:
  421. ha->isp_ops->complete_iocb(ha);
  422. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  423. }
  424. /**
  425. * qla4xxx_isr_decode_mailbox - decodes mailbox status
  426. * @ha: Pointer to host adapter structure.
  427. * @mailbox_status: Mailbox status.
  428. *
  429. * This routine decodes the mailbox status during the ISR.
  430. * Hardware_lock locked upon entry. runs in interrupt context.
  431. **/
  432. static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,
  433. uint32_t mbox_status)
  434. {
  435. int i;
  436. uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
  437. if ((mbox_status == MBOX_STS_BUSY) ||
  438. (mbox_status == MBOX_STS_INTERMEDIATE_COMPLETION) ||
  439. (mbox_status >> 12 == MBOX_COMPLETION_STATUS)) {
  440. ha->mbox_status[0] = mbox_status;
  441. if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {
  442. /*
  443. * Copy all mailbox registers to a temporary
  444. * location and set mailbox command done flag
  445. */
  446. for (i = 0; i < ha->mbox_status_count; i++)
  447. ha->mbox_status[i] = is_qla8022(ha)
  448. ? readl(&ha->qla4_8xxx_reg->mailbox_out[i])
  449. : readl(&ha->reg->mailbox[i]);
  450. set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
  451. if (test_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags))
  452. complete(&ha->mbx_intr_comp);
  453. }
  454. } else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {
  455. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  456. mbox_sts[i] = is_qla8022(ha)
  457. ? readl(&ha->qla4_8xxx_reg->mailbox_out[i])
  458. : readl(&ha->reg->mailbox[i]);
  459. /* Immediately process the AENs that don't require much work.
  460. * Only queue the database_changed AENs */
  461. if (ha->aen_log.count < MAX_AEN_ENTRIES) {
  462. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  463. ha->aen_log.entry[ha->aen_log.count].mbox_sts[i] =
  464. mbox_sts[i];
  465. ha->aen_log.count++;
  466. }
  467. switch (mbox_status) {
  468. case MBOX_ASTS_SYSTEM_ERROR:
  469. /* Log Mailbox registers */
  470. ql4_printk(KERN_INFO, ha, "%s: System Err\n", __func__);
  471. qla4xxx_dump_registers(ha);
  472. if (ql4xdontresethba) {
  473. DEBUG2(printk("scsi%ld: %s:Don't Reset HBA\n",
  474. ha->host_no, __func__));
  475. } else {
  476. set_bit(AF_GET_CRASH_RECORD, &ha->flags);
  477. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  478. }
  479. break;
  480. case MBOX_ASTS_REQUEST_TRANSFER_ERROR:
  481. case MBOX_ASTS_RESPONSE_TRANSFER_ERROR:
  482. case MBOX_ASTS_NVRAM_INVALID:
  483. case MBOX_ASTS_IP_ADDRESS_CHANGED:
  484. case MBOX_ASTS_DHCP_LEASE_EXPIRED:
  485. DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "
  486. "Reset HA\n", ha->host_no, mbox_status));
  487. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  488. break;
  489. case MBOX_ASTS_LINK_UP:
  490. set_bit(AF_LINK_UP, &ha->flags);
  491. if (test_bit(AF_INIT_DONE, &ha->flags))
  492. set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
  493. ql4_printk(KERN_INFO, ha, "%s: LINK UP\n", __func__);
  494. break;
  495. case MBOX_ASTS_LINK_DOWN:
  496. clear_bit(AF_LINK_UP, &ha->flags);
  497. if (test_bit(AF_INIT_DONE, &ha->flags))
  498. set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
  499. ql4_printk(KERN_INFO, ha, "%s: LINK DOWN\n", __func__);
  500. break;
  501. case MBOX_ASTS_HEARTBEAT:
  502. ha->seconds_since_last_heartbeat = 0;
  503. break;
  504. case MBOX_ASTS_DHCP_LEASE_ACQUIRED:
  505. DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "
  506. "ACQUIRED\n", ha->host_no, mbox_status));
  507. set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
  508. break;
  509. case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM:
  510. case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED: /* Target
  511. * mode
  512. * only */
  513. case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED: /* Connection mode */
  514. case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR:
  515. case MBOX_ASTS_SUBNET_STATE_CHANGE:
  516. case MBOX_ASTS_DUPLICATE_IP:
  517. /* No action */
  518. DEBUG2(printk("scsi%ld: AEN %04x\n", ha->host_no,
  519. mbox_status));
  520. break;
  521. case MBOX_ASTS_IP_ADDR_STATE_CHANGED:
  522. printk("scsi%ld: AEN %04x, mbox_sts[2]=%04x, "
  523. "mbox_sts[3]=%04x\n", ha->host_no, mbox_sts[0],
  524. mbox_sts[2], mbox_sts[3]);
  525. /* mbox_sts[2] = Old ACB state
  526. * mbox_sts[3] = new ACB state */
  527. if ((mbox_sts[3] == ACB_STATE_VALID) &&
  528. ((mbox_sts[2] == ACB_STATE_TENTATIVE) ||
  529. (mbox_sts[2] == ACB_STATE_ACQUIRING)))
  530. set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
  531. else if ((mbox_sts[3] == ACB_STATE_ACQUIRING) &&
  532. (mbox_sts[2] == ACB_STATE_VALID))
  533. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  534. break;
  535. case MBOX_ASTS_MAC_ADDRESS_CHANGED:
  536. case MBOX_ASTS_DNS:
  537. /* No action */
  538. DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x, "
  539. "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",
  540. ha->host_no, mbox_sts[0],
  541. mbox_sts[1], mbox_sts[2]));
  542. break;
  543. case MBOX_ASTS_SELF_TEST_FAILED:
  544. case MBOX_ASTS_LOGIN_FAILED:
  545. /* No action */
  546. DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "
  547. "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",
  548. ha->host_no, mbox_sts[0], mbox_sts[1],
  549. mbox_sts[2], mbox_sts[3]));
  550. break;
  551. case MBOX_ASTS_DATABASE_CHANGED:
  552. /* Queue AEN information and process it in the DPC
  553. * routine */
  554. if (ha->aen_q_count > 0) {
  555. /* decrement available counter */
  556. ha->aen_q_count--;
  557. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  558. ha->aen_q[ha->aen_in].mbox_sts[i] =
  559. mbox_sts[i];
  560. /* print debug message */
  561. DEBUG2(printk("scsi%ld: AEN[%d] %04x queued "
  562. "mb1:0x%x mb2:0x%x mb3:0x%x "
  563. "mb4:0x%x mb5:0x%x\n",
  564. ha->host_no, ha->aen_in,
  565. mbox_sts[0], mbox_sts[1],
  566. mbox_sts[2], mbox_sts[3],
  567. mbox_sts[4], mbox_sts[5]));
  568. /* advance pointer */
  569. ha->aen_in++;
  570. if (ha->aen_in == MAX_AEN_ENTRIES)
  571. ha->aen_in = 0;
  572. /* The DPC routine will process the aen */
  573. set_bit(DPC_AEN, &ha->dpc_flags);
  574. } else {
  575. DEBUG2(printk("scsi%ld: %s: aen %04x, queue "
  576. "overflowed! AEN LOST!!\n",
  577. ha->host_no, __func__,
  578. mbox_sts[0]));
  579. DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",
  580. ha->host_no));
  581. for (i = 0; i < MAX_AEN_ENTRIES; i++) {
  582. DEBUG2(printk("AEN[%d] %04x %04x %04x "
  583. "%04x\n", i, mbox_sts[0],
  584. mbox_sts[1], mbox_sts[2],
  585. mbox_sts[3]));
  586. }
  587. }
  588. break;
  589. case MBOX_ASTS_TXSCVR_INSERTED:
  590. DEBUG2(printk(KERN_WARNING
  591. "scsi%ld: AEN %04x Transceiver"
  592. " inserted\n", ha->host_no, mbox_sts[0]));
  593. break;
  594. case MBOX_ASTS_TXSCVR_REMOVED:
  595. DEBUG2(printk(KERN_WARNING
  596. "scsi%ld: AEN %04x Transceiver"
  597. " removed\n", ha->host_no, mbox_sts[0]));
  598. break;
  599. default:
  600. DEBUG2(printk(KERN_WARNING
  601. "scsi%ld: AEN %04x UNKNOWN\n",
  602. ha->host_no, mbox_sts[0]));
  603. break;
  604. }
  605. } else {
  606. DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",
  607. ha->host_no, mbox_status));
  608. ha->mbox_status[0] = mbox_status;
  609. }
  610. }
  611. /**
  612. * qla4_8xxx_interrupt_service_routine - isr
  613. * @ha: pointer to host adapter structure.
  614. *
  615. * This is the main interrupt service routine.
  616. * hardware_lock locked upon entry. runs in interrupt context.
  617. **/
  618. void qla4_8xxx_interrupt_service_routine(struct scsi_qla_host *ha,
  619. uint32_t intr_status)
  620. {
  621. /* Process response queue interrupt. */
  622. if (intr_status & HSRX_RISC_IOCB_INT)
  623. qla4xxx_process_response_queue(ha);
  624. /* Process mailbox/asynch event interrupt.*/
  625. if (intr_status & HSRX_RISC_MB_INT)
  626. qla4xxx_isr_decode_mailbox(ha,
  627. readl(&ha->qla4_8xxx_reg->mailbox_out[0]));
  628. /* clear the interrupt */
  629. writel(0, &ha->qla4_8xxx_reg->host_int);
  630. readl(&ha->qla4_8xxx_reg->host_int);
  631. }
  632. /**
  633. * qla4xxx_interrupt_service_routine - isr
  634. * @ha: pointer to host adapter structure.
  635. *
  636. * This is the main interrupt service routine.
  637. * hardware_lock locked upon entry. runs in interrupt context.
  638. **/
  639. void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,
  640. uint32_t intr_status)
  641. {
  642. /* Process response queue interrupt. */
  643. if (intr_status & CSR_SCSI_COMPLETION_INTR)
  644. qla4xxx_process_response_queue(ha);
  645. /* Process mailbox/asynch event interrupt.*/
  646. if (intr_status & CSR_SCSI_PROCESSOR_INTR) {
  647. qla4xxx_isr_decode_mailbox(ha,
  648. readl(&ha->reg->mailbox[0]));
  649. /* Clear Mailbox Interrupt */
  650. writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),
  651. &ha->reg->ctrl_status);
  652. readl(&ha->reg->ctrl_status);
  653. }
  654. }
  655. /**
  656. * qla4_8xxx_spurious_interrupt - processes spurious interrupt
  657. * @ha: pointer to host adapter structure.
  658. * @reqs_count: .
  659. *
  660. **/
  661. static void qla4_8xxx_spurious_interrupt(struct scsi_qla_host *ha,
  662. uint8_t reqs_count)
  663. {
  664. if (reqs_count)
  665. return;
  666. DEBUG2(ql4_printk(KERN_INFO, ha, "Spurious Interrupt\n"));
  667. if (is_qla8022(ha)) {
  668. writel(0, &ha->qla4_8xxx_reg->host_int);
  669. if (test_bit(AF_INTx_ENABLED, &ha->flags))
  670. qla4_8xxx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg,
  671. 0xfbff);
  672. }
  673. ha->spurious_int_count++;
  674. }
  675. /**
  676. * qla4xxx_intr_handler - hardware interrupt handler.
  677. * @irq: Unused
  678. * @dev_id: Pointer to host adapter structure
  679. **/
  680. irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
  681. {
  682. struct scsi_qla_host *ha;
  683. uint32_t intr_status;
  684. unsigned long flags = 0;
  685. uint8_t reqs_count = 0;
  686. ha = (struct scsi_qla_host *) dev_id;
  687. if (!ha) {
  688. DEBUG2(printk(KERN_INFO
  689. "qla4xxx: Interrupt with NULL host ptr\n"));
  690. return IRQ_NONE;
  691. }
  692. spin_lock_irqsave(&ha->hardware_lock, flags);
  693. ha->isr_count++;
  694. /*
  695. * Repeatedly service interrupts up to a maximum of
  696. * MAX_REQS_SERVICED_PER_INTR
  697. */
  698. while (1) {
  699. /*
  700. * Read interrupt status
  701. */
  702. if (ha->isp_ops->rd_shdw_rsp_q_in(ha) !=
  703. ha->response_out)
  704. intr_status = CSR_SCSI_COMPLETION_INTR;
  705. else
  706. intr_status = readl(&ha->reg->ctrl_status);
  707. if ((intr_status &
  708. (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) == 0) {
  709. if (reqs_count == 0)
  710. ha->spurious_int_count++;
  711. break;
  712. }
  713. if (intr_status & CSR_FATAL_ERROR) {
  714. DEBUG2(printk(KERN_INFO "scsi%ld: Fatal Error, "
  715. "Status 0x%04x\n", ha->host_no,
  716. readl(isp_port_error_status (ha))));
  717. /* Issue Soft Reset to clear this error condition.
  718. * This will prevent the RISC from repeatedly
  719. * interrupting the driver; thus, allowing the DPC to
  720. * get scheduled to continue error recovery.
  721. * NOTE: Disabling RISC interrupts does not work in
  722. * this case, as CSR_FATAL_ERROR overrides
  723. * CSR_SCSI_INTR_ENABLE */
  724. if ((readl(&ha->reg->ctrl_status) &
  725. CSR_SCSI_RESET_INTR) == 0) {
  726. writel(set_rmask(CSR_SOFT_RESET),
  727. &ha->reg->ctrl_status);
  728. readl(&ha->reg->ctrl_status);
  729. }
  730. writel(set_rmask(CSR_FATAL_ERROR),
  731. &ha->reg->ctrl_status);
  732. readl(&ha->reg->ctrl_status);
  733. __qla4xxx_disable_intrs(ha);
  734. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  735. break;
  736. } else if (intr_status & CSR_SCSI_RESET_INTR) {
  737. clear_bit(AF_ONLINE, &ha->flags);
  738. __qla4xxx_disable_intrs(ha);
  739. writel(set_rmask(CSR_SCSI_RESET_INTR),
  740. &ha->reg->ctrl_status);
  741. readl(&ha->reg->ctrl_status);
  742. if (!test_bit(AF_HA_REMOVAL, &ha->flags))
  743. set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
  744. break;
  745. } else if (intr_status & INTR_PENDING) {
  746. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  747. ha->total_io_count++;
  748. if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
  749. break;
  750. }
  751. }
  752. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  753. return IRQ_HANDLED;
  754. }
  755. /**
  756. * qla4_8xxx_intr_handler - hardware interrupt handler.
  757. * @irq: Unused
  758. * @dev_id: Pointer to host adapter structure
  759. **/
  760. irqreturn_t qla4_8xxx_intr_handler(int irq, void *dev_id)
  761. {
  762. struct scsi_qla_host *ha = dev_id;
  763. uint32_t intr_status;
  764. uint32_t status;
  765. unsigned long flags = 0;
  766. uint8_t reqs_count = 0;
  767. if (unlikely(pci_channel_offline(ha->pdev)))
  768. return IRQ_HANDLED;
  769. ha->isr_count++;
  770. status = qla4_8xxx_rd_32(ha, ISR_INT_VECTOR);
  771. if (!(status & ha->nx_legacy_intr.int_vec_bit))
  772. return IRQ_NONE;
  773. status = qla4_8xxx_rd_32(ha, ISR_INT_STATE_REG);
  774. if (!ISR_IS_LEGACY_INTR_TRIGGERED(status)) {
  775. DEBUG2(ql4_printk(KERN_INFO, ha,
  776. "%s legacy Int not triggered\n", __func__));
  777. return IRQ_NONE;
  778. }
  779. /* clear the interrupt */
  780. qla4_8xxx_wr_32(ha, ha->nx_legacy_intr.tgt_status_reg, 0xffffffff);
  781. /* read twice to ensure write is flushed */
  782. qla4_8xxx_rd_32(ha, ISR_INT_VECTOR);
  783. qla4_8xxx_rd_32(ha, ISR_INT_VECTOR);
  784. spin_lock_irqsave(&ha->hardware_lock, flags);
  785. while (1) {
  786. if (!(readl(&ha->qla4_8xxx_reg->host_int) &
  787. ISRX_82XX_RISC_INT)) {
  788. qla4_8xxx_spurious_interrupt(ha, reqs_count);
  789. break;
  790. }
  791. intr_status = readl(&ha->qla4_8xxx_reg->host_status);
  792. if ((intr_status &
  793. (HSRX_RISC_MB_INT | HSRX_RISC_IOCB_INT)) == 0) {
  794. qla4_8xxx_spurious_interrupt(ha, reqs_count);
  795. break;
  796. }
  797. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  798. /* Enable Interrupt */
  799. qla4_8xxx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, 0xfbff);
  800. if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
  801. break;
  802. }
  803. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  804. return IRQ_HANDLED;
  805. }
  806. irqreturn_t
  807. qla4_8xxx_msi_handler(int irq, void *dev_id)
  808. {
  809. struct scsi_qla_host *ha;
  810. ha = (struct scsi_qla_host *) dev_id;
  811. if (!ha) {
  812. DEBUG2(printk(KERN_INFO
  813. "qla4xxx: MSIX: Interrupt with NULL host ptr\n"));
  814. return IRQ_NONE;
  815. }
  816. ha->isr_count++;
  817. /* clear the interrupt */
  818. qla4_8xxx_wr_32(ha, ha->nx_legacy_intr.tgt_status_reg, 0xffffffff);
  819. /* read twice to ensure write is flushed */
  820. qla4_8xxx_rd_32(ha, ISR_INT_VECTOR);
  821. qla4_8xxx_rd_32(ha, ISR_INT_VECTOR);
  822. return qla4_8xxx_default_intr_handler(irq, dev_id);
  823. }
  824. /**
  825. * qla4_8xxx_default_intr_handler - hardware interrupt handler.
  826. * @irq: Unused
  827. * @dev_id: Pointer to host adapter structure
  828. *
  829. * This interrupt handler is called directly for MSI-X, and
  830. * called indirectly for MSI.
  831. **/
  832. irqreturn_t
  833. qla4_8xxx_default_intr_handler(int irq, void *dev_id)
  834. {
  835. struct scsi_qla_host *ha = dev_id;
  836. unsigned long flags;
  837. uint32_t intr_status;
  838. uint8_t reqs_count = 0;
  839. spin_lock_irqsave(&ha->hardware_lock, flags);
  840. while (1) {
  841. if (!(readl(&ha->qla4_8xxx_reg->host_int) &
  842. ISRX_82XX_RISC_INT)) {
  843. qla4_8xxx_spurious_interrupt(ha, reqs_count);
  844. break;
  845. }
  846. intr_status = readl(&ha->qla4_8xxx_reg->host_status);
  847. if ((intr_status &
  848. (HSRX_RISC_MB_INT | HSRX_RISC_IOCB_INT)) == 0) {
  849. qla4_8xxx_spurious_interrupt(ha, reqs_count);
  850. break;
  851. }
  852. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  853. if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
  854. break;
  855. }
  856. ha->isr_count++;
  857. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  858. return IRQ_HANDLED;
  859. }
  860. irqreturn_t
  861. qla4_8xxx_msix_rsp_q(int irq, void *dev_id)
  862. {
  863. struct scsi_qla_host *ha = dev_id;
  864. unsigned long flags;
  865. spin_lock_irqsave(&ha->hardware_lock, flags);
  866. qla4xxx_process_response_queue(ha);
  867. writel(0, &ha->qla4_8xxx_reg->host_int);
  868. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  869. ha->isr_count++;
  870. return IRQ_HANDLED;
  871. }
  872. /**
  873. * qla4xxx_process_aen - processes AENs generated by firmware
  874. * @ha: pointer to host adapter structure.
  875. * @process_aen: type of AENs to process
  876. *
  877. * Processes specific types of Asynchronous Events generated by firmware.
  878. * The type of AENs to process is specified by process_aen and can be
  879. * PROCESS_ALL_AENS 0
  880. * FLUSH_DDB_CHANGED_AENS 1
  881. * RELOGIN_DDB_CHANGED_AENS 2
  882. **/
  883. void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen)
  884. {
  885. uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
  886. struct aen *aen;
  887. int i;
  888. unsigned long flags;
  889. spin_lock_irqsave(&ha->hardware_lock, flags);
  890. while (ha->aen_out != ha->aen_in) {
  891. aen = &ha->aen_q[ha->aen_out];
  892. /* copy aen information to local structure */
  893. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  894. mbox_sts[i] = aen->mbox_sts[i];
  895. ha->aen_q_count++;
  896. ha->aen_out++;
  897. if (ha->aen_out == MAX_AEN_ENTRIES)
  898. ha->aen_out = 0;
  899. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  900. DEBUG2(printk("qla4xxx(%ld): AEN[%d]=0x%08x, mbx1=0x%08x mbx2=0x%08x"
  901. " mbx3=0x%08x mbx4=0x%08x\n", ha->host_no,
  902. (ha->aen_out ? (ha->aen_out-1): (MAX_AEN_ENTRIES-1)),
  903. mbox_sts[0], mbox_sts[1], mbox_sts[2],
  904. mbox_sts[3], mbox_sts[4]));
  905. switch (mbox_sts[0]) {
  906. case MBOX_ASTS_DATABASE_CHANGED:
  907. switch (process_aen) {
  908. case FLUSH_DDB_CHANGED_AENS:
  909. DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "
  910. "[%d] state=%04x FLUSHED!\n",
  911. ha->host_no, ha->aen_out,
  912. mbox_sts[0], mbox_sts[2],
  913. mbox_sts[3]));
  914. break;
  915. case PROCESS_ALL_AENS:
  916. default:
  917. /* Specific device. */
  918. if (mbox_sts[1] == 1)
  919. qla4xxx_process_ddb_changed(ha,
  920. mbox_sts[2], mbox_sts[3],
  921. mbox_sts[4]);
  922. break;
  923. }
  924. }
  925. spin_lock_irqsave(&ha->hardware_lock, flags);
  926. }
  927. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  928. }
  929. int qla4xxx_request_irqs(struct scsi_qla_host *ha)
  930. {
  931. int ret;
  932. if (!is_qla8022(ha))
  933. goto try_intx;
  934. if (ql4xenablemsix == 2)
  935. goto try_msi;
  936. if (ql4xenablemsix == 0 || ql4xenablemsix != 1)
  937. goto try_intx;
  938. /* Trying MSI-X */
  939. ret = qla4_8xxx_enable_msix(ha);
  940. if (!ret) {
  941. DEBUG2(ql4_printk(KERN_INFO, ha,
  942. "MSI-X: Enabled (0x%X).\n", ha->revision_id));
  943. goto irq_attached;
  944. }
  945. ql4_printk(KERN_WARNING, ha,
  946. "MSI-X: Falling back-to MSI mode -- %d.\n", ret);
  947. try_msi:
  948. /* Trying MSI */
  949. ret = pci_enable_msi(ha->pdev);
  950. if (!ret) {
  951. ret = request_irq(ha->pdev->irq, qla4_8xxx_msi_handler,
  952. 0, DRIVER_NAME, ha);
  953. if (!ret) {
  954. DEBUG2(ql4_printk(KERN_INFO, ha, "MSI: Enabled.\n"));
  955. set_bit(AF_MSI_ENABLED, &ha->flags);
  956. goto irq_attached;
  957. } else {
  958. ql4_printk(KERN_WARNING, ha,
  959. "MSI: Failed to reserve interrupt %d "
  960. "already in use.\n", ha->pdev->irq);
  961. pci_disable_msi(ha->pdev);
  962. }
  963. }
  964. ql4_printk(KERN_WARNING, ha,
  965. "MSI: Falling back-to INTx mode -- %d.\n", ret);
  966. try_intx:
  967. /* Trying INTx */
  968. ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler,
  969. IRQF_SHARED, DRIVER_NAME, ha);
  970. if (!ret) {
  971. DEBUG2(ql4_printk(KERN_INFO, ha, "INTx: Enabled.\n"));
  972. set_bit(AF_INTx_ENABLED, &ha->flags);
  973. goto irq_attached;
  974. } else {
  975. ql4_printk(KERN_WARNING, ha,
  976. "INTx: Failed to reserve interrupt %d already in"
  977. " use.\n", ha->pdev->irq);
  978. return ret;
  979. }
  980. irq_attached:
  981. set_bit(AF_IRQ_ATTACHED, &ha->flags);
  982. ha->host->irq = ha->pdev->irq;
  983. ql4_printk(KERN_INFO, ha, "%s: irq %d attached\n",
  984. __func__, ha->pdev->irq);
  985. return ret;
  986. }
  987. void qla4xxx_free_irqs(struct scsi_qla_host *ha)
  988. {
  989. if (test_bit(AF_MSIX_ENABLED, &ha->flags))
  990. qla4_8xxx_disable_msix(ha);
  991. else if (test_and_clear_bit(AF_MSI_ENABLED, &ha->flags)) {
  992. free_irq(ha->pdev->irq, ha);
  993. pci_disable_msi(ha->pdev);
  994. } else if (test_and_clear_bit(AF_INTx_ENABLED, &ha->flags))
  995. free_irq(ha->pdev->irq, ha);
  996. }