aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_context.c
diff options
context:
space:
mode:
authorBen Widawsky <benjamin.widawsky@intel.com>2014-02-20 14:47:06 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-03-04 09:52:15 -0500
commit321f2ada91ef142894f165814fc196e0cb168262 (patch)
tree7570b2faf2683f9ee90796915acebe183d9f79cc /drivers/gpu/drm/i915/i915_gem_context.c
parentc5c98a58990c1b2cf4d94b6759bed239976e5305 (diff)
drm/i915: Move ppgtt_release out of the header
At one time it was expected to be called in multiple places by kref_put. At the current time however, it is all contained within i915_gem_context.c. This patch makes an upcoming required addition a bit nicer since it too doesn't need to be defined in a header file. Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Imre Deak <imre.deak@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_context.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index da74522f377d..0785ddbb3d46 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -99,6 +99,42 @@
99static int do_switch(struct intel_ring_buffer *ring, 99static int do_switch(struct intel_ring_buffer *ring,
100 struct i915_hw_context *to); 100 struct i915_hw_context *to);
101 101
102static void ppgtt_release(struct kref *kref)
103{
104 struct i915_hw_ppgtt *ppgtt = container_of(kref, struct i915_hw_ppgtt, ref);
105 struct drm_device *dev = ppgtt->base.dev;
106 struct drm_i915_private *dev_priv = dev->dev_private;
107 struct i915_address_space *vm = &ppgtt->base;
108
109 if (ppgtt == dev_priv->mm.aliasing_ppgtt ||
110 (list_empty(&vm->active_list) && list_empty(&vm->inactive_list))) {
111 ppgtt->base.cleanup(&ppgtt->base);
112 return;
113 }
114
115 /*
116 * Make sure vmas are unbound before we take down the drm_mm
117 *
118 * FIXME: Proper refcounting should take care of this, this shouldn't be
119 * needed at all.
120 */
121 if (!list_empty(&vm->active_list)) {
122 struct i915_vma *vma;
123
124 list_for_each_entry(vma, &vm->active_list, mm_list)
125 if (WARN_ON(list_empty(&vma->vma_link) ||
126 list_is_singular(&vma->vma_link)))
127 break;
128
129 i915_gem_evict_vm(&ppgtt->base, true);
130 } else {
131 i915_gem_retire_requests(dev);
132 i915_gem_evict_vm(&ppgtt->base, false);
133 }
134
135 ppgtt->base.cleanup(&ppgtt->base);
136}
137
102static size_t get_context_alignment(struct drm_device *dev) 138static size_t get_context_alignment(struct drm_device *dev)
103{ 139{
104 if (IS_GEN6(dev)) 140 if (IS_GEN6(dev))