Commit 46990918 authored by Danilo Krummrich's avatar Danilo Krummrich

drm/nouveau: enable dynamic job-flow control

Make use of the scheduler's credit limit and scheduler job's credit
count to account for the actual size of a job, such that we fill up the
ring efficiently.
Signed-off-by: default avatarDanilo Krummrich <dakr@redhat.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231114002728.3491-2-dakr@redhat.com
parent 5f03a507
...@@ -337,7 +337,8 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) ...@@ -337,7 +337,8 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
if (ret) if (ret)
goto done; goto done;
ret = nouveau_sched_init(&chan->sched, drm, drm->sched_wq); ret = nouveau_sched_init(&chan->sched, drm, drm->sched_wq,
chan->chan->dma.ib_max);
if (ret) if (ret)
goto done; goto done;
......
...@@ -320,7 +320,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname, ...@@ -320,7 +320,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
* locks which indirectly or directly are held for allocations * locks which indirectly or directly are held for allocations
* elsewhere. * elsewhere.
*/ */
ret = nouveau_sched_init(&cli->sched, drm, NULL); ret = nouveau_sched_init(&cli->sched, drm, NULL, 1);
if (ret) if (ret)
goto done; goto done;
......
...@@ -231,10 +231,12 @@ nouveau_exec_job_init(struct nouveau_exec_job **pjob, ...@@ -231,10 +231,12 @@ nouveau_exec_job_init(struct nouveau_exec_job **pjob,
} }
} }
args.file_priv = __args->file_priv;
job->chan = __args->chan; job->chan = __args->chan;
args.sched = __args->sched; args.sched = __args->sched;
args.file_priv = __args->file_priv; /* Plus one to account for the HW fence. */
args.credits = job->push.count + 1;
args.in_sync.count = __args->in_sync.count; args.in_sync.count = __args->in_sync.count;
args.in_sync.s = __args->in_sync.s; args.in_sync.s = __args->in_sync.s;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "nouveau_abi16.h" #include "nouveau_abi16.h"
#include "nouveau_sched.h" #include "nouveau_sched.h"
#define NOUVEAU_SCHED_HW_SUBMISSIONS 1
#define NOUVEAU_SCHED_JOB_TIMEOUT_MS 10000 #define NOUVEAU_SCHED_JOB_TIMEOUT_MS 10000
/* Starts at 0, since the DRM scheduler interprets those parameters as (initial) /* Starts at 0, since the DRM scheduler interprets those parameters as (initial)
...@@ -85,10 +84,10 @@ nouveau_job_init(struct nouveau_job *job, ...@@ -85,10 +84,10 @@ nouveau_job_init(struct nouveau_job *job,
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_objs; goto err_free_objs;
} }
} }
ret = drm_sched_job_init(&job->base, &sched->entity, 1, NULL); ret = drm_sched_job_init(&job->base, &sched->entity,
args->credits, NULL);
if (ret) if (ret)
goto err_free_chains; goto err_free_chains;
...@@ -401,7 +400,7 @@ static const struct drm_sched_backend_ops nouveau_sched_ops = { ...@@ -401,7 +400,7 @@ static const struct drm_sched_backend_ops nouveau_sched_ops = {
int int
nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm, nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm,
struct workqueue_struct *wq) struct workqueue_struct *wq, u32 credit_limit)
{ {
struct drm_gpu_scheduler *drm_sched = &sched->base; struct drm_gpu_scheduler *drm_sched = &sched->base;
struct drm_sched_entity *entity = &sched->entity; struct drm_sched_entity *entity = &sched->entity;
...@@ -419,7 +418,7 @@ nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm, ...@@ -419,7 +418,7 @@ nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm,
ret = drm_sched_init(drm_sched, &nouveau_sched_ops, wq, ret = drm_sched_init(drm_sched, &nouveau_sched_ops, wq,
NOUVEAU_SCHED_PRIORITY_COUNT, NOUVEAU_SCHED_PRIORITY_COUNT,
NOUVEAU_SCHED_HW_SUBMISSIONS, 0, job_hang_limit, credit_limit, 0, job_hang_limit,
NULL, NULL, "nouveau_sched", drm->dev->dev); NULL, NULL, "nouveau_sched", drm->dev->dev);
if (ret) if (ret)
goto fail_wq; goto fail_wq;
......
...@@ -27,6 +27,7 @@ enum nouveau_job_state { ...@@ -27,6 +27,7 @@ enum nouveau_job_state {
struct nouveau_job_args { struct nouveau_job_args {
struct drm_file *file_priv; struct drm_file *file_priv;
struct nouveau_sched *sched; struct nouveau_sched *sched;
u32 credits;
enum dma_resv_usage resv_usage; enum dma_resv_usage resv_usage;
bool sync; bool sync;
...@@ -111,7 +112,7 @@ struct nouveau_sched { ...@@ -111,7 +112,7 @@ struct nouveau_sched {
}; };
int nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm, int nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm,
struct workqueue_struct *wq); struct workqueue_struct *wq, u32 credit_limit);
void nouveau_sched_fini(struct nouveau_sched *sched); void nouveau_sched_fini(struct nouveau_sched *sched);
#endif #endif
...@@ -1607,9 +1607,11 @@ nouveau_uvmm_bind_job_init(struct nouveau_uvmm_bind_job **pjob, ...@@ -1607,9 +1607,11 @@ nouveau_uvmm_bind_job_init(struct nouveau_uvmm_bind_job **pjob,
init_completion(&job->complete); init_completion(&job->complete);
args.sched = __args->sched;
args.file_priv = __args->file_priv; args.file_priv = __args->file_priv;
args.sched = __args->sched;
args.credits = 1;
args.in_sync.count = __args->in_sync.count; args.in_sync.count = __args->in_sync.count;
args.in_sync.s = __args->in_sync.s; args.in_sync.s = __args->in_sync.s;
......
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