**Description:**
Add support of GPU Passthrough for integrated graphics of AMD Ryzen V1000 APUs.
//Note://
This patch is currently not working on any system.
This patch is based on [[ https://reviews.freebsd.org/D26209 | D26209 ]].
**Prerequisites:**
- AMD Ryzen V1000 APU with Vega graphics
**How to enable GPU Passthrough:**
Add the new "apu" option to the graphic device.
Your bhyve config could look like:
```
bhyveload -S -m 4G -d /root/fbsd/fbsd.img fbsd
bhyve -c 4 -m 4G -A -H -P -S \
-s 0,hostbridge \
-s 2:0,passthru,4/0/0,apu \
-s 5,virtio-blk,/root/fbsd/fbsd.img \
-s 6,virtio-net,tap10 \
-s 30,lpc \
-l com1,stdio \
fbsd
```
**Tested Scenarios:**
CPU: AMD Ryzen Embedded V1807B
| **OS** | |
| Windows | Not Working |
| FreeBSD | Not Working |
**Installation Steps:**
1. Apply patch [[ https://reviews.freebsd.org/D26209 | D26209 (Diff 4) ]] and this patch to your FreeBSD sources
2. Rebuild kernel and bhyve
3. Install a FreeBSD VM
4. Log in to your Guest-OS:
1. Apply patch [[ https://reviews.freebsd.org/D26209 | D26209 (Diff 4) ]] and this patch to your FreeBSD sources
2. Rebuild kernel
3. Install drm-kmod (`pkg install drm-kmod`)
4. Build and install drm-kmod from source
- `git clone https://github.com/freebsd/drm-kmod`
- `cd drm-kmod`
- `make && make install`
5. Load amdgpu driver
- `kldload /boot/modules/linuxkpi_gplv2.ko`
- `kldload /boot/modules/drm.ko`
- `kldload /boot/modules/ttm.ko`
- `kldload /boot/modules/amdgpu.ko`
**Known Limitations:**
- Detection of VBIOS address only uses VFCT table. `drm-kmod/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c` contains more options
**Known Issues:**
- Load of amdgpu driver fails:
Following output is displayed on `kldload /boot/modules/amdgpu.ko`:
```
drmn0: successfully loaded firmware image with name: amdgpu/raven_vcn.bin
<6>[drm] Found VCN firmware Version ENC: 1.9 DEC: 1 VEP: 0 Revision: 28
<6>[drm] PSP loading VCN firmware
<6>[drm] reserve 0x400000 from 0xf43f800000 for PSP TMR
<4>[drm] psp command failed and response status is (0xFFFF)
[drm ERROR :psp_hw_start] PSP load tmr failed!
[drm ERROR :psp_hw_init] PSP firmware loading failed
[drm ERROR :amdgpu_device_fw_loading] hw_init of IP block <psp> failed -22
drmn0: amdgpu_device_ip_init failed
drmn0: Fatal error during GPU init
```
If `amdgpu_fw_load_type` (drm-kmod/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c) is set to `0` (AMDGPU_FW_LOAD_DIRECT) instead of `-1`, it'll fail with following message:
```
drmn0: successfully loaded firmware image with name: amdgpu/raven_vcn.bin
<6>[drm] Found VCN firmware Version ENC: 1.9 DEC: 1 VEP: 0 Revision: 28
drmn0: [drm:*ERROR* ] amdgpu_ring_test_helper[drm ERROR :gfx_v9_0_kiq_kcq_enable] KCQ enable failed
[drm ERROR :amdgpu_device_ip_hw_init_phase2] hw_init of IP block <gfx_v9_0> failed -60
drmn0: amdgpu_device_ip_init failed
drmn0: Fatal error during GPU init
```