summaryrefslogtreecommitdiff
path: root/mali_kbase/context
diff options
context:
space:
mode:
authorJörg Wagner <jorwag@google.com>2023-08-31 19:15:13 +0000
committerJörg Wagner <jorwag@google.com>2023-09-01 09:13:55 +0000
commitb6fd708b3a4da86a196a61592ea3585f1aca7313 (patch)
tree1cbe3029a45bf9869c17a5b6954e5ae074b44ac8 /mali_kbase/context
parent46edf1b5965d872c5f8a09c6dc3dcbff58f78a92 (diff)
parente61eb93296e9f940b32d4ad4b0c3a5557cbeaf17 (diff)
downloadgpu-b6fd708b3a4da86a196a61592ea3585f1aca7313.tar.gz
Merge r44p1-00dev3 from partner/upstream into android13-gs-pixel-5.10-udc-qpr1
Bug: 290882327 Change-Id: I90723cbaa3f294431087587fd8025f0688e51bf2
Diffstat (limited to 'mali_kbase/context')
-rw-r--r--mali_kbase/context/backend/mali_kbase_context_csf.c18
-rw-r--r--mali_kbase/context/backend/mali_kbase_context_jm.c17
-rw-r--r--mali_kbase/context/mali_kbase_context.c6
-rw-r--r--mali_kbase/context/mali_kbase_context.h7
4 files changed, 36 insertions, 12 deletions
diff --git a/mali_kbase/context/backend/mali_kbase_context_csf.c b/mali_kbase/context/backend/mali_kbase_context_csf.c
index 9aa661a..45a5a6c 100644
--- a/mali_kbase/context/backend/mali_kbase_context_csf.c
+++ b/mali_kbase/context/backend/mali_kbase_context_csf.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
/*
*
- * (C) COPYRIGHT 2019-2022 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2019-2023 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -124,7 +124,7 @@ struct kbase_context *kbase_create_context(struct kbase_device *kbdev,
bool is_compat,
base_context_create_flags const flags,
unsigned long const api_version,
- struct file *const filp)
+ struct kbase_file *const kfile)
{
struct kbase_context *kctx;
unsigned int i = 0;
@@ -143,9 +143,11 @@ struct kbase_context *kbase_create_context(struct kbase_device *kbdev,
kctx->kbdev = kbdev;
kctx->api_version = api_version;
- kctx->filp = filp;
+ kctx->kfile = kfile;
kctx->create_flags = flags;
+ memcpy(kctx->comm, current->comm, sizeof(current->comm));
+
if (is_compat)
kbase_ctx_flag_set(kctx, KCTX_COMPAT);
#if defined(CONFIG_64BIT)
@@ -213,6 +215,16 @@ void kbase_destroy_context(struct kbase_context *kctx)
kctx->tgid, kctx->id);
}
+ /* Have synchronized against the System suspend and incremented the
+ * pm.active_count. So any subsequent invocation of System suspend
+ * callback would get blocked.
+ * If System suspend callback was already in progress then the above loop
+ * would have waited till the System resume callback has begun.
+ * So wait for the System resume callback to also complete as we want to
+ * avoid context termination during System resume also.
+ */
+ wait_event(kbdev->pm.resume_wait, !kbase_pm_is_resuming(kbdev));
+
kbase_mem_pool_group_mark_dying(&kctx->mem_pools);
kbase_context_term_partial(kctx, ARRAY_SIZE(context_init));
diff --git a/mali_kbase/context/backend/mali_kbase_context_jm.c b/mali_kbase/context/backend/mali_kbase_context_jm.c
index 7acb3f6..39595d9 100644
--- a/mali_kbase/context/backend/mali_kbase_context_jm.c
+++ b/mali_kbase/context/backend/mali_kbase_context_jm.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
/*
*
- * (C) COPYRIGHT 2019-2022 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2019-2023 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -179,7 +179,7 @@ struct kbase_context *kbase_create_context(struct kbase_device *kbdev,
bool is_compat,
base_context_create_flags const flags,
unsigned long const api_version,
- struct file *const filp)
+ struct kbase_file *const kfile)
{
struct kbase_context *kctx;
unsigned int i = 0;
@@ -198,7 +198,7 @@ struct kbase_context *kbase_create_context(struct kbase_device *kbdev,
kctx->kbdev = kbdev;
kctx->api_version = api_version;
- kctx->filp = filp;
+ kctx->kfile = kfile;
kctx->create_flags = flags;
if (is_compat)
@@ -258,6 +258,17 @@ void kbase_destroy_context(struct kbase_context *kctx)
wait_event(kbdev->pm.resume_wait,
!kbase_pm_is_suspending(kbdev));
}
+
+ /* Have synchronized against the System suspend and incremented the
+ * pm.active_count. So any subsequent invocation of System suspend
+ * callback would get blocked.
+ * If System suspend callback was already in progress then the above loop
+ * would have waited till the System resume callback has begun.
+ * So wait for the System resume callback to also complete as we want to
+ * avoid context termination during System resume also.
+ */
+ wait_event(kbdev->pm.resume_wait, !kbase_pm_is_resuming(kbdev));
+
#ifdef CONFIG_MALI_ARBITER_SUPPORT
atomic_dec(&kbdev->pm.gpu_users_waiting);
#endif /* CONFIG_MALI_ARBITER_SUPPORT */
diff --git a/mali_kbase/context/mali_kbase_context.c b/mali_kbase/context/mali_kbase_context.c
index 84d56f7..70941ef 100644
--- a/mali_kbase/context/mali_kbase_context.c
+++ b/mali_kbase/context/mali_kbase_context.c
@@ -190,7 +190,7 @@ int kbase_context_common_init(struct kbase_context *kctx)
kctx->pid = current->pid;
/* Check if this is a Userspace created context */
- if (likely(kctx->filp)) {
+ if (likely(kctx->kfile)) {
struct pid *pid_struct;
rcu_read_lock();
@@ -264,7 +264,7 @@ int kbase_context_common_init(struct kbase_context *kctx)
if (err) {
dev_err(kctx->kbdev->dev,
"(err:%d) failed to insert kctx to kbase_process", err);
- if (likely(kctx->filp)) {
+ if (likely(kctx->kfile)) {
mmdrop(kctx->process_mm);
put_task_struct(kctx->task);
}
@@ -356,7 +356,7 @@ void kbase_context_common_term(struct kbase_context *kctx)
kbase_remove_kctx_from_process(kctx);
mutex_unlock(&kctx->kbdev->kctx_list_lock);
- if (likely(kctx->filp)) {
+ if (likely(kctx->kfile)) {
mmdrop(kctx->process_mm);
put_task_struct(kctx->task);
}
diff --git a/mali_kbase/context/mali_kbase_context.h b/mali_kbase/context/mali_kbase_context.h
index 7c90e27..22cb00c 100644
--- a/mali_kbase/context/mali_kbase_context.h
+++ b/mali_kbase/context/mali_kbase_context.h
@@ -56,8 +56,9 @@ void kbase_context_debugfs_term(struct kbase_context *const kctx);
* BASEP_CONTEXT_CREATE_KERNEL_FLAGS.
* @api_version: Application program interface version, as encoded in
* a single integer by the KBASE_API_VERSION macro.
- * @filp: Pointer to the struct file corresponding to device file
- * /dev/malixx instance, passed to the file's open method.
+ * @kfile: Pointer to the object representing the /dev/malixx device
+ * file instance. Shall be passed as NULL for internally created
+ * contexts.
*
* Up to one context can be created for each client that opens the device file
* /dev/malixx. Context creation is deferred until a special ioctl() system call
@@ -69,7 +70,7 @@ struct kbase_context *
kbase_create_context(struct kbase_device *kbdev, bool is_compat,
base_context_create_flags const flags,
unsigned long api_version,
- struct file *filp);
+ struct kbase_file *const kfile);
/**
* kbase_destroy_context - Destroy a kernel base context.