[Intel-gfx] [PATCH v3 04/23] drm/i915: Don't special case teardown of aliasing_ppgtt
Chris Wilson
chris at chris-wilson.co.uk
Tue Feb 14 11:04:38 UTC 2017
The aliasing_ppgtt is a regular ppgtt, and we can use the regular
i915_ppgtt_put() to properly tear it down.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld at intel.com>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 50 +++++++++++--------------------------
1 file changed, 15 insertions(+), 35 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index ddfb5963f521..0fcdc42edcdc 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2237,23 +2237,6 @@ static void gtt_write_workarounds(struct drm_i915_private *dev_priv)
I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT);
}
-static int i915_ppgtt_init(struct i915_hw_ppgtt *ppgtt,
- struct drm_i915_private *dev_priv,
- struct drm_i915_file_private *file_priv,
- const char *name)
-{
- int ret;
-
- ret = __hw_ppgtt_init(ppgtt, dev_priv);
- if (ret == 0) {
- kref_init(&ppgtt->ref);
- i915_address_space_init(&ppgtt->base, dev_priv, name);
- ppgtt->base.file = file_priv;
- }
-
- return ret;
-}
-
int i915_ppgtt_init_hw(struct drm_i915_private *dev_priv)
{
gtt_write_workarounds(dev_priv);
@@ -2291,12 +2274,16 @@ i915_ppgtt_create(struct drm_i915_private *dev_priv,
if (!ppgtt)
return ERR_PTR(-ENOMEM);
- ret = i915_ppgtt_init(ppgtt, dev_priv, fpriv, name);
+ ret = __hw_ppgtt_init(ppgtt, dev_priv);
if (ret) {
kfree(ppgtt);
return ERR_PTR(ret);
}
+ kref_init(&ppgtt->ref);
+ i915_address_space_init(&ppgtt->base, dev_priv, name);
+ ppgtt->base.file = fpriv;
+
trace_i915_ppgtt_create(&ppgtt->base);
return ppgtt;
@@ -2756,19 +2743,15 @@ int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915)
struct i915_hw_ppgtt *ppgtt;
int err;
- ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
- if (!ppgtt)
- return -ENOMEM;
-
- err = __hw_ppgtt_init(ppgtt, i915);
- if (err)
- goto err_ppgtt;
+ ppgtt = i915_ppgtt_create(i915, NULL, "[alias]");
+ if (IS_ERR(ppgtt))
+ return PTR_ERR(ppgtt);
if (ppgtt->base.allocate_va_range) {
err = ppgtt->base.allocate_va_range(&ppgtt->base,
0, ppgtt->base.total);
if (err)
- goto err_ppgtt_cleanup;
+ goto err_ppgtt;
}
ppgtt->base.clear_range(&ppgtt->base,
@@ -2781,10 +2764,8 @@ int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915)
return 0;
-err_ppgtt_cleanup:
- ppgtt->base.cleanup(&ppgtt->base);
err_ppgtt:
- kfree(ppgtt);
+ i915_ppgtt_put(ppgtt);
return err;
}
@@ -2797,8 +2778,7 @@ void i915_gem_fini_aliasing_ppgtt(struct drm_i915_private *i915)
if (!ppgtt)
return;
- ppgtt->base.cleanup(&ppgtt->base);
- kfree(ppgtt);
+ i915_ppgtt_put(ppgtt);
ggtt->base.bind_vma = ggtt_bind_vma;
}
@@ -2873,21 +2853,21 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv)
WARN_ON(i915_vma_unbind(vma));
mutex_unlock(&dev_priv->drm.struct_mutex);
- i915_gem_fini_aliasing_ppgtt(dev_priv);
i915_gem_cleanup_stolen(&dev_priv->drm);
+ mutex_lock(&dev_priv->drm.struct_mutex);
+ i915_gem_fini_aliasing_ppgtt(dev_priv);
+
if (drm_mm_node_allocated(&ggtt->error_capture))
drm_mm_remove_node(&ggtt->error_capture);
if (drm_mm_initialized(&ggtt->base.mm)) {
intel_vgt_deballoon(dev_priv);
-
- mutex_lock(&dev_priv->drm.struct_mutex);
i915_address_space_fini(&ggtt->base);
- mutex_unlock(&dev_priv->drm.struct_mutex);
}
ggtt->base.cleanup(&ggtt->base);
+ mutex_unlock(&dev_priv->drm.struct_mutex);
arch_phys_wc_del(ggtt->mtrr);
io_mapping_fini(&ggtt->mappable);
--
2.11.0
More information about the Intel-gfx
mailing list