From: Thomas Hellström <thellstrom@xxxxxxxxxx> Graphics APIs like OpenGL 4.4 and Vulkan require the graphics driver to provide coherent graphics memory, meaning that the GPU sees any content written to the coherent memory on the next GPU operation that touches that memory, and the CPU sees any content written by the GPU to that memory immediately after any fence object trailing the GPU operation has signaled. Paravirtual drivers that otherwise require explicit synchronization needs to do this by hooking up dirty tracking to pagefault handlers and buffer object validation. The mm patch page walk interface has been reworked to be similar to the reworked page-walk code (mm/pagewalk.c). There have been two other solutions to consider: 1) Using the page-walk code. That is currently not possible since it requires the mmap-sem to be held for the struct vm_area_struct vm_flags and for huge page splitting. The pagewalk code in this patchset can't hold the mmap sems since it will lead to locking inversion. We have an established locking order mmap_sem -> dma_reservation -> i_mmap_lock, whereas holding the mmap_sem in this case would require dma_reservation -> i_mmap_lock -> mmap_sem. Instead it uses an operation mode similar to unmap_mapping_range() where the i_mmap_lock is held. 2) Using apply_to_page_range(). The primary use of this code is to fill page tables. The operation modes are IMO sufficiently different to motivate re-implementing the page-walk. The code has been tested and exercised by a tailored version of mesa where we disable all explicit synchronization and assume graphics memory is coherent. The performance loss varies of course; a typical number is around 5%. I would like to merge this code through the DRM tree, so an ack to include the new mm helpers in that merge would be greatly appreciated. Changes since RFC: - Merge conflict changes moved to the correct patch. Fixes intra-patchset compile errors. - Be more aggressive when turning ttm vm code into helpers. This makes sure we can use a const qualifier on the vmwgfx vm_ops. - Reinstate a lost comment an fix an error path that was broken when turning the ttm vm code into helpers. - Remove explicit type-casts of struct vm_area_struct::vm_private_data - Clarify the locking inversion that makes us not being able to use the mm pagewalk code. Changes since v1: - Removed the vmwgfx maintainer entry for as_dirty_helpers.c, updated commit message accordingly - Removed the TTM patches from the series as they are merged separately through DRM. Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Huang Ying <ying.huang@xxxxxxxxx> Cc: Souptick Joarder <jrdr.linux@xxxxxxxxx> Cc: Jérôme Glisse <jglisse@xxxxxxxxxx> Cc: Christian König <christian.koenig@xxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel