-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
nv_uvm_interface.h
1761 lines (1416 loc) · 77.9 KB
/
nv_uvm_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* SPDX-FileCopyrightText: Copyright (c) 2013-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
//
// This file provides the interface that RM exposes to UVM.
//
#ifndef _NV_UVM_INTERFACE_H_
#define _NV_UVM_INTERFACE_H_
// Forward references, to break circular header file dependencies:
struct UvmOpsUvmEvents;
#if defined(NVIDIA_UVM_ENABLED)
// We are in the UVM build system, for a Linux target.
#include "uvm_linux.h"
#else
// We are in the RM build system, for a Linux target:
#include "nv-linux.h"
#endif // NVIDIA_UVM_ENABLED
#include "nvgputypes.h"
#include "nvstatus.h"
#include "nv_uvm_types.h"
// Define the type here as it's Linux specific, used only by the Linux specific
// nvUvmInterfaceRegisterGpu() API.
typedef struct
{
struct pci_dev *pci_dev;
// DMA addressable range of the device, mirrors fields in nv_state_t.
NvU64 dma_addressable_start;
NvU64 dma_addressable_limit;
} UvmGpuPlatformInfo;
/*******************************************************************************
nvUvmInterfaceRegisterGpu
Registers the GPU with the provided physical UUID for use. A GPU must be
registered before its UUID can be used with any other API. This call is
ref-counted so every nvUvmInterfaceRegisterGpu must be paired with a
corresponding nvUvmInterfaceUnregisterGpu.
You don't need to call nvUvmInterfaceSessionCreate before calling this.
Error codes:
NV_ERR_GPU_UUID_NOT_FOUND
NV_ERR_NO_MEMORY
NV_ERR_GENERIC
*/
NV_STATUS nvUvmInterfaceRegisterGpu(const NvProcessorUuid *gpuUuid, UvmGpuPlatformInfo *gpuInfo);
/*******************************************************************************
nvUvmInterfaceUnregisterGpu
Unregisters the GPU with the provided physical UUID. This drops the ref
count from nvUvmInterfaceRegisterGpu. Once the reference count goes to 0
the device may no longer be accessible until the next
nvUvmInterfaceRegisterGpu call. No automatic resource freeing is performed,
so only make the last unregister call after destroying all your allocations
associated with that UUID (such as those from
nvUvmInterfaceAddressSpaceCreate).
If the UUID is not found, no operation is performed.
*/
void nvUvmInterfaceUnregisterGpu(const NvProcessorUuid *gpuUuid);
/*******************************************************************************
nvUvmInterfaceSessionCreate
TODO: Creates session object. All allocations are tied to the session.
The platformInfo parameter is filled by the callee with miscellaneous system
information. Refer to the UvmPlatformInfo struct for details.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
*/
NV_STATUS nvUvmInterfaceSessionCreate(uvmGpuSessionHandle *session,
UvmPlatformInfo *platformInfo);
/*******************************************************************************
nvUvmInterfaceSessionDestroy
Destroys a session object. All allocations are tied to the session will
be destroyed.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
*/
NV_STATUS nvUvmInterfaceSessionDestroy(uvmGpuSessionHandle session);
/*******************************************************************************
nvUvmInterfaceDeviceCreate
Creates a device object under the given session for the GPU with the given
physical UUID. Also creates a partition object for the device iff
bCreateSmcPartition is true and pGpuInfo->smcEnabled is true.
pGpuInfo->smcUserClientInfo will be used to determine the SMC partition in
this case. A device handle is returned in the device output parameter.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
NV_ERR_INVALID_ARGUMENT
NV_ERR_INSUFFICIENT_RESOURCES
NV_ERR_OBJECT_NOT_FOUND
*/
NV_STATUS nvUvmInterfaceDeviceCreate(uvmGpuSessionHandle session,
const UvmGpuInfo *pGpuInfo,
const NvProcessorUuid *gpuUuid,
uvmGpuDeviceHandle *device,
NvBool bCreateSmcPartition);
/*******************************************************************************
nvUvmInterfaceDeviceDestroy
Destroys the device object for the given handle. The handle must have been
obtained in a prior call to nvUvmInterfaceDeviceCreate.
*/
void nvUvmInterfaceDeviceDestroy(uvmGpuDeviceHandle device);
/*******************************************************************************
nvUvmInterfaceAddressSpaceCreate
This function creates an address space.
This virtual address space is created on the GPU specified
by device.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
*/
NV_STATUS nvUvmInterfaceAddressSpaceCreate(uvmGpuDeviceHandle device,
unsigned long long vaBase,
unsigned long long vaSize,
NvBool enableAts,
uvmGpuAddressSpaceHandle *vaSpace,
UvmGpuAddressSpaceInfo *vaSpaceInfo);
/*******************************************************************************
nvUvmInterfaceDupAddressSpace
This function will dup the given vaspace from the users client to the
kernel client was created as an ops session.
By duping the vaspace it is guaranteed that RM will refcount the vaspace object.
Error codes:
NV_ERR_GENERIC
*/
NV_STATUS nvUvmInterfaceDupAddressSpace(uvmGpuDeviceHandle device,
NvHandle hUserClient,
NvHandle hUserVASpace,
uvmGpuAddressSpaceHandle *vaSpace,
UvmGpuAddressSpaceInfo *vaSpaceInfo);
/*******************************************************************************
nvUvmInterfaceAddressSpaceDestroy
Destroys an address space that was previously created via
nvUvmInterfaceAddressSpaceCreate.
*/
void nvUvmInterfaceAddressSpaceDestroy(uvmGpuAddressSpaceHandle vaSpace);
/*******************************************************************************
nvUvmInterfaceMemoryAllocFB
This function will allocate video memory and provide a mapped Gpu
virtual address to this allocation. It also returns the Gpu physical
offset if contiguous allocations are requested.
This function will allocate a minimum page size if the length provided is 0
and will return a unique GPU virtual address.
The default page size will be the small page size (as returned by query
caps). The physical alignment will also be enforced to small page
size(64K/128K).
Arguments:
vaSpace[IN] - Pointer to vaSpace object
length [IN] - Length of the allocation
gpuPointer[OUT] - GPU VA mapping
allocInfo[IN/OUT] - Pointer to allocation info structure which
contains below given fields
allocInfo Members:
gpuPhysOffset[OUT] - Physical offset of allocation returned only
if contiguous allocation is requested.
pageSize[IN] - Override the default page size (see above).
alignment[IN] - gpuPointer GPU VA alignment. 0 means 4KB
alignment.
bContiguousPhysAlloc[IN] - Flag to request contiguous allocation. Default
will follow the vidHeapControl default policy.
bMemGrowsDown[IN]
bPersistentVidmem[IN] - Allocate persistent vidmem.
hPhysHandle[IN/OUT] - The handle will be used in allocation if provided.
If not provided; allocator will return the handle
it used eventually.
Error codes:
NV_ERR_INVALID_ARGUMENT
NV_ERR_NO_MEMORY - Not enough physical memory to service
allocation request with provided constraints
NV_ERR_INSUFFICIENT_RESOURCES - Not enough available resources to satisfy allocation request
NV_ERR_INVALID_OWNER - Target memory not accessible by specified owner
NV_ERR_NOT_SUPPORTED - Operation not supported on broken FB
*/
NV_STATUS nvUvmInterfaceMemoryAllocFB(uvmGpuAddressSpaceHandle vaSpace,
NvLength length,
UvmGpuPointer * gpuPointer,
UvmGpuAllocInfo * allocInfo);
/*******************************************************************************
nvUvmInterfaceMemoryAllocSys
This function will allocate system memory and provide a mapped Gpu
virtual address to this allocation.
This function will allocate a minimum page size if the length provided is 0
and will return a unique GPU virtual address.
The default page size will be the small page size (as returned by query caps)
Arguments:
vaSpace[IN] - Pointer to vaSpace object
length [IN] - Length of the allocation
gpuPointer[OUT] - GPU VA mapping
allocInfo[IN/OUT] - Pointer to allocation info structure which
contains below given fields
allocInfo Members:
gpuPhysOffset[OUT] - Physical offset of allocation returned only
if contiguous allocation is requested.
pageSize[IN] - Override the default page size (see above).
alignment[IN] - gpuPointer GPU VA alignment. 0 means 4KB
alignment.
bContiguousPhysAlloc[IN] - Flag to request contiguous allocation. Default
will follow the vidHeapControl default policy.
bMemGrowsDown[IN]
bPersistentVidmem[IN] - Allocate persistent vidmem.
hPhysHandle[IN/OUT] - The handle will be used in allocation if provided.
If not provided; allocator will return the handle
it used eventually.
Error codes:
NV_ERR_INVALID_ARGUMENT
NV_ERR_NO_MEMORY - Not enough physical memory to service
allocation request with provided constraints
NV_ERR_INSUFFICIENT_RESOURCES - Not enough available resources to satisfy allocation request
NV_ERR_INVALID_OWNER - Target memory not accessible by specified owner
NV_ERR_NOT_SUPPORTED - Operation not supported
*/
NV_STATUS nvUvmInterfaceMemoryAllocSys(uvmGpuAddressSpaceHandle vaSpace,
NvLength length,
UvmGpuPointer * gpuPointer,
UvmGpuAllocInfo * allocInfo);
/*******************************************************************************
nvUvmInterfaceGetP2PCaps
Obtain the P2P capabilities between two devices.
Arguments:
device1[IN] - Device handle of the first GPU (required)
device2[IN] - Device handle of the second GPU (required)
p2pCapsParams [OUT] - P2P capabilities between the two GPUs
Error codes:
NV_ERR_INVALID_ARGUMENT
NV_ERR_GENERIC:
Unexpected error. We try hard to avoid returning this error
code,because it is not very informative.
*/
NV_STATUS nvUvmInterfaceGetP2PCaps(uvmGpuDeviceHandle device1,
uvmGpuDeviceHandle device2,
UvmGpuP2PCapsParams * p2pCapsParams);
/*******************************************************************************
nvUvmInterfaceGetPmaObject
This function will return pointer to PMA object for the given GPU. This
PMA object handle is required for page allocation.
Arguments:
device [IN] - Device handle allocated in
nvUvmInterfaceDeviceCreate
pPma [OUT] - Pointer to PMA object
pPmaPubStats [OUT] - Pointer to UvmPmaStatistics object
Error codes:
NV_ERR_NOT_SUPPORTED - Operation not supported on broken FB
NV_ERR_GENERIC:
Unexpected error. We try hard to avoid returning this error
code,because it is not very informative.
*/
NV_STATUS nvUvmInterfaceGetPmaObject(uvmGpuDeviceHandle device,
void **pPma,
const UvmPmaStatistics **pPmaPubStats);
// Mirrors pmaEvictPagesCb_t, see its documentation in pma.h.
typedef NV_STATUS (*uvmPmaEvictPagesCallback)(void *callbackData,
NvU64 pageSize,
NvU64 *pPages,
NvU32 count,
NvU64 physBegin,
NvU64 physEnd,
UVM_PMA_GPU_MEMORY_TYPE mem_type);
// Mirrors pmaEvictRangeCb_t, see its documentation in pma.h.
typedef NV_STATUS (*uvmPmaEvictRangeCallback)(void *callbackData,
NvU64 physBegin,
NvU64 physEnd,
UVM_PMA_GPU_MEMORY_TYPE mem_type);
/*******************************************************************************
nvUvmInterfacePmaRegisterEvictionCallbacks
Simple wrapper for pmaRegisterEvictionCb(), see its documentation in pma.h.
*/
NV_STATUS nvUvmInterfacePmaRegisterEvictionCallbacks(void *pPma,
uvmPmaEvictPagesCallback evictPages,
uvmPmaEvictRangeCallback evictRange,
void *callbackData);
/******************************************************************************
nvUvmInterfacePmaUnregisterEvictionCallbacks
Simple wrapper for pmaUnregisterEvictionCb(), see its documentation in pma.h.
*/
void nvUvmInterfacePmaUnregisterEvictionCallbacks(void *pPma);
/*******************************************************************************
nvUvmInterfacePmaAllocPages
@brief Synchronous API for allocating pages from the PMA.
PMA will decide which pma regions to allocate from based on the provided
flags. PMA will also initiate UVM evictions to make room for this
allocation unless prohibited by PMA_FLAGS_DONT_EVICT. UVM callers must pass
this flag to avoid deadlock. Only UVM may allocated unpinned memory from
this API.
For broadcast methods, PMA will guarantee the same physical frames are
allocated on multiple GPUs, specified by the PMA objects passed in.
If allocation is contiguous, only one page in pPages will be filled.
Also, contiguous flag must be passed later to nvUvmInterfacePmaFreePages.
Arguments:
pPma[IN] - Pointer to PMA object
pageCount [IN] - Number of pages required to be allocated.
pageSize [IN] - 64kb, 128kb or 2mb. No other values are permissible.
pPmaAllocOptions[IN] - Pointer to PMA allocation info structure.
pPages[OUT] - Array of pointers, containing the PA base
address of each page.
Error codes:
NV_ERR_NO_MEMORY:
Internal memory allocation failed.
NV_ERR_GENERIC:
Unexpected error. We try hard to avoid returning this error
code,because it is not very informative.
*/
NV_STATUS nvUvmInterfacePmaAllocPages(void *pPma,
NvLength pageCount,
NvU64 pageSize,
UvmPmaAllocationOptions *pPmaAllocOptions,
NvU64 *pPages);
/*******************************************************************************
nvUvmInterfacePmaPinPages
This function will pin the physical memory allocated using PMA. The pages
passed as input must be unpinned else this function will return an error and
rollback any change if any page is not previously marked "unpinned".
Arguments:
pPma[IN] - Pointer to PMA object.
pPages[IN] - Array of pointers, containing the PA base
address of each page to be pinned.
pageCount [IN] - Number of pages required to be pinned.
pageSize [IN] - Page size of each page to be pinned.
flags [IN] - UVM_PMA_CALLED_FROM_PMA_EVICTION if called from
PMA eviction, 0 otherwise.
Error codes:
NV_ERR_INVALID_ARGUMENT - Invalid input arguments.
NV_ERR_GENERIC - Unexpected error. We try hard to avoid
returning this error code as is not very
informative.
NV_ERR_NOT_SUPPORTED - Operation not supported on broken FB
*/
NV_STATUS nvUvmInterfacePmaPinPages(void *pPma,
NvU64 *pPages,
NvLength pageCount,
NvU64 pageSize,
NvU32 flags);
/*******************************************************************************
nvUvmInterfaceMemoryFree
Free up a GPU allocation
*/
void nvUvmInterfaceMemoryFree(uvmGpuAddressSpaceHandle vaSpace,
UvmGpuPointer gpuPointer);
/*******************************************************************************
nvUvmInterfacePmaFreePages
This function will free physical memory allocated using PMA. It marks a list
of pages as free. This operation is also used by RM to mark pages as "scrubbed"
for the initial ECC sweep. This function does not fail.
When allocation was contiguous, an appropriate flag needs to be passed.
Arguments:
pPma[IN] - Pointer to PMA object
pPages[IN] - Array of pointers, containing the PA base
address of each page.
pageCount [IN] - Number of pages required to be allocated.
pageSize [IN] - Page size of each page
flags [IN] - Flags with information about allocation type
with the same meaning as flags in options for
nvUvmInterfacePmaAllocPages. When called from PMA
eviction, UVM_PMA_CALLED_FROM_PMA_EVICTION needs
to be added to flags.
Error codes:
NV_ERR_INVALID_ARGUMENT
NV_ERR_NO_MEMORY - Not enough physical memory to service
allocation request with provided constraints
NV_ERR_INSUFFICIENT_RESOURCES - Not enough available resources to satisfy allocation request
NV_ERR_INVALID_OWNER - Target memory not accessible by specified owner
NV_ERR_NOT_SUPPORTED - Operation not supported on broken FB
*/
void nvUvmInterfacePmaFreePages(void *pPma,
NvU64 *pPages,
NvLength pageCount,
NvU64 pageSize,
NvU32 flags);
/*******************************************************************************
nvUvmInterfaceMemoryCpuMap
This function creates a CPU mapping to the provided GPU address.
If the address is not the same as what is returned by the Alloc
function, then the function will map it from the address provided.
This offset will be relative to the gpu offset obtained from the
memory alloc functions.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
*/
NV_STATUS nvUvmInterfaceMemoryCpuMap(uvmGpuAddressSpaceHandle vaSpace,
UvmGpuPointer gpuPointer,
NvLength length, void **cpuPtr,
NvU64 pageSize);
/*******************************************************************************
uvmGpuMemoryCpuUnmap
Unmaps the cpuPtr provided from the process virtual address space.
*/
void nvUvmInterfaceMemoryCpuUnMap(uvmGpuAddressSpaceHandle vaSpace,
void *cpuPtr);
/*******************************************************************************
nvUvmInterfaceTsgAllocate
This function allocates a Time-Slice Group (TSG).
allocParams must contain an engineIndex as TSGs need to be bound to an
engine type at allocation time. The possible values are [0,
UVM_COPY_ENGINE_COUNT_MAX) for CE engine type. Notably only the copy engines
that have UvmGpuCopyEngineCaps::supported set to true can be allocated.
Note that TSG is not supported on all GPU architectures for all engine
types, e.g., pre-Volta GPUs only support TSG for the GR/Compute engine type.
On devices that do not support HW TSGs on the requested engine, this API is
still required, i.e., a TSG handle is required in
nvUvmInterfaceChannelAllocate(), due to information stored in it necessary
for channel allocation. However, when HW TSGs aren't supported, a TSG handle
is essentially a "fake" TSG with no HW scheduling impact.
tsg is filled with the address of the corresponding TSG handle.
Arguments:
vaSpace[IN] - VA space linked to a client and a device under which
the TSG is allocated.
allocParams[IN] - structure with allocation settings.
tsg[OUT] - pointer to the new TSG handle.
Error codes:
NV_ERR_GENERIC
NV_ERR_INVALID_ARGUMENT
NV_ERR_NO_MEMORY
NV_ERR_NOT_SUPPORTED
*/
NV_STATUS nvUvmInterfaceTsgAllocate(uvmGpuAddressSpaceHandle vaSpace,
const UvmGpuTsgAllocParams *allocParams,
uvmGpuTsgHandle *tsg);
/*******************************************************************************
nvUvmInterfaceTsgDestroy
This function destroys a given TSG.
Arguments:
tsg[IN] - Tsg handle
*/
void nvUvmInterfaceTsgDestroy(uvmGpuTsgHandle tsg);
/*******************************************************************************
nvUvmInterfaceChannelAllocate
This function will allocate a channel bound to a copy engine(CE) or a SEC2
engine.
allocParams contains information relative to GPFIFO and GPPut.
channel is filled with the address of the corresponding channel handle.
channelInfo is filled out with channel get/put. The errorNotifier is filled
out when the channel hits an RC error. On Volta+ devices, it also computes
the work submission token and the work submission offset to be used in the
Host channel submission doorbell.
Arguments:
tsg[IN] - Time-Slice Group that the channel will be a member.
allocParams[IN] - structure with allocation settings
channel[OUT] - pointer to the new channel handle
channelInfo[OUT] - structure filled with channel information
Error codes:
NV_ERR_GENERIC
NV_ERR_INVALID_ARGUMENT
NV_ERR_NO_MEMORY
NV_ERR_NOT_SUPPORTED
*/
NV_STATUS nvUvmInterfaceChannelAllocate(const uvmGpuTsgHandle tsg,
const UvmGpuChannelAllocParams *allocParams,
uvmGpuChannelHandle *channel,
UvmGpuChannelInfo *channelInfo);
/*******************************************************************************
nvUvmInterfaceChannelDestroy
This function destroys a given channel.
Arguments:
channel[IN] - channel handle
*/
void nvUvmInterfaceChannelDestroy(uvmGpuChannelHandle channel);
/*******************************************************************************
nvUvmInterfaceQueryCaps
Return capabilities for the provided GPU.
If GPU does not exist, an error will be returned.
If the client is only interested in the capabilities of the Copy Engines of
the given GPU, use nvUvmInterfaceQueryCopyEnginesCaps instead.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
*/
NV_STATUS nvUvmInterfaceQueryCaps(uvmGpuDeviceHandle device,
UvmGpuCaps *caps);
/*******************************************************************************
nvUvmInterfaceQueryCopyEnginesCaps
Return the capabilities of all the Copy Engines for the provided GPU.
If the GPU does not exist, an error will be returned.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
*/
NV_STATUS nvUvmInterfaceQueryCopyEnginesCaps(uvmGpuDeviceHandle device,
UvmGpuCopyEnginesCaps *caps);
/*******************************************************************************
nvUvmInterfaceGetGpuInfo
Return various gpu info, refer to the UvmGpuInfo struct for details.
The input UUID is for the physical GPU and the pGpuClientInfo identifies
the SMC partition if SMC is enabled and the partition exists.
If no gpu matching the uuid is found, an error will be returned.
On Ampere+ GPUs, pGpuClientInfo contains SMC information provided by the
client regarding the partition targeted in this operation.
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
NV_ERR_GPU_UUID_NOT_FOUND
NV_ERR_INSUFFICIENT_PERMISSIONS
NV_ERR_INSUFFICIENT_RESOURCES
*/
NV_STATUS nvUvmInterfaceGetGpuInfo(const NvProcessorUuid *gpuUuid,
const UvmGpuClientInfo *pGpuClientInfo,
UvmGpuInfo *pGpuInfo);
/*******************************************************************************
nvUvmInterfaceServiceDeviceInterruptsRM
Tells RM to service all pending interrupts. This is helpful in ECC error
conditions when ECC error interrupt is set & error can be determined only
after ECC notifier will be set or reset.
Error codes:
NV_ERR_GENERIC
UVM_INVALID_ARGUMENTS
*/
NV_STATUS nvUvmInterfaceServiceDeviceInterruptsRM(uvmGpuDeviceHandle device);
/*******************************************************************************
nvUvmInterfaceSetPageDirectory
Sets pageDirectory in the provided location. Also moves the existing PDE to
the provided pageDirectory.
RM will propagate the update to all channels using the provided VA space.
All channels must be idle when this call is made.
Arguments:
vaSpace[IN} - VASpace Object
physAddress[IN] - Physical address of new page directory
numEntries[IN] - Number of entries including previous PDE which will be copied
bVidMemAperture[IN] - If set pageDirectory will reside in VidMem aperture else sysmem
pasid[IN] - PASID (Process Address Space IDentifier) of the process
corresponding to the VA space. Ignored unless the VA space
object has ATS enabled.
Error codes:
NV_ERR_GENERIC
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceSetPageDirectory(uvmGpuAddressSpaceHandle vaSpace,
NvU64 physAddress, unsigned numEntries,
NvBool bVidMemAperture, NvU32 pasid);
/*******************************************************************************
nvUvmInterfaceUnsetPageDirectory
Unsets/Restores pageDirectory to RM's defined location.
Arguments:
vaSpace[IN} - VASpace Object
Error codes:
NV_ERR_GENERIC
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceUnsetPageDirectory(uvmGpuAddressSpaceHandle vaSpace);
/*******************************************************************************
nvUvmInterfaceDupAllocation
Duplicate the given allocation in a different VA space.
The physical handle backing the source allocation is duplicated in
the GPU device associated with the destination VA space, and a new mapping
is created in that VA space.
The input allocation can be located in sysmem (i.e. allocated using
nvUvmInterfaceMemoryAllocSys) or vidmem (i.e. allocated using
nvUvmInterfaceMemoryAllocFB). If located in vidmem, duplication across
GPUs is not supported.
For duplication of physical memory use nvUvmInterfaceDupMemory.
Arguments:
srcVaSpace[IN] - Source VA space.
srcAddress[IN] - GPU VA in the source VA space. The provided address
should match one previously returned by
nvUvmInterfaceMemoryAllocFB or
nvUvmInterfaceMemoryAllocSys.
dstVaSpace[IN] - Destination VA space where the new mapping will be
created.
dstVaAlignment[IN] - Alignment of the GPU VA in the destination VA
space. 0 means 4KB alignment.
dstAddress[OUT] - Pointer to the GPU VA in the destination VA space.
Error codes:
NV_ERR_INVALID_ARGUMENT - If any of the inputs is invalid, or the source
and destination VA spaces are identical.
NV_ERR_OBJECT_NOT_FOUND - If the input allocation is not found in under
the provided VA space.
NV_ERR_NO_MEMORY - If there is no memory to back the duplicate,
or the associated metadata.
NV_ERR_NOT_SUPPORTED - If trying to duplicate vidmem across GPUs.
*/
NV_STATUS nvUvmInterfaceDupAllocation(uvmGpuAddressSpaceHandle srcVaSpace,
NvU64 srcAddress,
uvmGpuAddressSpaceHandle dstVaSpace,
NvU64 dstVaAlignment,
NvU64 *dstAddress);
/*******************************************************************************
nvUvmInterfaceDupMemory
Duplicates a physical memory allocation. If requested, provides information
about the allocation.
Arguments:
device[IN] - Device linked to a client under which
the phys memory needs to be duped.
hClient[IN] - Client owning the memory.
hPhysMemory[IN] - Phys memory which is to be duped.
hDupedHandle[OUT] - Handle of the duped memory object.
pGpuMemoryInfo[OUT] - see nv_uvm_types.h for more information.
This parameter can be NULL. (optional)
Error codes:
NV_ERR_INVALID_ARGUMENT - If the parameter/s is invalid.
NV_ERR_NOT_SUPPORTED - If the allocation is not a physical allocation.
NV_ERR_OBJECT_NOT_FOUND - If the allocation is not found in under the provided client.
*/
NV_STATUS nvUvmInterfaceDupMemory(uvmGpuDeviceHandle device,
NvHandle hClient,
NvHandle hPhysMemory,
NvHandle *hDupMemory,
UvmGpuMemoryInfo *pGpuMemoryInfo);
/*******************************************************************************
nvUvmInterfaceFreeDupedAllocation
Free the allocation represented by the physical handle used to create the
duped allocation.
Arguments:
device[IN] - Device handle used to dup the memory.
hPhysHandle[IN] - Handle representing the phys allocation.
Error codes:
NV_ERROR
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceFreeDupedHandle(uvmGpuDeviceHandle device,
NvHandle hPhysHandle);
/*******************************************************************************
nvUvmInterfaceGetFbInfo
Gets FB information from RM.
Arguments:
device[IN] - GPU device handle
fbInfo [OUT] - Pointer to FbInfo structure which contains
reservedHeapSize & heapSize
Error codes:
NV_ERROR
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceGetFbInfo(uvmGpuDeviceHandle device,
UvmGpuFbInfo * fbInfo);
/*******************************************************************************
nvUvmInterfaceGetEccInfo
Gets ECC information from RM.
Arguments:
device[IN] - GPU device handle
eccInfo [OUT] - Pointer to EccInfo structure
Error codes:
NV_ERROR
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceGetEccInfo(uvmGpuDeviceHandle device,
UvmGpuEccInfo * eccInfo);
/*******************************************************************************
nvUvmInterfaceOwnPageFaultIntr
This function transfers ownership of the replayable page fault interrupt,
between RM and UVM, for a particular GPU.
bOwnInterrupts == NV_TRUE: UVM is taking ownership from the RM. This causes
the following: RM will not service, enable or disable this interrupt and it
is up to the UVM driver to handle this interrupt. In this case, replayable
page fault interrupts are disabled by this function, before it returns.
bOwnInterrupts == NV_FALSE: UVM is returning ownership to the RM: in this
case, replayable page fault interrupts MUST BE DISABLED BEFORE CALLING this
function.
The cases above both result in transferring ownership of a GPU that has its
replayable page fault interrupts disabled. Doing otherwise would make it
very difficult to control which driver handles any interrupts that build up
during the hand-off.
The calling pattern should look like this:
UVM setting up a new GPU for operation:
UVM GPU LOCK
nvUvmInterfaceOwnPageFaultIntr(..., NV_TRUE)
UVM GPU UNLOCK
Enable replayable page faults for that GPU
UVM tearing down a GPU:
Disable replayable page faults for that GPU
UVM GPU GPU LOCK
nvUvmInterfaceOwnPageFaultIntr(..., NV_FALSE)
UVM GPU UNLOCK
Arguments:
device[IN] - Device handle associated with the gpu
bOwnInterrupts - Set to NV_TRUE for UVM to take ownership of the
replayable page fault interrupts. Set to NV_FALSE
to return ownership of the page fault interrupts
to RM.
Error codes:
NV_ERR_GENERIC
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceOwnPageFaultIntr(uvmGpuDeviceHandle device, NvBool bOwnInterrupts);
/*******************************************************************************
nvUvmInterfaceInitFaultInfo
This function obtains fault buffer address, size and a few register mappings
for replayable faults, and creates a shadow buffer to store non-replayable
faults if the GPU supports it.
Arguments:
device[IN] - Device handle associated with the gpu
pFaultInfo[OUT] - information provided by RM for fault handling
Error codes:
NV_ERR_GENERIC
NV_ERR_NO_MEMORY
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceInitFaultInfo(uvmGpuDeviceHandle device,
UvmGpuFaultInfo *pFaultInfo);
/*******************************************************************************
nvUvmInterfaceDestroyFaultInfo
This function obtains destroys unmaps the fault buffer and clears faultInfo
for replayable faults, and frees the shadow buffer for non-replayable faults.
Arguments:
device[IN] - Device handle associated with the gpu
pFaultInfo[OUT] - information provided by RM for fault handling
Error codes:
NV_ERR_GENERIC
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceDestroyFaultInfo(uvmGpuDeviceHandle device,
UvmGpuFaultInfo *pFaultInfo);
/*******************************************************************************
nvUvmInterfaceHasPendingNonReplayableFaults
This function tells whether there are pending non-replayable faults in the
client shadow fault buffer ready to be consumed.
NOTES:
- This function uses a pre-allocated stack per GPU (stored in the
UvmGpuFaultInfo object) for calls related to non-replayable faults from the
top half.
- Concurrent calls to this function using the same pFaultInfo are not
thread-safe due to pre-allocated stack. Therefore, locking is the caller's
responsibility.
- This function DOES NOT acquire the RM API or GPU locks. That is because
it is called during fault servicing, which could produce deadlocks.
Arguments:
pFaultInfo[IN] - information provided by RM for fault handling.
Contains a pointer to the shadow fault buffer
hasPendingFaults[OUT] - return value that tells if there are
non-replayable faults ready to be consumed by
the client
Error codes:
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceHasPendingNonReplayableFaults(UvmGpuFaultInfo *pFaultInfo,
NvBool *hasPendingFaults);
/*******************************************************************************
nvUvmInterfaceGetNonReplayableFaults
This function consumes all the non-replayable fault packets in the client
shadow fault buffer and copies them to the given buffer. It also returns the
number of faults that have been copied
NOTES:
- This function uses a pre-allocated stack per GPU (stored in the
UvmGpuFaultInfo object) for calls from the bottom half that handles
non-replayable faults.
- See nvUvmInterfaceHasPendingNonReplayableFaults for the implications of
using a shared stack.
- This function DOES NOT acquire the RM API or GPU locks. That is because
it is called during fault servicing, which could produce deadlocks.
Arguments:
pFaultInfo[IN] - information provided by RM for fault handling.
Contains a pointer to the shadow fault buffer
pFaultBuffer[OUT] - buffer provided by the client where fault buffers
are copied when they are popped out of the shadow
fault buffer (which is a circular queue).
numFaults[OUT] - return value that tells the number of faults copied
to the client's buffer
Error codes:
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceGetNonReplayableFaults(UvmGpuFaultInfo *pFaultInfo,
void *pFaultBuffer,
NvU32 *numFaults);
/*******************************************************************************
nvUvmInterfaceFlushReplayableFaultBuffer
This function sends an RPC to GSP in order to flush the HW replayable fault buffer.
NOTES:
- This function DOES NOT acquire the RM API or GPU locks. That is because
it is called during fault servicing, which could produce deadlocks.
- This function should not be called when interrupts are disabled.
Arguments:
pFaultInfo[IN] - information provided by RM for fault handling.
used for obtaining the device handle without locks.
bCopyAndFlush[IN] - Instructs RM to perform the flush in the Copy+Flush mode.
In this mode, RM will perform a copy of the packets from
the HW buffer to UVM's SW buffer as part of performing
the flush. This mode gives UVM the opportunity to observe
the packets contained within the HW buffer at the time
of issuing the call.
Error codes:
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceFlushReplayableFaultBuffer(UvmGpuFaultInfo *pFaultInfo,
NvBool bCopyAndFlush);
/*******************************************************************************
nvUvmInterfaceTogglePrefetchFaults
This function sends an RPC to GSP in order to toggle the prefetch fault PRI.
NOTES:
- This function DOES NOT acquire the RM API or GPU locks. That is because
it is called during fault servicing, which could produce deadlocks.
- This function should not be called when interrupts are disabled.
Arguments:
pFaultInfo[IN] - Information provided by RM for fault handling.
Used for obtaining the device handle without locks.
bEnable[IN] - Instructs RM whether to toggle generating faults on
prefetch on/off.
Error codes:
NV_ERR_INVALID_ARGUMENT
*/
NV_STATUS nvUvmInterfaceTogglePrefetchFaults(UvmGpuFaultInfo *pFaultInfo,
NvBool bEnable);
/*******************************************************************************
nvUvmInterfaceInitAccessCntrInfo
This function obtains access counter buffer address, size and a few register mappings