[Intel-gfx] [PATCH v2 5/5] drm/i915: Use partial view in mmap fault handler
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Thu Apr 30 05:32:21 PDT 2015
On 04/30/2015 12:21 PM, Joonas Lahtinen wrote:
>
> Use partial view for huge BOs (bigger than the mappable aperture)
> in fault handler so that they can be accessed without trying to make
> room for them by evicting other objects.
>
> v2:
> - Only use partial views in the case where early rejection was
> previously done.
> - Account variable type changes from previous reroll.
>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 69 +++++++++++++++++++++++++++--------------
> 1 file changed, 46 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a020836..2f3fa0b 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1635,6 +1635,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
> struct drm_i915_gem_object *obj = to_intel_bo(vma->vm_private_data);
> struct drm_device *dev = obj->base.dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> + struct i915_ggtt_view view = i915_ggtt_view_normal;
> pgoff_t page_offset;
> unsigned long pfn;
> int ret = 0;
> @@ -1667,8 +1668,21 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
> goto unlock;
> }
>
> - /* Now bind it into the GTT if needed */
> - ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_MAPPABLE);
> + /* Use a partial view if the object is bigger than the aperture. */
> + if (obj->base.size >= dev_priv->gtt.mappable_end) {
> + static const unsigned int chunk_size = 256; // 1 MiB
> + memset(&view, 0, sizeof(view));
I think you don't need to memset since you assigned normal view to it.
> + view.type = I915_GGTT_VIEW_PARTIAL;
> + view.params.partial.offset = rounddown(page_offset, chunk_size);
> + view.params.partial.size =
> + min_t(unsigned int,
> + chunk_size,
> + (vma->vm_end - vma->vm_start)/PAGE_SIZE -
> + view.params.partial.offset);
> + }
> +
> + /* Now pin it into the GTT if needed */
> + ret = i915_gem_object_ggtt_pin(obj, &view, 0, PIN_MAPPABLE);
Next fault outside this partial view will create a new vma? Is there
something which would remove the old one for that case? Or they are just
allowed to accumulate?
Regards,
Tvrtko
More information about the Intel-gfx
mailing list