From: Alex Williamson <alex.williamson@redhat.com>
To: Kirti Wankhede <kwankhede@nvidia.com>
Cc: <pbonzini@redhat.com>, <kraxel@redhat.com>, <cjia@nvidia.com>,
<qemu-devel@nongnu.org>, <kvm@vger.kernel.org>,
<kevin.tian@intel.com>, <jike.song@intel.com>,
<bjsdjshi@linux.vnet.ibm.com>
Subject: Re: [PATCH v6 3/4] vfio iommu: Add support for mediated devices
Date: Thu, 11 Aug 2016 10:28:13 -0600 [thread overview]
Message-ID: <20160811102813.269ab5f4@t450s.home> (raw)
In-Reply-To: <3924f091-a583-ec8c-75a2-dd3df47b5784@nvidia.com>
On Thu, 11 Aug 2016 19:52:06 +0530
Kirti Wankhede <kwankhede@nvidia.com> wrote:
> Thanks Alex. I'll take care of suggested nits and rename structures and
> function.
>
> On 8/10/2016 12:30 AM, Alex Williamson wrote:
> > On Thu, 4 Aug 2016 00:33:53 +0530
> > Kirti Wankhede <kwankhede@nvidia.com> wrote:
> >
> ...
>
> >>
> >> +/*
> >> + * Pin a set of guest PFNs and return their associated host PFNs for
> mediated
> >> + * domain only.
> >
> > Why only mediated domain? What assumption is specific to a mediated
> > domain other than unnecessarily passing an mdev_device?
> >
> >> + * @user_pfn [in]: array of user/guest PFNs
> >> + * @npage [in]: count of array elements
> >> + * @prot [in] : protection flags
> >> + * @phys_pfn[out] : array of host PFNs
> >> + */
> >> +long vfio_pin_pages(struct mdev_device *mdev, unsigned long *user_pfn,
> >
> > Why use and mdev_device here? We only reference the struct device to
> > get the drvdata. (dev also not listed above in param description)
> >
>
> Ok.
>
> >> + long npage, int prot, unsigned long *phys_pfn)
> >> +{
> >> + struct vfio_device *device;
> >> + struct vfio_container *container;
> >> + struct vfio_iommu_driver *driver;
> >> + ssize_t ret = -EINVAL;
> >> +
> >> + if (!mdev || !user_pfn || !phys_pfn)
> >> + return -EINVAL;
> >> +
> >> + device = dev_get_drvdata(&mdev->dev);
> >> +
> >> + if (!device || !device->group)
> >> + return -EINVAL;
> >> +
> >> + container = device->group->container;
> >
> > This doesn't seem like a valid way to get a reference to the container
> > and in fact there is no reference at all. I think you need to use
> > vfio_device_get_from_dev(), check and increment container_users around
> > the callback, abort on noiommu groups, and check for viability.
> >
>
> Thanks for pointing that out. I'll change it as suggested.
>
> >
> >
> > I see how you're trying to only do accounting when there is only an
> > mdev (local) domain, but the devices attached to the normal iommu API
> > domain can go away at any point. Where do we re-establish accounting
> > should the pinning from those devices be removed? I don't see that as
> > being an optional support case since userspace can already do this.
> >
>
> I missed this case. So in that case, when
> vfio_iommu_type1_detach_group() for iommu group for that device is
> called and it is the last entry in iommu capable domain_list, it should
> re-iterate through pfn_list of mediated_domain and do the accounting,
> right? Then we also have to update accounting when iommu capable device
> is hotplugged while mediated_domain already exist.
Yes, so pages are going to get pinned once for the iommu api domain and
once for the mediated domain, and accounting needs to be updated for
those domains coming and going in any order. Thanks,
Alex
next prev parent reply other threads:[~2016-08-11 16:28 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 19:03 [PATCH v6 0/4] Add Mediated device support Kirti Wankhede
2016-08-03 19:03 ` [PATCH v6 1/4] vfio: Mediated device Core driver Kirti Wankhede
2016-08-04 7:21 ` Tian, Kevin
2016-08-05 6:13 ` Kirti Wankhede
2016-08-15 9:15 ` Tian, Kevin
2016-08-09 19:00 ` Alex Williamson
2016-08-12 18:44 ` Kirti Wankhede
2016-08-12 21:16 ` Alex Williamson
2016-08-13 0:37 ` Kirti Wankhede
2016-08-15 9:38 ` Tian, Kevin
2016-08-15 15:59 ` Alex Williamson
2016-08-15 22:09 ` Neo Jia
2016-08-15 22:52 ` Alex Williamson
2016-08-15 23:23 ` Neo Jia
2016-08-16 0:49 ` Tian, Kevin
2016-08-15 19:59 ` Neo Jia
2016-08-15 22:47 ` [Qemu-devel] " Alex Williamson
2016-08-15 23:54 ` Neo Jia
2016-08-16 0:18 ` Tian, Kevin
2016-08-16 20:30 ` [Qemu-devel] " Neo Jia
2016-08-16 20:51 ` Alex Williamson
2016-08-16 21:17 ` Neo Jia
2016-08-16 0:30 ` Tian, Kevin
2016-08-16 3:45 ` Neo Jia
2016-08-16 3:50 ` Tian, Kevin
2016-08-16 4:16 ` Neo Jia
2016-08-16 4:52 ` Tian, Kevin
2016-08-16 5:43 ` Neo Jia
2016-08-16 5:58 ` Tian, Kevin
2016-08-16 6:13 ` Neo Jia
2016-08-16 21:03 ` Alex Williamson
2016-08-16 12:49 ` [Qemu-devel] " Alex Williamson
2016-08-03 19:03 ` [PATCH v6 2/4] vfio: VFIO driver for mediated PCI device Kirti Wankhede
2016-08-03 21:03 ` kbuild test robot
2016-08-04 0:19 ` kbuild test robot
2016-08-09 19:00 ` Alex Williamson
2016-08-10 21:23 ` Kirti Wankhede
2016-08-10 23:00 ` Alex Williamson
2016-08-11 15:59 ` Kirti Wankhede
2016-08-11 16:24 ` Alex Williamson
2016-08-11 17:46 ` Kirti Wankhede
2016-08-11 18:43 ` Alex Williamson
2016-08-12 17:57 ` Kirti Wankhede
2016-08-12 21:25 ` Alex Williamson
2016-08-13 0:42 ` Kirti Wankhede
2016-08-03 19:03 ` [PATCH v6 3/4] vfio iommu: Add support for mediated devices Kirti Wankhede
2016-08-09 19:00 ` Alex Williamson
2016-08-11 14:22 ` Kirti Wankhede
2016-08-11 16:28 ` Alex Williamson [this message]
2016-08-03 19:03 ` [PATCH v6 4/4] docs: Add Documentation for Mediated devices Kirti Wankhede
2016-08-04 7:31 ` Tian, Kevin
2016-08-05 7:45 ` Kirti Wankhede
2016-08-24 22:36 ` [Qemu-devel] " Daniel P. Berrange
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=20160811102813.269ab5f4@t450s.home \
--to=alex.williamson@redhat.com \
--cc=bjsdjshi@linux.vnet.ibm.com \
--cc=cjia@nvidia.com \
--cc=jike.song@intel.com \
--cc=kevin.tian@intel.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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).