aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2017-11-23 06:57:18 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 12:48:30 -0500
commitf3368128bacece315aa0384b54b7da9e6f0909cd (patch)
tree7b2654fc54b4847362c5b3281bb7512f155fe73f
parent341b759e642a847c3a88401db4263dec9f36d552 (diff)
drm/amdgpu: move validation of the VM size into the VM code
This moves validation of the VM size parameter into amdgpu_vm_adjust_size(). Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c16
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c13
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c6
7 files changed, 20 insertions, 24 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 748ecd74726d..cd74beb431c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1187,22 +1187,8 @@ static void amdgpu_check_vm_size(struct amdgpu_device *adev)
1187 if (amdgpu_vm_size < 1) { 1187 if (amdgpu_vm_size < 1) {
1188 dev_warn(adev->dev, "VM size (%d) too small, min is 1GB\n", 1188 dev_warn(adev->dev, "VM size (%d) too small, min is 1GB\n",
1189 amdgpu_vm_size); 1189 amdgpu_vm_size);
1190 goto def_value; 1190 amdgpu_vm_size = -1;
1191 } 1191 }
1192
1193 /*
1194 * Max GPUVM size for Cayman, SI, CI VI are 40 bits.
1195 */
1196 if (amdgpu_vm_size > 1024) {
1197 dev_warn(adev->dev, "VM size (%d) too large, max is 1TB\n",
1198 amdgpu_vm_size);
1199 goto def_value;
1200 }
1201
1202 return;
1203
1204def_value:
1205 amdgpu_vm_size = -1;
1206} 1192}
1207 1193
1208/** 1194/**
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 82a6f6c86aaf..44430c4820cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2580,13 +2580,22 @@ static uint32_t amdgpu_vm_get_block_size(uint64_t vm_size)
2580 * @vm_size: the default vm size if it's set auto 2580 * @vm_size: the default vm size if it's set auto
2581 */ 2581 */
2582void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, 2582void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size,
2583 uint32_t fragment_size_default, unsigned max_level) 2583 uint32_t fragment_size_default, unsigned max_level,
2584 unsigned max_bits)
2584{ 2585{
2585 uint64_t tmp; 2586 uint64_t tmp;
2586 2587
2587 /* adjust vm size first */ 2588 /* adjust vm size first */
2588 if (amdgpu_vm_size != -1) 2589 if (amdgpu_vm_size != -1) {
2590 unsigned max_size = 1 << (max_bits - 30);
2591
2589 vm_size = amdgpu_vm_size; 2592 vm_size = amdgpu_vm_size;
2593 if (vm_size > max_size) {
2594 dev_warn(adev->dev, "VM size (%d) too large, max is %u GB\n",
2595 amdgpu_vm_size, max_size);
2596 vm_size = max_size;
2597 }
2598 }
2590 2599
2591 adev->vm_manager.max_pfn = (uint64_t)vm_size << 18; 2600 adev->vm_manager.max_pfn = (uint64_t)vm_size << 18;
2592 2601
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 54e540d5e8d7..43ea131dd411 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -325,7 +325,8 @@ struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
325void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, 325void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,
326 struct amdgpu_bo_va *bo_va); 326 struct amdgpu_bo_va *bo_va);
327void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, 327void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size,
328 uint32_t fragment_size_default, unsigned max_level); 328 uint32_t fragment_size_default, unsigned max_level,
329 unsigned max_bits);
329int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp); 330int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
330bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring, 331bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
331 struct amdgpu_job *job); 332 struct amdgpu_job *job);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index 49224bf38324..468281f10e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -832,7 +832,7 @@ static int gmc_v6_0_sw_init(void *handle)
832 if (r) 832 if (r)
833 return r; 833 return r;
834 834
835 amdgpu_vm_adjust_size(adev, 64, 9, 1); 835 amdgpu_vm_adjust_size(adev, 64, 9, 1, 40);
836 836
837 adev->mc.mc_mask = 0xffffffffffULL; 837 adev->mc.mc_mask = 0xffffffffffULL;
838 838
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index c39cf8440afd..68a85051f4b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -971,7 +971,7 @@ static int gmc_v7_0_sw_init(void *handle)
971 * Currently set to 4GB ((1 << 20) 4k pages). 971 * Currently set to 4GB ((1 << 20) 4k pages).
972 * Max GPUVM size for cayman and SI is 40 bits. 972 * Max GPUVM size for cayman and SI is 40 bits.
973 */ 973 */
974 amdgpu_vm_adjust_size(adev, 64, 9, 1); 974 amdgpu_vm_adjust_size(adev, 64, 9, 1, 40);
975 975
976 /* Set the internal MC address mask 976 /* Set the internal MC address mask
977 * This is the max address of the GPU's 977 * This is the max address of the GPU's
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 421e751a0464..46ec97e70e5c 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -1068,7 +1068,7 @@ static int gmc_v8_0_sw_init(void *handle)
1068 * Currently set to 4GB ((1 << 20) 4k pages). 1068 * Currently set to 4GB ((1 << 20) 4k pages).
1069 * Max GPUVM size for cayman and SI is 40 bits. 1069 * Max GPUVM size for cayman and SI is 40 bits.
1070 */ 1070 */
1071 amdgpu_vm_adjust_size(adev, 64, 9, 1); 1071 amdgpu_vm_adjust_size(adev, 64, 9, 1, 40);
1072 1072
1073 /* Set the internal MC address mask 1073 /* Set the internal MC address mask
1074 * This is the max address of the GPU's 1074 * This is the max address of the GPU's
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 729e4d591293..cc972153d401 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -770,10 +770,10 @@ static int gmc_v9_0_sw_init(void *handle)
770 case CHIP_RAVEN: 770 case CHIP_RAVEN:
771 adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; 771 adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN;
772 if (adev->rev_id == 0x0 || adev->rev_id == 0x1) 772 if (adev->rev_id == 0x0 || adev->rev_id == 0x1)
773 amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3); 773 amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48);
774 else 774 else
775 /* vm_size is 64GB for legacy 2-level page support */ 775 /* vm_size is 64GB for legacy 2-level page support */
776 amdgpu_vm_adjust_size(adev, 64, 9, 1); 776 amdgpu_vm_adjust_size(adev, 64, 9, 1, 48);
777 break; 777 break;
778 case CHIP_VEGA10: 778 case CHIP_VEGA10:
779 /* XXX Don't know how to get VRAM type yet. */ 779 /* XXX Don't know how to get VRAM type yet. */
@@ -783,7 +783,7 @@ static int gmc_v9_0_sw_init(void *handle)
783 * vm size is 256TB (48bit), maximum size of Vega10, 783 * vm size is 256TB (48bit), maximum size of Vega10,
784 * block size 512 (9bit) 784 * block size 512 (9bit)
785 */ 785 */
786 amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3); 786 amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48);
787 break; 787 break;
788 default: 788 default:
789 break; 789 break;