drivers/scsi/qla4xxx/ql4_mbx.c
Source file repositories/reference/linux-study-clean/drivers/scsi/qla4xxx/ql4_mbx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/qla4xxx/ql4_mbx.c- Extension
.c- Size
- 73130 bytes
- Lines
- 2459
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ctype.hql4_def.hql4_glbl.hql4_dbg.hql4_inline.hql4_version.h
Detected Declarations
function Copyrightfunction qla4xxx_process_mbox_intrfunction qla4xxx_is_intr_poll_modefunction qla4xxx_mailbox_commandfunction qla4xxx_get_minidump_templatefunction qla4xxx_req_template_sizefunction qla4xxx_mailbox_premature_completionfunction qla4xxx_set_ifcbfunction qla4xxx_get_ifcbfunction qla4xxx_set_ipaddr_statefunction qla4xxx_update_local_ipfunction qla4xxx_update_local_ifcbfunction qla4xxx_initialize_fw_cbfunction qla4xxx_get_dhcp_ip_addressfunction qla4xxx_get_firmware_statefunction qla4xxx_get_firmware_statusfunction qla4xxx_get_fwddb_entryfunction qla4xxx_conn_openfunction qla4xxx_set_ddb_entryfunction qla4xxx_session_logout_ddbfunction qla4xxx_get_crash_recordfunction qla4xxx_get_conn_event_logfunction qla4xxx_abort_taskfunction qla4xxx_reset_lunfunction qla4xxx_reset_targetfunction qla4xxx_get_flashfunction qla4xxx_about_firmwarefunction qla4xxx_get_default_ddbfunction qla4xxx_req_ddb_entryfunction qla4xxx_clear_ddb_entryfunction qla4xxx_set_flashfunction qla4xxx_bootdb_by_indexfunction qla4xxx_flashdb_by_indexfunction qla4xxx_get_chapfunction qla4xxx_set_chapfunction qla4xxx_get_uni_chap_at_indexfunction qla4xxx_get_chap_indexfunction qla4xxx_conn_close_sess_logoutfunction qla4_84xx_extend_idc_tmofunction qla4xxx_disable_acbfunction qla4xxx_get_acbfunction qla4xxx_set_acbfunction qla4xxx_set_param_ddbentryfunction qla4xxx_get_mgmt_datafunction qla4xxx_get_ip_statefunction qla4xxx_get_nvramfunction qla4xxx_set_nvramfunction qla4xxx_restore_factory_defaults
Annotated Snippet
if (test_bit(AF_HA_REMOVAL, &ha->flags)) {
DEBUG2(ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: "
"prematurely completing mbx cmd as "
"adapter removal detected\n",
ha->host_no, __func__));
return status;
}
}
if ((is_aer_supported(ha)) &&
(test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags))) {
DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Perm failure on EEH, "
"timeout MBX Exiting.\n", ha->host_no, __func__));
return status;
}
/* Mailbox code active */
wait_count = MBOX_TOV * 100;
while (wait_count--) {
mutex_lock(&ha->mbox_sem);
if (!test_bit(AF_MBOX_COMMAND, &ha->flags)) {
set_bit(AF_MBOX_COMMAND, &ha->flags);
mutex_unlock(&ha->mbox_sem);
break;
}
mutex_unlock(&ha->mbox_sem);
if (!wait_count) {
DEBUG2(printk("scsi%ld: %s: mbox_sem failed\n",
ha->host_no, __func__));
return status;
}
msleep(10);
}
if (is_qla80XX(ha)) {
if (test_bit(AF_FW_RECOVERY, &ha->flags)) {
DEBUG2(ql4_printk(KERN_WARNING, ha,
"scsi%ld: %s: prematurely completing mbx cmd as firmware recovery detected\n",
ha->host_no, __func__));
goto mbox_exit;
}
/* Do not send any mbx cmd if h/w is in failed state*/
ha->isp_ops->idc_lock(ha);
dev_state = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE);
ha->isp_ops->idc_unlock(ha);
if (dev_state == QLA8XXX_DEV_FAILED) {
ql4_printk(KERN_WARNING, ha,
"scsi%ld: %s: H/W is in failed state, do not send any mailbox commands\n",
ha->host_no, __func__);
goto mbox_exit;
}
}
spin_lock_irqsave(&ha->hardware_lock, flags);
ha->mbox_status_count = outCount;
for (i = 0; i < outCount; i++)
ha->mbox_status[i] = 0;
/* Queue the mailbox command to the firmware */
ha->isp_ops->queue_mailbox_command(ha, mbx_cmd, inCount);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
/* Wait for completion */
/*
* If we don't want status, don't wait for the mailbox command to
* complete. For example, MBOX_CMD_RESET_FW doesn't return status,
* you must poll the inbound Interrupt Mask for completion.
*/
if (outCount == 0) {
status = QLA_SUCCESS;
goto mbox_exit;
}
/*
* Wait for completion: Poll or completion queue
*/
if (qla4xxx_is_intr_poll_mode(ha)) {
/* Poll for command to complete */
wait_count = jiffies + MBOX_TOV * HZ;
while (test_bit(AF_MBOX_COMMAND_DONE, &ha->flags) == 0) {
if (time_after_eq(jiffies, wait_count))
break;
/*
* Service the interrupt.
* The ISR will save the mailbox status registers
* to a temporary storage location in the adapter
Annotation
- Immediate include surface: `linux/ctype.h`, `ql4_def.h`, `ql4_glbl.h`, `ql4_dbg.h`, `ql4_inline.h`, `ql4_version.h`.
- Detected declarations: `function Copyright`, `function qla4xxx_process_mbox_intr`, `function qla4xxx_is_intr_poll_mode`, `function qla4xxx_mailbox_command`, `function qla4xxx_get_minidump_template`, `function qla4xxx_req_template_size`, `function qla4xxx_mailbox_premature_completion`, `function qla4xxx_set_ifcb`, `function qla4xxx_get_ifcb`, `function qla4xxx_set_ipaddr_state`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.