diff options
author | Tobias Jakobi <tjakobi@math.uni-bielefeld.de> | 2016-09-27 11:50:08 -0400 |
---|---|---|
committer | Inki Dae <daeinki@gmail.com> | 2016-09-30 11:39:39 -0400 |
commit | 5332737432ad5989830dae75df0d3e9cce56e893 (patch) | |
tree | fe97d8862b441619e25812280685fe62cf91d3f4 | |
parent | 22d6704dd4bf2c80b3850b8f7ff05a67f626fa53 (diff) |
drm/exynos: g2d: remove runqueue nodes in g2d_{close,remove}()
The driver might be closed (and/or removed) while there are still
nodes queued for processing.
Make sure to remove these nodes, which means all of them in
the case of g2d_remove() and only those belonging to the
corresponding process in g2d_close().
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_g2d.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 7252faeae2cf..0f84e7b32c0f 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c | |||
@@ -855,11 +855,27 @@ static void g2d_free_runqueue_node(struct g2d_data *g2d, | |||
855 | kmem_cache_free(g2d->runqueue_slab, runqueue_node); | 855 | kmem_cache_free(g2d->runqueue_slab, runqueue_node); |
856 | } | 856 | } |
857 | 857 | ||
858 | static void g2d_exec_runqueue(struct g2d_data *g2d) | 858 | /** |
859 | * g2d_remove_runqueue_nodes - remove items from the list of runqueue nodes | ||
860 | * @g2d: G2D state object | ||
861 | * @file: if not zero, only remove items with this DRM file | ||
862 | * | ||
863 | * Has to be called under runqueue lock. | ||
864 | */ | ||
865 | static void g2d_remove_runqueue_nodes(struct g2d_data *g2d, struct drm_file* file) | ||
859 | { | 866 | { |
860 | g2d->runqueue_node = g2d_get_runqueue_node(g2d); | 867 | struct g2d_runqueue_node *node, *n; |
861 | if (g2d->runqueue_node) | 868 | |
862 | g2d_dma_start(g2d, g2d->runqueue_node); | 869 | if (list_empty(&g2d->runqueue)) |
870 | return; | ||
871 | |||
872 | list_for_each_entry_safe(node, n, &g2d->runqueue, list) { | ||
873 | if (file && node->filp != file) | ||
874 | continue; | ||
875 | |||
876 | list_del_init(&node->list); | ||
877 | g2d_free_runqueue_node(g2d, node); | ||
878 | } | ||
863 | } | 879 | } |
864 | 880 | ||
865 | static void g2d_runqueue_worker(struct work_struct *work) | 881 | static void g2d_runqueue_worker(struct work_struct *work) |
@@ -1369,15 +1385,19 @@ static void g2d_close(struct drm_device *drm_dev, struct device *dev, | |||
1369 | if (!g2d) | 1385 | if (!g2d) |
1370 | return; | 1386 | return; |
1371 | 1387 | ||
1388 | /* Remove the runqueue nodes that belong to us. */ | ||
1389 | mutex_lock(&g2d->runqueue_mutex); | ||
1390 | g2d_remove_runqueue_nodes(g2d, file); | ||
1391 | mutex_unlock(&g2d->runqueue_mutex); | ||
1392 | |||
1393 | /* | ||
1394 | * Even after the engine is idle, there might still be stale cmdlists | ||
1395 | * (i.e. cmdlisst which we submitted but never executed) around, with | ||
1396 | * their corresponding GEM/userptr buffers. | ||
1397 | * Properly unmap these buffers here. | ||
1398 | */ | ||
1372 | mutex_lock(&g2d->cmdlist_mutex); | 1399 | mutex_lock(&g2d->cmdlist_mutex); |
1373 | list_for_each_entry_safe(node, n, &g2d_priv->inuse_cmdlist, list) { | 1400 | list_for_each_entry_safe(node, n, &g2d_priv->inuse_cmdlist, list) { |
1374 | /* | ||
1375 | * unmap all gem objects not completed. | ||
1376 | * | ||
1377 | * P.S. if current process was terminated forcely then | ||
1378 | * there may be some commands in inuse_cmdlist so unmap | ||
1379 | * them. | ||
1380 | */ | ||
1381 | g2d_unmap_cmdlist_gem(g2d, node, file); | 1401 | g2d_unmap_cmdlist_gem(g2d, node, file); |
1382 | list_move_tail(&node->list, &g2d->free_cmdlist); | 1402 | list_move_tail(&node->list, &g2d->free_cmdlist); |
1383 | } | 1403 | } |
@@ -1496,10 +1516,8 @@ static int g2d_remove(struct platform_device *pdev) | |||
1496 | cancel_work_sync(&g2d->runqueue_work); | 1516 | cancel_work_sync(&g2d->runqueue_work); |
1497 | exynos_drm_subdrv_unregister(&g2d->subdrv); | 1517 | exynos_drm_subdrv_unregister(&g2d->subdrv); |
1498 | 1518 | ||
1499 | while (g2d->runqueue_node) { | 1519 | /* There should be no locking needed here. */ |
1500 | g2d_free_runqueue_node(g2d, g2d->runqueue_node); | 1520 | g2d_remove_runqueue_nodes(g2d, NULL); |
1501 | g2d->runqueue_node = g2d_get_runqueue_node(g2d); | ||
1502 | } | ||
1503 | 1521 | ||
1504 | pm_runtime_disable(&pdev->dev); | 1522 | pm_runtime_disable(&pdev->dev); |
1505 | 1523 | ||