drm/ast: Various changes for video memory
Subsystems (3)
Thomas Zimmermann
maintainercover drm/ast: Various changes for video memory
Various changes to detecting and organizing video memory on Aspeed hardware. Resolves code duplication and cruft.
Patches 1 to 3 do a number of cleanups to the code for detecting the size of the video memory. Patches 4 to 7 provide helpers for calculating framebuffer and cursor locations within the video memory.
Tested on AST2600 hardware.
Thomas Zimmermann (7):
drm/ast: Replace AST_VIDMEM_SIZE_ with Linux SZ_ constants drm/ast: Add VGACRAA register constants
drm/ast: Add VGACR99 register constants
drm/ast: cursor: Add helpers for computing location in video memory drm/ast: Add helper for computing framebuffer location in video memory drm/ast: Remove vram_fb_available from struct ast_device drm/ast: cursor: Drop page alignment
drivers/gpu/drm/ast/ast_cursor.c | 36 +++++++++++++++++++------------- drivers/gpu/drm/ast/ast_drv.h | 13 +----------- drivers/gpu/drm/ast/ast_mm.c | 26 +++++++++++------------ drivers/gpu/drm/ast/ast_mode.c | 25 ++++++++++++++++++---- drivers/gpu/drm/ast/ast_post.c | 24 ++++++++++----------- drivers/gpu/drm/ast/ast_reg.h | 2 ++ 6 files changed, 69 insertions(+), 57 deletions(-)
Signature · 1 line
2.48.1
Thomas Zimmermann
maintainerPATCH 1/7 drm/ast: Replace AST_VIDMEM_SIZE_ with Linux SZ_ constants
Ast's AST_VIDMEM_SIZE_ constants enumerate supported video-memory sizes from 8 MiB to 128 MiB. Replace them with Linux' SZ_ constants of the same value. When expanded, the literal values remain the same.
The size constant for 128 MiB is unused and the default size is not necessary. Remove both of them.
--- drivers/gpu/drm/ast/ast_drv.h | 8 -------- drivers/gpu/drm/ast/ast_mm.c | 9 ++++----- drivers/gpu/drm/ast/ast_post.c | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 25 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +0 -8
@@ -340,14 +340,6 @@ static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 i__ast_write8_i_masked (ast->ioregs, base, index, preserve_mask, val); } -#define AST_VIDMEM_SIZE_8M 0x00800000 -#define AST_VIDMEM_SIZE_16M 0x01000000 -#define AST_VIDMEM_SIZE_32M 0x02000000 -#define AST_VIDMEM_SIZE_64M 0x04000000 -#define AST_VIDMEM_SIZE_128M 0x08000000 - -#define AST_VIDMEM_DEFAULT_SIZE AST_VIDMEM_SIZE_8M -struct ast_vbios_stdtable {u8 misc;u8 seq[4 ];
drivers/gpu/drm/ast/ast_mm.c +4 -5
@@ -38,20 +38,19 @@ static u32 ast_get_vram_size(struct ast_device *ast)u8 jreg;u32 vram_size; - vram_size =AST_VIDMEM_DEFAULT_SIZE ; jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xaa ,0xff );switch (jreg &3 ) {case 0 : - vram_size =AST_VIDMEM_SIZE_8M ; + vram_size =SZ_8M ;break ;case 1 : - vram_size =AST_VIDMEM_SIZE_16M ; + vram_size =SZ_16M ;break ;case 2 : - vram_size =AST_VIDMEM_SIZE_32M ; + vram_size =SZ_32M ;break ;case 3 : - vram_size =AST_VIDMEM_SIZE_64M ; + vram_size =SZ_64M ;break ; }
drivers/gpu/drm/ast/ast_post.c +12 -12
@@ -1075,16 +1075,16 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *parswitch (param->vram_size) {default : -case AST_VIDMEM_SIZE_8M : +case SZ_8M : param->dram_config |=0x00 ;break ; -case AST_VIDMEM_SIZE_16M : +case SZ_16M : param->dram_config |=0x04 ;break ; -case AST_VIDMEM_SIZE_32M : +case SZ_32M : param->dram_config |=0x08 ;break ; -case AST_VIDMEM_SIZE_64M : +case SZ_64M : param->dram_config |=0x0c ;break ; }
@@ -1446,16 +1446,16 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *parswitch (param->vram_size) {default : -case AST_VIDMEM_SIZE_8M : +case SZ_8M : param->dram_config |=0x00 ;break ; -case AST_VIDMEM_SIZE_16M : +case SZ_16M : param->dram_config |=0x04 ;break ; -case AST_VIDMEM_SIZE_32M : +case SZ_32M : param->dram_config |=0x08 ;break ; -case AST_VIDMEM_SIZE_64M : +case SZ_64M : param->dram_config |=0x0c ;break ; }
@@ -1635,19 +1635,19 @@ static void ast_post_chip_2300(struct ast_device *ast)switch (temp &0x0c ) {default :case 0x00 : - param.vram_size =AST_VIDMEM_SIZE_8M ; + param.vram_size =SZ_8M ;break ;case 0x04 : - param.vram_size =AST_VIDMEM_SIZE_16M ; + param.vram_size =SZ_16M ;break ;case 0x08 : - param.vram_size =AST_VIDMEM_SIZE_32M ; + param.vram_size =SZ_32M ;break ;case 0x0c : - param.vram_size =AST_VIDMEM_SIZE_64M ; + param.vram_size =SZ_64M ;break ; }
Signature · 1 line
2.48.1
Re: [PATCH 1/7] drm/ast: Replace AST_VIDMEM_SIZE_ with Linux SZ_ constants
Quoted 6 lines · Thomas Zimmermann
Ast's
AST_VIDMEM_SIZE_constants enumerate supported video-memory sizes from 8 MiB to 128 MiB. Replace them with Linux'SZ_constants of the same value. When expanded, the literal values remain the same.The size constant for 128 MiB is unused and the default size is not necessary. Remove both of them.
Thanks, it looks good to me.
Quoted 126 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_drv.h | 8 -------- drivers/gpu/drm/ast/ast_mm.c | 9 ++++----- drivers/gpu/drm/ast/ast_post.c | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 25 deletions(-)drivers/gpu/drm/ast/ast_drv.h +0
-8@@ -340,14 +340,6 @@ static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 i__ast_write8_i_masked (ast->ioregs, base, index, preserve_mask, val); } -#define AST_VIDMEM_SIZE_8M 0x00800000 -#define AST_VIDMEM_SIZE_16M 0x01000000 -#define AST_VIDMEM_SIZE_32M 0x02000000 -#define AST_VIDMEM_SIZE_64M 0x04000000 -#define AST_VIDMEM_SIZE_128M 0x08000000 - -#define AST_VIDMEM_DEFAULT_SIZE AST_VIDMEM_SIZE_8M -struct ast_vbios_stdtable {u8 misc;u8 seq[4 ];drivers/gpu/drm/ast/ast_mm.c +4
-5@@ -38,20 +38,19 @@ static u32 ast_get_vram_size(struct ast_device *ast)u8 jreg;u32 vram_size; - vram_size =AST_VIDMEM_DEFAULT_SIZE ; jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xaa ,0xff );switch (jreg &3 ) {case 0 : - vram_size =AST_VIDMEM_SIZE_8M ; + vram_size =SZ_8M ;break ;case 1 : - vram_size =AST_VIDMEM_SIZE_16M ; + vram_size =SZ_16M ;break ;case 2 : - vram_size =AST_VIDMEM_SIZE_32M ; + vram_size =SZ_32M ;break ;case 3 : - vram_size =AST_VIDMEM_SIZE_64M ; + vram_size =SZ_64M ;break ; }drivers/gpu/drm/ast/ast_post.c +12
-12@@ -1075,16 +1075,16 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *parswitch (param->vram_size) {default : -case AST_VIDMEM_SIZE_8M : +case SZ_8M : param->dram_config |=0x00 ;break ; -case AST_VIDMEM_SIZE_16M : +case SZ_16M : param->dram_config |=0x04 ;break ; -case AST_VIDMEM_SIZE_32M : +case SZ_32M : param->dram_config |=0x08 ;break ; -case AST_VIDMEM_SIZE_64M : +case SZ_64M : param->dram_config |=0x0c ;break ; }@@ -1446,16 +1446,16 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *parswitch (param->vram_size) {default : -case AST_VIDMEM_SIZE_8M : +case SZ_8M : param->dram_config |=0x00 ;break ; -case AST_VIDMEM_SIZE_16M : +case SZ_16M : param->dram_config |=0x04 ;break ; -case AST_VIDMEM_SIZE_32M : +case SZ_32M : param->dram_config |=0x08 ;break ; -case AST_VIDMEM_SIZE_64M : +case SZ_64M : param->dram_config |=0x0c ;break ; }@@ -1635,19 +1635,19 @@ static void ast_post_chip_2300(struct ast_device *ast)switch (temp &0x0c ) {default :case 0x00 : - param.vram_size =AST_VIDMEM_SIZE_8M ; + param.vram_size =SZ_8M ;break ;case 0x04 : - param.vram_size =AST_VIDMEM_SIZE_16M ; + param.vram_size =SZ_16M ;break ;case 0x08 : - param.vram_size =AST_VIDMEM_SIZE_32M ; + param.vram_size =SZ_32M ;break ;case 0x0c : - param.vram_size =AST_VIDMEM_SIZE_64M ; + param.vram_size =SZ_64M ;break ; }
Thomas Zimmermann
maintainerPATCH 2/7 drm/ast: Add VGACRAA register constants
In reply to Thomas ZimmermannAdd register constants for VGACRAA and use them when detecting the size of the VGA memory. Aligns the code with the programming manual.
--- drivers/gpu/drm/ast/ast_mm.c | 5 +++-- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mm.c +3 -2
@@ -37,9 +37,10 @@ static u32 ast_get_vram_size(struct ast_device *ast) {u8 jreg;u32 vram_size; +u8 vgacraa; - jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xaa ,0xff ); -switch (jreg &3 ) { + vgacraa =ast_get_index_reg (ast,AST_IO_VGACRI ,0xaa ); +switch (vgacraa &AST_IO_VGACRAA_VGAMEM_SIZE_MASK ) {case 0 : vram_size =SZ_8M ;break ;
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -33,6 +33,7 @@#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1)#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2)#define AST_IO_VGACRA3_DVO_ENABLED BIT(7) +#define AST_IO_VGACRAA_VGAMEM_SIZE_MASK GENMASK(1, 0)#define AST_IO_VGACRB6_HSYNC_OFF BIT(0)#define AST_IO_VGACRB6_VSYNC_OFF BIT(1)#define AST_IO_VGACRCB_HWC_16BPP BIT(0)/* set: ARGB4444, cleared: 2bpp palette */
Signature · 1 line
2.48.1
Re: [PATCH 2/7] drm/ast: Add VGACRAA register constants
Quoted 2 lines · Thomas Zimmermann
Add register constants for VGACRAA and use them when detecting the size of the VGA memory. Aligns the code with the programming manual.
Thanks, it looks good to me.
Quoted 36 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mm.c | 5 +++-- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/ast/ast_mm.c +3
-2@@ -37,9 +37,10 @@ static u32 ast_get_vram_size(struct ast_device *ast) {u8 jreg;u32 vram_size; +u8 vgacraa; - jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xaa ,0xff ); -switch (jreg &3 ) { + vgacraa =ast_get_index_reg (ast,AST_IO_VGACRI ,0xaa ); +switch (vgacraa &AST_IO_VGACRAA_VGAMEM_SIZE_MASK ) {case 0 : vram_size =SZ_8M ;break ;drivers/gpu/drm/ast/ast_reg.h +1
-0@@ -33,6 +33,7 @@#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1)#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2)#define AST_IO_VGACRA3_DVO_ENABLED BIT(7) +#define AST_IO_VGACRAA_VGAMEM_SIZE_MASK GENMASK(1, 0)#define AST_IO_VGACRB6_HSYNC_OFF BIT(0)#define AST_IO_VGACRB6_VSYNC_OFF BIT(1)#define AST_IO_VGACRCB_HWC_16BPP BIT(0)/* set: ARGB4444, cleared: 2bpp palette */
Thomas Zimmermann
maintainerPATCH 3/7 drm/ast: Add VGACR99 register constants
In reply to Thomas ZimmermannAdd register constants for VGACR99 and use them when detecting the size of the VGA memory. Aligns the code with the programming manual. Also replace literal size values with Linux' SZ_ size constants.
--- drivers/gpu/drm/ast/ast_mm.c | 13 ++++++------- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/ast/ast_mm.c +6 -7
@@ -35,9 +35,8 @@static u32 ast_get_vram_size (struct ast_device *ast) { -u8 jreg;u32 vram_size; -u8 vgacraa; +u8 vgacr99, vgacraa; vgacraa =ast_get_index_reg (ast,AST_IO_VGACRI ,0xaa );switch (vgacraa &AST_IO_VGACRAA_VGAMEM_SIZE_MASK ) {
@@ -55,16 +54,16 @@ static u32 ast_get_vram_size(struct ast_device *ast)break ; } - jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0x99 ,0xff ); -switch (jreg &0x03 ) { + vgacr99 =ast_get_index_reg (ast,AST_IO_VGACRI ,0x99 ); +switch (vgacr99 &AST_IO_VGACR99_VGAMEM_RSRV_MASK ) {case 1 : - vram_size -=0x100000 ; + vram_size -=SZ_1M ;break ;case 2 : - vram_size -=0x200000 ; + vram_size -=SZ_2M ;break ;case 3 : - vram_size -=0x400000 ; + vram_size -=SZ_4M ;break ; }
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -30,6 +30,7 @@#define AST_IO_VGACRI (0x54)#define AST_IO_VGACR80_PASSWORD (0xa8) +#define AST_IO_VGACR99_VGAMEM_RSRV_MASK GENMASK(1, 0)#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1)#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2)#define AST_IO_VGACRA3_DVO_ENABLED BIT(7)
Signature · 1 line
2.48.1
Re: [PATCH 3/7] drm/ast: Add VGACR99 register constants
Quoted 3 lines · Thomas Zimmermann
Add register constants for VGACR99 and use them when detecting the size of the VGA memory. Aligns the code with the programming manual. Also replace literal size values with Linux'
SZ_size constants.
Thanks, it looks good to me.
Quoted 56 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mm.c | 13 ++++++------- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/ast/ast_mm.c +6
-7@@ -35,9 +35,8 @@static u32 ast_get_vram_size (struct ast_device *ast) { -u8 jreg;u32 vram_size; -u8 vgacraa; +u8 vgacr99, vgacraa; vgacraa =ast_get_index_reg (ast,AST_IO_VGACRI ,0xaa );switch (vgacraa &AST_IO_VGACRAA_VGAMEM_SIZE_MASK ) {@@ -55,16 +54,16 @@ static u32 ast_get_vram_size(struct ast_device *ast)break ; } - jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0x99 ,0xff ); -switch (jreg &0x03 ) { + vgacr99 =ast_get_index_reg (ast,AST_IO_VGACRI ,0x99 ); +switch (vgacr99 &AST_IO_VGACR99_VGAMEM_RSRV_MASK ) {case 1 : - vram_size -=0x100000 ; + vram_size -=SZ_1M ;break ;case 2 : - vram_size -=0x200000 ; + vram_size -=SZ_2M ;break ;case 3 : - vram_size -=0x400000 ; + vram_size -=SZ_4M ;break ; }drivers/gpu/drm/ast/ast_reg.h +1
-0@@ -30,6 +30,7 @@#define AST_IO_VGACRI (0x54)#define AST_IO_VGACR80_PASSWORD (0xa8) +#define AST_IO_VGACR99_VGAMEM_RSRV_MASK GENMASK(1, 0)#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1)#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2)#define AST_IO_VGACRA3_DVO_ENABLED BIT(7)
Thomas Zimmermann
maintainerPATCH 4/7 drm/ast: cursor: Add helpers for computing location in video memory
In reply to Thomas ZimmermannThe ast drivers stores the cursor image at the end of the video memory. Add helpers to calculate the offset and size.
--- drivers/gpu/drm/ast/ast_cursor.c | 21 +++++++++++++++++++-- drivers/gpu/drm/ast/ast_drv.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_cursor.c +19 -2
@@ -45,6 +45,21 @@#define AST_HWC_SIGNATURE_HOTSPOTX 0x14#define AST_HWC_SIGNATURE_HOTSPOTY 0x18 +static unsigned long ast_cursor_vram_size (void ) +{ +return AST_HWC_SIZE +AST_HWC_SIGNATURE_SIZE ; +} + +long ast_cursor_vram_offset (struct ast_device *ast) +{ +unsigned long size =ast_cursor_vram_size (); + +if (size > ast->vram_size) +return -EINVAL ; + +return PAGE_ALIGN_DOWN (ast->vram_size - size); +} +static u32 ast_cursor_calculate_checksum (const void *src,unsigned int width,unsigned int height) {u32 csum =0 ;
@@ -276,7 +291,7 @@ int ast_cursor_plane_init(struct ast_device *ast)struct drm_plane *cursor_plane = &ast_plane->base;size_t size;void __iomem *vaddr; -u64 offset; +long offset;int ret;/*
@@ -290,7 +305,9 @@ int ast_cursor_plane_init(struct ast_device *ast)return -ENOMEM ; vaddr = ast->vram + ast->vram_fb_available - size; - offset = ast->vram_fb_available - size; + offset =ast_cursor_vram_offset (ast); +if (offset <0 ) +return offset; ret = ast_plane_init(dev, ast_plane, vaddr, offset, size, 0x01, &ast_cursor_plane_funcs,
drivers/gpu/drm/ast/ast_drv.h +1 -0
@@ -432,6 +432,7 @@ int ast_vga_output_init(struct ast_device *ast);int ast_sil164_output_init (struct ast_device *ast);/* ast_cursor.c */ +long ast_cursor_vram_offset (struct ast_device *ast);int ast_cursor_plane_init (struct ast_device *ast);/* ast dp501 */
Signature · 1 line
2.48.1
Re: [PATCH 4/7] drm/ast: cursor: Add helpers for computing location in video memory
Quoted 3 lines · Thomas Zimmermann
The ast drivers stores the cursor image at the end of the video memory. Add helpers to calculate the offset and size.
Thanks, it looks good to me.
Quoted 64 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_cursor.c | 21 +++++++++++++++++++-- drivers/gpu/drm/ast/ast_drv.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/ast/ast_cursor.c +19
-2@@ -45,6 +45,21 @@#define AST_HWC_SIGNATURE_HOTSPOTX 0x14#define AST_HWC_SIGNATURE_HOTSPOTY 0x18 +static unsigned long ast_cursor_vram_size (void ) +{ +return AST_HWC_SIZE +AST_HWC_SIGNATURE_SIZE ; +} + +long ast_cursor_vram_offset (struct ast_device *ast) +{ +unsigned long size =ast_cursor_vram_size (); + +if (size > ast->vram_size) +return -EINVAL ; + +return PAGE_ALIGN_DOWN (ast->vram_size - size); +} +static u32 ast_cursor_calculate_checksum (const void *src,unsigned int width,unsigned int height) {u32 csum =0 ;@@ -276,7 +291,7 @@ int ast_cursor_plane_init(struct ast_device *ast)struct drm_plane *cursor_plane = &ast_plane->base;size_t size;void __iomem *vaddr; -u64 offset; +long offset;int ret;/* @@ -290,7 +305,9 @@ int ast_cursor_plane_init(struct ast_device *ast)return -ENOMEM ; vaddr = ast->vram + ast->vram_fb_available - size; - offset = ast->vram_fb_available - size; + offset =ast_cursor_vram_offset (ast); +if (offset <0 ) +return offset; ret = ast_plane_init(dev, ast_plane, vaddr, offset, size, 0x01, &ast_cursor_plane_funcs,drivers/gpu/drm/ast/ast_drv.h +1
-0@@ -432,6 +432,7 @@ int ast_vga_output_init(struct ast_device *ast);int ast_sil164_output_init (struct ast_device *ast);/* ast_cursor.c */ +long ast_cursor_vram_offset (struct ast_device *ast);int ast_cursor_plane_init (struct ast_device *ast);/* ast dp501 */
Thomas Zimmermann
maintainerPATCH 5/7 drm/ast: Add helper for computing framebuffer location in video memory
In reply to Thomas ZimmermannThe ast driver stores the primary plane's image in the framebuffer memory up to where the cursor is located. Add helpers to calculate the offset and size.
--- drivers/gpu/drm/ast/ast_mode.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +21 -4
@@ -51,6 +51,24 @@#define AST_LUT_SIZE 256 +static unsigned long ast_fb_vram_offset (void ) +{ +return 0 ;// with shmem, the primary plane is always at offset 0 +} + +static unsigned long ast_fb_vram_size (struct ast_device *ast) +{ +struct drm_device *dev = &ast->base; +unsigned long offset =ast_fb_vram_offset ();// starts at offset +long cursor_offset =ast_cursor_vram_offset (ast);// ends at cursor offset + +if (cursor_offset <0 ) + cursor_offset = ast->vram_size;// no cursor; it's all ours +if (drm_WARN_ON_ONCE (dev, offset > cursor_offset)) +return 0 ;// cannot legally happen; signal error +return cursor_offset - offset; +} +static inline void ast_load_palette_index (struct ast_device *ast,u8 index,u8 red,u8 green,u8 blue)
@@ -609,9 +627,8 @@ static int ast_primary_plane_init(struct ast_device *ast)struct ast_plane *ast_primary_plane = &ast->primary_plane;struct drm_plane *primary_plane = &ast_primary_plane->base;void __iomem *vaddr = ast->vram; -u64 offset =0 ;/* with shmem, the primary plane is always at offset 0 */ -unsigned long cursor_size =roundup (AST_HWC_SIZE +AST_HWC_SIGNATURE_SIZE ,PAGE_SIZE ); -unsigned long size = ast->vram_fb_available - cursor_size; +u64 offset =ast_fb_vram_offset (); +unsigned long size =ast_fb_vram_size (ast);int ret; ret = ast_plane_init(dev, ast_primary_plane, vaddr, offset, size,
@@ -942,7 +959,7 @@ static enum drm_mode_status ast_mode_config_mode_valid(struct drm_device *dev,struct ast_device *ast =to_ast_device (dev);unsigned long fbsize, fbpages, max_fbpages; - max_fbpages = (ast->vram_fb_available) >>PAGE_SHIFT ; + max_fbpages =ast_fb_vram_size (ast) >>PAGE_SHIFT ; fbsize = mode->hdisplay * mode->vdisplay * max_bpp; fbpages =DIV_ROUND_UP (fbsize,PAGE_SIZE );
Signature · 1 line
2.48.1
Thomas Zimmermann
maintainerPATCH 6/7 drm/ast: Remove vram_fb_available from struct ast_device
In reply to Thomas ZimmermannHelpers 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.
--- drivers/gpu/drm/ast/ast_cursor.c | 15 ++------------- drivers/gpu/drm/ast/ast_drv.h | 4 ---- drivers/gpu/drm/ast/ast_mm.c | 1 - 3 files changed, 2 insertions(+), 18 deletions(-)
drivers/gpu/drm/ast/ast_cursor.c +2 -13
@@ -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
@@ -294,20 +295,10 @@ int ast_cursor_plane_init(struct ast_device *ast)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; 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 +311,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 ; }
drivers/gpu/drm/ast/ast_drv.h +0 -4
@@ -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 */
drivers/gpu/drm/ast/ast_mm.c +0 -1
@@ -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 ; }
Signature · 1 line
2.48.1
Thomas Zimmermann
maintainerRe: [PATCH 6/7] drm/ast: Remove vram_fb_available from struct ast_device
Am 05.03.25 um 14:35 schrieb Thomas Zimmermann:
Quoted 25 lines
Helpers compute the offset and size of the available framebuffer memory. Remove the obsolete field
vram_fb_availablefrom structast_device. Also define the cursor-signature size next to its only user.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_cursor.c | 15 ++------------- drivers/gpu/drm/ast/ast_drv.h | 4 ---- drivers/gpu/drm/ast/ast_mm.c | 1 - 3 files changed, 2 insertions(+), 18 deletions(-)drivers/gpu/drm/ast/ast_cursor.c +1
-0@@ -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
drivers/gpu/drm/ast/ast_cursor.c int ast_cursor_plane_init(struct ast_device *ast) · line 302
Quoted 9 lines
drivers/gpu/drm/ast/ast_cursor.c +0
-6@@ -294,20 +295,10 @@ int ast_cursor_plane_init(struct ast_device *ast)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 );
There's a bug here, as size if now uninitialized. will be fixed in the next iteration.
Quoted 57 lines
drivers/gpu/drm/ast/ast_cursor.c +1
-7- -if (ast->vram_fb_available < size) -return -ENOMEM ; - - vaddr = ast->vram + ast->vram_fb_available - 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 +311,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 ; }drivers/gpu/drm/ast/ast_drv.h +0
-4@@ -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 */ drivers/gpu/drm/ast/ast_mm.c +0
-1@@ -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 ; }
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Thomas Zimmermann
maintainerPATCH 7/7 drm/ast: cursor: Drop page alignment
In reply to Thomas ZimmermannThe cursor scanout address requires alignment to a multiple of 8, but does not require page alignment. Change the offset calculation accordingly. Frees up a few more bytes for the primary framebuffer.
--- drivers/gpu/drm/ast/ast_cursor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_cursor.c +1 -1
@@ -58,7 +58,7 @@ long ast_cursor_vram_offset(struct ast_device *ast)if (size > ast->vram_size)return -EINVAL ; -return PAGE_ALIGN_DOWN (ast->vram_size - size); +return ALIGN_DOWN (ast->vram_size - size,SZ_8 ); }static u32 ast_cursor_calculate_checksum (const void *src,unsigned int width,unsigned int height)
Signature · 1 line
2.48.1