[Intel-gfx] [PATCH] drm/i915: Cleaning up the relocate entry function
Daniel Vetter
daniel at ffwll.ch
Wed Aug 21 23:29:02 CEST 2013
On Wed, Aug 21, 2013 at 05:10:51PM +0100, rafael.barbalho at intel.com wrote:
> From: Rafael Barbalho <rafael.barbalho at intel.com>
>
> As the relocate entry function was getting a bit too big I've moved
> the code that used to use either the cpu or the gtt to for the
> relocation into two separate functions.
>
> Signed-off-by: Rafael Barbalho <rafael.barbalho at intel.com>
Queued for -next, thanks for the patch.
Note that you're mailer added a stupid "may be confidential legal
disclaimer", which is bullocks since you're sending this to the world. And
a bunch of companies have policies to immediately delete such mails since
they're not the explicit recipient. I've dropped the disclaimer so that
people can read your patch, but you need to fix this ;-)
Separate mail accound recommended.
-Daniel
> ---
> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 88 ++++++++++++++++++------------
> 1 file changed, 54 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 9b3b5f8..fa82396 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -208,6 +208,56 @@ static inline int use_cpu_reloc(struct drm_i915_gem_object *obj)
> }
>
> static int
> +relocate_entry_cpu(struct drm_i915_gem_object *obj,
> + struct drm_i915_gem_relocation_entry *reloc)
> +{
> + uint32_t page_offset = offset_in_page(reloc->offset);
> + char *vaddr;
> + int ret = -EINVAL;
> +
> + ret = i915_gem_object_set_to_cpu_domain(obj, 1);
> + if (ret)
> + return ret;
> +
> + vaddr = kmap_atomic(i915_gem_object_get_page(obj,
> + reloc->offset >> PAGE_SHIFT));
> + *(uint32_t *)(vaddr + page_offset) = reloc->delta;
> + kunmap_atomic(vaddr);
> +
> + return 0;
> +}
> +
> +static int
> +relocate_entry_gtt(struct drm_i915_gem_object *obj,
> + struct drm_i915_gem_relocation_entry *reloc)
> +{
> + struct drm_device *dev = obj->base.dev;
> + struct drm_i915_private *dev_priv = dev->dev_private;
> + uint32_t __iomem *reloc_entry;
> + void __iomem *reloc_page;
> + int ret = -EINVAL;
> +
> + ret = i915_gem_object_set_to_gtt_domain(obj, true);
> + if (ret)
> + return ret;
> +
> + ret = i915_gem_object_put_fence(obj);
> + if (ret)
> + return ret;
> +
> + /* Map the page containing the relocation we're going to perform. */
> + reloc->offset += i915_gem_obj_ggtt_offset(obj);
> + reloc_page = io_mapping_map_atomic_wc(dev_priv->gtt.mappable,
> + reloc->offset & PAGE_MASK);
> + reloc_entry = (uint32_t __iomem *)
> + (reloc_page + offset_in_page(reloc->offset));
> + iowrite32(reloc->delta, reloc_entry);
> + io_mapping_unmap_atomic(reloc_page);
> +
> + return 0;
> +}
> +
> +static int
> i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
> struct eb_vmas *eb,
> struct drm_i915_gem_relocation_entry *reloc,
> @@ -293,40 +343,10 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
> return -EFAULT;
>
> reloc->delta += target_offset;
> - if (use_cpu_reloc(obj)) {
> - uint32_t page_offset = offset_in_page(reloc->offset);
> - char *vaddr;
> -
> - ret = i915_gem_object_set_to_cpu_domain(obj, 1);
> - if (ret)
> - return ret;
> -
> - vaddr = kmap_atomic(i915_gem_object_get_page(obj,
> - reloc->offset >> PAGE_SHIFT));
> - *(uint32_t *)(vaddr + page_offset) = reloc->delta;
> - kunmap_atomic(vaddr);
> - } else {
> - struct drm_i915_private *dev_priv = dev->dev_private;
> - uint32_t __iomem *reloc_entry;
> - void __iomem *reloc_page;
> -
> - ret = i915_gem_object_set_to_gtt_domain(obj, true);
> - if (ret)
> - return ret;
> -
> - ret = i915_gem_object_put_fence(obj);
> - if (ret)
> - return ret;
> -
> - /* Map the page containing the relocation we're going to perform. */
> - reloc->offset += i915_gem_obj_ggtt_offset(obj);
> - reloc_page = io_mapping_map_atomic_wc(dev_priv->gtt.mappable,
> - reloc->offset & PAGE_MASK);
> - reloc_entry = (uint32_t __iomem *)
> - (reloc_page + offset_in_page(reloc->offset));
> - iowrite32(reloc->delta, reloc_entry);
> - io_mapping_unmap_atomic(reloc_page);
> - }
> + if (use_cpu_reloc(obj))
> + ret = relocate_entry_cpu(obj, reloc);
> + else
> + ret = relocate_entry_gtt(obj, reloc);
>
> /* and update the user's relocation entry */
> reloc->presumed_offset = target_offset;
> --
> 1.8.3.4
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
More information about the Intel-gfx
mailing list