NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release

Detailed Description

API to request Guest VM to yield VCPU to a low priority VM.

Functions

int32_t NvHvYieldVcpu (uint32_t vm_id, uint32_t timeout_us)
 API to request Guest VM to yield VCPU to a low priority VM. More...
 

NvHv VCPU-Yield Access Control(QNX)

Common Privileges(QNX)

Description of custom abilities

nvhv/yield_vcpu

  • Custom ability to yield VCPU of Guest VM to a low priority VM

Common privileges required for all NvHv VCPU-Yield APIs

  • Service/Group Name: nvhv

Function Documentation

◆ NvHvYieldVcpu()

int32_t NvHvYieldVcpu ( uint32_t  vm_id,
uint32_t  timeout_us 
)

API to request Guest VM to yield VCPU to a low priority VM.



  • This API yields the VCPU to a low priority VM if no other higher priority process than the caller is ready to
    run on this VCPU in the Guest VM. The API blocks till the time VCPU is yielded to the low priority VM is
    expired (i.e. timeout) or till the low priority VM returns the VCPU actively.
  • An IVC communication channel is established between Guest VM and the low priority VM to yield and return VCPU.
  • When the low priority VM releases it through the IVC communication channel or timeout occurs on Guest VM,
    the VCPU is returned to Guest VM.
  • Timeout value 0 is an invalid input parameter because VCPU yielding for 0 microsecond is inappropriate.
  • QNX:
    • The VCPU number is read from QNX device tree property "nvhv/yield_vcpu" which is updated by bootloader before launching NvHv resource manager.
    • Minimum timeout value is 1 microsecond and maximum timeout value is configured by "nvhv/max_timeout_us" property in QNX device tree (the default value of the configuration is 1000000 in microseconds).
    • QNX device tree property "nvhv/low_prio_vm" specifies the list of low priority VM Ids, user needs to
      ensure that the VM IDs listed in the DT property are valid and correct based on PCT configuration.
    • The resolution of timeout for QNX is millisecond because of limitation of ARM timer resolution.
      So the timeout value internally rounds up to the next millisecond.
  • Linux:
    • The VCPU number is read from Linux device tree property "/tegra_hv_vcpu_yield/yield_vcpu" which is updated by bootloader before launching CPU yield driver in linux kernel.
    • Minimum timeout value is 1 microsecond and maximum timeout value is configured by "/tegra_hv_vcpu_yield/max_timeout_us" property in Linux device tree (the default value of the configuration is 1000000 in microseconds).
    • Linux device tree property "/tegra_hv_vcpu_yield/low_prio_vm" specifies the list of low priority VM Ids, user needs to
      ensure that the VM IDs listed in the DT property are valid and correct based on PCT configuration.
Parameters
[in]vm_idVM ID for low priority VM for which VCPU would be yielded
[in]timeout_usTime for which the user is requesting to yield the VCPU to low priority VM
The minimum value is 1 microsecond and maximum value is configured in device tree.
(In QNX, the timeout value rounds up to the next millisecond due to limitation of ARM timer resolution)
Returns
EOK Success - VCPU is yielded successfully and returned to Guest VM by low priority VM releasing the VCPU
ENODEV Failed to open NvHv device node (potentially invalid VM ID)
ETIMEDOUT Success - VCPU is yielded successfully and taken back to Guest VM by timeout(QNX)
EFAULT VCPU yielding operation failed
EINVAL Invalid timeout_us parameter (zero or exceeded maximum value)(Linux) EINVAL Invalid timeout_us parameter (zero or exceeded maximum value) or general error at devctl call (QNX) EACCES Client doesn't have privilege to call this API(QNX)
Precondition
  • QNX:
    • To be able to call this API, GID of nvhv should be in Supplementary Group IDs list of client process.
  • Linux:
    • To be able to call this API, GID of "tegra_hv_vcpu_yield_vm1" nvhv should be in Supplementary Group IDs list of client process.
    • Tegra yield vcpu driver in linux kernel should have been initialized successfully in kernel to expose sysfs node
Postcondition
  • vcpu should have been yielded to low priority VM successfully after invoking this API


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No(QNX), NA(Linux)
    • Signal handler: No
    • Thread-safe: Yes(QNX), No(Linux)
    • Re-entrant: Yes
    • Async/Sync: Sync
  • Required Privileges(QNX):
    • Custom abilities: nvhv/yield_vcpu(QNX)
  • Allowed execution state
    • Initialization: Yes(QNX), No(Linux)
    • Operational: Yes
    • Reinit/Deinit Preparation: Yes(QNX), No(Linux)
  • Maturity: GA