OSDN Git Service

amdgpu: fix misplaced code block
authorGurchetan Singh <gurchetansingh@chromium.org>
Fri, 26 Oct 2018 00:12:18 +0000 (17:12 -0700)
committerMauro Rossi <issor.oruam@gmail.com>
Sun, 26 Jan 2020 21:43:48 +0000 (22:43 +0100)
We only need this workaround for DRI Android buffers, not
all buffers.

Also, we don't need this for buffers with non-SW uses.

BUG=b:117942643
TEST=compile

Change-Id: I7ea24b0dc3b040b726f6c1223c96998f078a20fc
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1300595
Reviewed-by: Robert Tarasov <tutankhamen@chromium.org>
amdgpu.c

index cb8c323..d994c5d 100644 (file)
--- a/amdgpu.c
+++ b/amdgpu.c
@@ -140,15 +140,22 @@ static int amdgpu_create_bo(struct bo *bo, uint32_t width, uint32_t height, uint
        if (!combo)
                return -EINVAL;
 
-       /* Currently Gralloc does not handle a different map_stride. So to work around,
-        * aligning the stride to 256 to make bo_stride same as map_stride. b/115946221.
-        */
+       if (combo->metadata.tiling == TILE_TYPE_DRI) {
 #ifdef __ANDROID__
-       uint32_t bytes_per_pixel = drv_bytes_per_pixel_from_format(format, 0);
-       width = ALIGN(width, 256 / bytes_per_pixel);
+               /*
+                * Currently, the gralloc API doesn't differentiate between allocation time and map
+                * time strides. A workaround for amdgpu DRI buffers is to always to align to 256 at
+                * allocation time.
+                *
+                * See b/115946221,b/117942643
+                */
+               if (use_flags & (BO_USE_SW_MASK)) {
+                       uint32_t bytes_per_pixel = drv_bytes_per_pixel_from_format(format, 0);
+                       width = ALIGN(width, 256 / bytes_per_pixel);
+               }
 #endif
-       if (combo->metadata.tiling == TILE_TYPE_DRI)
                return dri_bo_create(bo, width, height, format, use_flags);
+       }
 
        stride = drv_stride_from_format(format, width, 0);
        stride = ALIGN(stride,256);