From: Ben Widawsky <ben@bwidawsk.net>
To: Intel GFX <intel-gfx@lists.freedesktop.org>
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 10/12] drm/i915: destroy i915_gem_init_global_gtt
Date: Tue, 23 Apr 2013 23:15:38 -0700 [thread overview]
Message-ID: <1366784140-2670-11-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1366784140-2670-1-git-send-email-ben@bwidawsk.net>
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(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 11cc159..9f984cf 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index fbd289d..24f3aef 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -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);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 39ac37d..0598c6d 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -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;
--
1.8.2.1
next prev parent reply other threads:[~2013-04-24 6:13 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 6:15 [PATCH 00/12] [RFC] PPGTT prep patches part 1 Ben Widawsky
2013-04-24 6:15 ` [PATCH 01/12] drm/i915: Assert mutex_is_locked on context lookup Ben Widawsky
2013-05-02 20:27 ` Jesse Barnes
2013-05-06 9:40 ` Daniel Vetter
2013-05-06 9:44 ` Daniel Vetter
2013-05-06 17:59 ` Ben Widawsky
2013-05-06 18:35 ` Daniel Vetter
2013-04-24 6:15 ` [PATCH 02/12] drm/i915: BUG_ON bad PPGTT offset Ben Widawsky
2013-05-02 20:28 ` Jesse Barnes
2013-05-06 9:48 ` Daniel Vetter
2013-05-06 18:03 ` Ben Widawsky
2013-05-06 18:37 ` Daniel Vetter
2013-05-08 16:48 ` Ben Widawsky
2013-05-08 17:55 ` Daniel Vetter
2013-04-24 6:15 ` [PATCH 03/12] drm/i915: make PDE|PTE platform specific Ben Widawsky
2013-05-02 21:26 ` Jesse Barnes
2013-05-02 22:49 ` Ben Widawsky
2013-05-02 22:55 ` Jesse Barnes
2013-05-06 9:47 ` Daniel Vetter
2013-05-08 16:49 ` Ben Widawsky
2013-05-08 17:52 ` Daniel Vetter
2013-04-24 6:15 ` [PATCH 04/12] drm/i915: Extract PDE writes Ben Widawsky
2013-05-02 21:27 ` Jesse Barnes
2013-05-06 9:50 ` Daniel Vetter
2013-04-24 6:15 ` [PATCH 05/12] drm: Optionally create mm blocks from top-to-bottom Ben Widawsky
2013-04-24 6:15 ` [PATCH 06/12] drm/i915: Use drm_mm for PPGTT PDEs Ben Widawsky
2013-05-02 21:42 ` Jesse Barnes
2013-04-24 6:15 ` [PATCH 07/12] drm/i915: Use PDEs as the guard page Ben Widawsky
2013-04-24 6:15 ` [PATCH 08/12] drm/i915: Update context_fini Ben Widawsky
2013-04-24 15:11 ` Mika Kuoppala
2013-04-25 4:11 ` Ben Widawsky
2013-04-25 5:17 ` Ben Widawsky
2013-04-25 15:01 ` Mika Kuoppala
2013-04-25 17:22 ` Ben Widawsky
2013-04-24 6:15 ` [PATCH 09/12] drm/i915: Split context enabling from init Ben Widawsky
2013-04-24 10:04 ` Chris Wilson
2013-04-24 16:39 ` Ben Widawsky
2013-04-24 6:15 ` Ben Widawsky [this message]
2013-04-24 6:15 ` [PATCH 11/12] drm/i915: Embed PPGTT into the context Ben Widawsky
2013-04-24 6:15 ` [PATCH 12/12] drm/i915: No contexts without ppgtt Ben Widawsky
2013-04-24 10:06 ` Chris Wilson
2013-04-24 16:39 ` Ben Widawsky
2013-04-24 9:53 ` [PATCH 00/12] [RFC] PPGTT prep patches part 1 Chris Wilson
2013-04-24 19:58 ` Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366784140-2670-11-git-send-email-ben@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox