]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/amdgpu: enable VCN0 and VCN1 sriov instances support for Arcturus
authorJane Jian <Jane.Jian@amd.com>
Mon, 16 Dec 2019 09:04:01 +0000 (17:04 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 Dec 2019 15:10:05 +0000 (10:10 -0500)
v1: compared to bare-metal: sriov support psp loading VCN firmware; only one
encoding ring would be used in each instance.
v2: keep unchange for bare-metal VCN2.5 hw_init, just add a flag with sriov
and also remove multiple lines.
v3: squash in warning fix

Signed-off-by: Jane Jian <Jane.Jian@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c

index 5bd6ae7a52fe8e035eadd3aafaacdf1ae72e9cb9..b53d40177e93f8b44be1baa0af864ce94bacdf95 100644 (file)
@@ -830,8 +830,13 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
                if (!amdgpu_sriov_vf(adev))
                        amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
 
-               if (unlikely(adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT))
-                       amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
+               if (amdgpu_sriov_vf(adev)) {
+                       if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))
+                               amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
+               } else {
+                       if (unlikely(adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT))
+                               amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
+               }
                if (!amdgpu_sriov_vf(adev))
                        amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);
                break;
index 1379cfadfb32c38cab0d65e242c72db3c64b9386..4ea8e20ed15dad24fdc2d68646405e34017b6d44 100644 (file)
@@ -90,7 +90,13 @@ static int vcn_v2_5_early_init(void *handle)
        } else
                adev->vcn.num_vcn_inst = 1;
 
-       adev->vcn.num_enc_rings = 2;
+       if (amdgpu_sriov_vf(adev)) {
+               adev->vcn.num_vcn_inst = 2;
+               adev->vcn.harvest_config = 0;
+               adev->vcn.num_enc_rings = 1;
+       } else {
+               adev->vcn.num_enc_rings = 2;
+       }
 
        vcn_v2_5_set_dec_ring_funcs(adev);
        vcn_v2_5_set_enc_ring_funcs(adev);
@@ -178,7 +184,9 @@ static int vcn_v2_5_sw_init(void *handle)
 
                ring = &adev->vcn.inst[j].ring_dec;
                ring->use_doorbell = true;
-               ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 8*j;
+
+               ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) +
+                               (amdgpu_sriov_vf(adev) ? 2*j : 8*j);
                sprintf(ring->name, "vcn_dec_%d", j);
                r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.inst[j].irq, 0);
                if (r)
@@ -187,7 +195,10 @@ static int vcn_v2_5_sw_init(void *handle)
                for (i = 0; i < adev->vcn.num_enc_rings; ++i) {
                        ring = &adev->vcn.inst[j].ring_enc[i];
                        ring->use_doorbell = true;
-                       ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 2 + i + 8*j;
+
+                       ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) +
+                                       (amdgpu_sriov_vf(adev) ? (1 + i + 2*j) : (2 + i + 8*j));
+
                        sprintf(ring->name, "vcn_enc_%d.%d", j, i);
                        r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.inst[j].irq, 0);
                        if (r)
@@ -195,6 +206,12 @@ static int vcn_v2_5_sw_init(void *handle)
                }
        }
 
+       if (amdgpu_sriov_vf(adev)) {
+               r = amdgpu_virt_alloc_mm_table(adev);
+               if (r)
+                       return r;
+       }
+
        return 0;
 }
 
@@ -210,6 +227,9 @@ static int vcn_v2_5_sw_fini(void *handle)
        int r;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (amdgpu_sriov_vf(adev))
+               amdgpu_virt_free_mm_table(adev);
+
        r = amdgpu_vcn_suspend(adev);
        if (r)
                return r;
@@ -230,25 +250,37 @@ static int vcn_v2_5_hw_init(void *handle)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
        struct amdgpu_ring *ring;
-       int i, j, r;
+       int i, j, r = 0;
+
+       if (amdgpu_sriov_vf(adev))
+               r = vcn_v2_5_sriov_start(adev);
 
        for (j = 0; j < adev->vcn.num_vcn_inst; ++j) {
                if (adev->vcn.harvest_config & (1 << j))
                        continue;
-               ring = &adev->vcn.inst[j].ring_dec;
 
-               adev->nbio.funcs->vcn_doorbell_range(adev, ring->use_doorbell,
-                                                    ring->doorbell_index, j);
+               if (amdgpu_sriov_vf(adev)) {
+                       adev->vcn.inst[j].ring_enc[0].sched.ready = true;
+                       adev->vcn.inst[j].ring_enc[1].sched.ready = false;
+                       adev->vcn.inst[j].ring_enc[2].sched.ready = false;
+                       adev->vcn.inst[j].ring_dec.sched.ready = true;
+               } else {
 
-               r = amdgpu_ring_test_helper(ring);
-               if (r)
-                       goto done;
+                       ring = &adev->vcn.inst[j].ring_dec;
+
+                       adev->nbio.funcs->vcn_doorbell_range(adev, ring->use_doorbell,
+                                                    ring->doorbell_index, j);
 
-               for (i = 0; i < adev->vcn.num_enc_rings; ++i) {
-                       ring = &adev->vcn.inst[j].ring_enc[i];
                        r = amdgpu_ring_test_helper(ring);
                        if (r)
                                goto done;
+
+                       for (i = 0; i < adev->vcn.num_enc_rings; ++i) {
+                               ring = &adev->vcn.inst[j].ring_enc[i];
+                               r = amdgpu_ring_test_helper(ring);
+                               if (r)
+                                       goto done;
+                       }
                }
        }