Message ID | 20201224143455.387624-1-matthew.auld@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm/i915: clear the shadow batch | expand |
Quoting Matthew Auld (2020-12-24 14:34:54) > The shadow batch is an internal object, which doesn't have any page > clearing, and since the batch_len can be smaller than the object, we > should take care to clear it. > > Testcase: igt/gen9_exec_parse/shadow-peek > Fixes: 4f7af1948abc ("drm/i915: Support ro ppgtt mapped cmdparser shadow buffers") > Signed-off-by: Matthew Auld <matthew.auld@intel.com> > --- > drivers/gpu/drm/i915/i915_cmd_parser.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c > index 8d88402387bd..ff3a0b8ccdd5 100644 > --- a/drivers/gpu/drm/i915/i915_cmd_parser.c > +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c > @@ -1147,6 +1147,13 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj, > if (IS_ERR(dst)) > return dst; > > + if (length < dst_obj->base.size) { > + memset32(dst + length, 0, > + (dst_obj->base.size - length) / sizeof(u32)); > + __i915_gem_object_flush_map(dst_obj, length, > + dst_obj->base.size - length); > + } I feel like we might as well remove the shadow_needs_clflush() and just do a i915_gem_object_flush_map(shadow->obj) after parsing. Then for simple chronological ordering, we can place this at the end of copy_batch memset32(dst + length, 0, (dst_obj->base.size - length) / sizeof(u32)); The cost of one more function call along here? Unnoticable. -Chris
diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c index 8d88402387bd..ff3a0b8ccdd5 100644 --- a/drivers/gpu/drm/i915/i915_cmd_parser.c +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c @@ -1147,6 +1147,13 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj, if (IS_ERR(dst)) return dst; + if (length < dst_obj->base.size) { + memset32(dst + length, 0, + (dst_obj->base.size - length) / sizeof(u32)); + __i915_gem_object_flush_map(dst_obj, length, + dst_obj->base.size - length); + } + ret = i915_gem_object_pin_pages(src_obj); if (ret) { i915_gem_object_unpin_map(dst_obj);
The shadow batch is an internal object, which doesn't have any page clearing, and since the batch_len can be smaller than the object, we should take care to clear it. Testcase: igt/gen9_exec_parse/shadow-peek Fixes: 4f7af1948abc ("drm/i915: Support ro ppgtt mapped cmdparser shadow buffers") Signed-off-by: Matthew Auld <matthew.auld@intel.com> --- drivers/gpu/drm/i915/i915_cmd_parser.c | 7 +++++++ 1 file changed, 7 insertions(+)