drm/amdgpu: add flags to emit_ib interface v2
authorJack Xiao <Jack.Xiao@amd.com>
Fri, 18 Jan 2019 10:13:36 +0000 (18:13 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 25 Jan 2019 21:15:35 +0000 (16:15 -0500)
Replace the last bool type parameter with a general flags parameter,
to make the last parameter be able to contain more information.

v2: drop setting need_ctx_switch = false

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
20 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
drivers/gpu/drm/amd/amdgpu/si_dma.c
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c

index c48207b377bc5f5c64549eca69662896285971e5..0b8ef2d27d6b2b8e60e0959f0cb8e742e4de3c7f 100644 (file)
@@ -202,12 +202,12 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                        amdgpu_asic_flush_hdp(adev, ring);
        }
 
+       if (need_ctx_switch)
+               status |= AMDGPU_HAVE_CTX_SWITCH;
+
        skip_preamble = ring->current_ctx == fence_ctx;
        if (job && ring->funcs->emit_cntxcntl) {
-               if (need_ctx_switch)
-                       status |= AMDGPU_HAVE_CTX_SWITCH;
                status |= job->preamble_status;
-
                amdgpu_ring_emit_cntxcntl(ring, status);
        }
 
@@ -221,8 +221,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                        !amdgpu_sriov_vf(adev)) /* for SRIOV preemption, Preamble CE ib must be inserted anyway */
                        continue;
 
-               amdgpu_ring_emit_ib(ring, job, ib, need_ctx_switch);
-               need_ctx_switch = false;
+               amdgpu_ring_emit_ib(ring, job, ib, status);
+               status &= ~AMDGPU_HAVE_CTX_SWITCH;
        }
 
        if (ring->funcs->emit_tmz)
index d87e828a084b959ee6651ad080c698eb7f2b3bca..d7fae2676269478b66fb0fd45dfd450ed37de86f 100644 (file)
@@ -131,7 +131,7 @@ struct amdgpu_ring_funcs {
        void (*emit_ib)(struct amdgpu_ring *ring,
                        struct amdgpu_job *job,
                        struct amdgpu_ib *ib,
-                       bool ctx_switch);
+                       uint32_t flags);
        void (*emit_fence)(struct amdgpu_ring *ring, uint64_t addr,
                           uint64_t seq, unsigned flags);
        void (*emit_pipeline_sync)(struct amdgpu_ring *ring);
@@ -229,7 +229,7 @@ struct amdgpu_ring {
 #define amdgpu_ring_get_rptr(r) (r)->funcs->get_rptr((r))
 #define amdgpu_ring_get_wptr(r) (r)->funcs->get_wptr((r))
 #define amdgpu_ring_set_wptr(r) (r)->funcs->set_wptr((r))
-#define amdgpu_ring_emit_ib(r, job, ib, c) ((r)->funcs->emit_ib((r), (job), (ib), (c)))
+#define amdgpu_ring_emit_ib(r, job, ib, flags) ((r)->funcs->emit_ib((r), (job), (ib), (flags)))
 #define amdgpu_ring_emit_pipeline_sync(r) (r)->funcs->emit_pipeline_sync((r))
 #define amdgpu_ring_emit_vm_flush(r, vmid, addr) (r)->funcs->emit_vm_flush((r), (vmid), (addr))
 #define amdgpu_ring_emit_fence(r, addr, seq, flags) (r)->funcs->emit_fence((r), (addr), (seq), (flags))
index 98a1b2ce2b9d38cec778dc2c9a8097661eca27b0..c021b114c8a44ec04c6ca3bccc4479c141218232 100644 (file)
@@ -1035,7 +1035,7 @@ out:
 void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring,
                                struct amdgpu_job *job,
                                struct amdgpu_ib *ib,
-                               bool ctx_switch)
+                               uint32_t flags)
 {
        amdgpu_ring_write(ring, VCE_CMD_IB);
        amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
index 50293652af148cc3c8fa2d04d8b7723e8b744e32..30ea54dd91173b57dbf48e9a9d12915f752d0e13 100644 (file)
@@ -66,7 +66,7 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp);
 int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx);
 int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, uint32_t ib_idx);
 void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_job *job,
-                               struct amdgpu_ib *ib, bool ctx_switch);
+                               struct amdgpu_ib *ib, uint32_t flags);
 void amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,
                                unsigned flags);
 int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring);
index 45795191de1ff9865153ba04f926aef38500cc22..189599b694e8a88ec523d439462564c99970d3a1 100644 (file)
@@ -220,7 +220,7 @@ static void cik_sdma_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
 static void cik_sdma_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 extra_bits = vmid & 0xf;
index 1dc3013ea1d5401120bb9f87393ca7875903d676..305276c7e4bf849602159f7ef202bb9cb5a3a7e2 100644 (file)
@@ -1842,13 +1842,13 @@ static void gfx_v6_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
 static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 header, control = 0;
 
        /* insert SWITCH_BUFFER packet before first IB in the ring frame */
-       if (ctx_switch) {
+       if (flags & AMDGPU_HAVE_CTX_SWITCH) {
                amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
                amdgpu_ring_write(ring, 0);
        }
index 3a9fb6018c1611e99bf5e07eb35a21c44dda27f7..7984292f9282352c83adadfb9a52af1f254245f7 100644 (file)
@@ -2228,13 +2228,13 @@ static void gfx_v7_0_ring_emit_fence_compute(struct amdgpu_ring *ring,
 static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 header, control = 0;
 
        /* insert SWITCH_BUFFER packet before first IB in the ring frame */
-       if (ctx_switch) {
+       if (flags & AMDGPU_HAVE_CTX_SWITCH) {
                amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
                amdgpu_ring_write(ring, 0);
        }
@@ -2259,7 +2259,7 @@ static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
 static void gfx_v7_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
                                          struct amdgpu_job *job,
                                          struct amdgpu_ib *ib,
-                                         bool ctx_switch)
+                                         uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
index 57cb3a51bda7a3e899d4ace5e980b27f2ddda38f..a26747681ed6be2fc9d11192ae0a946236247c4f 100644 (file)
@@ -6047,7 +6047,7 @@ static void gfx_v8_0_ring_emit_vgt_flush(struct amdgpu_ring *ring)
 static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 header, control = 0;
@@ -6079,7 +6079,7 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
 static void gfx_v8_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
                                          struct amdgpu_job *job,
                                          struct amdgpu_ib *ib,
-                                         bool ctx_switch)
+                                         uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
index fbca0494f8719d34c3f342de613b8599de78d724..262ee3cf6f1c438dbbee1cb9ce7a8951afd7c6d3 100644 (file)
@@ -3972,7 +3972,7 @@ static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)
 static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 header, control = 0;
@@ -4005,7 +4005,7 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
 static void gfx_v9_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
                                          struct amdgpu_job *job,
                                          struct amdgpu_ib *ib,
-                                         bool ctx_switch)
+                                         uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        u32 control = INDIRECT_BUFFER_VALID | ib->length_dw | (vmid << 24);
index 9f3cb2aec7c2842beb64864188de3e9fe47ebc7a..cca3552b36eda31c23ff064d04c37ae4f8f13fa2 100644 (file)
@@ -247,7 +247,7 @@ static void sdma_v2_4_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
 static void sdma_v2_4_ring_emit_ib(struct amdgpu_ring *ring,
                                   struct amdgpu_job *job,
                                   struct amdgpu_ib *ib,
-                                  bool ctx_switch)
+                                  uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index 06c5a277aa769475eed37adef5dd2bdfffc9f154..0ce8331baeb2438b372d78290008611fa379271c 100644 (file)
@@ -421,7 +421,7 @@ static void sdma_v3_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
 static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
                                   struct amdgpu_job *job,
                                   struct amdgpu_ib *ib,
-                                  bool ctx_switch)
+                                  uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index 48a166ba9fed95b95f72ddd54e4393abf6cce9c1..127b85983e8fbdaa3fd888c0fb75387db0cfdf43 100644 (file)
@@ -500,7 +500,7 @@ static void sdma_v4_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
 static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring,
                                   struct amdgpu_job *job,
                                   struct amdgpu_ib *ib,
-                                  bool ctx_switch)
+                                  uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index b6e473134e19fae3bb107fa9160676616ecd44fc..f15f196684ba32fe66a31b9113eb8ebc2ee02d3b 100644 (file)
@@ -63,7 +63,7 @@ static void si_dma_ring_set_wptr(struct amdgpu_ring *ring)
 static void si_dma_ring_emit_ib(struct amdgpu_ring *ring,
                                struct amdgpu_job *job,
                                struct amdgpu_ib *ib,
-                               bool ctx_switch)
+                               uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
        /* The indirect buffer packet must end on an 8 DW boundary in the DMA ring.
index d69c8f6daaf80a0b062287cc7c4cf4ec3de2a356..c4fb58667fd451c8157398022735a1c35a568a3d 100644 (file)
@@ -511,7 +511,7 @@ static int uvd_v4_2_ring_test_ring(struct amdgpu_ring *ring)
 static void uvd_v4_2_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        amdgpu_ring_write(ring, PACKET0(mmUVD_RBC_IB_BASE, 0));
        amdgpu_ring_write(ring, ib->gpu_addr);
index ee8cd06ddc385f08deb8271b3751696ecd1200b3..52bd8a6547347e287e18c916ae6e07517f2039a3 100644 (file)
@@ -526,7 +526,7 @@ static int uvd_v5_0_ring_test_ring(struct amdgpu_ring *ring)
 static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        amdgpu_ring_write(ring, PACKET0(mmUVD_LMI_RBC_IB_64BIT_BAR_LOW, 0));
        amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr));
index d4f4a66f8324131f1e8d925026ee9ad39471d25e..c9edddf9f88a8c67ce9742632120287504838b68 100644 (file)
@@ -977,7 +977,7 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring)
 static void uvd_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
@@ -1003,7 +1003,7 @@ static void uvd_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
 static void uvd_v6_0_enc_ring_emit_ib(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index aef924026a28c620373763aeb5d0c1274c1c44d2..dc461df48da09c22020f48bd8c3bd387d276099f 100644 (file)
@@ -1272,7 +1272,7 @@ static int uvd_v7_0_ring_patch_cs_in_place(struct amdgpu_cs_parser *p,
 static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        struct amdgpu_device *adev = ring->adev;
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
@@ -1303,7 +1303,7 @@ static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring,
 static void uvd_v7_0_enc_ring_emit_ib(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index 2668effadd271a3cfc1d6cd35d631975716b5689..6ec65cf111124e1f5659d3d46d05a152ab64d5c6 100644 (file)
@@ -834,7 +834,7 @@ out:
 static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job,
                                  struct amdgpu_ib *ib,
-                                 bool ctx_switch)
+                                 uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index 9fb34b7d8e03e88f411dcf369a79d4853aaef897..aadc3e66ebd7c1164c359f8e13afb12deec4c46d 100644 (file)
@@ -947,7 +947,7 @@ static int vce_v4_0_set_powergating_state(void *handle,
 #endif
 
 static void vce_v4_0_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_job *job,
-                                       struct amdgpu_ib *ib, bool ctx_switch)
+                                       struct amdgpu_ib *ib, uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
index 89bb2fef90eb725d5793c32b3c3c90aa0f23edf7..3dbc51f9d3b92ecde0bb04b9983ffb0d30036310 100644 (file)
@@ -1371,7 +1371,7 @@ static void vcn_v1_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64
 static void vcn_v1_0_dec_ring_emit_ib(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        struct amdgpu_device *adev = ring->adev;
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
@@ -1531,7 +1531,7 @@ static void vcn_v1_0_enc_ring_insert_end(struct amdgpu_ring *ring)
 static void vcn_v1_0_enc_ring_emit_ib(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);
 
@@ -1736,7 +1736,7 @@ static void vcn_v1_0_jpeg_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u6
 static void vcn_v1_0_jpeg_ring_emit_ib(struct amdgpu_ring *ring,
                                        struct amdgpu_job *job,
                                        struct amdgpu_ib *ib,
-                                       bool ctx_switch)
+                                       uint32_t flags)
 {
        struct amdgpu_device *adev = ring->adev;
        unsigned vmid = AMDGPU_JOB_GET_VMID(job);