Skip to content

Commit

Permalink
Fixed a performance issue
Browse files Browse the repository at this point in the history
The use case of BO_USE_SW_READ_OFTEN should not use WC, due to frequent CPU data reads.

Tracked-On: OAM-113408
  • Loading branch information
gaoshunli committed Dec 6, 2023
1 parent 0e39b95 commit d0d1786
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,21 +932,22 @@ 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 */
int ret = gen_ioctl(bo->drv->fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &mmap_arg);
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit d0d1786

Please sign in to comment.