Commit 6cde9a02 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Extract aliasing ppgtt setup

In order to force testing of the aliasing ppgtt, extract its
initialisation function.

v2: Also extract the cleanup function for symmetry.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170213171558.20942-39-chris@chris-wilson.co.uk
parent 791ff39a
...@@ -2738,6 +2738,59 @@ static void i915_gtt_color_adjust(const struct drm_mm_node *node, ...@@ -2738,6 +2738,59 @@ static void i915_gtt_color_adjust(const struct drm_mm_node *node,
*end -= I915_GTT_PAGE_SIZE; *end -= I915_GTT_PAGE_SIZE;
} }
int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915)
{
struct i915_ggtt *ggtt = &i915->ggtt;
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;
if (ppgtt->base.allocate_va_range) {
err = ppgtt->base.allocate_va_range(&ppgtt->base,
0, ppgtt->base.total);
if (err)
goto err_ppgtt_cleanup;
}
ppgtt->base.clear_range(&ppgtt->base,
ppgtt->base.start,
ppgtt->base.total);
i915->mm.aliasing_ppgtt = ppgtt;
WARN_ON(ggtt->base.bind_vma != ggtt_bind_vma);
ggtt->base.bind_vma = aliasing_gtt_bind_vma;
return 0;
err_ppgtt_cleanup:
ppgtt->base.cleanup(&ppgtt->base);
err_ppgtt:
kfree(ppgtt);
return err;
}
void i915_gem_fini_aliasing_ppgtt(struct drm_i915_private *i915)
{
struct i915_ggtt *ggtt = &i915->ggtt;
struct i915_hw_ppgtt *ppgtt;
ppgtt = fetch_and_zero(&i915->mm.aliasing_ppgtt);
if (!ppgtt)
return;
ppgtt->base.cleanup(&ppgtt->base);
kfree(ppgtt);
ggtt->base.bind_vma = ggtt_bind_vma;
}
int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)
{ {
/* Let GEM Manage all of the aperture. /* Let GEM Manage all of the aperture.
...@@ -2751,7 +2804,6 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) ...@@ -2751,7 +2804,6 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)
*/ */
struct i915_ggtt *ggtt = &dev_priv->ggtt; struct i915_ggtt *ggtt = &dev_priv->ggtt;
unsigned long hole_start, hole_end; unsigned long hole_start, hole_end;
struct i915_hw_ppgtt *ppgtt;
struct drm_mm_node *entry; struct drm_mm_node *entry;
int ret; int ret;
...@@ -2780,38 +2832,13 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) ...@@ -2780,38 +2832,13 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)
ggtt->base.total - PAGE_SIZE, PAGE_SIZE); ggtt->base.total - PAGE_SIZE, PAGE_SIZE);
if (USES_PPGTT(dev_priv) && !USES_FULL_PPGTT(dev_priv)) { if (USES_PPGTT(dev_priv) && !USES_FULL_PPGTT(dev_priv)) {
ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL); ret = i915_gem_init_aliasing_ppgtt(dev_priv);
if (!ppgtt) {
ret = -ENOMEM;
goto err;
}
ret = __hw_ppgtt_init(ppgtt, dev_priv);
if (ret)
goto err_ppgtt;
if (ppgtt->base.allocate_va_range) {
ret = ppgtt->base.allocate_va_range(&ppgtt->base, 0,
ppgtt->base.total);
if (ret) if (ret)
goto err_ppgtt_cleanup; goto err;
}
ppgtt->base.clear_range(&ppgtt->base,
ppgtt->base.start,
ppgtt->base.total);
dev_priv->mm.aliasing_ppgtt = ppgtt;
WARN_ON(ggtt->base.bind_vma != ggtt_bind_vma);
ggtt->base.bind_vma = aliasing_gtt_bind_vma;
} }
return 0; return 0;
err_ppgtt_cleanup:
ppgtt->base.cleanup(&ppgtt->base);
err_ppgtt:
kfree(ppgtt);
err: err:
drm_mm_remove_node(&ggtt->error_capture); drm_mm_remove_node(&ggtt->error_capture);
return ret; return ret;
...@@ -2834,12 +2861,7 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv) ...@@ -2834,12 +2861,7 @@ 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);
if (dev_priv->mm.aliasing_ppgtt) { i915_gem_fini_aliasing_ppgtt(dev_priv);
struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
ppgtt->base.cleanup(&ppgtt->base);
kfree(ppgtt);
}
i915_gem_cleanup_stolen(&dev_priv->drm); i915_gem_cleanup_stolen(&dev_priv->drm);
if (drm_mm_node_allocated(&ggtt->error_capture)) if (drm_mm_node_allocated(&ggtt->error_capture))
......
...@@ -531,6 +531,9 @@ i915_vm_is_48bit(const struct i915_address_space *vm) ...@@ -531,6 +531,9 @@ i915_vm_is_48bit(const struct i915_address_space *vm)
return (vm->total - 1) >> 32; return (vm->total - 1) >> 32;
} }
int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915);
void i915_gem_fini_aliasing_ppgtt(struct drm_i915_private *i915);
int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv); int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv);
int i915_ggtt_init_hw(struct drm_i915_private *dev_priv); int i915_ggtt_init_hw(struct drm_i915_private *dev_priv);
int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv); int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment