From: Scott Wood <scottwood@freescale.com>
To: Yoder Stuart-B08248 <B08248@freescale.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Alexander Graf <agraf@suse.de>,
Wood Scott-B07421 <B07421@freescale.com>,
Bhushan Bharat-R65777 <R65777@freescale.com>,
Sethi Varun-B16395 <B16395@freescale.com>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
Antonios Motakis <a.motakis@virtualopensystems.com>,
"kvm@vger.kernel.org list" <kvm@vger.kernel.org>,
"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: RFC: vfio interface for platform devices
Date: Wed, 3 Jul 2013 17:31:35 -0500 [thread overview]
Message-ID: <1372890695.8183.155@snotra> (raw)
In-Reply-To: <9F6FE96B71CF29479FF1CDC8046E15036334B4@039-SN1MPN1-004.039d.mgd.msft.net> (from B08248@freescale.com on Tue Jul 2 18:25:59 2013)
On 07/02/2013 06:25:59 PM, Yoder Stuart-B08248 wrote:
> The write-up below is the first draft of a proposal for how the
> kernel can expose
> platform devices to user space using vfio.
>
> In short, I'm proposing a new ioctl VFIO_DEVICE_GET_DEVTREE_INFO which
> allows user space to correlate regions and interrupts to the
> corresponding
> device tree node structure that is defined for most platform devices.
>
> Regards,
> Stuart Yoder
>
> ------------------------------------------------------------------------------
> VFIO for Platform Devices
>
> The existing infrastructure for vfio-pci is pretty close to what we
> need:
> -mechanism to create a container
> -add groups/devices to a container
> -set the IOMMU model
> -map DMA regions
> -get an fd for a specific device, which allows user space to
> determine
> info about device regions (e.g. registers) and interrupt info
> -support for mmapping device regions
> -mechanism to set how interrupts are signaled
>
> Platform devices can get complicated-- potentially with a tree
> hierarchy
> of nodes, and links/phandles pointing to other platform
> devices. The kernel doesn't expose relationships between
> devices. The kernel just exposes mappable register regions and
> interrupts.
> It's up to user space to work out relationships between devices
> if it needs to-- this can be determined in the device tree exposed in
> /proc/device-tree.
>
> I think the changes needed for vfio are around some of the device tree
> related info that needs to be available with the device fd.
>
> 1. VFIO_GROUP_GET_DEVICE_FD
>
> User space has to know which device it is accessing and will call
> VFIO_GROUP_GET_DEVICE_FD passing a specific platform device path to
> get the device information:
>
> fd = ioctl(group, VFIO_GROUP_GET_DEVICE_FD,
> "/soc@ffe000000/usb@210000");
>
> (whether the path is a device tree path or a sysfs path is up for
> discussion, e.g. "/sys/bus/platform/devices/ffe210000.usb")
Doesn't VFIO need to operate on an actual Linux device, rather than
just an OF node?
Are we going to have a fixed assumption that you always want all the
children of the node corresponding to the assigned device, or will it
be possible to exclude some?
> 2. VFIO_DEVICE_GET_INFO
>
> Don't think any changes are needed to VFIO_DEVICE_GET_INFO other
> than adding a new flag identifying a devices as a 'platform'
> device.
>
> This ioctl simply returns the number of regions and number of irqs.
>
> The number of regions corresponds to the number of regions
> that can be mapped for the device-- corresponds to the regions
> defined
> in "reg" and "ranges" in the device tree.
>
> 3. VFIO_DEVICE_GET_REGION_INFO
>
> No changes needed, except perhaps adding a new flag. Freescale
> has some
> devices with regions that must be mapped cacheable.
While I don't object to making the information available to the user
just in case, the main thing we need here is to influence what the
kernel does when the user tries to map it. At least on PPC it's not up
to userspace to select whether a mmap is cacheable.
> 4. VFIO_DEVICE_GET_DEVTREE_INFO
>
> The VFIO_DEVICE_GET_REGION_INFO and VFIO_DEVICE_GET_IRQ_INFO APIs
> expose device regions and interrupts, but it's not enough to know
> that there are X regions and Y interrupts. User space needs to
> know what the resources are for-- to correlate those
> regions/interrupts
> to the device tree structure that drivers use. The device tree
> structure could consist of multiple nodes and it is necessary to
> identify the node corresponding to the region/interrupt exposed
> by VFIO.
>
> The following information is needed:
> -the device tree path to the node corresponding to the
> region or interrupt
> -for a region, whether it corresponds to a "reg" or "ranges"
> property
> -there could be multiple sub-regions per "reg" or "ranges" and
> the sub-index within the reg/ranges is needed
>
> The VFIO_DEVICE_GET_DEVTREE_INFO operates on a device fd.
>
> ioctl: VFIO_DEVICE_GET_DEVTREE_INFO
>
> struct vfio_path_info {
> __u32 argsz;
> __u32 flags;
> #define VFIO_DEVTREE_INFO_RANGES (1 << 3) /* the region is a
> "ranges" property */
What about distinguishing a normal interrupt from one found in an
interrupt-map?
In the case of both ranges and interrupt-maps, we'll also want to
decide what the policy is for when to expose them directly, versus just
using them to translate regs and interrupts of child nodes.
> __u32 index; /* input: index of region or irq for
> which we are getting info */
> __u32 type; /* input: 0 - get devtree info for a
> region
> 1 - get devtree info for an
> irq
> */
> __u32 start; /* output: identifies the index
> within the reg/ranges */
"start" is an odd name for this. I'd rename "index" to "vfio_index"
and this to "dt_index".
> __u8 path[]; /* output: Full path to associated
> device tree node */
How does the caller know what size buffer to supply for this?
> The VFIO_DEVICE_GET_DEVTREE_INFO ioctl would return:
>
> -for region index 0:
> flags: 0x0 // i.e. this is a "reg" property
> start: 0x0 // i.e. index 0x0 in "reg"
> path: "/soc@ffe000000/crypto@300000"
>
> -for interrupt index 0:
> path: "/soc@ffe000000/crypto@300000/jr@1000"
>
> -for interrupt index 1:
> path: "/soc@ffe000000/crypto@300000/jr@2000"
Where is "start" for the interrupts?
-Scott
next prev parent reply other threads:[~2013-07-03 22:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 23:25 RFC: vfio interface for platform devices Yoder Stuart-B08248
2013-07-03 1:07 ` Alexander Graf
2013-07-03 18:51 ` Scott Wood
2013-07-03 19:08 ` Yoder Stuart-B08248
2013-07-03 3:07 ` Alex Williamson
2013-07-03 10:44 ` Antonios Motakis
2013-07-03 19:23 ` Yoder Stuart-B08248
2013-07-03 17:20 ` Yoder Stuart-B08248
2013-07-03 22:31 ` Scott Wood [this message]
2013-07-16 21:51 ` Yoder Stuart-B08248
2013-07-16 22:01 ` Scott Wood
2013-07-16 22:41 ` Yoder Stuart-B08248
2013-07-16 22:50 ` Scott Wood
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=1372890695.8183.155@snotra \
--to=scottwood@freescale.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=alex.williamson@redhat.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=virtualization@lists.linux-foundation.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