8000 drm/i915: make compact dma scatter lists creation work with SWIOTLB b… · codeguru85/linux@426729d · GitHub
[go: up one dir, main page]

Skip to content

Commit 426729d

Browse files
konradwilkairlied
authored andcommitted
drm/i915: make compact dma scatter lists creation work with SWIOTLB backend.
Git commit 90797e6 ("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>
1 parent 0d20299 commit 426729d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,14 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
18011801
gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD;
18021802
gfp &= ~(__GFP_IO | __GFP_WAIT);
18031803
}
1804-
1804+
#ifdef CONFIG_SWIOTLB
1805+
if (swiotlb_nr_tbl()) {
1806+
st->nents++;
1807+
sg_set_page(sg, page, PAGE_SIZE, 0);
1808+
sg = sg_next(sg);
1809+
continue;
1810+
}
1811+
#endif
18051812
if (!i || page_to_pfn(page) != last_pfn + 1) {
18061813
if (i)
18071814
sg = sg_next(sg);
@@ -1812,8 +1819,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
18121819
}
18131820
last_pfn = page_to_pfn(page);
18141821
}
1815-
1816-
sg_mark_end(sg);
1822+
#ifdef CONFIG_SWIOTLB
1823+
if (!swiotlb_nr_tbl())
1824+
#endif
1825+
sg_mark_end(sg);
18171826
obj->pages = st;
18181827

18191828
if (i915_gem_object_needs_bit17_swizzle(obj))

0 commit comments

Comments
 (0)
0