提交 d6660add 编写于 作者: B Ben Widawsky 提交者: Daniel Vetter

drm/i915: Generalize PPGTT init

Rearrange the initialization code to try to special case the aliasing
PPGTT less, and provide usable interfaces for the general case later.
Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 90252e5c
...@@ -888,15 +888,11 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ...@@ -888,15 +888,11 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
return ret; return ret;
} }
static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) static int i915_gem_init_ppgtt(struct drm_device *dev,
struct i915_hw_ppgtt *ppgtt)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_hw_ppgtt *ppgtt; int ret = 0;
int ret;
ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
if (!ppgtt)
return -ENOMEM;
ppgtt->base.dev = dev; ppgtt->base.dev = dev;
...@@ -907,13 +903,9 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ...@@ -907,13 +903,9 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
else else
BUG(); BUG();
if (ret) if (!ret)
kfree(ppgtt);
else {
dev_priv->mm.aliasing_ppgtt = ppgtt;
drm_mm_init(&ppgtt->base.mm, ppgtt->base.start, drm_mm_init(&ppgtt->base.mm, ppgtt->base.start,
ppgtt->base.total); ppgtt->base.total);
}
return ret; return ret;
} }
...@@ -1430,10 +1422,22 @@ void i915_gem_init_global_gtt(struct drm_device *dev) ...@@ -1430,10 +1422,22 @@ void i915_gem_init_global_gtt(struct drm_device *dev)
i915_gem_setup_global_gtt(dev, 0, mappable_size, gtt_size); i915_gem_setup_global_gtt(dev, 0, mappable_size, gtt_size);
if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) { if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
struct i915_hw_ppgtt *ppgtt;
int ret; int ret;
ret = i915_gem_init_aliasing_ppgtt(dev); ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
if (ret) if (!ppgtt) {
DRM_ERROR("Aliased PPGTT setup failed -ENOMEM\n");
return;
}
ret = i915_gem_init_ppgtt(dev, ppgtt);
if (!ret) {
dev_priv->mm.aliasing_ppgtt = ppgtt;
return;
}
kfree(ppgtt);
DRM_ERROR("Aliased PPGTT setup failed %d\n", ret); DRM_ERROR("Aliased PPGTT setup failed %d\n", ret);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册