Skip to contentSkip to conversation

drm/ast: Fix start address computation

PATCH Superseded Jocelyn Falempe 2 participants 4 messages Feb 7, 2023 – Feb 9, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jocelyn Falempe

author reviewer
#0 lore raw

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

During the driver conversion to shmem, there is a missing page shift when computing the start address in GPU memory.
This leads to graphic garbage when connecting to the remote BMC, depending on the PCI start address.

Tested on a sr645 affected by this bug.

Fixes f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
---
 drivers/gpu/drm/ast/ast_mode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_mode.c +1 -1
index c7443317c747..d75e4a7611b3 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 = ast->vram_base << PAGE_SHIFT;
 	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;
Signature · 1 line
2.39.1
#1 lore raw

Hi

Am 07.02.23 um 11:53 schrieb Jocelyn Falempe:

Quoted 18 lines

During the driver conversion to shmem, there is a missing page shift when computing the start address in GPU memory.
This leads to graphic garbage when connecting to the remote BMC, depending on the PCI start address.

Tested on a sr645 affected by this bug.

Fixes f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
---
  drivers/gpu/drm/ast/ast_mode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index c7443317c747..d75e4a7611b3 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_primary_plane_init(struct ast_private *ast) · line 717

Quoted 5 lines
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -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 = ast->vram_base << PAGE_SHIFT;

That can't be the problem, I think. vram_base is already an address. [1] In the old code, drm_gem_vram_pg_offset() returned a page index. So shifting it to the left here is most likely incorrect.

Can you verify that the new offset is the same as the old one?

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.2-rc7/source/drivers/gpu/drm/ast/ast_mm.c#L96

Quoted 3 lines
drivers/gpu/drm/ast/ast_mode.c +0 -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;
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
author reviewer
#2 lore raw
Quoted 30 lines · Thomas Zimmermann

Hi

Am 07.02.23 um 11:53 schrieb Jocelyn Falempe:

Quoted 18 lines

During the driver conversion to shmem, there is a missing page shift when computing the start address in GPU memory.
This leads to graphic garbage when connecting to the remote BMC, depending on the PCI start address.

Tested on a sr645 affected by this bug.

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

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

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index c7443317c747..d75e4a7611b3 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_primary_plane_init(struct · line 718

Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -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 = ast->vram_base << PAGE_SHIFT;

That can't be the problem, I think. vram_base is already an address. [1] In the old code, drm_gem_vram_pg_offset() returned a page index. So shifting it to the left here is most likely incorrect.

Quoted 1 line

Can you verify that the new offset is the same as the old one?

Yes, I was also a bit unsure about this fix.

In my case, with the old code:

PCI base address is 0xce000000

with old code:
start address (which is 24bits) was 0

with shmem code:
start address is 0x800000

So the additional page shift makes it 0, which fixes the display.

I was wondering if this start address is not an offset in the GPU memory, and in this case the primary plane offset should always be 0 ?

Best regards,

Quoted 10 lines

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.2-rc7/source/drivers/gpu/drm/ast/ast_mm.c#L96

Quoted 3 lines
drivers/gpu/drm/ast/ast_mode.c +0 -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;

author reviewer
#3 lore raw
Quoted 5 lines · Jocelyn Falempe
Quoted 2 lines · Thomas Zimmermann

Hi

I was wondering if this start address is not an offset in the GPU memory, and in this case the primary plane offset should always be 0 ?

I think it's the case, so I will send a v2 shortly.

Quoted 14 lines

Best regards,

Quoted 10 lines

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.2-rc7/source/drivers/gpu/drm/ast/ast_mm.c#L96

Quoted 3 lines

      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;