> From: Baolu Lu <baolu.lu@xxxxxxxxxxxxxxx> > Sent: Monday, December 4, 2023 9:33 AM > > On 12/3/23 10:14 PM, Jason Gunthorpe wrote: > > On Sun, Dec 03, 2023 at 04:53:08PM +0800, Baolu Lu wrote: > >> Even if atomic replacement were to be implemented, > >> it would be necessary to ensure that all translation requests, > >> translated requests, page requests and responses for the old domain are > >> drained before switching to the new domain. > > > > Again, no it isn't required. > > > > Requests simply have to continue to be acked, it doesn't matter if > > they are acked against the wrong domain because the device will simply > > re-issue them.. > > Ah! I start to get your point now. > > Even a page fault response is postponed to a new address space, which > possibly be another address space or hardware blocking state, the > hardware just retries. if blocking then the device shouldn't retry. btw if a stale request targets an virtual address which is outside of the valid VMA's of the new address space then visible side-effect will be incurred in handle_mm_fault() on the new space. Is it desired? Or if a pending response carries an error code (Invalid Request) from the old address space is received by the device when the new address space is already activated, the hardware will report an error even though there might be a valid mapping in the new space. > > As long as we flushes all caches (IOTLB and device TLB) during > switching, the mappings of the old domain won't leak. So it's safe to > keep page requests there. > I don't think atomic replace is the main usage for this draining requirement. Instead I'm more interested in the basic popular usage: attach-detach-attach and not convinced that no draining is required between iommu/device to avoid interference between activities from old/new address space.