diff options
author | Christian König <christian.koenig@amd.com> | 2016-03-01 09:42:52 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-03-08 11:01:49 -0500 |
commit | b8c7b39ec1db98199df5bee33ca145ed9c2c62e7 (patch) | |
tree | 3a5fe2a5ee2700ee178c33f2c514b7b23ef9a76a | |
parent | 971fe9a9414b2ccabc11ff6a5ff6be0d6f2dabda (diff) |
drm/amdgpu: split pipeline sync and vm flush
This allows us to use the pipeline sync for other tasks as well.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 29 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 |
4 files changed, 35 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 866b5fa298e7..e0727de9c2b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -326,6 +326,7 @@ struct amdgpu_ring_funcs { | |||
326 | struct amdgpu_ib *ib); | 326 | struct amdgpu_ib *ib); |
327 | void (*emit_fence)(struct amdgpu_ring *ring, uint64_t addr, | 327 | void (*emit_fence)(struct amdgpu_ring *ring, uint64_t addr, |
328 | uint64_t seq, unsigned flags); | 328 | uint64_t seq, unsigned flags); |
329 | void (*emit_pipeline_sync)(struct amdgpu_ring *ring); | ||
329 | void (*emit_vm_flush)(struct amdgpu_ring *ring, unsigned vm_id, | 330 | void (*emit_vm_flush)(struct amdgpu_ring *ring, unsigned vm_id, |
330 | uint64_t pd_addr); | 331 | uint64_t pd_addr); |
331 | void (*emit_hdp_flush)(struct amdgpu_ring *ring); | 332 | void (*emit_hdp_flush)(struct amdgpu_ring *ring); |
@@ -2234,6 +2235,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
2234 | #define amdgpu_ring_get_wptr(r) (r)->funcs->get_wptr((r)) | 2235 | #define amdgpu_ring_get_wptr(r) (r)->funcs->get_wptr((r)) |
2235 | #define amdgpu_ring_set_wptr(r) (r)->funcs->set_wptr((r)) | 2236 | #define amdgpu_ring_set_wptr(r) (r)->funcs->set_wptr((r)) |
2236 | #define amdgpu_ring_emit_ib(r, ib) (r)->funcs->emit_ib((r), (ib)) | 2237 | #define amdgpu_ring_emit_ib(r, ib) (r)->funcs->emit_ib((r), (ib)) |
2238 | #define amdgpu_ring_emit_pipeline_sync(r) (r)->funcs->emit_pipeline_sync((r)) | ||
2237 | #define amdgpu_ring_emit_vm_flush(r, vmid, addr) (r)->funcs->emit_vm_flush((r), (vmid), (addr)) | 2239 | #define amdgpu_ring_emit_vm_flush(r, vmid, addr) (r)->funcs->emit_vm_flush((r), (vmid), (addr)) |
2238 | #define amdgpu_ring_emit_fence(r, addr, seq, flags) (r)->funcs->emit_fence((r), (addr), (seq), (flags)) | 2240 | #define amdgpu_ring_emit_fence(r, addr, seq, flags) (r)->funcs->emit_fence((r), (addr), (seq), (flags)) |
2239 | #define amdgpu_ring_emit_gds_switch(r, v, db, ds, wb, ws, ab, as) (r)->funcs->emit_gds_switch((r), (v), (db), (ds), (wb), (ws), (ab), (as)) | 2241 | #define amdgpu_ring_emit_gds_switch(r, v, db, ds, wb, ws, ab, as) (r)->funcs->emit_gds_switch((r), (v), (db), (ds), (wb), (ws), (ab), (as)) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 8642a1ccd6c3..9a9abbab9b7c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -257,6 +257,8 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, | |||
257 | 257 | ||
258 | if (pd_addr != AMDGPU_VM_NO_FLUSH) { | 258 | if (pd_addr != AMDGPU_VM_NO_FLUSH) { |
259 | trace_amdgpu_vm_flush(pd_addr, ring->idx, vm_id); | 259 | trace_amdgpu_vm_flush(pd_addr, ring->idx, vm_id); |
260 | if (ring->funcs->emit_pipeline_sync) | ||
261 | amdgpu_ring_emit_pipeline_sync(ring); | ||
260 | amdgpu_ring_emit_vm_flush(ring, vm_id, pd_addr); | 262 | amdgpu_ring_emit_vm_flush(ring, vm_id, pd_addr); |
261 | } | 263 | } |
262 | 264 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index 46c2436d74bd..a4913ebb673c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
@@ -3041,6 +3041,26 @@ static int gfx_v7_0_cp_resume(struct amdgpu_device *adev) | |||
3041 | return 0; | 3041 | return 0; |
3042 | } | 3042 | } |
3043 | 3043 | ||
3044 | /** | ||
3045 | * gfx_v7_0_ring_emit_vm_flush - cik vm flush using the CP | ||
3046 | * | ||
3047 | * @ring: the ring to emmit the commands to | ||
3048 | * | ||
3049 | * Sync the command pipeline with the PFP. E.g. wait for everything | ||
3050 | * to be completed. | ||
3051 | */ | ||
3052 | static void gfx_v7_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | ||
3053 | { | ||
3054 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | ||
3055 | if (usepfp) { | ||
3056 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | ||
3057 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
3058 | amdgpu_ring_write(ring, 0); | ||
3059 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
3060 | amdgpu_ring_write(ring, 0); | ||
3061 | } | ||
3062 | } | ||
3063 | |||
3044 | /* | 3064 | /* |
3045 | * vm | 3065 | * vm |
3046 | * VMID 0 is the physical GPU addresses as used by the kernel. | 3066 | * VMID 0 is the physical GPU addresses as used by the kernel. |
@@ -3059,13 +3079,6 @@ static void gfx_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
3059 | unsigned vm_id, uint64_t pd_addr) | 3079 | unsigned vm_id, uint64_t pd_addr) |
3060 | { | 3080 | { |
3061 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | 3081 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); |
3062 | if (usepfp) { | ||
3063 | /* synce CE with ME to prevent CE fetch CEIB before context switch done */ | ||
3064 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
3065 | amdgpu_ring_write(ring, 0); | ||
3066 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | ||
3067 | amdgpu_ring_write(ring, 0); | ||
3068 | } | ||
3069 | 3082 | ||
3070 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | 3083 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
3071 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) | | 3084 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) | |
@@ -5147,6 +5160,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { | |||
5147 | .parse_cs = NULL, | 5160 | .parse_cs = NULL, |
5148 | .emit_ib = gfx_v7_0_ring_emit_ib_gfx, | 5161 | .emit_ib = gfx_v7_0_ring_emit_ib_gfx, |
5149 | .emit_fence = gfx_v7_0_ring_emit_fence_gfx, | 5162 | .emit_fence = gfx_v7_0_ring_emit_fence_gfx, |
5163 | .emit_pipeline_sync = gfx_v7_0_ring_emit_pipeline_sync, | ||
5150 | .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush, | 5164 | .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush, |
5151 | .emit_gds_switch = gfx_v7_0_ring_emit_gds_switch, | 5165 | .emit_gds_switch = gfx_v7_0_ring_emit_gds_switch, |
5152 | .emit_hdp_flush = gfx_v7_0_ring_emit_hdp_flush, | 5166 | .emit_hdp_flush = gfx_v7_0_ring_emit_hdp_flush, |
@@ -5164,6 +5178,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { | |||
5164 | .parse_cs = NULL, | 5178 | .parse_cs = NULL, |
5165 | .emit_ib = gfx_v7_0_ring_emit_ib_compute, | 5179 | .emit_ib = gfx_v7_0_ring_emit_ib_compute, |
5166 | .emit_fence = gfx_v7_0_ring_emit_fence_compute, | 5180 | .emit_fence = gfx_v7_0_ring_emit_fence_compute, |
5181 | .emit_pipeline_sync = gfx_v7_0_ring_emit_pipeline_sync, | ||
5167 | .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush, | 5182 | .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush, |
5168 | .emit_gds_switch = gfx_v7_0_ring_emit_gds_switch, | 5183 | .emit_gds_switch = gfx_v7_0_ring_emit_gds_switch, |
5169 | .emit_hdp_flush = gfx_v7_0_ring_emit_hdp_flush, | 5184 | .emit_hdp_flush = gfx_v7_0_ring_emit_hdp_flush, |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index e0b64de9b5af..828e205a7326 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -4692,8 +4692,7 @@ static void gfx_v8_0_ring_emit_fence_gfx(struct amdgpu_ring *ring, u64 addr, | |||
4692 | 4692 | ||
4693 | } | 4693 | } |
4694 | 4694 | ||
4695 | static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | 4695 | static void gfx_v8_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) |
4696 | unsigned vm_id, uint64_t pd_addr) | ||
4697 | { | 4696 | { |
4698 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | 4697 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); |
4699 | uint32_t seq = ring->fence_drv.sync_seq; | 4698 | uint32_t seq = ring->fence_drv.sync_seq; |
@@ -4715,6 +4714,12 @@ static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
4715 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); | 4714 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); |
4716 | amdgpu_ring_write(ring, 0); | 4715 | amdgpu_ring_write(ring, 0); |
4717 | } | 4716 | } |
4717 | } | ||
4718 | |||
4719 | static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | ||
4720 | unsigned vm_id, uint64_t pd_addr) | ||
4721 | { | ||
4722 | int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); | ||
4718 | 4723 | ||
4719 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | 4724 | amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
4720 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) | | 4725 | amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) | |
@@ -5037,6 +5042,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { | |||
5037 | .parse_cs = NULL, | 5042 | .parse_cs = NULL, |
5038 | .emit_ib = gfx_v8_0_ring_emit_ib_gfx, | 5043 | .emit_ib = gfx_v8_0_ring_emit_ib_gfx, |
5039 | .emit_fence = gfx_v8_0_ring_emit_fence_gfx, | 5044 | .emit_fence = gfx_v8_0_ring_emit_fence_gfx, |
5045 | .emit_pipeline_sync = gfx_v8_0_ring_emit_pipeline_sync, | ||
5040 | .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush, | 5046 | .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush, |
5041 | .emit_gds_switch = gfx_v8_0_ring_emit_gds_switch, | 5047 | .emit_gds_switch = gfx_v8_0_ring_emit_gds_switch, |
5042 | .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush, | 5048 | .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush, |
@@ -5054,6 +5060,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { | |||
5054 | .parse_cs = NULL, | 5060 | .parse_cs = NULL, |
5055 | .emit_ib = gfx_v8_0_ring_emit_ib_compute, | 5061 | .emit_ib = gfx_v8_0_ring_emit_ib_compute, |
5056 | .emit_fence = gfx_v8_0_ring_emit_fence_compute, | 5062 | .emit_fence = gfx_v8_0_ring_emit_fence_compute, |
5063 | .emit_pipeline_sync = gfx_v8_0_ring_emit_pipeline_sync, | ||
5057 | .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush, | 5064 | .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush, |
5058 | .emit_gds_switch = gfx_v8_0_ring_emit_gds_switch, | 5065 | .emit_gds_switch = gfx_v8_0_ring_emit_gds_switch, |
5059 | .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush, | 5066 | .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush, |