| .. | .. |
|---|
| 170 | 170 | return 0; |
|---|
| 171 | 171 | } |
|---|
| 172 | 172 | |
|---|
| 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); |
|---|
| 175 | 174 | if (!cmd) { |
|---|
| 176 | | - DRM_ERROR("Failed reserving FIFO space for view creation.\n"); |
|---|
| 177 | 175 | mutex_unlock(&dev_priv->binding_mutex); |
|---|
| 178 | 176 | return -ENOMEM; |
|---|
| 179 | 177 | } |
|---|
| 178 | + |
|---|
| 180 | 179 | memcpy(cmd, &view->cmd, view->cmd_size); |
|---|
| 181 | 180 | WARN_ON(cmd->body.view_id != view->view_id); |
|---|
| 182 | 181 | /* Sid may have changed due to surface eviction. */ |
|---|
| .. | .. |
|---|
| 208 | 207 | union vmw_view_destroy body; |
|---|
| 209 | 208 | } *cmd; |
|---|
| 210 | 209 | |
|---|
| 211 | | - WARN_ON_ONCE(!mutex_is_locked(&dev_priv->binding_mutex)); |
|---|
| 210 | + lockdep_assert_held_once(&dev_priv->binding_mutex); |
|---|
| 212 | 211 | vmw_binding_res_list_scrub(&res->binding_head); |
|---|
| 213 | 212 | |
|---|
| 214 | 213 | if (!view->committed || res->id == -1) |
|---|
| 215 | 214 | return 0; |
|---|
| 216 | 215 | |
|---|
| 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) |
|---|
| 221 | 218 | return -ENOMEM; |
|---|
| 222 | | - } |
|---|
| 223 | 219 | |
|---|
| 224 | 220 | cmd->header.id = vmw_view_destroy_cmds[view->view_type]; |
|---|
| 225 | 221 | cmd->header.size = sizeof(cmd->body); |
|---|
| .. | .. |
|---|
| 323 | 319 | static const size_t vmw_view_define_sizes[] = { |
|---|
| 324 | 320 | [vmw_view_sr] = sizeof(SVGA3dCmdDXDefineShaderResourceView), |
|---|
| 325 | 321 | [vmw_view_rt] = sizeof(SVGA3dCmdDXDefineRenderTargetView), |
|---|
| 326 | | - [vmw_view_ds] = sizeof(SVGA3dCmdDXDefineDepthStencilView) |
|---|
| 322 | + [vmw_view_ds] = sizeof(SVGA3dCmdDXDefineDepthStencilView), |
|---|
| 323 | + [vmw_view_ua] = sizeof(SVGA3dCmdDXDefineUAView) |
|---|
| 327 | 324 | }; |
|---|
| 328 | 325 | |
|---|
| 329 | 326 | struct vmw_private *dev_priv = ctx->dev_priv; |
|---|
| .. | .. |
|---|
| 338 | 335 | |
|---|
| 339 | 336 | if (cmd_size != vmw_view_define_sizes[view_type] + |
|---|
| 340 | 337 | sizeof(SVGA3dCmdHeader)) { |
|---|
| 341 | | - DRM_ERROR("Illegal view create command size.\n"); |
|---|
| 338 | + VMW_DEBUG_USER("Illegal view create command size.\n"); |
|---|
| 342 | 339 | return -EINVAL; |
|---|
| 343 | 340 | } |
|---|
| 344 | 341 | |
|---|
| 345 | 342 | 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"); |
|---|
| 347 | 344 | return -EINVAL; |
|---|
| 348 | 345 | } |
|---|
| 349 | 346 | |
|---|
| .. | .. |
|---|
| 352 | 349 | ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), size, &ttm_opt_ctx); |
|---|
| 353 | 350 | if (ret) { |
|---|
| 354 | 351 | 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"); |
|---|
| 357 | 353 | return ret; |
|---|
| 358 | 354 | } |
|---|
| 359 | 355 | |
|---|
| .. | .. |
|---|
| 366 | 362 | res = &view->res; |
|---|
| 367 | 363 | view->ctx = ctx; |
|---|
| 368 | 364 | 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])); |
|---|
| 370 | 367 | view->view_type = view_type; |
|---|
| 371 | 368 | view->view_id = user_key; |
|---|
| 372 | 369 | view->cmd_size = cmd_size; |
|---|
| .. | .. |
|---|
| 386 | 383 | goto out_resource_init; |
|---|
| 387 | 384 | |
|---|
| 388 | 385 | res->id = view->view_id; |
|---|
| 389 | | - vmw_resource_activate(res, vmw_hw_view_destroy); |
|---|
| 386 | + res->hw_destroy = vmw_hw_view_destroy; |
|---|
| 390 | 387 | |
|---|
| 391 | 388 | out_resource_init: |
|---|
| 392 | 389 | vmw_resource_unreference(&res); |
|---|
| .. | .. |
|---|
| 412 | 409 | struct vmw_resource **res_p) |
|---|
| 413 | 410 | { |
|---|
| 414 | 411 | 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"); |
|---|
| 416 | 413 | return -EINVAL; |
|---|
| 417 | 414 | } |
|---|
| 418 | 415 | |
|---|
| .. | .. |
|---|
| 439 | 436 | { |
|---|
| 440 | 437 | struct vmw_view *entry, *next; |
|---|
| 441 | 438 | |
|---|
| 442 | | - WARN_ON_ONCE(!mutex_is_locked(&dev_priv->binding_mutex)); |
|---|
| 439 | + lockdep_assert_held_once(&dev_priv->binding_mutex); |
|---|
| 443 | 440 | |
|---|
| 444 | 441 | list_for_each_entry_safe(entry, next, list, cotable_head) |
|---|
| 445 | 442 | WARN_ON(vmw_view_destroy(&entry->res)); |
|---|
| .. | .. |
|---|
| 459 | 456 | { |
|---|
| 460 | 457 | struct vmw_view *entry, *next; |
|---|
| 461 | 458 | |
|---|
| 462 | | - WARN_ON_ONCE(!mutex_is_locked(&dev_priv->binding_mutex)); |
|---|
| 459 | + lockdep_assert_held_once(&dev_priv->binding_mutex); |
|---|
| 463 | 460 | |
|---|
| 464 | 461 | list_for_each_entry_safe(entry, next, list, srf_head) |
|---|
| 465 | 462 | WARN_ON(vmw_view_destroy(&entry->res)); |
|---|
| .. | .. |
|---|
| 496 | 493 | vmw_view_key(user_key, view_type)); |
|---|
| 497 | 494 | } |
|---|
| 498 | 495 | |
|---|
| 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 | + |
|---|
| 499 | 521 | const u32 vmw_view_destroy_cmds[] = { |
|---|
| 500 | 522 | [vmw_view_sr] = SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW, |
|---|
| 501 | 523 | [vmw_view_rt] = SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW, |
|---|
| 502 | 524 | [vmw_view_ds] = SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW, |
|---|
| 525 | + [vmw_view_ua] = SVGA_3D_CMD_DX_DESTROY_UA_VIEW, |
|---|
| 503 | 526 | }; |
|---|
| 504 | 527 | |
|---|
| 505 | 528 | const SVGACOTableType vmw_view_cotables[] = { |
|---|
| 506 | 529 | [vmw_view_sr] = SVGA_COTABLE_SRVIEW, |
|---|
| 507 | 530 | [vmw_view_rt] = SVGA_COTABLE_RTVIEW, |
|---|
| 508 | 531 | [vmw_view_ds] = SVGA_COTABLE_DSVIEW, |
|---|
| 532 | + [vmw_view_ua] = SVGA_COTABLE_UAVIEW, |
|---|
| 509 | 533 | }; |
|---|
| 510 | 534 | |
|---|
| 511 | 535 | const SVGACOTableType vmw_so_cotables[] = { |
|---|