aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2018-10-24 01:37:37 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-11-05 14:21:50 -0500
commit34955e038a1b313b0f19eeacfb0e22aa6877e11d (patch)
treee5ad8c3ed60f2639a2cc737bfa7b09df00926731
parent8469868df76fc417e0256f21af96809bad96ba66 (diff)
drm/amdgpu: Modify the argument of emit_ib interface
use the point of struct amdgpu_job as the function argument instand of vmid, so the other members of struct amdgpu_job can be visit in emit_ib function. v2: add a wrapper for getting the VMID add the job before the ib on the parameter list. v3: refine the wrapper name Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_job.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cik_sdma.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c26
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/si_dma.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c11
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vce_v3_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vce_v4_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c18
21 files changed, 106 insertions, 46 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index ec0e6238dbc3..c48207b377bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -221,8 +221,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
221 !amdgpu_sriov_vf(adev)) /* for SRIOV preemption, Preamble CE ib must be inserted anyway */ 221 !amdgpu_sriov_vf(adev)) /* for SRIOV preemption, Preamble CE ib must be inserted anyway */
222 continue; 222 continue;
223 223
224 amdgpu_ring_emit_ib(ring, ib, job ? job->vmid : 0, 224 amdgpu_ring_emit_ib(ring, job, ib, need_ctx_switch);
225 need_ctx_switch);
226 need_ctx_switch = false; 225 need_ctx_switch = false;
227 } 226 }
228 227
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
index 57cfe78a262b..e1b46a6703de 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
@@ -33,6 +33,8 @@
33#define to_amdgpu_job(sched_job) \ 33#define to_amdgpu_job(sched_job) \
34 container_of((sched_job), struct amdgpu_job, base) 34 container_of((sched_job), struct amdgpu_job, base)
35 35
36#define AMDGPU_JOB_GET_VMID(job) ((job) ? (job)->vmid : 0)
37
36struct amdgpu_fence; 38struct amdgpu_fence;
37 39
38struct amdgpu_job { 40struct amdgpu_job {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index 4cdddbc4491b..0beb01fef83f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -129,8 +129,9 @@ struct amdgpu_ring_funcs {
129 unsigned emit_ib_size; 129 unsigned emit_ib_size;
130 /* command emit functions */ 130 /* command emit functions */
131 void (*emit_ib)(struct amdgpu_ring *ring, 131 void (*emit_ib)(struct amdgpu_ring *ring,
132 struct amdgpu_job *job,
132 struct amdgpu_ib *ib, 133 struct amdgpu_ib *ib,
133 unsigned vmid, bool ctx_switch); 134 bool ctx_switch);
134 void (*emit_fence)(struct amdgpu_ring *ring, uint64_t addr, 135 void (*emit_fence)(struct amdgpu_ring *ring, uint64_t addr,
135 uint64_t seq, unsigned flags); 136 uint64_t seq, unsigned flags);
136 void (*emit_pipeline_sync)(struct amdgpu_ring *ring); 137 void (*emit_pipeline_sync)(struct amdgpu_ring *ring);
@@ -228,7 +229,7 @@ struct amdgpu_ring {
228#define amdgpu_ring_get_rptr(r) (r)->funcs->get_rptr((r)) 229#define amdgpu_ring_get_rptr(r) (r)->funcs->get_rptr((r))
229#define amdgpu_ring_get_wptr(r) (r)->funcs->get_wptr((r)) 230#define amdgpu_ring_get_wptr(r) (r)->funcs->get_wptr((r))
230#define amdgpu_ring_set_wptr(r) (r)->funcs->set_wptr((r)) 231#define amdgpu_ring_set_wptr(r) (r)->funcs->set_wptr((r))
231#define amdgpu_ring_emit_ib(r, ib, vmid, c) (r)->funcs->emit_ib((r), (ib), (vmid), (c)) 232#define amdgpu_ring_emit_ib(r, job, ib, c) ((r)->funcs->emit_ib((r), (job), (ib), (c)))
232#define amdgpu_ring_emit_pipeline_sync(r) (r)->funcs->emit_pipeline_sync((r)) 233#define amdgpu_ring_emit_pipeline_sync(r) (r)->funcs->emit_pipeline_sync((r))
233#define amdgpu_ring_emit_vm_flush(r, vmid, addr) (r)->funcs->emit_vm_flush((r), (vmid), (addr)) 234#define amdgpu_ring_emit_vm_flush(r, vmid, addr) (r)->funcs->emit_vm_flush((r), (vmid), (addr))
234#define amdgpu_ring_emit_fence(r, addr, seq, flags) (r)->funcs->emit_fence((r), (addr), (seq), (flags)) 235#define amdgpu_ring_emit_fence(r, addr, seq, flags) (r)->funcs->emit_fence((r), (addr), (seq), (flags))
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index 379e1ae7a8fb..98a1b2ce2b9d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -1032,8 +1032,10 @@ out:
1032 * @ib: the IB to execute 1032 * @ib: the IB to execute
1033 * 1033 *
1034 */ 1034 */
1035void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_ib *ib, 1035void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring,
1036 unsigned vmid, bool ctx_switch) 1036 struct amdgpu_job *job,
1037 struct amdgpu_ib *ib,
1038 bool ctx_switch)
1037{ 1039{
1038 amdgpu_ring_write(ring, VCE_CMD_IB); 1040 amdgpu_ring_write(ring, VCE_CMD_IB);
1039 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 1041 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
index a1f209eed4c4..50293652af14 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
@@ -65,8 +65,8 @@ int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
65void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp); 65void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp);
66int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx); 66int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx);
67int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, uint32_t ib_idx); 67int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, uint32_t ib_idx);
68void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_ib *ib, 68void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_job *job,
69 unsigned vmid, bool ctx_switch); 69 struct amdgpu_ib *ib, bool ctx_switch);
70void amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, 70void amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,
71 unsigned flags); 71 unsigned flags);
72int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring); 72int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring);
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 49275f358f7a..ad58dcec223e 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -218,9 +218,11 @@ static void cik_sdma_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
218 * Schedule an IB in the DMA ring (CIK). 218 * Schedule an IB in the DMA ring (CIK).
219 */ 219 */
220static void cik_sdma_ring_emit_ib(struct amdgpu_ring *ring, 220static void cik_sdma_ring_emit_ib(struct amdgpu_ring *ring,
221 struct amdgpu_job *job,
221 struct amdgpu_ib *ib, 222 struct amdgpu_ib *ib,
222 unsigned vmid, bool ctx_switch) 223 bool ctx_switch)
223{ 224{
225 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
224 u32 extra_bits = vmid & 0xf; 226 u32 extra_bits = vmid & 0xf;
225 227
226 /* IB packet must end on a 8 DW boundary */ 228 /* IB packet must end on a 8 DW boundary */
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
index 25cf905965fb..5b25c26fa30e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
@@ -1840,9 +1840,11 @@ static void gfx_v6_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
1840} 1840}
1841 1841
1842static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring, 1842static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
1843 struct amdgpu_job *job,
1843 struct amdgpu_ib *ib, 1844 struct amdgpu_ib *ib,
1844 unsigned vmid, bool ctx_switch) 1845 bool ctx_switch)
1845{ 1846{
1847 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1846 u32 header, control = 0; 1848 u32 header, control = 0;
1847 1849
1848 /* insert SWITCH_BUFFER packet before first IB in the ring frame */ 1850 /* insert SWITCH_BUFFER packet before first IB in the ring frame */
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index ff8d316d0533..243b8c502ca6 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -2227,9 +2227,11 @@ static void gfx_v7_0_ring_emit_fence_compute(struct amdgpu_ring *ring,
2227 * on the gfx ring for execution by the GPU. 2227 * on the gfx ring for execution by the GPU.
2228 */ 2228 */
2229static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, 2229static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
2230 struct amdgpu_ib *ib, 2230 struct amdgpu_job *job,
2231 unsigned vmid, bool ctx_switch) 2231 struct amdgpu_ib *ib,
2232 bool ctx_switch)
2232{ 2233{
2234 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
2233 u32 header, control = 0; 2235 u32 header, control = 0;
2234 2236
2235 /* insert SWITCH_BUFFER packet before first IB in the ring frame */ 2237 /* insert SWITCH_BUFFER packet before first IB in the ring frame */
@@ -2256,9 +2258,11 @@ static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
2256} 2258}
2257 2259
2258static void gfx_v7_0_ring_emit_ib_compute(struct amdgpu_ring *ring, 2260static void gfx_v7_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
2261 struct amdgpu_job *job,
2259 struct amdgpu_ib *ib, 2262 struct amdgpu_ib *ib,
2260 unsigned vmid, bool ctx_switch) 2263 bool ctx_switch)
2261{ 2264{
2265 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
2262 u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24); 2266 u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
2263 2267
2264 amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); 2268 amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 58c5ebe1cd73..bdae5636a910 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -6109,9 +6109,11 @@ static void gfx_v8_0_ring_emit_vgt_flush(struct amdgpu_ring *ring)
6109} 6109}
6110 6110
6111static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, 6111static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
6112 struct amdgpu_ib *ib, 6112 struct amdgpu_job *job,
6113 unsigned vmid, bool ctx_switch) 6113 struct amdgpu_ib *ib,
6114 bool ctx_switch)
6114{ 6115{
6116 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
6115 u32 header, control = 0; 6117 u32 header, control = 0;
6116 6118
6117 if (ib->flags & AMDGPU_IB_FLAG_CE) 6119 if (ib->flags & AMDGPU_IB_FLAG_CE)
@@ -6139,9 +6141,11 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
6139} 6141}
6140 6142
6141static void gfx_v8_0_ring_emit_ib_compute(struct amdgpu_ring *ring, 6143static void gfx_v8_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
6144 struct amdgpu_job *job,
6142 struct amdgpu_ib *ib, 6145 struct amdgpu_ib *ib,
6143 unsigned vmid, bool ctx_switch) 6146 bool ctx_switch)
6144{ 6147{
6148 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
6145 u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24); 6149 u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
6146 6150
6147 amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); 6151 amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 100f23b5e22f..928034ce7994 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -4049,9 +4049,11 @@ static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)
4049} 4049}
4050 4050
4051static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring, 4051static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
4052 struct amdgpu_ib *ib, 4052 struct amdgpu_job *job,
4053 unsigned vmid, bool ctx_switch) 4053 struct amdgpu_ib *ib,
4054 bool ctx_switch)
4054{ 4055{
4056 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
4055 u32 header, control = 0; 4057 u32 header, control = 0;
4056 4058
4057 if (ib->flags & AMDGPU_IB_FLAG_CE) 4059 if (ib->flags & AMDGPU_IB_FLAG_CE)
@@ -4080,20 +4082,22 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
4080} 4082}
4081 4083
4082static void gfx_v9_0_ring_emit_ib_compute(struct amdgpu_ring *ring, 4084static void gfx_v9_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
4083 struct amdgpu_ib *ib, 4085 struct amdgpu_job *job,
4084 unsigned vmid, bool ctx_switch) 4086 struct amdgpu_ib *ib,
4087 bool ctx_switch)
4085{ 4088{
4086 u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24); 4089 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
4090 u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
4087 4091
4088 amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); 4092 amdgpu_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
4089 BUG_ON(ib->gpu_addr & 0x3); /* Dword align */ 4093 BUG_ON(ib->gpu_addr & 0x3); /* Dword align */
4090 amdgpu_ring_write(ring, 4094 amdgpu_ring_write(ring,
4091#ifdef __BIG_ENDIAN 4095#ifdef __BIG_ENDIAN
4092 (2 << 0) | 4096 (2 << 0) |
4093#endif 4097#endif
4094 lower_32_bits(ib->gpu_addr)); 4098 lower_32_bits(ib->gpu_addr));
4095 amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr)); 4099 amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr));
4096 amdgpu_ring_write(ring, control); 4100 amdgpu_ring_write(ring, control);
4097} 4101}
4098 4102
4099static void gfx_v9_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, 4103static void gfx_v9_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
index c4ab54a59fc9..fb2a066c0ac9 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
@@ -245,9 +245,12 @@ static void sdma_v2_4_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
245 * Schedule an IB in the DMA ring (VI). 245 * Schedule an IB in the DMA ring (VI).
246 */ 246 */
247static void sdma_v2_4_ring_emit_ib(struct amdgpu_ring *ring, 247static void sdma_v2_4_ring_emit_ib(struct amdgpu_ring *ring,
248 struct amdgpu_job *job,
248 struct amdgpu_ib *ib, 249 struct amdgpu_ib *ib,
249 unsigned vmid, bool ctx_switch) 250 bool ctx_switch)
250{ 251{
252 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
253
251 /* IB packet must end on a 8 DW boundary */ 254 /* IB packet must end on a 8 DW boundary */
252 sdma_v2_4_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8); 255 sdma_v2_4_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8);
253 256
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index e3adddbcb593..a9848d28707d 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -419,9 +419,12 @@ static void sdma_v3_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
419 * Schedule an IB in the DMA ring (VI). 419 * Schedule an IB in the DMA ring (VI).
420 */ 420 */
421static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring, 421static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
422 struct amdgpu_job *job,
422 struct amdgpu_ib *ib, 423 struct amdgpu_ib *ib,
423 unsigned vmid, bool ctx_switch) 424 bool ctx_switch)
424{ 425{
426 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
427
425 /* IB packet must end on a 8 DW boundary */ 428 /* IB packet must end on a 8 DW boundary */
426 sdma_v3_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8); 429 sdma_v3_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8);
427 430
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
index 7f9a501c919d..e740953110d8 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
@@ -497,9 +497,12 @@ static void sdma_v4_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
497 * Schedule an IB in the DMA ring (VEGA10). 497 * Schedule an IB in the DMA ring (VEGA10).
498 */ 498 */
499static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring, 499static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,
500 struct amdgpu_ib *ib, 500 struct amdgpu_job *job,
501 unsigned vmid, bool ctx_switch) 501 struct amdgpu_ib *ib,
502 bool ctx_switch)
502{ 503{
504 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
505
503 /* IB packet must end on a 8 DW boundary */ 506 /* IB packet must end on a 8 DW boundary */
504 sdma_v4_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8); 507 sdma_v4_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8);
505 508
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c
index bff6954c2150..b6e473134e19 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_dma.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_dma.c
@@ -61,9 +61,11 @@ static void si_dma_ring_set_wptr(struct amdgpu_ring *ring)
61} 61}
62 62
63static void si_dma_ring_emit_ib(struct amdgpu_ring *ring, 63static void si_dma_ring_emit_ib(struct amdgpu_ring *ring,
64 struct amdgpu_job *job,
64 struct amdgpu_ib *ib, 65 struct amdgpu_ib *ib,
65 unsigned vmid, bool ctx_switch) 66 bool ctx_switch)
66{ 67{
68 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
67 /* The indirect buffer packet must end on an 8 DW boundary in the DMA ring. 69 /* The indirect buffer packet must end on an 8 DW boundary in the DMA ring.
68 * Pad as necessary with NOPs. 70 * Pad as necessary with NOPs.
69 */ 71 */
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
index 51681eb0dd58..90bbcee00f28 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
@@ -509,8 +509,9 @@ static int uvd_v4_2_ring_test_ring(struct amdgpu_ring *ring)
509 * Write ring commands to execute the indirect buffer 509 * Write ring commands to execute the indirect buffer
510 */ 510 */
511static void uvd_v4_2_ring_emit_ib(struct amdgpu_ring *ring, 511static void uvd_v4_2_ring_emit_ib(struct amdgpu_ring *ring,
512 struct amdgpu_job *job,
512 struct amdgpu_ib *ib, 513 struct amdgpu_ib *ib,
513 unsigned vmid, bool ctx_switch) 514 bool ctx_switch)
514{ 515{
515 amdgpu_ring_write(ring, PACKET0(mmUVD_RBC_IB_BASE, 0)); 516 amdgpu_ring_write(ring, PACKET0(mmUVD_RBC_IB_BASE, 0));
516 amdgpu_ring_write(ring, ib->gpu_addr); 517 amdgpu_ring_write(ring, ib->gpu_addr);
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
index 907afcf8d867..1c5e12703103 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
@@ -524,8 +524,9 @@ static int uvd_v5_0_ring_test_ring(struct amdgpu_ring *ring)
524 * Write ring commands to execute the indirect buffer 524 * Write ring commands to execute the indirect buffer
525 */ 525 */
526static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring, 526static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring,
527 struct amdgpu_job *job,
527 struct amdgpu_ib *ib, 528 struct amdgpu_ib *ib,
528 unsigned vmid, bool ctx_switch) 529 bool ctx_switch)
529{ 530{
530 amdgpu_ring_write(ring, PACKET0(mmUVD_LMI_RBC_IB_64BIT_BAR_LOW, 0)); 531 amdgpu_ring_write(ring, PACKET0(mmUVD_LMI_RBC_IB_64BIT_BAR_LOW, 0));
531 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 532 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index 7df41d1c818b..f184842ef2a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -975,9 +975,12 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring)
975 * Write ring commands to execute the indirect buffer 975 * Write ring commands to execute the indirect buffer
976 */ 976 */
977static void uvd_v6_0_ring_emit_ib(struct amdgpu_ring *ring, 977static void uvd_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
978 struct amdgpu_job *job,
978 struct amdgpu_ib *ib, 979 struct amdgpu_ib *ib,
979 unsigned vmid, bool ctx_switch) 980 bool ctx_switch)
980{ 981{
982 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
983
981 amdgpu_ring_write(ring, PACKET0(mmUVD_LMI_RBC_IB_VMID, 0)); 984 amdgpu_ring_write(ring, PACKET0(mmUVD_LMI_RBC_IB_VMID, 0));
982 amdgpu_ring_write(ring, vmid); 985 amdgpu_ring_write(ring, vmid);
983 986
@@ -998,8 +1001,12 @@ static void uvd_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
998 * Write enc ring commands to execute the indirect buffer 1001 * Write enc ring commands to execute the indirect buffer
999 */ 1002 */
1000static void uvd_v6_0_enc_ring_emit_ib(struct amdgpu_ring *ring, 1003static void uvd_v6_0_enc_ring_emit_ib(struct amdgpu_ring *ring,
1001 struct amdgpu_ib *ib, unsigned int vmid, bool ctx_switch) 1004 struct amdgpu_job *job,
1005 struct amdgpu_ib *ib,
1006 bool ctx_switch)
1002{ 1007{
1008 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1009
1003 amdgpu_ring_write(ring, HEVC_ENC_CMD_IB_VM); 1010 amdgpu_ring_write(ring, HEVC_ENC_CMD_IB_VM);
1004 amdgpu_ring_write(ring, vmid); 1011 amdgpu_ring_write(ring, vmid);
1005 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 1012 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index 3985530a882f..8a4595968d98 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -1270,10 +1270,12 @@ static int uvd_v7_0_ring_patch_cs_in_place(struct amdgpu_cs_parser *p,
1270 * Write ring commands to execute the indirect buffer 1270 * Write ring commands to execute the indirect buffer
1271 */ 1271 */
1272static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring, 1272static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring,
1273 struct amdgpu_job *job,
1273 struct amdgpu_ib *ib, 1274 struct amdgpu_ib *ib,
1274 unsigned vmid, bool ctx_switch) 1275 bool ctx_switch)
1275{ 1276{
1276 struct amdgpu_device *adev = ring->adev; 1277 struct amdgpu_device *adev = ring->adev;
1278 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1277 1279
1278 amdgpu_ring_write(ring, 1280 amdgpu_ring_write(ring,
1279 PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_LMI_RBC_IB_VMID), 0)); 1281 PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_LMI_RBC_IB_VMID), 0));
@@ -1299,8 +1301,12 @@ static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring,
1299 * Write enc ring commands to execute the indirect buffer 1301 * Write enc ring commands to execute the indirect buffer
1300 */ 1302 */
1301static void uvd_v7_0_enc_ring_emit_ib(struct amdgpu_ring *ring, 1303static void uvd_v7_0_enc_ring_emit_ib(struct amdgpu_ring *ring,
1302 struct amdgpu_ib *ib, unsigned int vmid, bool ctx_switch) 1304 struct amdgpu_job *job,
1305 struct amdgpu_ib *ib,
1306 bool ctx_switch)
1303{ 1307{
1308 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1309
1304 amdgpu_ring_write(ring, HEVC_ENC_CMD_IB_VM); 1310 amdgpu_ring_write(ring, HEVC_ENC_CMD_IB_VM);
1305 amdgpu_ring_write(ring, vmid); 1311 amdgpu_ring_write(ring, vmid);
1306 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 1312 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index 2b1a5a793942..3e84840859a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -833,8 +833,12 @@ out:
833} 833}
834 834
835static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring, 835static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
836 struct amdgpu_ib *ib, unsigned int vmid, bool ctx_switch) 836 struct amdgpu_job *job,
837 struct amdgpu_ib *ib,
838 bool ctx_switch)
837{ 839{
840 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
841
838 amdgpu_ring_write(ring, VCE_CMD_IB_VM); 842 amdgpu_ring_write(ring, VCE_CMD_IB_VM);
839 amdgpu_ring_write(ring, vmid); 843 amdgpu_ring_write(ring, vmid);
840 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 844 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
index 65b71fc2f7b9..0054ba1b9a68 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
@@ -946,9 +946,11 @@ static int vce_v4_0_set_powergating_state(void *handle,
946} 946}
947#endif 947#endif
948 948
949static void vce_v4_0_ring_emit_ib(struct amdgpu_ring *ring, 949static void vce_v4_0_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_job *job,
950 struct amdgpu_ib *ib, unsigned int vmid, bool ctx_switch) 950 struct amdgpu_ib *ib, bool ctx_switch)
951{ 951{
952 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
953
952 amdgpu_ring_write(ring, VCE_CMD_IB_VM); 954 amdgpu_ring_write(ring, VCE_CMD_IB_VM);
953 amdgpu_ring_write(ring, vmid); 955 amdgpu_ring_write(ring, vmid);
954 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 956 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
index 29628f60d50c..c1a03505f956 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
@@ -1358,10 +1358,12 @@ static void vcn_v1_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64
1358 * Write ring commands to execute the indirect buffer 1358 * Write ring commands to execute the indirect buffer
1359 */ 1359 */
1360static void vcn_v1_0_dec_ring_emit_ib(struct amdgpu_ring *ring, 1360static void vcn_v1_0_dec_ring_emit_ib(struct amdgpu_ring *ring,
1361 struct amdgpu_ib *ib, 1361 struct amdgpu_job *job,
1362 unsigned vmid, bool ctx_switch) 1362 struct amdgpu_ib *ib,
1363 bool ctx_switch)
1363{ 1364{
1364 struct amdgpu_device *adev = ring->adev; 1365 struct amdgpu_device *adev = ring->adev;
1366 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1365 1367
1366 amdgpu_ring_write(ring, 1368 amdgpu_ring_write(ring,
1367 PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0)); 1369 PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0));
@@ -1516,8 +1518,12 @@ static void vcn_v1_0_enc_ring_insert_end(struct amdgpu_ring *ring)
1516 * Write enc ring commands to execute the indirect buffer 1518 * Write enc ring commands to execute the indirect buffer
1517 */ 1519 */
1518static void vcn_v1_0_enc_ring_emit_ib(struct amdgpu_ring *ring, 1520static void vcn_v1_0_enc_ring_emit_ib(struct amdgpu_ring *ring,
1519 struct amdgpu_ib *ib, unsigned int vmid, bool ctx_switch) 1521 struct amdgpu_job *job,
1522 struct amdgpu_ib *ib,
1523 bool ctx_switch)
1520{ 1524{
1525 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1526
1521 amdgpu_ring_write(ring, VCN_ENC_CMD_IB); 1527 amdgpu_ring_write(ring, VCN_ENC_CMD_IB);
1522 amdgpu_ring_write(ring, vmid); 1528 amdgpu_ring_write(ring, vmid);
1523 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); 1529 amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
@@ -1717,10 +1723,12 @@ static void vcn_v1_0_jpeg_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u6
1717 * Write ring commands to execute the indirect buffer. 1723 * Write ring commands to execute the indirect buffer.
1718 */ 1724 */
1719static void vcn_v1_0_jpeg_ring_emit_ib(struct amdgpu_ring *ring, 1725static void vcn_v1_0_jpeg_ring_emit_ib(struct amdgpu_ring *ring,
1720 struct amdgpu_ib *ib, 1726 struct amdgpu_job *job,
1721 unsigned vmid, bool ctx_switch) 1727 struct amdgpu_ib *ib,
1728 bool ctx_switch)
1722{ 1729{
1723 struct amdgpu_device *adev = ring->adev; 1730 struct amdgpu_device *adev = ring->adev;
1731 unsigned vmid = AMDGPU_JOB_GET_VMID(job);
1724 1732
1725 amdgpu_ring_write(ring, 1733 amdgpu_ring_write(ring,
1726 PACKETJ(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_JRBC_IB_VMID), 0, 0, PACKETJ_TYPE0)); 1734 PACKETJ(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_JRBC_IB_VMID), 0, 0, PACKETJ_TYPE0));