Skip to content

Commit a44df74

Browse files
committed
drm/vmwgfx: Make the driver work without the dummy resources
In commit 1802537 ("drm/ttm: stop allocating dummy resources during BO creation") ttm stopped allocating dummy resources but vmwgfx was never ported to handle it. Make the driver treat null resources as initial creation and port code to handle null resources in general. Fixes kernel oops'es on boot with vmwgfx. Signed-off-by: Zack Rusin <[email protected]> Fixes: 1802537 ("drm/ttm: stop allocating dummy resources during BO creation") Cc: Christian König <[email protected]> Cc: Matthew Auld <[email protected]> Cc: Nirmoy Das <[email protected]> Cc: Christian Koenig <[email protected]> Cc: Huang Rui <[email protected]> Cc: [email protected] Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 668b206 commit a44df74

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_resource.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,8 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo,
837837
mutex_lock(&dev_priv->binding_mutex);
838838

839839
/* If BO is being moved from MOB to system memory */
840-
if (new_mem->mem_type == TTM_PL_SYSTEM &&
840+
if (old_mem &&
841+
new_mem->mem_type == TTM_PL_SYSTEM &&
841842
old_mem->mem_type == VMW_PL_MOB) {
842843
struct vmw_fence_obj *fence;
843844

drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,19 +515,29 @@ static int vmw_move(struct ttm_buffer_object *bo,
515515
struct ttm_resource *new_mem,
516516
struct ttm_place *hop)
517517
{
518-
struct ttm_resource_manager *old_man = ttm_manager_type(bo->bdev, bo->resource->mem_type);
519-
struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
520-
int ret;
518+
struct ttm_resource_manager *new_man;
519+
struct ttm_resource_manager *old_man = NULL;
520+
int ret = 0;
521+
522+
new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
523+
if (bo->resource)
524+
old_man = ttm_manager_type(bo->bdev, bo->resource->mem_type);
521525

522526
if (new_man->use_tt && !vmw_memtype_is_system(new_mem->mem_type)) {
523527
ret = vmw_ttm_bind(bo->bdev, bo->ttm, new_mem);
524528
if (ret)
525529
return ret;
526530
}
527531

532+
if (!bo->resource || (bo->resource->mem_type == TTM_PL_SYSTEM &&
533+
bo->ttm == NULL)) {
534+
ttm_bo_move_null(bo, new_mem);
535+
return 0;
536+
}
537+
528538
vmw_move_notify(bo, bo->resource, new_mem);
529539

530-
if (old_man->use_tt && new_man->use_tt) {
540+
if (old_man && old_man->use_tt && new_man->use_tt) {
531541
if (vmw_memtype_is_system(bo->resource->mem_type)) {
532542
ttm_bo_move_null(bo, new_mem);
533543
return 0;

0 commit comments

Comments
 (0)