diff mbox series

drm/i915/userptr: Don't mark readonly objects as dirty

Message ID 20190709081718.27843-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915/userptr: Don't mark readonly objects as dirty | expand

Commit Message

Chris Wilson July 9, 2019, 8:17 a.m. UTC
If we map an object as readonly into the GTT, we know that the GPU
cannot have written to it and so the object is not dirty and we don't
need to flush the writes back to the system.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Tvrtko Ursulin July 9, 2019, 8:44 a.m. UTC | #1
On 09/07/2019 09:17, Chris Wilson wrote:
> If we map an object as readonly into the GTT, we know that the GPU
> cannot have written to it and so the object is not dirty and we don't
> need to flush the writes back to the system.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> index 32d208ede343..b9d2bb15e4a6 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> @@ -663,6 +663,14 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
>   	__i915_gem_object_release_shmem(obj, pages, true);
>   	i915_gem_gtt_finish_pages(obj, pages);
>   
> +	/*
> +	 * We always mark objects as dirty when they are used by the GPU,
> +	 * just in case. However, if we set the vma as being read-only we know
> +	 * that the object will never have been written to.
> +	 */
> +	if (i915_gem_object_is_readonly(obj))
> +		obj->mm.dirty = false;
> +
>   	for_each_sgt_page(page, sgt_iter, pages) {
>   		if (obj->mm.dirty)
>   			/*
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 32d208ede343..b9d2bb15e4a6 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
@@ -663,6 +663,14 @@  i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
 	__i915_gem_object_release_shmem(obj, pages, true);
 	i915_gem_gtt_finish_pages(obj, pages);
 
+	/*
+	 * We always mark objects as dirty when they are used by the GPU,
+	 * just in case. However, if we set the vma as being read-only we know
+	 * that the object will never have been written to.
+	 */
+	if (i915_gem_object_is_readonly(obj))
+		obj->mm.dirty = false;
+
 	for_each_sgt_page(page, sgt_iter, pages) {
 		if (obj->mm.dirty)
 			/*