From 66385d79dcc667c707052c8c4abd219e17ca02fe Mon Sep 17 00:00:00 2001 From: Pierre Moreau Date: Sun, 8 Nov 2020 11:55:16 +0100 Subject: [PATCH] nv50: Report actual VRAM size v2: handle vram_size == 0 (Karol) Reviewed-by: Karol Herbst Reviewed-by: Ilia Mirkin Signed-off-by: Pierre Moreau Part-of: --- src/gallium/drivers/nouveau/nouveau_winsys.h | 20 +++++++++++++++++++ .../drivers/nouveau/nv50/nv50_screen.c | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index 94116cccfae..6a0b6774106 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -5,6 +5,7 @@ #include #include "pipe/p_defines.h" +#include "util/os_misc.h" #include "drm-uapi/drm.h" #include @@ -96,4 +97,23 @@ nv50_screen_create(struct nouveau_device *); extern struct nouveau_screen * nvc0_screen_create(struct nouveau_device *); +static inline uint64_t +nouveau_device_get_global_mem_size(struct nouveau_device *dev) +{ + uint64_t size = dev->vram_size; + + if (!size) { + os_get_available_system_memory(&size); + size = MIN2(dev->gart_size, size); + } + + /* cap to 32 bit on nv50 and older */ + if (dev->chipset < 0xc0) + size = MIN2(size, 1ull << 32); + else + size = MIN2(size, 1ull << 40); + + return size; +} + #endif diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index 3931d2e22e5..8a4e57c4bc4 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -569,6 +569,7 @@ nv50_screen_get_compute_param(struct pipe_screen *pscreen, enum pipe_compute_cap param, void *data) { struct nv50_screen *screen = nv50_screen(pscreen); + struct nouveau_device *dev = screen->base.device; #define RET(x) do { \ if (data) \ @@ -586,7 +587,7 @@ nv50_screen_get_compute_param(struct pipe_screen *pscreen, case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: RET((uint64_t []) { 512 }); case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: /* g0-15[] */ - RET((uint64_t []) { 1ULL << 32 }); + RET((uint64_t []) { nouveau_device_get_global_mem_size(dev) }); case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: /* s[] */ RET((uint64_t []) { 16 << 10 }); case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE: /* l[] */