On Wed, 10 Mar 2021 07:56:39 +0000 Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote: > On Mon, Mar 08, 2021 at 02:48:30PM -0700, Alex Williamson wrote: > > Using a vfio device, a notifier block can be registered to receive > > select device events. Notifiers can only be registered for contained > > devices, ie. they are available through a user context. Registration > > of a notifier increments the reference to that container context > > therefore notifiers must minimally respond to the release event by > > asynchronously removing notifiers. > > Notifiers generally are a horrible multiplexed API. Can't we just > add a proper method table for the intended communication channel? I've been trying to figure out how, but I think not. A user can have multiple devices, each with entirely separate IOMMU contexts. For each device, the user can create an mmap of memory to that device and add it to every other IOMMU context. That enables peer to peer DMA between all the devices, across all the IOMMU contexts. But each individual device has no direct reference to any IOMMU context other than its own. A callback on the IOMMU can't reach those other contexts either, there's no guarantee those other contexts are necessarily managed via the same vfio IOMMU backend driver. A notifier is the best I can come up with, please suggest if you have other ideas. Thanks, Alex