iris: Retry DRM_IOCTL_I915_GEM_EXECBUFFER2 on ENOMEM

We are seeing endless DRM_IOCTL_SYNCOBJ_WAIT ioctl when system memory is
under pressured.

Commit f9d8d9acbb ("iris: Avoid abort() if kernel can't allocate
memory") avoids the abort() on ENOMEM by resetting the batch. However,
when there's an ongoing OpenGL query, resetting the batch will make the
snapshots_landed never be flipped, so iris_get_query_result() gets stuck
in the while loop forever.

Since there's no guarantee that the next batch after resetting won't hit
ENOMEM, so instead of resetting the batch, be patient and wait until kernel has
enough memory. Once the batch is submiited and snapshots_landed gets
flipped, iris_get_query_result() can proceed normally.

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6851
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21829>
This commit is contained in:
Kai-Heng Feng 2022-12-29 13:43:27 +08:00 committed by Dylan Baker
parent f73b7aa813
commit f2b262feef
2 changed files with 10 additions and 5 deletions

View file

@ -17239,7 +17239,7 @@
"description": "iris: Retry DRM_IOCTL_I915_GEM_EXECBUFFER2 on ENOMEM",
"nominated": false,
"nomination_type": null,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null
},
@ -38258,4 +38258,4 @@
"main_sha": null,
"because_sha": null
}
]
]

View file

@ -981,9 +981,14 @@ submit_batch(struct iris_batch *batch)
}
int ret = 0;
if (!batch->screen->devinfo->no_hw &&
intel_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf))
ret = -errno;
if (!batch->screen->devinfo->no_hw) {
do {
ret = intel_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
} while (ret && errno == ENOMEM);
if (ret)
ret = -errno;
}
simple_mtx_unlock(bo_deps_lock);