Various vmwgfx fixes
Subsystems (3)
cover Various vmwgfx fixes
Mostly problems caused by the new device support. Unfortunately a couple of rather big patches at the end. These add the missing bits required to run legacy user-space drivers on the new device
PATCH 1/7 drm/vmwgfx: Don't commit staged bindings if execbuf fails
If execbuf fails and binding commands are never sent to the device, don't commit the staged context bindings to the tracker.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +4 -2
@@ -114,8 +114,10 @@ static void vmw_resource_list_unreserve(struct list_head *list,* persistent context binding tracker. */ if (unlikely (val->staged_bindings)) { -vmw_context_binding_state_transfer - (val->res, val->staged_bindings); +if (!backoff) { +vmw_context_binding_state_transfer + (val->res, val->staged_bindings); + }kfree (val->staged_bindings); val->staged_bindings =NULL ; }
Signature · 1 line
1.7.10.4
PATCH 2/7 drm/vmwgfx: Fix regression caused by "drm/ttm: make ttm reservation calls behave like reservation calls"
In reply to Thomas HellstromThe call to ttm_eu_backoff_reservation() as part of an error path would cause a lock imbalance if the reservation ticket was not initialized. This error is easily triggered from user-space by submitting a bogus command stream.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +5 -4
@@ -2195,11 +2195,11 @@ int vmw_execbuf_process(struct drm_file *file_priv, ret =vmw_cmd_check_all (dev_priv, sw_context, kernel_commands, command_size);if (unlikely (ret !=0 )) - goto out_err; + goto out_err_nores; ret =vmw_resources_reserve (sw_context);if (unlikely (ret !=0 )) - goto out_err; + goto out_err_nores; ret =ttm_eu_reserve_buffers (&ticket, &sw_context->validate_nodes);if (unlikely (ret !=0 ))
@@ -2291,10 +2291,11 @@ int vmw_execbuf_process(struct drm_file *file_priv, out_unlock_binding:mutex_unlock (&dev_priv->binding_mutex); out_err: -vmw_resource_relocations_free (&sw_context->res_relocations); -vmw_free_relocations (sw_context);ttm_eu_backoff_reservation (&ticket, &sw_context->validate_nodes); +out_err_nores:vmw_resource_list_unreserve (&sw_context->resource_list, true); +vmw_resource_relocations_free (&sw_context->res_relocations); +vmw_free_relocations (sw_context);vmw_clear_validations (sw_context);if (unlikely (dev_priv->pinned_bo !=NULL && !dev_priv->query_cid_valid))
Signature · 1 line
1.7.10.4
PATCH 3/7 drm/vmwgfx: Fix SET_SHADER_CONST emulation on guest-backed devices
In reply to Thomas HellstromEmulate the SET_SHADER_CONST legacy command on guest-backed devices by issuing a SET_GB_SHADERCONSTS_INLINE command.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +35 -2
@@ -1529,6 +1529,39 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv, }/** +* vmw_cmd_set_shader_const - Validate an SVGA_3D_CMD_SET_SHADER_CONST +* command +* +* @dev_priv: Pointer to a device private struct. +* @sw_context: The software context being used for this batch. +* @header: Pointer to the command header in the command stream. +*/ +static int vmw_cmd_set_shader_const (struct vmw_private *dev_priv, +struct vmw_sw_context *sw_context, +SVGA3dCmdHeader *header) +{ +struct vmw_set_shader_const_cmd { +SVGA3dCmdHeader header; +SVGA3dCmdSetShaderConst body; + } *cmd; +int ret; + + cmd = container_of(header, struct vmw_set_shader_const_cmd, + header); + + ret =vmw_cmd_res_check (dev_priv, sw_context, vmw_res_context, + user_context_converter, &cmd->body.cid, +NULL ); +if (unlikely (ret !=0 )) +return ret; + +if (dev_priv->has_mob) + header->id =SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE ; + +return 0 ; +} + +/** * vmw_cmd_bind_gb_shader - Validate an SVGA_3D_CMD_BIND_GB_SHADER * command *
@@ -1642,8 +1675,8 @@ static const struct vmw_cmd_entry const vmw_cmd_entries[SVGA_3D_CMD_MAX] = { true, true, false),VMW_CMD_DEF (SVGA_3D_CMD_SET_SHADER , &vmw_cmd_set_shader, true, false, false), -VMW_CMD_DEF (SVGA_3D_CMD_SET_SHADER_CONST , &vmw_cmd_cid_check, - true, true, false), +VMW_CMD_DEF (SVGA_3D_CMD_SET_SHADER_CONST , &vmw_cmd_set_shader_const, + true, false, false),VMW_CMD_DEF (SVGA_3D_CMD_DRAW_PRIMITIVES , &vmw_cmd_draw, true, false, false), VMW_CMD_DEF(SVGA_3D_CMD_SETSCISSORRECT, &vmw_cmd_cid_check,
Signature · 1 line
1.7.10.4
PATCH 4/7 drm/vmwgfx: Fix legacy surface reference size copyback
In reply to Thomas HellstromSurfaces created using the guest-backed surface interface only keeps the base mip size, so only copy that if the legacy surface reference ioctl requests the size information.
--- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +2 -2
@@ -908,8 +908,8 @@ int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, rep->size_addr;if (user_sizes) - ret =copy_to_user (user_sizes, srf->sizes, - srf->num_sizes *sizeof (*srf->sizes)); + ret =copy_to_user (user_sizes, &srf->base_size, +sizeof (srf->base_size));if (unlikely (ret !=0 )) {DRM_ERROR ("copy_to_user failed %p %u\n" , user_sizes, srf->num_sizes);
Signature · 1 line
1.7.10.4
PATCH 5/7 drm/vmwgfx: Emulate legacy shaders on guest-backed devices v2
In reply to Thomas HellstromCommand stream legacy shader creation and destruction is replaced by NOPs in the command stream, and instead guest-backed shaders are created and destroyed as part of the command validation process.
v2: Removed some stray debug messages.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 + drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 29 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 197 +++++++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 465 +++++++++++++++++++++++++++---- 4 files changed, 620 insertions(+), 78 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -0
@@ -941,6 +941,7 @@ static void vmw_postclose(struct drm_device *dev,drm_master_put (&vmw_fp->locked_master); } +vmw_compat_shader_man_destroy (vmw_fp->shman);ttm_object_file_release (&vmw_fp->tfile);kfree (vmw_fp); }
@@ -960,11 +961,17 @@ static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)if (unlikely (vmw_fp->tfile ==NULL )) goto out_no_tfile; + vmw_fp->shman =vmw_compat_shader_man_create (dev_priv); +if (IS_ERR (vmw_fp->shman)) + goto out_no_shman; + file_priv->driver_priv = vmw_fp; dev_priv->bdev.dev_mapping = dev->dev_mapping;return 0 ; +out_no_shman: +ttm_object_file_release (&vmw_fp->tfile); out_no_tfile:kfree (vmw_fp);return ret;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +28 -1
@@ -75,10 +75,14 @@#define VMW_RES_FENCE ttm_driver_type3#define VMW_RES_SHADER ttm_driver_type4 +struct vmw_compat_shader_manager ; +struct vmw_fpriv {struct drm_master *locked_master;struct ttm_object_file *tfile;struct list_head fence_events; +bool gb_aware; +struct vmw_compat_shader_manager *shman; };struct vmw_dma_buffer {
@@ -318,7 +322,7 @@ struct vmw_sw_context{struct drm_open_hash res_ht;bool res_ht_initialized;bool kernel;/**< is the called made from the kernel */ -struct ttm_object_file *tfile; +struct vmw_fpriv *fp;struct list_head validate_nodes;struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS ];uint32_t cur_reloc;
@@ -336,6 +340,7 @@ struct vmw_sw_context{bool needs_post_query_barrier;struct vmw_resource *error_resource;struct vmw_ctx_binding_state staged_bindings; +struct list_head staged_shaders; };struct vmw_legacy_display ;
@@ -991,6 +996,28 @@ extern int vmw_shader_define_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);extern int vmw_shader_destroy_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +extern int vmw_compat_shader_lookup (struct vmw_compat_shader_manager *man, +SVGA3dShaderType shader_type, +u32 *user_key); +extern void vmw_compat_shaders_commit (struct vmw_compat_shader_manager *man, +struct list_head *list); +extern void vmw_compat_shaders_revert (struct vmw_compat_shader_manager *man, +struct list_head *list); +extern int vmw_compat_shader_remove (struct vmw_compat_shader_manager *man, +u32 user_key, +SVGA3dShaderType shader_type, +struct list_head *list); +extern int vmw_compat_shader_add (struct vmw_compat_shader_manager *man, +u32 user_key,const void *bytecode, +SVGA3dShaderType shader_type, +size_t size, +struct ttm_object_file *tfile, +struct list_head *list); +extern struct vmw_compat_shader_manager * +vmw_compat_shader_man_create (struct vmw_private *dev_priv); +extern void +vmw_compat_shader_man_destroy (struct vmw_compat_shader_manager *man); +/** * Inline helper functions
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +168 -29
318 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +417 -48
511 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 6/7 drm/vmwgfx: Detect old user-space drivers and set up legacy emulation v2
In reply to Thomas HellstromGB aware mesa userspace drivers are detected by the fact that they are calling the vmw getparam ioctl querying DRM_VMW_PARAM_HW_CAPS to detect whether the device is Guest-backed object capable. For other drivers, lie about hardware version and send the 3D capabilities in a format they expect.
v2:
Use DRM_VMW_PARAM_MAX_MOB_MEMORY to detect gb awareness,
Make sure we don't ovwerwrite bounce buffer or write past user-space buffer indicated size.
--- drivers/gpu/drm/vmwgfx/svga3d_reg.h | 24 +++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 93 +++++++++++++++++++++++++++------ 2 files changed, 101 insertions(+), 16 deletions(-)
drivers/gpu/drm/vmwgfx/svga3d_reg.h +24 -0
@@ -2583,4 +2583,28 @@ typedef union { float f; } SVGA3dDevCapResult; +typedef enum { +SVGA3DCAPS_RECORD_UNKNOWN =0 , +SVGA3DCAPS_RECORD_DEVCAPS_MIN =0x100 , +SVGA3DCAPS_RECORD_DEVCAPS =0x100 , +SVGA3DCAPS_RECORD_DEVCAPS_MAX =0x1ff , +}SVGA3dCapsRecordType ; + +typedef +struct SVGA3dCapsRecordHeader { +uint32 length; +SVGA3dCapsRecordType type; +} +SVGA3dCapsRecordHeader ; + +typedef +struct SVGA3dCapsRecord { +SVGA3dCapsRecordHeader header; +uint32 data[1 ]; +} +SVGA3dCapsRecord ; + + +typedef uint32 SVGA3dCapPair [2 ]; +#endif /* _SVGA3D_REG_H_ */
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +77 -16
165 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 7/7 drm/vmwgfx: Reemit context bindings when necessary v2
In reply to Thomas HellstromWhen a context is first referenced in the command stream, make sure that all scrubbed (as a result of eviction) bindings are re-emitted. Also make sure that all bound resources are put on the resource validate list.
This is needed for legacy emulation, since legacy user-space drivers will typically not re-emit shader bindings. It also removes the requirement for user-space drivers to re-emit render-target- and texture bindings.
Makes suspend and hibernate now also work with legacy user-space drivers on guest-backed devices.
v2: Don't rebind on legacy devices.
--- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 144 +++++++++++++++++++++++++----- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 ++ drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 85 +++++++++++++++++- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 11 ++- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +- 6 files changed, 222 insertions(+), 28 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +123 -21
@@ -37,7 +37,7 @@ struct vmw_user_context { -typedef int (*vmw_scrub_func )(struct vmw_ctx_bindinfo *); +typedef int (*vmw_scrub_func )(struct vmw_ctx_bindinfo *,bool );static void vmw_user_context_free (struct vmw_resource *res); static struct vmw_resource *
@@ -50,9 +50,11 @@ static int vmw_gb_context_unbind(struct vmw_resource *res,bool readback, struct ttm_validate_buffer *val_buf);static int vmw_gb_context_destroy (struct vmw_resource *res); -static int vmw_context_scrub_shader (struct vmw_ctx_bindinfo *bi); -static int vmw_context_scrub_render_target (struct vmw_ctx_bindinfo *bi); -static int vmw_context_scrub_texture (struct vmw_ctx_bindinfo *bi); +static int vmw_context_scrub_shader (struct vmw_ctx_bindinfo *bi,bool rebind); +static int vmw_context_scrub_render_target (struct vmw_ctx_bindinfo *bi, +bool rebind); +static int vmw_context_scrub_texture (struct vmw_ctx_bindinfo *bi,bool rebind); +static void vmw_context_binding_state_scrub (struct vmw_ctx_binding_state *cbs);static void vmw_context_binding_state_kill (struct vmw_ctx_binding_state *cbs);static uint64_t vmw_user_context_size;
@@ -111,10 +113,14 @@ static void vmw_hw_context_destroy(struct vmw_resource *res)if (res->func->destroy == vmw_gb_context_destroy) {mutex_lock (&dev_priv->cmdbuf_mutex); +mutex_lock (&dev_priv->binding_mutex); + (void )vmw_context_binding_state_kill + (&container_of(res, struct vmw_user_context, res)->cbs); (void )vmw_gb_context_destroy (res);if (dev_priv->pinned_bo !=NULL && !dev_priv->query_cid_valid)__vmw_execbuf_release_pinned_bo (dev_priv,NULL ); +mutex_unlock (&dev_priv->binding_mutex);mutex_unlock (&dev_priv->cmdbuf_mutex);return ; }
@@ -328,7 +334,7 @@ static int vmw_gb_context_unbind(struct vmw_resource *res,BUG_ON (bo->mem.mem_type !=VMW_PL_MOB );mutex_lock (&dev_priv->binding_mutex); -vmw_context_binding_state_kill (&uctx->cbs); +vmw_context_binding_state_scrub (&uctx->cbs); submit_size =sizeof (*cmd2) + (readback ?sizeof (*cmd1) :0 );
@@ -378,10 +384,6 @@ static int vmw_gb_context_destroy(struct vmw_resource *res)SVGA3dCmdHeader header;SVGA3dCmdDestroyGBContext body; } *cmd; -struct vmw_user_context *uctx = - container_of(res, struct vmw_user_context, res); - -BUG_ON (!list_empty (&uctx->cbs.list));if (likely (res->id ==-1 ))return 0 ;
@@ -528,8 +530,9 @@ out_unlock:* vmw_context_scrub_shader - scrub a shader binding from a context. * * @bi: single binding information. +* @rebind: Whether to issue a bind instead of scrub command. */ -static int vmw_context_scrub_shader (struct vmw_ctx_bindinfo *bi) +static int vmw_context_scrub_shader (struct vmw_ctx_bindinfo *bi,bool rebind) {struct vmw_private *dev_priv = bi->ctx->dev_priv;struct {
@@ -548,7 +551,8 @@ static int vmw_context_scrub_shader(struct vmw_ctx_bindinfo *bi) cmd->header.size =sizeof (cmd->body); cmd->body.cid = bi->ctx->id; cmd->body.type = bi->i1.shader_type; - cmd->body.shid =SVGA3D_INVALID_ID ; + cmd->body.shid = +cpu_to_le32 ((rebind) ? bi->res->id :SVGA3D_INVALID_ID );vmw_fifo_commit (dev_priv,sizeof (*cmd));return 0 ;
@@ -559,8 +563,10 @@ static int vmw_context_scrub_shader(struct vmw_ctx_bindinfo *bi)* from a context. * * @bi: single binding information. +* @rebind: Whether to issue a bind instead of scrub command. */ -static int vmw_context_scrub_render_target (struct vmw_ctx_bindinfo *bi) +static int vmw_context_scrub_render_target (struct vmw_ctx_bindinfo *bi, +bool rebind) {struct vmw_private *dev_priv = bi->ctx->dev_priv;struct {
@@ -579,7 +585,8 @@ static int vmw_context_scrub_render_target(struct vmw_ctx_bindinfo *bi) cmd->header.size =sizeof (cmd->body); cmd->body.cid = bi->ctx->id; cmd->body.type = bi->i1.rt_type; - cmd->body.target.sid =SVGA3D_INVALID_ID ; + cmd->body.target.sid = +cpu_to_le32 ((rebind) ? bi->res->id :SVGA3D_INVALID_ID ); cmd->body.target.face =0 ; cmd->body.target.mipmap =0 ;vmw_fifo_commit (dev_priv,sizeof (*cmd));
@@ -591,11 +598,13 @@ static int vmw_context_scrub_render_target(struct vmw_ctx_bindinfo *bi)* vmw_context_scrub_texture - scrub a texture binding from a context. * * @bi: single binding information. +* @rebind: Whether to issue a bind instead of scrub command. * * TODO: Possibly complement this function with a function that takes * a list of texture bindings and combines them to a single command. */ -static int vmw_context_scrub_texture (struct vmw_ctx_bindinfo *bi) +static int vmw_context_scrub_texture (struct vmw_ctx_bindinfo *bi, +bool rebind) {struct vmw_private *dev_priv = bi->ctx->dev_priv;struct {
@@ -619,7 +628,8 @@ static int vmw_context_scrub_texture(struct vmw_ctx_bindinfo *bi) cmd->body.c.cid = bi->ctx->id; cmd->body.s1.stage = bi->i1.texture_stage; cmd->body.s1.name =SVGA3D_TS_BIND_TEXTURE ; - cmd->body.s1.value = (uint32 )SVGA3D_INVALID_ID ; + cmd->body.s1.value = +cpu_to_le32 ((rebind) ? bi->res->id :SVGA3D_INVALID_ID );vmw_fifo_commit (dev_priv,sizeof (*cmd));return 0 ;
@@ -692,6 +702,7 @@ int vmw_context_binding_add(struct vmw_ctx_binding_state *cbs,vmw_context_binding_drop (loc); loc->bi = *bi; + loc->bi.scrubbed = false;list_add_tail (&loc->ctx_list, &cbs->list);INIT_LIST_HEAD (&loc->res_list);
@@ -727,12 +738,11 @@ static void vmw_context_binding_transfer(struct vmw_ctx_binding_state *cbs,if (loc->bi.ctx !=NULL )vmw_context_binding_drop (loc); - loc->bi = *bi; -list_add_tail (&loc->ctx_list, &cbs->list); -if (bi->res !=NULL ) +if (bi->res !=NULL ) { + loc->bi = *bi; +list_add_tail (&loc->ctx_list, &cbs->list);list_add_tail (&loc->res_list, &bi->res->binding_head); -else -INIT_LIST_HEAD (&loc->res_list); + } }/**
@@ -746,7 +756,10 @@ static void vmw_context_binding_transfer(struct vmw_ctx_binding_state *cbs,*/ static void vmw_context_binding_kill (struct vmw_ctx_binding *cb) { - (void ) vmw_scrub_funcs[cb->bi.bt](&cb->bi); +if (!cb->bi.scrubbed) { + (void ) vmw_scrub_funcs[cb->bi.bt](&cb->bi, false); + cb->bi.scrubbed = true; + }vmw_context_binding_drop (cb); }
@@ -768,6 +781,27 @@ static void vmw_context_binding_state_kill(struct vmw_ctx_binding_state *cbs) }/** +* vmw_context_binding_state_scrub - Scrub all bindings associated with a +* struct vmw_ctx_binding state structure. +* +* @cbs: Pointer to the context binding state tracker. +* +* Emits commands to scrub all bindings associated with the +* context binding state tracker. +*/ +static void vmw_context_binding_state_scrub (struct vmw_ctx_binding_state *cbs) +{ +struct vmw_ctx_binding *entry; + +list_for_each_entry (entry, &cbs->list, ctx_list) { +if (!entry->bi.scrubbed) { + (void ) vmw_scrub_funcs[entry->bi.bt](&entry->bi, false); + entry->bi.scrubbed = true; + } + } +} + +/** * vmw_context_binding_res_list_kill - Kill all bindings on a * resource binding list *
@@ -785,6 +819,27 @@ void vmw_context_binding_res_list_kill(struct list_head *head) }/** +* vmw_context_binding_res_list_scrub - Scrub all bindings on a +* resource binding list +* +* @head: list head of resource binding list +* +* Scrub all bindings associated with a specific resource. Typically +* called before the resource is evicted. +*/ +void vmw_context_binding_res_list_scrub (struct list_head *head) +{ +struct vmw_ctx_binding *entry; + +list_for_each_entry (entry, head, res_list) { +if (!entry->bi.scrubbed) { + (void ) vmw_scrub_funcs[entry->bi.bt](&entry->bi, false); + entry->bi.scrubbed = true; + } + } +} + +/** * vmw_context_binding_state_transfer - Commit staged binding info * * @ctx: Pointer to context to commit the staged binding info to.
@@ -803,3 +858,50 @@ void vmw_context_binding_state_transfer(struct vmw_resource *ctx,list_for_each_entry_safe (entry, next, &from->list, ctx_list)vmw_context_binding_transfer (&uctx->cbs, &entry->bi); } + +/** +* vmw_context_rebind_all - Rebind all scrubbed bindings of a context +* +* @ctx: The context resource +* +* Walks through the context binding list and rebinds all scrubbed +* resources. +*/ +int vmw_context_rebind_all (struct vmw_resource *ctx) +{ +struct vmw_ctx_binding *entry; +struct vmw_user_context *uctx = + container_of(ctx, struct vmw_user_context, res); +struct vmw_ctx_binding_state *cbs = &uctx->cbs; +int ret; + +list_for_each_entry (entry, &cbs->list, ctx_list) { +if (likely (!entry->bi.scrubbed)) +continue ; + +if (WARN_ON (entry->bi.res ==NULL || entry->bi.res->id == +SVGA3D_INVALID_ID )) +continue ; + + ret = vmw_scrub_funcs[entry->bi.bt](&entry->bi, true); +if (unlikely (ret !=0 )) +return ret; + + entry->bi.scrubbed = false; + } + +return 0 ; +} + +/** +* vmw_context_binding_list - Return a list of context bindings +* +* @ctx: The context resource +* +* Returns the current list of bindings of the given context. Note that +* this list becomes stale as soon as the dev_priv::binding_mutex is unlocked. +*/ +struct list_head *vmw_context_binding_list (struct vmw_resource *ctx) +{ + return &(container_of(ctx, struct vmw_user_context, res)->cbs.list); +}
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +6 -0
@@ -276,6 +276,7 @@ struct vmw_ctx_bindinfo {struct vmw_resource *ctx;struct vmw_resource *res;enum vmw_ctx_binding_type bt; +bool scrubbed;union {SVGA3dShaderType shader_type;SVGA3dRenderTargetType rt_type;
@@ -574,6 +575,8 @@ struct vmw_user_resource_conv;extern void vmw_resource_unreference (struct vmw_resource **p_res);extern struct vmw_resource *vmw_resource_reference (struct vmw_resource *res); +extern struct vmw_resource * +vmw_resource_reference_unless_doomed (struct vmw_resource *res);extern int vmw_resource_validate (struct vmw_resource *res);extern int vmw_resource_reserve (struct vmw_resource *res,bool no_backup);extern bool vmw_resource_needs_backup (const struct vmw_resource *res);
@@ -962,6 +965,9 @@ extern void vmw_context_binding_state_transfer(struct vmw_resource *res, struct vmw_ctx_binding_state *cbs);extern void vmw_context_binding_res_list_kill (struct list_head *head); +extern void vmw_context_binding_res_list_scrub (struct list_head *head); +extern int vmw_context_rebind_all (struct vmw_resource *ctx); +extern struct list_head *vmw_context_binding_list (struct vmw_resource *ctx);/* * Surface management - vmwgfx_surface.c
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +81 -4
115 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +10 -1
@@ -88,6 +88,11 @@ struct vmw_resource *vmw_resource_reference(struct vmw_resource *res)return res; } +struct vmw_resource * +vmw_resource_reference_unless_doomed (struct vmw_resource *res) +{ +return kref_get_unless_zero (&res->kref) ? res :NULL ; +}/** * vmw_resource_release_id - release a resource id to the id manager.
@@ -136,8 +141,12 @@ static void vmw_resource_release(struct kref *kref)vmw_dmabuf_unreference (&res->backup); } -if (likely (res->hw_destroy !=NULL )) +if (likely (res->hw_destroy !=NULL )) { res->hw_destroy (res); +mutex_lock (&dev_priv->binding_mutex); +vmw_context_binding_res_list_kill (&res->binding_head); +mutex_unlock (&dev_priv->binding_mutex); + } id = res->id;if (res->res_free !=NULL )
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +1 -1
@@ -304,7 +304,7 @@ static int vmw_gb_shader_destroy(struct vmw_resource *res)return 0 ;mutex_lock (&dev_priv->binding_mutex); -vmw_context_binding_res_list_kill (&res->binding_head); +vmw_context_binding_res_list_scrub (&res->binding_head); cmd =vmw_fifo_reserve (dev_priv,sizeof (*cmd));if (unlikely (cmd ==NULL )) {
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +1 -1
@@ -1111,7 +1111,7 @@ static int vmw_gb_surface_destroy(struct vmw_resource *res)return 0 ;mutex_lock (&dev_priv->binding_mutex); -vmw_context_binding_res_list_kill (&res->binding_head); +vmw_context_binding_res_list_scrub (&res->binding_head); cmd =vmw_fifo_reserve (dev_priv,sizeof (*cmd));if (unlikely (cmd ==NULL )) {
Signature · 1 line
1.7.10.4