From e4ca97111f1017fd39457f9a0562dad0bb582952 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 8 Dec 2021 15:21:42 -0800 Subject: [PATCH] nouveau: disable fences when running under drm-shim. Otherwise, you get a hang at the end of shader-db. Reviewed-by: Ilia Mirkin Reviewed-by: Karol Herbst Part-of: --- src/gallium/drivers/nouveau/nouveau_fence.c | 6 ++++++ src/gallium/drivers/nouveau/nouveau_screen.c | 2 ++ src/gallium/drivers/nouveau/nouveau_screen.h | 1 + src/nouveau/drm-shim/nouveau_noop.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c b/src/gallium/drivers/nouveau/nouveau_fence.c index 345ef5f66f2..117bce3b5c8 100644 --- a/src/gallium/drivers/nouveau/nouveau_fence.c +++ b/src/gallium/drivers/nouveau/nouveau_fence.c @@ -131,6 +131,12 @@ nouveau_fence_update(struct nouveau_screen *screen, bool flushed) struct nouveau_fence *next = NULL; u32 sequence = screen->fence.update(&screen->base); + /* If running under drm-shim, let all fences be signalled so things run to + * completion (avoids a hang at the end of shader-db). + */ + if (unlikely(screen->disable_fences)) + sequence = screen->fence.sequence; + if (screen->fence.sequence_ack == sequence) return; screen->fence.sequence_ack = sequence; diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index f66ccc2ac1b..7312a5b1f98 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -208,6 +208,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) if (screen->force_enable_cl) glsl_type_singleton_init_or_ref(); + screen->disable_fences = debug_get_bool_option("NOUVEAU_DISABLE_FENCES", false); + /* These must be set before any failure is possible, as the cleanup * paths assume they're responsible for deleting them. */ diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index 9460152eff1..470e1336785 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -74,6 +74,7 @@ struct nouveau_screen { bool prefer_nir; bool force_enable_cl; bool has_svm; + bool disable_fences; void *svm_cutout; size_t svm_cutout_size; diff --git a/src/nouveau/drm-shim/nouveau_noop.c b/src/nouveau/drm-shim/nouveau_noop.c index a93563abc87..c81ccb5be2b 100644 --- a/src/nouveau/drm-shim/nouveau_noop.c +++ b/src/nouveau/drm-shim/nouveau_noop.c @@ -218,6 +218,9 @@ drm_shim_driver_init(void) nouveau_driver_get_device_info(); + /* Ask userspace to consider all fences completed. */ + setenv("NOUVEAU_DISABLE_FENCES", "true", true); + /* nothing looks at the pci id, so fix it to a GTX 780 */ static const char uevent_content[] = "DRIVER=nouveau\n"