Hi, Le mardi 17 novembre 2026 à 16:20 -0400, Jason Gunthorpe a écrit : > On Tue, Nov 17, 2026 at 05:09:11PM -0300, Daniel Almeida wrote: > > Hi Jason, > > > > > On 16 Nov 2026, at 16:38, Jason Gunthorpe wrote: > > > > > > On Thu, Nov 12, 2026 at 02:00:07PM -0300, Daniel Almeida wrote: > > > > This series adds a Rust abstraction for IOMMU paging domains. A driver > > > > can allocate a domain, attach it to its device, map pages into it, and > > > > install a handler for its faults. > > > > > > > > This will be used by the upcoming rkvenc driver that my colleagues > > > > Detlev Casanova, Nicolas Dufresne and I are working on. More details on > > > > this driver can be found by watching Nicolas Dufresne's talk at LPC 2026 > > > > [0]. > > > > > > > > As part of the security model, each client will have its own IOMMU > > > > domain. This is needed as the submission model will let userspace set > > > > most of the encoder's registers directly, so the kernel cannot check > > > > every memory access that a job makes the encoder do. With a single > > > > domain, one client could make the encoder read or write the memory of > > > > another client. > > > > > > How do you plan to get the paging domain in the first place? > > > > We plan to alloc a paging domain when a video encoder session is created. Then > > we call iommu_attach_device() before a job runs, and detach back to the default > > domain after it finishes so the next job can attach its own session's domain. > > This is so each session is isolated from each other. > > If you do that you can't use the DMA API at all in your driver as you > have to set 'driver_managed = true'. Is it OK? If it is why not just > use VFIO? > > Or are you planning DT horrors to get yourself a DT created "DMA > struct" ? This seem to digress. All we want to do is use the iommu subsystem as intended for the case the iommu driver is not inside the DRM driver (which seems to have never been the case so far in DRM). The existing infra for that (in C) is pretty abstract an simple in my opinion, and built into the DMA API if you manage which domain to attach to your device at the right time. To me, it fits CODEC HW driver which are also simple. The DT horrors you refer to seems totally unfounded, you just describe the iommu and the iommu subsystem will manage it for your device. > > > The fault handler is used in the same way it is used in GPU drivers: to kill > > sessions if they fault. This way the driver can simply refuse further work from > > a misbehaving client, for example. It is also the natural place to enqueue a > > reset if the codec hardware is frozen as a result of the fault. > > IIRC no GPU driver does that, they hook the obsolete fault handler not > supported in new iommu drivers not the new PRI based one... IDK we > have even wired this up to work this way. > > It is nicer if the HW can tell you it faulted rather than expect the > iommu to do it. We most likely don't need that, and should drop it from this series. We have never used the fault handler in any linux-media codec in the past, the HW would always endup producing an IRQ with a error or a timeout. Using the fault handler would probably be a bit racy too. Pausing work from a faulty source though isn't a bad idea, but more of a nice future addition, assuming it can work in a non- racy way. Nicolas