-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmali-memtester.c
75 lines (64 loc) · 1.74 KB
/
mali-memtester.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* mali-memtester version 0.1
*
* Memory Testing tool, based on https://github.com/ssvb/lima-memtester but
* using MALI instead of LIMA
*
* https://github.com/dimitar-kunchev/mali-memtester
*
* Copyright (C) 2018 Dimitar Kunchev <d.kunchev@gmail.com>
* Licensed under the terms of the GNU General Public License version 2 (only).
* See the file COPYING for details.
*
*/
#include <pthread.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include "textured-cube.h"
#include "memtester-4.3.0/memtester.h"
int threads_stop = 0;
void *fb_unblank_thread(void *data) {
int fd, ret;
fd = open("/dev/fb0", O_RDWR);
assert(fd != -1);
while (!threads_stop) {
ret = ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK);
assert(!ret);
sleep(1);
}
close(fd);
return 0;
}
static void *cube_thread(void *threadid)
{
textured_cube_main(&threads_stop);
if (threads_stop == 0) {
/* If we reach here, something bad has happened */
abort();
}
return NULL;
}
int main(int argc, char **argv) {
printf("This is a simple textured cube demo from the mali driver and\n");
printf("a memtester. Both combined in a single program. The mali400\n");
printf("hardware is only used to stress RAM in the background. But\n");
printf("this happens to significantly increase chances of exposing\n");
printf("memory stability related problems.\n\n");
if (argc > 1) {
pthread_t th1, th2;
pthread_create(&th1, NULL, cube_thread, NULL);
pthread_create(&th2, NULL, fb_unblank_thread, NULL);
sleep(1);
printf("\n");
int ec = memtester_main(argc, argv);
// printf("Memtester completed, %d\n", ec);
threads_stop = 1;
pthread_join(th2, NULL);
// printf("TH2 done\n");
pthread_join(th1, NULL);
// printf("TH1 done\n");
return ec;
} else {
return 0;
}
}