drivers/scsi/scsi_transport_sas.c
Source file repositories/reference/linux-study-clean/drivers/scsi/scsi_transport_sas.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/scsi_transport_sas.c- Extension
.c- Size
- 54232 bytes
- Lines
- 1987
- 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/init.hlinux/module.hlinux/jiffies.hlinux/err.hlinux/log2.hlinux/slab.hlinux/string.hlinux/blkdev.hlinux/bsg.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_transport.hscsi/scsi_transport_sas.hscsi_sas_internal.h
Detected Declarations
struct sas_host_attrsfunction sas_smp_dispatchfunction sas_bsg_initializefunction dma_opt_mapping_sizefunction sas_host_setupfunction sas_host_removefunction sas_host_matchfunction do_sas_phy_deletefunction sas_remove_childrenfunction sas_remove_hostfunction sas_get_addressfunction sas_tlr_supportedfunction sas_disable_tlrfunction sas_enable_tlrfunction sas_is_tlr_enabledfunction sas_ata_ncq_prio_supportedfunction DEVICE_ATTRfunction do_sas_phy_enablefunction store_sas_phy_enablefunction show_sas_phy_enablefunction do_sas_phy_resetfunction store_sas_link_resetfunction store_sas_hard_resetfunction sas_phy_setupfunction sas_phy_matchfunction sas_phy_releasefunction sas_phy_addfunction sas_phy_addfunction sas_phy_deletefunction scsi_is_sas_phyfunction sas_port_matchfunction sas_port_releasefunction sas_port_create_linkfunction sas_port_delete_linkfunction sas_port_addfunction sas_port_addfunction sas_port_deletefunction scsi_is_sas_portfunction sas_port_add_phyfunction sas_port_delete_phyfunction sas_port_mark_backlinkfunction SAS_DEVICE_ATTRfunction show_sas_rphy_enclosure_identifierfunction show_sas_rphy_bay_identifierfunction sas_read_port_mode_pagefunction sas_rphy_matchfunction sas_end_dev_matchfunction sas_expander_match
Annotated Snippet
error = device_add(&phy->dev);
if (error)
return error;
error = transport_add_device(&phy->dev);
if (error) {
device_del(&phy->dev);
return error;
}
transport_configure_device(&phy->dev);
return 0;
}
EXPORT_SYMBOL(sas_phy_add);
/**
* sas_phy_free - free a SAS PHY
* @phy: SAS PHY to free
*
* Frees the specified SAS PHY.
*
* Note:
* This function must only be called on a PHY that has not
* successfully been added using sas_phy_add().
*/
void sas_phy_free(struct sas_phy *phy)
{
transport_destroy_device(&phy->dev);
put_device(&phy->dev);
}
EXPORT_SYMBOL(sas_phy_free);
/**
* sas_phy_delete - remove SAS PHY
* @phy: SAS PHY to remove
*
* Removes the specified SAS PHY. If the SAS PHY has an
* associated remote PHY it is removed before.
*/
void
sas_phy_delete(struct sas_phy *phy)
{
struct device *dev = &phy->dev;
/* this happens if the phy is still part of a port when deleted */
BUG_ON(!list_empty(&phy->port_siblings));
transport_remove_device(dev);
device_del(dev);
transport_destroy_device(dev);
put_device(dev);
}
EXPORT_SYMBOL(sas_phy_delete);
/**
* scsi_is_sas_phy - check if a struct device represents a SAS PHY
* @dev: device to check
*
* Returns:
* %1 if the device represents a SAS PHY, %0 else
*/
int scsi_is_sas_phy(const struct device *dev)
{
return dev->release == sas_phy_release;
}
EXPORT_SYMBOL(scsi_is_sas_phy);
/*
* SAS Port attributes
*/
#define sas_port_show_simple(field, name, format_string, cast) \
static ssize_t \
show_sas_port_##name(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct sas_port *port = transport_class_to_sas_port(dev); \
\
return snprintf(buf, 20, format_string, cast port->field); \
}
#define sas_port_simple_attr(field, name, format_string, type) \
sas_port_show_simple(field, name, format_string, (type)) \
static DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL)
sas_port_simple_attr(num_phys, num_phys, "%d\n", int);
static DECLARE_TRANSPORT_CLASS(sas_port_class,
"sas_port", NULL, NULL, NULL);
static int sas_port_match(struct attribute_container *cont, struct device *dev)
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/jiffies.h`, `linux/err.h`, `linux/log2.h`, `linux/slab.h`, `linux/string.h`, `linux/blkdev.h`.
- Detected declarations: `struct sas_host_attrs`, `function sas_smp_dispatch`, `function sas_bsg_initialize`, `function dma_opt_mapping_size`, `function sas_host_setup`, `function sas_host_remove`, `function sas_host_match`, `function do_sas_phy_delete`, `function sas_remove_children`, `function sas_remove_host`.
- 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.