Skip to content

Commit 22ca7ca

Browse files
committed
Merge branch 'vmwgfx-fixes-4.3' of git://people.freedesktop.org/~thomash/linux
I'm not sure whether this patch comes in too late, but it would be good to have it in. It stabilizes command submission in case of command buffer errors. * 'vmwgfx-fixes-4.3' of git://people.freedesktop.org/~thomash/linux: drm/vmwgfx: Stabilize the command buffer submission code
2 parents aef8cc9 + 09dc138 commit 22ca7ca

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,16 @@ static void vmw_cmdbuf_ctx_process(struct vmw_cmdbuf_man *man,
415415
*
416416
* Calls vmw_cmdbuf_ctx_process() on all contexts. If any context has
417417
* command buffers left that are not submitted to hardware, Make sure
418-
* IRQ handling is turned on. Otherwise, make sure it's turned off. This
419-
* function may return -EAGAIN to indicate it should be rerun due to
420-
* possibly missed IRQs if IRQs has just been turned on.
418+
* IRQ handling is turned on. Otherwise, make sure it's turned off.
421419
*/
422-
static int vmw_cmdbuf_man_process(struct vmw_cmdbuf_man *man)
420+
static void vmw_cmdbuf_man_process(struct vmw_cmdbuf_man *man)
423421
{
424-
int notempty = 0;
422+
int notempty;
425423
struct vmw_cmdbuf_context *ctx;
426424
int i;
427425

426+
retry:
427+
notempty = 0;
428428
for_each_cmdbuf_ctx(man, i, ctx)
429429
vmw_cmdbuf_ctx_process(man, ctx, &notempty);
430430

@@ -440,10 +440,8 @@ static int vmw_cmdbuf_man_process(struct vmw_cmdbuf_man *man)
440440
man->irq_on = true;
441441

442442
/* Rerun in case we just missed an irq. */
443-
return -EAGAIN;
443+
goto retry;
444444
}
445-
446-
return 0;
447445
}
448446

449447
/**
@@ -468,8 +466,7 @@ static void vmw_cmdbuf_ctx_add(struct vmw_cmdbuf_man *man,
468466
header->cb_context = cb_context;
469467
list_add_tail(&header->list, &man->ctx[cb_context].submitted);
470468

471-
if (vmw_cmdbuf_man_process(man) == -EAGAIN)
472-
vmw_cmdbuf_man_process(man);
469+
vmw_cmdbuf_man_process(man);
473470
}
474471

475472
/**
@@ -488,8 +485,7 @@ static void vmw_cmdbuf_man_tasklet(unsigned long data)
488485
struct vmw_cmdbuf_man *man = (struct vmw_cmdbuf_man *) data;
489486

490487
spin_lock(&man->lock);
491-
if (vmw_cmdbuf_man_process(man) == -EAGAIN)
492-
(void) vmw_cmdbuf_man_process(man);
488+
vmw_cmdbuf_man_process(man);
493489
spin_unlock(&man->lock);
494490
}
495491

@@ -507,6 +503,7 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
507503
struct vmw_cmdbuf_man *man =
508504
container_of(work, struct vmw_cmdbuf_man, work);
509505
struct vmw_cmdbuf_header *entry, *next;
506+
uint32_t dummy;
510507
bool restart = false;
511508

512509
spin_lock_bh(&man->lock);
@@ -523,6 +520,8 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
523520
if (restart && vmw_cmdbuf_startstop(man, true))
524521
DRM_ERROR("Failed restarting command buffer context 0.\n");
525522

523+
/* Send a new fence in case one was removed */
524+
vmw_fifo_send_fence(man->dev_priv, &dummy);
526525
}
527526

528527
/**
@@ -682,7 +681,7 @@ static bool vmw_cmdbuf_try_alloc(struct vmw_cmdbuf_man *man,
682681
DRM_MM_SEARCH_DEFAULT,
683682
DRM_MM_CREATE_DEFAULT);
684683
if (ret) {
685-
(void) vmw_cmdbuf_man_process(man);
684+
vmw_cmdbuf_man_process(man);
686685
ret = drm_mm_insert_node_generic(&man->mm, info->node,
687686
info->page_size, 0, 0,
688687
DRM_MM_SEARCH_DEFAULT,
@@ -1168,7 +1167,14 @@ int vmw_cmdbuf_set_pool_size(struct vmw_cmdbuf_man *man,
11681167
drm_mm_init(&man->mm, 0, size >> PAGE_SHIFT);
11691168

11701169
man->has_pool = true;
1171-
man->default_size = default_size;
1170+
1171+
/*
1172+
* For now, set the default size to VMW_CMDBUF_INLINE_SIZE to
1173+
* prevent deadlocks from happening when vmw_cmdbuf_space_pool()
1174+
* needs to wait for space and we block on further command
1175+
* submissions to be able to free up space.
1176+
*/
1177+
man->default_size = VMW_CMDBUF_INLINE_SIZE;
11721178
DRM_INFO("Using command buffers with %s pool.\n",
11731179
(man->using_mob) ? "MOB" : "DMA");
11741180

0 commit comments

Comments
 (0)