interplane.Get Omega
Read in your language

physics-mv

FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.

Brought by drakestapleton

branch main Branches Tags History

physics-mv / third_party / nvidia-open-580.173.02 / src / common / sdk / nvidia / inc / nvos.h

3342 lines · 158869 bytes Raw Blame History
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: MIT
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 /***************************************************************************\
25|* *|
26|* NV Architecture Interface *|
27|* *|
28|* <nvos.h> defines the Operating System function and ioctl interfaces to *|
29|* NVIDIA's Unified Media Architecture (TM). *|
30|* *|
31 \***************************************************************************/
32
33#ifndef NVOS_INCLUDED
34#define NVOS_INCLUDED
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include "nvstatus.h"
40
41#include "nvgputypes.h"
42#include "rs_access.h"
43#include "nvcfg_sdk.h"
44
45
46// Temporary include. Please include this directly instead of nvos.h
47#include "alloc/alloc_channel.h"
48
49/* local defines here */
50#define FILE_DEVICE_NV 0x00008000
51#define NV_IOCTL_FCT_BASE 0x00000800
52
53// This is the maximum number of subdevices supported in an SLI
54// configuration.
55#define NVOS_MAX_SUBDEVICES 8
56
57/* Define to indicate the use of Unified status codes - bug 200043705*/
58#define UNIFIED_NV_STATUS 1
59
60 /***************************************************************************\
61|* NV OS Functions *|
62 \***************************************************************************/
63
64/*
65 Result codes for RM APIs, shared for all the APIs
66
67 *** IMPORTANT ***
68
69 Ensure that no NVOS_STATUS value has the highest bit set. That bit
70 is used to passthrough the NVOS_STATUS on code expecting an RM_STATUS.
71*/
72#define NVOS_STATUS NV_STATUS
73
74#define NVOS_STATUS_SUCCESS NV_OK
75#define NVOS_STATUS_ERROR_CARD_NOT_PRESENT NV_ERR_CARD_NOT_PRESENT
76#define NVOS_STATUS_ERROR_DUAL_LINK_INUSE NV_ERR_DUAL_LINK_INUSE
77#define NVOS_STATUS_ERROR_GENERIC NV_ERR_GENERIC
78#define NVOS_STATUS_ERROR_GPU_NOT_FULL_POWER NV_ERR_GPU_NOT_FULL_POWER
79#define NVOS_STATUS_ERROR_ILLEGAL_ACTION NV_ERR_ILLEGAL_ACTION
80#define NVOS_STATUS_ERROR_IN_USE NV_ERR_STATE_IN_USE
81#define NVOS_STATUS_ERROR_INSUFFICIENT_RESOURCES NV_ERR_INSUFFICIENT_RESOURCES
82#define NVOS_STATUS_ERROR_INSUFFICIENT_ZBC_ENTRY NV_ERR_INSUFFICIENT_ZBC_ENTRY
83#define NVOS_STATUS_ERROR_INVALID_ACCESS_TYPE NV_ERR_INVALID_ACCESS_TYPE
84#define NVOS_STATUS_ERROR_INVALID_ARGUMENT NV_ERR_INVALID_ARGUMENT
85#define NVOS_STATUS_ERROR_INVALID_BASE NV_ERR_INVALID_BASE
86#define NVOS_STATUS_ERROR_INVALID_CHANNEL NV_ERR_INVALID_CHANNEL
87#define NVOS_STATUS_ERROR_INVALID_CLASS NV_ERR_INVALID_CLASS
88#define NVOS_STATUS_ERROR_INVALID_CLIENT NV_ERR_INVALID_CLIENT
89#define NVOS_STATUS_ERROR_INVALID_COMMAND NV_ERR_INVALID_COMMAND
90#define NVOS_STATUS_ERROR_INVALID_DATA NV_ERR_INVALID_DATA
91#define NVOS_STATUS_ERROR_INVALID_DEVICE NV_ERR_INVALID_DEVICE
92#define NVOS_STATUS_ERROR_INVALID_DMA_SPECIFIER NV_ERR_INVALID_DMA_SPECIFIER
93#define NVOS_STATUS_ERROR_INVALID_EVENT NV_ERR_INVALID_EVENT
94#define NVOS_STATUS_ERROR_INVALID_FLAGS NV_ERR_INVALID_FLAGS
95#define NVOS_STATUS_ERROR_INVALID_FUNCTION NV_ERR_INVALID_FUNCTION
96#define NVOS_STATUS_ERROR_INVALID_HEAP NV_ERR_INVALID_HEAP
97#define NVOS_STATUS_ERROR_INVALID_INDEX NV_ERR_INVALID_INDEX
98#define NVOS_STATUS_ERROR_INVALID_LIMIT NV_ERR_INVALID_LIMIT
99#define NVOS_STATUS_ERROR_INVALID_METHOD NV_ERR_INVALID_METHOD
100#define NVOS_STATUS_ERROR_INVALID_OBJECT_BUFFER NV_ERR_BUFFER_TOO_SMALL
101#define NVOS_STATUS_ERROR_INVALID_OBJECT_ERROR NV_ERR_INVALID_OBJECT
102#define NVOS_STATUS_ERROR_INVALID_OBJECT_HANDLE NV_ERR_INVALID_OBJECT_HANDLE
103#define NVOS_STATUS_ERROR_INVALID_OBJECT_NEW NV_ERR_INVALID_OBJECT_NEW
104#define NVOS_STATUS_ERROR_INVALID_OBJECT_OLD NV_ERR_INVALID_OBJECT_OLD
105#define NVOS_STATUS_ERROR_INVALID_OBJECT_PARENT NV_ERR_INVALID_OBJECT_PARENT
106#define NVOS_STATUS_ERROR_INVALID_OFFSET NV_ERR_INVALID_OFFSET
107#define NVOS_STATUS_ERROR_INVALID_OWNER NV_ERR_INVALID_OWNER
108#define NVOS_STATUS_ERROR_INVALID_PARAM_STRUCT NV_ERR_INVALID_PARAM_STRUCT
109#define NVOS_STATUS_ERROR_INVALID_PARAMETER NV_ERR_INVALID_PARAMETER
110#define NVOS_STATUS_ERROR_INVALID_POINTER NV_ERR_INVALID_POINTER
111#define NVOS_STATUS_ERROR_INVALID_REGISTRY_KEY NV_ERR_INVALID_REGISTRY_KEY
112#define NVOS_STATUS_ERROR_INVALID_STATE NV_ERR_INVALID_STATE
113#define NVOS_STATUS_ERROR_INVALID_STRING_LENGTH NV_ERR_INVALID_STRING_LENGTH
114#define NVOS_STATUS_ERROR_INVALID_XLATE NV_ERR_INVALID_XLATE
115#define NVOS_STATUS_ERROR_IRQ_NOT_FIRING NV_ERR_IRQ_NOT_FIRING
116#define NVOS_STATUS_ERROR_MULTIPLE_MEMORY_TYPES NV_ERR_MULTIPLE_MEMORY_TYPES
117#define NVOS_STATUS_ERROR_NOT_SUPPORTED NV_ERR_NOT_SUPPORTED
118#define NVOS_STATUS_ERROR_OPERATING_SYSTEM NV_ERR_OPERATING_SYSTEM
119#define NVOS_STATUS_ERROR_LIB_RM_VERSION_MISMATCH NV_ERR_LIB_RM_VERSION_MISMATCH
120#define NVOS_STATUS_ERROR_PROTECTION_FAULT NV_ERR_PROTECTION_FAULT
121#define NVOS_STATUS_ERROR_TIMEOUT NV_ERR_TIMEOUT
122#define NVOS_STATUS_ERROR_TOO_MANY_PRIMARIES NV_ERR_TOO_MANY_PRIMARIES
123#define NVOS_STATUS_ERROR_IRQ_EDGE_TRIGGERED NV_ERR_IRQ_EDGE_TRIGGERED
124#define NVOS_STATUS_ERROR_INVALID_OPERATION NV_ERR_INVALID_OPERATION
125#define NVOS_STATUS_ERROR_NOT_COMPATIBLE NV_ERR_NOT_COMPATIBLE
126#define NVOS_STATUS_ERROR_MORE_PROCESSING_REQUIRED NV_WARN_MORE_PROCESSING_REQUIRED
127#define NVOS_STATUS_ERROR_INSUFFICIENT_PERMISSIONS NV_ERR_INSUFFICIENT_PERMISSIONS
128#define NVOS_STATUS_ERROR_TIMEOUT_RETRY NV_ERR_TIMEOUT_RETRY
129#define NVOS_STATUS_ERROR_NOT_READY NV_ERR_NOT_READY
130#define NVOS_STATUS_ERROR_GPU_IS_LOST NV_ERR_GPU_IS_LOST
131#define NVOS_STATUS_ERROR_IN_FULLCHIP_RESET NV_ERR_GPU_IN_FULLCHIP_RESET
132#define NVOS_STATUS_ERROR_INVALID_LOCK_STATE NV_ERR_INVALID_LOCK_STATE
133#define NVOS_STATUS_ERROR_INVALID_ADDRESS NV_ERR_INVALID_ADDRESS
134#define NVOS_STATUS_ERROR_INVALID_IRQ_LEVEL NV_ERR_INVALID_IRQ_LEVEL
135#define NVOS_STATUS_ERROR_MEMORY_TRAINING_FAILED NV_ERR_MEMORY_TRAINING_FAILED
136#define NVOS_STATUS_ERROR_BUSY_RETRY NV_ERR_BUSY_RETRY
137#define NVOS_STATUS_ERROR_INSUFFICIENT_POWER NV_ERR_INSUFFICIENT_POWER
138#define NVOS_STATUS_ERROR_OBJECT_NOT_FOUND NV_ERR_OBJECT_NOT_FOUND
139#define NVOS_STATUS_ERROR_RESOURCE_LOST NV_ERR_RESOURCE_LOST
140#define NVOS_STATUS_ERROR_BUFFER_TOO_SMALL NV_ERR_BUFFER_TOO_SMALL
141#define NVOS_STATUS_ERROR_RESET_REQUIRED NV_ERR_RESET_REQUIRED
142#define NVOS_STATUS_ERROR_INVALID_REQUEST NV_ERR_INVALID_REQUEST
143
144#define NVOS_STATUS_ERROR_PRIV_SEC_VIOLATION NV_ERR_PRIV_SEC_VIOLATION
145#define NVOS_STATUS_ERROR_GPU_IN_DEBUG_MODE NV_ERR_GPU_IN_DEBUG_MODE
146#define NVOS_STATUS_ERROR_ALREADY_SIGNALLED NV_ERR_ALREADY_SIGNALLED
147
148/*
149 Note:
150 This version of the architecture has been changed to allow the
151 RM to return a client handle that will subsequently used to
152 identify the client. NvAllocRoot() returns the handle. All
153 other functions must specify this client handle.
154
155*/
156/* macro NV01_FREE */
157#define NV01_FREE (0x00000000)
158
159/* NT ioctl data structure */
160typedef struct
161{
162 NvHandle hRoot;
163 NvHandle hObjectParent;
164 NvHandle hObjectOld;
165 NvV32 status;
166} NVOS00_PARAMETERS;
167
168/* valid hClass values. */
169#define NV01_ROOT (0x0U)
170//
171// Redefining it here to maintain consistency with current code
172// This is also defined in class cl0001.h
173//
174#define NV01_ROOT_NON_PRIV (0x00000001)
175
176// Deprecated, please use NV01_ROOT_CLIENT
177#define NV01_ROOT_USER NV01_ROOT_CLIENT
178
179//
180// This will eventually replace NV01_ROOT_USER in RM client code. Please use this
181// RM client object type for any new RM client object allocations that are being
182// added.
183//
184#define NV01_ROOT_CLIENT (0x00000041)
185
186/* macro NV01_ALLOC_MEMORY */
187#define NV01_ALLOC_MEMORY (0x00000002)
188
189/* parameter values */
190#define NVOS02_FLAGS_PHYSICALITY 7:4
191#define NVOS02_FLAGS_PHYSICALITY_CONTIGUOUS (0x00000000)
192#define NVOS02_FLAGS_PHYSICALITY_NONCONTIGUOUS (0x00000001)
193#define NVOS02_FLAGS_LOCATION 11:8
194#define NVOS02_FLAGS_LOCATION_PCI (0x00000000)
195#define NVOS02_FLAGS_LOCATION_VIDMEM (0x00000002)
196#define NVOS02_FLAGS_COHERENCY 15:12
197#define NVOS02_FLAGS_COHERENCY_UNCACHED (0x00000000)
198#define NVOS02_FLAGS_COHERENCY_CACHED (0x00000001)
199#define NVOS02_FLAGS_COHERENCY_WRITE_COMBINE (0x00000002)
200#define NVOS02_FLAGS_COHERENCY_WRITE_THROUGH (0x00000003)
201#define NVOS02_FLAGS_COHERENCY_WRITE_PROTECT (0x00000004)
202#define NVOS02_FLAGS_COHERENCY_WRITE_BACK (0x00000005)
203#define NVOS02_FLAGS_ALLOC 17:16
204#define NVOS02_FLAGS_ALLOC_NONE (0x00000001)
205#define NVOS02_FLAGS_GPU_CACHEABLE 18:18
206#define NVOS02_FLAGS_GPU_CACHEABLE_NO (0x00000000)
207#define NVOS02_FLAGS_GPU_CACHEABLE_YES (0x00000001)
208// If requested, RM will create a kernel mapping of this memory.
209// Default is no map.
210#define NVOS02_FLAGS_KERNEL_MAPPING 19:19
211#define NVOS02_FLAGS_KERNEL_MAPPING_NO_MAP (0x00000000)
212#define NVOS02_FLAGS_KERNEL_MAPPING_MAP (0x00000001)
213#define NVOS02_FLAGS_ALLOC_NISO_DISPLAY 20:20
214#define NVOS02_FLAGS_ALLOC_NISO_DISPLAY_NO (0x00000000)
215#define NVOS02_FLAGS_ALLOC_NISO_DISPLAY_YES (0x00000001)
216
217//
218// If the flag is set, the RM will only allow read-only CPU user mappings to the
219// allocation.
220//
221#define NVOS02_FLAGS_ALLOC_USER_READ_ONLY 21:21
222#define NVOS02_FLAGS_ALLOC_USER_READ_ONLY_NO (0x00000000)
223#define NVOS02_FLAGS_ALLOC_USER_READ_ONLY_YES (0x00000001)
224
225//
226// If the flag is set, the RM will only allow read-only DMA mappings to the
227// allocation.
228//
229#define NVOS02_FLAGS_ALLOC_DEVICE_READ_ONLY 22:22
230#define NVOS02_FLAGS_ALLOC_DEVICE_READ_ONLY_NO (0x00000000)
231#define NVOS02_FLAGS_ALLOC_DEVICE_READ_ONLY_YES (0x00000001)
232
233//
234// If the flag is set, the IO memory allocation can be registered with the RM if
235// the RM regkey peerMappingOverride is set or the client is privileged.
236//
237// See Bug 1630288 "[PeerSync] threat related to GPU.." for more details.
238//
239#define NVOS02_FLAGS_PEER_MAP_OVERRIDE 23:23
240#define NVOS02_FLAGS_PEER_MAP_OVERRIDE_DEFAULT (0x00000000)
241#define NVOS02_FLAGS_PEER_MAP_OVERRIDE_REQUIRED (0x00000001)
242
243// If the flag is set RM will assume the memory pages are of type syncpoint.
244#define NVOS02_FLAGS_ALLOC_TYPE_SYNCPOINT 24:24
245#define NVOS02_FLAGS_ALLOC_TYPE_SYNCPOINT_APERTURE (0x00000001)
246
247//
248// Allow client allocations to go to protected/unprotected video/system memory.
249// When Ampere Protected Model aka APM or Confidential Compute is enabled and
250// DEFAULT flag is set by client, allocations go to protected memory. When
251// protected memory is not enabled, allocations go to unprotected memory.
252// If APM or CC is not enabled, it is a bug for a client to set the PROTECTED
253// flag to YES
254//
255#define NVOS02_FLAGS_MEMORY_PROTECTION 26:25
256#define NVOS02_FLAGS_MEMORY_PROTECTION_DEFAULT (0x00000000)
257#define NVOS02_FLAGS_MEMORY_PROTECTION_PROTECTED (0x00000001)
258#define NVOS02_FLAGS_MEMORY_PROTECTION_UNPROTECTED (0x00000002)
259
260//
261// When allocating memory, register the memory descriptor to GSP-RM
262// so that GSP-RM is aware of and can access it
263//
264#define NVOS02_FLAGS_REGISTER_MEMDESC_TO_PHYS_RM 27:27
265#define NVOS02_FLAGS_REGISTER_MEMDESC_TO_PHYS_RM_FALSE (0x00000000)
266#define NVOS02_FLAGS_REGISTER_MEMDESC_TO_PHYS_RM_TRUE (0x00000001)
267
268//
269// If _NO_MAP is requested, the RM in supported platforms will not map the
270// allocated system or IO memory into user space. The client can later map
271// memory through the RmMapMemory() interface.
272// If _NEVER_MAP is requested, the RM will never map the allocated system or
273// IO memory into user space
274//
275#define NVOS02_FLAGS_MAPPING 31:30
276#define NVOS02_FLAGS_MAPPING_DEFAULT (0x00000000)
277#define NVOS02_FLAGS_MAPPING_NO_MAP (0x00000001)
278#define NVOS02_FLAGS_MAPPING_NEVER_MAP (0x00000002)
279
280// -------------------------------------------------------------------------------------
281
282/* parameters */
283typedef struct
284{
285 NvHandle hRoot;
286 NvHandle hObjectParent;
287 NvHandle hObjectNew;
288 NvV32 hClass;
289 NvV32 flags;
290 NvP64 pMemory NV_ALIGN_BYTES(8);
291 NvU64 limit NV_ALIGN_BYTES(8);
292 NvV32 status;
293} NVOS02_PARAMETERS;
294
295/* parameter values */
296#define NVOS03_FLAGS_ACCESS 1:0
297#define NVOS03_FLAGS_ACCESS_READ_WRITE (0x00000000)
298#define NVOS03_FLAGS_ACCESS_READ_ONLY (0x00000001)
299#define NVOS03_FLAGS_ACCESS_WRITE_ONLY (0x00000002)
300
301#define NVOS03_FLAGS_PREALLOCATE 2:2
302#define NVOS03_FLAGS_PREALLOCATE_DISABLE (0x00000000)
303#define NVOS03_FLAGS_PREALLOCATE_ENABLE (0x00000001)
304
305#define NVOS03_FLAGS_GPU_MAPPABLE 15:15
306#define NVOS03_FLAGS_GPU_MAPPABLE_DISABLE (0x00000000)
307#define NVOS03_FLAGS_GPU_MAPPABLE_ENABLE (0x00000001)
308
309// ------------------------------------------------------------------------------------
310// This flag is required for a hack to be placed inside DD that allows it to
311// access a dummy ctxdma as a block linear surface. Refer bug 1562766 for details.
312//
313// This flag is deprecated, use NVOS03_FLAGS_PTE_KIND.
314//
315#define NVOS03_FLAGS_PTE_KIND_BL_OVERRIDE 16:16
316#define NVOS03_FLAGS_PTE_KIND_BL_OVERRIDE_FALSE (0x00000000)
317#define NVOS03_FLAGS_PTE_KIND_BL_OVERRIDE_TRUE (0x00000001)
318
319/*
320 * This field allows to specify the page kind. If the page kind
321 * is not specified then the page kind associated with the memory will be used.
322 *
323 * In tegra display driver stack, the page kind remains unknown at the time
324 * of memory allocation/import, the page kind can only be known when display
325 * driver client creates a framebuffer from allocated/imported memory.
326 *
327 * This field compatible with NVOS03_FLAGS_PTE_KIND_BL_OVERRIDE flag.
328 */
329#define NVOS03_FLAGS_PTE_KIND 17:16
330#define NVOS03_FLAGS_PTE_KIND_NONE (0x00000000)
331#define NVOS03_FLAGS_PTE_KIND_BL (0x00000001)
332#define NVOS03_FLAGS_PTE_KIND_PITCH (0x00000002)
333
334#define NVOS03_FLAGS_TYPE 23:20
335#define NVOS03_FLAGS_TYPE_NOTIFIER (0x00000001)
336
337/*
338 * This is an alias into the LSB of the TYPE field which
339 * actually indicates if a Kernel Mapping should be created.
340 * If the RM should have access to the memory then Enable this
341 * flag.
342 *
343 * Note that the NV_OS03_FLAGS_MAPPING is an alias to
344 * the LSB of the NV_OS03_FLAGS_TYPE. And in fact if
345 * type is NV_OS03_FLAGS_TYPE_NOTIFIER (bit 20 set)
346 * then it implicitly means that NV_OS03_FLAGS_MAPPING
347 * is _MAPPING_KERNEL. If the client wants to have a
348 * Kernel Mapping, it should use the _MAPPING_KERNEL
349 * flag set and the _TYPE_NOTIFIER should be used only
350 * with NOTIFIERS.
351 */
352
353#define NVOS03_FLAGS_MAPPING 20:20
354#define NVOS03_FLAGS_MAPPING_NONE (0x00000000)
355#define NVOS03_FLAGS_MAPPING_KERNEL (0x00000001)
356
357#define NVOS03_FLAGS_CACHE_SNOOP 28:28
358#define NVOS03_FLAGS_CACHE_SNOOP_ENABLE (0x00000000)
359#define NVOS03_FLAGS_CACHE_SNOOP_DISABLE (0x00000001)
360
361// HASH_TABLE:ENABLE means that the context DMA is automatically bound into all
362// channels in the client. This can lead to excessive hash table usage.
363// HASH_TABLE:DISABLE means that the context DMA must be explicitly bound into
364// any channel that needs to use it via NvRmBindContextDma.
365// HASH_TABLE:ENABLE is not supported on NV50 and up, and HASH_TABLE:DISABLE should
366// be preferred for all new code.
367#define NVOS03_FLAGS_HASH_TABLE 29:29
368#define NVOS03_FLAGS_HASH_TABLE_ENABLE (0x00000000)
369#define NVOS03_FLAGS_HASH_TABLE_DISABLE (0x00000001)
370
371/* macro NV01_ALLOC_OBJECT */
372#define NV01_ALLOC_OBJECT (0x00000005)
373
374/* parameters */
375typedef struct
376{
377 NvHandle hRoot;
378 NvHandle hObjectParent;
379 NvHandle hObjectNew;
380 NvV32 hClass;
381 NvV32 status;
382} NVOS05_PARAMETERS;
383
384/* Valid values for hClass in Nv01AllocEvent */
385/* Note that NV01_EVENT_OS_EVENT is same as NV01_EVENT_WIN32_EVENT */
386/* TODO: delete the WIN32 name */
387#define NV01_EVENT_KERNEL_CALLBACK (0x00000078)
388#define NV01_EVENT_OS_EVENT (0x00000079)
389#define NV01_EVENT_WIN32_EVENT NV01_EVENT_OS_EVENT
390#define NV01_EVENT_KERNEL_CALLBACK_EX (0x0000007E)
391
392/* NOTE: NV01_EVENT_KERNEL_CALLBACK is deprecated. Please use NV01_EVENT_KERNEL_CALLBACK_EX. */
393/* For use with NV01_EVENT_KERNEL_CALLBACK. */
394/* NVOS10_EVENT_KERNEL_CALLBACK data structure storage needs to be retained by the caller. */
395typedef void (*Callback1ArgVoidReturn)(void *arg);
396typedef void (*Callback5ArgVoidReturn)(void *arg1, void *arg2, NvHandle hEvent, NvU32 data, NvU32 status);
397
398/* NOTE: the 'void* arg' below is ok (but unfortunate) since this interface
399 can only be used by other kernel drivers which must share the same ptr-size */
400typedef struct
401{
402 Callback1ArgVoidReturn func;
403 void *arg;
404} NVOS10_EVENT_KERNEL_CALLBACK;
405
406/* For use with NV01_EVENT_KERNEL_CALLBACK_EX. */
407/* NVOS10_EVENT_KERNEL_CALLBACK_EX data structure storage needs to be retained by the caller. */
408/* NOTE: the 'void* arg' below is ok (but unfortunate) since this interface
409 can only be used by other kernel drivers which must share the same ptr-size */
410typedef struct
411{
412 Callback5ArgVoidReturn func;
413 void *arg;
414} NVOS10_EVENT_KERNEL_CALLBACK_EX;
415
416/* Setting this bit in index will set the Event to a Broadcast type */
417/* i.e. each subdevice under a device needs to see the Event before it's signaled */
418#define NV01_EVENT_BROADCAST (0x80000000)
419
420/* allow non-root resman client to create NV01_EVENT_KERNEL_CALLBACK events */
421/* -- this works in debug/develop drivers only (for security reasons)*/
422#define NV01_EVENT_PERMIT_NON_ROOT_EVENT_KERNEL_CALLBACK_CREATION (0x40000000)
423
424/* RM event should be triggered only by the specified subdevice; see cl0005.h
425 * for details re: how to specify subdevice. */
426#define NV01_EVENT_SUBDEVICE_SPECIFIC (0x20000000)
427
428/* RM should trigger the event but shouldn't do the book-keeping of data
429 * associated with that event */
430#define NV01_EVENT_WITHOUT_EVENT_DATA (0x10000000)
431
432/* RM event should be triggered only by the non-stall interrupt */
433#define NV01_EVENT_NONSTALL_INTR (0x08000000)
434
435/* RM event was allocated from client RM, post events back to client RM */
436#define NV01_EVENT_CLIENT_RM (0x04000000)
437
438/* function OS19 */
439#define NV04_I2C_ACCESS (0x00000013)
440
441#define NVOS_I2C_ACCESS_MAX_BUFFER_SIZE 2048
442
443/* parameters */
444typedef struct
445{
446 NvHandle hClient;
447 NvHandle hDevice;
448 NvU32 paramSize;
449 NvP64 paramStructPtr NV_ALIGN_BYTES(8);
450 NvV32 status;
451} NVOS_I2C_ACCESS_PARAMS;
452
453/* current values for command */
454#define NVOS20_COMMAND_unused0001 0x0001
455#define NVOS20_COMMAND_unused0002 0x0002
456#define NVOS20_COMMAND_STRING_PRINT 0x0003
457
458/* function OS21 */
459#define NV04_ALLOC (0x00000015)
460
461/* parameters */
462typedef struct
463{
464 NvHandle hRoot;
465 NvHandle hObjectParent;
466 NvHandle hObjectNew;
467 NvV32 hClass;
468 NvP64 pAllocParms NV_ALIGN_BYTES(8);
469 NvU32 paramsSize;
470 NvV32 status;
471} NVOS21_PARAMETERS;
472
473#define NVOS64_FLAGS_NONE (0x00000000)
474#define NVOS64_FLAGS_FINN_SERIALIZED (0x00000001)
475
476/* New struct with rights requested */
477typedef struct
478{
479 NvHandle hRoot; // [IN] client handle
480 NvHandle hObjectParent; // [IN] parent handle of new object
481 NvHandle hObjectNew; // [INOUT] new object handle, 0 to generate
482 NvV32 hClass; // [in] class num of new object
483 NvP64 pAllocParms NV_ALIGN_BYTES(8); // [IN] class-specific alloc parameters
484 NvP64 pRightsRequested NV_ALIGN_BYTES(8); // [IN] RS_ACCESS_MASK to request rights, or NULL
485 NvU32 paramsSize; // [IN] Size of alloc params
486 NvU32 flags; // [IN] flags for FINN serialization
487 NvV32 status; // [OUT] status
488} NVOS64_PARAMETERS;
489
490/* RM Alloc header
491 *
492 * Replacement for NVOS21/64_PARAMETERS where embedded pointers are not allowed.
493 * Input layout for RM Alloc user space calls should be
494 *
495 * +--- NVOS62_PARAMETERS ---+--- RM Alloc parameters ---+
496 * +--- NVOS65_PARAMETERS ---+--- Rights Requested ---+--- RM Alloc parameters ---+
497 *
498 * NVOS62_PARAMETERS::paramsSize is the size of RM Alloc parameters
499 * If NVOS65_PARAMETERS::maskSize is 0, Rights Requested will not be present in memory.
500 *
501 */
502typedef struct
503{
504 NvHandle hRoot; // [IN] client handle
505 NvHandle hObjectParent; // [IN] parent handle of the new object
506 NvHandle hObjectNew; // [IN] new object handle
507 NvV32 hClass; // [IN] class num of the new object
508 NvU32 paramSize; // [IN] size in bytes of the RM alloc parameters
509 NvV32 status; // [OUT] status
510} NVOS62_PARAMETERS;
511
512#define NVOS65_PARAMETERS_VERSION_MAGIC 0x77FEF81E
513
514typedef struct
515{
516 NvHandle hRoot; // [IN] client handle
517 NvHandle hObjectParent; // [IN] parent handle of the new object
518 NvHandle hObjectNew; // [INOUT] new object handle, 0 to generate
519 NvV32 hClass; // [IN] class num of the new object
520 NvU32 paramSize; // [IN] size in bytes of the RM alloc parameters
521 NvU32 versionMagic; // [IN] NVOS65_PARAMETERS_VERISON_MAGIC
522 NvU32 maskSize; // [IN] size in bytes of access mask, or 0 if NULL
523 NvV32 status; // [OUT] status
524} NVOS65_PARAMETERS;
525
526/* function OS30 */
527#define NV04_IDLE_CHANNELS (0x0000001E)
528
529/* parameter values */
530#define NVOS30_FLAGS_BEHAVIOR 3:0
531#define NVOS30_FLAGS_BEHAVIOR_SPIN (0x00000000)
532#define NVOS30_FLAGS_BEHAVIOR_SLEEP (0x00000001)
533#define NVOS30_FLAGS_BEHAVIOR_QUERY (0x00000002)
534#define NVOS30_FLAGS_BEHAVIOR_FORCE_BUSY_CHECK (0x00000003)
535#define NVOS30_FLAGS_CHANNEL 7:4
536#define NVOS30_FLAGS_CHANNEL_LIST (0x00000000)
537#define NVOS30_FLAGS_CHANNEL_SINGLE (0x00000001)
538#define NVOS30_FLAGS_IDLE 30:8
539#define NVOS30_FLAGS_IDLE_PUSH_BUFFER (0x00000001)
540#define NVOS30_FLAGS_IDLE_CACHE1 (0x00000002)
541#define NVOS30_FLAGS_IDLE_GRAPHICS (0x00000004)
542#define NVOS30_FLAGS_IDLE_MPEG (0x00000008)
543#define NVOS30_FLAGS_IDLE_MOTION_ESTIMATION (0x00000010)
544#define NVOS30_FLAGS_IDLE_VIDEO_PROCESSOR (0x00000020)
545#define NVOS30_FLAGS_IDLE_MSPDEC (0x00000020)
546#define NVOS30_FLAGS_IDLE_BITSTREAM_PROCESSOR (0x00000040)
547#define NVOS30_FLAGS_IDLE_MSVLD (0x00000040)
548#define NVOS30_FLAGS_IDLE_NVDEC0 NVOS30_FLAGS_IDLE_MSVLD
549#define NVOS30_FLAGS_IDLE_CIPHER_DMA (0x00000080)
550#define NVOS30_FLAGS_IDLE_SEC (0x00000080)
551#define NVOS30_FLAGS_IDLE_CALLBACKS (0x00000100)
552#define NVOS30_FLAGS_IDLE_MSPPP (0x00000200)
553#define NVOS30_FLAGS_IDLE_CE0 (0x00000400)
554#define NVOS30_FLAGS_IDLE_CE1 (0x00000800)
555#define NVOS30_FLAGS_IDLE_CE2 (0x00001000)
556#define NVOS30_FLAGS_IDLE_CE3 (0x00002000)
557#define NVOS30_FLAGS_IDLE_CE4 (0x00004000)
558#define NVOS30_FLAGS_IDLE_CE5 (0x00008000)
559#define NVOS30_FLAGS_IDLE_VIC (0x00010000)
560#define NVOS30_FLAGS_IDLE_MSENC (0x00020000)
561#define NVOS30_FLAGS_IDLE_NVENC0 NVOS30_FLAGS_IDLE_MSENC
562#define NVOS30_FLAGS_IDLE_NVENC1 (0x00040000)
563#define NVOS30_FLAGS_IDLE_NVENC2 (0x00080000)
564#define NVOS30_FLAGS_IDLE_NVJPG (0x00100000)
565#define NVOS30_FLAGS_IDLE_NVDEC1 (0x00200000)
566#define NVOS30_FLAGS_IDLE_NVDEC2 (0x00400000)
567#define NVOS30_FLAGS_IDLE_ACTIVECHANNELS (0x00800000)
568#define NVOS30_FLAGS_IDLE_ALL_ENGINES (NVOS30_FLAGS_IDLE_GRAPHICS | \
569 NVOS30_FLAGS_IDLE_MPEG | \
570 NVOS30_FLAGS_IDLE_MOTION_ESTIMATION | \
571 NVOS30_FLAGS_IDLE_VIDEO_PROCESSOR | \
572 NVOS30_FLAGS_IDLE_BITSTREAM_PROCESSOR | \
573 NVOS30_FLAGS_IDLE_CIPHER_DMA | \
574 NVOS30_FLAGS_IDLE_MSPDEC | \
575 NVOS30_FLAGS_IDLE_NVDEC0 | \
576 NVOS30_FLAGS_IDLE_SEC | \
577 NVOS30_FLAGS_IDLE_MSPPP | \
578 NVOS30_FLAGS_IDLE_CE0 | \
579 NVOS30_FLAGS_IDLE_CE1 | \
580 NVOS30_FLAGS_IDLE_CE2 | \
581 NVOS30_FLAGS_IDLE_CE3 | \
582 NVOS30_FLAGS_IDLE_CE4 | \
583 NVOS30_FLAGS_IDLE_CE5 | \
584 NVOS30_FLAGS_IDLE_NVENC0 | \
585 NVOS30_FLAGS_IDLE_NVENC1 | \
586 NVOS30_FLAGS_IDLE_NVENC2 | \
587 NVOS30_FLAGS_IDLE_VIC | \
588 NVOS30_FLAGS_IDLE_NVJPG | \
589 NVOS30_FLAGS_IDLE_NVDEC1 | \
590 NVOS30_FLAGS_IDLE_NVDEC2)
591#define NVOS30_FLAGS_WAIT_FOR_ELPG_ON 31:31
592#define NVOS30_FLAGS_WAIT_FOR_ELPG_ON_NO (0x00000000)
593#define NVOS30_FLAGS_WAIT_FOR_ELPG_ON_YES (0x00000001)
594
595/* parameters */
596typedef struct
597{
598 NvHandle hClient;
599 NvHandle hDevice;
600 NvHandle hChannel;
601 NvV32 numChannels;
602
603 NvP64 phClients NV_ALIGN_BYTES(8);
604 NvP64 phDevices NV_ALIGN_BYTES(8);
605 NvP64 phChannels NV_ALIGN_BYTES(8);
606
607 NvV32 flags;
608 NvV32 timeout;
609 NvV32 status;
610} NVOS30_PARAMETERS;
611
612/* function OS32 */
613typedef void (*BindResultFunc)(void * pVoid, NvU32 gpuMask, NvU32 bState, NvU32 bResult);
614
615#define NV04_VID_HEAP_CONTROL (0x00000020)
616/*************************************************************************
617************************ New Heap Interface ******************************
618*************************************************************************/
619// NVOS32 Descriptor types
620//
621// NVOS32_DESCRIPTOR_TYPE_OS_DMA_BUF_PTR: The dma-buf object
622// pointer, provided by the linux kernel buffer sharing sub-system.
623// This descriptor can only be used by kernel space rm-clients.
624//
625#define NVOS32_DESCRIPTOR_TYPE_VIRTUAL_ADDRESS 0
626#define NVOS32_DESCRIPTOR_TYPE_OS_PAGE_ARRAY 1
627#define NVOS32_DESCRIPTOR_TYPE_OS_IO_MEMORY 2
628#define NVOS32_DESCRIPTOR_TYPE_OS_PHYS_ADDR 3
629#define NVOS32_DESCRIPTOR_TYPE_OS_FILE_HANDLE 4
630#define NVOS32_DESCRIPTOR_TYPE_OS_DMA_BUF_PTR 5
631#define NVOS32_DESCRIPTOR_TYPE_OS_SGT_PTR 6
632#define NVOS32_DESCRIPTOR_TYPE_KERNEL_VIRTUAL_ADDRESS 7
633// NVOS32 function
634#define NVOS32_FUNCTION_ALLOC_SIZE 2
635#define NVOS32_FUNCTION_FREE 3
636#define NVOS32_FUNCTION_INFO 5
637#define NVOS32_FUNCTION_ALLOC_TILED_PITCH_HEIGHT 6
638#define NVOS32_FUNCTION_ALLOC_SIZE_RANGE 14
639#define NVOS32_FUNCTION_REACQUIRE_COMPR 15
640#define NVOS32_FUNCTION_RELEASE_COMPR 16
641#define NVOS32_FUNCTION_GET_MEM_ALIGNMENT 18
642#define NVOS32_FUNCTION_HW_ALLOC 19
643#define NVOS32_FUNCTION_HW_FREE 20
644#define NVOS32_FUNCTION_ALLOC_OS_DESCRIPTOR 27
645
646typedef struct
647{
648 NvP64 sgt NV_ALIGN_BYTES(8);
649 NvP64 gem NV_ALIGN_BYTES(8);
650} NVOS32_DESCRIPTOR_TYPE_OS_SGT_PTR_PARAMETERS;
651
652// NVOS32 IVC-heap number delimiting value
653#define NVOS32_IVC_HEAP_NUMBER_DONT_ALLOCATE_ON_IVC_HEAP 0 // When IVC heaps are present,
654 // IVC-heap number specified
655 // as part of 'NVOS32_PARAMETERS'
656 // which is less or equal to this
657 // constant indicates that allocation
658 // should not be done on IVC heap.
659 // Explanation of IVC-heap number is
660 // under 'AllocSize' structure below.
661
662typedef struct
663{
664 NvHandle hRoot; // [IN] - root object handle
665 NvHandle hObjectParent; // [IN] - device handle
666 NvU32 function; // [IN] - heap function, see below FUNCTION* defines
667 NvHandle hVASpace; // [IN] - VASpace handle
668 NvS16 ivcHeapNumber; // [IN] - When IVC heaps are present: either 1) number of the IVC heap
669 // shared between two VMs or 2) number indicating that allocation
670 // should not be done on an IVC heap. Values greater than constant
671 // 'NVOS32_IVC_HEAP_NUMBER_DONT_ALLOCATE_ON_IVC_HEAP' define set 1)
672 // and values less or equal to that constant define set 2).
673 // When IVC heaps are present, correct IVC-heap number must be specified.
674 // When IVC heaps are absent, IVC-heap number is diregarded.
675 // RM provides for each VM a bitmask of heaps with each bit
676 // specifying the other peer that can use the partition.
677 // Each bit set to one can be enumerated, such that the bit
678 // with lowest significance is enumerated with one.
679 // 'ivcHeapNumber' parameter specifies this enumeration value.
680 // This value is used to uniquely identify a heap shared between
681 // two particular VMs.
682 // Illustration:
683 // bitmask: 1 1 0 1 0 = 0x1A
684 // possible 'ivcHeapNumber' values: 3, 2, 1
685 NvV32 status; // [OUT] - returned NVOS32* status code, see below STATUS* defines
686 NvU64 total NV_ALIGN_BYTES(8); // [OUT] - returned total size of heap
687 NvU64 free NV_ALIGN_BYTES(8); // [OUT] - returned free space available in heap
688
689 union
690 {
691 // NVOS32_FUNCTION_ALLOC_SIZE
692 struct
693 {
694 NvU32 owner; // [IN] - memory owner ID
695 NvHandle hMemory; // [IN/OUT] - unique memory handle - IN only if MEMORY_HANDLE_PROVIDED is set (otherwise generated)
696 NvU32 type; // [IN] - surface type, see below TYPE* defines
697 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
698 NvU32 attr; // [IN/OUT] - surface attributes requested, and surface attributes allocated
699 NvU32 format; // [IN/OUT] - format requested, and format allocated
700 NvU32 comprCovg; // [IN/OUT] - compr covg requested, and allocated
701 NvU32 zcullCovg; // [OUT] - zcull covg allocated
702 NvU32 partitionStride; // [IN/OUT] - 0 means "RM" chooses
703 NvU32 width; // [IN] - width "hint" used for zcull region allocations
704 NvU32 height; // [IN] - height "hint" used for zcull region allocations
705 NvU64 size NV_ALIGN_BYTES(8); // [IN/OUT] - size of allocation - also returns the actual size allocated
706 NvU64 alignment NV_ALIGN_BYTES(8); // [IN] - requested alignment - NVOS32_ALLOC_FLAGS_ALIGNMENT* must be on
707 NvU64 offset NV_ALIGN_BYTES(8); // [IN/OUT] - desired offset if NVOS32_ALLOC_FLAGS_FIXED_ADDRESS_ALLOCATE is on AND returned offset
708 NvU64 limit NV_ALIGN_BYTES(8); // [OUT] - returned surface limit
709 NvP64 address NV_ALIGN_BYTES(8);// [OUT] - returned address
710 NvU64 rangeBegin NV_ALIGN_BYTES(8); // [IN] - allocated memory will be limited to the range
711 NvU64 rangeEnd NV_ALIGN_BYTES(8); // [IN] - from rangeBegin to rangeEnd, inclusive.
712 NvU32 attr2; // [IN/OUT] - surface attributes requested, and surface attributes allocated
713 NvU32 ctagOffset; // [IN] - comptag offset for this surface (see NVOS32_ALLOC_COMPTAG_OFFSET)
714 NvS32 numaNode; // [IN] - NUMA node from which memory should be allocated
715 } AllocSize;
716
717 // NVOS32_FUNCTION_ALLOC_TILED_PITCH_HEIGHT
718 struct
719 {
720 NvU32 owner; // [IN] - memory owner ID
721 NvHandle hMemory; // [IN/OUT] - unique memory handle - IN only if MEMORY_HANDLE_PROVIDED is set (otherwise generated)
722 NvU32 type; // [IN] - surface type, see below TYPE* defines
723 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
724 NvU32 height; // [IN] - height of surface in pixels
725 NvS32 pitch; // [IN/OUT] - desired pitch AND returned actual pitch allocated
726 NvU32 attr; // [IN/OUT] - surface attributes requested, and surface attributes allocated
727 NvU32 width; //[IN] - width of surface in pixels
728 NvU32 format; // [IN/OUT] - format requested, and format allocated
729 NvU32 comprCovg; // [IN/OUT] - compr covg requested, and allocated
730 NvU32 zcullCovg; // [OUT] - zcull covg allocated
731 NvU32 partitionStride; // [IN/OUT] - 0 means "RM" chooses
732 NvU64 size NV_ALIGN_BYTES(8); // [IN/OUT] - size of allocation - also returns the actual size allocated
733 NvU64 alignment NV_ALIGN_BYTES(8); // [IN] - requested alignment - NVOS32_ALLOC_FLAGS_ALIGNMENT* must be on
734 NvU64 offset NV_ALIGN_BYTES(8); // [IN/OUT] - desired offset if NVOS32_ALLOC_FLAGS_FIXED_ADDRESS_ALLOCATE is on AND returned offset
735 NvU64 limit NV_ALIGN_BYTES(8); // [OUT] - returned surface limit
736 NvP64 address NV_ALIGN_BYTES(8);// [OUT] - returned address
737 NvU64 rangeBegin NV_ALIGN_BYTES(8); // [IN] - allocated memory will be limited to the range
738 NvU64 rangeEnd NV_ALIGN_BYTES(8); // [IN] - from rangeBegin to rangeEnd, inclusive.
739 NvU32 attr2; // [IN/OUT] - surface attributes requested, and surface attributes allocated
740 NvU32 ctagOffset; // [IN] - comptag offset for this surface (see NVOS32_ALLOC_COMPTAG_OFFSET)
741 NvS32 numaNode; // [IN] - NUMA node from which memory should be allocated
742 } AllocTiledPitchHeight;
743
744 // NVOS32_FUNCTION_FREE
745 struct
746 {
747 NvU32 owner; // [IN] - memory owner ID
748 NvHandle hMemory; // [IN] - unique memory handle
749 NvU32 flags; // [IN] - heap free flags (must be NVOS32_FREE_FLAGS_MEMORY_HANDLE_PROVIDED)
750 } Free;
751
752 // NVOS32_FUNCTION_RELEASE_COMPR
753 struct
754 {
755 NvU32 owner; // [IN] - memory owner ID
756 NvU32 flags; // [IN] - must be NVOS32_RELEASE_COMPR_FLAGS_MEMORY_HANDLE_PROVIDED
757 NvHandle hMemory; // [IN] - unique memory handle (valid if _RELEASE_COMPR_FLAGS_MEMORY_HANDLE_PROVIDED
758 } ReleaseCompr;
759
760 // NVOS32_FUNCTION_REACQUIRE_COMPR
761 struct
762 {
763 NvU32 owner; // [IN] - memory owner ID
764 NvU32 flags; // [IN] - must be NVOS32_REACQUIRE_COMPR_FLAGS_MEMORY_HANDLE_PROVIDED
765 NvHandle hMemory; // [IN] - unique memory handle (valid if _REACQUIRE_COMPR_FLAGS_MEMORY_HANDLE_PROVIDED
766 } ReacquireCompr;
767
768 // NVOS32_FUNCTION_INFO
769 struct
770 {
771 NvU32 attr; // [IN] - memory heap attributes requested
772 NvU64 offset NV_ALIGN_BYTES(8); // [OUT] - base of largest free block
773 NvU64 size NV_ALIGN_BYTES(8); // [OUT] - size of largest free block
774 NvU64 base NV_ALIGN_BYTES(8); // [OUT] - returned heap phys base
775 } Info;
776
777 // NVOS32_FUNCTION_ALLOC_SIZE_RANGE
778 struct
779 {
780 NvU32 owner; // [IN] - memory owner ID
781 NvHandle hMemory; // [IN] - unique memory handle
782 NvU32 type; // [IN] - surface type, see below TYPE* defines
783 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
784 NvU32 attr; // [IN/OUT] - surface attributes requested, and surface attributes allocated
785 NvU32 format; // [IN/OUT] - format requested, and format allocated
786 NvU32 comprCovg; // [IN/OUT] - compr covg requested, and allocated
787 NvU32 zcullCovg; // [OUT] - zcull covg allocated
788 NvU32 partitionStride; // [IN/OUT] - 0 means "RM" chooses
789 NvU64 size NV_ALIGN_BYTES(8); // [IN/OUT] - size of allocation - also returns the actual size allocated
790 NvU64 alignment NV_ALIGN_BYTES(8); // [IN] - requested alignment - NVOS32_ALLOC_FLAGS_ALIGNMENT* must be on
791 NvU64 offset NV_ALIGN_BYTES(8); // [IN/OUT] - desired offset if NVOS32_ALLOC_FLAGS_FIXED_ADDRESS_ALLOCATE is on AND returned offset
792 NvU64 limit NV_ALIGN_BYTES(8); // [OUT] - returned surface limit
793 NvU64 rangeBegin NV_ALIGN_BYTES(8); // [IN] - allocated memory will be limited to the range
794 NvU64 rangeEnd NV_ALIGN_BYTES(8); // [IN] - from rangeBegin to rangeEnd, inclusive.
795 NvP64 address NV_ALIGN_BYTES(8);// [OUT] - returned address
796 NvU32 attr2; // [IN/OUT] - surface attributes requested, and surface attributes allocated
797 NvU32 ctagOffset; // [IN] - comptag offset for this surface (see NVOS32_ALLOC_COMPTAG_OFFSET)
798 NvS32 numaNode; // [IN] - NUMA node from which memory should be allocated
799 } AllocSizeRange;
800
801 // NVOS32_FUNCTION_GET_MEM_ALIGNMENT
802 struct
803 {
804 NvU32 alignType; // Input
805 NvU32 alignAttr;
806 NvU32 alignInputFlags;
807 NvU64 alignSize NV_ALIGN_BYTES(8);
808 NvU32 alignHeight;
809 NvU32 alignWidth;
810 NvU32 alignPitch;
811 NvU32 alignPad;
812 NvU32 alignMask;
813 NvU32 alignKind;
814 NvU32 alignAdjust; // Output -- If non-zero the amount we need to adjust the offset
815 NvU32 alignAttr2;
816 } AllocHintAlignment;
817
818 struct
819 {
820 NvU32 allocOwner; // [IN] - memory owner ID
821 NvHandle allochMemory; // [IN/OUT] - unique memory handle - IN only if MEMORY_HANDLE_PROVIDED is set (otherwise generated)
822 NvU32 flags;
823 NvU32 allocType; // Input
824 NvU32 allocAttr;
825 NvU32 allocInputFlags;
826 NvU64 allocSize NV_ALIGN_BYTES(8);
827 NvU32 allocHeight;
828 NvU32 allocWidth;
829 NvU32 allocPitch;
830 NvU32 allocMask;
831 NvU32 allocComprCovg;
832 NvU32 allocZcullCovg;
833 NvP64 bindResultFunc NV_ALIGN_BYTES(8); // BindResultFunc
834 NvP64 pHandle NV_ALIGN_BYTES(8);
835 NvHandle hResourceHandle; // Handle to RM container
836 NvU32 retAttr; // Output Indicates the resources that we allocated
837 NvU32 kind;
838 NvU64 osDeviceHandle NV_ALIGN_BYTES(8);
839 NvU32 allocAttr2;
840 NvU32 retAttr2; // Output Indicates the resources that we allocated
841 NvU64 allocAddr NV_ALIGN_BYTES(8);
842 // [out] from GMMU_COMPR_INFO in drivers/common/shared/inc/mmu/gmmu_fmt.h
843 struct
844 {
845 NvU32 compPageShift;
846 NvU32 compressedKind;
847 NvU32 compTagLineMin;
848 NvU32 compPageIndexLo;
849 NvU32 compPageIndexHi;
850 NvU32 compTagLineMultiplier;
851 } comprInfo;
852 // [out] fallback uncompressed kind.
853 NvU32 uncompressedKind;
854 } HwAlloc;
855
856 // NVOS32_FUNCTION_HW_FREE
857 struct
858 {
859 NvHandle hResourceHandle; // Handle to RM Resource Info
860 NvU32 flags; // Indicate if HW Resources and/or Memory
861 } HwFree;
862// Updated interface check.
863#define NV_RM_OS32_ALLOC_OS_DESCRIPTOR_WITH_OS32_ATTR 1
864
865 // NVOS32_FUNCTION_ALLOC_OS_DESCRIPTOR
866 struct
867 {
868 NvHandle hMemory; // [IN/OUT] - unique memory handle - IN only if MEMORY_HANDLE_PROVIDED is set (otherwise generated)
869 NvU32 type; // [IN] - surface type, see below TYPE* defines
870 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
871 NvU32 attr; // [IN] - attributes for memory placement/properties, see below
872 NvU32 attr2; // [IN] - attributes GPU_CACHEABLE
873 NvP64 descriptor NV_ALIGN_BYTES(8); // [IN] - descriptor address
874 NvU64 limit NV_ALIGN_BYTES(8); // [IN] - allocated size -1
875 NvU32 descriptorType; // [IN] - descriptor type(Virtual | nvmap Handle)
876 } AllocOsDesc;
877
878 } data;
879} NVOS32_PARAMETERS;
880
881#define NVOS32_DELETE_RESOURCES_ALL 0
882
883// type field
884#define NVOS32_TYPE_IMAGE 0
885#define NVOS32_TYPE_DEPTH 1
886#define NVOS32_TYPE_TEXTURE 2
887#define NVOS32_TYPE_VIDEO 3
888#define NVOS32_TYPE_FONT 4
889#define NVOS32_TYPE_CURSOR 5
890#define NVOS32_TYPE_DMA 6
891#define NVOS32_TYPE_INSTANCE 7
892#define NVOS32_TYPE_PRIMARY 8
893#define NVOS32_TYPE_ZCULL 9
894#define NVOS32_TYPE_UNUSED 10
895#define NVOS32_TYPE_SHADER_PROGRAM 11
896#define NVOS32_TYPE_OWNER_RM 12
897#define NVOS32_TYPE_NOTIFIER 13
898#define NVOS32_TYPE_RESERVED 14
899#define NVOS32_TYPE_PMA 15
900#define NVOS32_TYPE_STENCIL 16
901#define NVOS32_TYPE_SYNCPOINT 17
902#define NVOS32_NUM_MEM_TYPES 18
903
904// Surface attribute field - bitmask of requested attributes the surface
905// should have.
906// This value is updated to reflect what was actually allocated, and so this
907// field must be checked after every allocation to determine what was
908// allocated. Pass in the ANY tags to indicate that RM should fall back but
909// still succeed the alloc.
910// for example, if tiled_any is passed in, but no tile ranges are available,
911// RM will allocate normal memory and indicate that in the returned attr field.
912// Each returned attribute will have the REQUIRED field set if that attribute
913// applies to the allocated surface.
914
915#define NVOS32_ATTR_NONE 0x00000000
916
917#define NVOS32_ATTR_DEPTH 2:0
918#define NVOS32_ATTR_DEPTH_UNKNOWN 0x00000000
919#define NVOS32_ATTR_DEPTH_8 0x00000001
920#define NVOS32_ATTR_DEPTH_16 0x00000002
921#define NVOS32_ATTR_DEPTH_24 0x00000003
922#define NVOS32_ATTR_DEPTH_32 0x00000004
923#define NVOS32_ATTR_DEPTH_64 0x00000005
924#define NVOS32_ATTR_DEPTH_128 0x00000006
925
926#define NVOS32_ATTR_COMPR_COVG 3:3
927#define NVOS32_ATTR_COMPR_COVG_DEFAULT 0x00000000
928#define NVOS32_ATTR_COMPR_COVG_PROVIDED 0x00000001
929
930// Surface description - number of AA samples
931// This number should only reflect AA done in hardware, not in software. For
932// example, OpenGL's 8x AA mode is a mix of 2x hardware multisample and 2x2
933// software supersample.
934// OpenGL should specify ATTR_AA_SAMPLES of 2 in this case, not 8, because
935// the hardware will be programmed to run in 2x AA mode.
936// Note that X_VIRTUAL_Y means X real samples with Y samples total (i.e. Y
937// does not indicate the number of virtual samples). For instance, what
938// arch and HW describe as NV_PGRAPH_ANTI_ALIAS_SAMPLES_MODE_2X2_VC_12
939// corresponds to NVOS32_ATTR_AA_SAMPLES_4_VIRTUAL_16 here.
940
941#define NVOS32_ATTR_AA_SAMPLES 7:4
942#define NVOS32_ATTR_AA_SAMPLES_1 0x00000000
943#define NVOS32_ATTR_AA_SAMPLES_2 0x00000001
944#define NVOS32_ATTR_AA_SAMPLES_4 0x00000002
945#define NVOS32_ATTR_AA_SAMPLES_4_ROTATED 0x00000003
946#define NVOS32_ATTR_AA_SAMPLES_6 0x00000004
947#define NVOS32_ATTR_AA_SAMPLES_8 0x00000005
948#define NVOS32_ATTR_AA_SAMPLES_16 0x00000006
949#define NVOS32_ATTR_AA_SAMPLES_4_VIRTUAL_8 0x00000007
950#define NVOS32_ATTR_AA_SAMPLES_4_VIRTUAL_16 0x00000008
951#define NVOS32_ATTR_AA_SAMPLES_8_VIRTUAL_16 0x00000009
952#define NVOS32_ATTR_AA_SAMPLES_8_VIRTUAL_32 0x0000000A
953
954//
955//
956// GPU_CACHE_SNOOPABLE_ON signals to RM that CPU (or other IO device)
957// accesses to this surface will snoop the GPU cache.
958// _OFF indicates no GPU cache snooping will take place.
959// _MAPPING defers the decision to mapping time.
960//
961// Only applies to fully coherent platforms.
962//
963//
964#define NVOS32_ATTR_GPU_CACHE_SNOOPABLE 9:8
965#define NVOS32_ATTR_GPU_CACHE_SNOOPABLE_MAPPING 0x00000000
966#define NVOS32_ATTR_GPU_CACHE_SNOOPABLE_OFF 0x00000001
967#define NVOS32_ATTR_GPU_CACHE_SNOOPABLE_ON 0x00000002
968#define NVOS32_ATTR_GPU_CACHE_SNOOPABLE_INVALID 0x00000003
969
970// Zcull region (NV40 and up)
971// If ATTR_ZCULL is REQUIRED or ANY and ATTR_DEPTH is UNKNOWN, the
972// allocation will fail.
973// If ATTR_DEPTH or ATTR_AA_SAMPLES is not accurate, erroneous rendering
974// may result.
975#define NVOS32_ATTR_ZCULL 11:10
976#define NVOS32_ATTR_ZCULL_NONE 0x00000000
977#define NVOS32_ATTR_ZCULL_REQUIRED 0x00000001
978#define NVOS32_ATTR_ZCULL_ANY 0x00000002
979#define NVOS32_ATTR_ZCULL_SHARED 0x00000003
980
981// Compression (NV20 and up)
982// If ATTR_COMPR is REQUIRED or ANY and ATTR_DEPTH is UNKNOWN, the
983// allocation will fail.
984// If ATTR_DEPTH or ATTR_AA_SAMPLES is not accurate, performance will
985// suffer heavily
986#define NVOS32_ATTR_COMPR 13:12
987#define NVOS32_ATTR_COMPR_NONE 0x00000000
988#define NVOS32_ATTR_COMPR_REQUIRED 0x00000001
989#define NVOS32_ATTR_COMPR_ANY 0x00000002
990#define NVOS32_ATTR_COMPR_PLC_REQUIRED NVOS32_ATTR_COMPR_REQUIRED
991#define NVOS32_ATTR_COMPR_PLC_ANY NVOS32_ATTR_COMPR_ANY
992#define NVOS32_ATTR_COMPR_DISABLE_PLC_ANY 0x00000003
993
994//
995// Force the allocation to go to the reserved heap.
996// This flag is used for KMD allocations when MIG is enabled.
997//
998#define NVOS32_ATTR_ALLOCATE_FROM_RESERVED_HEAP 14:14
999#define NVOS32_ATTR_ALLOCATE_FROM_RESERVED_HEAP_NO 0x00000000
1000#define NVOS32_ATTR_ALLOCATE_FROM_RESERVED_HEAP_YES 0x00000001
1001
1002// Format
1003// _BLOCK_LINEAR is only available for nv50+.
1004#define NVOS32_ATTR_FORMAT 17:16
1005// Macros representing the low/high bits of NVOS32_ATTR_FORMAT
1006// bit range. These provide direct access to the range limits
1007// without needing to split the low:high representation via
1008// ternary operator, thereby avoiding MISRA 14.3 violation.
1009#define NVOS32_ATTR_FORMAT_LOW_FIELD 16
1010#define NVOS32_ATTR_FORMAT_HIGH_FIELD 17
1011#define NVOS32_ATTR_FORMAT_PITCH 0x00000000
1012#define NVOS32_ATTR_FORMAT_SWIZZLED 0x00000001
1013#define NVOS32_ATTR_FORMAT_BLOCK_LINEAR 0x00000002
1014
1015#define NVOS32_ATTR_Z_TYPE 18:18
1016#define NVOS32_ATTR_Z_TYPE_FIXED 0x00000000
1017#define NVOS32_ATTR_Z_TYPE_FLOAT 0x00000001
1018
1019#define NVOS32_ATTR_ZS_PACKING 21:19
1020#define NVOS32_ATTR_ZS_PACKING_S8 0x00000000 // Z24S8 and S8 share definition
1021#define NVOS32_ATTR_ZS_PACKING_Z24S8 0x00000000
1022#define NVOS32_ATTR_ZS_PACKING_S8Z24 0x00000001
1023#define NVOS32_ATTR_ZS_PACKING_Z32 0x00000002
1024#define NVOS32_ATTR_ZS_PACKING_Z24X8 0x00000003
1025#define NVOS32_ATTR_ZS_PACKING_X8Z24 0x00000004
1026#define NVOS32_ATTR_ZS_PACKING_Z32_X24S8 0x00000005
1027#define NVOS32_ATTR_ZS_PACKING_X8Z24_X24S8 0x00000006
1028#define NVOS32_ATTR_ZS_PACKING_Z16 0x00000007
1029// NOTE: ZS packing and color packing fields are overlaid
1030#define NVOS32_ATTR_COLOR_PACKING NVOS32_ATTR_ZS_PACKING
1031#define NVOS32_ATTR_COLOR_PACKING_A8R8G8B8 0x00000000
1032#define NVOS32_ATTR_COLOR_PACKING_X8R8G8B8 0x00000001
1033
1034
1035
1036//
1037// For virtual allocs to choose page size for the region. Specifying
1038// _DEFAULT will select a virtual page size that allows for a surface
1039// to be mixed between video and system memory and allow the surface
1040// to be migrated between video and system memory. For tesla chips,
1041// 4KB will be used. For fermi chips with dual page tables, a virtual
1042// address with both page tables will be used.
1043//
1044// For physical allocation on chips with page swizzle this field is
1045// used to select the page swizzle. This later also sets the virtual
1046// page size, but does not have influence over selecting a migratable
1047// virtual address. That must be selected when mapping the physical
1048// memory.
1049//
1050// BIG_PAGE = 64 KB on PASCAL
1051// = 64 KB or 128 KB on pre_PASCAL chips
1052//
1053// HUGE_PAGE = 2 MB on PASCAL+
1054// = 2 MB or 512 MB on AMPERE+
1055// = not supported on pre_PASCAL chips.
1056//
1057// To request for a HUGE page size,
1058// set NVOS32_ATTR_PAGE_SIZE to _HUGE and NVOS32_ATTR2_PAGE_SIZE_HUGE to
1059// the desired size.
1060//
1061#define NVOS32_ATTR_PAGE_SIZE 24:23
1062#define NVOS32_ATTR_PAGE_SIZE_DEFAULT 0x00000000
1063#define NVOS32_ATTR_PAGE_SIZE_4KB 0x00000001
1064#define NVOS32_ATTR_PAGE_SIZE_BIG 0x00000002
1065#define NVOS32_ATTR_PAGE_SIZE_HUGE 0x00000003
1066
1067#define NVOS32_ATTR_LOCATION 26:25
1068#define NVOS32_ATTR_LOCATION_VIDMEM 0x00000000
1069#define NVOS32_ATTR_LOCATION_PCI 0x00000001
1070#define NVOS32_ATTR_LOCATION_ANY 0x00000003
1071
1072//
1073// _DEFAULT implies _CONTIGUOUS for video memory currently, but
1074// may be changed to imply _NONCONTIGUOUS in the future.
1075// _ALLOW_NONCONTIGUOUS enables falling back to the noncontiguous
1076// vidmem allocator if contig allocation fails.
1077//
1078#define NVOS32_ATTR_PHYSICALITY 28:27
1079#define NVOS32_ATTR_PHYSICALITY_DEFAULT 0x00000000
1080#define NVOS32_ATTR_PHYSICALITY_NONCONTIGUOUS 0x00000001
1081#define NVOS32_ATTR_PHYSICALITY_CONTIGUOUS 0x00000002
1082#define NVOS32_ATTR_PHYSICALITY_ALLOW_NONCONTIGUOUS 0x00000003
1083
1084#define NVOS32_ATTR_COHERENCY 31:29
1085#define NVOS32_ATTR_COHERENCY_UNCACHED 0x00000000
1086#define NVOS32_ATTR_COHERENCY_CACHED 0x00000001
1087#define NVOS32_ATTR_COHERENCY_WRITE_COMBINE 0x00000002
1088#define NVOS32_ATTR_COHERENCY_WRITE_THROUGH 0x00000003
1089#define NVOS32_ATTR_COHERENCY_WRITE_PROTECT 0x00000004
1090#define NVOS32_ATTR_COHERENCY_WRITE_BACK 0x00000005
1091
1092// ATTR2 fields
1093#define NVOS32_ATTR2_NONE 0x00000000
1094
1095//
1096// DEFAULT - Let lower level drivers pick optimal page kind.
1097// PREFER_NO_ZBC - Prefer other types of compression over ZBC when
1098// selecting page kind.
1099// PREFER_ZBC - Prefer ZBC over other types of compression when
1100// selecting page kind.
1101// REQUIRE_ONLY_ZBC - Require a page kind that enables ZBC but disables
1102// other types of compression (i.e. 2C page kind).
1103// INVALID - Aliases REQUIRE_ONLY_ZBC, which is not supported
1104// by all RM implementations.
1105//
1106#define NVOS32_ATTR2_ZBC 1:0
1107#define NVOS32_ATTR2_ZBC_DEFAULT 0x00000000
1108#define NVOS32_ATTR2_ZBC_PREFER_NO_ZBC 0x00000001
1109#define NVOS32_ATTR2_ZBC_PREFER_ZBC 0x00000002
1110#define NVOS32_ATTR2_ZBC_REQUIRE_ONLY_ZBC 0x00000003
1111#define NVOS32_ATTR2_ZBC_INVALID 0x00000003
1112
1113//
1114// DEFAULT - Highest performance cache policy that is coherent with the highest
1115// performance CPU mapping. Typically this is gpu cached for video
1116// memory and gpu uncached for system memory.
1117// YES - Enable gpu caching if supported on this surface type. For system
1118// memory this will not be coherent with direct CPU mappings.
1119// NO - Disable gpu caching if supported on this surface type.
1120// INVALID - Clients should never set YES and NO simultaneously.
1121//
1122#define NVOS32_ATTR2_GPU_CACHEABLE 3:2
1123#define NVOS32_ATTR2_GPU_CACHEABLE_DEFAULT 0x00000000
1124#define NVOS32_ATTR2_GPU_CACHEABLE_YES 0x00000001
1125#define NVOS32_ATTR2_GPU_CACHEABLE_NO 0x00000002
1126#define NVOS32_ATTR2_GPU_CACHEABLE_INVALID 0x00000003
1127
1128//
1129// DEFAULT - GPU-dependent cache policy
1130// YES - Enable gpu caching for p2p mem
1131// NO - Disable gpu caching for p2p mem
1132//
1133#define NVOS32_ATTR2_P2P_GPU_CACHEABLE 5:4
1134#define NVOS32_ATTR2_P2P_GPU_CACHEABLE_DEFAULT 0x00000000
1135#define NVOS32_ATTR2_P2P_GPU_CACHEABLE_YES 0x00000001
1136#define NVOS32_ATTR2_P2P_GPU_CACHEABLE_NO 0x00000002
1137
1138// This applies to virtual allocs only. See NVOS46_FLAGS_32BIT_POINTER.
1139#define NVOS32_ATTR2_32BIT_POINTER 6:6
1140#define NVOS32_ATTR2_32BIT_POINTER_DISABLE 0x00000000
1141#define NVOS32_ATTR2_32BIT_POINTER_ENABLE 0x00000001
1142
1143//
1144// Whether or not a NUMA Node ID has been specified.
1145// If yes, the NUMA node ID specified in numaNode will be used.
1146// If no, memory can be allocated from any socket (numaNode will be ignored).
1147// Specified numaNode must be of a CPU's memory
1148//
1149
1150#define NVOS32_ATTR2_FIXED_NUMA_NODE_ID 7:7
1151#define NVOS32_ATTR2_FIXED_NUMA_NODE_ID_NO 0x00000000
1152#define NVOS32_ATTR2_FIXED_NUMA_NODE_ID_YES 0x00000001
1153
1154//
1155// Force SMMU mapping on GPU physical allocation in Tegra
1156// SMMU mapping for GPU physical allocation decided internally by RM
1157// This attribute provide an override to RM policy for verification purposes.
1158//
1159#define NVOS32_ATTR2_SMMU_ON_GPU 9:8
1160#define NVOS32_ATTR2_SMMU_ON_GPU_DEFAULT 0x00000000
1161#define NVOS32_ATTR2_SMMU_ON_GPU_DISABLE 0x00000001
1162#define NVOS32_ATTR2_SMMU_ON_GPU_ENABLE 0x00000002
1163
1164// Used for allocating the memory from scanout carveout.
1165#define NVOS32_ATTR2_USE_SCANOUT_CARVEOUT 10:10
1166#define NVOS32_ATTR2_USE_SCANOUT_CARVEOUT_FALSE 0x00000000
1167#define NVOS32_ATTR2_USE_SCANOUT_CARVEOUT_TRUE 0x00000001
1168
1169//
1170// Make comptag allocation aligned to compression cacheline size.
1171// Specifying this attribute will make RM allocate comptags worth an entire
1172// comp cacheline. The allocation will be offset aligned to number of comptags/comp cacheline.
1173//
1174#define NVOS32_ATTR2_ALLOC_COMPCACHELINE_ALIGN 11:11
1175#define NVOS32_ATTR2_ALLOC_COMPCACHELINE_ALIGN_OFF 0x0
1176#define NVOS32_ATTR2_ALLOC_COMPCACHELINE_ALIGN_ON 0x1
1177#define NVOS32_ATTR2_ALLOC_COMPCACHELINE_ALIGN_DEFAULT \
1178 NVOS32_ATTR2_ALLOC_COMPCACHELINE_ALIGN_OFF
1179
1180// Allocation preferred in high or low priority memory
1181#define NVOS32_ATTR2_PRIORITY 13:12
1182#define NVOS32_ATTR2_PRIORITY_DEFAULT 0x0
1183#define NVOS32_ATTR2_PRIORITY_HIGH 0x1
1184#define NVOS32_ATTR2_PRIORITY_LOW 0x2
1185
1186// PMA: Allocation is an RM internal allocation (RM-only)
1187#define NVOS32_ATTR2_INTERNAL 14:14
1188#define NVOS32_ATTR2_INTERNAL_NO 0x0
1189#define NVOS32_ATTR2_INTERNAL_YES 0x1
1190
1191// Allocate 2C instead of 2CZ
1192#define NVOS32_ATTR2_PREFER_2C 15:15
1193#define NVOS32_ATTR2_PREFER_2C_NO 0x00000000
1194#define NVOS32_ATTR2_PREFER_2C_YES 0x00000001
1195
1196// Allocation used by display engine; RM verifies display engine has enough
1197// address bits or remapper available.
1198#define NVOS32_ATTR2_NISO_DISPLAY 16:16
1199#define NVOS32_ATTR2_NISO_DISPLAY_NO 0x00000000
1200#define NVOS32_ATTR2_NISO_DISPLAY_YES 0x00000001
1201
1202//
1203// !!WARNING!!!
1204//
1205// This flag is introduced as a temporary WAR to enable color compression
1206// without ZBC.
1207//
1208// This dangerous flag can be used by UMDs to instruct RM to skip the zbc
1209// table refcounting that RM does today, when the chosen PTE kind has ZBC
1210// support.
1211//
1212// Currently we do not have a safe per process zbc slot management and
1213// refcounting mechanism between RM and UMD and hence, any process can
1214// access any other process's zbc entry in the global zbc table (without mask)
1215// Inorder to flush the ZBC table for slot reuse RM cannot track which
1216// process is using which zbc slot. Hence RM has a global refcount for the
1217// zbc table to flush and reuse the entries if the PTE kind supports zbc.
1218//
1219// This scheme poses a problem if there are apps that are persistent such as
1220// the desktop components that can have color compression enabled which will
1221// always keep the refcount active. Since these apps can live without
1222// ZBC, UMD can disable ZBC using masks.
1223//
1224// In such a case, if UMD so chooses to disable ZBC, this flag should be used
1225// to skip refcounting as by default RM would refcount the ZBC table.
1226//
1227// NOTE: There is no way for RM to enforce/police this, and we totally rely
1228// on UMD to use a zbc mask in the pushbuffer method to prevent apps from
1229// accessing the ZBC table.
1230//
1231#define NVOS32_ATTR2_ZBC_SKIP_ZBCREFCOUNT 17:17
1232#define NVOS32_ATTR2_ZBC_SKIP_ZBCREFCOUNT_NO 0x00000000
1233#define NVOS32_ATTR2_ZBC_SKIP_ZBCREFCOUNT_YES 0x00000001
1234
1235// Allocation requires ISO bandwidth guarantees
1236#define NVOS32_ATTR2_ISO 18:18
1237#define NVOS32_ATTR2_ISO_NO 0x00000000
1238#define NVOS32_ATTR2_ISO_YES 0x00000001
1239
1240//
1241// Turn off blacklist feature for video memory allocation
1242// This attribute should be used only by Kernel client (KMD), to mask
1243// the blacklisted pages for the allocation. This is done so that the clients
1244// will manage the above masked blacklisted pages after the allocation. It will
1245// return to RM's pool after the allocation was free-d.RmVidHeapCtrl returns
1246// NV_ERR_INSUFFICIENT_PERMISSIONS if it is being called by non-kernel clients.
1247//
1248
1249// TODO: Project ReLingo - This term is marked for deletion. Use PAGE_OFFLINING.
1250#define NVOS32_ATTR2_BLACKLIST 19:19
1251#define NVOS32_ATTR2_BLACKLIST_ON 0x00000000
1252#define NVOS32_ATTR2_BLACKLIST_OFF 0x00000001
1253#define NVOS32_ATTR2_PAGE_OFFLINING 19:19
1254#define NVOS32_ATTR2_PAGE_OFFLINING_ON 0x00000000
1255#define NVOS32_ATTR2_PAGE_OFFLINING_OFF 0x00000001
1256
1257//
1258// For virtual allocs to choose the HUGE page size for the region.
1259// NVOS32_ATTR_PAGE_SIZE must be set to _HUGE to use this.
1260// Currently, the default huge page is 2MB, so a request with _DEFAULT
1261// set will always be interpreted as 2MB.
1262// Not supported on pre_AMPERE chips.
1263//
1264#define NVOS32_ATTR2_PAGE_SIZE_HUGE 21:20
1265#define NVOS32_ATTR2_PAGE_SIZE_HUGE_DEFAULT 0x00000000
1266#define NVOS32_ATTR2_PAGE_SIZE_HUGE_2MB 0x00000001
1267#define NVOS32_ATTR2_PAGE_SIZE_HUGE_512MB 0x00000002
1268#define NVOS32_ATTR2_PAGE_SIZE_HUGE_256GB 0x00000003
1269
1270// Allow read-only or read-write user CPU mappings
1271#define NVOS32_ATTR2_PROTECTION_USER 22:22
1272#define NVOS32_ATTR2_PROTECTION_USER_READ_WRITE 0x00000000
1273#define NVOS32_ATTR2_PROTECTION_USER_READ_ONLY 0x00000001
1274
1275// Allow read-only or read-write device mappings
1276#define NVOS32_ATTR2_PROTECTION_DEVICE 23:23
1277#define NVOS32_ATTR2_PROTECTION_DEVICE_READ_WRITE 0x00000000
1278#define NVOS32_ATTR2_PROTECTION_DEVICE_READ_ONLY 0x00000001
1279
1280// Deprecated. To be deleted once client code has removed references.
1281#define NVOS32_ATTR2_USE_EGM 24:24
1282#define NVOS32_ATTR2_USE_EGM_FALSE 0x00000000
1283#define NVOS32_ATTR2_USE_EGM_TRUE 0x00000001
1284
1285//
1286// Allow client allocations to go to protected/unprotected video/system memory.
1287// When Ampere Protected Model aka APM or Confidential Compute is enabled and
1288// DEFAULT flag is set by client, allocations go to protected memory. When
1289// protected memory is not enabled, allocations go to unprotected memory.
1290// If APM or CC is not enabled, it is a bug for a client to set the PROTECTED
1291// flag to YES
1292//
1293#define NVOS32_ATTR2_MEMORY_PROTECTION 26:25
1294#define NVOS32_ATTR2_MEMORY_PROTECTION_DEFAULT 0x00000000
1295#define NVOS32_ATTR2_MEMORY_PROTECTION_PROTECTED 0x00000001
1296#define NVOS32_ATTR2_MEMORY_PROTECTION_UNPROTECTED 0x00000002
1297//
1298// Force the allocation to go to guest subheap.
1299// This flag is used by vmiop plugin to allocate from GPA
1300//
1301#define NVOS32_ATTR2_ALLOCATE_FROM_SUBHEAP 27:27
1302#define NVOS32_ATTR2_ALLOCATE_FROM_SUBHEAP_NO 0x00000000
1303#define NVOS32_ATTR2_ALLOCATE_FROM_SUBHEAP_YES 0x00000001
1304
1305//
1306// Force the video memory allocation to localized allocation.
1307// Same attribute can be used to choose between uGPU0 and uGPU1.
1308// if set to default, RM will choose the next available uGPU memory.
1309// if set to _UGPU0, RM will choose the memory from uGPU0.
1310// if set to _UGPU1, RM will choose the memory from uGPU1.
1311//
1312#define NVOS32_ATTR2_ENABLE_LOCALIZED_MEMORY 30:29
1313#define NVOS32_ATTR2_ENABLE_LOCALIZED_MEMORY_DEFAULT 0x00000000
1314#define NVOS32_ATTR2_ENABLE_LOCALIZED_MEMORY_UGPU0 0x00000001
1315#define NVOS32_ATTR2_ENABLE_LOCALIZED_MEMORY_UGPU1 0x00000002
1316
1317//
1318// When allocating memory, register the memory descriptor to GSP-RM
1319// so that GSP-RM is aware of and can access it
1320//
1321#define NVOS32_ATTR2_REGISTER_MEMDESC_TO_PHYS_RM 31:31
1322#define NVOS32_ATTR2_REGISTER_MEMDESC_TO_PHYS_RM_FALSE 0x00000000
1323#define NVOS32_ATTR2_REGISTER_MEMDESC_TO_PHYS_RM_TRUE 0x00000001
1324
1325/**
1326 * NVOS32 ALLOC_FLAGS
1327 *
1328 * NVOS32_ALLOC_FLAGS_IGNORE_BANK_PLACEMENT
1329 *
1330 * NVOS32_ALLOC_FLAGS_FORCE_MEM_GROWS_UP
1331 *
1332 * NVOS32_ALLOC_FLAGS_FORCE_MEM_GROWS_DOWN
1333 *
1334 * NVOS32_ALLOC_FLAGS_FORCE_ALIGN_HOST_PAGE
1335 *
1336 * NVOS32_ALLOC_FLAGS_FIXED_ADDRESS_ALLOCATE
1337 *
1338 * NVOS32_ALLOC_FLAGS_BANK_HINT
1339 *
1340 * NVOS32_ALLOC_FLAGS_BANK_FORCE
1341 *
1342 * NVOS32_ALLOC_FLAGS_ALIGNMENT_HINT
1343 *
1344 * NVOS32_ALLOC_FLAGS_ALIGNMENT_FORCE
1345 *
1346 * NVOS32_ALLOC_FLAGS_BANK_GROW_UP
1347 * Only relevant if bank_hint or bank_force are set
1348 *
1349 * NVOS32_ALLOC_FLAGS_BANK_GROW_DOWN
1350 * Only relevant if bank_hint or bank_force are set
1351 *
1352 * NVOS32_ALLOC_FLAGS_LAZY
1353 * Lazy allocation (deferred pde, pagetable creation)
1354 *
1355 * NVOS32_ALLOC_FLAGS_NO_SCANOUT
1356 * Set if surface will never be scanned out
1357 *
1358 * NVOS32_ALLOC_FLAGS_PITCH_FORCE
1359 * Fail alloc if supplied pitch is not aligned
1360 *
1361 * NVOS32_ALLOC_FLAGS_MEMORY_HANDLE_PROVIDED
1362 * Memory handle provided to be associated with this allocation
1363 *
1364 * NVOS32_ALLOC_FLAGS_MAP_NOT_REQUIRED
1365 * By default memory is mapped into the CPU address space
1366 *
1367 * NVOS32_ALLOC_FLAGS_PERSISTENT_VIDMEM
1368 * Allocate persistent video memory
1369 *
1370 * NVOS32_ALLOC_FLAGS_USE_BEGIN_END
1371 * Use rangeBegin & rangeEnd fields in allocs other than size/range
1372 *
1373 * NVOS32_ALLOC_FLAGS_TURBO_CIPHER_ENCRYPTED
1374 * Allocate TurboCipher encrypted region
1375 *
1376 * NVOS32_ALLOC_FLAGS_VIRTUAL
1377 * Allocate virtual memory address space
1378 *
1379 * NVOS32_ALLOC_FLAGS_FORCE_INTERNAL_INDEX
1380 * Force allocation internal index
1381 *
1382 * NVOS32_ALLOC_FLAGS_ZCULL_COVG_SPECIFIED
1383 * This flag is depreciated and allocations will fail.
1384 *
1385 * NVOS32_ALLOC_FLAGS_EXTERNALLY_MANAGED
1386 * Must be used with NVOS32_ALLOC_FLAGS_VIRTUAL.
1387 * Page tables for this allocation will be managed outside of RM.
1388 *
1389 * NVOS32_ALLOC_FLAGS_FORCE_DEDICATED_PDE
1390 *
1391 * NVOS32_ALLOC_FLAGS_PROTECTED
1392 * Allocate in a protected memory region if available
1393 *
1394 * NVOS32_ALLOC_FLAGS_KERNEL_MAPPING_MAP
1395 * Map kernel os descriptor
1396 *
1397 * NVOS32_ALLOC_FLAGS_MAXIMIZE_ADDRESS_SPACE
1398 * On WDDM all address spaces are created with MINIMIZE_PTETABLE_SIZE
1399 * to reduce the overhead of private address spaces per application,
1400 * at the cost of holes in the virtual address space.
1401 *
1402 * Shaders have short pointers that are required to be within a
1403 * GPU dependent 32b range.
1404 *
1405 * MAXIMIZE_ADDRESS_SPACE will reverse the MINIMIZE_PTE_TABLE_SIZE
1406 * flag with certain restrictions:
1407 * - This flag only has an effect when the allocation has the side
1408 * effect of creating a new PDE. It does not affect existing PDEs.
1409 * - The first few PDEs of the address space are kept minimum to allow
1410 * small applications to use fewer resources.
1411 * - By default this operations on the 0-4GB address range.
1412 * - If USE_BEGIN_END is specified the setting will apply to the
1413 * specified range instead of the first 4GB.
1414 *
1415 * NVOS32_ALLOC_FLAGS_SPARSE
1416 * Denote that a virtual address range is "sparse". Must be used with
1417 * NVOS32_ALLOC_FLAGS_VIRTUAL. Creation of a "sparse" virtual address range
1418 * denotes that an unmapped virtual address range should "not" fault but simply
1419 * return 0's.
1420 *
1421 * NVOS32_ALLOC_FLAGS_ALLOCATE_KERNEL_PRIVILEGED
1422 * This a special flag that can be used only by kernel(root) clients
1423 * to allocate memory out of a protected region of the address space
1424 * If this flag is set by non kernel clients then the allocation will
1425 * fail.
1426 *
1427 * NVOS32_ALLOC_FLAGS_SKIP_RESOURCE_ALLOC
1428 *
1429 * NVOS32_ALLOC_FLAGS_PREFER_PTES_IN_SYSMEMORY
1430 * If new pagetable need to be allocated prefer them in sysmem (if supported by the gpu)
1431 *
1432 * NVOS32_ALLOC_FLAGS_SKIP_ALIGN_PAD
1433 * As per KMD request to eliminate extra allocation
1434 *
1435 * NVOS32_ALLOC_FLAGS_WPR1
1436 * Allocate in a WPR1 region if available
1437 *
1438 * NVOS32_ALLOC_FLAGS_ZCULL_DONT_ALLOCATE_SHARED_1X
1439 * If using zcull sharing and this surface is fsaa, then don't allocate an additional non-FSAA region.
1440 *
1441 * NVOS32_ALLOC_FLAGS_WPR2
1442 * Allocate in a WPR1 region if available
1443 */
1444#define NVOS32_ALLOC_FLAGS_IGNORE_BANK_PLACEMENT 0x00000001
1445#define NVOS32_ALLOC_FLAGS_FORCE_MEM_GROWS_UP 0x00000002
1446#define NVOS32_ALLOC_FLAGS_FORCE_MEM_GROWS_DOWN 0x00000004
1447#define NVOS32_ALLOC_FLAGS_FORCE_ALIGN_HOST_PAGE 0x00000008
1448#define NVOS32_ALLOC_FLAGS_FIXED_ADDRESS_ALLOCATE 0x00000010
1449#define NVOS32_ALLOC_FLAGS_BANK_HINT 0x00000020
1450#define NVOS32_ALLOC_FLAGS_BANK_FORCE 0x00000040
1451#define NVOS32_ALLOC_FLAGS_ALIGNMENT_HINT 0x00000080
1452#define NVOS32_ALLOC_FLAGS_ALIGNMENT_FORCE 0x00000100
1453#define NVOS32_ALLOC_FLAGS_BANK_GROW_UP 0x00000000
1454#define NVOS32_ALLOC_FLAGS_BANK_GROW_DOWN 0x00000200
1455#define NVOS32_ALLOC_FLAGS_LAZY 0x00000400
1456#define NVOS32_ALLOC_FLAGS_FORCE_REVERSE_ALLOC 0x00000800
1457#define NVOS32_ALLOC_FLAGS_NO_SCANOUT 0x00001000
1458#define NVOS32_ALLOC_FLAGS_PITCH_FORCE 0x00002000
1459#define NVOS32_ALLOC_FLAGS_MEMORY_HANDLE_PROVIDED 0x00004000
1460#define NVOS32_ALLOC_FLAGS_MAP_NOT_REQUIRED 0x00008000
1461#define NVOS32_ALLOC_FLAGS_PERSISTENT_VIDMEM 0x00010000
1462#define NVOS32_ALLOC_FLAGS_USE_BEGIN_END 0x00020000
1463#define NVOS32_ALLOC_FLAGS_TURBO_CIPHER_ENCRYPTED 0x00040000
1464#define NVOS32_ALLOC_FLAGS_VIRTUAL 0x00080000
1465#define NVOS32_ALLOC_FLAGS_FORCE_INTERNAL_INDEX 0x00100000
1466#define NVOS32_ALLOC_FLAGS_ZCULL_COVG_SPECIFIED 0x00200000
1467#define NVOS32_ALLOC_FLAGS_EXTERNALLY_MANAGED 0x00400000
1468#define NVOS32_ALLOC_FLAGS_FORCE_DEDICATED_PDE 0x00800000
1469#define NVOS32_ALLOC_FLAGS_PROTECTED 0x01000000
1470#define NVOS32_ALLOC_FLAGS_KERNEL_MAPPING_MAP 0x02000000 // TODO BUG 2488679: fix alloc flag aliasing
1471#define NVOS32_ALLOC_FLAGS_MAXIMIZE_ADDRESS_SPACE 0x02000000
1472#define NVOS32_ALLOC_FLAGS_SPARSE 0x04000000
1473#define NVOS32_ALLOC_FLAGS_USER_READ_ONLY 0x04000000 // TODO BUG 2488682: remove this after KMD transition
1474#define NVOS32_ALLOC_FLAGS_DEVICE_READ_ONLY 0x08000000 // TODO BUG 2488682: remove this after KMD transition
1475#define NVOS32_ALLOC_FLAGS_ALLOCATE_KERNEL_PRIVILEGED 0x08000000
1476#define NVOS32_ALLOC_FLAGS_SKIP_RESOURCE_ALLOC 0x10000000
1477#define NVOS32_ALLOC_FLAGS_PREFER_PTES_IN_SYSMEMORY 0x20000000
1478#define NVOS32_ALLOC_FLAGS_SKIP_ALIGN_PAD 0x40000000
1479#define NVOS32_ALLOC_FLAGS_WPR1 0x40000000 // TODO BUG 2488672: fix alloc flag aliasing
1480#define NVOS32_ALLOC_FLAGS_ZCULL_DONT_ALLOCATE_SHARED_1X 0x80000000
1481#define NVOS32_ALLOC_FLAGS_WPR2 0x80000000 // TODO BUG 2488672: fix alloc flag aliasing
1482
1483// Internal flags used for RM's allocation paths
1484#define NVOS32_ALLOC_INTERNAL_FLAGS_CLIENTALLOC 0x00000001 // RM internal flags - not sure if this should be exposed even. Keeping it here.
1485#define NVOS32_ALLOC_INTERNAL_FLAGS_SKIP_SCRUB 0x00000004 // RM internal flags - not sure if this should be exposed even. Keeping it here.
1486#define NVOS32_ALLOC_FLAGS_MAXIMIZE_4GB_ADDRESS_SPACE NVOS32_ALLOC_FLAGS_MAXIMIZE_ADDRESS_SPACE // Legacy name
1487
1488//
1489// Bitmask of flags that are only valid for virtual allocations.
1490//
1491#define NVOS32_ALLOC_FLAGS_VIRTUAL_ONLY ( \
1492 NVOS32_ALLOC_FLAGS_VIRTUAL | \
1493 NVOS32_ALLOC_FLAGS_LAZY | \
1494 NVOS32_ALLOC_FLAGS_EXTERNALLY_MANAGED | \
1495 NVOS32_ALLOC_FLAGS_SPARSE | \
1496 NVOS32_ALLOC_FLAGS_MAXIMIZE_ADDRESS_SPACE | \
1497 NVOS32_ALLOC_FLAGS_PREFER_PTES_IN_SYSMEMORY )
1498
1499// COMPR_COVG_* allows for specification of what compression resources
1500// are required (_MIN) and necessary (_MAX). Default behavior is for
1501// RM to provide as much as possible, including none if _ANY is allowed.
1502// Values for min/max are (0-100, a %) * _COVG_SCALE (so max value is
1503// 100*100==10000). _START is used to specify the % offset into the
1504// region to begin the requested coverage.
1505// _COVG_BITS allows specification of the number of comptags per ROP tile.
1506// A value of 0 is default and allows RM to choose based upon MMU/FB rules.
1507// All other values for _COVG_BITS are arch-specific.
1508// Note: NVOS32_ATTR_COMPR_COVG_PROVIDED must be set for this feature
1509// to be available (verif-only).
1510#define NVOS32_ALLOC_COMPR_COVG_SCALE 10
1511#define NVOS32_ALLOC_COMPR_COVG_BITS 1:0
1512#define NVOS32_ALLOC_COMPR_COVG_BITS_DEFAULT 0x00000000
1513#define NVOS32_ALLOC_COMPR_COVG_BITS_1 0x00000001
1514#define NVOS32_ALLOC_COMPR_COVG_BITS_2 0x00000002
1515#define NVOS32_ALLOC_COMPR_COVG_BITS_4 0x00000003
1516#define NVOS32_ALLOC_COMPR_COVG_MAX 11:2
1517#define NVOS32_ALLOC_COMPR_COVG_MIN 21:12
1518#define NVOS32_ALLOC_COMPR_COVG_START 31:22
1519
1520
1521// Note: NVOS32_ALLOC_FLAGS_ZCULL_COVG_SPECIFIED must be set for this feature
1522// to be enabled.
1523// If FALLBACK_ALLOW is set, a fallback from LOW_RES_Z or LOW_RES_ZS
1524// to HIGH_RES_Z is allowed if the surface can't be fully covered.
1525#define NVOS32_ALLOC_ZCULL_COVG_FORMAT 3:0
1526#define NVOS32_ALLOC_ZCULL_COVG_FORMAT_LOW_RES_Z 0x00000000
1527#define NVOS32_ALLOC_ZCULL_COVG_FORMAT_HIGH_RES_Z 0x00000002
1528#define NVOS32_ALLOC_ZCULL_COVG_FORMAT_LOW_RES_ZS 0x00000003
1529#define NVOS32_ALLOC_ZCULL_COVG_FALLBACK 4:4
1530#define NVOS32_ALLOC_ZCULL_COVG_FALLBACK_DISALLOW 0x00000000
1531#define NVOS32_ALLOC_ZCULL_COVG_FALLBACK_ALLOW 0x00000001
1532
1533
1534// _ALLOC_COMPTAG_OFFSET allows the caller to specify the starting
1535// offset for the comptags for a given surface, primarily for test only.
1536// To specify an offset, set _USAGE_FIXED or _USAGE_MIN in conjunction
1537// with _START.
1538//
1539// _USAGE_FIXED sets a surface's comptagline to start at the given
1540// starting value. If the offset has already been assigned, then
1541// the alloc call fails.
1542//
1543// _USAGE_MIN sets a surface's comptagline to start at the given
1544// starting value or higher, depending on comptagline availability.
1545// In this case, if the offset has already been assigned, the next
1546// available comptagline (in increasing order) will be assigned.
1547//
1548// For Fermi, up to 2^17 comptags may be allowed, but the actual,
1549// usable limit depends on the size of the compbit backing store.
1550//
1551// For Pascal, up to 2 ^ 18 comptags may be allowed
1552// From Turing. up to 2 ^ 20 comptags may be allowed
1553//
1554// See also field ctagOffset in struct NVOS32_PARAMETERS.
1555#define NVOS32_ALLOC_COMPTAG_OFFSET_START 19:0
1556#define NVOS32_ALLOC_COMPTAG_OFFSET_START_DEFAULT 0x00000000
1557#define NVOS32_ALLOC_COMPTAG_OFFSET_USAGE 31:30
1558#define NVOS32_ALLOC_COMPTAG_OFFSET_USAGE_DEFAULT 0x00000000
1559#define NVOS32_ALLOC_COMPTAG_OFFSET_USAGE_OFF 0x00000000
1560#define NVOS32_ALLOC_COMPTAG_OFFSET_USAGE_FIXED 0x00000001
1561#define NVOS32_ALLOC_COMPTAG_OFFSET_USAGE_MIN 0x00000002
1562
1563
1564// REALLOC flags field
1565#define NVOS32_REALLOC_FLAGS_GROW_ALLOCATION 0x00000000
1566#define NVOS32_REALLOC_FLAGS_SHRINK_ALLOCATION 0x00000001
1567#define NVOS32_REALLOC_FLAGS_REALLOC_UP 0x00000000 // towards/from high memory addresses
1568#define NVOS32_REALLOC_FLAGS_REALLOC_DOWN 0x00000002 // towards/from memory address 0
1569
1570// RELEASE_COMPR, REACQUIRE_COMPR flags field
1571#define NVOS32_RELEASE_COMPR_FLAGS_MEMORY_HANDLE_PROVIDED 0x000000001
1572
1573#define NVOS32_REACQUIRE_COMPR_FLAGS_MEMORY_HANDLE_PROVIDED 0x000000001
1574
1575
1576// FREE flags field
1577#define NVOS32_FREE_FLAGS_MEMORY_HANDLE_PROVIDED 0x00000001
1578
1579// DUMP flags field
1580#define NVOS32_DUMP_FLAGS_TYPE 1:0
1581#define NVOS32_DUMP_FLAGS_TYPE_FB 0x00000000
1582#define NVOS32_DUMP_FLAGS_TYPE_CLIENT_PD 0x00000001
1583#define NVOS32_DUMP_FLAGS_TYPE_CLIENT_VA 0x00000002
1584#define NVOS32_DUMP_FLAGS_TYPE_CLIENT_VAPTE 0x00000003
1585
1586#define NVOS32_BLOCK_TYPE_FREE 0xFFFFFFFF
1587#define NVOS32_INVALID_BLOCK_FREE_OFFSET 0xFFFFFFFF
1588
1589#define NVOS32_MEM_TAG_NONE 0x00000000
1590
1591/*
1592 * NV_CONTEXT_DMA_ALLOCATION_PARAMS - Allocation params to create context dma
1593 through NvRmAlloc.
1594 */
1595typedef struct
1596{
1597 NvHandle hSubDevice;
1598 NvV32 flags;
1599 NvHandle hMemory;
1600 NvU64 offset NV_ALIGN_BYTES(8);
1601 NvU64 limit NV_ALIGN_BYTES(8);
1602} NV_CONTEXT_DMA_ALLOCATION_PARAMS;
1603
1604/*
1605 * NV_MEMORY_ALLOCATION_PARAMS - Allocation params to create memory through
1606 * NvRmAlloc. Flags are populated with NVOS32_ defines.
1607 */
1608typedef struct
1609{
1610 NvU32 owner; // [IN] - memory owner ID
1611 NvU32 type; // [IN] - surface type, see below TYPE* defines
1612 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
1613
1614 NvU32 width; // [IN] - width of surface in pixels
1615 NvU32 height; // [IN] - height of surface in pixels
1616 NvS32 pitch; // [IN/OUT] - desired pitch AND returned actual pitch allocated
1617
1618 NvU32 attr; // [IN/OUT] - surface attributes requested, and surface attributes allocated
1619 NvU32 attr2; // [IN/OUT] - surface attributes requested, and surface attributes allocated
1620
1621 NvU32 format; // [IN/OUT] - format requested, and format allocated
1622 NvU32 comprCovg; // [IN/OUT] - compr covg requested, and allocated
1623 NvU32 zcullCovg; // [OUT] - zcull covg allocated
1624
1625 NvU64 rangeLo NV_ALIGN_BYTES(8); // [IN] - allocated memory will be limited to the range
1626 NvU64 rangeHi NV_ALIGN_BYTES(8); // [IN] - from rangeBegin to rangeEnd, inclusive.
1627
1628 NvU64 size NV_ALIGN_BYTES(8); // [IN/OUT] - size of allocation - also returns the actual size allocated
1629 NvU64 alignment NV_ALIGN_BYTES(8); // [IN] - requested alignment - NVOS32_ALLOC_FLAGS_ALIGNMENT* must be on
1630 NvU64 offset NV_ALIGN_BYTES(8); // [IN/OUT] - desired offset if NVOS32_ALLOC_FLAGS_FIXED_ADDRESS_ALLOCATE is on AND returned offset
1631 NvU64 limit NV_ALIGN_BYTES(8); // [OUT] - returned surface limit
1632 NvP64 address NV_ALIGN_BYTES(8); // [OUT] - returned address
1633
1634 NvU32 ctagOffset; // [IN] - comptag offset for this surface (see NVOS32_ALLOC_COMPTAG_OFFSET)
1635 NvHandle hVASpace; // [IN] - VASpace handle. Used when flag is VIRTUAL.
1636
1637 NvU32 internalflags; // [IN] - internal flags to change allocation behaviors from internal paths
1638
1639 NvU32 tag; // [IN] - memory tag used for debugging
1640
1641 NvS32 numaNode; // [IN] - CPU NUMA node from which memory should be allocated
1642} NV_MEMORY_ALLOCATION_PARAMS;
1643
1644/*
1645 * NV_OS_DESC_MEMORY_ALLOCATION_PARAMS - Allocation params to create OS
1646 * described memory through NvRmAlloc. Flags are populated with NVOS32_ defines.
1647 */
1648typedef struct
1649{
1650 NvU32 type; // [IN] - surface type, see below TYPE* defines
1651 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
1652 NvU32 attr; // [IN] - attributes for memory placement/properties, see below
1653 NvU32 attr2; // [IN] - attributes GPU_CACHEABLE
1654 NvP64 descriptor NV_ALIGN_BYTES(8); // [IN] - descriptor address
1655 NvU64 limit NV_ALIGN_BYTES(8); // [IN] - allocated size -1
1656 NvU32 descriptorType; // [IN] - descriptor type(Virtual | nvmap Handle)
1657 NvU32 tag; // [IN] - memory tag used for debugging
1658} NV_OS_DESC_MEMORY_ALLOCATION_PARAMS;
1659
1660/*
1661 * NV_USER_LOCAL_DESC_MEMORY_ALLOCATION_PARAMS - Allocation params to create a memory
1662 * object from user allocated video memory. Flags are populated with NVOS32_*
1663 * defines.
1664 */
1665typedef struct
1666{
1667 NvU32 flags; // [IN] - allocation modifier flags, see NVOS02_FLAGS* defines
1668 NvU64 physAddr NV_ALIGN_BYTES(8); // [IN] - physical address
1669 NvU64 size NV_ALIGN_BYTES(8); // [IN] - mem size
1670 NvU32 tag; // [IN] - memory tag used for debugging
1671 NvBool bGuestAllocated; // [IN] - Set if memory is guest allocated (mapped by VMMU)
1672} NV_USER_LOCAL_DESC_MEMORY_ALLOCATION_PARAMS;
1673
1674/*
1675 * NV_MEMORY_HW_RESOURCES_ALLOCATION_PARAMS - Allocation params to create
1676 * memory HW resources through NvRmAlloc. Flags are populated with NVOS32_
1677 * defines.
1678 */
1679typedef struct
1680{
1681 NvU32 owner; // [IN] - memory owner ID
1682 NvU32 flags; // [IN] - allocation modifier flags, see below ALLOC_FLAGS* defines
1683 NvU32 type; // [IN] - surface type, see below TYPE* defines
1684
1685 NvU32 attr; // [IN/OUT] - surface attributes requested, and surface attributes allocated
1686 NvU32 attr2; // [IN/OUT] - surface attributes requested, and surface attributes allocated
1687
1688 NvU32 height;
1689 NvU32 width;
1690 NvU32 pitch;
1691 NvU32 alignment;
1692 NvU32 comprCovg;
1693 NvU32 zcullCovg;
1694
1695 NvU32 kind;
1696
1697 NvP64 bindResultFunc NV_ALIGN_BYTES(8); // BindResultFunc
1698 NvP64 pHandle NV_ALIGN_BYTES(8);
1699 NvU64 osDeviceHandle NV_ALIGN_BYTES(8);
1700 NvU64 size NV_ALIGN_BYTES(8);
1701 NvU64 allocAddr NV_ALIGN_BYTES(8);
1702
1703 // [out] from GMMU_COMPR_INFO in drivers/common/shared/inc/mmu/gmmu_fmt.h
1704 NvU32 compPageShift;
1705 NvU32 compressedKind;
1706 NvU32 compTagLineMin;
1707 NvU32 compPageIndexLo;
1708 NvU32 compPageIndexHi;
1709 NvU32 compTagLineMultiplier;
1710
1711 // [out] fallback uncompressed kind.
1712 NvU32 uncompressedKind;
1713
1714 NvU32 tag; // [IN] - memory tag used for debugging
1715} NV_MEMORY_HW_RESOURCES_ALLOCATION_PARAMS;
1716
1717/* function OS33 */
1718#define NV04_MAP_MEMORY (0x00000021)
1719
1720// Legacy map and unmap memory flags that don't use DRF_DEF scheme
1721#define NV04_MAP_MEMORY_FLAGS_NONE (0x00000000)
1722#define NV04_MAP_MEMORY_FLAGS_USER (0x00004000)
1723
1724// New map and unmap memory flags. These flags are used for both NvRmMapMemory
1725// and for NvRmUnmapMemory.
1726
1727// Mappings can have restricted permissions (read-only, write-only). Some
1728// RM implementations may choose to ignore these flags, or they may work
1729// only for certain memory spaces (system, video memory); in such cases,
1730// you may get a read/write mapping even if you asked for a read-only or
1731// write-only mapping.
1732#define NVOS33_FLAGS_ACCESS 1:0
1733#define NVOS33_FLAGS_ACCESS_READ_WRITE (0x00000000)
1734#define NVOS33_FLAGS_ACCESS_READ_ONLY (0x00000001)
1735#define NVOS33_FLAGS_ACCESS_WRITE_ONLY (0x00000002)
1736
1737// Persistent mappings are no longer supported
1738#define NVOS33_FLAGS_PERSISTENT 4:4
1739#define NVOS33_FLAGS_PERSISTENT_DISABLE (0x00000000)
1740#define NVOS33_FLAGS_PERSISTENT_ENABLE (0x00000001)
1741
1742// This flag is a hack to work around bug 150889. It disables the error
1743// checking in the RM that verifies that the client is not trying to map
1744// memory past the end of the memory object. This error checking needs to
1745// be shut off in some cases for a PAE bug workaround in certain kernels.
1746#define NVOS33_FLAGS_SKIP_SIZE_CHECK 8:8
1747#define NVOS33_FLAGS_SKIP_SIZE_CHECK_DISABLE (0x00000000)
1748#define NVOS33_FLAGS_SKIP_SIZE_CHECK_ENABLE (0x00000001)
1749
1750// Normally, a mapping is created in the same memory space as the client -- in
1751// kernel space for a kernel RM client, or in user space for a user RM client.
1752// However, a kernel RM client can specify MEM_SPACE:USER to create a user-space
1753// mapping in the current RM client.
1754#define NVOS33_FLAGS_MEM_SPACE 14:14
1755#define NVOS33_FLAGS_MEM_SPACE_CLIENT (0x00000000)
1756#define NVOS33_FLAGS_MEM_SPACE_USER (0x00000001)
1757
1758// The client can ask for direct memory mapping (i.e. no BAR1) if remappers and
1759// blocklinear are not required. RM can do direct mapping in this case if
1760// carveout is available.
1761// DEFAULT: Use direct mapping if available and no address/data translation
1762// is necessary; reflected otherwise
1763// DIRECT: Use direct mapping if available, even if some translation is
1764// necessary (the client is responsible for translation)
1765// REFLECTED: Always use reflected mapping
1766#define NVOS33_FLAGS_MAPPING 16:15
1767#define NVOS33_FLAGS_MAPPING_DEFAULT (0x00000000)
1768#define NVOS33_FLAGS_MAPPING_DIRECT (0x00000001)
1769#define NVOS33_FLAGS_MAPPING_REFLECTED (0x00000002)
1770
1771// The client requests a fifo mapping but doesn't know the offset or length
1772// DEFAULT: Do error check length and offset
1773// ENABLE: Don't error check length and offset but have the RM fill them in
1774#define NVOS33_FLAGS_FIFO_MAPPING 17:17
1775#define NVOS33_FLAGS_FIFO_MAPPING_DEFAULT (0x00000000)
1776#define NVOS33_FLAGS_FIFO_MAPPING_ENABLE (0x00000001)
1777
1778// The client can require that the CPU mapping be to a specific CPU address
1779// (akin to MAP_FIXED for mmap).
1780// DISABLED: RM will map the allocation at a CPU VA that RM selects.
1781// ENABLED: RM will map the allocation at the CPU VA specified by the address
1782// pass-back parameter to NvRmMapMemory
1783// NOTES:
1784// - Used for controlling CPU addresses in CUDA's unified CPU+GPU virtual
1785// address space
1786// - Only valid on NvRmMapMemory
1787// - Implemented on Unix but not VMware
1788#define NVOS33_FLAGS_MAP_FIXED 18:18
1789#define NVOS33_FLAGS_MAP_FIXED_DISABLE (0x00000000)
1790#define NVOS33_FLAGS_MAP_FIXED_ENABLE (0x00000001)
1791
1792// The client can specify to the RM that the CPU virtual address range for an
1793// allocation should remain reserved after the allocation is unmapped.
1794// DISABLE: When this mapping is destroyed, RM will unmap the CPU virtual
1795// address space used by this allocation. On Linux this corresponds
1796// to calling munmap on the CPU VA region.
1797// ENABLE: When the map object is freed, RM will leave the CPU virtual
1798// address space used by allocation reserved. On Linux this means
1799// that RM will overwrite the previous mapping with an anonymous
1800// mapping of instead calling munmap.
1801// NOTES:
1802// - When combined with MAP_FIXED, this allows the client to exert
1803// significant control over the CPU heap
1804// - Used in CUDA's unified CPU+GPU virtual address space
1805// - Valid in nvRmUnmapMemory
1806// - Valid on NvRmMapMemory (specifies RM's behavior whenever the
1807// mapping is destroyed, regardless of mechanism)
1808// - Implemented on Unix but not VMware
1809#define NVOS33_FLAGS_RESERVE_ON_UNMAP 19:19
1810#define NVOS33_FLAGS_RESERVE_ON_UNMAP_DISABLE (0x00000000)
1811#define NVOS33_FLAGS_RESERVE_ON_UNMAP_ENABLE (0x00000001)
1812
1813// Internal use only
1814#define NVOS33_FLAGS_OS_DESCRIPTOR 22:22
1815#define NVOS33_FLAGS_OS_DESCRIPTOR_DISABLE (0x00000000)
1816#define NVOS33_FLAGS_OS_DESCRIPTOR_ENABLE (0x00000001)
1817
1818//
1819// For use in the linux mapping path. This flag sets the
1820// caching mode for pcie BAR mappings (from nv_memory_type.h).
1821// Internal use only.
1822//
1823#define NVOS33_FLAGS_CACHING_TYPE 25:23
1824#define NVOS33_FLAGS_CACHING_TYPE_CACHED 0
1825#define NVOS33_FLAGS_CACHING_TYPE_UNCACHED 1
1826#define NVOS33_FLAGS_CACHING_TYPE_WRITECOMBINED 2
1827#define NVOS33_FLAGS_CACHING_TYPE_WRITEBACK 5
1828#define NVOS33_FLAGS_CACHING_TYPE_DEFAULT 6
1829#define NVOS33_FLAGS_CACHING_TYPE_UNCACHED_WEAK 7
1830
1831//
1832// For use when Hopper Confidential Compute is operating in devtools mode
1833// BAR1 access to CPR vidmem is blocked to CPU-RM by default when HCC is
1834// enabled in both devtools and prod modes. However, certain mappings are
1835// allowed to go through successfully only in devtools mode. For example,
1836// CPU mappings made on behalf of devtools, event buffer mappings are allowed
1837// to happen in devtools mode
1838//
1839#define NVOS33_FLAGS_ALLOW_MAPPING_ON_HCC 26:26
1840#define NVOS33_FLAGS_ALLOW_MAPPING_ON_HCC_NO (0x00000000)
1841#define NVOS33_FLAGS_ALLOW_MAPPING_ON_HCC_YES (0x00000001)
1842
1843/* parameters */
1844typedef struct
1845{
1846 NvHandle hClient;
1847 NvHandle hDevice; // device or sub-device handle
1848 NvHandle hMemory; // handle to memory object if provided -- NULL if not
1849 NvU64 offset NV_ALIGN_BYTES(8);
1850 NvU64 length NV_ALIGN_BYTES(8);
1851 NvP64 pLinearAddress NV_ALIGN_BYTES(8); // pointer for returned address
1852 NvU32 status;
1853 NvU32 flags;
1854} NVOS33_PARAMETERS;
1855
1856
1857/* function OS34 */
1858#define NV04_UNMAP_MEMORY (0x00000022)
1859
1860/* parameters */
1861typedef struct
1862{
1863 NvHandle hClient;
1864 NvHandle hDevice;
1865 NvHandle hMemory;
1866 NvP64 pLinearAddress NV_ALIGN_BYTES(8); // ptr to virtual address of mapped memory
1867 NvU32 status;
1868 NvU32 flags;
1869} NVOS34_PARAMETERS;
1870
1871/* function OS38 */
1872#define NV04_ACCESS_REGISTRY (0x00000026)
1873
1874/* parameter values */
1875#define NVOS38_ACCESS_TYPE_READ_DWORD 1
1876#define NVOS38_ACCESS_TYPE_WRITE_DWORD 2
1877#define NVOS38_ACCESS_TYPE_READ_BINARY 6
1878#define NVOS38_ACCESS_TYPE_WRITE_BINARY 7
1879
1880#define NVOS38_MAX_REGISTRY_STRING_LENGTH 256
1881#define NVOS38_MAX_REGISTRY_BINARY_LENGTH 256
1882
1883/* parameters */
1884typedef struct
1885{
1886 NvHandle hClient;
1887 NvHandle hObject;
1888 NvV32 AccessType;
1889
1890 NvV32 DevNodeLength;
1891 NvP64 pDevNode NV_ALIGN_BYTES(8);
1892
1893 NvV32 ParmStrLength;
1894 NvP64 pParmStr NV_ALIGN_BYTES(8);
1895
1896 NvV32 BinaryDataLength;
1897 NvP64 pBinaryData NV_ALIGN_BYTES(8);
1898
1899 NvV32 Data;
1900 NvV32 Entry;
1901 NvV32 status;
1902} NVOS38_PARAMETERS;
1903
1904#define NV04_ALLOC_CONTEXT_DMA (0x00000027)
1905
1906/* parameter values are the same as NVOS03 -- not repeated here */
1907
1908/* parameters */
1909typedef struct
1910{
1911 NvHandle hObjectParent;
1912 NvHandle hSubDevice;
1913 NvHandle hObjectNew;
1914 NvV32 hClass;
1915 NvV32 flags;
1916 NvU32 selector;
1917 NvHandle hMemory;
1918 NvU64 offset NV_ALIGN_BYTES(8);
1919 NvU64 limit NV_ALIGN_BYTES(8);
1920 NvV32 status;
1921} NVOS39_PARAMETERS;
1922
1923
1924#define NV04_GET_EVENT_DATA (0x00000028)
1925
1926typedef struct
1927{
1928 NvHandle hObject;
1929 NvV32 NotifyIndex;
1930
1931 //
1932 // Holds same information as that of nvgputypes.h::NvNotification's
1933 // info32 and info16.
1934 //
1935 NvV32 info32;
1936 NvU16 info16;
1937} NvUnixEvent;
1938
1939/* parameters */
1940typedef struct
1941{
1942 NvP64 pEvent NV_ALIGN_BYTES(8);
1943 NvV32 MoreEvents;
1944 NvV32 status;
1945} NVOS41_PARAMETERS;
1946
1947/* function NVOS43 -- deleted 4/09 */
1948/* #define NV04_UNIFIED_FREE (0x0000002B) */
1949
1950
1951#define NVSIM01_BUS_XACT (0x0000002C)
1952
1953/* parameters */
1954typedef struct
1955{
1956 NvHandle hClient; // n/a currently
1957 NvHandle hDevice; // n/a currently
1958 NvU32 offset; // phy bus offset
1959 NvU32 bar; // ~0 := phy addr, {0..2} specify gpu bar
1960 NvU32 bytes; // # of bytes
1961 NvU32 write; // 0 := read request
1962 NvU32 data; // in/out based upon 'write'
1963 NvU32 status;
1964} NVOS2C_PARAMETERS;
1965
1966/* function NVOS2D -- deleted 4/09 */
1967/* #define NVSIM01_BUS_GET_IFACES (0x0000002D) */
1968
1969
1970/* function OS46 */
1971#define NV04_MAP_MEMORY_DMA (0x0000002E)
1972
1973/* parameter values */
1974#define NVOS46_FLAGS_ACCESS 1:0
1975#define NVOS46_FLAGS_ACCESS_READ_WRITE (0x00000000)
1976#define NVOS46_FLAGS_ACCESS_READ_ONLY (0x00000001)
1977#define NVOS46_FLAGS_ACCESS_WRITE_ONLY (0x00000002)
1978
1979//
1980// Compute shaders support both 32b and 64b pointers. This allows mappings
1981// to be restricted to the bottom 4GB of the address space. How _DISABLE
1982// is handled is chip specific and may force a pointer above 4GB.
1983//
1984#define NVOS46_FLAGS_32BIT_POINTER 2:2
1985#define NVOS46_FLAGS_32BIT_POINTER_DISABLE (0x00000000)
1986#define NVOS46_FLAGS_32BIT_POINTER_ENABLE (0x00000001)
1987
1988#define NVOS46_FLAGS_PAGE_KIND 3:3
1989#define NVOS46_FLAGS_PAGE_KIND_PHYSICAL (0x00000000)
1990#define NVOS46_FLAGS_PAGE_KIND_VIRTUAL (0x00000001)
1991
1992#define NVOS46_FLAGS_CACHE_SNOOP 4:4
1993#define NVOS46_FLAGS_CACHE_SNOOP_DISABLE (0x00000000)
1994#define NVOS46_FLAGS_CACHE_SNOOP_ENABLE (0x00000001)
1995
1996// The client requests a CPU kernel mapping so that SW class could use it
1997// DEFAULT: Don't map CPU address
1998// ENABLE: Map CPU address
1999#define NVOS46_FLAGS_KERNEL_MAPPING 5:5
2000#define NVOS46_FLAGS_KERNEL_MAPPING_NONE (0x00000000)
2001#define NVOS46_FLAGS_KERNEL_MAPPING_ENABLE (0x00000001)
2002
2003//
2004// Compute shader access control.
2005// GPUs that support this feature set the NV0080_CTRL_DMA_CAPS_SHADER_ACCESS_SUPPORTED
2006// property. These were first supported in Kepler. _DEFAULT will match the ACCESS field.
2007//
2008#define NVOS46_FLAGS_SHADER_ACCESS 7:6
2009#define NVOS46_FLAGS_SHADER_ACCESS_DEFAULT (0x00000000)
2010#define NVOS46_FLAGS_SHADER_ACCESS_READ_ONLY (0x00000001)
2011#define NVOS46_FLAGS_SHADER_ACCESS_WRITE_ONLY (0x00000002)
2012#define NVOS46_FLAGS_SHADER_ACCESS_READ_WRITE (0x00000003)
2013
2014//
2015// How the PAGE_SIZE field is interpreted is architecture specific.
2016//
2017// On Curie chips it is ignored.
2018//
2019// On Tesla it is used to guide is used to select which type PDE
2020// to use. By default the RM will select 4KB for system memory
2021// and BIG (64KB) for video memory. BOTH is not supported.
2022//
2023// Likewise on Fermi this used to select the PDE type. Fermi cannot
2024// mix page sizes to a single mapping so the page size is determined
2025// at surface alloation time. 4KB or BIG may be specified but they
2026// must match the page size selected at allocation time. DEFAULT
2027// allows the RM to select either a single page size or both PDE,
2028// while BOTH forces the RM to select a dual page size PDE.
2029//
2030// BIG_PAGE = 64 KB on PASCAL
2031// = 64 KB or 128 KB on pre_PASCAL chips
2032//
2033// HUGE_PAGE = 2 MB on PASCAL
2034// = not supported on pre_PASCAL chips.
2035//
2036#define NVOS46_FLAGS_PAGE_SIZE 11:8
2037#define NVOS46_FLAGS_PAGE_SIZE_DEFAULT (0x00000000)
2038#define NVOS46_FLAGS_PAGE_SIZE_4KB (0x00000001)
2039#define NVOS46_FLAGS_PAGE_SIZE_BIG (0x00000002)
2040#define NVOS46_FLAGS_PAGE_SIZE_BOTH (0x00000003)
2041#define NVOS46_FLAGS_PAGE_SIZE_HUGE (0x00000004)
2042#define NVOS46_FLAGS_PAGE_SIZE_512M (0x00000005)
2043
2044// Some systems allow the device to use the system L3 cache when accessing the
2045// system memory. For example, the iGPU on T19X can allocate from the system L3
2046// provided the SoC L3 cache is configured for device allocation.
2047//
2048// NVOS46_FLAGS_SYSTEM_L3_ALLOC_DEFAULT - Use the default L3 allocation
2049// policy. When using this policy, device memory access will be coherent with
2050// non-snooping devices such as the display on Tegra.
2051//
2052// NVOS46_FLAGS_SYSTEM_L3_ALLOC_ENABLE_HINT - Enable L3 allocation if possible.
2053// When L3 allocation is enabled, device memory access may be cached, and the
2054// memory access will be coherent only with other snoop-enabled access. This
2055// flag is a hint and will be ignored if the system does not support L3
2056// allocation for the device. NVOS46_FLAGS_CACHE_SNOOP_ENABLE must also be set
2057// for this flag to be effective.
2058//
2059// Note: This flag is implemented only by rmapi_tegra. It is not implemented by
2060// Resman.
2061//
2062#define NVOS46_FLAGS_SYSTEM_L3_ALLOC 13:13
2063#define NVOS46_FLAGS_SYSTEM_L3_ALLOC_DEFAULT (0x00000000)
2064#define NVOS46_FLAGS_SYSTEM_L3_ALLOC_ENABLE_HINT (0x00000001)
2065
2066#define NVOS46_FLAGS_DMA_OFFSET_GROWS 14:14
2067#define NVOS46_FLAGS_DMA_OFFSET_GROWS_UP (0x00000000)
2068#define NVOS46_FLAGS_DMA_OFFSET_GROWS_DOWN (0x00000001)
2069
2070//
2071// DMA_OFFSET_FIXED is overloaded for two purposes.
2072//
2073// 1. For CTXDMA mappings that use DMA_UNICAST_REUSE_ALLOC_FALSE,
2074// DMA_OFFSET_FIXED_TRUE indicates to use the dmaOffset parameter
2075// for a fixed address allocation out of the VA space heap.
2076// DMA_OFFSET_FIXED_FALSE indicates dmaOffset input will be ignored.
2077//
2078// 2. For CTXDMA mappings that use DMA_UNICAST_REUSE_ALLOC_TRUE and
2079// for *ALL* non-CTXDMA mappings, DMA_OFFSET_FIXED_TRUE indicates
2080// to treat the input dmaOffset as an absolute virtual address
2081// instead of an offset relative to the virtual allocation being
2082// mapped into. Whether relative or absolute, the resulting
2083// virtual address *must* be contained within the specified
2084// virtual allocation.
2085//
2086// Internally, it is also required that the virtual address be aligned
2087// to the page size of the mapping (obviously cannot map sub-pages).
2088// For client flexibility the physical offset does not require page alignment.
2089// This is handled by adding the physical misalignment
2090// (internally called pteAdjust) to the returned virtual address.
2091// The *input* dmaOffset can account for this pteAdjust (or not),
2092// but the returned virtual address always will.
2093//
2094#define NVOS46_FLAGS_DMA_OFFSET_FIXED 15:15
2095#define NVOS46_FLAGS_DMA_OFFSET_FIXED_FALSE (0x00000000)
2096#define NVOS46_FLAGS_DMA_OFFSET_FIXED_TRUE (0x00000001)
2097
2098#define NVOS46_FLAGS_DISABLE_ENCRYPTION 16:16
2099#define NVOS46_FLAGS_DISABLE_ENCRYPTION_FALSE (0x00000000)
2100#define NVOS46_FLAGS_DISABLE_ENCRYPTION_TRUE (0x00000001)
2101
2102//
2103// DEFAULT - Use the cache policy set at allocation
2104// YES - Enable gpu caching
2105// NO - Disable gpu caching
2106//
2107#define NVOS46_FLAGS_GPU_CACHEABLE 18:17
2108#define NVOS46_FLAGS_GPU_CACHEABLE_DEFAULT (0x00000000)
2109#define NVOS46_FLAGS_GPU_CACHEABLE_YES (0x00000001)
2110#define NVOS46_FLAGS_GPU_CACHEABLE_NO (0x00000002)
2111#define NVOS46_FLAGS_GPU_CACHEABLE_INVALID (0x00000003)
2112
2113#define NVOS46_FLAGS_PAGE_KIND_OVERRIDE 19:19
2114#define NVOS46_FLAGS_PAGE_KIND_OVERRIDE_NO (0x00000000)
2115#define NVOS46_FLAGS_PAGE_KIND_OVERRIDE_YES (0x00000001)
2116
2117#define NVOS46_FLAGS_P2P 27:20
2118
2119#define NVOS46_FLAGS_P2P_ENABLE 21:20
2120#define NVOS46_FLAGS_P2P_ENABLE_NO (0x00000000)
2121#define NVOS46_FLAGS_P2P_ENABLE_YES (0x00000001)
2122#define NVOS46_FLAGS_P2P_ENABLE_NONE NVOS46_FLAGS_P2P_ENABLE_NO
2123#define NVOS46_FLAGS_P2P_ENABLE_SLI NVOS46_FLAGS_P2P_ENABLE_YES
2124#define NVOS46_FLAGS_P2P_ENABLE_NOSLI (0x00000002)
2125// Subdevice ID. Reserved 3 bits for the possibility of 8-way SLI
2126#define NVOS46_FLAGS_P2P_SUBDEVICE_ID 24:22
2127#define NVOS46_FLAGS_P2P_SUBDEV_ID_SRC NVOS46_FLAGS_P2P_SUBDEVICE_ID
2128#define NVOS46_FLAGS_P2P_SUBDEV_ID_TGT 27:25
2129#define NVOS46_FLAGS_TLB_LOCK 28:28
2130#define NVOS46_FLAGS_TLB_LOCK_DISABLE (0x00000000)
2131#define NVOS46_FLAGS_TLB_LOCK_ENABLE (0x00000001)
2132#define NVOS46_FLAGS_DMA_UNICAST_REUSE_ALLOC 29:29
2133#define NVOS46_FLAGS_DMA_UNICAST_REUSE_ALLOC_FALSE (0x00000000)
2134#define NVOS46_FLAGS_DMA_UNICAST_REUSE_ALLOC_TRUE (0x00000001)
2135//
2136// Force pte kind to compresssed for this and future mappings of the memory object
2137// Only affects mappings using NVOS46_FLAGS_PAGE_KIND_VIRTUAL
2138// Only has effect when physical allocation is compressed
2139//
2140#define NVOS46_FLAGS_ENABLE_FORCE_COMPRESSED_MAP 30:30
2141#define NVOS46_FLAGS_ENABLE_FORCE_COMPRESSED_MAP_FALSE (0x00000000)
2142#define NVOS46_FLAGS_ENABLE_FORCE_COMPRESSED_MAP_TRUE (0x00000001)
2143
2144//
2145// This flag must be used with caution. Improper use can leave stale entries in the TLB,
2146// and allow access to memory no longer owned by the RM client or cause page faults.
2147// Also see corresponding flag for NvUnmapMemoryDma.
2148//
2149#define NVOS46_FLAGS_DEFER_TLB_INVALIDATION 31:31
2150#define NVOS46_FLAGS_DEFER_TLB_INVALIDATION_FALSE (0x00000000)
2151#define NVOS46_FLAGS_DEFER_TLB_INVALIDATION_TRUE (0x00000001)
2152
2153//
2154// This flag is used on fully coherent platforms to specify whether the GPU cache
2155// should be snooped by the CPU or other IO devices for this mapping.
2156//
2157// Only takes effect if the physical memory is allocated with
2158// _ATTR_GPU_CACHE_SNOOPABLE_MAPPING indicating the decision
2159// should be deferred to map time.
2160//
2161#define NVOS46_FLAGS2_GPU_CACHE_SNOOP 1:0
2162#define NVOS46_FLAGS2_GPU_CACHE_SNOOP_DEFAULT (0x00000000)
2163#define NVOS46_FLAGS2_GPU_CACHE_SNOOP_ENABLE (0x00000001)
2164#define NVOS46_FLAGS2_GPU_CACHE_SNOOP_DISABLE (0x00000002)
2165
2166/* parameters */
2167typedef struct
2168{
2169 NvHandle hClient; // [IN] client handle
2170 NvHandle hDevice; // [IN] device handle for mapping
2171 NvHandle hDma; // [IN] dma handle for mapping
2172 NvHandle hMemory; // [IN] memory handle for mapping
2173 NvU64 offset NV_ALIGN_BYTES(8); // [IN] offset of region
2174 NvU64 length NV_ALIGN_BYTES(8); // [IN] limit of region
2175 NvV32 flags; // [IN] flags
2176 NvV32 flags2; // [IN] flags2
2177 NvV32 kindOverride; // [IN] page kind - applied if NVOS46_FLAGS_PAGE_KIND_OVERRIDE is YES
2178 NvU64 dmaOffset NV_ALIGN_BYTES(8); // [OUT] offset of mapping
2179 // [IN] if FLAGS_DMA_OFFSET_FIXED_TRUE
2180 // *OR* hDma is NOT a CTXDMA handle
2181 // (see NVOS46_FLAGS_DMA_OFFSET_FIXED)
2182 NvV32 status; // [OUT] status
2183} NVOS46_PARAMETERS;
2184
2185typedef NVOS46_PARAMETERS NV_MAP_MEMORY_DMA_PARAMETERS;
2186
2187/* function OS47 */
2188#define NV04_UNMAP_MEMORY_DMA (0x0000002F)
2189
2190#define NVOS47_FLAGS_DEFER_TLB_INVALIDATION 0:0
2191#define NVOS47_FLAGS_DEFER_TLB_INVALIDATION_FALSE (0x00000000)
2192#define NVOS47_FLAGS_DEFER_TLB_INVALIDATION_TRUE (0x00000001)
2193
2194/* parameters */
2195typedef struct
2196{
2197 NvHandle hClient; // [IN] client handle
2198 NvHandle hDevice; // [IN] device handle for mapping
2199 NvHandle hDma; // [IN] dma handle for mapping
2200 NvHandle hMemory; // [IN] memory handle for mapping
2201 NvV32 flags; // [IN] flags
2202 NvU64 dmaOffset NV_ALIGN_BYTES(8); // [IN] dma offset from NV04_MAP_MEMORY_DMA
2203 NvU64 size NV_ALIGN_BYTES(8); // [IN] size to unmap, 0 to unmap entire mapping
2204 NvV32 status; // [OUT] status
2205} NVOS47_PARAMETERS;
2206
2207typedef NVOS47_PARAMETERS NV_UNMAP_MEMORY_DMA_PARAMETERS;
2208
2209#define NV04_BIND_CONTEXT_DMA (0x00000031)
2210/* parameters */
2211typedef struct
2212{
2213 NvHandle hClient; // [IN] client handle
2214 NvHandle hChannel; // [IN] channel handle for binding
2215 NvHandle hCtxDma; // [IN] ctx dma handle for binding
2216 NvV32 status; // [OUT] status
2217} NVOS49_PARAMETERS;
2218
2219
2220/* function OS54 */
2221#define NV04_CONTROL (0x00000036)
2222
2223#define NVOS54_FLAGS_NONE (0x00000000)
2224#define NVOS54_FLAGS_IRQL_RAISED (0x00000001)
2225#define NVOS54_FLAGS_LOCK_BYPASS (0x00000002)
2226#define NVOS54_FLAGS_FINN_SERIALIZED (0x00000004)
2227
2228/* parameters */
2229typedef struct
2230{
2231 NvHandle hClient;
2232 NvHandle hObject;
2233 NvV32 cmd;
2234 NvU32 flags;
2235 NvP64 params NV_ALIGN_BYTES(8);
2236 NvU32 paramsSize;
2237 NvV32 status;
2238} NVOS54_PARAMETERS;
2239
2240/* RM Control header
2241 *
2242 * Replacement for NVOS54_PARAMETERS where embedded pointers are not allowed.
2243 * Input layout for user space RM Control calls should be:
2244 *
2245 * +--- NVOS63_PARAMETERS ---+--- RM Control parameters ---+
2246 *
2247 * NVOS63_PARAMETERS::paramsSize is the size of RM Control parameters
2248 *
2249 */
2250typedef struct
2251{
2252 NvHandle hClient; // [IN] client handle
2253 NvHandle hObject; // [IN] object handle
2254 NvV32 cmd; // [IN] control command ID
2255 NvU32 paramsSize; // [IN] size in bytes of the RM Control parameters
2256 NvV32 status; // [OUT] status
2257} NVOS63_PARAMETERS;
2258
2259
2260/* function OS55 */
2261#define NV04_DUP_OBJECT (0x00000037)
2262
2263/* parameters */
2264typedef struct
2265{
2266 NvHandle hClient; // [IN] destination client handle
2267 NvHandle hParent; // [IN] parent of new object
2268 NvHandle hObject; // [INOUT] destination (new) object handle
2269 NvHandle hClientSrc; // [IN] source client handle
2270 NvHandle hObjectSrc; // [IN] source (old) object handle
2271 NvU32 flags; // [IN] flags
2272 NvU32 status; // [OUT] status
2273} NVOS55_PARAMETERS;
2274
2275#define NV04_DUP_HANDLE_FLAGS_NONE (0x00000000)
2276#define NV04_DUP_HANDLE_FLAGS_REJECT_KERNEL_DUP_PRIVILEGE (0x00000001) // If set, prevents an RM kernel client from duping unconditionally
2277 // NOTE: Do not declare a NV04_DUP_HANDLE_FLAGS_* value of 0x00000008
2278 // until Bug 2859347 is resolved! This is due to conflicting usage
2279 // of RS_RES_DUP_PARAMS_INTERNAL.flags to pass
2280 // NVOS32_ALLOC_INTERNAL_FLAGS_FLA_MEMORY to an object constructor.
2281
2282/* function OS56 */
2283#define NV04_UPDATE_DEVICE_MAPPING_INFO (0x00000038)
2284
2285/* parameters */
2286typedef struct
2287{
2288 NvHandle hClient;
2289 NvHandle hDevice;
2290 NvHandle hMemory;
2291 NvP64 pOldCpuAddress NV_ALIGN_BYTES(8);
2292 NvP64 pNewCpuAddress NV_ALIGN_BYTES(8);
2293 NvV32 status;
2294} NVOS56_PARAMETERS;
2295
2296/* function OS57 */
2297#define NV04_SHARE (0x0000003E)
2298
2299/* parameters */
2300typedef struct
2301{
2302 NvHandle hClient; // [IN] owner client handle
2303 NvHandle hObject; // [IN] resource to share
2304 RS_SHARE_POLICY sharePolicy; // [IN] share policy entry
2305 NvU32 status; // [OUT] status
2306} NVOS57_PARAMETERS;
2307
2308/*!
2309 * @defgroup NVPOWERSTATE_STAGE
2310 *
2311 * An enumeration of various "stages" during @ref NVPOWERSTATE_PARAMETERS
2312 * processing, particularly for tracking failures during a given stage.
2313 *
2314 * @{
2315 */
2316typedef NvU32 NVPOWERSTATE_STAGE;
2317#define NVPOWERSTATE_STAGE_NONE 0U
2318#define NVPOWERSTATE_STAGE_WAIT_FOR_GFW_BOOT_OK 1U
2319#define NVPOWERSTATE_STAGE_INIT_LIBOS_LOGGING_STRUCTURES 2U
2320#define NVPOWERSTATE_STAGE_GSP_PREPARE_FOR_BOOTSTRAP 3U
2321#define NVPOWERSTATE_STAGE_GSP_BOOTSTRAP 4U
2322#define NVPOWERSTATE_STAGE_BOOT_GSP_RM_PROXY 5U
2323#define NVPOWERSTATE_STAGE_VBIOS_HANDLE_SECURE_BOOT 6U
2324#define NVPOWERSTATE_STAGE_RESTORE_PCIE_CONFIG_REGISTERS 7U
2325#define NVPOWERSTATE_STAGE_GCX_BOOT_TIMER_CB_SCHEDULE 8U
2326#define NVPOWERSTATE_STAGE_POWER_MANAGEMENT_RESUME_PRE_LOAD_PHYSICAL_UNATTACHED 9U
2327#define NVPOWERSTATE_STAGE_PMS_EXPECTED_CHECKPOINT_DONE 10U
2328#define NVPOWERSTATE_STAGE_POLL_FOR_NVLINK_READY 11U
2329#define NVPOWERSTATE_STAGE_CE_STATE_PRE_LOAD 12U
2330#define NVPOWERSTATE_STAGE_LOAD_PROXY_UCODE_EARLY_INIT 13U
2331#define NVPOWERSTATE_STAGE_RESTORE_NON_WPR_REGION 14U
2332#define NVPOWERSTATE_STAGE_PMU_20_OS_BOOTSTRAP 15U
2333#define NVPOWERSTATE_STAGE_STATE_PRE_LOAD_ENGINE 16U
2334#define NVPOWERSTATE_STAGE_STATE_PRE_LOAD_UNKNOWN 17U
2335#define NVPOWERSTATE_STAGE_STATE_LOAD_ENGINE 18U
2336#define NVPOWERSTATE_STAGE_STATE_LOAD_UNKNOWN 19U
2337#define NVPOWERSTATE_STAGE_STATE_LOAD_PHYSICAL 20U
2338#define NVPOWERSTATE_STAGE_STATE_POST_LOAD_ENGINE 21U
2339#define NVPOWERSTATE_STAGE_STATE_POST_LOAD_UNKNOWN 22U
2340#define NVPOWERSTATE_STAGE_GSP_PREPARE_SUSPEND_RESUME_DATA 23U
2341#define NVPOWERSTATE_STAGE_MC_POINTER_NULL 24U
2342#define NVPOWERSTATE_STAGE_SAVE_PCIE_CONFIG_REGISTERS 25U
2343#define NVPOWERSTATE_STAGE_STATE_PRE_UNLOAD_ENGINE 26U
2344#define NVPOWERSTATE_STAGE_STATE_PRE_UNLOAD_UNKNOWN 27U
2345#define NVPOWERSTATE_STAGE_STATE_UNLOAD_ENGINE 28U
2346#define NVPOWERSTATE_STAGE_STATE_UNLOAD_UNKNOWN 29U
2347#define NVPOWERSTATE_STAGE_STATE_POST_UNLOAD_ENGINE 30U
2348#define NVPOWERSTATE_STAGE_STATE_POST_UNLOAD_UNKNOWN 31U
2349#define NVPOWERSTATE_STAGE_GSP_UNLOAD_RM 32U
2350#define NVPOWERSTATE_STAGE_MONITOR_STATE_0 33U
2351#define NVPOWERSTATE_STAGE_MONITOR_STATE_1 34U
2352#define NVPOWERSTATE_STAGE_MONITOR_STATE_HIBERNATE 35U
2353#define NVPOWERSTATE_STAGE_SET_POWER_STATE_UNKNOWN 36U
2354#define NVPOWERSTATE_STAGE__COUNT 37U
2355/*!@}*/
2356
2357/*!
2358 * Common structure for any failure within a given GPU engine in a top-level GPU
2359 * state transition
2360 */
2361typedef struct
2362{
2363 /*!
2364 * NVOC class ID of the failing engine
2365 */
2366 NvU32 classId;
2367
2368 /*!
2369 * Time from beginning of the state transition to this engine's failure
2370 */
2371 NvU64 cumulativeTimeus;
2372
2373 /*!
2374 * Maximum time any of the engines took to transition
2375 */
2376 NvU32 engineMaxTimeus;
2377
2378 /*!
2379 * NVOC class ID of the engine that took the longest time to transition
2380 */
2381 NvU32 engineMaxTimeClassId;
2382} NVPOWERSTATE_FAILURE_ENGINE_TRANSITION;
2383
2384/*!
2385 * @defgroup NVPOWERSTATE_FAILURE_STRUCTURE
2386 *
2387 * A set of structures for capturing additional, failure-specific data in a
2388 * @ref NVPOWERSTATE_PARAMETERS processing failure.
2389 *
2390 * @note These structures should correspond 1:1 with the list of
2391 * @ref NVPOWERSTATE_STAGE values
2392 *
2393 * @{
2394 */
2395typedef struct
2396{
2397 NvU8 rsvd;
2398} NVPOWERSTATE_FAILURE_WAIT_FOR_GFW_BOOT_OK;
2399
2400typedef struct
2401{
2402 NvU8 rsvd;
2403} NVPOWERSTATE_FAILURE_INIT_LIBOS_LOGGING_STRUCTURES;
2404
2405typedef struct
2406{
2407 NvU8 rsvd;
2408} NVPOWERSTATE_FAILURE_GSP_PREPARE_FOR_BOOTSTRAP;
2409
2410typedef struct
2411{
2412 NvU8 rsvd;
2413} NVPOWERSTATE_FAILURE_GSP_BOOTSTRAP;
2414
2415typedef struct
2416{
2417 NvU8 rsvd;
2418} NVPOWERSTATE_FAILURE_BOOT_GSP_RM_PROXY;
2419
2420typedef struct
2421{
2422 NvU8 rsvd;
2423} NVPOWERSTATE_FAILURE_VBIOS_HANDLE_SECURE_BOOT;
2424
2425typedef struct
2426{
2427 NvU8 rsvd;
2428} NVPOWERSTATE_FAILURE_RESTORE_PCIE_CONFIG_REGISTERS;
2429
2430typedef struct
2431{
2432 NvU8 rsvd;
2433} NVPOWERSTATE_FAILURE_GCX_BOOT_TIMER_CB_SCHEDULE;
2434
2435typedef struct
2436{
2437 NvU8 rsvd;
2438} NVPOWERSTATE_FAILURE_POWER_MANAGEMENT_RESUME_PRE_LOAD_PHYSICAL_UNATTACHED;
2439
2440typedef struct
2441{
2442 NvU8 rsvd;
2443} NVPOWERSTATE_FAILURE_PMS_EXPECTED_CHECKPOINT_DONE;
2444
2445typedef struct
2446{
2447 NvU8 rsvd;
2448} NVPOWERSTATE_FAILURE_POLL_FOR_NVLINK_READY;
2449
2450typedef struct
2451{
2452 NvU8 rsvd;
2453} NVPOWERSTATE_FAILURE_CE_STATE_PRE_LOAD;
2454
2455typedef struct
2456{
2457 NvU8 rsvd;
2458} NVPOWERSTATE_FAILURE_LOAD_PROXY_UCODE_EARLY_INIT;
2459
2460typedef struct
2461{
2462 NvU8 rsvd;
2463} NVPOWERSTATE_FAILURE_RESTORE_NON_WPR_REGION;
2464
2465typedef struct
2466{
2467 NvU8 rsvd;
2468} NVPOWERSTATE_FAILURE_PMU_20_OS_BOOTSTRAP;
2469
2470typedef struct
2471{
2472 NVPOWERSTATE_FAILURE_ENGINE_TRANSITION engineTransition;
2473} NVPOWERSTATE_FAILURE_STATE_PRE_LOAD_ENGINE;
2474
2475typedef struct
2476{
2477 NvU8 rsvd;
2478} NVPOWERSTATE_FAILURE_STATE_PRE_LOAD_UNKNOWN;
2479
2480typedef struct
2481{
2482 NVPOWERSTATE_FAILURE_ENGINE_TRANSITION engineTransition;
2483} NVPOWERSTATE_FAILURE_STATE_LOAD_ENGINE;
2484
2485typedef struct
2486{
2487 NvU8 rsvd;
2488} NVPOWERSTATE_FAILURE_STATE_LOAD_UNKNOWN;
2489
2490typedef struct
2491{
2492 NVPOWERSTATE_FAILURE_ENGINE_TRANSITION engineTransition;
2493} NVPOWERSTATE_FAILURE_STATE_POST_LOAD_ENGINE;
2494
2495typedef struct
2496{
2497 NvU8 rsvd;
2498} NVPOWERSTATE_FAILURE_STATE_POST_LOAD_UNKNOWN;
2499
2500typedef struct
2501{
2502 NvU8 rsvd;
2503} NVPOWERSTATE_FAILURE_STATE_LOAD_PHYSICAL;
2504
2505typedef struct
2506{
2507 NvU8 rsvd;
2508} NVPOWERSTATE_FAILURE_GSP_PREPARE_SUSPEND_RESUME_DATA;
2509
2510typedef struct
2511{
2512 NvU8 rsvd;
2513} NVPOWERSTATE_FAILURE_MC_POINTER_NULL;
2514
2515typedef struct
2516{
2517 NvU8 rsvd;
2518} NVPOWERSTATE_FAILURE_SAVE_PCIE_CONFIG_REGISTERS;
2519
2520typedef struct
2521{
2522 NVPOWERSTATE_FAILURE_ENGINE_TRANSITION engineTransition;
2523} NVPOWERSTATE_FAILURE_STATE_PRE_UNLOAD_ENGINE;
2524
2525typedef struct
2526{
2527 NvU8 rsvd;
2528} NVPOWERSTATE_FAILURE_STATE_PRE_UNLOAD_UNKNOWN;
2529
2530typedef struct
2531{
2532 NVPOWERSTATE_FAILURE_ENGINE_TRANSITION engineTransition;
2533} NVPOWERSTATE_FAILURE_STATE_UNLOAD_ENGINE;
2534
2535typedef struct
2536{
2537 NvU8 rsvd;
2538} NVPOWERSTATE_FAILURE_STATE_UNLOAD_UNKNOWN;
2539
2540typedef struct
2541{
2542 NVPOWERSTATE_FAILURE_ENGINE_TRANSITION engineTransition;
2543} NVPOWERSTATE_FAILURE_STATE_POST_UNLOAD_ENGINE;
2544
2545typedef struct
2546{
2547 NvU8 rsvd;
2548} NVPOWERSTATE_FAILURE_STATE_POST_UNLOAD_UNKNOWN;
2549
2550typedef struct
2551{
2552 NvU8 rsvd;
2553} NVPOWERSTATE_FAILURE_GSP_UNLOAD_RM;
2554
2555typedef struct
2556{
2557 NvU8 rsvd;
2558} NVPOWERSTATE_FAILURE_MONITOR_STATE_0;
2559
2560typedef struct
2561{
2562 NvU8 rsvd;
2563} NVPOWERSTATE_FAILURE_MONITOR_STATE_1;
2564
2565typedef struct
2566{
2567 NvU8 rsvd;
2568} NVPOWERSTATE_FAILURE_MONITOR_STATE_HIBERNATE;
2569
2570typedef struct
2571{
2572 /*!
2573 * NV_POWER_ADAPTER_STATE_* value
2574 */
2575 NvU32 state;
2576} NVPOWERSTATE_FAILURE_SET_POWER_STATE_UNKNOWN;
2577/*!@}*/
2578
2579/*!
2580 * A union to hold failure-specific data for any failure that might happen while
2581 * doing @ref NVPOWERSTATE_PARAMETERS processing
2582 *
2583 * @note Entries in the union should correspond 1:1 with
2584 * @ref NVPOWERSTATE_STAGE values
2585 */
2586typedef union
2587{
2588 NVPOWERSTATE_FAILURE_WAIT_FOR_GFW_BOOT_OK waitForGfwBootOk;
2589 NVPOWERSTATE_FAILURE_INIT_LIBOS_LOGGING_STRUCTURES initLibosLoggingStructures;
2590 NVPOWERSTATE_FAILURE_GSP_PREPARE_FOR_BOOTSTRAP gspPrepareForBootstrap;
2591 NVPOWERSTATE_FAILURE_GSP_BOOTSTRAP gspBootstrap;
2592 NVPOWERSTATE_FAILURE_BOOT_GSP_RM_PROXY bootGspRmProxy;
2593 NVPOWERSTATE_FAILURE_VBIOS_HANDLE_SECURE_BOOT vbiosHandleSecureBoot;
2594 NVPOWERSTATE_FAILURE_RESTORE_PCIE_CONFIG_REGISTERS restorePcieConfigRegisters;
2595 NVPOWERSTATE_FAILURE_GCX_BOOT_TIMER_CB_SCHEDULE gcxBootTimerCbSchedule;
2596 NVPOWERSTATE_FAILURE_POWER_MANAGEMENT_RESUME_PRE_LOAD_PHYSICAL_UNATTACHED powerManagementResumePreLoadPhysicalUnattached;
2597 NVPOWERSTATE_FAILURE_PMS_EXPECTED_CHECKPOINT_DONE pmsExpectedCheckpointDone;
2598 NVPOWERSTATE_FAILURE_POLL_FOR_NVLINK_READY pollForNvlinkReady;
2599 NVPOWERSTATE_FAILURE_CE_STATE_PRE_LOAD ceStatePreLoad;
2600 NVPOWERSTATE_FAILURE_LOAD_PROXY_UCODE_EARLY_INIT loadProxyUcodeEarlyInit;
2601 NVPOWERSTATE_FAILURE_RESTORE_NON_WPR_REGION restoreNonWprRegion;
2602 NVPOWERSTATE_FAILURE_PMU_20_OS_BOOTSTRAP pmu20OsBootstrap;
2603 NVPOWERSTATE_FAILURE_STATE_PRE_LOAD_ENGINE statePreLoadEngine;
2604 NVPOWERSTATE_FAILURE_STATE_PRE_LOAD_UNKNOWN statePreLoadUnknown;
2605 NVPOWERSTATE_FAILURE_STATE_LOAD_ENGINE stateLoadEngine;
2606 NVPOWERSTATE_FAILURE_STATE_LOAD_UNKNOWN stateLoadUnknown;
2607 NVPOWERSTATE_FAILURE_STATE_POST_LOAD_ENGINE statePostLoadEngine;
2608 NVPOWERSTATE_FAILURE_STATE_POST_LOAD_UNKNOWN statePostLoadUnknown;
2609 NVPOWERSTATE_FAILURE_STATE_LOAD_PHYSICAL stateLoadPhysical;
2610 NVPOWERSTATE_FAILURE_GSP_PREPARE_SUSPEND_RESUME_DATA gspPrepareSuspendResumeData;
2611 NVPOWERSTATE_FAILURE_MC_POINTER_NULL mcPointerNull;
2612 NVPOWERSTATE_FAILURE_SAVE_PCIE_CONFIG_REGISTERS savePcieConfigRegisters;
2613 NVPOWERSTATE_FAILURE_STATE_PRE_UNLOAD_ENGINE statePreUnloadEngine;
2614 NVPOWERSTATE_FAILURE_STATE_PRE_UNLOAD_UNKNOWN statePreUnloadUnknown;
2615 NVPOWERSTATE_FAILURE_STATE_UNLOAD_ENGINE stateUnloadEngine;
2616 NVPOWERSTATE_FAILURE_STATE_UNLOAD_UNKNOWN stateUnloadUnknown;
2617 NVPOWERSTATE_FAILURE_STATE_POST_UNLOAD_ENGINE statePostUnloadEngine;
2618 NVPOWERSTATE_FAILURE_STATE_POST_UNLOAD_UNKNOWN statePostUnloadUnknown;
2619 NVPOWERSTATE_FAILURE_GSP_UNLOAD_RM gspUnloadRm;
2620 NVPOWERSTATE_FAILURE_MONITOR_STATE_0 monitorState0;
2621 NVPOWERSTATE_FAILURE_MONITOR_STATE_1 monitorState1;
2622 NVPOWERSTATE_FAILURE_MONITOR_STATE_HIBERNATE monitorStateHibernate;
2623 NVPOWERSTATE_FAILURE_SET_POWER_STATE_UNKNOWN setPowerStateUnknown;
2624} NVPOWERSTATE_FAILURE_DATA;
2625
2626/*!
2627 * Contains failure data for a failure that occurred during
2628 * @ref NVPOWERSTATE_PARAMETERS processing
2629 */
2630typedef struct
2631{
2632 /*!
2633 * The @ref NVPOWERSTATE_STAGE in which the failure occurred, or @ref
2634 * @ref NVPOWERSTATE_STAGE_NONE if no failure occurred.
2635 *
2636 * @note This field is the discriminant for
2637 * @ref NVPOWERSTATE_FAILURE::data
2638 */
2639 NVPOWERSTATE_STAGE stage;
2640
2641 /*!
2642 * The @ref NV_STATUS value from the failure
2643 */
2644 NV_STATUS status;
2645
2646 /*!
2647 * Failure-specific data
2648 *
2649 * @note Valid entry is determined by @ref NVPOWERSTATE_FAILURE::stage
2650 */
2651 NVPOWERSTATE_FAILURE_DATA data;
2652} NVPOWERSTATE_FAILURE;
2653
2654/*!
2655 * @brief Initializes a @ref NVPOWERSTATE_FAILURE for tracking
2656 * during a transition
2657 *
2658 * @param[out] pFailure
2659 * Pointer to @ref NVPOWERSTATE_FAILURE to initialize
2660 */
2661static NV_FORCEINLINE void
2662nvPowerStateFailureInit
2663(
2664 NVPOWERSTATE_FAILURE *pFailure
2665)
2666{
2667 (void)NVMISC_MEMSET(
2668 pFailure,
2669 0x0,
2670 sizeof(*pFailure));
2671}
2672
2673/*!
2674 * @brief Returns whether the given @ref NVPOWERSTATE_FAILURE is already
2675 * populated with error data
2676 *
2677 * @param[in] pFailure
2678 * @ref NVPOWERSTATE_FAILURE to check
2679 *
2680 * @return @ref NV_TRUE
2681 * Structure is already populated with failure data
2682 * @return @ref NV_FALSE
2683 * Otherwise
2684 */
2685static NV_FORCEINLINE NvBool
2686nvPowerStateFailureIsPopulated
2687(
2688 const NVPOWERSTATE_FAILURE *pFailure
2689)
2690{
2691 return pFailure->stage != NVPOWERSTATE_STAGE_NONE;
2692}
2693
2694/* parameters */
2695typedef struct
2696{
2697 NvU32 deviceReference;
2698 NvU32 head;
2699 NvU32 state;
2700 NvU8 forceMonitorState;
2701 NvU8 bForcePerfBiosLevel;
2702 NvU8 bIsD3HotTransition; // [OUT] To tell client if it's a D3Hot transition
2703 NvU8 bForcePowerStateFail;
2704 NvU32 errorStatus; // [OUT] To tell client if there is bubble up errors
2705 NvU32 fastBootPowerState;
2706 NvU8 bGC8Transition;
2707 NvU8 bGC8InputRailCutOff; // [OUT] To tell client if input rail was cut off in GC8
2708 NVPOWERSTATE_FAILURE failure;
2709} NVPOWERSTATE_PARAMETERS, *PNVPOWERSTATE_PARAMETERS;
2710
2711 /***************************************************************************\
2712|* Object Allocation Parameters *|
2713 \***************************************************************************/
2714
2715// GR engine creation parameters
2716typedef struct {
2717 NvU32 version; // set to 0x2
2718 NvU32 flags; // input param from a rm client (no flags are currently defined)
2719 NvU32 size; // sizeof(NV_GR_ALLOCATION_PARAMETERS)
2720 NvU32 caps; // output param for a rm client - class dependent
2721} NV_GR_ALLOCATION_PARAMETERS;
2722
2723//
2724// NvAlloc parameters for NV03_DEVICE_XX class
2725// hClientShare
2726// For NV50+ this can be set to virtual address space for this
2727// device. On previous chips this field is ignored. There are
2728// three possible settings
2729// NV01_NULL_OBJECT - Use the default global VA space
2730// Handle to current client - Create a new private address space
2731// Handle to another client - Attach to other clients address space
2732// flags
2733// MAP_PTE_GLOBALLY Deprecated.
2734// MINIMIZE_PTETABLE_SIZE Pass hint to DMA HAL to use partial page
2735// tables. Depending on allocation pattern
2736// this may actually use more instance memory.
2737// RETRY_PTE_ALLOC_IN_SYS Fallback to PTEs allocation in sysmem. This
2738// is now enabled by default.
2739// VASPACE_SIZE Honor vaSpaceSize field.
2740//
2741// MAP_PTE Deprecated.
2742//
2743// VASPACE_IS_MIRRORED This flag will tell RM to create a mirrored
2744// kernel PDB for the address space associated
2745// with this device. When this flag is set
2746// the address space covered by the top PDE
2747// is restricted and cannot be allocated out of.
2748//
2749//
2750// VASPACE_BIG_PAGE_SIZE_64k ***Warning this flag will be deprecated do not use*****
2751// VASPACE_BIG_PAGE_SIZE_128k This flag will choose the big page size of the VASPace
2752// to 64K/128k if the system supports a configurable size.
2753// If the system does not support a configurable size then
2754// defaults will be chosen.
2755// If the user sets both these bits then this API will fail.
2756//
2757// SHARED_MANAGEMENT
2758// *** Warning: This will be deprecated - see NV_VASPACE_ALLOCATION_PARAMETERS. ***
2759//
2760//
2761// hTargetClient/hTargetDevice
2762// Deprecated. Can be deleted once client code has removed references.
2763//
2764// vaBase
2765// *** Warning: This will be deprecated - see NV_VASPACE_ALLOCATION_PARAMETERS. ***
2766//
2767// vaSpaceSize
2768// Set the size of the VA space used for this client if allocating
2769// a new private address space. Is expressed as a size such as
2770// (1<<32) for a 32b address space. Reducing the size of the address
2771// space allows the dma chip specific code to reduce the instance memory
2772// used for page tables.
2773//
2774// vaMode
2775// The vaspace allocation mode. There are three modes supported:
2776// 1. SINGLE_VASPACE
2777// An old abstraction that provides a single VA space under a
2778// device and it's allocated implicityly when an object requires a VA
2779// space. Typically, this VA space is also shared across clients.
2780//
2781// 2. OPTIONAL_MULTIPLE_VASPACES
2782// Global + multiple private va spaces. In this mode, the old abstraction,
2783// a single vaspace under a device that is allocated implicitly is still
2784// being supported. A private VA space is an entity under a device, which/
2785// cannot be shared with other clients, but multiple channels under the
2786// same device can still share a private VA space.
2787// Private VA spaces (class:90f1,FERMI_VASPACE_A) can be allocated as
2788// objects through RM APIs. This mode requires the users to know what they
2789// are doing in terms of using VA spaces. Page fault can easily occur if
2790// one is not careful with a mixed of an implicit VA space and multiple
2791// VA spaces.
2792//
2793// 3. MULTIPLE_VASPACES
2794// In this mode, all VA spaces have to be allocated explicitly through RM
2795// APIs and users have to specify which VA space to use for each object.
2796// This case prevents users to use context dma, which is not supported and
2797// can be misleading if used. Therefore, it's more a safeguard mode to
2798// prevent people making mistakes that are hard to debug.
2799//
2800// DEFAULT MODE: 2. OPTIONAL_MULTIPLE_VASPACES
2801//
2802// See NV0080_ALLOC_PARAMETERS for allocation parameter structure.
2803//
2804
2805#define NV_DEVICE_ALLOCATION_SZNAME_MAXLEN 128
2806#define NV_DEVICE_ALLOCATION_FLAGS_NONE (0x00000000)
2807#define NV_DEVICE_ALLOCATION_FLAGS_MAP_PTE_GLOBALLY (0x00000001)
2808#define NV_DEVICE_ALLOCATION_FLAGS_MINIMIZE_PTETABLE_SIZE (0x00000002)
2809#define NV_DEVICE_ALLOCATION_FLAGS_RETRY_PTE_ALLOC_IN_SYS (0x00000004)
2810#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_SIZE (0x00000008)
2811#define NV_DEVICE_ALLOCATION_FLAGS_MAP_PTE (0x00000010)
2812#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_IS_TARGET (0x00000020)
2813#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_SHARED_MANAGEMENT (0x00000100)
2814#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_BIG_PAGE_SIZE_64k (0x00000200)
2815#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_BIG_PAGE_SIZE_128k (0x00000400)
2816#define NV_DEVICE_ALLOCATION_FLAGS_RESTRICT_RESERVED_VALIMITS (0x00000800)
2817
2818/*
2819 *TODO: Delete this flag once CUDA moves to the ctrl call
2820 */
2821#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_IS_MIRRORED (0x00000040)
2822
2823// XXX NV_DEVICE_ALLOCATION_FLAGS_VASPACE_PTABLE_PMA_MANAGED should not
2824// should not be exposed to clients. It should be the default RM
2825// behavior.
2826//
2827// Until it is made the default, certain clients such as OpenGL
2828// might still need PTABLE allocations to go through PMA, so this
2829// flag has been temporary exposed.
2830//
2831// See bug 1880192
2832#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_PTABLE_PMA_MANAGED (0x00001000)
2833
2834//
2835// Indicates this device is being created by guest and requires a
2836// KernelHostVgpuDeviceApi creation in client.
2837//
2838#define NV_DEVICE_ALLOCATION_FLAGS_HOST_VGPU_DEVICE (0x00002000)
2839
2840//
2841// Indicates this device is being created for VGPU plugin use.
2842// Requires a HostVgpuDevice handle to indicate the guest on which
2843// this plugin operates.
2844//
2845#define NV_DEVICE_ALLOCATION_FLAGS_PLUGIN_CONTEXT (0x00004000)
2846
2847//
2848// For clients using unlinked SLI to catch allocations attempts on secondary GPUs
2849// not accompanied by a fixed offset.
2850//
2851#define NV_DEVICE_ALLOCATION_FLAGS_VASPACE_REQUIRE_FIXED_OFFSET (0x00008000)
2852
2853#define NV_DEVICE_ALLOCATION_VAMODE_OPTIONAL_MULTIPLE_VASPACES (0x00000000)
2854#define NV_DEVICE_ALLOCATION_VAMODE_SINGLE_VASPACE (0x00000001)
2855#define NV_DEVICE_ALLOCATION_VAMODE_MULTIPLE_VASPACES (0x00000002)
2856
2857
2858#define NV_CHANNELGPFIFO_NOTIFICATION_TYPE_ERROR 0x00000000
2859#define NV_CHANNELGPFIFO_NOTIFICATION_TYPE_WORK_SUBMIT_TOKEN 0x00000001
2860#define NV_CHANNELGPFIFO_NOTIFICATION_TYPE_KEY_ROTATION_STATUS 0x00000002
2861#define NV_CHANNELGPFIFO_NOTIFICATION_TYPE__SIZE_1 3
2862#define NV_CHANNELGPFIFO_NOTIFICATION_STATUS_VALUE 14:0
2863#define NV_CHANNELGPFIFO_NOTIFICATION_STATUS_IN_PROGRESS 15:15
2864#define NV_CHANNELGPFIFO_NOTIFICATION_STATUS_IN_PROGRESS_TRUE 0x1
2865#define NV_CHANNELGPFIFO_NOTIFICATION_STATUS_IN_PROGRESS_FALSE 0x0
2866
2867typedef enum
2868{
2869 PB_SIZE_4KB = 0,
2870 PB_SIZE_8KB,
2871 PB_SIZE_16KB,
2872 PB_SIZE_32KB,
2873 PB_SIZE_64KB
2874} ChannelPBSize;
2875
2876typedef struct
2877{
2878 NvV32 channelInstance; // One of the n channel instances of a given channel type.
2879 // Note that core channel has only one instance
2880 // while all others have two (one per head).
2881 NvHandle hObjectBuffer; // ctx dma handle for DMA push buffer
2882 NvHandle hObjectNotify; // ctx dma handle for an area (of type NvNotification defined in sdk/nvidia/inc/nvtypes.h) where RM can write errors/notifications
2883 NvU32 offset; // Initial offset for put/get, usually zero.
2884 NvP64 pControl NV_ALIGN_BYTES(8); // pControl gives virt addr of UDISP GET/PUT regs
2885
2886 NvU32 flags;
2887 ChannelPBSize channelPBSize; // Size of Push Buffer requested by client (allowed values in enum)
2888#define NV50VAIO_CHANNELDMA_ALLOCATION_FLAGS_CONNECT_PB_AT_GRAB 1:1
2889#define NV50VAIO_CHANNELDMA_ALLOCATION_FLAGS_CONNECT_PB_AT_GRAB_YES 0x00000000
2890#define NV50VAIO_CHANNELDMA_ALLOCATION_FLAGS_CONNECT_PB_AT_GRAB_NO 0x00000001
2891
2892 NvU32 subDeviceId; // One-hot encoded subDeviceId (i.e. SDM) that will be used to address the channel in the pushbuffer stream (via SSDM method)
2893} NV50VAIO_CHANNELDMA_ALLOCATION_PARAMETERS;
2894
2895typedef struct
2896{
2897 NvV32 channelInstance; // One of the n channel instances of a given channel type.
2898 // All PIO channels have two instances (one per head).
2899 NvHandle hObjectNotify; // ctx dma handle for an area (of type NvNotification defined in sdk/nvidia/inc/nvtypes.h) where RM can write errors.
2900 NvP64 pControl NV_ALIGN_BYTES(8); // pControl gives virt addr of control region for PIO channel
2901} NV50VAIO_CHANNELPIO_ALLOCATION_PARAMETERS;
2902
2903// Used for allocating a channel group
2904typedef struct
2905{
2906 NvHandle hObjectError; // Error notifier for TSG
2907 NvHandle hObjectEccError; // ECC Error notifier for TSG
2908 NvHandle hVASpace; // VA space handle for TSG
2909 NvU32 engineType; // Engine to which all channels in this TSG are associated with
2910 NvBool bIsCallingContextVgpuPlugin;
2911} NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS;
2912
2913/*
2914* @params:
2915* @engineId : Engine to which the software runlist be associated with.
2916* @maxTSGs : Maximum number of TSG entries that will be submitted in this software runlist
2917* The size of the runlist buffer will be determined by
2918* 2 * // double buffer
2919* maxTSGs * // determined by KMD
2920* maxChannelPerTSG * // Determined by RM
2921* sizeof(RunlistEntry) // Determined by HW format
2922* @qosIntrEnableMask: QOS Interrupt bitmask that needs to be enabled for the SW runlist defined below.
2923*/
2924typedef struct
2925{
2926 NvU32 engineId; //(IN)
2927 NvU32 maxTSGs; //(IN) // Size of the RM could return error if the request cannot be accommodated.
2928 NvU32 qosIntrEnableMask; //(IN) // Bitmask for QOS interrupts that needs to be enabled
2929} NV_SWRUNLIST_ALLOCATION_PARAMS;
2930
2931#define NV_SWRUNLIST_QOS_INTR_NONE 0x00000000
2932#define NV_SWRUNLIST_QOS_INTR_RUNLIST_AND_ENG_IDLE_ENABLE NVBIT32(0)
2933#define NV_SWRUNLIST_QOS_INTR_RUNLIST_IDLE_ENABLE NVBIT32(1)
2934#define NV_SWRUNLIST_QOS_INTR_RUNLIST_ACQUIRE_ENABLE NVBIT32(2)
2935#define NV_SWRUNLIST_QOS_INTR_RUNLIST_ACQUIRE_AND_ENG_IDLE_ENABLE NVBIT32(3)
2936
2937typedef struct
2938{
2939 NvU32 size;
2940 NvU32 caps;
2941} NV_ME_ALLOCATION_PARAMETERS;
2942
2943typedef struct
2944{
2945 NvU32 size;
2946 NvU32 prohibitMultipleInstances;
2947 NvU32 engineInstance; // Select NVDEC0 or NVDEC1 or NVDEC2
2948} NV_BSP_ALLOCATION_PARAMETERS;
2949
2950//
2951// These are referenced by mdiag mods tests, but do not appear to be used during
2952// in the RM any longer
2953//
2954#define NV_VP_ALLOCATION_FLAGS_STANDARD_UCODE (0x00000000)
2955#define NV_VP_ALLOCATION_FLAGS_STATIC_UCODE (0x00000001)
2956#define NV_VP_ALLOCATION_FLAGS_DYNAMIC_UCODE (0x00000002)
2957
2958//
2959// NV_VP_ALLOCATION_PARAMETERS.flags
2960//
2961// NV_VP_ALLOCATION_FLAGS_AVP_CLIENT are used by Tegra to specify if
2962// the current allocation with be used by Video or Audio
2963//
2964#define NV_VP_ALLOCATION_FLAGS_AVP_CLIENT_VIDEO (0x00000000)
2965#define NV_VP_ALLOCATION_FLAGS_AVP_CLIENT_AUDIO (0x00000001)
2966
2967typedef struct
2968{
2969 NvU32 size;
2970 NvU32 caps;
2971 NvU32 flags;
2972 NvU32 altUcode;
2973 NvP64 rawUcode NV_ALIGN_BYTES(8);
2974 NvU32 rawUcodeSize;
2975 NvU32 numSubClasses;
2976 NvU32 numSubSets;
2977 NvP64 subClasses NV_ALIGN_BYTES(8);
2978 NvU32 prohibitMultipleInstances;
2979 NvP64 pControl NV_ALIGN_BYTES(8); // Used by Tegra to return a mapping to NvE276Control
2980 NvHandle hMemoryCmdBuffer NV_ALIGN_BYTES(8); // Used by Tegra to specify cmd buffer
2981 NvU64 offset NV_ALIGN_BYTES(8); // Used by Tegra to specify an offset into the cmd buffer
2982
2983} NV_VP_ALLOCATION_PARAMETERS;
2984
2985typedef struct
2986{
2987 NvU32 size;
2988 NvU32 prohibitMultipleInstances;
2989} NV_PPP_ALLOCATION_PARAMETERS;
2990
2991typedef struct
2992{
2993 NvU32 size;
2994 NvU32 prohibitMultipleInstances; // Prohibit multiple allocations of MSENC?
2995 NvU32 engineInstance; // Select MSENC/NVENC0 or NVENC1 or NVENC2
2996} NV_MSENC_ALLOCATION_PARAMETERS;
2997
2998typedef struct
2999{
3000 NvU32 size;
3001 NvU32 prohibitMultipleInstances; // Prohibit multiple allocations of SEC2?
3002} NV_SEC2_ALLOCATION_PARAMETERS;
3003
3004typedef struct
3005{
3006 NvU32 size;
3007 NvU32 prohibitMultipleInstances; // Prohibit multiple allocations of NVJPG?
3008 NvU32 engineInstance;
3009} NV_NVJPG_ALLOCATION_PARAMETERS;
3010
3011typedef struct
3012{
3013 NvU32 size;
3014 NvU32 prohibitMultipleInstances; // Prohibit multiple allocations of OFA?
3015 NvU32 engineInstance;
3016} NV_OFA_ALLOCATION_PARAMETERS;
3017
3018#define NV04_ADD_VBLANK_CALLBACK (0x0000003D)
3019
3020#include "class/cl9010.h" // for OSVBLANKCALLBACKPROC
3021
3022/* parameters */
3023/* NOTE: the "void* pParm's" below are ok (but unfortunate) since this interface
3024 can only be used by other kernel drivers which must share the same ptr-size */
3025typedef struct
3026{
3027 NvHandle hClient; // [IN] client handle
3028 NvHandle hDevice; // [IN] device handle for mapping
3029 NvHandle hVblank; // [IN] Vblank handle for control
3030 OSVBLANKCALLBACKPROC pProc; // Routine to call at vblank time
3031
3032 NvV32 LogicalHead; // Logical Head
3033 void *pParm1;
3034 void *pParm2;
3035 NvU32 bAdd; // Add or Delete
3036 NvV32 status; // [OUT] status
3037} NVOS61_PARAMETERS;
3038
3039/**
3040 * @brief NvAlloc parameters for VASPACE classes
3041 *
3042 * Used to create a new private virtual address space.
3043 *
3044 * index
3045 * Tegra: With TEGRA_VASPACE_A, index specifies the IOMMU
3046 * virtual address space to be created. Based on the
3047 * index, RM/NVMEM will decide the HW ASID to be used with
3048 * this VA Space. "index" takes values from the
3049 * NVMEM_CLIENT_* defines in
3050 * "drivers/common/inc/tegra/memory/ioctl.h".
3051 *
3052 * Big GPU: With FERMI_VASPACE_A, see NV_VASPACE_ALLOCATION_INDEX_GPU_*.
3053 *
3054 * flags
3055 * MINIMIZE_PTETABLE_SIZE Pass hint to DMA HAL to use partial page tables.
3056 * Depending on allocation pattern this may actually
3057 * use more instance memory.
3058 *
3059 * RETRY_PTE_ALLOC_IN_SYS Fallback to PTEs allocation in sysmem. This is now
3060 * enabled by default.
3061 *
3062 * SHARED_MANAGEMENT
3063 * Indicates management of the VA space is shared with another
3064 * component (e.g. driver layer, OS, etc.).
3065 *
3066 * The initial VA range from vaBase (inclusive) through vaSize (exclusive)
3067 * is managed by RM. The range must be aligned to a top-level PDE's VA
3068 * coverage since backing page table levels for this range are managed by RM.
3069 * All normal RM virtual memory management APIs work within this range.
3070 *
3071 * An external component can manage the remaining VA ranges,
3072 * from 0 (inclusive) to vaBase (exclusive) and from vaSize (inclusive) up to the
3073 * maximum VA limit supported by HW.
3074 * Management of these ranges includes VA sub-allocation and the
3075 * backing lower page table levels.
3076 *
3077 * The top-level page directory is special since it is a shared resource.
3078 * Management of the page directory is as follows:
3079 * 1. Initially RM allocates a page directory for RM-managed PDEs.
3080 * 2. The external component may create a full page directory and commit it
3081 * with NV0080_CTRL_CMD_DMA_SET_PAGE_DIRECTORY.
3082 * This will copy the RM-managed PDEs from the RM-managed page directory
3083 * into the external page directory and commit channels to the external page directory.
3084 * After this point RM will update the external page directory directly for
3085 * operations that modify RM-managed PDEs.
3086 * 3. The external component may use NV0080_CTRL_CMD_DMA_SET_PAGE_DIRECTORY repeatedly
3087 * if it needs to update the page directory again (e.g. to resize or migrate).
3088 * This will copy the RM-managed PDEs from the old external page directory
3089 * into the new external page directory and commit channels to the new page directory.
3090 * 4. The external component may restore management of the page directory back to
3091 * RM with NV0080_CTRL_CMD_DMA_UNSET_PAGE_DIRECTORY.
3092 * This will copy the RM-managed PDEs from the external page directory
3093 * into the RM-managed page directory and commit channels to the RM-managed page directory.
3094 * After this point RM will update the RM-managed page directory for
3095 * operations that modify RM-managed PDEs.
3096 * Note that operations (2) and (4) are symmetric - the RM perspective of management is identical
3097 * before and after a sequence of SET => ... => UNSET.
3098 *
3099 * IS_MIRRORED <to be deprecated once CUDA uses EXTERNALLY_MANAGED>
3100 * This flag will tell RM to create a mirrored
3101 * kernel PDB for the address space associated
3102 * with this device. When this flag is set
3103 * the address space covered by the top PDE
3104 * is restricted and cannot be allocated out of.
3105 * ENABLE_PAGE_FAULTING
3106 * Enable page faulting if the architecture supports it.
3107 * As of now page faulting is only supported for compute on pascal+.
3108 * IS_EXTERNALLY_OWNED
3109 * This vaspace that has been allocated will be managed by
3110 * an external driver. RM will not own the pagetables for this vaspace.
3111 *
3112 * ENABLE_NVLINK_ATS
3113 * Enables VA translation for this address space using NVLINK ATS.
3114 * Note, the GMMU page tables still exist and take priority over NVLINK ATS.
3115 * VA space object creation will fail if:
3116 * - hardware support is not available (NV_ERR_NOT_SUPPORTED)
3117 * - incompatible options IS_MIRRORED or IS_EXTERNALLY_OWNED are set (NV_ERR_INVALID_ARGUMENT)
3118 * IS_FLA
3119 * Sets FLA flag for this VASPACE
3120 *
3121 * ALLOW_ZERO_ADDRESS
3122 * Allows VASPACE Range to start from zero
3123 * SKIP_SCRUB_MEMPOOL
3124 * Skip scrubbing in MemPool
3125 *
3126 * vaBase [in, out]
3127 * On input, the lowest usable base address of the VA space.
3128 * If 0, RM will pick a default value - 0 is always reserved to respresent NULL pointers.
3129 * The value must be aligned to the largest page size of the VA space.
3130 * Larger values aid in debug since offsets added to NULL pointers will still fault.
3131 *
3132 * On output, the actual usable base address is returned.
3133 *
3134 * vaSize [in,out]
3135 * On input, requested size of the virtual address space in bytes.
3136 * Requesting a smaller size reduces the memory required for the initial
3137 * page directory, but the VAS may be resized later (NV0080_CTRL_DMA_SET_VA_SPACE_SIZE).
3138 * If 0, the default VA space size will be used.
3139 *
3140 * On output, the actual size of the VAS in bytes.
3141 * NOTE: This corresponds to the VA_LIMIT + 1, so the usable size is (vaSize - vaBase).
3142 *
3143 * bigPageSIze
3144 * Set the size of the big page in this address space object. Current HW supports
3145 * either 64k or 128k as the size of the big page. HW that support multiple big
3146 * page size per address space will use this size. Hw that do not support this feature
3147 * will override to the default big page size that is supported by the system.
3148 * If the big page size value is set to ZERO then we will pick the default page size
3149 * of the system.
3150 * pasid
3151 * Process Address Space Identifier. Used by RM internally when
3152 * NV_VASPACE_ALLOCATION_FLAGS_ENABLE_NVLINK_ATS_TEST is set
3153 **/
3154typedef struct
3155{
3156 NvU32 index;
3157 NvV32 flags;
3158 NvU64 vaSize NV_ALIGN_BYTES(8);
3159 NvU64 vaStartInternal NV_ALIGN_BYTES(8);
3160 NvU64 vaLimitInternal NV_ALIGN_BYTES(8);
3161 NvU32 bigPageSize;
3162 NvU64 vaBase NV_ALIGN_BYTES(8);
3163 NvU32 pasid;
3164} NV_VASPACE_ALLOCATION_PARAMETERS;
3165
3166#define NV_VASPACE_ALLOCATION_FLAGS_NONE (0x00000000)
3167#define NV_VASPACE_ALLOCATION_FLAGS_MINIMIZE_PTETABLE_SIZE BIT(0)
3168#define NV_VASPACE_ALLOCATION_FLAGS_RETRY_PTE_ALLOC_IN_SYS BIT(1)
3169#define NV_VASPACE_ALLOCATION_FLAGS_SHARED_MANAGEMENT BIT(2)
3170#define NV_VASPACE_ALLOCATION_FLAGS_IS_EXTERNALLY_OWNED BIT(3)
3171#define NV_VASPACE_ALLOCATION_FLAGS_ENABLE_NVLINK_ATS BIT(4)
3172#define NV_VASPACE_ALLOCATION_FLAGS_IS_MIRRORED BIT(5)
3173#define NV_VASPACE_ALLOCATION_FLAGS_ENABLE_PAGE_FAULTING BIT(6)
3174#define NV_VASPACE_ALLOCATION_FLAGS_VA_INTERNAL_LIMIT BIT(7)
3175#define NV_VASPACE_ALLOCATION_FLAGS_ALLOW_ZERO_ADDRESS BIT(8)
3176#define NV_VASPACE_ALLOCATION_FLAGS_IS_FLA BIT(9)
3177#define NV_VASPACE_ALLOCATION_FLAGS_SKIP_SCRUB_MEMPOOL BIT(10)
3178#define NV_VASPACE_ALLOCATION_FLAGS_OPTIMIZE_PTETABLE_MEMPOOL_USAGE BIT(11)
3179#define NV_VASPACE_ALLOCATION_FLAGS_REQUIRE_FIXED_OFFSET BIT(12)
3180#define NV_VASPACE_ALLOCATION_FLAGS_PTETABLE_HEAP_MANAGED BIT(13)
3181// To be used only by SRT for testing ATS within RM
3182#define NV_VASPACE_ALLOCATION_FLAGS_ENABLE_NVLINK_ATS_TEST BIT(14)
3183
3184#define NV_VASPACE_ALLOCATION_INDEX_GPU_NEW 0x00 //<! Create new VASpace, by default
3185#define NV_VASPACE_ALLOCATION_INDEX_GPU_HOST 0x01 //<! Acquire reference to BAR1 VAS.
3186#define NV_VASPACE_ALLOCATION_INDEX_GPU_GLOBAL 0x02 //<! Acquire reference to global VAS.
3187#define NV_VASPACE_ALLOCATION_INDEX_GPU_DEVICE 0x03 //<! Acquire reference to device vaspace
3188#define NV_VASPACE_ALLOCATION_INDEX_GPU_FLA 0x04 //<! Acquire reference to FLA VAS.
3189#define NV_VASPACE_ALLOCATION_INDEX_GPU_MAX 0x05 //<! Increment this on adding index entries
3190
3191
3192#define NV_VASPACE_BIG_PAGE_SIZE_64K (64 * 1024)
3193#define NV_VASPACE_BIG_PAGE_SIZE_128K (128 * 1024)
3194
3195/**
3196 * @brief NvAlloc parameters for FERMI_CONTEXT_SHARE_A class
3197 *
3198 * Used to create a new context share object for use by a TSG channel.
3199 * Context share is now used to represent a subcontext within a TSG.
3200 * Refer subcontexts-rm-design.docx for more details.
3201 *
3202 * hVASpace
3203 * Handle of VA Space object associated with the context share.
3204 * All channels using the same using the context share the same va space.
3205 *
3206 * flags
3207 * Options for the context share allocation.
3208 *
3209 * NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT
3210 * Used to specify the subcontext slot
3211 * SYNC
3212 * Use synchronous graphics & compute subcontext
3213 * In VOLTA+ chips, this represent VEID 0
3214 * In pre-VOLTA chips, this represent SCG type 0
3215 * ASYNC
3216 * Use asynchronous compute subcontext
3217 * In VOLTA+ chips, this represent a VEID greater than 0
3218 * In pre-VOLTA chips, this represent SCG type 1
3219 * SPECIFIED
3220 * Force the VEID specified in the subctxId parameter.
3221 * This flag is intended for verif. i.e testing VEID reuse etc.
3222 * PREFER_LOWER
3223 * Identical behavior to ASYNC, except lower VEIDs are preferred on VOLTA+ chips
3224 *
3225 *
3226 * subctxId
3227 * As input, it is used to specify the subcontext ID, when the _SPECIFIED flag is set.
3228 * As output, it is used to return the subcontext ID allocated by RM.
3229 * This field is intended for verif.
3230 **/
3231
3232typedef struct
3233{
3234 NvHandle hVASpace;
3235 NvU32 flags;
3236 NvU32 subctxId;
3237} NV_CTXSHARE_ALLOCATION_PARAMETERS;
3238
3239#define NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT 1:0
3240#define NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT_SYNC (0x00000000)
3241#define NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT_ASYNC (0x00000001)
3242#define NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT_SPECIFIED (0x00000002)
3243#define NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT_ASYNC_PREFER_LOWER (0x00000003)
3244
3245/*
3246 * The high bit of NV_CTXSHARE_ALLOCATION_PARAMETERS.subctxId is used to indicate success or failure allocating
3247 * a subcontext ID below an architecture specific value, which can be queried with
3248 * NV2080_CTRL_FIFO_INFO_INDEX_MAX_LOWER_SUBCONTEXT. Remaining bits are currently reserved for the subcontext ID.
3249 */
3250#define NV_CTXSHARE_ALLOCATION_SUBCTXID_SUBCTXID 30:0
3251#define NV_CTXSHARE_ALLOCATION_SUBCTXID_ASYNC_PREFER_LOWER_ALLOCATION 31:31
3252#define NV_CTXSHARE_ALLOCATION_SUBCTXID_ASYNC_PREFER_LOWER_ALLOCATION_SUCCESS (0x00000001)
3253#define NV_CTXSHARE_ALLOCATION_SUBCTXID_ASYNC_PREFER_LOWER_ALLOCATION_FAIL (0x00000000)
3254
3255/**
3256 * @brief RmTimeoutControl parameters
3257 *
3258 * Used to set various timeout-related features in RM.
3259 *
3260 * cmd
3261 * The timeout-related command to issue to RM.
3262 *
3263 * value
3264 * Used by command, such as the timeout to be set, in milliseconds.
3265 **/
3266
3267typedef struct
3268{
3269 NvU32 cmd;
3270 NvU32 timeoutInMs;
3271 NvU32 deviceInstance;
3272} NV_TIMEOUT_CONTROL_PARAMETERS;
3273
3274#define NV_TIMEOUT_CONTROL_CMD_SET_DEVICE_TIMEOUT (0x00000002)
3275#define NV_TIMEOUT_CONTROL_CMD_RESET_DEVICE_TIMEOUT (0x00000003)
3276
3277// NV_TIMEOUT_CONTROL_CMD_SET_DEVICE_TIMEOUT sets a maximum timeout value for
3278// any RM call on a specific device on any thread. It uses 'timeoutInMs'
3279// as the target timeout and 'deviceInstance' as the target device.
3280
3281// NV_TIMEOUT_CONTROL_CMD_RESET_DEVICE_TIMEOUT resets the device timeout to its
3282// default value. It uses 'deviceInstance' as the target device.
3283
3284/*
3285 * NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_COH
3286 * NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_DEFAULT
3287 * Location is Coherent System memory (also the default option)
3288 * NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_NCOH
3289 * Location is Non-Coherent System memory
3290 * NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_VID
3291 * Location is FB
3292 *
3293 * Currently only used by MODS for the V1 VAB interface. To be deleted.
3294 */
3295typedef enum
3296{
3297 NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_DEFAULT = 0,
3298 NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_COH,
3299 NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_NCOH,
3300 NV_VIDMEM_ACCESS_BIT_BUFFER_ADDR_SPACE_VID
3301} NV_VIDMEM_ACCESS_BIT_ALLOCATION_PARAMS_ADDR_SPACE;
3302
3303/**
3304 * @brief Multiclient vidmem access bit allocation params
3305 */
3306typedef struct
3307{
3308 /* [OUT] Dirty/Access tracking */
3309 NvBool bDirtyTracking;
3310 /* [OUT] Current tracking granularity */
3311 NvU32 granularity;
3312 /* [OUT] 512B Access bit mask with 1s set on
3313 bits that are reserved for this client */
3314 NV_DECLARE_ALIGNED(NvU64 accessBitMask[64], 8);
3315 /* Number of entries of vidmem access buffer. Used by VAB v1 - to be deleted */
3316 NvU32 noOfEntries;
3317 /* Address space of the vidmem access bit buffer. Used by VAB v1 - to be deleted */
3318 NV_VIDMEM_ACCESS_BIT_ALLOCATION_PARAMS_ADDR_SPACE addrSpace;
3319} NV_VIDMEM_ACCESS_BIT_ALLOCATION_PARAMS;
3320
3321/**
3322 * @brief HopperUsermodeAParams
3323 * This set of optionalparameters is passed in on allocation of
3324 * HOPPER_USERMODE_A object to specify whether a BAR1/GMMU
3325 * privileged/non-privileged mapping is needed.
3326 */
3327
3328typedef struct
3329{
3330 /**
3331 * [IN] Whether to allocate GMMU/BAR1 mapping or BAR0 mapping.
3332 */
3333 NvBool bBar1Mapping;
3334 /* [IN] Whether to allocate the PRIV page or regular VF page */
3335 NvBool bPriv;
3336} NV_HOPPER_USERMODE_A_PARAMS;
3337
3338
3339#ifdef __cplusplus
3340};
3341#endif
3342#endif /* NVOS_INCLUDED */