All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guo DeshuiX <deshuix.guo@intel.com>
To: deshuix.guo@linux.intel.com
Cc: Guo DeshuiX <deshuix.guo@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Subject: [patch 22/24] OTC Port: drm/i915: make compact dma scatter lists creation work with SWIOTLB backend.
Date: Fri, 25 Apr 2014 18:00:07 +0800	[thread overview]
Message-ID: <1398420009-15627-22-git-send-email-deshuix.guo@intel.com> (raw)
In-Reply-To: <1398420009-15627-1-git-send-email-deshuix.guo@intel.com>

OTC Commit: 426729dcc713b3d1ae802e314030e5556a62da53

Git commit 90797e6d1ec0dfde6ba62a48b9ee3803887d6ed4
("drm/i915: create compact dma scatter lists for gem objects") makes
certain assumptions about the under laying DMA API that are not always
correct.

On a ThinkPad X230 with an Intel HD 4000 with Xen during the bootup
I see:

[drm:intel_pipe_set_base] *ERROR* pin & fence failed
[drm:intel_crtc_set_config] *ERROR* failed to set mode on [CRTC:3], err = -28

Bit of debugging traced it down to dma_map_sg failing (in
i915_gem_gtt_prepare_object) as some of the SG entries were huge (3MB).

That unfortunately are sizes that the SWIOTLB is incapable of handling -
the maximum it can handle is a an entry of 512KB of virtual contiguous
memory for its bounce buffer. (See IO_TLB_SEGSIZE).

Previous to the above mention git commit the SG entries were of 4KB, and
the code introduced by above git commit squashed the CPU contiguous PFNs
in one big virtual address provided to DMA API.

This patch is a simple semi-revert - were we emulate the old behavior
if we detect that SWIOTLB is online. If it is not online then we continue
on with the new compact scatter gather mechanism.

An alternative solution would be for the the '.get_pages' and the
i915_gem_gtt_prepare_object to retry with smaller max gap of the
amount of PFNs that can be combined together - but with this issue
discovered during rc7 that might be too risky.

Reported-and-Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Chris Wilson <chris@chris-wilson.co.uk>
CC: Imre Deak <imre.deak@intel.com>
CC: Daniel Vetter <daniel.vetter@ffwll.ch>
CC: David Airlie <airlied@linux.ie>
CC: <dri-devel@lists.freedesktop.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Guo DeshuiX <deshuix.guo@intel.com>
---
 src/core/i915/i915_gem.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/core/i915/i915_gem.c b/src/core/i915/i915_gem.c
index 1b850d4..8e4327b 100644
--- a/src/core/i915/i915_gem.c
+++ b/src/core/i915/i915_gem.c
@@ -1898,6 +1898,14 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 #if (LTSI_VERSION <= KERNEL_VERSION(3, 10, 0))
 		sg_set_page(sg, page, PAGE_SIZE, 0);
 #else
+#ifdef CONFIG_SWIOTLB
+	if (swiotlb_nr_tbl()) {
+		st->nents++;
+		sg_set_page(sg, page, PAGE_SIZE, 0);
+		sg = sg_next(sg);
+		continue;
+		}
+#endif
 		if (!i || page_to_pfn(page) != last_pfn + 1) {
 			if (i)
 				sg = sg_next(sg);
@@ -1911,7 +1919,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 	}
 
 #if (LTSI_VERSION >= KERNEL_VERSION(3, 10, 0))
-	sg_mark_end(sg);
+#ifdef CONFIG_SWIOTLB
+	if (!swiotlb_nr_tbl())
+#endif
+		sg_mark_end(sg);
 #endif
 	obj->pages = st;
 
-- 
1.7.4.4

       reply	other threads:[~2014-04-25 10:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1398420009-15627-1-git-send-email-deshuix.guo@intel.com>
2014-04-25 10:00 ` Guo DeshuiX [this message]
     [not found] <1398669979-3146-1-git-send-email-deshuix.guo@intel.com>
2014-04-28  7:26 ` [patch 22/24] OTC Port: drm/i915: make compact dma scatter lists creation work with SWIOTLB backend Guo DeshuiX

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=1398420009-15627-22-git-send-email-deshuix.guo@intel.com \
    --to=deshuix.guo@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=deshuix.guo@linux.intel.com \
    --cc=dri-devel@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.