interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / gsp / transport.om

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