<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    <div class="moz-cite-prefix">On 2021-10-19 11:13 a.m., Alex Deucher
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20211019151303.291103-1-alexander.deucher@amd.com">
      <pre class="moz-quote-pre" wrap="">Only enable firmware for the instance that is enabled.

Fixes: 1b592d00b4ac83 ("drm/amdgpu/vcn: remove manual instance setting")
Signed-off-by: Alex Deucher <a class="moz-txt-link-rfc2396E" href="mailto:alexander.deucher@amd.com"><alexander.deucher@amd.com></a>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index dbfd92984655..e311303a5e01 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -123,6 +123,7 @@ static int vcn_v3_0_sw_init(void *handle)
 {
        struct amdgpu_ring *ring;
        int i, j, r;
+       unsigned int idx;
        int vcn_doorbell_index = 0;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
@@ -133,14 +134,16 @@ static int vcn_v3_0_sw_init(void *handle)
        if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
                const struct common_firmware_header *hdr;
                hdr = (const struct common_firmware_header *)adev->vcn.fw->data;
-               adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].ucode_id = AMDGPU_UCODE_ID_VCN;
-               adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].fw = adev->vcn.fw;
-               adev->firmware.fw_size +=
-                       ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
-
-               if (adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID) {
-                       adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id = AMDGPU_UCODE_ID_VCN1;
-                       adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw = adev->vcn.fw;
+
+               for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
+                       if (adev->vcn.harvest_config & (1 << i))
+                               continue;
+                       if (i == 0)
+                               idx = AMDGPU_UCODE_ID_VCN;
+                       else
+                               idx = AMDGPU_UCODE_ID_VCN1;</pre>
    </blockquote>
    <p>[JZ] Not sure if it is worthy to replace idx with 
      (AMDGPU_UCODE_ID_VCN+ i).</p>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This<span style=" color:#c0c0c0;"> </span>patch<span style=" color:#c0c0c0;"> </span>is<span style=" color:#c0c0c0;"> </span>Reviewed-by:<span style=" color:#c0c0c0;"> </span>James<span style=" color:#c0c0c0;"> </span>Zhu<span style=" color:#c0c0c0;"> </span><a class="moz-txt-link-rfc2396E" href="mailto:James.Zhu@amd.com"><James.Zhu@amd.com></a>

</pre>
    <blockquote type="cite" cite="mid:20211019151303.291103-1-alexander.deucher@amd.com">
      <pre class="moz-quote-pre" wrap="">
+                       adev->firmware.ucode[idx].ucode_id = idx;
+                       adev->firmware.ucode[idx].fw = adev->vcn.fw;
                        adev->firmware.fw_size +=
                                ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
                }
</pre>
    </blockquote>
  </body>
</html>