Skip to contentSkip to conversation

drm/ast: Fix start address computation

PATCH In review Jocelyn Falempe 3 participants 4 messages Feb 9, 2023 – Feb 10, 2023

Subsystems (3)
lore
Share & tools
lore

Jocelyn Falempe

author reviewer
#0 lore raw

PATCH v3 1/1 drm/ast: Fix start address computation

During the driver conversion to shmem, the start address for the scanout buffer was set to the base PCI address.
In most cases it works because only the lower 24bits are used, and due to alignment it was almost always 0.
But on some unlucky hardware, it's not the case, and some unitilized memory is displayed on the BMC.
With shmem, the primary plane is always at offset 0 in GPU memory.

* v2: rewrite the patch to set the offset to 0. (Thomas Zimmermann)
* v3: move the change to plane_init() and also fix the cursor plane. (Jammy Huang)

Tested on a sr645 affected by this bug.

Fixes f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
---
 drivers/gpu/drm/ast/ast_mode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +2 -2
index c7443317c747..66a4a41c3fe9 100644
@@ -714,7 +714,7 @@ static int ast_primary_plane_init(struct ast_private *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 = ast->vram_base;
+	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;
 	int ret;
@@ -972,7 +972,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
 		return -ENOMEM;
 
 	vaddr = ast->vram + ast->vram_fb_available - size;
-	offset = ast->vram_base + ast->vram_fb_available - size;
+	offset = ast->vram_fb_available - size;
 
 	ret = ast_plane_init(dev, ast_cursor_plane, vaddr, offset, size,
 			     0x01, &ast_cursor_plane_funcs,
Signature · 1 line
2.39.1
maintainer Reviewed-by on v3 1/1
#1 lore raw

Am 09.02.23 um 10:44 schrieb Jocelyn Falempe:

Quoted 5 lines

During the driver conversion to shmem, the start address for the scanout buffer was set to the base PCI address.
In most cases it works because only the lower 24bits are used, and due to alignment it was almost always 0.
But on some unlucky hardware, it's not the case, and some unitilized

'uninitialized'

Quoted 11 lines

memory is displayed on the BMC.
With shmem, the primary plane is always at offset 0 in GPU memory.

* v2: rewrite the patch to set the offset to 0. (Thomas Zimmermann)
* v3: move the change to plane_init() and also fix the cursor plane. (Jammy Huang)

Tested on a sr645 affected by this bug.

Fixes f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
Quoted 26 lines
---
  drivers/gpu/drm/ast/ast_mode.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +2 -2
index c7443317c747..66a4a41c3fe9 100644
@@ -714,7 +714,7 @@ static int ast_primary_plane_init(struct ast_private *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 = ast->vram_base;
+	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;
  	int ret;
@@ -972,7 +972,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
  		return -ENOMEM;
 
  	vaddr = ast->vram + ast->vram_fb_available - size;
-	offset = ast->vram_base + ast->vram_fb_available - size;
+	offset = ast->vram_fb_available - size;
 
  	ret = ast_plane_init(dev, ast_cursor_plane, vaddr, offset, size,
  			     0x01, &ast_cursor_plane_funcs,
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
Reviewed-by
#2 lore raw
Quoted 18 lines · Thomas Zimmermann

Am 09.02.23 um 10:44 schrieb Jocelyn Falempe:

Quoted 5 lines

During the driver conversion to shmem, the start address for the scanout buffer was set to the base PCI address.
In most cases it works because only the lower 24bits are used, and due to alignment it was almost always 0.
But on some unlucky hardware, it's not the case, and some unitilized

'uninitialized'

Quoted 7 lines

memory is displayed on the BMC.
With shmem, the primary plane is always at offset 0 in GPU memory.

  * v2: rewrite the patch to set the offset to 0. (Thomas Zimmermann)
  * v3: move the change to plane_init() and also fix the cursor plane. (Jammy Huang)

Quoted 6 lines
Quoted 4 lines

Tested on a sr645 affected by this bug.

Fixes f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
Quoted 29 lines
Quoted 28 lines

---
  drivers/gpu/drm/ast/ast_mode.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +1 -1
index c7443317c747..66a4a41c3fe9 100644
@@ -714,7 +714,7 @@ static int ast_primary_plane_init(struct 
 ast_private *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 = ast->vram_base;
+    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;
      int ret;

drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -972,7 +972,7 @@ static int ast_cursor_plane_init(struct 
 ast_private *ast)
           return -ENOMEM;
         vaddr = ast->vram + ast->vram_fb_available - size;
-    offset = ast->vram_base + ast->vram_fb_available - size;
+    offset = ast->vram_fb_available - size;
         ret = ast_plane_init(dev, ast_cursor_plane, vaddr, offset, size,
                    0x01, &ast_cursor_plane_funcs,
Signature · 2 lines
Best Regards
Jammy
author reviewer
#3 lore raw
Quoted 20 lines · Jammy Huang
Quoted 18 lines · Thomas Zimmermann

Am 09.02.23 um 10:44 schrieb Jocelyn Falempe:

Quoted 5 lines

During the driver conversion to shmem, the start address for the scanout buffer was set to the base PCI address.
In most cases it works because only the lower 24bits are used, and due to alignment it was almost always 0.
But on some unlucky hardware, it's not the case, and some unitilized

'uninitialized'

Quoted 7 lines

memory is displayed on the BMC.
With shmem, the primary plane is always at offset 0 in GPU memory.

  * v2: rewrite the patch to set the offset to 0. (Thomas Zimmermann)
  * v3: move the change to plane_init() and also fix the cursor plane. (Jammy Huang)

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Tested on a sr645 affected by this bug.

Fixes f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")

I just pushed it to drm-misc-fixes.

Thanks a lot,

Signature · 1 line
Jocelyn