diff options
author | Christian König <christian.koenig@amd.com> | 2014-07-18 02:56:40 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2014-07-21 13:17:38 -0400 |
commit | 036bf46a3962c87fc6ab5e6dbc65f469730b4cf0 (patch) | |
tree | f104f7912d7127ebfd81362c9194a5c2ddfc83a2 /drivers/gpu | |
parent | 20b2656d7e644c8673f2b9944a0e65249e0ae555 (diff) |
drm/radeon: fix handling of radeon_vm_bo_rmv v3
v3: completely rewritten. We now just remember which areas
of the PT to clear and do so on the next command submission.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=79980
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_cs.c | 22 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_vm.c | 82 |
3 files changed, 86 insertions, 31 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index b7204500a9a6..3d5e1a93b947 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -449,6 +449,7 @@ struct radeon_bo_va { | |||
449 | 449 | ||
450 | /* protected by vm mutex */ | 450 | /* protected by vm mutex */ |
451 | struct list_head vm_list; | 451 | struct list_head vm_list; |
452 | struct list_head vm_status; | ||
452 | 453 | ||
453 | /* constant after initialization */ | 454 | /* constant after initialization */ |
454 | struct radeon_vm *vm; | 455 | struct radeon_vm *vm; |
@@ -867,6 +868,9 @@ struct radeon_vm { | |||
867 | struct list_head va; | 868 | struct list_head va; |
868 | unsigned id; | 869 | unsigned id; |
869 | 870 | ||
871 | /* BOs freed, but not yet updated in the PT */ | ||
872 | struct list_head freed; | ||
873 | |||
870 | /* contains the page directory */ | 874 | /* contains the page directory */ |
871 | struct radeon_bo *page_directory; | 875 | struct radeon_bo *page_directory; |
872 | uint64_t pd_gpu_addr; | 876 | uint64_t pd_gpu_addr; |
@@ -2832,9 +2836,10 @@ void radeon_vm_fence(struct radeon_device *rdev, | |||
2832 | uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); | 2836 | uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); |
2833 | int radeon_vm_update_page_directory(struct radeon_device *rdev, | 2837 | int radeon_vm_update_page_directory(struct radeon_device *rdev, |
2834 | struct radeon_vm *vm); | 2838 | struct radeon_vm *vm); |
2839 | int radeon_vm_clear_freed(struct radeon_device *rdev, | ||
2840 | struct radeon_vm *vm); | ||
2835 | int radeon_vm_bo_update(struct radeon_device *rdev, | 2841 | int radeon_vm_bo_update(struct radeon_device *rdev, |
2836 | struct radeon_vm *vm, | 2842 | struct radeon_bo_va *bo_va, |
2837 | struct radeon_bo *bo, | ||
2838 | struct ttm_mem_reg *mem); | 2843 | struct ttm_mem_reg *mem); |
2839 | void radeon_vm_bo_invalidate(struct radeon_device *rdev, | 2844 | void radeon_vm_bo_invalidate(struct radeon_device *rdev, |
2840 | struct radeon_bo *bo); | 2845 | struct radeon_bo *bo); |
@@ -2847,8 +2852,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev, | |||
2847 | struct radeon_bo_va *bo_va, | 2852 | struct radeon_bo_va *bo_va, |
2848 | uint64_t offset, | 2853 | uint64_t offset, |
2849 | uint32_t flags); | 2854 | uint32_t flags); |
2850 | int radeon_vm_bo_rmv(struct radeon_device *rdev, | 2855 | void radeon_vm_bo_rmv(struct radeon_device *rdev, |
2851 | struct radeon_bo_va *bo_va); | 2856 | struct radeon_bo_va *bo_va); |
2852 | 2857 | ||
2853 | /* audio */ | 2858 | /* audio */ |
2854 | void r600_audio_update_hdmi(struct work_struct *work); | 2859 | void r600_audio_update_hdmi(struct work_struct *work); |
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 71a143461478..09fcf4dcdfdb 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
@@ -461,14 +461,24 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p, | |||
461 | struct radeon_vm *vm) | 461 | struct radeon_vm *vm) |
462 | { | 462 | { |
463 | struct radeon_device *rdev = p->rdev; | 463 | struct radeon_device *rdev = p->rdev; |
464 | struct radeon_bo_va *bo_va; | ||
464 | int i, r; | 465 | int i, r; |
465 | 466 | ||
466 | r = radeon_vm_update_page_directory(rdev, vm); | 467 | r = radeon_vm_update_page_directory(rdev, vm); |
467 | if (r) | 468 | if (r) |
468 | return r; | 469 | return r; |
469 | 470 | ||
470 | r = radeon_vm_bo_update(rdev, vm, rdev->ring_tmp_bo.bo, | 471 | r = radeon_vm_clear_freed(rdev, vm); |
471 | &rdev->ring_tmp_bo.bo->tbo.mem); | 472 | if (r) |
473 | return r; | ||
474 | |||
475 | bo_va = radeon_vm_bo_find(vm, rdev->ring_tmp_bo.bo); | ||
476 | if (bo_va == NULL) { | ||
477 | DRM_ERROR("Tmp BO not in VM!\n"); | ||
478 | return -EINVAL; | ||
479 | } | ||
480 | |||
481 | r = radeon_vm_bo_update(rdev, bo_va, &rdev->ring_tmp_bo.bo->tbo.mem); | ||
472 | if (r) | 482 | if (r) |
473 | return r; | 483 | return r; |
474 | 484 | ||
@@ -480,7 +490,13 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p, | |||
480 | continue; | 490 | continue; |
481 | 491 | ||
482 | bo = p->relocs[i].robj; | 492 | bo = p->relocs[i].robj; |
483 | r = radeon_vm_bo_update(rdev, vm, bo, &bo->tbo.mem); | 493 | bo_va = radeon_vm_bo_find(vm, bo); |
494 | if (bo_va == NULL) { | ||
495 | dev_err(rdev->dev, "bo %p not in vm %p\n", bo, vm); | ||
496 | return -EINVAL; | ||
497 | } | ||
498 | |||
499 | r = radeon_vm_bo_update(rdev, bo_va, &bo->tbo.mem); | ||
484 | if (r) | 500 | if (r) |
485 | return r; | 501 | return r; |
486 | } | 502 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c index eecff6bbd341..2726b46ac819 100644 --- a/drivers/gpu/drm/radeon/radeon_vm.c +++ b/drivers/gpu/drm/radeon/radeon_vm.c | |||
@@ -332,6 +332,7 @@ struct radeon_bo_va *radeon_vm_bo_add(struct radeon_device *rdev, | |||
332 | bo_va->ref_count = 1; | 332 | bo_va->ref_count = 1; |
333 | INIT_LIST_HEAD(&bo_va->bo_list); | 333 | INIT_LIST_HEAD(&bo_va->bo_list); |
334 | INIT_LIST_HEAD(&bo_va->vm_list); | 334 | INIT_LIST_HEAD(&bo_va->vm_list); |
335 | INIT_LIST_HEAD(&bo_va->vm_status); | ||
335 | 336 | ||
336 | mutex_lock(&vm->mutex); | 337 | mutex_lock(&vm->mutex); |
337 | list_add(&bo_va->vm_list, &vm->va); | 338 | list_add(&bo_va->vm_list, &vm->va); |
@@ -468,6 +469,15 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev, | |||
468 | head = &tmp->vm_list; | 469 | head = &tmp->vm_list; |
469 | } | 470 | } |
470 | 471 | ||
472 | if (bo_va->soffset) { | ||
473 | /* add a clone of the bo_va to clear the old address */ | ||
474 | tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL); | ||
475 | tmp->soffset = bo_va->soffset; | ||
476 | tmp->eoffset = bo_va->eoffset; | ||
477 | tmp->vm = vm; | ||
478 | list_add(&tmp->vm_status, &vm->freed); | ||
479 | } | ||
480 | |||
471 | bo_va->soffset = soffset; | 481 | bo_va->soffset = soffset; |
472 | bo_va->eoffset = eoffset; | 482 | bo_va->eoffset = eoffset; |
473 | bo_va->flags = flags; | 483 | bo_va->flags = flags; |
@@ -823,25 +833,19 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev, | |||
823 | * Object have to be reserved and mutex must be locked! | 833 | * Object have to be reserved and mutex must be locked! |
824 | */ | 834 | */ |
825 | int radeon_vm_bo_update(struct radeon_device *rdev, | 835 | int radeon_vm_bo_update(struct radeon_device *rdev, |
826 | struct radeon_vm *vm, | 836 | struct radeon_bo_va *bo_va, |
827 | struct radeon_bo *bo, | ||
828 | struct ttm_mem_reg *mem) | 837 | struct ttm_mem_reg *mem) |
829 | { | 838 | { |
839 | struct radeon_vm *vm = bo_va->vm; | ||
830 | struct radeon_ib ib; | 840 | struct radeon_ib ib; |
831 | struct radeon_bo_va *bo_va; | ||
832 | unsigned nptes, ndw; | 841 | unsigned nptes, ndw; |
833 | uint64_t addr; | 842 | uint64_t addr; |
834 | int r; | 843 | int r; |
835 | 844 | ||
836 | bo_va = radeon_vm_bo_find(vm, bo); | ||
837 | if (bo_va == NULL) { | ||
838 | dev_err(rdev->dev, "bo %p not in vm %p\n", bo, vm); | ||
839 | return -EINVAL; | ||
840 | } | ||
841 | 845 | ||
842 | if (!bo_va->soffset) { | 846 | if (!bo_va->soffset) { |
843 | dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n", | 847 | dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n", |
844 | bo, vm); | 848 | bo_va->bo, vm); |
845 | return -EINVAL; | 849 | return -EINVAL; |
846 | } | 850 | } |
847 | 851 | ||
@@ -868,7 +872,7 @@ int radeon_vm_bo_update(struct radeon_device *rdev, | |||
868 | 872 | ||
869 | trace_radeon_vm_bo_update(bo_va); | 873 | trace_radeon_vm_bo_update(bo_va); |
870 | 874 | ||
871 | nptes = radeon_bo_ngpu_pages(bo); | 875 | nptes = (bo_va->eoffset - bo_va->soffset) / RADEON_GPU_PAGE_SIZE; |
872 | 876 | ||
873 | /* padding, etc. */ | 877 | /* padding, etc. */ |
874 | ndw = 64; | 878 | ndw = 64; |
@@ -911,33 +915,61 @@ int radeon_vm_bo_update(struct radeon_device *rdev, | |||
911 | } | 915 | } |
912 | 916 | ||
913 | /** | 917 | /** |
918 | * radeon_vm_clear_freed - clear freed BOs in the PT | ||
919 | * | ||
920 | * @rdev: radeon_device pointer | ||
921 | * @vm: requested vm | ||
922 | * | ||
923 | * Make sure all freed BOs are cleared in the PT. | ||
924 | * Returns 0 for success. | ||
925 | * | ||
926 | * PTs have to be reserved and mutex must be locked! | ||
927 | */ | ||
928 | int radeon_vm_clear_freed(struct radeon_device *rdev, | ||
929 | struct radeon_vm *vm) | ||
930 | { | ||
931 | struct radeon_bo_va *bo_va, *tmp; | ||
932 | int r; | ||
933 | |||
934 | list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status) { | ||
935 | list_del(&bo_va->vm_status); | ||
936 | r = radeon_vm_bo_update(rdev, bo_va, NULL); | ||
937 | kfree(bo_va); | ||
938 | if (r) | ||
939 | return r; | ||
940 | } | ||
941 | return 0; | ||
942 | |||
943 | } | ||
944 | |||
945 | /** | ||
914 | * radeon_vm_bo_rmv - remove a bo to a specific vm | 946 | * radeon_vm_bo_rmv - remove a bo to a specific vm |
915 | * | 947 | * |
916 | * @rdev: radeon_device pointer | 948 | * @rdev: radeon_device pointer |
917 | * @bo_va: requested bo_va | 949 | * @bo_va: requested bo_va |
918 | * | 950 | * |
919 | * Remove @bo_va->bo from the requested vm (cayman+). | 951 | * Remove @bo_va->bo from the requested vm (cayman+). |
920 | * Remove @bo_va->bo from the list of bos associated with the bo_va->vm and | ||
921 | * remove the ptes for @bo_va in the page table. | ||
922 | * Returns 0 for success. | ||
923 | * | 952 | * |
924 | * Object have to be reserved! | 953 | * Object have to be reserved! |
925 | */ | 954 | */ |
926 | int radeon_vm_bo_rmv(struct radeon_device *rdev, | 955 | void radeon_vm_bo_rmv(struct radeon_device *rdev, |
927 | struct radeon_bo_va *bo_va) | 956 | struct radeon_bo_va *bo_va) |
928 | { | 957 | { |
929 | int r = 0; | 958 | struct radeon_vm *vm = bo_va->vm; |
930 | 959 | ||
931 | mutex_lock(&bo_va->vm->mutex); | 960 | list_del(&bo_va->bo_list); |
932 | if (bo_va->soffset) | ||
933 | r = radeon_vm_bo_update(rdev, bo_va->vm, bo_va->bo, NULL); | ||
934 | 961 | ||
962 | mutex_lock(&vm->mutex); | ||
935 | list_del(&bo_va->vm_list); | 963 | list_del(&bo_va->vm_list); |
936 | mutex_unlock(&bo_va->vm->mutex); | ||
937 | list_del(&bo_va->bo_list); | ||
938 | 964 | ||
939 | kfree(bo_va); | 965 | if (bo_va->soffset) { |
940 | return r; | 966 | bo_va->bo = NULL; |
967 | list_add(&bo_va->vm_status, &vm->freed); | ||
968 | } else { | ||
969 | kfree(bo_va); | ||
970 | } | ||
971 | |||
972 | mutex_unlock(&vm->mutex); | ||
941 | } | 973 | } |
942 | 974 | ||
943 | /** | 975 | /** |
@@ -980,6 +1012,7 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm) | |||
980 | vm->last_id_use = NULL; | 1012 | vm->last_id_use = NULL; |
981 | mutex_init(&vm->mutex); | 1013 | mutex_init(&vm->mutex); |
982 | INIT_LIST_HEAD(&vm->va); | 1014 | INIT_LIST_HEAD(&vm->va); |
1015 | INIT_LIST_HEAD(&vm->freed); | ||
983 | 1016 | ||
984 | pd_size = radeon_vm_directory_size(rdev); | 1017 | pd_size = radeon_vm_directory_size(rdev); |
985 | pd_entries = radeon_vm_num_pdes(rdev); | 1018 | pd_entries = radeon_vm_num_pdes(rdev); |
@@ -1034,7 +1067,8 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm) | |||
1034 | kfree(bo_va); | 1067 | kfree(bo_va); |
1035 | } | 1068 | } |
1036 | } | 1069 | } |
1037 | 1070 | list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status) | |
1071 | kfree(bo_va); | ||
1038 | 1072 | ||
1039 | for (i = 0; i < radeon_vm_num_pdes(rdev); i++) | 1073 | for (i = 0; i < radeon_vm_num_pdes(rdev); i++) |
1040 | radeon_bo_unref(&vm->page_tables[i].bo); | 1074 | radeon_bo_unref(&vm->page_tables[i].bo); |