[igt-dev] [PATCH i-g-t 1/2] lib/intel_bufops: Add intel_buf_init_in_region
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Mon Sep 13 17:39:26 UTC 2021
On Wed, Sep 01, 2021 at 09:18:45PM +0530, apoorva1.singh at intel.com wrote:
> From: Apoorva Singh <apoorva1.singh at intel.com>
>
> Add intel_buf_init_in_region which allows memory region
> to be specified for new BO being created.
> Same as intel_buf_init with the additional region argument.
>
> Signed-off-by: Apoorva Singh <apoorva1.singh at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
> Cc: Melkaveri, Arjun <arjun.melkaveri at intel.com>
> ---
> lib/intel_bufops.c | 28 +++++++++++++++++++++++-----
> lib/intel_bufops.h | 5 +++++
> 2 files changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
> index faca4406..f5f67edd 100644
> --- a/lib/intel_bufops.c
> +++ b/lib/intel_bufops.c
> @@ -730,7 +730,8 @@ static void __intel_buf_init(struct buf_ops *bops,
> struct intel_buf *buf,
> int width, int height, int bpp, int alignment,
> uint32_t req_tiling, uint32_t compression,
> - uint64_t bo_size, int bo_stride)
> + uint64_t bo_size, int bo_stride,
> + uint32_t region)
> {
> uint32_t tiling = req_tiling;
> uint64_t size;
> @@ -818,7 +819,7 @@ static void __intel_buf_init(struct buf_ops *bops,
> if (handle)
> buf->handle = handle;
> else
> - buf->handle = gem_create(bops->fd, size);
> + buf->handle = gem_create_in_memory_regions(bops->fd, size, region);
>
> set_hw_tiled(bops, buf);
> }
> @@ -845,7 +846,24 @@ void intel_buf_init(struct buf_ops *bops,
> uint32_t tiling, uint32_t compression)
> {
> __intel_buf_init(bops, 0, buf, width, height, bpp, alignment,
> - tiling, compression, 0, 0);
> + tiling, compression, 0, 0, I915_SYSTEM_MEMORY);
> +
> + intel_buf_set_ownership(buf, true);
> +}
> +
> +/**
> + * intel_buf_init_in_region
> + *
> + * Same as intel_buf_init with the additional region argument
> + */
> +void intel_buf_init_in_region(struct buf_ops *bops,
> + struct intel_buf *buf,
> + int width, int height, int bpp, int alignment,
> + uint32_t tiling, uint32_t compression,
> + uint32_t region)
> +{
> + __intel_buf_init(bops, 0, buf, width, height, bpp, alignment,
> + tiling, compression, 0, 0, region);
>
> intel_buf_set_ownership(buf, true);
> }
> @@ -904,7 +922,7 @@ void intel_buf_init_using_handle(struct buf_ops *bops,
> uint32_t req_tiling, uint32_t compression)
> {
> __intel_buf_init(bops, handle, buf, width, height, bpp, alignment,
> - req_tiling, compression, 0, 0);
> + req_tiling, compression, 0, 0, -1);
> }
>
> /**
> @@ -990,7 +1008,7 @@ struct intel_buf *intel_buf_create_using_handle_and_size(struct buf_ops *bops,
> igt_assert(buf);
>
> __intel_buf_init(bops, handle, buf, width, height, bpp, alignment,
> - req_tiling, compression, size, stride);
> + req_tiling, compression, size, stride, -1);
>
> return buf;
> }
> diff --git a/lib/intel_bufops.h b/lib/intel_bufops.h
> index 9e57d53e..54f2ce45 100644
> --- a/lib/intel_bufops.h
> +++ b/lib/intel_bufops.h
> @@ -125,6 +125,11 @@ static inline void intel_buf_set_ownership(struct intel_buf *buf, bool is_owner)
> void intel_buf_init(struct buf_ops *bops, struct intel_buf *buf,
> int width, int height, int bpp, int alignment,
> uint32_t tiling, uint32_t compression);
> +void intel_buf_init_in_region(struct buf_ops *bops,
> + struct intel_buf *buf,
> + int width, int height, int bpp, int alignment,
> + uint32_t tiling, uint32_t compression,
> + uint32_t region);
> void intel_buf_close(struct buf_ops *bops, struct intel_buf *buf);
>
> void intel_buf_init_using_handle(struct buf_ops *bops,
> --
> 2.25.1
>
Looks ok,
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew
More information about the igt-dev
mailing list