diff options
Diffstat (limited to 'drivers/gpu/drm/drm_client.c')
| -rw-r--r-- | drivers/gpu/drm/drm_client.c | 38 | 
1 files changed, 24 insertions, 14 deletions
| diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c index 495f47d23d87..fe573acf1067 100644 --- a/drivers/gpu/drm/drm_client.c +++ b/drivers/gpu/drm/drm_client.c @@ -3,6 +3,7 @@   * Copyright 2018 Noralf Trønnes   */ +#include <linux/dma-buf-map.h>  #include <linux/list.h>  #include <linux/module.h>  #include <linux/mutex.h> @@ -234,7 +235,7 @@ static void drm_client_buffer_delete(struct drm_client_buffer *buffer)  {  	struct drm_device *dev = buffer->client->dev; -	drm_gem_vunmap(buffer->gem, buffer->vaddr); +	drm_gem_vunmap(buffer->gem, &buffer->map);  	if (buffer->gem)  		drm_gem_object_put(buffer->gem); @@ -290,24 +291,31 @@ err_delete:  /**   * drm_client_buffer_vmap - Map DRM client buffer into address space   * @buffer: DRM client buffer + * @map_copy: Returns the mapped memory's address   *   * This function maps a client buffer into kernel address space. If the - * buffer is already mapped, it returns the mapping's address. + * buffer is already mapped, it returns the existing mapping's address.   *   * Client buffer mappings are not ref'counted. Each call to   * drm_client_buffer_vmap() should be followed by a call to   * drm_client_buffer_vunmap(); or the client buffer should be mapped   * throughout its lifetime.   * + * The returned address is a copy of the internal value. In contrast to + * other vmap interfaces, you don't need it for the client's vunmap + * function. So you can modify it at will during blit and draw operations. + *   * Returns: - *	The mapped memory's address + *	0 on success, or a negative errno code otherwise.   */ -void *drm_client_buffer_vmap(struct drm_client_buffer *buffer) +int +drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map_copy)  { -	void *vaddr; +	struct dma_buf_map *map = &buffer->map; +	int ret; -	if (buffer->vaddr) -		return buffer->vaddr; +	if (dma_buf_map_is_set(map)) +		goto out;  	/*  	 * FIXME: The dependency on GEM here isn't required, we could @@ -317,13 +325,14 @@ void *drm_client_buffer_vmap(struct drm_client_buffer *buffer)  	 * fd_install step out of the driver backend hooks, to make that  	 * final step optional for internal users.  	 */ -	vaddr = drm_gem_vmap(buffer->gem); -	if (IS_ERR(vaddr)) -		return vaddr; +	ret = drm_gem_vmap(buffer->gem, map); +	if (ret) +		return ret; -	buffer->vaddr = vaddr; +out: +	*map_copy = *map; -	return vaddr; +	return 0;  }  EXPORT_SYMBOL(drm_client_buffer_vmap); @@ -337,8 +346,9 @@ EXPORT_SYMBOL(drm_client_buffer_vmap);   */  void drm_client_buffer_vunmap(struct drm_client_buffer *buffer)  { -	drm_gem_vunmap(buffer->gem, buffer->vaddr); -	buffer->vaddr = NULL; +	struct dma_buf_map *map = &buffer->map; + +	drm_gem_vunmap(buffer->gem, map);  }  EXPORT_SYMBOL(drm_client_buffer_vunmap); | 
