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/chan/complete.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 / chan / complete.om` 379 lines ยท 8323 bytes Raw Blame History 1 note chan/complete.om: completion semaphore producer/consumer protocol, command encoding, 2 note wrap-safe sequence progress tracking, and bounded drain policy for Blackwell GPFIFO channels. 3 note Layout source of record: NVIDIA open-gpu-kernel-modules 580.173.02 (MIT) clc96f.h:75-89, 4 note uvm_hopper_host.c:45-52. Library unit, no main. Prefix cm / CM. 5 note 6 note Blackwell USERD (Nvc96fControl, clc96f.h:29-33) has GPPut at offset 0x8c (140) and NO GPGet; 7 note Ignored01 covers bytes 0x90..0x1ff (512 bytes). Completion is tracked exclusively through 8 note hardware semaphores released into host-visible memory, never via caller assertion or GPGet. 9 note 10 note Pure protocol: 11 note cmhdr subc count -> uint incMethod header (2<<28 | count<<16 | subc<<13 | 23) 12 note cmrel subc va seq -> long encodes 5-method release command into cmwds[0..5] 13 note cmacq subc va seq -> long encodes 5-method acquire command into cmwds[0..5] 14 note cmprog ret put obs -> long wrap-safe sequence check; returns newly completed entries, 15 note 0 for pending, or CMESTALE (-5) for out-of-order/wrapped 16 note cmputpb b off subc va seq -> long writes 6-word release command into pushbuffer b at offset off 17 note 18 note Typed mapped effect adapter: 19 note cminit -> long initializes only unused tracker state; refuses retained bindings 20 note cmbind c slot off gen -> long verifies mapped host capabilities; never hardware admission 21 note cmsub c count -> long accounts only already-submitted channel entries within capacity 22 note cmpoll c -> long polls memory via mmrd32, advances retired, calls chretire 23 note cmdrain c budget -> long bounded poll loop; quarantines backing on timeout/error 24 note cmquar c gen -> long uncertainty latch; quarantines semaphore and window 25 note 26 note Status codes: 0 CMOK, -1 CMEINVAL, -2 CMEALIGN, -3 CMERANGE, -4 CMESTATE, -5 CMESTALE, 27 note -6 CMEFULL, -10 CMEGEN, -11 CMETIME, -12 CMEQUAR. No CPU/GPU ordering or cache flush is implied. 28 note Vendor uvm_hopper_host.c:43 requires wfi_membar before release. cmrel is ONLY the release packet. 29 note Production use additionally needs a qualified engine/cache fence and ordered mapped effects. 30 const CMOK long 0 31 const CMEINVAL long -1 32 const CMEALIGN long -2 33 const CMERANGE long -3 34 const CMESTATE long -4 35 const CMESTALE long -5 36 const CMEFULL long -6 37 const CMEGEN long -10 38 const CMETIME long -11 39 const CMEQUAR long -12 40 note NVC96F method byte offsets 41 const CMSADDR ulong 92 42 const CMSHI ulong 96 43 const CMSPLO ulong 100 44 const CMSPHI ulong 104 45 const CMSEXEC ulong 108 46 note Method index in method space: 0x5c / 4 = 23 47 const CMSEMM uint 23 48 note CHNINC header (2 << 28) = `536870912` 49 const CMINC uint `536870912` 50 const CMCWDS ulong 6 51 note Channel slots 52 const CMSLOTS ulong 4 53 note Tracker states 54 const CMSNONE ulong 0 55 const CMSBIND ulong 1 56 const CMSACTV ulong 2 57 const CMSDRN ulong 3 58 const CMSIDLE ulong 4 59 const CMSTOUT ulong 5 60 const CMSQST ulong 6 61 global cmwds uint 6 62 global cmlen ulong 1 63 global cmgen ulong 4 64 global cmbuf ulong 4 65 global cmbgen ulong 4 66 global cmpa ulong 4 67 global cmva ulong 4 68 global cmret uint 4 69 global cmput uint 4 70 global cmst ulong 4 71 fn cmhdr subc uint count uint to uint 72 ret or or CMINC shl and count 1023 16 or shl and subc 7 13 CMSEMM 73 end 74 fn cmrel subc uint va ulong seq uint to long 75 if gt subc 7 76 ret CMEINVAL 77 end 78 if ne and va 3 0 79 ret CMEALIGN 80 end 81 if or eq va 0 ge va MMVALIM 82 ret CMERANGE 83 end 84 put cmwds 0 cmhdr subc 5 85 put cmwds 1 and uint and va `4294967295` `4294967292` 86 put cmwds 2 and uint shr va 32 `33554431` 87 put cmwds 3 seq 88 put cmwds 4 0 89 put cmwds 5 1 90 put cmlen 0 CMCWDS 91 ret long CMCWDS 92 end 93 fn cmacq subc uint va ulong seq uint to long 94 if gt subc 7 95 ret CMEINVAL 96 end 97 if ne and va 3 0 98 ret CMEALIGN 99 end 100 if or eq va 0 ge va MMVALIM 101 ret CMERANGE 102 end 103 put cmwds 0 cmhdr subc 5 104 put cmwds 1 and uint and va `4294967295` `4294967292` 105 put cmwds 2 and uint shr va 32 `33554431` 106 put cmwds 3 seq 107 put cmwds 4 0 108 put cmwds 5 0 109 put cmlen 0 CMCWDS 110 ret long CMCWDS 111 end 112 fn cmprog ret_ uint put_ uint obs uint to long 113 inflight = sub put_ ret_ 114 if eq inflight 0 115 if eq obs ret_ 116 ret 0 117 end 118 ret CMESTALE 119 end 120 prog = sub obs ret_ 121 if eq prog 0 122 ret 0 123 end 124 if gt prog inflight 125 ret CMESTALE 126 end 127 ret long prog 128 end 129 fn cmputpb b ulong off uint subc uint va ulong seq uint to long 130 if ge b GMMAXB 131 ret CMEINVAL 132 end 133 if not gmlive b 134 ret CMEINVAL 135 end 136 if ne and off 3 0 137 ret CMEALIGN 138 end 139 sz = get gmbsz b 140 span = mul CMCWDS 4 141 if or gt ulong off sz gt span sub sz ulong off 142 ret CMERANGE 143 end 144 rc = cmrel subc va seq 145 if lt rc 0 146 ret rc 147 end 148 pa = add get gmbpa b ulong off 149 for i ulong 6 150 mmwr32 add pa mul i 4 ulong get cmwds i 151 end 152 ret long CMCWDS 153 end 154 fn cminit to long 155 for c ulong CMSLOTS 156 st = get cmst c 157 if ne st CMSNONE 158 ret CMESTATE 159 end 160 end 161 for c ulong CMSLOTS 162 put cmgen c 0 163 put cmbuf c GMNONE 164 put cmbgen c 0 165 put cmpa c 0 166 put cmva c 0 167 put cmret c 0 168 put cmput c 0 169 put cmst c CMSNONE 170 end 171 put cmlen 0 0 172 ret CMOK 173 end 174 fn cmbind c ulong slot ulong off uint gen ulong to long 175 if ge c CMSLOTS 176 ret CMEINVAL 177 end 178 if ne get mmwkind 0 1 179 ret CMESTATE 180 end 181 if or lt get mmwst 0 MMWDMA ge get mmwst 0 MMWQUAR 182 ret CMESTATE 183 end 184 if ne get mmwgen 0 gen 185 ret CMEGEN 186 end 187 if ge slot GMMAXB 188 ret CMEINVAL 189 end 190 if not gmlive slot 191 ret CMEINVAL 192 end 193 if ne get cmst c CMSNONE 194 ret CMESTATE 195 end 196 if or eq get chopen c 0 ne get chepoch c gen 197 ret CMESTATE 198 end 199 if ne get chret c get chput c 200 ret CMESTATE 201 end 202 if eq and get gmbfl slot GMHPOLL 0 203 ret CMESTATE 204 end 205 if ne get gmbca slot 1 206 ret CMESTATE 207 end 208 if ne and off 3 0 209 ret CMEALIGN 210 end 211 sz = get gmbsz slot 212 if gt add ulong off 4 sz 213 ret CMERANGE 214 end 215 pa = add get gmbpa slot ulong off 216 va = add get gmbva slot ulong off 217 put cmgen c gen 218 put cmbuf c slot 219 put cmbgen c ulong get gmbgen slot 220 put cmpa c pa 221 put cmva c va 222 put cmret c get chput c 223 put cmput c get chput c 224 put cmst c CMSBIND 225 mmwr32 pa ulong get chput c 226 ret CMOK 227 end 228 fn cmsub c ulong count uint to long 229 if ge c CMSLOTS 230 ret CMEINVAL 231 end 232 st = get cmst c 233 if and and ne st CMSBIND ne st CMSACTV ne st CMSIDLE 234 ret CMESTATE 235 end 236 if ne get mmwgen 0 get cmgen c 237 ret CMEGEN 238 end 239 if ne get mmwst 0 MMWPUB 240 ret CMESTATE 241 end 242 b = get cmbuf c 243 if not gmlive b 244 ret CMESTATE 245 end 246 if ne get cmbgen c ulong get gmbgen b 247 ret CMEGEN 248 end 249 ent = get chent c 250 if or eq count 0 eq ent 0 251 ret CMEINVAL 252 end 253 p = get cmput c 254 r = get cmret c 255 inflight = sub p r 256 if ge inflight ent 257 ret CMEFULL 258 end 259 if gt count sub sub ent 1 inflight 260 ret CMEFULL 261 end 262 chp = get chput c 263 if ne r get chret c 264 ret CMESTALE 265 end 266 avail = sub chp p 267 if or ge avail ent gt count avail 268 ret CMERANGE 269 end 270 put cmput c add p count 271 put cmst c CMSACTV 272 ret CMOK 273 end 274 fn cmpoll c ulong to long 275 if ge c CMSLOTS 276 ret CMEINVAL 277 end 278 st = get cmst c 279 if and and and ne st CMSBIND ne st CMSACTV ne st CMSDRN ne st CMSIDLE 280 ret CMESTATE 281 end 282 if ne get mmwgen 0 get cmgen c 283 ret CMEGEN 284 end 285 if ne get mmwst 0 MMWPUB 286 ret CMESTATE 287 end 288 b = get cmbuf c 289 if not gmlive b 290 ret CMESTATE 291 end 292 if ne get cmbgen c ulong get gmbgen b 293 ret CMEGEN 294 end 295 pa = get cmpa c 296 obs = uint mmrd32 pa 297 r = get cmret c 298 p = get cmput c 299 diff = cmprog r p obs 300 if lt diff 0 301 ret diff 302 end 303 if eq diff 0 304 ret 0 305 end 306 put cmret c obs 307 chretire c obs 308 if eq obs p 309 put cmst c CMSIDLE 310 end 311 ret diff 312 end 313 fn cmdrain c ulong budget uint to long 314 if ge c CMSLOTS 315 ret CMEINVAL 316 end 317 st = get cmst c 318 if and and and ne st CMSBIND ne st CMSACTV ne st CMSDRN ne st CMSIDLE 319 ret CMESTATE 320 end 321 if ne get mmwgen 0 get cmgen c 322 ret CMEGEN 323 end 324 if ne get mmwst 0 MMWPUB 325 ret CMESTATE 326 end 327 b = get cmbuf c 328 if not gmlive b 329 ret CMESTATE 330 end 331 if ne get cmbgen c ulong get gmbgen b 332 ret CMEGEN 333 end 334 if or ne get cmput c get chput c ne get cmret c get chret c 335 ret CMESTALE 336 end 337 if eq get cmret c get cmput c 338 put cmst c CMSIDLE 339 ret CMOK 340 end 341 put cmst c CMSDRN 342 drained = false 343 for i uint budget 344 r = cmpoll c 345 if lt r 0 346 break 347 end 348 if eq get cmret c get cmput c 349 drained = true 350 break 351 end 352 end 353 if drained 354 put cmst c CMSIDLE 355 ret CMOK 356 end 357 put cmst c CMSTOUT 358 note b is live under a published owned window: gmquar retires it AND quarantines the window (gmretire). 359 r = gmquar b 360 put cmst c CMSQST 361 ret CMETIME 362 end 363 fn cmquar c ulong gen ulong to long 364 if ge c CMSLOTS 365 ret CMEINVAL 366 end 367 if ne gen get cmgen c 368 ret CMEGEN 369 end 370 b = get cmbuf c 371 if ne b GMNONE 372 r = gmquar b 373 end 374 if eq get mmwst 0 MMWPUB 375 r = mmwquar gen 376 end 377 put cmst c CMSQST 378 ret CMOK 379 end