From 7685f60d9dd6ed062f3037d4e72ea124c103d211 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Thu, 28 Sep 2017 12:32:18 -0700 Subject: gpu: nvgpu: Abstract rw_semaphore implementation Abstract implementation of rw_semaphore. In Linux it's implemented in terms of rw_semaphore. Change deterministic_busy to use the new implementation. JIRA NVGPU-259 Change-Id: Ia9c1b6e397581bff7711c5ab6fb76ef6d23cff87 Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1570405 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/linux/rwsem.h | 26 ++++++++++++++++ drivers/gpu/nvgpu/include/nvgpu/rwsem.h | 44 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 drivers/gpu/nvgpu/include/nvgpu/linux/rwsem.h create mode 100644 drivers/gpu/nvgpu/include/nvgpu/rwsem.h (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/rwsem.h b/drivers/gpu/nvgpu/include/nvgpu/linux/rwsem.h new file mode 100644 index 00000000..7d073d39 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/rwsem.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __NVGPU_RWSEM_LINUX_H__ +#define __NVGPU_RWSEM_LINUX_H__ + +#include + +struct nvgpu_rwsem { + struct rw_semaphore rwsem; +}; + +#endif diff --git a/drivers/gpu/nvgpu/include/nvgpu/rwsem.h b/drivers/gpu/nvgpu/include/nvgpu/rwsem.h new file mode 100644 index 00000000..d37c11a8 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/rwsem.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef __NVGPU_RWSEM_H__ +#define __NVGPU_RWSEM_H__ + +#ifdef __KERNEL__ +#include +#endif + +/* + * struct nvgpu_rwsem + * + * Should be implemented per-OS in a separate library + * But implementation should adhere to rw_semaphore implementation + * as specified in Linux Documentation + */ +struct nvgpu_rwsem; + +void nvgpu_rwsem_init(struct nvgpu_rwsem *rwsem); +void nvgpu_rwsem_up_read(struct nvgpu_rwsem *rwsem); +void nvgpu_rwsem_down_read(struct nvgpu_rwsem *rwsem); +void nvgpu_rwsem_up_write(struct nvgpu_rwsem *rwsem); +void nvgpu_rwsem_down_write(struct nvgpu_rwsem *rwsem); + +#endif -- cgit v1.2.2