Files
reims-vgpu/docs
Anees Iqbal 80a97ebef9 🐛 Sync a surface copy again once a CPU write lock is let go
A copy of an IOSurface synced at a commit while another process's CPU held
the surface locked for writing copied the pages half written, and kept them:
IOSurface moves the surface's seed at a read-write lock, not at its unlock,
so the seed the copy recorded was already the one the finished write leaves,
and nothing synced the copy again until the next lock.

IOSurface keeps a second seed, the unlock seed, which unlockSurface moves at
each read-write unlock (and a GPU write moves with the lock seed), so the two
differ while a CPU holds the surface locked for writing; IOSurface itself
reads them so, and the Mac's GPU families (IOAcceleratorFamily2, IOGPUFamily)
import its getter. The device cache's op 3 is no unlock: IOSurface calls it
inside the lock, after op 2, and calls nothing at the unlock (read from
IOSurface's code in macOS 26.7.1's KDK).

The kext answers a surface's two seeds (SurfaceSeeds, selector 13, kext
feature 1 << 10, set only where IOSurface exports getUnlockSeed, which the
kext references weakly). A copy synced while the two differ records the
unlock seed in its header with a mark, and each commit that uses it asks
the kext again until the unlock seed moves, then syncs once more. A copy
synced with no write lock held asks nothing, so a commit costs what it did.
A named GPU write records its seed and clears the mark, as its seed already
stood over a CPU's write held meanwhile. The surface copies report counts
the uploads made mid-write and the asks.
2026-11-13 11:10:25 -08:00
..