summaryrefslogtreecommitdiff
path: root/mali_pixel
diff options
context:
space:
mode:
authorErik Staats <estaats@google.com>2021-10-07 12:27:10 -0700
committerErik Staats <estaats@google.com>2021-10-08 20:59:58 +0000
commitc17de739ab8e96c26c61444041585b61801163bb (patch)
treead83b71993171876248592c91b9ace54b8118ad7 /mali_pixel
parent66f97185a17de026db3685d872fc924ede192bcd (diff)
downloadgpu-c17de739ab8e96c26c61444041585b61801163bb.tar.gz
Add stubbed protected memory allocator driver.
Bug: 194627754 Test: Verified that device boots fully and stubbed protected memory allocated driver is not available. Test: Added protected memory allocator driver to the device tree and validated that it's probed but not ready. Test: Test: See details in testing done comment in https://partner-android-review.googlesource.com/2064216 . Change-Id: I772360bb68d3429267efa567f1958041fb0a41fe
Diffstat (limited to 'mali_pixel')
-rw-r--r--mali_pixel/Kbuild5
-rw-r--r--mali_pixel/Kconfig7
-rw-r--r--mali_pixel/Makefile1
-rw-r--r--mali_pixel/mali_pixel_mod.c14
-rw-r--r--mali_pixel/mali_pixel_mod.h4
-rw-r--r--mali_pixel/protected_memory_allocator.c40
6 files changed, 71 insertions, 0 deletions
diff --git a/mali_pixel/Kbuild b/mali_pixel/Kbuild
index b38d083..14aa628 100644
--- a/mali_pixel/Kbuild
+++ b/mali_pixel/Kbuild
@@ -23,6 +23,7 @@ src:=$(if $(patsubst /%,,$(src)),$(srctree)/$(src),$(src))
CONFIG_MALI_MEMORY_GROUP_MANAGER ?= m
CONFIG_MALI_PRIORITY_CONTROL_MANAGER ?= m
+CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR ?= m
CONFIG_MALI_PIXEL_STATS ?= m
mali_pixel-objs :=
@@ -40,6 +41,10 @@ ifeq ($(CONFIG_MALI_PRIORITY_CONTROL_MANAGER),m)
DEFINES += -DCONFIG_MALI_PRIORITY_CONTROL_MANAGER
mali_pixel-objs += priority_control_manager.o
endif
+ifeq ($(CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR),m)
+ DEFINES += -DCONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR
+ mali_pixel-objs += protected_memory_allocator.o
+endif
# Use our defines when compiling, and include mali platform module headers
ccflags-y += $(DEFINES) -I$(src)/../common/include
diff --git a/mali_pixel/Kconfig b/mali_pixel/Kconfig
index 2406990..60ec64f 100644
--- a/mali_pixel/Kconfig
+++ b/mali_pixel/Kconfig
@@ -30,3 +30,10 @@ config MALI_PRIORITY_CONTROL_MANAGER
help
This option enables an implementation of a priority control manager
for determining the target GPU scheduling priority of a process.
+
+config MALI_PROTECTED_MEMORY_ALLOCATOR
+ tristate "MALI_PROTECTED_MEMORY_ALLOCATOR"
+ help
+ This option enables an implementation of a protected memory allocator
+ for allocation and release of pages of protected memory for use by
+ Mali GPU device drivers.
diff --git a/mali_pixel/Makefile b/mali_pixel/Makefile
index 57510ee..8d80c07 100644
--- a/mali_pixel/Makefile
+++ b/mali_pixel/Makefile
@@ -8,6 +8,7 @@ M ?= $(shell pwd)
KBUILD_OPTIONS += CONFIG_MALI_MEMORY_GROUP_MANAGER=m
KBUILD_OPTIONS += CONFIG_MALI_PRIORITY_CONTROL_MANAGER=m
+KBUILD_OPTIONS += CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR=m
KBUILD_OPTIONS += CONFIG_MALI_PIXEL_STATS=n
KBUILD_OPTIONS += $(KBUILD_EXTRA) # Extra config if any
diff --git a/mali_pixel/mali_pixel_mod.c b/mali_pixel/mali_pixel_mod.c
index 8f4442c..22f6ede 100644
--- a/mali_pixel/mali_pixel_mod.c
+++ b/mali_pixel/mali_pixel_mod.c
@@ -30,8 +30,19 @@ static int __init mali_pixel_init(void)
if (ret)
goto fail_pcm;
+#ifdef CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR
+ ret = platform_driver_register(&protected_memory_allocator_driver);
+#endif
+ if (ret)
+ goto fail_pma;
+
goto exit;
+fail_pma:
+#ifdef CONFIG_MALI_PRIORITY_CONTROL_MANAGER
+ platform_driver_unregister(&priority_control_manager_driver);
+#endif
+
fail_pcm:
#ifdef CONFIG_MALI_MEMORY_GROUP_MANAGER
platform_driver_unregister(&memory_group_manager_driver);
@@ -49,6 +60,9 @@ module_init(mali_pixel_init);
static void __exit mali_pixel_exit(void)
{
+#ifdef CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR
+ platform_driver_unregister(&protected_memory_allocator_driver);
+#endif
#ifdef CONFIG_MALI_PRIORITY_CONTROL_MANAGER
platform_driver_unregister(&priority_control_manager_driver);
#endif
diff --git a/mali_pixel/mali_pixel_mod.h b/mali_pixel/mali_pixel_mod.h
index 163fd99..3a43c9e 100644
--- a/mali_pixel/mali_pixel_mod.h
+++ b/mali_pixel/mali_pixel_mod.h
@@ -10,6 +10,10 @@ extern struct platform_driver memory_group_manager_driver;
extern struct platform_driver priority_control_manager_driver;
#endif
+#ifdef CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR
+extern struct platform_driver protected_memory_allocator_driver;
+#endif
+
#ifdef CONFIG_MALI_PIXEL_STATS
extern int mali_pixel_init_pixel_stats(void);
#endif
diff --git a/mali_pixel/protected_memory_allocator.c b/mali_pixel/protected_memory_allocator.c
new file mode 100644
index 0000000..f037891
--- /dev/null
+++ b/mali_pixel/protected_memory_allocator.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Protected memory allocator driver for allocation and release of pages of
+ * protected memory for use by Mali GPU device drivers.
+ */
+
+#include <linux/of.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+static int protected_memory_allocator_probe(struct platform_device *pdev)
+{
+ dev_info(&pdev->dev, "Protected memory allocator not implemented\n");
+ return -ENODEV;
+}
+
+static int protected_memory_allocator_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static const struct of_device_id protected_memory_allocator_dt_ids[] = {
+ { .compatible = "arm,protected-memory-allocator" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, protected_memory_allocator_dt_ids);
+
+struct platform_driver protected_memory_allocator_driver = {
+ .probe = protected_memory_allocator_probe,
+ .remove = protected_memory_allocator_remove,
+ .driver = {
+ .name = "mali-pma",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(protected_memory_allocator_dt_ids),
+ .suppress_bind_attrs = true,
+ }
+};
+