drm/amdgpu: fix zeroing all IB fields manually v2
authorChristian König <christian.koenig@amd.com>
Tue, 18 Aug 2015 16:23:16 +0000 (18:23 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 20 Aug 2015 21:05:34 +0000 (17:05 -0400)
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: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com> (v1)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c

index 2cf7f52a5650cf4ec4c841eadfadfc15f695df1f..a592df574939c2557382d6e15226dad549fba476 100644 (file)
@@ -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;
 
index 5104e64e9ad8f18717fec0684518dc003ee2f7f0..1c237f5e3365aacd468f3ab3b2ff09ea6be567f3 100644 (file)
@@ -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;
 }
index 2b4242b39b0a0d71dfefa53d95f7323f6dc2a633..af526557ac663116ceb89cd71cee6b33fdb6e178 100644 (file)
@@ -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);
index 9b0cab41367731454f8f2ac9641c2f27069d95fb..fab7b236f37fa7753eb6983b4b177aa3dfd70587 100644 (file)
@@ -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);
index 4b68e6306f40cbeb8dfb8c4633f849d849cdc5bf..818edb37fa9cd8428d584d419597f22c3fe3045b 100644 (file)
@@ -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);
index 9de8104eddeb20965d68834a623f55a5321aa9e4..2b0e89e05b1df53167e81d41a5aeff4ca271e665 100644 (file)
@@ -689,6 +689,7 @@ static int sdma_v2_4_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);
index 029f3455f9f9721cde9c04b05044781a51561dc6..6f1df03ebc704954651ae4036079e10b1e9f5631 100644 (file)
@@ -810,6 +810,7 @@ static int sdma_v3_0_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);