interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / third_party / nvidia-open-580.173.02 / kernel-open / nvidia-uvm / uvm_ioctl.h

1157 lines · 41415 bytes Raw Blame History
1/*******************************************************************************
2 Copyright (c) 2013-2025 NVidia Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to
6 deal in the Software without restriction, including without limitation the
7 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 sell copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be
12 included in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 DEALINGS IN THE SOFTWARE.
21*******************************************************************************/
22
23#ifndef _UVM_IOCTL_H
24#define _UVM_IOCTL_H
25
26#include "uvm_types.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32//
33// Please see the header file (uvm.h) for detailed documentation on each of the
34// associated API calls.
35//
36
37#if defined(WIN32) || defined(WIN64)
38# define UVM_IOCTL_BASE(i) CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800+i, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
39#else
40# define UVM_IOCTL_BASE(i) i
41#endif
42
43//
44// UvmReserveVa
45//
46#define UVM_RESERVE_VA UVM_IOCTL_BASE(1)
47
48typedef struct
49{
50 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
51 NvU64 length NV_ALIGN_BYTES(8); // IN
52 NV_STATUS rmStatus; // OUT
53} UVM_RESERVE_VA_PARAMS;
54
55//
56// UvmReleaseVa
57//
58#define UVM_RELEASE_VA UVM_IOCTL_BASE(2)
59
60typedef struct
61{
62 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
63 NvU64 length NV_ALIGN_BYTES(8); // IN
64 NV_STATUS rmStatus; // OUT
65} UVM_RELEASE_VA_PARAMS;
66
67//
68// UvmRegionCommit
69//
70#define UVM_REGION_COMMIT UVM_IOCTL_BASE(3)
71
72typedef struct
73{
74 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
75 NvU64 length NV_ALIGN_BYTES(8); // IN
76 UvmStream streamId NV_ALIGN_BYTES(8); // IN
77 NvProcessorUuid gpuUuid; // IN
78 NV_STATUS rmStatus; // OUT
79} UVM_REGION_COMMIT_PARAMS;
80
81//
82// UvmRegionDecommit
83//
84#define UVM_REGION_DECOMMIT UVM_IOCTL_BASE(4)
85
86typedef struct
87{
88 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
89 NvU64 length NV_ALIGN_BYTES(8); // IN
90 NV_STATUS rmStatus; // OUT
91} UVM_REGION_DECOMMIT_PARAMS;
92
93//
94// UvmRegionSetStream
95//
96#define UVM_REGION_SET_STREAM UVM_IOCTL_BASE(5)
97
98typedef struct
99{
100 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
101 NvU64 length NV_ALIGN_BYTES(8); // IN
102 UvmStream newStreamId NV_ALIGN_BYTES(8); // IN
103 NvProcessorUuid gpuUuid; // IN
104 NV_STATUS rmStatus; // OUT
105} UVM_REGION_SET_STREAM_PARAMS;
106
107//
108// UvmSetStreamRunning
109//
110#define UVM_SET_STREAM_RUNNING UVM_IOCTL_BASE(6)
111
112typedef struct
113{
114 UvmStream streamId NV_ALIGN_BYTES(8); // IN
115 NV_STATUS rmStatus; // OUT
116} UVM_SET_STREAM_RUNNING_PARAMS;
117
118
119//
120// Due to limitations in how much we want to send per ioctl call, the nStreams
121// member must be less than or equal to about 250. That's an upper limit.
122//
123// However, from a typical user-space driver's point of view (for example, the
124// CUDA driver), a vast majority of the time, we expect there to be only one
125// stream passed in. The second most common case is something like atmost 32
126// streams being passed in. The cases where there are more than 32 streams are
127// the most rare. So we might want to optimize the ioctls accordingly so that we
128// don't always copy a 250 * sizeof(streamID) sized array when there's only one
129// or a few streams.
130//
131// For that reason, UVM_MAX_STREAMS_PER_IOCTL_CALL is set to 32.
132//
133// If the higher-level (uvm.h) call requires more streams to be stopped than
134// this value, then multiple ioctl calls should be made.
135//
136#define UVM_MAX_STREAMS_PER_IOCTL_CALL 32
137
138//
139// UvmSetStreamStopped
140//
141#define UVM_SET_STREAM_STOPPED UVM_IOCTL_BASE(7)
142
143typedef struct
144{
145 UvmStream streamIdArray[UVM_MAX_STREAMS_PER_IOCTL_CALL] NV_ALIGN_BYTES(8); // IN
146 NvU64 nStreams NV_ALIGN_BYTES(8); // IN
147 NV_STATUS rmStatus; // OUT
148} UVM_SET_STREAM_STOPPED_PARAMS;
149
150//
151// UvmCallTestFunction
152//
153#define UVM_RUN_TEST UVM_IOCTL_BASE(9)
154
155typedef struct
156{
157 NvProcessorUuid gpuUuid; // IN
158 NvU32 test; // IN
159 struct
160 {
161 NvProcessorUuid peerGpuUuid; // IN
162 NvU32 peerId; // IN
163 } multiGpu;
164 NV_STATUS rmStatus; // OUT
165} UVM_RUN_TEST_PARAMS;
166
167//
168// This is a magic offset for mmap. Any mapping of an offset above this
169// threshold will be treated as a counters mapping, not as an allocation
170// mapping. Since allocation offsets must be identical to the virtual address
171// of the mapping, this threshold has to be an offset that cannot be
172// a valid virtual address.
173//
174#if defined(__linux__)
175 #if defined(NV_64_BITS)
176 #define UVM_EVENTS_OFFSET_BASE (1UL << 63)
177 #define UVM_COUNTERS_OFFSET_BASE (1UL << 62)
178 #else
179 #define UVM_EVENTS_OFFSET_BASE (1UL << 31)
180 #define UVM_COUNTERS_OFFSET_BASE (1UL << 30)
181 #endif
182#endif // defined(__linux___)
183
184//
185// UvmAddSession
186//
187#define UVM_ADD_SESSION UVM_IOCTL_BASE(10)
188
189typedef struct
190{
191 NvU32 pidTarget; // IN
192#ifdef __linux__
193 NvP64 countersBaseAddress NV_ALIGN_BYTES(8); // IN
194 NvS32 sessionIndex; // OUT (session index that got added)
195#endif
196 NV_STATUS rmStatus; // OUT
197} UVM_ADD_SESSION_PARAMS;
198
199//
200// UvmRemoveSession
201//
202#define UVM_REMOVE_SESSION UVM_IOCTL_BASE(11)
203
204typedef struct
205{
206#ifdef __linux__
207 NvS32 sessionIndex; // IN (session index to be removed)
208#endif
209 NV_STATUS rmStatus; // OUT
210} UVM_REMOVE_SESSION_PARAMS;
211
212
213#define UVM_MAX_COUNTERS_PER_IOCTL_CALL 32
214
215//
216// UvmEnableCounters
217//
218#define UVM_ENABLE_COUNTERS UVM_IOCTL_BASE(12)
219
220typedef struct
221{
222#ifdef __linux__
223 NvS32 sessionIndex; // IN
224#endif
225 UvmCounterConfig config[UVM_MAX_COUNTERS_PER_IOCTL_CALL]; // IN
226 NvU32 count; // IN
227 NV_STATUS rmStatus; // OUT
228} UVM_ENABLE_COUNTERS_PARAMS;
229
230//
231// UvmMapCounter
232//
233#define UVM_MAP_COUNTER UVM_IOCTL_BASE(13)
234
235typedef struct
236{
237#ifdef __linux__
238 NvS32 sessionIndex; // IN
239#endif
240 NvU32 scope; // IN (UvmCounterScope)
241 NvU32 counterName; // IN (UvmCounterName)
242 NvProcessorUuid gpuUuid; // IN
243 NvP64 addr NV_ALIGN_BYTES(8); // OUT
244 NV_STATUS rmStatus; // OUT
245} UVM_MAP_COUNTER_PARAMS;
246
247//
248// UvmCreateEventQueue
249//
250#define UVM_CREATE_EVENT_QUEUE UVM_IOCTL_BASE(14)
251
252typedef struct
253{
254#ifdef __linux__
255 NvS32 sessionIndex; // IN
256#endif
257 NvU32 eventQueueIndex; // OUT
258 NvU64 queueSize NV_ALIGN_BYTES(8); // IN
259 NvU64 notificationCount NV_ALIGN_BYTES(8); // IN
260#if defined(WIN32) || defined(WIN64)
261 NvU64 notificationHandle NV_ALIGN_BYTES(8); // IN
262#endif
263 NvU32 timeStampType; // IN (UvmEventTimeStampType)
264 NV_STATUS rmStatus; // OUT
265} UVM_CREATE_EVENT_QUEUE_PARAMS;
266
267//
268// UvmRemoveEventQueue
269//
270#define UVM_REMOVE_EVENT_QUEUE UVM_IOCTL_BASE(15)
271
272typedef struct
273{
274#ifdef __linux__
275 NvS32 sessionIndex; // IN
276#endif
277 NvU32 eventQueueIndex; // IN
278 NV_STATUS rmStatus; // OUT
279} UVM_REMOVE_EVENT_QUEUE_PARAMS;
280
281//
282// UvmMapEventQueue
283//
284#define UVM_MAP_EVENT_QUEUE UVM_IOCTL_BASE(16)
285
286typedef struct
287{
288#ifdef __linux__
289 NvS32 sessionIndex; // IN
290#endif
291 NvU32 eventQueueIndex; // IN
292 NvP64 userRODataAddr NV_ALIGN_BYTES(8); // IN
293 NvP64 userRWDataAddr NV_ALIGN_BYTES(8); // IN
294 NvP64 readIndexAddr NV_ALIGN_BYTES(8); // OUT
295 NvP64 writeIndexAddr NV_ALIGN_BYTES(8); // OUT
296 NvP64 queueBufferAddr NV_ALIGN_BYTES(8); // OUT
297 NV_STATUS rmStatus; // OUT
298} UVM_MAP_EVENT_QUEUE_PARAMS;
299
300//
301// UvmEnableEvent
302//
303#define UVM_EVENT_CTRL UVM_IOCTL_BASE(17)
304
305typedef struct
306{
307#ifdef __linux__
308 NvS32 sessionIndex; // IN
309#endif
310 NvU32 eventQueueIndex; // IN
311 NvS32 eventType; // IN
312 NvU32 enable; // IN
313 NV_STATUS rmStatus; // OUT
314} UVM_EVENT_CTRL_PARAMS;
315
316//
317// UvmRegisterMpsServer
318//
319#define UVM_REGISTER_MPS_SERVER UVM_IOCTL_BASE(18)
320
321typedef struct
322{
323 NvProcessorUuid gpuUuidArray[UVM_MAX_GPUS_V1]; // IN
324 NvU32 numGpus; // IN
325 NvU64 serverId NV_ALIGN_BYTES(8); // OUT
326 NV_STATUS rmStatus; // OUT
327} UVM_REGISTER_MPS_SERVER_PARAMS;
328
329//
330// UvmRegisterMpsClient
331//
332#define UVM_REGISTER_MPS_CLIENT UVM_IOCTL_BASE(19)
333
334typedef struct
335{
336 NvU64 serverId NV_ALIGN_BYTES(8); // IN
337 NV_STATUS rmStatus; // OUT
338} UVM_REGISTER_MPS_CLIENT_PARAMS;
339
340//
341// UvmEventGetGpuUuidTable
342//
343#define UVM_GET_GPU_UUID_TABLE UVM_IOCTL_BASE(20)
344
345typedef struct
346{
347 NvProcessorUuid gpuUuidArray[UVM_MAX_GPUS_V1]; // OUT
348 NvU32 validCount; // OUT
349 NV_STATUS rmStatus; // OUT
350} UVM_GET_GPU_UUID_TABLE_PARAMS;
351
352#if defined(WIN32) || defined(WIN64)
353//
354// UvmRegionSetBacking
355//
356#define UVM_REGION_SET_BACKING UVM_IOCTL_BASE(21)
357
358typedef struct
359{
360 NvProcessorUuid gpuUuid; // IN
361 NvU32 hAllocation; // IN
362 NvP64 vaAddr NV_ALIGN_BYTES(8); // IN
363 NvU64 regionLength NV_ALIGN_BYTES(8); // IN
364 NV_STATUS rmStatus; // OUT
365} UVM_REGION_SET_BACKING_PARAMS;
366
367//
368// UvmRegionUnsetBacking
369//
370#define UVM_REGION_UNSET_BACKING UVM_IOCTL_BASE(22)
371
372typedef struct
373{
374 NvP64 vaAddr NV_ALIGN_BYTES(8); // IN
375 NvU64 regionLength NV_ALIGN_BYTES(8); // IN
376 NV_STATUS rmStatus; // OUT
377} UVM_REGION_UNSET_BACKING_PARAMS;
378
379#endif
380
381#define UVM_CREATE_RANGE_GROUP UVM_IOCTL_BASE(23)
382
383typedef struct
384{
385 NvU64 rangeGroupId NV_ALIGN_BYTES(8); // OUT
386 NV_STATUS rmStatus; // OUT
387} UVM_CREATE_RANGE_GROUP_PARAMS;
388
389#define UVM_DESTROY_RANGE_GROUP UVM_IOCTL_BASE(24)
390
391typedef struct
392{
393 NvU64 rangeGroupId NV_ALIGN_BYTES(8); // IN
394 NV_STATUS rmStatus; // OUT
395} UVM_DESTROY_RANGE_GROUP_PARAMS;
396
397//
398// UvmRegisterGpuVaSpace
399//
400#define UVM_REGISTER_GPU_VASPACE UVM_IOCTL_BASE(25)
401
402typedef struct
403{
404 NvProcessorUuid gpuUuid; // IN
405 NvS32 rmCtrlFd; // IN
406 NvHandle hClient; // IN
407 NvHandle hVaSpace; // IN
408 NV_STATUS rmStatus; // OUT
409} UVM_REGISTER_GPU_VASPACE_PARAMS;
410
411//
412// UvmUnregisterGpuVaSpace
413//
414#define UVM_UNREGISTER_GPU_VASPACE UVM_IOCTL_BASE(26)
415
416typedef struct
417{
418 NvProcessorUuid gpuUuid; // IN
419 NV_STATUS rmStatus; // OUT
420} UVM_UNREGISTER_GPU_VASPACE_PARAMS;
421
422//
423// UvmRegisterChannel
424//
425#define UVM_REGISTER_CHANNEL UVM_IOCTL_BASE(27)
426
427typedef struct
428{
429 NvProcessorUuid gpuUuid; // IN
430 NvS32 rmCtrlFd; // IN
431 NvHandle hClient; // IN
432 NvHandle hChannel; // IN
433 NvU64 base NV_ALIGN_BYTES(8); // IN
434 NvU64 length NV_ALIGN_BYTES(8); // IN
435 NV_STATUS rmStatus; // OUT
436} UVM_REGISTER_CHANNEL_PARAMS;
437
438//
439// UvmUnregisterChannel
440//
441#define UVM_UNREGISTER_CHANNEL UVM_IOCTL_BASE(28)
442
443typedef struct
444{
445 NvProcessorUuid gpuUuid; // IN
446 NvHandle hClient; // IN
447 NvHandle hChannel; // IN
448 NV_STATUS rmStatus; // OUT
449} UVM_UNREGISTER_CHANNEL_PARAMS;
450
451//
452// UvmEnablePeerAccess
453//
454#define UVM_ENABLE_PEER_ACCESS UVM_IOCTL_BASE(29)
455
456typedef struct
457{
458 NvProcessorUuid gpuUuidA; // IN
459 NvProcessorUuid gpuUuidB; // IN
460 NV_STATUS rmStatus; // OUT
461} UVM_ENABLE_PEER_ACCESS_PARAMS;
462
463//
464// UvmDisablePeerAccess
465//
466#define UVM_DISABLE_PEER_ACCESS UVM_IOCTL_BASE(30)
467
468typedef struct
469{
470 NvProcessorUuid gpuUuidA; // IN
471 NvProcessorUuid gpuUuidB; // IN
472 NV_STATUS rmStatus; // OUT
473} UVM_DISABLE_PEER_ACCESS_PARAMS;
474
475//
476// UvmSetRangeGroup
477//
478#define UVM_SET_RANGE_GROUP UVM_IOCTL_BASE(31)
479
480typedef struct
481{
482 NvU64 rangeGroupId NV_ALIGN_BYTES(8); // IN
483 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
484 NvU64 length NV_ALIGN_BYTES(8); // IN
485 NV_STATUS rmStatus; // OUT
486} UVM_SET_RANGE_GROUP_PARAMS;
487
488//
489// UvmMapExternalAllocation
490//
491#define UVM_MAP_EXTERNAL_ALLOCATION UVM_IOCTL_BASE(33)
492typedef struct
493{
494 NvU64 base NV_ALIGN_BYTES(8); // IN
495 NvU64 length NV_ALIGN_BYTES(8); // IN
496 NvU64 offset NV_ALIGN_BYTES(8); // IN
497 UvmGpuMappingAttributes perGpuAttributes[UVM_MAX_GPUS]; // IN
498 NvU64 gpuAttributesCount NV_ALIGN_BYTES(8); // IN
499 NvS32 rmCtrlFd; // IN
500 NvU32 hClient; // IN
501 NvU32 hMemory; // IN
502
503 NV_STATUS rmStatus; // OUT
504} UVM_MAP_EXTERNAL_ALLOCATION_PARAMS;
505
506//
507// UvmFree
508//
509#define UVM_FREE UVM_IOCTL_BASE(34)
510typedef struct
511{
512 NvU64 base NV_ALIGN_BYTES(8); // IN
513 NvU64 length NV_ALIGN_BYTES(8); // IN
514 NV_STATUS rmStatus; // OUT
515} UVM_FREE_PARAMS;
516
517//
518// UvmMemMap
519//
520#define UVM_MEM_MAP UVM_IOCTL_BASE(35)
521
522typedef struct
523{
524 NvP64 regionBase NV_ALIGN_BYTES(8); // IN
525 NvU64 regionLength NV_ALIGN_BYTES(8); // IN
526 NV_STATUS rmStatus; // OUT
527} UVM_MEM_MAP_PARAMS;
528
529//
530// UvmRegisterGpu
531//
532#define UVM_REGISTER_GPU UVM_IOCTL_BASE(37)
533
534typedef struct
535{
536 NvProcessorUuid gpu_uuid; // IN/OUT
537 NvBool numaEnabled; // OUT
538 NvS32 numaNodeId; // OUT
539 NvS32 rmCtrlFd; // IN
540 NvHandle hClient; // IN
541 NvHandle hSmcPartRef; // IN
542 NV_STATUS rmStatus; // OUT
543} UVM_REGISTER_GPU_PARAMS;
544
545//
546// UvmUnregisterGpu
547//
548#define UVM_UNREGISTER_GPU UVM_IOCTL_BASE(38)
549
550typedef struct
551{
552 NvProcessorUuid gpu_uuid; // IN
553 NV_STATUS rmStatus; // OUT
554} UVM_UNREGISTER_GPU_PARAMS;
555
556#define UVM_PAGEABLE_MEM_ACCESS UVM_IOCTL_BASE(39)
557
558typedef struct
559{
560 NvBool pageableMemAccess; // OUT
561 NV_STATUS rmStatus; // OUT
562} UVM_PAGEABLE_MEM_ACCESS_PARAMS;
563
564//
565// Due to limitations in how much we want to send per ioctl call, the numGroupIds
566// member must be less than or equal to about 250. That's an upper limit.
567//
568// However, from a typical user-space driver's point of view (for example, the
569// CUDA driver), a vast majority of the time, we expect there to be only one
570// range group passed in. The second most common case is something like atmost 32
571// range groups being passed in. The cases where there are more than 32 range
572// groups are the most rare. So we might want to optimize the ioctls accordingly
573// so that we don't always copy a 250 * sizeof(NvU64) sized array when there's
574// only one or a few range groups.
575//
576// For that reason, UVM_MAX_RANGE_GROUPS_PER_IOCTL_CALL is set to 32.
577//
578// If the higher-level (uvm.h) call requires more range groups than
579// this value, then multiple ioctl calls should be made.
580//
581#define UVM_MAX_RANGE_GROUPS_PER_IOCTL_CALL 32
582
583//
584// UvmPreventMigrationRangeGroups
585//
586#define UVM_PREVENT_MIGRATION_RANGE_GROUPS UVM_IOCTL_BASE(40)
587
588typedef struct
589{
590 NvU64 rangeGroupIds[UVM_MAX_RANGE_GROUPS_PER_IOCTL_CALL] NV_ALIGN_BYTES(8); // IN
591 NvU64 numGroupIds NV_ALIGN_BYTES(8); // IN
592 NV_STATUS rmStatus; // OUT
593} UVM_PREVENT_MIGRATION_RANGE_GROUPS_PARAMS;
594
595//
596// UvmAllowMigrationRangeGroups
597//
598#define UVM_ALLOW_MIGRATION_RANGE_GROUPS UVM_IOCTL_BASE(41)
599
600typedef struct
601{
602 NvU64 rangeGroupIds[UVM_MAX_RANGE_GROUPS_PER_IOCTL_CALL] NV_ALIGN_BYTES(8); // IN
603 NvU64 numGroupIds NV_ALIGN_BYTES(8); // IN
604 NV_STATUS rmStatus; // OUT
605} UVM_ALLOW_MIGRATION_RANGE_GROUPS_PARAMS;
606
607//
608// UvmSetPreferredLocation
609//
610#define UVM_SET_PREFERRED_LOCATION UVM_IOCTL_BASE(42)
611
612typedef struct
613{
614 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
615 NvU64 length NV_ALIGN_BYTES(8); // IN
616 NvProcessorUuid preferredLocation; // IN
617 NvS32 preferredCpuNumaNode; // IN
618 NV_STATUS rmStatus; // OUT
619} UVM_SET_PREFERRED_LOCATION_PARAMS;
620
621//
622// UvmUnsetPreferredLocation
623//
624#define UVM_UNSET_PREFERRED_LOCATION UVM_IOCTL_BASE(43)
625
626typedef struct
627{
628 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
629 NvU64 length NV_ALIGN_BYTES(8); // IN
630 NV_STATUS rmStatus; // OUT
631} UVM_UNSET_PREFERRED_LOCATION_PARAMS;
632
633//
634// UvmEnableReadDuplication
635//
636#define UVM_ENABLE_READ_DUPLICATION UVM_IOCTL_BASE(44)
637
638typedef struct
639{
640 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
641 NvU64 length NV_ALIGN_BYTES(8); // IN
642 NV_STATUS rmStatus; // OUT
643} UVM_ENABLE_READ_DUPLICATION_PARAMS;
644
645//
646// UvmDisableReadDuplication
647//
648#define UVM_DISABLE_READ_DUPLICATION UVM_IOCTL_BASE(45)
649
650typedef struct
651{
652 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
653 NvU64 length NV_ALIGN_BYTES(8); // IN
654 NV_STATUS rmStatus; // OUT
655} UVM_DISABLE_READ_DUPLICATION_PARAMS;
656
657//
658// UvmSetAccessedBy
659//
660#define UVM_SET_ACCESSED_BY UVM_IOCTL_BASE(46)
661
662typedef struct
663{
664 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
665 NvU64 length NV_ALIGN_BYTES(8); // IN
666 NvProcessorUuid accessedByUuid; // IN
667 NV_STATUS rmStatus; // OUT
668} UVM_SET_ACCESSED_BY_PARAMS;
669
670//
671// UvmUnsetAccessedBy
672//
673#define UVM_UNSET_ACCESSED_BY UVM_IOCTL_BASE(47)
674
675typedef struct
676{
677 NvU64 requestedBase NV_ALIGN_BYTES(8); // IN
678 NvU64 length NV_ALIGN_BYTES(8); // IN
679 NvProcessorUuid accessedByUuid; // IN
680 NV_STATUS rmStatus; // OUT
681} UVM_UNSET_ACCESSED_BY_PARAMS;
682
683// For managed allocations, UVM_MIGRATE implements the behavior described in
684// UvmMigrate. If the input virtual range corresponds to system-allocated
685// pageable memory, and the GPUs in the system support transparent access to
686// pageable memory, the scheme is a bit more elaborate, potentially with
687// several transitions betwen user and kernel spaces:
688//
689// 1) UVM_MIGRATE with the range base address and size. This will migrate
690// anonymous vmas until:
691// a) It finds a file-backed vma or no GPUs are registered in the VA space
692// so no GPU can drive the copy. It will try to populate the vma using
693// get_user_pages and return NV_WARN_NOTHING_TO_DO.
694// b) It fails to allocate memory on the destination CPU node. It will return
695// NV_ERR_MORE_PROCESSING_REQUIRED.
696// c) It fails to populate pages directly on the destination GPU. It will try
697// to populate the vma using get_user_pages and return.
698// d) The full input range is migrated (or empty), this call will release
699// the semaphore before returning.
700// 2) The user-mode needs to handle the following error codes:
701// a) NV_WARN_NOTHING_TO_DO: use move_pages to migrate pages for the VA
702// range corresponding to the vma that couldn't be migrated in kernel
703// mode. Then, it processes the remainder of the range, starting after
704// that vma.
705// b) NV_ERR_MORE_PROCESSING_REQUIRED: choose a different CPU NUMA node,
706// trying to enforce the NUMA policies of the thread and retry the
707// ioctl. If there are no more CPU NUMA nodes to try, try to populate
708// the remainder of the range anywhere using the UVM_POPULATE_PAGEABLE
709// ioctl.
710// c) NV_OK: success. This only guarantees that pages were populated, not
711// that they moved to the requested destination.
712// 3) For cases 2.a) and 2.b) Goto 1
713//
714// If UVM_MIGRATE_FLAG_ASYNC is 0, the ioctl won't return until the migration is
715// done and all mappings are updated, subject to the special rules for pageable
716// memory described above. semaphoreAddress must be 0. semaphorePayload is
717// ignored.
718//
719// If UVM_MIGRATE_FLAG_ASYNC is 1, the ioctl may return before the migration is
720// complete. If semaphoreAddress is 0, semaphorePayload is ignored and no
721// notification will be given on completion. If semaphoreAddress is non-zero
722// and the returned error code is NV_OK, semaphorePayload will be written to
723// semaphoreAddress once the migration is complete.
724#define UVM_MIGRATE_FLAG_ASYNC 0x00000001
725
726// When the migration destination is the CPU, skip the step which creates new
727// virtual mappings on the CPU. Creating CPU mappings must wait for the
728// migration to complete, so skipping this step allows the migration to be
729// fully asynchronous. This flag is ignored for pageable migrations if the GPUs
730// in the system support transparent access to pageable memory.
731//
732// The UVM driver must have builtin tests enabled for the API to use this flag.
733#define UVM_MIGRATE_FLAG_SKIP_CPU_MAP 0x00000002
734
735// By default UVM_MIGRATE returns an error if the destination UUID is a GPU
736// without a registered GPU VA space. Setting this flag skips that check, so the
737// destination GPU only needs to have been registered.
738//
739// This can be used in tests to trigger migrations of physical memory without
740// the overhead of GPU PTE mappings.
741//
742// The UVM driver must have builtin tests enabled for the API to use this flag.
743#define UVM_MIGRATE_FLAG_NO_GPU_VA_SPACE 0x00000004
744
745#define UVM_MIGRATE_FLAGS_TEST_ALL (UVM_MIGRATE_FLAG_SKIP_CPU_MAP | \
746 UVM_MIGRATE_FLAG_NO_GPU_VA_SPACE)
747
748#define UVM_MIGRATE_FLAGS_ALL (UVM_MIGRATE_FLAG_ASYNC | \
749 UVM_MIGRATE_FLAGS_TEST_ALL)
750
751// If NV_ERR_INVALID_ARGUMENT is returned it is because cpuMemoryNode is not
752// valid and the destination processor is the CPU. cpuMemoryNode is considered
753// invalid if:
754// * it is less than -1,
755// * it is equal to or larger than the maximum number of nodes, or
756// * it corresponds to a registered GPU.
757// * it is not in the node_possible_map set of nodes,
758// * it does not have onlined memory
759//
760// For pageable migrations:
761//
762// In addition to the above, in the case of pageable memory, the
763// cpuMemoryNode is considered invalid if it's -1.
764//
765// If NV_WARN_NOTHING_TO_DO is returned, user-space is responsible for
766// completing the migration of the VA range described by userSpaceStart and
767// userSpaceLength using move_pages.
768//
769// If NV_ERR_MORE_PROCESSING_REQUIRED is returned, user-space is responsible
770// for re-trying with a different cpuNumaNode, starting at userSpaceStart.
771//
772#define UVM_MIGRATE UVM_IOCTL_BASE(51)
773typedef struct
774{
775 NvU64 base NV_ALIGN_BYTES(8); // IN
776 NvU64 length NV_ALIGN_BYTES(8); // IN
777 NvProcessorUuid destinationUuid; // IN
778 NvU32 flags; // IN
779 NvU64 semaphoreAddress NV_ALIGN_BYTES(8); // IN
780 NvU32 semaphorePayload; // IN
781 NvS32 cpuNumaNode; // IN
782 NvU64 userSpaceStart NV_ALIGN_BYTES(8); // OUT
783 NvU64 userSpaceLength NV_ALIGN_BYTES(8); // OUT
784 NV_STATUS rmStatus; // OUT
785} UVM_MIGRATE_PARAMS;
786
787#define UVM_MIGRATE_RANGE_GROUP UVM_IOCTL_BASE(53)
788typedef struct
789{
790 NvU64 rangeGroupId NV_ALIGN_BYTES(8); // IN
791 NvProcessorUuid destinationUuid; // IN
792 NV_STATUS rmStatus; // OUT
793} UVM_MIGRATE_RANGE_GROUP_PARAMS;
794
795//
796// UvmEnableSystemWideAtomics
797//
798#define UVM_ENABLE_SYSTEM_WIDE_ATOMICS UVM_IOCTL_BASE(54)
799
800typedef struct
801{
802 NvProcessorUuid gpu_uuid; // IN
803 NV_STATUS rmStatus; // OUT
804} UVM_ENABLE_SYSTEM_WIDE_ATOMICS_PARAMS;
805
806//
807// UvmDisableSystemWideAtomics
808//
809#define UVM_DISABLE_SYSTEM_WIDE_ATOMICS UVM_IOCTL_BASE(55)
810
811typedef struct
812{
813 NvProcessorUuid gpu_uuid; // IN
814 NV_STATUS rmStatus; // OUT
815} UVM_DISABLE_SYSTEM_WIDE_ATOMICS_PARAMS;
816
817//
818// Initialize any tracker object such as a queue or counter
819// UvmToolsCreateEventQueue, UvmToolsCreateProcessAggregateCounters,
820// UvmToolsCreateProcessorCounters.
821//
822#define UVM_TOOLS_INIT_EVENT_TRACKER UVM_IOCTL_BASE(56)
823typedef struct
824{
825 NvU64 queueBuffer NV_ALIGN_BYTES(8); // IN
826 NvU64 queueBufferSize NV_ALIGN_BYTES(8); // IN
827 NvU64 controlBuffer NV_ALIGN_BYTES(8); // IN
828 NvProcessorUuid processor; // IN
829 NvU32 allProcessors; // IN
830 NvU32 uvmFd; // IN
831 NV_STATUS rmStatus; // OUT
832} UVM_TOOLS_INIT_EVENT_TRACKER_PARAMS;
833
834//
835// UvmToolsSetNotificationThreshold
836//
837#define UVM_TOOLS_SET_NOTIFICATION_THRESHOLD UVM_IOCTL_BASE(57)
838typedef struct
839{
840 NvU32 notificationThreshold; // IN
841 NV_STATUS rmStatus; // OUT
842} UVM_TOOLS_SET_NOTIFICATION_THRESHOLD_PARAMS;
843
844//
845// UvmToolsEventQueueEnableEvents
846//
847#define UVM_TOOLS_EVENT_QUEUE_ENABLE_EVENTS UVM_IOCTL_BASE(58)
848typedef struct
849{
850 NvU64 eventTypeFlags NV_ALIGN_BYTES(8); // IN
851 NV_STATUS rmStatus; // OUT
852} UVM_TOOLS_EVENT_QUEUE_ENABLE_EVENTS_PARAMS;
853
854//
855// UvmToolsEventQueueDisableEvents
856//
857#define UVM_TOOLS_EVENT_QUEUE_DISABLE_EVENTS UVM_IOCTL_BASE(59)
858typedef struct
859{
860 NvU64 eventTypeFlags NV_ALIGN_BYTES(8); // IN
861 NV_STATUS rmStatus; // OUT
862} UVM_TOOLS_EVENT_QUEUE_DISABLE_EVENTS_PARAMS;
863
864//
865// UvmToolsEnableCounters
866//
867#define UVM_TOOLS_ENABLE_COUNTERS UVM_IOCTL_BASE(60)
868typedef struct
869{
870 NvU64 counterTypeFlags NV_ALIGN_BYTES(8); // IN
871 NV_STATUS rmStatus; // OUT
872} UVM_TOOLS_ENABLE_COUNTERS_PARAMS;
873
874//
875// UvmToolsDisableCounters
876//
877#define UVM_TOOLS_DISABLE_COUNTERS UVM_IOCTL_BASE(61)
878typedef struct
879{
880 NvU64 counterTypeFlags NV_ALIGN_BYTES(8); // IN
881 NV_STATUS rmStatus; // OUT
882} UVM_TOOLS_DISABLE_COUNTERS_PARAMS;
883
884//
885// UvmToolsReadProcessMemory
886//
887#define UVM_TOOLS_READ_PROCESS_MEMORY UVM_IOCTL_BASE(62)
888typedef struct
889{
890 NvU64 buffer NV_ALIGN_BYTES(8); // IN
891 NvU64 size NV_ALIGN_BYTES(8); // IN
892 NvU64 targetVa NV_ALIGN_BYTES(8); // IN
893 NvU64 bytesRead NV_ALIGN_BYTES(8); // OUT
894 NV_STATUS rmStatus; // OUT
895} UVM_TOOLS_READ_PROCESS_MEMORY_PARAMS;
896
897//
898// UvmToolsWriteProcessMemory
899//
900#define UVM_TOOLS_WRITE_PROCESS_MEMORY UVM_IOCTL_BASE(63)
901typedef struct
902{
903 NvU64 buffer NV_ALIGN_BYTES(8); // IN
904 NvU64 size NV_ALIGN_BYTES(8); // IN
905 NvU64 targetVa NV_ALIGN_BYTES(8); // IN
906 NvU64 bytesWritten NV_ALIGN_BYTES(8); // OUT
907 NV_STATUS rmStatus; // OUT
908} UVM_TOOLS_WRITE_PROCESS_MEMORY_PARAMS;
909
910//
911// UvmToolsGetProcessorUuidTable
912//
913#define UVM_TOOLS_GET_PROCESSOR_UUID_TABLE UVM_IOCTL_BASE(64)
914typedef struct
915{
916 NvU64 tablePtr NV_ALIGN_BYTES(8); // IN
917 NV_STATUS rmStatus; // OUT
918} UVM_TOOLS_GET_PROCESSOR_UUID_TABLE_PARAMS;
919
920//
921// UvmMapDynamicParallelismRegion
922//
923#define UVM_MAP_DYNAMIC_PARALLELISM_REGION UVM_IOCTL_BASE(65)
924typedef struct
925{
926 NvU64 base NV_ALIGN_BYTES(8); // IN
927 NvU64 length NV_ALIGN_BYTES(8); // IN
928 NvProcessorUuid gpuUuid; // IN
929 NV_STATUS rmStatus; // OUT
930} UVM_MAP_DYNAMIC_PARALLELISM_REGION_PARAMS;
931
932//
933// UvmUnmapExternal
934//
935#define UVM_UNMAP_EXTERNAL UVM_IOCTL_BASE(66)
936typedef struct
937{
938 NvU64 base NV_ALIGN_BYTES(8); // IN
939 NvU64 length NV_ALIGN_BYTES(8); // IN
940 NvProcessorUuid gpuUuid; // IN
941 NV_STATUS rmStatus; // OUT
942} UVM_UNMAP_EXTERNAL_PARAMS;
943
944
945//
946// UvmToolsFlushEvents
947//
948#define UVM_TOOLS_FLUSH_EVENTS UVM_IOCTL_BASE(67)
949typedef struct
950{
951 NV_STATUS rmStatus; // OUT
952} UVM_TOOLS_FLUSH_EVENTS_PARAMS;
953
954//
955// UvmAllocSemaphorePool
956//
957#define UVM_ALLOC_SEMAPHORE_POOL UVM_IOCTL_BASE(68)
958typedef struct
959{
960 NvU64 base NV_ALIGN_BYTES(8); // IN
961 NvU64 length NV_ALIGN_BYTES(8); // IN
962 UvmGpuMappingAttributes perGpuAttributes[UVM_MAX_GPUS]; // IN
963 NvU64 gpuAttributesCount NV_ALIGN_BYTES(8); // IN
964 NV_STATUS rmStatus; // OUT
965} UVM_ALLOC_SEMAPHORE_POOL_PARAMS;
966
967//
968// UvmCleanUpZombieResources
969//
970#define UVM_CLEAN_UP_ZOMBIE_RESOURCES UVM_IOCTL_BASE(69)
971typedef struct
972{
973 NV_STATUS rmStatus; // OUT
974} UVM_CLEAN_UP_ZOMBIE_RESOURCES_PARAMS;
975
976//
977// UvmIsPageableMemoryAccessSupportedOnGpu
978//
979#define UVM_PAGEABLE_MEM_ACCESS_ON_GPU UVM_IOCTL_BASE(70)
980
981typedef struct
982{
983 NvProcessorUuid gpu_uuid; // IN
984 NvBool pageableMemAccess; // OUT
985 NV_STATUS rmStatus; // OUT
986} UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS;
987
988//
989// UvmPopulatePageable
990//
991#define UVM_POPULATE_PAGEABLE UVM_IOCTL_BASE(71)
992
993// Allow population of managed ranges. The goal is to validate that it is
994// possible to populate pageable ranges backed by VMAs with the VM_MIXEDMAP or
995// VM_DONTEXPAND special flags set. But since there is no portable way to force
996// allocation of such memory from user space, and it is not safe to change the
997// flags of an already-created VMA from kernel space, we take advantage of the
998// fact that managed ranges have both special flags set at creation time (see
999// uvm_mmap).
1000#define UVM_POPULATE_PAGEABLE_FLAG_ALLOW_MANAGED 0x00000001
1001
1002// By default UVM_POPULATE_PAGEABLE returns an error if the destination vma
1003// does not have read permission. This flag skips that check.
1004#define UVM_POPULATE_PAGEABLE_FLAG_SKIP_PROT_CHECK 0x00000002
1005
1006// By default UVM_POPULATE_PAGEABLE returns an error if the destination vma
1007// is VM_IO or VM_PFNMAP. This flag skips that check.
1008#define UVM_POPULATE_PAGEABLE_FLAG_ALLOW_SPECIAL 0x00000004
1009
1010// These flags are used internally within the driver and are not allowed from
1011// user space.
1012#define UVM_POPULATE_PAGEABLE_FLAGS_INTERNAL UVM_POPULATE_PAGEABLE_FLAG_ALLOW_SPECIAL
1013
1014// These flags are allowed from user space only when builtin tests are enabled.
1015// Some of them may also be used internally within the driver in non-test use
1016// cases.
1017#define UVM_POPULATE_PAGEABLE_FLAGS_TEST (UVM_POPULATE_PAGEABLE_FLAG_ALLOW_MANAGED | \
1018 UVM_POPULATE_PAGEABLE_FLAG_SKIP_PROT_CHECK)
1019
1020#define UVM_POPULATE_PAGEABLE_FLAGS_ALL (UVM_POPULATE_PAGEABLE_FLAGS_INTERNAL | \
1021 UVM_POPULATE_PAGEABLE_FLAGS_TEST)
1022
1023typedef struct
1024{
1025 NvU64 base NV_ALIGN_BYTES(8); // IN
1026 NvU64 length NV_ALIGN_BYTES(8); // IN
1027 NvU32 flags; // IN
1028 NV_STATUS rmStatus; // OUT
1029} UVM_POPULATE_PAGEABLE_PARAMS;
1030
1031//
1032// UvmValidateVaRange
1033//
1034#define UVM_VALIDATE_VA_RANGE UVM_IOCTL_BASE(72)
1035typedef struct
1036{
1037 NvU64 base NV_ALIGN_BYTES(8); // IN
1038 NvU64 length NV_ALIGN_BYTES(8); // IN
1039 NV_STATUS rmStatus; // OUT
1040} UVM_VALIDATE_VA_RANGE_PARAMS;
1041
1042#define UVM_CREATE_EXTERNAL_RANGE UVM_IOCTL_BASE(73)
1043typedef struct
1044{
1045 NvU64 base NV_ALIGN_BYTES(8); // IN
1046 NvU64 length NV_ALIGN_BYTES(8); // IN
1047 NV_STATUS rmStatus; // OUT
1048} UVM_CREATE_EXTERNAL_RANGE_PARAMS;
1049
1050#define UVM_MAP_EXTERNAL_SPARSE UVM_IOCTL_BASE(74)
1051typedef struct
1052{
1053 NvU64 base NV_ALIGN_BYTES(8); // IN
1054 NvU64 length NV_ALIGN_BYTES(8); // IN
1055 NvProcessorUuid gpuUuid; // IN
1056 NV_STATUS rmStatus; // OUT
1057} UVM_MAP_EXTERNAL_SPARSE_PARAMS;
1058
1059//
1060// Used to initialise a secondary UVM file-descriptor which holds a
1061// reference on the memory map to prevent it being torn down without
1062// first notifying UVM. This is achieved by preventing mmap() calls on
1063// the secondary file-descriptor so that on process exit
1064// uvm_mm_release() will be called while the memory map is present
1065// such that UVM can cleanly shutdown the GPU by handling faults
1066// instead of cancelling them.
1067//
1068// This ioctl must be called after the primary file-descriptor has
1069// been initialised with the UVM_INITIALIZE ioctl. The primary FD
1070// should be passed in the uvmFd field and the UVM_MM_INITIALIZE ioctl
1071// will hold a reference on the primary FD. Therefore uvm_release() is
1072// guaranteed to be called after uvm_mm_release().
1073//
1074// Once this file-descriptor has been closed the UVM context is
1075// effectively dead and subsequent operations requiring a memory map
1076// will fail. Calling UVM_MM_INITIALIZE on a context that has already
1077// been initialized via any FD will return NV_ERR_INVALID_STATE.
1078//
1079// Calling this with a non-UVM file-descriptor in uvmFd will return
1080// NV_ERR_INVALID_ARGUMENT. Calling this on the same file-descriptor
1081// as UVM_INITIALIZE or more than once on the same FD will return
1082// NV_ERR_IN_USE.
1083//
1084// Not all platforms require this secondary file-descriptor. On those
1085// platforms NV_WARN_NOTHING_TO_DO will be returned and users may
1086// close the file-descriptor at anytime.
1087#define UVM_MM_INITIALIZE UVM_IOCTL_BASE(75)
1088typedef struct
1089{
1090 NvS32 uvmFd; // IN
1091 NV_STATUS rmStatus; // OUT
1092} UVM_MM_INITIALIZE_PARAMS;
1093
1094#define UVM_TOOLS_INIT_EVENT_TRACKER_V2 UVM_IOCTL_BASE(76)
1095typedef UVM_TOOLS_INIT_EVENT_TRACKER_PARAMS UVM_TOOLS_INIT_EVENT_TRACKER_V2_PARAMS;
1096
1097#define UVM_TOOLS_GET_PROCESSOR_UUID_TABLE_V2 UVM_IOCTL_BASE(77)
1098typedef UVM_TOOLS_GET_PROCESSOR_UUID_TABLE_PARAMS UVM_TOOLS_GET_PROCESSOR_UUID_TABLE_V2_PARAMS;
1099
1100//
1101// UvmAllocDeviceP2P
1102//
1103#define UVM_ALLOC_DEVICE_P2P UVM_IOCTL_BASE(78)
1104typedef struct
1105{
1106 NvU64 base NV_ALIGN_BYTES(8); // IN
1107 NvU64 length NV_ALIGN_BYTES(8); // IN
1108 NvU64 offset NV_ALIGN_BYTES(8); // IN
1109 NvProcessorUuid gpuUuid; // IN
1110 NvS32 rmCtrlFd; // IN
1111 NvU32 hClient; // IN
1112 NvU32 hMemory; // IN
1113
1114 NV_STATUS rmStatus; // OUT
1115} UVM_ALLOC_DEVICE_P2P_PARAMS;
1116
1117#define UVM_CLEAR_ALL_ACCESS_COUNTERS UVM_IOCTL_BASE(79)
1118
1119typedef struct
1120{
1121 NV_STATUS rmStatus; // OUT
1122} UVM_CLEAR_ALL_ACCESS_COUNTERS_PARAMS;
1123
1124//
1125// UvmDiscard
1126//
1127#define UVM_DISCARD UVM_IOCTL_BASE(80)
1128typedef struct
1129{
1130 NvU64 base NV_ALIGN_BYTES(8); // IN
1131 NvU64 length; // IN
1132 NvU64 flags; // IN
1133 NV_STATUS rmStatus; // OUT
1134} UVM_DISCARD_PARAMS;
1135
1136//
1137// Temporary ioctls which should be removed before UVM 8 release
1138// Number backwards from 2047 - highest custom ioctl function number
1139// windows can handle.
1140//
1141
1142//
1143// UvmIs8Supported
1144//
1145#define UVM_IS_8_SUPPORTED UVM_IOCTL_BASE(2047)
1146
1147typedef struct
1148{
1149 NvU32 is8Supported; // OUT
1150 NV_STATUS rmStatus; // OUT
1151} UVM_IS_8_SUPPORTED_PARAMS;
1152
1153#ifdef __cplusplus
1154}
1155#endif
1156
1157#endif // _UVM_IOCTL_H