* [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin @ 2020-06-04 9:16 Zbigniew Kempczyński 2020-06-04 9:16 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_bufops: add fields for keeping offset and context Zbigniew Kempczyński 2020-06-04 9:16 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński 0 siblings, 2 replies; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 9:16 UTC (permalink / raw) To: igt-dev All localized functions gathered in media_spin were removed. v2: add implicit sync (set_domain) Zbigniew Kempczyński (4): lib/intel_bufops: add fields for keeping offset and context lib/intel_batchbuffer: add bb reset tests/i915_pm_sseu: remove libdrm dependency HAX: run gpgpu|media_fill and i915_pm_sseu in BAT only lib/gpu_cmds.c | 6 +- lib/intel_batchbuffer.c | 84 ++++- lib/intel_batchbuffer.h | 12 +- lib/intel_bufops.h | 4 + lib/media_spin.c | 469 ++++---------------------- lib/media_spin.h | 8 +- tests/i915/i915_pm_sseu.c | 73 ++-- tests/intel-ci/fast-feedback.testlist | 162 +-------- 8 files changed, 189 insertions(+), 629 deletions(-) -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_bufops: add fields for keeping offset and context 2020-06-04 9:16 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński @ 2020-06-04 9:16 ` Zbigniew Kempczyński 2020-06-04 9:16 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński 1 sibling, 0 replies; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 9:16 UTC (permalink / raw) To: igt-dev; +Cc: Chris Wilson To avoid relocations when intel_buf is used we need to keep previous offset and context. Add addr structure with offset and ctx fields. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> --- lib/gpu_cmds.c | 6 +++--- lib/intel_bufops.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/gpu_cmds.c b/lib/gpu_cmds.c index 8c284eb1..417253a7 100644 --- a/lib/gpu_cmds.c +++ b/lib/gpu_cmds.c @@ -109,7 +109,7 @@ gen7_fill_surface_state(struct intel_bb *ibb, address = intel_bb_offset_reloc(ibb, buf->handle, read_domain, write_domain, - offset + 4, 0x0); + offset + 4, buf->addr.offset); igt_assert(address >> 32 == 0); ss->ss1.base_addr = address; @@ -161,7 +161,7 @@ gen8_fill_surface_state(struct intel_bb *ibb, address = intel_bb_offset_reloc(ibb, buf->handle, read_domain, write_domain, - offset + 4 * 8, 0x0); + offset + 4 * 8, buf->addr.offset); ss->ss8.base_addr = (uint32_t) address; ss->ss9.base_addr_hi = address >> 32; @@ -218,7 +218,7 @@ gen11_fill_surface_state(struct intel_bb *ibb, address = intel_bb_offset_reloc(ibb, buf->handle, read_domain, write_domain, - offset + 4 * 8, 0x0); + offset + 4 * 8, buf->addr.offset); ss->ss8.base_addr = (uint32_t) address; ss->ss9.base_addr_hi = address >> 32; diff --git a/lib/intel_bufops.h b/lib/intel_bufops.h index 3a4fae4e..95217cfe 100644 --- a/lib/intel_bufops.h +++ b/lib/intel_bufops.h @@ -18,6 +18,10 @@ struct intel_buf { uint32_t offset; uint32_t stride; } aux; + struct { + uint64_t offset; + uint32_t ctx; + } addr; }; static inline unsigned int intel_buf_width(const struct intel_buf *buf) -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset 2020-06-04 9:16 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński 2020-06-04 9:16 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_bufops: add fields for keeping offset and context Zbigniew Kempczyński @ 2020-06-04 9:16 ` Zbigniew Kempczyński 1 sibling, 0 replies; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 9:16 UTC (permalink / raw) To: igt-dev; +Cc: Chris Wilson For some scenarios we want to keep previous objects and their offsets and recreate only batchbuffer object. To allow user do that add bb reset function which can or not purge collected objects from previous run. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> --- lib/intel_batchbuffer.c | 84 +++++++++++++++++++++++++++++++++++------ lib/intel_batchbuffer.h | 12 ++++-- 2 files changed, 81 insertions(+), 15 deletions(-) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 49f2d0fe..2a882627 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -1203,7 +1203,7 @@ static void __reallocate_objects(struct intel_bb *ibb) } /** - * __intel_bb_create: + * intel_bb_create: * @i915: drm fd * @size: size of the batchbuffer * @@ -1250,6 +1250,26 @@ static void __do_nothing(void *node) (void) node; } +static void __intel_bb_destroy_objects(struct intel_bb *ibb) +{ + uint32_t i; + + /* Free relocations */ + for (i = 0; i < ibb->num_objects; i++) + free(from_user_pointer(ibb->objects[i].relocs_ptr)); + + free(ibb->objects); + tdestroy(ibb->root, __do_nothing); + + ibb->objects = NULL; + ibb->root = NULL; + ibb->num_objects = 0; + ibb->num_relocs = 0; + ibb->allocated_objects = 0; + ibb->allocated_relocs = 0; + ibb->ptr = ibb->batch; +} + /** * intel_bb_destroy: * @ibb: pointer to intel_bb @@ -1258,21 +1278,33 @@ static void __do_nothing(void *node) */ void intel_bb_destroy(struct intel_bb *ibb) { - uint32_t i; - igt_assert(ibb); - /* Free relocations */ - for (i = 0; i < ibb->num_objects; i++) - free(from_user_pointer(ibb->objects[i].relocs_ptr)); + __intel_bb_destroy_objects(ibb); + gem_close(ibb->i915, ibb->handle); - free(ibb->objects); - tdestroy(ibb->root, __do_nothing); + free(ibb); +} + +/* + * intel_bb_reset: + * @ibb: pointer to intel_bb + * @purge_objects_cache: if true destroy internal execobj and relocs + cache + * + * Recreate batch bo. +*/ +void intel_bb_reset(struct intel_bb *ibb, bool purge_objects_cache) +{ + if (purge_objects_cache) { + __intel_bb_destroy_objects(ibb); + __reallocate_objects(ibb); + } - munmap(ibb->batch, ibb->size); gem_close(ibb->i915, ibb->handle); + ibb->handle = gem_create(ibb->i915, ibb->size); - free(ibb); + intel_bb_add_object(ibb, ibb->handle, 0, false); + ibb->ptr = ibb->batch; } /** @@ -1573,7 +1605,7 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset, execbuf.buffers_ptr = (uintptr_t) ibb->objects; execbuf.buffer_count = ibb->num_objects; execbuf.batch_len = end_offset; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ibb->ctx = ctx; execbuf.flags = flags | I915_EXEC_BATCH_FIRST; ret = __gem_execbuf(ibb->i915, &execbuf); @@ -1649,3 +1681,33 @@ uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle) return (*found)->offset; } + +/** + * intel_bb_object_offset_to_buf: + * @ibb: pointer to intel_bb + * @buf: buffer we want to store last exec offset and context id + * + * Copy object offset used in the batch to intel_buf to allow caller prepare + * other batch likely without relocations. + */ +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf) +{ + struct drm_i915_gem_exec_object2 object = { .handle = buf->handle }; + struct drm_i915_gem_exec_object2 **found; + + igt_assert(ibb); + igt_assert(buf); + + found = tfind((void *) &object, &ibb->root, __compare_objects); + if (!found) { + buf->addr.offset = 0; + buf->addr.ctx = 0; + + return false; + } + + buf->addr.offset = (*found)->offset; + buf->addr.ctx = ibb->ctx; + + return true; +} diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index ae052c17..0649fc22 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -405,8 +405,8 @@ igt_vme_func_t igt_get_media_vme_func(int devid); /** * igt_media_spinfunc_t: - * @batch: batchbuffer object - * @dst: destination i-g-t buffer object + * @i915: drm fd + * @buf: destination buffer object * @spins: number of loops to execute * * This is the type of the per-platform media spin functions. The @@ -420,8 +420,8 @@ igt_vme_func_t igt_get_media_vme_func(int devid); * destination buffer on completion. This utility provides a simple way * to keep the render engine busy for a set time for various tests. */ -typedef void (*igt_media_spinfunc_t)(struct intel_batchbuffer *batch, - const struct igt_buf *dst, uint32_t spins); +typedef void (*igt_media_spinfunc_t)(int i915, + struct intel_buf *buf, uint32_t spins); igt_media_spinfunc_t igt_get_media_spinfunc(int devid); @@ -443,6 +443,8 @@ struct intel_bb { uint64_t gtt_size; bool supports_48b_address; + uint32_t ctx; + void *root; struct drm_i915_gem_exec_object2 *objects; uint32_t num_objects; @@ -457,6 +459,7 @@ struct intel_bb { struct intel_bb *intel_bb_create(int i915, uint32_t size); void intel_bb_destroy(struct intel_bb *ibb); +void intel_bb_reset(struct intel_bb *ibb, bool purge_objects_cache); void intel_bb_set_debug(struct intel_bb *ibb, bool debug); static inline uint32_t intel_bb_offset(struct intel_bb *ibb) @@ -524,5 +527,6 @@ void intel_bb_exec_with_context(struct intel_bb *ibb, uint32_t end_offset, uint32_t ctx, uint64_t flags, bool sync); uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle); +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf); #endif -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin @ 2020-06-04 10:03 Zbigniew Kempczyński 2020-06-04 10:03 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński 0 siblings, 1 reply; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 10:03 UTC (permalink / raw) To: igt-dev All localized functions gathered in media_spin were removed. v2: add implicit sync (set_domain) Zbigniew Kempczyński (4): lib/intel_bufops: add fields for keeping offset and context lib/intel_batchbuffer: add bb reset tests/i915_pm_sseu: remove libdrm dependency HAX: run gpgpu|media_fill and i915_pm_sseu in BAT only lib/gpu_cmds.c | 6 +- lib/intel_batchbuffer.c | 84 ++++- lib/intel_batchbuffer.h | 12 +- lib/intel_bufops.h | 4 + lib/media_spin.c | 469 ++++---------------------- lib/media_spin.h | 8 +- tests/i915/i915_pm_sseu.c | 73 ++-- tests/intel-ci/fast-feedback.testlist | 162 +-------- 8 files changed, 189 insertions(+), 629 deletions(-) -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset 2020-06-04 10:03 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński @ 2020-06-04 10:03 ` Zbigniew Kempczyński 2020-06-04 15:07 ` Chris Wilson 0 siblings, 1 reply; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 10:03 UTC (permalink / raw) To: igt-dev; +Cc: Chris Wilson For some scenarios we want to keep previous objects and their offsets and recreate only batchbuffer object. To allow user do that add bb reset function which can or not purge collected objects from previous run. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> --- lib/intel_batchbuffer.c | 84 +++++++++++++++++++++++++++++++++++------ lib/intel_batchbuffer.h | 12 ++++-- 2 files changed, 81 insertions(+), 15 deletions(-) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 49f2d0fe..2a882627 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -1203,7 +1203,7 @@ static void __reallocate_objects(struct intel_bb *ibb) } /** - * __intel_bb_create: + * intel_bb_create: * @i915: drm fd * @size: size of the batchbuffer * @@ -1250,6 +1250,26 @@ static void __do_nothing(void *node) (void) node; } +static void __intel_bb_destroy_objects(struct intel_bb *ibb) +{ + uint32_t i; + + /* Free relocations */ + for (i = 0; i < ibb->num_objects; i++) + free(from_user_pointer(ibb->objects[i].relocs_ptr)); + + free(ibb->objects); + tdestroy(ibb->root, __do_nothing); + + ibb->objects = NULL; + ibb->root = NULL; + ibb->num_objects = 0; + ibb->num_relocs = 0; + ibb->allocated_objects = 0; + ibb->allocated_relocs = 0; + ibb->ptr = ibb->batch; +} + /** * intel_bb_destroy: * @ibb: pointer to intel_bb @@ -1258,21 +1278,33 @@ static void __do_nothing(void *node) */ void intel_bb_destroy(struct intel_bb *ibb) { - uint32_t i; - igt_assert(ibb); - /* Free relocations */ - for (i = 0; i < ibb->num_objects; i++) - free(from_user_pointer(ibb->objects[i].relocs_ptr)); + __intel_bb_destroy_objects(ibb); + gem_close(ibb->i915, ibb->handle); - free(ibb->objects); - tdestroy(ibb->root, __do_nothing); + free(ibb); +} + +/* + * intel_bb_reset: + * @ibb: pointer to intel_bb + * @purge_objects_cache: if true destroy internal execobj and relocs + cache + * + * Recreate batch bo. +*/ +void intel_bb_reset(struct intel_bb *ibb, bool purge_objects_cache) +{ + if (purge_objects_cache) { + __intel_bb_destroy_objects(ibb); + __reallocate_objects(ibb); + } - munmap(ibb->batch, ibb->size); gem_close(ibb->i915, ibb->handle); + ibb->handle = gem_create(ibb->i915, ibb->size); - free(ibb); + intel_bb_add_object(ibb, ibb->handle, 0, false); + ibb->ptr = ibb->batch; } /** @@ -1573,7 +1605,7 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset, execbuf.buffers_ptr = (uintptr_t) ibb->objects; execbuf.buffer_count = ibb->num_objects; execbuf.batch_len = end_offset; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ibb->ctx = ctx; execbuf.flags = flags | I915_EXEC_BATCH_FIRST; ret = __gem_execbuf(ibb->i915, &execbuf); @@ -1649,3 +1681,33 @@ uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle) return (*found)->offset; } + +/** + * intel_bb_object_offset_to_buf: + * @ibb: pointer to intel_bb + * @buf: buffer we want to store last exec offset and context id + * + * Copy object offset used in the batch to intel_buf to allow caller prepare + * other batch likely without relocations. + */ +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf) +{ + struct drm_i915_gem_exec_object2 object = { .handle = buf->handle }; + struct drm_i915_gem_exec_object2 **found; + + igt_assert(ibb); + igt_assert(buf); + + found = tfind((void *) &object, &ibb->root, __compare_objects); + if (!found) { + buf->addr.offset = 0; + buf->addr.ctx = 0; + + return false; + } + + buf->addr.offset = (*found)->offset; + buf->addr.ctx = ibb->ctx; + + return true; +} diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index ae052c17..0649fc22 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -405,8 +405,8 @@ igt_vme_func_t igt_get_media_vme_func(int devid); /** * igt_media_spinfunc_t: - * @batch: batchbuffer object - * @dst: destination i-g-t buffer object + * @i915: drm fd + * @buf: destination buffer object * @spins: number of loops to execute * * This is the type of the per-platform media spin functions. The @@ -420,8 +420,8 @@ igt_vme_func_t igt_get_media_vme_func(int devid); * destination buffer on completion. This utility provides a simple way * to keep the render engine busy for a set time for various tests. */ -typedef void (*igt_media_spinfunc_t)(struct intel_batchbuffer *batch, - const struct igt_buf *dst, uint32_t spins); +typedef void (*igt_media_spinfunc_t)(int i915, + struct intel_buf *buf, uint32_t spins); igt_media_spinfunc_t igt_get_media_spinfunc(int devid); @@ -443,6 +443,8 @@ struct intel_bb { uint64_t gtt_size; bool supports_48b_address; + uint32_t ctx; + void *root; struct drm_i915_gem_exec_object2 *objects; uint32_t num_objects; @@ -457,6 +459,7 @@ struct intel_bb { struct intel_bb *intel_bb_create(int i915, uint32_t size); void intel_bb_destroy(struct intel_bb *ibb); +void intel_bb_reset(struct intel_bb *ibb, bool purge_objects_cache); void intel_bb_set_debug(struct intel_bb *ibb, bool debug); static inline uint32_t intel_bb_offset(struct intel_bb *ibb) @@ -524,5 +527,6 @@ void intel_bb_exec_with_context(struct intel_bb *ibb, uint32_t end_offset, uint32_t ctx, uint64_t flags, bool sync); uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle); +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf); #endif -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset 2020-06-04 10:03 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński @ 2020-06-04 15:07 ` Chris Wilson 2020-06-05 5:40 ` Zbigniew Kempczyński 0 siblings, 1 reply; 8+ messages in thread From: Chris Wilson @ 2020-06-04 15:07 UTC (permalink / raw) To: zbigniew.kempczynski, igt-dev Quoting Zbigniew Kempczyński (2020-06-04 11:03:51) > +/** > + * intel_bb_object_offset_to_buf: > + * @ibb: pointer to intel_bb > + * @buf: buffer we want to store last exec offset and context id > + * > + * Copy object offset used in the batch to intel_buf to allow caller prepare > + * other batch likely without relocations. > + */ > +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf) > +{ > + struct drm_i915_gem_exec_object2 object = { .handle = buf->handle }; > + struct drm_i915_gem_exec_object2 **found; > + > + igt_assert(ibb); > + igt_assert(buf); > + > + found = tfind((void *) &object, &ibb->root, __compare_objects); > + if (!found) { > + buf->addr.offset = 0; > + buf->addr.ctx = 0; > + > + return false; > + } > + > + buf->addr.offset = (*found)->offset; > + buf->addr.ctx = ibb->ctx; Ok, so it's tracking ctx so that we can return the right offset when the buffer is used by multiple contexts. But ctx is never compared in the lookup? [There's also the problem of uint32_t ctx reuse, except there it can probably happily inherit the old addr.] -Chris _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset 2020-06-04 15:07 ` Chris Wilson @ 2020-06-05 5:40 ` Zbigniew Kempczyński 2020-06-05 14:17 ` Chris Wilson 0 siblings, 1 reply; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-05 5:40 UTC (permalink / raw) To: Chris Wilson; +Cc: igt-dev On Thu, Jun 04, 2020 at 04:07:49PM +0100, Chris Wilson wrote: > Quoting Zbigniew Kempczyński (2020-06-04 11:03:51) > > +/** > > + * intel_bb_object_offset_to_buf: > > + * @ibb: pointer to intel_bb > > + * @buf: buffer we want to store last exec offset and context id > > + * > > + * Copy object offset used in the batch to intel_buf to allow caller prepare > > + * other batch likely without relocations. > > + */ > > +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf) > > +{ > > + struct drm_i915_gem_exec_object2 object = { .handle = buf->handle }; > > + struct drm_i915_gem_exec_object2 **found; > > + > > + igt_assert(ibb); > > + igt_assert(buf); > > + > > + found = tfind((void *) &object, &ibb->root, __compare_objects); > > + if (!found) { > > + buf->addr.offset = 0; > > + buf->addr.ctx = 0; > > + > > + return false; > > + } > > + > > + buf->addr.offset = (*found)->offset; > > + buf->addr.ctx = ibb->ctx; > > Ok, so it's tracking ctx so that we can return the right offset when the > buffer is used by multiple contexts. But ctx is never compared in the > lookup? Do you think should I add such multictx tracking to the intel_bb? It will require additional collecting tree (current one is an index tree over objects allocated, so for caching ctx/address new one is necessary). I assumed intel_bb_objects_offset_to_buf() is enough to provide the user ability to collect the addresses on its own (if it really requires that). -- Zbigniew > > [There's also the problem of uint32_t ctx reuse, except there it can > probably happily inherit the old addr.] > -Chris _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset 2020-06-05 5:40 ` Zbigniew Kempczyński @ 2020-06-05 14:17 ` Chris Wilson 0 siblings, 0 replies; 8+ messages in thread From: Chris Wilson @ 2020-06-05 14:17 UTC (permalink / raw) To: zbigniew.kempczynski; +Cc: igt-dev Quoting Zbigniew Kempczyński (2020-06-05 06:40:50) > On Thu, Jun 04, 2020 at 04:07:49PM +0100, Chris Wilson wrote: > > Quoting Zbigniew Kempczyński (2020-06-04 11:03:51) > > > +/** > > > + * intel_bb_object_offset_to_buf: > > > + * @ibb: pointer to intel_bb > > > + * @buf: buffer we want to store last exec offset and context id > > > + * > > > + * Copy object offset used in the batch to intel_buf to allow caller prepare > > > + * other batch likely without relocations. > > > + */ > > > +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf) > > > +{ > > > + struct drm_i915_gem_exec_object2 object = { .handle = buf->handle }; > > > + struct drm_i915_gem_exec_object2 **found; > > > + > > > + igt_assert(ibb); > > > + igt_assert(buf); > > > + > > > + found = tfind((void *) &object, &ibb->root, __compare_objects); > > > + if (!found) { > > > + buf->addr.offset = 0; > > > + buf->addr.ctx = 0; > > > + > > > + return false; > > > + } > > > + > > > + buf->addr.offset = (*found)->offset; > > > + buf->addr.ctx = ibb->ctx; > > > > Ok, so it's tracking ctx so that we can return the right offset when the > > buffer is used by multiple contexts. But ctx is never compared in the > > lookup? > > Do you think should I add such multictx tracking to the intel_bb? It will > require additional collecting tree (current one is an index tree over > objects allocated, so for caching ctx/address new one is necessary). > I assumed intel_bb_objects_offset_to_buf() is enough to provide the user > ability to collect the addresses on its own (if it really requires that). Ok, so this is an export. I was thinking it was an internal lookup. My main concern was that something was using the ctx, and that appears to be satisfied. I may suggest that it is backwards and the caller should be telling the batch which context it was constructed for, but time will tell :) -Chris _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin @ 2020-06-04 9:13 Zbigniew Kempczyński 2020-06-04 9:13 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński 0 siblings, 1 reply; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 9:13 UTC (permalink / raw) To: igt-dev All localized functions gathered in media_spin were removed. v2: add implicit sync (set_domain) Zbigniew Kempczyński (4): lib/intel_bufops: add fields for keeping offset and context lib/intel_batchbuffer: add bb reset tests/i915_pm_sseu: remove libdrm dependency HAX: run gpgpu|media_fill and i915_pm_sseu in BAT only lib/gpu_cmds.c | 6 +- lib/intel_batchbuffer.c | 84 ++++- lib/intel_batchbuffer.h | 12 +- lib/intel_bufops.h | 4 + lib/media_spin.c | 469 ++++---------------------- lib/media_spin.h | 8 +- tests/i915/i915_pm_sseu.c | 73 ++-- tests/intel-ci/fast-feedback.testlist | 162 +-------- 8 files changed, 189 insertions(+), 629 deletions(-) -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset 2020-06-04 9:13 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński @ 2020-06-04 9:13 ` Zbigniew Kempczyński 0 siblings, 0 replies; 8+ messages in thread From: Zbigniew Kempczyński @ 2020-06-04 9:13 UTC (permalink / raw) To: igt-dev; +Cc: Chris Wilson For some scenarios we want to keep previous objects and their offsets and recreate only batchbuffer object. To allow user do that add bb reset function which can or not purge collected objects from previous run. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> --- lib/intel_batchbuffer.c | 84 +++++++++++++++++++++++++++++++++++------ lib/intel_batchbuffer.h | 12 ++++-- 2 files changed, 81 insertions(+), 15 deletions(-) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 49f2d0fe..2a882627 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -1203,7 +1203,7 @@ static void __reallocate_objects(struct intel_bb *ibb) } /** - * __intel_bb_create: + * intel_bb_create: * @i915: drm fd * @size: size of the batchbuffer * @@ -1250,6 +1250,26 @@ static void __do_nothing(void *node) (void) node; } +static void __intel_bb_destroy_objects(struct intel_bb *ibb) +{ + uint32_t i; + + /* Free relocations */ + for (i = 0; i < ibb->num_objects; i++) + free(from_user_pointer(ibb->objects[i].relocs_ptr)); + + free(ibb->objects); + tdestroy(ibb->root, __do_nothing); + + ibb->objects = NULL; + ibb->root = NULL; + ibb->num_objects = 0; + ibb->num_relocs = 0; + ibb->allocated_objects = 0; + ibb->allocated_relocs = 0; + ibb->ptr = ibb->batch; +} + /** * intel_bb_destroy: * @ibb: pointer to intel_bb @@ -1258,21 +1278,33 @@ static void __do_nothing(void *node) */ void intel_bb_destroy(struct intel_bb *ibb) { - uint32_t i; - igt_assert(ibb); - /* Free relocations */ - for (i = 0; i < ibb->num_objects; i++) - free(from_user_pointer(ibb->objects[i].relocs_ptr)); + __intel_bb_destroy_objects(ibb); + gem_close(ibb->i915, ibb->handle); - free(ibb->objects); - tdestroy(ibb->root, __do_nothing); + free(ibb); +} + +/* + * intel_bb_reset: + * @ibb: pointer to intel_bb + * @purge_objects_cache: if true destroy internal execobj and relocs + cache + * + * Recreate batch bo. +*/ +void intel_bb_reset(struct intel_bb *ibb, bool purge_objects_cache) +{ + if (purge_objects_cache) { + __intel_bb_destroy_objects(ibb); + __reallocate_objects(ibb); + } - munmap(ibb->batch, ibb->size); gem_close(ibb->i915, ibb->handle); + ibb->handle = gem_create(ibb->i915, ibb->size); - free(ibb); + intel_bb_add_object(ibb, ibb->handle, 0, false); + ibb->ptr = ibb->batch; } /** @@ -1573,7 +1605,7 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset, execbuf.buffers_ptr = (uintptr_t) ibb->objects; execbuf.buffer_count = ibb->num_objects; execbuf.batch_len = end_offset; - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = ibb->ctx = ctx; execbuf.flags = flags | I915_EXEC_BATCH_FIRST; ret = __gem_execbuf(ibb->i915, &execbuf); @@ -1649,3 +1681,33 @@ uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle) return (*found)->offset; } + +/** + * intel_bb_object_offset_to_buf: + * @ibb: pointer to intel_bb + * @buf: buffer we want to store last exec offset and context id + * + * Copy object offset used in the batch to intel_buf to allow caller prepare + * other batch likely without relocations. + */ +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf) +{ + struct drm_i915_gem_exec_object2 object = { .handle = buf->handle }; + struct drm_i915_gem_exec_object2 **found; + + igt_assert(ibb); + igt_assert(buf); + + found = tfind((void *) &object, &ibb->root, __compare_objects); + if (!found) { + buf->addr.offset = 0; + buf->addr.ctx = 0; + + return false; + } + + buf->addr.offset = (*found)->offset; + buf->addr.ctx = ibb->ctx; + + return true; +} diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index ae052c17..0649fc22 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -405,8 +405,8 @@ igt_vme_func_t igt_get_media_vme_func(int devid); /** * igt_media_spinfunc_t: - * @batch: batchbuffer object - * @dst: destination i-g-t buffer object + * @i915: drm fd + * @buf: destination buffer object * @spins: number of loops to execute * * This is the type of the per-platform media spin functions. The @@ -420,8 +420,8 @@ igt_vme_func_t igt_get_media_vme_func(int devid); * destination buffer on completion. This utility provides a simple way * to keep the render engine busy for a set time for various tests. */ -typedef void (*igt_media_spinfunc_t)(struct intel_batchbuffer *batch, - const struct igt_buf *dst, uint32_t spins); +typedef void (*igt_media_spinfunc_t)(int i915, + struct intel_buf *buf, uint32_t spins); igt_media_spinfunc_t igt_get_media_spinfunc(int devid); @@ -443,6 +443,8 @@ struct intel_bb { uint64_t gtt_size; bool supports_48b_address; + uint32_t ctx; + void *root; struct drm_i915_gem_exec_object2 *objects; uint32_t num_objects; @@ -457,6 +459,7 @@ struct intel_bb { struct intel_bb *intel_bb_create(int i915, uint32_t size); void intel_bb_destroy(struct intel_bb *ibb); +void intel_bb_reset(struct intel_bb *ibb, bool purge_objects_cache); void intel_bb_set_debug(struct intel_bb *ibb, bool debug); static inline uint32_t intel_bb_offset(struct intel_bb *ibb) @@ -524,5 +527,6 @@ void intel_bb_exec_with_context(struct intel_bb *ibb, uint32_t end_offset, uint32_t ctx, uint64_t flags, bool sync); uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle); +bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf); #endif -- 2.26.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-06-05 14:18 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-04 9:16 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński 2020-06-04 9:16 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/intel_bufops: add fields for keeping offset and context Zbigniew Kempczyński 2020-06-04 9:16 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński -- strict thread matches above, loose matches on Subject: below -- 2020-06-04 10:03 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński 2020-06-04 10:03 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński 2020-06-04 15:07 ` Chris Wilson 2020-06-05 5:40 ` Zbigniew Kempczyński 2020-06-05 14:17 ` Chris Wilson 2020-06-04 9:13 [igt-dev] [PATCH i-g-t v2 0/4] Remove libdrm from media_spin Zbigniew Kempczyński 2020-06-04 9:13 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/intel_batchbuffer: add bb reset Zbigniew Kempczyński
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox