omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / uvm / ring.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Serialized host snapshot ring, 16 NVC369 entries. Not DMA or an atomic device ring. |
| 3 | note GET/PUT are monotonic logical counters; physical slot is index modulo 16. |
| 4 | note Full refuses without overwriting unread entries and latches overflow until empty recovery. |
| 5 | global fbring uchar 512 |
| 6 | global fbget ulong 1 |
| 7 | global fbput ulong 1 |
| 8 | global fbov ulong 1 |
| 9 | global fbva ulong 16 |
| 10 | global fbacc ulong 16 |
| 11 | global fbn ulong 1 |
| 12 | fn fbpush to ulong |
| 13 | if ge sub get fbput 0 get fbget 0 16 |
| 14 | put fbov 0 1 |
| 15 | ret UVENOM |
| 16 | end |
| 17 | if eq get fbput 0 18446744073709551615 |
| 18 | ret UVERANGE |
| 19 | end |
| 20 | o = mul rem get fbput 0 16 32 |
| 21 | for j ulong 32 |
| 22 | put fbring add o j get uvpkt j |
| 23 | end |
| 24 | put fbput 0 add get fbput 0 1 |
| 25 | ret UVOK |
| 26 | end |
| 27 | fn fbpeek to ulong |
| 28 | if eq get fbget 0 get fbput 0 |
| 29 | ret UVIGN |
| 30 | end |
| 31 | o = mul rem get fbget 0 16 32 |
| 32 | for j ulong 32 |
| 33 | put uvpkt j get fbring add o j |
| 34 | end |
| 35 | uvpktdec |
| 36 | if eq get uvfval 0 0 |
| 37 | ret UVIGN |
| 38 | end |
| 39 | ret UVOK |
| 40 | end |
| 41 | fn fbconsume to void |
| 42 | o = add mul rem get fbget 0 16 32 31 |
| 43 | put fbring o uchar and get fbring o 127 |
| 44 | put fbget 0 add get fbget 0 1 |
| 45 | end |
| 46 | fn fbrecover to ulong |
| 47 | if ne get fbget 0 get fbput 0 |
| 48 | ret UVEBUSY |
| 49 | end |
| 50 | put fbov 0 0 |
| 51 | ret UVOK |
| 52 | end |
| 53 | fn fbduplicate to bool |
| 54 | for j ulong get fbn 0 |
| 55 | if ne get fbva j get uvfva 0 |
| 56 | continue |
| 57 | end |
| 58 | if eq get fbacc j get uvfacc 0 |
| 59 | ret true |
| 60 | end |
| 61 | end |
| 62 | ret false |
| 63 | end |
| 64 | fn fbbenign to bool |
| 65 | if ne get uvfen 0 1 |
| 66 | ret false |
| 67 | end |
| 68 | if ne get uvfrep 0 1 |
| 69 | ret false |
| 70 | end |
| 71 | ret lt get uvftyp 0 3 |
| 72 | end |
| 73 | fn fbbatch to ulong |
| 74 | put fbn 0 0 |
| 75 | for k ulong 16 |
| 76 | r = fbpeek |
| 77 | if ne r UVOK |
| 78 | ret UVOK |
| 79 | end |
| 80 | note Never deduplicate a fatal/disabled packet behind a benign same-page fault. |
| 81 | if fbbenign |
| 82 | if fbduplicate |
| 83 | fbconsume |
| 84 | continue |
| 85 | end |
| 86 | put fbva get fbn 0 get uvfva 0 |
| 87 | put fbacc get fbn 0 get uvfacc 0 |
| 88 | put fbn 0 add get fbn 0 1 |
| 89 | end |
| 90 | r = sservice |
| 91 | if eq r UVENOM |
| 92 | ret r |
| 93 | end |
| 94 | fbconsume |
| 95 | end |
| 96 | ret UVOK |
| 97 | end |