Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-gpu-driver/blob/main/gsp/transport.om # omega-gpu-driver aien-dev/omega-gpu-driver Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-gpu-driver / gsp / transport.om` 327 lines ยท 6184 bytes Raw Blame History 1 note Linux-process checked-mapping mechanism, NOT kernel transport or a hardware admission resolver. 2 note Link instead of replay.om; no implicit simulator fallback, no device opens or automatic retries. 3 note Coherent or explicitly cache-maintained queue memory is a mandatory external platform prerequisite. 4 note Compiler397e6704 mapget/mapset use one aligned access with DSB SY before/after; bulk copies do not. 5 note Legitimate pointer operations order payload stores before producer publish, acquire before capture, 6 note and captured loads before consumer acknowledgement. DSB does not establish cache coherency. 7 note Vendor msgq.c:411-420 SWAP_RX; message_queue_cpu.c:568-578; kernel_gsp.c:411-425. 8 note Notify chain kgspSetCmdQueueHead_TU102 writes PGSP_QUEUE_HEAD(0)=0, NOT a ring cursor/SEC2 queue. 9 note Caller owns validated mapping views; process-fatal mapping faults are NOT crash-safe DMA containment. 10 global qtstate ulong 1 11 global qtepoch ulong 1 12 global qtboot ulong 1 13 global qtcmd ulong 1 14 global qtstat ulong 1 15 global qtbar long 1 16 global qttok ulong 1 17 global qtpend uchar 1 18 global qtrd ulong 1 19 note Deferred receive: state2 retains an immutable validated frame until explicit semantic completion. 20 global qthand ulong 1 21 global qthold ulong 1 22 fn qtcheck to bool 23 if ne get qtstate 0 1 24 ret false 25 end 26 if not mmwepoch get qtepoch 0 27 ret false 28 end 29 if ne get mmwst 0 MMWPUB 30 ret false 31 end 32 ret eq get qtboot 0 get bgen 0 33 end 34 fn qtlose to void 35 if and mmwepoch get qtepoch 0 eq get mmwst 0 MMWPUB 36 r = mmwquar get qtepoch 0 37 end 38 put qtstate 0 2 39 put rqdead 0 1 40 put bstate 0 12 41 end 42 note Explicit mechanism attachment; success means bound spans, never qualified/coherent/hardware-ready. 43 fn qtattach gen ulong bar long barsz ulong boot42 uint to long 44 if ne get qtstate 0 0 45 ret -6 46 end 47 if ne gpchip boot42 1 48 ret -95 49 end 50 if or not mmwepoch gen ne get mmwst 0 MMWPUB 51 ret -6 52 end 53 if or ne gen get arsepoch 0 ne get bgen 0 get arsboot 0 54 ret -6 55 end 56 if ne get bstate 0 4 57 ret -6 58 end 59 if or lt barsz add GPNOTIF 4 le bar 0 60 ret -1 61 end 62 if lt get mmws 0 RQQSZ 63 ret -1 64 end 65 c = get arcmd 0 66 s = get arstat 0 67 if gt c sub get mmws 0 RQQSZ 68 ret -1 69 end 70 if gt s sub get mmws 0 RQQSZ 71 ret -1 72 end 73 if ne rem c RQSLOT 0 74 ret -1 75 end 76 if ne rem s RQSLOT 0 77 ret -1 78 end 79 if lt c s 80 if gt add c RQQSZ s 81 ret -1 82 end 83 else 84 if gt add s RQQSZ c 85 ret -1 86 end 87 end 88 if not rqshape 0 89 ret -1 90 end 91 h = get mmwh 0 92 v = mapget h add c 16 4 93 if ne v rqget32 0 16 94 ret -1 95 end 96 v = mapget h add c 32 4 97 if ne v rqget32 0 32 98 ret -1 99 end 100 put qtepoch 0 gen 101 put qtboot 0 get bgen 0 102 put qtcmd 0 c 103 put qtstat 0 s 104 put qtbar 0 bar 105 put qtpend 0 0 106 put qtstate 0 1 107 ret 0 108 end 109 fn qtxcopy wr ulong e ulong to long 110 h = get mmwh 0 111 for i ulong e 112 slot = rem add wr i RQCOUNT 113 o = add get qtcmd 0 mul add slot 1 RQSLOT 114 r = mapwrite h o rqtmp mul i RQSLOT RQSLOT 115 if ne r long RQSLOT 116 ret -6 117 end 118 end 119 ret 0 120 end 121 fn qtpub wr ulong e ulong to long 122 p = rem add wr e RQCOUNT 123 ret mapset get mmwh 0 add get qtcmd 0 16 4 p 124 end 125 fn qtsend f ulong n ulong p ulong sync bool to long 126 if not qtcheck 127 ret -6 128 end 129 if ne get qtpend 0 0 130 ret -6 131 end 132 h = get mmwh 0 133 rd = mapget h add get qtstat 0 32 4 134 if ge rd RQCOUNT 135 qtlose 136 ret -1 137 end 138 r = mapread h get qtstat 0 rqstat 0 32 139 if ne r 32 140 qtlose 141 ret -6 142 end 143 if and ne get rqlink 0 0 not rqshape 1 144 qtlose 145 ret -1 146 end 147 rqput32 1 32 rd 148 r = rqprep f n p sync 149 if ne r 0 150 if ne r -2 151 qtlose 152 end 153 ret r 154 end 155 wr = get rqpwr 0 156 e = get rqpcnt 0 157 token = get rqptok 0 158 r = qtxcopy wr e 159 if ne r 0 160 qtlose 161 ret r 162 end 163 note Leading DSB SY of this exact aligned store orders copied slot bytes before pointer publication. 164 r = qtpub wr e 165 if ne r 0 166 qtlose 167 ret -6 168 end 169 r = rqcommit token 170 if ne r 0 171 qtlose 172 ret r 173 end 174 note Pointer was published: any later failure is uncertain, never unsent/retryable. 175 r = qtbell get qtbar 0 176 if ne r 0 177 qtlose 178 ret -6 179 end 180 ret 0 181 end 182 note Capture a bounded immutable prefix under one acquired producer cursor. No live reread while validating. 183 fn qtsnap to long 184 if not qtcheck 185 ret -6 186 end 187 if ne get qtpend 0 0 188 ret -6 189 end 190 if eq add get qttok 0 1 0 191 ret -6 192 end 193 h = get mmwh 0 194 s = get qtstat 0 195 wr = mapget h add s 16 4 196 r = mapread h s rqstat 0 32 197 if ne r 32 198 qtlose 199 ret -6 200 end 201 rqput32 1 16 wr 202 rd = rqget32 0 32 203 put qtrd 0 rd 204 put qttok 0 add get qttok 0 1 205 put qtpend 0 1 206 if or ge wr RQCOUNT ge rd RQCOUNT 207 ret 0 208 end 209 avail = rem sub add wr RQCOUNT rd RQCOUNT 210 if eq avail 0 211 ret 0 212 end 213 o = add RQSLOT mul rd RQSLOT 214 r = mapread h add s o rqstat o RQSLOT 215 if ne r long RQSLOT 216 qtlose 217 ret -6 218 end 219 e = rqget32 1 add o 40 220 if or eq e 0 or gt e 16 gt e avail 221 ret 0 222 end 223 for i ulong sub e 1 224 slot = rem add add rd i 1 RQCOUNT 225 o = mul add slot 1 RQSLOT 226 r = mapread h add s o rqstat o RQSLOT 227 if ne r long RQSLOT 228 qtlose 229 ret -6 230 end 231 end 232 ret 0 233 end 234 fn qtstage token ulong to long 235 if not qtcheck 236 ret -6 237 end 238 if or ne get qtpend 0 1 ne token get qttok 0 239 ret -6 240 end 241 if ne rqget32 0 32 get qtrd 0 242 qtlose 243 ret -6 244 end 245 put qtpend 0 2 246 put qthand 0 0 247 r = rqrecv 248 if lt r 0 249 qtlose 250 ret r 251 end 252 if eq r 0 253 put qtpend 0 0 254 ret 0 255 end 256 ret 1 257 end 258 fn qthandled token ulong to long 259 if not qtcheck 260 ret -6 261 end 262 if or ne get qtpend 0 2 ne token get qttok 0 263 ret -6 264 end 265 if ne get qthand 0 0 266 ret -6 267 end 268 put qthand 0 1 269 ret 0 270 end 271 fn qtfinish token ulong to long 272 if not qtcheck 273 ret -6 274 end 275 if or ne get qtpend 0 2 ne token get qttok 0 276 ret -6 277 end 278 if ne get qthand 0 1 279 ret -6 280 end 281 note From here a failed publication is uncertain: quarantine, never restore/retry the local cursor. 282 put qtpend 0 0 283 put qthand 0 0 284 note Leading DSB SY is FULL: capture loads complete before the consumer store permits peer slot reuse. 285 x = mapset get mmwh 0 add get qtcmd 0 32 4 rqget32 0 32 286 if ne x 0 287 qtlose 288 ret -6 289 end 290 ret 1 291 end 292 note Existing pull API preserves its validated-capture completion boundary. 293 note IRQ callers instead stage, execute semantic handling, mark handled, then finish. 294 fn qtaccept token ulong to long 295 r = qtstage token 296 if ne r 1 297 ret r 298 end 299 r = qthandled token 300 if ne r 0 301 qtlose 302 ret r 303 end 304 ret qtfinish token 305 end 306 fn bcanrst to bool 307 ret eq get qtstate 0 0 308 end 309 fn blost to void 310 qtlose 311 end 312 fn bemit f ulong n ulong p ulong sync bool to long 313 ret qtsend f n p sync 314 end 315 fn bpull to long 316 if ne get qthold 0 0 317 if and qtcheck and eq get qtpend 0 2 eq get qthand 0 0 318 ret 1 319 end 320 ret -6 321 end 322 r = qtsnap 323 if ne r 0 324 ret r 325 end 326 ret qtaccept get qttok 0 327 end