intel / libva

Libva is an implementation for VA-API (Video Acceleration API)
http://intel.github.io/libva/
Other
664 stars 303 forks source link

Truncate the name nvidia(nvid), amdgpu(amdg), libva error: vaGetDriverNames() failed with unknown libva error #750

Closed denji closed 1 year ago

denji commented 1 year ago

If VAAPI does not support multiple dGPUs/iGPUs to select, is there a possibility to specify via an environment variable the path drm device /dev/dri/renderD129 to the iGPU that has second priority?

$ sudo vainfo 
Trying display: wayland
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Trying display: x11
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
libva error: /usr/lib/dri/iHD_drv_video.so init failed
vaInitialize failed with error code 18 (invalid parameter),exit

$ cat /etc/environment
# dGPU0 / NVIDIA
VDPAU_DRIVER=nvidia
# libva-vdpau-driver(LIBVA_DRIVER_NAME=vdpau)
# libva-vdpau-driver-vp9-git(LIBVA_DRIVER_NAME=vdpau)
##LIBVA_DRIVER_NAME=vdpau
# libva-nvidia-driver / libva-nvidia-driver-git(LIBVA_DRIVER_NAME=nvidia) + ffnvcodec-headers: https://github.com/elFarto/nvidia-vaapi-driver
#LIBVA_DRIVER_NAME=nvidia
#MOZ_DISABLE_RDD_SANDBOX=1
##NVD_BACKEND=egl
#NVD_BACKEND=direct

# iGPU1 / i915 (iHD/i965)
LIBVA_DRIVER_NAME=iHD

$ vainfo --display drm --device /dev/dri/renderD129
Trying display: drm
vainfo: VA-API version: 1.19 (libva 2.19.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.3.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

$ sudo env LIBVA_DRIVER_NAME=nvidia vainfo 
Trying display: wayland
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Trying display: x11
vainfo: VA-API version: 1.19 (libva 2.19.0)
vainfo: Driver version: VA-API NVDEC driver [egl backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

$ ls -1 /usr/lib/dri/*
/usr/lib/dri/crocus_dri.so
/usr/lib/dri/d3d12_dri.so
/usr/lib/dri/i915_dri.so
/usr/lib/dri/i965_drv_video.so
/usr/lib/dri/iHD_drv_video.so
/usr/lib/dri/iris_dri.so
/usr/lib/dri/kms_swrast_dri.so
/usr/lib/dri/nouveau_dri.so
/usr/lib/dri/nvidia_drv_video.so
/usr/lib/dri/r300_dri.so
/usr/lib/dri/r600_dri.so
/usr/lib/dri/radeonsi_dri.so
/usr/lib/dri/swrast_dri.so
/usr/lib/dri/virtio_gpu_dri.so
/usr/lib/dri/vmwgfx_dri.so
/usr/lib/dri/zink_dri.so
XinfengZhang commented 1 year ago

libva does not select the device by itself, it get the device from application or other components. lets use drm as the example: application call fd =open("/dev/dri/renderXXX",...) , then call vaGetDisplayDRM(fd), then call vaInitialize() so, all is controlled in upper layer.

maybe you want a priority list in libva-utils?

denji commented 1 year ago

@XinfengZhang It seems to be causing the driver to crash https://github.com/intel/libva-utils/blob/2.19.0/common/va_display_drm.c#L49-L51

$ google-chrome-stable
libva error: vaGetDriverNames() failed with unknown libva error
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
libva error: /usr/lib/dri/iHD_drv_video.so init failed
$ vainfo
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
libva error: /usr/lib/dri/iHD_drv_video.so init failed
vaInitialize failed with error code 18 (invalid parameter),exit

$ env LIBVA_DRIVER_NAME=iHD vainfo
Trying display: wayland
Trying display: x11
libva error: vaGetDriverNames() failed with unknown libva error
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
libva error: /usr/lib/dri/iHD_drv_video.so init failed
vaInitialize failed with error code 18 (invalid parameter),exit

$ env LIBVA_DRIVER_NAME=nvidia vainfo
Trying display: wayland
Trying display: x11
libva error: vaGetDriverNames() failed with unknown libva error
vainfo: VA-API version: 1.20 (libva 2.19.0)
vainfo: Driver version: VA-API NVDEC driver [egl backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

$ env LIBVA_DRIVER_NAME=nvidia vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
vainfo: VA-API version: 1.20 (libva 2.19.0)
vainfo: Driver version: VA-API NVDEC driver [egl backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

$ env LIBVA_DRIVER_NAME=nvidia vainfo --display drm --device /dev/dri/renderD129
Trying display: drm
libva error: /usr/lib/dri/nvidia_drv_video.so init failed
vaInitialize failed with error code 1 (operation failed),exit

$ env LIBVA_DRIVER_NAME=iHD vainfo --display drm --device /dev/dri/renderD129
Trying display: drm
vainfo: VA-API version: 1.20 (libva 2.19.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.3.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

$ env LIBVA_DRIVER_NAME=iHD vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
libva error: /usr/lib/dri/iHD_drv_video.so init failed
vaInitialize failed with error code 18 (invalid parameter),exit

/dev/dri/renderD128 - NVIDIA RTX A6000 (/usr/lib/dri/nvidia_drv_video.so) https://github.com/elFarto/nvidia-vaapi-driver/tree/cd54d4029490d6703de5a9080f1475e40efc242a /dev/dri/renderD129 - Intel HD Graphic (/usr/lib/dri/iHD_drv_video.so) https://github.com/intel/media-driver/releases/tag/intel-media-23.3.1

$ pacman -Q|grep -E 'libva|media-driver'
intel-media-driver 23.3.1-1
libva 2.20.0-1
libva-intel-driver 2.4.1-2
libva-nvidia-driver-git
libva-utils 2.19.0-1

# https://wiki.archlinux.org/title/intel_graphics#Enable_GuC_/_HuC_firmware_loading
$ grep -vE '^(#|\S*$)' /etc/modprobe.d/i915.conf 
options i915 enable_fbc=1 enable_guc=2 enable_fbc=2 disable_display=1

$ grep -vE '^(#|\S*$)' /etc/modprobe.d/nvidia.conf 
options nvidia NVreg_UsePageAttributeTable=1 NVreg_EnablePCIeGen3=1 NVreg_EnableGpuFirmware=1 NVreg_EnableResizableBar=1 NVreg_OpenRmEnableUnsupportedGpus=1

$ grep -vE '^(#|\s*$)' /etc/environment
VDPAU_DRIVER=nvidia
LIBVA_DRIVER_NAME=iHD

$ sudo dmesg|grep i915|grep -v hdcp
[   20.934354] i915 0000:00:02.0: enabling device (0000 -> 0003)
[   20.954990] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/kbl_dmc_ver1_04.bin (v1.4)
[   21.364296] i915 0000:00:02.0: [drm] [ENCODER:94:DDI A/PHY A] failed to retrieve link info, disabling eDP
[   21.373905] i915 0000:00:02.0: [drm] GT0: GuC firmware i915/kbl_guc_70.1.1.bin version 70.1.1
[   21.373910] i915 0000:00:02.0: [drm] GT0: HuC firmware i915/kbl_huc_4.0.0.bin version 4.0.0
[   21.397008] i915 0000:00:02.0: [drm] GT0: HuC: authenticated for all workloads
[   21.397013] i915 0000:00:02.0: [drm] GT0: GUC: submission disabled
[   21.397014] i915 0000:00:02.0: [drm] GT0: GUC: SLPC disabled
[   21.399199] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.0 on minor 1
[   21.399719] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[   21.400447] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
[   21.401021] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes

$ sudo cat /sys/kernel/debug/dri/1/gt0/uc/guc_info
GuC firmware: i915/kbl_guc_70.1.1.bin
        status: RUNNING
        version: found 70.1.1
        uCode: 206592 bytes
        RSA: 256 bytes
GuC status 0x8003f0ec:
        Bootrom status = 0x76
        uKernel status = 0xf0
        MIA Core status = 0x3
Scratch registers:
         0:     0xf0000000
         1:     0x1
         2:     0x1000
         3:     0x0
         4:     0x40
         5:     0x3ae
         6:     0x59120004
         7:     0x0
         8:     0x0
         9:     0x0
        10:     0x0
        11:     0x0
        12:     0x0
        13:     0x0
        14:     0x0
        15:     0x0

GuC logging stats:
        Relay full count: 0
        DEBUG:  flush count          0, overflow count          0
        CRASH:  flush count          0, overflow count          0
        CAPTURE:        flush count          0, overflow count          0

$ sudo cat /sys/kernel/debug/dri/1/gt0/uc/huc_info
HuC firmware: i915/kbl_huc_4.0.0.bin
        status: RUNNING
        version: found 4.0.0
        uCode: 225664 bytes
        RSA: 256 bytes
HuC status: 0x00006080

Is there a problem with the driver name output https://forums.gentoo.org/viewtopic-p-8801559.html#8801559

DRM_IOCTL_VERSION, unsupported drm device by media driver: amdg Instead of amdg it should be amdgpu, instead of nvid it should be nvidia.

DRM_IOCTL_VERSION, unsupported drm device by media driver: amdg
DRM_IOCTL_VERSION, unsupported drm device by media driver: amdg
[AVHWDeviceContext @ 0x564440780b80] libva: /usr/lib64/va/drivers/iHD_drv_video.so init failed
[AVHWDeviceContext @ 0x564440780b80] Failed to initialise VAAPI connection: 18 (invalid parameter).