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: rework common ucode handling for vega10

Handle ucode differences in vega10.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Huang Rui and committed by
Alex Deucher
2445b227 9079ac76

+52 -22
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1181 1181 enum amdgpu_firmware_load_type load_type; 1182 1182 struct amdgpu_bo *fw_buf; 1183 1183 unsigned int fw_size; 1184 + unsigned int max_ucodes; 1184 1185 }; 1185 1186 1186 1187 /*
+46 -22
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
··· 260 260 return AMDGPU_FW_LOAD_DIRECT; 261 261 } 262 262 263 - static int amdgpu_ucode_init_single_fw(struct amdgpu_firmware_info *ucode, 264 - uint64_t mc_addr, void *kptr) 263 + static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev, 264 + struct amdgpu_firmware_info *ucode, 265 + uint64_t mc_addr, void *kptr) 265 266 { 266 267 const struct common_firmware_header *header = NULL; 268 + const struct gfx_firmware_header_v1_0 *cp_hdr = NULL; 267 269 268 270 if (NULL == ucode->fw) 269 271 return 0; ··· 278 276 279 277 header = (const struct common_firmware_header *)ucode->fw->data; 280 278 281 - ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes); 279 + cp_hdr = (const struct gfx_firmware_header_v1_0 *)ucode->fw->data; 282 280 283 - memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data + 284 - le32_to_cpu(header->ucode_array_offset_bytes)), 285 - ucode->ucode_size); 281 + if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP || 282 + (ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC1 && 283 + ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2 && 284 + ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC1_JT && 285 + ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2_JT)) { 286 + ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes); 287 + 288 + memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data + 289 + le32_to_cpu(header->ucode_array_offset_bytes)), 290 + ucode->ucode_size); 291 + } else if (ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC1 || 292 + ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC2) { 293 + ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes) - 294 + le32_to_cpu(cp_hdr->jt_size) * 4; 295 + 296 + memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data + 297 + le32_to_cpu(header->ucode_array_offset_bytes)), 298 + ucode->ucode_size); 299 + } else if (ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC1_JT || 300 + ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC2_JT) { 301 + ucode->ucode_size = le32_to_cpu(cp_hdr->jt_size) * 4; 302 + 303 + memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data + 304 + le32_to_cpu(header->ucode_array_offset_bytes) + 305 + le32_to_cpu(cp_hdr->jt_offset) * 4), 306 + ucode->ucode_size); 307 + } 286 308 287 309 return 0; 288 310 } ··· 332 306 (le32_to_cpu(header->jt_offset) * 4); 333 307 memcpy(dst_addr, src_addr, le32_to_cpu(header->jt_size) * 4); 334 308 309 + ucode->ucode_size += le32_to_cpu(header->jt_size) * 4; 310 + 335 311 return 0; 336 312 } 337 - 338 313 339 314 int amdgpu_ucode_init_bo(struct amdgpu_device *adev) 340 315 { ··· 343 316 uint64_t fw_mc_addr; 344 317 void *fw_buf_ptr = NULL; 345 318 uint64_t fw_offset = 0; 346 - int i, err, max; 319 + int i, err; 347 320 struct amdgpu_firmware_info *ucode = NULL; 348 321 const struct common_firmware_header *header = NULL; 349 322 ··· 376 349 377 350 amdgpu_bo_unreserve(*bo); 378 351 352 + memset(fw_buf_ptr, 0, adev->firmware.fw_size); 353 + 379 354 /* 380 355 * if SMU loaded firmware, it needn't add SMC, UVD, and VCE 381 356 * ucode info here 382 357 */ 383 358 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) 384 - max = AMDGPU_UCODE_ID_MAXIMUM - 3; 359 + adev->firmware.max_ucodes = AMDGPU_UCODE_ID_MAXIMUM - 4; 385 360 else 386 - max = AMDGPU_UCODE_ID_MAXIMUM; 361 + adev->firmware.max_ucodes = AMDGPU_UCODE_ID_MAXIMUM; 387 362 388 - for (i = 0; i < max; i++) { 363 + for (i = 0; i < adev->firmware.max_ucodes; i++) { 389 364 ucode = &adev->firmware.ucode[i]; 390 365 if (ucode->fw) { 391 366 header = (const struct common_firmware_header *)ucode->fw->data; 392 - amdgpu_ucode_init_single_fw(ucode, fw_mc_addr + fw_offset, 393 - fw_buf_ptr + fw_offset); 394 - if (i == AMDGPU_UCODE_ID_CP_MEC1) { 367 + amdgpu_ucode_init_single_fw(adev, ucode, fw_mc_addr + fw_offset, 368 + (void *)((uint8_t *)fw_buf_ptr + fw_offset)); 369 + if (i == AMDGPU_UCODE_ID_CP_MEC1 && 370 + adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) { 395 371 const struct gfx_firmware_header_v1_0 *cp_hdr; 396 372 cp_hdr = (const struct gfx_firmware_header_v1_0 *)ucode->fw->data; 397 373 amdgpu_ucode_patch_jt(ucode, fw_mc_addr + fw_offset, 398 374 fw_buf_ptr + fw_offset); 399 375 fw_offset += ALIGN(le32_to_cpu(cp_hdr->jt_size) << 2, PAGE_SIZE); 400 376 } 401 - fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 377 + fw_offset += ALIGN(ucode->ucode_size, PAGE_SIZE); 402 378 } 403 379 } 404 380 return 0; ··· 423 393 { 424 394 int i; 425 395 struct amdgpu_firmware_info *ucode = NULL; 426 - int max; 427 396 428 - if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) 429 - max = AMDGPU_UCODE_ID_MAXIMUM - 3; 430 - else 431 - max = AMDGPU_UCODE_ID_MAXIMUM; 432 - 433 - for (i = 0; i < max; i++) { 397 + for (i = 0; i < adev->firmware.max_ucodes; i++) { 434 398 ucode = &adev->firmware.ucode[i]; 435 399 if (ucode->fw) { 436 400 ucode->mc_addr = 0;
+5
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
··· 128 128 AMDGPU_UCODE_ID_CP_PFP, 129 129 AMDGPU_UCODE_ID_CP_ME, 130 130 AMDGPU_UCODE_ID_CP_MEC1, 131 + AMDGPU_UCODE_ID_CP_MEC1_JT, 131 132 AMDGPU_UCODE_ID_CP_MEC2, 133 + AMDGPU_UCODE_ID_CP_MEC2_JT, 132 134 AMDGPU_UCODE_ID_RLC_G, 133 135 AMDGPU_UCODE_ID_STORAGE, 136 + AMDGPU_UCODE_ID_SMC, 137 + AMDGPU_UCODE_ID_UVD, 138 + AMDGPU_UCODE_ID_VCE, 134 139 AMDGPU_UCODE_ID_MAXIMUM, 135 140 }; 136 141