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.
> 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.
> 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.
Joerg
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu