drivers/ata/libata-eh.c
Source file repositories/reference/linux-study-clean/drivers/ata/libata-eh.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/libata-eh.c- Extension
.c- Size
- 117376 bytes
- Lines
- 4276
- Domain
- Driver Families
- Bucket
- drivers/ata
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/blkdev.hlinux/export.hlinux/pci.hscsi/scsi.hscsi/scsi_host.hscsi/scsi_eh.hscsi/scsi_device.hscsi/scsi_cmnd.hscsi/scsi_dbg.h../scsi/scsi_transport_api.hlinux/libata.htrace/events/libata.hlibata.h
Detected Declarations
struct ata_eh_cmd_timeout_entstruct speed_down_verdict_argfunction ata_eh_handle_port_suspendfunction spin_lock_irqsavefunction spin_lock_irqsavefunction spin_lock_irqsavefunction ata_port_descfunction ata_port_pbar_descfunction ata_lookup_timeout_tablefunction ata_internal_cmd_timeoutfunction ata_internal_cmd_timeoutfunction ata_ering_recordfunction ata_ering_mapfunction ata_ering_clear_cbfunction ata_ering_clearfunction ata_eh_dev_actionfunction ata_eh_clear_actionfunction ata_eh_acquirefunction ata_eh_acquirefunction ata_eh_dev_disablefunction ata_eh_unloadfunction ata_for_each_linkfunction layerfunction ata_scsi_cmd_error_handlerfunction list_for_each_entry_safefunction ata_qc_for_each_rawfunction ata_scsi_port_error_handlerfunction ata_for_each_linkfunction ata_for_each_devfunction contextfunction ata_eh_nr_in_flightfunction ata_eh_fastdrain_timerfnfunction ata_qc_for_eachfunction spin_lock_irqsavefunction spin_lock_irqsavefunction spin_lock_irqsavefunction spin_lock_irqsavefunction spin_lock_irqsavefunction ata_do_link_abortfunction spin_lock_irqsavefunction spin_lock_irqsavefunction spin_lock_irqsavefunction spin_lock_irqsavefunction ata_eh_freeze_portfunction ata_eh_thaw_portfunction ata_eh_scsidonefunction ata_eh_qc_completefunction failures
Annotated Snippet
struct ata_eh_cmd_timeout_ent {
const u8 *commands;
const unsigned int *timeouts;
};
/* The following table determines timeouts to use for EH internal
* commands. Each table entry is a command class and matches the
* commands the entry applies to and the timeout table to use.
*
* On the retry after a command timed out, the next timeout value from
* the table is used. If the table doesn't contain further entries,
* the last value is used.
*
* ehc->cmd_timeout_idx keeps track of which timeout to use per
* command class, so if SET_FEATURES times out on the first try, the
* next try will use the second timeout value only for that class.
*/
#define CMDS(cmds...) (const u8 []){ cmds, 0 }
static const struct ata_eh_cmd_timeout_ent
ata_eh_cmd_timeout_table[ATA_EH_CMD_TIMEOUT_TABLE_SIZE] = {
{ .commands = CMDS(ATA_CMD_ID_ATA, ATA_CMD_ID_ATAPI),
.timeouts = ata_eh_identify_timeouts, },
{ .commands = CMDS(ATA_CMD_READ_LOG_EXT, ATA_CMD_READ_LOG_DMA_EXT),
.timeouts = ata_eh_revalidate_timeouts, },
{ .commands = CMDS(ATA_CMD_READ_NATIVE_MAX, ATA_CMD_READ_NATIVE_MAX_EXT),
.timeouts = ata_eh_other_timeouts, },
{ .commands = CMDS(ATA_CMD_SET_MAX, ATA_CMD_SET_MAX_EXT),
.timeouts = ata_eh_other_timeouts, },
{ .commands = CMDS(ATA_CMD_SET_FEATURES),
.timeouts = ata_eh_other_timeouts, },
{ .commands = CMDS(ATA_CMD_INIT_DEV_PARAMS),
.timeouts = ata_eh_other_timeouts, },
{ .commands = CMDS(ATA_CMD_FLUSH, ATA_CMD_FLUSH_EXT),
.timeouts = ata_eh_flush_timeouts },
{ .commands = CMDS(ATA_CMD_VERIFY),
.timeouts = ata_eh_reset_timeouts },
};
#undef CMDS
static void __ata_port_freeze(struct ata_port *ap);
#ifdef CONFIG_PM
static void ata_eh_handle_port_suspend(struct ata_port *ap);
static void ata_eh_handle_port_resume(struct ata_port *ap);
#else /* CONFIG_PM */
static void ata_eh_handle_port_suspend(struct ata_port *ap)
{ }
static void ata_eh_handle_port_resume(struct ata_port *ap)
{ }
#endif /* CONFIG_PM */
static __printf(2, 0) void __ata_ehi_pushv_desc(struct ata_eh_info *ehi,
const char *fmt, va_list args)
{
ehi->desc_len += vscnprintf(ehi->desc + ehi->desc_len,
ATA_EH_DESC_LEN - ehi->desc_len,
fmt, args);
}
/**
* __ata_ehi_push_desc - push error description without adding separator
* @ehi: target EHI
* @fmt: printf format string
*
* Format string according to @fmt and append it to @ehi->desc.
*
* LOCKING:
* spin_lock_irqsave(host lock)
*/
void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
__ata_ehi_pushv_desc(ehi, fmt, args);
va_end(args);
}
EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
/**
* ata_ehi_push_desc - push error description with separator
* @ehi: target EHI
* @fmt: printf format string
*
* Format string according to @fmt and append it to @ehi->desc.
* If @ehi->desc is not empty, ", " is added in-between.
*
* LOCKING:
* spin_lock_irqsave(host lock)
*/
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/blkdev.h`, `linux/export.h`, `linux/pci.h`, `scsi/scsi.h`, `scsi/scsi_host.h`, `scsi/scsi_eh.h`, `scsi/scsi_device.h`.
- Detected declarations: `struct ata_eh_cmd_timeout_ent`, `struct speed_down_verdict_arg`, `function ata_eh_handle_port_suspend`, `function spin_lock_irqsave`, `function spin_lock_irqsave`, `function spin_lock_irqsave`, `function ata_port_desc`, `function ata_port_pbar_desc`, `function ata_lookup_timeout_table`, `function ata_internal_cmd_timeout`.
- Atlas domain: Driver Families / drivers/ata.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.