Re: [RFC PATCH 3/7] vfio: add spimdev support

2018-08-05 Thread Kenneth Lee
On Thu, Aug 02, 2018 at 12:43:27PM -0600, Alex Williamson wrote:
> Date: Thu, 2 Aug 2018 12:43:27 -0600
> From: Alex Williamson 
> To: Cornelia Huck 
> CC: Kenneth Lee , "Tian, Kevin"
>  , Kenneth Lee , Jonathan Corbet
>  , Herbert Xu , "David S .
>  Miller" , Joerg Roedel , Hao Fang
>  , Zhou Wang , Zaibo Xu
>  , Philippe Ombredanne , "Greg
>  Kroah-Hartman" , Thomas Gleixner
>  , "linux-...@vger.kernel.org"
>  , "linux-kernel@vger.kernel.org"
>  , "linux-cry...@vger.kernel.org"
>  , "io...@lists.linux-foundation.org"
>  , "k...@vger.kernel.org"
>  , "linux-accelerat...@lists.ozlabs.org\"
>  , Lu Baolu
>  ,  Kumar",   , " linux...@huawei.com "
>  ">
> Subject: Re: [RFC PATCH 3/7] vfio: add spimdev support
> Message-ID: <20180802124327.403b1...@t450s.home>
> 
> On Thu, 2 Aug 2018 10:35:28 +0200
> Cornelia Huck  wrote:
> 
> > On Thu, 2 Aug 2018 15:34:40 +0800
> > Kenneth Lee  wrote:
> > 
> > > On Thu, Aug 02, 2018 at 04:24:22AM +, Tian, Kevin wrote:  
> > 
> > > > > From: Kenneth Lee [mailto:liguo...@hisilicon.com]
> > > > > Sent: Thursday, August 2, 2018 11:47 AM
> > > > > 
> > > > > >
> > > > > > > From: Kenneth Lee
> > > > > > > Sent: Wednesday, August 1, 2018 6:22 PM
> > > > > > >
> > > > > > > From: Kenneth Lee 
> > > > > > >
> > > > > > > SPIMDEV is "Share Parent IOMMU Mdev". It is a vfio-mdev. But 
> > > > > > > differ
> > > > > from
> > > > > > > the general vfio-mdev:
> > > > > > >
> > > > > > > 1. It shares its parent's IOMMU.
> > > > > > > 2. There is no hardware resource attached to the mdev is created. 
> > > > > > > The
> > > > > > > hardware resource (A `queue') is allocated only when the mdev is
> > > > > > > opened.
> > > > > >
> > > > > > Alex has concern on doing so, as pointed out in:
> > > > > >
> > > > > > https://www.spinics.net/lists/kvm/msg172652.html
> > > > > >
> > > > > > resource allocation should be reserved at creation time.
> > > > > 
> > > > > Yes. That is why I keep telling that SPIMDEV is not for "VM", it is 
> > > > > for "many
> > > > > processes", it is just an access point to the process. Not a device 
> > > > > to VM. I
> > > > > hope
> > > > > Alex can accept it:)
> > > > > 
> > > > 
> > > > VFIO is just about assigning device resource to user space. It doesn't 
> > > > care
> > > > whether it's native processes or VM using the device so far. Along the 
> > > > direction
> > > > which you described, looks VFIO needs to support the configuration that
> > > > some mdevs are used for native process only, while others can be used
> > > > for both native and VM. I'm not sure whether there is a clean way to
> > > > enforce it...
> > > 
> > > I had the same idea at the beginning. But finally I found that the life 
> > > cycle
> > > of the virtual device for VM and process were different. Consider you 
> > > create
> > > some mdevs for VM use, you will give all those mdevs to lib-virt, which
> > > distribute those mdev to VMs or containers. If the VM or container exits, 
> > > the
> > > mdev is returned to the lib-virt and used for next allocation. It is the
> > > administrator who controlled every mdev's allocation.
> 
> Libvirt currently does no management of mdev devices, so I believe
> this example is fictitious.  The extent of libvirt's interaction with
> mdev is that XML may specify an mdev UUID as the source for a hostdev
> and set the permissions on the device files appropriately.  Whether
> mdevs are created in advance and re-used or created and destroyed
> around a VM instance (for example via qemu hooks scripts) is not a
> policy that libvirt imposes.
>  
> > > But for process, it is different. There is no lib-virt in control. The
> > > administrator's intension is to grant some type of application to access 
> > > the
> > > hardware. The application can get a handle of the hardware, send request 
> > > and ge

Re: [RFC PATCH 3/7] vfio: add spimdev support

2018-08-05 Thread Kenneth Lee
On Thu, Aug 02, 2018 at 12:43:27PM -0600, Alex Williamson wrote:
> Date: Thu, 2 Aug 2018 12:43:27 -0600
> From: Alex Williamson 
> To: Cornelia Huck 
> CC: Kenneth Lee , "Tian, Kevin"
>  , Kenneth Lee , Jonathan Corbet
>  , Herbert Xu , "David S .
>  Miller" , Joerg Roedel , Hao Fang
>  , Zhou Wang , Zaibo Xu
>  , Philippe Ombredanne , "Greg
>  Kroah-Hartman" , Thomas Gleixner
>  , "linux-...@vger.kernel.org"
>  , "linux-kernel@vger.kernel.org"
>  , "linux-cry...@vger.kernel.org"
>  , "io...@lists.linux-foundation.org"
>  , "k...@vger.kernel.org"
>  , "linux-accelerat...@lists.ozlabs.org\"
>  , Lu Baolu
>  ,  Kumar",   , " linux...@huawei.com "
>  ">
> Subject: Re: [RFC PATCH 3/7] vfio: add spimdev support
> Message-ID: <20180802124327.403b1...@t450s.home>
> 
> On Thu, 2 Aug 2018 10:35:28 +0200
> Cornelia Huck  wrote:
> 
> > On Thu, 2 Aug 2018 15:34:40 +0800
> > Kenneth Lee  wrote:
> > 
> > > On Thu, Aug 02, 2018 at 04:24:22AM +, Tian, Kevin wrote:  
> > 
> > > > > From: Kenneth Lee [mailto:liguo...@hisilicon.com]
> > > > > Sent: Thursday, August 2, 2018 11:47 AM
> > > > > 
> > > > > >
> > > > > > > From: Kenneth Lee
> > > > > > > Sent: Wednesday, August 1, 2018 6:22 PM
> > > > > > >
> > > > > > > From: Kenneth Lee 
> > > > > > >
> > > > > > > SPIMDEV is "Share Parent IOMMU Mdev". It is a vfio-mdev. But 
> > > > > > > differ
> > > > > from
> > > > > > > the general vfio-mdev:
> > > > > > >
> > > > > > > 1. It shares its parent's IOMMU.
> > > > > > > 2. There is no hardware resource attached to the mdev is created. 
> > > > > > > The
> > > > > > > hardware resource (A `queue') is allocated only when the mdev is
> > > > > > > opened.
> > > > > >
> > > > > > Alex has concern on doing so, as pointed out in:
> > > > > >
> > > > > > https://www.spinics.net/lists/kvm/msg172652.html
> > > > > >
> > > > > > resource allocation should be reserved at creation time.
> > > > > 
> > > > > Yes. That is why I keep telling that SPIMDEV is not for "VM", it is 
> > > > > for "many
> > > > > processes", it is just an access point to the process. Not a device 
> > > > > to VM. I
> > > > > hope
> > > > > Alex can accept it:)
> > > > > 
> > > > 
> > > > VFIO is just about assigning device resource to user space. It doesn't 
> > > > care
> > > > whether it's native processes or VM using the device so far. Along the 
> > > > direction
> > > > which you described, looks VFIO needs to support the configuration that
> > > > some mdevs are used for native process only, while others can be used
> > > > for both native and VM. I'm not sure whether there is a clean way to
> > > > enforce it...
> > > 
> > > I had the same idea at the beginning. But finally I found that the life 
> > > cycle
> > > of the virtual device for VM and process were different. Consider you 
> > > create
> > > some mdevs for VM use, you will give all those mdevs to lib-virt, which
> > > distribute those mdev to VMs or containers. If the VM or container exits, 
> > > the
> > > mdev is returned to the lib-virt and used for next allocation. It is the
> > > administrator who controlled every mdev's allocation.
> 
> Libvirt currently does no management of mdev devices, so I believe
> this example is fictitious.  The extent of libvirt's interaction with
> mdev is that XML may specify an mdev UUID as the source for a hostdev
> and set the permissions on the device files appropriately.  Whether
> mdevs are created in advance and re-used or created and destroyed
> around a VM instance (for example via qemu hooks scripts) is not a
> policy that libvirt imposes.
>  
> > > But for process, it is different. There is no lib-virt in control. The
> > > administrator's intension is to grant some type of application to access 
> > > the
> > > hardware. The application can get a handle of the hardware, send request 
> > > and ge