]> git.hungrycats.org Git - linux/commitdiff
drm/amdgpu: Use a common KGQ and KCQ reset helper for gfx11/12
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 19 May 2026 20:32:59 +0000 (16:32 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 17 Jun 2026 19:51:35 +0000 (15:51 -0400)
They are all the same so use a common implementation.

Reviewed-by: Jesse Zhang <jesse.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c

index d88e346b65ee869a935920a8f7f5887e1e53e909..529f615289488f7833947b6d0d31c3e568dcc8da 100644 (file)
@@ -377,7 +377,7 @@ int amdgpu_gfx_kiq_init(struct amdgpu_device *adev,
        return 0;
 }
 
-void amdgpu_gfx_mqd_reset_restore(struct amdgpu_ring *ring)
+static void amdgpu_gfx_mqd_reset_restore(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
        int mqd_idx, mqd_size;
@@ -1988,6 +1988,37 @@ static ssize_t amdgpu_gfx_get_compute_reset_mask(struct device *dev,
        return amdgpu_show_reset_mask(buf, adev->gfx.compute_supported_reset);
 }
 
+int amdgpu_gfx_mes_reset_queue(struct amdgpu_ring *ring,
+                              unsigned int vmid,
+                              struct amdgpu_fence *timedout_fence,
+                              bool use_mmio)
+{
+       struct amdgpu_device *adev = ring->adev;
+       int r;
+
+       amdgpu_ring_reset_helper_begin(ring, timedout_fence);
+
+       r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, use_mmio, 0);
+       if (r)
+               return r;
+
+       if (use_mmio) {
+               r = amdgpu_mes_unmap_legacy_queue(adev, ring,
+                                                 RESET_QUEUES, 0, 0, 0);
+               if (r)
+                       return r;
+               amdgpu_gfx_mqd_reset_restore(ring);
+
+               r = amdgpu_mes_map_legacy_queue(adev, ring, 0);
+               if (r) {
+                       dev_err(adev->dev, "failed to remap kgq\n");
+                       return r;
+               }
+       }
+
+       return amdgpu_ring_reset_helper_end(ring, timedout_fence);
+}
+
 static DEVICE_ATTR(run_cleaner_shader, 0200,
                   NULL, amdgpu_gfx_set_run_cleaner_shader);
 
index 60679615c317d45ba153118db67b890869ac23ef..59fae26ef0506e2ba42998fbf8dee25790472d10 100644 (file)
@@ -588,7 +588,6 @@ void amdgpu_gfx_kiq_fini(struct amdgpu_device *adev, int xcc_id);
 int amdgpu_gfx_kiq_init(struct amdgpu_device *adev,
                        unsigned hpd_size, int xcc_id);
 
-void amdgpu_gfx_mqd_reset_restore(struct amdgpu_ring *ring);
 int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,
                           unsigned mqd_size, int xcc_id);
 void amdgpu_gfx_mqd_sw_fini(struct amdgpu_device *adev, int xcc_id);
@@ -670,6 +669,11 @@ void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev);
 
 int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring);
 
+int amdgpu_gfx_mes_reset_queue(struct amdgpu_ring *ring,
+                              unsigned int vmid,
+                              struct amdgpu_fence *timedout_fence,
+                              bool use_mmio);
+
 static inline const char *amdgpu_gfx_compute_mode_desc(int mode)
 {
        switch (mode) {
index 0751199b8e4291856b4373a676addb2f156d6827..1701a4acbde1c03fba0e044ea56e7dca1c67e66c 100644 (file)
@@ -6823,29 +6823,8 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,
 {
        struct amdgpu_device *adev = ring->adev;
        bool use_mmio = adev->gfx.me.use_mmio_for_reset;
-       int r;
-
-       amdgpu_ring_reset_helper_begin(ring, timedout_fence);
-
-       r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, use_mmio, 0);
-       if (r)
-               return r;
-
-       if (use_mmio) {
-               r = amdgpu_mes_unmap_legacy_queue(adev, ring,
-                                                 RESET_QUEUES, 0, 0, 0);
-               if (r)
-                       return r;
-               amdgpu_gfx_mqd_reset_restore(ring);
-
-               r = amdgpu_mes_map_legacy_queue(adev, ring, 0);
-               if (r) {
-                       dev_err(adev->dev, "failed to remap kgq\n");
-                       return r;
-               }
-       }
 
-       return amdgpu_ring_reset_helper_end(ring, timedout_fence);
+       return amdgpu_gfx_mes_reset_queue(ring, vmid, timedout_fence, use_mmio);
 }
 
 static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring,
@@ -6854,29 +6833,8 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring,
 {
        struct amdgpu_device *adev = ring->adev;
        bool use_mmio = adev->gfx.mec.use_mmio_for_reset;
-       int r = 0;
-
-       amdgpu_ring_reset_helper_begin(ring, timedout_fence);
-
-       r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, use_mmio, 0);
-       if (r)
-               return r;
-
-       if (use_mmio) {
-               r = amdgpu_mes_unmap_legacy_queue(adev, ring,
-                                                 RESET_QUEUES, 0, 0, 0);
-               if (r)
-                       return r;
-               amdgpu_gfx_mqd_reset_restore(ring);
-
-               r = amdgpu_mes_map_legacy_queue(adev, ring, 0);
-               if (r) {
-                       dev_err(adev->dev, "failed to remap kcq\n");
-                       return r;
-               }
-       }
 
-       return amdgpu_ring_reset_helper_end(ring, timedout_fence);
+       return amdgpu_gfx_mes_reset_queue(ring, vmid, timedout_fence, use_mmio);
 }
 
 static void gfx_v11_ip_print(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
index 14ce595a5df943f887827d3636e1d3ac9d5316fb..5c846fcd3f83677db888cc55f7a49f043243d382 100644 (file)
@@ -5249,29 +5249,8 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring,
 {
        struct amdgpu_device *adev = ring->adev;
        bool use_mmio = adev->gfx.me.use_mmio_for_reset;
-       int r;
-
-       amdgpu_ring_reset_helper_begin(ring, timedout_fence);
-
-       r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, use_mmio, 0);
-       if (r)
-               return r;
-
-       if (use_mmio) {
-               r = amdgpu_mes_unmap_legacy_queue(adev, ring,
-                                                 RESET_QUEUES, 0, 0, 0);
-               if (r)
-                       return r;
-               amdgpu_gfx_mqd_reset_restore(ring);
-
-               r = amdgpu_mes_map_legacy_queue(adev, ring, 0);
-               if (r) {
-                       dev_err(adev->dev, "failed to remap kgq\n");
-                       return r;
-               }
-       }
 
-       return amdgpu_ring_reset_helper_end(ring, timedout_fence);
+       return amdgpu_gfx_mes_reset_queue(ring, vmid, timedout_fence, use_mmio);
 }
 
 static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring,
@@ -5280,29 +5259,8 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring,
 {
        struct amdgpu_device *adev = ring->adev;
        bool use_mmio = adev->gfx.mec.use_mmio_for_reset;
-       int r;
-
-       amdgpu_ring_reset_helper_begin(ring, timedout_fence);
-
-       r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, use_mmio, 0);
-       if (r)
-               return r;
-
-       if (use_mmio) {
-               r = amdgpu_mes_unmap_legacy_queue(adev, ring,
-                                                 RESET_QUEUES, 0, 0, 0);
-               if (r)
-                       return r;
-               amdgpu_gfx_mqd_reset_restore(ring);
-
-               r = amdgpu_mes_map_legacy_queue(adev, ring, 0);
-               if (r) {
-                       dev_err(adev->dev, "failed to remap kcq\n");
-                       return r;
-               }
-       }
 
-       return amdgpu_ring_reset_helper_end(ring, timedout_fence);
+       return amdgpu_gfx_mes_reset_queue(ring, vmid, timedout_fence, use_mmio);
 }
 
 static void gfx_v12_0_ring_begin_use(struct amdgpu_ring *ring)