<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
In general, one file carries multiple binaries. Maybe the check is there as the same binary file is used in a derivative of Renoir or PSP v12 based SOCs.</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Keeping size of the binary as 0 prevents the load (I think there's a check).</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Apart from this one, rest of the series is</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<span style="font-family: -apple-system, HelveticaNeue; font-size: 14.6667px; display: inline !important;">Reviewed-by: Lijo Lazar <</span><a href="mailto:lijo.lazar@amd.com" class="ms-outlook-linkify" style="font-family: -apple-system, HelveticaNeue; font-size: 14.6667px;">lijo.lazar@amd.com</a><span style="font-family: -apple-system, HelveticaNeue; font-size: 14.6667px; display: inline !important;">></span><br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div><br>
</div>
Thanks,<br>
Lijo</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Limonciello, Mario <Mario.Limonciello@amd.com><br>
<b>Sent:</b> Thursday, January 5, 2023 9:34:49 PM<br>
<b>To:</b> Lazar, Lijo <Lijo.Lazar@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org><br>
<b>Cc:</b> Javier Martinez Canillas <javierm@redhat.com>; Carlos Soriano Sanchez <csoriano@redhat.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>; David Airlie <airlied@gmail.com>;
Daniel Vetter <daniel@ffwll.ch>; Koenig, Christian <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com><br>
<b>Subject:</b> RE: [PATCH v6 20/45] drm/amd: Parse both v1 and v2 TA microcode headers using same function</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[AMD Official Use Only - General]<br>
<br>
<br>
<br>
> -----Original Message-----<br>
> From: Lazar, Lijo <Lijo.Lazar@amd.com><br>
> Sent: Thursday, January 5, 2023 07:22<br>
> To: Limonciello, Mario <Mario.Limonciello@amd.com>; Deucher, Alexander<br>
> <Alexander.Deucher@amd.com>; linux-kernel@vger.kernel.org<br>
> Cc: Javier Martinez Canillas <javierm@redhat.com>; Carlos Soriano Sanchez<br>
> <csoriano@redhat.com>; amd-gfx@lists.freedesktop.org; dri-<br>
> devel@lists.freedesktop.org; David Airlie <airlied@gmail.com>; Daniel Vetter<br>
> <daniel@ffwll.ch>; Koenig, Christian <Christian.Koenig@amd.com>; Pan,<br>
> Xinhui <Xinhui.Pan@amd.com><br>
> Subject: Re: [PATCH v6 20/45] drm/amd: Parse both v1 and v2 TA microcode<br>
> headers using same function<br>
> <br>
> <br>
> <br>
> On 1/5/2023 9:12 AM, Mario Limonciello wrote:<br>
> > Several IP versions duplicate code and can't use the common helpers.<br>
> > Move this code into a single function so that the helpers can be used.<br>
> ><br>
> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com><br>
> > ---<br>
> > v5->v6:<br>
> > * Rebase on earlier patches<br>
> > ---<br>
> > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 120<br>
> ++++++++++++++++++------<br>
> > drivers/gpu/drm/amd/amdgpu/psp_v10_0.c | 64 +------------<br>
> > drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 77 ++-------------<br>
> > drivers/gpu/drm/amd/amdgpu/psp_v12_0.c | 62 +-----------<br>
> > 4 files changed, 109 insertions(+), 214 deletions(-)<br>
> ><br>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> > index 7a2fc920739b..d971e3785eaf 100644<br>
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> > @@ -3272,41 +3272,75 @@ static int parse_ta_bin_descriptor(struct<br>
> psp_context *psp,<br>
> > return 0;<br>
> > }<br>
> ><br>
> > -int psp_init_ta_microcode(struct psp_context *psp,<br>
> > - const char *chip_name)<br>
> > +static int parse_ta_v1_microcode(struct psp_context *psp)<br>
> > {<br>
> > + const struct ta_firmware_header_v1_0 *ta_hdr;<br>
> > struct amdgpu_device *adev = psp->adev;<br>
> > - char fw_name[PSP_FW_NAME_LEN];<br>
> > - const struct ta_firmware_header_v2_0 *ta_hdr;<br>
> > - int err = 0;<br>
> > - int ta_index = 0;<br>
> ><br>
> > - if (!chip_name) {<br>
> > - dev_err(adev->dev, "invalid chip name for ta microcode\n");<br>
> > + ta_hdr = (const struct ta_firmware_header_v1_0 *)<br>
> > + adev->psp.ta_fw->data;<br>
> > +<br>
> > + if (le16_to_cpu(ta_hdr->header.header_version_major) != 1)<br>
> > return -EINVAL;<br>
> > +<br>
> > + adev->psp.xgmi_context.context.bin_desc.fw_version =<br>
> > + le32_to_cpu(ta_hdr->xgmi.fw_version);<br>
> > + adev->psp.xgmi_context.context.bin_desc.size_bytes =<br>
> > + le32_to_cpu(ta_hdr->xgmi.size_bytes);<br>
> > + adev->psp.xgmi_context.context.bin_desc.start_addr =<br>
> > + (uint8_t *)ta_hdr +<br>
> > + le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes);<br>
> > + adev->psp.ta_fw_version = le32_to_cpu(ta_hdr-<br>
> >header.ucode_version);<br>
> > + adev->psp.ras_context.context.bin_desc.fw_version =<br>
> > + le32_to_cpu(ta_hdr->ras.fw_version);<br>
> > + adev->psp.ras_context.context.bin_desc.size_bytes =<br>
> > + le32_to_cpu(ta_hdr->ras.size_bytes);<br>
> > + adev->psp.ras_context.context.bin_desc.start_addr =<br>
> > + (uint8_t *)adev-<br>
> >psp.xgmi_context.context.bin_desc.start_addr +<br>
> > + le32_to_cpu(ta_hdr->ras.offset_bytes);<br>
> > + adev->psp.hdcp_context.context.bin_desc.fw_version =<br>
> > + le32_to_cpu(ta_hdr->hdcp.fw_version);<br>
> > + adev->psp.hdcp_context.context.bin_desc.size_bytes =<br>
> > + le32_to_cpu(ta_hdr->hdcp.size_bytes);<br>
> > + adev->psp.hdcp_context.context.bin_desc.start_addr =<br>
> > + (uint8_t *)ta_hdr +<br>
> > + le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes);<br>
> > + adev->psp.ta_fw_version = le32_to_cpu(ta_hdr-<br>
> >header.ucode_version);<br>
> > + adev->psp.dtm_context.context.bin_desc.fw_version =<br>
> > + le32_to_cpu(ta_hdr->dtm.fw_version);<br>
> > + adev->psp.dtm_context.context.bin_desc.size_bytes =<br>
> > + le32_to_cpu(ta_hdr->dtm.size_bytes);<br>
> > + adev->psp.dtm_context.context.bin_desc.start_addr =<br>
> > + (uint8_t *)adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr +<br>
> > + le32_to_cpu(ta_hdr->dtm.offset_bytes);<br>
> > + if (adev->apu_flags & AMD_APU_IS_RENOIR) {<br>
> > + adev-<br>
> >psp.securedisplay_context.context.bin_desc.fw_version =<br>
> > + le32_to_cpu(ta_hdr->securedisplay.fw_version);<br>
> > + adev-<br>
> >psp.securedisplay_context.context.bin_desc.size_bytes =<br>
> > + le32_to_cpu(ta_hdr->securedisplay.size_bytes);<br>
> > + adev-<br>
> >psp.securedisplay_context.context.bin_desc.start_addr =<br>
> > + (uint8_t *)adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr +<br>
> > + le32_to_cpu(ta_hdr->securedisplay.offset_bytes);<br>
> > }<br>
> <br>
> psp_v10_0_init_microcode used to get securedisplay_context<br>
> unconditionally and now this is restricted to RENOIR following the logic<br>
> in psp v12. <br>
<br>
Good catch, thanks. I'll fix that.<br>
<br>
> Better is to fetch all FW details unconditionally and make<br>
> the size_bytes to 0 (just to be sure) in specific PSP versions to<br>
> prevent their load.<br>
<br>
I do have to wonder if this was just an oversight or it's intentional?<br>
<br>
For now I'll return it to just check in Renoir in psp-v12 code though.<br>
We can remove that bit later if it was just an oversight.<br>
<br>
> <br>
> Thanks,<br>
> Lijo<br>
> <br>
> ><br>
> > - snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin",<br>
> chip_name);<br>
> > - err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);<br>
> > - if (err)<br>
> > - goto out;<br>
> > + return 0;<br>
> > +}<br>
> ><br>
> > - err = amdgpu_ucode_validate(adev->psp.ta_fw);<br>
> > - if (err)<br>
> > - goto out;<br>
> > +static int parse_ta_v2_microcode(struct psp_context *psp)<br>
> > +{<br>
> > + const struct ta_firmware_header_v2_0 *ta_hdr;<br>
> > + struct amdgpu_device *adev = psp->adev;<br>
> > + int err = 0;<br>
> > + int ta_index = 0;<br>
> ><br>
> > ta_hdr = (const struct ta_firmware_header_v2_0 *)adev-<br>
> >psp.ta_fw->data;<br>
> ><br>
> > - if (le16_to_cpu(ta_hdr->header.header_version_major) != 2) {<br>
> > - dev_err(adev->dev, "unsupported TA header version\n");<br>
> > - err = -EINVAL;<br>
> > - goto out;<br>
> > - }<br>
> > + if (le16_to_cpu(ta_hdr->header.header_version_major) != 2)<br>
> > + return -EINVAL;<br>
> ><br>
> > if (le32_to_cpu(ta_hdr->ta_fw_bin_count) >=<br>
> UCODE_MAX_PSP_PACKAGING) {<br>
> > dev_err(adev->dev, "packed TA count exceeds maximum<br>
> limit\n");<br>
> > - err = -EINVAL;<br>
> > - goto out;<br>
> > + return -EINVAL;<br>
> > }<br>
> ><br>
> > for (ta_index = 0; ta_index < le32_to_cpu(ta_hdr-<br>
> >ta_fw_bin_count); ta_index++) {<br>
> > @@ -3314,14 +3348,46 @@ int psp_init_ta_microcode(struct psp_context<br>
> *psp,<br>
> > &ta_hdr->ta_fw_bin[ta_index],<br>
> > ta_hdr);<br>
> > if (err)<br>
> > - goto out;<br>
> > + return err;<br>
> > }<br>
> ><br>
> > return 0;<br>
> > -out:<br>
> > - dev_err(adev->dev, "fail to initialize ta microcode\n");<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > +}<br>
> > +<br>
> > +int psp_init_ta_microcode(struct psp_context *psp, const char<br>
> *chip_name)<br>
> > +{<br>
> > + const struct common_firmware_header *hdr;<br>
> > + struct amdgpu_device *adev = psp->adev;<br>
> > + char fw_name[PSP_FW_NAME_LEN];<br>
> > + int err;<br>
> > +<br>
> > + snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin",<br>
> chip_name);<br>
> > + err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);<br>
> > + if (err)<br>
> > + return err;<br>
> > + err = amdgpu_ucode_validate(adev->psp.ta_fw);<br>
> > + if (err)<br>
> > + return err;<br>
> > +<br>
> > + hdr = (const struct common_firmware_header *)adev->psp.ta_fw-<br>
> >data;<br>
> > + switch (le16_to_cpu(hdr->header_version_major)) {<br>
> > + case 1:<br>
> > + err = parse_ta_v1_microcode(psp);<br>
> > + break;<br>
> > + case 2:<br>
> > + err = parse_ta_v2_microcode(psp);<br>
> > + break;<br>
> > + default:<br>
> > + dev_err(adev->dev, "unsupported TA header version\n");<br>
> > + err = -EINVAL;<br>
> > + }<br>
> > +<br>
> > + if (err) {<br>
> > + dev_err(adev->dev, "fail to initialize ta microcode\n");<br>
> > + release_firmware(adev->psp.ta_fw);<br>
> > + adev->psp.ta_fw = NULL;<br>
> > + }<br>
> > +<br>
> > return err;<br>
> > }<br>
> ><br>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> > index 9de46fa8f46c..f14fcfb9c425 100644<br>
> > --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c<br>
> > @@ -48,9 +48,8 @@ static int psp_v10_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > {<br>
> > struct amdgpu_device *adev = psp->adev;<br>
> > const char *chip_name;<br>
> > - char fw_name[30];<br>
> > + char ucode_prefix[30];<br>
> > int err = 0;<br>
> > - const struct ta_firmware_header_v1_0 *ta_hdr;<br>
> > DRM_DEBUG("\n");<br>
> ><br>
> > switch (adev->asic_type) {<br>
> > @@ -64,66 +63,13 @@ static int psp_v10_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > break;<br>
> > default: BUG();<br>
> > }<br>
> > + amdgpu_ucode_ip_version_decode(adev, MP0_HWIP,<br>
> ucode_prefix, sizeof(ucode_prefix));<br>
> ><br>
> > - err = psp_init_asd_microcode(psp, chip_name);<br>
> > + err = psp_init_asd_microcode(psp, ucode_prefix);<br>
> > if (err)<br>
> > - goto out;<br>
> > -<br>
> > - snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin",<br>
> chip_name);<br>
> > - err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);<br>
> > - if (err) {<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > - dev_info(adev->dev,<br>
> > - "psp v10.0: Failed to load firmware \"%s\"\n",<br>
> > - fw_name);<br>
> > - } else {<br>
> > - err = amdgpu_ucode_validate(adev->psp.ta_fw);<br>
> > - if (err)<br>
> > - goto out2;<br>
> > -<br>
> > - ta_hdr = (const struct ta_firmware_header_v1_0 *)<br>
> > - adev->psp.ta_fw->data;<br>
> > - adev->psp.hdcp_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->hdcp.fw_version);<br>
> > - adev->psp.hdcp_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->hdcp.size_bytes);<br>
> > - adev->psp.hdcp_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)ta_hdr +<br>
> > - le32_to_cpu(ta_hdr-<br>
> >header.ucode_array_offset_bytes);<br>
> > -<br>
> > - adev->psp.dtm_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->dtm.fw_version);<br>
> > - adev->psp.dtm_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->dtm.size_bytes);<br>
> > - adev->psp.dtm_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr +<br>
> > - le32_to_cpu(ta_hdr->dtm.offset_bytes);<br>
> > -<br>
> > - adev-<br>
> >psp.securedisplay_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->securedisplay.fw_version);<br>
> > - adev-<br>
> >psp.securedisplay_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->securedisplay.size_bytes);<br>
> > - adev-<br>
> >psp.securedisplay_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr +<br>
> > - le32_to_cpu(ta_hdr->securedisplay.offset_bytes);<br>
> > -<br>
> > - adev->psp.ta_fw_version = le32_to_cpu(ta_hdr-<br>
> >header.ucode_version);<br>
> > - }<br>
> > -<br>
> > - return 0;<br>
> > -<br>
> > -out2:<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > -out:<br>
> > - if (err) {<br>
> > - dev_err(adev->dev,<br>
> > - "psp v10.0: Failed to load firmware \"%s\"\n",<br>
> > - fw_name);<br>
> > - }<br>
> > + return err;<br>
> ><br>
> > - return err;<br>
> > + return psp_init_ta_microcode(psp, ucode_prefix);<br>
> > }<br>
> ><br>
> > static int psp_v10_0_ring_create(struct psp_context *psp,<br>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c<br>
> b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c<br>
> > index bd3e3e23a939..21d20ca2377a 100644<br>
> > --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c<br>
> > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c<br>
> > @@ -89,9 +89,8 @@ static int psp_v11_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > {<br>
> > struct amdgpu_device *adev = psp->adev;<br>
> > const char *chip_name;<br>
> > - char fw_name[PSP_FW_NAME_LEN];<br>
> > + char ucode_prefix[30];<br>
> > int err = 0;<br>
> > - const struct ta_firmware_header_v1_0 *ta_hdr;<br>
> ><br>
> > DRM_DEBUG("\n");<br>
> ><br>
> > @@ -129,6 +128,7 @@ static int psp_v11_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > default:<br>
> > BUG();<br>
> > }<br>
> > + amdgpu_ucode_ip_version_decode(adev, MP0_HWIP,<br>
> ucode_prefix, sizeof(ucode_prefix));<br>
> ><br>
> ><br>
> > switch (adev->ip_versions[MP0_HWIP][0]) {<br>
> > @@ -140,35 +140,9 @@ static int psp_v11_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > err = psp_init_asd_microcode(psp, chip_name);<br>
> > if (err)<br>
> > return err;<br>
> > - snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin",<br>
> chip_name);<br>
> > - err = request_firmware(&adev->psp.ta_fw, fw_name, adev-<br>
> >dev);<br>
> > - if (err) {<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > - dev_info(adev->dev,<br>
> > - "psp v11.0: Failed to load firmware<br>
> \"%s\"\n", fw_name);<br>
> > - } else {<br>
> > - err = amdgpu_ucode_validate(adev->psp.ta_fw);<br>
> > - if (err)<br>
> > - goto out2;<br>
> > -<br>
> > - ta_hdr = (const struct ta_firmware_header_v1_0<br>
> *)adev->psp.ta_fw->data;<br>
> > - adev-<br>
> >psp.xgmi_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->xgmi.fw_version);<br>
> > - adev-<br>
> >psp.xgmi_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->xgmi.size_bytes);<br>
> > - adev-<br>
> >psp.xgmi_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)ta_hdr +<br>
> > - le32_to_cpu(ta_hdr-<br>
> >header.ucode_array_offset_bytes);<br>
> > - adev->psp.ta_fw_version = le32_to_cpu(ta_hdr-<br>
> >header.ucode_version);<br>
> > - adev->psp.ras_context.context.bin_desc.fw_version<br>
> =<br>
> > - le32_to_cpu(ta_hdr->ras.fw_version);<br>
> > - adev->psp.ras_context.context.bin_desc.size_bytes<br>
> =<br>
> > - le32_to_cpu(ta_hdr->ras.size_bytes);<br>
> > - adev->psp.ras_context.context.bin_desc.start_addr<br>
> =<br>
> > - (uint8_t *)adev-<br>
> >psp.xgmi_context.context.bin_desc.start_addr +<br>
> > - le32_to_cpu(ta_hdr->ras.offset_bytes);<br>
> > - }<br>
> > + err = psp_init_ta_microcode(psp, ucode_prefix);<br>
> > + if (err)<br>
> > + return err;<br>
> > break;<br>
> > case IP_VERSION(11, 0, 0):<br>
> > case IP_VERSION(11, 0, 5):<br>
> > @@ -179,39 +153,9 @@ static int psp_v11_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > err = psp_init_asd_microcode(psp, chip_name);<br>
> > if (err)<br>
> > return err;<br>
> > - snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin",<br>
> chip_name);<br>
> > - err = request_firmware(&adev->psp.ta_fw, fw_name, adev-<br>
> >dev);<br>
> > - if (err) {<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > - dev_info(adev->dev,<br>
> > - "psp v11.0: Failed to load firmware<br>
> \"%s\"\n", fw_name);<br>
> > - } else {<br>
> > - err = amdgpu_ucode_validate(adev->psp.ta_fw);<br>
> > - if (err)<br>
> > - goto out2;<br>
> > -<br>
> > - ta_hdr = (const struct ta_firmware_header_v1_0<br>
> *)adev->psp.ta_fw->data;<br>
> > - adev-<br>
> >psp.hdcp_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->hdcp.fw_version);<br>
> > - adev-<br>
> >psp.hdcp_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->hdcp.size_bytes);<br>
> > - adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)ta_hdr +<br>
> > - le32_to_cpu(<br>
> > - ta_hdr-<br>
> >header.ucode_array_offset_bytes);<br>
> > -<br>
> > - adev->psp.ta_fw_version = le32_to_cpu(ta_hdr-<br>
> >header.ucode_version);<br>
> > -<br>
> > - adev-<br>
> >psp.dtm_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->dtm.fw_version);<br>
> > - adev-<br>
> >psp.dtm_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->dtm.size_bytes);<br>
> > - adev-<br>
> >psp.dtm_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)adev->psp.hdcp_context.context<br>
> > - .bin_desc.start_addr +<br>
> > - le32_to_cpu(ta_hdr->dtm.offset_bytes);<br>
> > - }<br>
> > + err = psp_init_ta_microcode(psp, ucode_prefix);<br>
> > + if (err)<br>
> > + return err;<br>
> > break;<br>
> > case IP_VERSION(11, 0, 7):<br>
> > case IP_VERSION(11, 0, 11):<br>
> > @@ -237,11 +181,6 @@ static int psp_v11_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > }<br>
> ><br>
> > return 0;<br>
> > -<br>
> > -out2:<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > - return err;<br>
> > }<br>
> ><br>
> > static int psp_v11_0_wait_for_bootloader(struct psp_context *psp)<br>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c<br>
> b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c<br>
> > index 8ed2281b6557..634fa2822d8a 100644<br>
> > --- a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c<br>
> > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c<br>
> > @@ -49,9 +49,8 @@ static int psp_v12_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > {<br>
> > struct amdgpu_device *adev = psp->adev;<br>
> > const char *chip_name;<br>
> > - char fw_name[30];<br>
> > + char ucode_prefix[30];<br>
> > int err = 0;<br>
> > - const struct ta_firmware_header_v1_0 *ta_hdr;<br>
> > DRM_DEBUG("\n");<br>
> ><br>
> > switch (adev->asic_type) {<br>
> > @@ -64,67 +63,12 @@ static int psp_v12_0_init_microcode(struct<br>
> psp_context *psp)<br>
> > default:<br>
> > BUG();<br>
> > }<br>
> > + amdgpu_ucode_ip_version_decode(adev, MP0_HWIP,<br>
> ucode_prefix, sizeof(ucode_prefix));<br>
> ><br>
> > err = psp_init_asd_microcode(psp, chip_name);<br>
> > if (err)<br>
> > return err;<br>
> > -<br>
> > - snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin",<br>
> chip_name);<br>
> > - err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);<br>
> > - if (err) {<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > - dev_info(adev->dev,<br>
> > - "psp v12.0: Failed to load firmware \"%s\"\n",<br>
> > - fw_name);<br>
> > - } else {<br>
> > - err = amdgpu_ucode_validate(adev->psp.ta_fw);<br>
> > - if (err)<br>
> > - goto out;<br>
> > -<br>
> > - ta_hdr = (const struct ta_firmware_header_v1_0 *)<br>
> > - adev->psp.ta_fw->data;<br>
> > - adev->psp.hdcp_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->hdcp.fw_version);<br>
> > - adev->psp.hdcp_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->hdcp.size_bytes);<br>
> > - adev->psp.hdcp_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)ta_hdr +<br>
> > - le32_to_cpu(ta_hdr-<br>
> >header.ucode_array_offset_bytes);<br>
> > -<br>
> > - adev->psp.ta_fw_version = le32_to_cpu(ta_hdr-<br>
> >header.ucode_version);<br>
> > -<br>
> > - adev->psp.dtm_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr->dtm.fw_version);<br>
> > - adev->psp.dtm_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr->dtm.size_bytes);<br>
> > - adev->psp.dtm_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr +<br>
> > - le32_to_cpu(ta_hdr->dtm.offset_bytes);<br>
> > -<br>
> > - if (adev->apu_flags & AMD_APU_IS_RENOIR) {<br>
> > - adev-<br>
> >psp.securedisplay_context.context.bin_desc.fw_version =<br>
> > - le32_to_cpu(ta_hdr-<br>
> >securedisplay.fw_version);<br>
> > - adev-<br>
> >psp.securedisplay_context.context.bin_desc.size_bytes =<br>
> > - le32_to_cpu(ta_hdr-<br>
> >securedisplay.size_bytes);<br>
> > - adev-<br>
> >psp.securedisplay_context.context.bin_desc.start_addr =<br>
> > - (uint8_t *)adev-<br>
> >psp.hdcp_context.context.bin_desc.start_addr +<br>
> > - le32_to_cpu(ta_hdr-<br>
> >securedisplay.offset_bytes);<br>
> > - }<br>
> > - }<br>
> > -<br>
> > - return 0;<br>
> > -<br>
> > -out:<br>
> > - release_firmware(adev->psp.ta_fw);<br>
> > - adev->psp.ta_fw = NULL;<br>
> > - if (err) {<br>
> > - dev_err(adev->dev,<br>
> > - "psp v12.0: Failed to load firmware \"%s\"\n",<br>
> > - fw_name);<br>
> > - }<br>
> > -<br>
> > - return err;<br>
> > + return psp_init_ta_microcode(psp, ucode_prefix);<br>
> > }<br>
> ><br>
> > static int psp_v12_0_bootloader_load_sysdrv(struct psp_context *psp)<br>
</div>
</span></font></div>
</div>
</body>
</html>