As we have a large array of pages to be freed, we can call release_pages() directly and bypass the accumulation of a pagevec. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> --- drivers/gpu/drm/i915/i915_gem.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 80c394b..0633929 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2836,9 +2836,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj, return 0; err_pages: - while (i--) - page_cache_release(pages[i]); - + release_pages(pages, i, 0); return PTR_ERR(page); } @@ -2870,15 +2868,18 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj) if (obj->madv == I915_MADV_DONTNEED) obj->dirty = 0; - for (i = 0; i < page_count; i++) { - if (obj->dirty) - set_page_dirty(obj->pages[i]); - - if (obj->madv == I915_MADV_WILLNEED) - mark_page_accessed(obj->pages[i]); + if (obj->dirty || obj->madv == I915_MADV_WILLNEED) { + for (i = 0; i < page_count; i++) { + if (obj->dirty) + set_page_dirty(obj->pages[i]); - page_cache_release(obj->pages[i]); + if (obj->madv == I915_MADV_WILLNEED) + mark_page_accessed(obj->pages[i]); + } } + release_pages(obj->pages, page_count, + (obj->base.read_domains & I915_GEM_DOMAIN_CPU) == 0); + obj->dirty = 0; return 0; -- 1.7.9.5