Skip to content

Commit b3edf49

Browse files
committed
Merge branch 'vmwgfx-next' of https://gitlab.freedesktop.org/drawat/linux into drm-next
Resource dirtying improvement by Thomas, user-space error logging improvement and some other minor fixes. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Deepak Rawat <drawat@vmware.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190423211630.61874-1-drawat@vmware.com
2 parents dbb9247 + c601b12 commit b3edf49

25 files changed

Lines changed: 972 additions & 1231 deletions

‎drivers/gpu/drm/vmwgfx/vmwgfx_binding.c‎

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,9 @@ static int vmw_binding_scrub_shader(struct vmw_ctx_bindinfo *bi, bool rebind)
499499
SVGA3dCmdSetShader body;
500500
} *cmd;
501501

502-
cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
503-
if (unlikely(cmd == NULL)) {
504-
DRM_ERROR("Failed reserving FIFO space for shader "
505-
"unbinding.\n");
502+
cmd = VMW_FIFO_RESERVE(dev_priv, sizeof(*cmd));
503+
if (unlikely(cmd == NULL))
506504
return -ENOMEM;
507-
}
508505

509506
cmd->header.id = SVGA_3D_CMD_SET_SHADER;
510507
cmd->header.size = sizeof(cmd->body);
@@ -534,12 +531,9 @@ static int vmw_binding_scrub_render_target(struct vmw_ctx_bindinfo *bi,
534531
SVGA3dCmdSetRenderTarget body;
535532
} *cmd;
536533

537-
cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
538-
if (unlikely(cmd == NULL)) {
539-
DRM_ERROR("Failed reserving FIFO space for render target "
540-
"unbinding.\n");
534+
cmd = VMW_FIFO_RESERVE(dev_priv, sizeof(*cmd));
535+
if (unlikely(cmd == NULL))
541536
return -ENOMEM;
542-
}
543537

544538
cmd->header.id = SVGA_3D_CMD_SETRENDERTARGET;
545539
cmd->header.size = sizeof(cmd->body);
@@ -576,12 +570,9 @@ static int vmw_binding_scrub_texture(struct vmw_ctx_bindinfo *bi,
576570
} body;
577571
} *cmd;
578572

579-
cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
580-
if (unlikely(cmd == NULL)) {
581-
DRM_ERROR("Failed reserving FIFO space for texture "
582-
"unbinding.\n");
573+
cmd = VMW_FIFO_RESERVE(dev_priv, sizeof(*cmd));
574+
if (unlikely(cmd == NULL))
583575
return -ENOMEM;
584-
}
585576

586577
cmd->header.id = SVGA_3D_CMD_SETTEXTURESTATE;
587578
cmd->header.size = sizeof(cmd->body);
@@ -610,12 +601,10 @@ static int vmw_binding_scrub_dx_shader(struct vmw_ctx_bindinfo *bi, bool rebind)
610601
SVGA3dCmdDXSetShader body;
611602
} *cmd;
612603

613-
cmd = vmw_fifo_reserve_dx(dev_priv, sizeof(*cmd), bi->ctx->id);
614-
if (unlikely(cmd == NULL)) {
615-
DRM_ERROR("Failed reserving FIFO space for DX shader "
616-
"unbinding.\n");
604+
cmd = VMW_FIFO_RESERVE_DX(dev_priv, sizeof(*cmd), bi->ctx->id);
605+
if (unlikely(cmd == NULL))
617606
return -ENOMEM;
618-
}
607+
619608
cmd->header.id = SVGA_3D_CMD_DX_SET_SHADER;
620609
cmd->header.size = sizeof(cmd->body);
621610
cmd->body.type = binding->shader_slot + SVGA3D_SHADERTYPE_MIN;
@@ -641,12 +630,9 @@ static int vmw_binding_scrub_cb(struct vmw_ctx_bindinfo *bi, bool rebind)
641630
SVGA3dCmdDXSetSingleConstantBuffer body;
642631
} *cmd;
643632

644-
cmd = vmw_fifo_reserve_dx(dev_priv, sizeof(*cmd), bi->ctx->id);
645-
if (unlikely(cmd == NULL)) {
646-
DRM_ERROR("Failed reserving FIFO space for DX shader "
647-
"unbinding.\n");
633+
cmd = VMW_FIFO_RESERVE_DX(dev_priv, sizeof(*cmd), bi->ctx->id);
634+
if (unlikely(cmd == NULL))
648635
return -ENOMEM;
649-
}
650636

651637
cmd->header.id = SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER;
652638
cmd->header.size = sizeof(cmd->body);
@@ -768,12 +754,9 @@ static int vmw_emit_set_sr(struct vmw_ctx_binding_state *cbs,
768754

769755
view_id_size = cbs->bind_cmd_count*sizeof(uint32);
770756
cmd_size = sizeof(*cmd) + view_id_size;
771-
cmd = vmw_fifo_reserve_dx(ctx->dev_priv, cmd_size, ctx->id);
772-
if (unlikely(cmd == NULL)) {
773-
DRM_ERROR("Failed reserving FIFO space for DX shader"
774-
" resource binding.\n");
757+
cmd = VMW_FIFO_RESERVE_DX(ctx->dev_priv, cmd_size, ctx->id);
758+
if (unlikely(cmd == NULL))
775759
return -ENOMEM;
776-
}
777760

778761
cmd->header.id = SVGA_3D_CMD_DX_SET_SHADER_RESOURCES;
779762
cmd->header.size = sizeof(cmd->body) + view_id_size;
@@ -807,12 +790,9 @@ static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
807790
vmw_collect_view_ids(cbs, loc, SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS);
808791
view_id_size = cbs->bind_cmd_count*sizeof(uint32);
809792
cmd_size = sizeof(*cmd) + view_id_size;
810-
cmd = vmw_fifo_reserve_dx(ctx->dev_priv, cmd_size, ctx->id);
811-
if (unlikely(cmd == NULL)) {
812-
DRM_ERROR("Failed reserving FIFO space for DX render-target"
813-
" binding.\n");
793+
cmd = VMW_FIFO_RESERVE_DX(ctx->dev_priv, cmd_size, ctx->id);
794+
if (unlikely(cmd == NULL))
814795
return -ENOMEM;
815-
}
816796

817797
cmd->header.id = SVGA_3D_CMD_DX_SET_RENDERTARGETS;
818798
cmd->header.size = sizeof(cmd->body) + view_id_size;
@@ -894,12 +874,9 @@ static int vmw_emit_set_so(struct vmw_ctx_binding_state *cbs)
894874

895875
so_target_size = cbs->bind_cmd_count*sizeof(SVGA3dSoTarget);
896876
cmd_size = sizeof(*cmd) + so_target_size;
897-
cmd = vmw_fifo_reserve_dx(ctx->dev_priv, cmd_size, ctx->id);
898-
if (unlikely(cmd == NULL)) {
899-
DRM_ERROR("Failed reserving FIFO space for DX SO target"
900-
" binding.\n");
877+
cmd = VMW_FIFO_RESERVE_DX(ctx->dev_priv, cmd_size, ctx->id);
878+
if (unlikely(cmd == NULL))
901879
return -ENOMEM;
902-
}
903880

904881
cmd->header.id = SVGA_3D_CMD_DX_SET_SOTARGETS;
905882
cmd->header.size = sizeof(cmd->body) + so_target_size;
@@ -1011,12 +988,9 @@ static int vmw_emit_set_vb(struct vmw_ctx_binding_state *cbs)
1011988

1012989
set_vb_size = cbs->bind_cmd_count*sizeof(SVGA3dVertexBuffer);
1013990
cmd_size = sizeof(*cmd) + set_vb_size;
1014-
cmd = vmw_fifo_reserve_dx(ctx->dev_priv, cmd_size, ctx->id);
1015-
if (unlikely(cmd == NULL)) {
1016-
DRM_ERROR("Failed reserving FIFO space for DX vertex buffer"
1017-
" binding.\n");
991+
cmd = VMW_FIFO_RESERVE_DX(ctx->dev_priv, cmd_size, ctx->id);
992+
if (unlikely(cmd == NULL))
1018993
return -ENOMEM;
1019-
}
1020994

1021995
cmd->header.id = SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS;
1022996
cmd->header.size = sizeof(cmd->body) + set_vb_size;
@@ -1167,12 +1141,10 @@ static int vmw_binding_scrub_ib(struct vmw_ctx_bindinfo *bi, bool rebind)
11671141
SVGA3dCmdDXSetIndexBuffer body;
11681142
} *cmd;
11691143

1170-
cmd = vmw_fifo_reserve_dx(dev_priv, sizeof(*cmd), bi->ctx->id);
1171-
if (unlikely(cmd == NULL)) {
1172-
DRM_ERROR("Failed reserving FIFO space for DX index buffer "
1173-
"binding.\n");
1144+
cmd = VMW_FIFO_RESERVE_DX(dev_priv, sizeof(*cmd), bi->ctx->id);
1145+
if (unlikely(cmd == NULL))
11741146
return -ENOMEM;
1175-
}
1147+
11761148
cmd->header.id = SVGA_3D_CMD_DX_SET_INDEX_BUFFER;
11771149
cmd->header.size = sizeof(cmd->body);
11781150
if (rebind) {
@@ -1269,6 +1241,32 @@ void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs)
12691241
vmw_binding_drop(entry);
12701242
}
12711243

1244+
/**
1245+
* vmw_binding_dirtying - Return whether a binding type is dirtying its resource
1246+
* @binding_type: The binding type
1247+
*
1248+
* Each time a resource is put on the validation list as the result of a
1249+
* context binding referencing it, we need to determine whether that resource
1250+
* will be dirtied (written to by the GPU) as a result of the corresponding
1251+
* GPU operation. Currently rendertarget-, depth-stencil-, and
1252+
* stream-output-target bindings are capable of dirtying its resource.
1253+
*
1254+
* Return: Whether the binding type dirties the resource its binding points to.
1255+
*/
1256+
u32 vmw_binding_dirtying(enum vmw_ctx_binding_type binding_type)
1257+
{
1258+
static u32 is_binding_dirtying[vmw_ctx_binding_max] = {
1259+
[vmw_ctx_binding_rt] = VMW_RES_DIRTY_SET,
1260+
[vmw_ctx_binding_dx_rt] = VMW_RES_DIRTY_SET,
1261+
[vmw_ctx_binding_ds] = VMW_RES_DIRTY_SET,
1262+
[vmw_ctx_binding_so] = VMW_RES_DIRTY_SET,
1263+
};
1264+
1265+
/* Review this function as new bindings are added. */
1266+
BUILD_BUG_ON(vmw_ctx_binding_max != 11);
1267+
return is_binding_dirtying[binding_type];
1268+
}
1269+
12721270
/*
12731271
* This function is unused at run-time, and only used to hold various build
12741272
* asserts important for code optimization assumptions.

‎drivers/gpu/drm/vmwgfx/vmwgfx_binding.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,7 @@ extern void vmw_binding_state_free(struct vmw_ctx_binding_state *cbs);
205205
extern struct list_head *
206206
vmw_binding_state_list(struct vmw_ctx_binding_state *cbs);
207207
extern void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs);
208+
extern u32 vmw_binding_dirtying(enum vmw_ctx_binding_type binding_type);
209+
208210

209211
#endif

‎drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ static void vmw_cmdbuf_ctx_process(struct vmw_cmdbuf_man *man,
393393
__vmw_cmdbuf_header_free(entry);
394394
break;
395395
case SVGA_CB_STATUS_COMMAND_ERROR:
396+
WARN_ONCE(true, "Command buffer error.\n");
396397
entry->cb_header->status = SVGA_CB_STATUS_NONE;
397398
list_add_tail(&entry->list, &man->error);
398399
schedule_work(&man->work);
@@ -511,17 +512,14 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
511512
container_of(work, struct vmw_cmdbuf_man, work);
512513
struct vmw_cmdbuf_header *entry, *next;
513514
uint32_t dummy;
514-
bool restart[SVGA_CB_CONTEXT_MAX];
515515
bool send_fence = false;
516516
struct list_head restart_head[SVGA_CB_CONTEXT_MAX];
517517
int i;
518518
struct vmw_cmdbuf_context *ctx;
519519
bool global_block = false;
520520

521-
for_each_cmdbuf_ctx(man, i, ctx) {
521+
for_each_cmdbuf_ctx(man, i, ctx)
522522
INIT_LIST_HEAD(&restart_head[i]);
523-
restart[i] = false;
524-
}
525523

526524
mutex_lock(&man->error_mutex);
527525
spin_lock(&man->lock);
@@ -533,23 +531,23 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
533531
const char *cmd_name;
534532

535533
list_del_init(&entry->list);
536-
restart[entry->cb_context] = true;
537534
global_block = true;
538535

539536
if (!vmw_cmd_describe(header, &error_cmd_size, &cmd_name)) {
540-
DRM_ERROR("Unknown command causing device error.\n");
541-
DRM_ERROR("Command buffer offset is %lu\n",
542-
(unsigned long) cb_hdr->errorOffset);
537+
VMW_DEBUG_USER("Unknown command causing device error.\n");
538+
VMW_DEBUG_USER("Command buffer offset is %lu\n",
539+
(unsigned long) cb_hdr->errorOffset);
543540
__vmw_cmdbuf_header_free(entry);
544541
send_fence = true;
545542
continue;
546543
}
547544

548-
DRM_ERROR("Command \"%s\" causing device error.\n", cmd_name);
549-
DRM_ERROR("Command buffer offset is %lu\n",
550-
(unsigned long) cb_hdr->errorOffset);
551-
DRM_ERROR("Command size is %lu\n",
552-
(unsigned long) error_cmd_size);
545+
VMW_DEBUG_USER("Command \"%s\" causing device error.\n",
546+
cmd_name);
547+
VMW_DEBUG_USER("Command buffer offset is %lu\n",
548+
(unsigned long) cb_hdr->errorOffset);
549+
VMW_DEBUG_USER("Command size is %lu\n",
550+
(unsigned long) error_cmd_size);
553551

554552
new_start_offset = cb_hdr->errorOffset + error_cmd_size;
555553

0 commit comments

Comments
 (0)