Re: [PATCH 1/4] drm/amd/amdgpu: Fold TTM debugfs entries into array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 18.09.2017 um 15:01 schrieb Tom St Denis:
On 18/09/17 08:48 AM, Christian König wrote:
Am 18.09.2017 um 14:35 schrieb Tom St Denis:
Signed-off-by: Tom St Denis <tom.stdenis@xxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 53 ++++++++++++++++++---------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +--
  2 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 8ee16dfdb8af..7848ffa99eb4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1809,6 +1809,18 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
  #endif
+
+
+static const struct {
+    char *name;
+    const struct file_operations *fops;
+} ttm_debugfs_entries[] = {
+    { "amdgpu_vram", &amdgpu_ttm_vram_fops },
+#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
+    { "amdgpu_gtt", &amdgpu_ttm_gtt_fops },
+#endif
+};
+
  #endif
  static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
@@ -1819,22 +1831,21 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
      struct drm_minor *minor = adev->ddev->primary;
      struct dentry *ent, *root = minor->debugfs_root;
-    ent = debugfs_create_file("amdgpu_vram", S_IFREG | S_IRUGO, root,
-                  adev, &amdgpu_ttm_vram_fops);
-    if (IS_ERR(ent))
-        return PTR_ERR(ent);
-    i_size_write(ent->d_inode, adev->mc.mc_vram_size);
-    adev->mman.vram = ent;
-
-#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
-    ent = debugfs_create_file("amdgpu_gtt", S_IFREG | S_IRUGO, root,
-                  adev, &amdgpu_ttm_gtt_fops);
-    if (IS_ERR(ent))
-        return PTR_ERR(ent);
-    i_size_write(ent->d_inode, adev->mc.gart_size);
-    adev->mman.gtt = ent;
+ for (count = 0; count < ARRAY_SIZE(ttm_debugfs_entries); count++) {
+        ent = debugfs_create_file(
+                ttm_debugfs_entries[count].name,
+                S_IFREG | S_IRUGO, root,
+                adev,
+                ttm_debugfs_entries[count].fops);
+        if (IS_ERR(ent))
+            return PTR_ERR(ent);
+        if (!strcmp(ttm_debugfs_entries[count].name, "amdgpu_vram"))
+            i_size_write(ent->d_inode, adev->mc.mc_vram_size);
+ else if (!strcmp(ttm_debugfs_entries[count].name, "amdgpu_gtt"))
+            i_size_write(ent->d_inode, adev->mc.gart_size);

Uff, string compare? That is screaming break me by typo.

Maybe but the domain type into the struct as well?

Apart from that looks good to me,


Sure, a quick grep didn't turn up any defines/enums for VRAM vs GTT though so just make some up?

Just use TTM_PL_VRAM and TTM_PL_TT for this.

Christian.


Tom


_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux