forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
....@@ -170,13 +170,12 @@
170170 return 0;
171171 }
172172
173
- cmd = vmw_fifo_reserve_dx(res->dev_priv, view->cmd_size,
174
- view->ctx->id);
173
+ cmd = VMW_FIFO_RESERVE_DX(res->dev_priv, view->cmd_size, view->ctx->id);
175174 if (!cmd) {
176
- DRM_ERROR("Failed reserving FIFO space for view creation.\n");
177175 mutex_unlock(&dev_priv->binding_mutex);
178176 return -ENOMEM;
179177 }
178
+
180179 memcpy(cmd, &view->cmd, view->cmd_size);
181180 WARN_ON(cmd->body.view_id != view->view_id);
182181 /* Sid may have changed due to surface eviction. */
....@@ -208,18 +207,15 @@
208207 union vmw_view_destroy body;
209208 } *cmd;
210209
211
- WARN_ON_ONCE(!mutex_is_locked(&dev_priv->binding_mutex));
210
+ lockdep_assert_held_once(&dev_priv->binding_mutex);
212211 vmw_binding_res_list_scrub(&res->binding_head);
213212
214213 if (!view->committed || res->id == -1)
215214 return 0;
216215
217
- cmd = vmw_fifo_reserve_dx(dev_priv, sizeof(*cmd), view->ctx->id);
218
- if (!cmd) {
219
- DRM_ERROR("Failed reserving FIFO space for view "
220
- "destruction.\n");
216
+ cmd = VMW_FIFO_RESERVE_DX(dev_priv, sizeof(*cmd), view->ctx->id);
217
+ if (!cmd)
221218 return -ENOMEM;
222
- }
223219
224220 cmd->header.id = vmw_view_destroy_cmds[view->view_type];
225221 cmd->header.size = sizeof(cmd->body);
....@@ -323,7 +319,8 @@
323319 static const size_t vmw_view_define_sizes[] = {
324320 [vmw_view_sr] = sizeof(SVGA3dCmdDXDefineShaderResourceView),
325321 [vmw_view_rt] = sizeof(SVGA3dCmdDXDefineRenderTargetView),
326
- [vmw_view_ds] = sizeof(SVGA3dCmdDXDefineDepthStencilView)
322
+ [vmw_view_ds] = sizeof(SVGA3dCmdDXDefineDepthStencilView),
323
+ [vmw_view_ua] = sizeof(SVGA3dCmdDXDefineUAView)
327324 };
328325
329326 struct vmw_private *dev_priv = ctx->dev_priv;
....@@ -338,12 +335,12 @@
338335
339336 if (cmd_size != vmw_view_define_sizes[view_type] +
340337 sizeof(SVGA3dCmdHeader)) {
341
- DRM_ERROR("Illegal view create command size.\n");
338
+ VMW_DEBUG_USER("Illegal view create command size.\n");
342339 return -EINVAL;
343340 }
344341
345342 if (!vmw_view_id_ok(user_key, view_type)) {
346
- DRM_ERROR("Illegal view add view id.\n");
343
+ VMW_DEBUG_USER("Illegal view add view id.\n");
347344 return -EINVAL;
348345 }
349346
....@@ -352,8 +349,7 @@
352349 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), size, &ttm_opt_ctx);
353350 if (ret) {
354351 if (ret != -ERESTARTSYS)
355
- DRM_ERROR("Out of graphics memory for view"
356
- " creation.\n");
352
+ DRM_ERROR("Out of graphics memory for view creation\n");
357353 return ret;
358354 }
359355
....@@ -366,7 +362,8 @@
366362 res = &view->res;
367363 view->ctx = ctx;
368364 view->srf = vmw_resource_reference(srf);
369
- view->cotable = vmw_context_cotable(ctx, vmw_view_cotables[view_type]);
365
+ view->cotable = vmw_resource_reference
366
+ (vmw_context_cotable(ctx, vmw_view_cotables[view_type]));
370367 view->view_type = view_type;
371368 view->view_id = user_key;
372369 view->cmd_size = cmd_size;
....@@ -386,7 +383,7 @@
386383 goto out_resource_init;
387384
388385 res->id = view->view_id;
389
- vmw_resource_activate(res, vmw_hw_view_destroy);
386
+ res->hw_destroy = vmw_hw_view_destroy;
390387
391388 out_resource_init:
392389 vmw_resource_unreference(&res);
....@@ -412,7 +409,7 @@
412409 struct vmw_resource **res_p)
413410 {
414411 if (!vmw_view_id_ok(user_key, view_type)) {
415
- DRM_ERROR("Illegal view remove view id.\n");
412
+ VMW_DEBUG_USER("Illegal view remove view id.\n");
416413 return -EINVAL;
417414 }
418415
....@@ -439,7 +436,7 @@
439436 {
440437 struct vmw_view *entry, *next;
441438
442
- WARN_ON_ONCE(!mutex_is_locked(&dev_priv->binding_mutex));
439
+ lockdep_assert_held_once(&dev_priv->binding_mutex);
443440
444441 list_for_each_entry_safe(entry, next, list, cotable_head)
445442 WARN_ON(vmw_view_destroy(&entry->res));
....@@ -459,7 +456,7 @@
459456 {
460457 struct vmw_view *entry, *next;
461458
462
- WARN_ON_ONCE(!mutex_is_locked(&dev_priv->binding_mutex));
459
+ lockdep_assert_held_once(&dev_priv->binding_mutex);
463460
464461 list_for_each_entry_safe(entry, next, list, srf_head)
465462 WARN_ON(vmw_view_destroy(&entry->res));
....@@ -496,16 +493,43 @@
496493 vmw_view_key(user_key, view_type));
497494 }
498495
496
+/**
497
+ * vmw_view_dirtying - Return whether a view type is dirtying its resource
498
+ * @res: Pointer to the view
499
+ *
500
+ * Each time a resource is put on the validation list as the result of a
501
+ * view pointing to it, we need to determine whether that resource will
502
+ * be dirtied (written to by the GPU) as a result of the corresponding
503
+ * GPU operation. Currently only rendertarget-, depth-stencil and unordered
504
+ * access views are capable of dirtying its resource.
505
+ *
506
+ * Return: Whether the view type of @res dirties the resource it points to.
507
+ */
508
+u32 vmw_view_dirtying(struct vmw_resource *res)
509
+{
510
+ static u32 view_is_dirtying[vmw_view_max] = {
511
+ [vmw_view_rt] = VMW_RES_DIRTY_SET,
512
+ [vmw_view_ds] = VMW_RES_DIRTY_SET,
513
+ [vmw_view_ua] = VMW_RES_DIRTY_SET,
514
+ };
515
+
516
+ /* Update this function as we add more view types */
517
+ BUILD_BUG_ON(vmw_view_max != 4);
518
+ return view_is_dirtying[vmw_view(res)->view_type];
519
+}
520
+
499521 const u32 vmw_view_destroy_cmds[] = {
500522 [vmw_view_sr] = SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW,
501523 [vmw_view_rt] = SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW,
502524 [vmw_view_ds] = SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW,
525
+ [vmw_view_ua] = SVGA_3D_CMD_DX_DESTROY_UA_VIEW,
503526 };
504527
505528 const SVGACOTableType vmw_view_cotables[] = {
506529 [vmw_view_sr] = SVGA_COTABLE_SRVIEW,
507530 [vmw_view_rt] = SVGA_COTABLE_RTVIEW,
508531 [vmw_view_ds] = SVGA_COTABLE_DSVIEW,
532
+ [vmw_view_ua] = SVGA_COTABLE_UAVIEW,
509533 };
510534
511535 const SVGACOTableType vmw_so_cotables[] = {