drivers/scsi/megaraid/megaraid_mbox.c
Source file repositories/reference/linux-study-clean/drivers/scsi/megaraid/megaraid_mbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/megaraid/megaraid_mbox.c- Extension
.c- Size
- 99873 bytes
- Lines
- 4070
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/slab.hlinux/module.hmegaraid_mbox.h
Detected Declarations
function megaraid_initfunction megaraid_exitfunction megaraid_probe_onefunction megaraid_detach_onefunction megaraid_mbox_shutdownfunction megaraid_io_attachfunction megaraid_io_detachfunction megaraid_init_mboxfunction megaraid_fini_mboxfunction megaraid_alloc_cmd_packetsfunction megaraid_free_cmd_packetsfunction megaraid_mbox_setup_dma_poolsfunction megaraid_mbox_teardown_dma_poolsfunction megaraid_alloc_scbfunction megaraid_dealloc_scbfunction megaraid_mbox_mksglfunction scsi_for_each_sgfunction mbox_post_cmdfunction megaraid_queue_command_lckfunction DEF_SCSI_QCMDfunction megaraid_mbox_runpendqfunction megaraid_mbox_prepare_pthrufunction CDBsfunction megaraid_ack_sequencefunction megaraid_isrfunction megaraid_mbox_dpcfunction list_for_each_entry_safefunction megaraid_abort_handlerfunction relinquishfunction mbox_post_sync_cmdfunction mbox_post_sync_cmd_fastfunction megaraid_busywait_mboxfunction megaraid_mbox_product_infofunction megaraid_mbox_extended_cdbfunction megaraid_mbox_support_hafunction megaraid_mbox_support_random_delfunction megaraid_mbox_get_max_sgfunction megaraid_mbox_enum_raid_scsifunction megaraid_mbox_flush_cachefunction megaraid_mbox_fire_sync_cmdfunction megaraid_mbox_display_scbfunction megaraid_mbox_setup_device_mapfunction megaraid_cmm_registerfunction megaraid_cmm_unregisterfunction Modulefunction megaraid_mbox_mm_commandfunction wait_till_fw_emptyfunction megaraid_mbox_mm_done
Annotated Snippet
static struct pci_driver megaraid_pci_driver = {
.name = "megaraid",
.id_table = pci_id_table_g,
.probe = megaraid_probe_one,
.remove = megaraid_detach_one,
.shutdown = megaraid_mbox_shutdown,
};
// definitions for the device attributes for exporting logical drive number
// for a scsi address (Host, Channel, Id, Lun)
static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_app_hndl);
// Host template initializer for megaraid mbox sysfs device attributes
static struct attribute *megaraid_shost_attrs[] = {
&dev_attr_megaraid_mbox_app_hndl.attr,
NULL,
};
ATTRIBUTE_GROUPS(megaraid_shost);
static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_ld);
// Host template initializer for megaraid mbox sysfs device attributes
static struct attribute *megaraid_sdev_attrs[] = {
&dev_attr_megaraid_mbox_ld.attr,
NULL,
};
ATTRIBUTE_GROUPS(megaraid_sdev);
/*
* Scsi host template for megaraid unified driver
*/
static const struct scsi_host_template megaraid_template_g = {
.module = THIS_MODULE,
.name = "LSI Logic MegaRAID driver",
.proc_name = "megaraid",
.queuecommand = megaraid_queue_command,
.eh_abort_handler = megaraid_abort_handler,
.eh_host_reset_handler = megaraid_reset_handler,
.change_queue_depth = scsi_change_queue_depth,
.no_write_same = 1,
.sdev_groups = megaraid_sdev_groups,
.shost_groups = megaraid_shost_groups,
};
/**
* megaraid_init - module load hook
*
* We register ourselves as hotplug enabled module and let PCI subsystem
* discover our adapters.
*/
static int __init
megaraid_init(void)
{
int rval;
// Announce the driver version
con_log(CL_ANN, (KERN_INFO "megaraid: %s %s\n", MEGARAID_VERSION,
MEGARAID_EXT_VERSION));
// check validity of module parameters
if (megaraid_cmd_per_lun > MBOX_MAX_SCSI_CMDS) {
con_log(CL_ANN, (KERN_WARNING
"megaraid mailbox: max commands per lun reset to %d\n",
MBOX_MAX_SCSI_CMDS));
megaraid_cmd_per_lun = MBOX_MAX_SCSI_CMDS;
}
// register as a PCI hot-plug driver module
rval = pci_register_driver(&megaraid_pci_driver);
if (rval < 0) {
con_log(CL_ANN, (KERN_WARNING
"megaraid: could not register hotplug support.\n"));
}
return rval;
}
/**
* megaraid_exit - driver unload entry point
*
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `megaraid_mbox.h`.
- Detected declarations: `function megaraid_init`, `function megaraid_exit`, `function megaraid_probe_one`, `function megaraid_detach_one`, `function megaraid_mbox_shutdown`, `function megaraid_io_attach`, `function megaraid_io_detach`, `function megaraid_init_mbox`, `function megaraid_fini_mbox`, `function megaraid_alloc_cmd_packets`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern 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.