gpu: nvgpu: fix synchronization in nvgpu_vm_map

The mapping early returned from nvgpu_vm_map might already
be unmapped during channel clean up. Increase refcount of
an already mapped buffer inside the scope of update_gmmu_lock
mutex to avoid this race.

Bug 200494150

Change-Id: I66d9272e42c40cd3aae7ba3bb8106ec37691bf8e
Signed-off-by: Shih-hsin Li <seasonl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2114163
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-by: Daniel Fu <danifu@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Shih-hsin Li
2019-05-07 16:34:01 -07:00
committed by mobile promotions
parent 6509bb49da
commit af95d14bb0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -873,12 +873,13 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm,
map_addr,
flags,
map_key_kind);
nvgpu_mutex_release(&vm->update_gmmu_lock);
if (mapped_buffer) {
nvgpu_ref_get(&mapped_buffer->ref);
nvgpu_mutex_release(&vm->update_gmmu_lock);
return mapped_buffer;
}
nvgpu_mutex_release(&vm->update_gmmu_lock);
}
/*