omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / uvm / fault.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note uvm/fault.om: NVC369 32-byte fault packet and the replay policy. |
| 3 | note Word 2 holds page-number bits 19:0 at 31:12. Word 3 holds bits 51:20. |
| 4 | note Word 4 is timestamp 31:0, word 5 is timestamp 63:32. Word 7 is |
| 5 | note type 4:0, replayable 7:7, client 14:8, access 19:16, enable 30:30, valid 31:31. |
| 6 | note Policy: invalid packet is ignored. A non-replayable packet, a disabled engine, |
| 7 | note or a type other than PDE (0), PTE (1) or LIMIT (2) is fatal. A valid replayable |
| 8 | note fault outside a reservation, or inside one with no backing, is cancelled. |
| 9 | note A write or atomic on a read-only reservation is fatal. Otherwise the missing |
| 10 | note page is mapped from the reservation backing and the fault is replayed. |
| 11 | global uvpkt uchar 32 |
| 12 | global uvfva ulong 1 |
| 13 | global uvfts ulong 1 |
| 14 | global uvftyp ulong 1 |
| 15 | global uvfrep ulong 1 |
| 16 | global uvfacc ulong 1 |
| 17 | global uvfcli ulong 1 |
| 18 | global uvfen ulong 1 |
| 19 | global uvfval ulong 1 |
| 20 | fn uvpktw n ulong v ulong to void |
| 21 | b = mul n 4 |
| 22 | put uvpkt b uchar and v 255 |
| 23 | put uvpkt add b 1 uchar and shr v 8 255 |
| 24 | put uvpkt add b 2 uchar and shr v 16 255 |
| 25 | put uvpkt add b 3 uchar and shr v 24 255 |
| 26 | end |
| 27 | fn uvpktlw n ulong to ulong |
| 28 | b = mul n 4 |
| 29 | v = ulong get uvpkt b |
| 30 | v = or v shl ulong get uvpkt add b 1 8 |
| 31 | v = or v shl ulong get uvpkt add b 2 16 |
| 32 | ret or v shl ulong get uvpkt add b 3 24 |
| 33 | end |
| 34 | fn uvpktenc va ulong ts ulong typ ulong rep ulong acc ulong cli ulong to void |
| 35 | for i ulong 32 |
| 36 | put uvpkt i 0 |
| 37 | end |
| 38 | uvpktw 2 shl and shr va 12 1048575 12 |
| 39 | uvpktw 3 shr va 32 |
| 40 | uvpktw 4 and ts 4294967295 |
| 41 | uvpktw 5 shr ts 32 |
| 42 | w = and typ 31 |
| 43 | w = or w shl and rep 1 7 |
| 44 | w = or w shl and cli 127 8 |
| 45 | w = or w shl and acc 15 16 |
| 46 | w = or w shl and get uvfen 0 1 30 |
| 47 | w = or w shl and get uvfval 0 1 31 |
| 48 | uvpktw 7 w |
| 49 | end |
| 50 | fn uvdecva to void |
| 51 | w2 = uvpktlw 2 |
| 52 | w3 = uvpktlw 3 |
| 53 | put uvfva 0 shl or shr w2 12 shl w3 20 12 |
| 54 | end |
| 55 | fn uvdects to void |
| 56 | put uvfts 0 or uvpktlw 4 shl uvpktlw 5 32 |
| 57 | end |
| 58 | fn uvdecw7 to void |
| 59 | w = uvpktlw 7 |
| 60 | put uvftyp 0 and w 31 |
| 61 | put uvfrep 0 and shr w 7 1 |
| 62 | put uvfcli 0 and shr w 8 127 |
| 63 | put uvfacc 0 and shr w 16 15 |
| 64 | put uvfen 0 and shr w 30 1 |
| 65 | put uvfval 0 and shr w 31 1 |
| 66 | end |
| 67 | fn uvpktdec to void |
| 68 | uvdecva |
| 69 | uvdects |
| 70 | uvdecw7 |
| 71 | end |
| 72 | fn uvpolicy to ulong |
| 73 | if eq get uvfval 0 0 |
| 74 | ret UVIGN |
| 75 | end |
| 76 | if eq get uvfen 0 0 |
| 77 | ret UVFATAL |
| 78 | end |
| 79 | if eq get uvfrep 0 0 |
| 80 | ret UVFATAL |
| 81 | end |
| 82 | if ge get uvftyp 0 3 |
| 83 | ret UVFATAL |
| 84 | end |
| 85 | i = uvfind get uvfva 0 |
| 86 | if ge i 32 |
| 87 | ret UVCANCEL |
| 88 | end |
| 89 | if eq get uvrpa i 0 |
| 90 | ret UVCANCEL |
| 91 | end |
| 92 | if and ne get uvrro i 0 or eq get uvfacc 0 1 eq get uvfacc 0 2 |
| 93 | ret UVFATAL |
| 94 | end |
| 95 | ret UVREPLAY |
| 96 | end |
| 97 | fn uvserve to ulong |
| 98 | uvpktdec |
| 99 | act = uvpolicy |
| 100 | if ne act UVREPLAY |
| 101 | ret act |
| 102 | end |
| 103 | ret uvfix |
| 104 | end |
| 105 | fn uvfix to ulong |
| 106 | i = uvfind get uvfva 0 |
| 107 | page = get uvrpg i |
| 108 | base = get uvrva i |
| 109 | off = and sub get uvfva 0 base not sub page 1 |
| 110 | pa = add get uvrpa i off |
| 111 | r = uvread add base off page |
| 112 | if eq r UVMAPPED |
| 113 | ret UVREPLAY |
| 114 | end |
| 115 | pcf = ulong 0 |
| 116 | if ne get uvrro i 0 |
| 117 | pcf = 4 |
| 118 | end |
| 119 | r2 = uvmap add base off pa page page UVAPSYS pcf |
| 120 | if ne r2 UVOK |
| 121 | ret UVFATAL |
| 122 | end |
| 123 | ret UVREPLAY |
| 124 | end |