iris: Avoid abort() if kernel can't allocate memory
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Fri, 4 Jun 2021 04:13:04 +0000 (12:13 +0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 17 Jun 2021 09:04:17 +0000 (09:04 +0000)
When the system doesn't have enough memory, GNOME Shell may be crashed
by iris:
gnome-shell[1161]: iris: Failed to submit batchbuffer: Cannot allocate memory
gnome-shell[1161]: GNOME Shell crashed with signal 6

So don't abort() when kernel can't allocate memory to avoid crashing the
entire desktop.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11178>

src/gallium/drivers/iris/iris_batch.c

index 0e4c414..6e0dbac 100644 (file)
@@ -756,8 +756,9 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line)
     * with a new logical context, and inform iris_context that all state
     * has been lost and needs to be re-initialized.  If this succeeds,
     * dubiously claim success...
+    * Also handle ENOMEM here.
     */
-   if (ret == -EIO && replace_hw_ctx(batch)) {
+   if ((ret == -EIO || ret == -ENOMEM) && replace_hw_ctx(batch)) {
       if (batch->reset->reset) {
          /* Tell gallium frontends the device is lost and it was our fault. */
          batch->reset->reset(batch->reset->data, PIPE_GUILTY_CONTEXT_RESET);