Re: [Intel-gfx] [PATCH 1/4] drm/i915: Translate ENOSPC from shmem_get_page() to ENOMEM

2014-05-19 Thread Barbalho, Rafael
 -Original Message-
 From: Intel-gfx [mailto:intel-gfx-boun...@lists.freedesktop.org] On Behalf
 Of Chris Wilson
 Sent: Tuesday, March 25, 2014 1:23 PM
 To: intel-gfx@lists.freedesktop.org
 Cc: Hugh Dickins
 Subject: [Intel-gfx] [PATCH 1/4] drm/i915: Translate ENOSPC from
 shmem_get_page() to ENOMEM
 
 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 hu...@google.com
 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk

Reviewed-by: Rafael Barbalho rafael.barba...@intel.com

 ---
  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
 
 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 1/4] drm/i915: Translate ENOSPC from shmem_get_page() to ENOMEM

2014-03-25 Thread Chris Wilson
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 hu...@google.com
Signed-off-by: Chris Wilson ch...@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

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx