/** * pvr_context_destroy_queues() - Destroy all queues attached to a context. * @ctx: Context to destroy queues on. * * Should be called when the last reference to a context object is dropped. * It releases all resources attached to the queues bound to this context.
*/ staticvoid pvr_context_destroy_queues(struct pvr_context *ctx)
{ switch (ctx->type) { case DRM_PVR_CTX_TYPE_RENDER:
pvr_queue_destroy(ctx->queues.fragment);
pvr_queue_destroy(ctx->queues.geometry); break; case DRM_PVR_CTX_TYPE_COMPUTE:
pvr_queue_destroy(ctx->queues.compute); break; case DRM_PVR_CTX_TYPE_TRANSFER_FRAG:
pvr_queue_destroy(ctx->queues.transfer); break;
}
}
/** * pvr_context_create_queues() - Create all queues attached to a context. * @ctx: Context to create queues on. * @args: Context creation arguments passed by userspace. * @fw_ctx_map: CPU mapping of the FW context object. * * Return: * * 0 on success, or * * A negative error code otherwise.
*/ staticint pvr_context_create_queues(struct pvr_context *ctx, struct drm_pvr_ioctl_create_context_args *args, void *fw_ctx_map)
{ int 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.
*/ staticvoid 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;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM;
err = xa_alloc(&pvr_file->ctx_handles, &args->handle, ctx, xa_limit_32b, GFP_KERNEL); if (err) { /* * It's possible that another thread could have taken a reference on the context at * this point as it is in the ctx_ids xarray. Therefore instead of directly * destroying the context, drop a reference instead.
*/
pvr_context_put(ctx); return err;
}
/** * pvr_context_destroy() - Destroy context * @pvr_file: Pointer to pvr_file structure. * @handle: Userspace context handle. * * Removes context from context list and drops initial reference. Context will * then be destroyed once all outstanding references are dropped. * * Return: * * 0 on success, or * * -%EINVAL if context not in context list.
*/ int
pvr_context_destroy(struct pvr_file *pvr_file, u32 handle)
{ struct pvr_context *ctx = xa_erase(&pvr_file->ctx_handles, handle);
if (!ctx) return -EINVAL;
/* Make sure nothing can be queued to the queues after that point. */
pvr_context_kill_queues(ctx);
/* Release the reference held by the handle set. */
pvr_context_put(ctx);
return 0;
}
/** * pvr_destroy_contexts_for_file: Destroy any contexts associated with the given file * @pvr_file: Pointer to pvr_file structure. * * Removes all contexts associated with @pvr_file from the device context list and drops initial * references. Contexts will then be destroyed once all outstanding references are dropped.
*/ void pvr_destroy_contexts_for_file(struct pvr_file *pvr_file)
{ struct pvr_device *pvr_dev = pvr_file->pvr_dev; struct pvr_context *ctx; unsignedlong handle;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.