~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/freedreno/perfcntrs/fdperf.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
static struct {
88
88
   void *io;
89
 
   uint32_t chipid;
90
89
   uint32_t min_freq;
91
90
   uint32_t max_freq;
92
91
   /* per-generation table of counters: */
95
94
   /* drm device (for writing select regs via ring): */
96
95
   struct fd_device *dev;
97
96
   struct fd_pipe *pipe;
 
97
   const struct fd_dev_id *dev_id;
98
98
   struct fd_submit *submit;
99
99
   struct fd_ringbuffer *ring;
100
100
} dev;
146
146
 
147
147
   dev.pipe = fd_pipe_new(dev.dev, FD_PIPE_3D);
148
148
 
149
 
   uint64_t val;
150
 
   ret = fd_pipe_get_param(dev.pipe, FD_CHIP_ID, &val);
151
 
   if (ret) {
152
 
      err(1, "could not get gpu-id");
153
 
   }
154
 
   dev.chipid = val;
 
149
   dev.dev_id = fd_pipe_dev_id(dev.pipe);
 
150
   if (!fd_dev_info(dev.dev_id))
 
151
      err(1, "unknown device");
155
152
 
156
 
#define CHIP_FMT "d%d%d.%d"
157
 
#define CHIP_ARGS(chipid)                                                      \
158
 
   ((chipid) >> 24) & 0xff, ((chipid) >> 16) & 0xff, ((chipid) >> 8) & 0xff,   \
159
 
      ((chipid) >> 0) & 0xff
160
 
   printf("device: a%" CHIP_FMT "\n", CHIP_ARGS(dev.chipid));
 
153
   printf("device: %s\n", fd_dev_name(dev.dev_id));
161
154
 
162
155
   /* try MAX_FREQ first as that will work regardless of old dt
163
156
    * dt bindings vs upstream bindings:
164
157
    */
 
158
   uint64_t val;
165
159
   ret = fd_pipe_get_param(dev.pipe, FD_MAX_FREQ, &val);
166
160
   if (ret) {
167
161
      printf("falling back to parsing DT bindings for freq\n");
229
223
    * makes things more complicated for capturing inital sample value
230
224
    */
231
225
   struct fd_ringbuffer *ring = dev.ring;
232
 
   switch (dev.chipid >> 24) {
 
226
   switch (fd_dev_gen(dev.dev_id)) {
233
227
   case 2:
234
228
   case 3:
235
229
   case 4:
340
334
   char *footer;
341
335
   int n;
342
336
 
343
 
   n = asprintf(&footer, " fdperf: a%" CHIP_FMT " (%.2fMHz..%.2fMHz)",
344
 
                CHIP_ARGS(dev.chipid), ((float)dev.min_freq) / 1000000.0,
 
337
   n = asprintf(&footer, " fdperf: %s (%.2fMHz..%.2fMHz)",
 
338
                fd_dev_name(dev.dev_id), ((float)dev.min_freq) / 1000000.0,
345
339
                ((float)dev.max_freq) / 1000000.0);
346
340
 
347
341
   wmove(win, h - 1, 0);
573
567
   dialog = newwin(dh, dw, (h - dh) / 2, (w - dw) / 2);
574
568
   box(dialog, 0, 0);
575
569
   wrefresh(dialog);
576
 
   keypad(dialog, TRUE);
 
570
   keypad(dialog, true);
577
571
 
578
572
   while (true) {
579
573
      int max = MIN2(dh - 2, group->group->num_countables);
660
654
   cbreak();
661
655
   wtimeout(mainwin, options.refresh_ms);
662
656
   noecho();
663
 
   keypad(mainwin, TRUE);
 
657
   keypad(mainwin, true);
664
658
   curs_set(0);
665
659
   start_color();
666
660
   init_pair(COLOR_GROUP_HEADER, COLOR_WHITE, COLOR_GREEN);
846
840
   config_setting_t *root = config_root_setting(&cfg);
847
841
 
848
842
   /* per device settings: */
849
 
   (void)asprintf(&str, "a%dxx", dev.chipid >> 24);
 
843
   (void)asprintf(&str, "%s", fd_dev_name(dev.dev_id));
850
844
   setting = config_setting_get_member(root, str);
851
845
   if (!setting)
852
846
      setting = config_setting_add(root, str, CONFIG_TYPE_GROUP);
853
847
   free(str);
 
848
   if (!setting)
 
849
      return;
854
850
 
855
851
   for (unsigned i = 0; i < dev.ngroups; i++) {
856
852
      struct counter_group *group = &dev.groups[i];
926
922
   find_device();
927
923
 
928
924
   const struct fd_perfcntr_group *groups;
929
 
   struct fd_dev_id dev_id = {
930
 
         .gpu_id = (dev.chipid >> 24) * 100,
931
 
   };
932
 
   groups = fd_perfcntrs(&dev_id, &dev.ngroups);
 
925
   groups = fd_perfcntrs(dev.dev_id, &dev.ngroups);
933
926
   if (!groups) {
934
927
      errx(1, "no perfcntr support");
935
928
   }