drm/nouveau: bo read/write wrappers for nv04_crtc.c
Subsystems (3)
PATCH 1/6 drm/nouveau: bo read/write wrappers for nv04_crtc.c
Introduce accessors for TTM buffer object memory that has been mapped into the kernel virtual address space or as IO memory. IO memory needs to be accessed via special accessor functions, not by dereferencing the iomem cookie. The wrappers hide the details of 32-bit access and honour the TTM map type.
nv04_crtc_cursor_set() is changed to use the new wrappers. 'cursor' is received from user space, which means we cannot assume that it is or is not iomem. 'nv_crtc->cursor.nvbo' should always be iomem, and as such the access is relatively slow. Therefore using the wrappers for it, too, should not cost much.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/nouveau/nouveau_drv.h | 2 ++ drivers/gpu/drm/nouveau/nv04_crtc.c | 7 ++----- 3 files changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +23 -0
@@ -172,6 +172,29 @@ nouveau_bo_unmap(struct nouveau_bo *nvbo)ttm_bo_kunmap (&nvbo->kmap); } +u32 +nouveau_bo_rd32 (struct nouveau_bo *nvbo,unsigned index) +{ +bool is_iomem; +u32 *mem =ttm_kmap_obj_virtual (&nvbo->kmap, &is_iomem); + mem = &mem[index]; +if (is_iomem) +return ioread32_native ((void __force __iomem *)mem); +else +return *mem; +} + +void +nouveau_bo_wr32 (struct nouveau_bo *nvbo,unsigned index,u32 val) +{ +bool is_iomem; +u32 *mem =ttm_kmap_obj_virtual (&nvbo->kmap, &is_iomem); + mem = &mem[index]; +if (is_iomem) +iowrite32_native (val, (void __force __iomem *)mem); +else + *mem = val; +}static struct ttm_backend *nouveau_bo_create_ttm_backend_entry (struct ttm_bo_device *bdev) {
drivers/gpu/drm/nouveau/nouveau_drv.h +2 -0
@@ -926,6 +926,8 @@ extern int nouveau_bo_pin(struct nouveau_bo *, uint32_t flags);extern int nouveau_bo_unpin (struct nouveau_bo *);extern int nouveau_bo_map (struct nouveau_bo *);extern void nouveau_bo_unmap (struct nouveau_bo *); +extern u32 nouveau_bo_rd32 (struct nouveau_bo *nvbo,unsigned index); +extern void nouveau_bo_wr32 (struct nouveau_bo *nvbo,unsigned index,u32 val);/* nouveau_fence.c */ struct nouveau_fence ;
drivers/gpu/drm/nouveau/nv04_crtc.c +2 -5
@@ -1005,7 +1005,6 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,struct nouveau_crtc *nv_crtc =nouveau_crtc (crtc);struct nouveau_bo *cursor =NULL ;struct drm_gem_object *gem; -uint32_t *src, *dst, pixel;int ret =0 , alpha, i;if (width !=64 || height !=64 )
@@ -1024,8 +1023,6 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, ret =nouveau_bo_map (cursor);if (ret) goto out; - src = cursor->kmap.virtual; - dst = nv_crtc->cursor.nvbo->kmap.virtual;/* nv11+ supports premultiplied (PM), or non-premultiplied (NPM) alpha * cursors (though NPM in combination with fp dithering may not work on
@@ -1034,7 +1031,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,* blob uses, however we get given PM cursors so we use PM mode */ for (i =0 ; i <64 *64 ; i++) { - pixel = *src++; +uint32_t pixel =nouveau_bo_rd32 (cursor, i);/* hw gets unhappy if alpha <= rgb values. for a PM image "less * than" shouldn't happen; fix "equal to" case by adding one to
@@ -1054,7 +1051,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, }#endif - *dst++ = pixel; +nouveau_bo_wr32 (nv_crtc->cursor.nvbo, i, pixel); }nouveau_bo_unmap (cursor);
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/6 drm/nv50: proper notifier_bo access in nv50_display_vblank_crtc_handler()
--- drivers/gpu/drm/nouveau/nv50_display.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nv50_display.c +2 -4
@@ -639,14 +639,12 @@ nv50_display_vblank_crtc_handler(struct drm_device *dev, int crtc)struct drm_nouveau_private *dev_priv = dev->dev_private;struct nouveau_channel *chan;struct list_head *entry, *tmp; -uint32_t *sem;list_for_each_safe (entry, tmp, &dev_priv->vbl_waiting) { chan = list_entry(entry, struct nouveau_channel, nvsw.vbl_wait); - sem = chan->notifier_bo->kmap.virtual; - sem[chan->nvsw.vblsem_offset] = chan->nvsw.vblsem_rval; - +nouveau_bo_wr32 (chan->notifier_bo, chan->nvsw.vblsem_offset, + chan->nvsw.vblsem_rval);list_del (&chan->nvsw.vbl_wait); } }
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/6 drm/nouveau: use bo accessors for push buffers
Since push buffers may reside in system memory or VRAM (iomem), they must be accessed via the proper functions instead of just dereferencing a pointer which might be an iomem cookie.
Remove the redundant member nouveau_channel::dma.pushbuf.
--- drivers/gpu/drm/nouveau/nouveau_dma.c | 1 - drivers/gpu/drm/nouveau/nouveau_dma.h | 5 ++--- drivers/gpu/drm/nouveau/nouveau_drv.h | 3 +-- drivers/gpu/drm/nouveau/nv50_display.c | 1 - 4 files changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dma.c +0 -1
@@ -56,7 +56,6 @@ nouveau_dma_init(struct nouveau_channel *chan) ret =nouveau_bo_map (chan->pushbuf_bo);if (ret)return ret; - chan->dma.pushbuf = chan->pushbuf_bo->kmap.virtual;/* Map M2MF notifier object - fbcon. */ if (drm_core_check_feature (dev,DRIVER_MODESET )) {
drivers/gpu/drm/nouveau/nouveau_dma.h +2 -3
@@ -102,7 +102,7 @@ OUT_RING(struct nouveau_channel *chan, int data)NV_INFO (chan->dev,"Ch%d/0x%08x: 0x%08x\n" , chan->id, chan->dma.cur <<2 , data);#endif - chan->dma.pushbuf[chan->dma.cur++] = data; +nouveau_bo_wr32 (chan->pushbuf_bo, chan->dma.cur++, data); } static inline void
@@ -114,9 +114,8 @@ BEGIN_RING(struct nouveau_channel *chan, int subc, int mthd, int size)#define READ_GET () ((nvchan_rd32(chan->user_get) - chan->pushbuf_base) >> 2)#define WRITE_PUT (val) do { \ - volatile uint32_t tmp; \ DRM_MEMORYBARRIER(); \ - tmp = chan->dma.pushbuf[0]; \ + nouveau_bo_rd32(chan->pushbuf_bo, 0); \ nvchan_wr32(chan->user_put, ((val) << 2) + chan->pushbuf_base); \ chan->dma.put = (val); \ } while (0)
drivers/gpu/drm/nouveau/nouveau_drv.h +1 -2
@@ -226,8 +226,7 @@ struct nouveau_channelint free;int cur;int put; - -volatile uint32_t *pushbuf; +/* access via pushbuf_bo */ } dma;uint32_t sw_subchannel[8 ];
drivers/gpu/drm/nouveau/nv50_display.c +0 -1
@@ -328,7 +328,6 @@ nv50_display_init(struct drm_device *dev) evo->dma.put =0 ; evo->dma.cur = evo->dma.put; evo->dma.free = evo->dma.max - evo->dma.cur; - evo->dma.pushbuf = evo->pushbuf_bo->kmap.virtual;RING_SPACE (evo,NOUVEAU_DMA_SKIPS );for (i =0 ; i <NOUVEAU_DMA_SKIPS ; i++)
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 4/6 drm/nouveau: access fbcon notifier via bo accessors
Notifier can live in system memory or VRAM, hence they must be accessed using the bo wrapper functions.
Remove the redundant member nouveau_channel::m2mf_ntfy_map.
--- drivers/gpu/drm/nouveau/nouveau_dma.c | 2 -- drivers/gpu/drm/nouveau/nouveau_drv.h | 1 - drivers/gpu/drm/nouveau/nouveau_fbcon.c | 5 +++-- 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dma.c +0 -2
@@ -62,8 +62,6 @@ nouveau_dma_init(struct nouveau_channel *chan) ret =nouveau_bo_map (chan->notifier_bo);if (ret)return ret; - chan->m2mf_ntfy_map = chan->notifier_bo->kmap.virtual; - chan->m2mf_ntfy_map += chan->m2mf_ntfy; }/* Initialise DMA vars */
drivers/gpu/drm/nouveau/nouveau_drv.h +0 -1
@@ -215,7 +215,6 @@ struct nouveau_channel/* GPU object info for stuff used in-kernel (mm_enabled) */ uint32_t m2mf_ntfy; -volatile uint32_t *m2mf_ntfy_map;uint32_t vram_handle;uint32_t gart_handle;bool accel_done;
drivers/gpu/drm/nouveau/nouveau_fbcon.c +3 -2
@@ -73,12 +73,13 @@ nouveau_fbcon_sync(struct fb_info *info)OUT_RING (chan,0 );BEGIN_RING (chan,0 ,0x0100 ,1 );OUT_RING (chan,0 ); - chan->m2mf_ntfy_map[3 ] =0xffffffff ; +nouveau_bo_wr32 (chan->notifier_bo, chan->m2mf_ntfy +3 ,0xffffffff );FIRE_RING (chan); ret = -EBUSY ;for (i =0 ; i <100000 ; i++) { -if (chan->m2mf_ntfy_map[3 ] ==0 ) { +if (nouveau_bo_rd32 (chan->notifier_bo, chan->m2mf_ntfy +3 ) + ==0 ) { ret =0 ;break ; }
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 5/6 drm/nouveau: screen_base and lut must be iomem
This introduces nvbo_kmap_obj_iovirtual() for cases where the bo memory is guaranteed (or supposed) to be iomem.
Fbcon assumes screen_base is iomem, and the crtc color LUT must reside in iomem.
--- drivers/gpu/drm/nouveau/nouveau_drv.h | 11 +++++++++++ drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nv50_crtc.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +11 -0
@@ -101,6 +101,17 @@ nouveau_gem_object(struct drm_gem_object *gem)return gem ? gem->driver_private :NULL ; } +/* TODO: submit equivalent to TTM generic API upstream? */ +static inline void __iomem * +nvbo_kmap_obj_iovirtual (struct nouveau_bo *nvbo) +{ +bool is_iomem; +void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual ( + &nvbo->kmap, &is_iomem); +WARN_ON_ONCE (ioptr && !is_iomem); +return ioptr; +} +struct mem_block {struct mem_block *next;struct mem_block *prev;
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -582,7 +582,7 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width, info->flags =FBINFO_DEFAULT |FBINFO_HWACCEL_COPYAREA |FBINFO_HWACCEL_FILLRECT |FBINFO_HWACCEL_IMAGEBLIT ; - info->screen_base = nouveau_fb->nvbo->kmap.virtual; + info->screen_base =nvbo_kmap_obj_iovirtual (nouveau_fb->nvbo); info->screen_size = size; info->pseudo_palette = fb->pseudo_palette;
drivers/gpu/drm/nouveau/nv50_crtc.c +1 -1
@@ -43,7 +43,7 @@ nv50_crtc_lut_load(struct nouveau_crtc *crtc) {struct drm_device *dev = crtc->base.dev;uint32_t index =0 , i; -void __iomem *lut = crtc->lut.nvbo->kmap.virtual; +void __iomem *lut =nvbo_kmap_obj_iovirtual (crtc->lut.nvbo);NV_DEBUG (dev,"\n" );
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 6/6 drm/nouveau: remove redundant check in nouveau_bo_del_ttm()
ttm_bo_kunmap() already checks if the bo is not mapped.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -2
@@ -39,8 +39,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)struct drm_nouveau_private *dev_priv =nouveau_bdev (bo->bdev);struct nouveau_bo *nvbo =nouveau_bo (bo); -if (unlikely (nvbo->kmap.virtual)) -ttm_bo_kunmap (&nvbo->kmap); +ttm_bo_kunmap (&nvbo->kmap);if (unlikely (nvbo->gem))DRM_ERROR ("bo %p still attached to GEM object\n" , bo);
Signature · 1 line
1.6.3.3
PATCH 1/1 drm/nouveau: OUT_RINGp - optimize OUT_RING loops
In reply to a message not in the archiveThe introduction of nouveau_bo_wr32() in commit "drm/nouveau: use bo accessors for push buffers" to OUT_RING() made it considerably slower.
'x11perf -aa10text' benchmark hits the OUT_RING hard, since user pushbuffers are first copied from user to kernel, and then from kernel to the real pushbuffer bo using OUT_RING. The speed
- before nouveau_bo_wr32(): 677k/sec
- after: 475k/sec
This patch implements OUT_RINGp() for copying an arbitrary number of dwords from an array to the pushbuffer bo. All OUT_RING copy loops are replaced with calls to OUT_RINGp(). This brings aa10text speed to 785k/sec.
The tests have been run on nv28, Athlon64 3000+ (x86_64) and oprofile running.
--- drivers/gpu/drm/nouveau/nouveau_dma.c | 13 +++++++++++++ drivers/gpu/drm/nouveau/nouveau_dma.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_gem.c | 3 +-- drivers/gpu/drm/nouveau/nv04_fbcon.c | 14 ++++++++------ drivers/gpu/drm/nouveau/nv50_fbcon.c | 4 ++-- 5 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dma.c +13 -0
@@ -90,6 +90,19 @@ nouveau_dma_init(struct nouveau_channel *chan)return 0 ; } +void +OUT_RINGp (struct nouveau_channel *chan,const void *data,unsigned nr_dwords) +{ +bool is_iomem; +u32 *mem =ttm_kmap_obj_virtual (&chan->pushbuf_bo->kmap, &is_iomem); + mem = &mem[chan->dma.cur]; +if (is_iomem) +memcpy_toio ((void __force __iomem *)mem, data, nr_dwords *4 ); +else +memcpy (mem, data, nr_dwords *4 ); + chan->dma.cur += nr_dwords; +} +static inline bool READ_GET (struct nouveau_channel *chan,uint32_t *get) {
drivers/gpu/drm/nouveau/nouveau_dma.h +3 -0
@@ -109,6 +109,9 @@ OUT_RING(struct nouveau_channel *chan, int data)nouveau_bo_wr32 (chan->pushbuf_bo, chan->dma.cur++, data); } +extern void +OUT_RINGp (struct nouveau_channel *chan,const void *data,unsigned nr_dwords); +static inline void BEGIN_RING (struct nouveau_channel *chan,int subc,int mthd,int size) {
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -2
@@ -528,8 +528,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,if (ret) goto out; -for (i =0 ; i < req->nr_dwords; i++) -OUT_RING (chan, pushbuf[i]); +OUT_RINGp (chan, pushbuf, req->nr_dwords); ret =nouveau_fence_emit (fence);if (ret) {
drivers/gpu/drm/nouveau/nv04_fbcon.c +8 -6
@@ -94,9 +94,12 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)struct drm_device *dev = par->dev;struct drm_nouveau_private *dev_priv = dev->dev_private;struct nouveau_channel *chan = dev_priv->channel; -uint32_t fg, bg, mask = ~(~0 >> (32 - info->var.bits_per_pixel)); -uint32_t dsize, width, *data = (uint32_t *) image->data; -int j, k =0 ; +uint32_t fg; +uint32_t bg; +uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel)); +uint32_t dsize; +uint32_t width; +uint32_t *data = (uint32_t *)image->data;if (info->state !=FBINFO_STATE_RUNNING )return ;
@@ -140,9 +143,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) }BEGIN_RING (chan, NvSubGdiRect,0x0c00 , iter_len); -for (j = iter_len; j--;) -OUT_RING (chan, data[k++]); - +OUT_RINGp (chan, data, iter_len); + data += iter_len; dsize -= iter_len; }
drivers/gpu/drm/nouveau/nv50_fbcon.c +2 -2
@@ -139,8 +139,8 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) dwords -= push;BEGIN_RING (chan, NvSub2D,0x40000860 , push); -while (push--) -OUT_RING (chan, *data++); +OUT_RINGp (chan, data, push); + data += push; }FIRE_RING (chan);
Signature · 1 line
1.6.3.3