aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-04-10 17:31:18 -0400
committerDave Airlie <airlied@redhat.com>2017-04-10 17:31:18 -0400
commit1420f63b8207e966f54caec26d08abdc2ff37193 (patch)
treeeabaabbcaf7a39e36267a68f867f21504250fee5 /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
parent2b2fc72aa51ba20f047d4825f8ea3e0d9306d8fb (diff)
parent32df87dff04833bbf53f1750f6c6048192ed29bf (diff)
Merge branch 'drm-next-4.12' of git://people.freedesktop.org/~agd5f/linux into drm-next
Just some bug fixes and vega10 updates for 4.12. * 'drm-next-4.12' of git://people.freedesktop.org/~agd5f/linux: drm/amdgpu: fix fence memory leak in wait_all_fence V2 drm/amdgpu: fix "fix 64bit division" drm/amd/powerplay: add fan controller table v11 support. drm/amd/powerplay: port newest process pptable code for vega10. drm/amdgpu: set vm size and block size by individual gmc by default (v3) drm/amdgpu: Avoid overflows/divide-by-zero in latency_watermark calculations. drm/amdgpu: Make display watermark calculations more accurate drm/radeon: fix typo in bandwidth calculation drm/radeon: Refuse to migrate a prime BO to VRAM. (v2) drm/radeon: Maintain prime import/export refcount for BOs drm/amdgpu: Refuse to pin or change acceptable domains of prime BOs to VRAM. (v2) drm/amdgpu: Fail fb creation from imported dma-bufs. (v2) drm/radeon: Fail fb creation from imported dma-bufs.
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 2895d9d86f29..7ed5302b511a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2064,6 +2064,44 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
2064 } 2064 }
2065} 2065}
2066 2066
2067static uint32_t amdgpu_vm_get_block_size(uint64_t vm_size)
2068{
2069 /* Total bits covered by PD + PTs */
2070 unsigned bits = ilog2(vm_size) + 18;
2071
2072 /* Make sure the PD is 4K in size up to 8GB address space.
2073 Above that split equal between PD and PTs */
2074 if (vm_size <= 8)
2075 return (bits - 9);
2076 else
2077 return ((bits + 3) / 2);
2078}
2079
2080/**
2081 * amdgpu_vm_adjust_size - adjust vm size and block size
2082 *
2083 * @adev: amdgpu_device pointer
2084 * @vm_size: the default vm size if it's set auto
2085 */
2086void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size)
2087{
2088 /* adjust vm size firstly */
2089 if (amdgpu_vm_size == -1)
2090 adev->vm_manager.vm_size = vm_size;
2091 else
2092 adev->vm_manager.vm_size = amdgpu_vm_size;
2093
2094 /* block size depends on vm size */
2095 if (amdgpu_vm_block_size == -1)
2096 adev->vm_manager.block_size =
2097 amdgpu_vm_get_block_size(adev->vm_manager.vm_size);
2098 else
2099 adev->vm_manager.block_size = amdgpu_vm_block_size;
2100
2101 DRM_INFO("vm size is %llu GB, block size is %u-bit\n",
2102 adev->vm_manager.vm_size, adev->vm_manager.block_size);
2103}
2104
2067/** 2105/**
2068 * amdgpu_vm_init - initialize a vm instance 2106 * amdgpu_vm_init - initialize a vm instance
2069 * 2107 *