From: Christian Gmeiner Date: Fri, 7 Feb 2020 10:24:55 +0000 (+0100) Subject: etnaviv: enable texture upload memory throttling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c36b1c0dbf2dcb8ded2509bc547a026b9624cc0;p=mesa.git 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 Reviewed-by: Lucas Stach Tested-by: Marge Bot Part-of: --- 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;