drm/amdgpu/ring: move debugfs init into core amdgpu debugfs
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 25 Feb 2020 16:20:18 +0000 (11:20 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 26 Feb 2020 19:21:12 +0000 (14:21 -0500)
In order to remove the load and unload drm callbacks,
we need to reorder the init sequence to move all the drm
debugfs file handling.  Do this for rings.

Tested-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h

index 6dbc312d946533934e5eea5f1cf3c0f908ffe23c..02077b1ae3fe3ef52ce1b868024886fb6725708f 100644 (file)
@@ -1273,7 +1273,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
 
 int amdgpu_debugfs_init(struct amdgpu_device *adev)
 {
-       int r;
+       int r, i;
 
        adev->debugfs_preempt =
                debugfs_create_file("amdgpu_preempt_ib", 0600,
@@ -1316,12 +1316,33 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
        if (r)
                DRM_ERROR("registering firmware debugfs failed (%d).\n", r);
 
+       for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+               struct amdgpu_ring *ring = adev->rings[i];
+
+               if (!ring)
+                       continue;
+
+               if (amdgpu_debugfs_ring_init(adev, ring)) {
+                       DRM_ERROR("Failed to register debugfs file for rings !\n");
+               }
+       }
+
        return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_list,
                                        ARRAY_SIZE(amdgpu_debugfs_list));
 }
 
 void amdgpu_debugfs_fini(struct amdgpu_device *adev)
 {
+       int i;
+
+       for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+               struct amdgpu_ring *ring = adev->rings[i];
+
+               if (!ring)
+                       continue;
+
+               amdgpu_debugfs_ring_fini(ring);
+       }
        amdgpu_ttm_debugfs_fini(adev);
        debugfs_remove(adev->debugfs_preempt);
 }
index 6f20b5365f7652d1738a95c1ce72ccda86fb6118..18e11b0fdc3ef561f195ae3fe8c9c31e838f405f 100644 (file)
@@ -48,9 +48,6 @@
  * wptr.  The GPU then starts fetching commands and executes
  * them until the pointers are equal again.
  */
-static int amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
-                                   struct amdgpu_ring *ring);
-static void amdgpu_debugfs_ring_fini(struct amdgpu_ring *ring);
 
 /**
  * amdgpu_ring_alloc - allocate space on the ring buffer
@@ -334,10 +331,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
        for (i = 0; i < DRM_SCHED_PRIORITY_MAX; ++i)
                atomic_set(&ring->num_jobs[i], 0);
 
-       if (amdgpu_debugfs_ring_init(adev, ring)) {
-               DRM_ERROR("Failed to register debugfs file for rings !\n");
-       }
-
        return 0;
 }
 
@@ -368,8 +361,6 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)
                              &ring->gpu_addr,
                              (void **)&ring->ring);
 
-       amdgpu_debugfs_ring_fini(ring);
-
        dma_fence_put(ring->vmid_wait);
        ring->vmid_wait = NULL;
        ring->me = 0;
@@ -486,8 +477,8 @@ static const struct file_operations amdgpu_debugfs_ring_fops = {
 
 #endif
 
-static int amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
-                                   struct amdgpu_ring *ring)
+int amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
+                            struct amdgpu_ring *ring)
 {
 #if defined(CONFIG_DEBUG_FS)
        struct drm_minor *minor = adev->ddev->primary;
@@ -508,7 +499,7 @@ static int amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
        return 0;
 }
 
-static void amdgpu_debugfs_ring_fini(struct amdgpu_ring *ring)
+void amdgpu_debugfs_ring_fini(struct amdgpu_ring *ring)
 {
 #if defined(CONFIG_DEBUG_FS)
        debugfs_remove(ring->ent);
index 930316e601554003a42ae3a2fb83473a205379e3..24caff085d0046e5e9456b85c8333ab0b002d7e6 100644 (file)
@@ -328,4 +328,8 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring,
 
 int amdgpu_ring_test_helper(struct amdgpu_ring *ring);
 
+int amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
+                            struct amdgpu_ring *ring);
+void amdgpu_debugfs_ring_fini(struct amdgpu_ring *ring);
+
 #endif