d53828dc0b6f693b7bccb6bc8fb151ba90854d99
2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <arpa/inet.h>
36 #include <sys/types.h>
42 #include <libconfig.h>
46 #include "drm/freedreno_drmif.h"
47 #include "drm/freedreno_ringbuffer.h"
49 #include "freedreno_perfcntr.h"
51 #define MAX_CNTR_PER_GROUP 24
53 /* NOTE first counter group should always be CP, since we unconditionally
54 * use CP counter to measure the gpu freq.
57 struct counter_group
{
58 const struct fd_perfcntr_group
*group
;
61 const struct fd_perfcntr_counter
*counter
;
63 volatile uint32_t *val_hi
;
64 volatile uint32_t *val_lo
;
65 } counter
[MAX_CNTR_PER_GROUP
];
67 /* last sample time: */
68 uint32_t stime
[MAX_CNTR_PER_GROUP
];
69 /* for now just care about the low 32b value.. at least then we don't
70 * have to really care that we can't sample both hi and lo regs at the
73 uint32_t last
[MAX_CNTR_PER_GROUP
];
74 /* current value, ie. by how many did the counter increase in last
75 * sampling period divided by the sampling period:
77 float current
[MAX_CNTR_PER_GROUP
];
78 /* name of currently selected counters (for UI): */
79 const char *label
[MAX_CNTR_PER_GROUP
];
84 int address_cells
, size_cells
;
91 /* per-generation table of counters: */
93 struct counter_group
*groups
;
94 /* drm device (for writing select regs via ring): */
95 struct fd_device
*dev
;
97 struct fd_submit
*submit
;
98 struct fd_ringbuffer
*ring
;
101 static void config_save(void);
102 static void config_restore(void);
103 static void restore_counter_groups(void);
112 readfile(const char *path
, int *sz
)
117 fd
= open(path
, O_RDONLY
);
122 buf
= realloc(buf
, n
+ CHUNKSIZE
);
123 ret
= read(fd
, buf
+ n
, CHUNKSIZE
);
129 } else if (ret
< CHUNKSIZE
) {
144 clock_gettime(CLOCK_MONOTONIC
, &ts
);
145 return (ts
.tv_sec
* 1000000) + (ts
.tv_nsec
/ 1000);
149 delta(uint32_t a
, uint32_t b
)
151 /* deal with rollover: */
153 return 0xffffffff - a
+ b
;
159 * code to find stuff in /proc/device-tree:
161 * NOTE: if we sampled the counters from the cmdstream, we could avoid needing
162 * /dev/mem and /proc/device-tree crawling. OTOH when the GPU is heavily loaded
163 * we would be competing with whatever else is using the GPU.
167 readdt(const char *node
)
173 (void) asprintf(&path
, "%s/%s", dev
.dtnode
, node
);
174 buf
= readfile(path
, &sz
);
181 find_freqs_fn(const char *fpath
, const struct stat
*sb
, int typeflag
, struct FTW
*ftwbuf
)
183 const char *fname
= fpath
+ ftwbuf
->base
;
186 if (strcmp(fname
, "qcom,gpu-freq") == 0) {
187 uint32_t *buf
= readfile(fpath
, &sz
);
188 uint32_t freq
= ntohl(buf
[0]);
190 dev
.max_freq
= MAX2(dev
.max_freq
, freq
);
191 dev
.min_freq
= MIN2(dev
.min_freq
, freq
);
206 (void) asprintf(&path
, "%s/%s", dev
.dtnode
, "qcom,gpu-pwrlevels");
208 ret
= nftw(path
, find_freqs_fn
, 64, 0);
210 err(1, "could not find power levels");
215 static const char * compatibles
[] = {
223 * compatstrs is a list of compatible strings separated by null, ie.
225 * compatible = "qcom,adreno-630.2", "qcom,adreno";
227 * would result in "qcom,adreno-630.2\0qcom,adreno\0"
229 static bool match_compatible(char *compatstrs
, int sz
)
232 char *compatible
= compatstrs
;
234 for (unsigned i
= 0; i
< ARRAY_SIZE(compatibles
); i
++) {
235 if (strcmp(compatible
, compatibles
[i
]) == 0) {
240 compatstrs
+= strlen(compatible
) + 1;
241 sz
-= strlen(compatible
) + 1;
247 find_device_fn(const char *fpath
, const struct stat
*sb
, int typeflag
, struct FTW
*ftwbuf
)
249 const char *fname
= fpath
+ ftwbuf
->base
;
252 if (strcmp(fname
, "compatible") == 0) {
253 char *str
= readfile(fpath
, &sz
);
254 if (match_compatible(str
, sz
)) {
255 int dlen
= strlen(fpath
) - strlen("/compatible");
256 dev
.dtnode
= malloc(dlen
+ 1);
257 memcpy(dev
.dtnode
, fpath
, dlen
);
258 printf("found dt node: %s\n", dev
.dtnode
);
260 char buf
[dlen
+ sizeof("/../#address-cells") + 1];
263 sprintf(buf
, "%s/../#address-cells", dev
.dtnode
);
264 val
= readfile(buf
, &sz
);
265 dev
.address_cells
= ntohl(*val
);
268 sprintf(buf
, "%s/../#size-cells", dev
.dtnode
);
269 val
= readfile(buf
, &sz
);
270 dev
.size_cells
= ntohl(*val
);
273 printf("#address-cells=%d, #size-cells=%d\n",
274 dev
.address_cells
, dev
.size_cells
);
291 ret
= nftw("/proc/device-tree/", find_device_fn
, 64, 0);
293 err(1, "could not find adreno gpu");
296 errx(1, "could not find qcom,adreno-3xx node");
298 fd
= drmOpenWithType("msm", NULL
, DRM_NODE_RENDER
);
300 err(1, "could not open drm device");
302 dev
.dev
= fd_device_new(fd
);
303 dev
.pipe
= fd_pipe_new(dev
.dev
, FD_PIPE_3D
);
306 ret
= fd_pipe_get_param(dev
.pipe
, FD_CHIP_ID
, &val
);
308 err(1, "could not get gpu-id");
312 #define CHIP_FMT "d%d%d.%d"
313 #define CHIP_ARGS(chipid) \
314 ((chipid) >> 24) & 0xff, \
315 ((chipid) >> 16) & 0xff, \
316 ((chipid) >> 8) & 0xff, \
317 ((chipid) >> 0) & 0xff
318 printf("device: a%"CHIP_FMT
"\n", CHIP_ARGS(dev
.chipid
));
320 b
= buf
= readdt("reg");
322 if (dev
.address_cells
== 2) {
323 uint32_t u
[2] = { ntohl(buf
[0]), ntohl(buf
[1]) };
324 dev
.base
= (((uint64_t)u
[0]) << 32) | u
[1];
327 dev
.base
= ntohl(buf
[0]);
331 if (dev
.size_cells
== 2) {
332 uint32_t u
[2] = { ntohl(buf
[0]), ntohl(buf
[1]) };
333 dev
.size
= (((uint64_t)u
[0]) << 32) | u
[1];
336 dev
.size
= ntohl(buf
[0]);
342 printf("i/o region at %08"PRIx64
" (size: %x)\n", dev
.base
, dev
.size
);
344 /* try MAX_FREQ first as that will work regardless of old dt
345 * dt bindings vs upstream bindings:
347 ret
= fd_pipe_get_param(dev
.pipe
, FD_MAX_FREQ
, &val
);
349 printf("falling back to parsing DT bindings for freq\n");
356 printf("min_freq=%u, max_freq=%u\n", dev
.min_freq
, dev
.max_freq
);
358 fd
= open("/dev/mem", O_RDWR
| O_SYNC
);
360 err(1, "could not open /dev/mem");
362 dev
.io
= mmap(0, dev
.size
, PROT_READ
| PROT_WRITE
, MAP_SHARED
, fd
, dev
.base
);
363 if (dev
.io
== MAP_FAILED
) {
365 err(1, "could not map device");
381 ret
= fd_submit_flush(dev
.submit
, -1, NULL
, NULL
);
383 errx(1, "submit failed: %d", ret
);
384 fd_ringbuffer_del(dev
.ring
);
385 fd_submit_del(dev
.submit
);
392 select_counter(struct counter_group
*group
, int ctr
, int n
)
394 assert(n
< group
->group
->num_countables
);
395 assert(ctr
< group
->group
->num_counters
);
397 group
->label
[ctr
] = group
->group
->countables
[n
].name
;
398 group
->counter
[ctr
].select_val
= n
;
401 dev
.submit
= fd_submit_new(dev
.pipe
);
402 dev
.ring
= fd_submit_new_ringbuffer(dev
.submit
, 0x1000,
403 FD_RINGBUFFER_PRIMARY
| FD_RINGBUFFER_GROWABLE
);
406 /* bashing select register directly while gpu is active will end
407 * in tears.. so we need to write it via the ring:
409 * TODO it would help startup time, if gpu is loaded, to batch
410 * all the initial writes and do a single flush.. although that
411 * makes things more complicated for capturing inital sample value
413 struct fd_ringbuffer
*ring
= dev
.ring
;
414 switch (dev
.chipid
>> 24) {
418 OUT_PKT3(ring
, CP_WAIT_FOR_IDLE
, 1);
419 OUT_RING(ring
, 0x00000000);
421 if (group
->group
->counters
[ctr
].enable
) {
422 OUT_PKT0(ring
, group
->group
->counters
[ctr
].enable
, 1);
426 if (group
->group
->counters
[ctr
].clear
) {
427 OUT_PKT0(ring
, group
->group
->counters
[ctr
].clear
, 1);
430 OUT_PKT0(ring
, group
->group
->counters
[ctr
].clear
, 1);
434 OUT_PKT0(ring
, group
->group
->counters
[ctr
].select_reg
, 1);
437 if (group
->group
->counters
[ctr
].enable
) {
438 OUT_PKT0(ring
, group
->group
->counters
[ctr
].enable
, 1);
445 OUT_PKT7(ring
, CP_WAIT_FOR_IDLE
, 0);
447 if (group
->group
->counters
[ctr
].enable
) {
448 OUT_PKT4(ring
, group
->group
->counters
[ctr
].enable
, 1);
452 if (group
->group
->counters
[ctr
].clear
) {
453 OUT_PKT4(ring
, group
->group
->counters
[ctr
].clear
, 1);
456 OUT_PKT4(ring
, group
->group
->counters
[ctr
].clear
, 1);
460 OUT_PKT4(ring
, group
->group
->counters
[ctr
].select_reg
, 1);
463 if (group
->group
->counters
[ctr
].enable
) {
464 OUT_PKT4(ring
, group
->group
->counters
[ctr
].enable
, 1);
471 group
->last
[ctr
] = *group
->counter
[ctr
].val_lo
;
472 group
->stime
[ctr
] = gettime_us();
476 resample_counter(struct counter_group
*group
, int ctr
)
478 uint32_t val
= *group
->counter
[ctr
].val_lo
;
479 uint32_t t
= gettime_us();
480 uint32_t dt
= delta(group
->stime
[ctr
], t
);
481 uint32_t dval
= delta(group
->last
[ctr
], val
);
482 group
->current
[ctr
] = (float)dval
* 1000000.0 / (float)dt
;
483 group
->last
[ctr
] = val
;
484 group
->stime
[ctr
] = t
;
487 #define REFRESH_MS 500
489 /* sample all the counters: */
493 static uint64_t last_time
;
494 uint64_t current_time
= gettime_us();
496 if ((current_time
- last_time
) < (REFRESH_MS
* 1000 / 2))
499 last_time
= current_time
;
501 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
502 struct counter_group
*group
= &dev
.groups
[i
];
503 for (unsigned j
= 0; j
< group
->group
->num_counters
; j
++) {
504 resample_counter(group
, j
);
513 #define COLOR_GROUP_HEADER 1
514 #define COLOR_FOOTER 2
515 #define COLOR_INVERSE 3
518 static int ctr_width
;
519 static int max_rows
, current_cntr
= 1;
522 redraw_footer(WINDOW
*win
)
527 n
= asprintf(&footer
, " fdperf: a%"CHIP_FMT
" (%.2fMHz..%.2fMHz)",
528 CHIP_ARGS(dev
.chipid
),
529 ((float)dev
.min_freq
) / 1000000.0,
530 ((float)dev
.max_freq
) / 1000000.0);
532 wmove(win
, h
- 1, 0);
533 wattron(win
, COLOR_PAIR(COLOR_FOOTER
));
534 waddstr(win
, footer
);
535 whline(win
, ' ', w
- n
);
536 wattroff(win
, COLOR_PAIR(COLOR_FOOTER
));
542 redraw_group_header(WINDOW
*win
, int row
, const char *name
)
545 wattron(win
, A_BOLD
);
546 wattron(win
, COLOR_PAIR(COLOR_GROUP_HEADER
));
548 whline(win
, ' ', w
- strlen(name
));
549 wattroff(win
, COLOR_PAIR(COLOR_GROUP_HEADER
));
550 wattroff(win
, A_BOLD
);
554 redraw_counter_label(WINDOW
*win
, int row
, const char *name
, bool selected
)
556 int n
= strlen(name
);
557 assert(n
<= ctr_width
);
559 whline(win
, ' ', ctr_width
- n
);
560 wmove(win
, row
, ctr_width
- n
);
562 wattron(win
, COLOR_PAIR(COLOR_INVERSE
));
565 wattroff(win
, COLOR_PAIR(COLOR_INVERSE
));
570 redraw_counter_value_cycles(WINDOW
*win
, float val
)
573 int x
= getcurx(win
);
574 int valwidth
= w
- x
;
577 /* convert to fraction of max freq: */
578 val
= val
/ (float)dev
.max_freq
;
580 /* figure out percentage-bar width: */
581 barwidth
= (int)(val
* valwidth
);
583 /* sometimes things go over 100%.. idk why, could be
584 * things running faster than base clock, or counter
585 * summing up cycles in multiple cores?
587 barwidth
= MIN2(barwidth
, valwidth
- 1);
589 n
= asprintf(&str
, "%.2f%%", 100.0 * val
);
590 wattron(win
, COLOR_PAIR(COLOR_INVERSE
));
591 waddnstr(win
, str
, barwidth
);
593 whline(win
, ' ', barwidth
- n
);
594 wmove(win
, getcury(win
), x
+ barwidth
);
596 wattroff(win
, COLOR_PAIR(COLOR_INVERSE
));
598 waddstr(win
, str
+ barwidth
);
599 whline(win
, ' ', w
- getcurx(win
));
605 redraw_counter_value_raw(WINDOW
*win
, float val
)
608 (void) asprintf(&str
, "%'.2f", val
);
610 whline(win
, ' ', w
- getcurx(win
));
615 redraw_counter(WINDOW
*win
, int row
, struct counter_group
*group
,
616 int ctr
, bool selected
)
618 redraw_counter_label(win
, row
, group
->label
[ctr
], selected
);
620 /* quick hack, if the label has "CYCLE" in the name, it is
621 * probably a cycle counter ;-)
622 * Perhaps add more info in rnndb schema to know how to
623 * treat individual counters (ie. which are cycles, and
624 * for those we want to present as a percentage do we
625 * need to scale the result.. ie. is it running at some
626 * multiple or divisor of core clk, etc)
628 * TODO it would be much more clever to get this from xml
629 * Also.. in some cases I think we want to know how many
630 * units the counter is counting for, ie. if a320 has 2x
631 * shader as a306 we might need to scale the result..
633 if (strstr(group
->label
[ctr
], "CYCLE") ||
634 strstr(group
->label
[ctr
], "BUSY") ||
635 strstr(group
->label
[ctr
], "IDLE"))
636 redraw_counter_value_cycles(win
, group
->current
[ctr
]);
638 redraw_counter_value_raw(win
, group
->current
[ctr
]);
644 static int scroll
= 0;
652 if ((current_cntr
- scroll
) > (max
- 1)) {
653 scroll
= current_cntr
- (max
- 1);
654 } else if ((current_cntr
- 1) < scroll
) {
655 scroll
= current_cntr
- 1;
658 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
659 struct counter_group
*group
= &dev
.groups
[i
];
662 /* NOTE skip CP the first CP counter */
666 if (j
< group
->group
->num_counters
) {
667 if ((scroll
<= row
) && ((row
- scroll
) < max
))
668 redraw_group_header(win
, row
- scroll
, group
->group
->name
);
672 for (; j
< group
->group
->num_counters
; j
++) {
673 if ((scroll
<= row
) && ((row
- scroll
) < max
))
674 redraw_counter(win
, row
- scroll
, group
, j
, row
== current_cntr
);
679 /* convert back to physical (unscrolled) offset: */
682 redraw_group_header(win
, row
, "Status");
685 /* Draw GPU freq row: */
686 redraw_counter_label(win
, row
, "Freq (MHz)", false);
687 redraw_counter_value_raw(win
, dev
.groups
[0].current
[0] / 1000000.0);
695 static struct counter_group
*
696 current_counter(int *ctr
)
700 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
701 struct counter_group
*group
= &dev
.groups
[i
];
704 /* NOTE skip the first CP counter (CP_ALWAYS_COUNT) */
708 /* account for group header: */
709 if (j
< group
->group
->num_counters
) {
710 /* cannot select group header.. return null to indicate this
713 if (n
== current_cntr
)
719 for (; j
< group
->group
->num_counters
; j
++) {
720 if (n
== current_cntr
) {
737 struct counter_group
*group
;
738 int cnt
, current
= 0, scroll
;
740 /* figure out dialog size: */
742 int dw
= ctr_width
+ 2;
744 group
= current_counter(&cnt
);
746 /* find currently selected idx (note there can be discontinuities
747 * so the selected value does not map 1:1 to current idx)
749 uint32_t selected
= group
->counter
[cnt
].select_val
;
750 for (int i
= 0; i
< group
->group
->num_countables
; i
++) {
751 if (group
->group
->countables
[i
].selector
== selected
) {
757 /* scrolling offset, if dialog is too small for all the choices: */
760 dialog
= newwin(dh
, dw
, (h
-dh
)/2, (w
-dw
)/2);
763 keypad(dialog
, TRUE
);
766 int max
= MIN2(dh
- 2, group
->group
->num_countables
);
769 if ((current
- scroll
) >= (dh
- 3)) {
770 scroll
= current
- (dh
- 3);
771 } else if (current
< scroll
) {
775 for (int i
= 0; i
< max
; i
++) {
777 wmove(dialog
, i
+1, 1);
779 assert (n
< group
->group
->num_countables
);
780 selector
= group
->group
->countables
[n
].selector
;
781 wattron(dialog
, COLOR_PAIR(COLOR_INVERSE
));
783 if (n
< group
->group
->num_countables
)
784 waddstr(dialog
, group
->group
->countables
[n
].name
);
785 whline(dialog
, ' ', dw
- getcurx(dialog
) - 1);
787 wattroff(dialog
, COLOR_PAIR(COLOR_INVERSE
));
790 assert (selector
>= 0);
792 switch (wgetch(dialog
)) {
794 current
= MAX2(0, current
- 1);
797 current
= MIN2(group
->group
->num_countables
- 1, current
+ 1);
801 /* select new sampler */
802 select_counter(group
, cnt
, selector
);
817 wborder(dialog
, ' ', ' ', ' ',' ',' ',' ',' ',' ');
822 scroll_cntr(int amount
)
825 current_cntr
= MAX2(1, current_cntr
+ amount
);
826 if (current_counter(NULL
) == NULL
) {
827 current_cntr
= MAX2(1, current_cntr
- 1);
830 current_cntr
= MIN2(max_rows
- 1, current_cntr
+ amount
);
831 if (current_counter(NULL
) == NULL
)
832 current_cntr
= MIN2(max_rows
- 1, current_cntr
+ 1);
840 uint32_t last_time
= gettime_us();
848 wtimeout(mainwin
, REFRESH_MS
);
850 keypad(mainwin
, TRUE
);
853 init_pair(COLOR_GROUP_HEADER
, COLOR_WHITE
, COLOR_GREEN
);
854 init_pair(COLOR_FOOTER
, COLOR_WHITE
, COLOR_BLUE
);
855 init_pair(COLOR_INVERSE
, COLOR_BLACK
, COLOR_WHITE
);
858 switch (wgetch(mainwin
)) {
865 case KEY_NPAGE
: /* page-down */
866 /* TODO figure out # of rows visible? */
869 case KEY_PPAGE
: /* page-up */
870 /* TODO figure out # of rows visible? */
886 /* restore the counters every 0.5s in case the GPU has suspended,
887 * in which case the current selected countables will have reset:
889 uint32_t t
= gettime_us();
890 if (delta(last_time
, t
) > 500000) {
891 restore_counter_groups();
897 /* restore settings.. maybe we need an atexit()??*/
905 restore_counter_groups(void)
907 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
908 struct counter_group
*group
= &dev
.groups
[i
];
911 /* NOTE skip CP the first CP counter */
915 for (; j
< group
->group
->num_counters
; j
++) {
916 select_counter(group
, j
, group
->counter
[j
].select_val
);
922 setup_counter_groups(const struct fd_perfcntr_group
*groups
)
924 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
925 struct counter_group
*group
= &dev
.groups
[i
];
927 group
->group
= &groups
[i
];
929 max_rows
+= group
->group
->num_counters
+ 1;
931 /* the first CP counter is hidden: */
934 if (group
->group
->num_counters
<= 1)
938 for (unsigned j
= 0; j
< group
->group
->num_counters
; j
++) {
939 group
->counter
[j
].counter
= &group
->group
->counters
[j
];
941 group
->counter
[j
].val_hi
= dev
.io
+ (group
->counter
[j
].counter
->counter_reg_hi
* 4);
942 group
->counter
[j
].val_lo
= dev
.io
+ (group
->counter
[j
].counter
->counter_reg_lo
* 4);
944 group
->counter
[j
].select_val
= j
;
947 for (unsigned j
= 0; j
< group
->group
->num_countables
; j
++) {
948 ctr_width
= MAX2(ctr_width
, strlen(group
->group
->countables
[j
].name
) + 1);
954 * configuration / persistence
958 static config_setting_t
*setting
;
963 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
964 struct counter_group
*group
= &dev
.groups
[i
];
967 /* NOTE skip CP the first CP counter */
971 config_setting_t
*sect
=
972 config_setting_get_member(setting
, group
->group
->name
);
974 for (; j
< group
->group
->num_counters
; j
++) {
975 char name
[] = "counter0000";
976 sprintf(name
, "counter%d", j
);
977 config_setting_t
*s
=
978 config_setting_lookup(sect
, name
);
979 config_setting_set_int(s
, group
->counter
[j
].select_val
);
983 config_write_file(&cfg
, "fdperf.cfg");
993 /* Read the file. If there is an error, report it and exit. */
994 if(!config_read_file(&cfg
, "fdperf.cfg")) {
995 warn("could not restore settings");
998 config_setting_t
*root
= config_root_setting(&cfg
);
1000 /* per device settings: */
1001 (void) asprintf(&str
, "a%dxx", dev
.chipid
>> 24);
1002 setting
= config_setting_get_member(root
, str
);
1004 setting
= config_setting_add(root
, str
, CONFIG_TYPE_GROUP
);
1007 for (unsigned i
= 0; i
< dev
.ngroups
; i
++) {
1008 struct counter_group
*group
= &dev
.groups
[i
];
1011 /* NOTE skip CP the first CP counter */
1015 config_setting_t
*sect
=
1016 config_setting_get_member(setting
, group
->group
->name
);
1019 sect
= config_setting_add(setting
, group
->group
->name
,
1023 for (; j
< group
->group
->num_counters
; j
++) {
1024 char name
[] = "counter0000";
1025 sprintf(name
, "counter%d", j
);
1026 config_setting_t
*s
= config_setting_lookup(sect
, name
);
1028 config_setting_add(sect
, name
, CONFIG_TYPE_INT
);
1031 select_counter(group
, j
, config_setting_get_int(s
));
1041 main(int argc
, char **argv
)
1045 const struct fd_perfcntr_group
*groups
;
1046 groups
= fd_perfcntrs((dev
.chipid
>> 24) * 100, &dev
.ngroups
);
1048 errx(1, "no perfcntr support");
1051 dev
.groups
= calloc(dev
.ngroups
, sizeof(struct counter_group
));
1053 setlocale(LC_NUMERIC
, "en_US.UTF-8");
1055 setup_counter_groups(groups
);
1056 restore_counter_groups();