drm/i915: Compare GGTT view structs instead of types
Subsystems (2)
Joonas Lahtinen
maintainerPATCH v2 1/1 drm/i915: Compare GGTT view structs instead of types
Preparatory code to decrease amount of conflicts between rotated and partial views code.
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison. This allows including parameters like offset to be included in the view which is useful for eg. partial views.
--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 26 ++++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.h | 7 +++++++ 4 files changed, 26 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -4
@@ -2791,19 +2791,19 @@ void i915_gem_restore_fences(struct drm_device *dev);unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o,struct i915_address_space *vm);static inline unsigned long i915_gem_obj_ggtt_offset (struct drm_i915_gem_object *o) { -return i915_gem_obj_ggtt_offset_view (o,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_offset_view (o, &i915_ggtt_view_normal); }bool i915_gem_obj_bound_any (struct drm_i915_gem_object *o);bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);bool i915_gem_obj_bound (struct drm_i915_gem_object *o,struct i915_address_space *vm);
@@ -2851,7 +2851,7 @@ i915_vm_to_ppgtt(struct i915_address_space *vm)static inline bool i915_gem_obj_ggtt_bound (struct drm_i915_gem_object *obj) { -return i915_gem_obj_ggtt_bound_view (obj,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_bound_view (obj, &i915_ggtt_view_normal); } static inline unsigned long
drivers/gpu/drm/i915/i915_gem.c +14 -12
@@ -2978,7 +2978,7 @@ int i915_vma_unbind(struct i915_vma *vma)*/ if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type ==I915_GGTT_VIEW_NORMAL ) { +i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal)) {i915_gem_object_finish_gtt (obj);/* release the fence reg _after_ flushing */
@@ -4122,7 +4122,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,if (i915_vma_misplaced (vma, alignment, flags)) {unsigned long offset; - offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view->type) : + offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view) :i915_gem_obj_offset (obj, vm);WARN (vma->pin_count, "bo is already pinned in %s with incorrect alignment:"
@@ -4524,7 +4524,7 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,struct i915_vma *vma;list_for_each_entry (vma, &obj->vma_list, vma_link) {if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL ) + !i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal))continue ;if (vma->vm == vm)return vma;
@@ -4542,7 +4542,8 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,return ERR_PTR (-EINVAL );list_for_each_entry (vma, &obj->vma_list, vma_link) -if (vma->vm == ggtt && vma->ggtt_view.type == view->type) +if (vma->vm == ggtt && +i915_ggtt_view_equal (&vma->ggtt_view, view))return vma;return NULL ; }
@@ -5086,7 +5087,7 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,list_for_each_entry (vma, &o->vma_list, vma_link) {if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL ) + !i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal))continue ;if (vma->vm == vm)return vma->node.start;
@@ -5099,13 +5100,14 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link) -if (vma->vm == ggtt && vma->ggtt_view.type == view) +if (vma->vm == ggtt && +i915_ggtt_view_equal (&vma->ggtt_view, view))return vma->node.start;WARN (1 ,"global vma for this object not found.\n" );
@@ -5119,7 +5121,7 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,list_for_each_entry (vma, &o->vma_list, vma_link) {if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL ) + !i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal))continue ;if (vma->vm == vm &&drm_mm_node_allocated (&vma->node))return true;
@@ -5129,14 +5131,14 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o, }bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link)if (vma->vm == ggtt && - vma->ggtt_view.type == view && +i915_ggtt_view_equal (&vma->ggtt_view, view) &&drm_mm_node_allocated (&vma->node))return true;
@@ -5166,7 +5168,7 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,list_for_each_entry (vma, &o->vma_list, vma_link) {if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL ) + !i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal))continue ;if (vma->vm == vm)return vma->node.size;
@@ -5179,7 +5181,7 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)struct i915_vma *vma;list_for_each_entry (vma, &obj->vma_list, vma_link) {if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL ) + !i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal))continue ;if (vma->pin_count >0 )return true;
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -2507,7 +2507,7 @@ int i915_get_ggtt_vma_pages(struct i915_vma *vma)if (vma->ggtt_view.pages)return 0 ; -if (vma->ggtt_view.type ==I915_GGTT_VIEW_NORMAL ) +if (i915_ggtt_view_equal (&vma->ggtt_view, &i915_ggtt_view_normal)) vma->ggtt_view.pages = vma->obj->pages;else WARN_ONCE(1, "GGTT view %u not implemented!\n",
drivers/gpu/drm/i915/i915_gem_gtt.h +7 -0
@@ -382,6 +382,13 @@ static inline uint32_t gen6_pde_index(uint32_t addr)return i915_pde_index (addr,GEN6_PDE_SHIFT ); } +static inline bool +i915_ggtt_view_equal (const struct i915_ggtt_view *a, +const struct i915_ggtt_view *b) +{ +return a->type == b->type; +} +int i915_gem_gtt_init (struct drm_device *dev);void i915_gem_init_global_gtt (struct drm_device *dev);void i915_global_gtt_cleanup (struct drm_device *dev);
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Joonas Lahtinen
Preparatory code to decrease amount of conflicts between rotated and partial views code.
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison. This allows including parameters like offset to be included in the view which is useful for eg. partial views.
Quoted 7 lines
Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 26 ++++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.h | 7 +++++++ 4 files changed, 26 insertions(+), 17 deletions(-)
No objections for this version! :)
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerThe patch could be committed then with the R-B.
Quoted 17 lines · Tvrtko Ursulin
Quoted 8 lines · Joonas Lahtinen
Preparatory code to decrease amount of conflicts between rotated and partial views code.
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison. This allows including parameters like offset to be included in the view which is useful for eg. partial views.
Quoted 7 lines
Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 26 ++++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.h | 7 +++++++ 4 files changed, 26 insertions(+), 17 deletions(-)
Quoted 7 lines
No objections for this version! :)
Reviewed-by Tvrtko Ursulin <[email protected]>Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedQuoted 18 lines · Tvrtko Ursulin
Quoted 8 lines · Joonas Lahtinen
Preparatory code to decrease amount of conflicts between rotated and partial views code.
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison. This allows including parameters like offset to be included in the view which is useful for eg. partial views.
Quoted 7 lines
Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 26 ++++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.h | 7 +++++++ 4 files changed, 26 insertions(+), 17 deletions(-)
Quoted 3 lines
No objections for this version! :)
Reviewed-by Tvrtko Ursulin <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerPATCH v3 1/1 drm/i915: Compare GGTT view structs instead of types
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison when we match a GGTT view.
This allows including parameters like offset to be included in the view which is useful for eg. partial views.
v3:
- Rely on ggtt_view type being 0 for non-GGTT vma's, which equals to I915_GGTT_VIEW_NORMAL. (Daniel Vetter)
- Do not use potentially slower comparison when we only want to know if something is or is not a normal view.
- Rebase on top of rotated view patches. Add rotated view singleton.
- If one view is missing in comparison they're equal only if both are missing.
--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 13 +++++++------ drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ drivers/gpu/drm/i915/i915_gem_gtt.h | 8 ++++++++ drivers/gpu/drm/i915/intel_display.c | 8 +++----- 5 files changed, 25 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -4
@@ -2794,19 +2794,19 @@ void i915_gem_restore_fences(struct drm_device *dev);unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o,struct i915_address_space *vm);static inline unsigned long i915_gem_obj_ggtt_offset (struct drm_i915_gem_object *o) { -return i915_gem_obj_ggtt_offset_view (o,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_offset_view (o, &i915_ggtt_view_normal); }bool i915_gem_obj_bound_any (struct drm_i915_gem_object *o);bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);bool i915_gem_obj_bound (struct drm_i915_gem_object *o,struct i915_address_space *vm);
@@ -2854,7 +2854,7 @@ i915_vm_to_ppgtt(struct i915_address_space *vm)static inline bool i915_gem_obj_ggtt_bound (struct drm_i915_gem_object *obj) { -return i915_gem_obj_ggtt_bound_view (obj,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_bound_view (obj, &i915_ggtt_view_normal); } static inline unsigned long
drivers/gpu/drm/i915/i915_gem.c +7 -6
@@ -4131,7 +4131,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,if (i915_vma_misplaced (vma, alignment, flags)) {unsigned long offset; - offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view->type) : + offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view) :i915_gem_obj_offset (obj, vm);WARN (vma->pin_count, "bo is already pinned in %s with incorrect alignment:"
@@ -4230,7 +4230,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,BUG_ON (!vma);WARN_ON (vma->pin_count ==0 ); -WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view->type)); +WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view));if (--vma->pin_count ==0 && view->type ==I915_GGTT_VIEW_NORMAL ) obj->pin_mappable = false;
@@ -5109,13 +5109,14 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link) -if (vma->vm == ggtt && vma->ggtt_view.type == view) +if (vma->vm == ggtt && +i915_ggtt_view_equal (&vma->ggtt_view, view))return vma->node.start;WARN (1 ,"global vma for this object not found.\n" );
@@ -5139,14 +5140,14 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o, }bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link)if (vma->vm == ggtt && - vma->ggtt_view.type == view && +i915_ggtt_view_equal (&vma->ggtt_view, view) &&drm_mm_node_allocated (&vma->node))return true;
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -0
@@ -93,6 +93,9 @@*/ const struct i915_ggtt_view i915_ggtt_view_normal; +const struct i915_ggtt_view i915_ggtt_view_rotated = { + .type =I915_GGTT_VIEW_ROTATED +};static void bdw_setup_private_ppat (struct drm_i915_private *dev_priv);static void chv_setup_private_ppat (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem_gtt.h +8 -0
@@ -138,6 +138,7 @@ struct i915_ggtt_view { };extern const struct i915_ggtt_view i915_ggtt_view_normal; +extern const struct i915_ggtt_view i915_ggtt_view_rotated;enum i915_cache_level ;
@@ -422,4 +423,11 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev);int __must_check i915_gem_gtt_prepare_object (struct drm_i915_gem_object *obj);void i915_gem_gtt_finish_object (struct drm_i915_gem_object *obj); +static inline bool +i915_ggtt_view_equal (const struct i915_ggtt_view *a, +const struct i915_ggtt_view *b) +{ +return !!a && !!b ? a->type == b->type : !a && !b; +} +#endif
drivers/gpu/drm/i915/intel_display.c +3 -5
@@ -2293,8 +2293,6 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, const struct drm_plane_state *plane_state) {struct intel_rotation_info *info = &view->rotation_info; -static const struct i915_ggtt_view rotated_view = - { .type =I915_GGTT_VIEW_ROTATED }; *view = i915_ggtt_view_normal;
@@ -2304,7 +2302,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,if (!intel_rotation_90_or_270 (plane_state->rotation))return 0 ; - *view = rotated_view; + *view = i915_ggtt_view_rotated; info->height = fb->height; info->pixel_format = fb->pixel_format;
@@ -2904,10 +2902,10 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,unsigned long intel_plane_obj_offset (struct intel_plane *intel_plane,struct drm_i915_gem_object *obj) { -enum i915_ggtt_view_type view =I915_GGTT_VIEW_NORMAL ; +const struct i915_ggtt_view *view = &i915_ggtt_view_normal;if (intel_rotation_90_or_270 (intel_plane->base.state->rotation)) - view =I915_GGTT_VIEW_ROTATED ; + view = &i915_ggtt_view_rotated;return i915_gem_obj_ggtt_offset_view (obj, view); }
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi,
Quoted 76 lines · Joonas Lahtinen
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison when we match a GGTT view.
This allows including parameters like offset to be included in the view which is useful for eg. partial views.
v3:
- Rely onggtt_viewtype being 0 for non-GGTT vma's, which equals toI915_GGTT_VIEW_NORMAL. (Daniel Vetter)
- Do not use potentially slower comparison when we only want to know if something is or is not a normal view.
- Rebase on top of rotated view patches. Add rotated view singleton.
- If one view is missing in comparison they're equal only if both are missing.Cc Daniel Vetter <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]> (v2)Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 13 +++++++------ drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ drivers/gpu/drm/i915/i915_gem_gtt.h | 8 ++++++++ drivers/gpu/drm/i915/intel_display.c | 8 +++----- 5 files changed, 25 insertions(+), 15 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-4@@ -2794,19 +2794,19 @@ void i915_gem_restore_fences(struct drm_device *dev);unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o,struct i915_address_space *vm);static inline unsigned long i915_gem_obj_ggtt_offset (struct drm_i915_gem_object *o) { -return i915_gem_obj_ggtt_offset_view (o,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_offset_view (o, &i915_ggtt_view_normal); }bool i915_gem_obj_bound_any (struct drm_i915_gem_object *o);bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);bool i915_gem_obj_bound (struct drm_i915_gem_object *o,struct i915_address_space *vm);@@ -2854,7 +2854,7 @@ i915_vm_to_ppgtt(struct i915_address_space *vm)static inline bool i915_gem_obj_ggtt_bound (struct drm_i915_gem_object *obj) { -return i915_gem_obj_ggtt_bound_view (obj,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_bound_view (obj, &i915_ggtt_view_normal); } static inline unsigned longdrivers/gpu/drm/i915/i915_gem.c +1
-1@@ -4131,7 +4131,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,if (i915_vma_misplaced (vma, alignment, flags)) {unsigned long offset; - offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view->type) : + offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view) :i915_gem_obj_offset (obj, vm);WARN (vma->pin_count, "bo is already pinned in %s with incorrect alignment:"
drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj, · line 4236
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -4230,7 +4230,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,BUG_ON (!vma);WARN_ON (vma->pin_count ==0 ); -WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view->type)); +WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view));if (--vma->pin_count ==0 && view->type ==I915_GGTT_VIEW_NORMAL ) obj->pin_mappable = false;
No comparison helper in i915_gem_obj_to_ggtt_view()?
Quoted 61 lines
drivers/gpu/drm/i915/i915_gem.c +5
-4@@ -5109,13 +5109,14 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link) -if (vma->vm == ggtt && vma->ggtt_view.type == view) +if (vma->vm == ggtt && +i915_ggtt_view_equal (&vma->ggtt_view, view))return vma->node.start;WARN (1 ,"global vma for this object not found.\n" );@@ -5139,14 +5140,14 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o, }bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link)if (vma->vm == ggtt && - vma->ggtt_view.type == view && +i915_ggtt_view_equal (&vma->ggtt_view, view) &&drm_mm_node_allocated (&vma->node))return true;drivers/gpu/drm/i915/i915_gem_gtt.c +3
-0@@ -93,6 +93,9 @@*/ const struct i915_ggtt_view i915_ggtt_view_normal; +const struct i915_ggtt_view i915_ggtt_view_rotated = { + .type =I915_GGTT_VIEW_ROTATED +};static void bdw_setup_private_ppat (struct drm_i915_private *dev_priv);static void chv_setup_private_ppat (struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/i915_gem_gtt.h +1
-0@@ -138,6 +138,7 @@ struct i915_ggtt_view { };extern const struct i915_ggtt_view i915_ggtt_view_normal; +extern const struct i915_ggtt_view i915_ggtt_view_rotated;enum i915_cache_level ;
drivers/gpu/drm/i915/i915_gem_gtt.h void i915_gem_restore_gtt_mappings(struct drm_device *dev); · line 431
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +6
-0@@ -422,4 +423,11 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev);int __must_check i915_gem_gtt_prepare_object (struct drm_i915_gem_object *obj);void i915_gem_gtt_finish_object (struct drm_i915_gem_object *obj); +static inline bool +i915_ggtt_view_equal (const struct i915_ggtt_view *a, +const struct i915_ggtt_view *b) +{ +return !!a && !!b ? a->type == b->type : !a && !b; +}
What's the background behind this both NULL check? Will you ever use it like that?
I think the code elsewhere makes sure to always pass valid views to this internal helper so I don't get it.
Quoted 28 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1
-0+#endif drivers/gpu/drm/i915/intel_display.c +1
-3@@ -2293,8 +2293,6 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, const struct drm_plane_state *plane_state) {struct intel_rotation_info *info = &view->rotation_info; -static const struct i915_ggtt_view rotated_view = - { .type =I915_GGTT_VIEW_ROTATED }; *view = i915_ggtt_view_normal;@@ -2304,7 +2302,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,if (!intel_rotation_90_or_270 (plane_state->rotation))return 0 ; - *view = rotated_view; + *view = i915_ggtt_view_rotated; info->height = fb->height; info->pixel_format = fb->pixel_format;@@ -2904,10 +2902,10 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,unsigned long intel_plane_obj_offset (struct intel_plane *intel_plane,struct drm_i915_gem_object *obj)
drivers/gpu/drm/i915/intel_display.c u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier, · line 2911
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +2
-2{ -enum i915_ggtt_view_type view =I915_GGTT_VIEW_NORMAL ; +const struct i915_ggtt_view *view = &i915_ggtt_view_normal;if (intel_rotation_90_or_270 (intel_plane->base.state->rotation)) - view =I915_GGTT_VIEW_ROTATED ; + view = &i915_ggtt_view_rotated;return i915_gem_obj_ggtt_offset_view (obj, view); }
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerPATCH v4 1/1 drm/i915: Compare GGTT view structs instead of types
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison when we match a GGTT view.
This allows including parameters like offset to be included in the view which is useful for eg. partial views.
v3:
- Rely on ggtt_view type being 0 for non-GGTT vma's, which equals to I915_GGTT_VIEW_NORMAL. (Daniel Vetter)
- Do not use potentially slower comparison when we only want to know if something is or is not a normal view.
- Rebase on top of rotated view patches. Add rotated view singleton.
- If one view is missing in comparison they're equal only if both are missing.
v4:
- Use comparison helper in obj_to_ggtt_view too. (Tvrtko Ursulin)
- Do WARN_ON if one view is NULL. (Tvrtko Ursulin)
--- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- drivers/gpu/drm/i915/i915_gem.c | 16 +++++++++------- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ drivers/gpu/drm/i915/i915_gem_gtt.h | 11 +++++++++++ drivers/gpu/drm/i915/intel_display.c | 8 +++----- 5 files changed, 30 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -4
@@ -2794,19 +2794,19 @@ void i915_gem_restore_fences(struct drm_device *dev);unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o,struct i915_address_space *vm);static inline unsigned long i915_gem_obj_ggtt_offset (struct drm_i915_gem_object *o) { -return i915_gem_obj_ggtt_offset_view (o,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_offset_view (o, &i915_ggtt_view_normal); }bool i915_gem_obj_bound_any (struct drm_i915_gem_object *o);bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view); +const struct i915_ggtt_view *view);bool i915_gem_obj_bound (struct drm_i915_gem_object *o,struct i915_address_space *vm);
@@ -2854,7 +2854,7 @@ i915_vm_to_ppgtt(struct i915_address_space *vm)static inline bool i915_gem_obj_ggtt_bound (struct drm_i915_gem_object *obj) { -return i915_gem_obj_ggtt_bound_view (obj,I915_GGTT_VIEW_NORMAL ); +return i915_gem_obj_ggtt_bound_view (obj, &i915_ggtt_view_normal); } static inline unsigned long
drivers/gpu/drm/i915/i915_gem.c +9 -7
@@ -4131,7 +4131,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,if (i915_vma_misplaced (vma, alignment, flags)) {unsigned long offset; - offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view->type) : + offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view) :i915_gem_obj_offset (obj, vm);WARN (vma->pin_count, "bo is already pinned in %s with incorrect alignment:"
@@ -4230,7 +4230,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,BUG_ON (!vma);WARN_ON (vma->pin_count ==0 ); -WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view->type)); +WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view));if (--vma->pin_count ==0 && view->type ==I915_GGTT_VIEW_NORMAL ) obj->pin_mappable = false;
@@ -4552,7 +4552,8 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,return ERR_PTR (-EINVAL );list_for_each_entry (vma, &obj->vma_list, vma_link) -if (vma->vm == ggtt && vma->ggtt_view.type == view->type) +if (vma->vm == ggtt && +i915_ggtt_view_equal (&vma->ggtt_view, view))return vma;return NULL ; }
@@ -5109,13 +5110,14 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,unsigned long i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link) -if (vma->vm == ggtt && vma->ggtt_view.type == view) +if (vma->vm == ggtt && +i915_ggtt_view_equal (&vma->ggtt_view, view))return vma->node.start;WARN (1 ,"global vma for this object not found.\n" );
@@ -5139,14 +5141,14 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o, }bool i915_gem_obj_ggtt_bound_view (struct drm_i915_gem_object *o, -enum i915_ggtt_view_type view) +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link)if (vma->vm == ggtt && - vma->ggtt_view.type == view && +i915_ggtt_view_equal (&vma->ggtt_view, view) &&drm_mm_node_allocated (&vma->node))return true;
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -0
@@ -93,6 +93,9 @@*/ const struct i915_ggtt_view i915_ggtt_view_normal; +const struct i915_ggtt_view i915_ggtt_view_rotated = { + .type =I915_GGTT_VIEW_ROTATED +};static void bdw_setup_private_ppat (struct drm_i915_private *dev_priv);static void chv_setup_private_ppat (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem_gtt.h +11 -0
@@ -138,6 +138,7 @@ struct i915_ggtt_view { };extern const struct i915_ggtt_view i915_ggtt_view_normal; +extern const struct i915_ggtt_view i915_ggtt_view_rotated;enum i915_cache_level ;
@@ -422,4 +423,14 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev);int __must_check i915_gem_gtt_prepare_object (struct drm_i915_gem_object *obj);void i915_gem_gtt_finish_object (struct drm_i915_gem_object *obj); +static inline bool +i915_ggtt_view_equal (const struct i915_ggtt_view *a, +const struct i915_ggtt_view *b) +{ +if (WARN_ON (!a || !b)) +return false; + +return a->type == b->type; +} +#endif
drivers/gpu/drm/i915/intel_display.c +3 -5
@@ -2293,8 +2293,6 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, const struct drm_plane_state *plane_state) {struct intel_rotation_info *info = &view->rotation_info; -static const struct i915_ggtt_view rotated_view = - { .type =I915_GGTT_VIEW_ROTATED }; *view = i915_ggtt_view_normal;
@@ -2304,7 +2302,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,if (!intel_rotation_90_or_270 (plane_state->rotation))return 0 ; - *view = rotated_view; + *view = i915_ggtt_view_rotated; info->height = fb->height; info->pixel_format = fb->pixel_format;
@@ -2904,10 +2902,10 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,unsigned long intel_plane_obj_offset (struct intel_plane *intel_plane,struct drm_i915_gem_object *obj) { -enum i915_ggtt_view_type view =I915_GGTT_VIEW_NORMAL ; +const struct i915_ggtt_view *view = &i915_ggtt_view_normal;if (intel_rotation_90_or_270 (intel_plane->base.state->rotation)) - view =I915_GGTT_VIEW_ROTATED ; + view = &i915_ggtt_view_rotated;return i915_gem_obj_ggtt_offset_view (obj, view); }
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi,
Quoted 15 lines · Joonas Lahtinen
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison when we match a GGTT view.
This allows including parameters like offset to be included in the view which is useful for eg. partial views.
v3:
- Rely onggtt_viewtype being 0 for non-GGTT vma's, which equals toI915_GGTT_VIEW_NORMAL. (Daniel Vetter)
- Do not use potentially slower comparison when we only want to know if something is or is not a normal view.
- Rebase on top of rotated view patches. Add rotated view singleton.
- If one view is missing in comparison they're equal only if both are missing.
Quoted 7 lines
v4:
- Use comparison helper inobj_to_ggtt_viewtoo. (Tvrtko Ursulin)
- DoWARN_ONif one view is NULL. (Tvrtko Ursulin)Cc Daniel Vetter <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]> (v2)Signed-off-by Joonas Lahtinen <[email protected]>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedQuoted 23 lines · Tvrtko Ursulin
Hi,
Quoted 19 lines · Joonas Lahtinen
To allow for views where the view type is not defined by the view type only, like it is in stereo or rotated 90 degree view, change the semantic to require the whole view structure for comparison when we match a GGTT view.
This allows including parameters like offset to be included in the view which is useful for eg. partial views.
v3:
- Rely onggtt_viewtype being 0 for non-GGTT vma's, which equals toI915_GGTT_VIEW_NORMAL. (Daniel Vetter)
- Do not use potentially slower comparison when we only want to know if something is or is not a normal view.
- Rebase on top of rotated view patches. Add rotated view singleton.
- If one view is missing in comparison they're equal only if both are missing.v4:
- Use comparison helper inobj_to_ggtt_viewtoo. (Tvrtko Ursulin)
- DoWARN_ONif one view is NULL. (Tvrtko Ursulin)
Quoted 5 lines
Quoted 3 lines
Cc Daniel Vetter <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]> (v2)Signed-off-by Joonas Lahtinen <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Task id: 6076 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV 276/276 276/276 ILK 303/303 303/303 SNB 304/304 304/304 IVB -2 330/330 328/330 BYT 287/287 287/287 HSW 361/361 361/361 BDW 309/309 309/309
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*IVB igt@gem_storedw_batches_loop@normal PASS(5) DMESG_WARN(2)
(dmesg patch applied)drm:i915_hangcheck_elapsed[i915]]*ERROR*Hangcheck_timer_elapsed...blitter_ring_idle@Hangcheck timer elapsed... blitter ring idle
*IVB igt@gem_storedw_batches_loop@secure-dispatch PASS(2) DMESG_WARN(1)PASS(1)
(dmesg patch applied)drm:i915_hangcheck_elapsed[i915]]*ERROR*Hangcheck_timer_elapsed...blitter_ring_idle@Hangcheck timer elapsed... blitter ring idle
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Task id: 6072 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV 276/276 276/276 ILK 303/303 303/303 SNB 304/304 304/304 IVB -1 330/330 329/330 BYT 287/287 287/287 HSW 361/361 361/361 BDW 309/309 309/309
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*IVB igt@gem_pwrite_pread@snooped-copy-performance PASS(3) DMESG_WARN(1)PASS(1)
(dmesg patch applied)drm:i915_hangcheck_elapsed[i915]]*ERROR*Hangcheck_timer_elapsed...blitter_ring_idle@Hangcheck timer elapsed... blitter ring idle
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Task id: 6029 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV -1 275/275 274/275
ILK 303/303 303/303 SNB 304/304 304/304 IVB 339/339 339/339 BYT 287/287 287/287 HSW 361/361 361/361 BDW 310/310 310/310
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*PNV igt@gem_userptr_blits@minor-normal-sync PASS(2) DMESG_WARN(1)PASS(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx