Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/v3d: Move perfmon init completely into own unit

Now that the build time dependencies on various array sizes have been
removed, we can move the perfmon init completely into its own compilation
unit and remove the hardcoded defines.

This improves on the temporary fix quickly delivered in commit
9c3951ec27b9 ("drm/v3d: Fix perfmon build error/warning").

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
References: 9c3951ec27b9 ("drm/v3d: Fix perfmon build error/warning")
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240711135340.84617-10-tursulin@igalia.com

authored by

Tvrtko Ursulin and committed by
Maíra Canal
3ef80d4e 1be825c5

+38 -33
+2 -7
drivers/gpu/drm/v3d/v3d_drv.c
··· 95 95 args->value = 1; 96 96 return 0; 97 97 case DRM_V3D_PARAM_MAX_PERF_COUNTERS: 98 - args->value = v3d->max_counters; 98 + args->value = v3d->perfmon_info.max_counters; 99 99 return 0; 100 100 default: 101 101 DRM_DEBUG("Unknown parameter %d\n", args->param); ··· 298 298 v3d->cores = V3D_GET_FIELD(ident1, V3D_HUB_IDENT1_NCORES); 299 299 WARN_ON(v3d->cores > 1); /* multicore not yet implemented */ 300 300 301 - if (v3d->ver >= 71) 302 - v3d->max_counters = V3D_V71_NUM_PERFCOUNTERS; 303 - else if (v3d->ver >= 42) 304 - v3d->max_counters = V3D_V42_NUM_PERFCOUNTERS; 305 - else 306 - v3d->max_counters = 0; 301 + v3d_perfmon_init(v3d); 307 302 308 303 v3d->reset = devm_reset_control_get_exclusive(dev, NULL); 309 304 if (IS_ERR(v3d->reset)) {
+2 -4
drivers/gpu/drm/v3d/v3d_drv.h
··· 104 104 int ver; 105 105 bool single_irq_line; 106 106 107 - /* Different revisions of V3D have different total number of performance 108 - * counters 109 - */ 110 - unsigned int max_counters; 107 + struct v3d_perfmon_info perfmon_info; 111 108 112 109 void __iomem *hub_regs; 113 110 void __iomem *core_regs[3]; ··· 565 568 void v3d_sched_fini(struct v3d_dev *v3d); 566 569 567 570 /* v3d_perfmon.c */ 571 + void v3d_perfmon_init(struct v3d_dev *v3d); 568 572 void v3d_perfmon_get(struct v3d_perfmon *perfmon); 569 573 void v3d_perfmon_put(struct v3d_perfmon *perfmon); 570 574 void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon);
+23 -17
drivers/gpu/drm/v3d/v3d_perfmon.c
··· 195 195 {"QPU", "QPU-stalls-other", "[QPU] Stalled qcycles waiting for any other reason (vary/W/Z)"}, 196 196 }; 197 197 198 + void v3d_perfmon_init(struct v3d_dev *v3d) 199 + { 200 + const struct v3d_perf_counter_desc *counters = NULL; 201 + unsigned int max = 0; 202 + 203 + if (v3d->ver >= 71) { 204 + counters = v3d_v71_performance_counters; 205 + max = ARRAY_SIZE(v3d_v71_performance_counters); 206 + } else if (v3d->ver >= 42) { 207 + counters = v3d_v42_performance_counters; 208 + max = ARRAY_SIZE(v3d_v42_performance_counters); 209 + } 210 + 211 + v3d->perfmon_info.max_counters = max; 212 + v3d->perfmon_info.counters = counters; 213 + } 214 + 198 215 void v3d_perfmon_get(struct v3d_perfmon *perfmon) 199 216 { 200 217 if (perfmon) ··· 338 321 339 322 /* Make sure all counters are valid. */ 340 323 for (i = 0; i < req->ncounters; i++) { 341 - if (req->counters[i] >= v3d->max_counters) 324 + if (req->counters[i] >= v3d->perfmon_info.max_counters) 342 325 return -EINVAL; 343 326 } 344 327 ··· 433 416 return -EINVAL; 434 417 } 435 418 419 + if (!v3d->perfmon_info.max_counters) 420 + return -EOPNOTSUPP; 421 + 436 422 /* Make sure that the counter ID is valid */ 437 - if (req->counter >= v3d->max_counters) 423 + if (req->counter >= v3d->perfmon_info.max_counters) 438 424 return -EINVAL; 439 425 440 - BUILD_BUG_ON(ARRAY_SIZE(v3d_v42_performance_counters) != 441 - V3D_V42_NUM_PERFCOUNTERS); 442 - BUILD_BUG_ON(ARRAY_SIZE(v3d_v71_performance_counters) != 443 - V3D_V71_NUM_PERFCOUNTERS); 444 - BUILD_BUG_ON(V3D_MAX_COUNTERS < V3D_V42_NUM_PERFCOUNTERS); 445 - BUILD_BUG_ON(V3D_MAX_COUNTERS < V3D_V71_NUM_PERFCOUNTERS); 446 - BUILD_BUG_ON((V3D_MAX_COUNTERS != V3D_V42_NUM_PERFCOUNTERS) && 447 - (V3D_MAX_COUNTERS != V3D_V71_NUM_PERFCOUNTERS)); 448 - 449 - if (v3d->ver >= 71) 450 - counter = &v3d_v71_performance_counters[req->counter]; 451 - else if (v3d->ver >= 42) 452 - counter = &v3d_v42_performance_counters[req->counter]; 453 - else 454 - return -EOPNOTSUPP; 426 + counter = &v3d->perfmon_info.counters[req->counter]; 455 427 456 428 strscpy(req->name, counter->name, sizeof(req->name)); 457 429 strscpy(req->category, counter->category, sizeof(req->category));
+11 -5
drivers/gpu/drm/v3d/v3d_performance_counters.h
··· 19 19 char description[256]; 20 20 }; 21 21 22 + struct v3d_perfmon_info { 23 + /* 24 + * Different revisions of V3D have different total number of 25 + * performance counters. 26 + */ 27 + unsigned int max_counters; 22 28 23 - #define V3D_V42_NUM_PERFCOUNTERS (87) 24 - #define V3D_V71_NUM_PERFCOUNTERS (93) 25 - 26 - /* Maximum number of performance counters supported by any version of V3D */ 27 - #define V3D_MAX_COUNTERS (93) 29 + /* 30 + * Array of counters valid for the platform. 31 + */ 32 + const struct v3d_perf_counter_desc *counters; 33 + }; 28 34 29 35 #endif