Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b203dd95 authored by Christian König's avatar Christian König Committed by Alex Deucher
Browse files

drm/amdgpu: fix zeroing all IB fields manually v2



The problem now is that we don't necessarily call amdgpu_ib_get()
in some error paths and so work with uninitialized data.

Better require that the memory is already zeroed.

v2: better commit message

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com> (v1)
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bf7ebaee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
	}


	p->ibs = kmalloc_array(p->num_ibs, sizeof(struct amdgpu_ib), GFP_KERNEL);
	p->ibs = kcalloc(p->num_ibs, sizeof(struct amdgpu_ib), GFP_KERNEL);
	if (!p->ibs)
		r = -ENOMEM;

+0 −17
Original line number Diff line number Diff line
@@ -73,29 +73,12 @@ int amdgpu_ib_get(struct amdgpu_ring *ring, struct amdgpu_vm *vm,

		if (!vm)
			ib->gpu_addr = amdgpu_sa_bo_gpu_addr(ib->sa_bo);
		else
			ib->gpu_addr = 0;

	} else {
		ib->sa_bo = NULL;
		ib->ptr = NULL;
		ib->gpu_addr = 0;
	}

	amdgpu_sync_create(&ib->sync);

	ib->ring = ring;
	ib->fence = NULL;
	ib->user = NULL;
	ib->vm = vm;
	ib->ctx = NULL;
	ib->gds_base = 0;
	ib->gds_size = 0;
	ib->gws_base = 0;
	ib->gws_size = 0;
	ib->oa_base = 0;
	ib->oa_size = 0;
	ib->flags = 0;

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -630,6 +630,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring)
	gpu_addr = adev->wb.gpu_addr + (index * 4);
	tmp = 0xCAFEDEAD;
	adev->wb.wb[index] = cpu_to_le32(tmp);
	memset(&ib, 0, sizeof(ib));
	r = amdgpu_ib_get(ring, NULL, 256, &ib);
	if (r) {
		DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
+1 −0
Original line number Diff line number Diff line
@@ -2660,6 +2660,7 @@ static int gfx_v7_0_ring_test_ib(struct amdgpu_ring *ring)
		return r;
	}
	WREG32(scratch, 0xCAFEDEAD);
	memset(&ib, 0, sizeof(ib));
	r = amdgpu_ib_get(ring, NULL, 256, &ib);
	if (r) {
		DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
+1 −0
Original line number Diff line number Diff line
@@ -622,6 +622,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring)
		return r;
	}
	WREG32(scratch, 0xCAFEDEAD);
	memset(&ib, 0, sizeof(ib));
	r = amdgpu_ib_get(ring, NULL, 256, &ib);
	if (r) {
		DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
Loading