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.

Dependency Surface

Detected Declarations

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,
					   &ethosudev->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

Implementation Notes