OSDN Git Service

amdgpu: Set USWC for SCANOUT images.
authorBas Nieuwenhuizen <basni@chromium.org>
Mon, 6 Apr 2020 16:50:24 +0000 (18:50 +0200)
committerCommit Bot <commit-bot@chromium.org>
Sat, 25 Apr 2020 15:14:34 +0000 (15:14 +0000)
This is necessary for scanout from GTT. Without it, the kernel will
migrate it to the carveout. For large resolutions this would not be
feasible due to small carveout sizes and hence it is important that
we alloc scanout from GTT.

The original patch was on top of
4eebcea "amdgpu: make AMDGPU_GEM_CREATE_CPU_GTT_USWC flag default"
which set USWC unconditionally, but has since been reverted. The
main failure reason is being addressed in mesa-amd. This patch also
still disables USWC if we can and the image will be read often on
the CPU, to avoid staging textures during memory mapping.

BUG=b:153247881
TEST=Run CtsCameraTestCases on Grunt.
     4k YouTube video p/b

Change-Id: If6393e60cea5d2a98a052d7c46604e0012de0618
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2134451
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>

amdgpu.c

index 795d137..d70bb8f 100644 (file)
--- a/amdgpu.c
+++ b/amdgpu.c
@@ -159,7 +159,11 @@ static int amdgpu_create_bo_linear(struct bo *bo, uint32_t width, uint32_t heigh
                gem_create.in.domain_flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
 
        gem_create.in.domains = AMDGPU_GEM_DOMAIN_GTT;
-       if (!(use_flags & (BO_USE_SW_READ_OFTEN | BO_USE_SCANOUT)))
+
+       /* Scanout in GTT requires USWC, otherwise try to use cachable memory
+        * for buffers that are read often, because uncacheable reads can be
+        * very slow. USWC should be faster on the GPU though. */
+       if ((use_flags & BO_USE_SCANOUT) || !(use_flags & BO_USE_SW_READ_OFTEN))
                gem_create.in.domain_flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
 
        /* Allocate the buffer with the preferred heap. */