drivers/scsi/mpt3sas/mpt3sas_base.c
Source file repositories/reference/linux-study-clean/drivers/scsi/mpt3sas/mpt3sas_base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/mpt3sas/mpt3sas_base.c- Extension
.c- Size
- 260699 bytes
- Lines
- 9043
- 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/kernel.hlinux/module.hlinux/errno.hlinux/init.hlinux/slab.hlinux/types.hlinux/pci.hlinux/kdev_t.hlinux/blkdev.hlinux/delay.hlinux/interrupt.hlinux/dma-mapping.hlinux/io.hlinux/time.hlinux/ktime.hlinux/kthread.hasm/page.hmpt3sas_base.h
Detected Declarations
enum mpt3sas_perf_modefunction mpt3sas_base_check_cmd_timeoutfunction _scsih_set_fwfault_debugfunction readlfunction _base_readl_ext_retryfunction _base_readlfunction _base_clone_reply_to_sys_memfunction _base_clone_mpi_to_sys_memfunction _base_clone_to_sys_memfunction _base_get_chainfunction _base_get_chain_physfunction _base_get_buffer_bar0function _base_get_buffer_phys_bar0function _base_get_chain_buffer_dma_to_chain_bufferfunction _clone_sg_entriesfunction mpt3sas_remove_dead_ioc_funcfunction _base_sync_drv_fw_timestampfunction _base_fault_reset_workfunction mpt3sas_base_start_watchdogfunction mpt3sas_base_stop_watchdogfunction mpt3sas_base_fault_infofunction mpt3sas_base_coredump_infofunction mpt3sas_base_wait_for_coredump_completionfunction mpt3sas_halt_firmwarefunction _base_sas_ioc_infofunction _base_display_event_datafunction _base_sas_log_infofunction _base_display_reply_infofunction mpt3sas_base_donefunction _base_async_eventfunction _get_st_from_smidfunction _base_get_cb_idxfunction pollfunction mpt3sas_base_resume_mq_pollingfunction mpt3sas_base_mask_interruptsfunction mpt3sas_base_unmask_interruptsfunction base_mod64function _base_process_reply_queuefunction mpt3sas_blk_mq_pollfunction _base_interruptfunction _base_irqpollfunction _base_init_irqpollsfunction list_for_each_entry_safefunction _base_is_controller_msix_enabledfunction mpt3sas_base_sync_reply_irqsfunction list_for_each_entryfunction mpt3sas_base_release_callback_handlerfunction mpt3sas_base_register_callback_handler
Annotated Snippet
if (scmd == NULL) {
ioc_err(ioc, "scmd is NULL\n");
return;
}
/* Get sg_scmd from scmd provided */
sg_scmd = scsi_sglist(scmd);
}
/*
* 0 - 255 System register
* 256 - 4352 MPI Frame. (This is based on maxCredit 32)
* 4352 - 4864 Reply_free pool (512 byte is reserved
* considering maxCredit 32. Reply need extra
* room, for mCPU case kept four times of
* maxCredit).
* 4864 - 17152 SGE chain element. (32cmd * 3 chain of
* 128 byte size = 12288)
* 17152 - x Host buffer mapped with smid.
* (Each smid can have 64K Max IO.)
* BAR0+Last 1K MSIX Addr and Data
* Total size in use 2113664 bytes of 4MB BAR0
*/
buffer_iomem = _base_get_buffer_bar0(ioc, smid);
buffer_iomem_phys = _base_get_buffer_phys_bar0(ioc, smid);
buff_ptr = buffer_iomem;
buff_ptr_phys = buffer_iomem_phys;
WARN_ON(buff_ptr_phys > U32_MAX);
if (le32_to_cpu(sgel->FlagsLength) &
(MPI2_SGE_FLAGS_HOST_TO_IOC << MPI2_SGE_FLAGS_SHIFT))
is_write = true;
for (i = 0; i < MPT_MIN_PHYS_SEGMENTS + ioc->facts.MaxChainDepth; i++) {
sgl_flags =
(le32_to_cpu(sgel->FlagsLength) >> MPI2_SGE_FLAGS_SHIFT);
switch (sgl_flags & MPI2_SGE_FLAGS_ELEMENT_MASK) {
case MPI2_SGE_FLAGS_CHAIN_ELEMENT:
/*
* Helper function which on passing
* chain_buffer_dma returns chain_buffer. Get
* the virtual address for sgel->Address
*/
sgel_next =
_base_get_chain_buffer_dma_to_chain_buffer(ioc,
le32_to_cpu(sgel->Address));
if (sgel_next == NULL)
return;
/*
* This is coping 128 byte chain
* frame (not a host buffer)
*/
dst_chain_addr[sge_chain_count] =
_base_get_chain(ioc,
smid, sge_chain_count);
src_chain_addr[sge_chain_count] =
(void *) sgel_next;
dst_addr_phys = _base_get_chain_phys(ioc,
smid, sge_chain_count);
WARN_ON(dst_addr_phys > U32_MAX);
sgel->Address =
cpu_to_le32(lower_32_bits(dst_addr_phys));
sgel = sgel_next;
sge_chain_count++;
break;
case MPI2_SGE_FLAGS_SIMPLE_ELEMENT:
if (is_write) {
if (is_scsiio_req) {
_base_clone_to_sys_mem(buff_ptr,
sg_virt(sg_scmd),
(le32_to_cpu(sgel->FlagsLength) &
0x00ffffff));
/*
* FIXME: this relies on a a zero
* PCI mem_offset.
*/
sgel->Address =
cpu_to_le32((u32)buff_ptr_phys);
} else {
_base_clone_to_sys_mem(buff_ptr,
ioc->config_vaddr,
(le32_to_cpu(sgel->FlagsLength) &
0x00ffffff));
sgel->Address =
cpu_to_le32((u32)buff_ptr_phys);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/errno.h`, `linux/init.h`, `linux/slab.h`, `linux/types.h`, `linux/pci.h`, `linux/kdev_t.h`.
- Detected declarations: `enum mpt3sas_perf_mode`, `function mpt3sas_base_check_cmd_timeout`, `function _scsih_set_fwfault_debug`, `function readl`, `function _base_readl_ext_retry`, `function _base_readl`, `function _base_clone_reply_to_sys_mem`, `function _base_clone_mpi_to_sys_mem`, `function _base_clone_to_sys_mem`, `function _base_get_chain`.
- 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.