drivers/infiniband/hw/hfi1/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/debugfs.c- Extension
.c- Size
- 31310 bytes
- Lines
- 1336
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- 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/debugfs.hlinux/seq_file.hlinux/kernel.hlinux/export.hlinux/string.hlinux/types.hlinux/ratelimit.hlinux/fault-inject.hhfi.htrace.hdebugfs.hdevice.hqp.hsdma.hfault.h
Detected Declarations
struct counter_infofunction _opcode_stats_seq_stopfunction _opcode_stats_seq_showfunction _tx_opcode_stats_seq_stopfunction for_each_possible_cpufunction _ctx_stats_seq_stopfunction _qp_stats_seq_stopfunction _qp_stats_seq_showfunction _sdes_seq_stopfunction _rcds_seq_stopfunction _pios_seq_stopfunction dev_counters_readfunction dev_names_readfunction file_inodefunction portcntrs_debugfs_readfunction check_dyn_flagfunction asic_flags_readfunction asic_flags_writefunction dc8051_memory_readfunction debugfs_lcb_readfunction debugfs_lcb_writefunction qsfp_debugfs_dumpfunction __i2c_debugfs_writefunction i2c1_debugfs_writefunction i2c2_debugfs_writefunction __i2c_debugfs_readfunction i2c1_debugfs_readfunction i2c2_debugfs_readfunction __qsfp_debugfs_writefunction qsfp1_debugfs_writefunction qsfp2_debugfs_writefunction __qsfp_debugfs_readfunction qsfp1_debugfs_readfunction qsfp2_debugfs_readfunction __i2c_debugfs_openfunction i2c1_debugfs_openfunction i2c2_debugfs_openfunction __i2c_debugfs_releasefunction i2c1_debugfs_releasefunction i2c2_debugfs_releasefunction __qsfp_debugfs_openfunction qsfp1_debugfs_openfunction qsfp2_debugfs_openfunction __qsfp_debugfs_releasefunction qsfp1_debugfs_releasefunction qsfp2_debugfs_releasefunction exprom_wp_setfunction exprom_wp_debugfs_read
Annotated Snippet
const struct file_operations ops;
};
/*
* Could use file_inode(file)->i_ino to figure out which file,
* instead of separate routine for each, but for now, this works...
*/
/* read the per-port names (same for each port) */
static ssize_t portnames_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
char *names;
size_t avail;
struct hfi1_devdata *dd;
ssize_t rval;
dd = private2dd(file);
avail = hfi1_read_portcntrs(dd->pport, &names, NULL);
rval = simple_read_from_buffer(buf, count, ppos, names, avail);
return rval;
}
/* read the per-port counters */
static ssize_t portcntrs_debugfs_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
u64 *counters;
size_t avail;
struct hfi1_pportdata *ppd;
ssize_t rval;
ppd = private2ppd(file);
avail = hfi1_read_portcntrs(ppd, NULL, &counters);
rval = simple_read_from_buffer(buf, count, ppos, counters, avail);
return rval;
}
static void check_dyn_flag(u64 scratch0, char *p, int size, int *used,
int this_hfi, int hfi, u32 flag, const char *what)
{
u32 mask;
mask = flag << (hfi ? CR_DYN_SHIFT : 0);
if (scratch0 & mask) {
*used += scnprintf(p + *used, size - *used,
" 0x%08x - HFI%d %s in use, %s device\n",
mask, hfi, what,
this_hfi == hfi ? "this" : "other");
}
}
static ssize_t asic_flags_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct hfi1_pportdata *ppd;
struct hfi1_devdata *dd;
u64 scratch0;
char *tmp;
int ret = 0;
int size;
int used;
int i;
ppd = private2ppd(file);
dd = ppd->dd;
size = PAGE_SIZE;
used = 0;
tmp = kmalloc(size, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
scratch0 = read_csr(dd, ASIC_CFG_SCRATCH);
used += scnprintf(tmp + used, size - used,
"Resource flags: 0x%016llx\n", scratch0);
/* check permanent flag */
if (scratch0 & CR_THERM_INIT) {
used += scnprintf(tmp + used, size - used,
" 0x%08x - thermal monitoring initialized\n",
(u32)CR_THERM_INIT);
}
/* check each dynamic flag on each HFI */
for (i = 0; i < 2; i++) {
check_dyn_flag(scratch0, tmp, size, &used, dd->hfi1_id, i,
CR_SBUS, "SBus");
check_dyn_flag(scratch0, tmp, size, &used, dd->hfi1_id, i,
CR_EPROM, "EPROM");
check_dyn_flag(scratch0, tmp, size, &used, dd->hfi1_id, i,
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/seq_file.h`, `linux/kernel.h`, `linux/export.h`, `linux/string.h`, `linux/types.h`, `linux/ratelimit.h`, `linux/fault-inject.h`.
- Detected declarations: `struct counter_info`, `function _opcode_stats_seq_stop`, `function _opcode_stats_seq_show`, `function _tx_opcode_stats_seq_stop`, `function for_each_possible_cpu`, `function _ctx_stats_seq_stop`, `function _qp_stats_seq_stop`, `function _qp_stats_seq_show`, `function _sdes_seq_stop`, `function _rcds_seq_stop`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.
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.