Commit 2d7d2c4e authored by Rob Clark's avatar Rob Clark

drm/msm/gem: Split out submit_unpin_objects() helper

Untangle unpinning from unlock/unref loop.  The unpin only happens in
error paths so it is easier to decouple from the normal unlock path.

Since we never have an intermediate state where a subset of buffers
are pinned (ie. we never bail out of the pin or unpin loops) we can
replace the bo state flag bit with a global flag in the submit.
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/568335/
parent ceab575c
...@@ -274,8 +274,9 @@ struct msm_gem_submit { ...@@ -274,8 +274,9 @@ struct msm_gem_submit {
int fence_id; /* key into queue->fence_idr */ int fence_id; /* key into queue->fence_idr */
struct msm_gpu_submitqueue *queue; struct msm_gpu_submitqueue *queue;
struct pid *pid; /* submitting process */ struct pid *pid; /* submitting process */
bool fault_dumped; /* Limit devcoredump dumping to one per submit */ bool bos_pinned : 1;
bool in_rb; /* "sudo" mode, copy cmds into RB */ bool fault_dumped:1;/* Limit devcoredump dumping to one per submit */
bool in_rb : 1; /* "sudo" mode, copy cmds into RB */
struct msm_ringbuffer *ring; struct msm_ringbuffer *ring;
unsigned int nr_cmds; unsigned int nr_cmds;
unsigned int nr_bos; unsigned int nr_bos;
...@@ -292,7 +293,6 @@ struct msm_gem_submit { ...@@ -292,7 +293,6 @@ struct msm_gem_submit {
struct { struct {
/* make sure these don't conflict w/ MSM_SUBMIT_BO_x */ /* make sure these don't conflict w/ MSM_SUBMIT_BO_x */
#define BO_LOCKED 0x4000 /* obj lock is held */ #define BO_LOCKED 0x4000 /* obj lock is held */
#define BO_PINNED 0x2000 /* obj (pages) is pinned and on active list */
uint32_t flags; uint32_t flags;
union { union {
struct drm_gem_object *obj; struct drm_gem_object *obj;
......
...@@ -265,9 +265,6 @@ static void submit_cleanup_bo(struct msm_gem_submit *submit, int i, ...@@ -265,9 +265,6 @@ static void submit_cleanup_bo(struct msm_gem_submit *submit, int i,
*/ */
submit->bos[i].flags &= ~cleanup_flags; submit->bos[i].flags &= ~cleanup_flags;
if (flags & BO_PINNED)
msm_gem_unpin_locked(obj);
if (flags & BO_LOCKED) if (flags & BO_LOCKED)
dma_resv_unlock(obj->resv); dma_resv_unlock(obj->resv);
} }
...@@ -407,13 +404,28 @@ static int submit_pin_objects(struct msm_gem_submit *submit) ...@@ -407,13 +404,28 @@ static int submit_pin_objects(struct msm_gem_submit *submit)
mutex_lock(&priv->lru.lock); mutex_lock(&priv->lru.lock);
for (i = 0; i < submit->nr_bos; i++) { for (i = 0; i < submit->nr_bos; i++) {
msm_gem_pin_obj_locked(submit->bos[i].obj); msm_gem_pin_obj_locked(submit->bos[i].obj);
submit->bos[i].flags |= BO_PINNED;
} }
mutex_unlock(&priv->lru.lock); mutex_unlock(&priv->lru.lock);
submit->bos_pinned = true;
return ret; return ret;
} }
static void submit_unpin_objects(struct msm_gem_submit *submit)
{
if (!submit->bos_pinned)
return;
for (int i = 0; i < submit->nr_bos; i++) {
struct drm_gem_object *obj = submit->bos[i].obj;
msm_gem_unpin_locked(obj);
}
submit->bos_pinned = false;
}
static void submit_attach_object_fences(struct msm_gem_submit *submit) static void submit_attach_object_fences(struct msm_gem_submit *submit)
{ {
int i; int i;
...@@ -525,7 +537,7 @@ static void submit_cleanup(struct msm_gem_submit *submit, bool error) ...@@ -525,7 +537,7 @@ static void submit_cleanup(struct msm_gem_submit *submit, bool error)
unsigned i; unsigned i;
if (error) if (error)
cleanup_flags |= BO_PINNED; submit_unpin_objects(submit);
for (i = 0; i < submit->nr_bos; i++) { for (i = 0; i < submit->nr_bos; i++) {
struct drm_gem_object *obj = submit->bos[i].obj; struct drm_gem_object *obj = submit->bos[i].obj;
......
...@@ -29,9 +29,10 @@ static struct dma_fence *msm_job_run(struct drm_sched_job *job) ...@@ -29,9 +29,10 @@ static struct dma_fence *msm_job_run(struct drm_sched_job *job)
struct drm_gem_object *obj = submit->bos[i].obj; struct drm_gem_object *obj = submit->bos[i].obj;
msm_gem_unpin_active(obj); msm_gem_unpin_active(obj);
submit->bos[i].flags &= ~BO_PINNED;
} }
submit->bos_pinned = false;
mutex_unlock(&priv->lru.lock); mutex_unlock(&priv->lru.lock);
msm_gpu_submit(gpu, submit); msm_gpu_submit(gpu, submit);
......
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