drivers/gpu/drm/vmwgfx/vmwgfx_so.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_so.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_so.c
Extension
.c
Size
18466 bytes
Lines
577
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

struct vmw_view {
	struct rcu_head rcu;
	struct vmw_resource res;
	struct vmw_resource *ctx;      /* Immutable */
	struct vmw_resource *srf;      /* Immutable */
	struct vmw_resource *cotable;  /* Immutable */
	struct list_head srf_head;     /* Protected by binding_mutex */
	struct list_head cotable_head; /* Protected by binding_mutex */
	unsigned view_type;            /* Immutable */
	unsigned view_id;              /* Immutable */
	u32 cmd_size;                  /* Immutable */
	bool committed;                /* Protected by binding_mutex */
	u32 cmd[];		       /* Immutable */
};

static int vmw_view_create(struct vmw_resource *res);
static int vmw_view_destroy(struct vmw_resource *res);
static void vmw_hw_view_destroy(struct vmw_resource *res);
static void vmw_view_commit_notify(struct vmw_resource *res,
				   enum vmw_cmdbuf_res_state state);

static const struct vmw_res_func vmw_view_func = {
	.res_type = vmw_res_view,
	.needs_guest_memory = false,
	.may_evict = false,
	.type_name = "DX view",
	.domain = VMW_BO_DOMAIN_SYS,
	.busy_domain = VMW_BO_DOMAIN_SYS,
	.create = vmw_view_create,
	.commit_notify = vmw_view_commit_notify,
};

/**
 * struct vmw_view_define - view define command body stub
 *
 * @view_id: The device id of the view being defined
 * @sid: The surface id of the view being defined
 *
 * This generic struct is used by the code to change @view_id and @sid of a
 * saved view define command.
 */
struct vmw_view_define {
	uint32 view_id;
	uint32 sid;
};

/**
 * vmw_view - Convert a struct vmw_resource to a struct vmw_view
 *
 * @res: Pointer to the resource to convert.
 *
 * Returns a pointer to a struct vmw_view.
 */
static struct vmw_view *vmw_view(struct vmw_resource *res)
{
	return container_of(res, struct vmw_view, res);
}

/**
 * vmw_view_commit_notify - Notify that a view operation has been committed to
 * hardware from a user-supplied command stream.
 *
 * @res: Pointer to the view resource.
 * @state: Indicating whether a creation or removal has been committed.
 *
 */
static void vmw_view_commit_notify(struct vmw_resource *res,
				   enum vmw_cmdbuf_res_state state)
{
	struct vmw_view *view = vmw_view(res);
	struct vmw_private *dev_priv = res->dev_priv;

	mutex_lock(&dev_priv->binding_mutex);
	if (state == VMW_CMDBUF_RES_ADD) {
		struct vmw_surface *srf = vmw_res_to_srf(view->srf);

		list_add_tail(&view->srf_head, &srf->view_list);
		vmw_cotable_add_resource(view->cotable, &view->cotable_head);
		view->committed = true;
		res->id = view->view_id;

	} else {
		list_del_init(&view->cotable_head);
		list_del_init(&view->srf_head);
		view->committed = false;
		res->id = -1;
	}
	mutex_unlock(&dev_priv->binding_mutex);
}

Annotation

Implementation Notes