From f5224bde147537f55cc0d6e90761471ab802cf19 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 14 Sep 2016 17:07:05 -0700 Subject: gpu: nvgpu: Fix rmb()s in allocators Fix the rmb() location of the rmb() in the buddy and bitmap allocators. The previous fix was not quite right. The rmb() needs to be after the init value is read so that any subsequent reads occur after the init value is read. If this is not done then subsequent reads could be loaded before the value of init is checked and possibly be invalid. Bug 1811382 Change-Id: I6d1fa25cc16c5e19fd2769d489878afa2f8e3e35 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1221061 (cherry picked from commit f2ddb6c56e554c39733c8fc9ae870dfc12e47b44) Reviewed-on: http://git-master/r/1223458 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gk20a_allocator_bitmap.c | 3 ++- drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_bitmap.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_bitmap.c index 2291a953..a2aa85fa 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_bitmap.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_bitmap.c @@ -41,9 +41,10 @@ static u64 gk20a_bitmap_alloc_base(struct gk20a_allocator *a) static int gk20a_bitmap_alloc_inited(struct gk20a_allocator *a) { struct gk20a_bitmap_allocator *ba = a->priv; + int inited = ba->inited; rmb(); - return ba->inited; + return inited; } static u64 gk20a_bitmap_alloc_end(struct gk20a_allocator *a) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c index ee5e69d2..f9fb48b5 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c @@ -1077,9 +1077,10 @@ static u64 gk20a_buddy_alloc_base(struct gk20a_allocator *a) static int gk20a_buddy_alloc_inited(struct gk20a_allocator *a) { struct gk20a_buddy_allocator *ba = a->priv; + int inited = ba->initialized; rmb(); - return ba->initialized; + return inited; } static u64 gk20a_buddy_alloc_end(struct gk20a_allocator *a) -- cgit v1.2.2