drivers/ata/libata-sata.c
Source file repositories/reference/linux-study-clean/drivers/ata/libata-sata.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/libata-sata.c- Extension
.c- Size
- 45445 bytes
- Lines
- 1738
- 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.
- 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/module.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_eh.hlinux/libata.hlinux/unaligned.hlibata.hlibata-transport.h
Detected Declarations
function sata_scr_validfunction sata_scr_readfunction sata_scr_writefunction sata_scr_writefunction structurefunction ata_tf_from_fisfunction contextfunction contextfunction sata_link_scr_lpmfunction __sata_set_spd_neededfunction sata_set_spd_neededfunction sata_set_spdfunction sata_set_spdfunction ata_wait_readyfunction contextfunction ata_qc_completefunction preresetfunction sata_lpm_ignore_phy_eventsfunction ata_scsi_lpm_supportedfunction ata_for_each_linkfunction ata_scsi_lpm_supported_showfunction ata_scsi_lpm_storefunction ata_scsi_lpm_showfunction ata_ncq_prio_supportedfunction ata_ncq_prio_supported_showfunction ata_ncq_prio_enabledfunction ata_ncq_prio_enable_showfunction ata_ncq_prio_enablefunction ata_ncq_prio_enable_storefunction ata_scsi_em_message_storefunction ata_scsi_em_message_showfunction ata_scsi_em_message_type_showfunction ata_scsi_activity_showfunction ata_scsi_activity_storefunction ata_change_queue_depthfunction layerfunction ata_sas_sdev_configurefunction __ata_scsi_queuecmdfunction spin_lock_irqsavefunction ata_for_each_linkfunction contextfunction contextfunction ata_qc_for_each_rawfunction contextfunction ata_qc_for_each_rawexport sata_deb_timing_normalexport sata_deb_timing_hotplugexport sata_deb_timing_long
Annotated Snippet
if (sata_scr_valid(link)) {
rc = link->ap->ops->scr_write(link, reg, val);
if (rc == 0)
rc = link->ap->ops->scr_read(link, reg, &val);
return rc;
}
return -EOPNOTSUPP;
}
return sata_pmp_scr_write(link, reg, val);
}
EXPORT_SYMBOL_GPL(sata_scr_write_flush);
/**
* ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
* @tf: Taskfile to convert
* @pmp: Port multiplier port
* @is_cmd: This FIS is for command
* @fis: Buffer into which data will output
*
* Converts a standard ATA taskfile to a Serial ATA
* FIS structure (Register - Host to Device).
*
* LOCKING:
* Inherited from caller.
*/
void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis)
{
fis[0] = 0x27; /* Register - Host to Device FIS */
fis[1] = pmp & 0xf; /* Port multiplier number*/
if (is_cmd)
fis[1] |= (1 << 7); /* bit 7 indicates Command FIS */
fis[2] = tf->command;
fis[3] = tf->feature;
fis[4] = tf->lbal;
fis[5] = tf->lbam;
fis[6] = tf->lbah;
fis[7] = tf->device;
fis[8] = tf->hob_lbal;
fis[9] = tf->hob_lbam;
fis[10] = tf->hob_lbah;
fis[11] = tf->hob_feature;
fis[12] = tf->nsect;
fis[13] = tf->hob_nsect;
fis[14] = 0;
fis[15] = tf->ctl;
fis[16] = tf->auxiliary & 0xff;
fis[17] = (tf->auxiliary >> 8) & 0xff;
fis[18] = (tf->auxiliary >> 16) & 0xff;
fis[19] = (tf->auxiliary >> 24) & 0xff;
}
EXPORT_SYMBOL_GPL(ata_tf_to_fis);
/**
* ata_tf_from_fis - Convert SATA FIS to ATA taskfile
* @fis: Buffer from which data will be input
* @tf: Taskfile to output
*
* Converts a serial ATA FIS structure to a standard ATA taskfile.
*
* LOCKING:
* Inherited from caller.
*/
void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf)
{
tf->status = fis[2];
tf->error = fis[3];
tf->lbal = fis[4];
tf->lbam = fis[5];
tf->lbah = fis[6];
tf->device = fis[7];
tf->hob_lbal = fis[8];
tf->hob_lbam = fis[9];
tf->hob_lbah = fis[10];
tf->nsect = fis[12];
tf->hob_nsect = fis[13];
}
EXPORT_SYMBOL_GPL(ata_tf_from_fis);
/**
* sata_link_debounce - debounce SATA phy status
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `scsi/scsi_cmnd.h`, `scsi/scsi_device.h`, `scsi/scsi_eh.h`, `linux/libata.h`, `linux/unaligned.h`, `libata.h`.
- Detected declarations: `function sata_scr_valid`, `function sata_scr_read`, `function sata_scr_write`, `function sata_scr_write`, `function structure`, `function ata_tf_from_fis`, `function context`, `function context`, `function sata_link_scr_lpm`, `function __sata_set_spd_needed`.
- 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.