Hi Joerg, On Wednesday 09 April 2014 17:08:31 Joerg Roedel wrote: > On Tue, Apr 08, 2014 at 05:02:37PM +0200, Laurent Pinchart wrote: > > On Tuesday 08 April 2014 15:43:22 Joerg Roedel wrote: > > > Who is "someone" in this case? > > > > That's exactly the problem :-) The ARM DMA API implementation doesn't care > > who that "someone" is. Existing implementations call those functions > > either from the bus masters device drivers (in which case the drivers > > need to be IOMMU- aware, even if they use the DMA API and don't need to > > handle the IOMMU directly) or from the IOMMU drivers (in which case the > > bus masters device drivers don't have to care about the IOMMU, but > > without a way for drivers to handle the IOMMU directly when they need > > to). Possible other candidates are core IOMMU code or bus code. > > That doesn't sound very transparent for the device drivers. All what you > describe above (attaching a device to its default domain for DMA-API) > should happen in the IOMMU driver. For the device driver it should make > no difference if there is an IOMMU or not. Creating the DMA API mapping and attaching the device to the domain are definitely not transparent when performed by bus master device drivers. That's just the current situation for several drivers, and we obviously want to change it. > > If we call arm_iommu_attach_device() from the IOMMU driver to get default > > transparent IOMMU handling, the function will then attach the device to > > the default domain with a call to iommu_attach_device(). > > If you have to call a function it is not transparent anymore. Sure it is, IOMMU handling is transparent for the bus master device (which is the goal) when arm_iommu_attach_device() is called from the IOMMU driver. > > If a driver needs to handle the IOMMU directly, should it start by > > detaching the device from the ARM IOMMU domain ? We would need to be > > very careful with the assumptions made by the different layers, as > > they might not support a driver attaching a new domain to a device > > that already has a domain attached. I'd feel more comfortable with > > avoiding to attach the default domain to the device in the first > > place, but that might not be easily doable. > > The way this is solved by others is that iommu_attach_device() automatically > detaches the device from its default (DMA-API) domain and attach it to the > device drivers own domain. On iommu_detach_device() the device is attached > back to the default domain. That might work, I'll need to give it a try. It will make the attach/detach operations pretty complex though, with copies of the same code in all IOMMU drivers. Refactoring will probably be needed, but I'll first see if I can get it working properly without modifying the IOMMU core. -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html