Skip to contentSkip to conversation

drm/nv50: align size of buffer object to the right boundaries.

PATCH New Maarten Maathuis 1 participant 2 messages Dec 28, 2009 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/nv50: align size of buffer object to the right boundaries.

- Depth and stencil buffers are supposed to be large enough in general.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -5
index e342a41..5b1c0ae 100644
@@ -65,8 +65,10 @@ nouveau_bo_fixup_align(struct drm_device *dev,
 
 	/*
 	 * Some of the tile_flags have a periodic structure of N*4096 bytes,
-	 * align to to that as well as the page size. Overallocate memory to
-	 * avoid corruption of other buffer objects.
+	 * align to to that as well as the page size. Align the size to the
+	 * appropriate boundaries. This does imply that sizes are rounded up
+	 * 3-7 pages, so be aware of this and do not waste memory by allocating
+	 * many small buffers.
 	 */
 	if (dev_priv->card_type == NV_50) {
 		uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15;
@@ -77,22 +79,20 @@ nouveau_bo_fixup_align(struct drm_device *dev,
 		case 0x2800:
 		case 0x4800:
 		case 0x7a00:
-			*size = roundup(*size, block_size);
 			if (is_power_of_2(block_size)) {
-				*size += 3 * block_size;
 				for (i = 1; i < 10; i++) {
 					*align = 12 * i * block_size;
 					if (!(*align % 65536))
 						break;
 				}
 			} else {
-				*size += 6 * block_size;
 				for (i = 1; i < 10; i++) {
 					*align = 8 * i * block_size;
 					if (!(*align % 65536))
 						break;
 				}
 			}
+			*size = roundup(*size, *align);
 			break;
 		default:
 			break;
Signature · 1 line
1.6.6.rc4

A message that is not in the archive (sent off-list or not yet received): 1262044181-6269-1-git-send-email-madman2003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 2/2 drm/nouveau: synchronize channel after buffer object move on another channel

- The implementation is pretty generic and should work on most hw.
- It's only tested on nv50 and the userspace interface lacks awareness of fences, so it's not possible yet to do this from userspace.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c    |    7 ++
 drivers/gpu/drm/nouveau/nouveau_dma.c   |    5 +
 drivers/gpu/drm/nouveau/nouveau_dma.h   |    1 +
 drivers/gpu/drm/nouveau/nouveau_drv.h   |   21 +++++
 drivers/gpu/drm/nouveau/nouveau_fence.c |  129 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/nouveau/nv10_graph.c    |   50 ++++++++++++
 drivers/gpu/drm/nouveau/nv20_graph.c    |   10 +++
 drivers/gpu/drm/nouveau/nv40_graph.c    |    9 ++
 drivers/gpu/drm/nouveau/nv50_graph.c    |    4 +
 9 files changed, 236 insertions(+), 0 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +7 -0
index 5b1c0ae..462fc74 100644
@@ -467,6 +467,13 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
 	if (ret)
 		return ret;
 
+	/* Make the user channel wait for the kernel channel to be done. */
+	if (nvbo->channel && chan != nvbo->channel) {
+		ret = nouveau_fence_sync(nvbo->channel, fence);
+		if (ret)
+			return ret;
+	}
+
 	ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, NULL,
 					evict, no_wait, new_mem);
 	nouveau_fence_unref((void *)&fence);
drivers/gpu/drm/nouveau/nouveau_dma.c +5 -0
index f1fd3f2..23547d6 100644
@@ -62,6 +62,11 @@ nouveau_dma_init(struct nouveau_channel *chan)
 	if (ret)
 		return ret;
 
+	/* Notifier for internal/kernel cross channel synchronisation. */
+	ret = nouveau_notifier_alloc(chan, NvNotify1, 32, &chan->sync_ntfy);
+	if (ret)
+		return ret;
+
 	/* Map push buffer */
 	ret = nouveau_bo_map(chan->pushbuf_bo);
 	if (ret)
drivers/gpu/drm/nouveau/nouveau_dma.h +1 -0
index dabfd65..d1ef524 100644
@@ -69,6 +69,7 @@ enum {
 	NvGdiRect	= 0x8000000c,
 	NvImageBlit	= 0x8000000d,
 	NvSw		= 0x8000000e,
+	NvNotify1		= 0x8000000f,
 
 	/* G80+ display objects */
 	NvEvoVRAM	= 0x01000000,
drivers/gpu/drm/nouveau/nouveau_drv.h +21 -0
index 9181eae..b836f07 100644
@@ -228,6 +228,7 @@ struct nouveau_channel {
 
 	/* GPU object info for stuff used in-kernel (mm_enabled) */
 	uint32_t m2mf_ntfy;
+	uint32_t sync_ntfy;
 	uint32_t vram_handle;
 	uint32_t gart_handle;
 	bool accel_done;
@@ -248,6 +249,8 @@ struct nouveau_channel {
 		uint32_t vblsem_offset;
 		uint32_t vblsem_rval;
 		struct list_head vbl_wait;
+		uint32_t syncsem_handle;
+		uint32_t sync_sequence;
 	} nvsw;
 
 	struct {
@@ -983,6 +986,14 @@ extern int  nv10_graph_unload_context(struct drm_device *);
 extern void nv10_graph_context_switch(struct drm_device *);
 extern void nv10_graph_set_region_tiling(struct drm_device *, int, uint32_t,
 					 uint32_t, uint32_t);
+extern int nv10_graph_nvsw_flush_semaphore_notifier(struct nouveau_channel *,
+				int, int, uint32_t);
+extern int nv10_graph_nvsw_flush_semaphore_fence_sequence(
+				struct nouveau_channel *, int, int, uint32_t);
+extern int nv10_graph_nvsw_flush_semaphore_pre_acquire(struct nouveau_channel *,
+				int, int, uint32_t);
+extern int nv10_graph_nvsw_flush_semaphore_flush(struct nouveau_channel *, int,
+				int, uint32_t);
 
 /* nv20_graph.c */
 extern struct nouveau_pgraph_object_class nv20_graph_grclass[];
@@ -1134,6 +1145,12 @@ extern int nouveau_fence_flush(void *obj, void *arg);
 extern void nouveau_fence_unref(void **obj);
 extern void *nouveau_fence_ref(void *obj);
 extern void nouveau_fence_handler(struct drm_device *dev, int channel);
+extern int nouveau_fence_sync(struct nouveau_channel *chan,
+				struct nouveau_fence *fence);
+extern int nouveau_fence_semaphore_pre_acquire(struct nouveau_channel *chan,
+				int channel);
+extern int nouveau_fence_semaphore_flush(struct nouveau_channel *chan,
+				int channel);
 
 /* nouveau_gem.c */
 extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *,
@@ -1341,5 +1358,9 @@ nv_two_reg_pll(struct drm_device *dev)
 #define NV_SW_VBLSEM_OFFSET                                          0x00000400
 #define NV_SW_VBLSEM_RELEASE_VALUE                                   0x00000404
 #define NV_SW_VBLSEM_RELEASE                                         0x00000408
+#define NV_SW_SYNC_SEMAPHORE_NOTIFIER				0x00000500
+#define NV_SW_SYNC_SEMAPHORE_FENCE_SEQUENCE		0x00000504
+#define NV_SW_SYNC_SEMAPHORE_PRE_ACQUIRE			0x00000508
+#define NV_SW_SYNC_SEMAPHORE_FLUSH				0x0000050C
 
 #endif /* __NOUVEAU_DRV_H__ */
drivers/gpu/drm/nouveau/nouveau_fence.c +129 -0

132 lines not on this page · raw message

drivers/gpu/drm/nouveau/nv10_graph.c +50 -0

57 lines not on this page · raw message

drivers/gpu/drm/nouveau/nv20_graph.c +10 -0
index d6fc0a8..7adcdd3 100644
@@ -730,7 +730,16 @@ nv30_graph_init(struct drm_device *dev)
 	return 0;
 }
 
+static struct nouveau_pgraph_object_method nv20_graph_nvsw_methods[] = {
+	{ 0x0500, nv10_graph_nvsw_flush_semaphore_notifier },
+	{ 0x0504, nv10_graph_nvsw_flush_semaphore_fence_sequence },
+	{ 0x0508, nv10_graph_nvsw_flush_semaphore_pre_acquire },
+	{ 0x050C, nv10_graph_nvsw_flush_semaphore_flush },
+	{}
+};
+
 struct nouveau_pgraph_object_class nv20_graph_grclass[] = {
+	{ 0x506e, true, nv20_graph_nvsw_methods }, /* nvsw */
 	{ 0x0030, false, NULL }, /* null */
 	{ 0x0039, false, NULL }, /* m2mf */
 	{ 0x004a, false, NULL }, /* gdirect */
@@ -751,6 +760,7 @@ struct nouveau_pgraph_object_class nv20_graph_grclass[] = {
 };
 
 struct nouveau_pgraph_object_class nv30_graph_grclass[] = {
+	{ 0x506e, true, nv20_graph_nvsw_methods }, /* nvsw */
 	{ 0x0030, false, NULL }, /* null */
 	{ 0x0039, false, NULL }, /* m2mf */
 	{ 0x004a, false, NULL }, /* gdirect */
drivers/gpu/drm/nouveau/nv40_graph.c +9 -0
index 53e8afe..835e352 100644
@@ -383,7 +383,16 @@ void nv40_graph_takedown(struct drm_device *dev)
 	nouveau_grctx_fini(dev);
 }
 
+static struct nouveau_pgraph_object_method nv40_graph_nvsw_methods[] = {
+	{ 0x0500, nv10_graph_nvsw_flush_semaphore_notifier },
+	{ 0x0504, nv10_graph_nvsw_flush_semaphore_fence_sequence },
+	{ 0x0508, nv10_graph_nvsw_flush_semaphore_pre_acquire },
+	{ 0x050C, nv10_graph_nvsw_flush_semaphore_flush },
+	{}
+};
+
 struct nouveau_pgraph_object_class nv40_graph_grclass[] = {
+	{ 0x506e, true, nv40_graph_nvsw_methods }, /* nvsw */
 	{ 0x0030, false, NULL }, /* null */
 	{ 0x0039, false, NULL }, /* m2mf */
 	{ 0x004a, false, NULL }, /* gdirect */
drivers/gpu/drm/nouveau/nv50_graph.c +4 -0
index ca79f32..444a46b 100644
@@ -372,6 +372,10 @@ static struct nouveau_pgraph_object_method nv50_graph_nvsw_methods[] = {
 	{ 0x0400, nv50_graph_nvsw_vblsem_offset },
 	{ 0x0404, nv50_graph_nvsw_vblsem_release_val },
 	{ 0x0408, nv50_graph_nvsw_vblsem_release },
+	{ 0x0500, nv10_graph_nvsw_flush_semaphore_notifier },
+	{ 0x0504, nv10_graph_nvsw_flush_semaphore_fence_sequence },
+	{ 0x0508, nv10_graph_nvsw_flush_semaphore_pre_acquire },
+	{ 0x050C, nv10_graph_nvsw_flush_semaphore_flush },
 	{}
 };
 
Signature · 1 line
1.6.6.rc4