提交 1188bc66 编写于 作者: C Chris Wilson

drm/i915: Don't special case teardown of aliasing_ppgtt

The aliasing_ppgtt is a regular ppgtt, and we can use the regular
i915_ppgtt_put() to properly tear it down.
Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: NMatthew Auld <matthew.auld@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170215084357.19977-4-chris@chris-wilson.co.uk
上级 894ccebe
...@@ -2238,23 +2238,6 @@ static void gtt_write_workarounds(struct drm_i915_private *dev_priv) ...@@ -2238,23 +2238,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); 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) int i915_ppgtt_init_hw(struct drm_i915_private *dev_priv)
{ {
gtt_write_workarounds(dev_priv); gtt_write_workarounds(dev_priv);
...@@ -2292,12 +2275,16 @@ i915_ppgtt_create(struct drm_i915_private *dev_priv, ...@@ -2292,12 +2275,16 @@ i915_ppgtt_create(struct drm_i915_private *dev_priv,
if (!ppgtt) if (!ppgtt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ret = i915_ppgtt_init(ppgtt, dev_priv, fpriv, name); ret = __hw_ppgtt_init(ppgtt, dev_priv);
if (ret) { if (ret) {
kfree(ppgtt); kfree(ppgtt);
return ERR_PTR(ret); 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); trace_i915_ppgtt_create(&ppgtt->base);
return ppgtt; return ppgtt;
...@@ -2757,19 +2744,15 @@ int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915) ...@@ -2757,19 +2744,15 @@ int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915)
struct i915_hw_ppgtt *ppgtt; struct i915_hw_ppgtt *ppgtt;
int err; int err;
ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL); ppgtt = i915_ppgtt_create(i915, NULL, "[alias]");
if (!ppgtt) if (IS_ERR(ppgtt))
return -ENOMEM; return PTR_ERR(ppgtt);
err = __hw_ppgtt_init(ppgtt, i915);
if (err)
goto err_ppgtt;
if (ppgtt->base.allocate_va_range) { if (ppgtt->base.allocate_va_range) {
err = ppgtt->base.allocate_va_range(&ppgtt->base, err = ppgtt->base.allocate_va_range(&ppgtt->base,
0, ppgtt->base.total); 0, ppgtt->base.total);
if (err) if (err)
goto err_ppgtt_cleanup; goto err_ppgtt;
} }
ppgtt->base.clear_range(&ppgtt->base, ppgtt->base.clear_range(&ppgtt->base,
...@@ -2782,10 +2765,8 @@ int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915) ...@@ -2782,10 +2765,8 @@ int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915)
return 0; return 0;
err_ppgtt_cleanup:
ppgtt->base.cleanup(&ppgtt->base);
err_ppgtt: err_ppgtt:
kfree(ppgtt); i915_ppgtt_put(ppgtt);
return err; return err;
} }
...@@ -2798,8 +2779,7 @@ void i915_gem_fini_aliasing_ppgtt(struct drm_i915_private *i915) ...@@ -2798,8 +2779,7 @@ void i915_gem_fini_aliasing_ppgtt(struct drm_i915_private *i915)
if (!ppgtt) if (!ppgtt)
return; return;
ppgtt->base.cleanup(&ppgtt->base); i915_ppgtt_put(ppgtt);
kfree(ppgtt);
ggtt->base.bind_vma = ggtt_bind_vma; ggtt->base.bind_vma = ggtt_bind_vma;
} }
...@@ -2874,21 +2854,21 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv) ...@@ -2874,21 +2854,21 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv)
WARN_ON(i915_vma_unbind(vma)); WARN_ON(i915_vma_unbind(vma));
mutex_unlock(&dev_priv->drm.struct_mutex); mutex_unlock(&dev_priv->drm.struct_mutex);
i915_gem_fini_aliasing_ppgtt(dev_priv);
i915_gem_cleanup_stolen(&dev_priv->drm); 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)) if (drm_mm_node_allocated(&ggtt->error_capture))
drm_mm_remove_node(&ggtt->error_capture); drm_mm_remove_node(&ggtt->error_capture);
if (drm_mm_initialized(&ggtt->base.mm)) { if (drm_mm_initialized(&ggtt->base.mm)) {
intel_vgt_deballoon(dev_priv); intel_vgt_deballoon(dev_priv);
mutex_lock(&dev_priv->drm.struct_mutex);
i915_address_space_fini(&ggtt->base); i915_address_space_fini(&ggtt->base);
mutex_unlock(&dev_priv->drm.struct_mutex);
} }
ggtt->base.cleanup(&ggtt->base); ggtt->base.cleanup(&ggtt->base);
mutex_unlock(&dev_priv->drm.struct_mutex);
arch_phys_wc_del(ggtt->mtrr); arch_phys_wc_del(ggtt->mtrr);
io_mapping_fini(&ggtt->mappable); io_mapping_fini(&ggtt->mappable);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册