diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2011-10-04 14:13:28 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-10-05 05:17:20 -0400 |
commit | b37a6b9ad002a6c123a6924668dfef5c5fb0b700 (patch) | |
tree | ab1df2dec40546ec69fff9b6837cf5711cc7fb34 /drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c | |
parent | 0cff60c625131c64847debc2b4cee33ba33e8d8f (diff) |
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>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c | 86 |
1 files changed, 36 insertions, 50 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c index 5668ad980cb5..7f744a82892a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c | |||
@@ -32,10 +32,16 @@ | |||
32 | 32 | ||
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Validate a buffer to placement. | 35 | * vmw_dmabuf_to_placement - Validate a buffer to placement. |
36 | * | 36 | * |
37 | * May only be called by the current master as this function takes the | 37 | * @dev_priv: Driver private. |
38 | * its lock in write mode. | 38 | * @buf: DMA buffer to move. |
39 | * @pin: Pin buffer if true. | ||
40 | * @interruptible: Use interruptible wait. | ||
41 | * | ||
42 | * May only be called by the current master since it assumes that the | ||
43 | * master lock is the current master's lock. | ||
44 | * This function takes the master's lock in write mode. | ||
39 | * | 45 | * |
40 | * Returns | 46 | * Returns |
41 | * -ERESTARTSYS if interrupted by a signal. | 47 | * -ERESTARTSYS if interrupted by a signal. |
@@ -67,10 +73,11 @@ err: | |||
67 | } | 73 | } |
68 | 74 | ||
69 | /** | 75 | /** |
70 | * Move a buffer to vram or gmr. | 76 | * vmw_dmabuf_to_vram_or_gmr - Move a buffer to vram or gmr. |
71 | * | 77 | * |
72 | * May only be called by the current master as this function takes the | 78 | * May only be called by the current master since it assumes that the |
73 | * its lock in write mode. | 79 | * master lock is the current master's lock. |
80 | * This function takes the master's lock in write mode. | ||
74 | * | 81 | * |
75 | * @dev_priv: Driver private. | 82 | * @dev_priv: Driver private. |
76 | * @buf: DMA buffer to move. | 83 | * @buf: DMA buffer to move. |
@@ -134,10 +141,11 @@ err: | |||
134 | } | 141 | } |
135 | 142 | ||
136 | /** | 143 | /** |
137 | * Move a buffer to vram. | 144 | * vmw_dmabuf_to_vram - Move a buffer to vram. |
138 | * | 145 | * |
139 | * May only be called by the current master as this function takes the | 146 | * May only be called by the current master since it assumes that the |
140 | * its lock in write mode. | 147 | * master lock is the current master's lock. |
148 | * This function takes the master's lock in write mode. | ||
141 | * | 149 | * |
142 | * @dev_priv: Driver private. | 150 | * @dev_priv: Driver private. |
143 | * @buf: DMA buffer to move. | 151 | * @buf: DMA buffer to move. |
@@ -164,10 +172,11 @@ int vmw_dmabuf_to_vram(struct vmw_private *dev_priv, | |||
164 | } | 172 | } |
165 | 173 | ||
166 | /** | 174 | /** |
167 | * Move a buffer to start of vram. | 175 | * vmw_dmabuf_to_start_of_vram - Move a buffer to start of vram. |
168 | * | 176 | * |
169 | * May only be called by the current master as this function takes the | 177 | * May only be called by the current master since it assumes that the |
170 | * its lock in write mode. | 178 | * master lock is the current master's lock. |
179 | * This function takes the master's lock in write mode. | ||
171 | * | 180 | * |
172 | * @dev_priv: Driver private. | 181 | * @dev_priv: Driver private. |
173 | * @buf: DMA buffer to move. | 182 | * @buf: DMA buffer to move. |
@@ -219,11 +228,13 @@ err_unlock: | |||
219 | return ret; | 228 | return ret; |
220 | } | 229 | } |
221 | 230 | ||
231 | |||
222 | /** | 232 | /** |
223 | * Unpin the buffer given buffer, does not move the buffer. | 233 | * vmw_dmabuf_upin - Unpin the buffer given buffer, does not move the buffer. |
224 | * | 234 | * |
225 | * May only be called by the current master as this function takes the | 235 | * May only be called by the current master since it assumes that the |
226 | * its lock in write mode. | 236 | * master lock is the current master's lock. |
237 | * This function takes the master's lock in write mode. | ||
227 | * | 238 | * |
228 | * @dev_priv: Driver private. | 239 | * @dev_priv: Driver private. |
229 | * @buf: DMA buffer to unpin. | 240 | * @buf: DMA buffer to unpin. |
@@ -246,47 +257,22 @@ int vmw_dmabuf_unpin(struct vmw_private *dev_priv, | |||
246 | interruptible); | 257 | interruptible); |
247 | } | 258 | } |
248 | 259 | ||
260 | |||
249 | /** | 261 | /** |
250 | * Move a buffer to system memory, does not pin the buffer. | 262 | * vmw_bo_get_guest_ptr - Get the guest ptr representing the current placement |
251 | * | 263 | * of a buffer. |
252 | * May only be called by the current master as this function takes the | ||
253 | * its lock in write mode. | ||
254 | * | ||
255 | * @dev_priv: Driver private. | ||
256 | * @buf: DMA buffer to move. | ||
257 | * @interruptible: Use interruptible wait. | ||
258 | * | 264 | * |
259 | * Returns | 265 | * @bo: Pointer to a struct ttm_buffer_object. Must be pinned or reserved. |
260 | * -ERESTARTSYS if interrupted by a signal. | 266 | * @ptr: SVGAGuestPtr returning the result. |
261 | */ | 267 | */ |
262 | int vmw_dmabuf_to_system(struct vmw_private *dev_priv, | 268 | void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo, |
263 | struct vmw_dma_buffer *buf, | 269 | SVGAGuestPtr *ptr) |
264 | bool interruptible) | ||
265 | { | ||
266 | return vmw_dmabuf_to_placement(dev_priv, buf, | ||
267 | &vmw_sys_placement, | ||
268 | interruptible); | ||
269 | } | ||
270 | |||
271 | void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf, | ||
272 | uint32_t *gmrId, uint32_t *offset) | ||
273 | { | ||
274 | if (buf->base.mem.mem_type == TTM_PL_VRAM) { | ||
275 | *gmrId = SVGA_GMR_FRAMEBUFFER; | ||
276 | *offset = buf->base.offset; | ||
277 | } else { | ||
278 | *gmrId = buf->base.mem.start; | ||
279 | *offset = 0; | ||
280 | } | ||
281 | } | ||
282 | |||
283 | void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf, SVGAGuestPtr *ptr) | ||
284 | { | 270 | { |
285 | if (buf->base.mem.mem_type == TTM_PL_VRAM) { | 271 | if (bo->mem.mem_type == TTM_PL_VRAM) { |
286 | ptr->gmrId = SVGA_GMR_FRAMEBUFFER; | 272 | ptr->gmrId = SVGA_GMR_FRAMEBUFFER; |
287 | ptr->offset = buf->base.offset; | 273 | ptr->offset = bo->offset; |
288 | } else { | 274 | } else { |
289 | ptr->gmrId = buf->base.mem.start; | 275 | ptr->gmrId = bo->mem.start; |
290 | ptr->offset = 0; | 276 | ptr->offset = 0; |
291 | } | 277 | } |
292 | } | 278 | } |