edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Process-wide GPU reset epoch. |
| 2 | //! |
| 3 | //! When the kernel resets a hung VCN ring, every VA context alive in the |
| 4 | //! process is reset with it, the innocent ones too, and Mesa aborts the whole |
| 5 | //! process on the next submit to any of them. One session noticing (a sync that |
| 6 | //! errors or comes back after a ring reset) therefore has to condemn all the |
| 7 | //! others: each session remembers the epoch it was created in and refuses to |
| 8 | //! submit once the epoch has moved. |
| 9 | //! |
| 10 | //! New sessions are refused during a short grace period after the event, while |
| 11 | //! the ring is still being reset, and work normally afterwards. |
| 12 | //! |
| 13 | //! A DRM `AMDGPU_CTX_OP_QUERY_STATE2` query was considered and rejected: the |
| 14 | //! context id belongs to Mesa's winsys, not to ec-va, so there is nothing to |
| 15 | //! query from outside, and `vaQuerySurfaceStatus` does not report resets. |
| 16 | |
| 17 | use OnceLock; |
| 18 | use ; |
| 19 | use ; |
| 20 | |
| 21 | /// How long after a reset new sessions are refused. The kernel's ring reset |
| 22 | /// takes about 2 s after the 2 s job timeout has fired; the sync that detects |
| 23 | /// it returns after the reset. |
| 24 | pub const GRACE: Duration = from_secs; |
| 25 | |
| 26 | /// The epoch counter and the time of the last reset, in ms since `base` plus 1 |
| 27 | /// (0 means never). |
| 28 | |
| 29 | pub |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | /// Hard limit on one wait for a picture; past it the sync gives up. |
| 60 | |
| 61 | pub const SYNC_LIMIT: Duration = from_secs; |
| 62 | |
| 63 | /// A wait that took longer than this spent its time in a ring reset: a |
| 64 | /// healthy picture takes milliseconds. 1080p..8K pictures stay far below it. |
| 65 | |
| 66 | pub const SLOW_PICTURE: Duration = from_millis; |
| 67 | |
| 68 | /// Wait for `surface`, and condemn every session if the wait shows that the |
| 69 | /// GPU was reset: an error, or a wait longer than [`SLOW_PICTURE`]. |
| 70 | |
| 71 | pub |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | static CLOCK: ResetClock = new; |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | /// Record that the GPU was reset (or a context was lost, or a job timed out). |
| 102 | /// Every session created before this call refuses further submits. |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | /// The number of resets seen by this process so far. |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | /// Whether a reset happened within the last [`GRACE`]: a hardware session |
| 114 | /// created now would be reset under the caller, so use software instead. |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 |