aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
diff options
context:
space:
mode:
authorMonk Liu <Monk.Liu@amd.com>2016-09-27 04:39:58 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-10-25 14:38:23 -0400
commit4c2b2453ef9be2e105a987cd13cf3ce14e53f5e0 (patch)
treeb96f0d2e60cecaa71b44d3ceda72ff50629fa4bf /drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
parentbed5712e1a52bb5d177722bc0d76c2a3a71b8338 (diff)
drm/amdgpu:properly fix some JumpTable issues
we found some MEC ucode leads to IB test fail or even ring test fail if Jump Table of it is not start in FW bo with page aligned address, fixed by always make JT address page aligned. we don't need to patch JT2 for MEC2, because for VI, MEC2 is a copy of MEC1, thus when converting fw_type for MEC_JT2 we just return MEC1,hw can use the same JT for both MEC1 & MEC2. above two change fixed some ring/ib test failure issue for some version of MEC ucode. Signed-off-by: Frank Min <Frank.Min@amd.com> Signed-off-by: Monk Liu <Monk.Liu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index 5d3f6ca742a4..0f0b38191fac 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -239,6 +239,31 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_firmware_info *ucode,
239 return 0; 239 return 0;
240} 240}
241 241
242static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode,
243 uint64_t mc_addr, void *kptr)
244{
245 const struct gfx_firmware_header_v1_0 *header = NULL;
246 const struct common_firmware_header *comm_hdr = NULL;
247 uint8_t* src_addr = NULL;
248 uint8_t* dst_addr = NULL;
249
250 if (NULL == ucode->fw)
251 return 0;
252
253 comm_hdr = (const struct common_firmware_header *)ucode->fw->data;
254 header = (const struct gfx_firmware_header_v1_0 *)ucode->fw->data;
255 dst_addr = ucode->kaddr +
256 ALIGN(le32_to_cpu(comm_hdr->ucode_size_bytes),
257 PAGE_SIZE);
258 src_addr = (uint8_t *)ucode->fw->data +
259 le32_to_cpu(comm_hdr->ucode_array_offset_bytes) +
260 (le32_to_cpu(header->jt_offset) * 4);
261 memcpy(dst_addr, src_addr, le32_to_cpu(header->jt_size) * 4);
262
263 return 0;
264}
265
266
242int amdgpu_ucode_init_bo(struct amdgpu_device *adev) 267int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
243{ 268{
244 struct amdgpu_bo **bo = &adev->firmware.fw_buf; 269 struct amdgpu_bo **bo = &adev->firmware.fw_buf;
@@ -284,6 +309,13 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
284 header = (const struct common_firmware_header *)ucode->fw->data; 309 header = (const struct common_firmware_header *)ucode->fw->data;
285 amdgpu_ucode_init_single_fw(ucode, fw_mc_addr + fw_offset, 310 amdgpu_ucode_init_single_fw(ucode, fw_mc_addr + fw_offset,
286 fw_buf_ptr + fw_offset); 311 fw_buf_ptr + fw_offset);
312 if (i == AMDGPU_UCODE_ID_CP_MEC1) {
313 const struct gfx_firmware_header_v1_0 *cp_hdr;
314 cp_hdr = (const struct gfx_firmware_header_v1_0 *)ucode->fw->data;
315 amdgpu_ucode_patch_jt(ucode, fw_mc_addr + fw_offset,
316 fw_buf_ptr + fw_offset);
317 fw_offset += ALIGN(le32_to_cpu(cp_hdr->jt_size) << 2, PAGE_SIZE);
318 }
287 fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 319 fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
288 } 320 }
289 } 321 }