drivers/message/fusion/mptscsih.c
Source file repositories/reference/linux-study-clean/drivers/message/fusion/mptscsih.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/message/fusion/mptscsih.c- Extension
.c- Size
- 92708 bytes
- Lines
- 3260
- Domain
- Driver Families
- Bucket
- drivers/message
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/kernel.hlinux/slab.hlinux/init.hlinux/errno.hlinux/kdev_t.hlinux/blkdev.hlinux/delay.hlinux/interrupt.hlinux/reboot.hlinux/workqueue.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_tcq.hscsi/scsi_dbg.hmptbase.hmptscsih.hlsi/mpi_log_sas.h
Detected Declarations
function mptscsih_getFreeChainBufferfunction mptscsih_AddSGEfunction mptscsih_issue_sep_commandfunction mptscsih_info_scsiiofunction MPTfunction mptscsih_flush_running_cmdsfunction mptscsih_search_running_cmdsfunction printkfunction mptscsih_removefunction mptscsih_shutdownfunction mptscsih_resumefunction mptscsih_infofunction mptscsih_show_infofunction mptscsih_qcmdfunction bufferfunction mptscsih_freeChainBuffersfunction mptscsih_IssueTaskMgmtfunction CLEAR_MGMT_STATUSfunction mptscsih_get_tm_timeoutfunction mptscsih_abortfunction mptscsih_dev_resetfunction mptscsih_bus_resetfunction mptscsih_host_resetfunction mptscsih_taskmgmt_replyfunction mptscsih_taskmgmt_response_codefunction MPTfunction mptscsih_bios_paramfunction mptscsih_is_phys_diskfunction mptscsih_raid_id_to_numfunction mptscsih_sdev_destroyfunction mptscsih_change_queue_depthfunction mptscsih_sdev_configurefunction mptscsih_copy_sense_datafunction mptscsih_get_scsi_lookupfunction mptscsih_getclear_scsi_lookupfunction mptscsih_set_scsi_lookupfunction SCPNT_TO_LOOKUP_IDXfunction mptscsih_ioc_resetfunction mptscsih_event_processfunction MPTfunction mptscsih_get_completion_codefunction mptscsih_do_cmdfunction mptscsih_synchronize_cachefunction mptscsih_version_fw_showfunction mptscsih_version_bios_showfunction mptscsih_version_mpi_showfunction mptscsih_version_product_showfunction mptscsih_version_nvdata_persistent_show
Annotated Snippet
if (thisxfer == 0) {
/* Get next SG element from the OS */
sg = sg_next(sg);
sg_done++;
continue;
}
v2 = sg_dma_address(sg);
ioc->add_sge(psge, sgflags | thisxfer, v2);
/* Get next SG element from the OS */
sg = sg_next(sg);
psge += ioc->SGE_size;
sgeOffset += ioc->SGE_size;
sg_done++;
}
if (numSgeThisFrame == sges_left) {
/* Add last element, end of buffer and end of list flags.
*/
sgflags |= MPT_SGE_FLAGS_LAST_ELEMENT |
MPT_SGE_FLAGS_END_OF_BUFFER |
MPT_SGE_FLAGS_END_OF_LIST;
/* Add last SGE and set termination flags.
* Note: Last SGE may have a length of 0 - which should be ok.
*/
thisxfer = sg_dma_len(sg);
v2 = sg_dma_address(sg);
ioc->add_sge(psge, sgflags | thisxfer, v2);
sgeOffset += ioc->SGE_size;
sg_done++;
if (chainSge) {
/* The current buffer is a chain buffer,
* but there is not another one.
* Update the chain element
* Offset and Length fields.
*/
ioc->add_chain((char *)chainSge, 0, sgeOffset,
ioc->ChainBufferDMA + chain_dma_off);
} else {
/* The current buffer is the original MF
* and there is no Chain buffer.
*/
pReq->ChainOffset = 0;
RequestNB = (((sgeOffset - 1) >> ioc->NBShiftFactor) + 1) & 0x03;
dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT
"Single Buffer RequestNB=%x, sgeOffset=%d\n", ioc->name, RequestNB, sgeOffset));
ioc->RequestNB[req_idx] = RequestNB;
}
} else {
/* At least one chain buffer is needed.
* Complete the first MF
* - last SGE element, set the LastElement bit
* - set ChainOffset (words) for orig MF
* (OR finish previous MF chain buffer)
* - update MFStructPtr ChainIndex
* - Populate chain element
* Also
* Loop until done.
*/
dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SG: Chain Required! sg done %d\n",
ioc->name, sg_done));
/* Set LAST_ELEMENT flag for last non-chain element
* in the buffer. Since psge points at the NEXT
* SGE element, go back one SGE element, update the flags
* and reset the pointer. (Note: sgflags & thisxfer are already
* set properly).
*/
if (sg_done) {
u32 *ptmp = (u32 *) (psge - ioc->SGE_size);
sgflags = le32_to_cpu(*ptmp);
sgflags |= MPT_SGE_FLAGS_LAST_ELEMENT;
*ptmp = cpu_to_le32(sgflags);
}
if (chainSge) {
/* The current buffer is a chain buffer.
* chainSge points to the previous Chain Element.
* Update its chain element Offset and Length (must
* include chain element size) fields.
* Old chain element is now complete.
*/
u8 nextChain = (u8) (sgeOffset >> 2);
sgeOffset += ioc->SGE_size;
ioc->add_chain((char *)chainSge, nextChain, sgeOffset,
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/init.h`, `linux/errno.h`, `linux/kdev_t.h`, `linux/blkdev.h`, `linux/delay.h`.
- Detected declarations: `function mptscsih_getFreeChainBuffer`, `function mptscsih_AddSGE`, `function mptscsih_issue_sep_command`, `function mptscsih_info_scsiio`, `function MPT`, `function mptscsih_flush_running_cmds`, `function mptscsih_search_running_cmds`, `function printk`, `function mptscsih_remove`, `function mptscsih_shutdown`.
- Atlas domain: Driver Families / drivers/message.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.