aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs2010-12-20 00:02:42 -0600
committerBen Skeggs2010-12-20 20:46:51 -0600
commitbad5242a59aa8e31cf10749e2ac69b3c66ef7da0 (patch)
tree5502274e7e12e698436c15254ebd02145900783f /nouveau
parent45cfb9cf089cd56878b1cb5d15391d2470dbeb7c (diff)
downloadlibdrm-bad5242a59aa8e31cf10749e2ac69b3c66ef7da0.tar.gz
libdrm-bad5242a59aa8e31cf10749e2ac69b3c66ef7da0.tar.xz
libdrm-bad5242a59aa8e31cf10749e2ac69b3c66ef7da0.zip
nouveau: fix up reloc_emit() to accept NULL target buffer
The nvc0 gallium drivers passes NULL here to indicate to the memory manager that a buffer is being used, but without creating an actual reloc. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'nouveau')
-rw-r--r--nouveau/nouveau_reloc.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/nouveau/nouveau_reloc.c b/nouveau/nouveau_reloc.c
index 332dfa01..cd219db4 100644
--- a/nouveau/nouveau_reloc.c
+++ b/nouveau/nouveau_reloc.c
@@ -79,11 +79,7 @@ nouveau_reloc_emit(struct nouveau_channel *chan, struct nouveau_bo *reloc_bo,
79 if (!(nvbo->flags & (NOUVEAU_BO_GART | NOUVEAU_BO_VRAM))) 79 if (!(nvbo->flags & (NOUVEAU_BO_GART | NOUVEAU_BO_VRAM)))
80 nvbo->flags |= (flags & (NOUVEAU_BO_GART | NOUVEAU_BO_VRAM)); 80 nvbo->flags |= (flags & (NOUVEAU_BO_GART | NOUVEAU_BO_VRAM));
81 81
82 rpbbo = nouveau_bo_emit_buffer(chan, reloc_bo); 82 /* add buffer to validation list */
83 if (!rpbbo)
84 return -ENOMEM;
85 nouveau_bo(reloc_bo)->pending_refcnt++;
86
87 pbbo = nouveau_bo_emit_buffer(chan, bo); 83 pbbo = nouveau_bo_emit_buffer(chan, bo);
88 if (!pbbo) { 84 if (!pbbo) {
89 fprintf(stderr, "buffer emit fail :(\n"); 85 fprintf(stderr, "buffer emit fail :(\n");
@@ -91,10 +87,13 @@ nouveau_reloc_emit(struct nouveau_channel *chan, struct nouveau_bo *reloc_bo,
91 } 87 }
92 nouveau_bo(bo)->pending_refcnt++; 88 nouveau_bo(bo)->pending_refcnt++;
93 89
94 if (flags & NOUVEAU_BO_VRAM) 90 if (flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) {
95 domains |= NOUVEAU_GEM_DOMAIN_VRAM; 91 if (flags & NOUVEAU_BO_VRAM)
96 if (flags & NOUVEAU_BO_GART) 92 domains |= NOUVEAU_GEM_DOMAIN_VRAM;
97 domains |= NOUVEAU_GEM_DOMAIN_GART; 93 if (flags & NOUVEAU_BO_GART)
94 domains |= NOUVEAU_GEM_DOMAIN_GART;
95 } else
96 domains |= nvbo->domain;
98 97
99 if (!(pbbo->valid_domains & domains)) { 98 if (!(pbbo->valid_domains & domains)) {
100 fprintf(stderr, "no valid domains remain!\n"); 99 fprintf(stderr, "no valid domains remain!\n");
@@ -111,6 +110,23 @@ nouveau_reloc_emit(struct nouveau_channel *chan, struct nouveau_bo *reloc_bo,
111 nvbo->write_marker = 1; 110 nvbo->write_marker = 1;
112 } 111 }
113 112
113 /* nvc0 gallium driver uses reloc_emit() with NULL target buffer
114 * to inform bufmgr of a buffer's use - however, we need something
115 * to track, so create a reloc for now, and hope it never triggers
116 * (it shouldn't, constant virtual address..)..
117 */
118 if (!reloc_bo) {
119 reloc_bo = nvpb->buffer[nvpb->current];
120 reloc_offset = 0;
121 reloc_ptr = NULL;
122 }
123
124 /* add reloc target bo to validation list, and create the reloc */
125 rpbbo = nouveau_bo_emit_buffer(chan, reloc_bo);
126 if (!rpbbo)
127 return -ENOMEM;
128 nouveau_bo(reloc_bo)->pending_refcnt++;
129
114 r = nvpb->relocs + nvpb->nr_relocs++; 130 r = nvpb->relocs + nvpb->nr_relocs++;
115 r->reloc_bo_index = rpbbo - nvpb->buffers; 131 r->reloc_bo_index = rpbbo - nvpb->buffers;
116 r->reloc_bo_offset = reloc_offset; 132 r->reloc_bo_offset = reloc_offset;