From f9d8d9acbb6a620684fb4dac4affe25816587d92 Mon Sep 17 00:00:00 2001 From: Kai-Heng Feng Date: Fri, 4 Jun 2021 12:13:04 +0800 Subject: [PATCH] iris: Avoid abort() if kernel can't allocate memory 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 Part-of: --- src/gallium/drivers/iris/iris_batch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 0e4c414e53a..6e0dbac26f3 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -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);