All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 3/5] drm/i915: Extract gen6 aliasing ppgtt code
Date: Fri, 25 Jan 2013 16:41:05 -0800	[thread overview]
Message-ID: <1359160867-780-4-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1359160867-780-1-git-send-email-ben@bwidawsk.net>

This refactor clearly identifies the GEN specific portion of the aliased
ppgtt code. Aside from some of the gen specific parts being extracted,
it also preps us for an upcoming patch that pulls out the size, which
has some nice benefits.

v2: Fix wonky error handling (Chris)

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 42 ++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 31c490e..f79f427 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -108,10 +108,10 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt,
 	}
 }
 
-static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
+static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)
 {
+	struct drm_device *dev = ppgtt->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct i915_hw_ppgtt *ppgtt;
 	unsigned first_pd_entry_in_global_pt;
 	int i;
 	int ret = -ENOMEM;
@@ -121,16 +121,12 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
 	 * now. */
 	first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - I915_PPGTT_PD_ENTRIES;
 
-	ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
-	if (!ppgtt)
-		return ret;
-
-	ppgtt->dev = dev;
 	ppgtt->num_pd_entries = I915_PPGTT_PD_ENTRIES;
 	ppgtt->pt_pages = kzalloc(sizeof(struct page *)*ppgtt->num_pd_entries,
 				  GFP_KERNEL);
+
 	if (!ppgtt->pt_pages)
-		goto err_ppgtt;
+		return -ENOMEM;
 
 	for (i = 0; i < ppgtt->num_pd_entries; i++) {
 		ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL);
@@ -157,15 +153,11 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
 		ppgtt->pt_dma_addr[i] = pt_addr;
 	}
 
-	ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma;
-
 	i915_ppgtt_clear_range(ppgtt, 0,
 			       ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES);
 
 	ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof(gtt_pte_t);
 
-	dev_priv->mm.aliasing_ppgtt = ppgtt;
-
 	return 0;
 
 err_pd_pin:
@@ -180,9 +172,31 @@ err_pt_alloc:
 		if (ppgtt->pt_pages[i])
 			__free_page(ppgtt->pt_pages[i]);
 	}
+
 	kfree(ppgtt->pt_pages);
-err_ppgtt:
-	kfree(ppgtt);
+
+	return ret;
+}
+
+
+static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct i915_hw_ppgtt *ppgtt;
+	int ret = -ENOMEM;
+
+	ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
+	if (!ppgtt)
+		return ret;
+
+	ppgtt->dev = dev;
+	ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma;
+
+	ret = gen6_init_aliasing_ppgtt(ppgtt);
+	if (ret)
+		kfree(ppgtt);
+	else
+		dev_priv->mm.aliasing_ppgtt = ppgtt;
 
 	return ret;
 }
-- 
1.8.1.1

  parent reply	other threads:[~2013-01-26  0:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-26  0:41 [PATCH 0/5] [REPOST] GTT cleanups, rebased Ben Widawsky
2013-01-26  0:41 ` [PATCH 1/5] drm/i915: trivial: kill-agp collateral cleanups Ben Widawsky
2013-01-29 12:49   ` Daniel Vetter
2013-01-29 18:58     ` Ben Widawsky
2013-01-26  0:41 ` [PATCH 2/5] drm/i915: Reclaim GTT space for failed PPGTT Ben Widawsky
2013-01-29 12:51   ` Daniel Vetter
2013-01-26  0:41 ` Ben Widawsky [this message]
2013-01-29 12:55   ` [PATCH 3/5] drm/i915: Extract gen6 aliasing ppgtt code Daniel Vetter
2013-01-29 19:00     ` Ben Widawsky
2013-01-26  0:41 ` [PATCH 4/5] drm/i915: Aliased PPGTT size abstraction Ben Widawsky
2013-01-28 12:19   ` Jani Nikula
2013-01-28 18:26     ` Ben Widawsky
2013-01-28 18:31       ` Daniel Vetter
2013-01-28 20:35   ` [PATCH 4/5 v2] " Ben Widawsky
2013-01-29 12:58     ` Daniel Vetter
2013-01-26  0:41 ` [PATCH 5/5] drm/i915: Dynamically calculate dclv Ben Widawsky
2013-01-28 12:20   ` Jani Nikula
2013-01-28 20:36   ` Ben Widawsky
2013-01-28 21:08   ` Daniel Vetter
2013-01-28 12:24 ` [PATCH 0/5] [REPOST] GTT cleanups, rebased Jani Nikula
  -- strict thread matches above, loose matches on Subject: below --
2012-12-29  4:27 [PATCH 1/5] drm/i915: trivial: kill-agp collateral cleanups Ben Widawsky
2012-12-29  4:27 ` [PATCH 3/5] drm/i915: Extract gen6 aliasing ppgtt code Ben Widawsky
2012-12-29 11:49   ` Chris Wilson
2012-12-29 19:45     ` Ben Widawsky
2012-12-29 23:44       ` 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=1359160867-780-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.