arch/powerpc/platforms/book3s/vas-api.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/book3s/vas-api.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/book3s/vas-api.c- Extension
.c- Size
- 18088 bytes
- Lines
- 674
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/kernel.hlinux/device.hlinux/cdev.hlinux/fs.hlinux/slab.hlinux/uaccess.hlinux/kthread.hlinux/sched/signal.hlinux/mmu_context.hlinux/io.hasm/vas.huapi/asm/vas-api.h
Detected Declarations
struct coproc_instancefunction get_vas_user_win_reffunction ref_get_pid_and_taskfunction vas_update_csbfunction vas_dump_crbfunction coproc_openfunction coproc_ioc_tx_win_openfunction coproc_releasefunction do_fail_pastefunction vas_mmap_faultfunction reconfig_close_windowsfunction creditfunction mmapfunction coproc_mmapfunction coproc_ioctlfunction vas_register_coproc_apifunction vas_unregister_coproc_api
Annotated Snippet
static struct file_operations coproc_fops = {
.open = coproc_open,
.release = coproc_release,
.mmap = coproc_mmap,
.unlocked_ioctl = coproc_ioctl,
};
/*
* Supporting only nx-gzip coprocessor type now, but this API code
* extended to other coprocessor types later.
*/
int vas_register_coproc_api(struct module *mod, enum vas_cop_type cop_type,
const char *name,
const struct vas_user_win_ops *vops)
{
int rc = -EINVAL;
dev_t devno;
rc = alloc_chrdev_region(&coproc_device.devt, 1, 1, name);
if (rc) {
pr_err("Unable to allocate coproc major number: %i\n", rc);
return rc;
}
pr_devel("%s device allocated, dev [%i,%i]\n", name,
MAJOR(coproc_device.devt), MINOR(coproc_device.devt));
coproc_device.class = class_create(name);
if (IS_ERR(coproc_device.class)) {
rc = PTR_ERR(coproc_device.class);
pr_err("Unable to create %s class %d\n", name, rc);
goto err_class;
}
coproc_device.class->devnode = coproc_devnode;
coproc_device.cop_type = cop_type;
coproc_device.vops = vops;
coproc_fops.owner = mod;
cdev_init(&coproc_device.cdev, &coproc_fops);
devno = MKDEV(MAJOR(coproc_device.devt), 0);
rc = cdev_add(&coproc_device.cdev, devno, 1);
if (rc) {
pr_err("cdev_add() failed %d\n", rc);
goto err_cdev;
}
coproc_device.device = device_create(coproc_device.class, NULL,
devno, NULL, name, MINOR(devno));
if (IS_ERR(coproc_device.device)) {
rc = PTR_ERR(coproc_device.device);
pr_err("Unable to create coproc-%d %d\n", MINOR(devno), rc);
goto err;
}
pr_devel("Added dev [%d,%d]\n", MAJOR(devno), MINOR(devno));
return 0;
err:
cdev_del(&coproc_device.cdev);
err_cdev:
class_destroy(coproc_device.class);
err_class:
unregister_chrdev_region(coproc_device.devt, 1);
return rc;
}
void vas_unregister_coproc_api(void)
{
dev_t devno;
cdev_del(&coproc_device.cdev);
devno = MKDEV(MAJOR(coproc_device.devt), 0);
device_destroy(coproc_device.class, devno);
class_destroy(coproc_device.class);
unregister_chrdev_region(coproc_device.devt, 1);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/device.h`, `linux/cdev.h`, `linux/fs.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/kthread.h`, `linux/sched/signal.h`.
- Detected declarations: `struct coproc_instance`, `function get_vas_user_win_ref`, `function ref_get_pid_and_task`, `function vas_update_csb`, `function vas_dump_crb`, `function coproc_open`, `function coproc_ioc_tx_win_open`, `function coproc_release`, `function do_fail_paste`, `function vas_mmap_fault`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.