Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions drivers/gpu/drm/v3d/v3d_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
*/

#include <linux/kthread.h>
#include <linux/moduleparam.h>

#include "v3d_drv.h"
#include "v3d_regs.h"
#include "v3d_trace.h"

static uint timeout = 500;
module_param(timeout, uint, 0444);
MODULE_PARM_DESC(timeout,
"Timeout for a job in ms (0 means infinity and default is 500 ms)");

static struct v3d_job *
to_v3d_job(struct drm_sched_job *sched_job)
{
Expand Down Expand Up @@ -226,6 +232,17 @@ v3d_csd_job_run(struct drm_sched_job *sched_job)
struct dma_fence *fence;
int i;

/* This error is set to -ECANCELED by drm_sched_resubmit_jobs() if this
* job timed out more than sched_job->sched->hang_limit times.
*/
int error = sched_job->s_fence->finished.error;

if (unlikely(error < 0)) {
DRM_WARN("Skipping CSD job resubmission due to previous error (%d)\n",
error);
return ERR_PTR(error);
}

v3d->csd_job = job;

v3d_invalidate_caches(v3d);
Expand Down Expand Up @@ -394,13 +411,13 @@ v3d_sched_init(struct v3d_dev *v3d)
{
int hw_jobs_limit = 1;
int job_hang_limit = 0;
int hang_limit_ms = 500;
long timeout_jiffies = timeout ?
msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
int ret;

ret = drm_sched_init(&v3d->queue[V3D_BIN].sched,
&v3d_bin_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms),
hw_jobs_limit, job_hang_limit, timeout_jiffies,
"v3d_bin");
if (ret) {
dev_err(v3d->dev, "Failed to create bin scheduler: %d.", ret);
Expand All @@ -409,8 +426,7 @@ v3d_sched_init(struct v3d_dev *v3d)

ret = drm_sched_init(&v3d->queue[V3D_RENDER].sched,
&v3d_render_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms),
hw_jobs_limit, job_hang_limit, timeout_jiffies,
"v3d_render");
if (ret) {
dev_err(v3d->dev, "Failed to create render scheduler: %d.",
Expand All @@ -421,8 +437,7 @@ v3d_sched_init(struct v3d_dev *v3d)

ret = drm_sched_init(&v3d->queue[V3D_TFU].sched,
&v3d_tfu_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms),
hw_jobs_limit, job_hang_limit, timeout_jiffies,
"v3d_tfu");
if (ret) {
dev_err(v3d->dev, "Failed to create TFU scheduler: %d.",
Expand All @@ -434,8 +449,7 @@ v3d_sched_init(struct v3d_dev *v3d)
if (v3d_has_csd(v3d)) {
ret = drm_sched_init(&v3d->queue[V3D_CSD].sched,
&v3d_csd_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms),
hw_jobs_limit, job_hang_limit, timeout_jiffies,
"v3d_csd");
if (ret) {
dev_err(v3d->dev, "Failed to create CSD scheduler: %d.",
Expand All @@ -446,8 +460,7 @@ v3d_sched_init(struct v3d_dev *v3d)

ret = drm_sched_init(&v3d->queue[V3D_CACHE_CLEAN].sched,
&v3d_cache_clean_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms),
hw_jobs_limit, job_hang_limit, timeout_jiffies,
"v3d_cache_clean");
if (ret) {
dev_err(v3d->dev, "Failed to create CACHE_CLEAN scheduler: %d.",
Expand Down