Skip to content

Commit d214329

Browse files
Antonino Maniscalcobbrezillon
authored andcommitted
drm/panthor: Fix tiler OOM handling to allow incremental rendering
If the kernel couldn't allocate memory because we reached the maximum number of chunks but no render passes are in flight (panthor_heap_grow() returning -ENOMEM), we should defer the OOM handling to the FW by returning a NULL chunk. The FW will then call the tiler OOM exception handler, which is supposed to implement incremental rendering (execute an intermediate fragment job to flush the pending primitives, release the tiler memory that was used to store those primitives, and start over from where it stopped). Instead of checking for both ENOMEM and EBUSY, make panthor_heap_grow() return ENOMEM no matter the reason of this allocation failure, the FW doesn't care anyway. v3: - Add R-bs v2: - Make panthor_heap_grow() return -ENOMEM for all kind of allocation failures - Document the panthor_heap_grow() semantics Fixes: de85488 ("drm/panthor: Add the scheduler logical block") Signed-off-by: Antonino Maniscalco <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Liviu Dudau <[email protected]> Reviewed-by: Steven Price <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 713a750 commit d214329

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

drivers/gpu/drm/panthor/panthor_heap.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ int panthor_heap_return_chunk(struct panthor_heap_pool *pool,
410410
* @renderpasses_in_flight: Number of render passes currently in-flight.
411411
* @pending_frag_count: Number of fragment jobs waiting for execution/completion.
412412
* @new_chunk_gpu_va: Pointer used to return the chunk VA.
413+
*
414+
* Return:
415+
* - 0 if a new heap was allocated
416+
* - -ENOMEM if the tiler context reached the maximum number of chunks
417+
* or if too many render passes are in-flight
418+
* or if the allocation failed
419+
* - -EINVAL if any of the arguments passed to panthor_heap_grow() is invalid
413420
*/
414421
int panthor_heap_grow(struct panthor_heap_pool *pool,
415422
u64 heap_gpu_va,
@@ -439,10 +446,7 @@ int panthor_heap_grow(struct panthor_heap_pool *pool,
439446
* handler provided by the userspace driver, if any).
440447
*/
441448
if (renderpasses_in_flight > heap->target_in_flight ||
442-
(pending_frag_count > 0 && heap->chunk_count >= heap->max_chunks)) {
443-
ret = -EBUSY;
444-
goto out_unlock;
445-
} else if (heap->chunk_count >= heap->max_chunks) {
449+
heap->chunk_count >= heap->max_chunks) {
446450
ret = -ENOMEM;
447451
goto out_unlock;
448452
}

drivers/gpu/drm/panthor/panthor_sched.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,12 @@ static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id)
13851385
pending_frag_count, &new_chunk_va);
13861386
}
13871387

1388-
if (ret && ret != -EBUSY) {
1388+
/* If the heap context doesn't have memory for us, we want to let the
1389+
* FW try to reclaim memory by waiting for fragment jobs to land or by
1390+
* executing the tiler OOM exception handler, which is supposed to
1391+
* implement incremental rendering.
1392+
*/
1393+
if (ret && ret != -ENOMEM) {
13891394
drm_warn(&ptdev->base, "Failed to extend the tiler heap\n");
13901395
group->fatal_queues |= BIT(cs_id);
13911396
sched_queue_delayed_work(sched, tick, 0);

0 commit comments

Comments
 (0)