NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release

Detailed Description

List of APIs to initialize/de-initialize NvSciBuf module.

Functions

NvSciError NvSciBufModuleOpen (NvSciBufModule *newModule)
 Initializes and returns a new NvSciBufModule with no NvSciBufAttrLists, buffers, or NvSciBufObjs bound to it. More...
 
void NvSciBufModuleClose (NvSciBufModule module)
 Releases the NvSciBufModule obtained through an earlier call to NvSciBufModuleOpen(). More...
 
NvSciError NvSciBufCheckVersionCompatibility (uint32_t majorVer, uint32_t minorVer, bool *isCompatible)
 Checks if loaded NvSciBuf library version is compatible with NvSciBuf library version with which elements dependent on NvSciBuf were built. More...
 
NvSciError NvSciBufObjValidate (NvSciBufObj bufObj)
 Validates the NvSciBufObj satisfies the constraints of the NvSciBufAttrList that it is associated with. More...
 
NvSciError NvSciBufAttrListValidateReconciledAgainstAttrs (const NvSciBufAttrList reconciledAttrList, const NvSciBufAttrKeyValuePair *pairArray, const size_t pairCount)
 Validate the reconciled NvSciBufAttrList against the set of all attributes that the user has set in the unreconciled NvSciBufAttrList(s). More...
 
NvSciError NvSciBufObjGetMaxPerm (const NvSciBufObj bufObj, const NvSciIpcEndpoint ipcEndpoint, NvSciBufAttrValAccessPerm *accPerm)
 Retrieve the NvSciBufAttrValAccessPerm of an NvSciBufObj for given NvSciIpcEndpoint. More...
 
NvSciError NvSciBufObjGetDmaBufFd (NvSciBufObj bufObj, int *fd)
 Generate a new dma-buf file descriptor corresponding to the provided NvSciBufObj. More...
 
NvSciError NvSciBufObjGetDmaMap (NvSciBufObj bufObj, uint64_t hid, uint64_t *pIovaAddr)
 Map the buffer represented by bufObj into a hardware engine's IOVA space via the SMMU and return the contiguous IOVA address. More...
 
NvSciError NvSciBufObjGetDmaMapAtAddr (NvSciBufObj bufObj, uint64_t hid, uint64_t fixedIovaAddr, uint64_t *pActualIovaAddr)
 Same as NvSciBufObjGetDmaMap, but install the mapping at a caller-specified IOVA. More...
 
NvSciError NvSciBufObjUnmapDma (NvSciBufObj bufObj, uint64_t hid, uint64_t iovaAddr)
 Tear down a DMA IOVA mapping previously created via either NvSciBufObjGetDmaMap or NvSciBufObjGetDmaMapAtAddr. More...
 

Function Documentation

◆ NvSciBufAttrListValidateReconciledAgainstAttrs()

NvSciError NvSciBufAttrListValidateReconciledAgainstAttrs ( const NvSciBufAttrList  reconciledAttrList,
const NvSciBufAttrKeyValuePair *  pairArray,
const size_t  pairCount 
)

Validate the reconciled NvSciBufAttrList against the set of all attributes that the user has set in the unreconciled NvSciBufAttrList(s).

This API provides the safety mechanism to detect and report any reconciliation errors.

Parameters
[in]reconciledAttrListreconciled NvSciBufAttrList that need to be validated
[in]pairArrayArray of NvSciBufAttrKeyValuePair structures that the user has used to set in the unreconciled NvSciBufAttrList. Valid value: pairArray is valid input if it is not NULL and key member of every NvSciBufAttrKeyValuePair in the array is a valid enumeration value defined by the NvSciBufAttrKey enum and value member of every NvSciBufAttrKeyValuePair in the array is not NULL.
[in]pairCountNumber of elements/entries in pairArray. Valid value: pairCount is valid input if it is non-zero.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_Success if successful.
  • NvSciError_InsufficientMemory If any allocation of memory fails for validation.
  • NvSciError_BadParameter if any of the following occurs:
    • reconciledAttrList is NULL
    • pairArray is NULL
    • NvSciBufAttrKey specified in pairArray is invalid.
    • pairCount is 0.
  • NvSciError_AttrListValidationFailed indicates that reconciled NvSciBufAttrList is not valid against the user provided key value pair(s).
  • panics if reconciledAttrList is invalid.
Precondition
@id{NvSciBufAttrListValidateReconciledAgainstAttrs_PreCond_001} @asil{B} Valid reconciled NvSciBufAttrList is obtained.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA

◆ NvSciBufCheckVersionCompatibility()

NvSciError NvSciBufCheckVersionCompatibility ( uint32_t  majorVer,
uint32_t  minorVer,
bool *  isCompatible 
)

Checks if loaded NvSciBuf library version is compatible with NvSciBuf library version with which elements dependent on NvSciBuf were built.

This function checks loaded NvSciBuf library version with input NvSciBuf library version and sets output variable true provided major version of the loaded library is same as majorVer and minor version of the loaded library is not less than minorVer.

Parameters
[in]majorVerbuild major version. Valid value: majorVer is NvSciBufMajorVersion.
[in]minorVerbuild minor version. Valid value: [0 - <= NvSciBufMajorVersion].
[out]isCompatibleboolean value stating if loaded NvSciBuf library is compatible or not.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_Success if successful.
  • NvSciError_BadParameter if any of the following occurs:
    • isCompatible is NULL


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA

◆ NvSciBufModuleClose()

void NvSciBufModuleClose ( NvSciBufModule  module)

Releases the NvSciBufModule obtained through an earlier call to NvSciBufModuleOpen().

Once the NvSciBufModule is closed and all NvSciBufAttrLists and NvSciBufObjs bound to it are freed, the NvSciBufModule will be de-initialized in the calling process.

Note
Every owner of the NvSciBufModule shall call NvSciBufModuleClose() only after all the functions invoked by the owner with NvSciBufModule as an input are completed.
Parameters
[in]moduleThe NvSciBufModule to close.
Returns
void
  • Panic if:
    • if Init Mode API is called in Runtime Mode.
    • module is invalid
Precondition
@id{NvSciBufModuleClose_PreCond_001} @asil{QM} Valid NvSciBufModule is obtained.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes, with the following conditions:
      • Provided there is no active operation involving the input NvSciBufModule module
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA

◆ NvSciBufModuleOpen()

NvSciError NvSciBufModuleOpen ( NvSciBufModule *  newModule)

Initializes and returns a new NvSciBufModule with no NvSciBufAttrLists, buffers, or NvSciBufObjs bound to it.

Note
A process may call this function multiple times. Each successful invocation will yield a new NvSciBufModule.
Parameters
[out]newModuleThe new NvSciBufModule.
Returns
NvSciError, the completion code of this operation:
  • NvSciError_Success if successful.
  • NvSciError_BadParameter if newModule is NULL.
  • NvSciError_InsufficientMemory if memory is not available.
  • NvSciError_ResourceError if any of the following occurs:
    • NVIDIA driver stack failed
    • system lacks resource other than memory


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA

◆ NvSciBufObjGetDmaBufFd()

NvSciError NvSciBufObjGetDmaBufFd ( NvSciBufObj  bufObj,
int *  fd 
)

Generate a new dma-buf file descriptor corresponding to the provided NvSciBufObj.

This API is specific to Linux OS.

Parameters
[in]bufObjNvSciBufObj from which new file descriptor is generated
[out]fddma-buf File Descriptor corresponding to the underlying memory of the NvSciBufObj. The caller owns this returned file descriptor and is responsible for closing the file descriptor. Valid Value: non NULL Pointer.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_Success if successful.
  • NvSciError_BadParameter if any of the following occurs:
    • bufObj is NULL
    • fd is NULL.
    • fd is NULL.
    • bufObj did not request for CPU access by setting NvSciBufGeneralAttrKey_NeedCpuAccess to true
  • NvSciError_ResourceError if system lacks resource other than memory.
  • panics if bufObj is invalid.
Precondition
@id{NvSciBufObjGetDmaBufFd_PreCond_001} @asil{B} Valid NvSciBufObj is obtained. @arr @id{NvSciBufObjGetDmaBufFd_RES_001} @asil{D} The returned file descriptor shall not be shared with another process @arr @id{NvSciBufObjGetDmaBufFd_RES_002} @asil{D} The returned file descriptor shall not be duplicated


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA

◆ NvSciBufObjGetDmaMap()

NvSciError NvSciBufObjGetDmaMap ( NvSciBufObj  bufObj,
uint64_t  hid,
uint64_t *  pIovaAddr 
)

Map the buffer represented by bufObj into a hardware engine's IOVA space via the SMMU and return the contiguous IOVA address.

Use this when an off-CPU consumer (e.g. PCIe eDMA, VIC) needs an SMMU-contiguous IOVA over a buffer that NvSciBuf allocated and shared. The mapping persists until NvSciBufObjUnmapDma is called with the same hid and the returned address. The SMMU mapping inherits bufObj 's reconciled access permission; bufObj must have been reconciled with at least NvSciBufAccessPerm_Readonly.

This API is specific to QNX/Tegra.

Buffers reconciled with a consumer engine that NvSciBufHwEngName documents as isochronous are not supported and cause this call to return NvSciError_AccessDenied.

The PCIe-side peer's unreconciled attribute list must set NvSciBufGeneralAttrKey_PeerHwEngineArray to include a NvSciBufHwEngName_PCIe entry, and must set NvSciBufGeneralAttrKey_PeerLocationInfo with the remote SoC ID. Buffers reconciled without these constraints may fail to map, or map but transfer incorrectly, because their pitch, alignment or contiguity is not guaranteed to satisfy PCIe-side requirements.

NvSciBuf does not transmit buffer metadata (represented by the datatype attribute keys, e.g. pitch, plane offsets, alignment padding) across the PCIe link; the remote consumer of the IOVA cannot derive layout from the IOVA alone. The producer is responsible for communicating that metadata out-of-band. Applies equally to NvSciBufObjGetDmaMapAtAddr.

Parameters
[in]bufObjNvSciBufObj to map.
[in]hidSMMU StreamID of the target engine. Not necessarily 1:1 with NvSciBufHwEngName — an engine class may have multiple instances, each with its own StreamID.
[out]pIovaAddrOn success, receives the contiguous IOVA address to program into the consumer's descriptor. Valid Value: non NULL pointer.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_NotSupported
Precondition
@id{NvSciBufObjGetDmaMap_PreCond_001} @asil{QM} Valid NvSciBufObj is obtained.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges:
    • NvMap/Interfaces:DMA_MAP_INTERFACE_ABILITY
    • the engine's SMMU/SID abilities
  • API group
    • Init: Yes
    • Runtime: No
    • De-Init: No

◆ NvSciBufObjGetDmaMapAtAddr()

NvSciError NvSciBufObjGetDmaMapAtAddr ( NvSciBufObj  bufObj,
uint64_t  hid,
uint64_t  fixedIovaAddr,
uint64_t *  pActualIovaAddr 
)

Same as NvSciBufObjGetDmaMap, but install the mapping at a caller-specified IOVA.

Required by streaming protocols (e.g. PCIe eDMA ring buffers) where the producer and consumer agree on a fixed device address up front.

This API is specific to QNX/Tegra.

fixedIovaAddr must be 4 KiB aligned (the worst-case SMMU page size assumed by NvSciBuf), must lie within the engine's SMMU aperture, and must not collide with any existing mapping in that engine's SMMU domain. Failure of any of these returns NvSciError_ResourceError without installing a mapping.

On NvSciError_Success, *pActualIovaAddr is guaranteed to equal fixedIovaAddr; the implementation never silently relocates a colliding request. A NvSciError_Success return may therefore be treated as proof that DMA descriptors targeting fixedIovaAddr will land at the buffer's pages. This is safe under concurrency: if multiple callers target the same IOVA on the same engine, exactly one succeeds and the rest return NvSciError_ResourceError. The successful mapping is never disturbed by a losing caller.

On QNX, fixed-IOVA requests are honoured only against IOVA windows previously reserved on the engine's hwid through the platform's IOVA reservation interface, with the fixed-IOVA mode set. Calls outside any reserved window return NvSciError_ResourceError. Reserving a window requires the launcher to grant the process the RESERVE_IOVA_REGION_INTERFACE_ABILITY ability under "NvMap/Interfaces"; without it the reservation fails and this API returns NvSciError_AccessDenied for any subsequent fixed-IOVA call.

The isochronous-engine restriction (see NvSciBufHwEngName) and the reconciliation/image-layout requirements documented on NvSciBufObjGetDmaMap apply unchanged.

Parameters
[in]bufObjNvSciBufObj to map.
[in]hidSMMU StreamID identifying the consumer that will access the buffer; see NvSciBufObjGetDmaMap for the full description of this parameter.
[in]fixedIovaAddrIOVA at which the mapping must be installed. Valid Value: non-zero, 4 KiB aligned.
[out]pActualIovaAddrOn success, receives the IOVA actually installed. Per the no-relocation contract above, this equals fixedIovaAddr. Valid Value: non NULL pointer.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_NotSupported
Precondition
@id{NvSciBufObjGetDmaMapAtAddr_PreCond_001} @asil{QM} Valid NvSciBufObj is obtained.
@id{NvSciBufObjGetDmaMapAtAddr_PreCond_002} @asil{QM} IOVA window covering fixedIovaAddr has been reserved on hid through the platform's IOVA reservation interface.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges:
    • NvMap/Interfaces:DMA_MAP_INTERFACE_ABILITY
    • NvMap/Interfaces:RESERVE_IOVA_REGION_INTERFACE_ABILITY
    • the engine's SMMU/SID abilities
  • API group
    • Init: Yes
    • Runtime: No
    • De-Init: No

◆ NvSciBufObjGetMaxPerm()

NvSciError NvSciBufObjGetMaxPerm ( const NvSciBufObj  bufObj,
const NvSciIpcEndpoint  ipcEndpoint,
NvSciBufAttrValAccessPerm *  accPerm 
)

Retrieve the NvSciBufAttrValAccessPerm of an NvSciBufObj for given NvSciIpcEndpoint.

Application can use this API to ensure that when an NvSciBufObj is exported with NvSciBufAccessPerm_Auto, the NvSciBufObj will be exported with appropriate NvSciBufAttrValAccessPerm expected by the application.

Parameters
[in]bufObjobject for which access permissions need to be retrieved.
[in]ipcEndpointNvSciIpcEndpoint of the peer for which the permissions need to retrieved. Valid value: valid NvSciIpcEndpoint returned by NvSciIpc to identify the peer.
[out]accPermaddress at which the retrieved access permissions need to be stored. Valid Value: non NULL Pointer.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_Success if successful.
  • NvSciError_BadParameter if any of the following occurs:
    • bufObj is NULL
    • ipcEndpoint is invalid
    • accPerm is NULL.
  • panics if bufObj is invalid.
Precondition
@id{NvSciBufObjGetMaxPerm_PreCond_001} @asil{B} Valid NvSciBufObj is obtained.
@id{NvSciBufObjGetMaxPerm_PreCond_002} @asil{QM} Valid NvSciIpcEndpoint is obtained.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: No
    • Operational: Yes
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA

◆ NvSciBufObjUnmapDma()

NvSciError NvSciBufObjUnmapDma ( NvSciBufObj  bufObj,
uint64_t  hid,
uint64_t  iovaAddr 
)

Tear down a DMA IOVA mapping previously created via either NvSciBufObjGetDmaMap or NvSciBufObjGetDmaMapAtAddr.

The same call serves both flavours: the underlying SMMU manager does not distinguish fixed from dynamically-assigned mappings at unmap time.

This API is specific to QNX/Tegra.

The (bufObj, iovaAddr) pair is the caller's responsibility. iovaAddr must be an address returned by a prior NvSciBufObjGetDmaMap or NvSciBufObjGetDmaMapAtAddr call against either bufObj itself or a peer NvSciBufObj backing the same underlying memory (for example one obtained via NvSciBufObjDup or NvSciBufObjIpcImport). NvSciBuf does not track per-NvSciBufObj IOVAs and cannot validate the pair; the call is a thin pass-through that resolves bufObj to its underlying memory handle and forwards the unmap to the SMMU manager.

Passing an iovaAddr that does not name a current mapping under bufObj 's memory handle is undefined and may be destructive: the call may succeed and act as a no-op, may succeed and tear down a different mapping under the same memory handle, or may return NvSciError_ResourceError.

A redundant unmap of a (memory handle, IOVA) pair that has already been torn down (double-unmap) returns NvSciError_ResourceError; there is no distinguishable "already unmapped" success code.

Parameters
[in]bufObjNvSciBufObj whose mapping is being released.
[in]hidSMMU StreamID; must match the value passed to the corresponding map call. See NvSciBufObjGetDmaMap for the full description of this parameter.
[in]iovaAddrIOVA returned by the map call. Valid Value: non-zero.
Returns
NvSciError, the completion code of the operation:
  • NvSciError_NotSupported
Precondition
@id{NvSciBufObjUnmapDma_PreCond_001} @asil{QM} Valid NvSciBufObj is obtained.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges:
    • NvMap/Interfaces:DMA_UNMAP_INTERFACE_ABILITY
    • the engine's SMMU/SID abilities
  • API group
    • Init: Yes
    • Runtime: No
    • De-Init: No

◆ NvSciBufObjValidate()

NvSciError NvSciBufObjValidate ( NvSciBufObj  bufObj)

Validates the NvSciBufObj satisfies the constraints of the NvSciBufAttrList that it is associated with.

Parameters
[in]bufObjThe NvSciBufObj to validate
Returns
NvSciError, the completion code of this operation:
  • NvSciError_Success if successful.
  • NvSciError_BadParameter if any of the following occurs:
    • bufObj is NULL
    • bufObj is invalid
    • bufObj does not satisfy the constraints of the NvSciBufAttrList that it is associated with
  • NvSciError_Revalidation_Success if any of the following occurs:
    • the API is called after the provided bufObj has already been validated
  • NvSciError_ObjValidationFailed NvSciBufObj doesn't satisfy the reconciled NvSciBufAttrList or not holding a valid underlying buffer.
Precondition
@id{NvSciBufObjValidate_PreCond_001} @asil{B} Valid NvSciBufObj is obtained.
Postcondition
@id{NvSciBufObjValidate_PostCond_001} NvSciBufObj is marked as validated if successful.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Implementation ASIL: ASIL D
  • Maturity: GA