summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMichael Bestas <mkbestas@lineageos.org>2020-12-09 20:52:59 +0200
committerMichael Bestas <mkbestas@lineageos.org>2020-12-09 20:52:59 +0200
commit7b1ec6c9c1ad407744d6480da1ef9d650679e831 (patch)
treed31f3414e510917cdde91dacc9c4dea5e4d32325 /drivers/gpu
parent6107aa6dc24cc8c196bb18e5b5ec81f8f1a275a8 (diff)
parent0d6f3a76cfb07190719a68f7e73890f530427b91 (diff)
Merge tag 'LA.UM.8.4.r1-06200-8x98.0' of https://source.codeaurora.org/quic/la/kernel/msm-4.4 into lineage-17.1-caf-msm8998
* tag 'LA.UM.8.4.r1-06200-8x98.0' of https://source.codeaurora.org/quic/la/kernel/msm-4.4: crypto: Fix possible stack out of bound error ASoC: sdm660_cdc: Fix ear_pa_gain control soc: qcom: service-locator: Free PD list after client use cfg80211: Enhance the AKM advertizement to support per interface msm: kgsl: Don't wait for room in context queue when context is invalidated msm: kgsl: Don't allow re-importing memory owned by KGSL usb: dwc3: ep0: Return from handle_status if ep0_delegate_req succeeds scsi: ufs: Flush exception event before suspend msm: ipa: Fix deleting the routing entries mm-camera2:isp2: Add support for 12bit-plain16 raw format Revert "ipv6: defrag: drop non-last frags smaller than min mtu" usb: dwc3: ep0: Return from handle_status if ep0_delegate_req succeeds Change-Id: Ifcb5f033b250feaa41c4916bbbec757334e3429e
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/msm/adreno_dispatch.c23
-rw-r--r--drivers/gpu/msm/kgsl.c57
2 files changed, 38 insertions, 42 deletions
diff --git a/drivers/gpu/msm/adreno_dispatch.c b/drivers/gpu/msm/adreno_dispatch.c
index 9fee611e83d7..1a6d53b777d7 100644
--- a/drivers/gpu/msm/adreno_dispatch.c
+++ b/drivers/gpu/msm/adreno_dispatch.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1210,7 +1210,16 @@ static inline int _wait_for_room_in_context_queue(
spin_lock(&drawctxt->lock);
trace_adreno_drawctxt_wake(drawctxt);
- if (ret <= 0)
+ /*
+ * Account for the possibility that the context got invalidated
+ * while we were sleeping
+ */
+
+ if (ret > 0) {
+ ret = _check_context_state(&drawctxt->base);
+ if (ret)
+ return ret;
+ } else
return (ret == 0) ? -ETIMEDOUT : (int) ret;
}
@@ -1225,15 +1234,7 @@ static unsigned int _check_context_state_to_queue_cmds(
if (ret)
return ret;
- ret = _wait_for_room_in_context_queue(drawctxt);
- if (ret)
- return ret;
-
- /*
- * Account for the possiblity that the context got invalidated
- * while we were sleeping
- */
- return _check_context_state(&drawctxt->base);
+ return _wait_for_room_in_context_queue(drawctxt);
}
static void _queue_drawobj(struct adreno_context *drawctxt,
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index c5845a13b8a1..de5405615891 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -2091,13 +2091,6 @@ long kgsl_ioctl_cmdstream_freememontimestamp_ctxtid(
return ret;
}
-static inline int _check_region(unsigned long start, unsigned long size,
- uint64_t len)
-{
- uint64_t end = ((uint64_t) start) + size;
- return (end > len);
-}
-
static int check_vma_flags(struct vm_area_struct *vma,
unsigned int flags)
{
@@ -2112,23 +2105,27 @@ static int check_vma_flags(struct vm_area_struct *vma,
return -EFAULT;
}
-static int check_vma(struct vm_area_struct *vma, struct file *vmfile,
- struct kgsl_memdesc *memdesc)
+static int check_vma(unsigned long hostptr, u64 size)
{
- if (vma == NULL || vma->vm_file != vmfile)
- return -EINVAL;
+ struct vm_area_struct *vma;
+ unsigned long cur = hostptr;
- /* userspace may not know the size, in which case use the whole vma */
- if (memdesc->size == 0)
- memdesc->size = vma->vm_end - vma->vm_start;
- /* range checking */
- if (vma->vm_start != memdesc->useraddr ||
- (memdesc->useraddr + memdesc->size) != vma->vm_end)
- return -EINVAL;
- return check_vma_flags(vma, memdesc->flags);
+ while (cur < (hostptr + size)) {
+ vma = find_vma(current->mm, cur);
+ if (!vma)
+ return false;
+
+ /* Don't remap memory that we already own */
+ if (vma->vm_file && vma->vm_file->f_op == &kgsl_fops)
+ return false;
+
+ cur = vma->vm_end;
+ }
+
+ return true;
}
-static int memdesc_sg_virt(struct kgsl_memdesc *memdesc, struct file *vmfile)
+static int memdesc_sg_virt(struct kgsl_memdesc *memdesc)
{
int ret = 0;
long npages = 0, i;
@@ -2150,19 +2147,17 @@ static int memdesc_sg_virt(struct kgsl_memdesc *memdesc, struct file *vmfile)
}
down_read(&current->mm->mmap_sem);
- /* If we have vmfile, make sure we map the correct vma and map it all */
- if (vmfile != NULL)
- ret = check_vma(find_vma(current->mm, memdesc->useraddr),
- vmfile, memdesc);
-
- if (ret == 0) {
- npages = get_user_pages(current, current->mm, memdesc->useraddr,
- sglen, write ? FOLL_WRITE : 0,
- pages, NULL);
- ret = (npages < 0) ? (int)npages : 0;
+ if (!check_vma(memdesc->useraddr, memdesc->size)) {
+ up_read(&current->mm->mmap_sem);
+ ret = ~EFAULT;
+ goto out;
}
+
+ npages = get_user_pages(current, current->mm, memdesc->useraddr,
+ sglen, write ? FOLL_WRITE : 0, pages, NULL);
up_read(&current->mm->mmap_sem);
+ ret = (npages < 0) ? (int)npages : 0;
if (ret)
goto out;
@@ -2213,7 +2208,7 @@ static int kgsl_setup_anon_useraddr(struct kgsl_pagetable *pagetable,
entry->memdesc.gpuaddr = (uint64_t) entry->memdesc.useraddr;
}
- return memdesc_sg_virt(&entry->memdesc, NULL);
+ return memdesc_sg_virt(&entry->memdesc);
}
static int match_file(const void *p, struct file *file, unsigned int fd)