drivers/accel/ethosu/ethosu_drv.c
Source file repositories/reference/linux-study-clean/drivers/accel/ethosu/ethosu_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/ethosu/ethosu_drv.c- Extension
.c- Size
- 10381 bytes
- Lines
- 404
- Domain
- Driver Families
- Bucket
- drivers/accel
- 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.
- 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/bitfield.hlinux/clk.hlinux/genalloc.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/pm_runtime.hdrm/drm_drv.hdrm/drm_ioctl.hdrm/drm_utils.hdrm/drm_gem.hdrm/drm_accel.hdrm/ethosu_accel.hethosu_drv.hethosu_device.hethosu_gem.hethosu_job.h
Detected Declarations
function ethosu_ioctl_dev_queryfunction ethosu_ioctl_bo_createfunction ethosu_ioctl_bo_waitfunction ethosu_ioctl_bo_mmap_offsetfunction ethosu_ioctl_cmdstream_bo_createfunction ethosu_openfunction ethosu_postclosefunction ethosu_resetfunction ethosu_device_resumefunction ethosu_device_suspendfunction ethosu_sram_initfunction ethosu_initfunction ethosu_probefunction ethosu_remove
Annotated Snippet
switch (args->type) {
case DRM_ETHOSU_DEV_QUERY_NPU_INFO:
args->size = sizeof(ethosudev->npu_info);
return 0;
default:
return -EINVAL;
}
}
switch (args->type) {
case DRM_ETHOSU_DEV_QUERY_NPU_INFO:
if (args->size < offsetofend(struct drm_ethosu_npu_info, sram_size))
return -EINVAL;
return copy_struct_to_user(u64_to_user_ptr(args->pointer),
args->size,
ðosudev->npu_info,
sizeof(ethosudev->npu_info), NULL);
default:
return -EINVAL;
}
}
#define ETHOSU_BO_FLAGS DRM_ETHOSU_BO_NO_MMAP
static int ethosu_ioctl_bo_create(struct drm_device *ddev, void *data,
struct drm_file *file)
{
struct drm_ethosu_bo_create *args = data;
int cookie, ret;
if (!drm_dev_enter(ddev, &cookie))
return -ENODEV;
if (!args->size || (args->flags & ~ETHOSU_BO_FLAGS)) {
ret = -EINVAL;
goto out_dev_exit;
}
ret = ethosu_gem_create_with_handle(file, ddev, &args->size,
args->flags, &args->handle);
out_dev_exit:
drm_dev_exit(cookie);
return ret;
}
static int ethosu_ioctl_bo_wait(struct drm_device *ddev, void *data,
struct drm_file *file)
{
struct drm_ethosu_bo_wait *args = data;
int cookie, ret;
unsigned long timeout = drm_timeout_abs_to_jiffies(args->timeout_ns);
if (args->pad)
return -EINVAL;
if (!drm_dev_enter(ddev, &cookie))
return -ENODEV;
ret = drm_gem_dma_resv_wait(file, args->handle, true, timeout);
drm_dev_exit(cookie);
return ret;
}
static int ethosu_ioctl_bo_mmap_offset(struct drm_device *ddev, void *data,
struct drm_file *file)
{
struct drm_ethosu_bo_mmap_offset *args = data;
struct drm_gem_object *obj;
if (args->pad)
return -EINVAL;
obj = drm_gem_object_lookup(file, args->handle);
if (!obj)
return -ENOENT;
args->offset = drm_vma_node_offset_addr(&obj->vma_node);
drm_gem_object_put(obj);
return 0;
}
static int ethosu_ioctl_cmdstream_bo_create(struct drm_device *ddev, void *data,
struct drm_file *file)
{
struct drm_ethosu_cmdstream_bo_create *args = data;
int cookie, ret;
if (!drm_dev_enter(ddev, &cookie))
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/genalloc.h`, `linux/io.h`, `linux/iopoll.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`.
- Detected declarations: `function ethosu_ioctl_dev_query`, `function ethosu_ioctl_bo_create`, `function ethosu_ioctl_bo_wait`, `function ethosu_ioctl_bo_mmap_offset`, `function ethosu_ioctl_cmdstream_bo_create`, `function ethosu_open`, `function ethosu_postclose`, `function ethosu_reset`, `function ethosu_device_resume`, `function ethosu_device_suspend`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
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.