drivers/scsi/mpt3sas/mpt3sas_ctl.c
Source file repositories/reference/linux-study-clean/drivers/scsi/mpt3sas/mpt3sas_ctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/mpt3sas/mpt3sas_ctl.c- Extension
.c- Size
- 127810 bytes
- Lines
- 4519
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/delay.hlinux/compat.hlinux/poll.hlinux/io.hlinux/uaccess.hmpt3sas_base.hmpt3sas_ctl.h
Detected Declarations
struct DIAG_BUFFER_STARTenum block_statefunction _ctl_display_some_debugfunction mpt3sas_ctl_donefunction _ctl_check_event_typefunction mpt3sas_ctl_add_to_event_logfunction mpt3sas_ctl_event_callbackfunction _ctl_verify_adapterfunction mpt3sas_ctl_pre_reset_handlerfunction mpt3sas_ctl_clear_outstanding_ioctlsfunction mpt3sas_ctl_reset_done_handlerfunction _ctl_fasyncfunction _ctl_pollfunction _ctl_set_task_midfunction _ctl_send_mctp_passthru_reqfunction _ctl_do_mpt_commandfunction _ctl_getiocinfofunction _ctl_eventqueryfunction _ctl_eventenablefunction _ctl_eventreportfunction _ctl_do_resetfunction _ctl_btdh_search_sas_devicefunction _ctl_btdh_search_pcie_devicefunction _ctl_btdh_search_raid_devicefunction _ctl_btdh_mappingfunction _ctl_diag_capabilityfunction _ctl_diag_get_bufftypefunction _ctl_diag_register_2function mpt3sas_enable_diag_bufferfunction _ctl_diag_registerfunction _ctl_diag_unregisterfunction _ctl_diag_queryfunction mpt3sas_send_diag_releasefunction _ctl_diag_releasefunction _ctl_diag_read_bufferfunction _ctl_addnl_diag_queryfunction _ctl_enable_diag_sbr_reloadfunction _ctl_compat_mpt_commandfunction _ctl_ioctl_mainfunction _ctl_get_mpt_mctp_passthru_adapterfunction mpt3sas_get_device_countfunction mpt3sas_send_mctp_passthru_reqfunction _ctl_ioctlfunction _ctl_mpt2_ioctlfunction _ctl_ioctl_compatfunction _ctl_mpt2_ioctl_compatfunction version_fw_showfunction version_bios_show
Annotated Snippet
static const struct file_operations ctl_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = _ctl_ioctl,
.poll = _ctl_poll,
.fasync = _ctl_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = _ctl_ioctl_compat,
#endif
};
/* file operations table for mpt2ctl device */
static const struct file_operations ctl_gen2_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = _ctl_mpt2_ioctl,
.poll = _ctl_poll,
.fasync = _ctl_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = _ctl_mpt2_ioctl_compat,
#endif
};
static struct miscdevice ctl_dev = {
.minor = MPT3SAS_MINOR,
.name = MPT3SAS_DEV_NAME,
.fops = &ctl_fops,
};
static struct miscdevice gen2_ctl_dev = {
.minor = MPT2SAS_MINOR,
.name = MPT2SAS_DEV_NAME,
.fops = &ctl_gen2_fops,
};
/**
* mpt3sas_ctl_init - main entry point for ctl.
* @hbas_to_enumerate: ?
*/
void
mpt3sas_ctl_init(ushort hbas_to_enumerate)
{
async_queue = NULL;
/* Don't register mpt3ctl ioctl device if
* hbas_to_enumarate is one.
*/
if (hbas_to_enumerate != 1)
if (misc_register(&ctl_dev) < 0)
pr_err("%s can't register misc device [minor=%d]\n",
MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR);
/* Don't register mpt3ctl ioctl device if
* hbas_to_enumarate is two.
*/
if (hbas_to_enumerate != 2)
if (misc_register(&gen2_ctl_dev) < 0)
pr_err("%s can't register misc device [minor=%d]\n",
MPT2SAS_DRIVER_NAME, MPT2SAS_MINOR);
init_waitqueue_head(&ctl_poll_wait);
}
/**
* mpt3sas_ctl_release - release dma for ctl
* @ioc: per adapter object
*/
void
mpt3sas_ctl_release(struct MPT3SAS_ADAPTER *ioc)
{
int i;
/* free memory associated to diag buffers */
for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
if (!ioc->diag_buffer[i])
continue;
dma_free_coherent(&ioc->pdev->dev,
ioc->diag_buffer_sz[i],
ioc->diag_buffer[i],
ioc->diag_buffer_dma[i]);
ioc->diag_buffer[i] = NULL;
ioc->diag_buffer_status[i] = 0;
}
kfree(ioc->event_log);
}
/**
* mpt3sas_ctl_exit - exit point for ctl
* @hbas_to_enumerate: ?
*/
void
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/delay.h`.
- Detected declarations: `struct DIAG_BUFFER_START`, `enum block_state`, `function _ctl_display_some_debug`, `function mpt3sas_ctl_done`, `function _ctl_check_event_type`, `function mpt3sas_ctl_add_to_event_log`, `function mpt3sas_ctl_event_callback`, `function _ctl_verify_adapter`, `function mpt3sas_ctl_pre_reset_handler`, `function mpt3sas_ctl_clear_outstanding_ioctls`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.