Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: updated ta ucode loading

add support for loading ucode with ta_firmware_header_v2_0

Reviewed-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: John Clements <john.clements@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

John Clements and committed by
Alex Deucher
dcf9864d f893d74f

+101
+99
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 2277 2277 return err; 2278 2278 } 2279 2279 2280 + int parse_ta_bin_descriptor(struct psp_context *psp, 2281 + const struct ta_fw_bin_desc *desc, 2282 + const struct ta_firmware_header_v2_0 *ta_hdr) 2283 + { 2284 + uint8_t *ucode_start_addr = NULL; 2285 + 2286 + if (!psp || !desc || !ta_hdr) 2287 + return -EINVAL; 2288 + 2289 + ucode_start_addr = (uint8_t *)ta_hdr + le32_to_cpu(desc->offset_bytes); 2290 + 2291 + switch (desc->fw_type) { 2292 + case TA_FW_TYPE_PSP_ASD: 2293 + psp->asd_fw_version = le32_to_cpu(desc->fw_version); 2294 + psp->asd_feature_version = le32_to_cpu(desc->fw_version); 2295 + psp->asd_ucode_size = le32_to_cpu(desc->size_bytes); 2296 + psp->asd_start_addr = ucode_start_addr; 2297 + break; 2298 + case TA_FW_TYPE_PSP_XGMI: 2299 + psp->ta_xgmi_ucode_version = le32_to_cpu(desc->fw_version); 2300 + psp->ta_xgmi_ucode_size = le32_to_cpu(desc->size_bytes); 2301 + psp->ta_xgmi_start_addr = ucode_start_addr; 2302 + break; 2303 + case TA_FW_TYPE_PSP_RAS: 2304 + psp->ta_ras_ucode_version = le32_to_cpu(desc->fw_version); 2305 + psp->ta_ras_ucode_size = le32_to_cpu(desc->size_bytes); 2306 + psp->ta_ras_start_addr = ucode_start_addr; 2307 + break; 2308 + case TA_FW_TYPE_PSP_HDCP: 2309 + psp->ta_hdcp_ucode_version = le32_to_cpu(desc->fw_version); 2310 + psp->ta_hdcp_ucode_size = le32_to_cpu(desc->size_bytes); 2311 + psp->ta_hdcp_start_addr = ucode_start_addr; 2312 + break; 2313 + case TA_FW_TYPE_PSP_DTM: 2314 + psp->ta_dtm_ucode_version = le32_to_cpu(desc->fw_version); 2315 + psp->ta_dtm_ucode_size = le32_to_cpu(desc->size_bytes); 2316 + psp->ta_dtm_start_addr = ucode_start_addr; 2317 + break; 2318 + default: 2319 + dev_warn(psp->adev->dev, "Unsupported TA type: %d\n", desc->fw_type); 2320 + break; 2321 + } 2322 + 2323 + return 0; 2324 + } 2325 + 2326 + int psp_init_ta_microcode(struct psp_context *psp, 2327 + const char *chip_name) 2328 + { 2329 + struct amdgpu_device *adev = psp->adev; 2330 + char fw_name[30]; 2331 + const struct ta_firmware_header_v2_0 *ta_hdr; 2332 + int err = 0; 2333 + int ta_index = 0; 2334 + 2335 + if (!chip_name) { 2336 + dev_err(adev->dev, "invalid chip name for ta microcode\n"); 2337 + return -EINVAL; 2338 + } 2339 + 2340 + snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name); 2341 + err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev); 2342 + if (err) 2343 + goto out; 2344 + 2345 + err = amdgpu_ucode_validate(adev->psp.ta_fw); 2346 + if (err) 2347 + goto out; 2348 + 2349 + ta_hdr = (const struct ta_firmware_header_v2_0 *)adev->psp.ta_fw->data; 2350 + 2351 + if (le16_to_cpu(ta_hdr->header.header_version_major) != 2) { 2352 + dev_err(adev->dev, "unsupported TA header version\n"); 2353 + err = -EINVAL; 2354 + goto out; 2355 + } 2356 + 2357 + if (le32_to_cpu(ta_hdr->ta_fw_bin_count) >= UCODE_MAX_TA_PACKAGING) { 2358 + dev_err(adev->dev, "packed TA count exceeds maximum limit\n"); 2359 + err = -EINVAL; 2360 + goto out; 2361 + } 2362 + 2363 + for (ta_index = 0; ta_index < le32_to_cpu(ta_hdr->ta_fw_bin_count); ta_index++) { 2364 + err = parse_ta_bin_descriptor(psp, 2365 + &ta_hdr->ta_fw_bin[ta_index], 2366 + ta_hdr); 2367 + if (err) 2368 + goto out; 2369 + } 2370 + 2371 + return 0; 2372 + out: 2373 + dev_err(adev->dev, "fail to initialize ta microcode\n"); 2374 + release_firmware(adev->psp.ta_fw); 2375 + adev->psp.ta_fw = NULL; 2376 + return err; 2377 + } 2378 + 2280 2379 static int psp_set_clockgating_state(void *handle, 2281 2380 enum amd_clockgating_state state) 2282 2381 {
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
··· 371 371 const char *chip_name); 372 372 int psp_init_sos_microcode(struct psp_context *psp, 373 373 const char *chip_name); 374 + int psp_init_ta_microcode(struct psp_context *psp, 375 + const char *chip_name); 374 376 #endif