Skip to content

Commit f0d4103

Browse files
ravnarchrmhoffmann
authored andcommitted
msm: kgsl: Remove 'fd' dependency to get dma_buf handle
Get the dma_buf handle directly from 'vm_file' after doing necessary checks on the file. Change-Id: Id5eec16588d64e4e28483b32bb52d4d3d9b86b99 Signed-off-by: ravnar <[email protected]> Signed-off-by: Sanjay Yadav <[email protected]>
1 parent 3d6d2ed commit f0d4103

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

drivers/gpu/msm/kgsl.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,15 +2165,6 @@ static int kgsl_setup_anon_useraddr(struct kgsl_pagetable *pagetable,
21652165
return ret;
21662166
}
21672167

2168-
static int match_file(const void *p, struct file *file, unsigned int fd)
2169-
{
2170-
/*
2171-
* We must return fd + 1 because iterate_fd stops searching on
2172-
* non-zero return, but 0 is a valid fd.
2173-
*/
2174-
return (p == file) ? (fd + 1) : 0;
2175-
}
2176-
21772168
static void _setup_cache_mode(struct kgsl_mem_entry *entry,
21782169
struct vm_area_struct *vma)
21792170
{
@@ -2212,8 +2203,6 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device,
22122203
vma = find_vma(current->mm, hostptr);
22132204

22142205
if (vma && vma->vm_file) {
2215-
int fd;
2216-
22172206
ret = check_vma_flags(vma, entry->memdesc.flags);
22182207
if (ret) {
22192208
up_read(&current->mm->mmap_sem);
@@ -2229,10 +2218,13 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device,
22292218
return -EFAULT;
22302219
}
22312220

2232-
/* Look for the fd that matches this the vma file */
2233-
fd = iterate_fd(current->files, 0, match_file, vma->vm_file);
2234-
if (fd != 0)
2235-
dmabuf = dma_buf_get(fd - 1);
2221+
/*
2222+
* Take a refcount because dma_buf_put() decrements the
2223+
* refcount
2224+
*/
2225+
get_file(vma->vm_file);
2226+
2227+
dmabuf = vma->vm_file->private_data;
22362228
}
22372229

22382230
if (IS_ERR_OR_NULL(dmabuf)) {

0 commit comments

Comments
 (0)