Commit a78422e9 authored by Danilo Krummrich's avatar Danilo Krummrich
Browse files

drm/sched: implement dynamic job-flow control



Currently, job flow control is implemented simply by limiting the number
of jobs in flight. Therefore, a scheduler is initialized with a credit
limit that corresponds to the number of jobs which can be sent to the
hardware.

This implies that for each job, drivers need to account for the maximum
job size possible in order to not overflow the ring buffer.

However, there are drivers, such as Nouveau, where the job size has a
rather large range. For such drivers it can easily happen that job
submissions not even filling the ring by 1% can block subsequent
submissions, which, in the worst case, can lead to the ring run dry.

In order to overcome this issue, allow for tracking the actual job size
instead of the number of jobs. Therefore, add a field to track a job's
credit count, which represents the number of credits a job contributes
to the scheduler's credit limit.

Signed-off-by: default avatarDanilo Krummrich <dakr@redhat.com>
Reviewed-by: default avatarLuben Tuikov <ltuikov89@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231110001638.71750-1-dakr@redhat.com
parent 36245bd0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -552,6 +552,12 @@ Overview
.. kernel-doc:: drivers/gpu/drm/scheduler/sched_main.c
   :doc: Overview

Flow Control
------------

.. kernel-doc:: drivers/gpu/drm/scheduler/sched_main.c
   :doc: Flow Control

Scheduler Function References
-----------------------------

+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
	if (!entity)
		return 0;

	return drm_sched_job_init(&(*job)->base, entity, owner);
	return drm_sched_job_init(&(*job)->base, entity, 1, owner);
}

int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
+1 −1
Original line number Diff line number Diff line
@@ -535,7 +535,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,

	ret = drm_sched_job_init(&submit->sched_job,
				 &ctx->sched_entity[args->pipe],
				 submit->ctx);
				 1, submit->ctx);
	if (ret)
		goto err_submit_put;

+1 −1
Original line number Diff line number Diff line
@@ -1917,7 +1917,7 @@ static int etnaviv_gpu_rpm_suspend(struct device *dev)
	u32 idle, mask;

	/* If there are any jobs in the HW queue, we're not idle */
	if (atomic_read(&gpu->sched.hw_rq_count))
	if (atomic_read(&gpu->sched.credit_count))
		return -EBUSY;

	/* Check whether the hardware (except FE and MC) is idle */
+1 −1
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ int lima_device_suspend(struct device *dev)

	/* check any task running */
	for (i = 0; i < lima_pipe_num; i++) {
		if (atomic_read(&ldev->pipe[i].base.hw_rq_count))
		if (atomic_read(&ldev->pipe[i].base.credit_count))
			return -EBUSY;
	}

Loading