From d0d17864968226d5d747dc28d775bceabef7db44 Mon Sep 17 00:00:00 2001 From: "Li, Gaoshun" Date: Wed, 6 Dec 2023 16:38:38 +0000 Subject: [PATCH] Fixed a performance issue The use case of BO_USE_SW_READ_OFTEN should not use WC, due to frequent CPU data reads. Tracked-On: OAM-113408 --- i915.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/i915.c b/i915.c index 9c68d5c0..66429630 100644 --- a/i915.c +++ b/i915.c @@ -932,13 +932,14 @@ static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t if (i915->has_local_mem) { mmap_arg.flags = I915_MMAP_OFFSET_FIXED; } else { - if ((bo->meta.use_flags & BO_USE_SCANOUT) && - !(bo->meta.use_flags & - (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))) { - mmap_arg.flags = I915_MMAP_OFFSET_WC; - } else { - mmap_arg.flags = I915_MMAP_OFFSET_WB; - } + /* The use case of BO_USE_SW_READ_OFTEN should not use WC, due to frequent CPU data reads. */ + if ((bo->meta.use_flags & BO_USE_SCANOUT) && + !(bo->meta.use_flags & + (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SW_READ_OFTEN))) { + mmap_arg.flags = I915_MMAP_OFFSET_WC; + } else { + mmap_arg.flags = I915_MMAP_OFFSET_WB; + } } /* Get the fake offset back */ @@ -946,7 +947,7 @@ static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t if (ret != 0 && mmap_arg.flags == I915_MMAP_OFFSET_FIXED) { if ((bo->meta.use_flags & BO_USE_SCANOUT) && !(bo->meta.use_flags & - (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))) { + (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SW_READ_OFTEN))) { mmap_arg.flags = I915_MMAP_OFFSET_WC; } else { mmap_arg.flags = I915_MMAP_OFFSET_WB; @@ -981,8 +982,10 @@ static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t * performance-sensitive. */ if ((bo->meta.use_flags & BO_USE_SCANOUT) && !(bo->meta.use_flags & - (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))) - gem_map.flags = I915_MMAP_WC; + (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SW_READ_OFTEN))) + gem_map.flags = I915_MMAP_WC; + + gem_map.handle = bo->handles[0].u32; gem_map.offset = 0; @@ -1008,8 +1011,9 @@ static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t if ((bo->meta.use_flags & BO_USE_SCANOUT) && !(bo->meta.use_flags & - (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))) - gem_map.flags = I915_MMAP_WC; + (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SW_READ_OFTEN))) + gem_map.flags = I915_MMAP_WC; + gem_map.handle = bo->handles[0].u32; gem_map.offset = 0; gem_map.size = bo->meta.total_size;