summaryrefslogtreecommitdiff
path: root/mali_kbase/context
diff options
context:
space:
mode:
authorJörg Wagner <jorwag@google.com>2023-08-01 13:38:22 +0000
committerJörg Wagner <jorwag@google.com>2023-08-03 09:29:34 +0000
commitdacf004cc8a4b35f5a0fb5fb67246f9cc8fdaafb (patch)
tree07484dccba43bb2c2a07626c00154751f318bd47 /mali_kbase/context
parentbce5281a0408a175137c08dc93028e2a2c0fb69b (diff)
downloadgpu-dacf004cc8a4b35f5a0fb5fb67246f9cc8fdaafb.tar.gz
Update KMD to 'mini release: update r44p1-01bet1 to r44p1-00dev2'
Provenance: ipdelivery@d10c137c7691a470b8b33786aec4965315db4561 Change-Id: I4fbcc669d3b8e36c8288c91fdddd8b79258b6635
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.c21
-rw-r--r--mali_kbase/context/mali_kbase_context.c6
-rw-r--r--mali_kbase/context/mali_kbase_context.h7
4 files changed, 38 insertions, 14 deletions
diff --git a/mali_kbase/context/backend/mali_kbase_context_csf.c b/mali_kbase/context/backend/mali_kbase_context_csf.c
index 07d277b..8b74de0 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
@@ -121,7 +121,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;
@@ -140,9 +140,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)
@@ -198,6 +200,16 @@ void kbase_destroy_context(struct kbase_context *kctx)
!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));
+
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 995a08e..2a983fb 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
@@ -158,11 +158,11 @@ static const struct kbase_context_init context_init[] = {
kbase_debug_job_fault_context_term,
"Job fault context initialization failed" },
#endif
+ { kbasep_platform_context_init, kbasep_platform_context_term,
+ "Platform callback for kctx initialization failed" },
{ NULL, kbase_context_flush_jobs, NULL },
{ kbase_context_add_to_dev_list, kbase_context_remove_from_dev_list,
"Adding kctx to device failed" },
- { kbasep_platform_context_init, kbasep_platform_context_term,
- "Platform callback for kctx initialization failed" },
};
static void kbase_context_term_partial(
@@ -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 b8036b8..0164e74 100644
--- a/mali_kbase/context/mali_kbase_context.c
+++ b/mali_kbase/context/mali_kbase_context.c
@@ -143,7 +143,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();
@@ -217,7 +217,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);
}
@@ -307,7 +307,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.