summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ast/ast_cursor.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/ast/ast_cursor.c')
-rw-r--r--drivers/gpu/drm/ast/ast_cursor.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/gpu/drm/ast/ast_cursor.c b/drivers/gpu/drm/ast/ast_cursor.c
index 35680402e410..acf0d23514e8 100644
--- a/drivers/gpu/drm/ast/ast_cursor.c
+++ b/drivers/gpu/drm/ast/ast_cursor.c
@@ -28,9 +28,30 @@
*/
#include <drm/drm_gem_vram_helper.h>
+#include <drm/drm_managed.h>
#include "ast_drv.h"
+static void ast_cursor_fini(struct ast_private *ast)
+{
+ size_t i;
+ struct drm_gem_vram_object *gbo;
+
+ for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
+ gbo = ast->cursor.gbo[i];
+ drm_gem_vram_vunmap(gbo, ast->cursor.vaddr[i]);
+ drm_gem_vram_unpin(gbo);
+ drm_gem_vram_put(gbo);
+ }
+}
+
+static void ast_cursor_release(struct drm_device *dev, void *ptr)
+{
+ struct ast_private *ast = dev->dev_private;
+
+ ast_cursor_fini(ast);
+}
+
/*
* Allocate cursor BOs and pins them at the end of VRAM.
*/
@@ -68,7 +89,7 @@ int ast_cursor_init(struct ast_private *ast)
ast->cursor.vaddr[i] = vaddr;
}
- return 0;
+ return drmm_add_action_or_reset(dev, ast_cursor_release, NULL);
err_drm_gem_vram_put:
while (i) {
@@ -77,25 +98,10 @@ err_drm_gem_vram_put:
drm_gem_vram_vunmap(gbo, ast->cursor.vaddr[i]);
drm_gem_vram_unpin(gbo);
drm_gem_vram_put(gbo);
- ast->cursor.gbo[i] = NULL;
- ast->cursor.vaddr[i] = NULL;
}
return ret;
}
-void ast_cursor_fini(struct ast_private *ast)
-{
- size_t i;
- struct drm_gem_vram_object *gbo;
-
- for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
- gbo = ast->cursor.gbo[i];
- drm_gem_vram_vunmap(gbo, ast->cursor.vaddr[i]);
- drm_gem_vram_unpin(gbo);
- drm_gem_vram_put(gbo);
- }
-}
-
static void update_cursor_image(u8 __iomem *dst, const u8 *src, int width, int height)
{
union {