Commit f76c83b5 authored by Daniel Kurtz's avatar Daniel Kurtz Committed by Mark Yao

drm/rockchip: Only alloc a kmap for fbdev gem object

In general, the data in drm/rockchip GEM objects is never accessed by
the kernel.  The objects are either accessed by a GPU, by display
controller DMA, or by mmap'ing them to user space.  Thus, these
buffers need not be mapped into kernel address space.

The only exception is the fbdev framebuffer(s), which may be written
in-kernel by fbcon.
Signed-off-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
Signed-off-by: default avatarMark Yao <mark.yao@rock-chips.com>
parent 03be7005
...@@ -71,7 +71,7 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -71,7 +71,7 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
size = mode_cmd.pitches[0] * mode_cmd.height; size = mode_cmd.pitches[0] * mode_cmd.height;
rk_obj = rockchip_gem_create_object(dev, size); rk_obj = rockchip_gem_create_object(dev, size, true);
if (IS_ERR(rk_obj)) if (IS_ERR(rk_obj))
return -ENOMEM; return -ENOMEM;
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
#include "rockchip_drm_drv.h" #include "rockchip_drm_drv.h"
#include "rockchip_drm_gem.h" #include "rockchip_drm_gem.h"
static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj) static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj,
bool alloc_kmap)
{ {
struct drm_gem_object *obj = &rk_obj->base; struct drm_gem_object *obj = &rk_obj->base;
struct drm_device *drm = obj->dev; struct drm_device *drm = obj->dev;
...@@ -30,7 +31,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj) ...@@ -30,7 +31,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj)
init_dma_attrs(&rk_obj->dma_attrs); init_dma_attrs(&rk_obj->dma_attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &rk_obj->dma_attrs); dma_set_attr(DMA_ATTR_WRITE_COMBINE, &rk_obj->dma_attrs);
/* TODO(djkurtz): Use DMA_ATTR_NO_KERNEL_MAPPING except for fbdev */ if (!alloc_kmap)
dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &rk_obj->dma_attrs);
rk_obj->kvaddr = dma_alloc_attrs(drm->dev, obj->size, rk_obj->kvaddr = dma_alloc_attrs(drm->dev, obj->size,
&rk_obj->dma_addr, GFP_KERNEL, &rk_obj->dma_addr, GFP_KERNEL,
&rk_obj->dma_attrs); &rk_obj->dma_attrs);
...@@ -103,7 +106,8 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -103,7 +106,8 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
} }
struct rockchip_gem_object * struct rockchip_gem_object *
rockchip_gem_create_object(struct drm_device *drm, unsigned int size) rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
bool alloc_kmap)
{ {
struct rockchip_gem_object *rk_obj; struct rockchip_gem_object *rk_obj;
struct drm_gem_object *obj; struct drm_gem_object *obj;
...@@ -119,7 +123,7 @@ struct rockchip_gem_object * ...@@ -119,7 +123,7 @@ struct rockchip_gem_object *
drm_gem_private_object_init(drm, obj, size); drm_gem_private_object_init(drm, obj, size);
ret = rockchip_gem_alloc_buf(rk_obj); ret = rockchip_gem_alloc_buf(rk_obj, alloc_kmap);
if (ret) if (ret)
goto err_free_rk_obj; goto err_free_rk_obj;
...@@ -163,7 +167,7 @@ rockchip_gem_create_with_handle(struct drm_file *file_priv, ...@@ -163,7 +167,7 @@ rockchip_gem_create_with_handle(struct drm_file *file_priv,
struct drm_gem_object *obj; struct drm_gem_object *obj;
int ret; int ret;
rk_obj = rockchip_gem_create_object(drm, size); rk_obj = rockchip_gem_create_object(drm, size, false);
if (IS_ERR(rk_obj)) if (IS_ERR(rk_obj))
return ERR_CAST(rk_obj); return ERR_CAST(rk_obj);
...@@ -282,6 +286,9 @@ void *rockchip_gem_prime_vmap(struct drm_gem_object *obj) ...@@ -282,6 +286,9 @@ void *rockchip_gem_prime_vmap(struct drm_gem_object *obj)
{ {
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, &rk_obj->dma_attrs))
return NULL;
return rk_obj->kvaddr; return rk_obj->kvaddr;
} }
......
...@@ -41,7 +41,8 @@ int rockchip_gem_mmap_buf(struct drm_gem_object *obj, ...@@ -41,7 +41,8 @@ int rockchip_gem_mmap_buf(struct drm_gem_object *obj,
struct vm_area_struct *vma); struct vm_area_struct *vma);
struct rockchip_gem_object * struct rockchip_gem_object *
rockchip_gem_create_object(struct drm_device *drm, unsigned int size); rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
bool alloc_kmap);
void rockchip_gem_free_object(struct drm_gem_object *obj); void rockchip_gem_free_object(struct drm_gem_object *obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment