drm/radeon: move ring debugfs into radeon_ring.c
authorChristian König <deathsimple@vodafone.de>
Mon, 24 Oct 2011 15:08:44 +0000 (17:08 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 20 Dec 2011 19:51:04 +0000 (19:51 +0000)
Those debugfs files aren't r600 specific, so they
shouldn't be in r600.c. Move them to radeon_ring.c
and also add functionality to dump CP1 & CP2 ring
informations.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/radeon_ring.c

index d26e7c9f047cd54955b28097b7cd8ec6d903069b..17538926cc478feebd263864b683e8704bb415ad 100644 (file)
@@ -3513,31 +3513,6 @@ restart_ih:
  */
 #if defined(CONFIG_DEBUG_FS)
 
-static int r600_debugfs_cp_ring_info(struct seq_file *m, void *data)
-{
-       struct drm_info_node *node = (struct drm_info_node *) m->private;
-       struct drm_device *dev = node->minor->dev;
-       struct radeon_device *rdev = dev->dev_private;
-       struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
-       unsigned count, i, j;
-
-       radeon_ring_free_size(rdev, ring);
-       count = (ring->ring_size / 4) - ring->ring_free_dw;
-       seq_printf(m, "CP_STAT 0x%08x\n", RREG32(CP_STAT));
-       seq_printf(m, "CP_RB_WPTR 0x%08x\n", RREG32(CP_RB_WPTR));
-       seq_printf(m, "CP_RB_RPTR 0x%08x\n", RREG32(CP_RB_RPTR));
-       seq_printf(m, "driver's copy of the CP_RB_WPTR 0x%08x\n", ring->wptr);
-       seq_printf(m, "driver's copy of the CP_RB_RPTR 0x%08x\n", ring->rptr);
-       seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
-       seq_printf(m, "%u dwords in ring\n", count);
-       i = ring->rptr;
-       for (j = 0; j <= count; j++) {
-               seq_printf(m, "r[%04d]=0x%08x\n", i, ring->ring[i]);
-               i = (i + 1) & ring->ptr_mask;
-       }
-       return 0;
-}
-
 static int r600_debugfs_mc_info(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -3551,7 +3526,6 @@ static int r600_debugfs_mc_info(struct seq_file *m, void *data)
 
 static struct drm_info_list r600_mc_info_list[] = {
        {"r600_mc_info", r600_debugfs_mc_info, 0, NULL},
-       {"r600_ring_info", r600_debugfs_cp_ring_info, 0, NULL},
 };
 #endif
 
index 52dd22f2596ece295a684181b48f7a9d6213c114..b39a1d9306e5be59666eda5e7c715429201f3024 100644 (file)
@@ -34,6 +34,7 @@
 #include "atom.h"
 
 int radeon_debugfs_ib_init(struct radeon_device *rdev);
+int radeon_debugfs_ring_init(struct radeon_device *rdev);
 
 u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
 {
@@ -252,6 +253,9 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
        if (radeon_debugfs_ib_init(rdev)) {
                DRM_ERROR("Failed to register debugfs file for IB !\n");
        }
+       if (radeon_debugfs_ring_init(rdev)) {
+               DRM_ERROR("Failed to register debugfs file for rings !\n");
+       }
        return r;
 }
 
@@ -444,6 +448,42 @@ void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *ring)
  * Debugfs info
  */
 #if defined(CONFIG_DEBUG_FS)
+
+static int radeon_debugfs_ring_info(struct seq_file *m, void *data)
+{
+       struct drm_info_node *node = (struct drm_info_node *) m->private;
+       struct drm_device *dev = node->minor->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       int ridx = *(int*)node->info_ent->data;
+       struct radeon_ring *ring = &rdev->ring[ridx];
+       unsigned count, i, j;
+
+       radeon_ring_free_size(rdev, ring);
+       count = (ring->ring_size / 4) - ring->ring_free_dw;
+       seq_printf(m, "wptr(0x%04x): 0x%08x\n", ring->wptr_reg, RREG32(ring->wptr_reg));
+       seq_printf(m, "rptr(0x%04x): 0x%08x\n", ring->rptr_reg, RREG32(ring->rptr_reg));
+       seq_printf(m, "driver's copy of the wptr: 0x%08x\n", ring->wptr);
+       seq_printf(m, "driver's copy of the rptr: 0x%08x\n", ring->rptr);
+       seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
+       seq_printf(m, "%u dwords in ring\n", count);
+       i = ring->rptr;
+       for (j = 0; j <= count; j++) {
+               seq_printf(m, "r[%04d]=0x%08x\n", i, ring->ring[i]);
+               i = (i + 1) & ring->ptr_mask;
+       }
+       return 0;
+}
+
+static int radeon_ring_type_gfx_index = RADEON_RING_TYPE_GFX_INDEX;
+static int cayman_ring_type_cp1_index = CAYMAN_RING_TYPE_CP1_INDEX;
+static int cayman_ring_type_cp2_index = CAYMAN_RING_TYPE_CP2_INDEX;
+
+static struct drm_info_list radeon_debugfs_ring_info_list[] = {
+       {"radeon_ring_gfx", radeon_debugfs_ring_info, 0, &radeon_ring_type_gfx_index},
+       {"radeon_ring_cp1", radeon_debugfs_ring_info, 0, &cayman_ring_type_cp1_index},
+       {"radeon_ring_cp2", radeon_debugfs_ring_info, 0, &cayman_ring_type_cp2_index},
+};
+
 static int radeon_debugfs_ib_info(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -495,6 +535,16 @@ static struct drm_info_list radeon_debugfs_ib_bogus_info_list[] = {
 };
 #endif
 
+int radeon_debugfs_ring_init(struct radeon_device *rdev)
+{
+#if defined(CONFIG_DEBUG_FS)
+       return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list,
+                                       ARRAY_SIZE(radeon_debugfs_ring_info_list));
+#else
+       return 0;
+#endif
+}
+
 int radeon_debugfs_ib_init(struct radeon_device *rdev)
 {
 #if defined(CONFIG_DEBUG_FS)