drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
Extension
.c
Size
20285 bytes
Lines
682
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_cotable {
	struct vmw_resource res;
	struct vmw_resource *ctx;
	size_t size_read_back;
	int seen_entries;
	u32 type;
	bool scrubbed;
	struct list_head resource_list;
};

/**
 * struct vmw_cotable_info - Static info about cotable types
 *
 * @min_initial_entries: Min number of initial intries at cotable allocation
 * for this cotable type.
 * @size: Size of each entry.
 * @unbind_func: Unbind call-back function.
 */
struct vmw_cotable_info {
	u32 min_initial_entries;
	u32 size;
	void (*unbind_func)(struct vmw_private *, struct list_head *,
			    bool);
};


/*
 * Getting the initial size right is difficult because it all depends
 * on what the userspace is doing. The sizes will be aligned up to
 * a PAGE_SIZE so we just want to make sure that for majority of apps
 * the initial number of entries doesn't require an immediate resize.
 * For all cotables except SVGACOTableDXElementLayoutEntry and
 * SVGACOTableDXBlendStateEntry the initial number of entries fits
 * within the PAGE_SIZE. For SVGACOTableDXElementLayoutEntry and
 * SVGACOTableDXBlendStateEntry we want to reserve two pages,
 * because that's what all apps will require initially.
 */
static const struct vmw_cotable_info co_info[] = {
	{1, sizeof(SVGACOTableDXRTViewEntry), &vmw_view_cotable_list_destroy},
	{1, sizeof(SVGACOTableDXDSViewEntry), &vmw_view_cotable_list_destroy},
	{1, sizeof(SVGACOTableDXSRViewEntry), &vmw_view_cotable_list_destroy},
	{PAGE_SIZE/sizeof(SVGACOTableDXElementLayoutEntry) + 1, sizeof(SVGACOTableDXElementLayoutEntry), NULL},
	{PAGE_SIZE/sizeof(SVGACOTableDXBlendStateEntry) + 1, sizeof(SVGACOTableDXBlendStateEntry), NULL},
	{1, sizeof(SVGACOTableDXDepthStencilEntry), NULL},
	{1, sizeof(SVGACOTableDXRasterizerStateEntry), NULL},
	{1, sizeof(SVGACOTableDXSamplerEntry), NULL},
	{1, sizeof(SVGACOTableDXStreamOutputEntry), &vmw_dx_streamoutput_cotable_list_scrub},
	{1, sizeof(SVGACOTableDXQueryEntry), NULL},
	{1, sizeof(SVGACOTableDXShaderEntry), &vmw_dx_shader_cotable_list_scrub},
	{1, sizeof(SVGACOTableDXUAViewEntry), &vmw_view_cotable_list_destroy}
};

/*
 * Cotables with bindings that we remove must be scrubbed first,
 * otherwise, the device will swap in an invalid context when we remove
 * bindings before scrubbing a cotable...
 */
const SVGACOTableType vmw_cotable_scrub_order[] = {
	SVGA_COTABLE_RTVIEW,
	SVGA_COTABLE_DSVIEW,
	SVGA_COTABLE_SRVIEW,
	SVGA_COTABLE_DXSHADER,
	SVGA_COTABLE_ELEMENTLAYOUT,
	SVGA_COTABLE_BLENDSTATE,
	SVGA_COTABLE_DEPTHSTENCIL,
	SVGA_COTABLE_RASTERIZERSTATE,
	SVGA_COTABLE_SAMPLER,
	SVGA_COTABLE_STREAMOUTPUT,
	SVGA_COTABLE_DXQUERY,
	SVGA_COTABLE_UAVIEW,
};

static int vmw_cotable_bind(struct vmw_resource *res,
			    struct ttm_validate_buffer *val_buf);
static int vmw_cotable_unbind(struct vmw_resource *res,
			      bool readback,
			      struct ttm_validate_buffer *val_buf);
static int vmw_cotable_create(struct vmw_resource *res);
static int vmw_cotable_destroy(struct vmw_resource *res);

static const struct vmw_res_func vmw_cotable_func = {
	.res_type = vmw_res_cotable,
	.needs_guest_memory = true,
	.may_evict = true,
	.prio = 3,
	.dirty_prio = 3,
	.type_name = "context guest backed object tables",
	.domain = VMW_BO_DOMAIN_MOB,
	.busy_domain = VMW_BO_DOMAIN_MOB,
	.create = vmw_cotable_create,

Annotation

Implementation Notes