AMD显卡透传步骤

2023-05-16

哈哈哈,最近终于把AMD显卡透传做完了。小论文已经写完。超级开心!!!下面附上我的显卡透传步骤:

Step by Step:
  1. Hardware
GPU: AMD Firepro W2100
CPU: Intel(R) Core(TM) i3-6100 CPU @ 3.70GHz
MEM: 32G
SSD: 480G
OS:  CentOS7.3 + Ocata
  1. Update kernel for ‘CONFIG_VFIO_PCI_VGA’ and 'i915 VGA arbiter patch
[root@host016 astute]#rpm -ivh  http://ftp.sjtu.edu.cn/centos/7/centosplus/x86_64/Packages/kernel-plus-3.10.0-514.16.1.el7.centos.plus.x86_64.rpm
[root@host016 astute]# virsh version
根据库编译:libvirt 2.0.0
使用库:libvirt 2.0.0
使用的 API: QEMU 2.0.0
运行管理程序: QEMU 2.6.0
[root@host016 astute]# uname -a
Linux host016 3.10.0-514.16.1.el7.centos.plus.x86_64 #1 SMP Wed Apr 26 15:25:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@host016 gpu]# grep CONFIG_VFIO_PCI_VGA /boot/ -r
/boot/config-3.10.0-514.16.1.el7.centos.plus.x86_64:CONFIG_VFIO_PCI_VGA=y
  1. Modify grub parameter for intel_iommu and i915
[root@host016 gpu]# vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet idel=poll idel=poll intel_iommu=on i915.enable_hd_vgaarb=1 modprobe.blacklist=nouveau"
[root@host016 gpu]# grub2-mkconfig -o /boot/grub2/grub.cf g     #### GRUB2不再使用 menu.list,而是使用全新的配置文件 /boot/grub2/grub.cfg,文件权限为 444,其目的就是为避免手动更新,我们可以借助 grub2-mkconfig -o /boot/grub2/grub.cfg 命令来更新.
  1. Set default boot kernel
[root@host016 home]# cat /boot/grub2/grub.cfg | grep menuentry   
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (3.10.0-514.16.1.el7.centos.plus.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.16.1.el7.centos.plus.x86_64-advanced-6170d4eb-feee-4995-8f52-3796351ef5a8' {
menuentry 'CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-6170d4eb-feee-4995-8f52-3796351ef5a8' {
menuentry 'CentOS Linux (3.10.0-327.28.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.28.2.el7.x86_64-advanced-6170d4eb-feee-4995-8f52-3796351ef5a8' {
menuentry 'CentOS Linux (0-rescue-b3e17b2e45f34c48a47b1571ad9fac3d) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-b3e17b2e45f34c48a47b1571ad9fac3d-advanced-6170d4eb-feee-4995-8f52-3796351ef5a8'
[root@host016 gpu]# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core) 《—- current boot kernel
[root@host016 gpu]# [root@host016 home]# grub2-set-default 'CentOS Linux (3.10.0-514.16.1.el7.centos.plus.x86_64) 7 (Core)'
  1. Modify default load system module and paramter
[root@host016 home]# echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf
[root@host016 home]# echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" >> /etc/modprobe.d/vfio_iommu_type1.conf
[root@host016 home]# echo "options kvm ignore_msrs=1" >> /etc/modprobe.d/kvm.conf
  1. Reboot
[root@host016 home]#reboot
  1. Check pci info
[root@host016 home]# lspci | grep AMD
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Oland GL [FirePro W2100]
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
  1. Detach gpu from host
[root@host016 home]# vi bind.sh
#!/bin/bash
modprobe vfio-pci
for dev in "$@"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done
[root@host016 home]# ./bind.sh 0000:01:00.0 0000:01:00.1
[root@host016 home]# lspci -s 01:00.0 -v
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Oland GL [FirePro W2100] (prog-if 00 [VGA controller])
    Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Device 2120
    Flags: bus master, fast devsel, latency 0, IRQ 16
    Memory at e0000000 (64-bit, prefetchable) [size=256M]
    Memory at f7200000 (64-bit, non-prefetchable) [size=256K]
    I/O ports at e000 [size=256]
    Expansion ROM at f7240000 [disabled] [size=128K]
    Capabilities: [48] Vendor Specific Information: Len=08 <?>
    Capabilities: [50] Power Management version 3
    Capabilities: [58] Express Legacy Endpoint, MSI 00
    Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
    Capabilities: [150] Advanced Error Reporting
    Capabilities: [200] #15
    Capabilities: [270] #19
     Kernel driver in use: vfio-pci
    Kernel modules: radeon
[root@host016 home]# lspci -s 01:00.1 -v
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
    Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]
    Flags: bus master, fast devsel, latency 0, IRQ 17
    Memory at f7260000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: [48] Vendor Specific Information: Len=08 <?>
    Capabilities: [50] Power Management version 3
    Capabilities: [58] Express Legacy Endpoint, MSI 00
    Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
    Capabilities: [150] Advanced Error Reporting
    Kernel driver in use: vfio-pci
    Kernel modules: snd_hda_intel
  1. Check USB keyboard and mouse info
[root@host016 gpu]# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 8087:0a2b Intel Corp.
Bus 001 Device 003: ID 24ae:2003
Bus 001 Device 002: ID 046d:c534 Logitech, Inc. Unifying Receiver
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[root@host016 gpu]# lsusb -d 24ae:2003 -v
Bus 001 Device 003: ID 24ae:2003
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x24ae
  idProduct          0x2003
  bcdDevice           10.01
  iManufacturer           1 RAPOO
  iProduct                2 RAPOO 5G Wireless Device
  1. Create vm network(bridge)
brctl addbr br-test
brctl addif br-test 物理网口
echo "allow br-test" > /etc/qemu-kvm/bridge.conf
ifconfig br-test up
          
  1. Build start vm script
[root@host016 home]# vi vm_win10.sh
#!/bin/bash
modprobe vfio-pci
QEMU_AUDIO_DRV=alsa \
QEMU_AUDIO_TIMER_PERIOD=0 \
/usr/libexec/qemu-kvm -cpu host,kvm=off -no-user-config -nodefaults -m 4096M \
-smp 2,sockets=1,cores=2,threads=1 -boot menu=on \
-vnc 0.0.0.0:20 -k en-us \
-vga none \
-bios /usr/share/seabios/bios.bin \
-drive file=/var/lib/nova/gpu/win10.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,werror=stop,rerror=stop,aio=native \
-device virtio-blk-pci,scsi=off,bus=pcie.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-M q35 \
-net nic,model=virtio,macaddr=00:55:aa:00:00:01 -net bridge,br=br-test \
-monitor unix:/tmp/qmp-sock,server,nowait \
-daemonize \
-device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
-device vfio-pci,host=01:00.0,bus=root.1,addr=  下1QQ··························                               333300.0,multifunction=on,x-vga=on \
-device vfio-pci,host=01:00.1,bus=root.1,addr=00.1 \
-usbdevice tablet \
-device usb-host,vendorid=0x24ae,productid=0x2003
  1. Boot vm and start
[root@host016 home]# ./vm_win10.sh &


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AMD显卡透传步骤 的相关文章

随机推荐