Skip to content

Commit e583d31

Browse files
Timur Kristófalexdeucher
authored andcommitted
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>
1 parent f2e18c9 commit e583d31

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -314,40 +314,23 @@ int amdgpu_vce_suspend(struct amdgpu_device *adev)
314314
*/
315315
int amdgpu_vce_resume(struct amdgpu_device *adev)
316316
{
317-
void *cpu_addr;
318317
const struct common_firmware_header *hdr;
319318
unsigned int offset;
320-
int r, idx;
319+
int idx;
321320

322321
if (adev->vce.vcpu_bo == NULL)
323322
return -EINVAL;
324323

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-
338324
hdr = (const struct common_firmware_header *)adev->vce.fw->data;
339325
offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
340326

341327
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,
343330
adev->vce.fw->size - offset);
344331
drm_dev_exit(idx);
345332
}
346333

347-
amdgpu_bo_kunmap(adev->vce.vcpu_bo);
348-
349-
amdgpu_bo_unreserve(adev->vce.vcpu_bo);
350-
351334
return 0;
352335
}
353336

0 commit comments

Comments
 (0)