Skip to content

J516S: Qt WebEngine with GPU rendering halts the GPU firmware (a deferred unmap removes a re-imported dma-buf's new mapping) #174

Open

Description

@aronvandepol

Any Qt WebEngine app (Qt's embedded Chromium) with GPU rendering on can halt the GPU firmware. After the halt every GPU client stops rendering until a reboot. With QTWEBENGINE_CHROMIUM_FLAGS=--disable-gpu it never happens. I found it with a word-cloud page in a PyQt6 app (Orange Data Mining's Word Cloud widget, which draws wordcloud2.js in a QWebEngineView). On .19 it halted within 3–63 s on every run, and on .20 the first run halted after 7 s. The Anki halt in #90 is also Qt WebEngine, and the same patch fixes it.

Mac and build

  • MacBook Pro 16" M3 Pro (J516S, G15S)
  • aurora-2026.10.17.20, kernel 7.1.12-2-20261017.20-sep-ARCH, mesa-m3-native-pro 26.1.4.nativepro.20261013-10
  • PyQt6 / PyQt6-WebEngine 6.11.0 (Chromium 140.0.7339.225). Chromium runs its GPU thread inside the app process (ANGLE on OpenGL).

Kernel log at the halt (.20)

asahi 292400000.gpu: M3 firmware error event 4 bytes=[04, 00, ...]
asahi 292400000.gpu: M3 failed work owner: VM=10 process python pid 14070 thread python (error EIO, 2 commands in flight)
asahi 292400000.gpu: M3 fault render VM=10 slot=5 root=0x10141b6c000 draw=5561 batch=2
asahi 292400000.gpu: M3 bank 0 fault=0x81528a8011 address_word=0x21be7b1f6 address=0x86f9ec7d80
asahi 292400000.gpu: M3 fault mapping bank=0 address=0x86f9ec7d80 translation=Err(EFAULT)

Cause

Qt WebEngine hands each rendered web frame to Qt as a dma-buf, and Qt keeps two of them in rotation. Every frame Qt releases its GEM handle for the old buffer (DRM_IOCTL_GEM_CLOSE). About 5 ms later it imports the same dma-buf again (PRIME_FD_TO_HANDLE), which gives back the same GEM object, and maps it at the same GPU address. Traced on .19 with an LD_PRELOAD logger on the DRM ioctls:

GEM_CLOSE    h=16
PRIME_IMPORT h=16
VM_BIND MAP  h=16 addr=0x86ffdd8000 range=0x1e4000
SUBMIT ...

The GEM close lands while GPU jobs on that VM are still running. In that case drop_mappings() in mmu.rs does not unmap right away. It queues the object in job_lifetime.closed_objects. When the last running job retires, M3VmJobGuard::drop runs drop_mappings() on the queued object, and that removes every mapping of the object, including the new one made after the re-import. The next job that reads the buffer hits an unmapped address and the firmware halts.

Check from userspace on the stock kernel: the same LD_PRELOAD library, with the GEM_CLOSE ioctl for imported handles swallowed (the handle stays open, so the kernel never queues the deferred unmap), ran the repro for the full 120 s with no fault.

integration/aurora has since moved to 7.2.10 and split mmu.rs. The same sequence is there under new names: drop_mappings() in mmu/lifetime.rs queues the object in state.objects, drain_mappings() later calls drop_mappings_now(), and neither bind path takes the object off the list. I have not run a 7.2.10 kernel.

Repro without Orange: PyQt6-WebEngine plus wordcloud2.js and wordcloud-script.js from orange3-text. It shows the cloud and redraws it every 6 s. On the stock kernel it halts the GPU within a minute.

qwe_wordcloud.py
"""Minimal repro of Orange's Word Cloud: wordcloud2.js in PyQt6 QtWebEngine.

Usage: <orange python> qwe_wordcloud.py RESDIR SECONDS [chromium flags...]
RESDIR holds wordcloud2.js and wordcloud-script.js copied from orange3-text.
Redraws the cloud every 6 s (as resizing Orange's widget does) and logs each.
"""
import os
import random
import sys
import time

resdir, seconds = sys.argv[1], int(sys.argv[2])
os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = " ".join(sys.argv[3:])

from PyQt6.QtCore import QTimer, QUrl  # noqa: E402
from PyQt6.QtWebEngineWidgets import QWebEngineView  # noqa: E402
from PyQt6.QtWidgets import QApplication  # noqa: E402

random.seed(1)
syll = ["ka", "ro", "min", "tel", "sun", "pa", "do", "rik", "ve", "lo", "chu", "han"]
words = sorted({"".join(random.choice(syll) for _ in range(random.randint(1, 4))) for _ in range(300)})
wordlist = [[w, random.randint(4, 60)] for w in words][:200]
colors = {w: random.choice(["#1f77b4", "#d62728", "#2ca02c", "#9467bd"]) for w, _ in wordlist}
area = sum(len(w) * s for w, s in wordlist)

HTML = """<!doctype html><html><head><meta charset="utf-8"><style>
html, body {margin:0px;padding:0px;width:100%;height:100%;cursor:default;
 -webkit-user-select:none;user-select:none;overflow:hidden;}
</style></head><body id="canvas">
<script src="wordcloud2.js"></script><script src="wordcloud-script.js"></script>
</body></html>"""

app = QApplication(sys.argv[:1])
view = QWebEngineView()
view.resize(1400, 900)
view.setWindowTitle("qwe-wordcloud")
view.show()
t0 = time.monotonic()
n = 0


def log(msg):
    print(f"{time.strftime('%H:%M:%S')} +{time.monotonic() - t0:5.1f}s {msg}", flush=True)


def setup(ok):
    log(f"page loaded ok={ok} flags={os.environ['QTWEBENGINE_CHROMIUM_FLAGS']!r}")
    js = (f"colorList = {colors}; OPTIONS['color'] = function (w) {{ return colorList[w]; }};"
          f"textAreaEstimation = {area}; OPTIONS['minRotation'] = -{3.14159/4};"
          f"OPTIONS['maxRotation'] = {3.14159/4}; OPTIONS['rotateRatio'] = 1;"
          f"OPTIONS['list'] = {wordlist}; window.LAST = -1; window.DONE = 0;"
          "document.getElementById('canvas').addEventListener('wordcloudstop', function () {"
          " window.DONE++; window.LAST = document.getElementsByTagName('span').length; });")
    view.page().runJavaScript(js)
    redraw()
    timer.start(6000)


def redraw():
    global n
    n += 1
    view.page().runJavaScript("var r = [WordCloud.isSupported, window.DONE, window.LAST]; redrawWordCloud(); r",
                              lambda r: log(f"redraw {n}: supported/finished/spans of last={r}"))


timer = QTimer()
timer.timeout.connect(redraw)
view.loadFinished.connect(setup)
view.setHtml(HTML, QUrl.fromLocalFile(os.path.abspath(resdir) + "/"))
QTimer.singleShot(seconds * 1000, lambda: (log("done, no crash"), app.quit()))
sys.exit(app.exec())

Fix for .20: the patch below takes the object off closed_objects when it is bound again. It applies to the .20 source (c46d7dc). A PR against the 7.2.10 branch follows once I have ported and tested it there.

asahi-m3-cancel-deferred-close.patch
diff --git c/drivers/gpu/drm/asahi/mmu.rs w/drivers/gpu/drm/asahi/mmu.rs
index e39a328f5394..9b85fd2cfe19 100644
--- c/drivers/gpu/drm/asahi/mmu.rs
+++ w/drivers/gpu/drm/asahi/mmu.rs
@@ -2132,6 +2132,19 @@ pub(crate) fn bind_object(
             ..Default::default()
         };
 
+        // A GEM close while jobs were active queued this object for a deferred
+        // drop_mappings(). Userspace has now reopened it (a dma-buf imported
+        // again returns the same object) and is mapping it again: the deferred
+        // drop would remove this new mapping when the last job retires, and the
+        // next job reading it faults. Cancel the pending drop. Any mapping left
+        // over from before the close goes with the object's next close.
+        if let Some(job_lifetime) = &self.job_lifetime {
+            job_lifetime
+                .lock()
+                .closed_objects
+                .retain(|object| !core::ptr::eq(&**object, gem));
+        }
+
         let vm_bo = self.inner.obtain_bo(gem)?;
         {
             let mut vm_bo_guard = vm_bo.inner().inner.lock();

Tested on J516S, aurora-2026.10.17.20 plus this patch, booted 2026-10-21:

  • word-cloud repro: 120 s, 20 redraws, no fault, no software-rendering fallback in the app log. Stock .20 halted after 7 s.
  • clean boot: 0 failed units, panel at 120 Hz, no Oops or firmware errors in the kernel log.
  • on .19 plus the same patch (2026-10-16): Orange's Word Cloud and Anki reviews, both with Qt WebEngine on the GPU, no fault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions