diff options
author | Leo Liu <leo.liu@amd.com> | 2017-05-08 17:31:31 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-05-24 17:41:43 -0400 |
commit | 25547cfd262dc0621b0743aa78471a6c8a6b1e84 (patch) | |
tree | a95b912a2e818eb240993ca9892d74dc61827adf /drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |
parent | c3bd304009dee48adbb2b6937b7f4a07c5e4e281 (diff) |
drm/amdgpu: add vcn enc ib test
Update and enable the vcn encode IB test.
Signed-off-by: Leo Liu <leo.liu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 84 |
1 files changed, 33 insertions, 51 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index 18fd56558751..5c4057dd875b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |||
@@ -521,7 +521,7 @@ int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring) | |||
521 | static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, | 521 | static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, |
522 | struct dma_fence **fence) | 522 | struct dma_fence **fence) |
523 | { | 523 | { |
524 | const unsigned ib_size_dw = 1024; | 524 | const unsigned ib_size_dw = 16; |
525 | struct amdgpu_job *job; | 525 | struct amdgpu_job *job; |
526 | struct amdgpu_ib *ib; | 526 | struct amdgpu_ib *ib; |
527 | struct dma_fence *f = NULL; | 527 | struct dma_fence *f = NULL; |
@@ -533,37 +533,24 @@ static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t hand | |||
533 | return r; | 533 | return r; |
534 | 534 | ||
535 | ib = &job->ibs[0]; | 535 | ib = &job->ibs[0]; |
536 | |||
537 | dummy = ib->gpu_addr + 1024; | 536 | dummy = ib->gpu_addr + 1024; |
538 | 537 | ||
539 | /* stitch together an VCN enc create msg */ | ||
540 | ib->length_dw = 0; | 538 | ib->length_dw = 0; |
541 | ib->ptr[ib->length_dw++] = 0x0000000c; /* len */ | 539 | ib->ptr[ib->length_dw++] = 0x00000018; |
542 | ib->ptr[ib->length_dw++] = 0x00000001; /* session cmd */ | 540 | ib->ptr[ib->length_dw++] = 0x00000001; /* session info */ |
543 | ib->ptr[ib->length_dw++] = handle; | 541 | ib->ptr[ib->length_dw++] = handle; |
542 | ib->ptr[ib->length_dw++] = upper_32_bits(dummy); | ||
543 | ib->ptr[ib->length_dw++] = dummy; | ||
544 | ib->ptr[ib->length_dw++] = 0x0000000b; | ||
544 | 545 | ||
545 | ib->ptr[ib->length_dw++] = 0x00000040; /* len */ | 546 | ib->ptr[ib->length_dw++] = 0x00000014; |
546 | ib->ptr[ib->length_dw++] = 0x01000001; /* create cmd */ | 547 | ib->ptr[ib->length_dw++] = 0x00000002; /* task info */ |
547 | ib->ptr[ib->length_dw++] = 0x00000000; | 548 | ib->ptr[ib->length_dw++] = 0x0000001c; |
548 | ib->ptr[ib->length_dw++] = 0x00000042; | ||
549 | ib->ptr[ib->length_dw++] = 0x0000000a; | ||
550 | ib->ptr[ib->length_dw++] = 0x00000001; | ||
551 | ib->ptr[ib->length_dw++] = 0x00000080; | ||
552 | ib->ptr[ib->length_dw++] = 0x00000060; | ||
553 | ib->ptr[ib->length_dw++] = 0x00000100; | ||
554 | ib->ptr[ib->length_dw++] = 0x00000100; | ||
555 | ib->ptr[ib->length_dw++] = 0x0000000c; | ||
556 | ib->ptr[ib->length_dw++] = 0x00000000; | ||
557 | ib->ptr[ib->length_dw++] = 0x00000000; | ||
558 | ib->ptr[ib->length_dw++] = 0x00000000; | ||
559 | ib->ptr[ib->length_dw++] = 0x00000000; | 549 | ib->ptr[ib->length_dw++] = 0x00000000; |
560 | ib->ptr[ib->length_dw++] = 0x00000000; | 550 | ib->ptr[ib->length_dw++] = 0x00000000; |
561 | 551 | ||
562 | ib->ptr[ib->length_dw++] = 0x00000014; /* len */ | 552 | ib->ptr[ib->length_dw++] = 0x00000008; |
563 | ib->ptr[ib->length_dw++] = 0x05000005; /* feedback buffer */ | 553 | ib->ptr[ib->length_dw++] = 0x08000001; /* op initialize */ |
564 | ib->ptr[ib->length_dw++] = upper_32_bits(dummy); | ||
565 | ib->ptr[ib->length_dw++] = dummy; | ||
566 | ib->ptr[ib->length_dw++] = 0x00000001; | ||
567 | 554 | ||
568 | for (i = ib->length_dw; i < ib_size_dw; ++i) | 555 | for (i = ib->length_dw; i < ib_size_dw; ++i) |
569 | ib->ptr[i] = 0x0; | 556 | ib->ptr[i] = 0x0; |
@@ -577,6 +564,7 @@ static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t hand | |||
577 | if (fence) | 564 | if (fence) |
578 | *fence = dma_fence_get(f); | 565 | *fence = dma_fence_get(f); |
579 | dma_fence_put(f); | 566 | dma_fence_put(f); |
567 | |||
580 | return 0; | 568 | return 0; |
581 | 569 | ||
582 | err: | 570 | err: |
@@ -585,12 +573,13 @@ err: | |||
585 | } | 573 | } |
586 | 574 | ||
587 | static int amdgpu_vcn_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, | 575 | static int amdgpu_vcn_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, |
588 | bool direct, struct dma_fence **fence) | 576 | struct dma_fence **fence) |
589 | { | 577 | { |
590 | const unsigned ib_size_dw = 1024; | 578 | const unsigned ib_size_dw = 16; |
591 | struct amdgpu_job *job; | 579 | struct amdgpu_job *job; |
592 | struct amdgpu_ib *ib; | 580 | struct amdgpu_ib *ib; |
593 | struct dma_fence *f = NULL; | 581 | struct dma_fence *f = NULL; |
582 | uint64_t dummy; | ||
594 | int i, r; | 583 | int i, r; |
595 | 584 | ||
596 | r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); | 585 | r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); |
@@ -598,45 +587,38 @@ static int amdgpu_vcn_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t han | |||
598 | return r; | 587 | return r; |
599 | 588 | ||
600 | ib = &job->ibs[0]; | 589 | ib = &job->ibs[0]; |
590 | dummy = ib->gpu_addr + 1024; | ||
601 | 591 | ||
602 | /* stitch together an VCN enc destroy msg */ | ||
603 | ib->length_dw = 0; | 592 | ib->length_dw = 0; |
604 | ib->ptr[ib->length_dw++] = 0x0000000c; /* len */ | 593 | ib->ptr[ib->length_dw++] = 0x00000018; |
605 | ib->ptr[ib->length_dw++] = 0x00000001; /* session cmd */ | 594 | ib->ptr[ib->length_dw++] = 0x00000001; |
606 | ib->ptr[ib->length_dw++] = handle; | 595 | ib->ptr[ib->length_dw++] = handle; |
596 | ib->ptr[ib->length_dw++] = upper_32_bits(dummy); | ||
597 | ib->ptr[ib->length_dw++] = dummy; | ||
598 | ib->ptr[ib->length_dw++] = 0x0000000b; | ||
607 | 599 | ||
608 | ib->ptr[ib->length_dw++] = 0x00000020; /* len */ | 600 | ib->ptr[ib->length_dw++] = 0x00000014; |
609 | ib->ptr[ib->length_dw++] = 0x00000002; /* task info */ | 601 | ib->ptr[ib->length_dw++] = 0x00000002; |
610 | ib->ptr[ib->length_dw++] = 0xffffffff; /* next task info, set to 0xffffffff if no */ | 602 | ib->ptr[ib->length_dw++] = 0x0000001c; |
611 | ib->ptr[ib->length_dw++] = 0x00000001; /* destroy session */ | ||
612 | ib->ptr[ib->length_dw++] = 0x00000000; | ||
613 | ib->ptr[ib->length_dw++] = 0x00000000; | 603 | ib->ptr[ib->length_dw++] = 0x00000000; |
614 | ib->ptr[ib->length_dw++] = 0xffffffff; /* feedback is not needed, set to 0xffffffff and firmware will not output feedback */ | ||
615 | ib->ptr[ib->length_dw++] = 0x00000000; | 604 | ib->ptr[ib->length_dw++] = 0x00000000; |
616 | 605 | ||
617 | ib->ptr[ib->length_dw++] = 0x00000008; /* len */ | 606 | ib->ptr[ib->length_dw++] = 0x00000008; |
618 | ib->ptr[ib->length_dw++] = 0x02000001; /* destroy cmd */ | 607 | ib->ptr[ib->length_dw++] = 0x08000002; /* op close session */ |
619 | 608 | ||
620 | for (i = ib->length_dw; i < ib_size_dw; ++i) | 609 | for (i = ib->length_dw; i < ib_size_dw; ++i) |
621 | ib->ptr[i] = 0x0; | 610 | ib->ptr[i] = 0x0; |
622 | 611 | ||
623 | if (direct) { | 612 | r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); |
624 | r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); | 613 | job->fence = dma_fence_get(f); |
625 | job->fence = dma_fence_get(f); | 614 | if (r) |
626 | if (r) | 615 | goto err; |
627 | goto err; | ||
628 | |||
629 | amdgpu_job_free(job); | ||
630 | } else { | ||
631 | r = amdgpu_job_submit(job, ring, &ring->adev->vcn.entity_enc, | ||
632 | AMDGPU_FENCE_OWNER_UNDEFINED, &f); | ||
633 | if (r) | ||
634 | goto err; | ||
635 | } | ||
636 | 616 | ||
617 | amdgpu_job_free(job); | ||
637 | if (fence) | 618 | if (fence) |
638 | *fence = dma_fence_get(f); | 619 | *fence = dma_fence_get(f); |
639 | dma_fence_put(f); | 620 | dma_fence_put(f); |
621 | |||
640 | return 0; | 622 | return 0; |
641 | 623 | ||
642 | err: | 624 | err: |
@@ -655,7 +637,7 @@ int amdgpu_vcn_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
655 | goto error; | 637 | goto error; |
656 | } | 638 | } |
657 | 639 | ||
658 | r = amdgpu_vcn_enc_get_destroy_msg(ring, 1, true, &fence); | 640 | r = amdgpu_vcn_enc_get_destroy_msg(ring, 1, &fence); |
659 | if (r) { | 641 | if (r) { |
660 | DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); | 642 | DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); |
661 | goto error; | 643 | goto error; |