drm/amdgpu: Move kiq ring lock out of virt structure
authorShaoyun Liu <Shaoyun.Liu@amd.com>
Fri, 28 Apr 2017 21:18:26 +0000 (17:18 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 May 2017 21:40:12 +0000 (17:40 -0400)
The usage of kiq should not depend on the virtualization.

Signed-off-by: Shaoyun Liu <Shaoyun.Liu@amd.com>
Reviewed-by:Andres Rodriquez <andresx7@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

index 3608f16..8edc26c 100644 (file)
@@ -907,6 +907,7 @@ struct amdgpu_mec {
 struct amdgpu_kiq {
        u64                     eop_gpu_addr;
        struct amdgpu_bo        *eop_obj;
+       struct mutex            ring_mutex;
        struct amdgpu_ring      ring;
        struct amdgpu_irq_src   irq;
 };
index bd422f0..61fcf26 100644 (file)
@@ -108,7 +108,6 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev)
        adev->cg_flags = 0;
        adev->pg_flags = 0;
 
-       mutex_init(&adev->virt.lock_kiq);
        mutex_init(&adev->virt.lock_reset);
 }
 
@@ -122,12 +121,12 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 
        BUG_ON(!ring->funcs->emit_rreg);
 
-       mutex_lock(&adev->virt.lock_kiq);
+       mutex_lock(&kiq->ring_mutex);
        amdgpu_ring_alloc(ring, 32);
        amdgpu_ring_emit_rreg(ring, reg);
        amdgpu_fence_emit(ring, &f);
        amdgpu_ring_commit(ring);
-       mutex_unlock(&adev->virt.lock_kiq);
+       mutex_unlock(&kiq->ring_mutex);
 
        r = dma_fence_wait(f, false);
        if (r)
@@ -148,12 +147,12 @@ void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
 
        BUG_ON(!ring->funcs->emit_wreg);
 
-       mutex_lock(&adev->virt.lock_kiq);
+       mutex_lock(&kiq->ring_mutex);
        amdgpu_ring_alloc(ring, 32);
        amdgpu_ring_emit_wreg(ring, reg, v);
        amdgpu_fence_emit(ring, &f);
        amdgpu_ring_commit(ring);
-       mutex_unlock(&adev->virt.lock_kiq);
+       mutex_unlock(&kiq->ring_mutex);
 
        r = dma_fence_wait(f, false);
        if (r)
index a8ed162..6f2b7df 100644 (file)
@@ -52,7 +52,6 @@ struct amdgpu_virt {
        uint64_t                        csa_vmid0_addr;
        bool chained_ib_support;
        uint32_t                        reg_val_offs;
-       struct mutex                    lock_kiq;
        struct mutex                    lock_reset;
        struct amdgpu_irq_src           ack_irq;
        struct amdgpu_irq_src           rcv_irq;
index b92d5f1..700188a 100644 (file)
@@ -1385,6 +1385,8 @@ static int gfx_v8_0_kiq_init_ring(struct amdgpu_device *adev,
        struct amdgpu_kiq *kiq = &adev->gfx.kiq;
        int r = 0;
 
+       mutex_init(&kiq->ring_mutex);
+
        r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs);
        if (r)
                return r;
index 9788417..14f8867 100644 (file)
@@ -614,6 +614,8 @@ static int gfx_v9_0_kiq_init_ring(struct amdgpu_device *adev,
        struct amdgpu_kiq *kiq = &adev->gfx.kiq;
        int r = 0;
 
+       mutex_init(&kiq->ring_mutex);
+
        r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs);
        if (r)
                return r;