Skip to contentSkip to conversation

drm/amdgpu: Add the new sdma function pointers for amdgpu_sdma.h

PATCH In review [email protected] 2 participants 12 messages Apr 11, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/6 drm/amdgpu: Add the new sdma function pointers for amdgpu_sdma.h

From: "[email protected]" <[email protected]>

This patch introduces new function pointers in the amdgpu_sdma structure to handle queue stop, start and soft reset operations. These will replace the older callback mechanism.

The new functions are:
- stop_kernel_queue: Stops a specific SDMA queue
- start_kernel_queue: Starts/Restores a specific SDMA queue
- soft_reset_kernel_queue: Performs soft reset on a specific SDMA queue

v2: Update stop_queue/start_queue function paramters to use ring pointer instead of device/instance(Chritian)
v3: move stop_queue/start_queue to struct amdgpu_sdma_instance and rename them. (Alex)
v4: rework the ordering a bit (Alex)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +7 -1
index 0b1fbcf0b4d0..a6c8f07a0da4 100644
@@ -50,6 +50,12 @@ enum amdgpu_sdma_irq {
 
 #define NUM_SDMA(x) hweight32(x)
 
+struct amdgpu_sdma_funcs {
+	int (*stop_kernel_queue)(struct amdgpu_ring *ring);
+	int (*start_kernel_queue)(struct amdgpu_ring *ring);
+	int (*soft_reset_kernel_queue)(struct amdgpu_device *adev, u32 instance_id);
+};
+
 struct amdgpu_sdma_instance {
 	/* SDMA firmware */
 	const struct firmware	*fw;
@@ -68,7 +74,7 @@ struct amdgpu_sdma_instance {
 	/* track guilty state of GFX and PAGE queues */
 	bool			gfx_guilty;
 	bool			page_guilty;
-
+	const struct amdgpu_sdma_funcs   *funcs;
 };
 
 enum amdgpu_sdma_ras_memory_id {
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 2/6 drm/amdgpu: Register the new sdma function pointers for each sdma IP version that needs them

From: "[email protected]" <[email protected]>

Register stop/start/soft_reset queue functions for SDMA IP versions v4.4.2, v5.0 and v5.2.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 22 +++---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 76 ++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 92 ++++++++++++++----------
 3 files changed, 125 insertions(+), 65 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +14 -8
index 688a720bbbbd..c663c63485f4 100644
@@ -108,6 +108,8 @@ static void sdma_v4_4_2_set_irq_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_ras_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_update_reset_mask(struct amdgpu_device *adev);
+static int sdma_v4_4_2_stop_queue(struct amdgpu_ring *ring);
+static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring);
 
 static u32 sdma_v4_4_2_get_reg_offset(struct amdgpu_device *adev,
 		u32 instance, u32 offset)
@@ -1333,6 +1335,11 @@ static bool sdma_v4_4_2_fw_support_paging_queue(struct amdgpu_device *adev)
 	}
 }
 
+static const struct amdgpu_sdma_funcs sdma_v4_4_2_sdma_funcs = {
+	.stop_kernel_queue = &sdma_v4_4_2_stop_queue,
+	.start_kernel_queue = &sdma_v4_4_2_restore_queue,
+};
+
 static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
@@ -1352,7 +1359,6 @@ static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)
 	sdma_v4_4_2_set_irq_funcs(adev);
 	sdma_v4_4_2_set_ras_funcs(adev);
 	sdma_v4_4_2_set_engine_reset_funcs(adev);
-
 	return 0;
 }
 
@@ -1447,6 +1453,7 @@ static int sdma_v4_4_2_sw_init(struct amdgpu_ip_block *ip_block)
 		/* Initialize guilty flags for GFX and PAGE queues */
 		adev->sdma.instance[i].gfx_guilty = false;
 		adev->sdma.instance[i].page_guilty = false;
+		adev->sdma.instance[i].funcs = &sdma_v4_4_2_sdma_funcs;
 
 		ring = &adev->sdma.instance[i].ring;
 		ring->ring_obj = NULL;
@@ -1678,11 +1685,12 @@ static int sdma_v4_4_2_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
 	return r;
 }
 
-static int sdma_v4_4_2_stop_queue(struct amdgpu_device *adev, uint32_t instance_id)
+static int sdma_v4_4_2_stop_queue(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
+	u32 instance_id = GET_INST(SDMA0, ring->me);
 	u32 inst_mask;
 	uint64_t rptr;
-	struct amdgpu_ring *ring = &adev->sdma.instance[instance_id].ring;
 
 	if (amdgpu_sriov_vf(adev))
 		return -EINVAL;
@@ -1715,11 +1723,11 @@ static int sdma_v4_4_2_stop_queue(struct amdgpu_device *adev, uint32_t instance_
 	return 0;
 }
 
-static int sdma_v4_4_2_restore_queue(struct amdgpu_device *adev, uint32_t instance_id)
+static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring)
 {
-	int i;
+	struct amdgpu_device *adev = ring->adev;
 	u32 inst_mask;
-	struct amdgpu_ring *ring = &adev->sdma.instance[instance_id].ring;
+	int i;
 
 	inst_mask = 1 << ring->me;
 	udelay(50);
@@ -1740,8 +1748,6 @@ static int sdma_v4_4_2_restore_queue(struct amdgpu_device *adev, uint32_t instan
 }
 
 static struct sdma_on_reset_funcs sdma_v4_4_2_engine_reset_funcs = {
-	.pre_reset = sdma_v4_4_2_stop_queue,
-	.post_reset = sdma_v4_4_2_restore_queue,
 };
 
 static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +56 -20

113 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +55 -37

145 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v5 2/6
#2 lore raw

Re: [v5 2/6] drm/amdgpu: Register the new sdma function pointers for each sdma IP version that needs them

Quoted 8 lines · On Fri, Apr 11, 2025 at 4:37 AM [email protected] <[email protected]> wrote:

From: "[email protected]" <[email protected]>

Register stop/start/soft_reset queue functions for SDMA IP versions v4.4.2, v5.0 and v5.2.

Might want to split this per IP? Either way:

Quoted 365 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 22 +++---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 76 ++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 92 ++++++++++++++----------
 3 files changed, 125 insertions(+), 65 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +14 -8
index 688a720bbbbd..c663c63485f4 100644
@@ -108,6 +108,8 @@ static void sdma_v4_4_2_set_irq_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_ras_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_update_reset_mask(struct amdgpu_device *adev);
+static int sdma_v4_4_2_stop_queue(struct amdgpu_ring *ring);
+static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring);
 
 static u32 sdma_v4_4_2_get_reg_offset(struct amdgpu_device *adev,
                u32 instance, u32 offset)
@@ -1333,6 +1335,11 @@ static bool sdma_v4_4_2_fw_support_paging_queue(struct amdgpu_device *adev)
        }
 }
 
+static const struct amdgpu_sdma_funcs sdma_v4_4_2_sdma_funcs = {
+       .stop_kernel_queue = &sdma_v4_4_2_stop_queue,
+       .start_kernel_queue = &sdma_v4_4_2_restore_queue,
+};
+
 static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)
 {
        struct amdgpu_device *adev = ip_block->adev;
@@ -1352,7 +1359,6 @@ static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)
        sdma_v4_4_2_set_irq_funcs(adev);
        sdma_v4_4_2_set_ras_funcs(adev);
        sdma_v4_4_2_set_engine_reset_funcs(adev);
-
        return 0;
 }
 
@@ -1447,6 +1453,7 @@ static int sdma_v4_4_2_sw_init(struct amdgpu_ip_block *ip_block)
                /* Initialize guilty flags for GFX and PAGE queues */
                adev->sdma.instance[i].gfx_guilty = false;
                adev->sdma.instance[i].page_guilty = false;
+               adev->sdma.instance[i].funcs = &sdma_v4_4_2_sdma_funcs;
 
                ring = &adev->sdma.instance[i].ring;
                ring->ring_obj = NULL;
@@ -1678,11 +1685,12 @@ static int sdma_v4_4_2_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
        return r;
 }
 
-static int sdma_v4_4_2_stop_queue(struct amdgpu_device *adev, uint32_t instance_id)
+static int sdma_v4_4_2_stop_queue(struct amdgpu_ring *ring)
 {
+       struct amdgpu_device *adev = ring->adev;
+       u32 instance_id = GET_INST(SDMA0, ring->me);
        u32 inst_mask;
        uint64_t rptr;
-       struct amdgpu_ring *ring = &adev->sdma.instance[instance_id].ring;
 
        if (amdgpu_sriov_vf(adev))
                return -EINVAL;
@@ -1715,11 +1723,11 @@ static int sdma_v4_4_2_stop_queue(struct amdgpu_device *adev, uint32_t instance_
        return 0;
 }
 
-static int sdma_v4_4_2_restore_queue(struct amdgpu_device *adev, uint32_t instance_id)
+static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring)
 {
-       int i;
+       struct amdgpu_device *adev = ring->adev;
        u32 inst_mask;
-       struct amdgpu_ring *ring = &adev->sdma.instance[instance_id].ring;
+       int i;
 
        inst_mask = 1 << ring->me;
        udelay(50);
@@ -1740,8 +1748,6 @@ static int sdma_v4_4_2_restore_queue(struct amdgpu_device *adev, uint32_t instan
 }
 
 static struct sdma_on_reset_funcs sdma_v4_4_2_engine_reset_funcs = {
-       .pre_reset = sdma_v4_4_2_stop_queue,
-       .post_reset = sdma_v4_4_2_restore_queue,
 };
 
 static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +56 -20
index e1348b6d9c6a..bef80b318f8e 100644
@@ -112,6 +112,8 @@ static void sdma_v5_0_set_ring_funcs(struct amdgpu_device *adev);
 static void sdma_v5_0_set_buffer_funcs(struct amdgpu_device *adev);
 static void sdma_v5_0_set_vm_pte_funcs(struct amdgpu_device *adev);
 static void sdma_v5_0_set_irq_funcs(struct amdgpu_device *adev);
+static int sdma_v5_0_stop_queue(struct amdgpu_ring *ring);
+static int sdma_v5_0_restore_queue(struct amdgpu_ring *ring);
 
 static const struct soc15_reg_golden golden_settings_sdma_5[] = {
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmSDMA0_CHICKEN_BITS, 0xffbf1f0f, 0x03ab0107),
@@ -1323,6 +1325,36 @@ static void sdma_v5_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
        amdgpu_ring_emit_reg_wait(ring, reg1, mask, mask);
 }
 
+static int sdma_v5_0_soft_reset_engine(struct amdgpu_device *adev, u32 instance_id)
+{
+       u32 grbm_soft_reset;
+       u32 tmp;
+
+       grbm_soft_reset = REG_SET_FIELD(0,
+                                       GRBM_SOFT_RESET, SOFT_RESET_SDMA0,
+                                       1);
+       grbm_soft_reset <<= instance_id;
+
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+       tmp |= grbm_soft_reset;
+       DRM_DEBUG("GRBM_SOFT_RESET=0x%08X\n", tmp);
+       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+
+       udelay(50);
+
+       tmp &= ~grbm_soft_reset;
+       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+       return 0;
+}
+
+static const struct amdgpu_sdma_funcs sdma_v5_0_sdma_funcs = {
+       .stop_kernel_queue = &sdma_v5_0_stop_queue,
+       .start_kernel_queue = &sdma_v5_0_restore_queue,
+       .soft_reset_kernel_queue = &sdma_v5_0_soft_reset_engine,
+};
+
 static int sdma_v5_0_early_init(struct amdgpu_ip_block *ip_block)
 {
        struct amdgpu_device *adev = ip_block->adev;
@@ -1365,6 +1397,7 @@ static int sdma_v5_0_sw_init(struct amdgpu_ip_block *ip_block)
                return r;
 
        for (i = 0; i < adev->sdma.num_instances; i++) {
+               adev->sdma.instance[i].funcs = &sdma_v5_0_sdma_funcs;
                ring = &adev->sdma.instance[i].ring;
                ring->ring_obj = NULL;
                ring->use_doorbell = true;
@@ -1505,9 +1538,17 @@ static int sdma_v5_0_soft_reset(struct amdgpu_ip_block *ip_block)
 
 static int sdma_v5_0_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
 {
+       struct amdgpu_device *adev = ring->adev;
+       u32 inst_id = ring->me;
+
+       return amdgpu_sdma_reset_engine(adev, inst_id);
+}
+
+static int sdma_v5_0_stop_queue(struct amdgpu_ring *ring)
+{
+       u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, stat1_reg;
        struct amdgpu_device *adev = ring->adev;
        int i, j, r;
-       u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, preempt, soft_reset, stat1_reg;
 
        if (amdgpu_sriov_vf(adev))
                return -EINVAL;
@@ -1562,30 +1603,25 @@ static int sdma_v5_0_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
        cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_CNTL));
        cntl = REG_SET_FIELD(cntl, SDMA0_CNTL, UTC_L1_ENABLE, 0);
        WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_CNTL), cntl);
+err0:
+       amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
+       return r;
+}
 
-       /* soft reset SDMA_GFX_PREEMPT.IB_PREEMPT = 0 mmGRBM_SOFT_RESET.SOFT_RESET_SDMA0/1 = 1 */
-       preempt = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_PREEMPT));
-       preempt = REG_SET_FIELD(preempt, SDMA0_GFX_PREEMPT, IB_PREEMPT, 0);
-       WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_PREEMPT), preempt);
-
-       soft_reset = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
-       soft_reset |= 1 << GRBM_SOFT_RESET__SOFT_RESET_SDMA0__SHIFT << i;
-
-       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, soft_reset);
-
-       udelay(50);
-
-       soft_reset &= ~(1 << GRBM_SOFT_RESET__SOFT_RESET_SDMA0__SHIFT << i);
-       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, soft_reset);
+static int sdma_v5_0_restore_queue(struct amdgpu_ring *ring)
+{
+       struct amdgpu_device *adev = ring->adev;
+       u32 inst_id = ring->me;
+       u32 freeze;
+       int r;
 
+       amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
        /* unfreeze*/
-       freeze = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_FREEZE));
+       freeze = RREG32(sdma_v5_0_get_reg_offset(adev, inst_id, mmSDMA0_FREEZE));
        freeze = REG_SET_FIELD(freeze, SDMA0_FREEZE, FREEZE, 0);
-       WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_FREEZE), freeze);
+       WREG32(sdma_v5_0_get_reg_offset(adev, inst_id, mmSDMA0_FREEZE), freeze);
 
-       r = sdma_v5_0_gfx_resume_instance(adev, i, true);
-
-err0:
+       r = sdma_v5_0_gfx_resume_instance(adev, inst_id, true);
        amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
        return r;
 }
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +55 -38
index 964f12afac9e..4cd7010ad0d7 100644
@@ -113,6 +113,8 @@ static void sdma_v5_2_set_ring_funcs(struct amdgpu_device *adev);
 static void sdma_v5_2_set_buffer_funcs(struct amdgpu_device *adev);
 static void sdma_v5_2_set_vm_pte_funcs(struct amdgpu_device *adev);
 static void sdma_v5_2_set_irq_funcs(struct amdgpu_device *adev);
+static int sdma_v5_2_stop_queue(struct amdgpu_ring *ring);
+static int sdma_v5_2_restore_queue(struct amdgpu_ring *ring);
 
 static u32 sdma_v5_2_get_reg_offset(struct amdgpu_device *adev, u32 instance, u32 internal_offset)
 {
@@ -759,37 +761,49 @@ static int sdma_v5_2_load_microcode(struct amdgpu_device *adev)
        return 0;
 }
 
-static int sdma_v5_2_soft_reset(struct amdgpu_ip_block *ip_block)
+static int sdma_v5_2_soft_reset_engine(struct amdgpu_device *adev, u32 instance_id)
 {
-       struct amdgpu_device *adev = ip_block->adev;
        u32 grbm_soft_reset;
        u32 tmp;
-       int i;
 
-       for (i = 0; i < adev->sdma.num_instances; i++) {
-               grbm_soft_reset = REG_SET_FIELD(0,
-                                               GRBM_SOFT_RESET, SOFT_RESET_SDMA0,
-                                               1);
-               grbm_soft_reset <<= i;
+       grbm_soft_reset = REG_SET_FIELD(0,
+                                       GRBM_SOFT_RESET, SOFT_RESET_SDMA0,
+                                       1);
+       grbm_soft_reset <<= instance_id;
 
-               tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
-               tmp |= grbm_soft_reset;
-               DRM_DEBUG("GRBM_SOFT_RESET=0x%08X\n", tmp);
-               WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
-               tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+       tmp |= grbm_soft_reset;
+       DRM_DEBUG("GRBM_SOFT_RESET=0x%08X\n", tmp);
+       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
 
-               udelay(50);
+       udelay(50);
 
-               tmp &= ~grbm_soft_reset;
-               WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
-               tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+       tmp &= ~grbm_soft_reset;
+       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
+       return 0;
+}
 
+static int sdma_v5_2_soft_reset(struct amdgpu_ip_block *ip_block)
+{
+       struct amdgpu_device *adev = ip_block->adev;
+       int i;
+
+       for (i = 0; i < adev->sdma.num_instances; i++) {
+               sdma_v5_2_soft_reset_engine(adev, i);
                udelay(50);
        }
 
        return 0;
 }
 
+static const struct amdgpu_sdma_funcs sdma_v5_2_sdma_funcs = {
+       .stop_kernel_queue = &sdma_v5_2_stop_queue,
+       .start_kernel_queue = &sdma_v5_2_restore_queue,
+       .soft_reset_kernel_queue = &sdma_v5_2_soft_reset_engine,
+};
+
 /**
  * sdma_v5_2_start - setup and start the async dma engines
  *
@@ -1302,6 +1316,7 @@ static int sdma_v5_2_sw_init(struct amdgpu_ip_block *ip_block)
        }
 
        for (i = 0; i < adev->sdma.num_instances; i++) {
+               adev->sdma.instance[i].funcs = &sdma_v5_2_sdma_funcs;
                ring = &adev->sdma.instance[i].ring;
                ring->ring_obj = NULL;
                ring->use_doorbell = true;
@@ -1435,10 +1450,18 @@ static int sdma_v5_2_wait_for_idle(struct amdgpu_ip_block *ip_block)
 }
 
 static int sdma_v5_2_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
+{
+       struct amdgpu_device *adev = ring->adev;
+       u32 inst_id = ring->me;
+
+       return amdgpu_sdma_reset_engine(adev, inst_id);
+}
+
+static int sdma_v5_2_stop_queue(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
        int i, j, r;
-       u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, preempt, soft_reset, stat1_reg;
+       u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, stat1_reg;
 
        if (amdgpu_sriov_vf(adev))
                return -EINVAL;
@@ -1495,31 +1518,26 @@ static int sdma_v5_2_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
        cntl = REG_SET_FIELD(cntl, SDMA0_CNTL, UTC_L1_ENABLE, 0);
        WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_CNTL), cntl);
 
-       /* soft reset SDMA_GFX_PREEMPT.IB_PREEMPT = 0 mmGRBM_SOFT_RESET.SOFT_RESET_SDMA0/1 = 1 */
-       preempt = RREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_PREEMPT));
-       preempt = REG_SET_FIELD(preempt, SDMA0_GFX_PREEMPT, IB_PREEMPT, 0);
-       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_PREEMPT), preempt);
-
-       soft_reset = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
-       soft_reset |= 1 << GRBM_SOFT_RESET__SOFT_RESET_SDMA0__SHIFT << i;
-
-
-       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, soft_reset);
-
-       udelay(50);
-
-       soft_reset &= ~(1 << GRBM_SOFT_RESET__SOFT_RESET_SDMA0__SHIFT << i);
+err0:
+       amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
+       return r;
+}
 
-       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, soft_reset);
+static int sdma_v5_2_restore_queue(struct amdgpu_ring *ring)
+{
+       struct amdgpu_device *adev = ring->adev;
+       u32 inst_id = ring->me;
+       u32 freeze;
+       int r;
 
+       amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
        /* unfreeze and unhalt */
-       freeze = RREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_FREEZE));
+       freeze = RREG32(sdma_v5_2_get_reg_offset(adev, inst_id, mmSDMA0_FREEZE));
        freeze = REG_SET_FIELD(freeze, SDMA0_FREEZE, FREEZE, 0);
-       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_FREEZE), freeze);
+       WREG32(sdma_v5_2_get_reg_offset(adev, inst_id, mmSDMA0_FREEZE), freeze);
 
-       r = sdma_v5_2_gfx_resume_instance(adev, i, true);
+       r = sdma_v5_2_gfx_resume_instance(adev, inst_id, true);
 
-err0:
        amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
        return r;
 }
--

2.25.1

#3 lore raw

PATCH v5 3/6 drm/amdgpu: switch amdgpu_sdma_reset_engine to use the new sdma function pointers

In reply to [email protected]

From: "[email protected]" <[email protected]>

Replace old callback mechanism with direct calls to stop/start functions.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 34 +++---------------------
 1 file changed, 4 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +4 -30
index c3c6f03190c8..7139d574c23e 100644
@@ -559,16 +559,10 @@ void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct
  * @adev: Pointer to the AMDGPU device
  * @instance_id: ID of the SDMA engine instance to reset
  *
- * This function performs the following steps:
- * 1. Calls all registered pre_reset callbacks to allow KFD and AMDGPU to save their state.
- * 2. Resets the specified SDMA engine instance.
- * 3. Calls all registered post_reset callbacks to allow KFD and AMDGPU to restore their state.
- *
  * Returns: 0 on success, or a negative error code on failure.
  */
 int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
 {
-	struct sdma_on_reset_funcs *funcs;
 	int ret = 0;
 	struct amdgpu_sdma_instance *sdma_instance = &adev->sdma.instance[instance_id];
 	struct amdgpu_ring *gfx_ring = &sdma_instance->ring;
@@ -590,18 +584,8 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
 		page_sched_stopped = true;
 	}
 
-	/* Invoke all registered pre_reset callbacks */
-	list_for_each_entry(funcs, &adev->sdma.reset_callback_list, list) {
-		if (funcs->pre_reset) {
-			ret = funcs->pre_reset(adev, instance_id);
-			if (ret) {
-				dev_err(adev->dev,
-				"beforeReset callback failed for instance %u: %d\n",
-					instance_id, ret);
-				goto exit;
-			}
-		}
-	}
+	if (sdma_instance->funcs->stop_kernel_queue)
+		sdma_instance->funcs->stop_kernel_queue(gfx_ring);
 
 	/* Perform the SDMA reset for the specified instance */
 	ret = amdgpu_dpm_reset_sdma(adev, 1 << instance_id);
@@ -610,18 +594,8 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
 		goto exit;
 	}
 
-	/* Invoke all registered post_reset callbacks */
-	list_for_each_entry(funcs, &adev->sdma.reset_callback_list, list) {
-		if (funcs->post_reset) {
-			ret = funcs->post_reset(adev, instance_id);
-			if (ret) {
-				dev_err(adev->dev,
-				"afterReset callback failed for instance %u: %d\n",
-					instance_id, ret);
-				goto exit;
-			}
-		}
-	}
+	if (sdma_instance->funcs->start_kernel_queue)
+		sdma_instance->funcs->start_kernel_queue(gfx_ring);
 
 exit:
 	/* Restart the scheduler's work queue for the GFX and page rings
Signature · 1 line
2.25.1
Reviewed-by on v5 3/6
#4 lore raw

Re: [v5 3/6] drm/amdgpu: switch amdgpu_sdma_reset_engine to use the new sdma function pointers

Quoted 7 lines · On Fri, Apr 11, 2025 at 4:30 AM [email protected] <[email protected]> wrote:

From: "[email protected]" <[email protected]>

Replace old callback mechanism with direct calls to stop/start functions.

Quoted 70 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 34 +++---------------------
 1 file changed, 4 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +4 -31
index c3c6f03190c8..7139d574c23e 100644
@@ -559,16 +559,10 @@ void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct
  * @adev: Pointer to the AMDGPU device
  * @instance_id: ID of the SDMA engine instance to reset
  *
- * This function performs the following steps:
- * 1. Calls all registered pre_reset callbacks to allow KFD and AMDGPU to save their state.
- * 2. Resets the specified SDMA engine instance.
- * 3. Calls all registered post_reset callbacks to allow KFD and AMDGPU to restore their state.
- *
  * Returns: 0 on success, or a negative error code on failure.
  */
 int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
 {
-       struct sdma_on_reset_funcs *funcs;
        int ret = 0;
        struct amdgpu_sdma_instance *sdma_instance = &adev->sdma.instance[instance_id];
        struct amdgpu_ring *gfx_ring = &sdma_instance->ring;
@@ -590,18 +584,8 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
                page_sched_stopped = true;
        }
 
-       /* Invoke all registered pre_reset callbacks */
-       list_for_each_entry(funcs, &adev->sdma.reset_callback_list, list) {
-               if (funcs->pre_reset) {
-                       ret = funcs->pre_reset(adev, instance_id);
-                       if (ret) {
-                               dev_err(adev->dev,
-                               "beforeReset callback failed for instance %u: %d\n",
-                                       instance_id, ret);
-                               goto exit;
-                       }
-               }
-       }
+       if (sdma_instance->funcs->stop_kernel_queue)
+               sdma_instance->funcs->stop_kernel_queue(gfx_ring);
 
        /* Perform the SDMA reset for the specified instance */
        ret = amdgpu_dpm_reset_sdma(adev, 1 << instance_id);
@@ -610,18 +594,8 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
                goto exit;
        }
 
-       /* Invoke all registered post_reset callbacks */
-       list_for_each_entry(funcs, &adev->sdma.reset_callback_list, list) {
-               if (funcs->post_reset) {
-                       ret = funcs->post_reset(adev, instance_id);
-                       if (ret) {
-                               dev_err(adev->dev,
-                               "afterReset callback failed for instance %u: %d\n",
-                                       instance_id, ret);
-                               goto exit;
-                       }
-               }
-       }
+       if (sdma_instance->funcs->start_kernel_queue)
+               sdma_instance->funcs->start_kernel_queue(gfx_ring);
 
 exit:
        /* Restart the scheduler's work queue for the GFX and page rings
--

2.25.1

#5 lore raw

PATCH v5 4/6 drm/amdgpu: optimize queue reset and stop logic

In reply to [email protected]

From: "[email protected]" <[email protected]>

This patch refactors the SDMA v5.x queue reset and stop logic to improve code readability, maintainability, and performance. The key changes include:

1. **Generalized sdma_v5_x_gfx_stop Function**:
- Added an inst_mask parameter to allow stopping specific SDMA instances instead of all instances. This is useful for resetting individual queues.

2. **Simplified sdma_v5_x_reset_queue Function**:
- Removed redundant loops and checks by directly using the ring->me field to identify the SDMA instance.
- Reused the sdma_v5_x_gfx_stop function to stop the queue, reducing code duplication.

v1: The general coding style is to declare variables like "i" or "r" last. E.g. longest lines first and short lasts. (Chritian)

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 31 ++++++++------------------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 27 ++++++++--------------
 2 files changed, 18 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +9 -22
index bef80b318f8e..11dfa0b7544d 100644
@@ -557,15 +557,15 @@ static void sdma_v5_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
  * sdma_v5_0_gfx_stop - stop the gfx async dma engines
  *
  * @adev: amdgpu_device pointer
- *
+ * @inst_mask: mask of dma engine instances to be disabled
  * Stop the gfx async dma ring buffers (NAVI10).
  */
-static void sdma_v5_0_gfx_stop(struct amdgpu_device *adev)
+static void sdma_v5_0_gfx_stop(struct amdgpu_device *adev, uint32_t inst_mask)
 {
 	u32 rb_cntl, ib_cntl;
 	int i;
 
-	for (i = 0; i < adev->sdma.num_instances; i++) {
+	for_each_inst(i, inst_mask) {
 		rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
 		rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
 		WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
@@ -657,9 +657,11 @@ static void sdma_v5_0_enable(struct amdgpu_device *adev, bool enable)
 {
 	u32 f32_cntl;
 	int i;
+	uint32_t inst_mask;
 
+	inst_mask = GENMASK(adev->sdma.num_instances - 1, 0);
 	if (!enable) {
-		sdma_v5_0_gfx_stop(adev);
+		sdma_v5_0_gfx_stop(adev, 1 << inst_mask);
 		sdma_v5_0_rlc_stop(adev);
 	}
 
@@ -1546,33 +1548,18 @@ static int sdma_v5_0_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
 
 static int sdma_v5_0_stop_queue(struct amdgpu_ring *ring)
 {
-	u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, stat1_reg;
+	u32 f32_cntl, freeze, cntl, stat1_reg;
 	struct amdgpu_device *adev = ring->adev;
 	int i, j, r;
 
 	if (amdgpu_sriov_vf(adev))
 		return -EINVAL;
 
-	for (i = 0; i < adev->sdma.num_instances; i++) {
-		if (ring == &adev->sdma.instance[i].ring)
-			break;
-	}
-
-	if (i == adev->sdma.num_instances) {
-		DRM_ERROR("sdma instance not found\n");
-		return -EINVAL;
-	}
-
+	i = ring->me;
 	amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
 
 	/* stop queue */
-	ib_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL));
-	ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 0);
-	WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
-
-	rb_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
-	rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
-	WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
+	sdma_v5_0_gfx_stop(adev, 1 << i);
 
 	/* engine stop SDMA1_F32_CNTL.HALT to 1 and SDMAx_FREEZE freeze bit to 1 */
 	freeze = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_FREEZE));
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +9 -18
index 4cd7010ad0d7..db6630c3f30a 100644
@@ -407,15 +407,15 @@ static void sdma_v5_2_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
  * sdma_v5_2_gfx_stop - stop the gfx async dma engines
  *
  * @adev: amdgpu_device pointer
- *
+ * @inst_mask: mask of dma engine instances to be disabled
  * Stop the gfx async dma ring buffers.
  */
-static void sdma_v5_2_gfx_stop(struct amdgpu_device *adev)
+static void sdma_v5_2_gfx_stop(struct amdgpu_device *adev,  uint32_t inst_mask)
 {
 	u32 rb_cntl, ib_cntl;
 	int i;
 
-	for (i = 0; i < adev->sdma.num_instances; i++) {
+	for_each_inst(i, inst_mask) {
 		rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
 		rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
 		WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
@@ -506,9 +506,11 @@ static void sdma_v5_2_enable(struct amdgpu_device *adev, bool enable)
 {
 	u32 f32_cntl;
 	int i;
+	uint32_t inst_mask;
 
+	inst_mask = GENMASK(adev->sdma.num_instances - 1, 0);
 	if (!enable) {
-		sdma_v5_2_gfx_stop(adev);
+		sdma_v5_2_gfx_stop(adev, inst_mask);
 		sdma_v5_2_rlc_stop(adev);
 	}
 
@@ -1459,29 +1461,18 @@ static int sdma_v5_2_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
 
 static int sdma_v5_2_stop_queue(struct amdgpu_ring *ring)
 {
+	u32 rb_cntl, f32_cntl, freeze, cntl, stat1_reg;
 	struct amdgpu_device *adev = ring->adev;
 	int i, j, r;
-	u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, stat1_reg;
 
 	if (amdgpu_sriov_vf(adev))
 		return -EINVAL;
 
-	for (i = 0; i < adev->sdma.num_instances; i++) {
-		if (ring == &adev->sdma.instance[i].ring)
-			break;
-	}
-
-	if (i == adev->sdma.num_instances) {
-		DRM_ERROR("sdma instance not found\n");
-		return -EINVAL;
-	}
-
+	i = ring->me;
 	amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
 
 	/* stop queue */
-	ib_cntl = RREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL));
-	ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 0);
-	WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
+	sdma_v5_2_gfx_stop(adev, 1 << i);
 
 	rb_cntl = RREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
 	rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
Signature · 1 line
2.25.1
Reviewed-by on v5 4/6
#6 lore raw

Re: [v5 4/6] drm/amdgpu: optimize queue reset and stop logic

Quoted 16 lines · On Fri, Apr 11, 2025 at 4:42 AM [email protected] <[email protected]> wrote:

From: "[email protected]" <[email protected]>

This patch refactors the SDMA v5.x queue reset and stop logic to improve code readability, maintainability, and performance. The key changes include:

1. **Generalized sdma_v5_x_gfx_stop Function**:
- Added an inst_mask parameter to allow stopping specific SDMA instances instead of all instances. This is useful for resetting individual queues.

2. **Simplified sdma_v5_x_reset_queue Function**:
- Removed redundant loops and checks by directly using the ring->me field to identify the SDMA instance.
- Reused the sdma_v5_x_gfx_stop function to stop the queue, reducing code duplication.

Quoted 4 lines

v1: The general coding style is to declare variables like "i" or "r" last. E.g. longest lines first and short lasts. (Chritian)

Might want to split this per IP? Either way:

Quoted 150 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 31 ++++++++------------------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 27 ++++++++--------------
 2 files changed, 18 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +9 -22
index bef80b318f8e..11dfa0b7544d 100644
@@ -557,15 +557,15 @@ static void sdma_v5_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
  * sdma_v5_0_gfx_stop - stop the gfx async dma engines
  *
  * @adev: amdgpu_device pointer
- *
+ * @inst_mask: mask of dma engine instances to be disabled
  * Stop the gfx async dma ring buffers (NAVI10).
  */
-static void sdma_v5_0_gfx_stop(struct amdgpu_device *adev)
+static void sdma_v5_0_gfx_stop(struct amdgpu_device *adev, uint32_t inst_mask)
 {
        u32 rb_cntl, ib_cntl;
        int i;
 
-       for (i = 0; i < adev->sdma.num_instances; i++) {
+       for_each_inst(i, inst_mask) {
                rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
                rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
                WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
@@ -657,9 +657,11 @@ static void sdma_v5_0_enable(struct amdgpu_device *adev, bool enable)
 {
        u32 f32_cntl;
        int i;
+       uint32_t inst_mask;
 
+       inst_mask = GENMASK(adev->sdma.num_instances - 1, 0);
        if (!enable) {
-               sdma_v5_0_gfx_stop(adev);
+               sdma_v5_0_gfx_stop(adev, 1 << inst_mask);
                sdma_v5_0_rlc_stop(adev);
        }
 
@@ -1546,33 +1548,18 @@ static int sdma_v5_0_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
 
 static int sdma_v5_0_stop_queue(struct amdgpu_ring *ring)
 {
-       u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, stat1_reg;
+       u32 f32_cntl, freeze, cntl, stat1_reg;
        struct amdgpu_device *adev = ring->adev;
        int i, j, r;
 
        if (amdgpu_sriov_vf(adev))
                return -EINVAL;
 
-       for (i = 0; i < adev->sdma.num_instances; i++) {
-               if (ring == &adev->sdma.instance[i].ring)
-                       break;
-       }
-
-       if (i == adev->sdma.num_instances) {
-               DRM_ERROR("sdma instance not found\n");
-               return -EINVAL;
-       }
-
+       i = ring->me;
        amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
 
        /* stop queue */
-       ib_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL));
-       ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 0);
-       WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
-
-       rb_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
-       rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
-       WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
+       sdma_v5_0_gfx_stop(adev, 1 << i);
 
        /* engine stop SDMA1_F32_CNTL.HALT to 1 and SDMAx_FREEZE freeze bit to 1 */
        freeze = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_FREEZE));
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +9 -19
index 4cd7010ad0d7..db6630c3f30a 100644
@@ -407,15 +407,15 @@ static void sdma_v5_2_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
  * sdma_v5_2_gfx_stop - stop the gfx async dma engines
  *
  * @adev: amdgpu_device pointer
- *
+ * @inst_mask: mask of dma engine instances to be disabled
  * Stop the gfx async dma ring buffers.
  */
-static void sdma_v5_2_gfx_stop(struct amdgpu_device *adev)
+static void sdma_v5_2_gfx_stop(struct amdgpu_device *adev,  uint32_t inst_mask)
 {
        u32 rb_cntl, ib_cntl;
        int i;
 
-       for (i = 0; i < adev->sdma.num_instances; i++) {
+       for_each_inst(i, inst_mask) {
                rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
                rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
                WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
@@ -506,9 +506,11 @@ static void sdma_v5_2_enable(struct amdgpu_device *adev, bool enable)
 {
        u32 f32_cntl;
        int i;
+       uint32_t inst_mask;
 
+       inst_mask = GENMASK(adev->sdma.num_instances - 1, 0);
        if (!enable) {
-               sdma_v5_2_gfx_stop(adev);
+               sdma_v5_2_gfx_stop(adev, inst_mask);
                sdma_v5_2_rlc_stop(adev);
        }
 
@@ -1459,29 +1461,18 @@ static int sdma_v5_2_reset_queue(struct amdgpu_ring *ring, unsigned int vmid)
 
 static int sdma_v5_2_stop_queue(struct amdgpu_ring *ring)
 {
+       u32 rb_cntl, f32_cntl, freeze, cntl, stat1_reg;
        struct amdgpu_device *adev = ring->adev;
        int i, j, r;
-       u32 rb_cntl, ib_cntl, f32_cntl, freeze, cntl, stat1_reg;
 
        if (amdgpu_sriov_vf(adev))
                return -EINVAL;
 
-       for (i = 0; i < adev->sdma.num_instances; i++) {
-               if (ring == &adev->sdma.instance[i].ring)
-                       break;
-       }
-
-       if (i == adev->sdma.num_instances) {
-               DRM_ERROR("sdma instance not found\n");
-               return -EINVAL;
-       }
-
+       i = ring->me;
        amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
 
        /* stop queue */
-       ib_cntl = RREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL));
-       ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 0);
-       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
+       sdma_v5_2_gfx_stop(adev, 1 << i);
 
        rb_cntl = RREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
        rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
--

2.25.1

#7 lore raw

PATCH v5 5/6 drm/amdgpu: Implement SDMA soft reset directly for v5.x

In reply to [email protected]

From: "[email protected]" <[email protected]>

This patch introduces a new function amdgpu_sdma_soft_reset to handle SDMA soft resets directly, rather than relying on the DPM interface.

1. **New amdgpu_sdma_soft_reset Function**:
- Implements a soft reset for SDMA engines by directly writing to the hardware registers.
- Handles SDMA versions 4.x and 5.x separately:
- For SDMA 4.x, the existing amdgpu_dpm_reset_sdma function is used for backward compatibility.
- For SDMA 5.x, the driver directly manipulates the GRBM_SOFT_RESET register to reset the specified SDMA instance.

2. **Integration into amdgpu_sdma_reset_engine**:
- The amdgpu_sdma_soft_reset function is called during the SDMA reset process, replacing the previous call to amdgpu_dpm_reset_sdma.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 38 +++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +37 -1
index 7139d574c23e..b271a0626886 100644
@@ -26,6 +26,8 @@
 #include "amdgpu_sdma.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_reset.h"
+#include "gc/gc_10_1_0_offset.h"
+#include "gc/gc_10_3_0_sh_mask.h"
 
 #define AMDGPU_CSA_SDMA_SIZE 64
 /* SDMA CSA reside in the 3rd page of CSA */
@@ -554,6 +556,40 @@ void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct
 	list_add_tail(&funcs->list, &adev->sdma.reset_callback_list);
 }
 
+static int amdgpu_sdma_soft_reset(struct amdgpu_device *adev, u32 instance_id)
+{
+	struct amdgpu_sdma_instance *sdma_instance = &adev->sdma.instance[instance_id];
+	int r = 0;
+
+	switch (amdgpu_ip_version(adev, SDMA0_HWIP, 0)) {
+	case IP_VERSION(4, 4, 2):
+	case IP_VERSION(4, 4, 4):
+	case IP_VERSION(4, 4, 5):
+		/* For SDMA 4.x, use the existing DPM interface for backward compatibility */
+		r = amdgpu_dpm_reset_sdma(adev, 1 << instance_id);
+		break;
+	case IP_VERSION(5, 0, 0):
+	case IP_VERSION(5, 0, 1):
+	case IP_VERSION(5, 0, 2):
+	case IP_VERSION(5, 0, 5):
+	case IP_VERSION(5, 2, 0):
+	case IP_VERSION(5, 2, 2):
+	case IP_VERSION(5, 2, 4):
+	case IP_VERSION(5, 2, 5):
+	case IP_VERSION(5, 2, 6):
+	case IP_VERSION(5, 2, 3):
+	case IP_VERSION(5, 2, 1):
+	case IP_VERSION(5, 2, 7):
+		if (sdma_instance->funcs->soft_reset_kernel_queue)
+			r = sdma_instance->funcs->soft_reset_kernel_queue(adev, instance_id);
+		break;
+	default:
+		break;
+	}
+
+	return r;
+}
+
 /**
  * amdgpu_sdma_reset_engine - Reset a specific SDMA engine
  * @adev: Pointer to the AMDGPU device
@@ -588,7 +624,7 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
 		sdma_instance->funcs->stop_kernel_queue(gfx_ring);
 
 	/* Perform the SDMA reset for the specified instance */
-	ret = amdgpu_dpm_reset_sdma(adev, 1 << instance_id);
+	ret = amdgpu_sdma_soft_reset(adev, instance_id);
 	if (ret) {
 		dev_err(adev->dev, "Failed to reset SDMA instance %u\n", instance_id);
 		goto exit;
Signature · 1 line
2.25.1
Reviewed-by on v5 5/6
#8 lore raw

Re: [v5 5/6] drm/amdgpu: Implement SDMA soft reset directly for v5.x

Quoted 35 lines · On Fri, Apr 11, 2025 at 4:57 AM [email protected] <[email protected]> wrote:

From: "[email protected]" <[email protected]>

This patch introduces a new function amdgpu_sdma_soft_reset to handle SDMA soft resets directly, rather than relying on the DPM interface.

1. **New amdgpu_sdma_soft_reset Function**:
- Implements a soft reset for SDMA engines by directly writing to the hardware registers.
- Handles SDMA versions 4.x and 5.x separately:
- For SDMA 4.x, the existing amdgpu_dpm_reset_sdma function is used for backward compatibility.
- For SDMA 5.x, the driver directly manipulates the GRBM_SOFT_RESET register to reset the specified SDMA instance.

2. **Integration into amdgpu_sdma_reset_engine**:
- The amdgpu_sdma_soft_reset function is called during the SDMA reset process, replacing the previous call to amdgpu_dpm_reset_sdma.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 38 +++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +2 -0
index 7139d574c23e..b271a0626886 100644
@@ -26,6 +26,8 @@
 #include "amdgpu_sdma.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_reset.h"
+#include "gc/gc_10_1_0_offset.h"
+#include "gc/gc_10_3_0_sh_mask.h"
 
 #define AMDGPU_CSA_SDMA_SIZE 64
 /* SDMA CSA reside in the 3rd page of CSA */

drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct · line 562

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +4 -0
@@ -554,6 +556,40 @@ void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct
        list_add_tail(&funcs->list, &adev->sdma.reset_callback_list);
 }
 
+static int amdgpu_sdma_soft_reset(struct amdgpu_device *adev, u32 instance_id)
+{
+       struct amdgpu_sdma_instance *sdma_instance = &adev->sdma.instance[instance_id];
+       int r = 0;

r should default to an error, otherwise, we'll report success if nothing happens. with that fixed:

Quoted 45 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +31 -2
+
+       switch (amdgpu_ip_version(adev, SDMA0_HWIP, 0)) {
+       case IP_VERSION(4, 4, 2):
+       case IP_VERSION(4, 4, 4):
+       case IP_VERSION(4, 4, 5):
+               /* For SDMA 4.x, use the existing DPM interface for backward compatibility */
+               r = amdgpu_dpm_reset_sdma(adev, 1 << instance_id);
+               break;
+       case IP_VERSION(5, 0, 0):
+       case IP_VERSION(5, 0, 1):
+       case IP_VERSION(5, 0, 2):
+       case IP_VERSION(5, 0, 5):
+       case IP_VERSION(5, 2, 0):
+       case IP_VERSION(5, 2, 2):
+       case IP_VERSION(5, 2, 4):
+       case IP_VERSION(5, 2, 5):
+       case IP_VERSION(5, 2, 6):
+       case IP_VERSION(5, 2, 3):
+       case IP_VERSION(5, 2, 1):
+       case IP_VERSION(5, 2, 7):
+               if (sdma_instance->funcs->soft_reset_kernel_queue)
+                       r = sdma_instance->funcs->soft_reset_kernel_queue(adev, instance_id);
+               break;
+       default:
+               break;
+       }
+
+       return r;
+}
+
 /**
  * amdgpu_sdma_reset_engine - Reset a specific SDMA engine
  * @adev: Pointer to the AMDGPU device
@@ -588,7 +624,7 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id)
                sdma_instance->funcs->stop_kernel_queue(gfx_ring);
 
        /* Perform the SDMA reset for the specified instance */
-       ret = amdgpu_dpm_reset_sdma(adev, 1 << instance_id);
+       ret = amdgpu_sdma_soft_reset(adev, instance_id);
        if (ret) {
                dev_err(adev->dev, "Failed to reset SDMA instance %u\n", instance_id);
                goto exit;
--

2.25.1

#9 lore raw

PATCH v5 6/6 drm/amdgpu:remove old sdma reset callback mechanism

In reply to [email protected]

From: "[email protected]" <[email protected]>

This patch removes the deprecated SDMA reset callback mechanism, which was previously used to register pre-reset and post-reset callbacks for SDMA engine resets.
The callback mechanism has been replaced with a more direct and efficient approach using stop_queue and start_queue functions in the ring's function table.

The SDMA reset callback mechanism allowed KFD and AMDGPU to register pre-reset and post-reset functions for handling SDMA engine resets.
However, this approach added unnecessary complexity and was no longer needed after the introduction of the stop_queue and start_queue functions in the ring's function table.

1. **Remove Callback Mechanism**:
- Removed the amdgpu_sdma_register_on_reset_callbacks function and its associated data structures (sdma_on_reset_funcs).
- Removed the callback registration logic from the SDMA v4.4.2 initialization code.

2. **Clean Up Related Code**:
- Removed the sdma_v4_4_2_set_engine_reset_funcs function, which was used to register the callbacks.
- Removed the sdma_v4_4_2_engine_reset_funcs structure, which contained the pre-reset and post-reset callback functions.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 25 ------------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h |  8 --------
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 10 ----------
 3 files changed, 43 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +0 -25
index b271a0626886..ac6d811f4824 100644
@@ -531,31 +531,6 @@ bool amdgpu_sdma_is_shared_inv_eng(struct amdgpu_device *adev, struct amdgpu_rin
 		return false;
 }
 
-/**
- * amdgpu_sdma_register_on_reset_callbacks - Register SDMA reset callbacks
- * @adev: Pointer to the AMDGPU device
- * @funcs: Pointer to the callback structure containing pre_reset and post_reset functions
- *
- * This function allows KFD and AMDGPU to register their own callbacks for handling
- * pre-reset and post-reset operations for engine reset. These are needed because engine
- * reset will stop all queues on that engine.
- */
-void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct sdma_on_reset_funcs *funcs)
-{
-	if (!funcs)
-		return;
-
-	/* Ensure the reset_callback_list is initialized */
-	if (!adev->sdma.reset_callback_list.next) {
-		INIT_LIST_HEAD(&adev->sdma.reset_callback_list);
-	}
-	/* Initialize the list node in the callback structure */
-	INIT_LIST_HEAD(&funcs->list);
-
-	/* Add the callback structure to the global list */
-	list_add_tail(&funcs->list, &adev->sdma.reset_callback_list);
-}
-
 static int amdgpu_sdma_soft_reset(struct amdgpu_device *adev, u32 instance_id)
 {
 	struct amdgpu_sdma_instance *sdma_instance = &adev->sdma.instance[instance_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +0 -8
index a6c8f07a0da4..41cf29531652 100644
@@ -109,13 +109,6 @@ struct amdgpu_sdma_ras {
 	struct amdgpu_ras_block_object ras_block;
 };
 
-struct sdma_on_reset_funcs {
-	int (*pre_reset)(struct amdgpu_device *adev, uint32_t instance_id);
-	int (*post_reset)(struct amdgpu_device *adev, uint32_t instance_id);
-	/* Linked list node to store this structure in a list; */
-	struct list_head list;
-};
-
 struct amdgpu_sdma {
 	struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES];
 	struct amdgpu_irq_src	trap_irq;
@@ -177,7 +170,6 @@ struct amdgpu_buffer_funcs {
 				 uint32_t byte_count);
 };
 
-void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct sdma_on_reset_funcs *funcs);
 int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id);
 
 #define amdgpu_emit_copy_buffer(adev, ib, s, d, b, t) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b), (t))
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -10
index c663c63485f4..e343aaaea12d 100644
@@ -106,7 +106,6 @@ static void sdma_v4_4_2_set_buffer_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_vm_pte_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_irq_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_ras_funcs(struct amdgpu_device *adev);
-static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_update_reset_mask(struct amdgpu_device *adev);
 static int sdma_v4_4_2_stop_queue(struct amdgpu_ring *ring);
 static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring);
@@ -1358,7 +1357,6 @@ static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)
 	sdma_v4_4_2_set_vm_pte_funcs(adev);
 	sdma_v4_4_2_set_irq_funcs(adev);
 	sdma_v4_4_2_set_ras_funcs(adev);
-	sdma_v4_4_2_set_engine_reset_funcs(adev);
 	return 0;
 }
 
@@ -1747,14 +1745,6 @@ static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring)
 	return sdma_v4_4_2_inst_start(adev, inst_mask, true);
 }
 
-static struct sdma_on_reset_funcs sdma_v4_4_2_engine_reset_funcs = {
-};
-
-static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev)
-{
-	amdgpu_sdma_register_on_reset_callbacks(adev, &sdma_v4_4_2_engine_reset_funcs);
-}
-
 static int sdma_v4_4_2_set_trap_irq_state(struct amdgpu_device *adev,
 					struct amdgpu_irq_src *source,
 					unsigned type,
Signature · 1 line
2.25.1
Reviewed-by on v5 6/6
#10 lore raw

Re: [v5 6/6] drm/amdgpu:remove old sdma reset callback mechanism

Quoted 13 lines · On Fri, Apr 11, 2025 at 4:30 AM [email protected] <[email protected]> wrote:

From: "[email protected]" <[email protected]>

This patch removes the deprecated SDMA reset callback mechanism, which was previously used to register pre-reset and post-reset callbacks for SDMA engine resets.
The callback mechanism has been replaced with a more direct and efficient approach using stop_queue and start_queue functions in the ring's function table.

The SDMA reset callback mechanism allowed KFD and AMDGPU to register pre-reset and post-reset functions for handling SDMA engine resets.
However, this approach added unnecessary complexity and was no longer needed after the introduction of the stop_queue and start_queue functions in the ring's function table.

1. **Remove Callback Mechanism**:
- Removed the amdgpu_sdma_register_on_reset_callbacks function and its associated data structures (sdma_on_reset_funcs).
- Removed the callback registration logic from the SDMA v4.4.2 initialization code.

Quoted 6 lines

2. **Clean Up Related Code**:
- Removed the sdma_v4_4_2_set_engine_reset_funcs function, which was used to register the callbacks.
- Removed the sdma_v4_4_2_engine_reset_funcs structure, which contained the pre-reset and post-reset callback functions.

Quoted 106 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 25 ------------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h |  8 --------
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 10 ----------
 3 files changed, 43 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +0 -25
index b271a0626886..ac6d811f4824 100644
@@ -531,31 +531,6 @@ bool amdgpu_sdma_is_shared_inv_eng(struct amdgpu_device *adev, struct amdgpu_rin
                return false;
 }
 
-/**
- * amdgpu_sdma_register_on_reset_callbacks - Register SDMA reset callbacks
- * @adev: Pointer to the AMDGPU device
- * @funcs: Pointer to the callback structure containing pre_reset and post_reset functions
- *
- * This function allows KFD and AMDGPU to register their own callbacks for handling
- * pre-reset and post-reset operations for engine reset. These are needed because engine
- * reset will stop all queues on that engine.
- */
-void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct sdma_on_reset_funcs *funcs)
-{
-       if (!funcs)
-               return;
-
-       /* Ensure the reset_callback_list is initialized */
-       if (!adev->sdma.reset_callback_list.next) {
-               INIT_LIST_HEAD(&adev->sdma.reset_callback_list);
-       }
-       /* Initialize the list node in the callback structure */
-       INIT_LIST_HEAD(&funcs->list);
-
-       /* Add the callback structure to the global list */
-       list_add_tail(&funcs->list, &adev->sdma.reset_callback_list);
-}
-
 static int amdgpu_sdma_soft_reset(struct amdgpu_device *adev, u32 instance_id)
 {
        struct amdgpu_sdma_instance *sdma_instance = &adev->sdma.instance[instance_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +0 -8
index a6c8f07a0da4..41cf29531652 100644
@@ -109,13 +109,6 @@ struct amdgpu_sdma_ras {
        struct amdgpu_ras_block_object ras_block;
 };
 
-struct sdma_on_reset_funcs {
-       int (*pre_reset)(struct amdgpu_device *adev, uint32_t instance_id);
-       int (*post_reset)(struct amdgpu_device *adev, uint32_t instance_id);
-       /* Linked list node to store this structure in a list; */
-       struct list_head list;
-};
-
 struct amdgpu_sdma {
        struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES];
        struct amdgpu_irq_src   trap_irq;
@@ -177,7 +170,6 @@ struct amdgpu_buffer_funcs {
                                 uint32_t byte_count);
 };
 
-void amdgpu_sdma_register_on_reset_callbacks(struct amdgpu_device *adev, struct sdma_on_reset_funcs *funcs);
 int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id);
 
 #define amdgpu_emit_copy_buffer(adev, ib, s, d, b, t) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b), (t))
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -11
index c663c63485f4..e343aaaea12d 100644
@@ -106,7 +106,6 @@ static void sdma_v4_4_2_set_buffer_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_vm_pte_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_irq_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_set_ras_funcs(struct amdgpu_device *adev);
-static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev);
 static void sdma_v4_4_2_update_reset_mask(struct amdgpu_device *adev);
 static int sdma_v4_4_2_stop_queue(struct amdgpu_ring *ring);
 static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring);
@@ -1358,7 +1357,6 @@ static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)
        sdma_v4_4_2_set_vm_pte_funcs(adev);
        sdma_v4_4_2_set_irq_funcs(adev);
        sdma_v4_4_2_set_ras_funcs(adev);
-       sdma_v4_4_2_set_engine_reset_funcs(adev);
        return 0;
 }
 
@@ -1747,14 +1745,6 @@ static int sdma_v4_4_2_restore_queue(struct amdgpu_ring *ring)
        return sdma_v4_4_2_inst_start(adev, inst_mask, true);
 }
 
-static struct sdma_on_reset_funcs sdma_v4_4_2_engine_reset_funcs = {
-};
-
-static void sdma_v4_4_2_set_engine_reset_funcs(struct amdgpu_device *adev)
-{
-       amdgpu_sdma_register_on_reset_callbacks(adev, &sdma_v4_4_2_engine_reset_funcs);
-}
-
 static int sdma_v4_4_2_set_trap_irq_state(struct amdgpu_device *adev,
                                        struct amdgpu_irq_src *source,
                                        unsigned type,
--

2.25.1

Reviewed-by on v5 1/6
#11 lore raw
In reply to [email protected]
Quoted 12 lines · On Fri, Apr 11, 2025 at 4:29 AM [email protected] <[email protected]> wrote:

From: "[email protected]" <[email protected]>

This patch introduces new function pointers in the amdgpu_sdma structure to handle queue stop, start and soft reset operations. These will replace the older callback mechanism.

The new functions are:
- stop_kernel_queue: Stops a specific SDMA queue
- start_kernel_queue: Starts/Restores a specific SDMA queue
- soft_reset_kernel_queue: Performs soft reset on a specific SDMA queue

Quoted 6 lines

v2: Update stop_queue/start_queue function paramters to use ring pointer instead of device/instance(Chritian)
v3: move stop_queue/start_queue to struct amdgpu_sdma_instance and rename them. (Alex)
v4: rework the ordering a bit (Alex)

Quoted 33 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +7 -2
index 0b1fbcf0b4d0..a6c8f07a0da4 100644
@@ -50,6 +50,12 @@ enum amdgpu_sdma_irq {
 
 #define NUM_SDMA(x) hweight32(x)
 
+struct amdgpu_sdma_funcs {
+       int (*stop_kernel_queue)(struct amdgpu_ring *ring);
+       int (*start_kernel_queue)(struct amdgpu_ring *ring);
+       int (*soft_reset_kernel_queue)(struct amdgpu_device *adev, u32 instance_id);
+};
+
 struct amdgpu_sdma_instance {
        /* SDMA firmware */
        const struct firmware   *fw;
@@ -68,7 +74,7 @@ struct amdgpu_sdma_instance {
        /* track guilty state of GFX and PAGE queues */
        bool                    gfx_guilty;
        bool                    page_guilty;
-
+       const struct amdgpu_sdma_funcs   *funcs;
 };
 
 enum amdgpu_sdma_ras_memory_id {
--

2.25.1