Hello,
On 2016-02-16 16:59, Joerg Roedel wrote:
On Tue, Feb 16, 2016 at 03:40:31PM +0100, Marek Szyprowski wrote:
This patch ensures that devices attached to the default_domain will be first detached from it before attaching to new domain. To avoid forward declaration, __iommu_attach_group() function has been moved to new place in the source code.
Actually it was intentional to not invoke the detach_device call-back in the attach_device path.
The reason is that detaching first and than attaching again leaves the device without a domain for a short period of time, until it is attached to the new domain.
The attach_device call-back is supposed to handle this situation and just silently overwrite any other domain->device binding it finds for the device.
This allows to do re-attachment with less iommu flushes and to get rid of the detach_device call-back at some point.
Huh, I wasn't aware of this change in the iommu drivers api. For some drivers attach/detach callbacks does something more than just programming page table base register, like for example in case of exynos iommu it is enabling runtime power management and clocks. The code is really much simpler if those calls are balanced, but if the goal is to allow multiple unballanced attach calls, I will try to fix this in our driver.
Maybe it should be documented somewhere, that attach calls can be unbalanced?
Best regards