For security reasons Mali400 driver does not allow userspace code
to map any arbitrary physical memory buffers via MALI_IOC_MEM_MAP_EXT
ioctl. So the address of the framebuffer needs to be initialized
in the driver.
Instead of hardcoding framebuffer address/size constants in
sunxi specific config.h, use sunxi platform file to register
this information.
Signed-off-by: Siarhei Siamashka <
siarhei....@gmail.com>
---
.../mali/mali/arch-ca8-virtex820-m400-1/config.h | 7 -------
.../mali/mali/platform/mali400-pmu/mali_platform.c | 24 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/mali/mali/arch-ca8-virtex820-m400-1/config.h b/drivers/gpu/mali/mali/arch-ca8-virtex820-m400-1/config.h
index 6cc6a47..baab12e 100644
--- a/drivers/gpu/mali/mali/arch-ca8-virtex820-m400-1/config.h
+++ b/drivers/gpu/mali/mali/arch-ca8-virtex820-m400-1/config.h
@@ -59,13 +59,6 @@ static _mali_osk_resource_t arch_configuration [] =
.flags = _MALI_CPU_WRITEABLE | _MALI_CPU_READABLE | _MALI_MMU_READABLE | _MALI_MMU_WRITEABLE
},
{
- .type = MEM_VALIDATION,
- .description = "Framebuffer",
- .base = 0x5A000000,
- .size = 32 * 1024 * 1024, /*32M*/
- .flags = _MALI_CPU_WRITEABLE | _MALI_CPU_READABLE | _MALI_MMU_READABLE | _MALI_MMU_WRITEABLE
- },
- {
.type = OS_MEMORY,
.description = "OS Memory",
.alloc_order = 1, /* Lowest preference for this memory */
diff --git a/drivers/gpu/mali/mali/platform/mali400-pmu/mali_platform.c b/drivers/gpu/mali/mali/platform/mali400-pmu/mali_platform.c
index 5161faa..d482720 100644
--- a/drivers/gpu/mali/mali/platform/mali400-pmu/mali_platform.c
+++ b/drivers/gpu/mali/mali/platform/mali400-pmu/mali_platform.c
@@ -15,6 +15,7 @@
#include "mali_kernel_common.h"
#include "mali_osk.h"
#include "mali_platform.h"
+#include "mali_mem_validation.h"
#include <linux/module.h>
#include <linux/clk.h>
@@ -22,6 +23,11 @@
#include <mach/clock.h>
#include <plat/sys_config.h>
+#ifdef CONFIG_FB_SUNXI_RESERVED_MEM
+extern unsigned long fb_start;
+extern unsigned long fb_size;
+static int fb_validation_range_added;
+#endif
int mali_clk_div = 3;
module_param(mali_clk_div, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH);
@@ -37,6 +43,24 @@ _mali_osk_errcode_t mali_platform_init(void)
int clk_div;
int mali_used = 0;
+#ifdef CONFIG_FB_SUNXI_RESERVED_MEM
+ /* mali_platform_init() may be called multiple times,
+ but we only need to set the validation range once */
+ if (!fb_validation_range_added) {
+ _mali_osk_resource_t fb_resource = {
+ .type = MEM_VALIDATION,
+ .description = "Framebuffer",
+ .base = fb_start,
+ .size = fb_size,
+ .flags = 0
+ };
+ mali_mem_validation_add_range(&fb_resource);
+ MALI_PRINT(("permit MALI_IOC_MEM_MAP_EXT ioctl for framebuffer"
+ " (paddr=0x%08X, size=%d)\n", fb_start, fb_size));
+ fb_validation_range_added = 1;
+ }
+#endif
+
//get mali ahb clock
h_ahb_mali = clk_get(NULL, "ahb_mali");
if(!h_ahb_mali){
--
1.8.1.5