drivers/scsi/libsas/sas_scsi_host.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libsas/sas_scsi_host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libsas/sas_scsi_host.c- Extension
.c- Size
- 32445 bytes
- Lines
- 1245
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kthread.hlinux/firmware.hlinux/export.hlinux/ctype.hlinux/hex.hlinux/kernel.hsas_internal.hscsi/scsi_host.hscsi/scsi_device.hscsi/scsi_tcq.hscsi/scsi.hscsi/scsi_eh.hscsi/scsi_transport.hscsi/scsi_transport_sas.hscsi/sas_ata.hscsi_sas_internal.hscsi_transport_api.hscsi_priv.hlinux/err.hlinux/blkdev.hlinux/freezer.hlinux/gfp.hlinux/scatterlist.hlinux/libata.h
Detected Declarations
enum task_dispositionfunction SCSIfunction sas_scsi_task_donefunction sas_queuecommandfunction sas_eh_finish_cmdfunction sas_scsi_clear_queue_lufunction list_for_each_entry_safefunction sas_scsi_clear_queue_I_Tfunction list_for_each_entry_safefunction sas_scsi_clear_queue_portfunction list_for_each_entry_safefunction sas_scsi_find_taskfunction sas_recover_lufunction sas_recover_I_Tfunction sas_queue_resetfunction sas_eh_abort_handlerfunction sas_eh_device_reset_handlerfunction sas_eh_target_reset_handlerfunction try_to_reset_cmd_devicefunction sas_eh_handle_sas_errorsfunction sas_eh_handle_resetsfunction sas_scsi_recover_hostfunction sas_ioctlfunction list_for_each_entryfunction sas_target_allocfunction sas_sdev_configurefunction sas_change_queue_depthfunction sas_bios_paramfunction sas_task_internal_donefunction sas_task_internal_timedoutfunction sas_execute_internal_abortfunction sas_execute_internal_abort_singlefunction sas_execute_internal_abort_devfunction sas_execute_tmffunction sas_execute_ssp_tmffunction sas_abort_task_setfunction sas_clear_task_setfunction sas_lu_resetfunction sas_query_taskfunction sas_abort_taskfunction sas_task_abortfunction sas_sdev_initfunction sas_target_destroyfunction sas_request_addrexport sas_queuecommandexport sas_get_local_phyexport sas_eh_abort_handlerexport sas_eh_device_reset_handler
Annotated Snippet
switch (ts->stat) {
case SAS_DEV_NO_RESPONSE:
case SAS_INTERRUPTED:
case SAS_PHY_DOWN:
case SAS_NAK_R_ERR:
case SAS_OPEN_TO:
hs = DID_NO_CONNECT;
break;
case SAS_DATA_UNDERRUN:
scsi_set_resid(sc, ts->residual);
if (scsi_bufflen(sc) - scsi_get_resid(sc) < sc->underflow)
hs = DID_ERROR;
break;
case SAS_DATA_OVERRUN:
hs = DID_ERROR;
break;
case SAS_QUEUE_FULL:
hs = DID_SOFT_ERROR; /* retry */
break;
case SAS_DEVICE_UNKNOWN:
hs = DID_BAD_TARGET;
break;
case SAS_OPEN_REJECT:
if (ts->open_rej_reason == SAS_OREJ_RSVD_RETRY)
hs = DID_SOFT_ERROR; /* retry */
else
hs = DID_ERROR;
break;
case SAS_PROTO_RESPONSE:
pr_notice("LLDD:%s sent SAS_PROTO_RESP for an SSP task; please report this\n",
task->dev->port->ha->sas_ha_name);
break;
case SAS_ABORTED_TASK:
hs = DID_ABORT;
break;
case SAS_SAM_STAT_CHECK_CONDITION:
memcpy(sc->sense_buffer, ts->buf,
min(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
stat = SAS_SAM_STAT_CHECK_CONDITION;
break;
default:
stat = ts->stat;
break;
}
}
sc->result = (hs << 16) | stat;
ASSIGN_SAS_TASK(sc, NULL);
sas_free_task(task);
}
static void sas_scsi_task_done(struct sas_task *task)
{
struct scsi_cmnd *sc = task->uldd_task;
struct domain_device *dev = task->dev;
struct sas_ha_struct *ha = dev->port->ha;
unsigned long flags;
spin_lock_irqsave(&dev->done_lock, flags);
if (test_bit(SAS_HA_FROZEN, &ha->state))
task = NULL;
else
ASSIGN_SAS_TASK(sc, NULL);
spin_unlock_irqrestore(&dev->done_lock, flags);
if (unlikely(!task)) {
/* task will be completed by the error handler */
pr_debug("task done but aborted\n");
return;
}
if (unlikely(!sc)) {
pr_debug("task_done called with non existing SCSI cmnd!\n");
sas_free_task(task);
return;
}
sas_end_task(sc, task);
scsi_done(sc);
}
static struct sas_task *sas_create_task(struct scsi_cmnd *cmd,
struct domain_device *dev,
gfp_t gfp_flags)
{
struct sas_task *task = sas_alloc_task(gfp_flags);
struct scsi_lun lun;
if (!task)
return NULL;
Annotation
- Immediate include surface: `linux/kthread.h`, `linux/firmware.h`, `linux/export.h`, `linux/ctype.h`, `linux/hex.h`, `linux/kernel.h`, `sas_internal.h`, `scsi/scsi_host.h`.
- Detected declarations: `enum task_disposition`, `function SCSI`, `function sas_scsi_task_done`, `function sas_queuecommand`, `function sas_eh_finish_cmd`, `function sas_scsi_clear_queue_lu`, `function list_for_each_entry_safe`, `function sas_scsi_clear_queue_I_T`, `function list_for_each_entry_safe`, `function sas_scsi_clear_queue_port`.
- 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.