drivers/gpu/drm/imagination/pvr_context.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imagination/pvr_context.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/imagination/pvr_context.c
Extension
.c
Size
12826 bytes
Lines
488
Domain
Driver Families
Bucket
drivers/gpu
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

if (IS_ERR(ctx->queues.geometry)) {
			err = PTR_ERR(ctx->queues.geometry);
			ctx->queues.geometry = NULL;
			goto err_destroy_queues;
		}

		ctx->queues.fragment = pvr_queue_create(ctx, DRM_PVR_JOB_TYPE_FRAGMENT,
							args, fw_ctx_map);
		if (IS_ERR(ctx->queues.fragment)) {
			err = PTR_ERR(ctx->queues.fragment);
			ctx->queues.fragment = NULL;
			goto err_destroy_queues;
		}
		return 0;

	case DRM_PVR_CTX_TYPE_COMPUTE:
		ctx->queues.compute = pvr_queue_create(ctx, DRM_PVR_JOB_TYPE_COMPUTE,
						       args, fw_ctx_map);
		if (IS_ERR(ctx->queues.compute)) {
			err = PTR_ERR(ctx->queues.compute);
			ctx->queues.compute = NULL;
			goto err_destroy_queues;
		}
		return 0;

	case DRM_PVR_CTX_TYPE_TRANSFER_FRAG:
		ctx->queues.transfer = pvr_queue_create(ctx, DRM_PVR_JOB_TYPE_TRANSFER_FRAG,
							args, fw_ctx_map);
		if (IS_ERR(ctx->queues.transfer)) {
			err = PTR_ERR(ctx->queues.transfer);
			ctx->queues.transfer = NULL;
			goto err_destroy_queues;
		}
		return 0;
	}

	return -EINVAL;

err_destroy_queues:
	pvr_context_destroy_queues(ctx);
	return err;
}

/**
 * pvr_context_kill_queues() - Kill queues attached to context.
 * @ctx: Context to kill queues on.
 *
 * Killing the queues implies making them unusable for future jobs, while still
 * letting the currently submitted jobs a chance to finish. Queue resources will
 * stay around until pvr_context_destroy_queues() is called.
 */
static void pvr_context_kill_queues(struct pvr_context *ctx)
{
	switch (ctx->type) {
	case DRM_PVR_CTX_TYPE_RENDER:
		pvr_queue_kill(ctx->queues.fragment);
		pvr_queue_kill(ctx->queues.geometry);
		break;
	case DRM_PVR_CTX_TYPE_COMPUTE:
		pvr_queue_kill(ctx->queues.compute);
		break;
	case DRM_PVR_CTX_TYPE_TRANSFER_FRAG:
		pvr_queue_kill(ctx->queues.transfer);
		break;
	}
}

/**
 * pvr_context_create() - Create a context.
 * @pvr_file: File to attach the created context to.
 * @args: Context creation arguments.
 *
 * Return:
 *  * 0 on success, or
 *  * A negative error code on failure.
 */
int pvr_context_create(struct pvr_file *pvr_file, struct drm_pvr_ioctl_create_context_args *args)
{
	struct pvr_device *pvr_dev = pvr_file->pvr_dev;
	struct pvr_context *ctx;
	int ctx_size;
	int err;

	/* Context creation flags are currently unused and must be zero. */
	if (args->flags)
		return -EINVAL;

	ctx_size = get_fw_obj_size(args->type);
	if (ctx_size < 0)
		return ctx_size;

Annotation

Implementation Notes