Skip to content

iommu/apple-dart: keep page tables after a failed invalidate at root retire - #546

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
fix/dart-retire-invalidate-error
Oct 28, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
fix/dart-retire-invalidate-error

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Mirror of the review fix on omacom/linux-aurora#235 (commit 07d64c6 there), so both trees keep the same DART handoff code.

On DARTs with a firmware root mirror or handoff, retiring a locked root runs a range invalidate of the slots Linux published. apple_dart_hw_unmap_locked_ttbr() dropped its result and cleared the root. The invalidate that apple_dart_domain_free() checks afterwards then found no root, issued no command and returned 0, so the domain's page tables were freed even after a TLB timeout.

  • apple_dart_hw_unmap_locked_ttbr() returns the first retire-time invalidate error, and the DART remembers it per stream (locked_retire_err).
  • apple_dart_domain_free() keeps the page tables when its own retire or invalidate fails, and also when a consumer release or an attach rollback retired the root first and its invalidate failed.
  • The remembered error is never cleared, since only the hardware could show the TLB no longer holds those entries. Later domains on that stream keep their page tables too.

Testing:

  • Host fixture tools/asahi/apple-dart-fw-tests.py: 73/73. The new retire-* cases force the TLB command to time out for a direct free, a release before the free and a rollback before the free; each keeps the page tables, and the timeout cases fail on the old code. In this tree the fixture also stubs apple_dart_has_borrowed() and the DCP domain fields.
  • DART KUnit (minimal arm64 config with APPLE_DART_KUNIT_TEST): 25/25.

The cherry-pick applied without conflicts. The commit message notes that ff5c39a's message lists resume, which never reaches the stream invalidate for a locked DART.

…retire

On DARTs with a firmware root mirror or handoff, retiring a locked root
runs a range invalidate of the slots Linux published.
apple_dart_hw_unmap_locked_ttbr() dropped its result, returned 0 and
cleared the root. The invalidate that apple_dart_domain_free() checks
afterwards then found no root, issued no command and returned 0, so the
domain's page tables were freed even after a TLB timeout, while the
hardware could still cache translations through them. Before the
handoff DARTs took that path, a whole-stream flush there returned the
error and the page tables were kept.

Return the first retire-time invalidate error, and remember it per
stream on the DART. apple_dart_domain_free() keeps the page tables when
its own retire or invalidate fails, and also when a consumer release
or an attach rollback retired the root first and its invalidate failed.
The remembered error is never cleared, because only the hardware could
show that the TLB no longer holds those entries; later domains on that
stream keep their page tables too.

The host fixture now builds apple_dart_hw_unmap_locked_ttbr(),
apple_dart_release_device() and apple_dart_domain_free(), and forces
the TLB command to time out for a direct free, a release before the
free and a rollback before the free. Each keeps the page tables, and
the timeout cases fail on the old code. A comment in
apple_dart_check_fw_map() now says the firmware leaf is checked,
because only the root entry is snapshotted.

The message of ff5c39a ("iommu/apple-dart: keep stream invalidates
out of handed-off slots") also lists resume as a user of the stream
invalidate, but apple_dart_resume() returns early for locked DARTs, and
handoff requires a locked DART, so resume never reaches it.

In this tree the fixture also stubs apple_dart_has_borrowed() and the
DCP domain fields that apple_dart_release_device(),
apple_dart_t8110_hw_invalidate_tlb() and apple_dart_domain_free() read;
no borrowed display root is involved in these cases.

Signed-off-by: DjDeveloperr <[email protected]>
(cherry picked from omacom/linux-aurora commit 07d64c6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant