Shrenuj Bansal | a419c79 | 2016-10-20 14:05:11 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2002,2007-2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef __ADRENO_DRAWCTXT_H |
| 14 | #define __ADRENO_DRAWCTXT_H |
| 15 | |
| 16 | struct adreno_context_type { |
| 17 | unsigned int type; |
| 18 | const char *str; |
| 19 | }; |
| 20 | |
| 21 | #define ADRENO_CONTEXT_DRAWQUEUE_SIZE 128 |
| 22 | #define SUBMIT_RETIRE_TICKS_SIZE 7 |
| 23 | |
| 24 | struct kgsl_device; |
| 25 | struct adreno_device; |
| 26 | struct kgsl_device_private; |
| 27 | struct kgsl_context; |
| 28 | |
| 29 | /** |
| 30 | * struct adreno_context - Adreno GPU draw context |
| 31 | * @timestamp: Last issued context-specific timestamp |
| 32 | * @internal_timestamp: Global timestamp of the last issued command |
| 33 | * NOTE: guarded by device->mutex, not drawctxt->mutex! |
| 34 | * @type: Context type (GL, CL, RS) |
| 35 | * @mutex: Mutex to protect the drawqueue |
| 36 | * @drawqueue: Queue of drawobjs waiting to be dispatched for this |
| 37 | * context |
| 38 | * @drawqueue_head: Head of the drawqueue queue |
| 39 | * @drawqueue_tail: Tail of the drawqueue queue |
| 40 | * @pending: Priority list node for the dispatcher list of pending contexts |
| 41 | * @wq: Workqueue structure for contexts to sleep pending room in the queue |
| 42 | * @waiting: Workqueue structure for contexts waiting for a timestamp or event |
| 43 | * @queued: Number of commands queued in the drawqueue |
| 44 | * @fault_policy: GFT fault policy set in _skip_cmd(); |
| 45 | * @debug_root: debugfs entry for this context. |
| 46 | * @queued_timestamp: The last timestamp that was queued on this context |
| 47 | * @rb: The ringbuffer in which this context submits commands. |
| 48 | * @submitted_timestamp: The last timestamp that was submitted for this context |
| 49 | * @submit_retire_ticks: Array to hold command obj execution times from submit |
| 50 | * to retire |
| 51 | * @ticks_index: The index into submit_retire_ticks[] where the new delta will |
| 52 | * be written. |
| 53 | * @active_node: Linkage for nodes in active_list |
| 54 | * @active_time: Time when this context last seen |
| 55 | */ |
| 56 | struct adreno_context { |
| 57 | struct kgsl_context base; |
| 58 | unsigned int timestamp; |
| 59 | unsigned int internal_timestamp; |
| 60 | unsigned int type; |
| 61 | spinlock_t lock; |
| 62 | |
| 63 | /* Dispatcher */ |
| 64 | struct kgsl_drawobj *drawqueue[ADRENO_CONTEXT_DRAWQUEUE_SIZE]; |
| 65 | unsigned int drawqueue_head; |
| 66 | unsigned int drawqueue_tail; |
| 67 | |
| 68 | struct plist_node pending; |
| 69 | wait_queue_head_t wq; |
| 70 | wait_queue_head_t waiting; |
| 71 | |
| 72 | int queued; |
| 73 | unsigned int fault_policy; |
| 74 | struct dentry *debug_root; |
| 75 | unsigned int queued_timestamp; |
| 76 | struct adreno_ringbuffer *rb; |
| 77 | unsigned int submitted_timestamp; |
| 78 | uint64_t submit_retire_ticks[SUBMIT_RETIRE_TICKS_SIZE]; |
| 79 | int ticks_index; |
| 80 | |
| 81 | struct list_head active_node; |
| 82 | unsigned long active_time; |
| 83 | }; |
| 84 | |
| 85 | /* Flag definitions for flag field in adreno_context */ |
| 86 | |
| 87 | /** |
| 88 | * enum adreno_context_priv - Private flags for an adreno draw context |
| 89 | * @ADRENO_CONTEXT_FAULT - set if the context has faulted (and recovered) |
| 90 | * @ADRENO_CONTEXT_GPU_HANG - Context has caused a GPU hang |
| 91 | * @ADRENO_CONTEXT_GPU_HANG_FT - Context has caused a GPU hang |
| 92 | * and fault tolerance was successful |
| 93 | * @ADRENO_CONTEXT_SKIP_EOF - Context skip IBs until the next end of frame |
| 94 | * marker. |
| 95 | * @ADRENO_CONTEXT_FORCE_PREAMBLE - Force the preamble for the next submission. |
| 96 | * @ADRENO_CONTEXT_SKIP_CMD - Context's drawobj's skipped during |
| 97 | fault tolerance. |
| 98 | * @ADRENO_CONTEXT_FENCE_LOG - Dump fences on this context. |
| 99 | */ |
| 100 | enum adreno_context_priv { |
| 101 | ADRENO_CONTEXT_FAULT = KGSL_CONTEXT_PRIV_DEVICE_SPECIFIC, |
| 102 | ADRENO_CONTEXT_GPU_HANG, |
| 103 | ADRENO_CONTEXT_GPU_HANG_FT, |
| 104 | ADRENO_CONTEXT_SKIP_EOF, |
| 105 | ADRENO_CONTEXT_FORCE_PREAMBLE, |
| 106 | ADRENO_CONTEXT_SKIP_CMD, |
| 107 | ADRENO_CONTEXT_FENCE_LOG, |
| 108 | }; |
| 109 | |
| 110 | /* Flags for adreno_drawctxt_switch() */ |
| 111 | #define ADRENO_CONTEXT_SWITCH_FORCE_GPU BIT(0) |
| 112 | |
| 113 | struct kgsl_context *adreno_drawctxt_create( |
| 114 | struct kgsl_device_private *dev_priv, |
| 115 | uint32_t *flags); |
| 116 | |
| 117 | void adreno_drawctxt_detach(struct kgsl_context *context); |
| 118 | |
| 119 | void adreno_drawctxt_destroy(struct kgsl_context *context); |
| 120 | |
| 121 | void adreno_drawctxt_sched(struct kgsl_device *device, |
| 122 | struct kgsl_context *context); |
| 123 | |
| 124 | struct adreno_ringbuffer; |
| 125 | int adreno_drawctxt_switch(struct adreno_device *adreno_dev, |
| 126 | struct adreno_ringbuffer *rb, |
| 127 | struct adreno_context *drawctxt, |
| 128 | unsigned int flags); |
| 129 | |
| 130 | int adreno_drawctxt_wait(struct adreno_device *adreno_dev, |
| 131 | struct kgsl_context *context, |
| 132 | uint32_t timestamp, unsigned int timeout); |
| 133 | |
| 134 | void adreno_drawctxt_invalidate(struct kgsl_device *device, |
| 135 | struct kgsl_context *context); |
| 136 | |
| 137 | void adreno_drawctxt_dump(struct kgsl_device *device, |
| 138 | struct kgsl_context *context); |
| 139 | |
| 140 | #endif /* __ADRENO_DRAWCTXT_H */ |