Commit e0adf6c8 authored by Junwei Zhang's avatar Junwei Zhang Committed by Alex Deucher

drm/amd/amdgpu: unify memory query info interface

Signed-off-by: default avatarJunwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6a7f76e7
...@@ -411,32 +411,34 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file ...@@ -411,32 +411,34 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
return copy_to_user(out, &vram_gtt, return copy_to_user(out, &vram_gtt,
min((size_t)size, sizeof(vram_gtt))) ? -EFAULT : 0; min((size_t)size, sizeof(vram_gtt))) ? -EFAULT : 0;
} }
case AMDGPU_INFO_VRAM_GTT_TOTAL: { case AMDGPU_INFO_MEMORY: {
struct drm_amdgpu_info_vram_gtt_total vram_gtt_total; struct drm_amdgpu_memory_info mem;
vram_gtt_total.vram_total_size = adev->mc.real_vram_size; memset(&mem, 0, sizeof(mem));
vram_gtt_total.vram_cpu_accessible_total_size = adev->mc.visible_vram_size; mem.vram.total_heap_size = adev->mc.real_vram_size;
vram_gtt_total.gtt_total_size = adev->mc.gtt_size; mem.vram.usable_heap_size =
return copy_to_user(out, &vram_gtt_total, adev->mc.real_vram_size - adev->vram_pin_size;
min((size_t)size, sizeof(vram_gtt_total))) mem.vram.heap_usage = atomic64_read(&adev->vram_usage);
? -EFAULT : 0; mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4;
}
case AMDGPU_INFO_VRAM_GTT_MAX: { mem.cpu_accessible_vram.total_heap_size =
struct drm_amdgpu_info_vram_gtt_max vram_gtt_max; adev->mc.visible_vram_size;
u64 max_size; mem.cpu_accessible_vram.usable_heap_size =
adev->mc.visible_vram_size -
max_size = adev->mc.real_vram_size - adev->vram_pin_size; (adev->vram_pin_size - adev->invisible_pin_size);
vram_gtt_max.vram_max_size = max_size * 3 / 4; mem.cpu_accessible_vram.heap_usage =
atomic64_read(&adev->vram_vis_usage);
max_size = adev->mc.visible_vram_size - (adev->vram_pin_size - mem.cpu_accessible_vram.max_allocation =
adev->invisible_pin_size); mem.cpu_accessible_vram.usable_heap_size * 3 / 4;
vram_gtt_max.vram_cpu_accessible_max_size = max_size * 3 / 4;
mem.gtt.total_heap_size = adev->mc.gtt_size;
max_size = adev->mc.gtt_size - adev->gart_pin_size; mem.gtt.usable_heap_size =
vram_gtt_max.gtt_max_size = max_size * 3 / 4; adev->mc.gtt_size - adev->gart_pin_size;
mem.gtt.heap_usage = atomic64_read(&adev->gtt_usage);
return copy_to_user(out, &vram_gtt_max, mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4;
min((size_t)size, sizeof(vram_gtt_max)))
return copy_to_user(out, &mem,
min((size_t)size, sizeof(mem)))
? -EFAULT : 0; ? -EFAULT : 0;
} }
case AMDGPU_INFO_READ_MMR_REG: { case AMDGPU_INFO_READ_MMR_REG: {
......
...@@ -489,10 +489,8 @@ struct drm_amdgpu_cs_chunk_data { ...@@ -489,10 +489,8 @@ struct drm_amdgpu_cs_chunk_data {
#define AMDGPU_INFO_VIS_VRAM_USAGE 0x17 #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
/* number of TTM buffer evictions */ /* number of TTM buffer evictions */
#define AMDGPU_INFO_NUM_EVICTIONS 0x18 #define AMDGPU_INFO_NUM_EVICTIONS 0x18
/* Query the total size of VRAM and GTT domains */ /* Query memory about VRAM and GTT domains */
#define AMDGPU_INFO_VRAM_GTT_TOTAL 0x19 #define AMDGPU_INFO_MEMORY 0x19
/* Query the max allocation size of VRAM and GTT domains */
#define AMDGPU_INFO_VRAM_GTT_MAX 0x1a
#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
...@@ -578,16 +576,32 @@ struct drm_amdgpu_info_vram_gtt { ...@@ -578,16 +576,32 @@ struct drm_amdgpu_info_vram_gtt {
__u64 gtt_size; __u64 gtt_size;
}; };
struct drm_amdgpu_info_vram_gtt_total { struct drm_amdgpu_heap_info {
__u64 vram_total_size; /** max. physical memory */
__u64 vram_cpu_accessible_total_size; __u64 total_heap_size;
__u64 gtt_total_size;
/** Theoretical max. available memory in the given heap */
__u64 usable_heap_size;
/**
* Number of bytes allocated in the heap. This includes all processes
* and private allocations in the kernel. It changes when new buffers
* are allocated, freed, and moved. It cannot be larger than
* heap_size.
*/
__u64 heap_usage;
/**
* Theoretical possible max. size of buffer which
* could be allocated in the given heap
*/
__u64 max_allocation;
}; };
struct drm_amdgpu_info_vram_gtt_max { struct drm_amdgpu_memory_info {
__u64 vram_max_size; struct drm_amdgpu_heap_info vram;
__u64 vram_cpu_accessible_max_size; struct drm_amdgpu_heap_info cpu_accessible_vram;
__u64 gtt_max_size; struct drm_amdgpu_heap_info gtt;
}; };
struct drm_amdgpu_info_firmware { struct drm_amdgpu_info_firmware {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment