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/amd/pm: Add caching for SystemMetrics table

Implement caching separately for SystemMetrics table from PMFW. The same
table could be used for multiple interfaces. Hence, cache it internally
to avoid multiple queries to the firmware. For SystemMetrics table, 5ms
cache interval is sufficient.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
b842b994 cf32515a

+36 -13
+1
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
··· 333 333 SMU_TABLE_WIFIBAND, 334 334 SMU_TABLE_GPUBOARD_TEMP_METRICS, 335 335 SMU_TABLE_BASEBOARD_TEMP_METRICS, 336 + SMU_TABLE_PMFW_SYSTEM_METRICS, 336 337 SMU_TABLE_COUNT, 337 338 }; 338 339
+30 -13
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
··· 149 149 struct smu_table_cache *cache; 150 150 int ret; 151 151 152 + ret = smu_table_cache_init(smu, SMU_TABLE_PMFW_SYSTEM_METRICS, 153 + smu_v13_0_12_get_system_metrics_size(), 5); 154 + 155 + if (ret) 156 + return ret; 157 + 152 158 ret = smu_table_cache_init(smu, SMU_TABLE_BASEBOARD_TEMP_METRICS, 153 159 sizeof(*baseboard_temp_metrics), 50); 154 160 if (ret) ··· 168 162 ret = smu_table_cache_init(smu, SMU_TABLE_GPUBOARD_TEMP_METRICS, 169 163 sizeof(*gpuboard_temp_metrics), 50); 170 164 if (ret) { 165 + smu_table_cache_fini(smu, SMU_TABLE_PMFW_SYSTEM_METRICS); 171 166 smu_table_cache_fini(smu, SMU_TABLE_BASEBOARD_TEMP_METRICS); 172 167 return ret; 173 168 } ··· 183 176 { 184 177 smu_table_cache_fini(smu, SMU_TABLE_BASEBOARD_TEMP_METRICS); 185 178 smu_table_cache_fini(smu, SMU_TABLE_GPUBOARD_TEMP_METRICS); 179 + smu_table_cache_fini(smu, SMU_TABLE_PMFW_SYSTEM_METRICS); 186 180 } 187 181 188 182 static int smu_v13_0_12_get_enabled_mask(struct smu_context *smu, ··· 230 222 231 223 int smu_v13_0_12_get_max_metrics_size(void) 232 224 { 233 - return max3(sizeof(StaticMetricsTable_t), sizeof(MetricsTable_t), 234 - sizeof(SystemMetricsTable_t)); 225 + return max(sizeof(StaticMetricsTable_t), sizeof(MetricsTable_t)); 226 + } 227 + 228 + size_t smu_v13_0_12_get_system_metrics_size(void) 229 + { 230 + return sizeof(SystemMetricsTable_t); 235 231 } 236 232 237 233 static void smu_v13_0_12_init_xgmi_data(struct smu_context *smu, ··· 426 414 return 0; 427 415 } 428 416 429 - static int smu_v13_0_12_get_system_metrics_table(struct smu_context *smu, 430 - void *metrics_table) 417 + static int smu_v13_0_12_get_system_metrics_table(struct smu_context *smu) 431 418 { 432 419 struct smu_table_context *smu_table = &smu->smu_table; 433 - uint32_t table_size = smu_table->tables[SMU_TABLE_SMU_METRICS].size; 434 420 struct smu_table *table = &smu_table->driver_table; 421 + struct smu_table *tables = smu_table->tables; 422 + struct smu_table *sys_table; 435 423 int ret; 424 + 425 + sys_table = &tables[SMU_TABLE_PMFW_SYSTEM_METRICS]; 426 + if (smu_table_cache_is_valid(sys_table)) 427 + return 0; 436 428 437 429 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSystemMetricsTable, NULL); 438 430 if (ret) { ··· 446 430 } 447 431 448 432 amdgpu_asic_invalidate_hdp(smu->adev, NULL); 449 - memcpy(smu_table->metrics_table, table->cpu_addr, table_size); 450 - 451 - if (metrics_table) 452 - memcpy(metrics_table, smu_table->metrics_table, sizeof(SystemMetricsTable_t)); 433 + smu_table_cache_update_time(sys_table, jiffies); 434 + memcpy(sys_table->cache.buffer, table->cpu_addr, 435 + smu_v13_0_12_get_system_metrics_size()); 453 436 454 437 return 0; 455 438 } ··· 586 571 struct amdgpu_baseboard_temp_metrics_v1_0 *baseboard_temp_metrics; 587 572 struct amdgpu_gpuboard_temp_metrics_v1_0 *gpuboard_temp_metrics; 588 573 struct smu_table_context *smu_table = &smu->smu_table; 589 - SystemMetricsTable_t *metrics = 590 - (SystemMetricsTable_t *)smu_table->metrics_table; 591 - 574 + struct smu_table *tables = smu_table->tables; 575 + SystemMetricsTable_t *metrics; 592 576 struct smu_table *data_table; 577 + struct smu_table *sys_table; 593 578 int ret, sensor_type; 594 579 u32 idx, sensors; 595 580 ssize_t size; ··· 611 596 size = sizeof(*baseboard_temp_metrics); 612 597 } 613 598 614 - ret = smu_v13_0_12_get_system_metrics_table(smu, NULL); 599 + ret = smu_v13_0_12_get_system_metrics_table(smu); 615 600 if (ret) 616 601 return ret; 617 602 603 + sys_table = &tables[SMU_TABLE_PMFW_SYSTEM_METRICS]; 604 + metrics = (SystemMetricsTable_t *)sys_table->cache.buffer; 618 605 smu_table_cache_update_time(data_table, jiffies); 619 606 620 607 if (type == SMU_TEMP_METRIC_GPUBOARD) {
+4
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
··· 559 559 PAGE_SIZE, 560 560 AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT); 561 561 562 + SMU_TABLE_INIT(tables, SMU_TABLE_PMFW_SYSTEM_METRICS, 563 + smu_v13_0_12_get_system_metrics_size(), PAGE_SIZE, 564 + AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT); 565 + 562 566 metrics_table = kzalloc(METRICS_TABLE_SIZE, GFP_KERNEL); 563 567 if (!metrics_table) 564 568 return -ENOMEM;
+1
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
··· 82 82 83 83 bool smu_v13_0_12_is_dpm_running(struct smu_context *smu); 84 84 int smu_v13_0_12_get_max_metrics_size(void); 85 + size_t smu_v13_0_12_get_system_metrics_size(void); 85 86 int smu_v13_0_12_setup_driver_pptable(struct smu_context *smu); 86 87 int smu_v13_0_12_get_smu_metrics_data(struct smu_context *smu, 87 88 MetricsMember_t member, uint32_t *value);