diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_fence.h b/drivers/gpu/nvgpu/include/nvgpu/os_fence.h index 754db5075..fdd9db575 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/os_fence.h +++ b/drivers/gpu/nvgpu/include/nvgpu/os_fence.h @@ -25,14 +25,8 @@ #ifndef NVGPU_OS_FENCE_H #define NVGPU_OS_FENCE_H -#include #include -struct nvgpu_semaphore; -struct nvgpu_channel; -struct priv_cmd_entry; -struct nvgpu_nvhost_dev; - /* * struct nvgpu_os_fence adds an abstraction to the earlier Android Sync * Framework, specifically the sync-fence mechanism and the newer DMA sync @@ -68,6 +62,11 @@ struct nvgpu_os_fence_ops { void (*dup)(struct nvgpu_os_fence *s); }; +#if !defined(CONFIG_NVGPU_SYNCFD_NONE) + +struct gk20a; +struct nvgpu_channel; + /* * The priv field contains the actual backend: * - struct sync_fence for semas on LINUX_VERSION <= 4.14 @@ -89,51 +88,21 @@ static inline bool nvgpu_os_fence_is_initialized(struct nvgpu_os_fence *fence) return (fence->ops != NULL); } -#ifndef CONFIG_NVGPU_SYNCFD_NONE - -int nvgpu_os_fence_sema_create( - struct nvgpu_os_fence *fence_out, - struct nvgpu_channel *c, - struct nvgpu_semaphore *sema); - int nvgpu_os_fence_fdget( struct nvgpu_os_fence *fence_out, struct nvgpu_channel *c, int fd); -#else +#else /* CONFIG_NVGPU_SYNCFD_NONE */ -static inline int nvgpu_os_fence_sema_create( - struct nvgpu_os_fence *fence_out, - struct nvgpu_channel *c, - struct nvgpu_semaphore *sema) +struct nvgpu_os_fence { + const struct nvgpu_os_fence_ops *ops; +}; + +static inline bool nvgpu_os_fence_is_initialized(struct nvgpu_os_fence *fence) { - return -ENOSYS; -} -static inline int nvgpu_os_fence_fdget( - struct nvgpu_os_fence *fence_out, - struct nvgpu_channel *c, int fd) -{ - return -ENOSYS; + return false; } -#endif /* !CONFIG_NVGPU_SYNCFD_NONE */ - -#if defined(CONFIG_TEGRA_GK20A_NVHOST) && !defined(CONFIG_NVGPU_SYNCFD_NONE) - -int nvgpu_os_fence_syncpt_create(struct nvgpu_os_fence *fence_out, - struct nvgpu_channel *c, struct nvgpu_nvhost_dev *nvhost_dev, - u32 id, u32 thresh); - -#else - -static inline int nvgpu_os_fence_syncpt_create( - struct nvgpu_os_fence *fence_out, struct nvgpu_channel *c, - struct nvgpu_nvhost_dev *nvhost_dev, - u32 id, u32 thresh) -{ - return -ENOSYS; -} - -#endif /* CONFIG_TEGRA_GK20A_NVHOST && !CONFIG_NVGPU_SYNCFD_NONE */ +#endif /* CONFIG_NVGPU_SYNCFD_NONE */ #endif /* NVGPU_OS_FENCE_H */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_fence_semas.h b/drivers/gpu/nvgpu/include/nvgpu/os_fence_semas.h index 04d26ffce..9b4b64bb8 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/os_fence_semas.h +++ b/drivers/gpu/nvgpu/include/nvgpu/os_fence_semas.h @@ -25,6 +25,8 @@ #ifndef NVGPU_OS_FENCE_SEMA_H #define NVGPU_OS_FENCE_SEMA_H +#include + struct nvgpu_os_fence; struct nvgpu_semaphore; @@ -32,7 +34,13 @@ struct nvgpu_os_fence_sema { struct nvgpu_os_fence *fence; }; -#if !defined(CONFIG_NVGPU_SYNCFD_NONE) +#if defined(CONFIG_NVGPU_SW_SEMAPHORE) && !defined(CONFIG_NVGPU_SYNCFD_NONE) + +int nvgpu_os_fence_sema_create( + struct nvgpu_os_fence *fence_out, + struct nvgpu_channel *c, + struct nvgpu_semaphore *sema); + /* * Return a struct of nvgpu_os_fence_sema only if the underlying os_fence * object is backed by semaphore, else return empty object. @@ -58,7 +66,15 @@ void nvgpu_os_fence_sema_extract_nth_semaphore( u32 nvgpu_os_fence_sema_get_num_semaphores( struct nvgpu_os_fence_sema *fence); -#else +#else /* CONFIG_NVGPU_SW_SEMAPHORE && !CONFIG_NVGPU_SYNCFD_NONE */ + +static inline int nvgpu_os_fence_sema_create( + struct nvgpu_os_fence *fence_out, + struct nvgpu_channel *c, + struct nvgpu_semaphore *sema) +{ + return -ENOSYS; +} static inline int nvgpu_os_fence_get_semas( struct nvgpu_os_fence_sema *fence_sema_out, @@ -79,6 +95,6 @@ static inline u32 nvgpu_os_fence_sema_get_num_semaphores( return 0; } -#endif /* !CONFIG_NVGPU_SYNCFD_NONE */ +#endif /* CONFIG_NVGPU_SW_SEMAPHORE && !CONFIG_NVGPU_SYNCFD_NONE */ #endif /* NVGPU_OS_FENCE_SEMAS_H */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_fence_syncpts.h b/drivers/gpu/nvgpu/include/nvgpu/os_fence_syncpts.h index 84e1fef22..71213dda6 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/os_fence_syncpts.h +++ b/drivers/gpu/nvgpu/include/nvgpu/os_fence_syncpts.h @@ -25,14 +25,22 @@ #ifndef NVGPU_OS_FENCE_SYNCPT_H #define NVGPU_OS_FENCE_SYNCPT_H +#include + struct nvgpu_os_fence; struct nvhost_ctrl_sync_fence_info; +struct nvgpu_nvhost_dev; struct nvgpu_os_fence_syncpt { struct nvgpu_os_fence *fence; }; #if defined(CONFIG_TEGRA_GK20A_NVHOST) && !defined(CONFIG_NVGPU_SYNCFD_NONE) + +int nvgpu_os_fence_syncpt_create(struct nvgpu_os_fence *fence_out, + struct nvgpu_channel *c, struct nvgpu_nvhost_dev *nvhost_dev, + u32 id, u32 thresh); + /* * Return a struct of nvgpu_os_fence_syncpt only if the underlying os_fence * object is backed by syncpoints, else return empty object. @@ -59,7 +67,15 @@ int nvgpu_os_fence_syncpt_foreach_pt( u32 nvgpu_os_fence_syncpt_get_num_syncpoints( struct nvgpu_os_fence_syncpt *fence); -#else +#else /* CONFIG_TEGRA_GK20A_NVHOST && !CONFIG_NVGPU_SYNCFD_NONE */ + +static inline int nvgpu_os_fence_syncpt_create( + struct nvgpu_os_fence *fence_out, struct nvgpu_channel *c, + struct nvgpu_nvhost_dev *nvhost_dev, + u32 id, u32 thresh) +{ + return -ENOSYS; +} static inline int nvgpu_os_fence_get_syncpts( struct nvgpu_os_fence_syncpt *fence_syncpt_out, @@ -74,6 +90,6 @@ static inline u32 nvgpu_os_fence_syncpt_get_num_syncpoints( return 0; } -#endif +#endif /* CONFIG_TEGRA_GK20A_NVHOST && !CONFIG_NVGPU_SYNCFD_NONE */ #endif /* NVGPU_OS_FENCE_SYNPT_H */