drm/amdgpu: add common sdma_ras_fini function
authorTao Zhou <tao.zhou1@amd.com>
Thu, 12 Sep 2019 10:19:02 +0000 (18:19 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 3 Oct 2019 14:11:02 +0000 (09:11 -0500)
sdma_ras_fini can be shared among all generations of sdma

Signed-off-by: Tao Zhou <tao.zhou1@amd.com>
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c

index b83b0b7d0391ed5913e71c204c699f6bb5815384..6010999d90208321378e660c35ce5ab6b9c7af13 100644 (file)
@@ -136,6 +136,25 @@ free:
        return r;
 }
 
+void amdgpu_sdma_ras_fini(struct amdgpu_device *adev)
+{
+       if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__SDMA) &&
+                       adev->sdma.ras_if) {
+               struct ras_common_if *ras_if = adev->sdma.ras_if;
+               struct ras_ih_if ih_info = {
+                       .head = *ras_if,
+                       /* the cb member will not be used by
+                        * amdgpu_ras_interrupt_remove_handler, init it only
+                        * to cheat the check in ras_late_fini
+                        */
+                       .cb = amdgpu_sdma_process_ras_data_cb,
+               };
+
+               amdgpu_ras_late_fini(adev, ras_if, &ih_info);
+               kfree(ras_if);
+       }
+}
+
 int amdgpu_sdma_process_ras_data_cb(struct amdgpu_device *adev,
                void *err_data,
                struct amdgpu_iv_entry *entry)
index 95e01d5225370dd719a31753b8eb23a164a814c6..761ff8be63147559621219d13a4d25ba30a70024 100644 (file)
@@ -106,6 +106,7 @@ int amdgpu_sdma_get_index_from_ring(struct amdgpu_ring *ring, uint32_t *index);
 uint64_t amdgpu_sdma_get_csa_mc_addr(struct amdgpu_ring *ring, unsigned vmid);
 int amdgpu_sdma_ras_late_init(struct amdgpu_device *adev,
                              void *ras_ih_info);
+void amdgpu_sdma_ras_fini(struct amdgpu_device *adev);
 int amdgpu_sdma_process_ras_data_cb(struct amdgpu_device *adev,
                void *err_data,
                struct amdgpu_iv_entry *entry);
index 4db4e329e74b76052ac09bed7c3a0d2629308a6d..98fd1e5484d080c9b3f3ab97eb774a37a3f6bbeb 100644 (file)
@@ -1772,21 +1772,7 @@ static int sdma_v4_0_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
        int i;
 
-       if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__SDMA) &&
-                       adev->sdma.ras_if) {
-               struct ras_common_if *ras_if = adev->sdma.ras_if;
-               struct ras_ih_if ih_info = {
-                       .head = *ras_if,
-               };
-
-               /*remove fs first*/
-               amdgpu_ras_debugfs_remove(adev, ras_if);
-               amdgpu_ras_sysfs_remove(adev, ras_if);
-               /*remove the IH*/
-               amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
-               amdgpu_ras_feature_enable(adev, ras_if, 0);
-               kfree(ras_if);
-       }
+       amdgpu_sdma_ras_fini(adev);
 
        for (i = 0; i < adev->sdma.num_instances; i++) {
                amdgpu_ring_fini(&adev->sdma.instance[i].ring);