On Thu, Jan 14, 2021 at 09:45:37AM +0000, Chris Wilson wrote:
Quoting Daniel Vetter (2021-01-14 09:30:32)
On Thu, Jan 14, 2021 at 10:23 AM Chris Wilson chris@chris-wilson.co.uk wrote:
The only other problem I see with the implementation is that there's nothing that says that each dmabuf->ops->map_dma_buf() returns a new sg_table, so we may end up undoing the xor. Or should each dma-buf return a fresh dma-mapping for iommu isolation?
Maybe I screwed it up, but that's why I extracted the little helpers: We scramble when we get the sgtable from exporter, and unscramble before we pass it back. dma-buf.c does some caching and will hand back the same sgtable, but for that case we don't re-scramble.
The attachment is only mapped once, but there can be more than one attachment, and the backend could return the same sg_table for each mapping. Conceivably, it could return its own private sg_table where it wants to maintain the struct page. Seems like just adding a sentence to @map_dma_buf to clarify that each call should return a new sg_table will suffice.
Ah yes good point, will augment (once CI stops being angry at me). -Daniel