drm/nv50: align size of buffer object to the right boundaries.
Subsystems (3)
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 | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +4 -5
@@ -65,8 +65,9 @@ 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 make sure your "special" buffer sizes are large enough. */ if (dev_priv->card_type ==NV_50 ) {uint32_t block_size =nouveau_mem_fb_amount (dev) >>15 ;
@@ -77,22 +78,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): 1261914064-3535-1-git-send-email-madman2003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/2 drm/nv50: synchronize user channel after buffer object move on kernel channel
- This is not yet a generic implementation that will work everywhere, but it's a start.
- This will fix the corruption surrounding pixmap/texture bo moves on nv50.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 7 ++ drivers/gpu/drm/nouveau/nouveau_channel.c | 9 ++- drivers/gpu/drm/nouveau/nouveau_dma.c | 26 +++++++ drivers/gpu/drm/nouveau/nouveau_dma.h | 11 ++- drivers/gpu/drm/nouveau/nouveau_drv.h | 11 +++ drivers/gpu/drm/nouveau/nouveau_fence.c | 103 +++++++++++++++++++++++++++++ drivers/gpu/drm/nouveau/nouveau_object.c | 2 +- drivers/gpu/drm/nouveau/nv50_graph.c | 16 +++++ 8 files changed, 179 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +7 -0
@@ -466,6 +466,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_channel.c +8 -1
@@ -414,7 +414,14 @@ nouveau_ioctl_fifo_alloc(struct drm_device *dev, void *data, init->subchan[0 ].grclass =0x0039 ; else init->subchan[0].grclass = 0x5039; - init->nr_subchan =1 ; +if (dev_priv->card_type >=NV_50 ) { + init->subchan[1 ].handle = NvSw; + init->subchan[1 ].grclass =NV50_NVSW ; + } +if (dev_priv->card_type <NV_50 ) + init->nr_subchan =1 ; +else + init->nr_subchan =2 ;/* Named memory object area */ ret = drm_gem_handle_create(file_priv, chan->notifier_bo->gem,
drivers/gpu/drm/nouveau/nouveau_dma.c +26 -0
@@ -52,6 +52,23 @@ nouveau_dma_init(struct nouveau_channel *chan)if (ret)return ret; +/* Allocate what we need for (simple) cross channel synchronisation. */ +if (dev_priv->card_type >=NV_50 ) { +struct nouveau_gpuobj *nvsw =NULL ; + + ret =nouveau_gpuobj_sw_new (chan,NV50_NVSW , &nvsw); +if (ret) +return ret; + + ret =nouveau_gpuobj_ref_add (dev, chan, NvSw, nvsw,NULL ); +if (ret) +return ret; + + 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)
@@ -87,6 +104,15 @@ nouveau_dma_init(struct nouveau_channel *chan)BEGIN_RING (chan, NvSubM2MF,NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY ,1 );OUT_RING (chan, NvNotify0); +/* Bind NvSw to channel. */ +if (dev_priv->card_type >=NV_50 ) { + ret =RING_SPACE (chan,2 ); +if (ret) +return ret; +BEGIN_RING (chan, NvSubSw,0 ,1 ); +OUT_RING (chan, NvSw); + } +/* Sit back and pray the channel works.. */ FIRE_RING (chan);
drivers/gpu/drm/nouveau/nouveau_dma.h +7 -4
@@ -46,10 +46,11 @@/* Hardcoded object assignments to subchannels (subchannel id). */ enum { NvSubM2MF =0 , - NvSub2D =1 , - NvSubCtxSurf2D =1 , - NvSubGdiRect =2 , - NvSubImageBlit =3 + NvSubSw =1 , + NvSub2D =2 , + NvSubCtxSurf2D =2 , + NvSubGdiRect =3 , + NvSubImageBlit =4 };/* Object handles. */
@@ -67,6 +68,8 @@ enum { NvClipRect =0x8000000b , NvGdiRect =0x8000000c , NvImageBlit =0x8000000d , + NvSw =0x8000000e , + NvNotify1 =0x8000000f ,/* G80+ display objects */ NvEvoVRAM = 0x01000000,
drivers/gpu/drm/nouveau/nouveau_drv.h +11 -0
@@ -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;
@@ -788,6 +789,8 @@ extern int nouveau_gpuobj_gart_dma_new(struct nouveau_channel *, uint32_t *o_ret);extern int nouveau_gpuobj_gr_new (struct nouveau_channel *,int class,struct nouveau_gpuobj **); +extern int nouveau_gpuobj_sw_new (struct nouveau_channel *,int class, +struct nouveau_gpuobj **);extern int nouveau_ioctl_grobj_alloc (struct drm_device *,void *data,struct drm_file *); extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data,
@@ -1132,6 +1135,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 sequence); +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 *,
@@ -1339,5 +1348,7 @@ nv_two_reg_pll(struct drm_device *dev)#define NV50_NVSW_VBLSEM_OFFSET 0x00000400#define NV50_NVSW_VBLSEM_RELEASE_VALUE 0x00000404#define NV50_NVSW_VBLSEM_RELEASE 0x00000408 +#define NV50_NVSW_SEMAPHORE_PRE_ACQUIRE 0x00000500 +#define NV50_NVSW_SEMAPHORE_FLUSH 0x00000504#endif /* __NOUVEAU_DRV_H__ */
drivers/gpu/drm/nouveau/nouveau_fence.c +103 -0
106 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_object.c +1 -1
@@ -881,7 +881,7 @@ nouveau_gpuobj_gr_new(struct nouveau_channel *chan, int class,return 0 ; } -static int +int nouveau_gpuobj_sw_new (struct nouveau_channel *chan,int class,struct nouveau_gpuobj **gpuobj_ret) {
drivers/gpu/drm/nouveau/nv50_graph.c +16 -0
@@ -367,11 +367,27 @@ nv50_graph_nvsw_vblsem_release(struct nouveau_channel *chan, int grclass,return 0 ; } +static int +nv50_graph_semaphore_pre_acquire (struct nouveau_channel *chan,int grclass, +int mthd,uint32_t data) +{ +return nouveau_fence_semaphore_pre_acquire (chan, data); +} + +static int +nv50_graph_semaphore_flush (struct nouveau_channel *chan,int grclass, +int mthd,uint32_t data) +{ +return nouveau_fence_semaphore_flush (chan, data); +} +static struct nouveau_pgraph_object_method nv50_graph_nvsw_methods[] = { {0x018c , nv50_graph_nvsw_dma_vblsem }, {0x0400 , nv50_graph_nvsw_vblsem_offset }, {0x0404 , nv50_graph_nvsw_vblsem_release_val }, {0x0408 , nv50_graph_nvsw_vblsem_release }, + {0x0500 , nv50_graph_semaphore_pre_acquire }, + {0x0504 , nv50_graph_semaphore_flush }, {} };
Signature · 1 line
1.6.6.rc4
Quoted 12 lines · Maarten Maathuis
- Depth and stencil buffers are supposed to be large enough in general.
Signed-off-by Maarten Maathuis <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_bo.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_fixup_align(struct drm_device *dev, · line 71
Quoted 9 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +3
-2@@ -65,8 +65,9 @@ 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 make sure your "special" buffer sizes are large enough. */
No - 16x16 depth textures or whatever crazy idea some app might have won't be large enough.
Taking care of size in userspace and of alignment in kernel ... not nice to split in my opinion.
Quoted 26 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +1
-3if (dev_priv->card_type ==NV_50 ) {uint32_t block_size =nouveau_mem_fb_amount (dev) >>15 ;@@ -77,22 +78,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 ;
A message that is not in the archive (sent off-list or not yet received): 4B37647F.9030402-oe7qfRrRQffzPE21tAIdciO7C/[email protected]
Quoted 14 lines · Christoph Bumiller
Quoted 13 lines · Maarten Maathuis
- Depth and stencil buffers are supposed to be large enough in general.
Signed-off-by Maarten Maathuis <[email protected]>---
drivers/gpu/drm/nouveau/nouveau_bo.c | 9 ++++-----1 files changed, 4 insertions(+), 5 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0@@ -65,8 +65,9 @@ nouveau_bo_fixup_align(struct drm_device *dev,
Quoted 12 lines
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_fixup_align(struct drm_device *dev, · line 71
Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +3
-2/** 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 make sure your "special" buffer sizes are large enough. */ No - 16x16 depth textures or whatever crazy idea some app might have won't be large enough.
Taking care of size in userspace and of alignment in kernel ... not nice to split in my opinion.
Userspace doesn't know all constraints, so the kernel has to do something. How to deal with these limitations is another question. Either we over allocate (and hide the overallocation from everyone), align the size, or we try to make the allocator smarter to group them together based on their tile flags.
Quoted 28 lines
Quoted 26 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0if (dev_priv->card_type == NV_50) { uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15;@@ -77,22 +78,20 @@ nouveau_bo_fixup_align(struct drm_device *dev,case
0x2800:
case0x4800:
case0x7a00:
- *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;
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0912270628l4ccddb11ua1811be230bbb15d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
To avoid any confusion, "make sure your buffers are large enough" means you shouldn't go allocating very small depth/stencil buffers, because that will waste space. Userspace should never have to worry about the restrictions themselves.
Maarten.
Quoted 64 lines · Maarten Maathuis
Quoted 14 lines · Christoph Bumiller
Quoted 13 lines · Maarten Maathuis
- Depth and stencil buffers are supposed to be large enough in general.
Signed-off-by Maarten Maathuis <[email protected]>---
drivers/gpu/drm/nouveau/nouveau_bo.c | 9 ++++-----1 files changed, 4 insertions(+), 5 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0@@ -65,8 +65,9 @@ nouveau_bo_fixup_align(struct drm_device *dev,Quoted 12 lines
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_fixup_align(struct drm_device *dev, · line 71
Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +3
-2/** 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 make sure your "special" buffer sizes are large enough. */ No - 16x16 depth textures or whatever crazy idea some app might have won't be large enough.
Taking care of size in userspace and of alignment in kernel ... not nice to split in my opinion.Userspace doesn't know all constraints, so the kernel has to do something. How to deal with these limitations is another question. Either we over allocate (and hide the overallocation from everyone), align the size, or we try to make the allocator smarter to group them together based on their tile flags.
Quoted 28 lines
Quoted 26 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0if (dev_priv->card_type == NV_50) { uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15;@@ -77,22 +78,20 @@ nouveau_bo_fixup_align(struct drm_device *dev,case
0x2800:
case0x4800:
case0x7a00:
- *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;