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>
This commit is contained in:
Debarshi Dutta
2017-09-01 10:14:59 +05:30
committed by mobile promotions
parent 081dc658cb
commit 2dcfd29861
5 changed files with 23 additions and 19 deletions

View File

@@ -60,9 +60,9 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len)
if (len != pa->blk_size)
return 0;
head = ACCESS_ONCE(pa->head);
head = NV_ACCESS_ONCE(pa->head);
while (head >= 0) {
new_head = ACCESS_ONCE(pa->next[head]);
new_head = NV_ACCESS_ONCE(pa->next[head]);
ret = cmpxchg(&pa->head, head, new_head);
if (ret == head) {
addr = pa->base + head * pa->blk_size;
@@ -71,7 +71,7 @@ static u64 nvgpu_lockless_alloc(struct nvgpu_allocator *a, u64 len)
addr);
break;
}
head = ACCESS_ONCE(pa->head);
head = NV_ACCESS_ONCE(pa->head);
}
if (addr)
@@ -93,8 +93,8 @@ static void nvgpu_lockless_free(struct nvgpu_allocator *a, u64 addr)
alloc_dbg(a, "Free node # %llu @ addr 0x%llx\n", cur_idx, addr);
while (1) {
head = ACCESS_ONCE(pa->head);
ACCESS_ONCE(pa->next[cur_idx]) = head;
head = NV_ACCESS_ONCE(pa->head);
NV_ACCESS_ONCE(pa->next[cur_idx]) = head;
ret = cmpxchg(&pa->head, head, cur_idx);
if (ret == head) {
nvgpu_atomic_dec(&pa->nr_allocs);