vmwgfx: minor dmabuf utilities cleanup

Add / fix some function comments.
Don't move out an fbdev framebuffer when unused. Just unpin.
Only have a single function that computes a SVGAGuestPtr from the buffer's
current placement, and make it more versatile by accepting a
struct ttm_buffer_object

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Thomas Hellstrom 2011-10-04 20:13:28 +02:00 коммит произвёл Dave Airlie
Родитель 0cff60c625
Коммит b37a6b9ad0
5 изменённых файлов: 45 добавлений и 65 удалений

Просмотреть файл

@ -32,10 +32,16 @@
/** /**
* Validate a buffer to placement. * vmw_dmabuf_to_placement - Validate a buffer to placement.
* *
* May only be called by the current master as this function takes the * @dev_priv: Driver private.
* its lock in write mode. * @buf: DMA buffer to move.
* @pin: Pin buffer if true.
* @interruptible: Use interruptible wait.
*
* May only be called by the current master since it assumes that the
* master lock is the current master's lock.
* This function takes the master's lock in write mode.
* *
* Returns * Returns
* -ERESTARTSYS if interrupted by a signal. * -ERESTARTSYS if interrupted by a signal.
@ -67,10 +73,11 @@ err:
} }
/** /**
* Move a buffer to vram or gmr. * vmw_dmabuf_to_vram_or_gmr - Move a buffer to vram or gmr.
* *
* May only be called by the current master as this function takes the * May only be called by the current master since it assumes that the
* its lock in write mode. * master lock is the current master's lock.
* This function takes the master's lock in write mode.
* *
* @dev_priv: Driver private. * @dev_priv: Driver private.
* @buf: DMA buffer to move. * @buf: DMA buffer to move.
@ -134,10 +141,11 @@ err:
} }
/** /**
* Move a buffer to vram. * vmw_dmabuf_to_vram - Move a buffer to vram.
* *
* May only be called by the current master as this function takes the * May only be called by the current master since it assumes that the
* its lock in write mode. * master lock is the current master's lock.
* This function takes the master's lock in write mode.
* *
* @dev_priv: Driver private. * @dev_priv: Driver private.
* @buf: DMA buffer to move. * @buf: DMA buffer to move.
@ -164,10 +172,11 @@ int vmw_dmabuf_to_vram(struct vmw_private *dev_priv,
} }
/** /**
* Move a buffer to start of vram. * vmw_dmabuf_to_start_of_vram - Move a buffer to start of vram.
* *
* May only be called by the current master as this function takes the * May only be called by the current master since it assumes that the
* its lock in write mode. * master lock is the current master's lock.
* This function takes the master's lock in write mode.
* *
* @dev_priv: Driver private. * @dev_priv: Driver private.
* @buf: DMA buffer to move. * @buf: DMA buffer to move.
@ -219,11 +228,13 @@ err_unlock:
return ret; return ret;
} }
/** /**
* Unpin the buffer given buffer, does not move the buffer. * vmw_dmabuf_upin - Unpin the buffer given buffer, does not move the buffer.
* *
* May only be called by the current master as this function takes the * May only be called by the current master since it assumes that the
* its lock in write mode. * master lock is the current master's lock.
* This function takes the master's lock in write mode.
* *
* @dev_priv: Driver private. * @dev_priv: Driver private.
* @buf: DMA buffer to unpin. * @buf: DMA buffer to unpin.
@ -246,47 +257,22 @@ int vmw_dmabuf_unpin(struct vmw_private *dev_priv,
interruptible); interruptible);
} }
/** /**
* Move a buffer to system memory, does not pin the buffer. * vmw_bo_get_guest_ptr - Get the guest ptr representing the current placement
* of a buffer.
* *
* May only be called by the current master as this function takes the * @bo: Pointer to a struct ttm_buffer_object. Must be pinned or reserved.
* its lock in write mode. * @ptr: SVGAGuestPtr returning the result.
*
* @dev_priv: Driver private.
* @buf: DMA buffer to move.
* @interruptible: Use interruptible wait.
*
* Returns
* -ERESTARTSYS if interrupted by a signal.
*/ */
int vmw_dmabuf_to_system(struct vmw_private *dev_priv, void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,
struct vmw_dma_buffer *buf, SVGAGuestPtr *ptr)
bool interruptible)
{ {
return vmw_dmabuf_to_placement(dev_priv, buf, if (bo->mem.mem_type == TTM_PL_VRAM) {
&vmw_sys_placement,
interruptible);
}
void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf,
uint32_t *gmrId, uint32_t *offset)
{
if (buf->base.mem.mem_type == TTM_PL_VRAM) {
*gmrId = SVGA_GMR_FRAMEBUFFER;
*offset = buf->base.offset;
} else {
*gmrId = buf->base.mem.start;
*offset = 0;
}
}
void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf, SVGAGuestPtr *ptr)
{
if (buf->base.mem.mem_type == TTM_PL_VRAM) {
ptr->gmrId = SVGA_GMR_FRAMEBUFFER; ptr->gmrId = SVGA_GMR_FRAMEBUFFER;
ptr->offset = buf->base.offset; ptr->offset = bo->offset;
} else { } else {
ptr->gmrId = buf->base.mem.start; ptr->gmrId = bo->mem.start;
ptr->offset = 0; ptr->offset = 0;
} }
} }

Просмотреть файл

@ -416,13 +416,8 @@ extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv,
struct vmw_dma_buffer *bo, struct vmw_dma_buffer *bo,
bool interruptible); bool interruptible);
extern int vmw_dmabuf_to_system(struct vmw_private *vmw_priv, extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf,
struct vmw_dma_buffer *bo, SVGAGuestPtr *ptr);
bool interruptible);
extern void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf,
uint32_t *gmrId, uint32_t *offset);
extern void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf,
SVGAGuestPtr *ptr);
/** /**
* Misc Ioctl functionality - vmwgfx_ioctl.c * Misc Ioctl functionality - vmwgfx_ioctl.c

Просмотреть файл

@ -613,8 +613,7 @@ int vmw_fb_off(struct vmw_private *vmw_priv)
par->bo_ptr = NULL; par->bo_ptr = NULL;
ttm_bo_kunmap(&par->map); ttm_bo_kunmap(&par->map);
/* move this to system instead of just unpinning it */ vmw_dmabuf_unpin(vmw_priv, par->vmw_bo, false);
vmw_dmabuf_to_system(vmw_priv, par->vmw_bo, false);
return 0; return 0;
} }

Просмотреть файл

@ -99,9 +99,9 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
{ {
struct vmw_escape_video_flush *flush; struct vmw_escape_video_flush *flush;
size_t fifo_size; size_t fifo_size;
uint32_t gmrId, offset;
bool have_so = dev_priv->sou_priv ? true : false; bool have_so = dev_priv->sou_priv ? true : false;
int i, num_items; int i, num_items;
SVGAGuestPtr ptr;
struct { struct {
struct vmw_escape_header escape; struct vmw_escape_header escape;
@ -141,12 +141,12 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
items[i].registerId = i; items[i].registerId = i;
vmw_dmabuf_get_id_offset(buf, &gmrId, &offset); vmw_bo_get_guest_ptr(&buf->base, &ptr);
offset += arg->offset; ptr.offset += arg->offset;
items[SVGA_VIDEO_ENABLED].value = true; items[SVGA_VIDEO_ENABLED].value = true;
items[SVGA_VIDEO_FLAGS].value = arg->flags; items[SVGA_VIDEO_FLAGS].value = arg->flags;
items[SVGA_VIDEO_DATA_OFFSET].value = offset; items[SVGA_VIDEO_DATA_OFFSET].value = ptr.offset;
items[SVGA_VIDEO_FORMAT].value = arg->format; items[SVGA_VIDEO_FORMAT].value = arg->format;
items[SVGA_VIDEO_COLORKEY].value = arg->color_key; items[SVGA_VIDEO_COLORKEY].value = arg->color_key;
items[SVGA_VIDEO_SIZE].value = arg->size; items[SVGA_VIDEO_SIZE].value = arg->size;
@ -164,7 +164,7 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
items[SVGA_VIDEO_PITCH_2].value = arg->pitch[1]; items[SVGA_VIDEO_PITCH_2].value = arg->pitch[1];
items[SVGA_VIDEO_PITCH_3].value = arg->pitch[2]; items[SVGA_VIDEO_PITCH_3].value = arg->pitch[2];
if (have_so) { if (have_so) {
items[SVGA_VIDEO_DATA_GMRID].value = gmrId; items[SVGA_VIDEO_DATA_GMRID].value = ptr.gmrId;
items[SVGA_VIDEO_DST_SCREEN_ID].value = SVGA_ID_INVALID; items[SVGA_VIDEO_DST_SCREEN_ID].value = SVGA_ID_INVALID;
} }

Просмотреть файл

@ -168,7 +168,7 @@ static int vmw_sou_fifo_create(struct vmw_private *dev_priv,
cmd->obj.root.y = y; cmd->obj.root.y = y;
/* Ok to assume that buffer is pinned in vram */ /* Ok to assume that buffer is pinned in vram */
vmw_dmabuf_get_guest_ptr(sou->buffer, &cmd->obj.backingStore.ptr); vmw_bo_get_guest_ptr(&sou->buffer->base, &cmd->obj.backingStore.ptr);
cmd->obj.backingStore.pitch = mode->hdisplay * 4; cmd->obj.backingStore.pitch = mode->hdisplay * 4;
vmw_fifo_commit(dev_priv, fifo_size); vmw_fifo_commit(dev_priv, fifo_size);