gfp_t noreclaim;
int ret;
- /* Assert that the object is not currently in any GPU domain. As it
+ /*
+ * Assert that the object is not currently in any GPU domain. As it
* wasn't in the GTT, there shouldn't be any way it could have been in
* a GPU cache
*/
GEM_BUG_ON(obj->read_domains & I915_GEM_GPU_DOMAINS);
GEM_BUG_ON(obj->write_domain & I915_GEM_GPU_DOMAINS);
+ /*
+ * If there's no chance of allocating enough pages for the whole
+ * object, bail early.
+ */
+ if (page_count > totalram_pages)
+ return -ENOMEM;
+
st = kmalloc(sizeof(*st), GFP_KERNEL);
if (st == NULL)
return -ENOMEM;
return -ENOMEM;
}
- /* Get the list of pages out of our struct file. They'll be pinned
+ /*
+ * Get the list of pages out of our struct file. They'll be pinned
* at this point until we release them.
*
* Fail silently without starting the shrinker
i915_gem_shrink(dev_priv, 2 * page_count, NULL, *s++);
cond_resched();
- /* We've tried hard to allocate the memory by reaping
+ /*
+ * We've tried hard to allocate the memory by reaping
* our own buffer, now let the real VM do its job and
* go down in flames if truly OOM.
*
/* reclaim and warn, but no oom */
gfp = mapping_gfp_mask(mapping);
- /* Our bo are always dirty and so we require
+ /*
+ * Our bo are always dirty and so we require
* kswapd to reclaim our pages (direct reclaim
* does not effectively begin pageout of our
* buffers on its own). However, direct reclaim
ret = i915_gem_gtt_prepare_pages(obj, st);
if (ret) {
- /* DMA remapping failed? One possible cause is that
+ /*
+ * DMA remapping failed? One possible cause is that
* it could not reserve enough large entries, asking
* for PAGE_SIZE chunks instead may be helpful.
*/
sg_free_table(st);
kfree(st);
- /* shmemfs first checks if there is enough memory to allocate the page
+ /*
+ * shmemfs first checks if there is enough memory to allocate the page
* and reports ENOSPC should there be insufficient, along with the usual
* ENOMEM for a genuine allocation failure.
*