These patches tidy up the amdgpu_ttm debugfs creation, add an iova_to_phys interface and then remove the TTM trace from both amdgpu and drm/ttm.
Signed-off-by: Tom St Denis tom.stdenis@amd.com --- 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); + 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 } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 64709e041d5b..7abae6867339 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -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 */
Am 18.09.2017 um 14:35 schrieb Tom St Denis:
Signed-off-by: Tom St Denis tom.stdenis@amd.com
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, Christian.
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++)
#endif }debugfs_remove(adev->mman.debugfs_entries[i]);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 64709e041d5b..7abae6867339 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -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 */
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@amd.com
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?
Tom
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@amd.com
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
Signed-off-by: Tom St Denis tom.stdenis@amd.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 7848ffa99eb4..b4c298925e2a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -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
Am 18.09.2017 um 14:35 schrieb Tom St Denis:
Signed-off-by: Tom St Denis tom.stdenis@amd.com
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 7848ffa99eb4..b4c298925e2a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -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);
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.
- 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
On 18/09/17 08:52 AM, Christian König wrote:
Am 18.09.2017 um 14:35 schrieb Tom St Denis:
Signed-off-by: Tom St Denis tom.stdenis@amd.com
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 7848ffa99eb4..b4c298925e2a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -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);
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.
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
Signed-off-by: Tom St Denis tom.stdenis@amd.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 36 +++------------------------------ 1 file changed, 3 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index b4c298925e2a..e0c37fe4d043 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -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, >t->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, >t->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(>t->ttm, adev->dev); - goto trace_mappings; + return ttm_dma_populate(>t->ttm, adev->dev); } #endif
- r = ttm_populate_and_map_pages(adev->dev, >t->ttm); -trace_mappings: - if (likely(!r)) - amdgpu_trace_dma_map(ttm); - return r; + return ttm_populate_and_map_pages(adev->dev, >t->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(>t->ttm, adev->dev);
Signed-off-by: Tom St Denis tom.stdenis@amd.com --- 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
diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile index ab2bef1219e5..4d0c938ff4b2 100644 --- a/drivers/gpu/drm/ttm/Makefile +++ b/drivers/gpu/drm/ttm/Makefile @@ -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 diff --git a/drivers/gpu/drm/ttm/ttm_debug.c b/drivers/gpu/drm/ttm/ttm_debug.c deleted file mode 100644 index ef5f0d090154..000000000000 --- a/drivers/gpu/drm/ttm/ttm_debug.c +++ /dev/null @@ -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 tom.stdenis@amd.com - */ -#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); - diff --git a/drivers/gpu/drm/ttm/ttm_trace.h b/drivers/gpu/drm/ttm/ttm_trace.h deleted file mode 100644 index 715ce68b7b33..000000000000 --- a/drivers/gpu/drm/ttm/ttm_trace.h +++ /dev/null @@ -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 tom.stdenis@amd.com - */ -#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> - diff --git a/drivers/gpu/drm/ttm/ttm_tracepoints.c b/drivers/gpu/drm/ttm/ttm_tracepoints.c deleted file mode 100644 index 861a6266822b..000000000000 --- a/drivers/gpu/drm/ttm/ttm_tracepoints.c +++ /dev/null @@ -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 tom.stdenis@amd.com - */ -#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@lists.freedesktop.org