Skip to contentSkip to conversation

Remove TTM trace and use proper IOMMU api

PATCH In review Tom St Denis 5 participants 10 messages Sep 18, 2017 5 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#1 lore raw

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +29 -24
index 8ee16dfdb8af..7848ffa99eb4 100644
@@ -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);
+		adev->mman.debugfs_entries[count] = ent;
+	}
 
-#endif
 	count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
 
 #ifdef CONFIG_SWIOTLB
@@ -1844,7 +1855,6 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 
 	return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
 #else
-
 	return 0;
 #endif
 }
@@ -1852,14 +1862,9 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)
 {
 #if defined(CONFIG_DEBUG_FS)
+	unsigned i;
 
-	debugfs_remove(adev->mman.vram);
-	adev->mman.vram = NULL;
-
-#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
-	debugfs_remove(adev->mman.gtt);
-	adev->mman.gtt = NULL;
-#endif
-
+	for (i = 0; i < ARRAY_SIZE(ttm_debugfs_entries); i++)
+		debugfs_remove(adev->mman.debugfs_entries[i]);
 #endif
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -2
index 64709e041d5b..7abae6867339 100644
@@ -24,6 +24,7 @@
 #ifndef __AMDGPU_TTM_H__
 #define __AMDGPU_TTM_H__
 
+#include "amdgpu.h"
 #include "gpu_scheduler.h"
 
 #define AMDGPU_PL_GDS		(TTM_PL_PRIV + 0)
@@ -45,8 +46,7 @@ struct amdgpu_mman {
 	bool				initialized;
 
 #if defined(CONFIG_DEBUG_FS)
-	struct dentry			*vram;
-	struct dentry			*gtt;
+	struct dentry			*debugfs_entries[8];
 #endif
 
 	/* buffer handling */
Signature · 6 lines
2.12.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

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

Am 18.09.2017 um 14:35 schrieb Tom St Denis:

Quoted 49 lines
---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +14 -14
index 8ee16dfdb8af..7848ffa99eb4 100644
@@ -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(

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) · line 1845

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+				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,
Christian.

Quoted 46 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -10
+		adev->mman.debugfs_entries[count] = ent;
+	}
 
-#endif
  	count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
 
  #ifdef CONFIG_SWIOTLB
@@ -1844,7 +1855,6 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 
  	return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
  #else
-
  	return 0;
  #endif
  }
@@ -1852,14 +1862,9 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
  static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)
  {
  #if defined(CONFIG_DEBUG_FS)
+	unsigned i;
 
-	debugfs_remove(adev->mman.vram);
-	adev->mman.vram = NULL;
-
-#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
-	debugfs_remove(adev->mman.gtt);
-	adev->mman.gtt = NULL;
-#endif
-
+	for (i = 0; i < ARRAY_SIZE(ttm_debugfs_entries); i++)
+		debugfs_remove(adev->mman.debugfs_entries[i]);
  #endif
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
index 64709e041d5b..7abae6867339 100644
@@ -24,6 +24,7 @@
  #ifndef __AMDGPU_TTM_H__
  #define __AMDGPU_TTM_H__
 
+#include "amdgpu.h"
  #include "gpu_scheduler.h"
 
  #define AMDGPU_PL_GDS		(TTM_PL_PRIV + 0)

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h struct amdgpu_mman { · line 52

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -2
@@ -45,8 +46,7 @@ struct amdgpu_mman {
  	bool				initialized;
 
  #if defined(CONFIG_DEBUG_FS)
-	struct dentry			*vram;
-	struct dentry			*gtt;
+	struct dentry			*debugfs_entries[8];
  #endif
 
  	/* buffer handling */

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 049ebf9c-5293-f121-f005-a49ffeb65508-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw

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

Quoted 62 lines · Christian König

Am 18.09.2017 um 14:35 schrieb Tom St Denis:

Quoted 48 lines

---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +14 -14
index 8ee16dfdb8af..7848ffa99eb4 100644
@@ -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(

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_debugfs_init(struct · line 1845

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+                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.

Quoted 3 lines

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?

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 350a7d1b-7548-1347-b7bc-533acb47b1b7-5C7GfCeVMHo@public.gmane.org

#7 lore raw

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

Am 18.09.2017 um 15:01 schrieb Tom St Denis:

Quoted 65 lines · Christian König
Quoted 64 lines

Am 18.09.2017 um 14:35 schrieb Tom St Denis:

Quoted 50 lines
---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +15 -14
index 8ee16dfdb8af..7848ffa99eb4 100644
@@ -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,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_debugfs_init(struct · line 1847

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -0
+                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.

Quoted 6 lines
Quoted 3 lines

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.

Quoted 2 lines

Tom

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 2/4 drm/amd/amdgpu: add support for iova_to_phys to replace TTM trace

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +32 -0
index 7848ffa99eb4..b4c298925e2a 100644
@@ -43,6 +43,7 @@
 #include <linux/swap.h>
 #include <linux/pagemap.h>
 #include <linux/debugfs.h>
+#include <linux/iommu.h>
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 #include "bif/bif_4_1_d.h"
@@ -1810,6 +1811,36 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
 #endif
 
 
+static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
+				   size_t size, loff_t *pos)
+{
+	struct amdgpu_device *adev = file_inode(f)->i_private;
+	int r;
+	uint64_t phys;
+
+	// always return 8 bytes 
+	if (size != 8)
+		return -EINVAL;
+
+	// only accept page addresses
+	if (*pos & 0xFFF)
+		return -EINVAL;
+
+
+	phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos);
+
+	r = copy_to_user(buf, &phys, 8);
+	if (r)
+		return -EFAULT;
+
+	return 8;
+}
+
+static const struct file_operations amdgpu_ttm_iova_fops = {
+	.owner = THIS_MODULE,
+	.read = amdgpu_iova_to_phys_read,
+	.llseek = default_llseek
+};
 
 static const struct {
 	char *name;
@@ -1819,6 +1850,7 @@ static const struct {
 #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
 	{ "amdgpu_gtt", &amdgpu_ttm_gtt_fops },
 #endif
+	{ "amdgpu_iova", &amdgpu_ttm_iova_fops },
 };
 
 #endif
Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#10 lore raw

Re: [PATCH 2/4] drm/amd/amdgpu: add support for iova_to_phys to replace TTM trace

Am 18.09.2017 um 14:35 schrieb Tom St Denis:

Quoted 28 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32 ++++++++++++++++++++++++++++++++
  1 file changed, 32 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -0
index 7848ffa99eb4..b4c298925e2a 100644
@@ -43,6 +43,7 @@
  #include <linux/swap.h>
  #include <linux/pagemap.h>
  #include <linux/debugfs.h>
+#include <linux/iommu.h>
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
  #include "bif/bif_4_1_d.h"
@@ -1810,6 +1811,36 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
  #endif
 
 
+static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
+				   size_t size, loff_t *pos)
+{
+	struct amdgpu_device *adev = file_inode(f)->i_private;
+	int r;
+	uint64_t phys;
+

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static const struct file_operations amdgpu_ttm_gtt_fops = { · line 1830

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+	// always return 8 bytes
+	if (size != 8)
+		return -EINVAL;
+
+	// only accept page addresses
+	if (*pos & 0xFFF)
+		return -EINVAL;
+
+
+	phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos);

Well how about adding directly read/write support for the page behind the address?

This way we won't need to fiddle with /dev/mem any more either.

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13 -0
+
+	r = copy_to_user(buf, &phys, 8);
+	if (r)
+		return -EFAULT;
+
+	return 8;
+}
+
+static const struct file_operations amdgpu_ttm_iova_fops = {
+	.owner = THIS_MODULE,
+	.read = amdgpu_iova_to_phys_read,
+	.llseek = default_llseek
+};
 
  static const struct {
  	char *name;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static const struct { · line 1856

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
@@ -1819,6 +1850,7 @@ static const struct {
  #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
  	{ "amdgpu_gtt", &amdgpu_ttm_gtt_fops },
  #endif
+	{ "amdgpu_iova", &amdgpu_ttm_iova_fops },
  };
 
  #endif

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 927ae529-10cf-5cc9-fb96-76db8cfc0936-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#12 lore raw

Re: [PATCH 2/4] drm/amd/amdgpu: add support for iova_to_phys to replace TTM trace

Quoted 44 lines · Christian König

Am 18.09.2017 um 14:35 schrieb Tom St Denis:

Quoted 30 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32
++++++++++++++++++++++++++++++++

  1 file changed, 32 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -0
index 7848ffa99eb4..b4c298925e2a 100644
@@ -43,6 +43,7 @@
   #include <linux/swap.h>
   #include <linux/pagemap.h>
   #include <linux/debugfs.h>
+#include <linux/iommu.h>
   #include "amdgpu.h"
   #include "amdgpu_trace.h"
   #include "bif/bif_4_1_d.h"
@@ -1810,6 +1811,36 @@ static const struct file_operations 
 amdgpu_ttm_gtt_fops = {
   #endif
+static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user 
 *buf,
+                   size_t size, loff_t *pos)
+{
+    struct amdgpu_device *adev = file_inode(f)->i_private;
+    int r;
+    uint64_t phys;
+
+    // always return 8 bytes

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static const struct file_operations · line 1831

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -0
+    if (size != 8)
+        return -EINVAL;
+
+    // only accept page addresses
+    if (*pos & 0xFFF)
+        return -EINVAL;
+
+
+    phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), 
 *pos);

Well how about adding directly read/write support for the page behind the address?

Quoted 1 line

This way we won't need to fiddle with /dev/mem any more either.

Given the flak we got from requesting this from the iommu team I'm worried that might not be appreciated by the community (even though we maintain this part of the tree) and hurt our abilities to upstream.

I agree that adding a read/write method would be better though since we don't need config changes of /dev/fmem anymore.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#13 lore raw

PATCH 4/4 drm/ttm: Remove TTM dma tracepoint since it's not required anymore

In reply to a message not in the archive
---
 drivers/gpu/drm/ttm/Makefile          |  2 +-
 drivers/gpu/drm/ttm/ttm_debug.c       | 74 -----------------------------
 drivers/gpu/drm/ttm/ttm_trace.h       | 87 -----------------------------------
 drivers/gpu/drm/ttm/ttm_tracepoints.c | 45 ------------------
 4 files changed, 1 insertion(+), 207 deletions(-)
 delete mode 100644 drivers/gpu/drm/ttm/ttm_debug.c
 delete mode 100644 drivers/gpu/drm/ttm/ttm_trace.h
 delete mode 100644 drivers/gpu/drm/ttm/ttm_tracepoints.c
drivers/gpu/drm/ttm/Makefile +1 -1
index ab2bef1219e5..4d0c938ff4b2 100644
@@ -4,7 +4,7 @@
 ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
 	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
 	ttm_object.o ttm_lock.o ttm_execbuf_util.o ttm_page_alloc.o \
-	ttm_bo_manager.o ttm_page_alloc_dma.o ttm_debug.o ttm_tracepoints.o
+	ttm_bo_manager.o ttm_page_alloc_dma.o
 ttm-$(CONFIG_AGP) += ttm_agp_backend.o
 
 obj-$(CONFIG_DRM_TTM) += ttm.o
drivers/gpu/drm/ttm/ttm_debug.c deleted +0 -74

74 lines not on this page · raw message

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -87

87 lines not on this page · raw message

drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -45

45 lines not on this page · raw message

Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#14 lore raw

PATCH 3/4 drm/amd/amdgpu: remove usage of ttm trace

In reply to Tom St Denis
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 36 +++------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -33
index b4c298925e2a..e0c37fe4d043 100644
@@ -34,7 +34,6 @@
 #include <drm/ttm/ttm_placement.h>
 #include <drm/ttm/ttm_module.h>
 #include <drm/ttm/ttm_page_alloc.h>
-#include <drm/ttm/ttm_debug.h>
 #include <drm/drmP.h>
 #include <drm/amdgpu_drm.h>
 #include <linux/seq_file.h>
@@ -704,22 +703,6 @@ void amdgpu_ttm_tt_mark_user_pages(struct ttm_tt *ttm)
 	}
 }
 
-static void amdgpu_trace_dma_map(struct ttm_tt *ttm)
-{
-	struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
-	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-
-	ttm_trace_dma_map(adev->dev, &gtt->ttm);
-}
-
-static void amdgpu_trace_dma_unmap(struct ttm_tt *ttm)
-{
-	struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
-	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-
-	ttm_trace_dma_unmap(adev->dev, &gtt->ttm);
-}
-
 /* prepare the sg table with the user pages */
 static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
 {
@@ -746,8 +729,6 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
 	drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
 					 gtt->ttm.dma_address, ttm->num_pages);
 
-	amdgpu_trace_dma_map(ttm);
-
 	return 0;
 
 release_sg:
@@ -773,8 +754,6 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
 
 	amdgpu_ttm_tt_mark_user_pages(ttm);
 
-	amdgpu_trace_dma_unmap(ttm);
-
 	sg_free_table(ttm->sg);
 }
 
@@ -958,7 +937,6 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
 	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 	bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
 
 	if (ttm->state != tt_unpopulated)
@@ -978,22 +956,16 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
 		drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
 						 gtt->ttm.dma_address, ttm->num_pages);
 		ttm->state = tt_unbound;
-		r = 0;
-		goto trace_mappings;
+		return 0;
 	}
 
 #ifdef CONFIG_SWIOTLB
 	if (swiotlb_nr_tbl()) {
-		r = ttm_dma_populate(&gtt->ttm, adev->dev);
-		goto trace_mappings;
+		return ttm_dma_populate(&gtt->ttm, adev->dev);
 	}
 #endif
 
-	r = ttm_populate_and_map_pages(adev->dev, &gtt->ttm);
-trace_mappings:
-	if (likely(!r))
-		amdgpu_trace_dma_map(ttm);
-	return r;
+	return ttm_populate_and_map_pages(adev->dev, &gtt->ttm);
 }
 
 static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)
@@ -1014,8 +986,6 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)
 
 	adev = amdgpu_ttm_adev(ttm->bdev);
 
-	amdgpu_trace_dma_unmap(ttm);
-
 #ifdef CONFIG_SWIOTLB
 	if (swiotlb_nr_tbl()) {
 		ttm_dma_unpopulate(&gtt->ttm, adev->dev);
Signature · 6 lines
2.12.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel