Lines Matching +full:0 +full:- +full:job +full:- +full:ring
1 // SPDX-License-Identifier: GPL-2.0-only
14 static struct dma_fence *msm_job_run(struct drm_sched_job *job) in msm_job_run() argument
16 struct msm_gem_submit *submit = to_msm_submit(job); in msm_job_run()
17 struct msm_fence_context *fctx = submit->ring->fctx; in msm_job_run()
18 struct msm_gpu *gpu = submit->gpu; in msm_job_run()
19 struct msm_drm_private *priv = gpu->dev->dev_private; in msm_job_run()
22 msm_fence_init(submit->hw_fence, fctx); in msm_job_run()
24 mutex_lock(&priv->lru.lock); in msm_job_run()
26 for (i = 0; i < submit->nr_bos; i++) { in msm_job_run()
27 struct drm_gem_object *obj = submit->bos[i].obj; in msm_job_run()
30 submit->bos[i].flags &= ~BO_PINNED; in msm_job_run()
33 mutex_unlock(&priv->lru.lock); in msm_job_run()
35 /* TODO move submit path over to using a per-ring lock.. */ in msm_job_run()
36 mutex_lock(&gpu->lock); in msm_job_run()
40 mutex_unlock(&gpu->lock); in msm_job_run()
42 return dma_fence_get(submit->hw_fence); in msm_job_run()
45 static void msm_job_free(struct drm_sched_job *job) in msm_job_free() argument
47 struct msm_gem_submit *submit = to_msm_submit(job); in msm_job_free()
49 drm_sched_job_cleanup(job); in msm_job_free()
61 struct msm_ringbuffer *ring; in msm_ringbuffer_new() local
69 ring = kzalloc(sizeof(*ring), GFP_KERNEL); in msm_ringbuffer_new()
70 if (!ring) { in msm_ringbuffer_new()
71 ret = -ENOMEM; in msm_ringbuffer_new()
75 ring->gpu = gpu; in msm_ringbuffer_new()
76 ring->id = id; in msm_ringbuffer_new()
78 ring->start = msm_gem_kernel_new(gpu->dev, MSM_GPU_RINGBUFFER_SZ, in msm_ringbuffer_new()
80 gpu->aspace, &ring->bo, &ring->iova); in msm_ringbuffer_new()
82 if (IS_ERR(ring->start)) { in msm_ringbuffer_new()
83 ret = PTR_ERR(ring->start); in msm_ringbuffer_new()
84 ring->start = NULL; in msm_ringbuffer_new()
88 msm_gem_object_set_name(ring->bo, "ring%d", id); in msm_ringbuffer_new()
90 ring->end = ring->start + (MSM_GPU_RINGBUFFER_SZ >> 2); in msm_ringbuffer_new()
91 ring->next = ring->start; in msm_ringbuffer_new()
92 ring->cur = ring->start; in msm_ringbuffer_new()
94 ring->memptrs = memptrs; in msm_ringbuffer_new()
95 ring->memptrs_iova = memptrs_iova; in msm_ringbuffer_new()
100 ret = drm_sched_init(&ring->sched, &msm_sched_ops, in msm_ringbuffer_new()
101 num_hw_submissions, 0, sched_timeout, in msm_ringbuffer_new()
102 NULL, NULL, to_msm_bo(ring->bo)->name, gpu->dev->dev); in msm_ringbuffer_new()
107 INIT_LIST_HEAD(&ring->submits); in msm_ringbuffer_new()
108 spin_lock_init(&ring->submit_lock); in msm_ringbuffer_new()
109 spin_lock_init(&ring->preempt_lock); in msm_ringbuffer_new()
111 snprintf(name, sizeof(name), "gpu-ring-%d", ring->id); in msm_ringbuffer_new()
113 ring->fctx = msm_fence_context_alloc(gpu->dev, &ring->memptrs->fence, name); in msm_ringbuffer_new()
115 return ring; in msm_ringbuffer_new()
118 msm_ringbuffer_destroy(ring); in msm_ringbuffer_new()
122 void msm_ringbuffer_destroy(struct msm_ringbuffer *ring) in msm_ringbuffer_destroy() argument
124 if (IS_ERR_OR_NULL(ring)) in msm_ringbuffer_destroy()
127 drm_sched_fini(&ring->sched); in msm_ringbuffer_destroy()
129 msm_fence_context_free(ring->fctx); in msm_ringbuffer_destroy()
131 msm_gem_kernel_put(ring->bo, ring->gpu->aspace); in msm_ringbuffer_destroy()
133 kfree(ring); in msm_ringbuffer_destroy()