cregit-Linux how code gets into the kernel

Release 4.17 drivers/gpu/drm/etnaviv/etnaviv_sched.c

/*
 * Copyright (C) 2017 Etnaviv Project
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <linux/kthread.h>

#include "etnaviv_drv.h"
#include "etnaviv_dump.h"
#include "etnaviv_gem.h"
#include "etnaviv_gpu.h"
#include "etnaviv_sched.h"


static int etnaviv_job_hang_limit = 0;
module_param_named(job_hang_limit, etnaviv_job_hang_limit, int , 0444);

static int etnaviv_hw_jobs_limit = 4;
module_param_named(hw_job_limit, etnaviv_hw_jobs_limit, int , 0444);


static struct dma_fence * etnaviv_sched_dependency(struct drm_sched_job *sched_job, struct drm_sched_entity *entity) { struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job); struct dma_fence *fence; int i; if (unlikely(submit->in_fence)) { fence = submit->in_fence; submit->in_fence = NULL; if (!dma_fence_is_signaled(fence)) return fence; dma_fence_put(fence); } for (i = 0; i < submit->nr_bos; i++) { struct etnaviv_gem_submit_bo *bo = &submit->bos[i]; int j; if (bo->excl) { fence = bo->excl; bo->excl = NULL; if (!dma_fence_is_signaled(fence)) return fence; dma_fence_put(fence); } for (j = 0; j < bo->nr_shared; j++) { if (!bo->shared[j]) continue; fence = bo->shared[j]; bo->shared[j] = NULL; if (!dma_fence_is_signaled(fence)) return fence; dma_fence_put(fence); } kfree(bo->shared); bo->nr_shared = 0; bo->shared = NULL; } return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach22799.56%266.67%
Fabio Estevam10.44%133.33%
Total228100.00%3100.00%


static struct dma_fence *etnaviv_sched_run_job(struct drm_sched_job *sched_job) { struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job); struct dma_fence *fence = NULL; if (likely(!sched_job->s_fence->finished.error)) fence = etnaviv_gpu_submit(submit); else dev_dbg(submit->gpu->dev, "skipping bad job\n"); return fence; }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach6598.48%266.67%
Fabio Estevam11.52%133.33%
Total66100.00%3100.00%


static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job) { struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job); struct etnaviv_gpu *gpu = submit->gpu; /* block scheduler */ kthread_park(gpu->sched.thread); drm_sched_hw_job_reset(&gpu->sched, sched_job); /* get the GPU back into the init state */ etnaviv_core_dump(gpu); etnaviv_gpu_recover_hang(gpu); /* restart scheduler after GPU is usable again */ drm_sched_job_recovery(&gpu->sched); kthread_unpark(gpu->sched.thread); }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach79100.00%2100.00%
Total79100.00%2100.00%


static void etnaviv_sched_free_job(struct drm_sched_job *sched_job) { struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job); etnaviv_submit_put(submit); }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach26100.00%2100.00%
Total26100.00%2100.00%

static const struct drm_sched_backend_ops etnaviv_sched_ops = { .dependency = etnaviv_sched_dependency, .run_job = etnaviv_sched_run_job, .timedout_job = etnaviv_sched_timedout_job, .free_job = etnaviv_sched_free_job, };
int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity, struct etnaviv_gem_submit *submit) { int ret; ret = drm_sched_job_init(&submit->sched_job, &submit->gpu->sched, sched_entity, submit->cmdbuf.ctx); if (ret) return ret; submit->out_fence = dma_fence_get(&submit->sched_job.s_fence->finished); mutex_lock(&submit->gpu->fence_idr_lock); submit->out_fence_id = idr_alloc_cyclic(&submit->gpu->fence_idr, submit->out_fence, 0, INT_MAX, GFP_KERNEL); mutex_unlock(&submit->gpu->fence_idr_lock); if (submit->out_fence_id < 0) return -ENOMEM; /* the scheduler holds on to the job now */ kref_get(&submit->refcount); drm_sched_entity_push_job(&submit->sched_job, sched_entity); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach144100.00%1100.00%
Total144100.00%1100.00%


int etnaviv_sched_init(struct etnaviv_gpu *gpu) { int ret; ret = drm_sched_init(&gpu->sched, &etnaviv_sched_ops, etnaviv_hw_jobs_limit, etnaviv_job_hang_limit, msecs_to_jiffies(500), dev_name(gpu->dev)); if (ret) return ret; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach52100.00%1100.00%
Total52100.00%1100.00%


void etnaviv_sched_fini(struct etnaviv_gpu *gpu) { drm_sched_fini(&gpu->sched); }

Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach18100.00%1100.00%
Total18100.00%1100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Lucas Stach69299.71%480.00%
Fabio Estevam20.29%120.00%
Total694100.00%5100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.