drivers/message/fusion/mptctl.c
Source file repositories/reference/linux-study-clean/drivers/message/fusion/mptctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/message/fusion/mptctl.c- Extension
.c- Size
- 84738 bytes
- Lines
- 2954
- Domain
- Driver Families
- Bucket
- drivers/message
- 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/miscdevice.hlinux/mutex.hlinux/compat.hasm/io.hlinux/uaccess.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_tcq.hmptbase.hmptctl.h
Detected Declarations
struct buflistfunction listfunction mptctl_replyfunction mptctl_taskmgmt_replyfunction mptctl_do_taskmgmtfunction mptctl_timeout_expiredfunction CLEAR_MGMT_PENDING_STATUSfunction mptctl_ioc_resetfunction mptctl_event_processfunction mptctl_fasyncfunction __mptctl_ioctlfunction mptctl_ioctlfunction mptctl_do_resetfunction mptctl_fw_downloadfunction mptctl_do_fw_downloadfunction thefunction kfree_sglfunction mptctl_getiocinfofunction shost_for_each_devicefunction mptctl_gettargetinfofunction shost_for_each_devicefunction mptctl_readtestfunction mptctl_eventqueryfunction mptctl_eventenablefunction mptctl_eventreportfunction mptctl_replace_fwfunction mptctl_mpt_commandfunction mptctl_do_mpt_commandfunction shost_for_each_devicefunction dataOutSizefunction dataOutSizefunction setupfunction mptctl_hp_hostinfofunction ISTWIfunction mptctl_hp_targetinfofunction compat_mptfwxfer_ioctlfunction compat_mpt_commandfunction compat_mpctl_ioctlfunction mptctl_probefunction mptctl_removefunction mptctl_initfunction mptctl_exitmodule init mptctl_init
Annotated Snippet
static const struct file_operations mptctl_fops = {
.owner = THIS_MODULE,
.fasync = mptctl_fasync,
.unlocked_ioctl = mptctl_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_mpctl_ioctl,
#endif
};
static struct miscdevice mptctl_miscdev = {
MPT_MINOR,
MYNAM,
&mptctl_fops
};
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#ifdef CONFIG_COMPAT
static int
compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{
struct mpt_fw_xfer32 kfw32;
struct mpt_fw_xfer kfw;
MPT_ADAPTER *iocp = NULL;
int iocnum, iocnumX;
int nonblock = (filp->f_flags & O_NONBLOCK);
int ret;
if (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32)))
return -EFAULT;
/* Verify intended MPT adapter */
iocnumX = kfw32.iocnum & 0xFF;
if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
(iocp == NULL)) {
printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n",
__LINE__, iocnumX);
return -ENODEV;
}
if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)
return ret;
dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "compat_mptfwxfer_ioctl() called\n",
iocp->name));
kfw.iocnum = iocnum;
kfw.fwlen = kfw32.fwlen;
kfw.bufp = compat_ptr(kfw32.bufp);
ret = mptctl_do_fw_download(iocp, kfw.bufp, kfw.fwlen);
mutex_unlock(&iocp->ioctl_cmds.mutex);
return ret;
}
static int
compat_mpt_command(struct file *filp, unsigned int cmd,
unsigned long arg)
{
struct mpt_ioctl_command32 karg32;
struct mpt_ioctl_command32 __user *uarg = (struct mpt_ioctl_command32 __user *) arg;
struct mpt_ioctl_command karg;
MPT_ADAPTER *iocp = NULL;
int iocnum, iocnumX;
int nonblock = (filp->f_flags & O_NONBLOCK);
int ret;
if (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32)))
return -EFAULT;
/* Verify intended MPT adapter */
iocnumX = karg32.hdr.iocnum & 0xFF;
if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
(iocp == NULL)) {
printk(KERN_DEBUG MYNAM "::compat_mpt_command @%d - ioc%d not found!\n",
__LINE__, iocnumX);
return -ENODEV;
}
if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)
return ret;
dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "compat_mpt_command() called\n",
iocp->name));
/* Copy data to karg */
karg.hdr.iocnum = karg32.hdr.iocnum;
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 buflist`, `function list`, `function mptctl_reply`, `function mptctl_taskmgmt_reply`, `function mptctl_do_taskmgmt`, `function mptctl_timeout_expired`, `function CLEAR_MGMT_PENDING_STATUS`, `function mptctl_ioc_reset`, `function mptctl_event_process`, `function mptctl_fasync`.
- Atlas domain: Driver Families / drivers/message.
- 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.