omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / uvm / resident.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note GB10-specific model: identical CPU/GPU physical backing; zero copied bytes. |
| 3 | note Residency mask describes mappings, NOT proof of device coherence. GPU transition emits fence-required flags. |
| 4 | note Per-page ledger: VA, mapping mask(1 CPU/2 GPU), last access counter. 128 slots. |
| 5 | global spage ulong 384 |
| 6 | global scva ulong 1 |
| 7 | global scval ulong 1 |
| 8 | global sctyp ulong 1 |
| 9 | global sctag ulong 1 |
| 10 | fn spfind va ulong to ulong |
| 11 | for j ulong 128 |
| 12 | if eq get spage mul j 3 va |
| 13 | ret j |
| 14 | end |
| 15 | end |
| 16 | ret 128 |
| 17 | end |
| 18 | fn spfree to ulong |
| 19 | for j ulong 128 |
| 20 | if eq get spage mul j 3 0 |
| 21 | ret j |
| 22 | end |
| 23 | end |
| 24 | ret 128 |
| 25 | end |
| 26 | fn sforget va ulong size ulong to void |
| 27 | for j ulong 128 |
| 28 | v = get spage mul j 3 |
| 29 | if and ge v va lt v add va size |
| 30 | for f ulong 3 |
| 31 | put spage add mul j 3 f 0 |
| 32 | end |
| 33 | end |
| 34 | end |
| 35 | end |
| 36 | fn smask i ulong acc ulong to ulong |
| 37 | if or eq acc 1 eq acc 2 |
| 38 | ret 2 |
| 39 | end |
| 40 | if eq sget i 5 1 |
| 41 | ret 3 |
| 42 | end |
| 43 | if eq sget i 3 0 |
| 44 | ret 3 |
| 45 | end |
| 46 | ret or ulong 2 and sget i 4 1 |
| 47 | end |
| 48 | fn scdecode to ulong |
| 49 | note NVIDIA580.173.02 class/clc365.h:36-41,59-79; 32B, GVA words2/3, |
| 50 | note counter word6[15:0], tag word5[19:0], valid word7[31], type word0[0]. |
| 51 | if eq and shr uvpktlw 7 31 1 0 |
| 52 | ret UVIGN |
| 53 | end |
| 54 | if ne and shr uvpktlw 0 1 1 0 |
| 55 | ret UVEINVAL |
| 56 | end |
| 57 | if ne and shr uvpktlw 0 8 3 2 |
| 58 | ret UVEINVAL |
| 59 | end |
| 60 | put scva 0 and or uvpktlw 2 shl uvpktlw 3 32 not sub UV4K 1 |
| 61 | put scval 0 and uvpktlw 6 65535 |
| 62 | put sctyp 0 and uvpktlw 0 1 |
| 63 | put sctag 0 and uvpktlw 5 1048575 |
| 64 | ret UVOK |
| 65 | end |
| 66 | fn scnotify limit ulong to ulong |
| 67 | if or eq limit 0 gt limit 65535 |
| 68 | ret UVEINVAL |
| 69 | end |
| 70 | r = scdecode |
| 71 | if ne r UVOK |
| 72 | ret r |
| 73 | end |
| 74 | i = sfind get scva 0 |
| 75 | if eq i 64 |
| 76 | ret UVENOENT |
| 77 | end |
| 78 | j = spfind get scva 0 |
| 79 | if eq j 128 |
| 80 | ret UVENOENT |
| 81 | end |
| 82 | put spage add mul j 3 2 get scval 0 |
| 83 | if lt get scval 0 limit |
| 84 | ret UVIGN |
| 85 | end |
| 86 | note Threshold proposes remapping through the same fault pipeline, never data copy. |
| 87 | put uvfva 0 get scva 0 |
| 88 | put uvfacc 0 0 |
| 89 | put uvftyp 0 1 |
| 90 | put uvfrep 0 1 |
| 91 | put uvfen 0 1 |
| 92 | put uvfval 0 1 |
| 93 | note CPU notifications request CPU-accessed mapping via range preference; GPU keeps preferred policy. |
| 94 | if eq get sctyp 0 0 |
| 95 | if eq sget i 3 1 |
| 96 | ret UVIGN |
| 97 | end |
| 98 | end |
| 99 | ret sservice |
| 100 | end |