diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h b/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h index 872e78a48..f7308c9da 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/rwsem.h @@ -26,6 +26,9 @@ #include struct nvgpu_rwsem { + /** + * pthread_rwlock_t used internally to implement nvgpu rwsem. + */ pthread_rwlock_t rw_sem; }; diff --git a/drivers/gpu/nvgpu/include/nvgpu/rwsem.h b/drivers/gpu/nvgpu/include/nvgpu/rwsem.h index d16a4c0a7..3e9ad955d 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/rwsem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/rwsem.h @@ -37,10 +37,53 @@ */ struct nvgpu_rwsem; +/** + * @brief Initialize read write lock. + * + * @param rwsem [in] Read,write lock to initalize. + * + * Initializes the read,write lock referenced by \a rwsem. + */ void nvgpu_rwsem_init(struct nvgpu_rwsem *rwsem); + +/** + * @brief Acquire read lock. + * + * @param rwsem [in] Read,write lock to be locked for read. + * + * Acquires a read lock on the read,write lock object referenced by \a rwsem. + * The calling thread acquires a read lock if no writer is holding the lock + * on \a rwsem. + */ void nvgpu_rwsem_up_read(struct nvgpu_rwsem *rwsem); + +/** + * @brief Release read lock. + * + * @param rwsem [in] Read,write lock to be released. + * + * Releases the lock held on \a rwsem. To be used to release a read lock. + */ void nvgpu_rwsem_down_read(struct nvgpu_rwsem *rwsem); + +/** + * @brief Acquire write lock. + * + * @param rwsem [in] Read,write lock to be locked for write. + * + * Acquires the write lock on \a rwsem. The calling thread acquires write lock + * if no other thread is holding a lock on rwsem. + */ void nvgpu_rwsem_up_write(struct nvgpu_rwsem *rwsem); + +/** + * @brief Release the write lock. + * + * @param rwsem [in] Read,write lock to be released. + * + * Releases the write lock held on \a rwsem. To be used to release a write + * lock. + */ void nvgpu_rwsem_down_write(struct nvgpu_rwsem *rwsem); #endif /* NVGPU_RWSEM_H */