Skip to content

Commit 29e2501

Browse files
Zhigang Luoalexdeucher
authored andcommitted
drm/amdgpu: add CAP fw loading
The CAP fw is for enabling driver compatibility. Currently, it only enabled for vega10 VF. Signed-off-by: Zhigang Luo <[email protected]> Reviewed-by: Shaoyun Liu <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 8e02561 commit 29e2501

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ static int psp_sw_fini(void *handle)
159159
adev->psp.sos_fw = NULL;
160160
release_firmware(adev->psp.asd_fw);
161161
adev->psp.asd_fw = NULL;
162+
if (adev->psp.cap_fw) {
163+
release_firmware(adev->psp.cap_fw);
164+
adev->psp.cap_fw = NULL;
165+
}
162166
if (adev->psp.ta_fw) {
163167
release_firmware(adev->psp.ta_fw);
164168
adev->psp.ta_fw = NULL;
@@ -246,7 +250,7 @@ psp_cmd_submit_buf(struct psp_context *psp,
246250
DRM_WARN("psp command (0x%X) failed and response status is (0x%X)\n",
247251
psp->cmd_buf_mem->cmd_id,
248252
psp->cmd_buf_mem->resp.status);
249-
if (!timeout) {
253+
if ((ucode->ucode_id == AMDGPU_UCODE_ID_CAP) || !timeout) {
250254
mutex_unlock(&psp->mutex);
251255
return -EINVAL;
252256
}
@@ -1188,6 +1192,9 @@ static int psp_get_fw_type(struct amdgpu_firmware_info *ucode,
11881192
enum psp_gfx_fw_type *type)
11891193
{
11901194
switch (ucode->ucode_id) {
1195+
case AMDGPU_UCODE_ID_CAP:
1196+
*type = GFX_FW_TYPE_CAP;
1197+
break;
11911198
case AMDGPU_UCODE_ID_SDMA0:
11921199
*type = GFX_FW_TYPE_SDMA0;
11931200
break;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ struct psp_context
252252
uint32_t asd_ucode_size;
253253
uint8_t *asd_start_addr;
254254

255+
/* cap firmware */
256+
const struct firmware *cap_fw;
257+
255258
/* fence buffer */
256259
struct amdgpu_bo *fence_buf_bo;
257260
uint64_t fence_buf_mc_addr;

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ union amdgpu_firmware_header {
283283
* fw loading support
284284
*/
285285
enum AMDGPU_UCODE_ID {
286-
AMDGPU_UCODE_ID_SDMA0 = 0,
286+
AMDGPU_UCODE_ID_CAP = 0, /* CAP must be the 1st fw to be loaded */
287+
AMDGPU_UCODE_ID_SDMA0,
287288
AMDGPU_UCODE_ID_SDMA1,
288289
AMDGPU_UCODE_ID_SDMA2,
289290
AMDGPU_UCODE_ID_SDMA3,

drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ enum psp_gfx_fw_type {
246246
GFX_FW_TYPE_SDMA6 = 56, /* SDMA6 MI */
247247
GFX_FW_TYPE_SDMA7 = 57, /* SDMA7 MI */
248248
GFX_FW_TYPE_VCN1 = 58, /* VCN1 MI */
249+
GFX_FW_TYPE_CAP = 62, /* CAP_FW VG */
249250
GFX_FW_TYPE_MAX
250251
};
251252

drivers/gpu/drm/amd/amdgpu/psp_v3_1.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
MODULE_FIRMWARE("amdgpu/vega10_sos.bin");
4646
MODULE_FIRMWARE("amdgpu/vega10_asd.bin");
47+
MODULE_FIRMWARE("amdgpu/vega10_cap.bin");
4748
MODULE_FIRMWARE("amdgpu/vega12_sos.bin");
4849
MODULE_FIRMWARE("amdgpu/vega12_asd.bin");
4950

@@ -63,6 +64,7 @@ static int psp_v3_1_init_microcode(struct psp_context *psp)
6364
char fw_name[30];
6465
int err = 0;
6566
const struct psp_firmware_header_v1_0 *hdr;
67+
struct amdgpu_firmware_info *info = NULL;
6668

6769
DRM_DEBUG("\n");
6870

@@ -112,6 +114,26 @@ static int psp_v3_1_init_microcode(struct psp_context *psp)
112114
adev->psp.asd_start_addr = (uint8_t *)hdr +
113115
le32_to_cpu(hdr->header.ucode_array_offset_bytes);
114116

117+
if (amdgpu_sriov_vf(adev) && adev->asic_type == CHIP_VEGA10) {
118+
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_cap.bin",
119+
chip_name);
120+
err = request_firmware(&adev->psp.cap_fw, fw_name, adev->dev);
121+
if (err)
122+
goto out;
123+
124+
err = amdgpu_ucode_validate(adev->psp.cap_fw);
125+
if (err)
126+
goto out;
127+
128+
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CAP];
129+
info->ucode_id = AMDGPU_UCODE_ID_CAP;
130+
info->fw = adev->psp.cap_fw;
131+
hdr = (const struct psp_firmware_header_v1_0 *)
132+
adev->psp.cap_fw->data;
133+
adev->firmware.fw_size += ALIGN(
134+
le32_to_cpu(hdr->header.ucode_size_bytes), PAGE_SIZE);
135+
}
136+
115137
return 0;
116138
out:
117139
if (err) {
@@ -122,6 +144,8 @@ static int psp_v3_1_init_microcode(struct psp_context *psp)
122144
adev->psp.sos_fw = NULL;
123145
release_firmware(adev->psp.asd_fw);
124146
adev->psp.asd_fw = NULL;
147+
release_firmware(adev->psp.cap_fw);
148+
adev->psp.cap_fw = NULL;
125149
}
126150

127151
return err;

0 commit comments

Comments
 (0)