drivers/scsi/3w-sas.c
Source file repositories/reference/linux-study-clean/drivers/scsi/3w-sas.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/3w-sas.c- Extension
.c- Size
- 58235 bytes
- Lines
- 1862
- 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-sas.h
Detected Declarations
function twl_sysfs_aen_readfunction twl_sysfs_compat_infofunction twl_show_statsfunction twl_aen_queue_eventfunction twl_post_command_packetfunction twl_scsiop_execute_scsifunction scsi_for_each_sgfunction twl_aen_read_queuefunction twl_aen_sync_timefunction twl_get_request_idfunction twl_free_request_idfunction twl_aen_completefunction twl_poll_responsefunction twl_aen_drain_queuefunction twl_allocate_memoryfunction twl_load_sglfunction twl_chrdev_ioctlfunction twl_chrdev_openfunction twl_fill_sensefunction twl_free_device_extensionfunction twl_initconnectionfunction twl_initialize_device_extensionfunction twl_handle_attention_interruptfunction twl_interruptfunction twl_poll_registerfunction twl_reset_sequencefunction twl_reset_device_extensionfunction twl_scsi_biosparamfunction twl_scsi_eh_resetfunction twl_scsi_queue_lckfunction DEF_SCSI_QCMDfunction twl_shutdownfunction twl_sdev_configurefunction twl_probefunction twl_removefunction twl_suspendfunction twl_resumefunction twl_initfunction twl_exitmodule init twl_init
Annotated Snippet
static const struct file_operations twl_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = twl_chrdev_ioctl,
.open = twl_chrdev_open,
.release = NULL,
.llseek = noop_llseek,
};
/* This function passes sense data from firmware to scsi layer */
static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, int copy_sense, int print_host)
{
TW_Command_Apache_Header *header;
TW_Command_Full *full_command_packet;
unsigned short error;
char *error_str;
header = tw_dev->sense_buffer_virt[i];
full_command_packet = tw_dev->command_packet_virt[request_id];
/* Get embedded firmware error string */
error_str = &(header->err_specific_desc[strlen(header->err_specific_desc) + 1]);
/* Don't print error for Logical unit not supported during rollcall */
error = le16_to_cpu(header->status_block.error);
if ((error != TW_ERROR_LOGICAL_UNIT_NOT_SUPPORTED) && (error != TW_ERROR_UNIT_OFFLINE) && (error != TW_ERROR_INVALID_FIELD_IN_CDB)) {
if (print_host)
printk(KERN_WARNING "3w-sas: scsi%d: ERROR: (0x%02X:0x%04X): %s:%s.\n",
tw_dev->host->host_no,
TW_MESSAGE_SOURCE_CONTROLLER_ERROR,
header->status_block.error,
error_str,
header->err_specific_desc);
else
printk(KERN_WARNING "3w-sas: ERROR: (0x%02X:0x%04X): %s:%s.\n",
TW_MESSAGE_SOURCE_CONTROLLER_ERROR,
header->status_block.error,
error_str,
header->err_specific_desc);
}
if (copy_sense) {
memcpy(tw_dev->srb[request_id]->sense_buffer, header->sense_data, TW_SENSE_DATA_LENGTH);
tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1);
goto out;
}
out:
return 1;
} /* End twl_fill_sense() */
/* This function will free up device extension resources */
static void twl_free_device_extension(TW_Device_Extension *tw_dev)
{
if (tw_dev->command_packet_virt[0])
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
sizeof(TW_Command_Full)*TW_Q_LENGTH,
tw_dev->command_packet_virt[0],
tw_dev->command_packet_phys[0]);
if (tw_dev->generic_buffer_virt[0])
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
TW_SECTOR_SIZE*TW_Q_LENGTH,
tw_dev->generic_buffer_virt[0],
tw_dev->generic_buffer_phys[0]);
if (tw_dev->sense_buffer_virt[0])
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
sizeof(TW_Command_Apache_Header)*
TW_Q_LENGTH,
tw_dev->sense_buffer_virt[0],
tw_dev->sense_buffer_phys[0]);
kfree(tw_dev->event_queue[0]);
} /* End twl_free_device_extension() */
/* This function will get parameter table entries from the firmware */
static void *twl_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter_id, int parameter_size_bytes)
{
TW_Command_Full *full_command_packet;
TW_Command *command_packet;
TW_Param_Apache *param;
void *retval = NULL;
/* Setup the command packet */
full_command_packet = tw_dev->command_packet_virt[request_id];
memset(full_command_packet, 0, sizeof(TW_Command_Full));
command_packet = &full_command_packet->command.oldcommand;
command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
command_packet->size = TW_COMMAND_SIZE;
command_packet->request_id = request_id;
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 twl_sysfs_aen_read`, `function twl_sysfs_compat_info`, `function twl_show_stats`, `function twl_aen_queue_event`, `function twl_post_command_packet`, `function twl_scsiop_execute_scsi`, `function scsi_for_each_sg`, `function twl_aen_read_queue`, `function twl_aen_sync_time`, `function twl_get_request_id`.
- 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.