Mesa (master): etnaviv: enable texture upload memory throttling
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Feb 7 18:41:12 UTC 2020
Module: Mesa
Branch: master
Commit: 0c36b1c0dbf2dcb8ded2509bc547a026b9624cc0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c36b1c0dbf2dcb8ded2509bc547a026b9624cc0
Author: Christian Gmeiner <christian.gmeiner at gmail.com>
Date: Fri Feb 7 11:24:55 2020 +0100
etnaviv: enable texture upload memory throttling
Fixes oom-killer during piglit's streaming-texture-upload on a
SolidRun CuBox-i with 2GB of RAM.
Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3745>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3745>
---
src/gallium/drivers/etnaviv/etnaviv_screen.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index dcceddc4729..51154a3df11 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -229,6 +229,22 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
/* Preferences */
case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
return 0;
+ case PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET: {
+ /* etnaviv is being run on systems as small as 256MB total RAM so
+ * we need to provide a sane value for such a device. Limit the
+ * memory budget to min(~3% of pyhiscal memory, 64MB).
+ *
+ * a simple divison by 32 provides the numbers we want.
+ * 256MB / 32 = 8MB
+ * 2048MB / 32 = 64MB
+ */
+ uint64_t system_memory;
+
+ if (!os_get_total_physical_memory(&system_memory))
+ system_memory = 4096 << 20;
+
+ return MIN2(system_memory / 32, 64 * 1024 * 1024);
+ }
case PIPE_CAP_MAX_VARYINGS:
return screen->specs.max_varyings;
More information about the mesa-commit
mailing list