drivers/scsi/libsas/sas_ata.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libsas/sas_ata.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libsas/sas_ata.c- Extension
.c- Size
- 26723 bytes
- Lines
- 1042
- 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.
- 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/scatterlist.hlinux/slab.hlinux/async.hlinux/export.hscsi/sas_ata.hsas_internal.hscsi/scsi_host.hscsi/scsi_device.hscsi/scsi_tcq.hscsi/scsi.hscsi/scsi_transport.hscsi/scsi_transport_sas.hscsi_sas_internal.hscsi_transport_api.hscsi/scsi_eh.h
Detected Declarations
function SCSIfunction sas_ata_task_donefunction sas_ata_qc_issuefunction sas_ata_qc_fill_rtffunction sas_get_ata_command_setfunction sas_get_ata_infofunction sas_ata_clear_pendingfunction smp_ata_check_ready_typefunction smp_ata_check_readyfunction local_ata_check_readyfunction sas_ata_printkfunction sas_ata_wait_after_resetfunction sas_ata_hard_resetfunction sas_ata_internal_abortfunction sas_ata_post_internalfunction sas_ata_set_dmamodefunction sas_ata_sched_ehfunction sas_ata_end_ehfunction sas_ata_preresetfunction sas_ata_initfunction sas_ata_task_abortfunction sas_probe_satafunction list_for_each_entry_safefunction sas_ata_add_devfunction sas_ata_flush_pm_ehfunction list_for_each_entry_safefunction sas_suspend_satafunction sas_resume_satafunction sas_discover_satafunction async_sas_ata_ehfunction sas_ata_strategy_handlerfunction list_for_each_entryfunction sas_ata_ehfunction list_for_each_entry_safefunction sas_ata_schedule_resetfunction sas_ata_wait_ehfunction sas_ata_device_link_abortfunction sas_execute_ata_cmdfunction sas_ncq_prio_supported_showfunction sas_ncq_prio_enable_showfunction sas_ncq_prio_enable_storefunction sas_ata_attr_is_visibleexport smp_ata_check_ready_typeexport sas_ata_schedule_resetexport sas_ata_device_link_abortexport sas_execute_ata_cmdexport sas_ata_sdev_attr_group
Annotated Snippet
if (!link->sactive) {
qc->err_mask |= ac_err_mask(dev->sata_dev.fis[2]);
} else {
link->eh_info.err_mask |= ac_err_mask(dev->sata_dev.fis[2]);
if (unlikely(link->eh_info.err_mask))
qc->flags |= ATA_QCFLAG_EH;
}
} else {
ac = sas_to_ata_err(stat);
if (ac) {
pr_warn("%s: SAS error 0x%x\n", __func__, stat->stat);
/* We saw a SAS error. Send a vague error. */
if (!link->sactive) {
qc->err_mask = ac;
} else {
link->eh_info.err_mask |= AC_ERR_DEV;
qc->flags |= ATA_QCFLAG_EH;
}
dev->sata_dev.fis[2] = ATA_ERR | ATA_DRDY; /* tf status */
dev->sata_dev.fis[3] = ATA_ABORTED; /* tf error */
}
}
qc->lldd_task = NULL;
ata_qc_complete(qc);
spin_unlock_irqrestore(ap->lock, flags);
qc_already_gone:
sas_free_task(task);
}
static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
__must_hold(ap->lock)
{
struct sas_task *task;
struct scatterlist *sg;
int ret = AC_ERR_SYSTEM;
unsigned int si, xfer = 0;
struct ata_port *ap = qc->ap;
struct domain_device *dev = ap->private_data;
struct sas_ha_struct *sas_ha = dev->port->ha;
struct Scsi_Host *host = sas_ha->shost;
struct sas_internal *i = to_sas_internal(host->transportt);
/* TODO: we should try to remove that unlock */
spin_unlock(ap->lock);
/* If the device fell off, no sense in issuing commands */
if (test_bit(SAS_DEV_GONE, &dev->state))
goto out;
task = sas_alloc_task(GFP_ATOMIC);
if (!task)
goto out;
task->dev = dev;
task->task_proto = SAS_PROTOCOL_STP;
task->task_done = sas_ata_task_done;
/* For NCQ commands, zero out the tag libata assigned us */
if (ata_is_ncq(qc->tf.protocol))
qc->tf.nsect = 0;
ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *)&task->ata_task.fis);
task->uldd_task = qc;
if (ata_is_atapi(qc->tf.protocol)) {
memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len);
task->total_xfer_len = qc->nbytes;
task->num_scatter = qc->n_elem;
task->data_dir = qc->dma_dir;
} else if (!ata_is_data(qc->tf.protocol)) {
task->data_dir = DMA_NONE;
} else {
for_each_sg(qc->sg, sg, qc->n_elem, si)
xfer += sg_dma_len(sg);
task->total_xfer_len = xfer;
task->num_scatter = si;
task->data_dir = qc->dma_dir;
}
task->scatter = qc->sg;
qc->lldd_task = task;
task->ata_task.use_ncq = ata_is_ncq(qc->tf.protocol);
task->ata_task.dma_xfer = ata_is_dma(qc->tf.protocol);
if (qc->flags & ATA_QCFLAG_RESULT_TF)
task->ata_task.return_fis_on_success = 1;
if (qc->scsicmd)
Annotation
- Immediate include surface: `linux/scatterlist.h`, `linux/slab.h`, `linux/async.h`, `linux/export.h`, `scsi/sas_ata.h`, `sas_internal.h`, `scsi/scsi_host.h`, `scsi/scsi_device.h`.
- Detected declarations: `function SCSI`, `function sas_ata_task_done`, `function sas_ata_qc_issue`, `function sas_ata_qc_fill_rtf`, `function sas_get_ata_command_set`, `function sas_get_ata_info`, `function sas_ata_clear_pending`, `function smp_ata_check_ready_type`, `function smp_ata_check_ready`, `function local_ata_check_ready`.
- 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.
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.