Commit dd55cf69 authored by Rob Herring's avatar Rob Herring Committed by Maxime Ripard

drm: msm: Switch to use drm_gem_object reservation_object

Now that the base struct drm_gem_object has a reservation_object, use it
and remove the private BO one.

We can't use the drm_gem_reservation_object_wait() helper for MSM
because (in theory) msm_gem_cpu_prep() will also do some cache
maintenance on the GEM object.

Cc: David Airlie <airlied@linux.ie>
Cc: linux-arm-msm@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarRob Clark <robdclark@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190202154158.10443-4-robh@kernel.orgSigned-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
parent fa238ea1
...@@ -1085,7 +1085,6 @@ static struct drm_driver msm_driver = { ...@@ -1085,7 +1085,6 @@ static struct drm_driver msm_driver = {
.prime_fd_to_handle = drm_gem_prime_fd_to_handle, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_export = drm_gem_prime_export, .gem_prime_export = drm_gem_prime_export,
.gem_prime_import = drm_gem_prime_import, .gem_prime_import = drm_gem_prime_import,
.gem_prime_res_obj = msm_gem_prime_res_obj,
.gem_prime_pin = msm_gem_prime_pin, .gem_prime_pin = msm_gem_prime_pin,
.gem_prime_unpin = msm_gem_prime_unpin, .gem_prime_unpin = msm_gem_prime_unpin,
.gem_prime_get_sg_table = msm_gem_prime_get_sg_table, .gem_prime_get_sg_table = msm_gem_prime_get_sg_table,
......
...@@ -299,7 +299,6 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj); ...@@ -299,7 +299,6 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
void *msm_gem_prime_vmap(struct drm_gem_object *obj); void *msm_gem_prime_vmap(struct drm_gem_object *obj);
void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
struct reservation_object *msm_gem_prime_res_obj(struct drm_gem_object *obj);
struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev, struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg); struct dma_buf_attachment *attach, struct sg_table *sg);
int msm_gem_prime_pin(struct drm_gem_object *obj); int msm_gem_prime_pin(struct drm_gem_object *obj);
......
...@@ -668,14 +668,13 @@ void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass) ...@@ -668,14 +668,13 @@ void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass)
int msm_gem_sync_object(struct drm_gem_object *obj, int msm_gem_sync_object(struct drm_gem_object *obj,
struct msm_fence_context *fctx, bool exclusive) struct msm_fence_context *fctx, bool exclusive)
{ {
struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct reservation_object_list *fobj; struct reservation_object_list *fobj;
struct dma_fence *fence; struct dma_fence *fence;
int i, ret; int i, ret;
fobj = reservation_object_get_list(msm_obj->resv); fobj = reservation_object_get_list(obj->resv);
if (!fobj || (fobj->shared_count == 0)) { if (!fobj || (fobj->shared_count == 0)) {
fence = reservation_object_get_excl(msm_obj->resv); fence = reservation_object_get_excl(obj->resv);
/* don't need to wait on our own fences, since ring is fifo */ /* don't need to wait on our own fences, since ring is fifo */
if (fence && (fence->context != fctx->context)) { if (fence && (fence->context != fctx->context)) {
ret = dma_fence_wait(fence, true); ret = dma_fence_wait(fence, true);
...@@ -689,7 +688,7 @@ int msm_gem_sync_object(struct drm_gem_object *obj, ...@@ -689,7 +688,7 @@ int msm_gem_sync_object(struct drm_gem_object *obj,
for (i = 0; i < fobj->shared_count; i++) { for (i = 0; i < fobj->shared_count; i++) {
fence = rcu_dereference_protected(fobj->shared[i], fence = rcu_dereference_protected(fobj->shared[i],
reservation_object_held(msm_obj->resv)); reservation_object_held(obj->resv));
if (fence->context != fctx->context) { if (fence->context != fctx->context) {
ret = dma_fence_wait(fence, true); ret = dma_fence_wait(fence, true);
if (ret) if (ret)
...@@ -707,9 +706,9 @@ void msm_gem_move_to_active(struct drm_gem_object *obj, ...@@ -707,9 +706,9 @@ void msm_gem_move_to_active(struct drm_gem_object *obj,
WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED); WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED);
msm_obj->gpu = gpu; msm_obj->gpu = gpu;
if (exclusive) if (exclusive)
reservation_object_add_excl_fence(msm_obj->resv, fence); reservation_object_add_excl_fence(obj->resv, fence);
else else
reservation_object_add_shared_fence(msm_obj->resv, fence); reservation_object_add_shared_fence(obj->resv, fence);
list_del_init(&msm_obj->mm_list); list_del_init(&msm_obj->mm_list);
list_add_tail(&msm_obj->mm_list, &gpu->active_list); list_add_tail(&msm_obj->mm_list, &gpu->active_list);
} }
...@@ -729,13 +728,12 @@ void msm_gem_move_to_inactive(struct drm_gem_object *obj) ...@@ -729,13 +728,12 @@ void msm_gem_move_to_inactive(struct drm_gem_object *obj)
int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout) int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout)
{ {
struct msm_gem_object *msm_obj = to_msm_bo(obj);
bool write = !!(op & MSM_PREP_WRITE); bool write = !!(op & MSM_PREP_WRITE);
unsigned long remain = unsigned long remain =
op & MSM_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout); op & MSM_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout);
long ret; long ret;
ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write, ret = reservation_object_wait_timeout_rcu(obj->resv, write,
true, remain); true, remain);
if (ret == 0) if (ret == 0)
return remain == 0 ? -EBUSY : -ETIMEDOUT; return remain == 0 ? -EBUSY : -ETIMEDOUT;
...@@ -767,7 +765,7 @@ static void describe_fence(struct dma_fence *fence, const char *type, ...@@ -767,7 +765,7 @@ static void describe_fence(struct dma_fence *fence, const char *type,
void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m) void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
{ {
struct msm_gem_object *msm_obj = to_msm_bo(obj); struct msm_gem_object *msm_obj = to_msm_bo(obj);
struct reservation_object *robj = msm_obj->resv; struct reservation_object *robj = obj->resv;
struct reservation_object_list *fobj; struct reservation_object_list *fobj;
struct dma_fence *fence; struct dma_fence *fence;
struct msm_gem_vma *vma; struct msm_gem_vma *vma;
...@@ -879,9 +877,6 @@ void msm_gem_free_object(struct drm_gem_object *obj) ...@@ -879,9 +877,6 @@ void msm_gem_free_object(struct drm_gem_object *obj)
put_pages(obj); put_pages(obj);
} }
if (msm_obj->resv == &msm_obj->_resv)
reservation_object_fini(msm_obj->resv);
drm_gem_object_release(obj); drm_gem_object_release(obj);
mutex_unlock(&msm_obj->lock); mutex_unlock(&msm_obj->lock);
...@@ -941,12 +936,8 @@ static int msm_gem_new_impl(struct drm_device *dev, ...@@ -941,12 +936,8 @@ static int msm_gem_new_impl(struct drm_device *dev,
msm_obj->flags = flags; msm_obj->flags = flags;
msm_obj->madv = MSM_MADV_WILLNEED; msm_obj->madv = MSM_MADV_WILLNEED;
if (resv) { if (resv)
msm_obj->resv = resv; msm_obj->base.resv = resv;
} else {
msm_obj->resv = &msm_obj->_resv;
reservation_object_init(msm_obj->resv);
}
INIT_LIST_HEAD(&msm_obj->submit_entry); INIT_LIST_HEAD(&msm_obj->submit_entry);
INIT_LIST_HEAD(&msm_obj->vmas); INIT_LIST_HEAD(&msm_obj->vmas);
......
...@@ -70,10 +70,3 @@ void msm_gem_prime_unpin(struct drm_gem_object *obj) ...@@ -70,10 +70,3 @@ void msm_gem_prime_unpin(struct drm_gem_object *obj)
if (!obj->import_attach) if (!obj->import_attach)
msm_gem_put_pages(obj); msm_gem_put_pages(obj);
} }
struct reservation_object *msm_gem_prime_res_obj(struct drm_gem_object *obj)
{
struct msm_gem_object *msm_obj = to_msm_bo(obj);
return msm_obj->resv;
}
...@@ -173,7 +173,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit, ...@@ -173,7 +173,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit,
msm_gem_unpin_iova(&msm_obj->base, submit->gpu->aspace); msm_gem_unpin_iova(&msm_obj->base, submit->gpu->aspace);
if (submit->bos[i].flags & BO_LOCKED) if (submit->bos[i].flags & BO_LOCKED)
ww_mutex_unlock(&msm_obj->resv->lock); ww_mutex_unlock(&msm_obj->base.resv->lock);
if (backoff && !(submit->bos[i].flags & BO_VALID)) if (backoff && !(submit->bos[i].flags & BO_VALID))
submit->bos[i].iova = 0; submit->bos[i].iova = 0;
...@@ -196,7 +196,7 @@ static int submit_lock_objects(struct msm_gem_submit *submit) ...@@ -196,7 +196,7 @@ static int submit_lock_objects(struct msm_gem_submit *submit)
contended = i; contended = i;
if (!(submit->bos[i].flags & BO_LOCKED)) { if (!(submit->bos[i].flags & BO_LOCKED)) {
ret = ww_mutex_lock_interruptible(&msm_obj->resv->lock, ret = ww_mutex_lock_interruptible(&msm_obj->base.resv->lock,
&submit->ticket); &submit->ticket);
if (ret) if (ret)
goto fail; goto fail;
...@@ -218,7 +218,7 @@ static int submit_lock_objects(struct msm_gem_submit *submit) ...@@ -218,7 +218,7 @@ static int submit_lock_objects(struct msm_gem_submit *submit)
if (ret == -EDEADLK) { if (ret == -EDEADLK) {
struct msm_gem_object *msm_obj = submit->bos[contended].obj; struct msm_gem_object *msm_obj = submit->bos[contended].obj;
/* we lost out in a seqno race, lock and retry.. */ /* we lost out in a seqno race, lock and retry.. */
ret = ww_mutex_lock_slow_interruptible(&msm_obj->resv->lock, ret = ww_mutex_lock_slow_interruptible(&msm_obj->base.resv->lock,
&submit->ticket); &submit->ticket);
if (!ret) { if (!ret) {
submit->bos[contended].flags |= BO_LOCKED; submit->bos[contended].flags |= BO_LOCKED;
...@@ -244,7 +244,7 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) ...@@ -244,7 +244,7 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)
* strange place to call it. OTOH this is a * strange place to call it. OTOH this is a
* convenient can-fail point to hook it in. * convenient can-fail point to hook it in.
*/ */
ret = reservation_object_reserve_shared(msm_obj->resv, ret = reservation_object_reserve_shared(msm_obj->base.resv,
1); 1);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment