|
@@ -1341,9 +1341,14 @@ int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
|
|
|
static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n)
|
|
|
{
|
|
|
struct scatterlist *sg = obj->pages->sgl;
|
|
|
- while (n >= SG_MAX_SINGLE_ALLOC) {
|
|
|
+ int nents = obj->pages->nents;
|
|
|
+ while (nents > SG_MAX_SINGLE_ALLOC) {
|
|
|
+ if (n < SG_MAX_SINGLE_ALLOC - 1)
|
|
|
+ break;
|
|
|
+
|
|
|
sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1);
|
|
|
n -= SG_MAX_SINGLE_ALLOC - 1;
|
|
|
+ nents -= SG_MAX_SINGLE_ALLOC - 1;
|
|
|
}
|
|
|
return sg_page(sg+n);
|
|
|
}
|