Skip to contentSkip to conversation

remove ttm trace and add iova debugfs (v2)

PATCH In review Tom St Denis 4 participants 12 messages Sep 18, 2017 – Sep 19, 2017 3 messages not in the archive

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

In this respin I add some changes per feedback and make the iova entry have proper read/write methods which access pages mapped by amdgpu. So there is no need for /dev/mem or /dev/fmem anymore when reading system memory.

Patches 3/4 are unchanged and remove the TTM trace from amdgpu and from TTM itself.

_______________________________________________
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]

#2 lore raw

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

(v2): add domains and avoid strcmp

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 54 ++++++++++++++++++---------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +--
 2 files changed, 32 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +30 -24
index 8ee16dfdb8af..50d20903de4f 100644
@@ -1809,6 +1809,19 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
 
 #endif
 
+
+
+static const struct {
+	char *name;
+	const struct file_operations *fops;
+	int domain;
+} ttm_debugfs_entries[] = {
+	{ "amdgpu_vram", &amdgpu_ttm_vram_fops, TTM_PL_VRAM },
+#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
+	{ "amdgpu_gtt", &amdgpu_ttm_gtt_fops, TTM_PL_TT },
+#endif
+};
+
 #endif
 
 static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
@@ -1819,22 +1832,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 (ttm_debugfs_entries[count].domain == TTM_PL_VRAM)
+			i_size_write(ent->d_inode, adev->mc.mc_vram_size);
+		else if (ttm_debugfs_entries[count].domain == TTM_PL_TT)
+			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 +1856,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 +1863,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

_______________________________________________
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]

Reviewed-by
#4 lore raw

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

Am 18.09.2017 um 19:33 schrieb Tom St Denis:

Quoted 1 line
Quoted 107 lines

(v2): add domains and avoid strcmp

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 54 ++++++++++++++++++---------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  4 +--
  2 files changed, 32 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +30 -24
index 8ee16dfdb8af..50d20903de4f 100644
@@ -1809,6 +1809,19 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
 
  #endif
 
+
+
+static const struct {
+	char *name;
+	const struct file_operations *fops;
+	int domain;
+} ttm_debugfs_entries[] = {
+	{ "amdgpu_vram", &amdgpu_ttm_vram_fops, TTM_PL_VRAM },
+#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
+	{ "amdgpu_gtt", &amdgpu_ttm_gtt_fops, TTM_PL_TT },
+#endif
+};
+
  #endif
 
  static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
@@ -1819,22 +1832,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 (ttm_debugfs_entries[count].domain == TTM_PL_VRAM)
+			i_size_write(ent->d_inode, adev->mc.mc_vram_size);
+		else if (ttm_debugfs_entries[count].domain == TTM_PL_TT)
+			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 +1856,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 +1863,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

#5 lore raw

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

In reply to a message not in the archive

(v2): Add domain to iova debugfs
(v3): Add true read/write methods to access system memory of pages
mapped to the device

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 104 ++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +104 -0
index 50d20903de4f..02ae32378e1c 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,108 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
 #endif
 
 
+static void *transform_page(uint64_t phys)
+{
+	if (PageHighMem(pfn_to_page(PFN_DOWN(phys))))
+		return kmap(pfn_to_page(PFN_DOWN(phys)));
+	else
+		return __va(phys);
+}
+
+static void untransform_page(uint64_t phys)
+{
+	if (PageHighMem(pfn_to_page(PFN_DOWN(phys))))
+		return kunmap(pfn_to_page(PFN_DOWN(phys)));
+}
+
+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;
+	ssize_t result, n;
+	int r;
+	uint64_t phys;
+	void *ptr;
+
+	result = 0;
+	while (size) {
+		// get physical address and map
+		phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos);
+
+		// copy upto one page
+		if (size > PAGE_SIZE)
+			n = PAGE_SIZE;
+		else
+			n = size;
+
+		// to end of the page
+		if (((*pos & (PAGE_SIZE - 1)) + n) >= PAGE_SIZE)
+			n = PAGE_SIZE - (*pos & (PAGE_SIZE - 1));
+
+		ptr = transform_page(phys);
+		if (!ptr)
+			return -EFAULT;
+
+		r = copy_to_user(buf, ptr, n);
+		untransform_page(phys);
+		if (r)
+			return -EFAULT;
+
+		*pos += n;
+		size -= n;
+		result += n;
+	}
+
+	return result;
+}
+
+static ssize_t amdgpu_iova_to_phys_write(struct file *f, const char __user *buf,
+				   size_t size, loff_t *pos)
+{
+	struct amdgpu_device *adev = file_inode(f)->i_private;
+	ssize_t result, n;
+	int r;
+	uint64_t phys;
+	void *ptr;
+
+	result = 0;
+	while (size) {
+		// get physical address and map
+		phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos);
+
+		// copy upto one page
+		if (size > PAGE_SIZE)
+			n = PAGE_SIZE;
+		else
+			n = size;
+
+		// to end of the page
+		if (((*pos & (PAGE_SIZE - 1)) + n) >= PAGE_SIZE)
+			n = PAGE_SIZE - (*pos & (PAGE_SIZE - 1));
+
+		ptr = transform_page(phys);
+		if (!ptr)
+			return -EFAULT;
+
+		r = copy_from_user(ptr, buf, n);
+		untransform_page(phys);
+		if (r)
+			return -EFAULT;
+
+		*pos += n;
+		size -= n;
+		result += n;
+	}
+
+	return result;
+}
+
+static const struct file_operations amdgpu_ttm_iova_fops = {
+	.owner = THIS_MODULE,
+	.read = amdgpu_iova_to_phys_read,
+	.write = amdgpu_iova_to_phys_write,
+	.llseek = default_llseek
+};
 
 static const struct {
 	char *name;
@@ -1820,6 +1923,7 @@ static const struct {
 #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
 	{ "amdgpu_gtt", &amdgpu_ttm_gtt_fops, TTM_PL_TT },
 #endif
+	{ "amdgpu_iova", &amdgpu_ttm_iova_fops, TTM_PL_SYSTEM },
 };
 
 #endif
Signature · 6 lines
2.12.0

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

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

Am 18.09.2017 um 19:33 schrieb Tom St Denis:

Quoted 28 lines

(v2): Add domain to iova debugfs
(v3): Add true read/write methods to access system memory of pages
mapped to the device

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 104 ++++++++++++++++++++++++++++++++
  1 file changed, 104 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -0
index 50d20903de4f..02ae32378e1c 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,108 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
  #endif
 
 
+static void *transform_page(uint64_t phys)
+{
+	if (PageHighMem(pfn_to_page(PFN_DOWN(phys))))

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+		return kmap(pfn_to_page(PFN_DOWN(phys)));
+	else
+		return __va(phys);
+}
+
+static void untransform_page(uint64_t phys)
+{
+	if (PageHighMem(pfn_to_page(PFN_DOWN(phys))))
+		return kunmap(pfn_to_page(PFN_DOWN(phys)));
+}

No need for the extra PageHighMem check, just use kmap()/kunmap() they should do the right thing IIRC.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -0
+
+static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
+				   size_t size, loff_t *pos)
+{

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+	struct amdgpu_device *adev = file_inode(f)->i_private;
+	ssize_t result, n;
+	int r;
+	uint64_t phys;
+	void *ptr;
+
+	result = 0;
+	while (size) {
+		// get physical address and map
+		phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos);

Not sure what iommu_get_domain_for_dev does exactly, but the iommu domain for the device should always be the same so I would call the function only once before the loop.

Also failing with -ENODEV here when iommu_get_domain_for_dev() returns NULL sounds like a good idea to me.

Quoted 31 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +31 -0
+
+		// copy upto one page
+		if (size > PAGE_SIZE)
+			n = PAGE_SIZE;
+		else
+			n = size;
+
+		// to end of the page
+		if (((*pos & (PAGE_SIZE - 1)) + n) >= PAGE_SIZE)
+			n = PAGE_SIZE - (*pos & (PAGE_SIZE - 1));
+
+		ptr = transform_page(phys);
+		if (!ptr)
+			return -EFAULT;
+
+		r = copy_to_user(buf, ptr, n);
+		untransform_page(phys);
+		if (r)
+			return -EFAULT;
+
+		*pos += n;
+		size -= n;
+		result += n;
+	}
+
+	return result;
+}
+
+static ssize_t amdgpu_iova_to_phys_write(struct file *f, const char __user *buf,
+				   size_t size, loff_t *pos)
+{

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10 -0
+	struct amdgpu_device *adev = file_inode(f)->i_private;
+	ssize_t result, n;
+	int r;
+	uint64_t phys;
+	void *ptr;
+
+	result = 0;
+	while (size) {
+		// get physical address and map
+		phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos);

Same comment as above.

Apart from that looks good to me,
Christian.

Quoted 38 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +34 -0
+
+		// copy upto one page
+		if (size > PAGE_SIZE)
+			n = PAGE_SIZE;
+		else
+			n = size;
+
+		// to end of the page
+		if (((*pos & (PAGE_SIZE - 1)) + n) >= PAGE_SIZE)
+			n = PAGE_SIZE - (*pos & (PAGE_SIZE - 1));
+
+		ptr = transform_page(phys);
+		if (!ptr)
+			return -EFAULT;
+
+		r = copy_from_user(ptr, buf, n);
+		untransform_page(phys);
+		if (r)
+			return -EFAULT;
+
+		*pos += n;
+		size -= n;
+		result += n;
+	}
+
+	return result;
+}
+
+static const struct file_operations amdgpu_ttm_iova_fops = {
+	.owner = THIS_MODULE,
+	.read = amdgpu_iova_to_phys_read,
+	.write = amdgpu_iova_to_phys_write,
+	.llseek = default_llseek
+};
 
  static const struct {
  	char *name;

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

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

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

#7 lore raw

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

In reply to a message not in the archive
---
 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 02ae32378e1c..b41d03226c26 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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 3/4
#8 lore raw

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

Am 18.09.2017 um 19:33 schrieb Tom St Denis:

Quoted 1 line
Quoted 92 lines
---
  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 -31
index 02ae32378e1c..b41d03226c26 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)

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) · line 991

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -2
@@ -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);

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

#9 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
#10 lore raw

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

Am 18.09.2017 um 19:33 schrieb Tom St Denis:

Quoted 1 line

Mhm, I sometimes have good use for those. But just adding a printk at the right place does the job as well.

So patch is Reviewed-by: Christian König <[email protected]>.

Regards,
Christian.

Quoted 237 lines
---
  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
deleted file mode 100644
index ef5f0d090154..000000000000
@@ -1,74 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/shmem_fs.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drm_cache.h>
-#include <drm/ttm/ttm_module.h>
-#include <drm/ttm/ttm_bo_driver.h>
-#include <drm/ttm/ttm_placement.h>
-#include <drm/ttm/ttm_page_alloc.h>
-#include "ttm_trace.h"
-
-void ttm_trace_dma_map(struct device *dev, struct ttm_dma_tt *tt)
-{
-	unsigned i;
-
-	if (unlikely(trace_ttm_dma_map_enabled())) {
-		for (i = 0; i < tt->ttm.num_pages; i++) {
-			trace_ttm_dma_map(
-				dev,
-				tt->ttm.pages[i],
-				tt->dma_address[i]);
-		}
-	}
-}
-EXPORT_SYMBOL(ttm_trace_dma_map);
-
-void ttm_trace_dma_unmap(struct device *dev, struct ttm_dma_tt *tt)
-{
-	unsigned i;
-
-	if (unlikely(trace_ttm_dma_unmap_enabled())) {
-		for (i = 0; i < tt->ttm.num_pages; i++) {
-			trace_ttm_dma_unmap(
-				dev,
-				tt->ttm.pages[i],
-				tt->dma_address[i]);
-		}
-	}
-}
-EXPORT_SYMBOL(ttm_trace_dma_unmap);
-
drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -87
deleted file mode 100644
index 715ce68b7b33..000000000000
@@ -1,87 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#if !defined(_TTM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
-#define _TTM_TRACE_H_
-
-#include <linux/stringify.h>
-#include <linux/types.h>
-#include <linux/tracepoint.h>
-
-#include <drm/drmP.h>
-
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM ttm
-#define TRACE_INCLUDE_FILE ttm_trace
-
-TRACE_EVENT(ttm_dma_map,
-	    TP_PROTO(struct device *dev, struct page *page, dma_addr_t dma_address),
-	    TP_ARGS(dev, page, dma_address),
-	    TP_STRUCT__entry(
-				__string(device, dev_name(dev))
-				__field(dma_addr_t, dma)
-				__field(phys_addr_t, phys)
-			    ),
-	    TP_fast_assign(
-			   __assign_str(device, dev_name(dev));
-			   __entry->dma = dma_address;
-			   __entry->phys = page_to_phys(page);
-			   ),
-	    TP_printk("%s: %pad => %pa",
-		      __get_str(device),
-		      &__entry->dma,
-		      &__entry->phys)
-);
-
-TRACE_EVENT(ttm_dma_unmap,
-	    TP_PROTO(struct device *dev, struct page *page, dma_addr_t dma_address),
-	    TP_ARGS(dev, page, dma_address),
-	    TP_STRUCT__entry(
-				__string(device, dev_name(dev))
-				__field(dma_addr_t, dma)
-				__field(phys_addr_t, phys)
-			    ),
-	    TP_fast_assign(
-			   __assign_str(device, dev_name(dev));
-			   __entry->dma = dma_address;
-			   __entry->phys = page_to_phys(page);
-			   ),
-	    TP_printk("%s: %pad => %pa",
-		      __get_str(device),
-		      &__entry->dma,
-		      &__entry->phys)
-);
-
-#endif
-
-/* This part must be outside protection */
-#undef TRACE_INCLUDE_PATH
-#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/ttm/
-#include <trace/define_trace.h>
-
drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -35
deleted file mode 100644
index 861a6266822b..000000000000
@@ -1,45 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/shmem_fs.h>
-#include <linux/file.h>
-#include <linux/swap.h>

drivers/gpu/drm/ttm/ttm_tracepoints.c line 45

Quoted 10 lines
drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -10
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drm_cache.h>
-#include <drm/ttm/ttm_module.h>
-#include <drm/ttm/ttm_bo_driver.h>
-#include <drm/ttm/ttm_placement.h>
-#include <drm/ttm/ttm_page_alloc.h>
-
-#define CREATE_TRACE_POINTS
-#include "ttm_trace.h"

_______________________________________________
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): 1eef2bc2-742d-1737-1250-87c74dfb11da-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#12 lore raw

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

Quoted 6 lines · Christian König

Am 18.09.2017 um 19:33 schrieb Tom St Denis:

Quoted 1 line

Mhm, I sometimes have good use for those. But just adding a printk at the right place does the job as well.

So patch is Reviewed-by: Christian König <[email protected]>.

Well if you want to keep them we should not apply patch #3 then since we're the only users of it :-)

I'm ok with dropping #3/#4 if you want (also less work for Alex since we won't have to prune that history out of the branch we submit upstream).

umr has already been ported over to the new iova file though so it won't be using the trace.

Cheers,
Tom

Quoted 276 lines

Regards,
Christian.

Quoted 272 lines

---
  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 -6
deleted file mode 100644
index ef5f0d090154..000000000000
@@ -1,74 +0,0 @@
-/************************************************************************** 
 
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person 

obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/

drivers/gpu/drm/ttm/ttm_debug.c deleted +0 -48
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/shmem_fs.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drm_cache.h>
-#include <drm/ttm/ttm_module.h>
-#include <drm/ttm/ttm_bo_driver.h>
-#include <drm/ttm/ttm_placement.h>
-#include <drm/ttm/ttm_page_alloc.h>
-#include "ttm_trace.h"
-
-void ttm_trace_dma_map(struct device *dev, struct ttm_dma_tt *tt)
-{
-    unsigned i;
-
-    if (unlikely(trace_ttm_dma_map_enabled())) {
-        for (i = 0; i < tt->ttm.num_pages; i++) {
-            trace_ttm_dma_map(
-                dev,
-                tt->ttm.pages[i],
-                tt->dma_address[i]);
-        }
-    }
-}
-EXPORT_SYMBOL(ttm_trace_dma_map);
-
-void ttm_trace_dma_unmap(struct device *dev, struct ttm_dma_tt *tt)
-{
-    unsigned i;
-
-    if (unlikely(trace_ttm_dma_unmap_enabled())) {
-        for (i = 0; i < tt->ttm.num_pages; i++) {
-            trace_ttm_dma_unmap(
-                dev,
-                tt->ttm.pages[i],
-                tt->dma_address[i]);
-        }
-    }
-}
-EXPORT_SYMBOL(ttm_trace_dma_unmap);
-
drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -6
deleted file mode 100644
index 715ce68b7b33..000000000000
@@ -1,87 +0,0 @@
-/************************************************************************** 
 
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person 

obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -18
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#if !defined(_TTM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
-#define _TTM_TRACE_H_
-
-#include <linux/stringify.h>
-#include <linux/types.h>
-#include <linux/tracepoint.h>
-
-#include <drm/drmP.h>
-
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM ttm
-#define TRACE_INCLUDE_FILE ttm_trace
-
-TRACE_EVENT(ttm_dma_map,
-        TP_PROTO(struct device *dev, struct page *page, dma_addr_t 

dma_address),
-        TP_ARGS(dev, page, dma_address),
-        TP_STRUCT__entry(
-                __string(device, dev_name(dev)) -                __field(dma_addr_t, dma)
-                __field(phys_addr_t, phys) -                ),
-        TP_fast_assign(
-               __assign_str(device, dev_name(dev)); -               __entry->dma = dma_address; -               __entry->phys = page_to_phys(page); -               ),
-        TP_printk("%s: %pad => %pa",
-              __get_str(device),
-              &__entry->dma,
-              &__entry->phys)

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -4
-);
-
-TRACE_EVENT(ttm_dma_unmap,
-        TP_PROTO(struct device *dev, struct page *page, dma_addr_t 

dma_address),
-        TP_ARGS(dev, page, dma_address),
-        TP_STRUCT__entry(
-                __string(device, dev_name(dev)) -                __field(dma_addr_t, dma)
-                __field(phys_addr_t, phys) -                ),
-        TP_fast_assign(
-               __assign_str(device, dev_name(dev)); -               __entry->dma = dma_address; -               __entry->phys = page_to_phys(page); -               ),
-        TP_printk("%s: %pad => %pa",
-              __get_str(device),
-              &__entry->dma,
-              &__entry->phys)

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -9
-);
-
-#endif
-
-/* This part must be outside protection */
-#undef TRACE_INCLUDE_PATH
-#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/ttm/
-#include <trace/define_trace.h>
-
drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -6
deleted file mode 100644
index 861a6266822b..000000000000
@@ -1,45 +0,0 @@
-/************************************************************************** 
 
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person 

obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/

drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -11
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/shmem_fs.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/slab.h>
-#include <linux/export.h>
Quoted 10 lines

drivers/gpu/drm/ttm/ttm_tracepoints.c line 45

Quoted 8 lines
drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -8
-#include <drm/drm_cache.h>
-#include <drm/ttm/ttm_module.h>
-#include <drm/ttm/ttm_bo_driver.h>
-#include <drm/ttm/ttm_placement.h>
-#include <drm/ttm/ttm_page_alloc.h>
-
-#define CREATE_TRACE_POINTS
-#include "ttm_trace.h"

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

maintainer
#13 lore raw

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

Am 19.09.2017 um 13:15 schrieb Tom St Denis:

Quoted 11 lines · Christian König
Quoted 6 lines

Am 18.09.2017 um 19:33 schrieb Tom St Denis:

Quoted 1 line

Mhm, I sometimes have good use for those. But just adding a printk at the right place does the job as well.

So patch is Reviewed-by: Christian König <[email protected]>.

Well if you want to keep them we should not apply patch #3 then since we're the only users of it :-)

I'm ok with dropping #3/#4 if you want (also less work for Alex since we won't have to prune that history out of the branch we submit upstream).

Please remove that for now. The next time I need it I can cleanup and resubmit the patches so that they work for all drivers in the kernel.

Christian.

Quoted 304 lines

umr has already been ported over to the new iova file though so it won't be using the trace.

Cheers,
Tom

Quoted 296 lines

Regards,
Christian.

Quoted 290 lines
---
  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 +0 -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

drivers/gpu/drm/ttm/Makefile +1 -0
+    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 -6
deleted file mode 100644
index ef5f0d090154..000000000000
@@ -1,74 +0,0 @@
-/************************************************************************** 
 
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person 

obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/

drivers/gpu/drm/ttm/ttm_debug.c deleted +0 -48
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/shmem_fs.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drm_cache.h>
-#include <drm/ttm/ttm_module.h>
-#include <drm/ttm/ttm_bo_driver.h>
-#include <drm/ttm/ttm_placement.h>
-#include <drm/ttm/ttm_page_alloc.h>
-#include "ttm_trace.h"
-
-void ttm_trace_dma_map(struct device *dev, struct ttm_dma_tt *tt)
-{
-    unsigned i;
-
-    if (unlikely(trace_ttm_dma_map_enabled())) {
-        for (i = 0; i < tt->ttm.num_pages; i++) {
-            trace_ttm_dma_map(
-                dev,
-                tt->ttm.pages[i],
-                tt->dma_address[i]);
-        }
-    }
-}
-EXPORT_SYMBOL(ttm_trace_dma_map);
-
-void ttm_trace_dma_unmap(struct device *dev, struct ttm_dma_tt *tt)
-{
-    unsigned i;
-
-    if (unlikely(trace_ttm_dma_unmap_enabled())) {
-        for (i = 0; i < tt->ttm.num_pages; i++) {
-            trace_ttm_dma_unmap(
-                dev,
-                tt->ttm.pages[i],
-                tt->dma_address[i]);
-        }
-    }
-}
-EXPORT_SYMBOL(ttm_trace_dma_unmap);
-
drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -6
deleted file mode 100644
index 715ce68b7b33..000000000000
@@ -1,87 +0,0 @@
-/************************************************************************** 
 
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person 

obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -18
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#if !defined(_TTM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
-#define _TTM_TRACE_H_
-
-#include <linux/stringify.h>
-#include <linux/types.h>
-#include <linux/tracepoint.h>
-
-#include <drm/drmP.h>
-
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM ttm
-#define TRACE_INCLUDE_FILE ttm_trace
-
-TRACE_EVENT(ttm_dma_map,
-        TP_PROTO(struct device *dev, struct page *page, dma_addr_t 

dma_address),

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -19
-        TP_ARGS(dev, page, dma_address),
-        TP_STRUCT__entry(
-                __string(device, dev_name(dev))
-                __field(dma_addr_t, dma)
-                __field(phys_addr_t, phys)
-                ),
-        TP_fast_assign(
-               __assign_str(device, dev_name(dev));
-               __entry->dma = dma_address;
-               __entry->phys = page_to_phys(page);
-               ),
-        TP_printk("%s: %pad => %pa",
-              __get_str(device),
-              &__entry->dma,
-              &__entry->phys)
-);
-
-TRACE_EVENT(ttm_dma_unmap,
-        TP_PROTO(struct device *dev, struct page *page, dma_addr_t 

dma_address),

drivers/gpu/drm/ttm/ttm_trace.h deleted +0 -24
-        TP_ARGS(dev, page, dma_address),
-        TP_STRUCT__entry(
-                __string(device, dev_name(dev))
-                __field(dma_addr_t, dma)
-                __field(phys_addr_t, phys)
-                ),
-        TP_fast_assign(
-               __assign_str(device, dev_name(dev));
-               __entry->dma = dma_address;
-               __entry->phys = page_to_phys(page);
-               ),
-        TP_printk("%s: %pad => %pa",
-              __get_str(device),
-              &__entry->dma,
-              &__entry->phys)
-);
-
-#endif
-
-/* This part must be outside protection */
-#undef TRACE_INCLUDE_PATH
-#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/ttm/
-#include <trace/define_trace.h>
-
drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -6
deleted file mode 100644
index 861a6266822b..000000000000
@@ -1,45 +0,0 @@
-/************************************************************************** 
 
- *
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person 

obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/

drivers/gpu/drm/ttm/ttm_tracepoints.c deleted +0 -19
-/*
- * Authors: Tom St Denis <[email protected]>
- */
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/shmem_fs.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drm_cache.h>
-#include <drm/ttm/ttm_module.h>
-#include <drm/ttm/ttm_bo_driver.h>
-#include <drm/ttm/ttm_placement.h>
-#include <drm/ttm/ttm_page_alloc.h>
-
-#define CREATE_TRACE_POINTS
-#include "ttm_trace.h"

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

#14 lore raw
In reply to a message not in the archive

Should add I was able to read/write system memory mapped by amdgpu with these patches in place on my polaris10 device (with iommu enabled of course).

________________________________________
From: amd-gfx <[email protected]> on behalf of Tom St Denis <[email protected]>
Sent: Monday, September 18, 2017 13:33
To: [email protected]
Cc: [email protected]
Subject: remove ttm trace and add iova debugfs (v2)

In this respin I add some changes per feedback and make the iova entry have proper read/write methods which access pages mapped by amdgpu. So there is no need for /dev/mem or /dev/fmem anymore when reading system memory.

Patches 3/4 are unchanged and remove the TTM trace from amdgpu and from TTM itself.

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