On Fri, Jan 07, 2022 at 09:14:38AM +0800, Lu Baolu wrote: > > Once we know our calling context we can always automatic switch from > > DMA API mode to another domain without any trouble or special > > counters: > > > > if (!dev->driver->no_kernel_api_dma) { > > if (group->owner_cnt > 1 || group->owner) > > return -EBUSY; > > return __iommu_attach_group(domain, group); > > } > > Is there any lock issue when referencing dev->driver here? I guess this > requires iommu_attach_device() only being called during the driver life > (a.k.a. between driver .probe and .release). Yes, that is correct. That would need to be documented. It is the same reason the routine was able to get the group from the dev. The dev's group must be stable so long as a driver is attached or everything is broken :) Much of the group refcounting code is useless for this reason. The group simply cannot be concurrently destroyed in these contexts. Jason