Re: [PATCH] drm/amdgpu: add dce6 drm_panic support

2024-08-04 Thread yaolu



在 2024/8/2 17:39, Christian König 写道:

Am 02.08.24 um 09:17 schrieb Lu Yao:

Add support for the drm_panic module, which displays a pretty user
friendly message on the screen when a Linux kernel panic occurs.

Signed-off-by: Lu Yao 
---
The patch can work properly on the TTY, but after start X, drawn
image is messy, it looks like the data isn't linearly arranged.
However at this time 'fb->modifier' is 'DRM_FORMAT_MOD_LINEAR'.

Another difference I found is:
   For TTY, the amdgpu_bo is created with flag
'AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED|AMDGPU_GEM_CREATE_CPU_GTT_USWC|
AMDGPU_GEM_CREATE_VRAM_CLEARED|AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS'.
   For X, the amdgpu_bo is created with flag
'AMDGPU_GEM_CREATE_NO_CPU_ACCESS|AMDGPU_GEM_CREATE_CPU_GTT_USWC'
I try to use same flag for X, it looks like no difference.

Can someone provide some insight into this problem or where I am going
wrong. Thanks a lot.

Test environment: X86 arch + v6.6 kernel + R7340.
---
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 32 +++
  1 file changed, 32 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c

index 05c0df97f01d..12c3801c264a 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -28,6 +28,8 @@
  #include 
  #include 
  #include 
+#include 



+#include "../../drm_internal.h"


Well that this file is named "internal" and not in a common include 
directory is a strong indicator that you should absolutely *not* 
include it in a driver.



Okay, I'll fix it.

    #include "amdgpu.h"
  #include "amdgpu_pm.h"
@@ -2600,6 +2602,35 @@ static const struct drm_crtc_helper_funcs 
dce_v6_0_crtc_helper_funcs = {

  .get_scanout_position = amdgpu_crtc_get_scanout_position,
  };
  +static int dce_v6_0_drm_primary_plane_get_scanout_buffer(struct 
drm_plane *plane,

+ struct drm_scanout_buffer *sb)
+{
+    struct drm_framebuffer *fb;
+    struct drm_gem_object *obj;
+    struct amdgpu_bo *abo;
+    int ret = 0;
+
+    if (!plane->fb || plane->fb->modifier != DRM_FORMAT_MOD_LINEAR)
+    return -ENODEV;
+
+    fb = plane->fb;
+    sb->width = fb->width;
+    sb->height = fb->height;
+    sb->format = fb->format;
+    sb->pitch[0] = fb->pitches[0];
+
+    obj = fb->obj[0];
+    abo = gem_to_amdgpu_bo(obj);
+    if (!abo || abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
+    return -EINVAL;
+
+    return drm_gem_vmap(obj, &sb->map[0]);


Yeah that will almost always not work. Most display buffers are tilled 
and not CPU accessible.


Regards,
Christian.

I did some more tests. After removing the 
'AMDGPU_GEM_CREATE_NO_CPU_ACCESS' judgment here, then starting X, it 
worked well at '1280x960' resolution, but others (e.g. 1920x1080, 
640x480) not.
So, for this problem, it doesn't seem to matter 'Tiled memory' or 'CPU 
can't access'. Or is it just a coincidence ?


Thanks,
Lu Yao

+}
+
+static const struct drm_plane_helper_funcs 
dce_v6_0_drm_primary_plane_helper_funcs = {

+    .get_scanout_buffer = dce_v6_0_drm_primary_plane_get_scanout_buffer
+};
+
  static int dce_v6_0_crtc_init(struct amdgpu_device *adev, int index)
  {
  struct amdgpu_crtc *amdgpu_crtc;
@@ -2627,6 +2658,7 @@ static int dce_v6_0_crtc_init(struct 
amdgpu_device *adev, int index)

  amdgpu_crtc->encoder = NULL;
  amdgpu_crtc->connector = NULL;
  drm_crtc_helper_add(&amdgpu_crtc->base, 
&dce_v6_0_crtc_helper_funcs);
+    drm_plane_helper_add(amdgpu_crtc->base.primary, 
&dce_v6_0_drm_primary_plane_helper_funcs);

    return 0;
  }




Re: [PATCH] drm/imagination: Kconfig: add 'PAGE_SIZE=4K' dependency

2024-02-28 Thread yaolu


在 2024/2/28 18:47, Matt Coster 写道:

Hi, thanks for the patch!

On 28/02/2024 01:23, Lu Yao wrote:

When 'PAGE_SIZE=64K',the following compilation error occurs:
"
   ../drivers/gpu/drm/imagination/pvr_fw_mips.c: In function
‘pvr_mips_fw_process’:
   ../drivers/gpu/drm/imagination/pvr_fw_mips.c:140:60: error: array
subscript 0 is outside the bounds of an interior zero-length array
‘dma_addr_t[0]’ {aka ‘long long unsigned int[]’}
[-Werror=zero-length-bounds]
   140 |   boot_data->pt_phys_addr[page_nr] =
mips_data->pt_dma_addr[src_page_nr] +
~~^
   In file included from ../drivers/gpu/drm/imagination/pvr_fw_mips.c:6:
   ../drivers/gpu/drm/imagination/pvr_fw_mips.h:30:13: note: while
referencing ‘pt_dma_addr’
30 |  dma_addr_t pt_dma_addr[PVR_MIPS_PT_PAGE_COUNT];
"

This is because 'PVR_MIPS_PT_PAGE_COUNT' is defined as
'(ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES * ROGUE_MIPSFW_PAGE_SIZE_4K) \

PAGE_SHIFT', and under the above conditions, 'PAGE_SHIFT' is '16',

'ROGUE_MIPSFW_MAX_NUM_PAGETABLE_PAGES' is '4','ROGUE_MIPSFW_PAGE_SIZE_4K'
is '4096',so 'PVR_MIPS_PT_PAGE_COUNT' is '0' causing the member
'pt_dma_addr' to be incorrectly defined.

The whole MIPS page table system is supposed to be host page-size
agnostic. In practice, we don’t regularly test on non-4K platforms so
this may well be broken in subtle or not-so-subtle (as in this instance)
ways. There has been at least some testing with 64K host pages – the
configs from TI for the AM62-SK dev boards have that as the default (or
at least they did when we started working with them).

I’m loathed to accept this patch without at least investigating how deep
the problems go; the true fix here should be to fix the problems causing
this build error rather than just gating off non-4K hosts.

I’ll have a dig this afternoon to see what I can find. Did you try
anything to fix this yourself? It would be nice to not duplicate effort
on this if you have.


No, I haven't tried, and I'm currently disabling the DRM_POWERVR driver. 
Actually,
I don't have any IMG graphics cards. This error was found when  compiling the 
kernel
randomly.Looks like it's up to you to sort this out reasonably.;)

Regards,
Lu


Cheers,
Matt


Signed-off-by: Lu Yao
---
  drivers/gpu/drm/imagination/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imagination/Kconfig 
b/drivers/gpu/drm/imagination/Kconfig
index 3bfa2ac212dc..e585922f634d 100644
--- a/drivers/gpu/drm/imagination/Kconfig
+++ b/drivers/gpu/drm/imagination/Kconfig
@@ -3,7 +3,7 @@
  
  config DRM_POWERVR

tristate "Imagination Technologies PowerVR (Series 6 and later) & IMG 
Graphics"
-   depends on ARM64
+   depends on (ARM64 && ARM64_PAGE_SHIFT=12)
depends on DRM
depends on PM
select DRM_EXEC