public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/i915: Translate ENOSPC from shmem_get_page() to ENOMEM
@ 2014-03-25 13:23 Chris Wilson
  2014-03-25 13:23 ` [PATCH 2/4] drm/i915: Include bound and active pages in the count of shrinkable objects Chris Wilson
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Chris Wilson @ 2014-03-25 13:23 UTC (permalink / raw)
  To: intel-gfx; +Cc: Hugh Dickins

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.

We use ENOSPC in our driver to mean that we have run out of aperture
space and so want to translate the error from shmemfs back to
our usual understanding of ENOMEM. None of the the other GEM users
appear to distinguish between ENOMEM and ENOSPC in their error handling,
hence it is easiest to do the fixup in i915.ko

Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 33bbaa0d4412..c23034021753 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1976,7 +1976,19 @@ err_pages:
 		page_cache_release(sg_page_iter_page(&sg_iter));
 	sg_free_table(st);
 	kfree(st);
-	return PTR_ERR(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.
+	 *
+	 * We use ENOSPC in our driver to mean that we have run out of aperture
+	 * space and so want to translate the error from shmemfs back to our
+	 * usual understanding of ENOMEM.
+	 */
+	if (PTR_ERR(page) == -ENOSPC)
+		return -ENOMEM;
+	else
+		return PTR_ERR(page);
 }
 
 /* Ensure that the associated pages are gathered from the backing storage
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-05-20  8:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 13:23 [PATCH 1/4] drm/i915: Translate ENOSPC from shmem_get_page() to ENOMEM Chris Wilson
2014-03-25 13:23 ` [PATCH 2/4] drm/i915: Include bound and active pages in the count of shrinkable objects Chris Wilson
2014-05-19 16:04   ` Barbalho, Rafael
2014-03-25 13:23 ` [PATCH 3/4] drm/i915: Refactor common lock handling between shrinker count/scan Chris Wilson
2014-05-19 16:05   ` Barbalho, Rafael
2014-03-25 13:23 ` [PATCH 4/4] drm/i915: Invalidate our pages under memory pressure Chris Wilson
2014-04-11  8:30   ` Chris Wilson
2014-04-11  8:38     ` Daniel Vetter
2014-04-11  8:46       ` Chris Wilson
2014-04-16 17:13   ` Robert Beckett
2014-04-17 16:34     ` Jani Nikula
2014-04-22 19:06       ` Daniel Vetter
2014-04-22 23:23         ` Robert Beckett
2014-05-19 16:07   ` Barbalho, Rafael
2014-05-20  7:53   ` Daniel Vetter
2014-05-20  7:56     ` Chris Wilson
2014-05-20  8:12       ` Daniel Vetter
2014-05-19 16:03 ` [PATCH 1/4] drm/i915: Translate ENOSPC from shmem_get_page() to ENOMEM Barbalho, Rafael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox