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

drm/amdgpu/vce: Clear VCPU BO, don't unmap/unreserve (v4)

The VCPU BO doesn't only contain the VCE firmware but also other
ranges that the VCE uses for its stack and data. Let's initialize
this to zero to avoid having garbage in the VCPU BO.

Additionally, don't unmap/unreserve the VCPU BO.
The VCPU BO needs to stay at the same location before and after
sleep/resume because the FW code is not relocatable once it's
started.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Timur Kristóf and committed by
Alex Deucher
e583d31f f2e18c94

+3 -20
+3 -20
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
··· 314 314 */ 315 315 int amdgpu_vce_resume(struct amdgpu_device *adev) 316 316 { 317 - void *cpu_addr; 318 317 const struct common_firmware_header *hdr; 319 318 unsigned int offset; 320 - int r, idx; 319 + int idx; 321 320 322 321 if (adev->vce.vcpu_bo == NULL) 323 322 return -EINVAL; 324 - 325 - r = amdgpu_bo_reserve(adev->vce.vcpu_bo, false); 326 - if (r) { 327 - dev_err(adev->dev, "(%d) failed to reserve VCE bo\n", r); 328 - return r; 329 - } 330 - 331 - r = amdgpu_bo_kmap(adev->vce.vcpu_bo, &cpu_addr); 332 - if (r) { 333 - amdgpu_bo_unreserve(adev->vce.vcpu_bo); 334 - dev_err(adev->dev, "(%d) VCE map failed\n", r); 335 - return r; 336 - } 337 323 338 324 hdr = (const struct common_firmware_header *)adev->vce.fw->data; 339 325 offset = le32_to_cpu(hdr->ucode_array_offset_bytes); 340 326 341 327 if (drm_dev_enter(adev_to_drm(adev), &idx)) { 342 - memcpy_toio(cpu_addr, adev->vce.fw->data + offset, 328 + memset_io(adev->vce.cpu_addr, 0, amdgpu_bo_size(adev->vce.vcpu_bo)); 329 + memcpy_toio(adev->vce.cpu_addr, adev->vce.fw->data + offset, 343 330 adev->vce.fw->size - offset); 344 331 drm_dev_exit(idx); 345 332 } 346 - 347 - amdgpu_bo_kunmap(adev->vce.vcpu_bo); 348 - 349 - amdgpu_bo_unreserve(adev->vce.vcpu_bo); 350 333 351 334 return 0; 352 335 }