What: the dma-buf rule reads the first type a dma-buf's fd query offers as the driver's word for
where such an import lives. Where that type is host-visible and host-coherent and the buffer's
requirements list it, the import takes it, as before. Where it is device-local, the import takes
the first type offered that the requirements list and that is device-local, host-visible and
host-coherent, in that first type's own heap. Anything else is Limit::ImportType. It is still one
choice from the query and one import, never a type after another (on NVIDIA's 620.70.06 one failed
import into a later type broke that type's later allocations). DmaBufTypes holds each type's
coherent and device-local bits and its heap, read once at the device's making. import_dma_bufs
takes its fds' types by the same rule. Docs: the module doc, import_dma_buf, Limit::ImportType,
and the runtime README (the import contract, the NVIDIA paragraph, the Iris Xe known gap with the
Xe2 claim as read, the pointer-import and texture-over-dma-buf paragraphs, and the AMDVLK row,
which now says nothing of a dma-buf pick: its recorded row gives no flags or heap of type 0).
Why: the planner's ruling (rule A). The Iris Xe's query offers its device-local type 0 first, so
every dma-buf was refused there, and its pages took the host-memory import and the counted copy.
Rows, each from the device test every_device_takes_its_dma_buf_type_by_the_rule at f3f332b209
(before, the rule's pick):
- Iris Xe RPL-P (ANV, Mesa 26.2.6, i915), m3-max-78652: offered 0x7f, listed 0x7, types
[0:DL 1:DL|HV|HC 2:DL|HV|HC|HCACHED 3:DL 4:DL 5:DL|HV|HC 6:DL|HV|HC|HCACHED], one heap:
refused, 1.
- RX 7900 XTX (RADV), m3-max-78660: offered 0x420, listed 0x7ad: 5, 5.
- Radeon 780M Phoenix (RADV), m3-max-78662: offered 0x10820, listed 0x1eaad: 5, 5; the same
table as Hawk Point's, m3-max-78548: 5, 5. RX 550 (RADV), m3-max-78563: 5, 5.
- RTX 3090, m3-max-78667, and RTX 2080, m3-max-78547 (620.70.06): offered 0x11, listed 0x3b,
type 0 with no flag, both offered types of heap 1: refused, refused.
- lavapipe, m3-max-78608: offered 0x1, listed 0x1: 0, 0.
Coherence both ways, every_device_imports_a_dma_buf_by_the_rule_and_each_side_reads_the_other_s_write:
65,536 bytes the guest's side wrote through a shared mapping of the memfd after the import, read
by a GPU copy, then a GPU fill read through that mapping, with no flush or invalidate call: 0
stale each way on the Iris Xe in type 1 under i915 (m3-max-78652), the XTX (m3-max-78660), the
Phoenix 780M (m3-max-78662), the RX 550 (m3-max-78563) and lavapipe (m3-max-78608).
Tests: the unit test a_dma_buf_takes_the_first_offered_type_or_a_coherent_type_of_its_device_memory
over the three table shapes (RADV's from m3-max-78548, the Iris Xe's from m3-max-78652, the RTX
2080's from m3-max-78547) and its refusals: a coherent first type not listed, nothing coherent
offered or listed, a coherent device-local type of another heap, no type offered.
Verified: the dma-buf modules (import, import_time, import_overs, dma_bufs, the Managed buffer
over a dma-buf) on the Iris Xe at this code, m3-max-78694: 24 passed, 860 skipped; a texture over
a dma-buf in place there with 0 copies and 1 acquire. At this tree (74c6614ae9): clippy -D warnings
plain, under m2v_cpu_icd and under m2v_gpu, and rustdoc -D warnings, all exit 0 (job m3-max-78815);
the runtime suite on lavapipe 884 passed, 3 skipped (job m3-max-78816).