qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kim Phillips <kim.phillips@linaro.org>
To: alex.williamson@redhat.com
Cc: peter.maydell@linaro.org, kim.phillips@freescale.com,
	eric.auger@linaro.org, stuart.yoder@freescale.com,
	qemu-devel@nongnu.org, agraf@suse.de,
	a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu,
	christoffer.dall@linaro.org
Subject: Re: [Qemu-devel] [RFC 2/2] hw/misc/vfio: add vfio-platform support
Date: Tue, 4 Mar 2014 18:24:18 -0600	[thread overview]
Message-ID: <20140304182418.7840d09f8254faaac0d36e65@linaro.org> (raw)
In-Reply-To: <1393610598.26901.21.camel@ul30vt.home>

On Fri, 28 Feb 2014 11:03:18 -0700
Alex Williamson <alex.williamson@redhat.com> wrote:

> On Tue, 2014-02-25 at 20:37 -0600, Kim Phillips wrote:
> > - support allocating a variable number of regions
> >   - VFIODevice's bars[] become dynamically allocated *regions
> >   - VFIOBAR's device fd replaced with parent VFIODevice ptr,
> >     to facilitate BAR r/w ops calling vfio_eoi()
> 
> On one hand, I had assumed we'd create a hw/misc/vfio/ directory and
> perhaps split things into pci, common, vga, and platform.  We already
> need the pci vs vga split as there's lots of irrelevant and complicated
> vga quirks that most people don't want to see.  On the other hand, I'm
> surprised how much of the PCI code you can re-use.  Still, I think it
> would be cleaner to create a VFIOPCIDevice and a VFIOPlatformDevice.

sounds good, had started down that path but reverted it because I too
realized how much code was indeed being reused.  I'm ok with
VFIOPCIDevice and a separate VFIOPlatformDevice for now, thanks.

> >  static void vfio_map_bars(VFIODevice *vdev)
> >  {
> >      int i;
> >  
> > +    if (!vdev->config_size) {
> > +        /* platform device */
> > +        for (i = 0; i < vdev->nr_regions; i++) {
> > +            vfio_map_region(vdev, i);
> > +        }
> > +        return;
> > +    }
> 
> I don't understand this, vfio_map_region() calls vfio_mmap_bar(), but
> vfio_mmap_bar() has been gutted so that it only initializes the mmap
> subregion, but never adds it.  vfio_map_bar() does both the
> initialization of the slow, read/write, memory region as well as adding
> the mmap sub-region.  I don't see where platform devices get a memory
> region inserted anywhere into the guest address space.

it's being done by the board code via the first RFC/patch ("hw/arm/virt:
add a Calxeda XGMAC device"), and vfio_mmap_bar()'s call to
memory_region_init_ram_ptr().

Yeah, the slow, r/w ops region path isn't used, and I'm not sure how to
make it work without addressing the problems the first RFC presents.

> > -    if (dev_info.num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) {
> > +    if (dev_info.num_regions > PCI_NUM_REGIONS) ||
> > +        ((dev_info.flags & VFIO_DEVICE_FLAGS_PCI) &&
> > +         (dev_info.num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1)) {
> 
> Now we start to have platform devices error out if they have more
> regions than PCI knows about...  That doesn't make much sense.

right, I should have made it more clear that the multiple-regions code
is sketchy in the "support allocating a variable number of regions"
blurb in the commit text of this RFC.

> > +static void register_vfio_platform_dev_type(void)
> > +{
> > +    type_register_static(&vfio_platform_dev_info);
> > +}
> > +
> > +type_init(register_vfio_platform_dev_type)
> 
> This all looks reasonable, but I suspect it would be cleaner if
> vfio_find_get_group() was in a common file along with basic mmap and
> read/write access functions.  Thanks,

so rename existing hw/misc/vfio.c to its original name vfio-pci.c, and
load all common functions back into a vfio.c?

Kim

  reply	other threads:[~2014-03-05  0:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26  2:37 [Qemu-devel] [RFC 0/2] platform device passthrough Kim Phillips
2014-02-26  2:37 ` [Qemu-devel] [RFC 1/2] hw/arm/virt: add a Calxeda XGMAC device Kim Phillips
2014-03-05  4:27   ` Eric Auger
2014-03-05 11:25     ` Andreas Färber
2014-03-06  2:27       ` Eric Auger
2014-02-26  2:37 ` [Qemu-devel] [RFC 2/2] hw/misc/vfio: add vfio-platform support Kim Phillips
2014-02-28 18:03   ` Alex Williamson
2014-03-05  0:24     ` Kim Phillips [this message]
2014-03-05  1:23       ` Alex Williamson
2014-03-05 11:28         ` Andreas Färber
2014-03-05 11:30           ` Paolo Bonzini
2014-03-05  7:56   ` Eric Auger

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=20140304182418.7840d09f8254faaac0d36e65@linaro.org \
    --to=kim.phillips@linaro.org \
    --cc=a.motakis@virtualopensystems.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=christoffer.dall@linaro.org \
    --cc=eric.auger@linaro.org \
    --cc=kim.phillips@freescale.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stuart.yoder@freescale.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).