Commit 5b223e94 authored by Lucas Stach's avatar Lucas Stach

drm/etnaviv: move GPU active handling to bo pin/unpin

The active count is used to check if the BO is idle, where idle is defined
as not active on the GPU and all VM mappings and reference counts dropped
to the initial state. As the idling of the mappings and references now only
happens in the submit cleanup, the active state handling must be moved to
the same location in order to keep the userspace semantics.
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
parent 2f9225db
...@@ -229,6 +229,7 @@ static int submit_pin_objects(struct etnaviv_gem_submit *submit) ...@@ -229,6 +229,7 @@ static int submit_pin_objects(struct etnaviv_gem_submit *submit)
ret = PTR_ERR(mapping); ret = PTR_ERR(mapping);
break; break;
} }
atomic_inc(&etnaviv_obj->gpu_active);
submit->bos[i].flags |= BO_PINNED; submit->bos[i].flags |= BO_PINNED;
submit->bos[i].mapping = mapping; submit->bos[i].mapping = mapping;
...@@ -363,6 +364,7 @@ static void submit_cleanup(struct kref *kref) ...@@ -363,6 +364,7 @@ static void submit_cleanup(struct kref *kref)
/* unpin all objects */ /* unpin all objects */
if (submit->bos[i].flags & BO_PINNED) { if (submit->bos[i].flags & BO_PINNED) {
etnaviv_gem_mapping_unreference(submit->bos[i].mapping); etnaviv_gem_mapping_unreference(submit->bos[i].mapping);
atomic_dec(&etnaviv_obj->gpu_active);
submit->bos[i].mapping = NULL; submit->bos[i].mapping = NULL;
submit->bos[i].flags &= ~BO_PINNED; submit->bos[i].flags &= ~BO_PINNED;
} }
...@@ -372,6 +374,8 @@ static void submit_cleanup(struct kref *kref) ...@@ -372,6 +374,8 @@ static void submit_cleanup(struct kref *kref)
drm_gem_object_put_unlocked(&etnaviv_obj->base); drm_gem_object_put_unlocked(&etnaviv_obj->base);
} }
wake_up_all(&submit->gpu->fence_event);
if (submit->in_fence) if (submit->in_fence)
dma_fence_put(submit->in_fence); dma_fence_put(submit->in_fence);
if (submit->out_fence) if (submit->out_fence)
......
...@@ -1201,7 +1201,6 @@ static void retire_worker(struct work_struct *work) ...@@ -1201,7 +1201,6 @@ static void retire_worker(struct work_struct *work)
retire_work); retire_work);
u32 fence = gpu->completed_fence; u32 fence = gpu->completed_fence;
struct etnaviv_gem_submit *submit, *tmp; struct etnaviv_gem_submit *submit, *tmp;
unsigned int i;
mutex_lock(&gpu->lock); mutex_lock(&gpu->lock);
list_for_each_entry_safe(submit, tmp, &gpu->active_submit_list, node) { list_for_each_entry_safe(submit, tmp, &gpu->active_submit_list, node) {
...@@ -1210,9 +1209,6 @@ static void retire_worker(struct work_struct *work) ...@@ -1210,9 +1209,6 @@ static void retire_worker(struct work_struct *work)
list_del(&submit->node); list_del(&submit->node);
for (i = 0; i < submit->nr_bos; i++)
atomic_dec(&submit->bos[i].obj->gpu_active);
etnaviv_submit_put(submit); etnaviv_submit_put(submit);
/* /*
* We need to balance the runtime PM count caused by * We need to balance the runtime PM count caused by
...@@ -1227,8 +1223,6 @@ static void retire_worker(struct work_struct *work) ...@@ -1227,8 +1223,6 @@ static void retire_worker(struct work_struct *work)
gpu->retired_fence = fence; gpu->retired_fence = fence;
mutex_unlock(&gpu->lock); mutex_unlock(&gpu->lock);
wake_up_all(&gpu->fence_event);
} }
int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
...@@ -1429,10 +1423,6 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu, ...@@ -1429,10 +1423,6 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
/* We're committed to adding this command buffer, hold a PM reference */ /* We're committed to adding this command buffer, hold a PM reference */
pm_runtime_get_noresume(gpu->dev); pm_runtime_get_noresume(gpu->dev);
for (i = 0; i < submit->nr_bos; i++) {
struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
atomic_inc(&etnaviv_obj->gpu_active);
}
hangcheck_timer_reset(gpu); hangcheck_timer_reset(gpu);
ret = 0; ret = 0;
......
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