aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_ttm.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2013-12-18 15:07:40 -0500
committerAlex Deucher <alexander.deucher@amd.com>2013-12-24 16:12:53 -0500
commitdd66d20e39292e94ea9e210872ef76e5dc1cc688 (patch)
tree62faf14d34431b1b4cc367e47744c1aba6a61989 /drivers/gpu/drm/radeon/radeon_ttm.c
parent2014b5694182b54c781b93d26ec993f8a12bca01 (diff)
drm/radeon: add GART debugfs access v3
v2: add default_llseek v3: set inode size in the open callback Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_ttm.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index a29d7cbd62e7..77f5b0c3edb8 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -917,6 +917,60 @@ static const struct file_operations radeon_ttm_vram_fops = {
917 .llseek = default_llseek 917 .llseek = default_llseek
918}; 918};
919 919
920static int radeon_ttm_gtt_open(struct inode *inode, struct file *filep)
921{
922 struct radeon_device *rdev = inode->i_private;
923 i_size_write(inode, rdev->mc.gtt_size);
924 filep->private_data = inode->i_private;
925 return 0;
926}
927
928static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf,
929 size_t size, loff_t *pos)
930{
931 struct radeon_device *rdev = f->private_data;
932 ssize_t result = 0;
933 int r;
934
935 while (size) {
936 loff_t p = *pos / PAGE_SIZE;
937 unsigned off = *pos & ~PAGE_MASK;
938 ssize_t cur_size = min(size, PAGE_SIZE - off);
939 struct page *page;
940 void *ptr;
941
942 if (p >= rdev->gart.num_cpu_pages)
943 return result;
944
945 page = rdev->gart.pages[p];
946 if (page) {
947 ptr = kmap(page);
948 ptr += off;
949
950 r = copy_to_user(buf, ptr, cur_size);
951 kunmap(rdev->gart.pages[p]);
952 } else
953 r = clear_user(buf, cur_size);
954
955 if (r)
956 return -EFAULT;
957
958 result += cur_size;
959 buf += cur_size;
960 *pos += cur_size;
961 size -= cur_size;
962 }
963
964 return result;
965}
966
967static const struct file_operations radeon_ttm_gtt_fops = {
968 .owner = THIS_MODULE,
969 .open = radeon_ttm_gtt_open,
970 .read = radeon_ttm_gtt_read,
971 .llseek = default_llseek
972};
973
920#endif 974#endif
921 975
922static int radeon_ttm_debugfs_init(struct radeon_device *rdev) 976static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
@@ -933,6 +987,12 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
933 return PTR_ERR(ent); 987 return PTR_ERR(ent);
934 rdev->mman.vram = ent; 988 rdev->mman.vram = ent;
935 989
990 ent = debugfs_create_file("radeon_gtt", S_IFREG | S_IRUGO, root,
991 rdev, &radeon_ttm_gtt_fops);
992 if (IS_ERR(ent))
993 return PTR_ERR(ent);
994 rdev->mman.gtt = ent;
995
936 count = ARRAY_SIZE(radeon_ttm_debugfs_list); 996 count = ARRAY_SIZE(radeon_ttm_debugfs_list);
937 997
938#ifdef CONFIG_SWIOTLB 998#ifdef CONFIG_SWIOTLB
@@ -953,5 +1013,8 @@ static void radeon_ttm_debugfs_fini(struct radeon_device *rdev)
953 1013
954 debugfs_remove(rdev->mman.vram); 1014 debugfs_remove(rdev->mman.vram);
955 rdev->mman.vram = NULL; 1015 rdev->mman.vram = NULL;
1016
1017 debugfs_remove(rdev->mman.gtt);
1018 rdev->mman.gtt = NULL;
956#endif 1019#endif
957} 1020}