drm/ast: Remove vram_fb_available from struct ast_device
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 5 Mar 2025 16:30:45 +0000 (17:30 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 12 Mar 2025 07:38:12 +0000 (08:38 +0100)
Helpers compute the offset and size of the available framebuffer
memory. Remove the obsolete field vram_fb_available from struct
ast_device. Also define the cursor-signature size next to its only
user.

v2:
- initialize plane size

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250305163207.267650-7-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_cursor.c
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_mm.c

index 05e297f30b4e1b3ffa575b71328e17102a259f33..cb0c48d4720768f84bc80e3157d40eebcc1bf30a 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 /* define for signature structure */
+#define AST_HWC_SIGNATURE_SIZE         SZ_32
 #define AST_HWC_SIGNATURE_CHECKSUM     0x00
 #define AST_HWC_SIGNATURE_SizeX                0x04
 #define AST_HWC_SIGNATURE_SizeY                0x08
@@ -289,25 +290,16 @@ int ast_cursor_plane_init(struct ast_device *ast)
        struct ast_cursor_plane *ast_cursor_plane = &ast->cursor_plane;
        struct ast_plane *ast_plane = &ast_cursor_plane->base;
        struct drm_plane *cursor_plane = &ast_plane->base;
-       size_t size;
+       unsigned long size;
        void __iomem *vaddr;
        long offset;
        int ret;
 
-       /*
-        * Allocate backing storage for cursors. The BOs are permanently
-        * pinned to the top end of the VRAM.
-        */
-
-       size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
-
-       if (ast->vram_fb_available < size)
-               return -ENOMEM;
-
-       vaddr = ast->vram + ast->vram_fb_available - size;
+       size = ast_cursor_vram_size();
        offset = ast_cursor_vram_offset(ast);
        if (offset < 0)
                return offset;
+       vaddr = ast->vram + offset;
 
        ret = ast_plane_init(dev, ast_plane, vaddr, offset, size,
                             0x01, &ast_cursor_plane_funcs,
@@ -320,7 +312,5 @@ int ast_cursor_plane_init(struct ast_device *ast)
        drm_plane_helper_add(cursor_plane, &ast_cursor_plane_helper_funcs);
        drm_plane_enable_fb_damage_clips(cursor_plane);
 
-       ast->vram_fb_available -= size;
-
        return 0;
 }
index ec9ec77260e9b9a2d2731b6c57f8ef94003acde4..d9da2328d46bb7559e8ce6f982d9738ea3666b3e 100644 (file)
@@ -112,12 +112,9 @@ enum ast_config_mode {
 
 #define AST_MAX_HWC_WIDTH      64
 #define AST_MAX_HWC_HEIGHT     64
-
 #define AST_HWC_PITCH          (AST_MAX_HWC_WIDTH * SZ_2)
 #define AST_HWC_SIZE           (AST_MAX_HWC_HEIGHT * AST_HWC_PITCH)
 
-#define AST_HWC_SIGNATURE_SIZE 32
-
 /*
  * Planes
  */
@@ -183,7 +180,6 @@ struct ast_device {
        void __iomem    *vram;
        unsigned long   vram_base;
        unsigned long   vram_size;
-       unsigned long   vram_fb_available;
 
        struct mutex modeset_lock; /* Protects access to modeset I/O registers in ioregs */
 
index 3d03ef556d0ad879660e411551ec38b67cf4847f..0bc140319464916322e317ca0cd2c1899e93a14c 100644 (file)
@@ -92,7 +92,6 @@ int ast_mm_init(struct ast_device *ast)
 
        ast->vram_base = base;
        ast->vram_size = vram_size;
-       ast->vram_fb_available = vram_size;
 
        return 0;
 }