Skip to content

Commit

Permalink
Safeguard against 'sunxi_no_mali_mem_reserve' kernel cmdline
Browse files Browse the repository at this point in the history
Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  • Loading branch information
ssvb committed Apr 16, 2014
1 parent 00c2439 commit 75eccfd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,31 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int textured_cube_main(void);
int memtester_main(int argc, char *argv[]);

static void check_kernel_cmdline(void)
{
char buffer[1024];
FILE *f = fopen("/proc/cmdline", "r");
if (!f) {
printf("Warning: can't open /proc/cmdline\n");
return;
}
if (fgets(buffer, sizeof(buffer), f) &&
strstr(buffer, "sunxi_no_mali_mem_reserve"))
{
fprintf(stderr, "Please remove 'sunxi_no_mali_mem_reserve' option from\n");
fprintf(stderr, "your kernel command line. Otherwise the mali kernel\n");
fprintf(stderr, "driver may be non-functional and actually knock down\n");
fprintf(stderr, "your system with some old linux-sunxi kernels.\n");
abort();
}
fclose(f);
}

static void *lima_thread(void *threadid)
{
textured_cube_main();
Expand All @@ -41,6 +62,8 @@ static void start_lima_thread(void)
{
pthread_t th;

check_kernel_cmdline();

if (system("modprobe mali >/dev/null 2>&1")) {
fprintf(stderr, "Failed to 'modprobe mali'.\n");
abort();
Expand Down

0 comments on commit 75eccfd

Please sign in to comment.