diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2013-03-03 22:34:38 +0100 |
---|---|---|
committer | Marcin Slusarz <marcin.slusarz@gmail.com> | 2013-03-26 21:08:03 +0100 |
commit | f92d7969bf6ba636d193423cf2388956badde3ff (patch) | |
tree | faed372387963e5796f89ab826aa775aa1abf947 | |
parent | 284421a56921337aaabcec7ad2790034249c7b31 (diff) |
nouveau: add a way to override single pushbuffer memory limits
Currently single pushbuffer can take up to 80% of VRAM and 80% of GART.
As this value seems to be arbitrary (and user may need to set it differently)
this patch adds support for 2 environment variables:
NOUVEAU_LIBDRM_VRAM_LIMIT_PERCENT (default 80)
NOUVEAU_LIBDRM_GART_LIMIT_PERCENT (default 80)
which will let users override pushbuffer VRAM/GART limits.
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
-rw-r--r-- | nouveau/nouveau.c | 18 | ||||
-rw-r--r-- | nouveau/private.h | 1 | ||||
-rw-r--r-- | nouveau/pushbuf.c | 6 |
3 files changed, 21 insertions, 4 deletions
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c index 9b32e319..ee7893b3 100644 --- a/nouveau/nouveau.c +++ b/nouveau/nouveau.c @@ -77,6 +77,7 @@ nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev) uint64_t chipset, vram, gart, bousage; drmVersionPtr ver; int ret; + char *tmp; #ifdef DEBUG debug_init(getenv("NOUVEAU_LIBDRM_DEBUG")); @@ -114,14 +115,27 @@ nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev) nvdev->have_bo_usage = (bousage != 0); nvdev->close = close; + + tmp = getenv("NOUVEAU_LIBDRM_VRAM_LIMIT_PERCENT"); + if (tmp) + nvdev->vram_limit_percent = atoi(tmp); + else + nvdev->vram_limit_percent = 80; + tmp = getenv("NOUVEAU_LIBDRM_GART_LIMIT_PERCENT"); + if (tmp) + nvdev->gart_limit_percent = atoi(tmp); + else + nvdev->gart_limit_percent = 80; DRMINITLISTHEAD(&nvdev->bo_list); nvdev->base.object.oclass = NOUVEAU_DEVICE_CLASS; nvdev->base.lib_version = 0x01000000; nvdev->base.chipset = chipset; nvdev->base.vram_size = vram; nvdev->base.gart_size = gart; - nvdev->base.vram_limit = (nvdev->base.vram_size * 80) / 100; - nvdev->base.gart_limit = (nvdev->base.gart_size * 80) / 100; + nvdev->base.vram_limit = + (nvdev->base.vram_size * nvdev->vram_limit_percent) / 100; + nvdev->base.gart_limit = + (nvdev->base.gart_size * nvdev->gart_limit_percent) / 100; *pdev = &nvdev->base; return 0; diff --git a/nouveau/private.h b/nouveau/private.h index 8a5cb261..60714b8e 100644 --- a/nouveau/private.h +++ b/nouveau/private.h @@ -99,6 +99,7 @@ struct nouveau_device_priv { uint32_t *client; int nr_client; bool have_bo_usage; + int gart_limit_percent, vram_limit_percent; }; static inline struct nouveau_device_priv * diff --git a/nouveau/pushbuf.c b/nouveau/pushbuf.c index e720a082..0fd0c47a 100644 --- a/nouveau/pushbuf.c +++ b/nouveau/pushbuf.c @@ -347,8 +347,10 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct nouveau_object *chan) &req, sizeof(req)); nvpb->suffix0 = req.suffix0; nvpb->suffix1 = req.suffix1; - dev->vram_limit = (req.vram_available * 80) / 100; - dev->gart_limit = (req.gart_available * 80) / 100; + dev->vram_limit = (req.vram_available * + nouveau_device(dev)->vram_limit_percent) / 100; + dev->gart_limit = (req.gart_available * + nouveau_device(dev)->gart_limit_percent) / 100; #else if (dbg_on(31)) ret = -EINVAL; |