From e26ce10cc6b59314ccf5931a8c5b46a9e57b085a Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 5 Oct 2017 17:22:41 -0700 Subject: gpu: nvgpu: Convert VIDMEM work_struct to thread Convert the work_struct used by the vidmem background clearing to a thread to make it more cross platform. The thread waits on a condition variable to determine when work needs to be done. The signal comes from the DMA API when it enqueues a new nvgpu_mem that needs clearing. Add logic for handling suspend: the CE cannot be accessed while the GPU is suspended. As such the background thread must be paused while the GPU is suspended and the CE is not available. Several other changes were also made: o Move the code that enqueues a nvgpu_mem from the DMA API code to a function in the VIDMEM code. o Move nvgpu_vidmem_get_pending_alloc() to the Linux specific code as this function is only used there. It's a trivial function that QNX can easily implement as well. o Remove the was_empty logic from the enqueue. Now just always signal the condition variable when anew nvgpu_mem comes in. o Move CE suspend to after MM suspend. JIRA NVGPU-30 JIRA NVGPU-138 Change-Id: Ie9286ae5a127c3fced86dfb9794e7d81eab0491c Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1574498 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 10 ++++++++++ drivers/gpu/nvgpu/include/nvgpu/vidmem.h | 21 +++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index 537409a8..6feacff7 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h @@ -272,6 +272,16 @@ int nvgpu_mem_create_from_mem(struct gk20a *g, struct nvgpu_mem *dest, struct nvgpu_mem *src, int start_page, int nr_pages); +/* + * Really free a vidmem buffer. There's a fair amount of work involved in + * freeing vidmem buffers in the DMA API. This handles none of that - it only + * frees the underlying vidmem specific structures used in vidmem buffers. + * + * This is implemented in the OS specific code. If it's not necessary it can + * be a noop. But the symbol must at least be present. + */ +void __nvgpu_mem_free_vidmem_alloc(struct gk20a *g, struct nvgpu_mem *vidmem); + /* * Buffer accessors - wrap between begin() and end() if there is no permanent * kernel mapping for this buffer. diff --git a/drivers/gpu/nvgpu/include/nvgpu/vidmem.h b/drivers/gpu/nvgpu/include/nvgpu/vidmem.h index 9e9f8301..690f8164 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vidmem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vidmem.h @@ -73,17 +73,19 @@ struct nvgpu_vidmem_buf *nvgpu_vidmem_user_alloc(struct gk20a *g, size_t bytes); void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf); +int nvgpu_vidmem_clear_list_enqueue(struct gk20a *g, struct nvgpu_mem *mem); + bool nvgpu_addr_is_vidmem_page_alloc(u64 addr); int nvgpu_vidmem_get_space(struct gk20a *g, u64 *space); -struct nvgpu_mem *nvgpu_vidmem_get_pending_alloc(struct mm_gk20a *mm); - void nvgpu_vidmem_destroy(struct gk20a *g); int nvgpu_vidmem_init(struct mm_gk20a *mm); -void nvgpu_vidmem_clear_mem_worker(struct work_struct *work); int nvgpu_vidmem_clear(struct gk20a *g, struct nvgpu_mem *mem); +void nvgpu_vidmem_thread_pause_sync(struct mm_gk20a *mm); +void nvgpu_vidmem_thread_unpause(struct mm_gk20a *mm); + #else /* !defined(CONFIG_GK20A_VIDMEM) */ /* @@ -110,11 +112,6 @@ static inline int nvgpu_vidmem_get_space(struct gk20a *g, u64 *space) return -ENOSYS; } -static inline struct nvgpu_mem *nvgpu_vidmem_get_pending_alloc(struct mm_gk20a *mm) -{ - return NULL; -} - static inline void nvgpu_vidmem_destroy(struct gk20a *g) { } @@ -135,6 +132,14 @@ static inline int nvgpu_vidmem_clear(struct gk20a *g, return -ENOSYS; } +static inline void nvgpu_vidmem_thread_pause_sync(struct mm_gk20a *mm) +{ +} + +static inline void nvgpu_vidmem_thread_unpause(struct mm_gk20a *mm) +{ +} + #endif /* !defined(CONFIG_GK20A_VIDMEM) */ #endif /* __NVGPU_VIDMEM_H__ */ -- cgit v1.2.2