summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Park <Youngeun.Park@arm.com>2023-12-08 17:01:50 +0000
committerRenato Grottesi <otaner@google.com>2023-12-11 12:57:25 +0000
commit2226bae46b7a606e97a9ced0e91d7209cd04758c (patch)
treec5d287e0fd9699c37b4c42a40ece494c848f5b5a
parentcab5dbbee97ee9e3baa41d00372363a2f53196e0 (diff)
downloadgpu-2226bae46b7a606e97a9ced0e91d7209cd04758c.tar.gz
Fix deadlock BTW user thread and page fault worker
MIDCET-4882,GPUCORE-40989 Break deadlock BTW user thread and page fault worker This commit adds a RW semaphore 1> to prevent MMU operations during P.Mode entrance and 2> to break the deadlock on 'kctx reg_lock' between user thread and page-fault worker thread. Bug: 301064831 Signed-off-by: Renato Grottesi <otaner@google.com> Test: manual run of the use case from the ticket Provenance: https://code.ipdelivery.arm.com/c/GPU/mali-ddk/+/6221 Change-Id: I692f8fafc558a6a45b5ca4210aa3f66c2617553f
-rw-r--r--mali_kbase/csf/mali_kbase_csf_defs.h2
-rw-r--r--mali_kbase/csf/mali_kbase_csf_firmware.c3
-rw-r--r--mali_kbase/csf/mali_kbase_csf_firmware_no_mali.c1
-rw-r--r--mali_kbase/csf/mali_kbase_csf_kcpu.c24
-rw-r--r--mali_kbase/csf/mali_kbase_csf_scheduler.c6
-rw-r--r--mali_kbase/csf/mali_kbase_csf_tiler_heap.c5
-rw-r--r--mali_kbase/mali_kbase_core_linux.c8
-rw-r--r--mali_kbase/mali_kbase_gwt.c6
-rw-r--r--mali_kbase/mali_kbase_mem.c37
-rw-r--r--mali_kbase/mali_kbase_mem.h18
-rw-r--r--mali_kbase/mali_kbase_mem_linux.c51
-rw-r--r--mali_kbase/mali_kbase_mem_migrate.c8
12 files changed, 106 insertions, 63 deletions
diff --git a/mali_kbase/csf/mali_kbase_csf_defs.h b/mali_kbase/csf/mali_kbase_csf_defs.h
index ef973b7..fdaa10f 100644
--- a/mali_kbase/csf/mali_kbase_csf_defs.h
+++ b/mali_kbase/csf/mali_kbase_csf_defs.h
@@ -1645,6 +1645,7 @@ struct kbase_csf_user_reg {
* kbase_queue.pending_kick_link.
* @quirks_ext: Pointer to an allocated buffer containing the firmware
* workarounds configuration.
+ * @pmode_sync_sem: RW Semaphore to prevent MMU operations during P.Mode entrance.
*/
struct kbase_csf_device {
struct kbase_mmu_table mcu_mmu;
@@ -1701,6 +1702,7 @@ struct kbase_csf_device {
struct list_head pending_gpuq_kicks[KBASE_QUEUE_GROUP_PRIORITY_COUNT];
spinlock_t pending_gpuq_kicks_lock;
u32 *quirks_ext;
+ struct rw_semaphore pmode_sync_sem;
};
/**
diff --git a/mali_kbase/csf/mali_kbase_csf_firmware.c b/mali_kbase/csf/mali_kbase_csf_firmware.c
index bd815c4..cf4bb4c 100644
--- a/mali_kbase/csf/mali_kbase_csf_firmware.c
+++ b/mali_kbase/csf/mali_kbase_csf_firmware.c
@@ -2424,6 +2424,7 @@ int kbase_csf_firmware_early_init(struct kbase_device *kbdev)
INIT_WORK(&kbdev->csf.fw_error_work, firmware_error_worker);
INIT_WORK(&kbdev->csf.coredump_work, coredump_worker);
+ init_rwsem(&kbdev->csf.pmode_sync_sem);
mutex_init(&kbdev->csf.reg_lock);
kbase_csf_pending_gpuq_kicks_init(kbdev);
@@ -3023,8 +3024,6 @@ int kbase_csf_wait_protected_mode_enter(struct kbase_device *kbdev)
{
int err;
- lockdep_assert_held(&kbdev->mmu_hw_mutex);
-
err = wait_for_global_request(kbdev, GLB_REQ_PROTM_ENTER_MASK);
if (!err) {
diff --git a/mali_kbase/csf/mali_kbase_csf_firmware_no_mali.c b/mali_kbase/csf/mali_kbase_csf_firmware_no_mali.c
index 764c18d..93d7c36 100644
--- a/mali_kbase/csf/mali_kbase_csf_firmware_no_mali.c
+++ b/mali_kbase/csf/mali_kbase_csf_firmware_no_mali.c
@@ -1179,6 +1179,7 @@ int kbase_csf_firmware_early_init(struct kbase_device *kbdev)
kbase_csf_firmware_reload_worker);
INIT_WORK(&kbdev->csf.fw_error_work, firmware_error_worker);
+ init_rwsem(&kbdev->csf.pmode_sync_sem);
mutex_init(&kbdev->csf.reg_lock);
kbase_csf_pending_gpuq_kicks_init(kbdev);
diff --git a/mali_kbase/csf/mali_kbase_csf_kcpu.c b/mali_kbase/csf/mali_kbase_csf_kcpu.c
index 52bd307..0b08dba 100644
--- a/mali_kbase/csf/mali_kbase_csf_kcpu.c
+++ b/mali_kbase/csf/mali_kbase_csf_kcpu.c
@@ -2270,10 +2270,10 @@ static void kcpu_queue_process(struct kbase_kcpu_command_queue *queue,
KBASE_TLSTREAM_TL_KBASE_KCPUQUEUE_EXECUTE_MAP_IMPORT_START(kbdev,
queue);
- kbase_gpu_vm_lock(queue->kctx);
- meta = kbase_sticky_resource_acquire(
- queue->kctx, cmd->info.import.gpu_va);
- kbase_gpu_vm_unlock(queue->kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(queue->kctx);
+ meta = kbase_sticky_resource_acquire(queue->kctx,
+ cmd->info.import.gpu_va);
+ kbase_gpu_vm_unlock_with_pmode_sync(queue->kctx);
if (meta == NULL) {
queue->has_error = true;
@@ -2292,10 +2292,10 @@ static void kcpu_queue_process(struct kbase_kcpu_command_queue *queue,
KBASE_TLSTREAM_TL_KBASE_KCPUQUEUE_EXECUTE_UNMAP_IMPORT_START(kbdev, queue);
- kbase_gpu_vm_lock(queue->kctx);
- ret = kbase_sticky_resource_release(
- queue->kctx, NULL, cmd->info.import.gpu_va);
- kbase_gpu_vm_unlock(queue->kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(queue->kctx);
+ ret = kbase_sticky_resource_release(queue->kctx, NULL,
+ cmd->info.import.gpu_va);
+ kbase_gpu_vm_unlock_with_pmode_sync(queue->kctx);
if (!ret) {
queue->has_error = true;
@@ -2313,10 +2313,10 @@ static void kcpu_queue_process(struct kbase_kcpu_command_queue *queue,
KBASE_TLSTREAM_TL_KBASE_KCPUQUEUE_EXECUTE_UNMAP_IMPORT_FORCE_START(kbdev,
queue);
- kbase_gpu_vm_lock(queue->kctx);
- ret = kbase_sticky_resource_release_force(
- queue->kctx, NULL, cmd->info.import.gpu_va);
- kbase_gpu_vm_unlock(queue->kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(queue->kctx);
+ ret = kbase_sticky_resource_release_force(queue->kctx, NULL,
+ cmd->info.import.gpu_va);
+ kbase_gpu_vm_unlock_with_pmode_sync(queue->kctx);
if (!ret) {
queue->has_error = true;
diff --git a/mali_kbase/csf/mali_kbase_csf_scheduler.c b/mali_kbase/csf/mali_kbase_csf_scheduler.c
index 817e25e..e8cdce7 100644
--- a/mali_kbase/csf/mali_kbase_csf_scheduler.c
+++ b/mali_kbase/csf/mali_kbase_csf_scheduler.c
@@ -4505,7 +4505,7 @@ static void scheduler_group_check_protm_enter(struct kbase_device *const kbdev,
* entry to protected mode happens with a memory region being locked and
* the same region is then accessed by the GPU in protected mode.
*/
- mutex_lock(&kbdev->mmu_hw_mutex);
+ down_write(&kbdev->csf.pmode_sync_sem);
spin_lock_irqsave(&scheduler->interrupt_lock, flags);
/* Check if the previous transition to enter & exit the protected
@@ -4574,7 +4574,7 @@ static void scheduler_group_check_protm_enter(struct kbase_device *const kbdev,
spin_unlock_irqrestore(&scheduler->interrupt_lock, flags);
err = kbase_csf_wait_protected_mode_enter(kbdev);
- mutex_unlock(&kbdev->mmu_hw_mutex);
+ up_write(&kbdev->csf.pmode_sync_sem);
if (err)
schedule_actions_trigger_df(kbdev, input_grp->kctx,
@@ -4588,7 +4588,7 @@ static void scheduler_group_check_protm_enter(struct kbase_device *const kbdev,
}
spin_unlock_irqrestore(&scheduler->interrupt_lock, flags);
- mutex_unlock(&kbdev->mmu_hw_mutex);
+ up_write(&kbdev->csf.pmode_sync_sem);
}
/**
diff --git a/mali_kbase/csf/mali_kbase_csf_tiler_heap.c b/mali_kbase/csf/mali_kbase_csf_tiler_heap.c
index 85d8018..f7e1a8d 100644
--- a/mali_kbase/csf/mali_kbase_csf_tiler_heap.c
+++ b/mali_kbase/csf/mali_kbase_csf_tiler_heap.c
@@ -224,7 +224,7 @@ static void remove_unlinked_chunk(struct kbase_context *kctx,
if (WARN_ON(!list_empty(&chunk->link)))
return;
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
kbase_vunmap(kctx, &chunk->map);
/* KBASE_REG_DONT_NEED regions will be confused with ephemeral regions (inc freed JIT
* regions), and so we must clear that flag too before freeing.
@@ -237,7 +237,7 @@ static void remove_unlinked_chunk(struct kbase_context *kctx,
chunk->region->flags &= ~KBASE_REG_DONT_NEED;
#endif
kbase_mem_free_region(kctx, chunk->region);
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
kfree(chunk);
}
@@ -1072,6 +1072,7 @@ static bool delete_chunk_physical_pages(struct kbase_csf_tiler_heap *heap, u64 c
struct kbase_csf_tiler_heap_chunk *chunk = NULL;
lockdep_assert_held(&heap->kctx->csf.tiler_heaps.lock);
+ lockdep_assert_held(&kctx->kbdev->csf.scheduler.lock);
chunk = find_chunk(heap, chunk_gpu_va);
if (unlikely(!chunk)) {
diff --git a/mali_kbase/mali_kbase_core_linux.c b/mali_kbase/mali_kbase_core_linux.c
index 75e8023..9af1eab 100644
--- a/mali_kbase/mali_kbase_core_linux.c
+++ b/mali_kbase/mali_kbase_core_linux.c
@@ -1539,7 +1539,7 @@ static int kbase_api_sticky_resource_map(struct kbase_context *kctx,
if (ret != 0)
return -EFAULT;
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
for (i = 0; i < map->count; i++) {
if (!kbase_sticky_resource_acquire(kctx, gpu_addr[i])) {
@@ -1556,7 +1556,7 @@ static int kbase_api_sticky_resource_map(struct kbase_context *kctx,
}
}
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return ret;
}
@@ -1577,7 +1577,7 @@ static int kbase_api_sticky_resource_unmap(struct kbase_context *kctx,
if (ret != 0)
return -EFAULT;
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
for (i = 0; i < unmap->count; i++) {
if (!kbase_sticky_resource_release_force(kctx, NULL, gpu_addr[i])) {
@@ -1586,7 +1586,7 @@ static int kbase_api_sticky_resource_unmap(struct kbase_context *kctx,
}
}
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return ret;
}
diff --git a/mali_kbase/mali_kbase_gwt.c b/mali_kbase/mali_kbase_gwt.c
index 32c9241..4914e24 100644
--- a/mali_kbase/mali_kbase_gwt.c
+++ b/mali_kbase/mali_kbase_gwt.c
@@ -61,9 +61,9 @@ static void kbase_gpu_gwt_setup_pages(struct kbase_context *kctx,
int kbase_gpu_gwt_start(struct kbase_context *kctx)
{
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
if (kctx->gwt_enabled) {
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return -EBUSY;
}
@@ -90,7 +90,7 @@ int kbase_gpu_gwt_start(struct kbase_context *kctx)
kbase_gpu_gwt_setup_pages(kctx, ~KBASE_REG_GPU_WR);
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return 0;
}
diff --git a/mali_kbase/mali_kbase_mem.c b/mali_kbase/mali_kbase_mem.c
index c07d520..9de0893 100644
--- a/mali_kbase/mali_kbase_mem.c
+++ b/mali_kbase/mali_kbase_mem.c
@@ -2293,7 +2293,7 @@ int kbase_mem_free(struct kbase_context *kctx, u64 gpu_addr)
__func__);
return -EINVAL;
}
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
if (gpu_addr >= BASE_MEM_COOKIE_BASE &&
gpu_addr < BASE_MEM_FIRST_FREE_ADDRESS) {
@@ -2333,7 +2333,7 @@ int kbase_mem_free(struct kbase_context *kctx, u64 gpu_addr)
}
out_unlock:
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return err;
}
@@ -3478,17 +3478,31 @@ void kbase_gpu_vm_lock(struct kbase_context *kctx)
KBASE_DEBUG_ASSERT(kctx != NULL);
mutex_lock(&kctx->reg_lock);
}
-
KBASE_EXPORT_TEST_API(kbase_gpu_vm_lock);
+void kbase_gpu_vm_lock_with_pmode_sync(struct kbase_context *kctx)
+{
+#if MALI_USE_CSF
+ down_read(&kctx->kbdev->csf.pmode_sync_sem);
+#endif
+ kbase_gpu_vm_lock(kctx);
+}
+
void kbase_gpu_vm_unlock(struct kbase_context *kctx)
{
KBASE_DEBUG_ASSERT(kctx != NULL);
mutex_unlock(&kctx->reg_lock);
}
-
KBASE_EXPORT_TEST_API(kbase_gpu_vm_unlock);
+void kbase_gpu_vm_unlock_with_pmode_sync(struct kbase_context *kctx)
+{
+ kbase_gpu_vm_unlock(kctx);
+#if MALI_USE_CSF
+ up_read(&kctx->kbdev->csf.pmode_sync_sem);
+#endif
+}
+
#if IS_ENABLED(CONFIG_DEBUG_FS)
struct kbase_jit_debugfs_data {
int (*func)(struct kbase_jit_debugfs_data *data);
@@ -4360,7 +4374,7 @@ struct kbase_va_region *kbase_jit_allocate(struct kbase_context *kctx,
}
}
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
mutex_lock(&kctx->jit_evict_lock);
/*
@@ -4442,7 +4456,7 @@ struct kbase_va_region *kbase_jit_allocate(struct kbase_context *kctx,
kbase_jit_done_phys_increase(kctx, needed_pages);
#endif /* MALI_JIT_PRESSURE_LIMIT_BASE */
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
if (ret < 0) {
/*
@@ -4507,7 +4521,7 @@ struct kbase_va_region *kbase_jit_allocate(struct kbase_context *kctx,
#endif /* MALI_JIT_PRESSURE_LIMIT_BASE */
mutex_unlock(&kctx->jit_evict_lock);
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
reg = kbase_mem_alloc(kctx, info->va_pages, info->commit_pages, info->extension,
&flags, &gpu_addr, mmu_sync_info);
@@ -4609,9 +4623,9 @@ void kbase_jit_free(struct kbase_context *kctx, struct kbase_va_region *reg)
u64 delta = old_pages - new_size;
if (delta) {
- mutex_lock(&kctx->reg_lock);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
kbase_mem_shrink(kctx, reg, old_pages - delta);
- mutex_unlock(&kctx->reg_lock);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
}
}
@@ -4718,8 +4732,7 @@ void kbase_jit_term(struct kbase_context *kctx)
struct kbase_va_region *walker;
/* Free all allocations for this context */
-
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
mutex_lock(&kctx->jit_evict_lock);
/* Free all allocations from the pool */
while (!list_empty(&kctx->jit_pool_head)) {
@@ -4762,7 +4775,7 @@ void kbase_jit_term(struct kbase_context *kctx)
WARN_ON(kctx->jit_phys_pages_to_be_allocated);
#endif
mutex_unlock(&kctx->jit_evict_lock);
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
/*
* Flush the freeing of allocations whose backing has been freed
diff --git a/mali_kbase/mali_kbase_mem.h b/mali_kbase/mali_kbase_mem.h
index aa67717..1a59706 100644
--- a/mali_kbase/mali_kbase_mem.h
+++ b/mali_kbase/mali_kbase_mem.h
@@ -1516,11 +1516,29 @@ int kbase_update_region_flags(struct kbase_context *kctx,
void kbase_gpu_vm_lock(struct kbase_context *kctx);
/**
+ * kbase_gpu_vm_lock_with_pmode_sync() - Wrapper of kbase_gpu_vm_lock.
+ * @kctx: KBase context
+ *
+ * Same as kbase_gpu_vm_lock for JM GPU.
+ * Additionally acquire P.mode read-write semaphore for CSF GPU.
+ */
+void kbase_gpu_vm_lock_with_pmode_sync(struct kbase_context *kctx);
+
+/**
* kbase_gpu_vm_unlock() - Release the per-context region list lock
* @kctx: KBase context
*/
void kbase_gpu_vm_unlock(struct kbase_context *kctx);
+/**
+ * kbase_gpu_vm_unlock_with_pmode_sync() - Wrapper of kbase_gpu_vm_unlock.
+ * @kctx: KBase context
+ *
+ * Same as kbase_gpu_vm_unlock for JM GPU.
+ * Additionally release P.mode read-write semaphore for CSF GPU.
+ */
+void kbase_gpu_vm_unlock_with_pmode_sync(struct kbase_context *kctx);
+
int kbase_alloc_phy_pages(struct kbase_va_region *reg, size_t vsize, size_t size);
/**
diff --git a/mali_kbase/mali_kbase_mem_linux.c b/mali_kbase/mali_kbase_mem_linux.c
index 1af833d..0c11b23 100644
--- a/mali_kbase/mali_kbase_mem_linux.c
+++ b/mali_kbase/mali_kbase_mem_linux.c
@@ -431,7 +431,7 @@ struct kbase_va_region *kbase_mem_alloc(struct kbase_context *kctx, u64 va_pages
}
reg->initial_commit = commit_pages;
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
if (reg->flags & KBASE_REG_PERMANENT_KERNEL_MAPPING) {
/* Permanent kernel mappings must happen as soon as
@@ -442,7 +442,7 @@ struct kbase_va_region *kbase_mem_alloc(struct kbase_context *kctx, u64 va_pages
int err = kbase_phy_alloc_mapping_init(kctx, reg, va_pages,
commit_pages);
if (err < 0) {
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
goto no_kern_mapping;
}
}
@@ -454,7 +454,7 @@ struct kbase_va_region *kbase_mem_alloc(struct kbase_context *kctx, u64 va_pages
/* Bind to a cookie */
if (bitmap_empty(kctx->cookies, BITS_PER_LONG)) {
dev_err(dev, "No cookies available for allocation!");
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
goto no_cookie;
}
/* return a cookie */
@@ -490,7 +490,7 @@ struct kbase_va_region *kbase_mem_alloc(struct kbase_context *kctx, u64 va_pages
if (kbase_gpu_mmap(kctx, reg, *gpu_va, va_pages, align,
mmu_sync_info) != 0) {
dev_warn(dev, "Failed to map memory on GPU");
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
goto no_mmap;
}
/* return real GPU VA */
@@ -508,7 +508,7 @@ struct kbase_va_region *kbase_mem_alloc(struct kbase_context *kctx, u64 va_pages
}
#endif /* MALI_JIT_PRESSURE_LIMIT_BASE */
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
#if MALI_USE_CSF
if (*flags & BASE_MEM_FIXABLE)
@@ -722,6 +722,13 @@ unsigned long kbase_mem_evictable_reclaim_scan_objects(struct shrinker *s,
kctx = container_of(s, struct kbase_context, reclaim);
+#if MALI_USE_CSF
+ if (!down_read_trylock(&kctx->kbdev->csf.pmode_sync_sem)) {
+ dev_warn(kctx->kbdev->dev,
+ "Can't shrink GPU memory when P.Mode entrance is in progress");
+ return 0;
+ }
+#endif
mutex_lock(&kctx->jit_evict_lock);
list_for_each_entry_safe(alloc, tmp, &kctx->evict_list, evict_node) {
@@ -761,7 +768,9 @@ unsigned long kbase_mem_evictable_reclaim_scan_objects(struct shrinker *s,
}
mutex_unlock(&kctx->jit_evict_lock);
-
+#if MALI_USE_CSF
+ up_read(&kctx->kbdev->csf.pmode_sync_sem);
+#endif
return freed;
}
@@ -1086,7 +1095,7 @@ int kbase_mem_flags_change(struct kbase_context *kctx, u64 gpu_addr, unsigned in
reg->flags = new_flags;
out_unlock:
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
up_write(kbase_mem_get_process_mmap_lock());
out:
return ret;
@@ -1885,7 +1894,7 @@ u64 kbase_mem_alias(struct kbase_context *kctx, u64 *flags, u64 stride,
if (!reg->gpu_alloc->imported.alias.aliased)
goto no_aliased_array;
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
/* validate and add src handles */
for (i = 0; i < nents; i++) {
@@ -1997,7 +2006,7 @@ u64 kbase_mem_alias(struct kbase_context *kctx, u64 *flags, u64 stride,
reg->flags &= ~KBASE_REG_FREE;
reg->flags &= ~KBASE_REG_GROWABLE;
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return gpu_va;
@@ -2008,7 +2017,7 @@ bad_handle:
* them is handled by putting reg's allocs, so no rollback of those
* actions is done here.
*/
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
no_aliased_array:
invalid_flags:
kbase_mem_phy_alloc_put(reg->cpu_alloc);
@@ -2119,7 +2128,7 @@ int kbase_mem_import(struct kbase_context *kctx, enum base_mem_import_type type,
if (!reg)
goto no_reg;
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
/* mmap needed to setup VA? */
if (*flags & (BASE_MEM_SAME_VA | BASE_MEM_NEED_MMAP)) {
@@ -2154,13 +2163,13 @@ int kbase_mem_import(struct kbase_context *kctx, enum base_mem_import_type type,
/* clear out private flags */
*flags &= ((1UL << BASE_MEM_FLAGS_NR_BITS) - 1);
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return 0;
no_gpu_va:
no_cookie:
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
kbase_mem_phy_alloc_put(reg->cpu_alloc);
kbase_mem_phy_alloc_put(reg->gpu_alloc);
kfree(reg);
@@ -2243,7 +2252,7 @@ int kbase_mem_commit(struct kbase_context *kctx, u64 gpu_addr, u64 new_pages)
}
down_write(kbase_mem_get_process_mmap_lock());
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
/* Validate the region */
reg = kbase_region_tracker_find_region_base_address(kctx, gpu_addr);
@@ -2347,7 +2356,7 @@ int kbase_mem_commit(struct kbase_context *kctx, u64 gpu_addr, u64 new_pages)
}
out_unlock:
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
if (read_locked)
up_read(kbase_mem_get_process_mmap_lock());
else
@@ -2432,7 +2441,7 @@ static void kbase_cpu_vm_close(struct vm_area_struct *vma)
KBASE_DEBUG_ASSERT(map->kctx);
KBASE_DEBUG_ASSERT(map->alloc);
- kbase_gpu_vm_lock(map->kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(map->kctx);
if (map->free_on_close) {
KBASE_DEBUG_ASSERT(kbase_bits_to_zone(map->region->flags) == SAME_VA_ZONE);
@@ -2446,7 +2455,7 @@ static void kbase_cpu_vm_close(struct vm_area_struct *vma)
list_del(&map->mappings_list);
kbase_va_region_alloc_put(map->kctx, map->region);
- kbase_gpu_vm_unlock(map->kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(map->kctx);
kbase_mem_phy_alloc_put(map->alloc);
kbase_file_dec_cpu_mapping_count(map->kctx->kfile);
@@ -2866,7 +2875,7 @@ int kbase_context_mmap(struct kbase_context *const kctx,
goto out;
}
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
if (vma->vm_pgoff == PFN_DOWN(BASE_MEM_MAP_TRACKING_HANDLE)) {
/* The non-mapped tracking helper page */
@@ -2901,12 +2910,12 @@ int kbase_context_mmap(struct kbase_context *const kctx,
#endif /* defined(CONFIG_MALI_VECTOR_DUMP) */
#if MALI_USE_CSF
case PFN_DOWN(BASEP_MEM_CSF_USER_REG_PAGE_HANDLE):
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
err = kbase_csf_cpu_mmap_user_reg_page(kctx, vma);
goto out;
case PFN_DOWN(BASEP_MEM_CSF_USER_IO_PAGES_HANDLE) ...
PFN_DOWN(BASE_MEM_COOKIE_BASE) - 1: {
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
rt_mutex_lock(&kctx->csf.lock);
err = kbase_csf_cpu_mmap_user_io_pages(kctx, vma);
rt_mutex_unlock(&kctx->csf.lock);
@@ -3007,7 +3016,7 @@ int kbase_context_mmap(struct kbase_context *const kctx,
}
#endif /* defined(CONFIG_MALI_VECTOR_DUMP) */
out_unlock:
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
out:
if (err)
dev_err(dev, "mmap failed %d\n", err);
diff --git a/mali_kbase/mali_kbase_mem_migrate.c b/mali_kbase/mali_kbase_mem_migrate.c
index f2014f6..4c2cc0f 100644
--- a/mali_kbase/mali_kbase_mem_migrate.c
+++ b/mali_kbase/mali_kbase_mem_migrate.c
@@ -225,7 +225,7 @@ static int kbasep_migrate_page_pt_mapped(struct page *old_page, struct page *new
* This blocks the CPU page fault handler from remapping pages.
* Only MCU's mmut is device wide, i.e. no corresponding kctx.
*/
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
ret = kbase_mmu_migrate_page(
as_tagged(page_to_phys(old_page)), as_tagged(page_to_phys(new_page)), old_dma_addr,
@@ -252,7 +252,7 @@ static int kbasep_migrate_page_pt_mapped(struct page *old_page, struct page *new
dma_unmap_page(kbdev->dev, new_dma_addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
/* Page fault handler for CPU mapping unblocked. */
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return ret;
}
@@ -291,7 +291,7 @@ static int kbasep_migrate_page_allocated_mapped(struct page *old_page, struct pa
/* Lock context to protect access to array of pages in physical allocation.
* This blocks the CPU page fault handler from remapping pages.
*/
- kbase_gpu_vm_lock(kctx);
+ kbase_gpu_vm_lock_with_pmode_sync(kctx);
/* Unmap the old physical range. */
unmap_mapping_range(kctx->kfile->filp->f_inode->i_mapping,
@@ -327,7 +327,7 @@ static int kbasep_migrate_page_allocated_mapped(struct page *old_page, struct pa
dma_unmap_page(kctx->kbdev->dev, new_dma_addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
/* Page fault handler for CPU mapping unblocked. */
- kbase_gpu_vm_unlock(kctx);
+ kbase_gpu_vm_unlock_with_pmode_sync(kctx);
return ret;
}