]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Use drm_gem_object.resv
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 18 Jun 2019 12:58:58 +0000 (13:58 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 18 Jun 2019 14:30:32 +0000 (15:30 +0100)
Since commit 1ba627148ef5 ("drm: Add reservation_object to
drm_gem_object"), struct drm_gem_object grew its own builtin
reservation_object rendering our own private one bloat. Remove our
redundant reservation_object and point into obj->base.resv instead.

References: 1ba627148ef5 ("drm: Add reservation_object to drm_gem_object")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190618125858.7295-1-chris@chris-wilson.co.uk
13 files changed:
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/gem/i915_gem_busy.c
drivers/gpu/drm/i915/gem/i915_gem_clflush.c
drivers/gpu/drm/i915/gem/i915_gem_client_blt.c
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
drivers/gpu/drm/i915/gem/i915_gem_fence.c
drivers/gpu/drm/i915/gem/i915_gem_object.c
drivers/gpu/drm/i915/gem/i915_gem_object.h
drivers/gpu/drm/i915/gem/i915_gem_object_types.h
drivers/gpu/drm/i915/gem/i915_gem_wait.c
drivers/gpu/drm/i915/i915_gem_batch_pool.c
drivers/gpu/drm/i915/i915_request.c
drivers/gpu/drm/i915/i915_vma.c

index 8d7e4c8b60bcb80afbd523bde6cd0dd4a16fe42b..ad5cccf4413d19c1f86f51fef1d3a22ab90a47f6 100644 (file)
@@ -14256,7 +14256,7 @@ intel_prepare_plane_fb(struct drm_plane *plane,
                 */
                if (needs_modeset(crtc_state)) {
                        ret = i915_sw_fence_await_reservation(&intel_state->commit_ready,
-                                                             old_obj->resv, NULL,
+                                                             old_obj->base.resv, NULL,
                                                              false, 0,
                                                              GFP_KERNEL);
                        if (ret < 0)
@@ -14300,13 +14300,13 @@ intel_prepare_plane_fb(struct drm_plane *plane,
                struct dma_fence *fence;
 
                ret = i915_sw_fence_await_reservation(&intel_state->commit_ready,
-                                                     obj->resv, NULL,
+                                                     obj->base.resv, NULL,
                                                      false, I915_FENCE_TIMEOUT,
                                                      GFP_KERNEL);
                if (ret < 0)
                        return ret;
 
-               fence = reservation_object_get_excl_rcu(obj->resv);
+               fence = reservation_object_get_excl_rcu(obj->base.resv);
                if (fence) {
                        add_rps_boost_after_vblank(new_state->crtc, fence);
                        dma_fence_put(fence);
index 5a5eda3003e952a10e9f1b33bcd9ee5c9d2cee69..6ad93a09968ca4ae9d7517f4666a80b050545e88 100644 (file)
@@ -110,13 +110,14 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
         *
         */
 retry:
-       seq = raw_read_seqcount(&obj->resv->seq);
+       seq = raw_read_seqcount(&obj->base.resv->seq);
 
        /* Translate the exclusive fence to the READ *and* WRITE engine */
-       args->busy = busy_check_writer(rcu_dereference(obj->resv->fence_excl));
+       args->busy =
+               busy_check_writer(rcu_dereference(obj->base.resv->fence_excl));
 
        /* Translate shared fences to READ set of engines */
-       list = rcu_dereference(obj->resv->fence);
+       list = rcu_dereference(obj->base.resv->fence);
        if (list) {
                unsigned int shared_count = list->shared_count, i;
 
@@ -128,7 +129,7 @@ retry:
                }
        }
 
-       if (args->busy && read_seqcount_retry(&obj->resv->seq, seq))
+       if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq))
                goto retry;
 
        err = 0;
index 9018e12b536b2d50c8b270588c08c54ca5f212ce..5295285d5843fc9cff676fd0c05a7fbba4e59174 100644 (file)
@@ -143,11 +143,12 @@ bool i915_gem_clflush_object(struct drm_i915_gem_object *obj,
                dma_fence_get(&clflush->dma);
 
                i915_sw_fence_await_reservation(&clflush->wait,
-                                               obj->resv, NULL,
+                                               obj->base.resv, NULL,
                                                true, I915_FENCE_TIMEOUT,
                                                I915_FENCE_GFP);
 
-               reservation_object_add_excl_fence(obj->resv, &clflush->dma);
+               reservation_object_add_excl_fence(obj->base.resv,
+                                                 &clflush->dma);
 
                i915_sw_fence_commit(&clflush->wait);
        } else if (obj->mm.pages) {
index f253ec5765adbf02d55da0fc7e7cc3381c8f422d..1fdab0767a4785831d44a0cbeec5075abf0315d3 100644 (file)
@@ -282,13 +282,13 @@ int i915_gem_schedule_fill_pages_blt(struct drm_i915_gem_object *obj,
 
        i915_gem_object_lock(obj);
        err = i915_sw_fence_await_reservation(&work->wait,
-                                             obj->resv, NULL,
+                                             obj->base.resv, NULL,
                                              true, I915_FENCE_TIMEOUT,
                                              I915_FENCE_GFP);
        if (err < 0) {
                dma_fence_set_error(&work->dma, err);
        } else {
-               reservation_object_add_excl_fence(obj->resv, &work->dma);
+               reservation_object_add_excl_fence(obj->base.resv, &work->dma);
                err = 0;
        }
        i915_gem_object_unlock(obj);
index a93e233cfaa9b8f7f96226ff128bdebe309dce3f..cbf1701d3acc6db6fe8100eb60fcda5a41c93983 100644 (file)
@@ -214,7 +214,7 @@ struct dma_buf *i915_gem_prime_export(struct drm_device *dev,
        exp_info.size = gem_obj->size;
        exp_info.flags = flags;
        exp_info.priv = gem_obj;
-       exp_info.resv = obj->resv;
+       exp_info.resv = obj->base.resv;
 
        if (obj->ops->dmabuf_export) {
                int ret = obj->ops->dmabuf_export(obj);
@@ -290,7 +290,7 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
        drm_gem_private_object_init(dev, &obj->base, dma_buf->size);
        i915_gem_object_init(obj, &i915_gem_object_dmabuf_ops);
        obj->base.import_attach = attach;
-       obj->resv = dma_buf->resv;
+       obj->base.resv = dma_buf->resv;
 
        /* We use GTT as shorthand for a coherent domain, one that is
         * neither in the GPU cache nor in the CPU cache, where all
index 57dbc0862713a90543faeb94b74550cee1e20937..cf0439e6be83a563a095e0d6378a5c43ee8dbe44 100644 (file)
@@ -73,12 +73,12 @@ i915_gem_object_lock_fence(struct drm_i915_gem_object *obj)
                       0);
 
        if (i915_sw_fence_await_reservation(&stub->chain,
-                                           obj->resv, NULL,
+                                           obj->base.resv, NULL,
                                            true, I915_FENCE_TIMEOUT,
                                            I915_FENCE_GFP) < 0)
                goto err;
 
-       reservation_object_add_excl_fence(obj->resv, &stub->dma);
+       reservation_object_add_excl_fence(obj->base.resv, &stub->dma);
 
        return &stub->dma;
 
index 272ce30ce1d339465fd7608b38f87a9adcabaff6..a8c77f5713c66794ab3eab3e67d1527c311d034f 100644 (file)
@@ -70,9 +70,6 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
 
        obj->ops = ops;
 
-       reservation_object_init(&obj->__builtin_resv);
-       obj->resv = &obj->__builtin_resv;
-
        obj->frontbuffer_ggtt_origin = ORIGIN_GTT;
        i915_active_request_init(&obj->frontbuffer_write,
                                 NULL, frontbuffer_retire);
@@ -233,7 +230,6 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
                if (obj->base.import_attach)
                        drm_prime_gem_destroy(&obj->base, NULL);
 
-               reservation_object_fini(&obj->__builtin_resv);
                drm_gem_object_release(&obj->base);
 
                bitmap_free(obj->bit_17);
index 7cb1871d7128e51a59411dcc1c5a44267dffe13e..dfebd5706f16ddc3b1dc8aaf43e9d4bba6179118 100644 (file)
@@ -99,22 +99,22 @@ i915_gem_object_put(struct drm_i915_gem_object *obj)
        __drm_gem_object_put(&obj->base);
 }
 
-#define assert_object_held(obj) reservation_object_assert_held((obj)->resv)
+#define assert_object_held(obj) reservation_object_assert_held((obj)->base.resv)
 
 static inline void i915_gem_object_lock(struct drm_i915_gem_object *obj)
 {
-       reservation_object_lock(obj->resv, NULL);
+       reservation_object_lock(obj->base.resv, NULL);
 }
 
 static inline int
 i915_gem_object_lock_interruptible(struct drm_i915_gem_object *obj)
 {
-       return reservation_object_lock_interruptible(obj->resv, NULL);
+       return reservation_object_lock_interruptible(obj->base.resv, NULL);
 }
 
 static inline void i915_gem_object_unlock(struct drm_i915_gem_object *obj)
 {
-       reservation_object_unlock(obj->resv);
+       reservation_object_unlock(obj->base.resv);
 }
 
 struct dma_fence *
@@ -373,7 +373,7 @@ i915_gem_object_last_write_engine(struct drm_i915_gem_object *obj)
        struct dma_fence *fence;
 
        rcu_read_lock();
-       fence = reservation_object_get_excl_rcu(obj->resv);
+       fence = reservation_object_get_excl_rcu(obj->base.resv);
        rcu_read_unlock();
 
        if (fence && dma_fence_is_i915(fence) && !dma_fence_is_signaled(fence))
index 5b05698619ceebfa8423c1a2e4a4e40cb5167ebe..18bf4f8d6d809a169199f01e1d2703787def2bfb 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef __I915_GEM_OBJECT_TYPES_H__
 #define __I915_GEM_OBJECT_TYPES_H__
 
-#include <linux/reservation.h>
-
 #include <drm/drm_gem.h>
 
 #include "i915_active.h"
@@ -228,18 +226,6 @@ struct drm_i915_gem_object {
                bool quirked:1;
        } mm;
 
-       /** Breadcrumb of last rendering to the buffer.
-        * There can only be one writer, but we allow for multiple readers.
-        * If there is a writer that necessarily implies that all other
-        * read requests are complete - but we may only be lazily clearing
-        * the read requests. A read request is naturally the most recent
-        * request on a ring, so we may have two different write and read
-        * requests on one ring where the write request is older than the
-        * read request. This allows for the CPU to read from an active
-        * buffer by only waiting for the write to complete.
-        */
-       struct reservation_object *resv;
-
        /** References from framebuffers, locks out tiling changes. */
        unsigned int framebuffer_references;
 
@@ -262,8 +248,6 @@ struct drm_i915_gem_object {
 
        /** for phys allocated objects */
        struct drm_dma_handle *phys_handle;
-
-       struct reservation_object __builtin_resv;
 };
 
 static inline struct drm_i915_gem_object *
index fed5c751ef37a6cbcc745dfc09acb0b9af6f29f9..26ec6579b7cdfa76c782664ba8bccf88c4ca58ff 100644 (file)
@@ -144,7 +144,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,
                unsigned int count, i;
                int ret;
 
-               ret = reservation_object_get_fences_rcu(obj->resv,
+               ret = reservation_object_get_fences_rcu(obj->base.resv,
                                                        &excl, &count, &shared);
                if (ret)
                        return ret;
@@ -156,7 +156,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,
 
                kfree(shared);
        } else {
-               excl = reservation_object_get_excl_rcu(obj->resv);
+               excl = reservation_object_get_excl_rcu(obj->base.resv);
        }
 
        if (excl) {
@@ -180,7 +180,8 @@ i915_gem_object_wait(struct drm_i915_gem_object *obj,
        might_sleep();
        GEM_BUG_ON(timeout < 0);
 
-       timeout = i915_gem_object_wait_reservation(obj->resv, flags, timeout);
+       timeout = i915_gem_object_wait_reservation(obj->base.resv,
+                                                  flags, timeout);
        return timeout < 0 ? timeout : 0;
 }
 
index 56adfdcaed3e08d09a8131d108609a24484db93c..25a3e4d09a2ffe9c6589999fd9e10ca6b4981db9 100644 (file)
@@ -96,7 +96,7 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
        list_for_each_entry(obj, list, batch_pool_link) {
                /* The batches are strictly LRU ordered */
                if (i915_gem_object_is_active(obj)) {
-                       struct reservation_object *resv = obj->resv;
+                       struct reservation_object *resv = obj->base.resv;
 
                        if (!reservation_object_test_signaled_rcu(resv, true))
                                break;
@@ -119,7 +119,7 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
                        }
                }
 
-               GEM_BUG_ON(!reservation_object_test_signaled_rcu(obj->resv,
+               GEM_BUG_ON(!reservation_object_test_signaled_rcu(obj->base.resv,
                                                                 true));
 
                if (obj->base.size >= size)
index 9819483d1b5dd2859691f0374e8aa5c7218da1e7..7418e8f1ed6a21ca8b41733777d22c7a8bc20ccd 100644 (file)
@@ -1027,7 +1027,7 @@ i915_request_await_object(struct i915_request *to,
                struct dma_fence **shared;
                unsigned int count, i;
 
-               ret = reservation_object_get_fences_rcu(obj->resv,
+               ret = reservation_object_get_fences_rcu(obj->base.resv,
                                                        &excl, &count, &shared);
                if (ret)
                        return ret;
@@ -1044,7 +1044,7 @@ i915_request_await_object(struct i915_request *to,
                        dma_fence_put(shared[i]);
                kfree(shared);
        } else {
-               excl = reservation_object_get_excl_rcu(obj->resv);
+               excl = reservation_object_get_excl_rcu(obj->base.resv);
        }
 
        if (excl) {
index 5fc0fda32e2a4994920c5df00d1841ce1c879d06..a57729be8312ae0903f15252170830f6c7e7950b 100644 (file)
@@ -99,10 +99,10 @@ static void __i915_vma_retire(struct i915_active *ref)
                return;
 
        /* Prune the shared fence arrays iff completely idle (inc. external) */
-       if (reservation_object_trylock(obj->resv)) {
-               if (reservation_object_test_signaled_rcu(obj->resv, true))
-                       reservation_object_add_excl_fence(obj->resv, NULL);
-               reservation_object_unlock(obj->resv);
+       if (reservation_object_trylock(obj->base.resv)) {
+               if (reservation_object_test_signaled_rcu(obj->base.resv, true))
+                       reservation_object_add_excl_fence(obj->base.resv, NULL);
+               reservation_object_unlock(obj->base.resv);
        }
 
        /*
@@ -134,7 +134,7 @@ vma_create(struct drm_i915_gem_object *obj,
        vma->vm = vm;
        vma->ops = &vm->vma_ops;
        vma->obj = obj;
-       vma->resv = obj->resv;
+       vma->resv = obj->base.resv;
        vma->size = obj->base.size;
        vma->display_alignment = I915_GTT_MIN_ALIGNMENT;