From 69e032653df5aae335764f6346703a1e55c96a2d Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Tue, 14 Nov 2017 15:56:09 +0200 Subject: gpu: nvgpu: Add synchronization to comptag alloc and clearing Comptags allocation and clearing was not synchronized for a buffer. Fix this race by serializing the operations with the gk20a_dmabuf_priv lock. While doing that, add an error check in the cbc_ctrl call. Bug 1902982 Change-Id: Icd96f1855eb5e5340651bcc85849b5ccc199b821 Signed-off-by: Sami Kiminki Reviewed-on: https://git-master.nvidia.com/r/1597904 Reviewed-by: Alex Waterman Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/comptags.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/comptags.h b/drivers/gpu/nvgpu/include/nvgpu/comptags.h index 99e2d657..679a0f9e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/comptags.h +++ b/drivers/gpu/nvgpu/include/nvgpu/comptags.h @@ -74,6 +74,24 @@ int gk20a_alloc_or_get_comptags(struct gk20a *g, struct gk20a_comptags *comptags); void gk20a_get_comptags(struct nvgpu_os_buffer *buf, struct gk20a_comptags *comptags); -void gk20a_mark_comptags_cleared(struct nvgpu_os_buffer *buf); + +/* + * These functions must be used to synchronize comptags clear. The usage: + * + * if (gk20a_comptags_start_clear(os_buf)) { + * // we now hold the buffer lock for clearing + * + * bool successful = hw_clear_comptags(); + * + * // mark the buf cleared (or not) and release the buffer lock + * gk20a_comptags_finish_clear(os_buf, successful); + * } + * + * If gk20a_start_comptags_clear() returns false, another caller has + * already cleared the comptags. + */ +bool gk20a_comptags_start_clear(struct nvgpu_os_buffer *buf); +void gk20a_comptags_finish_clear(struct nvgpu_os_buffer *buf, + bool clear_successful); #endif -- cgit v1.2.2