Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70c13b73 authored by Puranam V G Tejaswi's avatar Puranam V G Tejaswi
Browse files

msm: kgsl: Change vma->vm_file to shmem file



If shmem is enabled, change vma->vm_file to shmem file. During mmap, the
vma is added to the vma chains contained in the adderss_space struct of
the file. This can later be used when trying to remove all mappings of
a page.

Change-Id: Ifa373c3300c4676fd2ba3d330d306060e4c321dc
Signed-off-by: default avatarPuranam V G Tejaswi <pvgtejas@codeaurora.org>
parent cb82ed90
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ static inline struct kgsl_pagetable *_get_memdesc_pagetable(

static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry);

static const struct file_operations kgsl_fops;
static const struct vm_operations_struct kgsl_gpumem_vm_ops;

/*
 * The memfree list contains the last N blocks of memory that have been freed.
@@ -2437,7 +2437,7 @@ static int check_vma(unsigned long hostptr, u64 size)
			return false;

		/* Don't remap memory that we already own */
		if (vma->vm_file && vma->vm_file->f_op == &kgsl_fops)
		if (vma->vm_file && vma->vm_ops == &kgsl_gpumem_vm_ops)
			return false;

		cur = vma->vm_end;
@@ -2594,7 +2594,7 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device,
		 * Check to see that this isn't our own memory that we have
		 * already mapped
		 */
		if (vma->vm_file->f_op == &kgsl_fops) {
		if (vma->vm_ops == &kgsl_gpumem_vm_ops) {
			up_read(&current->mm->mmap_sem);
			return -EFAULT;
		}
@@ -4973,9 +4973,10 @@ static int kgsl_mmap(struct file *file, struct vm_area_struct *vma)
		}
	}

	vma->vm_file = file;

	entry->memdesc.vma = vma;
	if (entry->memdesc.shmem_filp) {
		fput(vma->vm_file);
		vma->vm_file = get_file(entry->memdesc.shmem_filp);
	}

	/*
	 * kgsl gets the entry id or the gpu address through vm_pgoff.
+1 −5
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2008-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2008-2021, The Linux Foundation. All rights reserved.
 */
#ifndef __KGSL_H
#define __KGSL_H
@@ -227,10 +227,6 @@ struct kgsl_memdesc {
	unsigned int page_count;
	unsigned int cur_bindings;
	struct file *shmem_filp;
	/**
	 * @vma: Pointer to the vm_area_struct this memdesc is mapped to
	 */
	struct vm_area_struct *vma;
	/**
	 * @lock: Spinlock to protect the pages array
	 */