Skip to content

Commit

Permalink
drm/i915: Limit the scattergather coalescing to 32bits
Browse files Browse the repository at this point in the history
The scattergather list uses a 32bit size counter, we should avoid
exceeding it.

v2: Also we should use unsigned int to match sg->length.

Fixes: 871dfbd ("drm/i915: Allow compaction upto SWIOTLB max segment size")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161018120251.25043-3-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Oct 18, 2016
1 parent b4bcbe2 commit 4ff340f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
return 0;
}

static unsigned long swiotlb_max_size(void)
static unsigned int swiotlb_max_size(void)
{
#if IS_ENABLED(CONFIG_SWIOTLB)
return rounddown(swiotlb_nr_tbl() << IO_TLB_SHIFT, PAGE_SIZE);
Expand All @@ -2225,7 +2225,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
struct sgt_iter sgt_iter;
struct page *page;
unsigned long last_pfn = 0; /* suppress gcc warning */
unsigned long max_segment;
unsigned int max_segment;
int ret;
gfp_t gfp;

Expand All @@ -2238,7 +2238,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)

max_segment = swiotlb_max_size();
if (!max_segment)
max_segment = obj->base.size;
max_segment = rounddown(UINT_MAX, PAGE_SIZE);

st = kmalloc(sizeof(*st), GFP_KERNEL);
if (st == NULL)
Expand Down

0 comments on commit 4ff340f

Please sign in to comment.