drivers/sbus/char/oradax.c
Source file repositories/reference/linux-study-clean/drivers/sbus/char/oradax.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/sbus/char/oradax.c- Extension
.c- Size
- 26738 bytes
- Lines
- 989
- Domain
- Driver Families
- Bucket
- drivers/sbus
- 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.
- 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/uaccess.hlinux/module.hlinux/delay.hlinux/cdev.hlinux/slab.hlinux/mm.hasm/hypervisor.hasm/mdesc.hasm/oradax.h
Detected Declarations
struct dax_headerstruct dax_controlstruct dax_data_accessstruct dax_ccbstruct dax_ccastruct dax_ctxfunction dax_attachfunction mdesc_for_each_node_by_namefunction dax_detachfunction dax_devmapfunction dax_unlock_pagesfunction dax_lock_pagefunction dax_lock_pagesfunction dax_ccb_waitfunction dax_closefunction dax_readfunction dax_writefunction dax_openfunction dax_ccb_killfunction dax_ccb_infofunction dax_prt_ccbsfunction dax_preprocess_usr_ccbsfunction dax_ccb_execmodule init dax_attach
Annotated Snippet
static const struct file_operations dax_fops = {
.owner = THIS_MODULE,
.open = dax_open,
.read = dax_read,
.write = dax_write,
.mmap = dax_devmap,
.release = dax_close,
};
static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
size_t count, loff_t *ppos);
static int dax_ccb_info(u64 ca, struct ccb_info_result *info);
static int dax_ccb_kill(u64 ca, u16 *kill_res);
static struct cdev c_dev;
static dev_t first;
static const struct class cl = {
.name = DAX_NAME,
};
static int max_ccb_version;
static int dax_debug;
module_param(dax_debug, int, 0644);
MODULE_PARM_DESC(dax_debug, "Debug flags");
static int __init dax_attach(void)
{
unsigned long dummy, hv_rv, major, minor, minor_requested, max_ccbs;
struct mdesc_handle *hp = mdesc_grab();
char *prop, *dax_name;
bool found = false;
int len, ret = 0;
u64 pn;
if (hp == NULL) {
dax_err("Unable to grab mdesc");
return -ENODEV;
}
mdesc_for_each_node_by_name(hp, pn, "virtual-device") {
prop = (char *)mdesc_get_property(hp, pn, "name", &len);
if (prop == NULL)
continue;
if (strncmp(prop, "dax", strlen("dax")))
continue;
dax_dbg("Found node 0x%llx = %s", pn, prop);
prop = (char *)mdesc_get_property(hp, pn, "compatible", &len);
if (prop == NULL)
continue;
dax_dbg("Found node 0x%llx = %s", pn, prop);
found = true;
break;
}
if (!found) {
dax_err("No DAX device found");
ret = -ENODEV;
goto done;
}
if (strncmp(prop, DAX2_STR, strlen(DAX2_STR)) == 0) {
dax_name = DAX_NAME "2";
major = DAX2_MAJOR;
minor_requested = DAX2_MINOR;
max_ccb_version = 1;
dax_dbg("MD indicates DAX2 coprocessor");
} else if (strncmp(prop, DAX1_STR, strlen(DAX1_STR)) == 0) {
dax_name = DAX_NAME "1";
major = DAX1_MAJOR;
minor_requested = DAX1_MINOR;
max_ccb_version = 0;
dax_dbg("MD indicates DAX1 coprocessor");
} else {
dax_err("Unknown dax type: %s", prop);
ret = -ENODEV;
goto done;
}
minor = minor_requested;
dax_dbg("Registering DAX HV api with major %ld minor %ld", major,
minor);
if (sun4v_hvapi_register(HV_GRP_DAX, major, &minor)) {
dax_err("hvapi_register failed");
ret = -ENODEV;
goto done;
} else {
dax_dbg("Max minor supported by HV = %ld (major %ld)", minor,
major);
minor = min(minor, minor_requested);
Annotation
- Immediate include surface: `linux/uaccess.h`, `linux/module.h`, `linux/delay.h`, `linux/cdev.h`, `linux/slab.h`, `linux/mm.h`, `asm/hypervisor.h`, `asm/mdesc.h`.
- Detected declarations: `struct dax_header`, `struct dax_control`, `struct dax_data_access`, `struct dax_ccb`, `struct dax_cca`, `struct dax_ctx`, `function dax_attach`, `function mdesc_for_each_node_by_name`, `function dax_detach`, `function dax_devmap`.
- Atlas domain: Driver Families / drivers/sbus.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.