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

drm/amd/amdgpu: add info about vram and gtt max allocation size

Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Junwei Zhang and committed by
Alex Deucher
cfa32556 9f6163e7

+26
+18
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 421 421 min((size_t)size, sizeof(vram_gtt_total))) 422 422 ? -EFAULT : 0; 423 423 } 424 + case AMDGPU_INFO_VRAM_GTT_MAX: { 425 + struct drm_amdgpu_info_vram_gtt_max vram_gtt_max; 426 + u64 max_size; 427 + 428 + max_size = adev->mc.real_vram_size - adev->vram_pin_size; 429 + vram_gtt_max.vram_max_size = max_size * 3 / 4; 430 + 431 + max_size = adev->mc.visible_vram_size - (adev->vram_pin_size - 432 + adev->invisible_pin_size); 433 + vram_gtt_max.vram_cpu_accessible_max_size = max_size * 3 / 4; 434 + 435 + max_size = adev->mc.gtt_size - adev->gart_pin_size; 436 + vram_gtt_max.gtt_max_size = max_size * 3 / 4; 437 + 438 + return copy_to_user(out, &vram_gtt_max, 439 + min((size_t)size, sizeof(vram_gtt_max))) 440 + ? -EFAULT : 0; 441 + } 424 442 case AMDGPU_INFO_READ_MMR_REG: { 425 443 unsigned n, alloc_size; 426 444 uint32_t *regs;
+8
include/uapi/drm/amdgpu_drm.h
··· 489 489 #define AMDGPU_INFO_NUM_EVICTIONS 0x18 490 490 /* Query the total size of VRAM and GTT domains */ 491 491 #define AMDGPU_INFO_VRAM_GTT_TOTAL 0x19 492 + /* Query the max allocation size of VRAM and GTT domains */ 493 + #define AMDGPU_INFO_VRAM_GTT_MAX 0x1a 492 494 493 495 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0 494 496 #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff ··· 580 578 __u64 vram_total_size; 581 579 __u64 vram_cpu_accessible_total_size; 582 580 __u64 gtt_total_size; 581 + }; 582 + 583 + struct drm_amdgpu_info_vram_gtt_max { 584 + __u64 vram_max_size; 585 + __u64 vram_cpu_accessible_max_size; 586 + __u64 gtt_max_size; 583 587 }; 584 588 585 589 struct drm_amdgpu_info_firmware {