From: Alex Williamson <alex.williamson@redhat.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David Woodhouse <dwmw2@infradead.org>,
David Gibson <dwg@au1.ibm.com>,
joerg.roedel@amd.com, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, chrisw@redhat.com, agraf@suse.de,
scottwood@freescale.com, B08248@freescale.com
Subject: Re: [PATCH 1/4] iommu: Add iommu_device_group callback and iommu_group sysfs entry
Date: Thu, 01 Dec 2011 15:37:50 -0700 [thread overview]
Message-ID: <1322779070.26545.152.camel@bling.home> (raw)
In-Reply-To: <1322775989.3729.35.camel@pasglop>
On Fri, 2011-12-02 at 08:46 +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2011-12-01 at 07:34 -0700, Alex Williamson wrote:
>
> > We've got multiple levels when we add qemu and guests into the mix. A
> > group is the smallest assignable unit for kernel->userspace. In fact,
> > vfio is constructed so that the user cannot do anything with a group
> > until all the devices of the group are bound to the vfio bus drivers.
> > Qemu, as a userspace driver, must therefore take ownership of the entire
> > group. However, there's no requirement that a userspace driver must
> > make use of all the devices in the group, so qemu is free to expose
> > individual devices from the group to the guest.
>
> Sure but that has nothing to do with your kernel->user API. As you said,
> you still need to take "ownership" of the entire group. If qemu chose to
> only present to the guest part of that group, it's qemu's problem.
>
> Put it differently. One day, maybe, we'll finally get some clues and
> implement a proper way for admin tools to know what can or cannot be put
> into a guest. In any case, how would you present to the user
> (administrator) the groups ? By individual devices with odd behaviours /
> errors etc... when the said user/admin tries to put individual devices
> into different partitions while they belong in the same group ? Or by
> just exposing ... groups ?
Why are we even talking about this here? We both agree on the
kernel->user ownership model and it's qemu's decision what to do from
there. x86 will typically have groups with a single device. When
that's not the case, it really doesn't seem that hard for an admin tool
to notify the user and ask them if they want to also assign the
dependent device or leave it unused. The complexity vs "hey, why did
this other device just appear on my guest and disappear from my host" or
even "why won't this stupid tool let me separate these two devices"
feels like a wash.
> So while those various tools will want to see what's in the group (to
> represent it to the user, to expose it to the guest, for other finer
> grained operations such as MSI setup, etc...) the basic unit of
> ownership is and remains the group, and I don't see how it makes sense
> to have your underlying iommu interface operate on anything else.
Are we going to tear apart every aspect of the IOMMU API, or can we use
some pieces of it as it exists and incrementally improve it? Yes, if
the IOMMU really can't distinguish between devices in a group, it
probably doesn't matter which of them you attach to a domain. However,
groups of devices aren't a basic unit of work for the rest of the kernel
and even if the iommu device decoders can't tell the difference between
transactions from hardware, the iommu driver might care for accounting
purposes.
> > IMHO, it doesn't make
> > sense to have a default model saying "I know you just wanted the nic,
> > but it's in the same group as this graphics card, so surprise, you get
> > both!". Obviously if a user does want to expose multiple devices from a
> > group to a guest, we support that too.
>
> No you don't get it. That's the wrong way around. The user will be
> presented to start with with a group of nic+graphics card so that user
> knows from the beginning what's going on.
>
> Because your other option is to put the nic in ... and suddenly have the
> graphic card go away from the host without showing up in a guest. That
> won't be any better than having it "just show up" in the guest without
> asking for it.
>
> IE. In both cases, it's wrong. The only thing that makes sense is from
> the beginning, expose those two as a group so that the user has no other
> choice but put them both into the guest at once and have it represented
> to the user as such to begin with.
People have very different ideas about what's intuitive and how
interfaces should work, just look at gnome3/unity versus the useful
desktops we used to have. Neither of us are likely to write the piece
of management code that does this and the design decisions we're making
here enable either usage model.
> > Spitting groups among multiple VMs or between VM and native host drivers
> > defeats the purpose of the group. Neither of these are allowed.
> >
> > > Btw, did we get a quirk for the Ricoh multi-function devices which all
> > > need to be in the same group because they do all their DMA from function
> > > zero? I think we need another similar quirk for a Marvell SATA
> > > controller which seems to do its AHCI DMA from its IDE function; see
> > > https://bugzilla.redhat.com/757166
> >
> > No, as I mentioned, groups are currently for iommu_ops, not dma_ops,
> > though it makes sense that iommu drivers could use the group info or
> > create common quirk infrastructure for handling broken devices like
> > these. Thanks,
>
> Which is why the group info in iommu_ops should just be a representation
> of something else under the hood that needs to be sorted out more
> clearly than what we are doing at the moment.
I will be happy to review your patches to transform groups from an
identifier into an object and make them the pervasive unit of work in
the iommu layer. The above problem can be solved by:
struct pci_dev *pci_quirk_dma_dev(struct pci_dev *pdev)
{
if (some match code)
return lookup different device
return pdev
}
Which would get called by both the dma_ops code and iommu_device_group.
Thanks,
Alex
next prev parent reply other threads:[~2011-12-01 22:38 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-21 19:55 [PATCH 0/4] iommu: iommu_ops group interface Alex Williamson
2011-10-21 19:56 ` [PATCH 1/4] iommu: Add iommu_device_group callback and iommu_group sysfs entry Alex Williamson
2011-11-30 2:42 ` David Gibson
2011-11-30 4:51 ` Benjamin Herrenschmidt
2011-11-30 5:25 ` Alex Williamson
2011-11-30 9:23 ` Benjamin Herrenschmidt
2011-12-01 0:06 ` David Gibson
2011-12-01 6:20 ` Alex Williamson
2011-12-01 0:03 ` David Gibson
2011-12-01 0:52 ` Chris Wright
2011-12-01 0:57 ` David Gibson
2011-12-01 1:04 ` Chris Wright
2011-12-01 1:50 ` Benjamin Herrenschmidt
2011-12-01 2:00 ` David Gibson
2011-12-01 2:05 ` Chris Wright
2011-12-01 7:28 ` Alex Williamson
2011-12-01 14:02 ` Yoder Stuart-B08248
2011-12-01 6:48 ` Alex Williamson
2011-12-01 10:33 ` David Woodhouse
2011-12-01 14:34 ` Alex Williamson
2011-12-01 21:46 ` Benjamin Herrenschmidt
2011-12-01 22:37 ` Alex Williamson [this message]
2011-12-01 23:14 ` David Woodhouse
2011-12-07 6:20 ` Benjamin Herrenschmidt
2011-12-01 21:32 ` Benjamin Herrenschmidt
2011-10-21 19:56 ` [PATCH 2/4] intel-iommu: Implement iommu_device_group Alex Williamson
2011-11-08 17:23 ` Roedel, Joerg
2011-11-10 15:22 ` David Woodhouse
2011-10-21 19:56 ` [PATCH 3/4] amd-iommu: " Alex Williamson
2011-10-21 19:56 ` [PATCH 4/4] iommu: Add option to group multi-function devices Alex Williamson
2011-12-01 0:11 ` David Gibson
2011-10-21 20:34 ` [PATCH 0/4] iommu: iommu_ops group interface Woodhouse, David
2011-10-21 21:16 ` Alex Williamson
2011-10-21 22:39 ` Woodhouse, David
2011-10-21 22:34 ` Alex Williamson
2011-10-27 16:31 ` Alex Williamson
2011-11-15 15:51 ` Roedel, Joerg
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=1322779070.26545.152.camel@bling.home \
--to=alex.williamson@redhat.com \
--cc=B08248@freescale.com \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=chrisw@redhat.com \
--cc=dwg@au1.ibm.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joerg.roedel@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=scottwood@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
all inboxes | Powered by JetHome®