From f6ba35b02115a9a41b0eb647b8c2f10b2632cf5e Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Thu, 5 Nov 2026 14:37:46 +0200 Subject: [PATCH] thunderbolt: apple: Do not start the NHI without its DART The NHI and its DART are both children of the ACIO and are created together when the router starts. The DART normally binds first, and the driver core defers the NHI until it has. Once the core has stopped waiting for missing suppliers, though (for example, the DART driver is a module that is not loaded yet when a cable is plugged in), the NHI probes without an IOMMU and would hand the hardware physical ring addresses. Refuse to probe an NHI that has iommus but is not attached to an IOMMU domain. Report it through the boot status as well, so that the ACIO fails this start right away with -EPROBE_DEFER instead of waiting for the 10 s NHI boot timeout; the next connection retries. Signed-off-by: Dmitriy Assisted-by: LLM --- drivers/thunderbolt/apple.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index ba7ec0bc0296c..6330140715e2b 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -2052,6 +2053,20 @@ static int apple_nhi_probe(struct platform_device *pdev) goto err; } + /* + * The rings must never run untranslated. The DART is populated with + * the NHI, so it is normally bound first; but once the driver core + * has stopped waiting for missing suppliers (DART driver not loaded + * yet), the NHI would probe without its IOMMU. Defer, and fail the + * ACIO start now instead of letting it wait for the NHI to time out. + */ + if (of_property_present(pdev->dev.of_node, "iommus") && + !device_iommu_mapped(&pdev->dev)) { + dev_warn(&pdev->dev, "DART not bound yet, not starting the NHI\n"); + ret = -EPROBE_DEFER; + goto err; + } + anhi = devm_kzalloc(&pdev->dev, sizeof(*anhi), GFP_KERNEL); if (!anhi) { ret = -ENOMEM;