drivers/scsi/megaraid/megaraid_sas_fusion.c
Source file repositories/reference/linux-study-clean/drivers/scsi/megaraid/megaraid_sas_fusion.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/megaraid/megaraid_sas_fusion.c- Extension
.c- Size
- 159289 bytes
- Lines
- 5389
- 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/types.hlinux/pci.hlinux/list.hlinux/moduleparam.hlinux/module.hlinux/spinlock.hlinux/interrupt.hlinux/delay.hlinux/uio.hlinux/uaccess.hlinux/fs.hlinux/compat.hlinux/blkdev.hlinux/mutex.hlinux/poll.hlinux/vmalloc.hlinux/workqueue.hlinux/irq_poll.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_dbg.hlinux/dmi.hmegaraid_sas_fusion.hmegaraid_sas.h
Detected Declarations
function megasas_adp_reset_wait_for_readyfunction megasas_check_same_4gb_regionfunction megasas_enable_intr_fusionfunction megasas_disable_intr_fusionfunction megasas_clear_intr_fusionfunction megasas_sdev_busy_incfunction megasas_sdev_busy_decfunction megasas_sdev_busy_readfunction megasas_return_cmd_fusionfunction megasas_write_64bit_req_descfunction megasas_fire_cmd_fusionfunction megasas_fusion_update_can_queuefunction megasas_get_msix_indexfunction megasas_free_cmds_fusionfunction megasas_create_sg_sense_fusionfunction megasas_alloc_cmdlist_fusionfunction megasas_alloc_request_fusionfunction megasas_alloc_reply_fusionfunction megasas_alloc_rdpq_fusionfunction megasas_free_rdpq_fusionfunction megasas_free_reply_fusionfunction megasas_alloc_cmds_fusionfunction wait_and_pollfunction megasas_ioc_init_fusionfunction megasas_sync_pd_seq_numfunction commandfunction megasas_get_map_infofunction commandfunction megasas_display_intel_brandingfunction megasas_allocate_raid_mapsfunction megasas_configure_queue_sizesfunction megasas_alloc_ioc_init_framefunction megasas_free_ioc_init_cmdfunction megasas_init_adapter_fusionfunction megasas_fault_detect_workfunction megasas_fusion_start_watchdogfunction megasas_fusion_stop_watchdogfunction map_cmd_statusfunction megasas_is_prp_possiblefunction pagefunction PRPsfunction megasas_make_sgl_fusionfunction scsi_for_each_sgfunction megasas_make_sglfunction megasas_set_pd_lbafunction megasas_stream_detectfunction affinityfunction elements
Annotated Snippet
if (cur_max_fw_cmds < instance->max_fw_cmds) {
instance->cur_can_queue =
cur_max_fw_cmds - (MEGASAS_FUSION_INTERNAL_CMDS +
MEGASAS_FUSION_IOCTL_CMDS);
instance->host->can_queue = instance->cur_can_queue;
instance->ldio_threshold = ldio_threshold;
}
} else {
instance->max_fw_cmds = cur_max_fw_cmds;
instance->ldio_threshold = ldio_threshold;
if (reset_devices)
instance->max_fw_cmds = min(instance->max_fw_cmds,
(u16)MEGASAS_KDUMP_QUEUE_DEPTH);
/*
* Reduce the max supported cmds by 1. This is to ensure that the
* reply_q_sz (1 more than the max cmd that driver may send)
* does not exceed max cmds that the FW can support
*/
instance->max_fw_cmds = instance->max_fw_cmds-1;
}
}
static inline void
megasas_get_msix_index(struct megasas_instance *instance,
struct scsi_cmnd *scmd,
struct megasas_cmd_fusion *cmd,
u8 data_arms)
{
if (instance->perf_mode == MR_BALANCED_PERF_MODE &&
(megasas_sdev_busy_read(instance, scmd) >
(data_arms * MR_DEVICE_HIGH_IOPS_DEPTH))) {
cmd->request_desc->SCSIIO.MSIxIndex =
mega_mod64((atomic64_add_return(1, &instance->high_iops_outstanding) /
MR_HIGH_IOPS_BATCH_COUNT), instance->low_latency_index_start);
} else if (instance->msix_load_balance) {
cmd->request_desc->SCSIIO.MSIxIndex =
(mega_mod64(atomic64_add_return(1, &instance->total_io_count),
instance->msix_vectors));
} else if (instance->host->nr_hw_queues > 1) {
u32 tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
cmd->request_desc->SCSIIO.MSIxIndex = blk_mq_unique_tag_to_hwq(tag) +
instance->low_latency_index_start;
} else {
cmd->request_desc->SCSIIO.MSIxIndex =
instance->reply_map[raw_smp_processor_id()];
}
}
/**
* megasas_free_cmds_fusion - Free all the cmds in the free cmd pool
* @instance: Adapter soft state
*/
void
megasas_free_cmds_fusion(struct megasas_instance *instance)
{
int i;
struct fusion_context *fusion = instance->ctrl_context;
struct megasas_cmd_fusion *cmd;
if (fusion->sense)
dma_pool_free(fusion->sense_dma_pool, fusion->sense,
fusion->sense_phys_addr);
/* SG */
if (fusion->cmd_list) {
for (i = 0; i < instance->max_mpt_cmds; i++) {
cmd = fusion->cmd_list[i];
if (cmd) {
if (cmd->sg_frame)
dma_pool_free(fusion->sg_dma_pool,
cmd->sg_frame,
cmd->sg_frame_phys_addr);
}
kfree(cmd);
}
kfree(fusion->cmd_list);
}
if (fusion->sg_dma_pool) {
dma_pool_destroy(fusion->sg_dma_pool);
fusion->sg_dma_pool = NULL;
}
if (fusion->sense_dma_pool) {
dma_pool_destroy(fusion->sense_dma_pool);
fusion->sense_dma_pool = NULL;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/pci.h`, `linux/list.h`, `linux/moduleparam.h`, `linux/module.h`, `linux/spinlock.h`, `linux/interrupt.h`.
- Detected declarations: `function megasas_adp_reset_wait_for_ready`, `function megasas_check_same_4gb_region`, `function megasas_enable_intr_fusion`, `function megasas_disable_intr_fusion`, `function megasas_clear_intr_fusion`, `function megasas_sdev_busy_inc`, `function megasas_sdev_busy_dec`, `function megasas_sdev_busy_read`, `function megasas_return_cmd_fusion`, `function megasas_write_64bit_req_desc`.
- 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.