drivers/scsi/smartpqi/smartpqi_sas_transport.c
Source file repositories/reference/linux-study-clean/drivers/scsi/smartpqi/smartpqi_sas_transport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/smartpqi/smartpqi_sas_transport.c- Extension
.c- Size
- 13464 bytes
- Lines
- 575
- 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.
- 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/bsg-lib.hscsi/scsi_host.hscsi/scsi_cmnd.hscsi/scsi_transport_sas.hlinux/unaligned.hsmartpqi.h
Detected Declarations
function Copyrightfunction pqi_free_sas_phyfunction pqi_sas_port_add_phyfunction pqi_sas_port_add_rphyfunction pqi_free_sas_portfunction pqi_free_sas_nodefunction list_for_each_entryfunction pqi_add_sas_hostfunction pqi_delete_sas_hostfunction pqi_add_sas_devicefunction pqi_remove_sas_devicefunction pqi_sas_get_linkerrorsfunction pqi_sas_get_enclosure_identifierfunction list_for_each_entryfunction list_for_each_entryfunction pqi_sas_get_bay_identifierfunction pqi_sas_phy_resetfunction pqi_sas_phy_enablefunction pqi_sas_phy_setupfunction pqi_sas_phy_releasefunction pqi_build_csmi_smp_passthru_bufferfunction pqi_build_sas_smp_handler_replyfunction pqi_sas_smp_handler
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* driver for Microchip PQI-based storage controllers
* Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
* Copyright (c) 2016-2018 Microsemi Corporation
* Copyright (c) 2016 PMC-Sierra, Inc.
*
* Questions/Comments/Bugfixes to storagedev@microchip.com
*
*/
#include <linux/kernel.h>
#include <linux/bsg-lib.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_transport_sas.h>
#include <linux/unaligned.h>
#include "smartpqi.h"
static struct pqi_sas_phy *pqi_alloc_sas_phy(struct pqi_sas_port *pqi_sas_port)
{
struct pqi_sas_phy *pqi_sas_phy;
struct sas_phy *phy;
pqi_sas_phy = kzalloc_obj(*pqi_sas_phy);
if (!pqi_sas_phy)
return NULL;
phy = sas_phy_alloc(pqi_sas_port->parent_node->parent_dev,
pqi_sas_port->next_phy_index);
if (!phy) {
kfree(pqi_sas_phy);
return NULL;
}
pqi_sas_port->next_phy_index++;
pqi_sas_phy->phy = phy;
pqi_sas_phy->parent_port = pqi_sas_port;
return pqi_sas_phy;
}
static void pqi_free_sas_phy(struct pqi_sas_phy *pqi_sas_phy)
{
struct sas_phy *phy = pqi_sas_phy->phy;
sas_port_delete_phy(pqi_sas_phy->parent_port->port, phy);
if (pqi_sas_phy->added_to_port)
list_del(&pqi_sas_phy->phy_list_entry);
sas_phy_delete(phy);
kfree(pqi_sas_phy);
}
static int pqi_sas_port_add_phy(struct pqi_sas_phy *pqi_sas_phy)
{
int rc;
struct pqi_sas_port *pqi_sas_port;
struct sas_phy *phy;
struct sas_identify *identify;
pqi_sas_port = pqi_sas_phy->parent_port;
phy = pqi_sas_phy->phy;
identify = &phy->identify;
memset(identify, 0, sizeof(*identify));
identify->sas_address = pqi_sas_port->sas_address;
identify->device_type = SAS_END_DEVICE;
identify->initiator_port_protocols = SAS_PROTOCOL_ALL;
identify->target_port_protocols = SAS_PROTOCOL_ALL;
phy->minimum_linkrate_hw = SAS_LINK_RATE_UNKNOWN;
phy->maximum_linkrate_hw = SAS_LINK_RATE_UNKNOWN;
phy->minimum_linkrate = SAS_LINK_RATE_UNKNOWN;
phy->maximum_linkrate = SAS_LINK_RATE_UNKNOWN;
phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
rc = sas_phy_add(pqi_sas_phy->phy);
if (rc)
return rc;
sas_port_add_phy(pqi_sas_port->port, pqi_sas_phy->phy);
list_add_tail(&pqi_sas_phy->phy_list_entry,
&pqi_sas_port->phy_list_head);
pqi_sas_phy->added_to_port = true;
return 0;
}
static int pqi_sas_port_add_rphy(struct pqi_sas_port *pqi_sas_port,
struct sas_rphy *rphy)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/bsg-lib.h`, `scsi/scsi_host.h`, `scsi/scsi_cmnd.h`, `scsi/scsi_transport_sas.h`, `linux/unaligned.h`, `smartpqi.h`.
- Detected declarations: `function Copyright`, `function pqi_free_sas_phy`, `function pqi_sas_port_add_phy`, `function pqi_sas_port_add_rphy`, `function pqi_free_sas_port`, `function pqi_free_sas_node`, `function list_for_each_entry`, `function pqi_add_sas_host`, `function pqi_delete_sas_host`, `function pqi_add_sas_device`.
- 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.