Skip to contentSkip to conversation

drm/amdgpu: Allow direct CPU drawing of DRM panic on APUs

PATCH In review Tvrtko Ursulin 2 participants 4 messages Nov 28, 2025 – Dec 1, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Allow direct CPU drawing of DRM panic on APUs

There is no need to draw the panic screen via the slow MMIO access on APUs, since the frame buffer is guaranteed to be CPU accessible.

Lets skip setting the .set_pixel method which allows the DRM panic core to just work and it renders much more quickly.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Rodrigo Siqueira <[email protected]>

---
FWIW this draws the panic faster, but.. the whole DRM panic setup only appears to work with non-tiled modes. There is something broken in the dcn10_reset_surface_dcc_and_tiling() code with "more advanced" modes where thing the turning off compression seems to trigger some weird display engine behaviour. (On the Steam Deck at least.)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index b5d34797d606..7f75f1319d3f 100644
@@ -1900,7 +1900,8 @@ int amdgpu_display_get_scanout_buffer(struct drm_plane *plane,
 
 	sb->pitch[0] = fb->pitches[0];
 
-	if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
+	if (!(amdgpu_ttm_adev(abo->tbo.bdev)->flags & AMD_IS_APU) &&
+	    (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
 		if (abo->tbo.resource->mem_type != TTM_PL_VRAM) {
 			drm_warn(plane->dev, "amdgpu panic, framebuffer not in VRAM\n");
 			return -EINVAL;
Signature · 1 line
2.51.1
maintainer
#1 lore raw
Quoted 2 lines · Tvrtko Ursulin

There is no need to draw the panic screen via the slow MMIO access on APUs, since the frame buffer is guaranteed to be CPU accessible.

Well that is actually not correct. It is only guaranteed to be CPU accessible on 64bit kernels!

I suggest to use the appropriate test function to see if a BO is fully CPU accessible or not and just drop the check for the AMDGPU_GEM_CREATE_NO_CPU_ACCESS flag.

BTW: It is perfectly normal for the framebuffer to not be in VRAM on APUs! So the check below is broken as well.

Regards,
Christian.

Quoted 33 lines

Lets skip setting the .set_pixel method which allows the DRM panic core to just work and it renders much more quickly.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Rodrigo Siqueira <[email protected]>

---
FWIW this draws the panic faster, but.. the whole DRM panic setup only appears to work with non-tiled modes. There is something broken in the dcn10_reset_surface_dcc_and_tiling() code with "more advanced" modes where thing the turning off compression seems to trigger some weird display engine behaviour. (On the Steam Deck at least.)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index b5d34797d606..7f75f1319d3f 100644
@@ -1900,7 +1900,8 @@ int amdgpu_display_get_scanout_buffer(struct drm_plane *plane,
 
 	sb->pitch[0] = fb->pitches[0];
 
-	if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
+	if (!(amdgpu_ttm_adev(abo->tbo.bdev)->flags & AMD_IS_APU) &&
+	    (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
 		if (abo->tbo.resource->mem_type != TTM_PL_VRAM) {
 			drm_warn(plane->dev, "amdgpu panic, framebuffer not in VRAM\n");
 			return -EINVAL;
#2 lore raw
Quoted 9 lines · Christian König
Quoted 2 lines · Tvrtko Ursulin

There is no need to draw the panic screen via the slow MMIO access on APUs, since the frame buffer is guaranteed to be CPU accessible.

Well that is actually not correct. It is only guaranteed to be CPU accessible on 64bit kernels!

I suggest to use the appropriate test function to see if a BO is fully CPU accessible or not and just drop the check for the AMDGPU_GEM_CREATE_NO_CPU_ACCESS flag.

BTW: It is perfectly normal for the framebuffer to not be in VRAM on APUs! So the check below is broken as well.

Hmm I also misread the tail end of this function. It wouldn't even work if frame buffer was non-contiguous since it uses ttm_bo_kmap.

Never mind then, archive to /dev/null please.

Regards,

Tvrtko

Quoted 34 lines
Quoted 33 lines

Lets skip setting the .set_pixel method which allows the DRM panic core to just work and it renders much more quickly.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Rodrigo Siqueira <[email protected]>

---
FWIW this draws the panic faster, but.. the whole DRM panic setup only appears to work with non-tiled modes. There is something broken in the dcn10_reset_surface_dcc_and_tiling() code with "more advanced" modes where thing the turning off compression seems to trigger some weird display engine behaviour. (On the Steam Deck at least.)

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index b5d34797d606..7f75f1319d3f 100644
@@ -1900,7 +1900,8 @@ int amdgpu_display_get_scanout_buffer(struct drm_plane *plane,
 
  	sb->pitch[0] = fb->pitches[0];
 
-	if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
+	if (!(amdgpu_ttm_adev(abo->tbo.bdev)->flags & AMD_IS_APU) &&
+	    (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
  		if (abo->tbo.resource->mem_type != TTM_PL_VRAM) {
  			drm_warn(plane->dev, "amdgpu panic, framebuffer not in VRAM\n");
  			return -EINVAL;
maintainer
#3 lore raw
Quoted 6 lines · Tvrtko Ursulin
Quoted 4 lines · Christian König
Quoted 2 lines · Tvrtko Ursulin

There is no need to draw the panic screen via the slow MMIO access on APUs, since the frame buffer is guaranteed to be CPU accessible.

Quoted 7 lines
Quoted 5 lines

Well that is actually not correct. It is only guaranteed to be CPU accessible on 64bit kernels!

I suggest to use the appropriate test function to see if a BO is fully CPU accessible or not and just drop the check for the AMDGPU_GEM_CREATE_NO_CPU_ACCESS flag.

BTW: It is perfectly normal for the framebuffer to not be in VRAM on APUs! So the check below is broken as well.

Hmm I also misread the tail end of this function. It wouldn't even work if frame buffer was non-contiguous since it uses ttm_bo_kmap.

Oh, yeah that won't work for scanout from GTT.

But we never implemented non-contigius scanout from VRAM (it is still on the TODO list). So in theory you could use direct access for that case.

Regards,
Christian.

Quoted 39 lines

Never mind then, archive to /dev/null please.

Regards,

Tvrtko

Quoted 32 lines
Quoted 31 lines

Lets skip setting the .set_pixel method which allows the DRM panic core to just work and it renders much more quickly.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Rodrigo Siqueira <[email protected]>

---
FWIW this draws the panic faster, but.. the whole DRM panic setup only appears to work with non-tiled modes. There is something broken in the dcn10_reset_surface_dcc_and_tiling() code with "more advanced" modes where thing the turning off compression seems to trigger some weird display engine behaviour. (On the Steam Deck at least.)
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -0
index b5d34797d606..7f75f1319d3f 100644
@@ -1900,7 +1900,8 @@ int amdgpu_display_get_scanout_buffer(struct drm_plane *plane,
         sb->pitch[0] = fb->pitches[0];
   -    if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
+    if (!(amdgpu_ttm_adev(abo->tbo.bdev)->flags & AMD_IS_APU) &&
+        (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
           if (abo->tbo.resource->mem_type != TTM_PL_VRAM) {
               drm_warn(plane->dev, "amdgpu panic, framebuffer not in VRAM\n");
               return -EINVAL;