summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/msm/kgsl.c10
-rw-r--r--drivers/gpu/msm/kgsl_mmu.c5
2 files changed, 11 insertions, 4 deletions
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 5d3986dd..5215328 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -2383,6 +2383,8 @@ static int kgsl_setup_anon_useraddr(struct kgsl_pagetable *pagetable,
{
/* Map an anonymous memory chunk */
+ int ret;
+
if (size == 0 || offset != 0 ||
!IS_ALIGNED(size, PAGE_SIZE))
return -EINVAL;
@@ -2392,7 +2394,6 @@ static int kgsl_setup_anon_useraddr(struct kgsl_pagetable *pagetable,
entry->memdesc.flags |= (uint64_t)KGSL_MEMFLAGS_USERMEM_ADDR;
if (kgsl_memdesc_use_cpu_map(&entry->memdesc)) {
- int ret;
/* Register the address in the database */
ret = kgsl_mmu_set_svm_region(pagetable,
@@ -2404,7 +2405,12 @@ static int kgsl_setup_anon_useraddr(struct kgsl_pagetable *pagetable,
entry->memdesc.gpuaddr = (uint64_t) hostptr;
}
- return memdesc_sg_virt(&entry->memdesc, hostptr);
+ ret = memdesc_sg_virt(&entry->memdesc, hostptr);
+
+ if (ret && kgsl_memdesc_use_cpu_map(&entry->memdesc))
+ kgsl_mmu_put_gpuaddr(&entry->memdesc);
+
+ return ret;
}
#ifdef CONFIG_DMA_SHARED_BUFFER
diff --git a/drivers/gpu/msm/kgsl_mmu.c b/drivers/gpu/msm/kgsl_mmu.c
index 3ad92a7..b2558a7 100644
--- a/drivers/gpu/msm/kgsl_mmu.c
+++ b/drivers/gpu/msm/kgsl_mmu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002,2007-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2002,2007-2017,2021, 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
@@ -439,7 +439,8 @@ void kgsl_mmu_put_gpuaddr(struct kgsl_memdesc *memdesc)
if (memdesc->size == 0 || memdesc->gpuaddr == 0)
return;
- if (!kgsl_memdesc_is_global(memdesc))
+ if (!kgsl_memdesc_is_global(memdesc) &&
+ (KGSL_MEMDESC_MAPPED & memdesc->priv))
unmap_fail = kgsl_mmu_unmap(pagetable, memdesc);
/*