aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_client.c')
-rw-r--r--drivers/gpu/drm/drm_client.c60
1 files changed, 49 insertions, 11 deletions
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 410572f14257..e1dafb0cc5e2 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -254,7 +254,6 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u
254 struct drm_device *dev = client->dev; 254 struct drm_device *dev = client->dev;
255 struct drm_client_buffer *buffer; 255 struct drm_client_buffer *buffer;
256 struct drm_gem_object *obj; 256 struct drm_gem_object *obj;
257 void *vaddr;
258 int ret; 257 int ret;
259 258
260 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 259 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
@@ -281,6 +280,36 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u
281 280
282 buffer->gem = obj; 281 buffer->gem = obj;
283 282
283 return buffer;
284
285err_delete:
286 drm_client_buffer_delete(buffer);
287
288 return ERR_PTR(ret);
289}
290
291/**
292 * drm_client_buffer_vmap - Map DRM client buffer into address space
293 * @buffer: DRM client buffer
294 *
295 * This function maps a client buffer into kernel address space. If the
296 * buffer is already mapped, it returns the mapping's address.
297 *
298 * Client buffer mappings are not ref'counted. Each call to
299 * drm_client_buffer_vmap() should be followed by a call to
300 * drm_client_buffer_vunmap(); or the client buffer should be mapped
301 * throughout its lifetime.
302 *
303 * Returns:
304 * The mapped memory's address
305 */
306void *drm_client_buffer_vmap(struct drm_client_buffer *buffer)
307{
308 void *vaddr;
309
310 if (buffer->vaddr)
311 return buffer->vaddr;
312
284 /* 313 /*
285 * FIXME: The dependency on GEM here isn't required, we could 314 * FIXME: The dependency on GEM here isn't required, we could
286 * convert the driver handle to a dma-buf instead and use the 315 * convert the driver handle to a dma-buf instead and use the
@@ -289,21 +318,30 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u
289 * fd_install step out of the driver backend hooks, to make that 318 * fd_install step out of the driver backend hooks, to make that
290 * final step optional for internal users. 319 * final step optional for internal users.
291 */ 320 */
292 vaddr = drm_gem_vmap(obj); 321 vaddr = drm_gem_vmap(buffer->gem);
293 if (IS_ERR(vaddr)) { 322 if (IS_ERR(vaddr))
294 ret = PTR_ERR(vaddr); 323 return vaddr;
295 goto err_delete;
296 }
297 324
298 buffer->vaddr = vaddr; 325 buffer->vaddr = vaddr;
299 326
300 return buffer; 327 return vaddr;
301 328}
302err_delete: 329EXPORT_SYMBOL(drm_client_buffer_vmap);
303 drm_client_buffer_delete(buffer);
304 330
305 return ERR_PTR(ret); 331/**
332 * drm_client_buffer_vunmap - Unmap DRM client buffer
333 * @buffer: DRM client buffer
334 *
335 * This function removes a client buffer's memory mapping. Calling this
336 * function is only required by clients that manage their buffer mappings
337 * by themselves.
338 */
339void drm_client_buffer_vunmap(struct drm_client_buffer *buffer)
340{
341 drm_gem_vunmap(buffer->gem, buffer->vaddr);
342 buffer->vaddr = NULL;
306} 343}
344EXPORT_SYMBOL(drm_client_buffer_vunmap);
307 345
308static void drm_client_buffer_rmfb(struct drm_client_buffer *buffer) 346static void drm_client_buffer_rmfb(struct drm_client_buffer *buffer)
309{ 347{