diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-08-15 14:16:07 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-08-16 14:04:20 -0400 |
commit | 61ef5a58744d22e65d3ad7c3a04a2521d0ccb6af (patch) | |
tree | 5b8836864d06495101e15d381f8fdcb8f19f6a6a /drivers/gpu/nvgpu | |
parent | ff38ab4dcd87088dc60c870aaf910fcdc4af5918 (diff) |
gpu: nvgpu: Deterministic submit fix
Fix some simple pointer arithmetic errors in the deterministic submit
path. The lockless allocator was doing a subtraction to determine the
correct offset of the element to free. However, this subtraction was
using the base address and a numeric offset - not a pointer offset. Thus
the difference computed was in bytes not in elements of the block size.
The fix is simple: just divide by the block size.
Also this modifies the debugging statement a bit so that a bit more
information is printed at more useful times.
Lastly, a pointer to numeric cast was fixed in the fence code.
Change-Id: I514724205f1b73805b21e979481a13ac689f3482
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1538905
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Aingara Paramakuru <aparamakuru@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 13 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/fence_gk20a.c | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index 944b4b0f..2a569efd 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c | |||
@@ -66,12 +66,16 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len) | |||
66 | if (ret == head) { | 66 | if (ret == head) { |
67 | addr = pa->base + head * pa->blk_size; | 67 | addr = pa->base + head * pa->blk_size; |
68 | atomic_inc(&pa->nr_allocs); | 68 | atomic_inc(&pa->nr_allocs); |
69 | alloc_dbg(a, "Alloc node # %d @ addr 0x%llx\n", head, | ||
70 | addr); | ||
71 | break; | 69 | break; |
72 | } | 70 | } |
73 | head = ACCESS_ONCE(pa->head); | 71 | head = ACCESS_ONCE(pa->head); |
74 | } | 72 | } |
73 | |||
74 | if (addr) | ||
75 | alloc_dbg(a, "Alloc node # %d @ addr 0x%llx\n", head, addr); | ||
76 | else | ||
77 | alloc_dbg(a, "Alloc failed!\n"); | ||
78 | |||
75 | return addr; | 79 | return addr; |
76 | } | 80 | } |
77 | 81 | ||
@@ -81,7 +85,9 @@ static void nvgpu_lockless_free(struct nvgpu_allocator *a, u64 addr) | |||
81 | int head, ret; | 85 | int head, ret; |
82 | u64 cur_idx; | 86 | u64 cur_idx; |
83 | 87 | ||
84 | cur_idx = addr - pa->base; | 88 | cur_idx = (addr - pa->base) / pa->blk_size; |
89 | |||
90 | alloc_dbg(a, "Free node # %llu @ addr 0x%llx\n", cur_idx, addr); | ||
85 | 91 | ||
86 | while (1) { | 92 | while (1) { |
87 | head = ACCESS_ONCE(pa->head); | 93 | head = ACCESS_ONCE(pa->head); |
@@ -89,7 +95,6 @@ static void nvgpu_lockless_free(struct nvgpu_allocator *a, u64 addr) | |||
89 | ret = cmpxchg(&pa->head, head, cur_idx); | 95 | ret = cmpxchg(&pa->head, head, cur_idx); |
90 | if (ret == head) { | 96 | if (ret == head) { |
91 | atomic_dec(&pa->nr_allocs); | 97 | atomic_dec(&pa->nr_allocs); |
92 | alloc_dbg(a, "Free node # %llu\n", cur_idx); | ||
93 | break; | 98 | break; |
94 | } | 99 | } |
95 | } | 100 | } |
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c index 51363059..8ad24c44 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c | |||
@@ -51,7 +51,7 @@ static void gk20a_fence_free(struct kref *ref) | |||
51 | 51 | ||
52 | if (f->allocator) { | 52 | if (f->allocator) { |
53 | if (nvgpu_alloc_initialized(f->allocator)) | 53 | if (nvgpu_alloc_initialized(f->allocator)) |
54 | nvgpu_free(f->allocator, (size_t)f); | 54 | nvgpu_free(f->allocator, (u64)(uintptr_t)f); |
55 | } else | 55 | } else |
56 | nvgpu_kfree(g, f); | 56 | nvgpu_kfree(g, f); |
57 | } | 57 | } |