drivers/ata/libata-sff.c
Source file repositories/reference/linux-study-clean/drivers/ata/libata-sff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/libata-sff.c- Extension
.c- Size
- 81832 bytes
- Lines
- 3208
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/gfp.hlinux/pci.hlinux/module.hlinux/libata.hlinux/highmem.htrace/events/libata.hlibata.h
Detected Declarations
function ata_sff_check_statusfunction ata_sff_altstatusfunction ata_sff_irq_statusfunction ata_sff_syncfunction ata_sff_pausefunction ata_sff_dma_pausefunction ata_sff_check_readyfunction contextfunction ata_sff_set_devctlfunction dev_selectfunction ata_dev_selectfunction ata_sff_irq_onfunction ata_sff_tf_loadfunction ata_sff_tf_readfunction spin_lock_irqsavefunction spin_lock_irqsavefunction ata_sff_data_xferfunction ata_sff_data_xfer32function ata_pio_xferfunction ata_pio_sectorfunction ata_pio_sectorsfunction atapi_send_cdbfunction __atapi_pio_bytesfunction atapi_pio_bytesfunction ata_hsm_ok_in_wqfunction ata_hsm_qc_completefunction ata_sff_hsm_movefunction transferfunction ata_sff_queue_workfunction ata_sff_queue_delayed_workfunction ata_sff_queue_pio_taskfunction ata_sff_flush_pio_taskfunction ata_sff_pio_taskfunction spin_lock_irqsavefunction spin_lock_irqsavefunction ata_sff_idle_irqfunction __ata_sff_port_intrfunction spin_lock_irqsavefunction __ata_sff_interruptfunction sff_irq_clearfunction ata_sff_port_intrfunction ata_sff_lost_interruptfunction ata_sff_freezefunction ata_sff_thawfunction ata_std_preresetfunction ata_devchkfunction ata_sff_dev_classifyfunction context
Annotated Snippet
if (likely(ioaddr->ctl_addr)) {
iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
tf->hob_feature = ioread8(ioaddr->error_addr);
tf->hob_nsect = ioread8(ioaddr->nsect_addr);
tf->hob_lbal = ioread8(ioaddr->lbal_addr);
tf->hob_lbam = ioread8(ioaddr->lbam_addr);
tf->hob_lbah = ioread8(ioaddr->lbah_addr);
iowrite8(tf->ctl, ioaddr->ctl_addr);
ap->last_ctl = tf->ctl;
} else
WARN_ON_ONCE(1);
}
}
EXPORT_SYMBOL_GPL(ata_sff_tf_read);
/**
* ata_sff_exec_command - issue ATA command to host controller
* @ap: port to which command is being issued
* @tf: ATA taskfile register set
*
* Issues ATA command, with proper synchronization with interrupt
* handler / other threads.
*
* LOCKING:
* spin_lock_irqsave(host lock)
*/
void ata_sff_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
{
iowrite8(tf->command, ap->ioaddr.command_addr);
ata_sff_pause(ap);
}
EXPORT_SYMBOL_GPL(ata_sff_exec_command);
/**
* ata_tf_to_host - issue ATA taskfile to host controller
* @ap: port to which command is being issued
* @tf: ATA taskfile register set
* @tag: tag of the associated command
*
* Issues ATA taskfile register set to ATA host controller,
* with proper synchronization with interrupt handler and
* other threads.
*
* LOCKING:
* spin_lock_irqsave(host lock)
*/
static inline void ata_tf_to_host(struct ata_port *ap,
const struct ata_taskfile *tf,
unsigned int tag)
{
trace_ata_tf_load(ap, tf);
ap->ops->sff_tf_load(ap, tf);
trace_ata_exec_command(ap, tf, tag);
ap->ops->sff_exec_command(ap, tf);
}
/**
* ata_sff_data_xfer - Transfer data by PIO
* @qc: queued command
* @buf: data buffer
* @buflen: buffer length
* @rw: read/write
*
* Transfer data from/to the device data register by PIO.
*
* LOCKING:
* Inherited from caller.
*
* RETURNS:
* Bytes consumed.
*/
unsigned int ata_sff_data_xfer(struct ata_queued_cmd *qc, unsigned char *buf,
unsigned int buflen, int rw)
{
struct ata_port *ap = qc->dev->link->ap;
void __iomem *data_addr = ap->ioaddr.data_addr;
unsigned int words = buflen >> 1;
/* Transfer multiple of 2 bytes */
if (rw == READ)
ioread16_rep(data_addr, buf, words);
else
iowrite16_rep(data_addr, buf, words);
/* Transfer trailing byte, if any. */
if (unlikely(buflen & 0x01)) {
unsigned char pad[2] = { };
/* Point buf to the tail of buffer */
buf += buflen - 1;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/gfp.h`, `linux/pci.h`, `linux/module.h`, `linux/libata.h`, `linux/highmem.h`, `trace/events/libata.h`, `libata.h`.
- Detected declarations: `function ata_sff_check_status`, `function ata_sff_altstatus`, `function ata_sff_irq_status`, `function ata_sff_sync`, `function ata_sff_pause`, `function ata_sff_dma_pause`, `function ata_sff_check_ready`, `function context`, `function ata_sff_set_devctl`, `function dev_select`.
- 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.
- 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.