drivers/scsi/esp_scsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/esp_scsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/esp_scsi.c- Extension
.c- Size
- 70237 bytes
- Lines
- 2910
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/types.hlinux/slab.hlinux/delay.hlinux/list.hlinux/completion.hlinux/kallsyms.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/irqreturn.hasm/irq.hasm/io.hasm/dma.hscsi/scsi.hscsi/scsi_host.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_tcq.hscsi/scsi_dbg.hscsi/scsi_transport_spi.hesp_scsi.h
Detected Declarations
function esp_log_fill_regsfunction scsi_esp_cmdfunction esp_send_dma_cmdfunction esp_eventfunction esp_dump_cmd_logfunction esp_flush_fifofunction hme_read_fifofunction esp_set_all_config3function esp_reset_espfunction esp_map_dmafunction scsi_for_each_sgfunction esp_cur_dma_addrfunction esp_cur_dma_lenfunction esp_advance_dmafunction esp_unmap_dmafunction esp_save_pointersfunction esp_restore_pointersfunction esp_write_tgt_config3function esp_write_tgt_syncfunction esp_dma_length_limitfunction esp_need_to_nego_widefunction esp_need_to_nego_syncfunction esp_alloc_lun_tagfunction esp_free_lun_tagfunction esp_map_sensefunction esp_unmap_sensefunction esp_autosensefunction list_for_each_entryfunction esp_maybe_execute_commandfunction esp_put_entfunction esp_cmd_is_donefunction esp_event_queue_fullfunction esp_queuecommand_lckfunction DEF_SCSI_QCMDfunction esp_check_spur_intrfunction esp_schedule_resetfunction esp_reconnectfunction esp_finish_selectfunction resourcesfunction esp_data_bytes_sentfunction esp_setsyncfunction esp_msgin_rejectfunction esp_msgin_sdtrfunction esp_msgin_wdtrfunction esp_msgin_extendedfunction esp_msgin_processfunction esp_process_eventfunction esp_reset_cleanup_one
Annotated Snippet
module_init(esp_init);
module_exit(esp_exit);
#ifdef CONFIG_SCSI_ESP_PIO
static inline unsigned int esp_wait_for_fifo(struct esp *esp)
{
int i = 500000;
do {
unsigned int fbytes = esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES;
if (fbytes)
return fbytes;
udelay(1);
} while (--i);
shost_printk(KERN_ERR, esp->host, "FIFO is empty. sreg [%02x]\n",
esp_read8(ESP_STATUS));
return 0;
}
static inline int esp_wait_for_intr(struct esp *esp)
{
int i = 500000;
do {
esp->sreg = esp_read8(ESP_STATUS);
if (esp->sreg & ESP_STAT_INTR)
return 0;
udelay(1);
} while (--i);
shost_printk(KERN_ERR, esp->host, "IRQ timeout. sreg [%02x]\n",
esp->sreg);
return 1;
}
#define ESP_FIFO_SIZE 16
void esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
u32 dma_count, int write, u8 cmd)
{
u8 phase = esp->sreg & ESP_STAT_PMASK;
cmd &= ~ESP_CMD_DMA;
esp->send_cmd_error = 0;
if (write) {
u8 *dst = (u8 *)addr;
u8 mask = ~(phase == ESP_MIP ? ESP_INTR_FDONE : ESP_INTR_BSERV);
scsi_esp_cmd(esp, cmd);
while (1) {
if (!esp_wait_for_fifo(esp))
break;
*dst++ = readb(esp->fifo_reg);
--esp_count;
if (!esp_count)
break;
if (esp_wait_for_intr(esp)) {
esp->send_cmd_error = 1;
break;
}
if ((esp->sreg & ESP_STAT_PMASK) != phase)
break;
esp->ireg = esp_read8(ESP_INTRPT);
if (esp->ireg & mask) {
esp->send_cmd_error = 1;
break;
}
if (phase == ESP_MIP)
esp_write8(ESP_CMD_MOK, ESP_CMD);
esp_write8(ESP_CMD_TI, ESP_CMD);
}
} else {
unsigned int n = ESP_FIFO_SIZE;
u8 *src = (u8 *)addr;
scsi_esp_cmd(esp, ESP_CMD_FLUSH);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/slab.h`, `linux/delay.h`, `linux/list.h`, `linux/completion.h`, `linux/kallsyms.h`, `linux/module.h`.
- Detected declarations: `function esp_log_fill_regs`, `function scsi_esp_cmd`, `function esp_send_dma_cmd`, `function esp_event`, `function esp_dump_cmd_log`, `function esp_flush_fifo`, `function hme_read_fifo`, `function esp_set_all_config3`, `function esp_reset_esp`, `function esp_map_dma`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration 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.