qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Le Tan <tamlokveer@gmail.com>
Cc: Jan Kiszka <jan.kiszka@web.de>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] vfio in the guest: no available reset mechanism
Date: Wed, 30 Jul 2014 16:49:37 +0200	[thread overview]
Message-ID: <20140730144937.GC26933@redhat.com> (raw)
In-Reply-To: <CACrq+iLkYP1vhTfwfTFMuv5x69FZOkuAtshiC1PCWOOX_qhKmg@mail.gmail.com>

On Wed, Jul 30, 2014 at 10:16:32PM +0800, Le Tan wrote:
> Hi Michael,
> 
> 2014-07-30 21:16 GMT+08:00 Michael S. Tsirkin <mst@redhat.com>:
> > On Wed, Jul 30, 2014 at 08:24:04PM +0800, Le Tan wrote:
> >> Hi,
> >> I am testing vfio in L1 with my VT-d emulation project. I assigned one
> >> of the two AHCI controllers in L1 to L2 via vfio. After I ran the QEMU
> >> in L1, it complains that:
> >> qemu-system-x86_64: vfio: Cannot reset device 0000:00:03.0, no
> >> available reset mechanism.
> >> qemu-system-x86_64: vfio: Cannot reset device 0000:00:03.0, no
> >> available reset mechanism.
> >>
> >> Then L2 paused when the SeaBIOS executed in ahci_controller_setup(). I
> >> look into this and found that:
> >> val = ahci_ctrl_readl(ctrl, HOST_CTL);
> >> ahci_ctrl_writel(ctrl, HOST_CTL, val | HOST_CTL_AHCI_EN);
> >> When the BIOS tried to read the HOST_CTL, it returns 0x80000002, which
> >> bit 2 (Interrupt Enable) is 1. The AHCI manual says that this bit
> >> should be cleared by default. So maybe L1 didn't reset the device
> >> before assigning it to L2?
> >> Then the BIOS tried to write back to HOST_CTL and it was stuck here. :(
> >>
> >> So can anyone give me some advice? About the state of PCI device or
> >> bus-level reset?
> >>
> >> Here is the detail of the environment and the way I did the vfio.
> >> 1. lspci in L1 said:
> >> 00:03.0 SATA controller [0106]: Intel Corporation 82801IR/IO/IH
> >> (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] [8086:2922] (rev 02)
> >> 00:1f.0 ISA bridge [0601]: Intel Corporation 82801IB (ICH9) LPC
> >> Interface Controller [8086:2918] (rev 02)
> >> 00:1f.2 SATA controller [0106]: Intel Corporation 82801IR/IO/IH
> >> (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] [8086:2922] (rev 02)
> >> 00:1f.3 SMBus [0c05]: Intel Corporation 82801I (ICH9 Family) SMBus
> >> Controller [8086:2930] (rev 02)
> >> 2. Unbind 00:03.0 and do vfio:
> >> modprobe -r vfio_iommu_type1
> >> modprobe vfio_iommu_type1 allow_unsafe_interrupts=1
> >> modprobe vfio-pci
> >> echo 0000:00:03.0 > /sys/bus/pci/devices/0000\:00\:03.0/driver/unbind
> >> echo "8086 2922" > /sys/bus/pci/drivers/vfio-pci/new_id
> >> 3. run L2 with "-device vfio-pci,host=00:03.0"
> >>
> >> Any help is appreciated! Thanks very much!
> >>
> >> Regards,
> >> Le
> >
> > Clearly, bus level reset can't work for the root bus :)
> 
> Thanks very much!
> I test the vfio with a second-bus ahci controller and it didn't
> complain about the lack of reset mechanism. :) And the return val of
> HOST_CTL is normal now (the same as emulated ahci controller).
> However, it still paused when the BIOS tried to write to the HOST_CTL.
> Do you have any idea?
> And we should just test vfio and legacy pci-assignment with second bus
> devices, not considering the root-bus devices?
> Thanks again!
> 
> Regards,
> Le

If you want it to work for root bus, you need to implement
a device/function level reset mechanism, e.g. using PM or FLR.

> > --
> > MST

      parent reply	other threads:[~2014-07-30 14:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30 12:24 [Qemu-devel] vfio in the guest: no available reset mechanism Le Tan
2014-07-30 13:16 ` Michael S. Tsirkin
2014-07-30 14:16   ` Le Tan
2014-07-30 14:46     ` Alex Williamson
2014-08-01  1:35       ` Le Tan
2014-08-01 15:25         ` Alex Williamson
2014-08-01 16:35           ` Alex Williamson
2014-08-01 16:39             ` Jan Kiszka
2014-08-01 17:16               ` Alex Williamson
2014-08-02  5:54                 ` Jan Kiszka
2014-08-04 12:43                   ` Michael S. Tsirkin
2014-08-01 22:58           ` Le Tan
2014-07-30 14:49     ` Michael S. Tsirkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140730144937.GC26933@redhat.com \
    --to=mst@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    --cc=tamlokveer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).