Skip to contentSkip to conversation

drm/amdgpu: fix incorrect use of fcheck

PATCH In review Christian König 2 participants 3 messages Aug 17, 2018 2 messages not in the archive

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

PATCH 1/2 drm/amdgpu: fix incorrect use of fcheck

The usage isn't RCU protected.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +3 -1
index 86a0715d9431..cb62a90d0686 100644
@@ -53,7 +53,7 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
 						  int fd,
 						  enum drm_sched_priority priority)
 {
-	struct file *filp = fcheck(fd);
+	struct file *filp = fget(fd);
 	struct drm_file *file;
 	struct pid *pid;
 	struct amdgpu_fpriv *fpriv;
@@ -78,6 +78,8 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
 
 	put_pid(pid);
 
+	fput(filp);
+
 	return 0;
 }
 
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180817174150.2297-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/amdgpu: fix incorrect use of drm_file->pid

That's the PID of the creator of the file (usually the X server) and not the end user of the file.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +4 -15
index cb62a90d0686..1cafe8d83a4d 100644
@@ -55,7 +55,6 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
 {
 	struct file *filp = fget(fd);
 	struct drm_file *file;
-	struct pid *pid;
 	struct amdgpu_fpriv *fpriv;
 	struct amdgpu_ctx *ctx;
 	uint32_t id;
@@ -63,20 +62,10 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
 	if (!filp)
 		return -EINVAL;
 
-	pid = get_pid(((struct drm_file *)filp->private_data)->pid);
-
-	mutex_lock(&adev->ddev->filelist_mutex);
-	list_for_each_entry(file, &adev->ddev->filelist, lhead) {
-		if (file->pid != pid)
-			continue;
-
-		fpriv = file->driver_priv;
-		idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
-				amdgpu_ctx_priority_override(ctx, priority);
-	}
-	mutex_unlock(&adev->ddev->filelist_mutex);
-
-	put_pid(pid);
+	file = filp->private_data;
+	fpriv = file->driver_priv;
+	idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
+		amdgpu_ctx_priority_override(ctx, priority);
 
 	fput(filp);
 
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180817174150.2297-2-christian.koenig-5C7GfCeVMHo@public.gmane.org

Acked-by
#4 lore raw

Re: [PATCH 2/2] drm/amdgpu: fix incorrect use of drm_file->pid

Quoted 6 lines · Christian König

That's the PID of the creator of the file (usually the X server) and not the end user of the file.

Series is:

Quoted 44 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +4 -16
index cb62a90d0686..1cafe8d83a4d 100644
@@ -55,7 +55,6 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
 {
        struct file *filp = fget(fd);
        struct drm_file *file;
-       struct pid *pid;
        struct amdgpu_fpriv *fpriv;
        struct amdgpu_ctx *ctx;
        uint32_t id;
@@ -63,20 +62,10 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
        if (!filp)
                return -EINVAL;
 
-       pid = get_pid(((struct drm_file *)filp->private_data)->pid);
-
-       mutex_lock(&adev->ddev->filelist_mutex);
-       list_for_each_entry(file, &adev->ddev->filelist, lhead) {
-               if (file->pid != pid)
-                       continue;
-
-               fpriv = file->driver_priv;
-               idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
-                               amdgpu_ctx_priority_override(ctx, priority);
-       }
-       mutex_unlock(&adev->ddev->filelist_mutex);
-
-       put_pid(pid);
+       file = filp->private_data;
+       fpriv = file->driver_priv;
+       idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
+               amdgpu_ctx_priority_override(ctx, priority);
 
        fput(filp);
 
--

2.14.1

Quoted 4 lines

_______________________________________________
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