All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Michael Williamson <mike.a.williamson@gmail.com>
Cc: Yi Liu <yi.l.liu@intel.com>, <kvm@vger.kernel.org>,
	Jason Gunthorpe <jgg@nvidia.com>, Vidya Sagar <vidyas@nvidia.com>
Subject: Re: Supporting VFIO on nVidia's Orin platform
Date: Mon, 30 Sep 2024 14:47:36 -0700	[thread overview]
Message-ID: <ZvsceAd20HVZ5Ugn@Asurada-Nvidia> (raw)
In-Reply-To: <CACcEcgTuhgX5RYCCCwU+sWS7iGKUVpGQkFGdh8yWyTVxoU=fiw@mail.gmail.com>

On Mon, Sep 30, 2024 at 05:27:33PM -0400, Michael Williamson wrote:
> On Mon, Sep 30, 2024 at 12:00 AM Yi Liu <yi.l.liu@intel.com> wrote:
> >
> > On 2024/9/29 23:02, Michael Williamson wrote:
> > > Hello,
> > >
> > > I've been trying to get VFIO working on nVidia's Orin platform (ARM64) in
> > > order to support moving data efficiently off of an attached FPGA PCIe board
> > > using the SMMU from a user space application.  We have a full application
> > > working on x86/x64 boxes that properly support the VFIO interface.  We're
> > > trying to port support to the Orin.
> > >
> > > I'm on nVidia's 5.15.36 branch.  It doesn't work out of the box, as the
> > > tegra194-pcie platform controller is lumped in the same iommu group as the
> > > actual PCIe card.  The acs override patch didn't help to separate them.
> > >
> > > I have a patch below that *seems* to work for us, but I will admit I do not
> > > know the implications of what I am doing here.
> >
> > your below patch is to pass the vfio_dev_viable() check I suppose. If you
> 
> yes.
> 
> > are sure the tegra194-pcie platform controller will not issue DMA, then it
> > is fine. If not, you should be careful about it.
> >
> 
> There are multiple tegra194-pcie platform controllers defined in the dts.  This
> one only has the one PCIe slot we are working with and nothing else.  There
> are other instances of the tegra194-pcie controllers that have control over
> other PCIe devices in the system.  There appear to be two main smmu controllers
> that support multiple masters.  The tegra194-pcie platform controller tied
> to the PCIe bus I want has a unique smmu/iommu master ID but is sharing the main
> smmu controller with other devices.  However, they are all assigned to
> different iommu groups, so I think this is OK?
> 
> > > Can anyone let me know if this is (and why it is) a bad idea, and what really
> > > needs to be done?  Or if this is the wrong mailing list, point me in the right
> > > direction?
> >
> > this is the right place to ask. +NV folks I know.
> >
> 
> I appreciate the insight.  Thank you.

I am not quite sure about tegra194-pcie. +Vidya who's the owner.

Nicolin

> > > Thanks,
> > > Mike
> > >
> > > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> > > index 818e47fc0896..a598a2204781 100644
> > > --- a/drivers/vfio/vfio.c
> > > +++ b/drivers/vfio/vfio.c
> > > @@ -638,8 +638,15 @@ static struct vfio_device
> > > *vfio_group_get_device(struct vfio_group *group,
> > >    * breaks anything, it only does so for user owned devices downstream.  Note
> > >    * that error notification via MSI can be affected for platforms that handle
> > >    * MSI within the same IOVA space as DMA.
> > > + *
> > > + * [MAW] - the tegra194-pcie driver is a platform PCie device controller and
> > > + * fails the dev_is_pci() check below.  Not sure if it's because its grouping
> > > + * needs to be reworked, but I don't know how this is (or if it
> > > should be) done.
> > > + * This is a hack to see if we can get it going well enough to use the
> > > + * SMMU from user space.  The other two devices (for the Orin) in the group
> > > + * are the host bridge and the PCIe card itself.
> > >    */
> > > -static const char * const vfio_driver_allowed[] = { "pci-stub" };
> > > +static const char * const vfio_driver_allowed[] = { "pci-stub",
> > > "tegra194-pcie" };
> > >
> > >   static bool vfio_dev_driver_allowed(struct device *dev,
> > >                                      struct device_driver *drv)
> > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> > > index 66bbb125d761..e34fbe17ae1a 100644
> > > --- a/drivers/vfio/vfio_iommu_type1.c
> > > +++ b/drivers/vfio/vfio_iommu_type1.c
> > > @@ -45,7 +45,8 @@
> > >   #define DRIVER_AUTHOR   "Alex Williamson <alex.williamson@redhat.com>"
> > >   #define DRIVER_DESC     "Type1 IOMMU driver for VFIO"
> > >
> > > -static bool allow_unsafe_interrupts;
> > > +/** [MAW] - hack, need this set for Orin test, not compiled is module
> > > currently */
> > > +static bool allow_unsafe_interrupts = true;
> > >   module_param_named(allow_unsafe_interrupts,
> > >                     allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR);
> > >   MODULE_PARM_DESC(allow_unsafe_interrupts,
> > > @@ -1733,8 +1734,18 @@ static int vfio_bus_type(struct device *dev, void *data)
> > >   {
> > >          struct bus_type **bus = data;
> > >
> > > -       if (*bus && *bus != dev->bus)
> > > +       /**
> > > +        * [MAW] - hack.  the orin tegra194-pcie is in this group and
> > > +        * reports in as bus-type of "platform".  We will ignore it
> > > +        * in an attempt to get vfio to play along.
> > > +        */
> > > +       if (!strcmp(dev->bus->name,"platform")) {
> > > +               return 0;
> > > +       }
> > > +
> > > +       if (*bus && *bus != dev->bus) {
> > >                  return -EINVAL;
> > > +       }
> > >
> > >          *bus = dev->bus;
> > >
> >
> > --
> > Regards,
> > Yi Liu
> 
> 
> 
> --
> Mike Williamson
> OpenPGP Public Key

      reply	other threads:[~2024-09-30 21:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29 15:02 Supporting VFIO on nVidia's Orin platform Michael Williamson
2024-09-30  4:04 ` Yi Liu
2024-09-30 21:27   ` Michael Williamson
2024-09-30 21:47     ` Nicolin Chen [this message]

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=ZvsceAd20HVZ5Ugn@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=jgg@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=mike.a.williamson@gmail.com \
    --cc=vidyas@nvidia.com \
    --cc=yi.l.liu@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.