diff mbox

[v2] drm/i915: Compare GGTT view structs instead of types

Message ID 1427115109.2390.2.camel@jlahtine-mobl1 (mailing list archive)
State New, archived
Headers show

Commit Message

Joonas Lahtinen March 23, 2015, 12:51 p.m. UTC
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.

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 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(-)

Comments

Tvrtko Ursulin March 23, 2015, 1:39 p.m. UTC | #1
On 03/23/2015 12:51 PM, Joonas Lahtinen wrote:
> 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.
>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>   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! :)

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
Joonas Lahtinen March 24, 2015, 12:45 p.m. UTC | #2
The patch could be committed then with the R-B.

On ma, 2015-03-23 at 13:39 +0000, Tvrtko Ursulin wrote:
> On 03/23/2015 12:51 PM, Joonas Lahtinen wrote:
> > 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.
> >
> > Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > ---
> >   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! :)
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Regards,
> 
> Tvrtko
Shuang He March 24, 2015, 6:18 p.m. UTC | #3
Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
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 '*'
Daniel Vetter March 25, 2015, 10:59 a.m. UTC | #4
On Mon, Mar 23, 2015 at 01:39:16PM +0000, Tvrtko Ursulin wrote:
> 
> On 03/23/2015 12:51 PM, Joonas Lahtinen wrote:
> >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.
> >
> >Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> >---
> >  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! :)
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Queued for -next, thanks for the patch.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index eb38cd1..712f55e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 84e2a23..34aa7c0 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 645c363..ff0ef1c 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -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",
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 75e29f7..1db82d3 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -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);