Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013-2016 Red Hat |
| 3 | * Author: Rob Clark <robdclark@gmail.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __MSM_FENCE_H__ |
| 19 | #define __MSM_FENCE_H__ |
| 20 | |
| 21 | #include "msm_drv.h" |
| 22 | |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame^] | 23 | struct msm_fence_context { |
| 24 | struct drm_device *dev; |
| 25 | const char *name; |
| 26 | /* last_fence == completed_fence --> no pending work */ |
| 27 | uint32_t last_fence; /* last assigned fence */ |
| 28 | uint32_t completed_fence; /* last completed fence */ |
| 29 | wait_queue_head_t event; |
| 30 | /* callbacks deferred until bo is inactive: */ |
| 31 | struct list_head fence_cbs; |
| 32 | }; |
| 33 | |
| 34 | struct msm_fence_context * msm_fence_context_alloc(struct drm_device *dev, |
| 35 | const char *name); |
| 36 | void msm_fence_context_free(struct msm_fence_context *fctx); |
| 37 | |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 38 | /* callback from wq once fence has passed: */ |
| 39 | struct msm_fence_cb { |
| 40 | struct work_struct work; |
| 41 | uint32_t fence; |
| 42 | void (*func)(struct msm_fence_cb *cb); |
| 43 | }; |
| 44 | |
| 45 | void __msm_fence_worker(struct work_struct *work); |
| 46 | |
| 47 | #define INIT_FENCE_CB(_cb, _func) do { \ |
| 48 | INIT_WORK(&(_cb)->work, __msm_fence_worker); \ |
| 49 | (_cb)->func = _func; \ |
| 50 | } while (0) |
| 51 | |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame^] | 52 | int msm_wait_fence(struct msm_fence_context *fctx, uint32_t fence, |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 53 | ktime_t *timeout, bool interruptible); |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame^] | 54 | int msm_queue_fence_cb(struct msm_fence_context *fctx, |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 55 | struct msm_fence_cb *cb, uint32_t fence); |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame^] | 56 | void msm_update_fence(struct msm_fence_context *fctx, uint32_t fence); |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 57 | |
| 58 | #endif |