summaryrefslogtreecommitdiff
path: root/mali_kbase/context/backend
diff options
context:
space:
mode:
authorSidath Senanayake <sidaths@google.com>2020-11-25 16:47:38 +0000
committerSidath Senanayake <sidaths@google.com>2020-11-25 16:47:38 +0000
commit86ef494fcee7e40a37d17b101883d8beea42acf2 (patch)
tree8ae28a633b3f5b2b117edef6138ae82571155312 /mali_kbase/context/backend
parentef7db1a858a7c156d6310d11d04efbaf7e216bf6 (diff)
parent72f2457ff7355ff0389efe5bc9cec3365362d8c4 (diff)
downloadgpu-86ef494fcee7e40a37d17b101883d8beea42acf2.tar.gz
Merge r27p0 from upstream into android-gs-pixel-mainline
This commit updates the Mali KMD to version r27p0 from commit 72f2457ff7355ff0389efe5bc9cec3365362d8c4 Bug: 171747612 Change-Id: Ida619c400a9652ebbbc871e2c973d3c78fc5de62
Diffstat (limited to 'mali_kbase/context/backend')
-rw-r--r--mali_kbase/context/backend/mali_kbase_context_csf.c177
-rw-r--r--mali_kbase/context/backend/mali_kbase_context_jm.c53
2 files changed, 203 insertions, 27 deletions
diff --git a/mali_kbase/context/backend/mali_kbase_context_csf.c b/mali_kbase/context/backend/mali_kbase_context_csf.c
new file mode 100644
index 0000000..7c68eb2
--- /dev/null
+++ b/mali_kbase/context/backend/mali_kbase_context_csf.c
@@ -0,0 +1,177 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *
+ * (C) COPYRIGHT 2019-2020 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
+ * Foundation, and any use by you of this program is subject to the terms
+ * of such GNU licence.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ */
+
+/*
+ * Base kernel context APIs for CSF GPUs
+ */
+
+#include <context/mali_kbase_context_internal.h>
+#include <gpu/mali_kbase_gpu_regmap.h>
+#include <mali_kbase.h>
+#include <mali_kbase_ctx_sched.h>
+#include <mali_kbase_dma_fence.h>
+#include <mali_kbase_mem_linux.h>
+#include <mali_kbase_mem_pool_group.h>
+#include <mmu/mali_kbase_mmu.h>
+#include <tl/mali_kbase_timeline.h>
+#include <tl/mali_kbase_tracepoints.h>
+
+#ifdef CONFIG_DEBUG_FS
+#include <csf/mali_kbase_csf_csg_debugfs.h>
+#include <csf/mali_kbase_csf_kcpu_debugfs.h>
+#include <csf/mali_kbase_csf_tiler_heap_debugfs.h>
+#include <mali_kbase_debug_mem_view.h>
+#include <mali_kbase_mem_pool_debugfs.h>
+
+void kbase_context_debugfs_init(struct kbase_context *const kctx)
+{
+ kbase_debug_mem_view_init(kctx);
+ kbase_mem_pool_debugfs_init(kctx->kctx_dentry, kctx);
+ kbase_jit_debugfs_init(kctx);
+ kbase_csf_queue_group_debugfs_init(kctx);
+ kbase_csf_kcpu_debugfs_init(kctx);
+ kbase_csf_tiler_heap_debugfs_init(kctx);
+}
+KBASE_EXPORT_SYMBOL(kbase_context_debugfs_init);
+
+void kbase_context_debugfs_term(struct kbase_context *const kctx)
+{
+ debugfs_remove_recursive(kctx->kctx_dentry);
+}
+KBASE_EXPORT_SYMBOL(kbase_context_debugfs_term);
+#else
+void kbase_context_debugfs_init(struct kbase_context *const kctx)
+{
+ CSTD_UNUSED(kctx);
+}
+KBASE_EXPORT_SYMBOL(kbase_context_debugfs_init);
+
+void kbase_context_debugfs_term(struct kbase_context *const kctx)
+{
+ CSTD_UNUSED(kctx);
+}
+KBASE_EXPORT_SYMBOL(kbase_context_debugfs_term);
+#endif /* CONFIG_DEBUG_FS */
+
+static const struct kbase_context_init context_init[] = {
+ {kbase_context_common_init, kbase_context_common_term, NULL},
+ {kbase_context_mem_pool_group_init, kbase_context_mem_pool_group_term,
+ "Memory pool goup initialization failed"},
+ {kbase_mem_evictable_init, kbase_mem_evictable_deinit,
+ "Memory evictable initialization failed"},
+ {kbase_context_mmu_init, kbase_context_mmu_term,
+ "MMU initialization failed"},
+ {kbase_context_mem_alloc_page, kbase_context_mem_pool_free,
+ "Memory alloc page failed"},
+ {kbase_region_tracker_init, kbase_region_tracker_term,
+ "Region tracker initialization failed"},
+ {kbase_sticky_resource_init, kbase_context_sticky_resource_term,
+ "Sticky resource initialization failed"},
+ {kbase_jit_init, kbase_jit_term,
+ "JIT initialization failed"},
+ {kbase_csf_ctx_init, kbase_csf_ctx_term,
+ "CSF context initialization failed"},
+};
+
+static void kbase_context_term_partial(
+ struct kbase_context *kctx,
+ unsigned int i)
+{
+ while (i-- > 0) {
+ if (context_init[i].term)
+ context_init[i].term(kctx);
+ }
+}
+
+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_context *kctx;
+ unsigned int i = 0;
+
+ if (WARN_ON(!kbdev))
+ return NULL;
+
+ /* Validate flags */
+ if (WARN_ON(flags != (flags & BASEP_CONTEXT_CREATE_KERNEL_FLAGS)))
+ return NULL;
+
+ /* zero-inited as lot of code assume it's zero'ed out on create */
+ kctx = vzalloc(sizeof(*kctx));
+ if (WARN_ON(!kctx))
+ return NULL;
+
+ kctx->kbdev = kbdev;
+ kctx->api_version = api_version;
+ kctx->filp = filp;
+ kctx->create_flags = flags;
+
+ if (is_compat)
+ kbase_ctx_flag_set(kctx, KCTX_COMPAT);
+#if defined(CONFIG_64BIT)
+ else
+ kbase_ctx_flag_set(kctx, KCTX_FORCE_SAME_VA);
+#endif /* !defined(CONFIG_64BIT) */
+
+ for (i = 0; i < ARRAY_SIZE(context_init); i++) {
+ int err = context_init[i].init(kctx);
+
+ if (err) {
+ dev_err(kbdev->dev, "%s error = %d\n",
+ context_init[i].err_mes, err);
+ kbase_context_term_partial(kctx, i);
+ return NULL;
+ }
+ }
+
+ return kctx;
+}
+KBASE_EXPORT_SYMBOL(kbase_create_context);
+
+void kbase_destroy_context(struct kbase_context *kctx)
+{
+ struct kbase_device *kbdev;
+
+ if (WARN_ON(!kctx))
+ return;
+
+ kbdev = kctx->kbdev;
+ if (WARN_ON(!kbdev))
+ return;
+
+ /* Ensure the core is powered up for the destroy process
+ * A suspend won't happen here, because we're in a syscall
+ * from a userspace thread.
+ */
+ kbase_pm_context_active(kbdev);
+
+ kbase_mem_pool_group_mark_dying(&kctx->mem_pools);
+
+ kbase_context_term_partial(kctx, ARRAY_SIZE(context_init));
+
+ kbase_pm_context_idle(kbdev);
+}
+KBASE_EXPORT_SYMBOL(kbase_destroy_context);
diff --git a/mali_kbase/context/backend/mali_kbase_context_jm.c b/mali_kbase/context/backend/mali_kbase_context_jm.c
index c9d65fc..7b65354 100644
--- a/mali_kbase/context/backend/mali_kbase_context_jm.c
+++ b/mali_kbase/context/backend/mali_kbase_context_jm.c
@@ -115,33 +115,32 @@ static int kbase_context_submit_check(struct kbase_context *kctx)
}
static const struct kbase_context_init context_init[] = {
- {kbase_context_common_init, kbase_context_common_term, NULL},
- {kbase_context_mem_pool_group_init, kbase_context_mem_pool_group_term,
- "Memory pool goup initialization failed"},
- {kbase_mem_evictable_init, kbase_mem_evictable_deinit,
- "Memory evictable initialization failed"},
- {kbasep_js_kctx_init, kbasep_js_kctx_term,
- "JS kctx initialization failed"},
- {kbase_jd_init, kbase_jd_exit,
- "JD initialization failed"},
- {kbase_event_init, kbase_event_cleanup,
- "Event initialization failed"},
- {kbase_dma_fence_init, kbase_dma_fence_term,
- "DMA fence initialization failed"},
- {kbase_context_mmu_init, kbase_context_mmu_term,
- "MMU initialization failed"},
- {kbase_context_mem_alloc_page, kbase_context_mem_pool_free,
- "Memory alloc page failed"},
- {kbase_region_tracker_init, kbase_region_tracker_term,
- "Region tracker initialization failed"},
- {kbase_sticky_resource_init, kbase_context_sticky_resource_term,
- "Sticky resource initialization failed"},
- {kbase_jit_init, kbase_jit_term,
- "JIT initialization failed"},
- {kbase_context_kbase_kinstr_jm_init, kbase_context_kbase_kinstr_jm_term,
- "JM instrumentation initialization failed"},
- {kbase_context_kbase_timer_setup, NULL, NULL},
- {kbase_context_submit_check, NULL, NULL},
+ { kbase_context_common_init, kbase_context_common_term, NULL },
+ { kbase_dma_fence_init, kbase_dma_fence_term,
+ "DMA fence initialization failed" },
+ { kbase_context_mem_pool_group_init, kbase_context_mem_pool_group_term,
+ "Memory pool goup initialization failed" },
+ { kbase_mem_evictable_init, kbase_mem_evictable_deinit,
+ "Memory evictable initialization failed" },
+ { kbase_context_mmu_init, kbase_context_mmu_term,
+ "MMU initialization failed" },
+ { kbase_context_mem_alloc_page, kbase_context_mem_pool_free,
+ "Memory alloc page failed" },
+ { kbase_region_tracker_init, kbase_region_tracker_term,
+ "Region tracker initialization failed" },
+ { kbase_sticky_resource_init, kbase_context_sticky_resource_term,
+ "Sticky resource initialization failed" },
+ { kbase_jit_init, kbase_jit_term, "JIT initialization failed" },
+ { kbase_context_kbase_kinstr_jm_init,
+ kbase_context_kbase_kinstr_jm_term,
+ "JM instrumentation initialization failed" },
+ { kbase_context_kbase_timer_setup, NULL, NULL },
+ { kbase_event_init, kbase_event_cleanup,
+ "Event initialization failed" },
+ { kbasep_js_kctx_init, kbasep_js_kctx_term,
+ "JS kctx initialization failed" },
+ { kbase_jd_init, kbase_jd_exit, "JD initialization failed" },
+ { kbase_context_submit_check, NULL, NULL },
};
static void kbase_context_term_partial(