[PATCH] drm/amdgpu: don't map BO in reserved region

2020-10-16 Thread Madhav Chauhan
2MB area is reserved at top inside VM.

Suggested-by: Christian König 
Signed-off-by: Madhav Chauhan 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 5047989fe941..5b50860eece4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -596,6 +596,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
struct ww_acquire_ctx ticket;
struct list_head list, duplicates;
uint64_t va_flags;
+   uint64_t vm_size;
int r = 0;
 
if (args->va_address < AMDGPU_VA_RESERVED_SIZE) {
@@ -616,6 +617,15 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
 
args->va_address &= AMDGPU_GMC_HOLE_MASK;
 
+   vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
+   vm_size -= AMDGPU_VA_RESERVED_SIZE;
+   if (args->va_address + args->map_size > vm_size) {
+   dev_dbg(&dev->pdev->dev,
+   "va_address 0x%llx is in top reserved area 0x%llx\n",
+   args->va_address + args->map_size, vm_size);
+   return -EINVAL;
+   }
+
if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) {
dev_dbg(&dev->pdev->dev, "invalid flags combination 0x%08X\n",
args->flags);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH] drm/amdgpu: Add uid info to process BO list

2020-09-21 Thread Madhav Chauhan
UID is helpful while doing analysis of BO allocated
by a process.

Signed-off-by: Madhav Chauhan 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index f4c2e2e75b8f..c1982349ec7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -892,6 +892,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void 
*data)
struct drm_info_node *node = (struct drm_info_node *)m->private;
struct drm_device *dev = node->minor->dev;
struct drm_file *file;
+   kuid_t uid;
int r;
 
r = mutex_lock_interruptible(&dev->filelist_mutex);
@@ -909,7 +910,10 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, 
void *data)
 */
rcu_read_lock();
task = pid_task(file->pid, PIDTYPE_PID);
-   seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid),
+   uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;
+   seq_printf(m, "pid %8d uid %5d command %s:\n",
+  pid_nr(file->pid),
+  from_kuid_munged(seq_user_ns(m), uid),
   task ? task->comm : "");
rcu_read_unlock();
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx