drivers/scsi/3w-9xxx.c
Source file repositories/reference/linux-study-clean/drivers/scsi/3w-9xxx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/3w-9xxx.c- Extension
.c- Size
- 75831 bytes
- Lines
- 2306
- 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/module.hlinux/reboot.hlinux/spinlock.hlinux/interrupt.hlinux/moduleparam.hlinux/errno.hlinux/types.hlinux/delay.hlinux/pci.hlinux/time.hlinux/mutex.hlinux/slab.hasm/io.hasm/irq.hlinux/uaccess.hscsi/scsi.hscsi/scsi_host.hscsi/scsi_tcq.hscsi/scsi_cmnd.h3w-9xxx.h
Detected Declarations
function twa_show_statsfunction twa_command_mappedfunction twa_aen_completefunction twa_aen_drain_queuefunction twa_aen_queue_eventfunction twa_aen_read_queuefunction twa_aen_sync_timefunction memcpyfunction twa_allocate_memoryfunction twa_check_bitsfunction twa_check_srlfunction twa_chrdev_ioctlfunction twa_chrdev_openfunction twa_decode_bitsfunction twa_empty_response_queuefunction twa_empty_response_queue_largefunction twa_fill_sensefunction twa_free_device_extensionfunction twa_free_request_idfunction twa_get_request_idfunction twa_initconnectionfunction twa_initialize_device_extensionfunction twa_interruptfunction twa_load_sglfunction twa_poll_responsefunction twa_poll_statusfunction twa_poll_status_gonefunction twa_post_command_packetfunction twa_reset_device_extensionfunction twa_reset_sequencefunction twa_scsi_biosparamfunction twa_scsi_eh_resetfunction twa_scsi_queue_lckfunction DEF_SCSI_QCMDfunction scsi_for_each_sgfunction twa_scsiop_execute_scsi_completefunction __twa_shutdownfunction twa_shutdownfunction twa_sdev_configurefunction twa_probefunction twa_removefunction twa_suspendfunction twa_resumefunction twa_initfunction twa_exitmodule init twa_init
Annotated Snippet
static const struct file_operations twa_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = twa_chrdev_ioctl,
.open = twa_chrdev_open,
.release = NULL,
.llseek = noop_llseek,
};
/*
* The controllers use an inline buffer instead of a mapped SGL for small,
* single entry buffers. Note that we treat a zero-length transfer like
* a mapped SGL.
*/
static bool twa_command_mapped(struct scsi_cmnd *cmd)
{
return scsi_sg_count(cmd) != 1 ||
scsi_bufflen(cmd) >= TW_MIN_SGL_LENGTH;
}
/* This function will complete an aen request from the isr */
static int twa_aen_complete(TW_Device_Extension *tw_dev, int request_id)
{
TW_Command_Full *full_command_packet;
TW_Command *command_packet;
TW_Command_Apache_Header *header;
unsigned short aen;
int retval = 1;
header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
tw_dev->posted_request_count--;
aen = le16_to_cpu(header->status_block.error);
full_command_packet = tw_dev->command_packet_virt[request_id];
command_packet = &full_command_packet->command.oldcommand;
/* First check for internal completion of set param for time sync */
if (TW_OP_OUT(command_packet->opcode__sgloffset) == TW_OP_SET_PARAM) {
/* Keep reading the queue in case there are more aen's */
if (twa_aen_read_queue(tw_dev, request_id))
goto out2;
else {
retval = 0;
goto out;
}
}
switch (aen) {
case TW_AEN_QUEUE_EMPTY:
/* Quit reading the queue if this is the last one */
break;
case TW_AEN_SYNC_TIME_WITH_HOST:
twa_aen_sync_time(tw_dev, request_id);
retval = 0;
goto out;
default:
twa_aen_queue_event(tw_dev, header);
/* If there are more aen's, keep reading the queue */
if (twa_aen_read_queue(tw_dev, request_id))
goto out2;
else {
retval = 0;
goto out;
}
}
retval = 0;
out2:
tw_dev->state[request_id] = TW_S_COMPLETED;
twa_free_request_id(tw_dev, request_id);
clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
out:
return retval;
} /* End twa_aen_complete() */
/* This function will drain aen queue */
static int twa_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset)
{
int request_id = 0;
unsigned char cdb[TW_MAX_CDB_LEN];
TW_SG_Entry sglist[1];
int finished = 0, count = 0;
TW_Command_Full *full_command_packet;
TW_Command_Apache_Header *header;
unsigned short aen;
int first_reset = 0, queue = 0, retval = 1;
if (no_check_reset)
first_reset = 0;
else
first_reset = 1;
Annotation
- Immediate include surface: `linux/module.h`, `linux/reboot.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/moduleparam.h`, `linux/errno.h`, `linux/types.h`, `linux/delay.h`.
- Detected declarations: `function twa_show_stats`, `function twa_command_mapped`, `function twa_aen_complete`, `function twa_aen_drain_queue`, `function twa_aen_queue_event`, `function twa_aen_read_queue`, `function twa_aen_sync_time`, `function memcpy`, `function twa_allocate_memory`, `function twa_check_bits`.
- 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.