• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <lib/pan_device.h>
3 #include "pan_perf.h"
4 
main(void)5 int main(void) {
6         int fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
7 
8         if (fd < 0) {
9                 fprintf(stderr, "No panfrost device\n");
10                 exit(1);
11         }
12 
13         void *ctx = ralloc_context(NULL);
14         struct panfrost_perf *perf = rzalloc(ctx, struct panfrost_perf);
15 
16         struct panfrost_device dev = {};
17         panfrost_open_device(ctx, fd, &dev);
18 
19         panfrost_perf_init(perf, &dev);
20         int ret = panfrost_perf_enable(perf);
21 
22         if (ret < 0) {
23                 fprintf(stderr, "failed to enable counters (%d)\n", ret);
24                 fprintf(stderr, "try `# echo Y > /sys/module/panfrost/parameters/unstable_ioctls`\n");
25 
26                 exit(1);
27         }
28 
29         sleep(1);
30 
31         panfrost_perf_dump(perf);
32 
33         for (unsigned i = 0; i < perf->cfg->n_categories; ++i) {
34                 const struct panfrost_perf_category *cat = &perf->cfg->categories[i];
35                 printf("%s\n", cat->name);
36 
37                 for (unsigned j = 0; j < cat->n_counters; ++j) {
38                         const struct panfrost_perf_counter *ctr = &cat->counters[j];
39                         uint32_t val = panfrost_perf_counter_read(ctr, perf);
40                         printf("%s (%s): %u\n", ctr->name, ctr->symbol_name, val);
41                 }
42 
43                 printf("\n");
44         }
45 
46         if (panfrost_perf_disable(perf) < 0) {
47                 fprintf(stderr, "failed to disable counters\n");
48                 exit(1);
49         }
50 
51         panfrost_close_device(&dev);
52 }
53