drivers/scsi/mpi3mr/mpi3mr_fw.c
Source file repositories/reference/linux-study-clean/drivers/scsi/mpi3mr/mpi3mr_fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/mpi3mr/mpi3mr_fw.c- Extension
.c- Size
- 198755 bytes
- Lines
- 6602
- 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
mpi3mr.hlinux/io-64-nonatomic-lo-hi.h
Detected Declarations
function mpi3mr_writeqfunction mpi3mr_writeqfunction mpi3mr_check_req_qfullfunction mpi3mr_sync_irqsfunction mpi3mr_ioc_disable_intrfunction mpi3mr_ioc_enable_intrfunction mpi3mr_cleanup_isrfunction mpi3mr_add_sg_singlefunction mpi3mr_build_zero_len_sgefunction mpi3mr_repost_reply_buffunction mpi3mr_repost_sense_buffunction mpi3mr_print_event_datafunction mpi3mr_handle_eventsfunction mpi3mr_get_drv_cmdfunction mpi3mr_process_admin_reply_descfunction mpi3mr_process_admin_reply_qfunction mpi3mr_get_reply_descfunction mpi3mr_process_op_reply_qfunction mpi3mr_blk_mq_pollfunction mpi3mr_isr_primaryfunction mpi3mr_isrfunction mpi3mr_isr_pollfunction mpi3mr_request_irqfunction mpi3mr_calc_poll_queuesfunction mpi3mr_setup_isrfunction mpi3mr_is_fault_recoverablefunction mpi3mr_print_fault_infofunction mpi3mr_save_fault_infofunction mpi3mr_get_iocstatefunction mpi3mr_free_ioctl_dma_memoryfunction mpi3mr_alloc_ioctl_dma_memoryfunction mpi3mr_fault_uevent_emitfunction mpi3mr_clear_reset_historyfunction mpi3mr_issue_and_process_murfunction mpi3mr_revalidate_factsdatafunction mpi3mr_bring_ioc_readyfunction mpi3mr_soft_reset_successfunction mpi3mr_diagfault_successfunction mpi3mr_set_diagsavefunction mpi3mr_issue_resetfunction mpi3mr_admin_request_postfunction mpi3mr_free_op_req_q_segmentsfunction mpi3mr_free_op_reply_q_segmentsfunction mpi3mr_delete_op_reply_qfunction mpi3mr_alloc_op_reply_q_segmentsfunction mpi3mr_alloc_op_req_q_segmentsfunction mpi3mr_create_op_reply_qfunction mpi3mr_create_op_req_q
Annotated Snippet
if (def_reply->function == MPI3_FUNCTION_SCSI_IO) {
scsi_reply = (struct mpi3_scsi_io_reply *)def_reply;
sense_buf = mpi3mr_get_sensebuf_virt_addr(mrioc,
le64_to_cpu(scsi_reply->sense_data_buffer_address));
sense_count = le32_to_cpu(scsi_reply->sense_count);
if (sense_buf) {
scsi_normalize_sense(sense_buf, sense_count,
&sshdr);
mpi3mr_scsisense_trigger(mrioc, sshdr.sense_key,
sshdr.asc, sshdr.ascq);
}
}
mpi3mr_reply_trigger(mrioc, masked_ioc_status, ioc_loginfo);
break;
case MPI3_REPLY_DESCRIPT_FLAGS_TYPE_SUCCESS:
success_desc = (struct mpi3_success_reply_descriptor *)reply_desc;
host_tag = le16_to_cpu(success_desc->host_tag);
break;
default:
break;
}
cmdptr = mpi3mr_get_drv_cmd(mrioc, host_tag, def_reply);
if (cmdptr) {
if (cmdptr->state & MPI3MR_CMD_PENDING) {
cmdptr->state |= MPI3MR_CMD_COMPLETE;
cmdptr->ioc_loginfo = ioc_loginfo;
if (host_tag == MPI3MR_HOSTTAG_BSG_CMDS)
cmdptr->ioc_status = ioc_status;
else
cmdptr->ioc_status = masked_ioc_status;
cmdptr->state &= ~MPI3MR_CMD_PENDING;
if (def_reply) {
cmdptr->state |= MPI3MR_CMD_REPLY_VALID;
memcpy((u8 *)cmdptr->reply, (u8 *)def_reply,
mrioc->reply_sz);
}
if (sense_buf && cmdptr->sensebuf) {
cmdptr->is_sense = 1;
memcpy(cmdptr->sensebuf, sense_buf,
MPI3MR_SENSE_BUF_SZ);
}
if (cmdptr->is_waiting) {
cmdptr->is_waiting = 0;
complete(&cmdptr->done);
} else if (cmdptr->callback)
cmdptr->callback(mrioc, cmdptr);
}
}
out:
if (sense_buf)
mpi3mr_repost_sense_buf(mrioc,
le64_to_cpu(scsi_reply->sense_data_buffer_address));
}
int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc)
{
u32 exp_phase = mrioc->admin_reply_ephase;
u32 admin_reply_ci = mrioc->admin_reply_ci;
u32 num_admin_replies = 0;
u64 reply_dma = 0;
u16 threshold_comps = 0;
struct mpi3_default_reply_descriptor *reply_desc;
if (!atomic_add_unless(&mrioc->admin_reply_q_in_use, 1, 1)) {
atomic_inc(&mrioc->admin_pend_isr);
return 0;
}
atomic_set(&mrioc->admin_pend_isr, 0);
reply_desc = (struct mpi3_default_reply_descriptor *)mrioc->admin_reply_base +
admin_reply_ci;
if ((le16_to_cpu(reply_desc->reply_flags) &
MPI3_REPLY_DESCRIPT_FLAGS_PHASE_MASK) != exp_phase) {
atomic_dec(&mrioc->admin_reply_q_in_use);
return 0;
}
do {
if (mrioc->unrecoverable || mrioc->io_admin_reset_sync)
break;
mrioc->admin_req_ci = le16_to_cpu(reply_desc->request_queue_ci);
mpi3mr_process_admin_reply_desc(mrioc, reply_desc, &reply_dma);
if (reply_dma)
mpi3mr_repost_reply_buf(mrioc, reply_dma);
num_admin_replies++;
threshold_comps++;
if (++admin_reply_ci == mrioc->num_admin_replies) {
Annotation
- Immediate include surface: `mpi3mr.h`, `linux/io-64-nonatomic-lo-hi.h`.
- Detected declarations: `function mpi3mr_writeq`, `function mpi3mr_writeq`, `function mpi3mr_check_req_qfull`, `function mpi3mr_sync_irqs`, `function mpi3mr_ioc_disable_intr`, `function mpi3mr_ioc_enable_intr`, `function mpi3mr_cleanup_isr`, `function mpi3mr_add_sg_single`, `function mpi3mr_build_zero_len_sge`, `function mpi3mr_repost_reply_buf`.
- 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.