Re: PCI passthrough resource remapping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/3/29 Alexander Graf <agraf@xxxxxxx>:
>
> On 29.03.2010, at 19:23, Kenni Lund wrote:
>
>>>> 2010/1/9 Alexander Graf <agraf@xxxxxxx>:
>>>>>
>>>>> On 09.01.2010, at 03:45, Ryan C. Underwood wrote:
>>>>>
>>>>>>
>>>>>> I have a multifunction PCI device that I'd like to pass through to KVM.
>>>>>> In order to do that, I'm reading that the PCI memory region must be
>>>>>> 4K-page
>>>>>> aligned and the PCI memory resources itself must also be exact multiples
>>>>>> of 4K pages.
>>>>>>
>>>>>> I have added the following on my kernel command line:
>>>>>> reassign_resources reassigndev=08:09.0,08:09.1,08:09.2,08:09.3,08:09.4
>>>>>>
>>>>>> But I don't know if it has any effect.  The resources are still not
>>>>>> sized in 4K pages.  Also, this seems to screw up the last device.
>>>>>
>>>>> I submitted a patch to qemu-kvm recently that got rid of that limitation.
>>>>> Please try out if the current git head works for you.
>>>>>
>>>>> Alex--
>>>>
>>>> I just upgraded to kernel 2.6.32.10 with qemu-kvm  0.12.3 and I still
>>>> get the following error when trying to pass through a dedicated PCI
>>>> USB card:
>>>>
>>>> "Unable to assign device: PCI region 0 at address 0xe9403000 has size
>>>> 0x100,  which is not a multiple of 4K
>>>> Error initializing device pci-assign"
>>>>
>>>> Didn't the above patch make it into qemu-kvm? I don't know why, but I
>>>> was under the impression that this was fixed when I upgraded to
>>>> qemu-kvm 0.12.3.
>>>>
>>> It's only in qemu-kvm.git. Maybe it should go into qemu-kvm-0.12.4 if there
>>> is one
>>
>> That would be highly appriciated...with the current USB support in
>> QEMU, PCI passthrough is the only way to get USB 2.0 support. I've
>> bought two dedicated PCI USB cards for this, but none of them works
>> due to the above limitation.
>>
>> Perhaps a developer can comment on this? Are there any plans on
>> including this patch in the stable releases in the near future?
>
> Please first try out to build the current git snapshot of qemu-kvm. If it works properly for you then I agree that we should take this into 0.12-stable.
>
> I wrote the support for a card that still didn't work even with this patch. So having someone say it makes things work for him is definitely a must :-).

Sure, I have compiled the current git snapshot and performed some
tests...It's at least mostly working, so I'm a bit unsure if this is a
bug related to this or to something else.

Here's my test results on trying to passthrough a PCI USB card (I've
copy-pasted the text below into http://pastebin.com/8RJE36wG in case
formatting is lost below):

--------

qemu-kvm complete command line:

qemu-kvm -usbdevice tablet -net
nic,macaddr=52:54:00:00:00:01,model=virtio -net tap,ifname=tap0 -vnc
:1 -smp 2 -m 2048 -cdrom
/data/server/Linux/mythbuntu-9.10-desktop-amd64.iso -drive
file=/data/virtualization/01_Mythbuntu.img,if=virtio,boot=on -boot c
-localtime -daemonize -pcidevice host=02:01.0 -pcidevice host=02:01.1
-pcidevice host=02:01.2 -pcidevice host=02:01.3 -monitor
unix:/var/run/kvm/01.socket,server,nowait -k da
--------

uname -a on host

Linux mediaserver 2.6.32-ARCH #1 SMP PREEMPT Fri Mar 26 02:03:53 CET
2010 x86_64 Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz GenuineIntel
GNU/Linux

Exact kernel version is 2.6.32.10.

--------

lspci -v on host, only for the USB PCI card:

02:01.0 USB Controller: ALi Corporation USB 1.1 Controller (rev 03)
(prog-if 10 [OHCI])
        Subsystem: ALi Corporation ASRock 939Dual-SATA2 Motherboard
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 18
        Memory at e9400000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: [60] Power Management version 2
        Kernel driver in use: pci-stub
        Kernel modules: ohci-hcd

02:01.1 USB Controller: ALi Corporation USB 1.1 Controller (rev 03)
(prog-if 10 [OHCI])
        Subsystem: ALi Corporation ASRock 939Dual-SATA2 Motherboard
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 16
        Memory at e9401000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: [60] Power Management version 2
        Kernel driver in use: pci-stub
        Kernel modules: ohci-hcd

02:01.2 USB Controller: ALi Corporation USB 1.1 Controller (rev 03)
(prog-if 10 [OHCI])
        Subsystem: ALi Corporation ASRock 939Dual-SATA2 Motherboard
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 20
        Memory at e9402000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: [60] Power Management version 2
        Kernel driver in use: pci-stub
        Kernel modules: ohci-hcd

02:01.3 USB Controller: ALi Corporation USB 2.0 Controller (rev 01)
(prog-if 20 [EHCI])
        Subsystem: Device 2020:8888
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 19
        Memory at e9403000 (32-bit, non-prefetchable) [size=256]
        Capabilities: [50] Power Management version 2
        Capabilities: [58] Debug port: BAR=1 offset=0090
        Kernel driver in use: pci-stub
        Kernel modules: ehci-hcd
--------

Commands on host used to prepare PCI USB card:

echo "10b9 5237" > /sys/bus/pci/drivers/pci-stub/new_id
echo "0000:02:01.0" > /sys/bus/pci/drivers/ohci_hcd/unbind
echo "0000:02:01.1" > /sys/bus/pci/drivers/ohci_hcd/unbind
echo "0000:02:01.2" > /sys/bus/pci/drivers/ohci_hcd/unbind
echo "0000:02:01.0" > /sys/bus/pci/drivers/pci-stub/bind
echo "0000:02:01.1" > /sys/bus/pci/drivers/pci-stub/bind
echo "0000:02:01.2" > /sys/bus/pci/drivers/pci-stub/bind
echo "10b9 5237" > /sys/bus/pci/drivers/pci-stub/remove_id

echo "10b9 5239" > /sys/bus/pci/drivers/pci-stub/new_id
echo "0000:02:01.3" > /sys/bus/pci/drivers/ehci_hcd/unbind
echo "0000:02:01.3" > /sys/bus/pci/drivers/pci-stub/bind
echo "10b9 5239" > /sys/bus/pci/drivers/pci-stub/remove_id
--------

Starting qemu-kvm 0.12.3 (fails):

device: 02:01.0: driver="pci-assign" host="02:01.0"
device: 02:01.1: driver="pci-assign" host="02:01.1"
device: 02:01.2: driver="pci-assign" host="02:01.2"
device: 02:01.3: driver="pci-assign" host="02:01.3"
Unable to assign device: PCI region 0 at address 0xe9403000 has size
0x100,  which is not a multiple of 4K
Error initializing device pci-assign
--------

Starting qemu-kvm git (succeeds):

device: 02:01.0: driver="pci-assign" host="02:01.0"
device: 02:01.1: driver="pci-assign" host="02:01.1"
device: 02:01.2: driver="pci-assign" host="02:01.2"
device: 02:01.3: driver="pci-assign" host="02:01.3"
PCI region 0 at address 0xe9403000 has size 0x100, which is not a
multiple of 4K. You might experience some performance hit due to that.
--------

lspci -v in guest with qemu-kvm git (seems fine?):

00:05.0 USB Controller: ALi Corporation USB 1.1 Controller (rev 03) (prog-if 10)
        Subsystem: ALi Corporation USB 1.1 Controller
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 10
        Memory at f2041000 (32-bit, non-prefetchable) [size=4K]
        Kernel driver in use: ohci_hcd

00:06.0 USB Controller: ALi Corporation USB 1.1 Controller (rev 03) (prog-if 10)
        Subsystem: ALi Corporation USB 1.1 Controller
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 11
        Memory at f2042000 (32-bit, non-prefetchable) [size=4K]
        Kernel driver in use: ohci_hcd

00:07.0 USB Controller: ALi Corporation USB 1.1 Controller (rev 03) (prog-if 10)
        Subsystem: ALi Corporation USB 1.1 Controller
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 10
        Memory at f2043000 (32-bit, non-prefetchable) [size=4K]
        Kernel driver in use: ohci_hcd

00:08.0 USB Controller: ALi Corporation USB 2.0 Controller (rev 01) (prog-if 20)
        Subsystem: Device 2020:8888
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 11
        Memory at f2044000 (32-bit, non-prefetchable) [size=256]
        Kernel driver in use: ehci_hcd

--------

dmesg in guest when inserting a DVB-T USB tuner into the PCI USB card:

[  190.900076] usb 1-6: new high speed USB device using ehci_hcd and address 2
[  191.223314] usb 1-6: configuration #1 chosen from 1 choice
[  191.505921] dvb-usb: found a 'Intel CE9500 reference design' in warm state.
[  191.523481] dvb-usb: will pass the complete MPEG2 transport stream
to the software demuxer.
[  191.537924] DVB: registering new adapter (Intel CE9500 reference design)
[  191.647202] DVB: registering adapter 0 frontend 0 (Zarlink ZL10353 DVB-T)...
[  191.716542] MXL5005S: Attached at address 0xc6
[  191.719948] dvb-usb: Intel CE9500 reference design successfully
initialized and connected.
[  191.719989] usbcore: registered new interface driver dvb_usb_ce6230

So far, so good...I'm actually able to scan and find channels with
this USB tuner, but once I try to actually watch a channel, it'll only
give me garbage, eg. artifacts. Probably at the same time the
following message is written to the host:

irq 19: nobody cared (try booting with the "irqpoll" option)
Pid: 0, comm: swapper Not tainted 2.6.32-ARCH #1
Call Trace:
 <IRQ>  [<ffffffff810ab7ee>] ? __report_bad_irq+0x1e/0x90
 [<ffffffff810ab9eb>] ? note_interrupt+0x18b/0x1d0
 [<ffffffff810ac2fd>] ? handle_fasteoi_irq+0xcd/0xf0
 [<ffffffff810153e5>] ? handle_irq+0x15/0x20
 [<ffffffff81014902>] ? do_IRQ+0x62/0xe0
 [<ffffffff81012a53>] ? ret_from_intr+0x0/0x11
 <EOI>  [<ffffffff81033d22>] ? native_safe_halt+0x2/0x10
 [<ffffffffa01d2233>] ? acpi_idle_enter_c1+0x9b/0x112 [processor]
 [<ffffffff81285342>] ? menu_select+0x102/0x290
 [<ffffffff8128422f>] ? cpuidle_idle_call+0x9f/0x170
 [<ffffffff81011202>] ? cpu_idle+0xb2/0x110
 [<ffffffff81516d33>] ? start_kernel+0x3c6/0x3d1
 [<ffffffff81516430>] ? x86_64_start_kernel+0xfd/0x10c
handlers:
[<ffffffffa009a7f0>] (usb_hcd_irq+0x0/0x80 [usbcore])
Disabling IRQ #19

...after which the PCI USB card stops working in the guest. Is this
issue related to the issue the other person had? I'm more than willing
to help out with testing, if you or another developer are interested
in fixing this passthrough support.

Thanks :)

Best Regards
Kenni Lund
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux