All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <benjamin.widawsky@intel.com>
To: Intel GFX <intel-gfx@lists.freedesktop.org>
Cc: Ben Widawsky <ben@bwidawsk.net>,
	Ben Widawsky <benjamin.widawsky@intel.com>
Subject: [PATCH 4/4] drm/i915: Reserve space for FBC (fbcon)
Date: Thu, 19 Jun 2014 12:06:13 -0700	[thread overview]
Message-ID: <1403204773-7112-4-git-send-email-benjamin.widawsky@intel.com> (raw)
In-Reply-To: <1403204773-7112-1-git-send-email-benjamin.widawsky@intel.com>

This is one part in a few fixes needed to make FBC work with limited
stolen memory and large resolution displays. It is not the full
solution, but one (easy) step.

The patch is straight-forward, it attempts to check there will be room
for FBC before trying to "reclaim"

This modifies behavior originally introduced:
commit 0ffb0ff283cca16f72caf29c44496d83b0c291fb
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Nov 15 11:32:27 2012 +0000

    drm/i915: Allocate fbcon from stolen memory

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/intel_fbdev.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 27975c3..ca83af8 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -57,6 +57,36 @@ static struct fb_ops intelfb_ops = {
 	.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
+static bool intelfb_use_stolen(struct drm_device *dev, struct drm_mm *mm,
+			       int size)
+{
+	struct drm_mm_node *entry;
+	unsigned long adj_start;
+	unsigned long adj_end;
+
+	if (!drm_mm_initialized(mm))
+		return false;
+
+	if (!HAS_FBC(dev))
+		return true;
+
+	/* It is more desirable to use FBC (if enabled) than to allocate the
+	 * framebuffer from stolen. We can cheat this by rounding up the size by
+	 * 2 (and hope to get lucky with alignment). The other options are more
+	 * invasive, and arguably not any more effective.
+	 */
+	size *= 2;
+	__drm_mm_for_each_hole(entry, mm, adj_start, adj_end,
+			       DRM_MM_SEARCH_DEFAULT) {
+		if (adj_end - adj_start < size)
+			continue;
+
+		if (adj_end >= adj_start + size)
+			return true;
+	}
+
+	return false;
+}
 static int intelfb_alloc(struct drm_fb_helper *helper,
 			 struct drm_fb_helper_surface_size *sizes)
 {
@@ -64,8 +94,9 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
 		container_of(helper, struct intel_fbdev, helper);
 	struct drm_framebuffer *fb;
 	struct drm_device *dev = helper->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_mode_fb_cmd2 mode_cmd = {};
-	struct drm_i915_gem_object *obj;
+	struct drm_i915_gem_object *obj = NULL;
 	int size, ret;
 
 	/* we don't do packed 24bpp */
@@ -82,7 +113,9 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
 
 	size = mode_cmd.pitches[0] * mode_cmd.height;
 	size = ALIGN(size, PAGE_SIZE);
-	obj = i915_gem_object_create_stolen(dev, size);
+
+	if (intelfb_use_stolen(dev, &dev_priv->mm.stolen, size))
+		obj = i915_gem_object_create_stolen(dev, size);
 	if (obj == NULL)
 		obj = i915_gem_alloc_object(dev, size);
 	if (!obj) {
-- 
2.0.0

  parent reply	other threads:[~2014-06-19 19:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 19:06 [PATCH 1/4] drm/i915: Move compressed_fb to static allocation Ben Widawsky
2014-06-19 19:06 ` [PATCH 2/4] drm/i915: Extract CFB threshold calculation Ben Widawsky
2014-07-01  0:16   ` Rodrigo Vivi
2014-06-19 19:06 ` [PATCH 3/4] drm/i915: Try harder to get FBC Ben Widawsky
2014-06-20 15:56   ` Runyan, Arthur J
2014-06-20 16:55     ` Ben Widawsky
2014-06-30 17:41       ` [PATCH] " Rodrigo Vivi
2014-07-01 16:09         ` Rodrigo Vivi
2014-07-03 11:52           ` Jani Nikula
2014-06-19 19:06 ` Ben Widawsky [this message]
2014-06-19 19:28   ` [PATCH 4/4] drm/i915: Reserve space for FBC (fbcon) Chris Wilson
2014-06-19 19:41     ` Ben Widawsky
2014-07-01  3:34     ` Ben Widawsky
2014-07-01  0:15 ` [PATCH 1/4] drm/i915: Move compressed_fb to static allocation Rodrigo Vivi

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=1403204773-7112-4-git-send-email-benjamin.widawsky@intel.com \
    --to=benjamin.widawsky@intel.com \
    --cc=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.