lkml.org 
[lkml]   [2020]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.7 126/179] drm/amdgpu: fix preemption unit test
    Date
    From: Jack Xiao <Jack.Xiao@amd.com>

    [ Upstream commit d845a2051b6b673fab4229b920ea04c7c4352b51 ]

    Remove signaled jobs from job list and ensure the
    job was indeed preempted.

    Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 20 +++++++++++++++-----
    1 file changed, 15 insertions(+), 5 deletions(-)

    diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
    index c0f9a651dc067..92b18c4760e55 100644
    --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
    +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
    @@ -1156,27 +1156,37 @@ static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched)
    static void amdgpu_ib_preempt_mark_partial_job(struct amdgpu_ring *ring)
    {
    struct amdgpu_job *job;
    - struct drm_sched_job *s_job;
    + struct drm_sched_job *s_job, *tmp;
    uint32_t preempt_seq;
    struct dma_fence *fence, **ptr;
    struct amdgpu_fence_driver *drv = &ring->fence_drv;
    struct drm_gpu_scheduler *sched = &ring->sched;
    + bool preempted = true;

    if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
    return;

    preempt_seq = le32_to_cpu(*(drv->cpu_addr + 2));
    - if (preempt_seq <= atomic_read(&drv->last_seq))
    - return;
    + if (preempt_seq <= atomic_read(&drv->last_seq)) {
    + preempted = false;
    + goto no_preempt;
    + }

    preempt_seq &= drv->num_fences_mask;
    ptr = &drv->fences[preempt_seq];
    fence = rcu_dereference_protected(*ptr, 1);

    +no_preempt:
    spin_lock(&sched->job_list_lock);
    - list_for_each_entry(s_job, &sched->ring_mirror_list, node) {
    + list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) {
    + if (dma_fence_is_signaled(&s_job->s_fence->finished)) {
    + /* remove job from ring_mirror_list */
    + list_del_init(&s_job->node);
    + sched->ops->free_job(s_job);
    + continue;
    + }
    job = to_amdgpu_job(s_job);
    - if (job->fence == fence)
    + if (preempted && job->fence == fence)
    /* mark the job as preempted */
    job->preemption_status |= AMDGPU_IB_PREEMPTED;
    }
    --
    2.25.1


    \
     
     \ /
      Last update: 2020-07-27 16:29    [W:9.137 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site