On Wed, Feb 05, 2020 at 03:50:14PM +0800, Jason Wang wrote:> > Would it be better for the map/umnap logic to happen inside each device ? > > Devices that needs the IOMMU will call iommu APIs from inside the driver callback. > > Technically, this can work. But if it can be done by vhost-vpda it will make > the vDPA driver more compact and easier to be implemented.Generally speaking, in the kernel, it is normal to not hoist code of out drivers into subsystems until 2-3 drivers are duplicating that code. It helps ensure the right design is used Jason
On Wed, Feb 05, 2020 at 08:56:48AM -0400, Jason Gunthorpe wrote:> On Wed, Feb 05, 2020 at 03:50:14PM +0800, Jason Wang wrote: > > > Would it be better for the map/umnap logic to happen inside each device ? > > > Devices that needs the IOMMU will call iommu APIs from inside the driver callback. > > > > Technically, this can work. But if it can be done by vhost-vpda it will make > > the vDPA driver more compact and easier to be implemented. > > Generally speaking, in the kernel, it is normal to not hoist code of > out drivers into subsystems until 2-3 drivers are duplicating that > code. It helps ensure the right design is used > > JasonThat's up to the sybsystem maintainer really, as there's also some intuition involved in guessing a specific API is widely useful. In-kernel APIs are flexible, if we find something isn't needed we just drop it. -- MST
On 2020/2/5 ??9:14, Michael S. Tsirkin wrote:> On Wed, Feb 05, 2020 at 08:56:48AM -0400, Jason Gunthorpe wrote: >> On Wed, Feb 05, 2020 at 03:50:14PM +0800, Jason Wang wrote: >>>> Would it be better for the map/umnap logic to happen inside each device ? >>>> Devices that needs the IOMMU will call iommu APIs from inside the driver callback. >>> Technically, this can work. But if it can be done by vhost-vpda it will make >>> the vDPA driver more compact and easier to be implemented. >> Generally speaking, in the kernel, it is normal to not hoist code of >> out drivers into subsystems until 2-3 drivers are duplicating that >> code. It helps ensure the right design is used >> >> Jason > That's up to the sybsystem maintainer really, as there's also some > intuition involved in guessing a specific API is widely useful. > In-kernel APIs are flexible, if we find something isn't needed we just > drop it. >If I understand correctly. At least Intel (Ling Shan) and Brodcom (Rob) doesn't want to deal with DMA stuffs in their driver. Anyway since the DMA bus operations is optional, driver may still choose to do DMA by itself if they want even if it requires platform IOMMU to work. Thanks