Re: [Intel-gfx] [PATCH 61/73] drm/i915: Record allocated vma size

2016-08-01 Thread Chris Wilson
On Mon, Aug 01, 2016 at 03:36:27PM +0300, Joonas Lahtinen wrote:
> On ma, 2016-08-01 at 10:11 +0100, Chris Wilson wrote:
> > Tracking the size of the VMA as allocated allows us to dramatically
> > reduce the complexity of later functions (like inserting the VMA in to
> > the drm_mm range manager).
> > 
> 
> I assume this new revision only removed the extra hunk of code, right?

Yeah, it was just rebased after the hunk was moved out. I've been lax in
not mentioning every single time the patches have been touched after a
rebase.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 61/73] drm/i915: Record allocated vma size

2016-08-01 Thread Joonas Lahtinen
On ma, 2016-08-01 at 10:11 +0100, Chris Wilson wrote:
> Tracking the size of the VMA as allocated allows us to dramatically
> reduce the complexity of later functions (like inserting the VMA in to
> the drm_mm range manager).
> 

I assume this new revision only removed the extra hunk of code, right?

If so,

Reviewed-by: Joonas Lahtinen 

> Signed-off-by: Chris Wilson 
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 103 
> ++--
>  drivers/gpu/drm/i915/i915_gem_gtt.c |  67 ---
>  drivers/gpu/drm/i915/i915_gem_gtt.h |   5 +-
>  3 files changed, 63 insertions(+), 112 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index f11bf6c4f86a..d89fbee5c48a 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2976,53 +2976,36 @@ i915_gem_object_insert_into_vm(struct 
> drm_i915_gem_object *obj,
>      u64 alignment,
>      u64 flags)
>  {
> - struct drm_device *dev = obj->base.dev;
> - struct drm_i915_private *dev_priv = to_i915(dev);
> - u64 start, end;
> - u32 search_flag, alloc_flag;
> + struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
>   struct i915_vma *vma;
> + u64 start, end;
> + u64 min_alignment;
>   int ret;
>  
> - if (i915_is_ggtt(vm)) {
> - u32 fence_size, fence_alignment, unfenced_alignment;
> - u64 view_size;
> -
> - if (WARN_ON(!ggtt_view))
> - return ERR_PTR(-EINVAL);
> -
> - view_size = i915_ggtt_view_size(obj, ggtt_view);
> -
> - fence_size = i915_gem_get_ggtt_size(dev_priv,
> - view_size,
> - obj->tiling_mode);
> - fence_alignment = i915_gem_get_ggtt_alignment(dev_priv,
> -   view_size,
> -   obj->tiling_mode,
> -   true);
> - unfenced_alignment = i915_gem_get_ggtt_alignment(dev_priv,
> -  view_size,
> -  
> obj->tiling_mode,
> -  false);
> - size = max(size, view_size);
> - if (flags & PIN_MAPPABLE)
> - size = max_t(u64, size, fence_size);
> -
> - if (alignment == 0)
> - alignment = flags & PIN_MAPPABLE ? fence_alignment :
> - unfenced_alignment;
> - if (flags & PIN_MAPPABLE && alignment & (fence_alignment - 1)) {
> - DRM_DEBUG("Invalid object (view type=%u) alignment 
> requested %llx\n",
> -   ggtt_view ? ggtt_view->type : 0,
> -   (long long)alignment);
> - return ERR_PTR(-EINVAL);
> - }
> - } else {
> - size = max_t(u64, size, obj->base.size);
> - alignment = 4096;
> + vma = ggtt_view ?
> + i915_gem_obj_lookup_or_create_ggtt_vma(obj, ggtt_view) :
> + i915_gem_obj_lookup_or_create_vma(obj, vm);
> + if (IS_ERR(vma))
> + return vma;
> +
> + size = max(size, vma->size);
> + if (flags & PIN_MAPPABLE)
> + size = i915_gem_get_ggtt_size(dev_priv, size, obj->tiling_mode);
> +
> + min_alignment =
> + i915_gem_get_ggtt_alignment(dev_priv, size, obj->tiling_mode,
> + flags & PIN_MAPPABLE);
> + if (alignment == 0)
> + alignment = min_alignment;
> + if (alignment & (min_alignment - 1)) {
> + DRM_DEBUG("Invalid object alignment requested %llu, minimum 
> %llu\n",
> +   alignment, min_alignment);
> + return ERR_PTR(-EINVAL);
>   }
>  
>   start = flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0;
> - end = vm->total;
> +
> + end = vma->vm->total;
>   if (flags & PIN_MAPPABLE)
>   end = min_t(u64, end, dev_priv->ggtt.mappable_end);
>   if (flags & PIN_ZONE_4G)
> @@ -3033,8 +3016,7 @@ i915_gem_object_insert_into_vm(struct 
> drm_i915_gem_object *obj,
>    * attempt to find space.
>    */
>   if (size > end) {
> - DRM_DEBUG("Attempting to bind an object (view type=%u) larger 
> than the aperture: request=%llu [object=%zd] > %s aperture=%llu\n",
> -   ggtt_view ? ggtt_view->type : 0,
> + DRM_DEBUG("Attempting to bind an object larger than the 
> aperture: request=%llu [object=%zd] > %s aperture=%llu\n",
>     size, obj->base.size,
>     

[Intel-gfx] [PATCH 61/73] drm/i915: Record allocated vma size

2016-08-01 Thread Chris Wilson
Tracking the size of the VMA as allocated allows us to dramatically
reduce the complexity of later functions (like inserting the VMA in to
the drm_mm range manager).

Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/i915/i915_gem.c | 103 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c |  67 ---
 drivers/gpu/drm/i915/i915_gem_gtt.h |   5 +-
 3 files changed, 63 insertions(+), 112 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f11bf6c4f86a..d89fbee5c48a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2976,53 +2976,36 @@ i915_gem_object_insert_into_vm(struct 
drm_i915_gem_object *obj,
   u64 alignment,
   u64 flags)
 {
-   struct drm_device *dev = obj->base.dev;
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   u64 start, end;
-   u32 search_flag, alloc_flag;
+   struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
struct i915_vma *vma;
+   u64 start, end;
+   u64 min_alignment;
int ret;
 
-   if (i915_is_ggtt(vm)) {
-   u32 fence_size, fence_alignment, unfenced_alignment;
-   u64 view_size;
-
-   if (WARN_ON(!ggtt_view))
-   return ERR_PTR(-EINVAL);
-
-   view_size = i915_ggtt_view_size(obj, ggtt_view);
-
-   fence_size = i915_gem_get_ggtt_size(dev_priv,
-   view_size,
-   obj->tiling_mode);
-   fence_alignment = i915_gem_get_ggtt_alignment(dev_priv,
- view_size,
- obj->tiling_mode,
- true);
-   unfenced_alignment = i915_gem_get_ggtt_alignment(dev_priv,
-view_size,
-
obj->tiling_mode,
-false);
-   size = max(size, view_size);
-   if (flags & PIN_MAPPABLE)
-   size = max_t(u64, size, fence_size);
-
-   if (alignment == 0)
-   alignment = flags & PIN_MAPPABLE ? fence_alignment :
-   unfenced_alignment;
-   if (flags & PIN_MAPPABLE && alignment & (fence_alignment - 1)) {
-   DRM_DEBUG("Invalid object (view type=%u) alignment 
requested %llx\n",
- ggtt_view ? ggtt_view->type : 0,
- (long long)alignment);
-   return ERR_PTR(-EINVAL);
-   }
-   } else {
-   size = max_t(u64, size, obj->base.size);
-   alignment = 4096;
+   vma = ggtt_view ?
+   i915_gem_obj_lookup_or_create_ggtt_vma(obj, ggtt_view) :
+   i915_gem_obj_lookup_or_create_vma(obj, vm);
+   if (IS_ERR(vma))
+   return vma;
+
+   size = max(size, vma->size);
+   if (flags & PIN_MAPPABLE)
+   size = i915_gem_get_ggtt_size(dev_priv, size, obj->tiling_mode);
+
+   min_alignment =
+   i915_gem_get_ggtt_alignment(dev_priv, size, obj->tiling_mode,
+   flags & PIN_MAPPABLE);
+   if (alignment == 0)
+   alignment = min_alignment;
+   if (alignment & (min_alignment - 1)) {
+   DRM_DEBUG("Invalid object alignment requested %llu, minimum 
%llu\n",
+ alignment, min_alignment);
+   return ERR_PTR(-EINVAL);
}
 
start = flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0;
-   end = vm->total;
+
+   end = vma->vm->total;
if (flags & PIN_MAPPABLE)
end = min_t(u64, end, dev_priv->ggtt.mappable_end);
if (flags & PIN_ZONE_4G)
@@ -3033,8 +3016,7 @@ i915_gem_object_insert_into_vm(struct drm_i915_gem_object 
*obj,
 * attempt to find space.
 */
if (size > end) {
-   DRM_DEBUG("Attempting to bind an object (view type=%u) larger 
than the aperture: request=%llu [object=%zd] > %s aperture=%llu\n",
- ggtt_view ? ggtt_view->type : 0,
+   DRM_DEBUG("Attempting to bind an object larger than the 
aperture: request=%llu [object=%zd] > %s aperture=%llu\n",
  size, obj->base.size,
  flags & PIN_MAPPABLE ? "mappable" : "total",
  end);
@@ -3047,31 +3029,27 @@ i915_gem_object_insert_into_vm(struct 
drm_i915_gem_object *obj,
 
i915_gem_object_pin_pages(obj);
 
-   vma = ggtt_view ?