From 6fbfb19ec72900e4c72eb953c564824d4fcab347 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:21:32 -0500 Subject: [PATCH 01/10] dt-bindings: thunderbolt: apple: document T8122 MxWrap registers Describe the existing four-range format used by the T8122 router. Signed-off-by: Satya Benson Assisted-by: LLM --- .../devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml index fe61df65c5c27..ef6a2e723cef1 100644 --- a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml @@ -52,7 +52,7 @@ properties: PCIe adapter configuration space of the USB4 router. Present where the root complex exposes the adapter separately, so that the tunnel can be configured before a PCIe-C link is brought up. - - description: MxWrap co-processor control registers, on T8132 and T6050 + - description: MxWrap co-processor control registers, on T6030, T8122, T8132 and T6050 - description: PCIe router AP firmware registers, on T6050 reg-names: From 7ba567215c3d775f7f33691feb3491d9d97d413f Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:21:32 -0500 Subject: [PATCH 02/10] pmdomain: apple: witness a consumer power-domain reset boundary Read target, actual, busy and automatic state after release. Do not override shared votes; let the caller quarantine restart when power-off is unproven. Signed-off-by: Satya Benson Assisted-by: LLM --- drivers/pmdomain/apple/pmgr-pwrstate.c | 25 +++++++++++++++++++++++++ include/linux/soc/apple/pmgr-pwrstate.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/drivers/pmdomain/apple/pmgr-pwrstate.c b/drivers/pmdomain/apple/pmgr-pwrstate.c index d6b0cc28b6c2c..73248b81cb853 100644 --- a/drivers/pmdomain/apple/pmgr-pwrstate.c +++ b/drivers/pmdomain/apple/pmgr-pwrstate.c @@ -838,6 +838,31 @@ static int apple_pmgr_ps_probe(struct platform_device *pdev) return ret; } +/* A reset witness, not a request to override another consumer's vote. */ +int apple_pmgr_ps_verify_off(struct device *consumer) +{ + struct generic_pm_domain *genpd; + struct apple_pmgr_ps *ps; + u32 val; + int ret; + + if (!consumer->pm_domain) + return -ENODEV; + genpd = pd_to_genpd(consumer->pm_domain); + if (genpd->power_off != apple_pmgr_ps_power_off) + return -EOPNOTSUPP; + ps = genpd_to_apple_pmgr_ps(genpd); + ret = regmap_read(ps->regmap, ps->offset, &val); + if (ret) + return ret; + if (val & (APPLE_PMGR_PS_LEVELS | APPLE_PMGR_BUSY | APPLE_PMGR_AUTO_ENABLE)) { + dev_err(consumer, "reset boundary not reached: PMGR %#x\n", val); + return -EBUSY; + } + return 0; +} +EXPORT_SYMBOL_GPL(apple_pmgr_ps_verify_off); + static struct platform_driver apple_pmgr_ps_driver; /* Wait for the masked state word to read @want; @cur gets the last value. */ diff --git a/include/linux/soc/apple/pmgr-pwrstate.h b/include/linux/soc/apple/pmgr-pwrstate.h index e09a7ee3e031c..859565972edac 100644 --- a/include/linux/soc/apple/pmgr-pwrstate.h +++ b/include/linux/soc/apple/pmgr-pwrstate.h @@ -8,6 +8,7 @@ struct device; struct device_node; #if IS_ENABLED(CONFIG_APPLE_PMGR_PWRSTATE) +int apple_pmgr_ps_verify_off(struct device *consumer); int apple_pmgr_ps_cycle(struct device_node *np); /* * Power off (child first) or on (parent first) the chain of @@ -20,6 +21,7 @@ int apple_pmgr_ps_consumer_check(struct device *consumer); int apple_pmgr_ps_consumer_off(struct device *consumer); int apple_pmgr_ps_consumer_on(struct device *consumer); #else +static inline int apple_pmgr_ps_verify_off(struct device *consumer) { return -EOPNOTSUPP; } static inline int apple_pmgr_ps_cycle(struct device_node *np) { return -EOPNOTSUPP; } static inline int apple_pmgr_ps_consumer_check(struct device *consumer) { return -EOPNOTSUPP; } static inline int apple_pmgr_ps_consumer_off(struct device *consumer) { return -EOPNOTSUPP; } From 271b13af0321c9de21cd789d7e5f26e48cdfe258 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:21:32 -0500 Subject: [PATCH 03/10] PCI: apple: validate the T8122 PCIe-C MSI slices Keep the two J613 ECAM windows in disjoint 32-vector slices of the ADT AIC window. Signed-off-by: Satya Benson Assisted-by: LLM --- drivers/pci/controller/pcie-apple.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index b0f9cc67858f5..967ce0f4b968a 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -3259,6 +3259,18 @@ static int apple_msi_init(struct apple_pcie *pcie) default: goto invalid_slice; } + } else if (of_machine_is_compatible("apple,t8122")) { + aic_base = 1075; + switch (ecam.start) { + case 0x730000000ULL: + expected_base = 0x20; + break; + case 0xb30000000ULL: + expected_base = 0x40; + break; + default: + goto invalid_slice; + } } else if (of_machine_is_compatible("apple,t8132")) { aic_base = 1506; switch (ecam.start) { From df6efbabb90d7ca32a4c8b26300b03fc794b51b0 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:21:33 -0500 Subject: [PATCH 04/10] thunderbolt: apple: add the J613 MxWrap start and teardown policy Use RUN with explicit pre-RTKit LSTX and strict firmware readiness; disable DP tunnelling. Own power references and require a witnessed off boundary before restart. Order PD, NHI and role/PHY shutdown. Keep the T8122 session coordinator scoped to J613. The sequence was inferred from the T6030 generation, not a J613 macOS restart trace, then exercised on J613 hardware. Suspend coordination is carried from the trial but is not hardware qualified; sleep remains outside admission. Signed-off-by: Satya Benson Assisted-by: LLM --- drivers/thunderbolt/apple.c | 199 +++++++++++++++++++++++++++--- drivers/thunderbolt/tb.c | 23 ++++ drivers/thunderbolt/tb.h | 2 + drivers/usb/typec/tipd/core.c | 90 ++++++++++++++ drivers/usb/typec/tipd/spmi.c | 6 + drivers/usb/typec/tipd/tps6598x.h | 4 + include/linux/usb/typec_mux.h | 3 + 7 files changed, 313 insertions(+), 14 deletions(-) diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index 7e6b10c828a33..a4e6dcda107d8 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -101,9 +101,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -131,8 +133,10 @@ #define APPLE_MXWRAP_CPU_CTRL 0x28 #define APPLE_MXWRAP_CPU_CTRL_RUN BIT(4) #define APPLE_MXWRAP_CPU_STATUS 0x44 +#define APPLE_CIO_T8122_LINK_CHECK_MS 8000 struct apple_cio_hw { + bool strict_power_cycle; bool mxwrap; bool lstx_explicit; /* Leave MxWrap RUN alone: the CIO reconfig restarts the CPU. */ @@ -171,6 +175,15 @@ static const struct apple_cio_hw apple_cio_t6030_hw = { .dp = &apple_dpin_m3, }; +/* T8122 shares the T6030 MxWrap/PHY generation; DP is unqualified. */ +static const struct apple_cio_hw apple_cio_t8122_hw = { + .strict_power_cycle = true, + .mxwrap = true, + .lstx_explicit = true, + .strict_fw_ready = true, + .dp = &apple_dpin_disabled, +}; + /* * T8132 has the T6030 ACIO layout and MxWrap CPU block, but the CIO reconfig * already starts the CPU from its preloaded SRAM: RUN is never written. LSTX @@ -360,6 +373,8 @@ struct apple_cio { struct reset_control *reset; struct dev_pm_domain_list *pd_list; + unsigned int pd_held; + bool reset_failed; struct mutex lock; /* serializes cable transitions and ACIO power up/down */ bool removing; /* protected by lock */ @@ -2150,6 +2165,48 @@ static const struct tb_nhi_ring_layout apple_nhi_ring_layout = { .options_stride = APPLE_CIO_NHI_RING_STRIDE, }; +/* + * PD owns session shutdown. Put it after the dynamic NHI, and the NHI after + * the role/PHY suppliers, so device_shutdown visits the coordinator first. + * Stateless links are purged by device_del of this per-attach NHI. + */ +static int apple_nhi_shutdown_order(struct apple_cio *acio, struct device *nhi) +{ + struct device_node *np; + struct spmi_device *pd; + int ret = 0; + + if (!acio->hw->strict_power_cycle) + return 0; + if (!IS_REACHABLE(CONFIG_SPMI)) + return -EOPNOTSUPP; + np = of_get_parent(acio->connector_np); + pd = spmi_find_device_by_of_node(np); + of_node_put(np); + if (!pd) + return -EPROBE_DEFER; + for (unsigned int port = 0; port < 2; port++) { + struct platform_device *supplier; + + np = of_graph_get_remote_node(acio->connector_np, port, -1); + supplier = of_find_device_by_node(np); + of_node_put(np); + if (!supplier) { + ret = -EPROBE_DEFER; + break; + } + if (!device_link_add(nhi, &supplier->dev, DL_FLAG_STATELESS)) + ret = -EINVAL; + put_device(&supplier->dev); + if (ret) + break; + } + if (!ret && !device_link_add(&pd->dev, nhi, DL_FLAG_STATELESS)) + ret = -EINVAL; + put_device(&pd->dev); + return ret; +} + static int apple_nhi_probe(struct platform_device *pdev) { struct apple_cio *acio = dev_get_drvdata(pdev->dev.parent); @@ -2349,6 +2406,11 @@ static int apple_nhi_probe(struct platform_device *pdev) mutex_unlock(&anhi->tb->lock); + ret = apple_nhi_shutdown_order(acio, &pdev->dev); + if (ret) { + mutex_lock(&anhi->tb->lock); + goto err_unlock_tb_domain; + } WRITE_ONCE(acio->nhi_pdev, pdev); acio->nhi_boot_status = 0; complete(&acio->nhi_boot_completion); @@ -2762,6 +2824,37 @@ static void apple_cio_cpu_halt(struct apple_cio *acio) acio->cpu_base + APPLE_MXWRAP_CPU_CTRL); } +/* Release exactly the references we own, children first, then witness PMGR. */ +static void apple_cio_power_down(struct apple_cio *acio) +{ + int i, ret; + + for (i = acio->pd_list->num_pds - 1; i >= 0; i--) { + if (acio->pd_list->pd_links[i]) + device_link_del(acio->pd_list->pd_links[i]); + acio->pd_list->pd_links[i] = NULL; + dev_pm_syscore_device(acio->pd_list->pd_devs[i], false); + } + if (!acio->hw->strict_power_cycle) + return; + while (acio->pd_held) { + struct device *pd = acio->pd_list->pd_devs[--acio->pd_held]; + + ret = pm_runtime_put_sync_suspend(pd); + if (ret < 0) + acio->reset_failed = true; + } + for (i = 0; i < acio->pd_list->num_pds; i++) { + ret = apple_pmgr_ps_verify_off(acio->pd_list->pd_devs[i]); + if (ret) + acio->reset_failed = true; + } + if (acio->reset_failed) + dev_err(acio->dev, "ACIO reset boundary unproven; restart quarantined until reboot\n"); + else + dev_info(acio->dev, "ACIO reset boundary: PMGR domains off\n"); +} + /** * apple_cio_stop - Stop and power down the ACIO complex * @acio: ACIO complex to stop @@ -2772,7 +2865,7 @@ static void apple_cio_cpu_halt(struct apple_cio *acio) */ static void apple_cio_stop(struct apple_cio *acio) { - int ret, i; + int ret; lockdep_assert_held(&acio->lock); if (!acio->current_cable_info) @@ -2795,12 +2888,7 @@ static void apple_cio_stop(struct apple_cio *acio) APPLE_CIO_LSTX_CTRL_LEVEL)); /* Finally, remove the links to the PD domains to power everything off */ - for (i = 0; i < acio->pd_list->num_pds; i++) { - if (acio->pd_list->pd_links[i]) - device_link_del(acio->pd_list->pd_links[i]); - acio->pd_list->pd_links[i] = NULL; - dev_pm_syscore_device(acio->pd_list->pd_devs[i], false); - } + apple_cio_power_down(acio); acio->current_cable_info = 0; acio->resume_link_failed = false; @@ -2882,10 +2970,20 @@ static int apple_cio_start(struct apple_cio *acio) dev_info(acio->dev, "PCIe-C reset before ACIO start\n"); } + if (acio->reset_failed) + return -EHOSTDOWN; + /* Create device links to the power domains in order to power them on */ for (i = 0; i < acio->pd_list->num_pds; i++) { + if (acio->hw->strict_power_cycle) { + ret = pm_runtime_resume_and_get(acio->pd_list->pd_devs[i]); + if (ret < 0) + goto remove_links; + acio->pd_held++; + } link = device_link_add(acio->dev, acio->pd_list->pd_devs[i], - DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + acio->hw->strict_power_cycle ? DL_FLAG_STATELESS : + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); if (!link) { ret = -ENODEV; goto remove_links; @@ -3046,6 +3144,11 @@ static int apple_cio_start(struct apple_cio *acio) acio->current_cable_info = acio->target_cable_info; acio->start_gen++; + if (acio->hw->strict_power_cycle) { + acio->link_lost_gen = acio->start_gen; + mod_delayed_work(system_freezable_wq, &acio->link_lost_work, + msecs_to_jiffies(APPLE_CIO_T8122_LINK_CHECK_MS)); + } return 0; err_depopulate: @@ -3061,12 +3164,7 @@ static int apple_cio_start(struct apple_cio *acio) acio->rtk = NULL; apple_cio_cpu_halt(acio); /* Cut power to reset the entire block */ - for (i = 0; i < acio->pd_list->num_pds; i++) { - if (acio->pd_list->pd_links[i]) - device_link_del(acio->pd_list->pd_links[i]); - acio->pd_list->pd_links[i] = NULL; - dev_pm_syscore_device(acio->pd_list->pd_devs[i], false); - } + apple_cio_power_down(acio); return ret; } @@ -3164,6 +3262,15 @@ static bool apple_cio_has_peer(struct apple_cio *acio, u64 *activity) tb_switch_for_each_port(anhi->tb->root_switch, port) { if (!tb_port_is_null(port)) continue; + if (acio->hw->strict_power_cycle) { + u32 lane; + int err = tb_port_read(port, &lane, TB_CFG_PORT, + port->cap_phy + LANE_ADP_CS_1, 1); + + dev_info(acio->dev, "attach health generation %u lane %u: %d state %#x activity %llu\n", + acio->start_gen, port->port, err, err ? 0 : lane, + *activity); + } if ((port->xdomain && !port->xdomain->is_unplugged) || (port->remote && !port->remote->sw->is_unplugged)) peer = true; @@ -3310,12 +3417,46 @@ static int apple_cio_tbt_switch_set(struct typec_thunderbolt_switch_dev *sw, { struct apple_cio *acio = typec_thunderbolt_switch_get_drvdata(sw); + if (data->state == TYPEC_THUNDERBOLT_SWITCH_SLEEP) { + cancel_delayed_work_sync(&acio->link_lost_work); + cancel_delayed_work_sync(&acio->resume_link_work); + } + guard(mutex)(&acio->lock); /* Removal turns the cable off itself; only refuse to start new work. */ if (acio->removing) return data->state == TYPEC_THUNDERBOLT_SWITCH_OFF ? 0 : -ESHUTDOWN; + if (data->state == TYPEC_THUNDERBOLT_SWITCH_WAKE) { + acio->sleep_phase = APPLE_CIO_SLEEP_OPEN; + acio->sleep_restart_owed = false; + return 0; + } + + if (data->state == TYPEC_THUNDERBOLT_SWITCH_SLEEP) { + struct platform_device *pdev = READ_ONCE(acio->nhi_pdev); + struct apple_nhi *anhi; + int ret; + + if (!acio->hw->strict_power_cycle) + return -EOPNOTSUPP; + if (acio->current_cable_info) { + if (!pdev) + return -EBUSY; + anhi = platform_get_drvdata(pdev); + if (!anhi) + return -EBUSY; + ret = tb_apple_sleep_quiesce(anhi->tb); + if (ret) + return ret; + acio->sleep_restart_owed = true; + apple_cio_stop(acio); + } + acio->sleep_phase = APPLE_CIO_SLEEP_CLOSED; + return acio->reset_failed ? -EHOSTDOWN : 0; + } + dev_dbg(acio->dev, "set cable state: %d\n", data->state); switch (data->state) { @@ -3491,6 +3632,9 @@ static int apple_cio_pm_notify(struct notifier_block *nb, unsigned long event, struct apple_cio *acio = container_of(nb, struct apple_cio, pm_notifier); bool owed, early; + if (acio->hw->strict_power_cycle) + return NOTIFY_DONE; + /* Teardown off and no restart owed from an earlier sleep: nothing to do. */ if (!READ_ONCE(s2idle_teardown) && !READ_ONCE(acio->sleep_restart_owed)) return NOTIFY_DONE; @@ -3562,6 +3706,10 @@ static int apple_cio_probe(struct platform_device *pdev) acio->dev = &pdev->dev; acio->np = dev->of_node; acio->hw = of_device_get_match_data(dev); + /* Only J613 has qualified the T8122 router policy and resources. */ + if (acio->hw == &apple_cio_t8122_hw && + !of_machine_is_compatible("apple,j613")) + acio->hw = &apple_cio_t8103_hw; if (!acio->hw) return -EINVAL; @@ -3772,6 +3920,24 @@ static int apple_cio_probe(struct platform_device *pdev) return 0; } +static void apple_cio_shutdown(struct platform_device *pdev) +{ + struct apple_cio *acio = platform_get_drvdata(pdev); + + if (!acio->hw->strict_power_cycle) + return; + + scoped_guard(mutex, &acio->lock) + acio->removing = true; + disable_delayed_work_sync(&acio->sleep_restart_work); + disable_delayed_work_sync(&acio->resume_link_work); + disable_delayed_work_sync(&acio->link_lost_work); + disable_delayed_work_sync(&acio->pcie_tunnel_work); + guard(mutex)(&acio->lock); + acio->target_cable_info = 0; + apple_cio_stop(acio); +} + static void apple_cio_remove(struct platform_device *pdev) { struct apple_cio *acio = platform_get_drvdata(pdev); @@ -3799,6 +3965,10 @@ static void apple_cio_remove(struct platform_device *pdev) static const struct of_device_id apple_acio_match[] = { + { + .compatible = "apple,t8122-usb4-acio", + .data = &apple_cio_t8122_hw, + }, { .compatible = "apple,t6040-usb4-acio", .data = &apple_cio_t6040_hw, @@ -3839,6 +4009,7 @@ static struct platform_driver apple_cio_driver = { }, .probe = apple_cio_probe, .remove = apple_cio_remove, + .shutdown = apple_cio_shutdown, }; static struct platform_driver * const apple_cio_drivers[] = { diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index ad59f4ede6bfc..1fa5ff9b32e0f 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -3802,6 +3802,29 @@ static void tb_handle_event(struct tb *tb, enum tb_cfg_pkg_type type, tb_queue_hotplug(tb, route, pkg->port, pkg->unplug); } +/* Called before the freezer. Close discovery and inspect in one transaction. */ +int tb_apple_sleep_quiesce(struct tb *tb) +{ + struct tb_cm *tcm = tb_priv(tb); + struct tb_port *port; + struct tb_tunnel *tunnel; + + if (!tb->root_switch || !tb->cm_ops) + return -EBUSY; + scoped_guard(mutex, &tb->lock) { + tb_switch_for_each_port(tb->root_switch, port) + if (port->remote) + return -EBUSY; + list_for_each_entry(tunnel, &tcm->tunnel_list, list) + if (!tb_tunnel_is_dma(tunnel)) + return -EBUSY; + tcm->hotplug_active = false; + } + /* No topology worker can now publish a router after the inspection. */ + flush_workqueue(tb->wq); + return 0; +} + static void tb_stop(struct tb *tb) { struct tb_cm *tcm = tb_priv(tb); diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 841d1ccb27042..2e692519c1ae1 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -1617,4 +1617,6 @@ static inline int tb_configfs_init(void) { return 0; } static inline void tb_configfs_exit(void) { } #endif +int tb_apple_sleep_quiesce(struct tb *tb); + #endif diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index fed6ea4097662..7a74365cea5c5 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -2188,10 +2189,83 @@ static int cd321x_tbt_notify(struct notifier_block *nb, return NOTIFY_OK; } +/* ACIO -> USB role -> PHY SAFE, before tasks freeze. */ +static int cd321x_session_stop(struct cd321x *cd, bool sleep) +{ + struct tps6598x *tps = &cd->tps; + struct typec_thunderbolt_switch_data data = { + .state = sleep ? TYPEC_THUNDERBOLT_SWITCH_SLEEP : + TYPEC_THUNDERBOLT_SWITCH_OFF, + }; + struct typec_mux_state safe = { .mode = TYPEC_STATE_SAFE }; + bool active; + int ret; + + cd321x_prepare(tps); + guard(mutex)(&tps->lock); + active = cd->state.mode == TYPEC_MODE_USB4 || + cd->state.alt == cd->port_altmode_tbt; + ret = typec_thunderbolt_switch_set(cd->tbt_switch, &data); + if (ret) + return ret; + cd->session_closed = true; + if (sleep && !active) + return 0; + ret = usb_role_switch_set_role(tps->role_sw, USB_ROLE_NONE); + if (!ret) + ret = typec_mux_set(cd->mux, &safe); + if (ret) + dev_err(tps->dev, "session quiesce failed, retaining PHY ownership: %d\n", ret); + else + dev_info(tps->dev, "USB4 session quiesced before freezer\n"); + return ret; +} + +static void cd321x_session_restore(struct cd321x *cd) +{ + struct typec_thunderbolt_switch_data data = { + .state = TYPEC_THUNDERBOLT_SWITCH_WAKE, + }; + + scoped_guard(mutex, &cd->tps.lock) { + typec_thunderbolt_switch_set(cd->tbt_switch, &data); + if (cd->session_closed) { + atomic_set(&cd->restore_event, 1); + cd->session_closed = false; + } + } + cd321x_complete(&cd->tps); +} + +static int cd321x_session_pm(struct notifier_block *nb, unsigned long event, void *unused) +{ + struct cd321x *cd = container_of(nb, struct cd321x, session_pm); + int ret; + + switch (event) { + case PM_SUSPEND_PREPARE: + ret = cd321x_session_stop(cd, true); + if (ret) + cd321x_session_restore(cd); + return notifier_from_errno(ret); + case PM_POST_SUSPEND: + cd321x_session_restore(cd); + break; + } + return NOTIFY_OK; +} + static void cd321x_ready(struct tps6598x *tps) { struct cd321x *cd321x = container_of(tps, struct cd321x, tps); + if (of_machine_is_compatible("apple,j613")) { + cd321x->session_pm.notifier_call = cd321x_session_pm; + cd321x->session_pm.priority = 100; + if (!register_pm_notifier(&cd321x->session_pm)) + cd321x->session_pm_registered = true; + } + guard(mutex)(&tps->lock); /* Include failures reported while the port was still being initialized. */ if (cd321x_pm_ready(&cd321x->pm)) { @@ -2204,6 +2278,10 @@ static void cd321x_ready(struct tps6598x *tps) VISIBLE_IF_KUNIT void cd321x_stop_work(struct cd321x *cd321x) { + if (cd321x->session_pm_registered) { + unregister_pm_notifier(&cd321x->session_pm); + cd321x->session_pm_registered = false; + } scoped_guard(mutex, &cd321x->tps.lock) cd321x_pm_remove(&cd321x->pm); @@ -3198,6 +3276,18 @@ int tipd_init(struct tps6598x *tps) } EXPORT_SYMBOL_GPL(tipd_init); +void tipd_shutdown(struct tps6598x *tps) +{ + int ret; + + if (!of_machine_is_compatible("apple,j613")) + return; + ret = cd321x_session_stop(container_of(tps, struct cd321x, tps), false); + if (ret) + dev_err(tps->dev, "USB4 shutdown incomplete: %d\n", ret); +} +EXPORT_SYMBOL_GPL(tipd_shutdown); + void tipd_remove(struct tps6598x *tps) { int ret = 0; diff --git a/drivers/usb/typec/tipd/spmi.c b/drivers/usb/typec/tipd/spmi.c index 30d472c3d83a4..ff2c6ad922353 100644 --- a/drivers/usb/typec/tipd/spmi.c +++ b/drivers/usb/typec/tipd/spmi.c @@ -980,6 +980,11 @@ static const struct dev_pm_ops sn201202x_pm_ops = { SET_RUNTIME_PM_OPS(sn201202x_runtime_suspend, sn201202x_runtime_resume, NULL) }; +static void sn201202x_shutdown(struct spmi_device *sdev) +{ + tipd_shutdown(dev_get_drvdata(&sdev->dev)); +} + static struct spmi_driver sn201202x_driver = { .driver = { .name = "sn201202x", @@ -988,6 +993,7 @@ static struct spmi_driver sn201202x_driver = { }, .probe = sn201202x_probe, .remove = sn201202x_remove, + .shutdown = sn201202x_shutdown, }; module_spmi_driver(sn201202x_driver); diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 20b6b73436a29..0721db6134bc0 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -438,6 +438,9 @@ struct cd321x_status { }; struct cd321x { + struct notifier_block session_pm; + bool session_pm_registered; + bool session_closed; struct tps6598x tps; struct tps6598x_dp_sid_status_reg dp_sid_status; @@ -505,6 +508,7 @@ extern const struct regmap_config tps6598x_regmap_config; int tipd_init(struct tps6598x *tps); void tipd_remove(struct tps6598x *tps); +void tipd_shutdown(struct tps6598x *tps); int tipd_prepare(struct device *dev); void tipd_complete(struct device *dev); int tipd_suspend(struct tps6598x *tps); diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index 9d1df67201239..bf7fe40be1501 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -212,6 +212,9 @@ enum typec_thunderbolt_switch_state { TYPEC_THUNDERBOLT_SWITCH_OFF, TYPEC_THUNDERBOLT_SWITCH_TBT, TYPEC_THUNDERBOLT_SWITCH_USB4, + /* Close topology admission, reject native tunnels, stop before freezer. */ + TYPEC_THUNDERBOLT_SWITCH_SLEEP, + TYPEC_THUNDERBOLT_SWITCH_WAKE, }; /** From 0d67c64ca9e7d7ae0b6158ae329e7d3a0c38540d Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:21:33 -0500 Subject: [PATCH 05/10] arm64: dts: apple: describe J613 USB4 PCIe-C resources Use saved J613 ADT windows, interrupts and tuning. Populate the root tunnel containers dynamically and include them only on J613. Own all four ACIO domains. Drop the disabled unused OTG node whose shared PHY/DARTs older Stage 2 loaders otherwise prune. Both J613 firmware profiles inherit the repair. Signed-off-by: Satya Benson Assisted-by: LLM --- arch/arm64/boot/dts/apple/t8122-j613.dts | 13 ++ arch/arm64/boot/dts/apple/t8122-usb4.dtsi | 202 ++++++++++++++++++++++ arch/arm64/boot/dts/apple/t8122.dtsi | 12 +- 3 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 arch/arm64/boot/dts/apple/t8122-usb4.dtsi diff --git a/arch/arm64/boot/dts/apple/t8122-j613.dts b/arch/arm64/boot/dts/apple/t8122-j613.dts index 1c503729a3101..17f3982727f46 100644 --- a/arch/arm64/boot/dts/apple/t8122-j613.dts +++ b/arch/arm64/boot/dts/apple/t8122-j613.dts @@ -10,6 +10,7 @@ /dts-v1/; #include "t8122.dtsi" +#include "t8122-usb4.dtsi" #include "t8122-j613-j615.dtsi" #include @@ -17,6 +18,15 @@ compatible = "apple,j613", "apple,t8122", "apple,arm-platform"; model = "Apple MacBook Air (13-inch, M3, 2024)"; + aliases { + usb4_0_pcie = &usb4_0_pcie; + usb4_0_pcie_port = &usb4_0_pcie_port; + usb4_1_pcie = &usb4_1_pcie; + usb4_1_pcie_port = &usb4_1_pcie_port; + usb4_0_pcie_adapter = &usb4_0_acio; + usb4_1_pcie_adapter = &usb4_1_acio; + }; + /* * Fanless: every die sensor throttles both clusters, E weighted 3:1 * and capped at state 3. Trips as on the J700; sustainable-power from @@ -432,3 +442,6 @@ /* Per-device factory data from this Mac's own iBoot system container. */ firmware-name = "apple/mesacal-j613.bin"; }; + +/* Older Stage 2 loaders prune the shared ATC0 suppliers of this unused node. */ +/delete-node/ &usb_otg0; diff --git a/arch/arm64/boot/dts/apple/t8122-usb4.dtsi b/arch/arm64/boot/dts/apple/t8122-usb4.dtsi new file mode 100644 index 0000000000000..359236dc07f6b --- /dev/null +++ b/arch/arm64/boot/dts/apple/t8122-usb4.dtsi @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* J613 ADT PCIe-C windows; DP tunnelling deliberately omitted. */ +/ { + usb4_0_pcie_tunnel: usb4-pcie-tunnel-0 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + /* Preserve the SoC DMA window after moving the virtual container. */ + dma-ranges = <0 0 0 0 0xffffffff 0xffffc000>; + + usb4_0_pcie_dart: iommu@721008000 { + compatible = "apple,t8122-dart", "apple,t8110-dart"; + reg = <0x7 0x21008000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = ; + #iommu-cells = <1>; + /* No bootloader fills this one; the tunnel's cold init needs it. */ + apple,tunable = + <0x20c 0x800001b7 0x800001b7>, + <0x220 0xf0f0f 0xf0f0f>, + <0x224 0xffffff 0x80808>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x318 0x1f31 0x1>, + <0x320 0x3ffffffc 0x1f00000>, + <0x328 0x3ffffffc 0x1f0bffc>; + }; + + usb4_0_pcie: pcie@730000000 { + compatible = "apple,t8122-pciec", "apple,t8103-pciec"; + device_type = "pci"; + reg = <0x7 0x30000000 0x0 0x10000000>, + <0x7 0x20000000 0x0 0x4000>, + <0x7 0x21000000 0x0 0x8000>, + <0x7 0x20004000 0x0 0x4000>, + <0x7 0x20200000 0x0 0x4000>, + <0x7 0x21010000 0x0 0x4000>, + <0x7 0x20008000 0x0 0x4000>, + <0x7 0x2100c000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", + "debug", "ltssm", "oe-fabric", "intr2axi"; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_atc0_cio_pcie>; + resets = <&ps_atc0_pcie>; + apple,pciec-kernel-init; + /* + * m1n1 fills the rc, fabric and debug tunables through the + * usb4_0_pcie alias, but not this one. + */ + apple,tunable-oe-fabric = + <0x4 0x70007 0x40004>, + <0x8 0x1 0x1>, + <0xc 0x1 0x1>, + <0x10 0x801f 0x4>, + <0x18 0x801f 0x4>, + <0x20 0x801f 0x4>; + apple,msi-vector-base = <32>; + msi-controller; + msi-parent = <&usb4_0_pcie>; + msi-ranges = <&aic AIC_IRQ 1107 IRQ_TYPE_EDGE_RISING 32>; + iommu-map = <0x0 &usb4_0_pcie_dart 0x0 0x40>; + iommu-map-mask = <0x3f>; + bus-range = <0x0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x43000000 0x8 0x0 + 0x8 0x0 0x2 0x0>, + <0x02000000 0x0 0x100000 + 0xa 0x100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 + 0xa 0x40000000 0x0 0x40000000>; + + usb4_0_pcie_port: pci@0,0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + external-facing; + /* apple,tunable is filled by the bootloader */ + #address-cells = <3>; + #size-cells = <2>; + ranges; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &usb4_0_pcie_port 0 0 0 0>, + <0 0 0 2 &usb4_0_pcie_port 0 0 0 1>, + <0 0 0 3 &usb4_0_pcie_port 0 0 0 2>, + <0 0 0 4 &usb4_0_pcie_port 0 0 0 3>; + }; + }; + }; +}; + +&usb4_0_acio { + power-domains = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>, <&ps_atc0_pcie>; + post-init-providers = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>, <&ps_atc0_pcie>; + apple,pcie-tunnel = <&usb4_0_pcie_tunnel>; +}; +/ { + usb4_1_pcie_tunnel: usb4-pcie-tunnel-1 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + /* Preserve the SoC DMA window after moving the virtual container. */ + dma-ranges = <0 0 0 0 0xffffffff 0xffffc000>; + + usb4_1_pcie_dart: iommu@b21008000 { + compatible = "apple,t8122-dart", "apple,t8110-dart"; + reg = <0xb 0x21008000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = ; + #iommu-cells = <1>; + /* No bootloader fills this one; the tunnel's cold init needs it. */ + apple,tunable = + <0x20c 0x800001b7 0x800001b7>, + <0x220 0xf0f0f 0xf0f0f>, + <0x224 0xffffff 0x80808>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x318 0x1f31 0x1>, + <0x320 0x3ffffffc 0x1f00000>, + <0x328 0x3ffffffc 0x1f0bffc>; + }; + + usb4_1_pcie: pcie@b30000000 { + compatible = "apple,t8122-pciec", "apple,t8103-pciec"; + device_type = "pci"; + reg = <0xb 0x30000000 0x0 0x10000000>, + <0xb 0x20000000 0x0 0x4000>, + <0xb 0x21000000 0x0 0x8000>, + <0xb 0x20004000 0x0 0x4000>, + <0xb 0x20200000 0x0 0x4000>, + <0xb 0x21010000 0x0 0x4000>, + <0xb 0x20008000 0x0 0x4000>, + <0xb 0x2100c000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", + "debug", "ltssm", "oe-fabric", "intr2axi"; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_atc1_cio_pcie>; + resets = <&ps_atc1_pcie>; + apple,pciec-kernel-init; + /* + * m1n1 fills the rc, fabric and debug tunables through the + * usb4_1_pcie alias, but not this one. + */ + apple,tunable-oe-fabric = + <0x4 0x70007 0x40004>, + <0xc 0x1 0x1>, + <0xc 0x1 0x1>, + <0x10 0x801f 0x4>, + <0x18 0x801f 0x4>, + <0x20 0x801f 0x4>; + apple,msi-vector-base = <64>; + msi-controller; + msi-parent = <&usb4_1_pcie>; + msi-ranges = <&aic AIC_IRQ 1139 IRQ_TYPE_EDGE_RISING 32>; + iommu-map = <0x0 &usb4_1_pcie_dart 0x0 0x40>; + iommu-map-mask = <0x3f>; + bus-range = <0x0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x43000000 0xc 0x0 + 0xc 0x0 0x2 0x0>, + <0x02000000 0x0 0x100000 + 0xe 0x100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 + 0xe 0x40000000 0x0 0x40000000>; + + usb4_1_pcie_port: pci@0,0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + external-facing; + /* apple,tunable is filled by the bootloader */ + #address-cells = <3>; + #size-cells = <2>; + ranges; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &usb4_1_pcie_port 0 0 0 0>, + <0 0 0 2 &usb4_1_pcie_port 0 0 0 1>, + <0 0 0 3 &usb4_1_pcie_port 0 0 0 2>, + <0 0 0 4 &usb4_1_pcie_port 0 0 0 3>; + }; + }; + }; +}; + +&usb4_1_acio { + power-domains = <&ps_atc1_cio>, <&ps_atc1_cio_pcie>, + <&ps_atc1_cio_usb>, <&ps_atc1_pcie>; + post-init-providers = <&ps_atc1_cio>, <&ps_atc1_cio_pcie>, + <&ps_atc1_cio_usb>, <&ps_atc1_pcie>; + apple,pcie-tunnel = <&usb4_1_pcie_tunnel>; +}; diff --git a/arch/arm64/boot/dts/apple/t8122.dtsi b/arch/arm64/boot/dts/apple/t8122.dtsi index ba3e893a234f5..67b2f620dfc63 100644 --- a/arch/arm64/boot/dts/apple/t8122.dtsi +++ b/arch/arm64/boot/dts/apple/t8122.dtsi @@ -1591,8 +1591,10 @@ usb4_0_acio: cio@701ac0000 { compatible = "apple,t8122-usb4-acio", "apple,t8103-usb4-acio"; reg = <0x7 0x01ac0000 0x0 0xc000>, - <0x7 0x01080000 0x0 0x20000>; - reg-names = "rc", "sram"; + <0x7 0x01080000 0x0 0x20000>, + <0x7 0x01e44000 0x0 0x4000>, + <0x7 0x01100000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "cpu"; mboxes = <&usb4_0_mbox>; resets = <&cio_reset 0>; @@ -1758,8 +1760,10 @@ usb4_1_acio: cio@b01ac0000 { compatible = "apple,t8122-usb4-acio", "apple,t8103-usb4-acio"; reg = <0xb 0x01ac0000 0x0 0xc000>, - <0xb 0x01080000 0x0 0x20000>; - reg-names = "rc", "sram"; + <0xb 0x01080000 0x0 0x20000>, + <0xb 0x01e44000 0x0 0x4000>, + <0xb 0x01100000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "cpu"; mboxes = <&usb4_1_mbox>; resets = <&cio_reset 1>; From 1ddd99f52cca81e732feb02fe5e17cc76fcbeca4 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:21:33 -0500 Subject: [PATCH 06/10] selftests: apple: exercise the J613 PMGR reset witness Compile the production function with missing and foreign domains, regmap errors and each status bit independently injected. Extract provider masks rather than duplicating register constants. Signed-off-by: Satya Benson Assisted-by: LLM --- tools/testing/j613-usb4/run.py | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tools/testing/j613-usb4/run.py diff --git a/tools/testing/j613-usb4/run.py b/tools/testing/j613-usb4/run.py new file mode 100644 index 0000000000000..142b68ca1169c --- /dev/null +++ b/tools/testing/j613-usb4/run.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only +"""Compile the production PMGR off witness against a fault-injecting regmap.""" +import os +from pathlib import Path +import re +import subprocess +import tempfile + +root = Path(__file__).resolve().parents[3] +source = (root / 'drivers/pmdomain/apple/pmgr-pwrstate.c').read_text() +start = source.index('int apple_pmgr_ps_verify_off(') +end = source.index('\nEXPORT_SYMBOL', start) +macros = '\n'.join(re.findall(r'^#define APPLE_PMGR_(?:AUTO_ENABLE|BUSY|PS_ACTUAL|PS_TARGET|PS_LEVELS)\b[^\n]*', source, re.M)) +prefix = r''' +#include +#include +#include +#include +typedef uint32_t u32; +#define BIT(n) (1U << (n)) +#define GENMASK(h, l) ((~0U >> (31-(h))) & (~0U << (l))) +struct generic_pm_domain { void *power_off; }; +struct device { void *pm_domain; }; +struct apple_pmgr_ps { void *regmap; unsigned int offset; }; +static struct apple_pmgr_ps state; +static struct generic_pm_domain domain; +static void apple_pmgr_ps_power_off(void) {} +#define pd_to_genpd(p) ((struct generic_pm_domain *)(p)) +#define genpd_to_apple_pmgr_ps(p) (&state) +#define dev_err(...) ((void)0) +static u32 value; +static int error; +static int regmap_read(void *map, unsigned int offset, u32 *out) +{ *out = value; return error; } +''' +cases = r''' +int main(void) +{ + struct device d = {0}; + assert(apple_pmgr_ps_verify_off(&d) == -ENODEV); + d.pm_domain = &domain; + assert(apple_pmgr_ps_verify_off(&d) == -EOPNOTSUPP); + domain.power_off = apple_pmgr_ps_power_off; + error = -EIO; + assert(apple_pmgr_ps_verify_off(&d) == -EIO); + error = 0; + assert(apple_pmgr_ps_verify_off(&d) == 0); + for (unsigned int bit = 0; bit < 32; bit++) { + value = BIT(bit); + int expected = value & (APPLE_PMGR_PS_LEVELS | APPLE_PMGR_BUSY | + APPLE_PMGR_AUTO_ENABLE) ? -EBUSY : 0; + assert(apple_pmgr_ps_verify_off(&d) == expected); + } + return 0; +} +''' +with tempfile.TemporaryDirectory(prefix='j613-usb4-') as tmp: + t = Path(tmp) + (t / 'test.c').write_text(prefix + macros + '\n' + source[start:end] + cases) + subprocess.run([os.environ.get('CC', 'cc'), '-Wall', '-Werror', + str(t / 'test.c'), '-o', str(t / 'test')], check=True) + subprocess.run([str(t / 'test')], check=True) +print('PASS: production PMGR witness rejects missing/foreign domains, read faults, all live state bits') From e1644365d442023b58710a2b759c0c716037b0a3 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 10 Nov 2026 16:29:24 -0500 Subject: [PATCH 07/10] PCI: apple: share named T8122 MSI resources with host tests Use one aperture selector for PCIe-C admission and its negative tests. Reject unknown apertures rather than borrowing another bridge slice. Signed-off-by: Satya Benson Assisted-by: LLM --- drivers/pci/controller/pcie-apple-t8122.h | 24 ++++++++++++++++++++++ drivers/pci/controller/pcie-apple.c | 15 +++++--------- tools/testing/j613-usb4/run.py | 25 +++++++++++++++++++++++ 3 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 drivers/pci/controller/pcie-apple-t8122.h diff --git a/drivers/pci/controller/pcie-apple-t8122.h b/drivers/pci/controller/pcie-apple-t8122.h new file mode 100644 index 0000000000000..bf0cef030b682 --- /dev/null +++ b/drivers/pci/controller/pcie-apple-t8122.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef PCIE_APPLE_T8122_H +#define PCIE_APPLE_T8122_H + +#define APPLE_T8122_PCIEC0_ECAM 0x730000000ULL +#define APPLE_T8122_PCIEC1_ECAM 0xb30000000ULL +#define APPLE_T8122_PCIEC_AIC_BASE 1075 +#define APPLE_T8122_PCIEC0_MSI_BASE 32 +#define APPLE_T8122_PCIEC1_MSI_BASE 64 + +/* Reject unknown apertures instead of assigning another bridge's slice. */ +static inline int apple_t8122_msi_vector_base(unsigned long long ecam) +{ + switch (ecam) { + case APPLE_T8122_PCIEC0_ECAM: + return APPLE_T8122_PCIEC0_MSI_BASE; + case APPLE_T8122_PCIEC1_ECAM: + return APPLE_T8122_PCIEC1_MSI_BASE; + default: + return -1; + } +} + +#endif diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 967ce0f4b968a..2bbe63bc93055 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -47,6 +47,7 @@ #include "../pci.h" #include "pci-host-common.h" #include "pcie-apple-t8140-bootstrap.h" +#include "pcie-apple-t8122.h" static ATOMIC_NOTIFIER_HEAD(apple_pcie_tunnel_notifiers); @@ -3260,17 +3261,11 @@ static int apple_msi_init(struct apple_pcie *pcie) goto invalid_slice; } } else if (of_machine_is_compatible("apple,t8122")) { - aic_base = 1075; - switch (ecam.start) { - case 0x730000000ULL: - expected_base = 0x20; - break; - case 0xb30000000ULL: - expected_base = 0x40; - break; - default: + aic_base = APPLE_T8122_PCIEC_AIC_BASE; + ret = apple_t8122_msi_vector_base(ecam.start); + if (ret < 0) goto invalid_slice; - } + expected_base = ret; } else if (of_machine_is_compatible("apple,t8132")) { aic_base = 1506; switch (ecam.start) { diff --git a/tools/testing/j613-usb4/run.py b/tools/testing/j613-usb4/run.py index 142b68ca1169c..8515b5e4a7235 100644 --- a/tools/testing/j613-usb4/run.py +++ b/tools/testing/j613-usb4/run.py @@ -62,3 +62,28 @@ str(t / 'test.c'), '-o', str(t / 'test')], check=True) subprocess.run([str(t / 'test')], check=True) print('PASS: production PMGR witness rejects missing/foreign domains, read faults, all live state bits') + +# Use the same aperture selector and constants as PCIe-C admission. +msi = r''' +#include +#include "pcie-apple-t8122.h" +int main(void) +{ + assert(apple_t8122_msi_vector_base(APPLE_T8122_PCIEC0_ECAM) == 32); + assert(apple_t8122_msi_vector_base(APPLE_T8122_PCIEC1_ECAM) == 64); + assert(APPLE_T8122_PCIEC_AIC_BASE + APPLE_T8122_PCIEC0_MSI_BASE == 1107); + assert(APPLE_T8122_PCIEC_AIC_BASE + APPLE_T8122_PCIEC1_MSI_BASE == 1139); + assert(apple_t8122_msi_vector_base(0) < 0); + assert(apple_t8122_msi_vector_base(APPLE_T8122_PCIEC0_ECAM + 1) < 0); + assert(apple_t8122_msi_vector_base(APPLE_T8122_PCIEC1_ECAM - 1) < 0); + return 0; +} +''' +with tempfile.TemporaryDirectory(prefix='j613-msi-') as tmp: + t = Path(tmp) + (t / 'test.c').write_text(msi) + subprocess.run([os.environ.get('CC', 'cc'), '-Wall', '-Werror', + '-I', str(root / 'drivers/pci/controller'), + str(t / 'test.c'), '-o', str(t / 'test')], check=True) + subprocess.run([str(t / 'test')], check=True) +print('PASS: shared T8122 PCIe-C aperture/MSI selector and unknown apertures') From 0f5991d51269f2538b3fb2fab2929290857acfb1 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Wed, 11 Nov 2026 04:06:40 -0500 Subject: [PATCH 08/10] thunderbolt: apple: Export the sleep-quiesce core helper The Apple NHI driver calls tb_apple_sleep_quiesce() from the Thunderbolt core. With CONFIG_USB4=m and CONFIG_USB4_APPLE_SOC=m, these are separate modules and modpost rejects thunderbolt_apple.ko with an undefined symbol. Export the existing helper to GPL modules so the modular configuration links. No quiesce behavior or hardware register access changes. Validated with the J613 production configuration, LLVM 18 Image/modules/ DTBs build and modpost, plus strict checkpatch. Assisted-by: LLM Signed-off-by: Satya Benson --- drivers/thunderbolt/tb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 1fa5ff9b32e0f..4a034783bf0c9 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -3824,6 +3825,7 @@ int tb_apple_sleep_quiesce(struct tb *tb) flush_workqueue(tb->wq); return 0; } +EXPORT_SYMBOL_GPL(tb_apple_sleep_quiesce); static void tb_stop(struct tb *tb) { From 9b89ce2742e2f43abf70dc9d6331d5211406cc9e Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 11 Nov 2026 10:49:43 -0500 Subject: [PATCH 09/10] ci: avoid failing Azure mirror in host and DT checks Both targeted retries failed before validation in Ubuntu apt DNS bootstrap. Use Ubuntu's signed HTTPS archive/security mirror list on the ephemeral runner and fail apt update on repository errors. Keep test/toolchain, permissions, job limits and driver/DT source unchanged. --- .github/workflows/dt-checks.yml | 8 +++++++- .github/workflows/host-tests.yml | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dt-checks.yml b/.github/workflows/dt-checks.yml index a887f663e6955..1c2d88af7bc3e 100644 --- a/.github/workflows/dt-checks.yml +++ b/.github/workflows/dt-checks.yml @@ -50,7 +50,13 @@ jobs: - name: Install the tools run: | - sudo apt-get update -q + # Avoid the hosted runner's Azure mirror after repeated DNS failures. + # Keep signed Ubuntu archive/security suites and fail on update errors. + if [ -f /etc/apt/apt-mirrors.txt ]; then + printf '%s\n' 'https://archive.ubuntu.com/ubuntu/' 'https://security.ubuntu.com/ubuntu/' | \ + sudo tee /etc/apt/apt-mirrors.txt >/dev/null + fi + sudo apt-get update -q -o APT::Update::Error-Mode=any sudo apt-get install -y -q flex bison bc libyaml-dev clang-$CLANG_VERSION lld-$CLANG_VERSION llvm-$CLANG_VERSION swig device-tree-compiler echo "/usr/lib/llvm-$CLANG_VERSION/bin" >> "$GITHUB_PATH" pip install --quiet dtschema yamllint pylibfdt diff --git a/.github/workflows/host-tests.yml b/.github/workflows/host-tests.yml index fd665f948d991..cc947aaf986ea 100644 --- a/.github/workflows/host-tests.yml +++ b/.github/workflows/host-tests.yml @@ -61,7 +61,13 @@ jobs: command -v fdtget >/dev/null || need="$need device-tree-compiler" dpkg -s "libclang-rt-$CLANG_VERSION-dev" >/dev/null 2>&1 || need="$need libclang-rt-$CLANG_VERSION-dev" if [ -n "$need" ]; then - sudo apt-get update -q + # Avoid the hosted runner's Azure mirror after repeated DNS failures. + # Keep signed Ubuntu archive/security suites and fail on update errors. + if [ -f /etc/apt/apt-mirrors.txt ]; then + printf '%s\n' 'https://archive.ubuntu.com/ubuntu/' 'https://security.ubuntu.com/ubuntu/' | \ + sudo tee /etc/apt/apt-mirrors.txt >/dev/null + fi + sudo apt-get update -q -o APT::Update::Error-Mode=any sudo apt-get install -y -q $need fi # The tests call clang, ld.lld, cc and gcc by name. From 972cf33ed4d44015f13ebf80aadcdc6210454292 Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Mon, 16 Nov 2026 04:40:22 -0500 Subject: [PATCH 10/10] dt-bindings: apple: describe the J613 USB4 PCIe-C handoff Describe the T8122 PCIe-C compatible and its eight named resources, and the ACIO post-init power-domain providers. Use valid hyphenated names for the six new J613 USB4 aliases, retaining their node targets and the inherited legacy aliases. The renamed PCIe-C aliases require the legacy-first lookup fallback in aurora-silicon/aura#273, built and adopted with the new DTBs. Do not roll these DTBs out with an older incompatible Stage 2. Signed-off-by: Diljit Singh --- .../devicetree/bindings/pci/apple,pcie.yaml | 33 +++++++++++++++++++ .../thunderbolt/apple,t8103-usb4-acio.yaml | 8 +++++ arch/arm64/boot/dts/apple/t8122-j613.dts | 12 +++---- arch/arm64/boot/dts/apple/t8122-usb4.dtsi | 4 +-- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml index a9fd4822fd127..39ec5dda86d6e 100644 --- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml +++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml @@ -99,6 +99,9 @@ properties: - items: - const: apple,t8112-pciec - const: apple,t8103-pciec + - items: + - const: apple,t8122-pciec + - const: apple,t8103-pciec - const: apple,t6000-pciec - const: apple,t6050-pciec - items: @@ -522,6 +525,15 @@ allOf: - const: debug - const: ltssm - enum: [intr2axi, oe-fabric] + - items: + - const: config + - const: rc + - const: port0 + - const: fabric + - const: debug + - const: ltssm + - const: oe-fabric + - const: intr2axi - items: - const: config - const: rc @@ -547,6 +559,27 @@ allOf: minItems: 3 maxItems: 3 allOf: + - if: + properties: + compatible: + items: + - const: apple,t8122-pciec + - const: apple,t8103-pciec + then: + properties: + reg: + minItems: 8 + maxItems: 8 + reg-names: + items: + - const: config + - const: rc + - const: port0 + - const: fabric + - const: debug + - const: ltssm + - const: oe-fabric + - const: intr2axi - if: properties: compatible: diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml index b1158d39b7ac9..df1dc71379521 100644 --- a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml @@ -108,6 +108,14 @@ properties: apple,pcie-tunnel is present, the domain after them powers its PCIe-C controller and is enabled only after the USB4 PCIe tunnel is active. + post-init-providers: + $ref: /schemas/types.yaml#/definitions/phandle-array + maxItems: 4 + description: + Power-domain suppliers managed explicitly by the router, rather than + required before it can probe, to break their initialization dependency + cycle. On J613 these are the four power domains listed above. + thunderbolt-switch: type: boolean description: diff --git a/arch/arm64/boot/dts/apple/t8122-j613.dts b/arch/arm64/boot/dts/apple/t8122-j613.dts index 17f3982727f46..b35346094bcbc 100644 --- a/arch/arm64/boot/dts/apple/t8122-j613.dts +++ b/arch/arm64/boot/dts/apple/t8122-j613.dts @@ -19,12 +19,12 @@ model = "Apple MacBook Air (13-inch, M3, 2024)"; aliases { - usb4_0_pcie = &usb4_0_pcie; - usb4_0_pcie_port = &usb4_0_pcie_port; - usb4_1_pcie = &usb4_1_pcie; - usb4_1_pcie_port = &usb4_1_pcie_port; - usb4_0_pcie_adapter = &usb4_0_acio; - usb4_1_pcie_adapter = &usb4_1_acio; + usb4-0-pcie = &usb4_0_pcie; + usb4-0-pcie-port = &usb4_0_pcie_port; + usb4-1-pcie = &usb4_1_pcie; + usb4-1-pcie-port = &usb4_1_pcie_port; + usb4-0-pcie-adapter = &usb4_0_acio; + usb4-1-pcie-adapter = &usb4_1_acio; }; /* diff --git a/arch/arm64/boot/dts/apple/t8122-usb4.dtsi b/arch/arm64/boot/dts/apple/t8122-usb4.dtsi index 359236dc07f6b..ce69d7ec74f9c 100644 --- a/arch/arm64/boot/dts/apple/t8122-usb4.dtsi +++ b/arch/arm64/boot/dts/apple/t8122-usb4.dtsi @@ -48,7 +48,7 @@ apple,pciec-kernel-init; /* * m1n1 fills the rc, fabric and debug tunables through the - * usb4_0_pcie alias, but not this one. + * usb4-0-pcie alias, but not this one. */ apple,tunable-oe-fabric = <0x4 0x70007 0x40004>, @@ -148,7 +148,7 @@ apple,pciec-kernel-init; /* * m1n1 fills the rc, fabric and debug tunables through the - * usb4_1_pcie alias, but not this one. + * usb4-1-pcie alias, but not this one. */ apple,tunable-oe-fabric = <0x4 0x70007 0x40004>,