Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## Unreleased

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recreate the commit with the mandated identity

The reviewed commit records both its author and committer as Codex <codex@openai.com>, so it cannot land under this repository's standing identity policy. Recreate it with Joshua Warren and 816217+joshuaswarren@users.noreply.github.com as both identities.

AGENTS.md reference: AGENTS.md:L252-L257

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against the commits API: ba5e5b4 has author and committer Joshua Warren <816217+joshuaswarren@users.noreply.github.com> (GET /repos/joshuaswarren/omarchy-ane/commits/ba5e5b4396e77ada0281aafce08a60e0c4c92fef). The follow-up 8c0ae1b has the same identity. No change.


### Fixed

- `omarchy-ane-dt` counts only an enabled kernel node (no `status`, `"okay"`
or `"ok"`) as the kernel's ANE node. Before, a disabled node, as in
aurora-silicon/linux #65, made it skip the T6021 overlay, and the ANE stayed
disabled. Now the overlay applies over the disabled nodes and enables them.
The T6021 overlay sets `status = "okay"` on its three DARTs, so a merged
DART does not stay disabled. `validate` refuses a new or changed node that
names a disabled provider. `omarchy-ane-dt status` and
`omarchy-ane-m2-enable` ignore disabled ANE nodes. See
`receipts/2026-10-01-ane-dt-disabled-nodes`.

## 0.4.0 (2026-10-01)

The T6021 (M2 Max) driver stays opt-in. This release adds whole-model runs on
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ The package installs the driver. You do not need `install.sh`.
`ane.ko` binds only to a device-tree node with an `apple,t*-ane` compatible. The device trees in `linux-aurora` 7.1.12 and `linux-asahi` 7.1.13 do not have this node. The package adds it with an overlay until the kernel's device trees have it.

- **Overlays.** `packaging/dt/` holds one overlay for each SoC. `packaging/build-dtbo` compiles each `PREFIX-NAME.dts` to `/usr/lib/omarchy-platform/dtb-overlays/PREFIX/omarchy-NAME.dtbo`. The prefix selects the board device trees by file name: `t8103` selects every `t8103-*.dtb`. The T8103 overlay makes the same ANE, DART and power-domain nodes that the bound M1 host has. The T6001 overlay makes the nodes of the lab overlay `ane/t6001-j316c-set-domains.dts`. The T6021 overlay is opt-in: it has the root string `omarchy,opt-in = "ane-t6021"`, and it applies only when `ane-t6021` is a line of `/etc/omarchy-platform/dtb-overlays.opt-in`. T6021 also has an opt-in overlay that is not an ANE part: see "U-Boot input" below.
- **The kernel wins.** Each ANE overlay names its compatible in `omarchy,skip-if-compatible`. When the kernel's board device tree has that node, that overlay is not used. The other overlays still apply.
- **Arch Linux ARM (asahi-alarm).** `omarchy-ane-dt apply` finds this Mac's board device tree from `/sys/firmware/devicetree/base/compatible`. For each installed kernel, it applies the overlays to a copy of that device tree. It checks that dtc can read the result and that the ANE node is present, and that every reference in the new nodes resolves. It writes the copy to `/var/lib/omarchy-ane/dtbs/KERNEL/`. It does not change a file that a package owns. It adds one line to `/etc/default/update-m1n1`. That line sources `/usr/lib/omarchy-ane/update-m1n1-dtbs`, which puts the copy in `DTBS` only while the copy was made from the same kernel file. A second run changes nothing. If a step fails, the original device trees stay in use and the tool prints the reason.
- **The kernel wins.** Each ANE overlay names its compatible in `omarchy,skip-if-compatible`. When the kernel's board device tree has that node enabled (no `status`, `"okay"` or `"ok"`), that overlay is not used. The other overlays still apply. A disabled kernel node does not count: the overlay applies, fdtoverlay merges each overlay node into the kernel node of the same name, and the overlay's properties and `status = "okay"` replace the kernel's ([receipt](receipts/2026-10-01-ane-dt-disabled-nodes/README.md)). `omarchy-ane-dt` follows this rule. The draft omarchy-mac-boot `dtb-overlays.sh` (`986486a7`) does not yet: it skips the overlay for a disabled kernel node too.
- **Arch Linux ARM (asahi-alarm).** `omarchy-ane-dt apply` finds this Mac's board device tree from `/sys/firmware/devicetree/base/compatible`. For each installed kernel, it applies the overlays to a copy of that device tree. It checks that dtc can read the result and that the ANE node is present and enabled, and that every reference in the new or changed nodes resolves to an enabled node. It writes the copy to `/var/lib/omarchy-ane/dtbs/KERNEL/`. It does not change a file that a package owns. It adds one line to `/etc/default/update-m1n1`. That line sources `/usr/lib/omarchy-ane/update-m1n1-dtbs`, which puts the copy in `DTBS` only while the copy was made from the same kernel file. A second run changes nothing. If a step fails, the original device trees stay in use and the tool prints the reason.
- **Kernel updates.** The pacman hook `90-omarchy-ane-dt.hook` runs `omarchy-ane-dt apply` after a kernel update. It runs before `95-m1n1-install.hook`, so `update-m1n1` reads the new copy. omarchy-ane does not run `update-m1n1` itself. After the first install, run `sudo update-m1n1`, then reboot.
- **Omarchy Macs (omarchy-mac-boot).** omarchy-mac-boot builds `boot.bin` and checks it on each `omarchy update`. A version of omarchy-mac-boot with device tree overlay support ([omacom/omarchy-mac#677](https://github.com/omacom/omarchy-mac/pull/677), draft) applies `/usr/lib/omarchy-platform/dtb-overlays` itself, and `omarchy-ane-dt` does nothing. With an older omarchy-mac-boot, `omarchy-ane-dt` refuses, because its boot check stops `omarchy update` when a device tree changes.
- **Removal.** Removing the package runs `omarchy-ane-dt remove`. It removes the line and the copies. `boot.bin` keeps the node until `update-m1n1` runs again: run `sudo update-m1n1`.
Expand Down
8 changes: 8 additions & 0 deletions packaging/dt/t6021-ane.dts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
* 16 MiB, in the ane DART domain).
* AIC2 and the ANE power islands already exist in stock T6021 trees. Their
* phandles differ between kernels and boards, so they are reached by path.
* The DARTs, the mailbox and ane set status "okay": aurora-silicon/linux #65
* ships these nodes, same names, disabled. On such a kernel omarchy-ane-dt
* applies this overlay, fdtoverlay merges each node into the kernel's, and a
* node without a status here would stay disabled
* (receipts/2026-10-01-ane-dt-disabled-nodes).
*/
/dts-v1/;
/plugin/;
Expand Down Expand Up @@ -113,6 +118,7 @@
interrupt-parent = <&aic>;
interrupts = <0 0 885 4>;
power-domains = <&ps_pmp>;
status = "okay";
};

ane_dart1: iommu@285810000 {
Expand All @@ -122,6 +128,7 @@
interrupt-parent = <&aic>;
interrupts = <0 0 885 4>;
power-domains = <&ps_ane_cpu>;
status = "okay";
};

ane_dart2: iommu@285820000 {
Expand All @@ -131,6 +138,7 @@
interrupt-parent = <&aic>;
interrupts = <0 0 885 4>;
power-domains = <&ps_ane_cpu>;
status = "okay";
};

ane_mbox: mailbox@285408000 {
Expand Down
35 changes: 25 additions & 10 deletions packaging/omarchy-ane-dt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ writes the overlaid copy to /var/lib/omarchy-ane/dtbs/KERNEL/ and adds one line
to /etc/default/update-m1n1 that sources /usr/lib/omarchy-ane/update-m1n1-dtbs.
That script swaps the copy in only while it was made from the same kernel file.
An overlay whose root has the string list "omarchy,skip-if-compatible" is left
out of a kernel device tree that already has a node with one of them: the
kernel's node wins. When no overlay is left, apply retires the copy.
out of a kernel device tree that already has an enabled node (no status, "okay"
or "ok") with one of them: the kernel's node wins. A disabled node does not
count: the overlay applies, and its nodes of the same name replace the kernel
node's properties and enable it. When no overlay is left, apply retires the copy.
An overlay whose root has the string "omarchy,opt-in" applies only when that
string is a line of /etc/omarchy-platform/dtb-overlays.opt-in (the T6021 node:
"ane-t6021", written by omarchy-ane-m2-enable; the T6021 U-Boot input:
Expand Down Expand Up @@ -92,8 +94,13 @@ class Tree:
def strings(self, path, prop):
return [s.decode() for s in self.nodes.get(path, {}).get(prop, b"").split(b"\0") if s]

def enabled(self, path):
"""Linux's of_device_is_available(): no status, "okay" or "ok"."""
return self.strings(path, "status") in ([], ["okay"], ["ok"])

def ane_nodes(self):
return [path for path in self.nodes if any(ANE.fullmatch(c) for c in self.strings(path, "compatible"))]
return [path for path in self.nodes
if self.enabled(path) and any(ANE.fullmatch(c) for c in self.strings(path, "compatible"))]


def cells(data):
Expand Down Expand Up @@ -142,7 +149,8 @@ def skip_compatibles(overlay):


def validate(stock, result, wanted):
"""Refuse RESULT unless it is STOCK plus nodes whose references resolve."""
"""Refuse RESULT unless it is STOCK plus new or changed nodes whose
references resolve to enabled providers."""
if result.strings("/", "compatible") != stock.strings("/", "compatible"):
raise Refuse("the overlay changed the board compatible")
for path, props in stock.nodes.items():
Expand All @@ -151,33 +159,36 @@ def validate(stock, result, wanted):
if "phandle" in props and result.nodes[path].get("phandle") != props["phandle"]:
raise Refuse(f"the overlay renumbered {path}; this dtc is too old (1.7.1 or newer keeps phandles)")
for compatible in wanted:
live = [p for p in result.nodes if compatible in result.strings(p, "compatible")
and result.strings(p, "status") in ([], ["okay"])]
live = [p for p in result.nodes if compatible in result.strings(p, "compatible") and result.enabled(p)]
if not live:
raise Refuse(f"the result has no enabled {compatible} node")
for path in set(result.nodes) - set(stock.nodes):
for path in [p for p in result.nodes if result.nodes[p] != stock.nodes.get(p)]:
props = result.nodes[path]
plain = cells(props.get("interrupt-parent", b"")) + cells(props.get("memory-region", b""))
if "iommu-addresses" in props:
Comment on lines +165 to 168

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject disabled plain-phandle providers

When an applied overlay's new or changed node has an interrupt-parent, memory-region, or iommu-addresses phandle targeting a node whose status is disabled, this validation path checks only that the phandle exists; the new availability check applies only to properties in REFS. In the newly supported case where an overlay enables a previously disabled ANE node, this can accept and install an enabled consumer backed by a disabled interrupt controller or reserved-memory provider, contrary to the validator's stated contract. Check result.enabled(result.phandles[phandle]) for these plain references as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8c0ae1b: the interrupt-parent, memory-region and iommu-addresses targets of a new or changed node must be enabled too (... names /soc/interrupt-controller@..., which is disabled). tools/test_ane_dt.py has a case for a disabled AIC and for a disabled power domain; the AIC case fails on ba5e5b4 with validate accepted. test_ane_dt ok, test_ane_m2 ok, pytest -q tests tools 26 passed. The merge-experiment logs in the receipt are unchanged with the new check.

plain.append(cells(props["iommu-addresses"])[0])
for phandle in plain:
if phandle not in result.phandles:
raise Refuse(f"{path} names phandle {phandle:#x}, which no node has")
if not result.enabled(result.phandles[phandle]):
raise Refuse(f"{path} names {result.phandles[phandle]}, which is disabled")
for prop, count in REFS.items():
words, i = cells(props.get(prop, b"")), 0
while i < len(words):
target = result.phandles.get(words[i])
if target is None or count not in result.nodes[target]:
raise Refuse(f"{path} {prop} names phandle {words[i]:#x}, which is not a {count} provider")
if not result.enabled(target):
raise Refuse(f"{path} {prop} names {target}, which is disabled")
i += 1 + cells(result.nodes[target][count])[0]


def build(stock_file, overlays, workdir):
"""(overlaid device tree bytes, validated; the overlays applied), or None
when the kernel's tree has the nodes of every overlay."""
when the kernel's tree has enabled nodes for every overlay."""
stock_bytes = stock_file.read_bytes()
stock = Tree(stock_bytes)
present = {c for p in stock.nodes for c in stock.strings(p, "compatible")}
present = {c for p in stock.nodes if stock.enabled(p) for c in stock.strings(p, "compatible")}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Broadened reference check now also reaches stock nodes the overlay only tweaks

Changing the loop from new nodes to new or changed nodes widens what validate() inspects: packaging/dt/t6001-ane.dts fragment@3 sets reg on the existing /soc/power-management@28e080000, so that stock node becomes "changed" and its own interrupt-parent/power-domains targets are reference-checked for the first time. tools/test_ane_dt.py only ever calls build() with the t8103 and t6021 overlays, so that path has no coverage at all — a refusal on a real M1 Max tree would be the first sign of it.

A fixture that builds the t6001 overlay over a stock-like tree would pin the widened rule where it can actually regress.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

needed = [o for o in overlays if not present.intersection(skip_compatibles(o))]
if not needed:
return None
Expand Down Expand Up @@ -297,7 +308,8 @@ def apply(root, hook_targets):
if built is None:
if state.exists():
remove_tree(state)
print(f"omarchy-ane-dt: {kernel.name}: the kernel's {name} has the overlays' nodes; no copy needed")
print(f"omarchy-ane-dt: {kernel.name}: the kernel's {name} has the overlays' nodes enabled; "
"no copy needed")
continue
data, applied = built
changed = changed or not (state / name).is_file() or (state / name).read_bytes() != data
Expand Down Expand Up @@ -326,6 +338,9 @@ def status(root, kver):
base = root / "sys/firmware/devicetree/base"
live = []
for compat in base.glob("**/compatible") if base.is_dir() else []:
st = compat.parent / "status"
if st.exists() and st.read_bytes().rstrip(b"\0") not in (b"okay", b"ok"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Third, slightly different copy of the availability rule

Tree.enabled() (line 97) implements of_device_is_available() as status in ([], ["okay"], ["ok"]). This inline version diverges for a zero-length status property: b"" is not in (b"okay", b"ok"), so the node is skipped here, while strings() filters empty strings and would report the same node as enabled. The two answers then disagree inside one run of status — the live loop here versus kernel_has/copy_has from Tree(...).ane_nodes() a few lines below.

Worth routing both through one helper so the rule cannot drift.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

continue
if any(ANE.fullmatch(s) for s in compat.read_bytes().decode(errors="replace").split("\0")):
live.append(str(compat.parent.relative_to(base)))
name = board(root)
Expand Down
11 changes: 6 additions & 5 deletions packaging/omarchy-ane-m2-enable
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def module_file(root, kver):

def board_dtb(root, kver):
"""The board device tree KVER boots with the T6021 overlay on: the kernel's
own when it already has the ANE node, else the overlays applied to it."""
own when it already has an enabled ANE node, else the overlays applied to it."""
name = dt.board(root)
stock = root / "usr/lib/modules" / kver / "dtbs" / name
if not stock.is_file():
Expand All @@ -91,10 +91,10 @@ def board_dtb(root, kver):


def mailbox_irqs(data):
"""The interrupt-names of the mailbox the T6021 ANE node names in mboxes;
None when the tree has no T6021 ANE node."""
"""The interrupt-names of the mailbox the enabled T6021 ANE node names in
mboxes; None when the tree has no enabled T6021 ANE node."""
tree = dt.Tree(data)
ane = [p for p in tree.nodes if "apple,t6021-ane" in tree.strings(p, "compatible")]
ane = [p for p in tree.ane_nodes() if "apple,t6021-ane" in tree.strings(p, "compatible")]
if not ane:
return None
words = dt.cells(tree.nodes[ane[0]].get("mboxes", b""))
Expand Down Expand Up @@ -186,7 +186,8 @@ def enable(root, kver):
f"then run: sudo dkms autoinstall -k {kver}")
names = mailbox_irqs(board_dtb(root, kver))
if names is None:
raise Refuse(f"the device tree for kernel {kver} has no apple,t6021-ane node, even with the T6021 overlay")
raise Refuse(f"the device tree for kernel {kver} has no enabled apple,t6021-ane node, "
"even with the T6021 overlay")
if not all(irq in names for irq in MAILBOX_IRQS):
raise Refuse(f"the ANE mailbox in the device tree for kernel {kver} has interrupt-names {names}; "
f"the stock apple-mailbox binds it only with {' and '.join(MAILBOX_IRQS)}")
Expand Down
Loading