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/amdgpu: add helper to read UMA carveout info

Currently, the available UMA allocation configs in the integrated system
information table have not been parsed. Add a helper function to retrieve
and store these configs.

Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Yo-Jung Leo Lin (AMD) and committed by
Alex Deucher
685b7113 6f3b631e

+113
+34
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 713 713 struct amdgpu_device *adev; 714 714 }; 715 715 716 + #define MAX_UMA_OPTION_NAME 28 717 + #define MAX_UMA_OPTION_ENTRIES 19 718 + 719 + #define AMDGPU_UMA_FLAG_AUTO BIT(1) 720 + #define AMDGPU_UMA_FLAG_CUSTOM BIT(0) 721 + 722 + /** 723 + * struct amdgpu_uma_carveout_option - single UMA carveout option 724 + * @name: Name of the carveout option 725 + * @memory_carved_mb: Amount of memory carved in MB 726 + * @flags: ATCS flags supported by this option 727 + */ 728 + struct amdgpu_uma_carveout_option { 729 + char name[MAX_UMA_OPTION_NAME]; 730 + uint32_t memory_carved_mb; 731 + uint8_t flags; 732 + }; 733 + 734 + /** 735 + * struct amdgpu_uma_carveout_info - table of available UMA carveout options 736 + * @num_entries: Number of available options 737 + * @uma_option_index: The index of the option currently applied 738 + * @update_lock: Lock to serialize changes to the option 739 + * @entries: The array of carveout options 740 + */ 741 + struct amdgpu_uma_carveout_info { 742 + uint8_t num_entries; 743 + uint8_t uma_option_index; 744 + struct mutex update_lock; 745 + struct amdgpu_uma_carveout_option entries[MAX_UMA_OPTION_ENTRIES]; 746 + }; 747 + 716 748 struct amd_powerplay { 717 749 void *pp_handle; 718 750 const struct amd_pm_funcs *pp_funcs; ··· 1228 1196 bool userq_halt_for_enforce_isolation; 1229 1197 struct work_struct userq_reset_work; 1230 1198 struct amdgpu_uid *uid_info; 1199 + 1200 + struct amdgpu_uma_carveout_info uma_info; 1231 1201 1232 1202 /* KFD 1233 1203 * Must be last --ends in a flexible-array member.
+77
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
··· 296 296 return vram_type; 297 297 } 298 298 299 + static int amdgpu_atomfirmware_get_uma_carveout_info_v2_3(struct amdgpu_device *adev, 300 + union igp_info *igp_info, 301 + struct amdgpu_uma_carveout_info *uma_info) 302 + { 303 + struct uma_carveout_option *opts; 304 + uint8_t nr_uma_options; 305 + int i; 306 + 307 + nr_uma_options = igp_info->v23.UMACarveoutIndexMax; 308 + 309 + if (!nr_uma_options) 310 + return -ENODEV; 311 + 312 + if (nr_uma_options > MAX_UMA_OPTION_ENTRIES) { 313 + drm_dbg(adev_to_drm(adev), 314 + "Number of UMA options exceeds max table size. Options will not be parsed"); 315 + return -EINVAL; 316 + } 317 + 318 + uma_info->num_entries = nr_uma_options; 319 + uma_info->uma_option_index = igp_info->v23.UMACarveoutIndex; 320 + 321 + opts = igp_info->v23.UMASizeControlOption; 322 + 323 + for (i = 0; i < nr_uma_options; i++) { 324 + if (!opts[i].memoryCarvedGb) 325 + uma_info->entries[i].memory_carved_mb = 512; 326 + else 327 + uma_info->entries[i].memory_carved_mb = (uint32_t)opts[i].memoryCarvedGb << 10; 328 + 329 + uma_info->entries[i].flags = opts[i].uma_carveout_option_flags.all8; 330 + strscpy(uma_info->entries[i].name, opts[i].optionName, MAX_UMA_OPTION_NAME); 331 + } 332 + 333 + return 0; 334 + } 335 + 336 + int amdgpu_atomfirmware_get_uma_carveout_info(struct amdgpu_device *adev, 337 + struct amdgpu_uma_carveout_info *uma_info) 338 + { 339 + struct amdgpu_mode_info *mode_info = &adev->mode_info; 340 + union igp_info *igp_info; 341 + u16 data_offset, size; 342 + u8 frev, crev; 343 + int index; 344 + 345 + if (!(adev->flags & AMD_IS_APU)) 346 + return -ENODEV; 347 + 348 + index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, 349 + integratedsysteminfo); 350 + 351 + if (!amdgpu_atom_parse_data_header(mode_info->atom_context, 352 + index, &size, 353 + &frev, &crev, &data_offset)) { 354 + return -EINVAL; 355 + } 356 + 357 + igp_info = (union igp_info *) 358 + (mode_info->atom_context->bios + data_offset); 359 + 360 + switch (frev) { 361 + case 2: 362 + switch (crev) { 363 + case 3: 364 + return amdgpu_atomfirmware_get_uma_carveout_info_v2_3(adev, igp_info, uma_info); 365 + break; 366 + default: 367 + break; 368 + } 369 + break; 370 + default: 371 + break; 372 + } 373 + return -ENODEV; 374 + } 375 + 299 376 int 300 377 amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, 301 378 int *vram_width, int *vram_type,
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
··· 32 32 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev); 33 33 int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, 34 34 int *vram_width, int *vram_type, int *vram_vendor); 35 + int amdgpu_atomfirmware_get_uma_carveout_info(struct amdgpu_device *adev, 36 + struct amdgpu_uma_carveout_info *uma_info); 35 37 int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev); 36 38 int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev); 37 39 bool amdgpu_atomfirmware_mem_ecc_supported(struct amdgpu_device *adev);