drivers/scsi/esas2r/esas2r_main.c
Source file repositories/reference/linux-study-clean/drivers/scsi/esas2r/esas2r_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/esas2r/esas2r_main.c- Extension
.c- Size
- 47592 bytes
- Lines
- 1913
- 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.
- 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
esas2r.h
Detected Declarations
function read_fwfunction write_fwfunction read_fsfunction write_fsfunction read_vdafunction write_vdafunction read_live_nvramfunction write_live_nvramfunction read_default_nvramfunction read_hwfunction write_hwfunction esas2r_probefunction esas2r_removefunction esas2r_initfunction esas2r_proc_ioctlfunction esas2r_exitfunction esas2r_show_infofunction get_physaddr_from_sgcfunction esas2r_queuecommandfunction complete_task_management_requestfunction esas2r_check_active_queuefunction list_for_each_safefunction esas2r_eh_abortfunction esas2r_host_bus_resetfunction esas2r_host_resetfunction esas2r_bus_resetfunction esas2r_dev_targ_resetfunction esas2r_device_resetfunction esas2r_target_resetfunction esas2r_log_request_failurefunction esas2r_wait_requestfunction esas2r_map_data_windowfunction esas2r_read_mem_blockfunction esas2r_nuxi_mgt_datafunction esas2r_nuxi_cfg_datafunction esas2r_nuxi_ae_datafunction esas2r_free_requestfunction esas2r_complete_request_cbfunction esas2r_adapter_taskletfunction esas2r_kickoff_timerfunction esas2r_timer_callbackfunction esas2r_free_fw_eventfunction esas2r_fw_event_offfunction esas2r_fw_event_onfunction esas2r_add_devicefunction esas2r_remove_devicefunction esas2r_send_ae_eventfunction esas2r_firmware_event_work
Annotated Snippet
static struct pci_driver
esas2r_pci_driver = {
.name = ESAS2R_DRVR_NAME,
.id_table = esas2r_pci_table,
.probe = esas2r_probe,
.remove = esas2r_remove,
.driver.pm = &esas2r_pm_ops,
};
static int esas2r_probe(struct pci_dev *pcid,
const struct pci_device_id *id)
{
struct Scsi_Host *host = NULL;
struct esas2r_adapter *a;
int err;
size_t host_alloc_size = sizeof(struct esas2r_adapter)
+ ((num_requests) +
1) * sizeof(struct esas2r_request);
esas2r_log_dev(ESAS2R_LOG_DEBG, &(pcid->dev),
"esas2r_probe() 0x%02x 0x%02x 0x%02x 0x%02x",
pcid->vendor,
pcid->device,
pcid->subsystem_vendor,
pcid->subsystem_device);
esas2r_log_dev(ESAS2R_LOG_INFO, &(pcid->dev),
"before pci_enable_device() "
"enable_cnt: %d",
pcid->enable_cnt.counter);
err = pci_enable_device(pcid);
if (err != 0) {
esas2r_log_dev(ESAS2R_LOG_CRIT, &(pcid->dev),
"pci_enable_device() FAIL (%d)",
err);
return -ENODEV;
}
esas2r_log_dev(ESAS2R_LOG_INFO, &(pcid->dev),
"pci_enable_device() OK");
esas2r_log_dev(ESAS2R_LOG_INFO, &(pcid->dev),
"after pci_enable_device() enable_cnt: %d",
pcid->enable_cnt.counter);
host = scsi_host_alloc(&driver_template, host_alloc_size);
if (host == NULL) {
esas2r_log(ESAS2R_LOG_CRIT, "scsi_host_alloc() FAIL");
return -ENODEV;
}
memset(host->hostdata, 0, host_alloc_size);
a = (struct esas2r_adapter *)host->hostdata;
esas2r_log(ESAS2R_LOG_INFO, "scsi_host_alloc() OK host: %p", host);
/* override max LUN and max target id */
host->max_id = ESAS2R_MAX_ID + 1;
host->max_lun = 255;
/* we can handle 16-byte CDbs */
host->max_cmd_len = 16;
host->can_queue = can_queue;
host->cmd_per_lun = cmd_per_lun;
host->this_id = host->max_id + 1;
host->max_channel = 0;
host->unique_id = found_adapters;
host->sg_tablesize = sg_tablesize;
host->max_sectors = esas2r_max_sectors;
/* set to bus master for BIOses that don't do it for us */
esas2r_log(ESAS2R_LOG_INFO, "pci_set_master() called");
pci_set_master(pcid);
if (!esas2r_init_adapter(host, pcid, found_adapters)) {
esas2r_log(ESAS2R_LOG_CRIT,
"unable to initialize device at PCI bus %x:%x",
pcid->bus->number,
pcid->devfn);
esas2r_log_dev(ESAS2R_LOG_INFO, &(host->shost_gendev),
"scsi_host_put() called");
Annotation
- Immediate include surface: `esas2r.h`.
- Detected declarations: `function read_fw`, `function write_fw`, `function read_fs`, `function write_fs`, `function read_vda`, `function write_vda`, `function read_live_nvram`, `function write_live_nvram`, `function read_default_nvram`, `function read_hw`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern implementation candidate.
- 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.