diff options
-rw-r--r-- | drivers/gpu/drm/i915/selftests/scatterlist.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/selftests/scatterlist.c b/drivers/gpu/drm/i915/selftests/scatterlist.c index eb2cda8e2b9f..1cc5d2931753 100644 --- a/drivers/gpu/drm/i915/selftests/scatterlist.c +++ b/drivers/gpu/drm/i915/selftests/scatterlist.c | |||
@@ -189,6 +189,13 @@ static unsigned int random(unsigned long n, | |||
189 | return 1 + (prandom_u32_state(rnd) % 1024); | 189 | return 1 + (prandom_u32_state(rnd) % 1024); |
190 | } | 190 | } |
191 | 191 | ||
192 | static inline bool page_contiguous(struct page *first, | ||
193 | struct page *last, | ||
194 | unsigned long npages) | ||
195 | { | ||
196 | return first + npages == last; | ||
197 | } | ||
198 | |||
192 | static int alloc_table(struct pfn_table *pt, | 199 | static int alloc_table(struct pfn_table *pt, |
193 | unsigned long count, unsigned long max, | 200 | unsigned long count, unsigned long max, |
194 | npages_fn_t npages_fn, | 201 | npages_fn_t npages_fn, |
@@ -216,7 +223,9 @@ static int alloc_table(struct pfn_table *pt, | |||
216 | unsigned long npages = npages_fn(n, count, rnd); | 223 | unsigned long npages = npages_fn(n, count, rnd); |
217 | 224 | ||
218 | /* Nobody expects the Sparse Memmap! */ | 225 | /* Nobody expects the Sparse Memmap! */ |
219 | if (pfn_to_page(pfn + npages) != pfn_to_page(pfn) + npages) { | 226 | if (!page_contiguous(pfn_to_page(pfn), |
227 | pfn_to_page(pfn + npages), | ||
228 | npages)) { | ||
220 | sg_free_table(&pt->st); | 229 | sg_free_table(&pt->st); |
221 | return -ENOSPC; | 230 | return -ENOSPC; |
222 | } | 231 | } |