From 97ab92e1b981ab2dd35e07587284ffbcef1260e6 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Thu, 1 Oct 2026 23:08:35 -0500 Subject: [PATCH 1/2] dt-bindings: mailbox: apple,mailbox: Allow the ANE mailbox variant The T6021 (M2 Max) ANE coprocessor mailbox is an ASC mailbox, but only one of its interrupts is known: the Apple device tree gives the ANE a single interrupt line. The binding requires the four ASC mailbox interrupts in a fixed order, so a node for this mailbox fails dtbs_check. Add the apple,t6021-ane-mailbox compatible with the apple,asc-mailbox-v4 fallback. For it, recv-not-empty is the only required interrupt; send-empty, send-not-empty and recv-empty may follow in that order. Without send-empty, the OS must poll the FIFO status before it sends. The other variants keep their constraints. The four-interrupt rule moves into a condition that excludes the ANE and AOP setup mailboxes, and the AOP setup mailbox states its minimum of two interrupts, which the top-level limit gave it before. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- .../bindings/mailbox/apple,mailbox.yaml | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml index ee40e13c9a2b9..96675c53c3dd0 100644 --- a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml +++ b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml @@ -36,6 +36,13 @@ properties: - apple,t6020-asc-mailbox - const: apple,asc-mailbox-v4 + - description: + The T6021 ANE coprocessor mailbox is an ASC mailbox. Only its + recv-not-empty interrupt is known. + items: + - const: apple,t6021-ane-mailbox + - const: apple,asc-mailbox-v4 + - description: AOP setup-port mailbox with a separate register layout. const: apple,t8140-aop-setup-mailbox @@ -62,11 +69,11 @@ properties: maxItems: 1 interrupts: - minItems: 2 + minItems: 1 maxItems: 4 interrupt-names: - minItems: 2 + minItems: 1 maxItems: 4 iommus: @@ -95,6 +102,7 @@ allOf: then: properties: interrupts: + minItems: 2 maxItems: 2 interrupt-names: items: @@ -104,6 +112,34 @@ allOf: - iommus - apple,dma-range else: + properties: + iommus: false + apple,dma-range: false + + - if: + properties: + compatible: + contains: + const: apple,t6021-ane-mailbox + then: + properties: + interrupt-names: + minItems: 1 + items: + - const: recv-not-empty + - const: send-empty + - const: send-not-empty + - const: recv-empty + + - if: + properties: + compatible: + not: + contains: + enum: + - apple,t6021-ane-mailbox + - apple,t8140-aop-setup-mailbox + then: properties: interrupts: minItems: 4 @@ -113,8 +149,6 @@ allOf: - const: send-not-empty - const: recv-empty - const: recv-not-empty - iommus: false - apple,dma-range: false required: - compatible From 00248157ec1fc4e6369cd26cb8304bb56df7415d Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Thu, 1 Oct 2026 23:08:36 -0500 Subject: [PATCH 2/2] soc: apple: mailbox: Make the send-empty IRQ optional (poll TX) The T6021 (M2 Max) ANE coprocessor mailbox has one known AIC line, which the device tree names recv-not-empty. apple-mailbox insists on a send-empty IRQ as well, so it cannot bind that mailbox. Look send-empty up with platform_get_irq_byname_optional(). When the node has none (-ENXIO), do not request it, and let apple_mbox_send() wait for FIFO space by polling the A2I control register, the way its atomic path already does (100 us steps, 500 ms timeout, under tx_lock). Any other lookup error still fails the probe with -ENODEV. A mailbox whose node names send-empty takes the old path unchanged: the IRQ is requested at the same point with the same flags and name, and a non-atomic send still sleeps on tx_empty. All 71 apple-mailbox nodes in arch/arm64/boot/dts/apple name send-empty today. The Rust wrapper (RUST_APPLE_MAILBOX) needs no change. It only calls apple_mbox_get_byname(), apple_mbox_start(), apple_mbox_send() and apple_mbox_stop(), and never reads the IRQ fields, so a Rust client gets the poll through apple_mbox_send(). An equivalent change ran on an M2 Max lab kernel (Asahi 7.1.13 base) from 2026-09-24 to 2026-09-30, where apple-mailbox bound the one-interrupt ANE mailbox. The FIFO-full poll itself did not run there: with the ANE firmware in use (from macOS 13.5), the host sends no mailbox message after probe. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- drivers/soc/apple/mailbox.c | 33 ++++++++++++++++++++----------- include/linux/soc/apple/mailbox.h | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/soc/apple/mailbox.c b/drivers/soc/apple/mailbox.c index 16631fc352f44..4a4df15707ce3 100644 --- a/drivers/soc/apple/mailbox.c +++ b/drivers/soc/apple/mailbox.c @@ -121,7 +121,7 @@ int apple_mbox_send(struct apple_mbox *mbox, const struct apple_mbox_msg msg, mbox_ctrl = readl_relaxed(mbox->regs + mbox->hw->a2i_control); while (mbox_ctrl & mbox->hw->control_full) { - if (atomic) { + if (atomic || mbox->irq_send_empty < 0) { ret = readl_poll_timeout_atomic( mbox->regs + mbox->hw->a2i_control, mbox_ctrl, !(mbox_ctrl & mbox->hw->control_full), 100, @@ -397,8 +397,13 @@ static int apple_mbox_probe(struct platform_device *pdev) if (mbox->irq_recv_not_empty < 0) return -ENODEV; - mbox->irq_send_empty = platform_get_irq_byname(pdev, "send-empty"); - if (mbox->irq_send_empty < 0) + /* + * Some coprocessors (e.g. the T6021 ANE ASC) have no send-empty line. + * apple_mbox_send then polls the A2I control register instead. + */ + mbox->irq_send_empty = + platform_get_irq_byname_optional(pdev, "send-empty"); + if (mbox->irq_send_empty < 0 && mbox->irq_send_empty != -ENXIO) return -ENODEV; spin_lock_init(&mbox->rx_lock); @@ -415,15 +420,19 @@ static int apple_mbox_probe(struct platform_device *pdev) if (ret) return ret; - irqname = devm_kasprintf(dev, GFP_KERNEL, "%s-send", dev_name(dev)); - if (!irqname) - return -ENOMEM; - - ret = devm_request_irq(dev, mbox->irq_send_empty, - apple_mbox_send_empty_irq, - IRQF_NO_AUTOEN | IRQF_NO_SUSPEND, irqname, mbox); - if (ret) - return ret; + if (mbox->irq_send_empty >= 0) { + irqname = devm_kasprintf(dev, GFP_KERNEL, "%s-send", + dev_name(dev)); + if (!irqname) + return -ENOMEM; + + ret = devm_request_irq(dev, mbox->irq_send_empty, + apple_mbox_send_empty_irq, + IRQF_NO_AUTOEN | IRQF_NO_SUSPEND, + irqname, mbox); + if (ret) + return ret; + } ret = devm_pm_runtime_enable(dev); if (ret) diff --git a/include/linux/soc/apple/mailbox.h b/include/linux/soc/apple/mailbox.h index 9cfbbac411b8e..f7e76b554272c 100644 --- a/include/linux/soc/apple/mailbox.h +++ b/include/linux/soc/apple/mailbox.h @@ -24,7 +24,7 @@ struct apple_mbox { bool active; int irq_recv_not_empty; - int irq_send_empty; + int irq_send_empty; /* < 0: no send-empty IRQ, TX polls */ spinlock_t rx_lock; spinlock_t tx_lock;