drivers/scsi/aacraid/commctrl.c
Source file repositories/reference/linux-study-clean/drivers/scsi/aacraid/commctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/aacraid/commctrl.c- Extension
.c- Size
- 29445 bytes
- Lines
- 1122
- 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.
- 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/init.hlinux/types.hlinux/pci.hlinux/spinlock.hlinux/slab.hlinux/completion.hlinux/dma-mapping.hlinux/blkdev.hlinux/compat.hlinux/delay.hlinux/kthread.hlinux/uaccess.hscsi/scsi_host.haacraid.h
Detected Declarations
struct compat_fib_ioctlstruct aac_pci_infostruct aac_reset_iopfunction Copyrightfunction open_getadapter_fibfunction next_getadapter_fibfunction aac_close_fib_contextfunction close_getadapter_fibfunction check_revisionfunction aac_send_raw_srbfunction aac_get_pci_infofunction aac_get_hba_infofunction aac_send_reset_adapterfunction aac_do_ioctl
Annotated Snippet
struct compat_fib_ioctl {
u32 fibctx;
s32 wait;
compat_uptr_t fib;
};
/**
* next_getadapter_fib - get the next fib
* @dev: adapter to use
* @arg: ioctl argument
*
* This routine will get the next Fib, if available, from the AdapterFibContext
* passed in from the user.
*/
static int next_getadapter_fib(struct aac_dev * dev, void __user *arg)
{
struct fib_ioctl f;
struct fib *fib;
struct aac_fib_context *fibctx;
int status;
struct list_head * entry;
unsigned long flags;
if (in_compat_syscall()) {
struct compat_fib_ioctl cf;
if (copy_from_user(&cf, arg, sizeof(struct compat_fib_ioctl)))
return -EFAULT;
f.fibctx = cf.fibctx;
f.wait = cf.wait;
f.fib = compat_ptr(cf.fib);
} else {
if (copy_from_user(&f, arg, sizeof(struct fib_ioctl)))
return -EFAULT;
}
/*
* Verify that the HANDLE passed in was a valid AdapterFibContext
*
* Search the list of AdapterFibContext addresses on the adapter
* to be sure this is a valid address
*/
spin_lock_irqsave(&dev->fib_lock, flags);
entry = dev->fib_list.next;
fibctx = NULL;
while (entry != &dev->fib_list) {
fibctx = list_entry(entry, struct aac_fib_context, next);
/*
* Extract the AdapterFibContext from the Input parameters.
*/
if (fibctx->unique == f.fibctx) { /* We found a winner */
break;
}
entry = entry->next;
fibctx = NULL;
}
if (!fibctx) {
spin_unlock_irqrestore(&dev->fib_lock, flags);
dprintk ((KERN_INFO "Fib Context not found\n"));
return -EINVAL;
}
if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
(fibctx->size != sizeof(struct aac_fib_context))) {
spin_unlock_irqrestore(&dev->fib_lock, flags);
dprintk ((KERN_INFO "Fib Context corrupt?\n"));
return -EINVAL;
}
status = 0;
/*
* If there are no fibs to send back, then either wait or return
* -EAGAIN
*/
return_fib:
if (!list_empty(&fibctx->fib_list)) {
/*
* Pull the next fib from the fibs
*/
entry = fibctx->fib_list.next;
list_del(entry);
fib = list_entry(entry, struct fib, fiblink);
fibctx->count--;
spin_unlock_irqrestore(&dev->fib_lock, flags);
if (copy_to_user(f.fib, fib->hw_fib_va, sizeof(struct hw_fib))) {
kfree(fib->hw_fib_va);
kfree(fib);
return -EFAULT;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/types.h`, `linux/pci.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/completion.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct compat_fib_ioctl`, `struct aac_pci_info`, `struct aac_reset_iop`, `function Copyright`, `function open_getadapter_fib`, `function next_getadapter_fib`, `function aac_close_fib_context`, `function close_getadapter_fib`, `function check_revision`, `function aac_send_raw_srb`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.