drivers/scsi/libsas/sas_phy.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libsas/sas_phy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libsas/sas_phy.c- Extension
.c- Size
- 4655 bytes
- Lines
- 190
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
sas_internal.hscsi/scsi_host.hscsi/scsi_transport.hscsi/scsi_transport_sas.hscsi_sas_internal.h
Detected Declarations
function SCSIfunction sas_phye_oob_donefunction sas_phye_oob_errorfunction sas_phye_spinup_holdfunction sas_phye_resume_timeoutfunction sas_phye_shutdownfunction sas_register_physfunction sas_unregister_phys
Annotated Snippet
switch (phy->error) {
case 1:
case 2:
i->dft->lldd_control_phy(phy, PHY_FUNC_HARD_RESET,
NULL);
break;
case 3:
default:
phy->error = 0;
phy->enabled = 0;
i->dft->lldd_control_phy(phy, PHY_FUNC_DISABLE, NULL);
break;
}
}
}
static void sas_phye_spinup_hold(struct work_struct *work)
{
struct asd_sas_event *ev = to_asd_sas_event(work);
struct asd_sas_phy *phy = ev->phy;
struct sas_ha_struct *sas_ha = phy->ha;
struct sas_internal *i =
to_sas_internal(sas_ha->shost->transportt);
phy->error = 0;
i->dft->lldd_control_phy(phy, PHY_FUNC_RELEASE_SPINUP_HOLD, NULL);
}
static void sas_phye_resume_timeout(struct work_struct *work)
{
struct asd_sas_event *ev = to_asd_sas_event(work);
struct asd_sas_phy *phy = ev->phy;
/* phew, lldd got the phy back in the nick of time */
if (!phy->suspended) {
dev_info(&phy->phy->dev, "resume timeout cancelled\n");
return;
}
phy->error = 0;
phy->suspended = 0;
sas_deform_port(phy, true);
}
static void sas_phye_shutdown(struct work_struct *work)
{
struct asd_sas_event *ev = to_asd_sas_event(work);
struct asd_sas_phy *phy = ev->phy;
struct sas_ha_struct *sas_ha = phy->ha;
struct sas_internal *i =
to_sas_internal(sas_ha->shost->transportt);
if (phy->enabled) {
int ret;
phy->error = 0;
phy->enabled = 0;
ret = i->dft->lldd_control_phy(phy, PHY_FUNC_DISABLE, NULL);
if (ret)
pr_notice("lldd disable phy%d returned %d\n", phy->id,
ret);
} else
pr_notice("phy%d is not enabled, cannot shutdown\n", phy->id);
phy->in_shutdown = 0;
}
/* ---------- Phy class registration ---------- */
int sas_register_phys(struct sas_ha_struct *sas_ha)
{
int i;
int err;
/* Now register the phys. */
for (i = 0; i < sas_ha->num_phys; i++) {
struct asd_sas_phy *phy = sas_ha->sas_phy[i];
phy->error = 0;
atomic_set(&phy->event_nr, 0);
INIT_LIST_HEAD(&phy->port_phy_el);
phy->port = NULL;
phy->ha = sas_ha;
spin_lock_init(&phy->frame_rcvd_lock);
spin_lock_init(&phy->sas_prim_lock);
phy->frame_rcvd_size = 0;
phy->phy = sas_phy_alloc(&sas_ha->shost->shost_gendev, i);
if (!phy->phy) {
Annotation
- Immediate include surface: `sas_internal.h`, `scsi/scsi_host.h`, `scsi/scsi_transport.h`, `scsi/scsi_transport_sas.h`, `scsi_sas_internal.h`.
- Detected declarations: `function SCSI`, `function sas_phye_oob_done`, `function sas_phye_oob_error`, `function sas_phye_spinup_hold`, `function sas_phye_resume_timeout`, `function sas_phye_shutdown`, `function sas_register_phys`, `function sas_unregister_phys`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.