Repository navigation
iommu/apple-dart: report IOMMU_CAP_CACHE_COHERENCY for coherent devices - #3117
Conversation
Inherited from upstream/Asahi apple-dart.c, apple_dart_capable() only handles IOMMU_CAP_DEFERRED_FLUSH and never reports IOMMU_CAP_CACHE_COHERENCY. Because vfio_register_group_dev() and iommufd_bind_iommu() require IOMMU_CAP_CACHE_COHERENCY before allowing userspace to map DMA pages with IOMMU_CACHE, every device behind an Apple DART is rejected with -EINVAL when binding to vfio-pci or iommufd. Report IOMMU_CAP_CACHE_COHERENCY when dev_is_dma_coherent(dev) holds and every DART in the device's stream map can safely support exclusive paging and blocked-domain ownership: - APPLE_DART (T8020/T8103) operates on a coherent interconnect for DMA-coherent masters, and APPLE_DART2 (T6000/T8110/Gen3) clears APPLE_DART2_PTE_PROT_NO_CACHE in io-pgtable-dart.c whenever IOMMU_CACHE is set. - Non-coherent devices (dev_is_dma_coherent(dev) == false, including nodes marked dma-noncoherent in DT) and devices with no valid stream map continue to return false. - Every DART in cfg->stream_maps is checked; DARTs that cannot support independent paging/blocking (pgsize > PAGE_SIZE, locked, managed_sids, retained, retained_mtp, live_mtp, cold_ane, isp_host, preserve_display, v27_provider, or borrowed DCP/display streams) return false. - IOMMU_CAP_ENFORCE_CACHE_COHERENCY and .enforce_cache_coherency are intentionally not advertised: Apple DART does not enforce PCIe No-Snoop overrides in hardware, and neither vfio-pci, iommufd, nor arm64 KVM require it. Add KUnit coverage in apple_dart_test_cache_coherency() exercising coherent, non-coherent, multi-DART, and ineligible DART configurations. Signed-off-by: Dj <[email protected]>
|
M1 Air row at 07c48e9. Boot and read-only checks only.
What I checked:
Not done: the vfio-pci bind and the guest passthrough. Wi-Fi is the Air's only network, so I didn't unbind it on an unattended boot. That still needs a run at the Mac. The second-generation row is still open too. This PR now conflicts with main in |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: REQUEST CHANGES at 07c48e98
Blockers:
- Branch is
CONFLICTINGwithmain. Rebase/merge currentmainsoapple-dartapplies cleanly (MERGEABLE) and full CI executes at the rebased head. - Incomplete hardware verification. Only a read-only boot row on M1 Air (
J313) has been posted; a second GPU/SoC generation row plus VFIO/iommufdcoherency check at the rebased head remains open.
Checked:
- Metadata and diff summary (
+129/-0, 2 files),CONFLICTINGagainstmain.
Evidence
- PR body notes pending 2-generation hardware rows;
J313row (2026-11-30) covered boot/read-only checks only, and the branch now conflicts withmain.
Resolve apple-dart-test.c: keep the cache-coherency case from this branch beside the cases main added. Signed-off-by: DjDeveloperr <[email protected]>
There was a problem hiding this comment.
Verdict: HOLD at 8d90bf8c0537
Blockers:
- Hosted CI at
8d90bf8c0537is still queued (21jobs queued:apple-build,host-tests,pr-text,readiness, and KUnit suites includingapple_dart_test_cache_coherency) — wait for all checks to complete green. - Hardware check on the changed
IOMMU_CAP_CACHE_COHERENCYpath (e.g., VFIO/iommufdcoherency probe or a second SoC generation boot alongside the read-onlyJ313M1 Air boot row at07c48e98).
Checked:
- Audited the full 2-file diff (
drivers/iommu/apple-dart.canddrivers/iommu/apple-dart-test.c,+129/-0,MERGEABLEagainstmain):apple_dart_supports_cache_coherency()conservatively gatesIOMMU_CAP_CACHE_COHERENCYondev_is_dma_coherent(dev)and verifies every backing DART incfg->stream_mapshaspgsize <= PAGE_SIZEand is unlocked, unmanaged, non-retained, non-MTP, non-cold-ANE, non-ISP-host, non-display, non-v27-provider, and non-borrowed.- Merge commit
8d90bf8c0537cleanly retainsapple_dart_test_cache_coherencyalongside the KUnit cases added onmain.
Evidence
- Head:
8d90bf8c05372d16e8bfde097abde730a43b024c(basemain,MERGEABLE). - Status checks at review time: 21 queued, 3 skipped, 0 failed.
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed the conflict-pass merge commit 8d90bf8 only: single-file union, no hand edits. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.
There was a problem hiding this comment.
Verdict: MERGE at 8d90bf8c0537
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Audited the full 2-file diff (drivers/iommu/apple-dart.c and drivers/iommu/apple-dart-test.c, +129/-0, MERGEABLE against main):
apple_dart_supports_cache_coherency()conservatively gatesIOMMU_CAP_CACHE_COHERENCYondev_is_dma_coherent(dev)and verifies every backing DART incfg->stream_mapshaspgsize <= PAGE_SIZEand is unlocked, unmanaged, non-retained, non-MTP, non-cold-ANE, non-ISP-host, non-display, non-v27-provider, and non-borrowed.- Merge commit
8d90bf8c0537cleanly retainsapple_dart_test_cache_coherencyalongside the KUnit cases added onmain.
Follow-ups (not blocking): queued CI; coherency-path hardware check
|
J616s (MacBook Pro 14", M4 Pro, T6040) at |
|
Merging at |
What: Report
IOMMU_CAP_CACHE_COHERENCYinapple_dart_capable()for DMA-coherent devices behind ordinary unlocked Apple DARTs, unblockingvfio-pciandiommufddevice passthrough.Tested: Pending 2-generation hardware rows at
07c48e984d47(arm64 KUnit 37/37 pass includingapple_dart_test_cache_coherency,CONFIG_APPLE_DART_J713_DCP=y/nCONFIG_WERROR=ycompile pass, targetedapple-darthost tests pass,checkpatch --strict0/0/0).Risk: two-way door · all Macs (shared
apple-dartIOMMU driver; only affectsIOMMU_CAP_CACHE_COHERENCYqueries from VFIO/iommufd/vDPA, leaving DMA API paths unchanged).Not yet
2-generation hardware rows at
07c48e984d47(boot + regression check on two Apple Silicon generations plusvfio-pci/iommufdbind and passthrough verification).Details
drivers/iommu/apple-dart.conly handledIOMMU_CAP_DEFERRED_FLUSHinapple_dart_capable(). Bothvfio_register_group_dev()andiommufd_bind_iommu()requiredevice_iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY)and otherwise fail with-EINVAL.APPLE_DART(T8020/T8103) operates on a coherent fabric for DMA-coherent masters, andAPPLE_DART2(drivers/iommu/io-pgtable-dart.c) clearsAPPLE_DART2_PTE_PROT_NO_CACHEwheneverIOMMU_CACHEis present inprot.apple_dart_capable()now checksdev_is_dma_coherent(dev)and walks every DART incfg->stream_maps(for_each_stream_map), rejecting devices with missing/empty configs or any DART that cannot safely support exclusive paging and blocked-domain ownership (pgsize > PAGE_SIZE,locked,managed_sids,retained,retained_mtp,live_mtp,cold_ane,isp_host,preserve_display,v27_provider, or borrowed DCP/display streams).dev_is_dma_coherent(dev)and DART hardware/DT/driver state, covering unlocked PCIe and USB4 PCIe-C DARTs across M1-M5/Neo while excluding non-coherent (dma-noncoherent), managed-SID, retained, borrowed, and locked DARTs.IOMMU_CAP_ENFORCE_CACHE_COHERENCY/.enforce_cache_coherencyis intentionally not claimed because Apple DART does not enforce PCIe No-Snoop overrides in hardware, and neithervfio-pci,iommufd, nor arm64 KVM require it.Evidence
origin/main(2943fffab7db7)07c48e984d47b0a0dffb9b96b217d89ac288b4e1./scripts/checkpatch.pl --strict --git HEAD: 0 errors, 0 warnings, 0 checksCONFIG_APPLE_DART=y,CONFIG_APPLE_DART_J713_DCP=y,CONFIG_APPLE_DART_KUNIT_TEST=y,CONFIG_ARM64_16K_PAGES=y,CONFIG_WERROR=y): 37/37 passed (apple-dart36 subtests includingapple_dart_test_cache_coherency,apple-dart-firmware-leaf1 subtest)CONFIG_APPLE_DART_J713_DCP=n,CONFIG_WERROR=y):drivers/iommu/apple-dart.ocompiled cleanlyapple-dart-dapf-tests.py,apple-dart-fw-tests.py,apple-dart-fw-harness-tests.py,apple-dart-range-tests.py,dart-sleep-snapshot-tests.py,dart-sleep-writer-tests.pyall passed