@@ -1709,20 +1709,20 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
struct drm_file *file);
/* i915_gem_gtt.c */
+bool intel_enable_ppgtt(struct drm_device *dev);
+int i915_gem_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
void i915_gem_cleanup_aliasing_ppgtt(struct drm_device *dev);
void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,
struct drm_i915_gem_object *obj,
enum i915_cache_level cache_level);
void i915_ppgtt_unbind_object(struct i915_hw_ppgtt *ppgtt,
struct drm_i915_gem_object *obj);
-
void i915_gem_restore_gtt_mappings(struct drm_device *dev);
int __must_check i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj);
void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj,
enum i915_cache_level cache_level);
void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj);
void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj);
-void i915_gem_init_global_gtt(struct drm_device *dev);
void i915_gem_setup_global_gtt(struct drm_device *dev, unsigned long start,
unsigned long mappable_end, unsigned long end,
bool guard_page);
@@ -4057,7 +4057,7 @@ i915_gem_init_hw(struct drm_device *dev)
int i915_gem_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
- int ret;
+ int ret = -ENOMEM;
mutex_lock(&dev->struct_mutex);
@@ -4068,9 +4068,32 @@ int i915_gem_init(struct drm_device *dev)
DRM_DEBUG_DRIVER("allow wake ack timed out\n");
}
- i915_gem_init_global_gtt(dev);
+ if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
+ struct i915_hw_ppgtt *ppgtt;
+ ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
+ if (!ppgtt)
+ goto ggtt_only;
+
+
+ i915_gem_setup_global_gtt(dev, 0, dev_priv->gtt.mappable_end,
+ dev_priv->gtt.total, false);
+ i915_gem_context_init(dev);
+ ret = i915_gem_ppgtt_init(dev, ppgtt);
+ if (ret) {
+ kfree(ppgtt);
+ drm_mm_takedown(&dev_priv->mm.gtt_space);
+ goto ggtt_only;
+ }
+
+ dev_priv->mm.aliasing_ppgtt = ppgtt;
+ }
- i915_gem_context_init(dev);
+ggtt_only:
+ if (ret) {
+ DRM_ERROR("Aliased PPGTT setup failed %d\n", ret);
+ i915_gem_setup_global_gtt(dev, 0, dev_priv->gtt.mappable_end,
+ dev_priv->gtt.total, true);
+ }
ret = i915_gem_init_hw(dev);
mutex_unlock(&dev->struct_mutex);
@@ -589,7 +589,7 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node,
}
}
-static bool intel_enable_ppgtt(struct drm_device *dev)
+bool intel_enable_ppgtt(struct drm_device *dev)
{
if (i915_enable_ppgtt >= 0)
return i915_enable_ppgtt;
@@ -664,46 +664,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
dev_priv->gtt.gtt_clear_range(dev, end / PAGE_SIZE - 1, 1);
}
-void i915_gem_init_global_gtt(struct drm_device *dev)
-{
- struct drm_i915_private *dev_priv = dev->dev_private;
- unsigned long gtt_size, mappable_size;
- int ret = 0;
-
- gtt_size = dev_priv->gtt.total;
- mappable_size = dev_priv->gtt.mappable_end;
-
- if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
- struct i915_hw_ppgtt *ppgtt;
-
- i915_gem_setup_global_gtt(dev, 0, mappable_size, gtt_size, false);
-
- ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
- if (!ppgtt) {
- ret = -ENOMEM;
- goto ggtt_only;
- }
-
- ret = i915_gem_ppgtt_init(dev, ppgtt);
- if (ret)
- goto ggtt_only;
- dev_priv->mm.aliasing_ppgtt = ppgtt;
-
- return;
- }
-
-/* XXX: We need to takedown the drm_mm and have this fall back because of the
- * conditional use of the guard page.
- * TODO: It's a bit hackish and could use cleanup.
- */
-ggtt_only:
- if (ret) {
- DRM_ERROR("Aliased PPGTT setup failed %d\n", ret);
- drm_mm_takedown(&dev_priv->mm.gtt_space);
- }
- i915_gem_setup_global_gtt(dev, 0, mappable_size, gtt_size, true);
-}
-
static int setup_scratch_page(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
The resulting code isn't a huge improvement, but that will change in the next patch (at least a bit). Signed-off-by: Ben Widawsky <ben@bwidawsk.net> --- drivers/gpu/drm/i915/i915_drv.h | 4 ++-- drivers/gpu/drm/i915/i915_gem.c | 29 ++++++++++++++++++++++--- drivers/gpu/drm/i915/i915_gem_gtt.c | 42 +------------------------------------ 3 files changed, 29 insertions(+), 46 deletions(-)