qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Yoder Stuart-B08248 <B08248@freescale.com>
Cc: 'Peter Maydell' <peter.maydell@linaro.org>,
	'Antonios Motakis' <a.motakis@virtualopensystems.com>,
	Wood Scott-B07421 <B07421@freescale.com>,
	'Santosh Shukla' <santosh.shukla@linaro.org>,
	'Alexander Graf' <agraf@suse.de>,
	"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"'kim.phillips@linaro.org'" <kim.phillips@linaro.org>,
	Bhushan Bharat-R65777 <R65777@freescale.com>,
	Sethi Varun-B16395 <B16395@freescale.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	'Christoffer Dall' <christoffer.dall@linaro.org>
Subject: Re: [Qemu-devel] vfio for platform devices - 9/5/2012 - minutes
Date: Wed, 11 Sep 2013 11:14:42 -0600	[thread overview]
Message-ID: <1378919682.2631.378.camel@ul30vt.home> (raw)
In-Reply-To: <9F6FE96B71CF29479FF1CDC8046E15036AA03E@039-SN1MPN1-002.039d.mgd.msft.net>

On Wed, 2013-09-11 at 16:42 +0000, Yoder Stuart-B08248 wrote:
> 
> > -----Original Message-----
> > From: Yoder Stuart-B08248
> > Sent: Thursday, September 05, 2013 12:51 PM
> > To: Wood Scott-B07421; Sethi Varun-B16395; Bhushan Bharat-R65777; 'Peter
> > Maydell'; 'Santosh Shukla'; 'Alex Williamson'; 'Alexander Graf';
> > 'Antonios Motakis'; 'Christoffer Dall'; 'kim.phillips@linaro.org'
> > Cc: kvmarm@lists.cs.columbia.edu; 'kvm-ppc@vger.kernel.org'; 'qemu-
> > devel@nongnu.org'
> > Subject: vfio for platform devices - 9/5/2012 - minutes
> > 
> > We had a call with those interested and/or working on vfio
> > for platform devices.
> > 
> > Participants: Scott Wood, Varun Sethi, Bharat Bhushan, Peter Maydell,
> >               Santosh Shukla, Alex Williamson, Alexander Graf,
> >               Antonios Motakis, Christoffer Dall, Kim Phillips,
> >               Stuart Yoder
> > 
> > Several aspects to vfio for platform devices:
> > 
> > 1. IOMMU groups
> > 
> >  -iommu driver needs to register a bus notifier for the platform bus
> >   and create groups for relevant platform devices
> >  -Antonios is looking at this for several ARM IOMMUs
> >  -PAMU (Freescale) driver already does this
> > 
> > 2. unbinding device from host
> > 
> >  PCI:
> >    echo 0000:06:0d.0 > /sys/bus/pci/devices/0000:06:0d.0/driver/unbind
> >  Platform:
> >    echo ffe101300.dma >
> > /sys/bus/platform/devices/ffe101300.dma/driver/unbind
> > 
> >  -don't believe there are issues or work to do here
> > 
> > 3. binding device to vfio-platform driver
> > 
> >  PCI:
> >    echo 1102 0002 > /sys/bus/pci/drivers/vfio-pci/new_id
> > 
> >  -this is probably the least understood issue-- platform drivers
> >   register themselves with the bus for a specific "name"
> >   string.  That is matched with device tree "compatible" strings
> >   later to bind a device to a driver
> >  -we want is to have the vfio-platform driver to dynamically bind
> >   to a variety of platform devices previously unknown to
> >   vfio-platform
> >  -ideally unbinding and binding could be an atomic operation
> >  -Alex W pointed out that x86 could leverage this work so
> >   keep that in mind in what we design
> >  -Kim Phillips (Linaro) will start working on this
> 
> One thing we didn't discuss needs to be considered (probably by
> Kim who is looking at the 'binding device' issue) is around
> returning a passthru device back to the host.
> 
> After a platform device has been bound to vfio and is in use by
> user space or a virtual machine, we also need to be able
> to unwind all that and return the device back to the host
> in a sane state.
> 
> What happens when user space exits and the vfio file
> descriptors are closed?

For reference, expectations of how vfio-pci handles these situations:

For vfio-pci, when the reference count on the device fd drops to zero we
call a device disable function that includes disabling the bus master
bit in config space stop ongoing DMA.

> What if the device is still active and doing bus 
> mastering?   (e.g. a VM crashed causing a QEMU
> exit)

If the VM crashes the vfio fds get released resulting in the above
opportunity for the vfio device driver to quiesce the device.

> How can the vfio-platform layer in the host kernel
> get a specific device in a sane state?

It's not easy on pci either.  We save config space prior to exposing the
device and restore config space later, but it's not complete.  We mostly
rely on device (function) resets, to put things in a sane state, but
those aren't always supported.  I just introduced patches for v3.12 that
enable a PCI bus reset interface, but it's mostly useful for userspace,
since on PCI it's often the case that a bus contains multiple devices
which don't necessarily align to iommu group boundaries.

> When a plaform device is 'unbound' from vfio, what
> specifically happens to the device?

The driver remove function is called, which needs to call
vfio_del_group_dev(), which will block if the device is in use.  If it's
unused, the release function should have already been called and the
device should be in a quiesced state.  On x86/pci, there is no auto
probe of devices when unbound, so the device sits without a driver until
manually bound or until something causes an auto probe.  Thanks,

Alex

> Platform devices don't have generic mechanisms like on PCI
> to disable bus mastering or even disable or reset a
> device.
> 
> Haven't thought through all this yet, but just raising
> some issues I see.
> 
> Regards,
> Stuart
> 
> 
> 
> 

  parent reply	other threads:[~2013-09-11 17:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 16:42 [Qemu-devel] vfio for platform devices - 9/5/2012 - minutes Yoder Stuart-B08248
2013-09-11 17:08 ` Scott Wood
2013-09-11 17:14 ` Alex Williamson [this message]
2013-09-12  9:18   ` Bhushan Bharat-R65777
2013-09-12 18:10     ` Scott Wood
2013-09-12 21:23       ` Alexander Graf
2013-09-12 21:45         ` Scott Wood
2013-09-12 21:48           ` Alexander Graf
2013-09-12 21:51             ` Scott Wood
  -- strict thread matches above, loose matches on Subject: below --
2013-09-05 17:51 Yoder Stuart-B08248
2013-09-06 16:56 ` Sethi Varun-B16395
2013-09-06 18:20   ` Yoder Stuart-B08248
2013-09-09  8:52     ` Will Deacon
2013-09-09  9:18       ` Sethi Varun-B16395

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=1378919682.2631.378.camel@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=B07421@freescale.com \
    --cc=B08248@freescale.com \
    --cc=B16395@freescale.com \
    --cc=R65777@freescale.com \
    --cc=a.motakis@virtualopensystems.com \
    --cc=agraf@suse.de \
    --cc=christoffer.dall@linaro.org \
    --cc=kim.phillips@linaro.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=santosh.shukla@linaro.org \
    /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).