Lines Matching +full:mmu +full:- +full:500
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
2 /* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
4 #include <linux/iosys-map.h>
34 return -ENOMEM; in lima_sched_slab_init()
43 if (!--lima_fence_slab_refcnt) { in lima_sched_slab_fini()
63 return f->pipe->base.name; in lima_fence_get_timeline_name()
78 call_rcu(&f->base.rcu, lima_fence_release_rcu); in lima_fence_release()
95 fence->pipe = pipe; in lima_fence_create()
96 dma_fence_init(&fence->base, &lima_fence_ops, &pipe->fence_lock, in lima_fence_create()
97 pipe->fence_context, ++pipe->fence_seqno); in lima_fence_create()
119 task->bos = kmemdup(bos, sizeof(*bos) * num_bos, GFP_KERNEL); in lima_sched_task_init()
120 if (!task->bos) in lima_sched_task_init()
121 return -ENOMEM; in lima_sched_task_init()
124 drm_gem_object_get(&bos[i]->base.base); in lima_sched_task_init()
126 err = drm_sched_job_init(&task->base, &context->base, vm); in lima_sched_task_init()
128 kfree(task->bos); in lima_sched_task_init()
132 drm_sched_job_arm(&task->base); in lima_sched_task_init()
134 task->num_bos = num_bos; in lima_sched_task_init()
135 task->vm = lima_vm_get(vm); in lima_sched_task_init()
144 drm_sched_job_cleanup(&task->base); in lima_sched_task_fini()
146 if (task->bos) { in lima_sched_task_fini()
147 for (i = 0; i < task->num_bos; i++) in lima_sched_task_fini()
148 drm_gem_object_put(&task->bos[i]->base.base); in lima_sched_task_fini()
149 kfree(task->bos); in lima_sched_task_fini()
152 lima_vm_put(task->vm); in lima_sched_task_fini()
159 struct drm_gpu_scheduler *sched = &pipe->base; in lima_sched_context_init()
161 return drm_sched_entity_init(&context->base, DRM_SCHED_PRIORITY_NORMAL, in lima_sched_context_init()
168 drm_sched_entity_destroy(&context->base); in lima_sched_context_fini()
173 struct dma_fence *fence = dma_fence_get(&task->base.s_fence->finished); in lima_sched_context_queue_task()
176 drm_sched_entity_push_job(&task->base); in lima_sched_context_queue_task()
185 ret = pm_runtime_resume_and_get(ldev->dev); in lima_pm_busy()
189 lima_devfreq_record_busy(&ldev->devfreq); in lima_pm_busy()
195 lima_devfreq_record_idle(&ldev->devfreq); in lima_pm_idle()
198 pm_runtime_mark_last_busy(ldev->dev); in lima_pm_idle()
199 pm_runtime_put_autosuspend(ldev->dev); in lima_pm_idle()
205 struct lima_sched_pipe *pipe = to_lima_pipe(job->sched); in lima_sched_run_job()
206 struct lima_device *ldev = pipe->ldev; in lima_sched_run_job()
211 if (job->s_fence->finished.error < 0) in lima_sched_run_job()
220 dma_fence_put(&fence->base); in lima_sched_run_job()
224 task->fence = &fence->base; in lima_sched_run_job()
229 dma_fence_get(task->fence); in lima_sched_run_job()
231 pipe->current_task = task; in lima_sched_run_job()
233 /* this is needed for MMU to work correctly, otherwise GP/PP in lima_sched_run_job()
248 for (i = 0; i < pipe->num_l2_cache; i++) in lima_sched_run_job()
249 lima_l2_cache_flush(pipe->l2_cache[i]); in lima_sched_run_job()
251 lima_vm_put(pipe->current_vm); in lima_sched_run_job()
252 pipe->current_vm = lima_vm_get(task->vm); in lima_sched_run_job()
254 if (pipe->bcast_mmu) in lima_sched_run_job()
255 lima_mmu_switch_vm(pipe->bcast_mmu, pipe->current_vm); in lima_sched_run_job()
257 for (i = 0; i < pipe->num_mmu; i++) in lima_sched_run_job()
258 lima_mmu_switch_vm(pipe->mmu[i], pipe->current_vm); in lima_sched_run_job()
263 pipe->error = false; in lima_sched_run_job()
264 pipe->task_run(pipe, task); in lima_sched_run_job()
266 return task->fence; in lima_sched_run_job()
272 struct lima_sched_pipe *pipe = to_lima_pipe(task->base.sched); in lima_sched_build_error_task_list()
273 struct lima_ip *ip = pipe->processor[0]; in lima_sched_build_error_task_list()
274 int pipe_id = ip->id == lima_ip_gp ? lima_pipe_gp : lima_pipe_pp; in lima_sched_build_error_task_list()
275 struct lima_device *dev = ip->dev; in lima_sched_build_error_task_list()
277 container_of(task->base.entity, in lima_sched_build_error_task_list()
290 mutex_lock(&dev->error_task_list_lock); in lima_sched_build_error_task_list()
292 if (dev->dump.num_tasks >= lima_max_error_tasks) { in lima_sched_build_error_task_list()
293 dev_info(dev->dev, "fail to save task state from %s pid %d: " in lima_sched_build_error_task_list()
294 "error task list is full\n", ctx->pname, ctx->pid); in lima_sched_build_error_task_list()
299 size = sizeof(struct lima_dump_chunk) + pipe->frame_size; in lima_sched_build_error_task_list()
301 size += sizeof(struct lima_dump_chunk) + sizeof(ctx->pname); in lima_sched_build_error_task_list()
305 for (i = 0; i < task->num_bos; i++) { in lima_sched_build_error_task_list()
306 struct lima_bo *bo = task->bos[i]; in lima_sched_build_error_task_list()
309 size += bo->heap_size ? bo->heap_size : lima_bo_size(bo); in lima_sched_build_error_task_list()
316 dev_err(dev->dev, "fail to alloc task dump buffer of size %x\n", in lima_sched_build_error_task_list()
321 et->data = et + 1; in lima_sched_build_error_task_list()
322 et->size = task_size; in lima_sched_build_error_task_list()
324 dt = et->data; in lima_sched_build_error_task_list()
326 dt->id = pipe_id; in lima_sched_build_error_task_list()
327 dt->size = size; in lima_sched_build_error_task_list()
331 chunk->id = LIMA_DUMP_CHUNK_FRAME; in lima_sched_build_error_task_list()
332 chunk->size = pipe->frame_size; in lima_sched_build_error_task_list()
333 memcpy(chunk + 1, task->frame, pipe->frame_size); in lima_sched_build_error_task_list()
334 dt->num_chunks++; in lima_sched_build_error_task_list()
336 chunk = (void *)(chunk + 1) + chunk->size; in lima_sched_build_error_task_list()
338 chunk->id = LIMA_DUMP_CHUNK_PROCESS_NAME; in lima_sched_build_error_task_list()
339 chunk->size = sizeof(ctx->pname); in lima_sched_build_error_task_list()
340 memcpy(chunk + 1, ctx->pname, sizeof(ctx->pname)); in lima_sched_build_error_task_list()
341 dt->num_chunks++; in lima_sched_build_error_task_list()
343 pid_chunk = (void *)(chunk + 1) + chunk->size; in lima_sched_build_error_task_list()
345 pid_chunk->id = LIMA_DUMP_CHUNK_PROCESS_ID; in lima_sched_build_error_task_list()
346 pid_chunk->pid = ctx->pid; in lima_sched_build_error_task_list()
347 dt->num_chunks++; in lima_sched_build_error_task_list()
349 buffer_chunk = (void *)(pid_chunk + 1) + pid_chunk->size; in lima_sched_build_error_task_list()
350 for (i = 0; i < task->num_bos; i++) { in lima_sched_build_error_task_list()
351 struct lima_bo *bo = task->bos[i]; in lima_sched_build_error_task_list()
355 buffer_chunk->id = LIMA_DUMP_CHUNK_BUFFER; in lima_sched_build_error_task_list()
356 buffer_chunk->va = lima_vm_get_va(task->vm, bo); in lima_sched_build_error_task_list()
358 if (bo->heap_size) { in lima_sched_build_error_task_list()
359 buffer_chunk->size = bo->heap_size; in lima_sched_build_error_task_list()
361 data = vmap(bo->base.pages, bo->heap_size >> PAGE_SHIFT, in lima_sched_build_error_task_list()
368 memcpy(buffer_chunk + 1, data, buffer_chunk->size); in lima_sched_build_error_task_list()
372 buffer_chunk->size = lima_bo_size(bo); in lima_sched_build_error_task_list()
374 ret = drm_gem_vmap_unlocked(&bo->base.base, &map); in lima_sched_build_error_task_list()
380 memcpy(buffer_chunk + 1, map.vaddr, buffer_chunk->size); in lima_sched_build_error_task_list()
382 drm_gem_vunmap_unlocked(&bo->base.base, &map); in lima_sched_build_error_task_list()
385 buffer_chunk = (void *)(buffer_chunk + 1) + buffer_chunk->size; in lima_sched_build_error_task_list()
386 dt->num_chunks++; in lima_sched_build_error_task_list()
389 list_add(&et->list, &dev->error_task_list); in lima_sched_build_error_task_list()
390 dev->dump.size += et->size; in lima_sched_build_error_task_list()
391 dev->dump.num_tasks++; in lima_sched_build_error_task_list()
393 dev_info(dev->dev, "save error task state success\n"); in lima_sched_build_error_task_list()
396 mutex_unlock(&dev->error_task_list_lock); in lima_sched_build_error_task_list()
401 struct lima_sched_pipe *pipe = to_lima_pipe(job->sched); in lima_sched_timedout_job()
403 struct lima_device *ldev = pipe->ldev; in lima_sched_timedout_job()
405 if (!pipe->error) in lima_sched_timedout_job()
408 drm_sched_stop(&pipe->base, &task->base); in lima_sched_timedout_job()
410 drm_sched_increase_karma(&task->base); in lima_sched_timedout_job()
415 pipe->task_error(pipe); in lima_sched_timedout_job()
417 if (pipe->bcast_mmu) in lima_sched_timedout_job()
418 lima_mmu_page_fault_resume(pipe->bcast_mmu); in lima_sched_timedout_job()
422 for (i = 0; i < pipe->num_mmu; i++) in lima_sched_timedout_job()
423 lima_mmu_page_fault_resume(pipe->mmu[i]); in lima_sched_timedout_job()
426 lima_vm_put(pipe->current_vm); in lima_sched_timedout_job()
427 pipe->current_vm = NULL; in lima_sched_timedout_job()
428 pipe->current_task = NULL; in lima_sched_timedout_job()
432 drm_sched_resubmit_jobs(&pipe->base); in lima_sched_timedout_job()
433 drm_sched_start(&pipe->base, true); in lima_sched_timedout_job()
441 struct lima_sched_pipe *pipe = to_lima_pipe(job->sched); in lima_sched_free_job()
442 struct lima_vm *vm = task->vm; in lima_sched_free_job()
443 struct lima_bo **bos = task->bos; in lima_sched_free_job()
446 dma_fence_put(task->fence); in lima_sched_free_job()
448 for (i = 0; i < task->num_bos; i++) in lima_sched_free_job()
452 kmem_cache_free(pipe->task_slab, task); in lima_sched_free_job()
467 for (i = 0; i < pipe->num_l2_cache; i++) in lima_sched_recover_work()
468 lima_l2_cache_flush(pipe->l2_cache[i]); in lima_sched_recover_work()
470 if (pipe->bcast_mmu) { in lima_sched_recover_work()
471 lima_mmu_flush_tlb(pipe->bcast_mmu); in lima_sched_recover_work()
473 for (i = 0; i < pipe->num_mmu; i++) in lima_sched_recover_work()
474 lima_mmu_flush_tlb(pipe->mmu[i]); in lima_sched_recover_work()
477 if (pipe->task_recover(pipe)) in lima_sched_recover_work()
478 drm_sched_fault(&pipe->base); in lima_sched_recover_work()
484 lima_sched_timeout_ms : 500; in lima_sched_pipe_init()
486 pipe->fence_context = dma_fence_context_alloc(1); in lima_sched_pipe_init()
487 spin_lock_init(&pipe->fence_lock); in lima_sched_pipe_init()
489 INIT_WORK(&pipe->recover_work, lima_sched_recover_work); in lima_sched_pipe_init()
491 return drm_sched_init(&pipe->base, &lima_sched_ops, 1, in lima_sched_pipe_init()
494 NULL, name, pipe->ldev->dev); in lima_sched_pipe_init()
499 drm_sched_fini(&pipe->base); in lima_sched_pipe_fini()
504 struct lima_sched_task *task = pipe->current_task; in lima_sched_pipe_task_done()
505 struct lima_device *ldev = pipe->ldev; in lima_sched_pipe_task_done()
507 if (pipe->error) { in lima_sched_pipe_task_done()
508 if (task && task->recoverable) in lima_sched_pipe_task_done()
509 schedule_work(&pipe->recover_work); in lima_sched_pipe_task_done()
511 drm_sched_fault(&pipe->base); in lima_sched_pipe_task_done()
513 pipe->task_fini(pipe); in lima_sched_pipe_task_done()
514 dma_fence_signal(task->fence); in lima_sched_pipe_task_done()