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 125/179] drm/amdgpu/gfx10: fix race condition for kiq
    Date
    From: Jack Xiao <Jack.Xiao@amd.com>

    [ Upstream commit 7d65a577bb58d4f27a3398a4c0cb0b00ab7d0511 ]

    During preemption test for gfx10, it uses kiq to trigger
    gfx preemption, which would result in race condition
    with flushing TLB for kiq.

    Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Acked-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 ++++++++-
    1 file changed, 8 insertions(+), 1 deletion(-)

    diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
    index 0e0daf0021b60..ff94f756978d5 100644
    --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
    +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
    @@ -4746,12 +4746,17 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring)
    struct amdgpu_device *adev = ring->adev;
    struct amdgpu_kiq *kiq = &adev->gfx.kiq;
    struct amdgpu_ring *kiq_ring = &kiq->ring;
    + unsigned long flags;

    if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
    return -EINVAL;

    - if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size))
    + spin_lock_irqsave(&kiq->ring_lock, flags);
    +
    + if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) {
    + spin_unlock_irqrestore(&kiq->ring_lock, flags);
    return -ENOMEM;
    + }

    /* assert preemption condition */
    amdgpu_ring_set_preempt_cond_exec(ring, false);
    @@ -4762,6 +4767,8 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring)
    ++ring->trail_seq);
    amdgpu_ring_commit(kiq_ring);

    + spin_unlock_irqrestore(&kiq->ring_lock, flags);
    +
    /* poll the trailing fence */
    for (i = 0; i < adev->usec_timeout; i++) {
    if (ring->trail_seq ==
    --
    2.25.1


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