Skip to contentSkip to conversation

drm/amdgpu: deduplicate ring preempt ib function

PATCH Superseded Leonardo Cesar 3 participants 3 messages Apr 22

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: deduplicate ring preempt ib function

The ring preemption function is identical for both gfx_v11_0 and gfx_v12_0. This patch refactors the code by moving the core logic into a generic function inside amdgpu_gfx.c to reduce code duplication and simplify future maintenance.

---
v1 -> v2:
- Removed wrapper functions for gfx_v11 and gfx_v12 and updated call sites directly.

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | ...

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 51 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  2 +
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 52 +------------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 52 +------------------------
 4 files changed, 55 insertions(+), 102 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +51 -0
index 2956e45c9..a157cbd8e 100644
@@ -2684,3 +2684,54 @@ void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev)
 #endif
 }
 
+int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring)
+{
+	int i, r = 0;
+	struct amdgpu_device *adev = ring->adev;
+	struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
+	struct amdgpu_ring *kiq_ring = &kiq->ring;
+	unsigned long flags;
+
+	if (adev->enable_mes)
+		return -EINVAL;
+
+	if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
+		return -EINVAL;
+
+	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);
+
+	/* assert IB preemption, emit the trailing fence */
+	kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
+					ring->trail_fence_gpu_addr,
+					++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 ==
+			le32_to_cpu(*(ring->trail_fence_cpu_addr)))
+			break;
+		udelay(1);
+	}
+
+	if (i >= adev->usec_timeout) {
+		r = -EINVAL;
+		DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
+	}
+
+	/* deassert preemption condition */
+	amdgpu_ring_set_preempt_cond_exec(ring, true);
+	return r;
+}
+
+
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
index a0cf0a3b4..77050f988 100644
@@ -664,6 +664,8 @@ void amdgpu_gfx_csb_preamble_end(u32 *buffer, u32 count);
 void amdgpu_debugfs_gfx_sched_mask_init(struct amdgpu_device *adev);
 void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev);
 
+int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring);
+
 static inline const char *amdgpu_gfx_compute_mode_desc(int mode)
 {
 	switch (mode) {
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -51

64 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -51

64 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 4 lines · Leonardo Cesar

The ring preemption function is identical for both gfx_v11_0 and gfx_v12_0. This patch refactors the code by moving the core logic into a generic function inside amdgpu_gfx.c to reduce code duplication and simplify future maintenance.

Yeah that one looks reasonable. As far as I can see there isn't anything HW generation specific in the function.

Question is rather why we have that for gfx12 in the first place. @Alex IIRC we support preemption only for a very narrow use case on gfx11, could that just be accidentially be copied over?

Quoted 20 lines

---
v1 -> v2:
- Removed wrapper functions for gfx_v11 and gfx_v12 and updated call sites directly.

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | ...

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 51 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  2 +
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 52 +------------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 52 +------------------------
 4 files changed, 55 insertions(+), 102 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 2956e45c9..a157cbd8e 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev) · line 2689

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3 -0
@@ -2684,3 +2684,54 @@ void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev)
 #endif
 }
 
+int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring)
+{
+       int i, r = 0;

Just a style nit: Variables like "i" or "r" last please and don't initialize vairables like "r" while defining it.

Regards,
Christian.

Quoted 204 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +48 -0
+       struct amdgpu_device *adev = ring->adev;
+       struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
+       struct amdgpu_ring *kiq_ring = &kiq->ring;
+       unsigned long flags;
+
+       if (adev->enable_mes)
+               return -EINVAL;
+
+       if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
+               return -EINVAL;
+
+       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);
+
+       /* assert IB preemption, emit the trailing fence */
+       kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
+                                       ring->trail_fence_gpu_addr,
+                                       ++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 ==
+                       le32_to_cpu(*(ring->trail_fence_cpu_addr)))
+                       break;
+               udelay(1);
+       }
+
+       if (i >= adev->usec_timeout) {
+               r = -EINVAL;
+               DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
+       }
+
+       /* deassert preemption condition */
+       amdgpu_ring_set_preempt_cond_exec(ring, true);
+       return r;
+}
+
+
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
index a0cf0a3b4..77050f988 100644
@@ -664,6 +664,8 @@ void amdgpu_gfx_csb_preamble_end(u32 *buffer, u32 count);
 void amdgpu_debugfs_gfx_sched_mask_init(struct amdgpu_device *adev);
 void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev);
 
+int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring);
+
 static inline const char *amdgpu_gfx_compute_mode_desc(int mode)
 {
        switch (mode) {
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -51
index 5097de940..1ba848bfa 100644
@@ -6206,56 +6206,6 @@ static void gfx_v11_0_ring_emit_gfx_shadow(struct amdgpu_ring *ring,
        ring->set_q_mode_offs = offs;
 }
 
-static int gfx_v11_0_ring_preempt_ib(struct amdgpu_ring *ring)
-{
-       int i, r = 0;
-       struct amdgpu_device *adev = ring->adev;
-       struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
-       struct amdgpu_ring *kiq_ring = &kiq->ring;
-       unsigned long flags;
-
-       if (adev->enable_mes)
-               return -EINVAL;
-
-       if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
-               return -EINVAL;
-
-       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);
-
-       /* assert IB preemption, emit the trailing fence */
-       kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
-                                  ring->trail_fence_gpu_addr,
-                                  ++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 ==
-                   le32_to_cpu(*(ring->trail_fence_cpu_addr)))
-                       break;
-               udelay(1);
-       }
-
-       if (i >= adev->usec_timeout) {
-               r = -EINVAL;
-               DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
-       }
-
-       /* deassert preemption condition */
-       amdgpu_ring_set_preempt_cond_exec(ring, true);
-       return r;
-}
-
 static void gfx_v11_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume)
 {
        struct amdgpu_device *adev = ring->adev;
@@ -7295,7 +7245,7 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = {
        .emit_cntxcntl = gfx_v11_0_ring_emit_cntxcntl,
        .emit_gfx_shadow = gfx_v11_0_ring_emit_gfx_shadow,
        .init_cond_exec = gfx_v11_0_ring_emit_init_cond_exec,
-       .preempt_ib = gfx_v11_0_ring_preempt_ib,
+       .preempt_ib = amdgpu_gfx_ring_preempt_ib,
        .emit_frame_cntl = gfx_v11_0_ring_emit_frame_cntl,
        .emit_wreg = gfx_v11_0_ring_emit_wreg,
        .emit_reg_wait = gfx_v11_0_ring_emit_reg_wait,
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -52
index 65c33823a..6cf244349 100644
@@ -4611,56 +4611,6 @@ static unsigned gfx_v12_0_ring_emit_init_cond_exec(struct amdgpu_ring *ring,
        return ret;
 }
 
-static int gfx_v12_0_ring_preempt_ib(struct amdgpu_ring *ring)
-{
-       int i, r = 0;
-       struct amdgpu_device *adev = ring->adev;
-       struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
-       struct amdgpu_ring *kiq_ring = &kiq->ring;
-       unsigned long flags;
-
-       if (adev->enable_mes)
-               return -EINVAL;
-
-       if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
-               return -EINVAL;
-
-       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);
-
-       /* assert IB preemption, emit the trailing fence */
-       kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
-                                  ring->trail_fence_gpu_addr,
-                                  ++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 ==
-                   le32_to_cpu(*(ring->trail_fence_cpu_addr)))
-                       break;
-               udelay(1);
-       }
-
-       if (i >= adev->usec_timeout) {
-               r = -EINVAL;
-               DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
-       }
-
-       /* deassert preemption condition */
-       amdgpu_ring_set_preempt_cond_exec(ring, true);
-       return r;
-}
-
 static void gfx_v12_0_ring_emit_rreg(struct amdgpu_ring *ring, uint32_t reg,
                                     uint32_t reg_val_offs)
 {
@@ -5539,7 +5489,7 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_gfx = {
        .pad_ib = amdgpu_ring_generic_pad_ib,
        .emit_cntxcntl = gfx_v12_0_ring_emit_cntxcntl,
        .init_cond_exec = gfx_v12_0_ring_emit_init_cond_exec,
-       .preempt_ib = gfx_v12_0_ring_preempt_ib,
+       .preempt_ib = amdgpu_gfx_ring_preempt_ib,
        .emit_wreg = gfx_v12_0_ring_emit_wreg,
        .emit_reg_wait = gfx_v12_0_ring_emit_reg_wait,
        .emit_reg_write_reg_wait = gfx_v12_0_ring_emit_reg_write_reg_wait,
--

2.43.0

#2 lore raw
Quoted 11 lines · Christian König
Quoted 4 lines · Leonardo Cesar

The ring preemption function is identical for both gfx_v11_0 and gfx_v12_0. This patch refactors the code by moving the core logic into a generic function inside amdgpu_gfx.c to reduce code duplication and simplify future maintenance.

Yeah that one looks reasonable. As far as I can see there isn't anything HW generation specific in the function.

Question is rather why we have that for gfx12 in the first place. @Alex IIRC we support preemption only for a very narrow use case on gfx11, could that just be accidentially be copied over?

Yeah, probably just copy and pasted over when we brought up gfx12.

Alex

Quoted 237 lines
Quoted 20 lines

---
v1 -> v2:
- Removed wrapper functions for gfx_v11 and gfx_v12 and updated call sites directly.

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | ...

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 51 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  2 +
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 52 +------------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 52 +------------------------
 4 files changed, 55 insertions(+), 102 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 2956e45c9..a157cbd8e 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev) · line 2689

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3 -0
@@ -2684,3 +2684,54 @@ void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev)
 #endif
 }
 
+int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring)
+{
+       int i, r = 0;

Just a style nit: Variables like "i" or "r" last please and don't initialize vairables like "r" while defining it.

Regards,
Christian.

Quoted 204 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +48 -0
+       struct amdgpu_device *adev = ring->adev;
+       struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
+       struct amdgpu_ring *kiq_ring = &kiq->ring;
+       unsigned long flags;
+
+       if (adev->enable_mes)
+               return -EINVAL;
+
+       if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
+               return -EINVAL;
+
+       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);
+
+       /* assert IB preemption, emit the trailing fence */
+       kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
+                                       ring->trail_fence_gpu_addr,
+                                       ++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 ==
+                       le32_to_cpu(*(ring->trail_fence_cpu_addr)))
+                       break;
+               udelay(1);
+       }
+
+       if (i >= adev->usec_timeout) {
+               r = -EINVAL;
+               DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
+       }
+
+       /* deassert preemption condition */
+       amdgpu_ring_set_preempt_cond_exec(ring, true);
+       return r;
+}
+
+
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
index a0cf0a3b4..77050f988 100644
@@ -664,6 +664,8 @@ void amdgpu_gfx_csb_preamble_end(u32 *buffer, u32 count);
 void amdgpu_debugfs_gfx_sched_mask_init(struct amdgpu_device *adev);
 void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev);
 
+int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring);
+
 static inline const char *amdgpu_gfx_compute_mode_desc(int mode)
 {
        switch (mode) {
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -51
index 5097de940..1ba848bfa 100644
@@ -6206,56 +6206,6 @@ static void gfx_v11_0_ring_emit_gfx_shadow(struct amdgpu_ring *ring,
        ring->set_q_mode_offs = offs;
 }
 
-static int gfx_v11_0_ring_preempt_ib(struct amdgpu_ring *ring)
-{
-       int i, r = 0;
-       struct amdgpu_device *adev = ring->adev;
-       struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
-       struct amdgpu_ring *kiq_ring = &kiq->ring;
-       unsigned long flags;
-
-       if (adev->enable_mes)
-               return -EINVAL;
-
-       if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
-               return -EINVAL;
-
-       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);
-
-       /* assert IB preemption, emit the trailing fence */
-       kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
-                                  ring->trail_fence_gpu_addr,
-                                  ++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 ==
-                   le32_to_cpu(*(ring->trail_fence_cpu_addr)))
-                       break;
-               udelay(1);
-       }
-
-       if (i >= adev->usec_timeout) {
-               r = -EINVAL;
-               DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
-       }
-
-       /* deassert preemption condition */
-       amdgpu_ring_set_preempt_cond_exec(ring, true);
-       return r;
-}
-
 static void gfx_v11_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume)
 {
        struct amdgpu_device *adev = ring->adev;
@@ -7295,7 +7245,7 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = {
        .emit_cntxcntl = gfx_v11_0_ring_emit_cntxcntl,
        .emit_gfx_shadow = gfx_v11_0_ring_emit_gfx_shadow,
        .init_cond_exec = gfx_v11_0_ring_emit_init_cond_exec,
-       .preempt_ib = gfx_v11_0_ring_preempt_ib,
+       .preempt_ib = amdgpu_gfx_ring_preempt_ib,
        .emit_frame_cntl = gfx_v11_0_ring_emit_frame_cntl,
        .emit_wreg = gfx_v11_0_ring_emit_wreg,
        .emit_reg_wait = gfx_v11_0_ring_emit_reg_wait,
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -52
index 65c33823a..6cf244349 100644
@@ -4611,56 +4611,6 @@ static unsigned gfx_v12_0_ring_emit_init_cond_exec(struct amdgpu_ring *ring,
        return ret;
 }
 
-static int gfx_v12_0_ring_preempt_ib(struct amdgpu_ring *ring)
-{
-       int i, r = 0;
-       struct amdgpu_device *adev = ring->adev;
-       struct amdgpu_kiq *kiq = &adev->gfx.kiq[0];
-       struct amdgpu_ring *kiq_ring = &kiq->ring;
-       unsigned long flags;
-
-       if (adev->enable_mes)
-               return -EINVAL;
-
-       if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
-               return -EINVAL;
-
-       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);
-
-       /* assert IB preemption, emit the trailing fence */
-       kiq->pmf->kiq_unmap_queues(kiq_ring, ring, PREEMPT_QUEUES_NO_UNMAP,
-                                  ring->trail_fence_gpu_addr,
-                                  ++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 ==
-                   le32_to_cpu(*(ring->trail_fence_cpu_addr)))
-                       break;
-               udelay(1);
-       }
-
-       if (i >= adev->usec_timeout) {
-               r = -EINVAL;
-               DRM_ERROR("ring %d failed to preempt ib\n", ring->idx);
-       }
-
-       /* deassert preemption condition */
-       amdgpu_ring_set_preempt_cond_exec(ring, true);
-       return r;
-}
-
 static void gfx_v12_0_ring_emit_rreg(struct amdgpu_ring *ring, uint32_t reg,
                                     uint32_t reg_val_offs)
 {
@@ -5539,7 +5489,7 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_gfx = {
        .pad_ib = amdgpu_ring_generic_pad_ib,
        .emit_cntxcntl = gfx_v12_0_ring_emit_cntxcntl,
        .init_cond_exec = gfx_v12_0_ring_emit_init_cond_exec,
-       .preempt_ib = gfx_v12_0_ring_preempt_ib,
+       .preempt_ib = amdgpu_gfx_ring_preempt_ib,
        .emit_wreg = gfx_v12_0_ring_emit_wreg,
        .emit_reg_wait = gfx_v12_0_ring_emit_reg_wait,
        .emit_reg_write_reg_wait = gfx_v12_0_ring_emit_reg_write_reg_wait,
--

2.43.0