diff options
author | Debarshi Dutta <ddutta@nvidia.com> | 2017-09-01 00:44:59 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-09-03 17:26:27 -0400 |
commit | 2dcfd29861f2c5dc75cff988e7d950e15aad9da2 (patch) | |
tree | 8995756cdeeba70d771c2cfaf2bfa147611ff8f2 /drivers/gpu/nvgpu/common/mm/lockless_allocator.c | |
parent | 081dc658cba1982deaeee8e5745d54826b04db38 (diff) |
gpu: nvgpu: NVGPU abstraction for ACCESS_ONCE
Construct a wrapper macro NV_ACCESS_ONCE(x) which uses OS specific
versions of ACCESS_ONCE. e.g for linux, ACCESS_ONCE(x) is used.
Jira NVGPU-125
Change-Id: Ia5c67baae111c1a7978c530bf279715fc808287d
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1549928
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/lockless_allocator.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index 04df7e3f..0df1ae9d 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c | |||
@@ -60,9 +60,9 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len) | |||
60 | if (len != pa->blk_size) | 60 | if (len != pa->blk_size) |
61 | return 0; | 61 | return 0; |
62 | 62 | ||
63 | head = ACCESS_ONCE(pa->head); | 63 | head = NV_ACCESS_ONCE(pa->head); |
64 | while (head >= 0) { | 64 | while (head >= 0) { |
65 | new_head = ACCESS_ONCE(pa->next[head]); | 65 | new_head = NV_ACCESS_ONCE(pa->next[head]); |
66 | ret = cmpxchg(&pa->head, head, new_head); | 66 | ret = cmpxchg(&pa->head, head, new_head); |
67 | if (ret == head) { | 67 | if (ret == head) { |
68 | addr = pa->base + head * pa->blk_size; | 68 | addr = pa->base + head * pa->blk_size; |
@@ -71,7 +71,7 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len) | |||
71 | addr); | 71 | addr); |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | head = ACCESS_ONCE(pa->head); | 74 | head = NV_ACCESS_ONCE(pa->head); |
75 | } | 75 | } |
76 | 76 | ||
77 | if (addr) | 77 | if (addr) |
@@ -93,8 +93,8 @@ static void nvgpu_lockless_free(struct nvgpu_allocator *a, u64 addr) | |||
93 | alloc_dbg(a, "Free node # %llu @ addr 0x%llx\n", cur_idx, addr); | 93 | alloc_dbg(a, "Free node # %llu @ addr 0x%llx\n", cur_idx, addr); |
94 | 94 | ||
95 | while (1) { | 95 | while (1) { |
96 | head = ACCESS_ONCE(pa->head); | 96 | head = NV_ACCESS_ONCE(pa->head); |
97 | ACCESS_ONCE(pa->next[cur_idx]) = head; | 97 | NV_ACCESS_ONCE(pa->next[cur_idx]) = head; |
98 | ret = cmpxchg(&pa->head, head, cur_idx); | 98 | ret = cmpxchg(&pa->head, head, cur_idx); |
99 | if (ret == head) { | 99 | if (ret == head) { |
100 | nvgpu_atomic_dec(&pa->nr_allocs); | 100 | nvgpu_atomic_dec(&pa->nr_allocs); |