diff options
author | Christian König <christian.koenig@amd.com> | 2016-08-12 07:29:18 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-08-16 10:44:45 -0400 |
commit | afef8b8f99b6489ae1e9fe535d74bf2ce9fa17bd (patch) | |
tree | 926f32e39cff4e7a628803abb68fb9c228bfcd0f /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |
parent | 96105e5375892f63cc56fa707a1db0d74abc764d (diff) |
drm/amdgpu: add function pointer to the pte_update_params
Remember what function to call while planning the commands instead
of figuring it our later on.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 76 |
1 files changed, 54 insertions, 22 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 673c258e49db..7ca2e8fa5906 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -61,6 +61,10 @@ struct amdgpu_pte_update_params { | |||
61 | uint64_t src; | 61 | uint64_t src; |
62 | /* indirect buffer to fill with commands */ | 62 | /* indirect buffer to fill with commands */ |
63 | struct amdgpu_ib *ib; | 63 | struct amdgpu_ib *ib; |
64 | /* Function which actually does the update */ | ||
65 | void (*func)(struct amdgpu_pte_update_params *params, uint64_t pe, | ||
66 | uint64_t addr, unsigned count, uint32_t incr, | ||
67 | uint32_t flags); | ||
64 | }; | 68 | }; |
65 | 69 | ||
66 | /** | 70 | /** |
@@ -464,7 +468,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, | |||
464 | } | 468 | } |
465 | 469 | ||
466 | /** | 470 | /** |
467 | * amdgpu_vm_update_pages - helper to call the right asic function | 471 | * amdgpu_vm_do_set_ptes - helper to call the right asic function |
468 | * | 472 | * |
469 | * @params: see amdgpu_pte_update_params definition | 473 | * @params: see amdgpu_pte_update_params definition |
470 | * @pe: addr of the page entry | 474 | * @pe: addr of the page entry |
@@ -476,18 +480,14 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, | |||
476 | * Traces the parameters and calls the right asic functions | 480 | * Traces the parameters and calls the right asic functions |
477 | * to setup the page table using the DMA. | 481 | * to setup the page table using the DMA. |
478 | */ | 482 | */ |
479 | static void amdgpu_vm_update_pages(struct amdgpu_pte_update_params *params, | 483 | static void amdgpu_vm_do_set_ptes(struct amdgpu_pte_update_params *params, |
480 | uint64_t pe, uint64_t addr, | 484 | uint64_t pe, uint64_t addr, |
481 | unsigned count, uint32_t incr, | 485 | unsigned count, uint32_t incr, |
482 | uint32_t flags) | 486 | uint32_t flags) |
483 | { | 487 | { |
484 | trace_amdgpu_vm_set_page(pe, addr, count, incr, flags); | 488 | trace_amdgpu_vm_set_page(pe, addr, count, incr, flags); |
485 | 489 | ||
486 | if (params->src) { | 490 | if (count < 3) { |
487 | amdgpu_vm_copy_pte(params->adev, params->ib, | ||
488 | pe, (params->src + (addr >> 12) * 8), count); | ||
489 | |||
490 | } else if (count < 3) { | ||
491 | amdgpu_vm_write_pte(params->adev, params->ib, pe, | 491 | amdgpu_vm_write_pte(params->adev, params->ib, pe, |
492 | addr | flags, count, incr); | 492 | addr | flags, count, incr); |
493 | 493 | ||
@@ -498,6 +498,29 @@ static void amdgpu_vm_update_pages(struct amdgpu_pte_update_params *params, | |||
498 | } | 498 | } |
499 | 499 | ||
500 | /** | 500 | /** |
501 | * amdgpu_vm_do_copy_ptes - copy the PTEs from the GART | ||
502 | * | ||
503 | * @params: see amdgpu_pte_update_params definition | ||
504 | * @pe: addr of the page entry | ||
505 | * @addr: dst addr to write into pe | ||
506 | * @count: number of page entries to update | ||
507 | * @incr: increase next addr by incr bytes | ||
508 | * @flags: hw access flags | ||
509 | * | ||
510 | * Traces the parameters and calls the DMA function to copy the PTEs. | ||
511 | */ | ||
512 | static void amdgpu_vm_do_copy_ptes(struct amdgpu_pte_update_params *params, | ||
513 | uint64_t pe, uint64_t addr, | ||
514 | unsigned count, uint32_t incr, | ||
515 | uint32_t flags) | ||
516 | { | ||
517 | trace_amdgpu_vm_set_page(pe, addr, count, incr, flags); | ||
518 | |||
519 | amdgpu_vm_copy_pte(params->adev, params->ib, pe, | ||
520 | (params->src + (addr >> 12) * 8), count); | ||
521 | } | ||
522 | |||
523 | /** | ||
501 | * amdgpu_vm_clear_bo - initially clear the page dir/table | 524 | * amdgpu_vm_clear_bo - initially clear the page dir/table |
502 | * | 525 | * |
503 | * @adev: amdgpu_device pointer | 526 | * @adev: amdgpu_device pointer |
@@ -537,7 +560,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev, | |||
537 | memset(¶ms, 0, sizeof(params)); | 560 | memset(¶ms, 0, sizeof(params)); |
538 | params.adev = adev; | 561 | params.adev = adev; |
539 | params.ib = &job->ibs[0]; | 562 | params.ib = &job->ibs[0]; |
540 | amdgpu_vm_update_pages(¶ms, addr, 0, entries, 0, 0); | 563 | amdgpu_vm_do_set_ptes(¶ms, addr, 0, entries, 0, 0); |
541 | amdgpu_ring_pad_ib(ring, &job->ibs[0]); | 564 | amdgpu_ring_pad_ib(ring, &job->ibs[0]); |
542 | 565 | ||
543 | WARN_ON(job->ibs[0].length_dw > 64); | 566 | WARN_ON(job->ibs[0].length_dw > 64); |
@@ -643,9 +666,9 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, | |||
643 | (count == AMDGPU_VM_MAX_UPDATE_SIZE)) { | 666 | (count == AMDGPU_VM_MAX_UPDATE_SIZE)) { |
644 | 667 | ||
645 | if (count) { | 668 | if (count) { |
646 | amdgpu_vm_update_pages(¶ms, last_pde, | 669 | amdgpu_vm_do_set_ptes(¶ms, last_pde, |
647 | last_pt, count, incr, | 670 | last_pt, count, incr, |
648 | AMDGPU_PTE_VALID); | 671 | AMDGPU_PTE_VALID); |
649 | } | 672 | } |
650 | 673 | ||
651 | count = 1; | 674 | count = 1; |
@@ -657,8 +680,8 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, | |||
657 | } | 680 | } |
658 | 681 | ||
659 | if (count) | 682 | if (count) |
660 | amdgpu_vm_update_pages(¶ms, last_pde, last_pt, | 683 | amdgpu_vm_do_set_ptes(¶ms, last_pde, last_pt, |
661 | count, incr, AMDGPU_PTE_VALID); | 684 | count, incr, AMDGPU_PTE_VALID); |
662 | 685 | ||
663 | if (params.ib->length_dw != 0) { | 686 | if (params.ib->length_dw != 0) { |
664 | amdgpu_ring_pad_ib(ring, params.ib); | 687 | amdgpu_ring_pad_ib(ring, params.ib); |
@@ -747,14 +770,13 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, | |||
747 | if ((cur_pe_start + 8 * cur_nptes) == next_pe_start && | 770 | if ((cur_pe_start + 8 * cur_nptes) == next_pe_start && |
748 | ((cur_nptes + nptes) <= AMDGPU_VM_MAX_UPDATE_SIZE)) { | 771 | ((cur_nptes + nptes) <= AMDGPU_VM_MAX_UPDATE_SIZE)) { |
749 | /* The next ptb is consecutive to current ptb. | 772 | /* The next ptb is consecutive to current ptb. |
750 | * Don't call amdgpu_vm_update_pages now. | 773 | * Don't call the update function now. |
751 | * Will update two ptbs together in future. | 774 | * Will update two ptbs together in future. |
752 | */ | 775 | */ |
753 | cur_nptes += nptes; | 776 | cur_nptes += nptes; |
754 | } else { | 777 | } else { |
755 | amdgpu_vm_update_pages(params, cur_pe_start, cur_dst, | 778 | params->func(params, cur_pe_start, cur_dst, cur_nptes, |
756 | cur_nptes, AMDGPU_GPU_PAGE_SIZE, | 779 | AMDGPU_GPU_PAGE_SIZE, flags); |
757 | flags); | ||
758 | 780 | ||
759 | cur_pe_start = next_pe_start; | 781 | cur_pe_start = next_pe_start; |
760 | cur_nptes = nptes; | 782 | cur_nptes = nptes; |
@@ -766,8 +788,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, | |||
766 | dst += nptes * AMDGPU_GPU_PAGE_SIZE; | 788 | dst += nptes * AMDGPU_GPU_PAGE_SIZE; |
767 | } | 789 | } |
768 | 790 | ||
769 | amdgpu_vm_update_pages(params, cur_pe_start, cur_dst, cur_nptes, | 791 | params->func(params, cur_pe_start, cur_dst, cur_nptes, |
770 | AMDGPU_GPU_PAGE_SIZE, flags); | 792 | AMDGPU_GPU_PAGE_SIZE, flags); |
771 | } | 793 | } |
772 | 794 | ||
773 | /* | 795 | /* |
@@ -875,6 +897,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
875 | struct fence *f = NULL; | 897 | struct fence *f = NULL; |
876 | int r; | 898 | int r; |
877 | 899 | ||
900 | memset(¶ms, 0, sizeof(params)); | ||
901 | params.adev = adev; | ||
902 | params.src = src; | ||
903 | |||
878 | ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); | 904 | ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); |
879 | 905 | ||
880 | memset(¶ms, 0, sizeof(params)); | 906 | memset(¶ms, 0, sizeof(params)); |
@@ -900,6 +926,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
900 | /* only copy commands needed */ | 926 | /* only copy commands needed */ |
901 | ndw += ncmds * 7; | 927 | ndw += ncmds * 7; |
902 | 928 | ||
929 | params.func = amdgpu_vm_do_copy_ptes; | ||
930 | |||
903 | } else if (pages_addr) { | 931 | } else if (pages_addr) { |
904 | /* copy commands needed */ | 932 | /* copy commands needed */ |
905 | ndw += ncmds * 7; | 933 | ndw += ncmds * 7; |
@@ -907,12 +935,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
907 | /* and also PTEs */ | 935 | /* and also PTEs */ |
908 | ndw += nptes * 2; | 936 | ndw += nptes * 2; |
909 | 937 | ||
938 | params.func = amdgpu_vm_do_copy_ptes; | ||
939 | |||
910 | } else { | 940 | } else { |
911 | /* set page commands needed */ | 941 | /* set page commands needed */ |
912 | ndw += ncmds * 10; | 942 | ndw += ncmds * 10; |
913 | 943 | ||
914 | /* two extra commands for begin/end of fragment */ | 944 | /* two extra commands for begin/end of fragment */ |
915 | ndw += 2 * 10; | 945 | ndw += 2 * 10; |
946 | |||
947 | params.func = amdgpu_vm_do_set_ptes; | ||
916 | } | 948 | } |
917 | 949 | ||
918 | r = amdgpu_job_alloc_with_ib(adev, ndw * 4, &job); | 950 | r = amdgpu_job_alloc_with_ib(adev, ndw * 4, &job); |