Skip to contentSkip to conversation

nouveau: support for custom VRAM domains

PATCH Superseded Alexandre Courbot 5 participants 8 messages Nov 19, 2014 – Nov 20, 2014 3 messages not in the archive Tegra architecture support

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover nouveau: support for custom VRAM domains

This series is to allow NVIDIA chips with shared memory to operate more efficiently (and to operate at all once we disable VRAM from the kernel driver) by allowing nouveau_screen to specify a domain to use for objects originally allocated into VRAM. If the domain is not overridden, the default NOUVEAU_BO_VRAM is used. A NV_VRAM_DOMAIN() macro is then introduced to be used in place of NOUVEAU_BO_VRAM when allocating objects, so the right domain for the chip is used.

Doing so greatly simplifies the equation of memory management on shared- memory devices, since we don't have to simulate non-existent VRAM memory. In that respect it seems to be the right thing to do, and all things taken is not very intrusive.

Tested on GK20A with Wayland and several EGL clients running, and working fine.

Changes since v1:
- When using GART as the VRAM domain, move all vidmem bindings to sysmem and set vidmem_bindings to 0.

Alexandre Courbot (3):
nouveau: support for custom VRAM domains
nvc0: use NV_VRAM_DOMAIN() macro
gk20a: use NOUVEAU_BO_GART as VRAM domain

 src/gallium/drivers/nouveau/nouveau_buffer.c       |  6 ++---
 src/gallium/drivers/nouveau/nouveau_screen.c       |  6 +++++
 src/gallium/drivers/nouveau/nouveau_screen.h       |  4 ++++
 src/gallium/drivers/nouveau/nv50/nv50_miptree.c    |  4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_compute.c    |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c    |  4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c    |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c    |  8 +++----
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c     | 27 +++++++++++++++++-----
 .../drivers/nouveau/nvc0/nvc0_shader_state.c       |  2 +-
 .../drivers/nouveau/nvc0/nvc0_state_validate.c     |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_tex.c        |  2 +-
 src/gallium/drivers/nouveau/nvc0/nve4_compute.c    |  2 +-
 13 files changed, 47 insertions(+), 24 deletions(-)
Signature · 1 line
2.1.3

A message that is not in the archive (sent off-list or not yet received): 1416375705-14068-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH v2 1/3 nouveau: support for custom VRAM domains

Some NVIDIA chips (e.g. GK20A) do not embed VRAM of their own and have complete shared access to system memory. For these systems, allocating objects in VRAM might lead to unneeded copies and sub-optimal memory management. It will also lead to errors if the kernel does not allow VRAM objects allocations.

This patch adds a vram_domain member to struct nouveau_screen that can optionally be initialized to an alternative domain to use for VRAM allocations (most likely, NOUVEAU_BO_GART to allocate everything in system memory). If not initialized, the default NOUVEAU_BO_VRAM domain is used.

Code that allocates GPU objects is then expected to use the NV_VRAM_DOMAIN() macro in place of NOUVEAU_BO_VRAM to ensure correct behavior on VRAM-less chips.

---
 src/gallium/drivers/nouveau/nouveau_screen.c | 6 ++++++
 src/gallium/drivers/nouveau/nouveau_screen.h | 4 ++++
 2 files changed, 10 insertions(+)
src/gallium/drivers/nouveau/nouveau_screen.c +6 -0
index 517978d88588..e4598c3fd24f 100644
@@ -158,6 +158,12 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
 		size = sizeof(nvc0_data);
 	}
 
+	/*
+	 * Set default VRAM domain if not overridden
+	 */
+	if (!screen->vram_domain)
+		screen->vram_domain = NOUVEAU_BO_VRAM;
+
 	ret = nouveau_object_new(&dev->object, 0, NOUVEAU_FIFO_CHANNEL_CLASS,
 				 data, size, &screen->channel);
 	if (ret)
src/gallium/drivers/nouveau/nouveau_screen.h +4 -0
index cf06f7e88aa0..30041b271c94 100644
@@ -51,6 +51,8 @@ struct nouveau_screen {
 
 	boolean hint_buf_keep_sysmem_copy;
 
+	unsigned vram_domain;
+
 	struct {
 		unsigned profiles_checked;
 		unsigned profiles_present;
@@ -94,6 +96,8 @@ struct nouveau_screen {
 #endif
 };
 
+#define NV_VRAM_DOMAIN(screen) ((screen)->vram_domain)
+
 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
 # define NOUVEAU_DRV_STAT(s, n, v) do {         \
       (s)->stats.named.n += (v);               \
Signature · 1 line
2.1.3
#3 lore raw

PATCH v2 2/3 nvc0: use NV_VRAM_DOMAIN() macro

In reply to a message not in the archive

Use the newly-introduced NV_VRAM_DOMAIN() macro to support alternative VRAM domains for chips that do not use dedicated video memory.

---
 src/gallium/drivers/nouveau/nouveau_buffer.c           |  6 ++----
 src/gallium/drivers/nouveau/nv50/nv50_miptree.c        |  4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_compute.c        |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c        |  4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c        |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c        |  8 ++++----
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c         | 12 ++++++------
 src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c   |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_tex.c            |  2 +-
 src/gallium/drivers/nouveau/nvc0/nve4_compute.c        |  2 +-
 11 files changed, 22 insertions(+), 24 deletions(-)
src/gallium/drivers/nouveau/nouveau_buffer.c +2 -4
index 49ff100c4ece..4c21691ee671 100644
@@ -658,13 +658,11 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
       switch (buffer->base.usage) {
       case PIPE_USAGE_DEFAULT:
       case PIPE_USAGE_IMMUTABLE:
-         buffer->domain = NOUVEAU_BO_VRAM;
-         break;
       case PIPE_USAGE_DYNAMIC:
          /* For most apps, we'd have to do staging transfers to avoid sync
           * with this usage, and GART -> GART copies would be suboptimal.
           */
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
          break;
       case PIPE_USAGE_STAGING:
       case PIPE_USAGE_STREAM:
@@ -676,7 +674,7 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
       }
    } else {
       if (buffer->base.bind & screen->vidmem_bindings)
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
       else
       if (buffer->base.bind & screen->sysmem_bindings)
          buffer->domain = NOUVEAU_BO_GART;
src/gallium/drivers/nouveau/nv50/nv50_miptree.c +2 -2
index 1aacaec89acf..ddff508c475c 100644
@@ -359,7 +359,7 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    if (!bo_config.nv50.memtype && (pt->bind & PIPE_BIND_SHARED))
       mt->base.domain = NOUVEAU_BO_GART;
    else
-      mt->base.domain = NOUVEAU_BO_VRAM;
+      mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
 
    bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP;
    if (mt->base.base.bind & (PIPE_BIND_CURSOR | PIPE_BIND_DISPLAY_TARGET))
@@ -401,7 +401,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen,
       FREE(mt);
       return NULL;
    }
-   mt->base.domain = NOUVEAU_BO_VRAM;
+   mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
    mt->base.address = mt->base.bo->offset;
 
    mt->base.base = *templ;
src/gallium/drivers/nouveau/nvc0/nvc0_compute.c +1 -1
index ad287a2af6b6..56fc83d3679f 100644
@@ -57,7 +57,7 @@ nvc0_screen_compute_setup(struct nvc0_screen *screen,
       return ret;
    }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 1 << 12, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 0, 1 << 12, NULL,
                         &screen->parm);
    if (ret)
       return ret;
src/gallium/drivers/nouveau/nvc0/nvc0_context.c +2 -2
index b33a6731a1c0..a0189f528e6f 100644
@@ -322,7 +322,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
 
    /* add permanently resident buffers to bufctxts */
 
-   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD;
+   flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD;
 
    BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->text);
    BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->uniform_bo);
@@ -333,7 +333,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
       BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->parm);
    }
 
-   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
+   flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RDWR;
 
    if (screen->poly_cache)
       BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->poly_cache);
src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c +1 -1
index 1beda7d4a2c8..3afde38e71ba 100644
@@ -302,7 +302,7 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
    if (!bo_config.nvc0.memtype && (pt->usage == PIPE_USAGE_STAGING || pt->bind & PIPE_BIND_SHARED))
       mt->base.domain = NOUVEAU_BO_GART;
    else
-      mt->base.domain = NOUVEAU_BO_VRAM;
+      mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
 
    bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP;
 
src/gallium/drivers/nouveau/nvc0/nvc0_program.c +4 -4
index 21be8b7240ea..7600dc4e7208 100644
@@ -734,12 +734,12 @@ nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog)
 
    if (!is_cp)
       nvc0->base.push_data(&nvc0->base, screen->text, prog->code_base,
-                           NOUVEAU_BO_VRAM, NVC0_SHADER_HEADER_SIZE, prog->hdr);
+                           NV_VRAM_DOMAIN(&screen->base), NVC0_SHADER_HEADER_SIZE, prog->hdr);
    nvc0->base.push_data(&nvc0->base, screen->text, code_pos,
-                        NOUVEAU_BO_VRAM, prog->code_size, prog->code);
+                        NV_VRAM_DOMAIN(&screen->base), prog->code_size, prog->code);
    if (prog->immd_size)
       nvc0->base.push_data(&nvc0->base,
-                           screen->text, prog->immd_base, NOUVEAU_BO_VRAM,
+                           screen->text, prog->immd_base, NV_VRAM_DOMAIN(&screen->base),
                            prog->immd_size, prog->immd_data);
 
    BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(MEM_BARRIER), 1);
@@ -770,7 +770,7 @@ nvc0_program_library_upload(struct nvc0_context *nvc0)
       return;
 
    nvc0->base.push_data(&nvc0->base,
-                        screen->text, screen->lib_code->start, NOUVEAU_BO_VRAM,
+                        screen->text, screen->lib_code->start, NV_VRAM_DOMAIN(&screen->base),
                         size, code);
    /* no need for a memory barrier, will be emitted with first program */
 }
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +6 -6
index 2a759311bf76..506165d179de 100644
@@ -570,7 +570,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
 
    size = align(size, 1 << 17);
 
-   ret = nouveau_bo_new(screen->base.device, NOUVEAU_BO_VRAM, 1 << 17, size,
+   ret = nouveau_bo_new(screen->base.device, NV_VRAM_DOMAIN(&screen->base), 1 << 17, size,
                         NULL, &bo);
    if (ret) {
       NOUVEAU_ERR("failed to allocate TLS area, size: 0x%"PRIx64"\n", size);
@@ -812,7 +812,7 @@ nvc0_screen_create(struct nouveau_device *dev)
 
    nvc0_magic_3d_init(push, screen->eng3d->oclass);
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 20, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
                         &screen->text);
    if (ret)
       goto fail;
@@ -822,12 +822,12 @@ nvc0_screen_create(struct nouveau_device *dev)
     */
    nouveau_heap_init(&screen->text_heap, 0, (1 << 20) - 0x100);
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 12, 6 << 16, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 12, 6 << 16, NULL,
                         &screen->uniform_bo);
    if (ret)
       goto fail;
 
-   PUSH_REFN (push, screen->uniform_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+   PUSH_REFN (push, screen->uniform_bo, NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_WR);
 
    for (i = 0; i < 5; ++i) {
       /* TIC and TSC entries for each unit (nve4+ only) */
@@ -898,7 +898,7 @@ nvc0_screen_create(struct nouveau_device *dev)
    PUSH_DATA (push, 0);
 
    if (screen->eng3d->oclass < GM107_3D_CLASS) {
-      ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 20, NULL,
+      ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
                            &screen->poly_cache);
       if (ret)
          goto fail;
@@ -909,7 +909,7 @@ nvc0_screen_create(struct nouveau_device *dev)
       PUSH_DATA (push, 3);
    }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 17, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 17, NULL,
                         &screen->txc);
    if (ret)
       goto fail;
src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c +1 -1
index 1000d8286d77..3fcca1671c8c 100644
@@ -34,7 +34,7 @@ nvc0_program_update_context_state(struct nvc0_context *nvc0,
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
 
    if (prog && prog->need_tls) {
-      const uint32_t flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
+      const uint32_t flags = NV_VRAM_DOMAIN(&nvc0->screen->base) | NOUVEAU_BO_RDWR;
       if (!nvc0->state.tls_required)
          BCTX_REFN_bo(nvc0->bufctx_3d, TLS, flags, nvc0->screen->tls);
       nvc0->state.tls_required |= 1 << stage;
src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +1 -1
index 25a3232b48d9..696eacaa1e20 100644
@@ -439,7 +439,7 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
                BEGIN_NVC0(push, NVC0_3D(CB_BIND(s)), 1);
                PUSH_DATA (push, (0 << 4) | 1);
             }
-            nvc0_cb_push(&nvc0->base, bo, NOUVEAU_BO_VRAM,
+            nvc0_cb_push(&nvc0->base, bo, NV_VRAM_DOMAIN(&nvc0->screen->base),
                          base, nvc0->state.uniform_buffer_bound[s],
                          0, (size + 3) / 4,
                          nvc0->constbuf[s][0].u.data);
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c +1 -1
index db6b6036a72d..dc4389d7432f 100644
@@ -396,7 +396,7 @@ nvc0_validate_tsc(struct nvc0_context *nvc0, int s)
          tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc);
 
          nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->txc,
-                               65536 + tsc->id * 32, NOUVEAU_BO_VRAM,
+                               65536 + tsc->id * 32, NV_VRAM_DOMAIN(&nvc0->screen->base),
                                32, tsc->tsc);
          need_flush = TRUE;
       }
src/gallium/drivers/nouveau/nvc0/nve4_compute.c +1 -1
index f243316b899c..fce02a7cc576 100644
@@ -63,7 +63,7 @@ nve4_screen_compute_setup(struct nvc0_screen *screen,
       return ret;
    }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, NVE4_CP_PARAM_SIZE, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 0, NVE4_CP_PARAM_SIZE, NULL,
                         &screen->parm);
    if (ret)
       return ret;
Signature · 6 lines
2.1.3

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1416375705-14068-3-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org

#5 lore raw

Re: [PATCH v2 2/3] nvc0: use NV_VRAM_DOMAIN() macro

Quoted 38 lines · Alexandre Courbot

Use the newly-introduced NV_VRAM_DOMAIN() macro to support alternative VRAM domains for chips that do not use dedicated video memory.

---
 src/gallium/drivers/nouveau/nouveau_buffer.c           |  6 ++----
 src/gallium/drivers/nouveau/nv50/nv50_miptree.c        |  4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_compute.c        |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c        |  4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c        |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c        |  8 ++++----
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c         | 12 ++++++------
 src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c   |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_tex.c            |  2 +-
 src/gallium/drivers/nouveau/nvc0/nve4_compute.c        |  2 +-
 11 files changed, 22 insertions(+), 24 deletions(-)
src/gallium/drivers/nouveau/nouveau_buffer.c +1 -3
index 49ff100c4ece..4c21691ee671 100644
@@ -658,13 +658,11 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
       switch (buffer->base.usage) {
       case PIPE_USAGE_DEFAULT:
       case PIPE_USAGE_IMMUTABLE:
-         buffer->domain = NOUVEAU_BO_VRAM;
-         break;
       case PIPE_USAGE_DYNAMIC:
          /* For most apps, we'd have to do staging transfers to avoid sync
           * with this usage, and GART -> GART copies would be suboptimal.
           */
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
          break;
       case PIPE_USAGE_STAGING:
       case PIPE_USAGE_STREAM:

src/gallium/drivers/nouveau/nouveau_buffer.c nouveau_buffer_create(struct pipe_screen *pscreen, · line 680

Quoted 8 lines
src/gallium/drivers/nouveau/nouveau_buffer.c +1 -1
@@ -676,7 +674,7 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
       }
    } else {
       if (buffer->base.bind & screen->vidmem_bindings)
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
       else
       if (buffer->base.bind & screen->sysmem_bindings)
          buffer->domain = NOUVEAU_BO_GART;

Both of these changes should be unnecessary if vidmem_bindings is cleared out, right?

Quoted 207 lines
src/gallium/drivers/nouveau/nv50/nv50_miptree.c +2 -2
index 1aacaec89acf..ddff508c475c 100644
@@ -359,7 +359,7 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    if (!bo_config.nv50.memtype && (pt->bind & PIPE_BIND_SHARED))
       mt->base.domain = NOUVEAU_BO_GART;
    else
-      mt->base.domain = NOUVEAU_BO_VRAM;
+      mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
 
    bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP;
    if (mt->base.base.bind & (PIPE_BIND_CURSOR | PIPE_BIND_DISPLAY_TARGET))
@@ -401,7 +401,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen,
       FREE(mt);
       return NULL;
    }
-   mt->base.domain = NOUVEAU_BO_VRAM;
+   mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
    mt->base.address = mt->base.bo->offset;
 
    mt->base.base = *templ;
src/gallium/drivers/nouveau/nvc0/nvc0_compute.c +1 -1
index ad287a2af6b6..56fc83d3679f 100644
@@ -57,7 +57,7 @@ nvc0_screen_compute_setup(struct nvc0_screen *screen,
       return ret;
    }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 1 << 12, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 0, 1 << 12, NULL,
                         &screen->parm);
    if (ret)
       return ret;
src/gallium/drivers/nouveau/nvc0/nvc0_context.c +2 -2
index b33a6731a1c0..a0189f528e6f 100644
@@ -322,7 +322,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
 
    /* add permanently resident buffers to bufctxts */
 
-   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD;
+   flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD;
 
    BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->text);
    BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->uniform_bo);
@@ -333,7 +333,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
       BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->parm);
    }
 
-   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
+   flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RDWR;
 
    if (screen->poly_cache)
       BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->poly_cache);
src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c +1 -1
index 1beda7d4a2c8..3afde38e71ba 100644
@@ -302,7 +302,7 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
    if (!bo_config.nvc0.memtype && (pt->usage == PIPE_USAGE_STAGING || pt->bind & PIPE_BIND_SHARED))
       mt->base.domain = NOUVEAU_BO_GART;
    else
-      mt->base.domain = NOUVEAU_BO_VRAM;
+      mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
 
    bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP;
 
src/gallium/drivers/nouveau/nvc0/nvc0_program.c +4 -4
index 21be8b7240ea..7600dc4e7208 100644
@@ -734,12 +734,12 @@ nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog)
 
    if (!is_cp)
       nvc0->base.push_data(&nvc0->base, screen->text, prog->code_base,
-                           NOUVEAU_BO_VRAM, NVC0_SHADER_HEADER_SIZE, prog->hdr);
+                           NV_VRAM_DOMAIN(&screen->base), NVC0_SHADER_HEADER_SIZE, prog->hdr);
    nvc0->base.push_data(&nvc0->base, screen->text, code_pos,
-                        NOUVEAU_BO_VRAM, prog->code_size, prog->code);
+                        NV_VRAM_DOMAIN(&screen->base), prog->code_size, prog->code);
    if (prog->immd_size)
       nvc0->base.push_data(&nvc0->base,
-                           screen->text, prog->immd_base, NOUVEAU_BO_VRAM,
+                           screen->text, prog->immd_base, NV_VRAM_DOMAIN(&screen->base),
                            prog->immd_size, prog->immd_data);
 
    BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(MEM_BARRIER), 1);
@@ -770,7 +770,7 @@ nvc0_program_library_upload(struct nvc0_context *nvc0)
       return;
 
    nvc0->base.push_data(&nvc0->base,
-                        screen->text, screen->lib_code->start, NOUVEAU_BO_VRAM,
+                        screen->text, screen->lib_code->start, NV_VRAM_DOMAIN(&screen->base),
                         size, code);
    /* no need for a memory barrier, will be emitted with first program */
 }
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +6 -6
index 2a759311bf76..506165d179de 100644
@@ -570,7 +570,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
 
    size = align(size, 1 << 17);
 
-   ret = nouveau_bo_new(screen->base.device, NOUVEAU_BO_VRAM, 1 << 17, size,
+   ret = nouveau_bo_new(screen->base.device, NV_VRAM_DOMAIN(&screen->base), 1 << 17, size,
                         NULL, &bo);
    if (ret) {
       NOUVEAU_ERR("failed to allocate TLS area, size: 0x%"PRIx64"\n", size);
@@ -812,7 +812,7 @@ nvc0_screen_create(struct nouveau_device *dev)
 
    nvc0_magic_3d_init(push, screen->eng3d->oclass);
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 20, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
                         &screen->text);
    if (ret)
       goto fail;
@@ -822,12 +822,12 @@ nvc0_screen_create(struct nouveau_device *dev)
     */
    nouveau_heap_init(&screen->text_heap, 0, (1 << 20) - 0x100);
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 12, 6 << 16, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 12, 6 << 16, NULL,
                         &screen->uniform_bo);
    if (ret)
       goto fail;
 
-   PUSH_REFN (push, screen->uniform_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+   PUSH_REFN (push, screen->uniform_bo, NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_WR);
 
    for (i = 0; i < 5; ++i) {
       /* TIC and TSC entries for each unit (nve4+ only) */
@@ -898,7 +898,7 @@ nvc0_screen_create(struct nouveau_device *dev)
    PUSH_DATA (push, 0);
 
    if (screen->eng3d->oclass < GM107_3D_CLASS) {
-      ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 20, NULL,
+      ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
                            &screen->poly_cache);
       if (ret)
          goto fail;
@@ -909,7 +909,7 @@ nvc0_screen_create(struct nouveau_device *dev)
       PUSH_DATA (push, 3);
    }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 17, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 17, NULL,
                         &screen->txc);
    if (ret)
       goto fail;
src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c +1 -1
index 1000d8286d77..3fcca1671c8c 100644
@@ -34,7 +34,7 @@ nvc0_program_update_context_state(struct nvc0_context *nvc0,
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
 
    if (prog && prog->need_tls) {
-      const uint32_t flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
+      const uint32_t flags = NV_VRAM_DOMAIN(&nvc0->screen->base) | NOUVEAU_BO_RDWR;
       if (!nvc0->state.tls_required)
          BCTX_REFN_bo(nvc0->bufctx_3d, TLS, flags, nvc0->screen->tls);
       nvc0->state.tls_required |= 1 << stage;
src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +1 -1
index 25a3232b48d9..696eacaa1e20 100644
@@ -439,7 +439,7 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
                BEGIN_NVC0(push, NVC0_3D(CB_BIND(s)), 1);
                PUSH_DATA (push, (0 << 4) | 1);
             }
-            nvc0_cb_push(&nvc0->base, bo, NOUVEAU_BO_VRAM,
+            nvc0_cb_push(&nvc0->base, bo, NV_VRAM_DOMAIN(&nvc0->screen->base),
                          base, nvc0->state.uniform_buffer_bound[s],
                          0, (size + 3) / 4,
                          nvc0->constbuf[s][0].u.data);
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c +1 -1
index db6b6036a72d..dc4389d7432f 100644
@@ -396,7 +396,7 @@ nvc0_validate_tsc(struct nvc0_context *nvc0, int s)
          tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc);
 
          nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->txc,
-                               65536 + tsc->id * 32, NOUVEAU_BO_VRAM,
+                               65536 + tsc->id * 32, NV_VRAM_DOMAIN(&nvc0->screen->base),
                                32, tsc->tsc);
          need_flush = TRUE;
       }
src/gallium/drivers/nouveau/nvc0/nve4_compute.c +1 -2
index f243316b899c..fce02a7cc576 100644
@@ -63,7 +63,7 @@ nve4_screen_compute_setup(struct nvc0_screen *screen,
       return ret;
    }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, NVE4_CP_PARAM_SIZE, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 0, NVE4_CP_PARAM_SIZE, NULL,
                         &screen->parm);
    if (ret)
       return ret;
--
Quoted 2 lines

2.1.3

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#6 lore raw

Re: [PATCH v2 2/3] nvc0: use NV_VRAM_DOMAIN() macro

Quoted 42 lines · Ilia Mirkin
Quoted 41 lines · Alexandre Courbot

Use the newly-introduced NV_VRAM_DOMAIN() macro to support alternative VRAM domains for chips that do not use dedicated video memory.

---
  src/gallium/drivers/nouveau/nouveau_buffer.c           |  6 ++----
  src/gallium/drivers/nouveau/nv50/nv50_miptree.c        |  4 ++--
  src/gallium/drivers/nouveau/nvc0/nvc0_compute.c        |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_context.c        |  4 ++--
  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c        |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_program.c        |  8 ++++----
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c         | 12 ++++++------
  src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c   |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_tex.c            |  2 +-
  src/gallium/drivers/nouveau/nvc0/nve4_compute.c        |  2 +-
  11 files changed, 22 insertions(+), 24 deletions(-)
src/gallium/drivers/nouveau/nouveau_buffer.c +1 -3
index 49ff100c4ece..4c21691ee671 100644
@@ -658,13 +658,11 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
        switch (buffer->base.usage) {
        case PIPE_USAGE_DEFAULT:
        case PIPE_USAGE_IMMUTABLE:
-         buffer->domain = NOUVEAU_BO_VRAM;
-         break;
        case PIPE_USAGE_DYNAMIC:
           /* For most apps, we'd have to do staging transfers to avoid sync
            * with this usage, and GART -> GART copies would be suboptimal.
            */
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
           break;
        case PIPE_USAGE_STAGING:
        case PIPE_USAGE_STREAM:
@@ -676,7 +674,7 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
        }
     } else {
        if (buffer->base.bind & screen->vidmem_bindings)
Quoted 8 lines

src/gallium/drivers/nouveau/nouveau_buffer.c nouveau_buffer_create(struct pipe_screen *pscreen, · line 680

Quoted 5 lines
src/gallium/drivers/nouveau/nouveau_buffer.c +1 -1
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
        else
        if (buffer->base.bind & screen->sysmem_bindings)
           buffer->domain = NOUVEAU_BO_GART;

Both of these changes should be unnecessary if vidmem_bindings is cleared out, right?

For our particular case (vram_domain == NOUVEAU_BO_GART), that's correct. However NV_VRAM_DOMAIN could be a any combination of NOUVEAU_BO_*, so we can imagine a future scenario where (buffer->base.bind & screen->vidmem_bindings) == 1 but NV_VRAM_DOMAIN() will return something different from NOUVEAU_BO_VRAM. For this reason it seems consistent to use this macro here as well.
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

#7 lore raw

Re: [PATCH v2 2/3] nvc0: use NV_VRAM_DOMAIN() macro

In reply to a message not in the archive

Hello Alex,

Op 19-11-14 om 06:41 schreef Alexandre Courbot:

Quoted 2 lines

Use the newly-introduced NV_VRAM_DOMAIN() macro to support alternative VRAM domains for chips that do not use dedicated video memory.

Should we construct a similar patch for NVAA/NVAC (MCP7x) as well?

Quoted 242 lines
---
  src/gallium/drivers/nouveau/nouveau_buffer.c           |  6 ++----
  src/gallium/drivers/nouveau/nv50/nv50_miptree.c        |  4 ++--
  src/gallium/drivers/nouveau/nvc0/nvc0_compute.c        |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_context.c        |  4 ++--
  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c        |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_program.c        |  8 ++++----
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c         | 12 ++++++------
  src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c   |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_tex.c            |  2 +-
  src/gallium/drivers/nouveau/nvc0/nve4_compute.c        |  2 +-
  11 files changed, 22 insertions(+), 24 deletions(-)
src/gallium/drivers/nouveau/nouveau_buffer.c +2 -4
index 49ff100c4ece..4c21691ee671 100644
@@ -658,13 +658,11 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
        switch (buffer->base.usage) {
        case PIPE_USAGE_DEFAULT:
        case PIPE_USAGE_IMMUTABLE:
-         buffer->domain = NOUVEAU_BO_VRAM;
-         break;
        case PIPE_USAGE_DYNAMIC:
           /* For most apps, we'd have to do staging transfers to avoid sync
            * with this usage, and GART -> GART copies would be suboptimal.
            */
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
           break;
        case PIPE_USAGE_STAGING:
        case PIPE_USAGE_STREAM:
@@ -676,7 +674,7 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
        }
     } else {
        if (buffer->base.bind & screen->vidmem_bindings)
-         buffer->domain = NOUVEAU_BO_VRAM;
+         buffer->domain = NV_VRAM_DOMAIN(screen);
        else
        if (buffer->base.bind & screen->sysmem_bindings)
           buffer->domain = NOUVEAU_BO_GART;
src/gallium/drivers/nouveau/nv50/nv50_miptree.c +2 -2
index 1aacaec89acf..ddff508c475c 100644
@@ -359,7 +359,7 @@ nv50_miptree_create(struct pipe_screen *pscreen,
     if (!bo_config.nv50.memtype && (pt->bind & PIPE_BIND_SHARED))
        mt->base.domain = NOUVEAU_BO_GART;
     else
-      mt->base.domain = NOUVEAU_BO_VRAM;
+      mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
 
     bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP;
     if (mt->base.base.bind & (PIPE_BIND_CURSOR | PIPE_BIND_DISPLAY_TARGET))
@@ -401,7 +401,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen,
        FREE(mt);
        return NULL;
     }
-   mt->base.domain = NOUVEAU_BO_VRAM;
+   mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
     mt->base.address = mt->base.bo->offset;
 
     mt->base.base = *templ;
src/gallium/drivers/nouveau/nvc0/nvc0_compute.c +1 -1
index ad287a2af6b6..56fc83d3679f 100644
@@ -57,7 +57,7 @@ nvc0_screen_compute_setup(struct nvc0_screen *screen,
        return ret;
     }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 1 << 12, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 0, 1 << 12, NULL,
                          &screen->parm);
     if (ret)
        return ret;
src/gallium/drivers/nouveau/nvc0/nvc0_context.c +2 -2
index b33a6731a1c0..a0189f528e6f 100644
@@ -322,7 +322,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
 
     /* add permanently resident buffers to bufctxts */
 
-   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD;
+   flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD;
 
     BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->text);
     BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->uniform_bo);
@@ -333,7 +333,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
        BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->parm);
     }
 
-   flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
+   flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RDWR;
 
     if (screen->poly_cache)
        BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->poly_cache);
src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c +1 -1
index 1beda7d4a2c8..3afde38e71ba 100644
@@ -302,7 +302,7 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
     if (!bo_config.nvc0.memtype && (pt->usage == PIPE_USAGE_STAGING || pt->bind & PIPE_BIND_SHARED))
        mt->base.domain = NOUVEAU_BO_GART;
     else
-      mt->base.domain = NOUVEAU_BO_VRAM;
+      mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen));
 
     bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP;
 
src/gallium/drivers/nouveau/nvc0/nvc0_program.c +4 -4
index 21be8b7240ea..7600dc4e7208 100644
@@ -734,12 +734,12 @@ nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog)
 
     if (!is_cp)
        nvc0->base.push_data(&nvc0->base, screen->text, prog->code_base,
-                           NOUVEAU_BO_VRAM, NVC0_SHADER_HEADER_SIZE, prog->hdr);
+                           NV_VRAM_DOMAIN(&screen->base), NVC0_SHADER_HEADER_SIZE, prog->hdr);
     nvc0->base.push_data(&nvc0->base, screen->text, code_pos,
-                        NOUVEAU_BO_VRAM, prog->code_size, prog->code);
+                        NV_VRAM_DOMAIN(&screen->base), prog->code_size, prog->code);
     if (prog->immd_size)
        nvc0->base.push_data(&nvc0->base,
-                           screen->text, prog->immd_base, NOUVEAU_BO_VRAM,
+                           screen->text, prog->immd_base, NV_VRAM_DOMAIN(&screen->base),
                             prog->immd_size, prog->immd_data);
 
     BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(MEM_BARRIER), 1);
@@ -770,7 +770,7 @@ nvc0_program_library_upload(struct nvc0_context *nvc0)
        return;
 
     nvc0->base.push_data(&nvc0->base,
-                        screen->text, screen->lib_code->start, NOUVEAU_BO_VRAM,
+                        screen->text, screen->lib_code->start, NV_VRAM_DOMAIN(&screen->base),
                          size, code);
     /* no need for a memory barrier, will be emitted with first program */
  }
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +6 -6
index 2a759311bf76..506165d179de 100644
@@ -570,7 +570,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
 
     size = align(size, 1 << 17);
 
-   ret = nouveau_bo_new(screen->base.device, NOUVEAU_BO_VRAM, 1 << 17, size,
+   ret = nouveau_bo_new(screen->base.device, NV_VRAM_DOMAIN(&screen->base), 1 << 17, size,
                          NULL, &bo);
     if (ret) {
        NOUVEAU_ERR("failed to allocate TLS area, size: 0x%"PRIx64"\n", size);
@@ -812,7 +812,7 @@ nvc0_screen_create(struct nouveau_device *dev)
 
     nvc0_magic_3d_init(push, screen->eng3d->oclass);
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 20, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
                          &screen->text);
     if (ret)
        goto fail;
@@ -822,12 +822,12 @@ nvc0_screen_create(struct nouveau_device *dev)
      */
     nouveau_heap_init(&screen->text_heap, 0, (1 << 20) - 0x100);
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 12, 6 << 16, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 12, 6 << 16, NULL,
                          &screen->uniform_bo);
     if (ret)
        goto fail;
 
-   PUSH_REFN (push, screen->uniform_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+   PUSH_REFN (push, screen->uniform_bo, NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_WR);
 
     for (i = 0; i < 5; ++i) {
        /* TIC and TSC entries for each unit (nve4+ only) */
@@ -898,7 +898,7 @@ nvc0_screen_create(struct nouveau_device *dev)
     PUSH_DATA (push, 0);
 
     if (screen->eng3d->oclass < GM107_3D_CLASS) {
-      ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 20, NULL,
+      ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
                             &screen->poly_cache);
        if (ret)
           goto fail;
@@ -909,7 +909,7 @@ nvc0_screen_create(struct nouveau_device *dev)
        PUSH_DATA (push, 3);
     }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 1 << 17, 1 << 17, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 17, NULL,
                          &screen->txc);
     if (ret)
        goto fail;
src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c +1 -1
index 1000d8286d77..3fcca1671c8c 100644
@@ -34,7 +34,7 @@ nvc0_program_update_context_state(struct nvc0_context *nvc0,
     struct nouveau_pushbuf *push = nvc0->base.pushbuf;
 
     if (prog && prog->need_tls) {
-      const uint32_t flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR;
+      const uint32_t flags = NV_VRAM_DOMAIN(&nvc0->screen->base) | NOUVEAU_BO_RDWR;
        if (!nvc0->state.tls_required)
           BCTX_REFN_bo(nvc0->bufctx_3d, TLS, flags, nvc0->screen->tls);
        nvc0->state.tls_required |= 1 << stage;
src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +1 -1
index 25a3232b48d9..696eacaa1e20 100644
@@ -439,7 +439,7 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
                 BEGIN_NVC0(push, NVC0_3D(CB_BIND(s)), 1);
                 PUSH_DATA (push, (0 << 4) | 1);
              }
-            nvc0_cb_push(&nvc0->base, bo, NOUVEAU_BO_VRAM,
+            nvc0_cb_push(&nvc0->base, bo, NV_VRAM_DOMAIN(&nvc0->screen->base),
                           base, nvc0->state.uniform_buffer_bound[s],
                           0, (size + 3) / 4,
                           nvc0->constbuf[s][0].u.data);
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c +1 -1
index db6b6036a72d..dc4389d7432f 100644
@@ -396,7 +396,7 @@ nvc0_validate_tsc(struct nvc0_context *nvc0, int s)
           tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc);
 
           nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->txc,
-                               65536 + tsc->id * 32, NOUVEAU_BO_VRAM,
+                               65536 + tsc->id * 32, NV_VRAM_DOMAIN(&nvc0->screen->base),
                                 32, tsc->tsc);
           need_flush = TRUE;
        }
src/gallium/drivers/nouveau/nvc0/nve4_compute.c +0 -0
index f243316b899c..fce02a7cc576 100644

src/gallium/drivers/nouveau/nvc0/nve4_compute.c nve4_screen_compute_setup(struct nvc0_screen *screen, · line 69

Quoted 8 lines
src/gallium/drivers/nouveau/nvc0/nve4_compute.c +1 -1
@@ -63,7 +63,7 @@ nve4_screen_compute_setup(struct nvc0_screen *screen,
        return ret;
     }
 
-   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, NVE4_CP_PARAM_SIZE, NULL,
+   ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 0, NVE4_CP_PARAM_SIZE, NULL,
                          &screen->parm);
     if (ret)
        return ret;

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 546C68F8.90502-FA6nBp6kBxZzu6KWmfFNGwC/[email protected]

#9 lore raw

Re: [PATCH v2 2/3] nvc0: use NV_VRAM_DOMAIN() macro

Hi Roy,

Quoted 9 lines · Roy Spliet

Hello Alex,

Op 19-11-14 om 06:41 schreef Alexandre Courbot:

Quoted 3 lines

Use the newly-introduced NV_VRAM_DOMAIN() macro to support alternative VRAM domains for chips that do not use dedicated video memory.

Should we construct a similar patch for NVAA/NVAC (MCP7x) as well?

Not sure - aren't these cards carving out a contiguous area of physical memory to use as VRAM instead of actually sharing the whole system memory?
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#10 lore raw

PATCH v2 3/3 gk20a: use NOUVEAU_BO_GART as VRAM domain

In reply to a message not in the archive

GK20A does not have dedicated VRAM, therefore allocating in VRAM can be sub-optimal and sometimes even harmful. Set its VRAM domain to NOUVEAU_BO_GART so all objects are allocated in system memory.

---
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +15 -0
index 506165d179de..b3f462ade11c 100644
@@ -617,6 +617,16 @@ nvc0_screen_create(struct nouveau_device *dev)
       return NULL;
    pscreen = &screen->base.base;
 
+   /* Recognize chipsets with no VRAM */
+   switch (dev->chipset) {
+   /* GK20A */
+   case 0xea:
+      screen->base.vram_domain = NOUVEAU_BO_GART;
+      break;
+   default:
+      break;
+   }
+
    ret = nouveau_screen_init(&screen->base, dev);
    if (ret) {
       nvc0_screen_destroy(pscreen);
@@ -633,6 +643,11 @@ nvc0_screen_create(struct nouveau_device *dev)
    screen->base.sysmem_bindings |=
       PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER;
 
+   if (screen->base.vram_domain & NOUVEAU_BO_GART) {
+      screen->base.sysmem_bindings |= screen->base.vidmem_bindings;
+      screen->base.vidmem_bindings = 0;
+   }
+
    pscreen->destroy = nvc0_screen_destroy;
    pscreen->context_create = nvc0_create;
    pscreen->is_format_supported = nvc0_screen_is_format_supported;
Signature · 1 line
2.1.3