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 gtt stolen calculations
Date: Mon, 21 Jan 2013 14:10:34 -0800	[thread overview]
Message-ID: <1358806236-1143-4-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1358806236-1143-1-git-send-email-ben@bwidawsk.net>

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_drv.h     |  3 +++
 drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4c0e670..d462875 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -369,6 +369,9 @@ struct i915_gtt_operations {
 	int (*gmch_probe)(struct i915_gtt *gtt,
 			  size_t *gtt_total, size_t *stolen);
 	void (*gmch_remove)(struct i915_gtt *gtt);
+
+	/* GEN6+ helpers */
+	size_t (*get_stolen_size)(u16 gmch_ctl);
 };
 
 /* The Graphics Translation Table is the way in which GEN hardware translates a
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index d383add..2f2b1ba 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -707,11 +707,7 @@ static int gen6_gmch_probe(struct i915_gtt *gtt,
 	pci_read_config_word(dev->pdev, SNB_GMCH_CTRL, &snb_gmch_ctl);
 	gtt_size = gen6_get_total_gtt_size(snb_gmch_ctl);
 
-	if (IS_GEN7(dev))
-		*stolen = gen7_get_stolen_size(snb_gmch_ctl);
-	else
-		*stolen = gen6_get_stolen_size(snb_gmch_ctl);
-
+	*stolen = gtt->gtt_ops->get_stolen_size(snb_gmch_ctl);
 	*gtt_total = (gtt_size / sizeof(gtt_pte_t)) << PAGE_SHIFT;
 
 	/* For GEN6+ the PTEs for the ggtt live at 2MB + BAR0 */
@@ -740,6 +736,13 @@ void gen6_gmch_remove(struct i915_gtt *gtt)
 static const struct i915_gtt_operations gen6_gtt_ops = {
 	.gmch_probe = gen6_gmch_probe,
 	.gmch_remove = gen6_gmch_remove,
+	.get_stolen_size = gen6_get_stolen_size,
+};
+
+static const struct i915_gtt_operations gen7_gtt_ops = {
+	.gmch_probe = gen6_gmch_probe,
+	.gmch_remove = gen6_gmch_remove,
+	.get_stolen_size = gen7_get_stolen_size,
 };
 
 static int i915_gmch_probe(struct i915_gtt *gtt,
@@ -792,9 +795,12 @@ int i915_gem_gtt_init(struct drm_device *dev)
 
 	if (INTEL_INFO(dev)->gen <= 5)
 		gtt->gtt_ops = &legacy_gtt_ops;
-	else
+	else if(IS_GEN6(dev))
 		gtt->gtt_ops = &gen6_gtt_ops;
-
+	else if(IS_GEN7(dev))
+		gtt->gtt_ops = &gen7_gtt_ops;
+	else
+		BUG();
 	ret = gtt->gtt_ops->gmch_probe(gtt, &dev_priv->gtt.total,
 				       &dev_priv->gtt.stolen_size);
 	if (ret)
-- 
1.8.1.1

  parent reply	other threads:[~2013-01-21 22:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-21 22:10 [PATCH 0/5 v2] [RFC] GTT vtable Ben Widawsky
2013-01-21 22:10 ` [PATCH 1/5] drm/i915: Create a vtable for i915 gtt Ben Widawsky
2013-01-21 22:10 ` [PATCH 2/5] drm/i915: Resume dissecting intel_gtt Ben Widawsky
2013-01-21 22:10 ` Ben Widawsky [this message]
2013-01-21 22:10 ` [PATCH 4/5] drm/i915: Extract clear_range to gtt_ops Ben Widawsky
2013-01-21 22:10 ` [PATCH 5/5] drm/i915: Extract bind object Ben Widawsky
2013-01-23 11:03 ` [PATCH 0/5 v2] [RFC] GTT vtable Chris Wilson
2013-01-23 11:39   ` Daniel Vetter
2013-01-23 13:07     ` 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=1358806236-1143-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.