NVIDIA DRIVE OS Linux API Reference

5.1.3.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvrm_gpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018 NVIDIA Corporation. All rights reserved.
3  *
4  * NVIDIA Corporation and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA Corporation is strictly prohibited.
9  */
10 
11 #ifndef INCLUDED_nvrm_gpu_H
12 #define INCLUDED_nvrm_gpu_H
13 
14 #include <stdbool.h>
15 #include <stdint.h>
16 #include <stddef.h>
17 
18 #include "nvcommon.h"
19 #include "nverror.h"
20 
21 #if defined(__cplusplus)
22 extern "C"
23 {
24 #endif
25 
79 typedef struct NvRmGpuLibRec NvRmGpuLib;
81 typedef struct NvRmGpuDeviceRec NvRmGpuDevice;
82 
83 /**** Generic functions ****/
84 
85 typedef struct NvRmGpuLibOpenAttrRec
86 {
87  // placeholder for extensions
88  uint32_t reserved;
89 
91 
92 #define NVRM_GPU_DEFINE_LIB_OPEN_ATTR(x) \
93  NvRmGpuLibOpenAttr x = { 0 }
94 
100 
104 void NvRmGpuLibClose(NvRmGpuLib *hlib);
105 
106 typedef enum
107 {
111 
113 {
116  const char *name; // temporary name, e.g., Nouveau GPU 0 or some such
118 
134 const NvRmGpuLibDeviceListEntry *NvRmGpuLibListDevices(NvRmGpuLib *hlib, size_t *pnumDevices);
135 
143 NvError NvRmGpuLibAttachDevice(NvRmGpuLib *const hlib, const int deviceIndex);
144 
152 NvError NvRmGpuLibDetachDevice(NvRmGpuLib *const hlib, const int deviceIndex);
153 
154 /**** Device functions ****/
155 
156 #define NVRM_GPU_DEVICE_INDEX_DEFAULT (-1)
157 
158 typedef enum
159 {
160  NvRmGpuSyncType_Default, // platform-specific default
164 
166 {
175 
184 
185 #define NVRM_GPU_DEFINE_DEVICE_OPEN_ATTR(x) \
186  NvRmGpuDeviceOpenAttr x = { NvRmGpuSyncType_Default, false }
187 
188 
198 NvError NvRmGpuDeviceOpen(NvRmGpuLib *hLib, int deviceIndex, const NvRmGpuDeviceOpenAttr *attr,
199  NvRmGpuDevice **phDevice);
200 
204 void NvRmGpuDeviceClose(NvRmGpuDevice *hDevice);
205 
233 #if NVOS_IS_LINUX || NVOS_IS_QNX
234 #define NVRM_GPU_CLOCK_ASYNC_REQ_HANDLE_PRIFMT "d"
235 typedef int NvRmGpuClockAsyncReqHandle;
236 #else
237 #define NVRM_GPU_CLOCK_ASYNC_REQ_HANDLE_PRIFMT "p"
238 typedef struct NvRmGpuClockAsyncNotImplemented *NvRmGpuClockAsyncReqHandle;
239 #endif
240 
244 typedef enum NvRmGpuClockDomain
245 {
250 
251 typedef enum NvRmGpuClockType
252 {
257 
259 {
262  uint64_t freqHz;
264 
266 {
268  uint64_t freqHz;
270 
271 typedef struct NvRmGpuClockRangeRec
272 {
273  uint64_t minHz;
274  uint64_t maxHz;
276 
277 typedef struct NvRmGpuClockPointRec
278 {
279  uint64_t freqHz;
281 
283 {
286  size_t maxVfPoints;
288 
300  const NvRmGpuClockDomainInfo **infos,
301  size_t *pNumDomains);
302 
319  NvRmGpuClockDomain domain,
320  NvRmGpuClockPoint *pClkPoints,
321  size_t *pNumPoints);
322 
359  const NvRmGpuClockSetEntry *pClkSetEntries,
360  size_t numEntries,
361  NvRmGpuClockAsyncReqHandle *phReq);
362 
379  const NvRmGpuClockAsyncReqHandle *phReqs,
380  size_t numEntries,
381  uint32_t timeoutMs);
382 
395  NvRmGpuClockAsyncReqHandle hReq);
396 
411  uint32_t timeoutMs);
412 
426  NvRmGpuClockGetEntry *pClkGetEntries,
427  size_t numEntries);
428 
438  uint32_t *pLoadPerMille);
439 
440 typedef enum
441 {
446 
458  const NvRmGpuDeviceVoltage **pSensors,
459  size_t *numSensors);
470  NvRmGpuDeviceVoltage which,
471  uint64_t *pVoltageMicroVolt);
472 
473 typedef enum
474 {
477 
489  const NvRmGpuDeviceCurrent **pSensors,
490  size_t *numSensors);
491 
502  NvRmGpuDeviceCurrent which,
503  uint64_t *pCurrentMicroAmpere);
504 
505 typedef enum
506 {
507  NvRmGpuDevicePower_Bus = 1 // power consumed at regulator
509 
521  const NvRmGpuDevicePower **pSensors,
522  size_t *numSensors);
523 
534  NvRmGpuDevicePower which,
535  uint64_t *pPowerMicroWatt);
536 
537 
538 typedef enum
539 {
542 
554  const NvRmGpuDeviceTemperature **pSensors,
555  size_t *numSensors);
556 
568  int32_t *pTemperatureMilliCelsius);
569 
579  int32_t temperature_mC);
580 
582 typedef enum
583 {
604 
605 typedef struct NvRmGpuDeviceEventSessionRec NvRmGpuDeviceEventSession;
606 
609 {
615 
616 #define NVRM_GPU_DEFINE_DEVICE_EVENT_SESSION_ATTR(x) \
617  NvRmGpuDeviceEventSessionOpenAttr x = { NULL, 0 }
618 
620 {
621  static const NvRmGpuDeviceEventId allEvents[] =
622  {
631  };
632  attr->filterList = allEvents;
633  attr->filterListSize = NV_ARRAY_SIZE(allEvents);
634 }
635 
647  NvRmGpuDeviceEventSession **phSession);
648 
650 {
652  uint64_t timeNs; // GPU timestamp in ns
654 
672  NvRmGpuDeviceEventInfo *pEventInfo,
673  uint32_t timeoutMs);
674 
684 
687 #if defined(__cplusplus)
688 }
689 #endif
690 
691 #if !defined(NV_SDK_BUILD)
692 #include "nvrm_gpu_priv.h"
693 #endif
694 
695 #endif
void NvRmGpuLibClose(NvRmGpuLib *hlib)
Closes the library and releases all resources.
NvError NvRmGpuDeviceEventSessionOpen(NvRmGpuDevice *hDevice, const NvRmGpuDeviceEventSessionOpenAttr *attr, NvRmGpuDeviceEventSession **phSession)
Opens the session to monitor device events.
struct NvRmGpuDeviceRec NvRmGpuDevice
Handle type.
Definition: nvrm_gpu.h:81
struct NvRmGpuDeviceEventSessionOpenAttrRec NvRmGpuDeviceEventSessionOpenAttr
Holds the events for which to listen.
Actual clock frequency programmed (including PLL constraints).
Definition: nvrm_gpu.h:254
void NvRmGpuDeviceClose(NvRmGpuDevice *hDevice)
Closes the GPU device.
Main graphics core clock.
Definition: nvrm_gpu.h:247
struct NvRmGpuLibOpenAttrRec NvRmGpuLibOpenAttr
VF update occurred for a clock domain, either because one session changed target frequency or because...
Definition: nvrm_gpu.h:586
NvError NvRmGpuLibDetachDevice(NvRmGpuLib *const hlib, const int deviceIndex)
Detach and power down a GPU.
One clock domain frequency is below target.
Definition: nvrm_gpu.h:588
NvRmGpuDeviceEventId
Holds information about the GPU device event.
Definition: nvrm_gpu.h:582
GPU lost (non-recoverable).
Definition: nvrm_gpu.h:600
const NvRmGpuLibDeviceListEntry * NvRmGpuLibListDevices(NvRmGpuLib *hlib, size_t *pnumDevices)
Returns a pointer to the device array.
NvRmGpuDeviceState
Definition: nvrm_gpu.h:106
NvRmGpuDeviceState deviceState
Definition: nvrm_gpu.h:115
NvError NvRmGpuDeviceGetTemperature(NvRmGpuDevice *hDevice, NvRmGpuDeviceTemperature which, int32_t *pTemperatureMilliCelsius)
Gets the temperature.
NvError NvRmGpuClockGetPoints(NvRmGpuDevice *hDevice, NvRmGpuClockDomain domain, NvRmGpuClockPoint *pClkPoints, size_t *pNumPoints)
Gets VF points for a given clock domain.
NvError NvRmGpuDeviceGetPower(NvRmGpuDevice *hDevice, NvRmGpuDevicePower which, uint64_t *pPowerMicroWatt)
Gets the power consumed by the GPU.
NvRmGpuClockDomain
Clock domains.
Definition: nvrm_gpu.h:244
NvError NvRmGpuDeviceEventSessionRead(NvRmGpuDeviceEventSession *hSession, NvRmGpuDeviceEventInfo *pEventInfo, uint32_t timeoutMs)
Reads detailed event information from the event session.
NvRmGpuDeviceTemperature
Definition: nvrm_gpu.h:538
One clock domain frequency is below local target frequency requested by one session.
Definition: nvrm_gpu.h:590
NvError
The NvError enumeration contains ALL return / error codes.
Definition: nverror.h:36
NvError NvRmGpuDeviceListTemperatureSensors(NvRmGpuDevice *hDevice, const NvRmGpuDeviceTemperature **pSensors, size_t *numSensors)
Gets the list of available temperature sensors.
NvRmGpuClockRange range
Definition: nvrm_gpu.h:285
static void NvRmGpuDeviceEventSessionOpenAttrSetAllEvents(NvRmGpuDeviceEventSessionOpenAttr *attr)
Definition: nvrm_gpu.h:619
struct NvRmGpuDeviceEventSessionRec NvRmGpuDeviceEventSession
Definition: nvrm_gpu.h:605
struct NvRmGpuClockPointRec NvRmGpuClockPoint
NvError NvRmGpuClockGet(NvRmGpuDevice *hDevice, NvRmGpuClockGetEntry *pClkGetEntries, size_t numEntries)
Gets clock state(s).
Memory clock.
Definition: nvrm_gpu.h:246
NvError NvRmGpuDeviceGetLoad(NvRmGpuDevice *hDevice, uint32_t *pLoadPerMille)
Gets gpu load.
Target clock frequency requested by application.
Definition: nvrm_gpu.h:253
struct NvRmGpuLibDeviceListEntryRec NvRmGpuLibDeviceListEntry
NvError NvRmGpuDeviceListCurrentSensors(NvRmGpuDevice *hDevice, const NvRmGpuDeviceCurrent **pSensors, size_t *numSensors)
Gets a list of the available current sensors.
void NvRmGpuDeviceEventSessionClose(NvRmGpuDeviceEventSession *hSession)
Closes the event session.
NvError NvRmGpuClockWaitAnyEvent(NvRmGpuDevice *hDevice, uint32_t timeoutMs)
Waits on any clock update event.
NvRmGpuDeviceEventId eventId
Definition: nvrm_gpu.h:651
NvError NvRmGpuDeviceListPowerSensors(NvRmGpuDevice *hDevice, const NvRmGpuDevicePower **pSensors, size_t *numSensors)
Gets a list of the available power sensors.
struct NvRmGpuClockGetEntryRec NvRmGpuClockGetEntry
NvError NvRmGpuClockGetDomains(NvRmGpuDevice *hDevice, const NvRmGpuClockDomainInfo **infos, size_t *pNumDomains)
Gets configurable clock domains.
struct NvRmGpuClockRangeRec NvRmGpuClockRange
NvError NvRmGpuClockCloseAsyncReq(NvRmGpuDevice *hDevice, NvRmGpuClockAsyncReqHandle hReq)
Closes an asynchronous request handle.
NvError NvRmGpuClockSet(NvRmGpuDevice *hDevice, const NvRmGpuClockSetEntry *pClkSetEntries, size_t numEntries, NvRmGpuClockAsyncReqHandle *phReq)
Sets a clock request.
NVIDIA Quickboot Interface: Error Handling (Parker)
const NvRmGpuDeviceEventId * filterList
Holds the events for which to listen.
Definition: nvrm_gpu.h:611
struct NvRmGpuClockDomainInfoRec NvRmGpuClockDomainInfo
NvError NvRmGpuDeviceThermalAlertSetLimit(NvRmGpuDevice *hDevice, int32_t temperature_mC)
Sets the thermal alert limit.
NvRmGpuLib * NvRmGpuLibOpen(const NvRmGpuLibOpenAttr *attr)
Opens a new instance of the library.
struct NvRmGpuDeviceOpenAttrRec NvRmGpuDeviceOpenAttr
NvError NvRmGpuClockWaitAsyncReq(NvRmGpuDevice *hDevice, const NvRmGpuClockAsyncReqHandle *phReqs, size_t numEntries, uint32_t timeoutMs)
Waits for completion of one or more asynchronous requests.
NvRmGpuSyncType
Definition: nvrm_gpu.h:158
NvRmGpuDeviceCurrent
Definition: nvrm_gpu.h:473
struct NvRmGpuLibRec NvRmGpuLib
Handle type.
Definition: nvrm_gpu.h:79
NvRmGpuDevicePower
Definition: nvrm_gpu.h:505
NvRmGpuDeviceVoltage
Definition: nvrm_gpu.h:440
NvError NvRmGpuDeviceGetVoltage(NvRmGpuDevice *hDevice, NvRmGpuDeviceVoltage which, uint64_t *pVoltageMicroVolt)
Gets the current voltage.
NvRmGpuClockDomain domain
in: Clock domain to query
Definition: nvrm_gpu.h:260
struct NvRmGpuClockSetEntryRec NvRmGpuClockSetEntry
Number of events.
Definition: nvrm_gpu.h:602
NvRmGpuClockDomain domain
Definition: nvrm_gpu.h:267
NvRmGpuClockType type
in: Frequency type (target, actual or effective)
Definition: nvrm_gpu.h:261
struct NvRmGpuClockAsyncNotImplemented * NvRmGpuClockAsyncReqHandle
Definition: nvrm_gpu.h:238
bool sandboxFriendlyChannels
If true, channels are created in sandbox-friendly manner.
Definition: nvrm_gpu.h:182
NvRmGpuSyncType syncType
The default sync type for all input/output sync objects.
Definition: nvrm_gpu.h:174
NvRmGpuClockType
Definition: nvrm_gpu.h:251
Effective clock, measured from hardware.
Definition: nvrm_gpu.h:255
NvError NvRmGpuLibAttachDevice(NvRmGpuLib *const hlib, const int deviceIndex)
Power up and attach a GPU.
uint64_t freqHz
out: Frequency in Hz
Definition: nvrm_gpu.h:262
NvError NvRmGpuDeviceGetCurrent(NvRmGpuDevice *hDevice, NvRmGpuDeviceCurrent which, uint64_t *pCurrentMicroAmpere)
Gets the current drawn by the GPU.
NvError NvRmGpuDeviceListVoltageSensors(NvRmGpuDevice *hDevice, const NvRmGpuDeviceVoltage **pSensors, size_t *numSensors)
Gets a list of the available voltage sensors.
Holds the events for which to listen.
Definition: nvrm_gpu.h:608
size_t filterListSize
Holds the size of the filter list.
Definition: nvrm_gpu.h:613
Temperature above threshold.
Definition: nvrm_gpu.h:596
NvError NvRmGpuDeviceOpen(NvRmGpuLib *hLib, int deviceIndex, const NvRmGpuDeviceOpenAttr *attr, NvRmGpuDevice **phDevice)
Opens the GPU device.
NvRmGpuClockDomain domain
Definition: nvrm_gpu.h:284
struct NvRmGpuDeviceEventInfoRec NvRmGpuDeviceEventInfo