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: Do not use intermediate storage when copying performance query results

Removing the intermediate buffer removes the last use of the
V3D_MAX_COUNTERS define, which will enable further driver cleanup.

While at it pull the 32 vs 64 bit copying decision outside the loop in
order to reduce the number of conditional instructions.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
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-9-tursulin@igalia.com

authored by

Tvrtko Ursulin and committed by
Maíra Canal
1be825c5 c9d6630f

+36 -21
+36 -21
drivers/gpu/drm/v3d/v3d_sched.c
··· 421 421 v3d_put_bo_vaddr(bo); 422 422 } 423 423 424 - static void 425 - write_to_buffer(void *dst, u32 idx, bool do_64bit, u64 value) 424 + static void write_to_buffer_32(u32 *dst, unsigned int idx, u32 value) 426 425 { 427 - if (do_64bit) { 428 - u64 *dst64 = (u64 *)dst; 426 + dst[idx] = value; 427 + } 429 428 430 - dst64[idx] = value; 431 - } else { 432 - u32 *dst32 = (u32 *)dst; 429 + static void write_to_buffer_64(u64 *dst, unsigned int idx, u64 value) 430 + { 431 + dst[idx] = value; 432 + } 433 433 434 - dst32[idx] = (u32)value; 435 - } 434 + static void 435 + write_to_buffer(void *dst, unsigned int idx, bool do_64bit, u64 value) 436 + { 437 + if (do_64bit) 438 + write_to_buffer_64(dst, idx, value); 439 + else 440 + write_to_buffer_32(dst, idx, value); 436 441 } 437 442 438 443 static void ··· 510 505 } 511 506 512 507 static void 513 - v3d_write_performance_query_result(struct v3d_cpu_job *job, void *data, u32 query) 508 + v3d_write_performance_query_result(struct v3d_cpu_job *job, void *data, 509 + unsigned int query) 514 510 { 515 - struct v3d_performance_query_info *performance_query = &job->performance_query; 516 - struct v3d_copy_query_results_info *copy = &job->copy; 511 + struct v3d_performance_query_info *performance_query = 512 + &job->performance_query; 517 513 struct v3d_file_priv *v3d_priv = job->base.file->driver_priv; 514 + struct v3d_performance_query *perf_query = 515 + &performance_query->queries[query]; 518 516 struct v3d_dev *v3d = job->base.v3d; 519 - struct v3d_perfmon *perfmon; 520 - u64 counter_values[V3D_MAX_COUNTERS]; 517 + unsigned int i, j, offset; 521 518 522 - for (int i = 0; i < performance_query->nperfmons; i++) { 519 + for (i = 0, offset = 0; 520 + i < performance_query->nperfmons; 521 + i++, offset += DRM_V3D_MAX_PERF_COUNTERS) { 522 + struct v3d_perfmon *perfmon; 523 + 523 524 perfmon = v3d_perfmon_find(v3d_priv, 524 - performance_query->queries[query].kperfmon_ids[i]); 525 + perf_query->kperfmon_ids[i]); 525 526 if (!perfmon) { 526 527 DRM_DEBUG("Failed to find perfmon."); 527 528 continue; ··· 535 524 536 525 v3d_perfmon_stop(v3d, perfmon, true); 537 526 538 - memcpy(&counter_values[i * DRM_V3D_MAX_PERF_COUNTERS], perfmon->values, 539 - perfmon->ncounters * sizeof(u64)); 527 + if (job->copy.do_64bit) { 528 + for (j = 0; j < perfmon->ncounters; j++) 529 + write_to_buffer_64(data, offset + j, 530 + perfmon->values[j]); 531 + } else { 532 + for (j = 0; j < perfmon->ncounters; j++) 533 + write_to_buffer_32(data, offset + j, 534 + perfmon->values[j]); 535 + } 540 536 541 537 v3d_perfmon_put(perfmon); 542 538 } 543 - 544 - for (int i = 0; i < performance_query->ncounters; i++) 545 - write_to_buffer(data, i, copy->do_64bit, counter_values[i]); 546 539 } 547 540 548 541 static void