From: Andreas Hartmann Subject: [AMD iommu] pci Failed to assign device "hostdev0" : Device or resource busy Date: Mon, 12 Dec 2011 12:15:24 +0100 Message-ID: <201112121115.pBCBFMTA004221@mail.maya.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from mout0.freenet.de ([195.4.92.90]:34300 "EHLO mout0.freenet.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752562Ab1LLLTT (ORCPT ); Mon, 12 Dec 2011 06:19:19 -0500 Received: from [195.4.92.140] (helo=mjail0.freenet.de) by mout0.freenet.de with esmtpa (ID andihartmann@freenet.de) (port 25) (Exim 4.76 #1) id 1Ra3uf-0004Ko-La for kvm@vger.kernel.org; Mon, 12 Dec 2011 12:19:17 +0100 Received: from localhost ([::1]:41598 helo=mjail0.freenet.de) by mjail0.freenet.de with esmtpa (ID andihartmann@freenet.de) (Exim 4.76 #1) id 1Ra3uf-0008NC-HI for kvm@vger.kernel.org; Mon, 12 Dec 2011 12:19:17 +0100 Received: from [195.4.92.12] (port=40290 helo=2.mx.freenet.de) by mjail0.freenet.de with esmtpa (ID andihartmann@freenet.de) (Exim 4.76 #1) id 1Ra3s7-0007RJ-4H for kvm@vger.kernel.org; Mon, 12 Dec 2011 12:16:39 +0100 Received: from p4fde0cc6.dip0.t-ipconnect.de ([79.222.12.198]:36994 helo=mail.maya.org) by 2.mx.freenet.de with esmtpsa (ID andihartmann@freenet.de) (TLSv1:AES256-SHA:256) (port 25) (Exim 4.76 #1) id 1Ra3s6-0003Jo-PG for kvm@vger.kernel.org; Mon, 12 Dec 2011 12:16:39 +0100 Received: from dualc.maya.org (dualc.maya.org [192.168.1.6]) by mail.maya.org (8.14.4/8.13.8) with ESMTP id pBCBFMTA004221 for ; Mon, 12 Dec 2011 12:15:22 +0100 Sender: kvm-owner@vger.kernel.org List-ID: Hello! I've got a few questions to a problem, which already was analyzed here sometime ago: http://markmail.org/message/dspovwvzp3wtdrf6#query:+page:1+mid:i2oph4xwfmiknt3y+state:results My situation is a bit different. I do have two PCI cards (a Linksys wlan card and an intel e100 card). Each of these cards should be managed in an own VM. I do have no problems with IRQ sharing (each device does have its own IRQ). I'm using linux 3.0.6, kvm 0.15 and libvirt 0.9.7. Mainboard is: GA-990XA-UD3. The problem is: both cards are behind a PCI-PCI bridge: 00:14.4 PCI bridge: ATI Technologies Inc SBx00 PCI to PCI Bridge (rev 40) -[0000:00]-+-00.0 ATI Technologies Inc RD890 PCI to PCI bridge (external gfx0 port B) +-00.2 ATI Technologies Inc Device 5a23 +-02.0-[01]--+-00.0 ATI Technologies Inc Device 6759 | \-00.1 ATI Technologies Inc Device aa90 +-04.0-[02]----00.0 Device 1b6f:7023 +-09.0-[03]----00.0 Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller +-0a.0-[04]----00.0 Device 1b6f:7023 +-11.0 ATI Technologies Inc SB700/SB800 SATA Controller [AHCI mode] +-12.0 ATI Technologies Inc SB700/SB800 USB OHCI0 Controller +-12.2 ATI Technologies Inc SB700/SB800 USB EHCI Controller +-13.0 ATI Technologies Inc SB700/SB800 USB OHCI0 Controller +-13.2 ATI Technologies Inc SB700/SB800 USB EHCI Controller +-14.0 ATI Technologies Inc SBx00 SMBus Controller +-14.1 ATI Technologies Inc SB700/SB800 IDE Controller +-14.2 ATI Technologies Inc SBx00 Azalia (Intel HDA) +-14.3 ATI Technologies Inc SB700/SB800 LPC host controller +-14.4-[05]--+-06.0 Intel Corporation 82557/8/9/0/1 Ethernet Pro 100 | \-07.0 RaLink RT2800 802.11n PCI +-14.5 ATI Technologies Inc SB700/SB800 USB OHCI2 Controller +-15.0-[06]-- +-16.0 ATI Technologies Inc SB700/SB800 USB OHCI0 Controller +-16.2 ATI Technologies Inc SB700/SB800 USB EHCI Controller +-18.0 Advanced Micro Devices [AMD] Device 1600 +-18.1 Advanced Micro Devices [AMD] Device 1601 +-18.2 Advanced Micro Devices [AMD] Device 1602 +-18.3 Advanced Micro Devices [AMD] Device 1603 +-18.4 Advanced Micro Devices [AMD] Device 1604 \-18.5 Advanced Micro Devices [AMD] Device 1605 That's what can be seen during boot: [ 0.621901] AMD-Vi: device: 00:00.2 cap: 0040 seg: 0 flags: 3e info 1300 [ 0.621906] AMD-Vi: mmio-addr: 00000000fec30000 [ 0.622091] AMD-Vi: DEV_SELECT_RANGE_START devid: 00:00.0 flags: 00 [ 0.622095] AMD-Vi: DEV_RANGE_END devid: 00:00.2 [ 0.622097] AMD-Vi: DEV_SELECT devid: 00:02.0 flags: 00 [ 0.622100] AMD-Vi: DEV_SELECT_RANGE_START devid: 01:00.0 flags: 00 [ 0.622102] AMD-Vi: DEV_RANGE_END devid: 01:00.1 [ 0.622105] AMD-Vi: DEV_SELECT devid: 00:04.0 flags: 00 [ 0.622107] AMD-Vi: DEV_SELECT devid: 02:00.0 flags: 00 [ 0.622109] AMD-Vi: DEV_SELECT devid: 00:09.0 flags: 00 [ 0.622112] AMD-Vi: DEV_SELECT devid: 03:00.0 flags: 00 [ 0.622114] AMD-Vi: DEV_SELECT devid: 00:0a.0 flags: 00 [ 0.622117] AMD-Vi: DEV_SELECT devid: 04:00.0 flags: 00 [ 0.622119] AMD-Vi: DEV_SELECT devid: 00:11.0 flags: 00 [ 0.622122] AMD-Vi: DEV_SELECT_RANGE_START devid: 00:12.0 flags: 00 [ 0.622124] AMD-Vi: DEV_RANGE_END devid: 00:12.2 [ 0.622127] AMD-Vi: DEV_SELECT_RANGE_START devid: 00:13.0 flags: 00 [ 0.622129] AMD-Vi: DEV_RANGE_END devid: 00:13.2 [ 0.622132] AMD-Vi: DEV_SELECT devid: 00:14.0 flags: d7 [ 0.622134] AMD-Vi: DEV_SELECT devid: 00:14.1 flags: 00 [ 0.622137] AMD-Vi: DEV_SELECT devid: 00:14.2 flags: 00 [ 0.622139] AMD-Vi: DEV_SELECT devid: 00:14.3 flags: 00 [ 0.622141] AMD-Vi: DEV_SELECT devid: 00:14.4 flags: 00 [ 0.622144] AMD-Vi: DEV_ALIAS_RANGE devid: 05:00.0 flags: 00 devid_to: 00:14.4 [ 0.622147] AMD-Vi: DEV_RANGE_END devid: 05:1f.7 [ 0.622154] AMD-Vi: DEV_SELECT devid: 00:14.5 flags: 00 [ 0.622157] AMD-Vi: DEV_SELECT devid: 00:15.0 flags: 00 [ 0.622159] AMD-Vi: DEV_SELECT_RANGE_START devid: 06:00.0 flags: 00 [ 0.622162] AMD-Vi: DEV_RANGE_END devid: 06:1f.7 [ 0.622166] AMD-Vi: DEV_SELECT_RANGE_START devid: 00:16.0 flags: 00 [ 0.622169] AMD-Vi: DEV_RANGE_END devid: 00:16.2 [ 0.622176] pci 0000:00:00.2: can't derive routing for PCI INT A [ 0.622179] pci 0000:00:00.2: PCI INT A: no GSI [ 0.622379] pci 0000:00:00.2: irq 40 for MSI/MSI-X [ 0.622453] AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40 [ 0.681866] AMD-Vi: Lazy IO/TLB flushing enabled [ 0.681870] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [ 0.681873] Placing 64MB software IO TLB between ffff8800cbd9d000 - ffff8800cfd9d000 [ 0.681877] software IO TLB at phys 0xcbd9d000 - 0xcfd9d000 Unbind is done like this: # PCI bridge echo "1002 4384" > /sys/bus/pci/drivers/pci-stub/new_id echo "0000:00:14.4" > /sys/bus/pci/drivers/pci-stub/unbind # e100 echo "8086 1229" > /sys/bus/pci/drivers/pci-stub/new_id echo "0000:05:06.0" > /sys/bus/pci/drivers/pci-stub/unbind echo "0000:05:06.0" > /sys/bus/pci/drivers/pci-stub/bind echo "8086 1229" > /sys/bus/pci/drivers/pci-stub/remove_id # Linksys echo "1814 0601" > /sys/bus/pci/drivers/pci-stub/new_id echo "0000:05:07.0" > /sys/bus/pci/drivers/pci-stub/unbind echo "0000:05:07.0" > /sys/bus/pci/drivers/pci-stub/bind echo "1814 0601" > /sys/bus/pci/drivers/pci-stub/remove_id I can start a VM (and can see the devices in the VM) with both devices or just one PCI device (without the bridge). If the machine in this VM is halted, the host crashes as already described here: http://markmail.org/message/dspovwvzp3wtdrf6 (The bridge can't be put to the VM because libvirt (I'm using libvirt) doesn't like it.) Unfortunately, it wasn't possible to put the PCI devices to different VMs at the same time (Failed to assign device "hostdev0" : Device or resource busy) - but that's exactly what I need :-(. Now my questions: 1. Is there any way to get the devices into different VMs? (I can't put them to another PCI slot as there are just 2 PCI slots on the board.) 2. Is there any fix to prevent the host crash - maybe in a newer version of kvm or kernel? Thank you very much for your help, kind regards, Andreas Hartmann