drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Source file repositories/reference/linux-study-clean/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c- Extension
.c- Size
- 155263 bytes
- Lines
- 5340
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/sched/clock.hhisi_sas.h
Detected Declarations
struct hisi_sas_protect_iu_v3_hwstruct hisi_sas_complete_v3_hdrstruct hisi_sas_err_record_v3struct hisi_sas_debugfs_reg_lustruct hisi_sas_debugfs_regenum fifo_dump_mode_v3_hwenum fifo_trigger_mode_v3_hwfunction hisi_sas_read32function hisi_sas_write32function hisi_sas_phy_write32function hisi_sas_phy_read32function interrupt_enable_v3_hwfunction init_reg_v3_hwfunction config_phy_opt_mode_v3_hwfunction config_id_frame_v3_hwfunction setup_itct_v3_hwfunction clear_itct_v3_hwfunction dereg_device_v3_hwfunction reset_hw_v3_hwfunction hw_init_v3_hwfunction enable_phy_v3_hwfunction disable_phy_v3_hwfunction start_phy_v3_hwfunction phy_hard_reset_v3_hwfunction phy_get_max_linkrate_v3_hwfunction phys_init_v3_hwfunction sl_notify_ssp_v3_hwfunction get_wideport_bitmap_v3_hwfunction start_delivery_v3_hwfunction list_for_each_entry_safefunction prep_prd_sge_v3_hwfunction for_each_sgfunction prep_prd_sge_dif_v3_hwfunction for_each_sgfunction get_prot_chk_msk_v3_hwfunction fill_prot_v3_hwfunction prep_ssp_v3_hwfunction prep_smp_v3_hwfunction prep_ata_v3_hwfunction prep_abort_v3_hwfunction phy_up_v3_hwfunction phy_down_v3_hwfunction phy_bcast_v3_hwfunction int_phy_up_down_bcast_v3_hwfunction handle_chl_int1_v3_hwfunction phy_get_events_v3_hwfunction handle_chl_int2_v3_hwfunction handle_chl_int0_v3_hw
Annotated Snippet
static const struct file_operations debugfs_trigger_dump_v3_hw_fops = {
.write = &debugfs_trigger_dump_v3_hw_write,
.owner = THIS_MODULE,
};
enum {
HISI_SAS_BIST_LOOPBACK_MODE_DIGITAL = 0,
HISI_SAS_BIST_LOOPBACK_MODE_SERDES,
HISI_SAS_BIST_LOOPBACK_MODE_REMOTE,
};
static const struct {
int value;
char *name;
} debugfs_loop_linkrate_v3_hw[] = {
{ SAS_LINK_RATE_1_5_GBPS, "1.5 Gbit" },
{ SAS_LINK_RATE_3_0_GBPS, "3.0 Gbit" },
{ SAS_LINK_RATE_6_0_GBPS, "6.0 Gbit" },
{ SAS_LINK_RATE_12_0_GBPS, "12.0 Gbit" },
};
static int debugfs_bist_linkrate_v3_hw_show(struct seq_file *s, void *p)
{
struct hisi_hba *hisi_hba = s->private;
int i;
for (i = 0; i < ARRAY_SIZE(debugfs_loop_linkrate_v3_hw); i++) {
int match = (hisi_hba->debugfs_bist_linkrate ==
debugfs_loop_linkrate_v3_hw[i].value);
seq_printf(s, "%s%s%s ", match ? "[" : "",
debugfs_loop_linkrate_v3_hw[i].name,
match ? "]" : "");
}
seq_puts(s, "\n");
return 0;
}
static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp,
const char __user *buf,
size_t count, loff_t *ppos)
{
struct seq_file *m = filp->private_data;
struct hisi_hba *hisi_hba = m->private;
char kbuf[BIST_BUF_SIZE] = {}, *pkbuf;
bool found = false;
int i;
if (hisi_hba->debugfs_bist_enable)
return -EPERM;
if (count >= sizeof(kbuf))
return -EOVERFLOW;
if (copy_from_user(kbuf, buf, count))
return -EINVAL;
pkbuf = strstrip(kbuf);
for (i = 0; i < ARRAY_SIZE(debugfs_loop_linkrate_v3_hw); i++) {
if (!strncmp(debugfs_loop_linkrate_v3_hw[i].name,
pkbuf, BIST_BUF_SIZE)) {
hisi_hba->debugfs_bist_linkrate =
debugfs_loop_linkrate_v3_hw[i].value;
found = true;
break;
}
}
if (!found)
return -EINVAL;
return count;
}
DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_linkrate_v3_hw);
static const struct {
int value;
char *name;
} debugfs_loop_code_mode_v3_hw[] = {
{ HISI_SAS_BIST_CODE_MODE_PRBS7, "PRBS7" },
{ HISI_SAS_BIST_CODE_MODE_PRBS23, "PRBS23" },
{ HISI_SAS_BIST_CODE_MODE_PRBS31, "PRBS31" },
{ HISI_SAS_BIST_CODE_MODE_JTPAT, "JTPAT" },
{ HISI_SAS_BIST_CODE_MODE_CJTPAT, "CJTPAT" },
{ HISI_SAS_BIST_CODE_MODE_SCRAMBED_0, "SCRAMBED_0" },
{ HISI_SAS_BIST_CODE_MODE_TRAIN, "TRAIN" },
{ HISI_SAS_BIST_CODE_MODE_TRAIN_DONE, "TRAIN_DONE" },
{ HISI_SAS_BIST_CODE_MODE_HFTP, "HFTP" },
Annotation
- Immediate include surface: `linux/sched/clock.h`, `hisi_sas.h`.
- Detected declarations: `struct hisi_sas_protect_iu_v3_hw`, `struct hisi_sas_complete_v3_hdr`, `struct hisi_sas_err_record_v3`, `struct hisi_sas_debugfs_reg_lu`, `struct hisi_sas_debugfs_reg`, `enum fifo_dump_mode_v3_hw`, `enum fifo_trigger_mode_v3_hw`, `function hisi_sas_read32`, `function hisi_sas_write32`, `function hisi_sas_phy_write32`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.