diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-03-20 05:40:28 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-03-21 06:22:42 -0400 |
commit | 272bce17cc3ef4629e28c38324d81ca72a862115 (patch) | |
tree | 3dcb276aafa7b76bbaedc19c971afa23990d00bb | |
parent | 24caf6559393f68eeefa39faf8c47c0d51a63cee (diff) |
drm/i915: split out check for noncontiguous pfn range
We get a warning with gcc-7 about a pointless comparison when
using a linear memmap:
drivers/gpu/drm/i915/selftests/scatterlist.c: In function 'alloc_table':
drivers/gpu/drm/i915/selftests/scatterlist.c:219:66: error: self-comparison always evaluates to false [-Werror=tautological-compare]
Splitting out the comparison into a separate function avoids the warning
and makes it slightly more obvious what happens.
Fixes: 935a2f776aa5 ("drm/i915: Add some selftests for sg_table manipulation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20170320094335.1266306-2-arnd@arndb.de
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-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 | } |