Skip to contentSkip to conversation

drm/i915: Remove i915_gem_obj_size

PATCH In review Tvrtko Ursulin 4 participants 10 messages Apr 21, 2016 – Apr 25, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/i915: Remove i915_gem_obj_size

From: Tvrtko Ursulin <[email protected]>

Only caller is i915_gem_obj_ggtt_size which only cares about GGTT so simplify it and implement under that name.

---
 drivers/gpu/drm/i915/i915_drv.h | 12 ++----------
 drivers/gpu/drm/i915/i915_gem.c | 13 ++++---------
 2 files changed, 6 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -10
index 6f1e0f127c0a..b059304a850b 100644
@@ -3215,8 +3215,6 @@ bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
 bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
 			struct i915_address_space *vm);
 
-unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,
-				struct i915_address_space *vm);
 struct i915_vma *
 i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
 		    struct i915_address_space *vm);
@@ -3251,14 +3249,8 @@ 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);
 }
 
-static inline unsigned long
-i915_gem_obj_ggtt_size(struct drm_i915_gem_object *obj)
-{
-	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
-	struct i915_ggtt *ggtt = &dev_priv->ggtt;
-
-	return i915_gem_obj_size(obj, &ggtt->base);
-}
+unsigned long
+i915_gem_obj_ggtt_size(struct drm_i915_gem_object *obj);
 
 static inline int __must_check
 i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj,
drivers/gpu/drm/i915/i915_gem.c +4 -9
index 261a3ef72828..f7e9558178d4 100644
@@ -5306,23 +5306,18 @@ bool i915_gem_obj_bound_any(struct drm_i915_gem_object *o)
 	return false;
 }
 
-unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,
-				struct i915_address_space *vm)
+unsigned long i915_gem_obj_ggtt_size(struct drm_i915_gem_object *o)
 {
-	struct drm_i915_private *dev_priv = o->base.dev->dev_private;
 	struct i915_vma *vma;
 
-	WARN_ON(vm == &dev_priv->mm.aliasing_ppgtt->base);
-
-	BUG_ON(list_empty(&o->vma_list));
+	GEM_BUG_ON(list_empty(&o->vma_list));
 
 	list_for_each_entry(vma, &o->vma_list, obj_link) {
 		if (vma->is_ggtt &&
-		    vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
-			continue;
-		if (vma->vm == vm)
+		    vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL)
 			return vma->node.size;
 	}
+
 	return 0;
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/4 drm/i915: Simplify i915_gem_obj_to_ggtt_view

From: Tvrtko Ursulin <[email protected]>

Can use vma->is_ggtt to simplify the check and also switch the BUG_ON to GEM_BUG_ON which is more appropriate for this.

---
 drivers/gpu/drm/i915/i915_gem.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -6
index f7e9558178d4..4abaa364da32 100644
@@ -4648,16 +4648,12 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
 struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,
 					   const struct i915_ggtt_view *view)
 {
-	struct drm_device *dev = obj->base.dev;
-	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct i915_ggtt *ggtt = &dev_priv->ggtt;
 	struct i915_vma *vma;
 
-	BUG_ON(!view);
+	GEM_BUG_ON(!view);
 
 	list_for_each_entry(vma, &obj->vma_list, obj_link)
-		if (vma->vm == &ggtt->base &&
-		    i915_ggtt_view_equal(&vma->ggtt_view, view))
+		if (vma->is_ggtt && i915_ggtt_view_equal(&vma->ggtt_view, view))
 			return vma;
 	return NULL;
 }
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/4 drm/i915: Simplify i915_gem_obj_ggtt_offset_view

In reply to Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Can use the new vma->is_ggtt to simplify the check and remove the local variables.

---
 drivers/gpu/drm/i915/i915_gem.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -4
index 4abaa364da32..135e1e9c40c2 100644
@@ -5246,13 +5246,10 @@ u64 i915_gem_obj_offset(struct drm_i915_gem_object *o,
 u64 i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o,
 				  const struct i915_ggtt_view *view)
 {
-	struct drm_i915_private *dev_priv = to_i915(o->base.dev);
-	struct i915_ggtt *ggtt = &dev_priv->ggtt;
 	struct i915_vma *vma;
 
 	list_for_each_entry(vma, &o->vma_list, obj_link)
-		if (vma->vm == &ggtt->base &&
-		    i915_ggtt_view_equal(&vma->ggtt_view, view))
+		if (vma->is_ggtt && i915_ggtt_view_equal(&vma->ggtt_view, view))
 			return vma->node.start;
 
 	WARN(1, "global vma for this object not found. (view=%u)\n", view->type);
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 4/4 drm/i915: Simplify i915_gem_obj_ggtt_bound_view

In reply to Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Can use the new vma->is_gtt to simplify the check and get rid of the local variables.

---
 drivers/gpu/drm/i915/i915_gem.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -3
index 135e1e9c40c2..c5ca53d2e35d 100644
@@ -5275,12 +5275,10 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
 bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
 				  const struct i915_ggtt_view *view)
 {
-	struct drm_i915_private *dev_priv = to_i915(o->base.dev);
-	struct i915_ggtt *ggtt = &dev_priv->ggtt;
 	struct i915_vma *vma;
 
 	list_for_each_entry(vma, &o->vma_list, obj_link)
-		if (vma->vm == &ggtt->base &&
+		if (vma->is_ggtt &&
 		    i915_ggtt_view_equal(&vma->ggtt_view, view) &&
 		    drm_mm_node_allocated(&vma->node))
 			return true;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 4/4
#4 lore raw

Re: [PATCH 4/4] drm/i915: Simplify i915_gem_obj_ggtt_bound_view

Quoted 19 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Can use the new vma->is_gtt to simplify the check and get rid of the local variables.

---
  drivers/gpu/drm/i915/i915_gem.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 135e1e9c40c2..c5ca53d2e35d 100644
@@ -5275,12 +5275,10 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
  bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
  				  const struct i915_ggtt_view *view)
  {

drivers/gpu/drm/i915/i915_gem.c bool i915_gem_obj_bound(struct drm_i915_gem_object *o, · line 5284

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +1 -3
-	struct drm_i915_private *dev_priv = to_i915(o->base.dev);
-	struct i915_ggtt *ggtt = &dev_priv->ggtt;
  	struct i915_vma *vma;
 
  	list_for_each_entry(vma, &o->vma_list, obj_link)
-		if (vma->vm == &ggtt->base &&
+		if (vma->is_ggtt &&
  		    i915_ggtt_view_equal(&vma->ggtt_view, view) &&
  		    drm_mm_node_allocated(&vma->node))
  			return true;

For patches 2-4,

As these three all now contain

	if (vma->is_ggtt &&
	    i915_ggtt_view_equal(&vma->ggtt_view, view)
	    ...

and these are the ONLY three uses of i915_ggtt_view_equal(), perhaps
the latter could be deleted from the header file and replaced by a local (static) inline that encapsulates the is_ggtt test as well?

The Cocci script below found one more candidate for updating:

cocci-output-24681-2f2e3b-i915_gem_gtt.c renamed from gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -3255,7 +3255,7 @@ void i915_gem_restore_gtt_mappings(struc
 	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
 		flush = false;
 		list_for_each_entry(vma, &obj->vma_list, obj_link) {
-			if (vma->vm != &ggtt->base)
+			if (!vma->is_ggtt)
 				continue;
 

Cocci:
@is_ggtt@
idexpression struct i915_ggtt *GGTT;
idexpression struct i915_vma *VMA;
@@

  {
    <...
-     VMA->vm == &GGTT->base
+     VMA->is_ggtt
    ...>

}

@not_ggtt@
idexpression struct i915_ggtt *GGTT;
idexpression struct i915_vma *VMA;
@@

  {
    <...
-     VMA->vm != &GGTT->base
+     !VMA->is_ggtt
    ...>

}

.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
In reply to Tvrtko Ursulin
Quoted 1 line · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Almost all of these vma family of functions need to be deleted and their object level inconvenience wrappers.

I don't feel this set of patches is heading in the right direction. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 7 lines · Chris Wilson
Quoted 1 line · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Almost all of these vma family of functions need to be deleted and their object level inconvenience wrappers.

I don't feel this set of patches is heading in the right direction.

There is no direction really, just accidentally spotted we could remove some code (source and binary), mostly which was missed with the vm(a)->is_ggtt addition.

Regards,

Tvrtko

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

✗ Fi.CI.BAT: warning for series starting with [1/4] drm/i915: Remove i915_gem_obj_size

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: series starting with [1/4] drm/i915: Remove i915_gem_obj_size
URL : https://patchwork.freedesktop.org/series/6060/
State : warning

== Summary ==

Series 6060v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/6060/revisions/1/mbox/

Test kms_force_connector_basic:

        Subgroup force-connector-state:
                pass       -> SKIP       (snb-x220t)
bdw-nuci7        total:193  pass:181  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:193  pass:170  dwarn:0   dfail:0   fail:0   skip:23 
bsw-nuc-2        total:192  pass:153  dwarn:0   dfail:0   fail:0   skip:39 
byt-nuc          total:192  pass:154  dwarn:0   dfail:0   fail:0   skip:38 
ilk-hp8440p      total:193  pass:136  dwarn:0   dfail:0   fail:0   skip:57 
ivb-t430s        total:193  pass:165  dwarn:0   dfail:0   fail:0   skip:28 
skl-i7k-2        total:193  pass:168  dwarn:0   dfail:0   fail:0   skip:25 
skl-nuci5        total:193  pass:182  dwarn:0   dfail:0   fail:0   skip:11 
snb-dellxps      total:193  pass:155  dwarn:0   dfail:0   fail:0   skip:38 
snb-x220t        total:193  pass:154  dwarn:0   dfail:0   fail:1   skip:38 

Results at /archive/results/CI_IGT_test/Patchwork_2021/

340c485ad98d0ec0369a3b18d4a09938f3f5537d drm-intel-nightly: 2016y-04m-22d-17h-32m-25s UTC integration manifest a430046 drm/i915: Simplify i915_gem_obj_ggtt_bound_view
3388a30 drm/i915: Simplify i915_gem_obj_ggtt_offset_view
9d90cdf drm/i915: Simplify i915_gem_obj_to_ggtt_view
e3d8799 drm/i915: Remove i915_gem_obj_size

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: ✗ Fi.CI.BAT: warning for series starting with [1/4] drm/i915: Remove i915_gem_obj_size

Quoted 6 lines · Patchwork

== Series Details ==

Series: series starting with [1/4] drm/i915: Remove i915_gem_obj_size
URL : https://patchwork.freedesktop.org/series/6060/
State : warning

Quoted 8 lines

== Summary ==

Series 6060v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/6060/revisions/1/mbox/

Test kms_force_connector_basic:

         Subgroup force-connector-state:
                 pass       -> SKIP       (snb-x220t)

That's the phantom VGA connector again!

Everything else looks good :)

Quoted 11 lines
bdw-nuci7        total:193  pass:181  dwarn:0   dfail:0   fail:0   skip:12
bdw-ultra        total:193  pass:170  dwarn:0   dfail:0   fail:0   skip:23
bsw-nuc-2        total:192  pass:153  dwarn:0   dfail:0   fail:0   skip:39
byt-nuc          total:192  pass:154  dwarn:0   dfail:0   fail:0   skip:38
ilk-hp8440p      total:193  pass:136  dwarn:0   dfail:0   fail:0   skip:57
ivb-t430s        total:193  pass:165  dwarn:0   dfail:0   fail:0   skip:28
skl-i7k-2        total:193  pass:168  dwarn:0   dfail:0   fail:0   skip:25
skl-nuci5        total:193  pass:182  dwarn:0   dfail:0   fail:0   skip:11
snb-dellxps      total:193  pass:155  dwarn:0   dfail:0   fail:0   skip:38
snb-x220t        total:193  pass:154  dwarn:0   dfail:0   fail:1   skip:38
Quoted 8 lines

Results at /archive/results/CI_IGT_test/Patchwork_2021/

340c485ad98d0ec0369a3b18d4a09938f3f5537d drm-intel-nightly: 2016y-04m-22d-17h-32m-25s UTC integration manifest a430046 drm/i915: Simplify i915_gem_obj_ggtt_bound_view
3388a30 drm/i915: Simplify i915_gem_obj_ggtt_offset_view
9d90cdf drm/i915: Simplify i915_gem_obj_to_ggtt_view
e3d8799 drm/i915: Remove i915_gem_obj_size

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author Applied
#9 lore raw

Re: ✗ Fi.CI.BAT: warning for series starting with [1/4] drm/i915: Remove i915_gem_obj_size

Quoted 12 lines · Dave Gordon
Quoted 11 lines · Patchwork

== Series Details ==

Series: series starting with [1/4] drm/i915: Remove i915_gem_obj_size
URL : https://patchwork.freedesktop.org/series/6060/
State : warning

== Summary ==

Series 6060v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/6060/revisions/1/mbox/

Quoted 37 lines
Quoted 3 lines

Test kms_force_connector_basic:

         Subgroup force-connector-state:
                 pass       -> SKIP       (snb-x220t)

That's the phantom VGA connector again!

Everything else looks good :)

Quoted 29 lines

bdw-nuci7 total:193 pass:181 dwarn:0 dfail:0 fail:0
skip:12
bdw-ultra total:193 pass:170 dwarn:0 dfail:0 fail:0
skip:23
bsw-nuc-2 total:192 pass:153 dwarn:0 dfail:0 fail:0
skip:39
byt-nuc total:192 pass:154 dwarn:0 dfail:0 fail:0
skip:38
ilk-hp8440p total:193 pass:136 dwarn:0 dfail:0 fail:0
skip:57
ivb-t430s total:193 pass:165 dwarn:0 dfail:0 fail:0
skip:28
skl-i7k-2 total:193 pass:168 dwarn:0 dfail:0 fail:0
skip:25
skl-nuci5 total:193 pass:182 dwarn:0 dfail:0 fail:0
skip:11
snb-dellxps total:193 pass:155 dwarn:0 dfail:0 fail:0
skip:38
snb-x220t total:193 pass:154 dwarn:0 dfail:0 fail:1
skip:38

Results at /archive/results/CI_IGT_test/Patchwork_2021/

340c485ad98d0ec0369a3b18d4a09938f3f5537d drm-intel-nightly:
2016y-04m-22d-17h-32m-25s UTC integration manifest a430046 drm/i915: Simplify i915_gem_obj_ggtt_bound_view 3388a30 drm/i915: Simplify i915_gem_obj_ggtt_offset_view 9d90cdf drm/i915: Simplify i915_gem_obj_to_ggtt_view e3d8799 drm/i915: Remove i915_gem_obj_size

Merged, thanks for the reviews!

Regards,

Tvrtko

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx