Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-15 Thread Benjamin Herrenschmidt
On Fri, 2018-06-15 at 02:16 -0700, Christoph Hellwig wrote: > On Wed, Jun 13, 2018 at 11:11:01PM +1000, Benjamin Herrenschmidt wrote: > > Actually ... the stuff in lib/dma-direct.c seems to be just it, no ? > > > > There's no cache flushing and there's no architecture hooks that I can > > see

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-15 Thread Christoph Hellwig
On Wed, Jun 13, 2018 at 11:11:01PM +1000, Benjamin Herrenschmidt wrote: > Actually ... the stuff in lib/dma-direct.c seems to be just it, no ? > > There's no cache flushing and there's no architecture hooks that I can > see other than the AMD security stuff which is probably fine. > > Or am I

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Michael S. Tsirkin
On Mon, Jun 11, 2018 at 01:34:50PM +1000, Benjamin Herrenschmidt wrote: > On Mon, 2018-06-11 at 06:28 +0300, Michael S. Tsirkin wrote: > > > > > However if the administrator > > > ignores/forgets/deliberatey-decides/is-constrained to NOT enable the > > > flag, virtio will not be able to pass

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Michael S. Tsirkin
On Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > On Sun, 2018-06-10 at 19:39 -0700, Ram Pai wrote: > > > > However if the administrator > > ignores/forgets/deliberatey-decides/is-constrained to NOT enable the > > flag, virtio will not be able to pass control to the DMA

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Michael S. Tsirkin
On Wed, Jun 13, 2018 at 12:41:41AM -0700, Christoph Hellwig wrote: > On Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > > At the risk of repeating myself, let's just do the first pass which is > > to switch virtio over to always using the DMA API in the actual data > > flow

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Michael S. Tsirkin
On Thu, Jun 07, 2018 at 11:36:55PM -0700, Christoph Hellwig wrote: > > This seems to be what was being asked for in this thread, > > with comments claiming IOMMU flag adds too much overhead. > > Right now it means implementing a virtual iommu, which I agree is > way too much overhead. Well not

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Benjamin Herrenschmidt
On Wed, 2018-06-13 at 22:25 +1000, Benjamin Herrenschmidt wrote: > On Wed, 2018-06-13 at 00:41 -0700, Christoph Hellwig wrote: > > On Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > > > At the risk of repeating myself, let's just do the first pass which is > > > to switch

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Benjamin Herrenschmidt
On Wed, 2018-06-13 at 00:41 -0700, Christoph Hellwig wrote: > On Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > > At the risk of repeating myself, let's just do the first pass which is > > to switch virtio over to always using the DMA API in the actual data > > flow code,

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-13 Thread Christoph Hellwig
On Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > At the risk of repeating myself, let's just do the first pass which is > to switch virtio over to always using the DMA API in the actual data > flow code, with a hook at initialization time that replaces the DMA ops > with

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-10 Thread Benjamin Herrenschmidt
On Mon, 2018-06-11 at 06:28 +0300, Michael S. Tsirkin wrote: > > > However if the administrator > > ignores/forgets/deliberatey-decides/is-constrained to NOT enable the > > flag, virtio will not be able to pass control to the DMA ops associated > > with the virtio devices. Which means, we have no

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-10 Thread Benjamin Herrenschmidt
On Sun, 2018-06-10 at 19:39 -0700, Ram Pai wrote: > > However if the administrator > ignores/forgets/deliberatey-decides/is-constrained to NOT enable the > flag, virtio will not be able to pass control to the DMA ops associated > with the virtio devices. Which means, we have no opportunity to

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-10 Thread Michael S. Tsirkin
On Sun, Jun 10, 2018 at 07:39:09PM -0700, Ram Pai wrote: > On Thu, Jun 07, 2018 at 07:28:35PM +0300, Michael S. Tsirkin wrote: > > On Wed, Jun 06, 2018 at 10:23:06PM -0700, Christoph Hellwig wrote: > > > On Thu, May 31, 2018 at 08:43:58PM +0300, Michael S. Tsirkin wrote: > > > > Pls work on a long

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-10 Thread Ram Pai
On Thu, Jun 07, 2018 at 07:28:35PM +0300, Michael S. Tsirkin wrote: > On Wed, Jun 06, 2018 at 10:23:06PM -0700, Christoph Hellwig wrote: > > On Thu, May 31, 2018 at 08:43:58PM +0300, Michael S. Tsirkin wrote: > > > Pls work on a long term solution. Short term needs can be served by > > > enabling

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-08 Thread Christoph Hellwig
On Thu, Jun 07, 2018 at 07:28:35PM +0300, Michael S. Tsirkin wrote: > Let me restate it: DMA API has support for a wide range of hardware, and > hardware based virtio implementations likely won't benefit from all of > it. That is completely wrong. All aspects of the DMA API are about the system

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-07 Thread Michael S. Tsirkin
On Wed, Jun 06, 2018 at 10:23:06PM -0700, Christoph Hellwig wrote: > On Thu, May 31, 2018 at 08:43:58PM +0300, Michael S. Tsirkin wrote: > > Pls work on a long term solution. Short term needs can be served by > > enabling the iommu platform in qemu. > > So, I spent some time looking at converting

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-06 Thread Christoph Hellwig
On Thu, May 31, 2018 at 08:43:58PM +0300, Michael S. Tsirkin wrote: > Pls work on a long term solution. Short term needs can be served by > enabling the iommu platform in qemu. So, I spent some time looking at converting virtio to dma ops overrides, and the current virtio spec, and the sad

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Christoph Hellwig
On Tue, Jun 05, 2018 at 09:26:56AM +1000, Benjamin Herrenschmidt wrote: > Sorry Michael, that doesn't click. Yes of course virtio is implemented > in qemu, but the problem we are trying to solve is *not* a qemu problem > (the fact that the Linux drivers bypass the DMA API is wrong, needs > fixing,

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread David Gibson
On Mon, Jun 04, 2018 at 07:48:54PM +1000, Benjamin Herrenschmidt wrote: > On Mon, 2018-06-04 at 18:57 +1000, David Gibson wrote: > > > > > - First qemu doesn't know that the guest will switch to "secure mode" > > > in advance. There is no difference between a normal and a secure > > > partition

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Michael S. Tsirkin
On Tue, Jun 05, 2018 at 09:26:56AM +1000, Benjamin Herrenschmidt wrote: > I would like to keep however the ability to bypass the iommu for > performance reasons So that's easy, clear the IOMMU flag and this means "bypass the IOMMU". -- MST

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Benjamin Herrenschmidt
On Mon, 2018-06-04 at 19:21 +0300, Michael S. Tsirkin wrote: > > > > > - First qemu doesn't know that the guest will switch to "secure mode" > > > > in advance. There is no difference between a normal and a secure > > > > partition until the partition does the magic UV call to "enter secure > > >

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Michael S. Tsirkin
On Mon, Jun 04, 2018 at 11:14:36PM +1000, Benjamin Herrenschmidt wrote: > On Mon, 2018-06-04 at 05:55 -0700, Christoph Hellwig wrote: > > On Mon, Jun 04, 2018 at 03:43:09PM +0300, Michael S. Tsirkin wrote: > > > Another is that given the basic functionality is in there, optimizations > > > can

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Michael S. Tsirkin
On Mon, Jun 04, 2018 at 11:11:52PM +1000, Benjamin Herrenschmidt wrote: > On Mon, 2018-06-04 at 15:43 +0300, Michael S. Tsirkin wrote: > > On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > > > On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > > > > > > > I

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Benjamin Herrenschmidt
On Mon, 2018-06-04 at 05:55 -0700, Christoph Hellwig wrote: > On Mon, Jun 04, 2018 at 03:43:09PM +0300, Michael S. Tsirkin wrote: > > Another is that given the basic functionality is in there, optimizations > > can possibly wait until per-device quirks in DMA API are supported. > > We have had

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Christoph Hellwig
On Mon, Jun 04, 2018 at 03:43:09PM +0300, Michael S. Tsirkin wrote: > Another is that given the basic functionality is in there, optimizations > can possibly wait until per-device quirks in DMA API are supported. We have had per-device dma_ops for quite a while.

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Benjamin Herrenschmidt
On Mon, 2018-06-04 at 15:43 +0300, Michael S. Tsirkin wrote: > On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > > On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > > > > > I re-read that discussion and I'm still unclear on the > > > original question, since I

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Michael S. Tsirkin
On Mon, Jun 04, 2018 at 07:48:54PM +1000, Benjamin Herrenschmidt wrote: > On Mon, 2018-06-04 at 18:57 +1000, David Gibson wrote: > > > > > - First qemu doesn't know that the guest will switch to "secure mode" > > > in advance. There is no difference between a normal and a secure > > > partition

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Michael S. Tsirkin
On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > > > I re-read that discussion and I'm still unclear on the > > original question, since I got several apparently > > conflicting answers. > > > > I asked: > >

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread Benjamin Herrenschmidt
On Mon, 2018-06-04 at 18:57 +1000, David Gibson wrote: > > > - First qemu doesn't know that the guest will switch to "secure mode" > > in advance. There is no difference between a normal and a secure > > partition until the partition does the magic UV call to "enter secure > > mode" and qemu

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-06-04 Thread David Gibson
On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > > > I re-read that discussion and I'm still unclear on the > > original question, since I got several apparently > > conflicting answers. > > > > I asked: > >

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-31 Thread Michael S. Tsirkin
On Thu, May 31, 2018 at 09:09:24AM +0530, Anshuman Khandual wrote: > On 05/24/2018 12:51 PM, Ram Pai wrote: > > On Wed, May 23, 2018 at 09:50:02PM +0300, Michael S. Tsirkin wrote: > >> subj: s/virito/virtio/ > >> > > ..snip.. > >>> machine_subsys_initcall_sync(pseries,

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-30 Thread Anshuman Khandual
On 05/24/2018 12:51 PM, Ram Pai wrote: > On Wed, May 23, 2018 at 09:50:02PM +0300, Michael S. Tsirkin wrote: >> subj: s/virito/virtio/ >> > ..snip.. >>> machine_subsys_initcall_sync(pseries, tce_iommu_bus_notifier_init); >>> + >>> +bool platform_forces_virtio_dma(struct virtio_device *vdev) >>>

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-29 Thread Benjamin Herrenschmidt
On Tue, 2018-05-29 at 07:03 -0700, Christoph Hellwig wrote: > On Tue, May 29, 2018 at 09:56:24AM +1000, Benjamin Herrenschmidt wrote: > > I don't think forcing the addition of an emulated iommu in the middle > > just to work around the fact that virtio "cheats" and doesn't use the > > dma API

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-29 Thread Christoph Hellwig
On Tue, May 29, 2018 at 09:56:24AM +1000, Benjamin Herrenschmidt wrote: > I don't think forcing the addition of an emulated iommu in the middle > just to work around the fact that virtio "cheats" and doesn't use the > dma API unless there is one, is the right "fix". Agreed. > The right long term

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-28 Thread Benjamin Herrenschmidt
On Tue, 2018-05-29 at 09:48 +1000, Benjamin Herrenschmidt wrote: > > Well it's not supposed to be much slower for the static case. > > > > vhost has a cache so should be fine. > > > > A while ago Paolo implemented a translation cache which should be > > perfect for this case - most of the code

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-28 Thread Benjamin Herrenschmidt
On Fri, 2018-05-25 at 20:45 +0300, Michael S. Tsirkin wrote: > On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > > On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > > > > > I re-read that discussion and I'm still unclear on the > > > original question, since I

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-25 Thread Michael S. Tsirkin
On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > > > I re-read that discussion and I'm still unclear on the > > original question, since I got several apparently > > conflicting answers. > > > > I asked: > >

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-24 Thread Christoph Hellwig
On Thu, May 24, 2018 at 08:27:04AM +1000, Benjamin Herrenschmidt wrote: > - First qemu doesn't know that the guest will switch to "secure mode" > in advance. There is no difference between a normal and a secure > partition until the partition does the magic UV call to "enter secure > mode" and

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-24 Thread Ram Pai
On Wed, May 23, 2018 at 09:50:02PM +0300, Michael S. Tsirkin wrote: > subj: s/virito/virtio/ > ..snip.. > > machine_subsys_initcall_sync(pseries, tce_iommu_bus_notifier_init); > > + > > +bool platform_forces_virtio_dma(struct virtio_device *vdev) > > +{ > > + /* > > +* On protected guest

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-23 Thread Benjamin Herrenschmidt
On Wed, 2018-05-23 at 21:50 +0300, Michael S. Tsirkin wrote: > I re-read that discussion and I'm still unclear on the > original question, since I got several apparently > conflicting answers. > > I asked: > > Why isn't setting VIRTIO_F_IOMMU_PLATFORM on the > hypervisor side

Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-23 Thread Michael S. Tsirkin
subj: s/virito/virtio/ On Tue, May 22, 2018 at 12:03:17PM +0530, Anshuman Khandual wrote: > This adds a hook which a platform can define in order to allow it to > force the use of the DMA API for all virtio devices even if they don't > have the VIRTIO_F_IOMMU_PLATFORM flag set. We want to use

[RFC V2] virtio: Add platform specific DMA API translation for virito devices

2018-05-22 Thread Anshuman Khandual
This adds a hook which a platform can define in order to allow it to force the use of the DMA API for all virtio devices even if they don't have the VIRTIO_F_IOMMU_PLATFORM flag set. We want to use this to do bounce-buffering of data on the new secure pSeries platform, currently under