Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: use job and ib structures directly in CS parsers

Instead of providing the ib index provide the job and ib pointers directly to
the patch and parse functions for UVD and VCE.

Also move the set/get functions for IB values to the IB declerations.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
cdc7893f a190f8dc

+130 -114
+5 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 783 783 memcpy(ib->ptr, kptr, chunk_ib->ib_bytes); 784 784 amdgpu_bo_kunmap(aobj); 785 785 786 - r = amdgpu_ring_parse_cs(ring, p, j); 786 + r = amdgpu_ring_parse_cs(ring, p, p->job, 787 + &p->job->ibs[i]); 787 788 if (r) 788 789 return r; 789 790 } else { 790 791 ib->ptr = (uint32_t *)kptr; 791 - r = amdgpu_ring_patch_cs_in_place(ring, p, j); 792 + r = amdgpu_ring_patch_cs_in_place(ring, p, 793 + p->job, 794 + &p->job->ibs[i]); 792 795 amdgpu_bo_kunmap(aobj); 793 796 if (r) 794 797 return r;
-13
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.h
··· 73 73 struct amdgpu_cs_post_dep *post_deps; 74 74 }; 75 75 76 - static inline u32 amdgpu_get_ib_value(struct amdgpu_cs_parser *p, 77 - uint32_t ib_idx, int idx) 78 - { 79 - return p->job->ibs[ib_idx].ptr[idx]; 80 - } 81 - 82 - static inline void amdgpu_set_ib_value(struct amdgpu_cs_parser *p, 83 - uint32_t ib_idx, int idx, 84 - uint32_t value) 85 - { 86 - p->job->ibs[ib_idx].ptr[idx] = value; 87 - } 88 - 89 76 int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, 90 77 uint64_t addr, struct amdgpu_bo **bo, 91 78 struct amdgpu_bo_va_mapping **mapping);
+19 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
··· 163 163 u64 (*get_wptr)(struct amdgpu_ring *ring); 164 164 void (*set_wptr)(struct amdgpu_ring *ring); 165 165 /* validating and patching of IBs */ 166 - int (*parse_cs)(struct amdgpu_cs_parser *p, uint32_t ib_idx); 167 - int (*patch_cs_in_place)(struct amdgpu_cs_parser *p, uint32_t ib_idx); 166 + int (*parse_cs)(struct amdgpu_cs_parser *p, 167 + struct amdgpu_job *job, 168 + struct amdgpu_ib *ib); 169 + int (*patch_cs_in_place)(struct amdgpu_cs_parser *p, 170 + struct amdgpu_job *job, 171 + struct amdgpu_ib *ib); 168 172 /* constants to calculate how many DW are needed for an emit */ 169 173 unsigned emit_frame_size; 170 174 unsigned emit_ib_size; ··· 268 264 atomic_t *sched_score; 269 265 }; 270 266 271 - #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib))) 272 - #define amdgpu_ring_patch_cs_in_place(r, p, ib) ((r)->funcs->patch_cs_in_place((p), (ib))) 267 + #define amdgpu_ring_parse_cs(r, p, job, ib) ((r)->funcs->parse_cs((p), (job), (ib))) 268 + #define amdgpu_ring_patch_cs_in_place(r, p, job, ib) ((r)->funcs->patch_cs_in_place((p), (job), (ib))) 273 269 #define amdgpu_ring_test_ring(r) (r)->funcs->test_ring((r)) 274 270 #define amdgpu_ring_test_ib(r, t) (r)->funcs->test_ib((r), (t)) 275 271 #define amdgpu_ring_get_rptr(r) (r)->funcs->get_rptr((r)) ··· 367 363 368 364 void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, 369 365 struct amdgpu_ring *ring); 366 + 367 + static inline u32 amdgpu_ib_get_value(struct amdgpu_ib *ib, int idx) 368 + { 369 + return ib->ptr[idx]; 370 + } 371 + 372 + static inline void amdgpu_ib_set_value(struct amdgpu_ib *ib, int idx, 373 + uint32_t value) 374 + { 375 + ib->ptr[idx] = value; 376 + } 370 377 371 378 int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, 372 379 unsigned size,
+17 -19
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
··· 99 99 unsigned reg, count; 100 100 unsigned data0, data1; 101 101 unsigned idx; 102 - unsigned ib_idx; 102 + struct amdgpu_ib *ib; 103 103 104 104 /* does the IB has a msg command */ 105 105 bool has_msg_cmd; ··· 558 558 uint32_t lo, hi; 559 559 uint64_t addr; 560 560 561 - lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0); 562 - hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1); 561 + lo = amdgpu_ib_get_value(ctx->ib, ctx->data0); 562 + hi = amdgpu_ib_get_value(ctx->ib, ctx->data1); 563 563 addr = ((uint64_t)lo) | (((uint64_t)hi) << 32); 564 564 565 565 return addr; ··· 590 590 591 591 if (!ctx->parser->adev->uvd.address_64_bit) { 592 592 /* check if it's a message or feedback command */ 593 - cmd = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->idx) >> 1; 593 + cmd = amdgpu_ib_get_value(ctx->ib, ctx->idx) >> 1; 594 594 if (cmd == 0x0 || cmd == 0x3) { 595 595 /* yes, force it into VRAM */ 596 596 uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM; ··· 928 928 addr -= mapping->start * AMDGPU_GPU_PAGE_SIZE; 929 929 start += addr; 930 930 931 - amdgpu_set_ib_value(ctx->parser, ctx->ib_idx, ctx->data0, 932 - lower_32_bits(start)); 933 - amdgpu_set_ib_value(ctx->parser, ctx->ib_idx, ctx->data1, 934 - upper_32_bits(start)); 931 + amdgpu_ib_set_value(ctx->ib, ctx->data0, lower_32_bits(start)); 932 + amdgpu_ib_set_value(ctx->ib, ctx->data1, upper_32_bits(start)); 935 933 936 - cmd = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->idx) >> 1; 934 + cmd = amdgpu_ib_get_value(ctx->ib, ctx->idx) >> 1; 937 935 if (cmd < 0x4) { 938 936 if ((end - start) < ctx->buf_sizes[cmd]) { 939 937 DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd, ··· 991 993 static int amdgpu_uvd_cs_reg(struct amdgpu_uvd_cs_ctx *ctx, 992 994 int (*cb)(struct amdgpu_uvd_cs_ctx *ctx)) 993 995 { 994 - struct amdgpu_ib *ib = &ctx->parser->job->ibs[ctx->ib_idx]; 995 996 int i, r; 996 997 997 998 ctx->idx++; 998 999 for (i = 0; i <= ctx->count; ++i) { 999 1000 unsigned reg = ctx->reg + i; 1000 1001 1001 - if (ctx->idx >= ib->length_dw) { 1002 + if (ctx->idx >= ctx->ib->length_dw) { 1002 1003 DRM_ERROR("Register command after end of CS!\n"); 1003 1004 return -EINVAL; 1004 1005 } ··· 1037 1040 static int amdgpu_uvd_cs_packets(struct amdgpu_uvd_cs_ctx *ctx, 1038 1041 int (*cb)(struct amdgpu_uvd_cs_ctx *ctx)) 1039 1042 { 1040 - struct amdgpu_ib *ib = &ctx->parser->job->ibs[ctx->ib_idx]; 1041 1043 int r; 1042 1044 1043 - for (ctx->idx = 0 ; ctx->idx < ib->length_dw; ) { 1044 - uint32_t cmd = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->idx); 1045 + for (ctx->idx = 0 ; ctx->idx < ctx->ib->length_dw; ) { 1046 + uint32_t cmd = amdgpu_ib_get_value(ctx->ib, ctx->idx); 1045 1047 unsigned type = CP_PACKET_GET_TYPE(cmd); 1046 1048 switch (type) { 1047 1049 case PACKET_TYPE0: ··· 1065 1069 * amdgpu_uvd_ring_parse_cs - UVD command submission parser 1066 1070 * 1067 1071 * @parser: Command submission parser context 1068 - * @ib_idx: Which indirect buffer to use 1072 + * @job: the job to parse 1073 + * @ib: the IB to patch 1069 1074 * 1070 1075 * Parse the command stream, patch in addresses as necessary. 1071 1076 */ 1072 - int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) 1077 + int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, 1078 + struct amdgpu_job *job, 1079 + struct amdgpu_ib *ib) 1073 1080 { 1074 1081 struct amdgpu_uvd_cs_ctx ctx = {}; 1075 1082 unsigned buf_sizes[] = { ··· 1082 1083 [0x00000003] = 2048, 1083 1084 [0x00000004] = 0xFFFFFFFF, 1084 1085 }; 1085 - struct amdgpu_ib *ib = &parser->job->ibs[ib_idx]; 1086 1086 int r; 1087 1087 1088 - parser->job->vm = NULL; 1088 + job->vm = NULL; 1089 1089 ib->gpu_addr = amdgpu_sa_bo_gpu_addr(ib->sa_bo); 1090 1090 1091 1091 if (ib->length_dw % 16) { ··· 1095 1097 1096 1098 ctx.parser = parser; 1097 1099 ctx.buf_sizes = buf_sizes; 1098 - ctx.ib_idx = ib_idx; 1100 + ctx.ib = ib; 1099 1101 1100 1102 /* first round only required on chips without UVD 64 bit address support */ 1101 1103 if (!parser->adev->uvd.address_64_bit) {
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
··· 82 82 bool direct, struct dma_fence **fence); 83 83 void amdgpu_uvd_free_handles(struct amdgpu_device *adev, 84 84 struct drm_file *filp); 85 - int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx); 85 + int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, 86 + struct amdgpu_job *job, 87 + struct amdgpu_ib *ib); 86 88 void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring); 87 89 void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring); 88 90 int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring, long timeout);
+60 -56
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
··· 588 588 /** 589 589 * amdgpu_vce_validate_bo - make sure not to cross 4GB boundary 590 590 * 591 - * @p: parser context 592 - * @ib_idx: indirect buffer to use 591 + * @ib: indirect buffer to use 593 592 * @lo: address of lower dword 594 593 * @hi: address of higher dword 595 594 * @size: minimum size ··· 596 597 * 597 598 * Make sure that no BO cross a 4GB boundary. 598 599 */ 599 - static int amdgpu_vce_validate_bo(struct amdgpu_cs_parser *p, uint32_t ib_idx, 600 - int lo, int hi, unsigned size, int32_t index) 600 + static int amdgpu_vce_validate_bo(struct amdgpu_cs_parser *p, 601 + struct amdgpu_ib *ib, int lo, int hi, 602 + unsigned size, int32_t index) 601 603 { 602 604 int64_t offset = ((uint64_t)size) * ((int64_t)index); 603 605 struct ttm_operation_ctx ctx = { false, false }; ··· 608 608 uint64_t addr; 609 609 int r; 610 610 611 - addr = ((uint64_t)amdgpu_get_ib_value(p, ib_idx, lo)) | 612 - ((uint64_t)amdgpu_get_ib_value(p, ib_idx, hi)) << 32; 611 + addr = ((uint64_t)amdgpu_ib_get_value(ib, lo)) | 612 + ((uint64_t)amdgpu_ib_get_value(ib, hi)) << 32; 613 613 if (index >= 0) { 614 614 addr += offset; 615 615 fpfn = PAGE_ALIGN(offset) >> PAGE_SHIFT; ··· 639 639 * amdgpu_vce_cs_reloc - command submission relocation 640 640 * 641 641 * @p: parser context 642 - * @ib_idx: indirect buffer to use 642 + * @ib: indirect buffer to use 643 643 * @lo: address of lower dword 644 644 * @hi: address of higher dword 645 645 * @size: minimum size ··· 647 647 * 648 648 * Patch relocation inside command stream with real buffer address 649 649 */ 650 - static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser *p, uint32_t ib_idx, 650 + static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser *p, struct amdgpu_ib *ib, 651 651 int lo, int hi, unsigned size, uint32_t index) 652 652 { 653 653 struct amdgpu_bo_va_mapping *mapping; ··· 658 658 if (index == 0xffffffff) 659 659 index = 0; 660 660 661 - addr = ((uint64_t)amdgpu_get_ib_value(p, ib_idx, lo)) | 662 - ((uint64_t)amdgpu_get_ib_value(p, ib_idx, hi)) << 32; 661 + addr = ((uint64_t)amdgpu_ib_get_value(ib, lo)) | 662 + ((uint64_t)amdgpu_ib_get_value(ib, hi)) << 32; 663 663 addr += ((uint64_t)size) * ((uint64_t)index); 664 664 665 665 r = amdgpu_cs_find_mapping(p, addr, &bo, &mapping); ··· 680 680 addr += amdgpu_bo_gpu_offset(bo); 681 681 addr -= ((uint64_t)size) * ((uint64_t)index); 682 682 683 - amdgpu_set_ib_value(p, ib_idx, lo, lower_32_bits(addr)); 684 - amdgpu_set_ib_value(p, ib_idx, hi, upper_32_bits(addr)); 683 + amdgpu_ib_set_value(ib, lo, lower_32_bits(addr)); 684 + amdgpu_ib_set_value(ib, hi, upper_32_bits(addr)); 685 685 686 686 return 0; 687 687 } ··· 730 730 * amdgpu_vce_ring_parse_cs - parse and validate the command stream 731 731 * 732 732 * @p: parser context 733 - * @ib_idx: indirect buffer to use 733 + * @job: the job to parse 734 + * @ib: the IB to patch 734 735 */ 735 - int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) 736 + int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, 737 + struct amdgpu_job *job, 738 + struct amdgpu_ib *ib) 736 739 { 737 - struct amdgpu_ib *ib = &p->job->ibs[ib_idx]; 738 740 unsigned fb_idx = 0, bs_idx = 0; 739 741 int session_idx = -1; 740 742 uint32_t destroyed = 0; ··· 747 745 unsigned idx; 748 746 int i, r = 0; 749 747 750 - p->job->vm = NULL; 748 + job->vm = NULL; 751 749 ib->gpu_addr = amdgpu_sa_bo_gpu_addr(ib->sa_bo); 752 750 753 751 for (idx = 0; idx < ib->length_dw;) { 754 - uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); 755 - uint32_t cmd = amdgpu_get_ib_value(p, ib_idx, idx + 1); 752 + uint32_t len = amdgpu_ib_get_value(ib, idx); 753 + uint32_t cmd = amdgpu_ib_get_value(ib, idx + 1); 756 754 757 755 if ((len < 8) || (len & 3)) { 758 756 DRM_ERROR("invalid VCE command length (%d)!\n", len); ··· 762 760 763 761 switch (cmd) { 764 762 case 0x00000002: /* task info */ 765 - fb_idx = amdgpu_get_ib_value(p, ib_idx, idx + 6); 766 - bs_idx = amdgpu_get_ib_value(p, ib_idx, idx + 7); 763 + fb_idx = amdgpu_ib_get_value(ib, idx + 6); 764 + bs_idx = amdgpu_ib_get_value(ib, idx + 7); 767 765 break; 768 766 769 767 case 0x03000001: /* encode */ 770 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 10, 771 - idx + 9, 0, 0); 768 + r = amdgpu_vce_validate_bo(p, ib, idx + 10, idx + 9, 769 + 0, 0); 772 770 if (r) 773 771 goto out; 774 772 775 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 12, 776 - idx + 11, 0, 0); 773 + r = amdgpu_vce_validate_bo(p, ib, idx + 12, idx + 11, 774 + 0, 0); 777 775 if (r) 778 776 goto out; 779 777 break; 780 778 781 779 case 0x05000001: /* context buffer */ 782 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 3, 783 - idx + 2, 0, 0); 780 + r = amdgpu_vce_validate_bo(p, ib, idx + 3, idx + 2, 781 + 0, 0); 784 782 if (r) 785 783 goto out; 786 784 break; 787 785 788 786 case 0x05000004: /* video bitstream buffer */ 789 - tmp = amdgpu_get_ib_value(p, ib_idx, idx + 4); 790 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 3, idx + 2, 787 + tmp = amdgpu_ib_get_value(ib, idx + 4); 788 + r = amdgpu_vce_validate_bo(p, ib, idx + 3, idx + 2, 791 789 tmp, bs_idx); 792 790 if (r) 793 791 goto out; 794 792 break; 795 793 796 794 case 0x05000005: /* feedback buffer */ 797 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 3, idx + 2, 795 + r = amdgpu_vce_validate_bo(p, ib, idx + 3, idx + 2, 798 796 4096, fb_idx); 799 797 if (r) 800 798 goto out; 801 799 break; 802 800 803 801 case 0x0500000d: /* MV buffer */ 804 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 3, 805 - idx + 2, 0, 0); 802 + r = amdgpu_vce_validate_bo(p, ib, idx + 3, idx + 2, 803 + 0, 0); 806 804 if (r) 807 805 goto out; 808 806 809 - r = amdgpu_vce_validate_bo(p, ib_idx, idx + 8, 810 - idx + 7, 0, 0); 807 + r = amdgpu_vce_validate_bo(p, ib, idx + 8, idx + 7, 808 + 0, 0); 811 809 if (r) 812 810 goto out; 813 811 break; ··· 817 815 } 818 816 819 817 for (idx = 0; idx < ib->length_dw;) { 820 - uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); 821 - uint32_t cmd = amdgpu_get_ib_value(p, ib_idx, idx + 1); 818 + uint32_t len = amdgpu_ib_get_value(ib, idx); 819 + uint32_t cmd = amdgpu_ib_get_value(ib, idx + 1); 822 820 823 821 switch (cmd) { 824 822 case 0x00000001: /* session */ 825 - handle = amdgpu_get_ib_value(p, ib_idx, idx + 2); 823 + handle = amdgpu_ib_get_value(ib, idx + 2); 826 824 session_idx = amdgpu_vce_validate_handle(p, handle, 827 825 &allocated); 828 826 if (session_idx < 0) { ··· 833 831 break; 834 832 835 833 case 0x00000002: /* task info */ 836 - fb_idx = amdgpu_get_ib_value(p, ib_idx, idx + 6); 837 - bs_idx = amdgpu_get_ib_value(p, ib_idx, idx + 7); 834 + fb_idx = amdgpu_ib_get_value(ib, idx + 6); 835 + bs_idx = amdgpu_ib_get_value(ib, idx + 7); 838 836 break; 839 837 840 838 case 0x01000001: /* create */ ··· 849 847 goto out; 850 848 } 851 849 852 - *size = amdgpu_get_ib_value(p, ib_idx, idx + 8) * 853 - amdgpu_get_ib_value(p, ib_idx, idx + 10) * 850 + *size = amdgpu_ib_get_value(ib, idx + 8) * 851 + amdgpu_ib_get_value(ib, idx + 10) * 854 852 8 * 3 / 2; 855 853 break; 856 854 ··· 879 877 break; 880 878 881 879 case 0x03000001: /* encode */ 882 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 10, idx + 9, 880 + r = amdgpu_vce_cs_reloc(p, ib, idx + 10, idx + 9, 883 881 *size, 0); 884 882 if (r) 885 883 goto out; 886 884 887 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 12, idx + 11, 885 + r = amdgpu_vce_cs_reloc(p, ib, idx + 12, idx + 11, 888 886 *size / 3, 0); 889 887 if (r) 890 888 goto out; ··· 895 893 break; 896 894 897 895 case 0x05000001: /* context buffer */ 898 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 3, idx + 2, 896 + r = amdgpu_vce_cs_reloc(p, ib, idx + 3, idx + 2, 899 897 *size * 2, 0); 900 898 if (r) 901 899 goto out; 902 900 break; 903 901 904 902 case 0x05000004: /* video bitstream buffer */ 905 - tmp = amdgpu_get_ib_value(p, ib_idx, idx + 4); 906 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 3, idx + 2, 903 + tmp = amdgpu_ib_get_value(ib, idx + 4); 904 + r = amdgpu_vce_cs_reloc(p, ib, idx + 3, idx + 2, 907 905 tmp, bs_idx); 908 906 if (r) 909 907 goto out; 910 908 break; 911 909 912 910 case 0x05000005: /* feedback buffer */ 913 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 3, idx + 2, 911 + r = amdgpu_vce_cs_reloc(p, ib, idx + 3, idx + 2, 914 912 4096, fb_idx); 915 913 if (r) 916 914 goto out; 917 915 break; 918 916 919 917 case 0x0500000d: /* MV buffer */ 920 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 3, 921 - idx + 2, *size, 0); 918 + r = amdgpu_vce_cs_reloc(p, ib, idx + 3, 919 + idx + 2, *size, 0); 922 920 if (r) 923 921 goto out; 924 922 925 - r = amdgpu_vce_cs_reloc(p, ib_idx, idx + 8, 926 - idx + 7, *size / 12, 0); 923 + r = amdgpu_vce_cs_reloc(p, ib, idx + 8, 924 + idx + 7, *size / 12, 0); 927 925 if (r) 928 926 goto out; 929 927 break; ··· 968 966 * amdgpu_vce_ring_parse_cs_vm - parse the command stream in VM mode 969 967 * 970 968 * @p: parser context 971 - * @ib_idx: indirect buffer to use 969 + * @job: the job to parse 970 + * @ib: the IB to patch 972 971 */ 973 - int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, uint32_t ib_idx) 972 + int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, 973 + struct amdgpu_job *job, 974 + struct amdgpu_ib *ib) 974 975 { 975 - struct amdgpu_ib *ib = &p->job->ibs[ib_idx]; 976 976 int session_idx = -1; 977 977 uint32_t destroyed = 0; 978 978 uint32_t created = 0; ··· 983 979 int i, r = 0, idx = 0; 984 980 985 981 while (idx < ib->length_dw) { 986 - uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); 987 - uint32_t cmd = amdgpu_get_ib_value(p, ib_idx, idx + 1); 982 + uint32_t len = amdgpu_ib_get_value(ib, idx); 983 + uint32_t cmd = amdgpu_ib_get_value(ib, idx + 1); 988 984 989 985 if ((len < 8) || (len & 3)) { 990 986 DRM_ERROR("invalid VCE command length (%d)!\n", len); ··· 994 990 995 991 switch (cmd) { 996 992 case 0x00000001: /* session */ 997 - handle = amdgpu_get_ib_value(p, ib_idx, idx + 2); 993 + handle = amdgpu_ib_get_value(ib, idx + 2); 998 994 session_idx = amdgpu_vce_validate_handle(p, handle, 999 995 &allocated); 1000 996 if (session_idx < 0) {
+5 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
··· 59 59 int amdgpu_vce_suspend(struct amdgpu_device *adev); 60 60 int amdgpu_vce_resume(struct amdgpu_device *adev); 61 61 void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp); 62 - int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx); 63 - int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, uint32_t ib_idx); 62 + int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, struct amdgpu_job *job, 63 + struct amdgpu_ib *ib); 64 + int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, 65 + struct amdgpu_job *job, 66 + struct amdgpu_ib *ib); 64 67 void amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_job *job, 65 68 struct amdgpu_ib *ib, uint32_t flags); 66 69 void amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,
+7 -6
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
··· 1276 1276 * uvd_v7_0_ring_patch_cs_in_place - Patch the IB for command submission. 1277 1277 * 1278 1278 * @p: the CS parser with the IBs 1279 - * @ib_idx: which IB to patch 1279 + * @job: which job this ib is in 1280 + * @ib: which IB to patch 1280 1281 * 1281 1282 */ 1282 1283 static int uvd_v7_0_ring_patch_cs_in_place(struct amdgpu_cs_parser *p, 1283 - uint32_t ib_idx) 1284 + struct amdgpu_job *job, 1285 + struct amdgpu_ib *ib) 1284 1286 { 1285 - struct amdgpu_ring *ring = to_amdgpu_ring(p->entity->rq->sched); 1286 - struct amdgpu_ib *ib = &p->job->ibs[ib_idx]; 1287 + struct amdgpu_ring *ring = to_amdgpu_ring(job->base.sched); 1287 1288 unsigned i; 1288 1289 1289 1290 /* No patching necessary for the first instance */ ··· 1292 1291 return 0; 1293 1292 1294 1293 for (i = 0; i < ib->length_dw; i += 2) { 1295 - uint32_t reg = amdgpu_get_ib_value(p, ib_idx, i); 1294 + uint32_t reg = amdgpu_ib_get_value(ib, i); 1296 1295 1297 1296 reg -= p->adev->reg_offset[UVD_HWIP][0][1]; 1298 1297 reg += p->adev->reg_offset[UVD_HWIP][1][1]; 1299 1298 1300 - amdgpu_set_ib_value(p, ib_idx, i, reg); 1299 + amdgpu_ib_set_value(ib, i, reg); 1301 1300 } 1302 1301 return 0; 1303 1302 }
+14 -11
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
··· 1812 1812 .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, 1813 1813 }; 1814 1814 1815 - static int vcn_v3_0_limit_sched(struct amdgpu_cs_parser *p) 1815 + static int vcn_v3_0_limit_sched(struct amdgpu_cs_parser *p, 1816 + struct amdgpu_job *job) 1816 1817 { 1817 1818 struct drm_gpu_scheduler **scheds; 1818 1819 1819 1820 /* The create msg must be in the first IB submitted */ 1820 - if (atomic_read(&p->entity->fence_seq)) 1821 + if (atomic_read(&job->base.entity->fence_seq)) 1821 1822 return -EINVAL; 1822 1823 1823 1824 scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_DEC] 1824 1825 [AMDGPU_RING_PRIO_DEFAULT].sched; 1825 - drm_sched_entity_modify_sched(p->entity, scheds, 1); 1826 + drm_sched_entity_modify_sched(job->base.entity, scheds, 1); 1826 1827 return 0; 1827 1828 } 1828 1829 1829 - static int vcn_v3_0_dec_msg(struct amdgpu_cs_parser *p, uint64_t addr) 1830 + static int vcn_v3_0_dec_msg(struct amdgpu_cs_parser *p, struct amdgpu_job *job, 1831 + uint64_t addr) 1830 1832 { 1831 1833 struct ttm_operation_ctx ctx = { false, false }; 1832 1834 struct amdgpu_bo_va_mapping *map; ··· 1899 1897 if (create[0] == 0x7 || create[0] == 0x10 || create[0] == 0x11) 1900 1898 continue; 1901 1899 1902 - r = vcn_v3_0_limit_sched(p); 1900 + r = vcn_v3_0_limit_sched(p, job); 1903 1901 if (r) 1904 1902 goto out; 1905 1903 } ··· 1910 1908 } 1911 1909 1912 1910 static int vcn_v3_0_ring_patch_cs_in_place(struct amdgpu_cs_parser *p, 1913 - uint32_t ib_idx) 1911 + struct amdgpu_job *job, 1912 + struct amdgpu_ib *ib) 1914 1913 { 1915 - struct amdgpu_ring *ring = to_amdgpu_ring(p->entity->rq->sched); 1916 - struct amdgpu_ib *ib = &p->job->ibs[ib_idx]; 1914 + struct amdgpu_ring *ring = to_amdgpu_ring(job->base.sched); 1917 1915 uint32_t msg_lo = 0, msg_hi = 0; 1918 1916 unsigned i; 1919 1917 int r; ··· 1923 1921 return 0; 1924 1922 1925 1923 for (i = 0; i < ib->length_dw; i += 2) { 1926 - uint32_t reg = amdgpu_get_ib_value(p, ib_idx, i); 1927 - uint32_t val = amdgpu_get_ib_value(p, ib_idx, i + 1); 1924 + uint32_t reg = amdgpu_ib_get_value(ib, i); 1925 + uint32_t val = amdgpu_ib_get_value(ib, i + 1); 1928 1926 1929 1927 if (reg == PACKET0(p->adev->vcn.internal.data0, 0)) { 1930 1928 msg_lo = val; ··· 1932 1930 msg_hi = val; 1933 1931 } else if (reg == PACKET0(p->adev->vcn.internal.cmd, 0) && 1934 1932 val == 0) { 1935 - r = vcn_v3_0_dec_msg(p, ((u64)msg_hi) << 32 | msg_lo); 1933 + r = vcn_v3_0_dec_msg(p, job, 1934 + ((u64)msg_hi) << 32 | msg_lo); 1936 1935 if (r) 1937 1936 return r; 1938 1937 }